Commit 0556c661 authored by Dave Moxey's avatar Dave Moxey

Merge branch 'fix/python-cmake' into 'master'

Another attempt to fix CMake Python detection on USE_PYTHON3 status changes

See merge request !1099
parents 67618ee4 cc1aaef6
Pipeline #1200 failed with stages
in 13 minutes and 8 seconds
......@@ -17,77 +17,70 @@ IF (NEKTAR_BUILD_PYTHON)
ENDIF()
IF (NOT NEKTAR_PYTHON3_STATUS STREQUAL NEKTAR_USE_PYTHON3)
# Unset any existing python executable/library settings so that we can
# rediscover correct python version if v2/3 settings changed.
IF (DEFINED NEKTAR_PYTHON3_STATUS)
unset(PYTHON_EXECUTABLE CACHE)
unset(PYTHON_INCLUDE_DIR CACHE)
unset(PYTHON_LIBRARY CACHE)
unset(PYTHON_LIBRARY_DEBUG CACHE)
unset(BOOST_PYTHON_LIB CACHE)
unset(BOOST_NUMPY_LIB CACHE)
ENDIF()
unset(PYTHON_EXECUTABLE CACHE)
unset(PYTHON_INCLUDE_DIR CACHE)
unset(PYTHON_LIBRARY CACHE)
unset(PYTHON_LIBRARY_DEBUG CACHE)
unset(BOOST_PYTHON_LIB CACHE)
unset(BOOST_NUMPY_LIB CACHE)
SET(NEKTAR_PYTHON3_STATUS ${NEKTAR_USE_PYTHON3} CACHE INTERNAL "")
ENDIF()
SET(PYTHONVER 2.7)
IF (NEKTAR_USE_PYTHON3)
SET(PYTHONVER 3.0)
ENDIF()
SET(PYTHONVER 2.7)
IF (NEKTAR_USE_PYTHON3)
SET(PYTHONVER 3.0)
ENDIF()
# Find Python
FIND_PACKAGE(PythonInterp ${PYTHONVER} REQUIRED)
FIND_PACKAGE(PythonLibsNew ${PYTHONVER} REQUIRED)
# Save include dir in Cache for subsequent configures.
SET(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS} CACHE INTERNAL "" FORCE)
# Include headers from root directory for config file.
# Now try to find Boost::Python. For now we are relying entirely on
# distributed versions of this (versus trying to compile via ThirdParty)
# because they come with various names and FindBoost is not really geared up
# for this at present. Therefore this is done separately to avoid lots of
# warnings and extraneous output.
#
# We need to try a few variants, depending on if we're doing Python 2 or
# Python 3. Irritatingly this is all very much distriution dependent so we
# just take our best guess at filenames. Seemingly from Boost 1.67 onwards,
# names are just `python27` and `numpy32` but for now we have to deal with
# this ourselves.
STRING(REPLACE "." ";" BOOST_PYTHON_VERSION ${PYTHONLIBS_VERSION_STRING})
LIST(GET BOOST_PYTHON_VERSION 0 BOOST_PYTHON_VERSION_MAJOR)
LIST(GET BOOST_PYTHON_VERSION 1 BOOST_PYTHON_VERSION_MINOR)
SET(TMP_BOOST_LIST ${NEEDED_BOOST_LIBS})
# If we're using multi-threaded, the existing library likely has a '-mt'
# suffix so we need to append this too.
IF (Boost_SYSTEM_LIBRARY MATCHES "-mt")
SET(BOOST_LIB_SUFFIX "-mt")
ENDIF()
# Find Python
FIND_PACKAGE(PythonInterp ${PYTHONVER} REQUIRED)
FIND_PACKAGE(PythonLibsNew ${PYTHONVER} REQUIRED)
# Include headers from root directory for config file.
# Now try to find Boost::Python. For now we are relying entirely on
# distributed versions of this (versus trying to compile via ThirdParty)
# because they come with various names and FindBoost is not really geared up
# for this at present. Therefore this is done separately to avoid lots of
# warnings and extraneous output.
#
# We need to try a few variants, depending on if we're doing Python 2 or
# Python 3. Irritatingly this is all very much distriution dependent so we
# just take our best guess at filenames. Seemingly from Boost 1.67 onwards,
# names are just `python27` and `numpy32` but for now we have to deal with
# this ourselves.
STRING(REPLACE "." ";" BOOST_PYTHON_VERSION ${PYTHONLIBS_VERSION_STRING})
LIST(GET BOOST_PYTHON_VERSION 0 BOOST_PYTHON_VERSION_MAJOR)
LIST(GET BOOST_PYTHON_VERSION 1 BOOST_PYTHON_VERSION_MINOR)
SET(TMP_BOOST_LIST ${NEEDED_BOOST_LIBS})
# If we're using multi-threaded, the existing library likely has a '-mt'
# suffix so we need to append this too.
IF (Boost_SYSTEM_LIBRARY MATCHES "-mt")
SET(BOOST_LIB_SUFFIX "-mt")
ENDIF()
# Try to find Boost::Python
FIND_LIBRARY(BOOST_PYTHON_LIB
NAMES boost_python-py${BOOST_PYTHON_VERSION_MAJOR}${BOOST_PYTHON_VERSION_MINOR}${BOOST_LIB_SUFFIX}
boost_python${BOOST_PYTHON_VERSION_MAJOR}${BOOST_PYTHON_VERSION_MINOR}${BOOST_LIB_SUFFIX}
boost_python-py${BOOST_PYTHON_VERSION_MAJOR}${BOOST_LIB_SUFFIX}
boost_python${BOOST_PYTHON_VERSION_MAJOR}${BOOST_LIB_SUFFIX}
boost_python${BOOST_LIB_SUFFIX}
PATHS ${Boost_LIBRARY_DIRS})
IF (NOT BOOST_PYTHON_LIB)
MESSAGE(FATAL_ERROR "Could not find Boost Python installation: check it is installed in your distribution.")
ENDIF()
# Try to find Boost::Python
FIND_LIBRARY(BOOST_PYTHON_LIB
NAMES boost_python-py${BOOST_PYTHON_VERSION_MAJOR}${BOOST_PYTHON_VERSION_MINOR}${BOOST_LIB_SUFFIX}
boost_python${BOOST_PYTHON_VERSION_MAJOR}${BOOST_PYTHON_VERSION_MINOR}${BOOST_LIB_SUFFIX}
boost_python-py${BOOST_PYTHON_VERSION_MAJOR}${BOOST_LIB_SUFFIX}
boost_python${BOOST_PYTHON_VERSION_MAJOR}${BOOST_LIB_SUFFIX}
boost_python${BOOST_LIB_SUFFIX}
PATHS ${Boost_LIBRARY_DIRS})
IF (NOT BOOST_PYTHON_LIB)
MESSAGE(FATAL_ERROR "Could not find Boost Python installation: check it is installed in your distribution.")
ENDIF()
# Try to find Boost.NumPy
FIND_LIBRARY(BOOST_NUMPY_LIB
NAMES boost_numpy-py${BOOST_PYTHON_VERSION_MAJOR}${BOOST_PYTHON_VERSION_MINOR}${BOOST_LIB_SUFFIX}
boost_numpy${BOOST_PYTHON_VERSION_MAJOR}${BOOST_PYTHON_VERSION_MINOR}${BOOST_LIB_SUFFIX}
boost_numpy-py${BOOST_PYTHON_VERSION_MAJOR}${BOOST_LIB_SUFFIX}
boost_numpy${BOOST_PYTHON_VERSION_MAJOR}${BOOST_LIB_SUFFIX}
boost_numpy${BOOST_LIB_SUFFIX}
PATHS ${Boost_LIBRARY_DIRS})
# Try to find Boost.NumPy
FIND_LIBRARY(BOOST_NUMPY_LIB
NAMES boost_numpy-py${BOOST_PYTHON_VERSION_MAJOR}${BOOST_PYTHON_VERSION_MINOR}${BOOST_LIB_SUFFIX}
boost_numpy${BOOST_PYTHON_VERSION_MAJOR}${BOOST_PYTHON_VERSION_MINOR}${BOOST_LIB_SUFFIX}
boost_numpy-py${BOOST_PYTHON_VERSION_MAJOR}${BOOST_LIB_SUFFIX}
boost_numpy${BOOST_PYTHON_VERSION_MAJOR}${BOOST_LIB_SUFFIX}
boost_numpy${BOOST_LIB_SUFFIX}
PATHS ${Boost_LIBRARY_DIRS})
SET(NEKTAR_PYTHON3_STATUS ${NEKTAR_USE_PYTHON3} CACHE INTERNAL "")
ENDIF()
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS})
ADD_DEFINITIONS(-DWITH_PYTHON)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment