Commit 6d2fb78e authored by David Moxey's avatar David Moxey

Rejig CMake configuration to avoid warnings

parent 10ac4069
......@@ -177,29 +177,6 @@ IF (MSVC)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE)
ENDIF()
# Add option to use Python 3.
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_PYTHON3
"If true, prefer to use Python 3." OFF "NEKTAR_BUILD_PYTHON" OFF)
IF (NEKTAR_BUILD_PYTHON)
# Unset any existing python executable/library settings so that
# we can rediscover correct python version if v2/3 settings changed
unset(PYTHON_EXECUTABLE CACHE)
unset(PYTHON_INCLUDE_DIR CACHE)
unset(PYTHON_LIBRARY CACHE)
unset(PYTHON_LIBRARY_DEBUG CACHE)
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)
INCLUDE_DIRECTORIES(SYSTEM ${PYTHON_INCLUDE_DIRS})
ENDIF()
# Include Nektar++ common macros
INCLUDE (NektarCommon)
......
......@@ -271,7 +271,7 @@ MACRO(ADD_NEKPY_LIBRARY name)
# Add target link libraries.
TARGET_LINK_LIBRARIES(_${name}
${Boost_SYSTEM_LIBRARY}
${Boost_PYTHON_LIBRARY}
${BOOST_PYTHON_LIB}
${BOOST_NUMPY_LIB}
${PYTHON_LIBRARIES}
${name})
......
......@@ -6,31 +6,6 @@
#
########################################################################
# Define a macro that checks for common Boost environment variables.
MACRO(NektarFindBoost)
SET(Boost_DEBUG 0)
SET(Boost_NO_BOOST_CMAKE ON)
IF (BOOST_ROOT)
SET(Boost_NO_SYSTEM_PATHS ON)
FIND_PACKAGE(Boost ${MIN_VER} QUIET COMPONENTS ${NEEDED_BOOST_LIBS})
ELSE ()
SET(TEST_ENV1 $ENV{BOOST_HOME})
SET(TEST_ENV2 $ENV{BOOST_DIR})
IF (DEFINED TEST_ENV1)
SET(BOOST_ROOT $ENV{BOOST_HOME})
SET(Boost_NO_SYSTEM_PATHS ON)
FIND_PACKAGE(Boost ${MIN_VER} QUIET COMPONENTS ${NEEDED_BOOST_LIBS})
ELSEIF (DEFINED TEST_ENV2)
SET(BOOST_ROOT $ENV{BOOST_DIR})
SET(Boost_NO_SYSTEM_PATHS ON)
FIND_PACKAGE(Boost ${MIN_VER} QUIET COMPONENTS ${NEEDED_BOOST_LIBS})
ELSE ()
SET(BOOST_ROOT ${TPDIST})
FIND_PACKAGE(Boost ${MIN_VER} QUIET COMPONENTS ${NEEDED_BOOST_LIBS})
ENDIF()
ENDIF()
ENDMACRO()
#If the user has not set BOOST_ROOT, look in a couple common places first.
MESSAGE(STATUS "Searching for Boost:")
......@@ -38,37 +13,6 @@ MESSAGE(STATUS "Searching for Boost:")
SET(MIN_VER "1.56.0")
SET(NEEDED_BOOST_LIBS thread iostreams filesystem system program_options regex)
IF (NEKTAR_BUILD_PYTHON)
# 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.
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})
# Now try different versions of the string.
SET(NAMES_TO_TRY python-py${BOOST_PYTHON_VERSION_MAJOR}${BOOST_PYTHON_VERSION_MINOR}
python-py${BOOST_PYTHON_VERSION_MAJOR}
python${BOOST_PYTHON_VERSION_MAJOR}${BOOST_PYTHON_VERSION_MINOR}
python${BOOST_PYTHON_VERSION_MAJOR}
python
)
FOREACH(BPLIB ${NAMES_TO_TRY})
SET(NEEDED_BOOST_LIBS ${TMP_BOOST_LIST} ${BPLIB})
NektarFindBoost()
STRING(TOUPPER ${BPLIB} BPLIB_UPPER)
IF (Boost_${BPLIB_UPPER}_FOUND)
SET(Boost_PYTHON_LIBRARY ${Boost_${BPLIB_UPPER}_LIBRARY})
break()
ENDIF()
ENDFOREACH()
ELSE()
NektarFindBoost()
ENDIF()
SET(Boost_NO_BOOST_CMAKE ON)
IF( BOOST_ROOT )
SET(Boost_NO_SYSTEM_PATHS ON)
......
......@@ -7,6 +7,57 @@
########################################################################
IF (NEKTAR_BUILD_PYTHON)
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_PYTHON3
"If true, prefer to use Python 3." OFF "NEKTAR_BUILD_PYTHON" OFF)
# Unset any existing python executable/library settings so that
# we can rediscover correct python version if v2/3 settings changed
unset(PYTHON_EXECUTABLE CACHE)
unset(PYTHON_INCLUDE_DIR CACHE)
unset(PYTHON_LIBRARY CACHE)
unset(PYTHON_LIBRARY_DEBUG CACHE)
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)
INCLUDE_DIRECTORIES(SYSTEM ${PYTHON_INCLUDE_DIRS})
# 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})
# Try to find Boost::Python
FIND_LIBRARY(BOOST_PYTHON_LIB
NAMES boost_python-py${BOOST_PYTHON_VERSION_MAJOR}${BOOST_PYTHON_VERSION_MINOR}
boost_python${BOOST_PYTHON_VERSION_MAJOR}${BOOST_PYTHON_VERSION_MINOR}
boost_python-py${BOOST_PYTHON_VERSION_MAJOR}
boost_python${BOOST_PYTHON_VERSION_MAJOR}
boost_python
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()
MESSAGE(STATUS "Found Boost.Python: ${BOOST_PYTHON_LIB}")
# Try to find Boost.NumPy
FIND_LIBRARY(BOOST_NUMPY_LIB
NAMES boost_numpy-py${BOOST_PYTHON_VERSION_MAJOR}${BOOST_PYTHON_VERSION_MINOR}
......@@ -38,8 +89,10 @@ IF (NEKTAR_BUILD_PYTHON)
)
SET(BOOST_NUMPY_LIB ${TPDIST}/lib64/${CMAKE_STATIC_LIBRARY_PREFIX}boost_numpy${CMAKE_STATIC_LIBRARY_SUFFIX})
INCLUDE_DIRECTORIES(SYSTEM ${TPDIST}/include)
INCLUDE_DIRECTORIES(SYSTEM ${TPDIST}/include)
MESSAGE(STATUS "Build Boost.NumPy: ${BOOST_NUMPY_LIB}")
ELSE()
MESSAGE(STATUS "Found Boost.NumPy: ${BOOST_NUMPY_LIB}")
ADD_CUSTOM_TARGET(boost-numpy ALL)
ADD_DEFINITIONS(-DBOOST_HAS_NUMPY)
ENDIF()
......
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