浏览代码

FindPython: Add variable 'Python_FIND_FRAMEWORK' to control frameworks lookup.

Marc Chevrier 6 年之前
父节点
当前提交
62d6ed79fb

+ 5 - 0
Help/release/dev/FindPython-FIND_FRAMEWORK.rst

@@ -0,0 +1,5 @@
+FindPython-FIND_FRAMEWORK
+-------------------------
+
+* Modules :module:`FindPython3`, :module:`FindPython2` and :module:`FindPython`
+  gain a new variable to control frameworks lookup on macOS.

+ 7 - 2
Modules/FindPython.cmake

@@ -161,14 +161,19 @@ Hints
   * ``LAST``: Try to use registry after environment variables.
   * ``LAST``: Try to use registry after environment variables.
   * ``NEVER``: Never try to use registry.
   * ``NEVER``: Never try to use registry.
 
 
-``CMAKE_FIND_FRAMEWORK``
-  On macOS the :variable:`CMAKE_FIND_FRAMEWORK` variable determine the order of
+``Python_FIND_FRAMEWORK``
+  On macOS the ``Python_FIND_FRAMEWORK`` variable determine the order of
   preference between Apple-style and unix-style package components.
   preference between Apple-style and unix-style package components.
+  This variable can be set to empty or take same values as
+  :variable:`CMAKE_FIND_FRAMEWORK` variable.
 
 
   .. note::
   .. note::
 
 
     Value ``ONLY`` is not supported so ``FIRST`` will be used instead.
     Value ``ONLY`` is not supported so ``FIRST`` will be used instead.
 
 
+  If ``Python_FIND_FRAMEWORK`` is not defined, :variable:`CMAKE_FIND_FRAMEWORK`
+  variable will be used, if any.
+
 ``Python_FIND_VIRTUALENV``
 ``Python_FIND_VIRTUALENV``
   This variable defines the handling of virtual environments. It is meaningfull
   This variable defines the handling of virtual environments. It is meaningfull
   only when a virtual environment is active (i.e. the ``activate`` script has
   only when a virtual environment is active (i.e. the ``activate`` script has

+ 20 - 9
Modules/FindPython/Support.cmake

@@ -361,6 +361,24 @@ set (_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES net45 net40)
 # Apple frameworks handling
 # Apple frameworks handling
 _python_find_frameworks ()
 _python_find_frameworks ()
 
 
+set (_${_PYTHON_PREFIX}_FIND_FRAMEWORK "FIRST")
+
+if (DEFINED ${_PYTHON_PREFIX}_FIND_FRAMEWORK)
+  if (NOT ${_PYTHON_PREFIX}_FIND_FRAMEWORK MATCHES "^(FIRST|LAST|NEVER)$")
+    message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: ${${_PYTHON_PREFIX}_FIND_FRAMEWORK}: invalid value for '${_PYTHON_PREFIX}_FIND_FRAMEWORK'. 'FIRST', 'LAST' or 'NEVER' expected. 'FIRST' will be used instead.")
+  else()
+    set (_${_PYTHON_PREFIX}_FIND_FRAMEWORK ${${_PYTHON_PREFIX}_FIND_FRAMEWORK})
+  endif()
+elseif (DEFINED CMAKE_FIND_FRAMEWORK)
+  if (CMAKE_FIND_FRAMEWORK STREQUAL "ONLY")
+    message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: CMAKE_FIND_FRAMEWORK: 'ONLY' value is not supported. 'FIRST' will be used instead.")
+  elseif (NOT CMAKE_FIND_FRAMEWORK MATCHES "^(FIRST|LAST|NEVER)$")
+    message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: ${CMAKE_FIND_FRAMEWORK}: invalid value for 'CMAKE_FIND_FRAMEWORK'. 'FIRST', 'LAST' or 'NEVER' expected. 'FIRST' will be used instead.")
+  else()
+    set (_${_PYTHON_PREFIX}_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK})
+  endif()
+endif()
+
 # Save CMAKE_FIND_APPBUNDLE
 # Save CMAKE_FIND_APPBUNDLE
 if (DEFINED CMAKE_FIND_APPBUNDLE)
 if (DEFINED CMAKE_FIND_APPBUNDLE)
   set (_${_PYTHON_PREFIX}_CMAKE_FIND_APPBUNDLE ${CMAKE_FIND_APPBUNDLE})
   set (_${_PYTHON_PREFIX}_CMAKE_FIND_APPBUNDLE ${CMAKE_FIND_APPBUNDLE})
@@ -373,15 +391,8 @@ set (CMAKE_FIND_APPBUNDLE "NEVER")
 # Save CMAKE_FIND_FRAMEWORK
 # Save CMAKE_FIND_FRAMEWORK
 if (DEFINED CMAKE_FIND_FRAMEWORK)
 if (DEFINED CMAKE_FIND_FRAMEWORK)
   set (_${_PYTHON_PREFIX}_CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK})
   set (_${_PYTHON_PREFIX}_CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK})
-  if (CMAKE_FIND_FRAMEWORK STREQUAL "ONLY")
-    message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: CMAKE_FIND_FRAMEWORK: 'ONLY' value is not supported. 'FIRST' will be used instead.")
-    set (_${_PYTHON_PREFIX}_FIND_FRAMEWORK "FIRST")
-  else()
-    set (_${_PYTHON_PREFIX}_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK})
-  endif()
 else()
 else()
   unset (_${_PYTHON_PREFIX}_CMAKE_FIND_FRAMEWORK)
   unset (_${_PYTHON_PREFIX}_CMAKE_FIND_FRAMEWORK)
-  set (_${_PYTHON_PREFIX}_FIND_FRAMEWORK "FIRST")
 endif()
 endif()
 # To avoid framework lookup
 # To avoid framework lookup
 set (CMAKE_FIND_FRAMEWORK "NEVER")
 set (CMAKE_FIND_FRAMEWORK "NEVER")
@@ -389,7 +400,7 @@ set (CMAKE_FIND_FRAMEWORK "NEVER")
 # Windows Registry handling
 # Windows Registry handling
 if (DEFINED ${_PYTHON_PREFIX}_FIND_REGISTRY)
 if (DEFINED ${_PYTHON_PREFIX}_FIND_REGISTRY)
   if (NOT ${_PYTHON_PREFIX}_FIND_REGISTRY MATCHES "^(FIRST|LAST|NEVER)$")
   if (NOT ${_PYTHON_PREFIX}_FIND_REGISTRY MATCHES "^(FIRST|LAST|NEVER)$")
-    message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: ${${_PYTHON_PREFIX}_FIND_REGISTRY}: invalid value for '${_PYTHON_PREFIX}_FIND_REGISTRY'. 'FIRST', 'LAST' or 'NEVER' expected.")
+    message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: ${${_PYTHON_PREFIX}_FIND_REGISTRY}: invalid value for '${_PYTHON_PREFIX}_FIND_REGISTRY'. 'FIRST', 'LAST' or 'NEVER' expected. 'FIRST' will be used instead.")
     set (_${_PYTHON_PREFIX}_FIND_REGISTRY "FIRST")
     set (_${_PYTHON_PREFIX}_FIND_REGISTRY "FIRST")
   else()
   else()
     set (_${_PYTHON_PREFIX}_FIND_REGISTRY ${${_PYTHON_PREFIX}_FIND_REGISTRY})
     set (_${_PYTHON_PREFIX}_FIND_REGISTRY ${${_PYTHON_PREFIX}_FIND_REGISTRY})
@@ -402,7 +413,7 @@ endif()
 if (DEFINED ENV{VIRTUAL_ENV})
 if (DEFINED ENV{VIRTUAL_ENV})
   if (DEFINED ${_PYTHON_PREFIX}_FIND_VIRTUALENV)
   if (DEFINED ${_PYTHON_PREFIX}_FIND_VIRTUALENV)
     if (NOT ${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY|STANDARD)$")
     if (NOT ${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY|STANDARD)$")
-      message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: ${${_PYTHON_PREFIX}_FIND_VIRTUALENV}: invalid value for '${_PYTHON_PREFIX}_FIND_VIRTUALENV'. 'FIRST', 'ONLY' or 'IGNORE' expected.")
+      message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: ${${_PYTHON_PREFIX}_FIND_VIRTUALENV}: invalid value for '${_PYTHON_PREFIX}_FIND_VIRTUALENV'. 'FIRST', 'ONLY' or 'STANDARD' expected. 'FIRST' will be used instead.")
       set (_${_PYTHON_PREFIX}_FIND_VIRTUALENV "FIRST")
       set (_${_PYTHON_PREFIX}_FIND_VIRTUALENV "FIRST")
     else()
     else()
       set (_${_PYTHON_PREFIX}_FIND_VIRTUALENV ${${_PYTHON_PREFIX}_FIND_VIRTUALENV})
       set (_${_PYTHON_PREFIX}_FIND_VIRTUALENV ${${_PYTHON_PREFIX}_FIND_VIRTUALENV})

+ 7 - 2
Modules/FindPython2.cmake

@@ -162,14 +162,19 @@ Hints
   * ``LAST``: Try to use registry after environment variables.
   * ``LAST``: Try to use registry after environment variables.
   * ``NEVER``: Never try to use registry.
   * ``NEVER``: Never try to use registry.
 
 
-``CMAKE_FIND_FRAMEWORK``
-  On macOS the :variable:`CMAKE_FIND_FRAMEWORK` variable determine the order of
+``Python2_FIND_FRAMEWORK``
+  On macOS the ``Python2_FIND_FRAMEWORK`` variable determine the order of
   preference between Apple-style and unix-style package components.
   preference between Apple-style and unix-style package components.
+  This variable can be set to empty or take same values as
+  :variable:`CMAKE_FIND_FRAMEWORK` variable.
 
 
   .. note::
   .. note::
 
 
     Value ``ONLY`` is not supported so ``FIRST`` will be used instead.
     Value ``ONLY`` is not supported so ``FIRST`` will be used instead.
 
 
+  If ``Python2_FIND_FRAMEWORK`` is not defined, :variable:`CMAKE_FIND_FRAMEWORK`
+  variable will be used, if any.
+
 ``Python2_FIND_VIRTUALENV``
 ``Python2_FIND_VIRTUALENV``
   This variable defines the handling of virtual environments. It is meaningfull
   This variable defines the handling of virtual environments. It is meaningfull
   only when a virtual environment is active (i.e. the ``activate`` script has
   only when a virtual environment is active (i.e. the ``activate`` script has

+ 7 - 2
Modules/FindPython3.cmake

@@ -162,14 +162,19 @@ Hints
   * ``LAST``: Try to use registry after environment variables.
   * ``LAST``: Try to use registry after environment variables.
   * ``NEVER``: Never try to use registry.
   * ``NEVER``: Never try to use registry.
 
 
-``CMAKE_FIND_FRAMEWORK``
-  On macOS the :variable:`CMAKE_FIND_FRAMEWORK` variable determine the order of
+``Python3_FIND_FRAMEWORK``
+  On macOS the ``Python3_FIND_FRAMEWORK`` variable determine the order of
   preference between Apple-style and unix-style package components.
   preference between Apple-style and unix-style package components.
+  This variable can be set to empty or take same values as
+  :variable:`CMAKE_FIND_FRAMEWORK` variable.
 
 
   .. note::
   .. note::
 
 
     Value ``ONLY`` is not supported so ``FIRST`` will be used instead.
     Value ``ONLY`` is not supported so ``FIRST`` will be used instead.
 
 
+  If ``Python3_FIND_FRAMEWORK`` is not defined, :variable:`CMAKE_FIND_FRAMEWORK`
+  variable will be used, if any.
+
 ``Python3_FIND_VIRTUALENV``
 ``Python3_FIND_VIRTUALENV``
   This variable defines the handling of virtual environments. It is meaningfull
   This variable defines the handling of virtual environments. It is meaningfull
   only when a virtual environment is active (i.e. the ``activate`` script has
   only when a virtual environment is active (i.e. the ``activate`` script has