diff options
Diffstat (limited to 'Modules/UseSWIG.cmake')
-rw-r--r-- | Modules/UseSWIG.cmake | 57 |
1 files changed, 47 insertions, 10 deletions
diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index 6073125..9808861 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -38,7 +38,13 @@ Defines the following command for use with ``SWIG``: .. versionchanged:: 3.15 Alternate library name (set with the :prop_tgt:`OUTPUT_NAME` property, - for example) will be passed on to Python and CSharp wrapper libraries. + for example) will be passed on to ``Python`` and ``CSharp`` wrapper + libraries. + + .. versionchanged:: 3.21 + Generated library use standard naming conventions for ``CSharp`` language + when policy :policy:`CMP0122` is set to ``NEW``. Otherwise, the legacy + behavior is applied. .. note:: @@ -185,8 +191,17 @@ ensure generated files will receive the required settings. If set to ``TRUE``, implicit dependencies are generated by the ``swig`` tool itself. This property is only meaningful for - :ref:`Makefile <Makefile Generators>` and - :ref:`Ninja <Ninja Generators>` generators. Default value is ``FALSE``. + :ref:`Makefile <Makefile Generators>`, + :ref:`Ninja <Ninja Generators>`, :generator:`Xcode`, and + :ref:`Visual Studio <Visual Studio Generators>` + (:generator:`Visual Studio 11 2012` and above) generators. Default value is + ``FALSE``. + + .. versionadded:: 3.21 + Added the support of :generator:`Xcode` generator. + + .. versionadded:: 3.22 + Added the support of :ref:`Visual Studio Generators`. ``SWIG_MODULE_NAME`` Specify the actual import name of the module in the target language. @@ -330,12 +345,22 @@ as well as ``SWIG``: .. versionadded:: 3.20 If set to ``TRUE``, implicit dependencies are generated by the ``swig`` tool - itself. This property is only meaningful for - :ref:`Makefile <Makefile Generators>` and - :ref:`Ninja <Ninja Generators>` generators. Default value is ``FALSE``. + itself. This variable is only meaningful for + :ref:`Makefile <Makefile Generators>`, + :ref:`Ninja <Ninja Generators>`, :generator:`Xcode`, and + :ref:`Visual Studio <Visual Studio Generators>` + (:generator:`Visual Studio 11 2012` and above) generators. Default value is + ``FALSE``. Source file property ``USE_SWIG_DEPENDENCIES``, if not defined, will be initialized with the value of this variable. + + .. versionadded:: 3.21 + Added the support of :generator:`Xcode` generator. + + .. versionadded:: 3.22 + Added the support of :ref:`Visual Studio Generators`. + #]=======================================================================] cmake_policy(PUSH) @@ -500,7 +525,7 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) endif() set (use_swig_dependencies ${SWIG_USE_SWIG_DEPENDENCIES}) - if (CMAKE_GENERATOR MATCHES "Make|Ninja") + if (CMAKE_GENERATOR MATCHES "Make|Ninja|Xcode|Visual Studio (1[1-9]|[2-9][0-9])") get_property(use_swig_dependencies_set SOURCE "${infile}" PROPERTY USE_SWIG_DEPENDENCIES SET) if (use_swig_dependencies_set) get_property(use_swig_dependencies SOURCE "${infile}" PROPERTY USE_SWIG_DEPENDENCIES) @@ -515,7 +540,7 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) endif() set (property "$<TARGET_PROPERTY:${target_name},SWIG_INCLUDE_DIRECTORIES>") list (APPEND swig_source_file_flags "$<$<BOOL:${property}>:-I$<JOIN:$<TARGET_GENEX_EVAL:${target_name},${property}>,$<SEMICOLON>-I>>") - set (property "$<TARGET_PROPERTY:${target_name},INCLUDE_DIRECTORIES>") + set (property "$<REMOVE_DUPLICATES:$<TARGET_PROPERTY:${target_name},INCLUDE_DIRECTORIES>>") get_source_file_property(use_target_include_dirs "${infile}" USE_TARGET_INCLUDE_DIRECTORIES) if (use_target_include_dirs) list (APPEND swig_source_file_flags "$<$<BOOL:${property}>:-I$<JOIN:${property},$<SEMICOLON>-I>>") @@ -825,8 +850,9 @@ function(SWIG_ADD_LIBRARY name) set(SWIG_SOURCE_FILE_EXTENSIONS ".i") endif() - if (CMAKE_GENERATOR MATCHES "Make|Ninja") - # For Makefiles and Ninja generators, use SWIG generated dependencies + if (CMAKE_GENERATOR MATCHES "Make|Ninja|Xcode|Visual Studio (1[1-9]|[2-9][0-9])") + # For Makefiles, Ninja, Xcode and Visual Studio generators, + # use SWIG generated dependencies if requested if (NOT DEFINED SWIG_USE_SWIG_DEPENDENCIES) set (SWIG_USE_SWIG_DEPENDENCIES OFF) endif() @@ -952,6 +978,17 @@ function(SWIG_ADD_LIBRARY name) endif () elseif (swig_lowercase_language STREQUAL "fortran") # Do *not* override the target's library prefix + elseif (swig_lowercase_language STREQUAL "csharp") + cmake_policy(GET CMP0122 csharp_naming_policy) + if (csharp_naming_policy STREQUAL "NEW") + # Do *not* override the target's library prefix + else() + if (NOT csharp_naming_policy) + cmake_policy(GET_WARNING CMP0122 _cmp0122_warning) + message(AUTHOR_WARNING "${_cmp0122_warning}\n") + endif() + set_target_properties (${target_name} PROPERTIES PREFIX "") + endif() else() # assume empty prefix because we expect the module to be dynamically loaded set_target_properties (${target_name} PROPERTIES PREFIX "") |