Commit bb57cb80 authored by Marc Chevrier's avatar Marc Chevrier

UseSWIG: multiple input files must be supported in version 2

Fixes: #18506
parent c780f5ee
......@@ -234,6 +234,8 @@ set(SWIG_PYTHON_EXTRA_FILE_EXTENSIONS ".py")
set(SWIG_JAVA_EXTRA_FILE_EXTENSIONS ".java" "JNI.java")
set(SWIG_CSHARP_EXTRA_FILE_EXTENSIONS ".cs" "PINVOKE.cs")
set(SWIG_MANAGE_SUPPORT_FILES_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/UseSWIG/ManageSupportFiles.cmake")
##
## PRIVATE functions
##
......@@ -444,9 +446,13 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
if (UseSWIG_MODULE_VERSION VERSION_GREATER 1)
# as part of custom command, start by removing old generated files
# to ensure obsolete files do not stay
set (swig_cleanup_command COMMAND "${CMAKE_COMMAND}" -E remove_directory "${outdir}")
set (swig_file_outdir "${workingdir}/${swig_source_file_name_we}.files")
set (swig_cleanup_command COMMAND "${CMAKE_COMMAND}" "-DSUPPORT_FILES_WORKING_DIRECTORY=${swig_file_outdir}" "-DSUPPORT_FILES_OUTPUT_DIRECTORY=${outdir}" -DACTION=CLEAN -P "${SWIG_MANAGE_SUPPORT_FILES_SCRIPT}")
set (swig_copy_command COMMAND "${CMAKE_COMMAND}" "-DSUPPORT_FILES_WORKING_DIRECTORY=${swig_file_outdir}" "-DSUPPORT_FILES_OUTPUT_DIRECTORY=${outdir}" -DACTION=COPY -P "${SWIG_MANAGE_SUPPORT_FILES_SCRIPT}")
else()
set (swig_file_outdir "${outdir}")
unset (swig_cleanup_command)
unset (swig_copy_command)
endif()
# IMPLICIT_DEPENDS below can not handle situations where a dependent file is
......@@ -476,12 +482,13 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
COMMAND "${CMAKE_COMMAND}" -E env "SWIG_LIB=${SWIG_DIR}" "${SWIG_EXECUTABLE}"
"-${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}"
"${swig_source_file_flags}"
-outdir "${outdir}"
-outdir "${swig_file_outdir}"
${swig_special_flags}
${swig_extra_flags}
"${swig_include_dirs}"
-o "${swig_generated_file_fullname}"
"${swig_source_file_fullname}"
${swig_copy_command}
MAIN_DEPENDENCY "${swig_source_file_fullname}"
DEPENDS ${swig_dependencies}
IMPLICIT_DEPENDS CXX "${swig_source_file_fullname}"
......
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
if (ACTION STREQUAL "CLEAN")
# Collect current list of generated files
file (GLOB files LIST_DIRECTORIES FALSE RELATIVE "${SUPPORT_FILES_WORKING_DIRECTORY}" "${SUPPORT_FILES_WORKING_DIRECTORY}/*")
if (files)
# clean-up the output directory
## compute full paths
list (TRANSFORM files PREPEND "${SUPPORT_FILES_OUTPUT_DIRECTORY}/")
## remove generated files from the output directory
file (REMOVE ${files})
# clean-up working directory
file (REMOVE_RECURSE "${SUPPORT_FILES_WORKING_DIRECTORY}")
endif()
file (MAKE_DIRECTORY "${SUPPORT_FILES_WORKING_DIRECTORY}")
endif()
if (ACTION STREQUAL "COPY")
# Collect current list of generated files
file (GLOB files LIST_DIRECTORIES FALSE "${SUPPORT_FILES_WORKING_DIRECTORY}/*")
if (files)
# copy files to the output directory
file (COPY ${files} DESTINATION "${SUPPORT_FILES_OUTPUT_DIRECTORY}")
endif()
endif()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment