Modify Python checks when cMake >= 3.12

This commit is contained in:
Chris Hennes
2021-03-04 14:44:44 -06:00
committed by wmayer
parent 13702ce5de
commit 7bbff520a0
3 changed files with 21 additions and 15 deletions

View File

@@ -123,21 +123,27 @@ macro(SetupPython)
else (NOT DEFINED PYTHON_VERSION_STRING)
find_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT)
endif(NOT DEFINED PYTHON_VERSION_STRING)
if(NOT PYTHONLIBS_FOUND)
message(FATAL_ERROR "=================================\n"
"Python not found, install Python!\n"
"=================================\n")
endif()
else()
find_package(Python3 COMPONENTS Interpreter Development)
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
# For compatibility with old CMake scripts
set(PYTHON_LIBRARIES ${Python3_LIBRARIES})
set(PYTHON_INCLUDE_DIRS ${Python3_INCLUDE_DIRS})
set(PYTHON_LIBRARY_DIRS ${Python3_LIBRARY_DIRS})
set(PYTHON_VERSION_STRING ${Python3_VERSION})
set(PYTHON_VERSION_MAJOR ${Python3_VERSION_MAJOR})
set(PYTHON_VERSION_MINOR ${Python3_VERSION_MINOR})
set(PYTHON_VERSION_PATCH ${Python3_VERSION_PATCH})
endif()
if(NOT PYTHONLIBS_FOUND)
message(FATAL_ERROR "=================================\n"
"Python not found, install Python!\n"
"=================================\n")
else(NOT PYTHONLIBS_FOUND)
# prevent python3 lower than 3.6 (not enough utf8<->unicode tools)
if(PYTHON_VERSION_MAJOR EQUAL 3)
if(PYTHON_VERSION_MINOR LESS 6)
message(FATAL_ERROR "To build FreeCAD you need at least Python 3.6\n")
endif(PYTHON_VERSION_MINOR LESS 6)
endif(PYTHON_VERSION_MAJOR EQUAL 3)
endif(NOT PYTHONLIBS_FOUND)
# prevent python3 lower than 3.6
if (${PYTHON_VERSION_STRING} VERSION_LESS "3.6")
message(FATAL_ERROR "To build FreeCAD you need at least Python 3.6\n")
endif()
endmacro(SetupPython)

View File

@@ -15,7 +15,7 @@ macro(SetupShibokenAndPyside)
if (Shiboken2_FOUND)
# Shiboken2 config file was found but it may use the wrong Python version
# Try to get the matching config suffix and repeat finding the package
set(SHIBOKEN_PATTERN .cpython-${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR})
set(SHIBOKEN_PATTERN .cpython-${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})
file(GLOB SHIBOKEN_CONFIG "${Shiboken2_DIR}/Shiboken2Config${SHIBOKEN_PATTERN}*.cmake")
if (SHIBOKEN_CONFIG)

View File

@@ -12,7 +12,7 @@ include_directories(
${Boost_INCLUDE_DIRS}
${OCC_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
${PYTHON_INCLUDE_PATH}
${Python3_INCLUDE_DIRS}
${XERCESC_INCLUDE_DIR}
)
link_directories(${OCC_LIBRARY_DIR})