From 855142cabf77131ffbe8124c544dca085bacffde Mon Sep 17 00:00:00 2001 From: Andre Sailer <andre.philippe.sailer@cern.ch> Date: Mon, 19 Oct 2020 14:07:36 +0200 Subject: [PATCH] [CMAKE]: use the same python as root, if root has pyroot --- .github/scripts/compile_and_test.sh | 4 +++- CMakeLists.txt | 5 ----- cmake/DD4hepBuild.cmake | 16 ++++++++-------- cmake/DD4hepConfig.cmake.in | 2 -- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/.github/scripts/compile_and_test.sh b/.github/scripts/compile_and_test.sh index 7f850b330..d8be0c2d9 100755 --- a/.github/scripts/compile_and_test.sh +++ b/.github/scripts/compile_and_test.sh @@ -33,7 +33,9 @@ ctest --output-on-failure -j4 && \ cd ../examples/ && \ mkdir build && \ cd build && \ -cmake -GNinja -DBoost_NO_BOOST_CMAKE=ON -DCMAKE_CXX_STANDARD=${STANDARD} .. && \ +cmake -GNinja \ + -DBoost_NO_BOOST_CMAKE=ON \ + -DCMAKE_CXX_STANDARD=${STANDARD} .. && \ ninja && \ ninja install && \ ctest --output-on-failure -j2 diff --git a/CMakeLists.txt b/CMakeLists.txt index e57171acc..18948d7a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,11 +118,6 @@ dd4hep_configure_output( OUTPUT "${PROJECT_BINARY_DIR}" INSTALL "${CMAKE_INSTALL # Resolve dependencies # ######################## -# Configure Python -set(Python_FIND_FRAMEWORK LAST) -find_package(Python COMPONENTS Development) -set(DD4HEP_PYTHON_INSTALL_DIR lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages) - # Configure ROOT find_package (ROOT 6.08 REQUIRED) DD4HEP_SETUP_ROOT_TARGETS() diff --git a/cmake/DD4hepBuild.cmake b/cmake/DD4hepBuild.cmake index eff65340f..342fc13d3 100644 --- a/cmake/DD4hepBuild.cmake +++ b/cmake/DD4hepBuild.cmake @@ -649,16 +649,16 @@ endfunction(dd4hep_add_plugin) macro(DD4HEP_SETUP_ROOT_TARGETS) #Check if Python version detected matches the version used to build ROOT - IF(${ROOT_VERSION} VERSION_GREATER_EQUAL 6.19) - IF(${ROOT_PYTHON_VERSION} EQUAL ${Python_VERSION}) - dd4hep_debug( "D++> Python version used for building ROOT ${ROOT_PYTHON_VERSION}" ) - ELSE() - dd4hep_print( "Python version used to build ROOT = ${ROOT_PYTHON_VERSION}" ) - dd4hep_print( "Python version detected by CMake to build DD4hep = ${Python_VERSION}" ) - #dd4hep_fatal( "Mismatch between Python version used for building ROOT and Python version detected by CMake" ) - ENDIF() + SET(Python_FIND_FRAMEWORK LAST) + IF((TARGET ROOT::PyROOT OR TARGET ROOT::ROOTTPython) AND ${ROOT_VERSION} VERSION_GREATER_EQUAL 6.19) + dd4hep_debug( "D++> Python version used for building ROOT ${ROOT_PYTHON_VERSION}" ) + FIND_PACKAGE(Python ${ROOT_PYTHON_VERSION} EXACT REQUIRED COMPONENTS Development) + ELSE() + FIND_PACKAGE(Python COMPONENTS Development) ENDIF() + SET(DD4HEP_PYTHON_INSTALL_DIR lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages) + # root python changes target name in 6.22 IF(TARGET ROOT::PyROOT) SET(DD4HEP_ROOT_PYTHON ROOT::PyROOT) diff --git a/cmake/DD4hepConfig.cmake.in b/cmake/DD4hepConfig.cmake.in index 5b6d798db..f1e309c8e 100644 --- a/cmake/DD4hepConfig.cmake.in +++ b/cmake/DD4hepConfig.cmake.in @@ -60,8 +60,6 @@ if(DD4HEP_USE_GEANT4) DD4HEP_SETUP_GEANT4_TARGETS() endif() -FIND_DEPENDENCY(Python COMPONENTS Development) - FIND_DEPENDENCY(ROOT REQUIRED) DD4HEP_SETUP_ROOT_TARGETS() -- GitLab