From 0ba53032a697f6d3fd54284821030c3440c7d911 Mon Sep 17 00:00:00 2001
From: "Dr. Thomas Orgis" <thomas.orgis@uni-hamburg.de>
Date: Mon, 23 Mar 2020 00:18:49 +0100
Subject: [PATCH] aoflagger: better search for Boost+Python, use fftw3_threads
 explicitly

---
 aoflagger-buildfix.patch | 67 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 aoflagger-buildfix.patch

diff --git a/aoflagger-buildfix.patch b/aoflagger-buildfix.patch
new file mode 100644
index 0000000..efdcb36
--- /dev/null
+++ b/aoflagger-buildfix.patch
@@ -0,0 +1,67 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index fd1d7c7..37b00ea 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -29,14 +29,22 @@ find_package(PNG REQUIRED)
+ set(Boost_NO_BOOST_CMAKE ON)
+ #set(PY_VERSION 3)
+ #find_package(PythonLibs ${PY_VERSION} REQUIRED)
+-find_package(PythonInterp REQUIRED)
++#find_package(PythonInterp REQUIRED)
+ #find_package(PythonLibs ${PYTHON_VERSION_STRING} REQUIRED)
+-find_package(PythonLibs 2.7 REQUIRED)
++#find_package(PythonLibs 2.7 REQUIRED)
++# 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)
+-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
++# code again to support older versions, too.
++find_package(Boost 1.67.0 REQUIRED COMPONENTS date_time filesystem ${boostpython} system)
+ #find_package(Boost REQUIRED COMPONENTS date_time filesystem python-py36 system)
+ find_library(FFTW3_LIB fftw3 REQUIRED)
++# Not sure if this is needed everywhere, but I get linker
++# errors with missing symbols if not explicitly linking to fftw3_threads.
++find_library(FFTW3_THREADS_LIB fftw3_threads OPTIONAL)
+ enable_language(Fortran OPTIONAL)
+ find_package(BLAS REQUIRED)
+ find_package(LAPACK REQUIRED)
+@@ -53,7 +61,7 @@ include_directories(${FFTW3_INCLUDE_DIR})
+ if(GSL_INCLUDE_DIR)
+ 	include_directories(${GSL_INCLUDE_DIR})
+ endif(GSL_INCLUDE_DIR)
+-include_directories(${PYTHON_INCLUDE_DIRS})
++include_directories(${Python3_INCLUDE_DIRS})
+ 
+ # The following stuff will set the "rpath" correctly, so that
+ # LD_LIBRARY_PATH doesn't have to be set.
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index 4a36e1c..be7fdcf 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -235,17 +235,17 @@ set(PYTHON_FILES
+ 
+ set(ALL_LIBRARIES
+ 	${BLAS_LIBRARIES} ${LAPACK_LIBRARIES}
+-	${Boost_SYSTEM_LIBRARY}
+-	${Boost_FILESYSTEM_LIBRARY} ${Boost_DATE_TIME_LIBRARY}
+-#	${Boost_PYTHON-PY36_LIBRARIES}
+-	${Boost_PYTHON_LIBRARIES}
+-	${FFTW3_LIB}
++	Boost::system
++	Boost::filesystem
++	Boost::date_time
++	Boost::${boostpython}
++	${FFTW3_THREADS_LIB} ${FFTW3_LIB}
+ 	${CASACORE_LIBRARIES}
+ 	${LAPACK_lapack_LIBRARY}
+ 	${CFITSIO_LIBRARY}
+ 	${CMAKE_THREAD_LIBS_INIT}
+ 	${PNG_LIBRARIES} ${LIBXML2_LIBRARIES}
+-	${PYTHON_LIBRARIES})
++	${Python3_LIBRARIES})
+ 
+ if(GTKMM_FOUND)
+ 	message(STATUS "GTKMM found.") 
-- 
GitLab