diff --git a/DDTest/CMakeLists.txt b/DDTest/CMakeLists.txt index f2fef37f891ff86bca845982f2445380f1fb4b3c..bd3d7e2d2b5abc91e55d9bddf148c2a1c686f7b8 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 6a2ddde95bf15852a523499428ff700a06c2e26e..b09d0b52f32c9ee054291571820a5520a4b10dc2 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 ed6128fd33b8a66f8e4f1a141d1f4ee724b25abc..11d89bc0771cfabf41c3e8a991af62874475a20c 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 e4897fbe7fae3569b6eed4a12ca3255ba1f95027..f04b649db7b1c0d1fb5e616905c5bbe17c4a5fe6 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 4cad85088b507e3fcc143dcf6422baae003f80cc..873f493bd823e96e1749b101cc546b00c5730379 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 974a1b66494d7639bad70e18263209de53ad94f2..4211aafed8dcb3f6ef29745772ab0b2e21e0d3f9 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 26372512c305233f1f8fd2ee243d45f02c06f759..663de1ef268debd19293658cf665475a8e16795f 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 c894a0424edbe344bcdb5175e23b23e9b6ffc7b9..bfd22f520f396f38215daec79decf02e37410253 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 6ccb786f5fab2243571543b6d1fd9169832fe2e6..e30e22997f5729edb750811d08ba10bcca0dc103 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 6e6f3f120e3c8964e3c5364f272c939209a0a7c1..67b35b0518e09bfd8deeab55143c4296603b228c 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)