summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2018-11-27 15:10:32 +0100
committerMarc Chevrier <marc.chevrier@gmail.com>2018-12-07 18:51:57 +0100
commitdff28141dcddd90b0bb95740d66b8f698cc8da6a (patch)
tree0a6a26af46a22a672f7e12a53550b7f691559dcb /Modules
parent7b3d4799f8c03162d537e65effd3dd8d56fc3386 (diff)
downloadcmake-dff28141dcddd90b0bb95740d66b8f698cc8da6a.tar.gz
UseSWIG: add management of SWIG option -module
When file property SWIG_MODULE_NAME is specified, provide option -module to SWIG compiler. Fixes: #18374
Diffstat (limited to 'Modules')
-rw-r--r--Modules/UseSWIG.cmake25
1 files changed, 25 insertions, 0 deletions
diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake
index d9a03898e0..a3d6d9e347 100644
--- a/Modules/UseSWIG.cmake
+++ b/Modules/UseSWIG.cmake
@@ -142,6 +142,11 @@ ensure generated files will receive the required settings.
set_property(SOURCE mymod.i PROPERTY SWIG_MODULE_NAME mymod_realname)
+ .. note::
+
+ If policy :policy:`CMP0086` is set to ``NEW``, ``-module <module_name>``
+ is passed to ``SWIG`` compiler.
+
Target library properties can be set to apply same configuration to all SWIG
input files.
@@ -220,12 +225,19 @@ as well as ``SWIG``:
#]=======================================================================]
cmake_policy(GET CMP0078 target_name_policy)
+cmake_policy(GET CMP0086 module_name_policy)
+
cmake_policy (VERSION 3.12)
if (target_name_policy)
# respect user choice regarding CMP0078 policy
cmake_policy(SET CMP0078 ${target_name_policy})
endif()
+if (module_name_policy)
+ # respect user choice regarding CMP0086 policy
+ cmake_policy(SET CMP0086 ${module_name_policy})
+endif()
unset(target_name_policy)
+unset(module_name_policy)
set(SWIG_CXX_EXTENSION "cxx")
set(SWIG_EXTRA_LIBRARIES "")
@@ -426,6 +438,19 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
list (APPEND swig_special_flags "-c++")
endif()
+ cmake_policy(GET CMP0086 module_name_policy)
+ if (module_name_policy STREQUAL "NEW")
+ get_source_file_property(module_name "${infile}" SWIG_MODULE_NAME)
+ if (module_name)
+ list (APPEND swig_special_flags "-module" "${module_name}")
+ endif()
+ else()
+ if (NOT module_name_policy)
+ cmake_policy(GET_WARNING CMP0086 _cmp0086_warning)
+ message(AUTHOR_WARNING "${_cmp0086_warning}\n")
+ endif()
+ endif()
+
set (swig_extra_flags)
if(SWIG_MODULE_${name}_LANGUAGE STREQUAL "CSHARP")
if(NOT ("-dllimport" IN_LIST swig_source_file_flags OR "-dllimport" IN_LIST SWIG_MODULE_${name}_EXTRA_FLAGS))