diff --git a/CMakeLists.txt b/CMakeLists.txt index cb25314f4303b06d9d01d6ba162fbaf3ae9281c2..70fbc0a2daf406bd74d2dabe25386a6824203802 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,6 +81,7 @@ option(DD4HEP_LOAD_ASSIMP "Download and build ASSIMP from github" option(BUILD_TESTING "Enable and build tests" ON) option(BUILD_SHARED_LIBS "If OFF build STATIC Libraries" ON) option(DD4HEP_SET_RPATH "Link libraries with built-in RPATH (run-time search path)" ON) +option(DD4HEP_RELAX_PYVER "Do not require exact python version match with ROOT" OFF) SET(DD4HEP_BUILD_PACKAGES "DDRec DDDetectors DDCond DDAlign DDCAD DDDigi DDG4 DDEve UtilityApps" CACHE STRING "List of DD4hep packages to build") diff --git a/cmake/DD4hepBuild.cmake b/cmake/DD4hepBuild.cmake index 3d5d4bd8f3be725df8286d64705634c5c83ed6a3..20d08880c8b5772b80bb5b3ec38bd4bddb3b366e 100644 --- a/cmake/DD4hepBuild.cmake +++ b/cmake/DD4hepBuild.cmake @@ -686,9 +686,22 @@ macro(DD4HEP_SETUP_ROOT_TARGETS) SET(REQUIRE_PYTHON_VERSION ${ROOT_PYTHON_VERSION}) ENDIF() dd4hep_debug("D++> Python version used for building ROOT ${ROOT_PYTHON_VERSION}" ) - dd4hep_debug("D++> Required python version ${REQUIRE_PYTHON_VERSION}") - FIND_PACKAGE(Python ${REQUIRE_PYTHON_VERSION} EXACT REQUIRED COMPONENTS Development) - FIND_PACKAGE(Python ${REQUIRE_PYTHON_VERSION} EXACT QUIET COMPONENTS Interpreter) + if (NOT DD4HEP_RELAX_PYVER) + dd4hep_debug("D++> Required python version ${REQUIRE_PYTHON_VERSION}") + FIND_PACKAGE(Python ${REQUIRE_PYTHON_VERSION} EXACT REQUIRED COMPONENTS Development) + FIND_PACKAGE(Python ${REQUIRE_PYTHON_VERSION} EXACT QUIET COMPONENTS Interpreter) + else() + FIND_PACKAGE(Python REQUIRED COMPONENTS Development) + FIND_PACKAGE(Python QUIET COMPONENTS Interpreter) + dd4hep_debug("D++> Found python version ${Python_VERSION}") + string(REPLACE "." ";" _root_pyver_tuple ${REQUIRE_PYTHON_VERSION}) + list(GET _root_pyver_tuple 0 _root_pyver_major) + list(GET _root_pyver_tuple 1 _root_pyver_minor) + if (NOT "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}" VERSION_EQUAL "${_root_pyver_major}.${_root_pyver_minor}") + dd4hep_print("WARNING: Mismatch in Python version: ${Python_VERSION} vs. ${REQUIRE_PYTHON_VERSION}") + dd4hep_print(" ABI compatibility should not be assumed!") + endif() + endif() ELSE() FIND_PACKAGE(Python COMPONENTS Development) FIND_PACKAGE(Python QUIET COMPONENTS Interpreter)