Commit 718afce2 authored by Dave Moxey's avatar Dave Moxey
Browse files

Add buildsystem support for Python 3

parent 690dfafb
...@@ -210,6 +210,22 @@ IF (MSVC) ...@@ -210,6 +210,22 @@ IF (MSVC)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE) ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE)
ENDIF() ENDIF()
# Add option to use Python 3.
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_PYTHON3
"If true, prefer to use Python 3." OFF "NEKTAR_USE_PYTHON3" OFF)
IF (NEKTAR_BUILD_PYTHON)
SET(PYTHONVER 2.7)
IF (NEKTAR_USE_PYTHON3)
SET(PYTHONVER 3)
ENDIF()
# Find Python
FIND_PACKAGE(PythonInterp ${PYTHONVER} REQUIRED)
FIND_PACKAGE(PythonLibs ${PYTHONVER} REQUIRED)
INCLUDE_DIRECTORIES(SYSTEM ${PYTHON_INCLUDE_DIRS})
ENDIF()
# Include Nektar++ common macros # Include Nektar++ common macros
INCLUDE (NektarCommon) INCLUDE (NektarCommon)
......
...@@ -6,42 +6,67 @@ ...@@ -6,42 +6,67 @@
# #
######################################################################## ########################################################################
# 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. #If the user has not set BOOST_ROOT, look in a couple common places first.
MESSAGE(STATUS "Searching for Boost:") MESSAGE(STATUS "Searching for Boost:")
SET(MIN_VER "1.56.0")
# Minimum version and boost libraries required
SET(MIN_VER "1.56.0")
SET(NEEDED_BOOST_LIBS thread iostreams filesystem system program_options regex) SET(NEEDED_BOOST_LIBS thread iostreams filesystem system program_options regex)
IF (NEKTAR_BUILD_PYTHON) IF (NEKTAR_BUILD_PYTHON)
SET(NEEDED_BOOST_LIBS ${NEEDED_BOOST_LIBS} python) # We need to try a few variants, depending on if we're doing Python 2 or
ENDIF() # Python 3. Irritatingly this is all very much distriution dependent so we
# just take our best guess at filenames.
SET(Boost_DEBUG 0) STRING(REPLACE "." ";" BOOST_PYTHON_VERSION ${PYTHONLIBS_VERSION_STRING})
SET(Boost_NO_BOOST_CMAKE ON) LIST(GET BOOST_PYTHON_VERSION 0 BOOST_PYTHON_VERSION_MAJOR)
IF( BOOST_ROOT ) LIST(GET BOOST_PYTHON_VERSION 1 BOOST_PYTHON_VERSION_MINOR)
SET(Boost_NO_SYSTEM_PATHS ON) SET(TMP_BOOST_LIST ${NEEDED_BOOST_LIBS})
FIND_PACKAGE( Boost ${MIN_VER} COMPONENTS ${NEEDED_BOOST_LIBS})
ELSE () # Now try different versions of the string.
SET(TEST_ENV1 $ENV{BOOST_HOME}) 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} python)
SET(TEST_ENV2 $ENV{BOOST_DIR})
IF (DEFINED TEST_ENV1) FOREACH(BPLIB ${NAMES_TO_TRY})
SET(BOOST_ROOT $ENV{BOOST_HOME}) SET(NEEDED_BOOST_LIBS ${TMP_BOOST_LIST} ${BPLIB})
SET(Boost_NO_SYSTEM_PATHS ON) NektarFindBoost()
FIND_PACKAGE( Boost ${MIN_VER} QUIET COMPONENTS ${NEEDED_BOOST_LIBS} ) STRING(TOUPPER ${BPLIB} BPLIB_UPPER)
ELSEIF (DEFINED TEST_ENV2)
SET(BOOST_ROOT $ENV{BOOST_DIR}) IF (Boost_${BPLIB_UPPER}_FOUND)
SET(Boost_NO_SYSTEM_PATHS ON) break()
FIND_PACKAGE( Boost ${MIN_VER} QUIET COMPONENTS ${NEEDED_BOOST_LIBS} ) ENDIF()
ELSE () ENDFOREACH()
SET(BOOST_ROOT ${TPDIST}) ELSE()
FIND_PACKAGE( Boost ${MIN_VER} QUIET COMPONENTS ${NEEDED_BOOST_LIBS} ) NektarFindBoost()
ENDIF()
ENDIF() ENDIF()
# Check what we found and determine if we need to build boost # Check what we found and determine if we need to build boost
FOREACH(FOUND_VAR ${NEEDED_BOOST_LIBS}) FOREACH(FOUND_VAR ${NEEDED_BOOST_LIBS})
STRING(TOUPPER ${FOUND_VAR} FOUND_VAR_UPPER) STRING(TOUPPER ${FOUND_VAR} FOUND_VAR_UPPER)
IF (Boost_${FOUND_VAR_UPPER}_FOUND ) IF (Boost_${FOUND_VAR_UPPER}_FOUND)
MESSAGE(STATUS "-- Found Boost ${FOUND_VAR} library: " MESSAGE(STATUS "-- Found Boost ${FOUND_VAR} library: "
"${Boost_${FOUND_VAR_UPPER}_LIBRARY}") "${Boost_${FOUND_VAR_UPPER}_LIBRARY}")
ELSE () ELSE ()
......
...@@ -7,13 +7,6 @@ ...@@ -7,13 +7,6 @@
######################################################################## ########################################################################
IF (NEKTAR_BUILD_PYTHON) IF (NEKTAR_BUILD_PYTHON)
# Find Python
FIND_PACKAGE(PythonInterp REQUIRED)
FIND_PACKAGE(PythonLibsNew REQUIRED)
INCLUDE_DIRECTORIES(SYSTEM ${PYTHON_INCLUDE_DIRS})
# Include headers from root directory for config file.
# Try to find Boost.NumPy # Try to find Boost.NumPy
FIND_LIBRARY(BOOST_NUMPY_LIB boost_numpy PATHS ${Boost_LIBRARY_DIRS}) FIND_LIBRARY(BOOST_NUMPY_LIB boost_numpy PATHS ${Boost_LIBRARY_DIRS})
...@@ -31,7 +24,9 @@ IF (NEKTAR_BUILD_PYTHON) ...@@ -31,7 +24,9 @@ IF (NEKTAR_BUILD_PYTHON)
TMP_DIR ${TPBUILD}/boost-numpy-tmp TMP_DIR ${TPBUILD}/boost-numpy-tmp
INSTALL_DIR ${TPDIST} INSTALL_DIR ${TPDIST}
CONFIGURE_COMMAND ${CMAKE_COMMAND} CONFIGURE_COMMAND ${CMAKE_COMMAND}
-G ${CMAKE_GENERATOR} -DCMAKE_INSTALL_PREFIX:PATH=${TPDIST} -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DLIBRARY_TYPE=STATIC -G ${CMAKE_GENERATOR} -DCMAKE_INSTALL_PREFIX:PATH=${TPDIST}
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
-DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DLIBRARY_TYPE=STATIC
${TPSRC}/boost-numpy ${TPSRC}/boost-numpy
) )
......
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