[Cmake-commits] CMake branch, master, updated. v3.13.3-1083-g1d02491

Kitware Robot kwrobot at kitware.com
Thu Jan 24 05:43:07 EST 2019


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, master has been updated
       via  1d02491950b0aa05d2053e7fa32b39dca31e537b (commit)
       via  02f5caf4879018fca79fe01fbd196e65e6227870 (commit)
       via  e4541b0e3dde49183742eda8100f608d03d0d027 (commit)
       via  f2d7ed1cda590688e4ff4e37119007d0ee7cf893 (commit)
       via  8ef1916c8226ebf781c4ad0de158d15754d411f5 (commit)
      from  a5789224674999ed206464fa7cea62ae31e3dc67 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1d02491950b0aa05d2053e7fa32b39dca31e537b
commit 1d02491950b0aa05d2053e7fa32b39dca31e537b
Merge: 02f5caf f2d7ed1
Author:     Marc Chevrier <marc.chevrier at gmail.com>
AuthorDate: Thu Jan 24 10:38:02 2019 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Thu Jan 24 05:38:08 2019 -0500

    Merge topic 'findgit-note'
    
    f2d7ed1cda Help: Add note about CMAKE_ROLE to FindGit documentation
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2847


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=02f5caf4879018fca79fe01fbd196e65e6227870
commit 02f5caf4879018fca79fe01fbd196e65e6227870
Merge: a578922 e4541b0
Author:     Marc Chevrier <marc.chevrier at gmail.com>
AuthorDate: Thu Jan 24 10:34:18 2019 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Thu Jan 24 05:34:27 2019 -0500

    Merge topic 'findpython-script'
    
    e4541b0e3d FindPython: Support script mode
    8ef1916c82 FindPython: Test existence of imported targets
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2844


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e4541b0e3dde49183742eda8100f608d03d0d027
commit e4541b0e3dde49183742eda8100f608d03d0d027
Author:     Kyle Edwards <kyle.edwards at kitware.com>
AuthorDate: Wed Jan 23 10:08:27 2019 -0500
Commit:     Kyle Edwards <kyle.edwards at kitware.com>
CommitDate: Wed Jan 23 13:51:09 2019 -0500

    FindPython: Support script mode
    
    Fixes: #18827

diff --git a/Help/release/dev/findpython-script.rst b/Help/release/dev/findpython-script.rst
new file mode 100644
index 0000000..5de1ebf
--- /dev/null
+++ b/Help/release/dev/findpython-script.rst
@@ -0,0 +1,6 @@
+findpython-script
+-----------------
+
+* The :module:`FindPython2`, :module:`FindPython3`, and :module:`FindPython`
+  modules now support running in script mode by skipping the creation of
+  imported targets and helper functions.
diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake
index 8645a0d..f5fb0ab 100644
--- a/Modules/FindPython.cmake
+++ b/Modules/FindPython.cmake
@@ -30,7 +30,8 @@ To manage concurrent versions 3 and 2 of Python, use :module:`FindPython3` and
 Imported Targets
 ^^^^^^^^^^^^^^^^
 
-This module defines the following :ref:`Imported Targets <Imported Targets>`:
+This module defines the following :ref:`Imported Targets <Imported Targets>`
+(when :prop_gbl:`CMAKE_ROLE` is ``PROJECT``):
 
 ``Python::Interpreter``
   Python interpreter. Target defined if component ``Interpreter`` is found.
@@ -144,9 +145,10 @@ Hints
 Commands
 ^^^^^^^^
 
-This module defines the command ``Python_add_library`` which have the same
-semantic as :command:`add_library` but take care of Python module naming rules
-(only applied if library is of type ``MODULE``) and add dependency to target
+This module defines the command ``Python_add_library`` (when
+:prop_gbl:`CMAKE_ROLE` is ``PROJECT``), which has the same semantics as
+:command:`add_library`, but takes care of Python module naming rules
+(only applied if library is of type ``MODULE``), and adds a dependency to target
 ``Python::Python``::
 
   Python_add_library (my_module MODULE src1.cpp)
diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake
index e0ebb90..fd429e2 100644
--- a/Modules/FindPython/Support.cmake
+++ b/Modules/FindPython/Support.cmake
@@ -24,6 +24,8 @@ else()
   message (FATAL_ERROR "FindPython: INTERNAL ERROR")
 endif()
 
+get_property(_${_PYTHON_PREFIX}_CMAKE_ROLE GLOBAL PROPERTY CMAKE_ROLE)
+
 
 #
 # helper commands
@@ -1133,118 +1135,120 @@ find_package_handle_standard_args (${_PYTHON_PREFIX}
                                    HANDLE_COMPONENTS)
 
 # Create imported targets and helper functions
-if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
-    AND ${_PYTHON_PREFIX}_Interpreter_FOUND
-    AND NOT TARGET ${_PYTHON_PREFIX}::Interpreter)
-  add_executable (${_PYTHON_PREFIX}::Interpreter IMPORTED)
-  set_property (TARGET ${_PYTHON_PREFIX}::Interpreter
-                PROPERTY IMPORTED_LOCATION "${${_PYTHON_PREFIX}_EXECUTABLE}")
-endif()
-
-if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
-    AND ${_PYTHON_PREFIX}_Compiler_FOUND
-    AND NOT TARGET ${_PYTHON_PREFIX}::Compiler)
-  add_executable (${_PYTHON_PREFIX}::Compiler IMPORTED)
-  set_property (TARGET ${_PYTHON_PREFIX}::Compiler
-                PROPERTY IMPORTED_LOCATION "${${_PYTHON_PREFIX}_COMPILER}")
-endif()
-
-if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
-    AND ${_PYTHON_PREFIX}_Development_FOUND AND NOT TARGET ${_PYTHON_PREFIX}::Python)
+if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT")
+  if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
+      AND ${_PYTHON_PREFIX}_Interpreter_FOUND
+      AND NOT TARGET ${_PYTHON_PREFIX}::Interpreter)
+    add_executable (${_PYTHON_PREFIX}::Interpreter IMPORTED)
+    set_property (TARGET ${_PYTHON_PREFIX}::Interpreter
+                  PROPERTY IMPORTED_LOCATION "${${_PYTHON_PREFIX}_EXECUTABLE}")
+  endif()
 
-  if (${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$"
-      OR ${_PYTHON_PREFIX}_LIBRARY_DEBUG MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$"
-      OR ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE OR ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG)
-    set (_${_PYTHON_PREFIX}_LIBRARY_TYPE SHARED)
-  else()
-    set (_${_PYTHON_PREFIX}_LIBRARY_TYPE STATIC)
+  if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
+      AND ${_PYTHON_PREFIX}_Compiler_FOUND
+      AND NOT TARGET ${_PYTHON_PREFIX}::Compiler)
+    add_executable (${_PYTHON_PREFIX}::Compiler IMPORTED)
+    set_property (TARGET ${_PYTHON_PREFIX}::Compiler
+                  PROPERTY IMPORTED_LOCATION "${${_PYTHON_PREFIX}_COMPILER}")
   endif()
 
-  add_library (${_PYTHON_PREFIX}::Python ${_${_PYTHON_PREFIX}_LIBRARY_TYPE} IMPORTED)
-
-  set_property (TARGET ${_PYTHON_PREFIX}::Python
-                PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_INCLUDE_DIR}")
-
-  if ((${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE)
-      OR (${_PYTHON_PREFIX}_LIBRARY_DEBUG AND ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG))
-    # System manage shared libraries in two parts: import and runtime
-    if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_LIBRARY_DEBUG)
-      set_property (TARGET ${_PYTHON_PREFIX}::Python PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG)
-      set_target_properties (${_PYTHON_PREFIX}::Python
-                             PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
-                                        IMPORTED_IMPLIB_RELEASE "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}"
-                                        IMPORTED_LOCATION_RELEASE "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE}")
-      set_target_properties (${_PYTHON_PREFIX}::Python
-                             PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
-                                        IMPORTED_IMPLIB_DEBUG "${${_PYTHON_PREFIX}_LIBRARY_DEBUG}"
-                                        IMPORTED_LOCATION_DEBUG "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG}")
+  if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
+      AND ${_PYTHON_PREFIX}_Development_FOUND AND NOT TARGET ${_PYTHON_PREFIX}::Python)
+
+    if (${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$"
+        OR ${_PYTHON_PREFIX}_LIBRARY_DEBUG MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$"
+        OR ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE OR ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG)
+      set (_${_PYTHON_PREFIX}_LIBRARY_TYPE SHARED)
     else()
-      set_target_properties (${_PYTHON_PREFIX}::Python
-                             PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C"
-                                        IMPORTED_IMPLIB "${${_PYTHON_PREFIX}_LIBRARY}"
-                                        IMPORTED_LOCATION "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY}")
+      set (_${_PYTHON_PREFIX}_LIBRARY_TYPE STATIC)
     endif()
-  else()
-    if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_LIBRARY_DEBUG)
-      set_property (TARGET ${_PYTHON_PREFIX}::Python PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG)
-      set_target_properties (${_PYTHON_PREFIX}::Python
-                             PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
-                                        IMPORTED_LOCATION_RELEASE "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}")
-      set_target_properties (${_PYTHON_PREFIX}::Python
-                             PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
-                                        IMPORTED_LOCATION_DEBUG "${${_PYTHON_PREFIX}_LIBRARY_DEBUG}")
+
+    add_library (${_PYTHON_PREFIX}::Python ${_${_PYTHON_PREFIX}_LIBRARY_TYPE} IMPORTED)
+
+    set_property (TARGET ${_PYTHON_PREFIX}::Python
+                  PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_INCLUDE_DIR}")
+
+    if ((${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE)
+        OR (${_PYTHON_PREFIX}_LIBRARY_DEBUG AND ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG))
+      # System manage shared libraries in two parts: import and runtime
+      if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_LIBRARY_DEBUG)
+        set_property (TARGET ${_PYTHON_PREFIX}::Python PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG)
+        set_target_properties (${_PYTHON_PREFIX}::Python
+                               PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
+                                          IMPORTED_IMPLIB_RELEASE "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}"
+                                          IMPORTED_LOCATION_RELEASE "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE}")
+        set_target_properties (${_PYTHON_PREFIX}::Python
+                               PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
+                                          IMPORTED_IMPLIB_DEBUG "${${_PYTHON_PREFIX}_LIBRARY_DEBUG}"
+                                          IMPORTED_LOCATION_DEBUG "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG}")
+      else()
+        set_target_properties (${_PYTHON_PREFIX}::Python
+                               PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+                                          IMPORTED_IMPLIB "${${_PYTHON_PREFIX}_LIBRARY}"
+                                          IMPORTED_LOCATION "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY}")
+      endif()
     else()
-      set_target_properties (${_PYTHON_PREFIX}::Python
-                             PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C"
-                                        IMPORTED_LOCATION "${${_PYTHON_PREFIX}_LIBRARY}")
+      if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_LIBRARY_DEBUG)
+        set_property (TARGET ${_PYTHON_PREFIX}::Python PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG)
+        set_target_properties (${_PYTHON_PREFIX}::Python
+                               PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
+                                          IMPORTED_LOCATION_RELEASE "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}")
+        set_target_properties (${_PYTHON_PREFIX}::Python
+                               PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
+                                          IMPORTED_LOCATION_DEBUG "${${_PYTHON_PREFIX}_LIBRARY_DEBUG}")
+      else()
+        set_target_properties (${_PYTHON_PREFIX}::Python
+                               PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+                                          IMPORTED_LOCATION "${${_PYTHON_PREFIX}_LIBRARY}")
+      endif()
     endif()
-  endif()
 
-  if (_${_PYTHON_PREFIX}_CONFIG AND _${_PYTHON_PREFIX}_LIBRARY_TYPE STREQUAL "STATIC")
-    # extend link information with dependent libraries
-    execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --ldflags
-                     RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
-                     OUTPUT_VARIABLE _${_PYTHON_PREFIX}_FLAGS
-                     ERROR_QUIET
-                     OUTPUT_STRIP_TRAILING_WHITESPACE)
-    if (NOT _${_PYTHON_PREFIX}_RESULT)
-      string (REGEX MATCHALL "-[Ll][^ ]+" _${_PYTHON_PREFIX}_LINK_LIBRARIES "${_${_PYTHON_PREFIX}_FLAGS}")
-      # remove elements relative to python library itself
-      list (FILTER _${_PYTHON_PREFIX}_LINK_LIBRARIES EXCLUDE REGEX "-lpython")
-      foreach (_${_PYTHON_PREFIX}_DIR IN LISTS ${_PYTHON_PREFIX}_LIBRARY_DIRS)
-        list (FILTER _${_PYTHON_PREFIX}_LINK_LIBRARIES EXCLUDE REGEX "-L${${_PYTHON_PREFIX}_DIR}")
-      endforeach()
-      set_property (TARGET ${_PYTHON_PREFIX}::Python
-                    PROPERTY INTERFACE_LINK_LIBRARIES ${_${_PYTHON_PREFIX}_LINK_LIBRARIES})
+    if (_${_PYTHON_PREFIX}_CONFIG AND _${_PYTHON_PREFIX}_LIBRARY_TYPE STREQUAL "STATIC")
+      # extend link information with dependent libraries
+      execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --ldflags
+                       RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+                       OUTPUT_VARIABLE _${_PYTHON_PREFIX}_FLAGS
+                       ERROR_QUIET
+                       OUTPUT_STRIP_TRAILING_WHITESPACE)
+      if (NOT _${_PYTHON_PREFIX}_RESULT)
+        string (REGEX MATCHALL "-[Ll][^ ]+" _${_PYTHON_PREFIX}_LINK_LIBRARIES "${_${_PYTHON_PREFIX}_FLAGS}")
+        # remove elements relative to python library itself
+        list (FILTER _${_PYTHON_PREFIX}_LINK_LIBRARIES EXCLUDE REGEX "-lpython")
+        foreach (_${_PYTHON_PREFIX}_DIR IN LISTS ${_PYTHON_PREFIX}_LIBRARY_DIRS)
+          list (FILTER _${_PYTHON_PREFIX}_LINK_LIBRARIES EXCLUDE REGEX "-L${${_PYTHON_PREFIX}_DIR}")
+        endforeach()
+        set_property (TARGET ${_PYTHON_PREFIX}::Python
+                      PROPERTY INTERFACE_LINK_LIBRARIES ${_${_PYTHON_PREFIX}_LINK_LIBRARIES})
+      endif()
     endif()
-  endif()
 
-  #
-  # PYTHON_ADD_LIBRARY (<name> [STATIC|SHARED|MODULE] src1 src2 ... srcN)
-  # It is used to build modules for python.
-  #
-  function (__${_PYTHON_PREFIX}_ADD_LIBRARY prefix name)
-    cmake_parse_arguments (PARSE_ARGV 2 PYTHON_ADD_LIBRARY
-                           "STATIC;SHARED;MODULE" "" "")
-
-    unset (type)
-    if (NOT (PYTHON_ADD_LIBRARY_STATIC
-          OR PYTHON_ADD_LIBRARY_SHARED
-          OR PYTHON_ADD_LIBRARY_MODULE))
-      set (type MODULE)
-    endif()
-    add_library (${name} ${type} ${ARGN})
-    target_link_libraries (${name} PRIVATE ${prefix}::Python)
-
-    # customize library name to follow module name rules
-    get_property (type TARGET ${name} PROPERTY TYPE)
-    if (type STREQUAL "MODULE_LIBRARY")
-      set_property (TARGET ${name} PROPERTY PREFIX "")
-      if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
-        set_property (TARGET ${name} PROPERTY SUFFIX ".pyd")
+    #
+    # PYTHON_ADD_LIBRARY (<name> [STATIC|SHARED|MODULE] src1 src2 ... srcN)
+    # It is used to build modules for python.
+    #
+    function (__${_PYTHON_PREFIX}_ADD_LIBRARY prefix name)
+      cmake_parse_arguments (PARSE_ARGV 2 PYTHON_ADD_LIBRARY
+                             "STATIC;SHARED;MODULE" "" "")
+
+      unset (type)
+      if (NOT (PYTHON_ADD_LIBRARY_STATIC
+            OR PYTHON_ADD_LIBRARY_SHARED
+            OR PYTHON_ADD_LIBRARY_MODULE))
+        set (type MODULE)
       endif()
-    endif()
-  endfunction()
+      add_library (${name} ${type} ${ARGN})
+      target_link_libraries (${name} PRIVATE ${prefix}::Python)
+
+      # customize library name to follow module name rules
+      get_property (type TARGET ${name} PROPERTY TYPE)
+      if (type STREQUAL "MODULE_LIBRARY")
+        set_property (TARGET ${name} PROPERTY PREFIX "")
+        if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+          set_property (TARGET ${name} PROPERTY SUFFIX ".pyd")
+        endif()
+      endif()
+    endfunction()
+  endif()
 endif()
 
 # final clean-up
diff --git a/Modules/FindPython2.cmake b/Modules/FindPython2.cmake
index 998e992..b770708 100644
--- a/Modules/FindPython2.cmake
+++ b/Modules/FindPython2.cmake
@@ -31,7 +31,8 @@ for you.
 Imported Targets
 ^^^^^^^^^^^^^^^^
 
-This module defines the following :ref:`Imported Targets <Imported Targets>`:
+This module defines the following :ref:`Imported Targets <Imported Targets>`
+(when :prop_gbl:`CMAKE_ROLE` is ``PROJECT``):
 
 ``Python2::Interpreter``
   Python 2 interpreter. Target defined if component ``Interpreter`` is found.
@@ -145,9 +146,10 @@ Hints
 Commands
 ^^^^^^^^
 
-This module defines the command ``Python2_add_library`` which have the same
-semantic as :command:`add_library` but take care of Python module naming rules
-(only applied if library is of type ``MODULE``) and add dependency to target
+This module defines the command ``Python2_add_library`` (when
+:prop_gbl:`CMAKE_ROLE` is ``PROJECT``), which has the same semantics as
+:command:`add_library`, but takes care of Python module naming rules
+(only applied if library is of type ``MODULE``), and adds a dependency to target
 ``Python2::Python``::
 
   Python2_add_library (my_module MODULE src1.cpp)
diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake
index 2176f3f..17f1e56 100644
--- a/Modules/FindPython3.cmake
+++ b/Modules/FindPython3.cmake
@@ -31,7 +31,8 @@ for you.
 Imported Targets
 ^^^^^^^^^^^^^^^^
 
-This module defines the following :ref:`Imported Targets <Imported Targets>`:
+This module defines the following :ref:`Imported Targets <Imported Targets>`
+(when :prop_gbl:`CMAKE_ROLE` is ``PROJECT``):
 
 ``Python3::Interpreter``
   Python 3 interpreter. Target defined if component ``Interpreter`` is found.
@@ -145,9 +146,10 @@ Hints
 Commands
 ^^^^^^^^
 
-This module defines the command ``Python3_add_library`` which have the same
-semantic as :command:`add_library` but take care of Python module naming rules
-(only applied if library is of type ``MODULE``) and add dependency to target
+This module defines the command ``Python3_add_library`` (when
+:prop_gbl:`CMAKE_ROLE` is ``PROJECT``), which has the same semantics as
+:command:`add_library`, but takes care of Python module naming rules
+(only applied if library is of type ``MODULE``), and adds a dependency to target
 ``Python3::Python``::
 
   Python3_add_library (my_module MODULE src1.cpp)
diff --git a/Tests/FindPython/FindPythonScript.cmake b/Tests/FindPython/FindPythonScript.cmake
new file mode 100644
index 0000000..9450092
--- /dev/null
+++ b/Tests/FindPython/FindPythonScript.cmake
@@ -0,0 +1 @@
+find_package(${PYTHON_PACKAGE_NAME} REQUIRED QUIET)
diff --git a/Tests/FindPython/Python/CMakeLists.txt b/Tests/FindPython/Python/CMakeLists.txt
index 4919062..f7fc243 100644
--- a/Tests/FindPython/Python/CMakeLists.txt
+++ b/Tests/FindPython/Python/CMakeLists.txt
@@ -23,3 +23,7 @@ target_compile_definitions (spam3 PRIVATE PYTHON3)
 add_test (NAME python_spam3
           COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>"
           "${Python_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")")
+
+add_test(NAME findpython_script
+         COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python
+         -P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake")
diff --git a/Tests/FindPython/Python2/CMakeLists.txt b/Tests/FindPython/Python2/CMakeLists.txt
index c5da3b1..a0753f6 100644
--- a/Tests/FindPython/Python2/CMakeLists.txt
+++ b/Tests/FindPython/Python2/CMakeLists.txt
@@ -28,3 +28,7 @@ target_compile_definitions (spam2 PRIVATE PYTHON2)
 add_test (NAME python2_spam2
           COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam2>"
           "${Python2_EXECUTABLE}" -c "import spam2; spam2.system(\"cd\")")
+
+add_test(NAME findpython2_script
+         COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python2
+         -P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake")
diff --git a/Tests/FindPython/Python3/CMakeLists.txt b/Tests/FindPython/Python3/CMakeLists.txt
index eb3ad79..65eea4c 100644
--- a/Tests/FindPython/Python3/CMakeLists.txt
+++ b/Tests/FindPython/Python3/CMakeLists.txt
@@ -28,3 +28,7 @@ target_compile_definitions (spam3 PRIVATE PYTHON3)
 add_test (NAME python3_spam3
           COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>"
           "${Python3_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")")
+
+add_test(NAME findpython3_script
+         COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python3
+         -P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake")

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f2d7ed1cda590688e4ff4e37119007d0ee7cf893
commit f2d7ed1cda590688e4ff4e37119007d0ee7cf893
Author:     Kyle Edwards <kyle.edwards at kitware.com>
AuthorDate: Wed Jan 23 13:22:55 2019 -0500
Commit:     Kyle Edwards <kyle.edwards at kitware.com>
CommitDate: Wed Jan 23 13:45:12 2019 -0500

    Help: Add note about CMAKE_ROLE to FindGit documentation

diff --git a/Modules/FindGit.cmake b/Modules/FindGit.cmake
index 900e4f5..3491cdc 100644
--- a/Modules/FindGit.cmake
+++ b/Modules/FindGit.cmake
@@ -5,7 +5,8 @@
 FindGit
 -------
 
-The module defines the following ``IMPORTED`` targets:
+The module defines the following ``IMPORTED`` targets (when
+:prop_gbl:`CMAKE_ROLE` is ``PROJECT``):
 
 ``Git::Git``
   Executable of the Git command-line client.

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8ef1916c8226ebf781c4ad0de158d15754d411f5
commit 8ef1916c8226ebf781c4ad0de158d15754d411f5
Author:     Kyle Edwards <kyle.edwards at kitware.com>
AuthorDate: Wed Jan 23 11:53:21 2019 -0500
Commit:     Kyle Edwards <kyle.edwards at kitware.com>
CommitDate: Wed Jan 23 11:53:54 2019 -0500

    FindPython: Test existence of imported targets

diff --git a/Tests/FindPython/Python/CMakeLists.txt b/Tests/FindPython/Python/CMakeLists.txt
index bebd23f..4919062 100644
--- a/Tests/FindPython/Python/CMakeLists.txt
+++ b/Tests/FindPython/Python/CMakeLists.txt
@@ -9,6 +9,14 @@ if (NOT Python_FOUND)
   message (FATAL_ERROR "Fail to found Python 3")
 endif()
 
+if(NOT TARGET Python::Interpreter)
+  message(SEND_ERROR "Python::Interpreter not found")
+endif()
+
+if(NOT TARGET Python::Python)
+  message(SEND_ERROR "Python::Python not found")
+endif()
+
 Python_add_library (spam3 MODULE ../spam.c)
 target_compile_definitions (spam3 PRIVATE PYTHON3)
 
diff --git a/Tests/FindPython/Python2/CMakeLists.txt b/Tests/FindPython/Python2/CMakeLists.txt
index 9622b6f..c5da3b1 100644
--- a/Tests/FindPython/Python2/CMakeLists.txt
+++ b/Tests/FindPython/Python2/CMakeLists.txt
@@ -14,6 +14,14 @@ if (NOT Python2_FOUND)
   message (FATAL_ERROR "Fail to found Python 2")
 endif()
 
+if(NOT TARGET Python2::Interpreter)
+  message(SEND_ERROR "Python2::Interpreter not found")
+endif()
+
+if(NOT TARGET Python2::Python)
+  message(SEND_ERROR "Python2::Python not found")
+endif()
+
 Python2_add_library (spam2 MODULE ../spam.c)
 target_compile_definitions (spam2 PRIVATE PYTHON2)
 
diff --git a/Tests/FindPython/Python3/CMakeLists.txt b/Tests/FindPython/Python3/CMakeLists.txt
index cb86eae..eb3ad79 100644
--- a/Tests/FindPython/Python3/CMakeLists.txt
+++ b/Tests/FindPython/Python3/CMakeLists.txt
@@ -14,6 +14,14 @@ if (NOT Python3_FOUND)
   message (FATAL_ERROR "Fail to found Python 3")
 endif()
 
+if(NOT TARGET Python3::Interpreter)
+  message(SEND_ERROR "Python2::Interpreter not found")
+endif()
+
+if(NOT TARGET Python3::Python)
+  message(SEND_ERROR "Python2::Python not found")
+endif()
+
 Python3_add_library (spam3 MODULE ../spam.c)
 target_compile_definitions (spam3 PRIVATE PYTHON3)
 

-----------------------------------------------------------------------

Summary of changes:
 Help/release/dev/findpython-script.rst  |   6 +
 Modules/FindGit.cmake                   |   3 +-
 Modules/FindPython.cmake                |  10 +-
 Modules/FindPython/Support.cmake        | 206 ++++++++++++++++----------------
 Modules/FindPython2.cmake               |  10 +-
 Modules/FindPython3.cmake               |  10 +-
 Tests/FindPython/FindPythonScript.cmake |   1 +
 Tests/FindPython/Python/CMakeLists.txt  |  12 ++
 Tests/FindPython/Python2/CMakeLists.txt |  12 ++
 Tests/FindPython/Python3/CMakeLists.txt |  12 ++
 10 files changed, 168 insertions(+), 114 deletions(-)
 create mode 100644 Help/release/dev/findpython-script.rst
 create mode 100644 Tests/FindPython/FindPythonScript.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list