summaryrefslogtreecommitdiff
path: root/Modules/UseSWIG.cmake
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@sap.com>2018-04-10 10:54:01 +0200
committerMarc Chevrier <marc.chevrier@sap.com>2018-04-10 11:28:32 +0200
commit963837cf173fac75ffdabfa0ba754775968b5547 (patch)
treed34955b411d38035b808bae1d7173bd8a1288238 /Modules/UseSWIG.cmake
parente769e61f992ba0c0028e28bdf7531f495a625925 (diff)
downloadcmake-963837cf173fac75ffdabfa0ba754775968b5547.tar.gz
UseSWIG: fix erroneous generator expressions
Add note regarding multi-config generators
Diffstat (limited to 'Modules/UseSWIG.cmake')
-rw-r--r--Modules/UseSWIG.cmake18
1 files changed, 11 insertions, 7 deletions
diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake
index 5f9afc1f40..8713cd8be5 100644
--- a/Modules/UseSWIG.cmake
+++ b/Modules/UseSWIG.cmake
@@ -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()