Skip to content
Snippets Groups Projects
Commit 494405a7 authored by Orgis, Dr. Thomas's avatar Orgis, Dr. Thomas
Browse files

more cmake patchwork

parent 0ba53032
No related branches found
No related tags found
No related merge requests found
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2867d9c..7d41a23 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.0.0)
+cmake_minimum_required(VERSION 3.5.0)
project(lofarbeam)
@@ -65,37 +65,40 @@ elseif(DOXYGEN_FOUND)
endif(DOXYGEN_FOUND)
+# ThOr: This is NOT the modern cmake-included FindPython!
find_package (Python COMPONENTS Development)
+
message("Compiling Python ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} support. If this is not the intended target use 'DPYTHON_EXECUTABLE' to control.")
# bind against boost-python for compilation of the python API
# depending on major release version of the python libraries
-if (${PYTHON_VERSION_MAJOR} VERSION_LESS "3")
- find_package (Boost REQUIRED COMPONENTS python numpy)
- find_package (Casacore REQUIRED COMPONENTS python)
- message(STATUS "Boost python library: ${Boost_PYTHON_LIBRARY}")
- message(STATUS "Boost numpy library: ${Boost_NUMPY_LIBRARY}")
- message(STATUS "Python library ${PYTHON_LIBRARIES}")
- set(BOOST_PY_FOUND TRUE)
-else (${PYTHON_VERSION_MAJOR} VERSION_LESS "3")
- find_package (Boost REQUIRED COMPONENTS python3 numpy3)
- find_package (Casacore REQUIRED COMPONENTS python3)
- message(STATUS "Boost python library: ${Boost_PYTHON3_LIBRARY}")
- message(STATUS "Boost numpy library: ${Boost_NUMPY3_LIBRARY}")
- message(STATUS "Python library ${PYTHON_LIBRARIES}")
- set(BOOST_PY_FOUND TRUE)
-endif (${PYTHON_VERSION_MAJOR} VERSION_LESS "3")
-
-
-if(BOOST_PY_FOUND)
- add_library(_stationresponse MODULE pystationresponse.cc)
- set_target_properties(_stationresponse PROPERTIES PREFIX "")
- target_include_directories(_stationresponse PRIVATE ${PYTHON_INCLUDE_DIR} ${Boost_INCLUDE_DIRS})
- if (${PYTHON_VERSION_MAJOR} VERSION_LESS "3")
- target_link_libraries(_stationresponse stationresponse ${CASA_PYTHON_LIBRARY} ${Boost_PYTHON_LIBRARY} ${Boost_NUMPY_LIBRARY} ${PYTHON_LIBRARIES})
- else (${PYTHON_VERSION_MAJOR} VERSION_LESS "3")
- target_link_libraries(_stationresponse stationresponse ${CASA_PYTHON3_LIBRARY} ${Boost_PYTHON3_LIBRARY} ${Boost_NUMPY3_LIBRARY} ${PYTHON_LIBRARIES})
- endif (${PYTHON_VERSION_MAJOR} VERSION_LESS "3")
- install(TARGETS _stationresponse DESTINATION ${PYTHON_INSTALL_DIR}/lofar/stationresponse)
- install(FILES __init__.py DESTINATION ${PYTHON_INSTALL_DIR}/lofar/stationresponse)
-endif(BOOST_PY_FOUND)
-
+if(${PYTHON_VERSION_MAJOR} VERSION_LESS "3")
+ set(casapy "")
+ set(oldboostpy "")
+else()
+ set(casapy "3")
+ set(oldboostpy "3")
+endif()
+set(boostpy ${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR})
+message("trying boostpy=${boostpy}")
+find_package(Boost 1.67.0 COMPONENTS python${boostpy} numpy${boostpy})
+if(NOT Boost_FOUND)
+ message(STATUS "Falling back to old Boost search.")
+ set(boostpy ${oldboostpy})
+ find_package(Boost REQUIRED COMPONENTS python${boostpy} numpy${boostpy})
+endif()
+find_package (Casacore REQUIRED COMPONENTS python${casapy})
+if(${PYTHON_VERSION_MAJOR} VERSION_LESS "3")
+ set(casapylib ${CASA_PYTHON_LIBRARY})
+else()
+endif()
+
+message(STATUS "Boost python library: ${Boost_PYTHON_LIBRARY}")
+message(STATUS "Boost numpy library: ${Boost_NUMPY_LIBRARY}")
+message(STATUS "Python library ${Python_LIBRARIES}")
+
+add_library(_stationresponse MODULE pystationresponse.cc)
+set_target_properties(_stationresponse PROPERTIES PREFIX "")
+target_include_directories(_stationresponse PRIVATE ${PYTHON_INCLUDE_DIR} ${Boost_INCLUDE_DIRS})
+target_link_libraries(_stationresponse stationresponse ${casapylib} Boost::python${boostpy} Boost::numpy${boostpy} ${PYTHON_LIBRARIES})
+install(TARGETS _stationresponse DESTINATION ${PYTHON_INSTALL_DIR}/lofar/stationresponse)
+install(FILES __init__.py DESTINATION ${PYTHON_INSTALL_DIR}/lofar/stationresponse)
diff --git a/CMakeLists.txt b/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt
index fd1d7c7..37b00ea 100644 index fd1d7c7..777a05e 100644
--- a/CMakeLists.txt --- a/CMakeLists.txt
+++ b/CMakeLists.txt +++ b/CMakeLists.txt
@@ -29,14 +29,22 @@ find_package(PNG REQUIRED) @@ -25,18 +25,35 @@ find_path(GSL_INCLUDE_DIR NAMES gsl/gsl_version.h)
find_package(Threads REQUIRED)
find_package(LibXml2 REQUIRED)
find_package(PNG REQUIRED)
+find_package(Python COMPONENTS Interpreter Development)
+if(NOT Python_FOUND)
+ message(STATUS "Falling back to deprecated Python search.")
+ find_package(PythonInterp REQUIRED)
+ find_package(PythonLibs REQUIRED)
+ set(Python_VERSION ${PYTHON_VERSION_STRING})
+ set(Python_VERSION_MAJOR ${PYTHON_VERSION_MAJOR})
+ set(Python_VERSION_MINOR ${PYTHON_VERSION_MINOR})
+ set(Python_LIBRARIES ${PYTHON_LIBRARIES})
+ set(Python_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS})
+endif()
+message(STATUS "Using python version ${Python_VERSION}")
#Prevent accidentally finding old BoostConfig.cmake file from casapy
set(Boost_NO_BOOST_CMAKE ON) set(Boost_NO_BOOST_CMAKE ON)
#set(PY_VERSION 3) -#set(PY_VERSION 3)
#find_package(PythonLibs ${PY_VERSION} REQUIRED) -#find_package(PythonLibs ${PY_VERSION} REQUIRED)
-find_package(PythonInterp REQUIRED) -find_package(PythonInterp REQUIRED)
+#find_package(PythonInterp REQUIRED) -#find_package(PythonLibs ${PYTHON_VERSION_STRING} REQUIRED)
#find_package(PythonLibs ${PYTHON_VERSION_STRING} REQUIRED)
-find_package(PythonLibs 2.7 REQUIRED) -find_package(PythonLibs 2.7 REQUIRED)
+#find_package(PythonLibs 2.7 REQUIRED) -#message(STATUS "Using python version ${PYTHON_VERSION_STRING}")
+# CMake since 3.12 wants you to use this.
+find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
+set(boostpython python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})
#message(STATUS "Using python version ${PYTHON_VERSION_STRING}")
# At least the intrusive_ref_counter needs Boost 1.55 (because the header was moved) # At least the intrusive_ref_counter needs Boost 1.55 (because the header was moved)
-find_package(Boost 1.55.0 REQUIRED COMPONENTS date_time filesystem python system) -find_package(Boost 1.55.0 REQUIRED COMPONENTS date_time filesystem python system)
+# Bumped to 1.67 to be able to proper python suffix. You may complicate the -#find_package(Boost REQUIRED COMPONENTS date_time filesystem python-py36 system)
+# code again to support older versions, too. +# Bumped to 1.67 to be able to use proper python suffix. One attempt
+find_package(Boost 1.67.0 REQUIRED COMPONENTS date_time filesystem ${boostpython} system) +# to support at least two boost_python naming schemes here.
#find_package(Boost REQUIRED COMPONENTS date_time filesystem python-py36 system) +set(boostpython python${Python_VERSION_MAJOR}${Python_VERSION_MINOR})
+find_package(Boost 1.67.0 COMPONENTS date_time filesystem ${boostpython} system)
+if(NOT Boost_FOUND)
+ message(STATUS "Falling back to old Boost search.")
+ set(boostpython python)
+ find_package(Boost 1.55.0 REQUIRED COMPONENTS date_time filesystem ${boostpython} system)
+endif()
+
find_library(FFTW3_LIB fftw3 REQUIRED) find_library(FFTW3_LIB fftw3 REQUIRED)
+# Not sure if this is needed everywhere, but I get linker +# Not sure if this is needed everywhere, but I get linker
+# errors with missing symbols if not explicitly linking to fftw3_threads. +# errors with missing symbols if not explicitly linking to fftw3_threads.
...@@ -28,17 +46,17 @@ index fd1d7c7..37b00ea 100644 ...@@ -28,17 +46,17 @@ index fd1d7c7..37b00ea 100644
enable_language(Fortran OPTIONAL) enable_language(Fortran OPTIONAL)
find_package(BLAS REQUIRED) find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED) find_package(LAPACK REQUIRED)
@@ -53,7 +61,7 @@ include_directories(${FFTW3_INCLUDE_DIR}) @@ -53,7 +70,7 @@ include_directories(${FFTW3_INCLUDE_DIR})
if(GSL_INCLUDE_DIR) if(GSL_INCLUDE_DIR)
include_directories(${GSL_INCLUDE_DIR}) include_directories(${GSL_INCLUDE_DIR})
endif(GSL_INCLUDE_DIR) endif(GSL_INCLUDE_DIR)
-include_directories(${PYTHON_INCLUDE_DIRS}) -include_directories(${PYTHON_INCLUDE_DIRS})
+include_directories(${Python3_INCLUDE_DIRS}) +include_directories(${Python_INCLUDE_DIRS})
# The following stuff will set the "rpath" correctly, so that # The following stuff will set the "rpath" correctly, so that
# LD_LIBRARY_PATH doesn't have to be set. # LD_LIBRARY_PATH doesn't have to be set.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4a36e1c..be7fdcf 100644 index 4a36e1c..55713b2 100644
--- a/src/CMakeLists.txt --- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt +++ b/src/CMakeLists.txt
@@ -235,17 +235,17 @@ set(PYTHON_FILES @@ -235,17 +235,17 @@ set(PYTHON_FILES
...@@ -61,7 +79,7 @@ index 4a36e1c..be7fdcf 100644 ...@@ -61,7 +79,7 @@ index 4a36e1c..be7fdcf 100644
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_THREAD_LIBS_INIT}
${PNG_LIBRARIES} ${LIBXML2_LIBRARIES} ${PNG_LIBRARIES} ${LIBXML2_LIBRARIES}
- ${PYTHON_LIBRARIES}) - ${PYTHON_LIBRARIES})
+ ${Python3_LIBRARIES}) + ${Python_LIBRARIES})
if(GTKMM_FOUND) if(GTKMM_FOUND)
message(STATUS "GTKMM found.") message(STATUS "GTKMM found.")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment