mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
ifcwrap/CMakeLists.txt: as PYTHONLIBS_FOUND and PYTHONINTERP_FOUND cannot seem to be trusted, perform further checks to see whether the packages were actually found or not.
E.g. one can doo set PYTHONHOME=C:/NoPythonHere and when running CMake it will happily report: -- Found PythonLibs: C:/NoPythonHere/libs/python34.lib
This commit is contained in:
committed by
Thomas Krijnen
parent
7fdbc9811d
commit
dd8ee915c3
@@ -33,18 +33,20 @@ IF(NOT "$ENV{PYTHON_LIBRARY}" STREQUAL "")
|
||||
MESSAGE(STATUS "Looking for Python library file in: ${PYTHON_LIBRARY}")
|
||||
ENDIF()
|
||||
|
||||
# NOTE PYTHONLIBS_FOUND and PYTHONINTERP_FOUND cannot seem to be trusted so
|
||||
# we need further checks to see whether the packages were actually found or not.
|
||||
FIND_PACKAGE(PythonLibs)
|
||||
IF(NOT PYTHONLIBS_FOUND)
|
||||
MESSAGE(FATAL_ERROR "BUILD_IFCPYTHON enabled, but unable to find Python. Disable BUILD_IFCPYTHON or fix Python paths to proceed.")
|
||||
IF(NOT PYTHONLIBS_FOUND OR "$PYTHON_INCLUDE_DIRS}" STREQUAL "")
|
||||
MESSAGE(FATAL_ERROR "BUILD_IFCPYTHON enabled, but unable to find Python lib or header. Disable BUILD_IFCPYTHON or fix Python paths to proceed.")
|
||||
ENDIF()
|
||||
|
||||
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS})
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
SET(CMAKE_SWIG_FLAGS "")
|
||||
# NOTE Workaround for most likely missing debug Python libraries on Windows (requires Python built from the source).
|
||||
# Python 3.5 intaller and onwards will have an option to install the debug libraries too.
|
||||
# NOTE PYTHON_DEBUG_LIBRARIES appears to be a deprecated variable
|
||||
IF (WIN32 AND NOT PYTHON_DEBUG_LIBRARIES)
|
||||
MESSAGE(STATUS "PYTHON_DEBUG_LIBRARIES not found, defining SWIG_PYTHON_INTERPRETER_NO_DEBUG workaround for IfcWrap.")
|
||||
ADD_DEFINITIONS(-DSWIG_PYTHON_INTERPRETER_NO_DEBUG)
|
||||
@@ -67,7 +69,7 @@ endif()
|
||||
# Try to find the Python interpreter to get the site-packages
|
||||
# directory in which the wrapper can be installed.
|
||||
FIND_PACKAGE(PythonInterp)
|
||||
IF(PYTHONINTERP_FOUND)
|
||||
IF(PYTHONINTERP_FOUND AND NOT "${PYTHON_EXECUTABLE}" STREQUAL "")
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${PYTHON_EXECUTABLE} -c "import sys; from distutils.sysconfig import get_python_lib; sys.stdout.write(get_python_lib(1))"
|
||||
OUTPUT_VARIABLE python_package_dir
|
||||
|
||||
Reference in New Issue
Block a user