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

Add buildsystem support for Python 3

parent 690dfafb
......@@ -210,6 +210,22 @@ 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_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 (NektarCommon)
......
......@@ -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.
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)
IF (NEKTAR_BUILD_PYTHON)
SET(NEEDED_BOOST_LIBS ${NEEDED_BOOST_LIBS} python)
ENDIF()
SET(Boost_DEBUG 0)
SET(Boost_NO_BOOST_CMAKE ON)
IF( BOOST_ROOT )
SET(Boost_NO_SYSTEM_PATHS ON)
FIND_PACKAGE( Boost ${MIN_VER} 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()
# 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} 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)
break()
ENDIF()
ENDFOREACH()
ELSE()
NektarFindBoost()
ENDIF()
# Check what we found and determine if we need to build boost
FOREACH(FOUND_VAR ${NEEDED_BOOST_LIBS})
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: "
"${Boost_${FOUND_VAR_UPPER}_LIBRARY}")
ELSE ()
......
......@@ -7,13 +7,6 @@
########################################################################
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
FIND_LIBRARY(BOOST_NUMPY_LIB boost_numpy PATHS ${Boost_LIBRARY_DIRS})
......@@ -31,7 +24,9 @@ IF (NEKTAR_BUILD_PYTHON)
TMP_DIR ${TPBUILD}/boost-numpy-tmp
INSTALL_DIR ${TPDIST}
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
)
......
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