Skip to content

Commit b344251

Browse files
committed
Ensure FIND_PACKAGE PythonInterp called before PythonLibs
Upstream Cmake docs specify that PythonInterp should be called before PythonLibs[1]. In some environments, inconsistency is possible when called out of order. [1] https://cmake.org/cmake/help/latest/module/FindPythonInterp.html
1 parent ff88787 commit b344251

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

bindings/python/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ IF (ENABLE_PYTHON3 AND NOT DEFINED PythonLibs_FIND_VERSION)
55
SET (PythonLibs_FIND_VERSION_MAJOR 2)
66
ENDIF (ENABLE_PYTHON3 AND NOT DEFINED PythonLibs_FIND_VERSION)
77

8-
FIND_PACKAGE (PythonLibs REQUIRED)
9-
IF(PYTHONLIBS_VERSION_STRING MATCHES "^([0-9.]+)")
8+
FIND_PACKAGE (PythonInterp ${python_version} REQUIRED)
9+
IF(PYTHON_VERSION_STRING MATCHES "^([0-9.]+)")
1010
SET(python_version "${CMAKE_MATCH_1}")
1111
ELSE()
12-
MESSAGE(FATAL_ERROR "PythonLibs version format unknown '${PYTHONLIBS_VERSION_STRING}'")
12+
MESSAGE(FATAL_ERROR "PythonInterp version format unknown '${PYTHON_VERSION_STRING}'")
1313
ENDIF()
14-
FIND_PACKAGE (PythonInterp ${python_version} REQUIRED)
14+
FIND_PACKAGE (PythonLibs ${python_version} REQUIRED)
1515

1616
EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "from sys import stdout; from distutils import sysconfig; stdout.write(sysconfig.get_python_lib(True))" OUTPUT_VARIABLE PYTHON_INSTALL_DIR)
1717

0 commit comments

Comments
 (0)