فهرست منبع

FindPython: Implement lookup strategies.

Configration variable Python_FIND_STRATEGY controls the lookup startegy.
Possible values are LOCATION and VERSION.

Fixes: #19159
Marc Chevrier 6 سال پیش
والد
کامیت
9f205acefe
5فایلهای تغییر یافته به همراه623 افزوده شده و 290 حذف شده
  1. 11 0
      Modules/FindPython.cmake
  2. 564 284
      Modules/FindPython/Support.cmake
  3. 11 0
      Modules/FindPython2.cmake
  4. 11 0
      Modules/FindPython3.cmake
  5. 26 6
      Tests/FindPython/CMakeLists.txt

+ 11 - 0
Modules/FindPython.cmake

@@ -137,6 +137,17 @@ Hints
   * If set to TRUE, search **only** for static libraries.
   * If set to FALSE, search **only** for shared libraries.
 
+``Python_FIND_STRATEGY``
+  This variable defines how lookup will be done.
+  The ``Python_FIND_STRATEGY`` variable can be set to empty or one of the
+  following:
+
+  * ``VERSION``: Try to find the most recent version in all specified
+    locations.
+    This is the default.
+  * ``LOCATION``: Stops lookup as soon as a version satisfying version
+    constraints is founded.
+
 ``Python_FIND_REGISTRY``
   On Windows the ``Python_FIND_REGISTRY`` variable determine the order
   of preference between registry and environment variables.

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 564 - 284
Modules/FindPython/Support.cmake


+ 11 - 0
Modules/FindPython2.cmake

@@ -138,6 +138,17 @@ Hints
   * If set to TRUE, search **only** for static libraries.
   * If set to FALSE, search **only** for shared libraries.
 
+``Python2_FIND_STRATEGY``
+  This variable defines how lookup will be done.
+  The ``Python2_FIND_STRATEGY`` variable can be set to empty or one of the
+  following:
+
+  * ``VERSION``: Try to find the most recent version in all specified
+    locations.
+    This is the default.
+  * ``LOCATION``: Stops lookup as soon as a version satisfying version
+    constraints is founded.
+
 ``Python2_FIND_REGISTRY``
   On Windows the ``Python2_FIND_REGISTRY`` variable determine the order
   of preference between registry and environment variables.

+ 11 - 0
Modules/FindPython3.cmake

@@ -138,6 +138,17 @@ Hints
   * If set to TRUE, search **only** for static libraries.
   * If set to FALSE, search **only** for shared libraries.
 
+``Python3_FIND_STRATEGY``
+  This variable defines how lookup will be done.
+  The ``Python3_FIND_STRATEGY`` variable can be set to empty or one of the
+  following:
+
+  * ``VERSION``: Try to find the most recent version in all specified
+    locations.
+    This is the default.
+  * ``LOCATION``: Stops lookup as soon as a version satisfying version
+    constraints is founded.
+
 ``Python3_FIND_REGISTRY``
   On Windows the ``Python3_FIND_REGISTRY`` variable determine the order
   of preference between registry and environment variables.

+ 26 - 6
Tests/FindPython/CMakeLists.txt

@@ -1,12 +1,22 @@
 if(CMake_TEST_FindPython)
-  add_test(NAME FindPython.Python2 COMMAND
+  add_test(NAME FindPython.Python2.LOCATION COMMAND
     ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
     --build-and-test
     "${CMake_SOURCE_DIR}/Tests/FindPython/Python2"
-    "${CMake_BINARY_DIR}/Tests/FindPython/Python2"
+    "${CMake_BINARY_DIR}/Tests/FindPython/Python2.LOCATION"
     ${build_generator_args}
     --build-project TestPython2
-    --build-options ${build_options}
+    --build-options ${build_options} -DPython2_FIND_STRATEGY=LOCATION
+    --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+    )
+  add_test(NAME FindPython.Python2.VERSION COMMAND
+    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+    --build-and-test
+    "${CMake_SOURCE_DIR}/Tests/FindPython/Python2"
+    "${CMake_BINARY_DIR}/Tests/FindPython/Python2.VERSION"
+    ${build_generator_args}
+    --build-project TestPython2
+    --build-options ${build_options} -DPython2_FIND_STRATEGY=VERSION
     --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
     )
 
@@ -23,14 +33,24 @@ if(CMake_TEST_FindPython)
   set_tests_properties(FindPython.Python2Fail PROPERTIES
     PASS_REGULAR_EXPRESSION "Could NOT find Python2 \\(missing: foobar\\)")
 
-  add_test(NAME FindPython.Python3 COMMAND
+  add_test(NAME FindPython.Python3.LOCATION COMMAND
     ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
     --build-and-test
     "${CMake_SOURCE_DIR}/Tests/FindPython/Python3"
-    "${CMake_BINARY_DIR}/Tests/FindPython/Python3"
+    "${CMake_BINARY_DIR}/Tests/FindPython/Python3.LOCATION"
     ${build_generator_args}
     --build-project TestPython3
-    --build-options ${build_options}
+    --build-options ${build_options} -DPython3_FIND_STRATEGY=LOCATION
+    --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+    )
+  add_test(NAME FindPython.Python3.VERSION COMMAND
+    ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+    --build-and-test
+    "${CMake_SOURCE_DIR}/Tests/FindPython/Python3"
+    "${CMake_BINARY_DIR}/Tests/FindPython/Python3.VERSION"
+    ${build_generator_args}
+    --build-project TestPython3
+    --build-options ${build_options} -DPython3_FIND_STRATEGY=VERSION
     --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
     )
 

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است