From 963837cf173fac75ffdabfa0ba754775968b5547 Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Tue, 10 Apr 2018 10:54:01 +0200 Subject: UseSWIG: fix erroneous generator expressions Add note regarding multi-config generators --- Modules/UseSWIG.cmake | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index 5f9afc1..8713cd8 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$-I>") + list (APPEND swig_source_file_flags "$<$:-I$-I>>") endif() set (property "$") list (APPEND swig_source_file_flags "$<$:-I$-I>>") @@ -306,7 +310,7 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) list (APPEND swig_source_file_flags "$<$:-D$-D>>") get_source_file_property (compile_definitions "${infile}" COMPILE_DEFINITIONS) if (compile_definitions) - list (APPEND swig_source_file_flags "-D$-D>") + list (APPEND swig_source_file_flags "$<$:-D$-D>>") endif() list (APPEND swig_source_file_flags "$") @@ -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$-I>") + set (swig_include_dirs "$<$:-I$-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() -- cgit v0.12