From 045e33e06be00bb27a0450f9b751d25034609da0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Offringa?= <offringa@gmail.com> Date: Thu, 28 Jul 2022 11:41:05 +0000 Subject: [PATCH] Improve Python version finding mechanism --- CMakeLists.txt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 89bcbfa3..48ba8d40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.8) +cmake_minimum_required(VERSION 3.12) project(AOFlagger) @@ -49,6 +49,15 @@ if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") endif() endif() +# Python needs to be found before pybind11 to avoid finding different versions +# of python +find_package( + Python + COMPONENTS Interpreter Development + REQUIRED) +message(STATUS "Using python version ${Python_VERSION}") +include_directories(SYSTEM ${Python_INCLUDE_DIRS}) + list(APPEND ExternalSubmoduleDirectories aocommon pybind11) foreach(ExternalSubmodule IN LISTS ExternalSubmoduleDirectories) if(NOT EXISTS ${CMAKE_SOURCE_DIR}/external/${ExternalSubmodule}) @@ -96,10 +105,6 @@ endif(GSL_INCLUDE_DIR) find_package(Threads REQUIRED) find_package(PNG REQUIRED) -find_package(PythonLibs 3 REQUIRED) -find_package(PythonInterp REQUIRED) -message(STATUS "Using python version ${PYTHON_VERSION_STRING}") -include_directories(SYSTEM ${PYTHON_INCLUDE_DIRS}) # boost::alignment requires Boost 1.56 find_package(Boost 1.56.0 REQUIRED COMPONENTS date_time filesystem system @@ -333,7 +338,7 @@ set(ALL_LIBRARIES ${CASACORE_LIBRARIES} ${FFTW3_LIB} ${CFITSIO_LIBRARY} - ${PYTHON_LIBRARIES} + ${Python_LIBRARIES} ${PNG_LIBRARIES} ${LUA_LIBRARIES} ${Boost_LIBRARIES} -- GitLab