From d1bece92d508edec5a390783ffb245acf22ac5ac Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Fri, 9 Jul 2021 17:31:20 +0200 Subject: UseSWIG: Use swig generated dependencies for Visual Studio --- Help/release/dev/UseSWIG-dependencies.rst | 6 ++++++ Modules/UseSWIG.cmake | 25 ++++++++++++++++++------- Tests/UseSWIG/CMakeLists.txt | 2 +- 3 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 Help/release/dev/UseSWIG-dependencies.rst diff --git a/Help/release/dev/UseSWIG-dependencies.rst b/Help/release/dev/UseSWIG-dependencies.rst new file mode 100644 index 0000000..a3ec29e --- /dev/null +++ b/Help/release/dev/UseSWIG-dependencies.rst @@ -0,0 +1,6 @@ +UseSWIG-dependencies +-------------------- + +* :module:`UseSWIG` module gained the capability, for + :ref:`Visual Studio Generators` to use `swig` tool to generate implicit + dependencies. diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index 5c8f152..9808861 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -192,12 +192,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 `, - :ref:`Ninja ` and :generator:`Xcode` generators. Default - value is ``FALSE``. + :ref:`Ninja `, :generator:`Xcode`, and + :ref:`Visual Studio ` + (: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. This is required if it cannot be scanned automatically from source @@ -342,8 +347,10 @@ as well as ``SWIG``: If set to ``TRUE``, implicit dependencies are generated by the ``swig`` tool itself. This variable is only meaningful for :ref:`Makefile `, - :ref:`Ninja ` and :generator:`Xcode` generators. Default - value is ``FALSE``. + :ref:`Ninja `, :generator:`Xcode`, and + :ref:`Visual Studio ` + (: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. @@ -351,6 +358,9 @@ as well as ``SWIG``: .. versionadded:: 3.21 Added the support of :generator:`Xcode` generator. + .. versionadded:: 3.22 + Added the support of :ref:`Visual Studio Generators`. + #]=======================================================================] cmake_policy(PUSH) @@ -515,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|Xcode") + 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) @@ -840,8 +850,9 @@ function(SWIG_ADD_LIBRARY name) set(SWIG_SOURCE_FILE_EXTENSIONS ".i") endif() - if (CMAKE_GENERATOR MATCHES "Make|Ninja|Xcode") - # 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() diff --git a/Tests/UseSWIG/CMakeLists.txt b/Tests/UseSWIG/CMakeLists.txt index f1b2f32..c3f9e03 100644 --- a/Tests/UseSWIG/CMakeLists.txt +++ b/Tests/UseSWIG/CMakeLists.txt @@ -67,7 +67,7 @@ add_test(NAME UseSWIG.BasicPerl COMMAND --test-command ${CMAKE_CTEST_COMMAND} -V -C $ ) if(SWIG_FOUND AND NOT SWIG_VERSION VERSION_LESS "4.0.2" - AND CMAKE_GENERATOR MATCHES "Make|Ninja|Xcode") + AND CMAKE_GENERATOR MATCHES "Make|Ninja|Xcode|Visual Studio (1[1-9]|[2-9][0-9])") add_test(NAME UseSWIG.Depfile.BasicPython COMMAND ${CMAKE_CTEST_COMMAND} -C $ --build-and-test -- cgit v0.12