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

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``:
those targets can be used with any command expecting a target (e.g.
: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``
``SHARED``, ``MODULE`` and ``STATIC`` have the same semantic as for the
......@@ -297,7 +301,7 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
# handle various swig compile flags properties
get_source_file_property (include_directories "${infile}" 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()
set (property "$<TARGET_PROPERTY:${name},SWIG_INCLUDE_DIRECTORIES>")
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)
list (APPEND swig_source_file_flags "$<$<BOOL:${property}>:-D$<JOIN:${property},$<SEMICOLON>-D>>")
get_source_file_property (compile_definitions "${infile}" 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()
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)
list (REMOVE_DUPLICATES cmake_include_directories)
set (swig_include_dirs)
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()
set(swig_special_flags)
......@@ -374,7 +378,7 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
list (APPEND swig_dependencies ${file_depends})
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
# to ensure obsolete files do not stay
set (swig_cleanup_command COMMAND "${CMAKE_COMMAND}" -E remove_directory "${outdir}")
......@@ -501,7 +505,7 @@ function(SWIG_ADD_LIBRARY name)
if (CMAKE_SWIG_OUTDIR)
set (outputdir "${CMAKE_SWIG_OUTDIR}")
else()
if (UseSWIG_MODULE_VERSION VERSION_EQUAL 2)
if (UseSWIG_MODULE_VERSION VERSION_GREATER 1)
set (outputdir "${workingdir}/${_SAM_LANGUAGE}.files")
else()
set (outputdir "${CMAKE_CURRENT_BINARY_DIR}")
......@@ -550,7 +554,7 @@ function(SWIG_ADD_LIBRARY name)
endforeach()
set_property (DIRECTORY APPEND PROPERTY
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}")
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