From 458ba5a61e219de6be326ed77916eeaa6e1fd32b Mon Sep 17 00:00:00 2001 From: Markus Frank <Markus.Frank@cern.ch> Date: Wed, 25 Aug 2021 15:39:09 +0200 Subject: [PATCH] Fix CMakeLists.txt to pick python executable from rather than invoking directly python --- DDTest/CMakeLists.txt | 2 +- cmake/DD4hepBuild.cmake | 9 ++++++++- examples/CLICSiD/CMakeLists.txt | 2 +- examples/ClientTests/CMakeLists.txt | 2 +- examples/DDCMS/CMakeLists.txt | 2 +- examples/DDDigi/CMakeLists.txt | 2 +- examples/DDG4/CMakeLists.txt | 2 +- examples/DDG4_MySensDet/CMakeLists.txt | 2 +- examples/LHeD/CMakeLists.txt | 2 +- examples/Persistency/CMakeLists.txt | 2 +- 10 files changed, 17 insertions(+), 10 deletions(-) diff --git a/DDTest/CMakeLists.txt b/DDTest/CMakeLists.txt index f2fef37f8..bd3d7e2d2 100644 --- a/DDTest/CMakeLists.txt +++ b/DDTest/CMakeLists.txt @@ -12,7 +12,7 @@ add_library(DDTest INTERFACE) add_library(DD4hep::DDTest ALIAS DDTest) -find_package(Python REQUIRED COMPONENTS Interpreter) +dd4hep_use_python_executable() target_include_directories(DDTest INTERFACE include) foreach(TEST_NAME diff --git a/cmake/DD4hepBuild.cmake b/cmake/DD4hepBuild.cmake index 6a2ddde95..b09d0b52f 100644 --- a/cmake/DD4hepBuild.cmake +++ b/cmake/DD4hepBuild.cmake @@ -23,7 +23,14 @@ set ( DD4hepBuild_included ON ) macro(dd4hep_to_parent_scope val) set ( ${val} ${${val}} PARENT_SCOPE ) endmacro(dd4hep_to_parent_scope) - +#--------------------------------------------------------------------------------------------------- +macro(dd4hep_use_python_executable) + find_package(Python) + if("${Python_EXECUTABLE}" STREQUAL "") + set (Python_EXECUTABLE python) + endif() + dd4hep_print("|++> Using python executable: ${Python_EXECUTABLE}") +endmacro(dd4hep_use_python_executable) #--------------------------------------------------------------------------------------------------- # MACRO: dd4hep_set_compiler_flags # diff --git a/examples/CLICSiD/CMakeLists.txt b/examples/CLICSiD/CMakeLists.txt index ed6128fd3..11d89bc07 100644 --- a/examples/CLICSiD/CMakeLists.txt +++ b/examples/CLICSiD/CMakeLists.txt @@ -18,7 +18,7 @@ IF(NOT TARGET DD4hep::DDCore) ENDIF() dd4hep_set_compiler_flags() -find_package(Python REQUIRED COMPONENTS Interpreter) +dd4hep_use_python_executable() #========================================================================== set(CLICSiDEx_INSTALL ${CMAKE_INSTALL_PREFIX}/examples/CLICSiD) diff --git a/examples/ClientTests/CMakeLists.txt b/examples/ClientTests/CMakeLists.txt index e4897fbe7..f04b649db 100644 --- a/examples/ClientTests/CMakeLists.txt +++ b/examples/ClientTests/CMakeLists.txt @@ -18,7 +18,7 @@ IF(NOT TARGET DD4hep::DDCore) ENDIF() dd4hep_set_compiler_flags() -find_package(Python REQUIRED COMPONENTS Interpreter) +dd4hep_use_python_executable() #========================================================================== if(TARGET XercesC::XercesC) SET(OPT_XERCESC XercesC::XercesC) diff --git a/examples/DDCMS/CMakeLists.txt b/examples/DDCMS/CMakeLists.txt index 4cad85088..873f493bd 100644 --- a/examples/DDCMS/CMakeLists.txt +++ b/examples/DDCMS/CMakeLists.txt @@ -22,7 +22,7 @@ IF(NOT TARGET DD4hep::DDCore) ENDIF() dd4hep_set_compiler_flags() -find_package(Python REQUIRED COMPONENTS Interpreter) +dd4hep_use_python_executable() #========================================================================== # CLHEP dependent stuff if(NOT TARGET CLHEP::CLHEP) diff --git a/examples/DDDigi/CMakeLists.txt b/examples/DDDigi/CMakeLists.txt index 974a1b664..4211aafed 100644 --- a/examples/DDDigi/CMakeLists.txt +++ b/examples/DDDigi/CMakeLists.txt @@ -18,7 +18,7 @@ IF(NOT TARGET DD4hep::DDCore) ENDIF() dd4hep_set_compiler_flags() -find_package(Python REQUIRED COMPONENTS Interpreter) +dd4hep_use_python_executable() #========================================================================== dd4hep_configure_output () diff --git a/examples/DDG4/CMakeLists.txt b/examples/DDG4/CMakeLists.txt index 26372512c..663de1ef2 100644 --- a/examples/DDG4/CMakeLists.txt +++ b/examples/DDG4/CMakeLists.txt @@ -18,7 +18,7 @@ IF(NOT TARGET DD4hep::DDCore) ENDIF() dd4hep_set_compiler_flags() -find_package(Python REQUIRED COMPONENTS Interpreter) +dd4hep_use_python_executable() #========================================================================== set(DDG4examples_INSTALL ${CMAKE_INSTALL_PREFIX}/examples/DDG4) diff --git a/examples/DDG4_MySensDet/CMakeLists.txt b/examples/DDG4_MySensDet/CMakeLists.txt index c894a0424..bfd22f520 100644 --- a/examples/DDG4_MySensDet/CMakeLists.txt +++ b/examples/DDG4_MySensDet/CMakeLists.txt @@ -18,7 +18,7 @@ IF(NOT TARGET DD4hep::DDCore) ENDIF() dd4hep_set_compiler_flags() -find_package(Python REQUIRED COMPONENTS Interpreter) +dd4hep_use_python_executable() #========================================================================== if(NOT TARGET Geant4::Interface) dd4hep_print("Not creating DDG4_MySensDet tests") diff --git a/examples/LHeD/CMakeLists.txt b/examples/LHeD/CMakeLists.txt index 6ccb786f5..e30e22997 100644 --- a/examples/LHeD/CMakeLists.txt +++ b/examples/LHeD/CMakeLists.txt @@ -18,7 +18,7 @@ IF(NOT TARGET DD4hep::DDCore) ENDIF() dd4hep_set_compiler_flags() -find_package(Python REQUIRED COMPONENTS Interpreter) +dd4hep_use_python_executable() #========================================================================== set(LHeDEx_INSTALL ${CMAKE_INSTALL_PREFIX}/examples/LHeD) dd4hep_install_dir( src compact scripts sim DESTINATION ${LHeDEx_INSTALL} ) diff --git a/examples/Persistency/CMakeLists.txt b/examples/Persistency/CMakeLists.txt index 6e6f3f120..67b35b051 100644 --- a/examples/Persistency/CMakeLists.txt +++ b/examples/Persistency/CMakeLists.txt @@ -18,7 +18,7 @@ IF(NOT TARGET DD4hep::DDCore) ENDIF() dd4hep_set_compiler_flags() -find_package(Python REQUIRED COMPONENTS Interpreter) +dd4hep_use_python_executable() #========================================================================== if(TARGET XercesC::XercesC) SET(OPT_XERCESC XercesC::XercesC) -- GitLab