Commit 963837cf authored by Marc Chevrier's avatar Marc Chevrier
Browse files

UseSWIG: fix erroneous generator expressions

Add note regarding multi-config generators
parent e769e61f
...@@ -28,7 +28,11 @@ Defines the following command for use with ``SWIG``: ...@@ -28,7 +28,11 @@ Defines the following command for use with ``SWIG``:
those targets can be used with any command expecting a target (e.g. those targets can be used with any command expecting a target (e.g.
:command:`target_link_libraries`). :command:`target_link_libraries`).
The arguments are: .. note::
For multi-config generators, this module does not support
configuration-specific files generated by ``SWIG``. All build
configurations must result in the same generated source file.
``TYPE`` ``TYPE``
``SHARED``, ``MODULE`` and ``STATIC`` have the same semantic as for the ``SHARED``, ``MODULE`` and ``STATIC`` have the same semantic as for the
...@@ -297,7 +301,7 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) ...@@ -297,7 +301,7 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
# handle various swig compile flags properties # handle various swig compile flags properties
get_source_file_property (include_directories "${infile}" INCLUDE_DIRECTORIES) get_source_file_property (include_directories "${infile}" INCLUDE_DIRECTORIES)
if (include_directories) if (include_directories)
list (APPEND swig_source_file_flags "-I$<JOIN:${include_directories},$<SEMICOLON>-I>") list (APPEND swig_source_file_flags "$<$<BOOL:${include_directories}>:-I$<JOIN:${include_directories},$<SEMICOLON>-I>>")
endif() endif()
set (property "$<TARGET_PROPERTY:${name},SWIG_INCLUDE_DIRECTORIES>") set (property "$<TARGET_PROPERTY:${name},SWIG_INCLUDE_DIRECTORIES>")
list (APPEND swig_source_file_flags "$<$<BOOL:${property}>:-I$<JOIN:${property},$<SEMICOLON>-I>>") list (APPEND swig_source_file_flags "$<$<BOOL:${property}>:-I$<JOIN:${property},$<SEMICOLON>-I>>")
...@@ -306,7 +310,7 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) ...@@ -306,7 +310,7 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
list (APPEND swig_source_file_flags "$<$<BOOL:${property}>:-D$<JOIN:${property},$<SEMICOLON>-D>>") list (APPEND swig_source_file_flags "$<$<BOOL:${property}>:-D$<JOIN:${property},$<SEMICOLON>-D>>")
get_source_file_property (compile_definitions "${infile}" COMPILE_DEFINITIONS) get_source_file_property (compile_definitions "${infile}" COMPILE_DEFINITIONS)
if (compile_definitions) if (compile_definitions)
list (APPEND swig_source_file_flags "-D$<JOIN:${compile_definitions},$<SEMICOLON>-D>") list (APPEND swig_source_file_flags "$<$<BOOL:${compile_definitions}>:-D$<JOIN:${compile_definitions},$<SEMICOLON>-D>>")
endif() endif()
list (APPEND swig_source_file_flags "$<TARGET_PROPERTY:${name},SWIG_COMPILE_OPTIONS>") list (APPEND swig_source_file_flags "$<TARGET_PROPERTY:${name},SWIG_COMPILE_OPTIONS>")
...@@ -348,7 +352,7 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) ...@@ -348,7 +352,7 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
list (REMOVE_DUPLICATES cmake_include_directories) list (REMOVE_DUPLICATES cmake_include_directories)
set (swig_include_dirs) set (swig_include_dirs)
if (cmake_include_directories) if (cmake_include_directories)
set (swig_include_dirs "-I$<JOIN:${cmake_include_directories},$<SEMICOLON>-I>") set (swig_include_dirs "$<$<BOOL:${cmake_include_directories}>:-I$<JOIN:${cmake_include_directories},$<SEMICOLON>-I>>")
endif() endif()
set(swig_special_flags) set(swig_special_flags)
...@@ -374,7 +378,7 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) ...@@ -374,7 +378,7 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
list (APPEND swig_dependencies ${file_depends}) list (APPEND swig_dependencies ${file_depends})
endif() endif()
if (UseSWIG_MODULE_VERSION VERSION_EQUAL 2) if (UseSWIG_MODULE_VERSION VERSION_GREATER 1)
# as part of custom command, start by removing old generated files # as part of custom command, start by removing old generated files
# to ensure obsolete files do not stay # to ensure obsolete files do not stay
set (swig_cleanup_command COMMAND "${CMAKE_COMMAND}" -E remove_directory "${outdir}") set (swig_cleanup_command COMMAND "${CMAKE_COMMAND}" -E remove_directory "${outdir}")
...@@ -501,7 +505,7 @@ function(SWIG_ADD_LIBRARY name) ...@@ -501,7 +505,7 @@ function(SWIG_ADD_LIBRARY name)
if (CMAKE_SWIG_OUTDIR) if (CMAKE_SWIG_OUTDIR)
set (outputdir "${CMAKE_SWIG_OUTDIR}") set (outputdir "${CMAKE_SWIG_OUTDIR}")
else() else()
if (UseSWIG_MODULE_VERSION VERSION_EQUAL 2) if (UseSWIG_MODULE_VERSION VERSION_GREATER 1)
set (outputdir "${workingdir}/${_SAM_LANGUAGE}.files") set (outputdir "${workingdir}/${_SAM_LANGUAGE}.files")
else() else()
set (outputdir "${CMAKE_CURRENT_BINARY_DIR}") set (outputdir "${CMAKE_CURRENT_BINARY_DIR}")
...@@ -550,7 +554,7 @@ function(SWIG_ADD_LIBRARY name) ...@@ -550,7 +554,7 @@ function(SWIG_ADD_LIBRARY name)
endforeach() endforeach()
set_property (DIRECTORY APPEND PROPERTY set_property (DIRECTORY APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES ${swig_generated_sources} ${swig_generated_timestamps}) ADDITIONAL_MAKE_CLEAN_FILES ${swig_generated_sources} ${swig_generated_timestamps})
if (UseSWIG_MODULE_VERSION VERSION_EQUAL 2) if (UseSWIG_MODULE_VERSION VERSION_GREATER 1)
set_property (DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${outputdir}") set_property (DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${outputdir}")
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