From 81937e7818c95bc15ce97b5f6b66cfc9b1a95a5c Mon Sep 17 00:00:00 2001 From: vsr Date: Wed, 13 Oct 2021 16:21:13 +0300 Subject: [PATCH] bos #26520 Attempt 2: detecting of boost::python library is not a trivial thing with cmake --- cmake/FindSalomeBoost.cmake | 16 ++++++++++------ cmake/SalomeMacros.cmake | 32 +++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/cmake/FindSalomeBoost.cmake b/cmake/FindSalomeBoost.cmake index 927fe1c..01c71c3 100644 --- a/cmake/FindSalomeBoost.cmake +++ b/cmake/FindSalomeBoost.cmake @@ -23,12 +23,14 @@ # # !! Please read the generic detection procedure in SalomeMacros.cmake !! # -SET(Boost_USE_STATIC_LIBS OFF) -SET(Boost_USE_MULTITHREADED ON) -SET(Boost_USE_STATIC_RUNTIME OFF) -SET(Boost_NO_BOOST_CMAKE ON) -SET(SalomeBoost_COMPONENTS filesystem regex system thread date_time chrono serialization python3) -SET(SalomeBoost_FIND_COMPONENTS ${SalomeBoost_COMPONENTS}) +SET(Boost_USE_STATIC_LIBS OFF) +SET(Boost_USE_MULTITHREADED ON) +SET(Boost_USE_STATIC_RUNTIME OFF) +SET(Boost_NO_BOOST_CMAKE ON) +SET(SalomeBoost_COMPONENTS filesystem regex system thread date_time chrono serialization) +SET(SalomeBoost_FIND_COMPONENTS ${SalomeBoost_COMPONENTS}) +SET(SalomeBoost_OPTIONAL_COMPONENTS python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR} python${PYTHON_VERSION_MAJOR}) +SET(SalomeBoost_FIND_OPTIONAL_COMPONENTS ${SalomeBoost_OPTIONAL_COMPONENTS}) IF(WIN32) # Under windows, one extra sub-directory in the boost installation hierarchy: @@ -41,6 +43,8 @@ IF(Boost_FOUND OR BOOST_FOUND) ENDIF() #MARK_AS_ADVANCED() +SET(Boost_PYTHON_LIBRARY ${Boost_PYTHON${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_LIBRARY} ${Boost_PYTHON${PYTHON_VERSION_MAJOR}_LIBRARY}) + ## Specific definitions: IF(WIN32) SET(BOOST_DEFINITIONS -DBOOST_DISABLE_ASSERTS -DBOOST_ALL_DYN_LINK) diff --git a/cmake/SalomeMacros.cmake b/cmake/SalomeMacros.cmake index 805d05b..e706deb 100644 --- a/cmake/SalomeMacros.cmake +++ b/cmake/SalomeMacros.cmake @@ -424,11 +424,20 @@ MACRO(SALOME_FIND_PACKAGE englobPkg stdPkg mode) # Do we need to call the signature using components? IF(${englobPkg}_FIND_COMPONENTS) - FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact} - NO_MODULE ${_tmp_quiet} ${_tmp_req} COMPONENTS ${${englobPkg}_FIND_COMPONENTS} - PATH_SUFFIXES "salome_adm/cmake_files" "adm_local/cmake_files" "adm/cmake" - NO_CMAKE_BUILDS_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PATH + IF(${englobPkg}_FIND_OPTIONAL_COMPONENTS) + FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact} + NO_MODULE ${_tmp_quiet} ${_tmp_req} COMPONENTS ${${englobPkg}_FIND_COMPONENTS} + OPTIONAL_COMPONENTS ${${englobPkg}_FIND_OPTIONAL_COMPONENTS} + PATH_SUFFIXES "salome_adm/cmake_files" "adm_local/cmake_files" "adm/cmake" + NO_CMAKE_BUILDS_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PATH + NO_SYSTEM_ENVIRONMENT_PATH) + ELSE() + FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact} + NO_MODULE ${_tmp_quiet} ${_tmp_req} COMPONENTS ${${englobPkg}_FIND_COMPONENTS} + PATH_SUFFIXES "salome_adm/cmake_files" "adm_local/cmake_files" "adm/cmake" + NO_CMAKE_BUILDS_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH) + ENDIF() ELSE() FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact} NO_MODULE ${_tmp_quiet} ${_tmp_req} @@ -439,11 +448,17 @@ MACRO(SALOME_FIND_PACKAGE englobPkg stdPkg mode) MARK_AS_ADVANCED(${stdPkg}_DIR) ELSEIF("${mode}" STREQUAL "MODULE") - + # Do we need to call the signature using components? IF(${englobPkg}_FIND_COMPONENTS) - FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact} - MODULE ${_tmp_quiet} ${_tmp_req} COMPONENTS ${${englobPkg}_FIND_COMPONENTS}) + IF(${englobPkg}_FIND_OPTIONAL_COMPONENTS) + FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact} + MODULE ${_tmp_quiet} ${_tmp_req} COMPONENTS ${${englobPkg}_FIND_COMPONENTS} + OPTIONAL_COMPONENTS ${${englobPkg}_FIND_OPTIONAL_COMPONENTS}) + ELSE() + FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact} + MODULE ${_tmp_quiet} ${_tmp_req} COMPONENTS ${${englobPkg}_FIND_COMPONENTS}) + ENDIF() ELSE() FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact} MODULE ${_tmp_quiet} ${_tmp_req}) @@ -1013,6 +1028,7 @@ ENDMACRO(SALOME_APPEND_LIST_OF_LIST) # - _PREREQ_DIR_LIST : their corresponding CMake directories (i.e. where the CMake configuration # file for this package can be found, if there is any!) # - _PREREQ_COMPO_LIST: the list of components requested when this package was invoked +# - _PREREQ_COMPO_OPT_LIST: the list of optional components requested when this package was invoked # # All this information is built from the package_list, the list of level 1 packages for this module. # Only the packages found in CONFIG mode are retained. @@ -1022,12 +1038,14 @@ MACRO(SALOME_CONFIGURE_PREPARE) SET(_PREREQ_LIST) SET(_PREREQ_DIR_LIST) SET(_PREREQ_COMPO_LIST) + SET(_PREREQ_COMPO_OPT_LIST) FOREACH(_prereq IN LISTS _tmp_prereq) IF(${_prereq}_DIR) SET(_PREREQ_LIST "${_PREREQ_LIST} ${_prereq}") FILE(TO_CMAKE_PATH ${${_prereq}_DIR} CURR_DIR) SET(_PREREQ_DIR_LIST "${_PREREQ_DIR_LIST} \"${CURR_DIR}\"") SALOME_APPEND_LIST_OF_LIST(_PREREQ_COMPO_LIST Salome${_prereq}_COMPONENTS) + SALOME_APPEND_LIST_OF_LIST(_PREREQ_COMPO_OPT_LIST Salome${_prereq}_OPTIONAL_COMPONENTS) ENDIF() ENDFOREACH() ENDMACRO(SALOME_CONFIGURE_PREPARE) -- 2.39.2