From eb9e9d15ed977757cabea37fbcbdee727d88341b Mon Sep 17 00:00:00 2001 From: Lars Bilke Date: Mon, 30 Sep 2024 11:34:40 +0200 Subject: [PATCH 1/4] [cmake] Update Boost to 1.82 Uses full sources instead of subset. Download is 90 MB. --- CMakeLists.txt | 3 +++ scripts/cmake/Dependencies.cmake | 22 +++++++++------------- web/data/versions.json | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 80d05d50a73..8f60568c8cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,9 @@ cmake_minimum_required(VERSION 3.22) if(CMAKE_VERSION GREATER_EQUAL 3.29) cmake_policy(SET CMP0156 NEW) endif() +if(CMAKE_VERSION GREATER_EQUAL 3.30) + cmake_policy(SET CMP0167 NEW) +endif() project(OGS-6) diff --git a/scripts/cmake/Dependencies.cmake b/scripts/cmake/Dependencies.cmake index f63dafc6b6a..814ddc9d15a 100644 --- a/scripts/cmake/Dependencies.cmake +++ b/scripts/cmake/Dependencies.cmake @@ -190,20 +190,16 @@ if(OGS_USE_MFRONT) endif() endif() -CPMFindPackage( - NAME Boost - VERSION ${ogs.minimum_version.boost} - URL https://gitlab.opengeosys.org/ogs/libs/boost-subset/-/jobs/303158/artifacts/raw/ogs-boost-${ogs.minimum_version.boost}.tar.gz - SYSTEM TRUE -) -if(Boost_ADDED) - add_library(Boost::boost INTERFACE IMPORTED) - target_include_directories( - Boost::boost SYSTEM INTERFACE "${Boost_SOURCE_DIR}" - ) +if(GUIX_BUILD) + find_package(Boost REQUIRED) else() - target_include_directories( - Boost::boost SYSTEM INTERFACE "${Boost_INCLUDE_DIR}" + CPMFindPackage( + NAME Boost + VERSION ${ogs.minimum_version.boost} + URL https://github.com/boostorg/boost/releases/download/boost-${ogs.minimum_version.boost}/boost-${ogs.minimum_version.boost}.tar.xz + OPTIONS + "BOOST_ENABLE_CMAKE ON" + "BOOST_INCLUDE_LIBRARIES algorithm\\\;math\\\;multi_index\\\;property_tree\\\;smart_ptr" ) endif() diff --git a/web/data/versions.json b/web/data/versions.json index f19856d7b2a..aad89748c01 100644 --- a/web/data/versions.json +++ b/web/data/versions.json @@ -12,7 +12,7 @@ "git": "2.14", "cmake": "3.22", "hugo": "0.122.0", - "boost": "1.73.0", + "boost": "1.82.0", "eigen": "3.4.0", "eigen-unsupported": "9000b3767770f6dd0f4cfb12f4e19c71921885a4", "vtk": "9.3.0", From f03c767f09ef0360640039c7c09822d965374c87 Mon Sep 17 00:00:00 2001 From: Lars Bilke Date: Mon, 30 Sep 2024 11:36:27 +0200 Subject: [PATCH 2/4] [cmake] Link to Boost::headers instead of Boost::boost. headers are header-only libs, boost are compiled libs. --- BaseLib/CMakeLists.txt | 2 +- MaterialLib/CMakeLists.txt | 2 +- MaterialLib/SolidModels/MFront/CMakeLists.txt | 2 +- NumLib/CMakeLists.txt | 2 +- ProcessLib/CMakeLists.txt | 2 +- Tests/CMakeLists.txt | 2 +- scripts/cmake/CheckHeaderCompilation.cmake | 2 +- scripts/cmake/Dependencies.cmake | 5 +++-- 8 files changed, 10 insertions(+), 9 deletions(-) diff --git a/BaseLib/CMakeLists.txt b/BaseLib/CMakeLists.txt index 019bb739d23..71664c7801a 100644 --- a/BaseLib/CMakeLists.txt +++ b/BaseLib/CMakeLists.txt @@ -10,7 +10,7 @@ ogs_add_library(BaseLib GENERATE_EXPORT_HEADER ${SOURCES}) target_link_libraries( BaseLib - PUBLIC Boost::boost + PUBLIC Boost::headers spdlog tclap $<$:WinMM> # needed for timeGetTime diff --git a/MaterialLib/CMakeLists.txt b/MaterialLib/CMakeLists.txt index 7afb9705495..5f33d7bdf7e 100644 --- a/MaterialLib/CMakeLists.txt +++ b/MaterialLib/CMakeLists.txt @@ -38,7 +38,7 @@ ogs_add_library(MaterialLib GENERATE_EXPORT_HEADER ${SOURCES}) target_link_libraries( MaterialLib PUBLIC BaseLib Eigen3::Eigen MaterialLib_SolidModels MaterialLib_FractureModels - PRIVATE MathLib MeshLib ParameterLib exprtk Boost::boost + PRIVATE MathLib MeshLib ParameterLib exprtk Boost::headers ) target_precompile_headers( diff --git a/MaterialLib/SolidModels/MFront/CMakeLists.txt b/MaterialLib/SolidModels/MFront/CMakeLists.txt index d93dc977159..0c6ec6c4138 100644 --- a/MaterialLib/SolidModels/MFront/CMakeLists.txt +++ b/MaterialLib/SolidModels/MFront/CMakeLists.txt @@ -13,7 +13,7 @@ ogs_add_library(MaterialLib_SolidModels_MFront ${SOURCES}) target_link_libraries( MaterialLib_SolidModels_MFront PUBLIC BaseLib NumLib MFrontGenericInterface - Boost::boost PRIVATE MathLib MeshLib + Boost::headers PRIVATE MathLib MeshLib ParameterLib ) target_include_directories( diff --git a/NumLib/CMakeLists.txt b/NumLib/CMakeLists.txt index 6974ec44b62..d41f389d485 100644 --- a/NumLib/CMakeLists.txt +++ b/NumLib/CMakeLists.txt @@ -20,7 +20,7 @@ set_target_properties(NumLib PROPERTIES LINKER_LANGUAGE CXX) target_link_libraries( NumLib PUBLIC BaseLib GeoLib MathLib MeshLib $<$:petsc> - Boost::boost + Boost::headers ) target_precompile_headers( diff --git a/ProcessLib/CMakeLists.txt b/ProcessLib/CMakeLists.txt index e6a88815419..44a70eb8b16 100644 --- a/ProcessLib/CMakeLists.txt +++ b/ProcessLib/CMakeLists.txt @@ -53,7 +53,7 @@ target_link_libraries( MeshGeoToolsLib MeshLib NumLib - Boost::boost + Boost::headers range-v3 $<$:petsc> ProcessLibBoundaryConditionAndSourceTermPython diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index eb6363d6c8a..61d5503cddf 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -112,7 +112,7 @@ target_link_libraries( TestInfoLib VTK::FiltersGeneral VTK::FiltersSources - Boost::boost # TODO move OGSMFrontThermodynamicForcesView to MathLib? + Boost::headers # TODO move OGSMFrontThermodynamicForcesView to MathLib? $<$:LIE> $<$:TH2M> $<$,$>:MPI::MPI_CXX> diff --git a/scripts/cmake/CheckHeaderCompilation.cmake b/scripts/cmake/CheckHeaderCompilation.cmake index 07773fbbf56..377ca95b451 100644 --- a/scripts/cmake/CheckHeaderCompilation.cmake +++ b/scripts/cmake/CheckHeaderCompilation.cmake @@ -40,7 +40,7 @@ function(_check_header_compilation target) lib ${LINK_LIBS} spdlog::spdlog - Boost::boost + Boost::headers Eigen3::Eigen nlohmann_json::nlohmann_json range-v3 diff --git a/scripts/cmake/Dependencies.cmake b/scripts/cmake/Dependencies.cmake index 814ddc9d15a..20df3a23449 100644 --- a/scripts/cmake/Dependencies.cmake +++ b/scripts/cmake/Dependencies.cmake @@ -402,14 +402,15 @@ if((OGS_BUILD_TESTING OR OGS_BUILD_UTILS) AND NOT GUIX_BUILD) OgsXdmf SYSTEM PUBLIC ${xdmf_SOURCE_DIR} ${xdmf_BINARY_DIR} ) - target_link_libraries(OgsXdmf Boost::boost) + target_link_libraries(OgsXdmf Boost::headers) target_include_directories( OgsXdmfCore SYSTEM PUBLIC ${xdmf_SOURCE_DIR}/core ${xdmf_BINARY_DIR}/core PRIVATE ${xdmf_SOURCE_DIR}/CMake/VersionSuite ) target_link_libraries( - OgsXdmfCore PUBLIC Boost::boost LibXml2::LibXml2 ${HDF5_LIBRARIES} + OgsXdmfCore PUBLIC Boost::headers LibXml2::LibXml2 + ${HDF5_LIBRARIES} ) set_target_properties( From 9812ed8237a8e52215eb8d579690a19f2b1efb38 Mon Sep 17 00:00:00 2001 From: Lars Bilke Date: Mon, 30 Sep 2024 15:48:50 +0200 Subject: [PATCH 3/4] [cmake] Link to specific boost libs. See https://github.com/boostorg/cmake/issues/45#issuecomment-1815570996. --- Applications/FileIO/CMakeLists.txt | 1 + BaseLib/CMakeLists.txt | 3 +- MaterialLib/CMakeLists.txt | 2 +- MaterialLib/FractureModels/CMakeLists.txt | 1 + MaterialLib/SolidModels/CMakeLists.txt | 10 +++--- MaterialLib/SolidModels/MFront/CMakeLists.txt | 3 +- NumLib/CMakeLists.txt | 4 +-- ProcessLib/CMakeLists.txt | 33 +++++++++---------- ProcessLib/LIE/Common/CMakeLists.txt | 2 +- Tests/CMakeLists.txt | 2 +- Tests/xdmfdiff/CMakeLists.txt | 2 +- scripts/cmake/Dependencies.cmake | 22 +++++++++---- 12 files changed, 49 insertions(+), 36 deletions(-) diff --git a/Applications/FileIO/CMakeLists.txt b/Applications/FileIO/CMakeLists.txt index fc14b9dfd9f..1f4b9ebe84f 100644 --- a/Applications/FileIO/CMakeLists.txt +++ b/Applications/FileIO/CMakeLists.txt @@ -32,6 +32,7 @@ target_link_libraries( $<$:QtBase> $<$:shp> $<$:SwmmInterface> + Boost::dynamic_bitset PRIVATE MeshLib MeshToolsLib GitInfoLib ) diff --git a/BaseLib/CMakeLists.txt b/BaseLib/CMakeLists.txt index 71664c7801a..de9b42964c1 100644 --- a/BaseLib/CMakeLists.txt +++ b/BaseLib/CMakeLists.txt @@ -10,7 +10,8 @@ ogs_add_library(BaseLib GENERATE_EXPORT_HEADER ${SOURCES}) target_link_libraries( BaseLib - PUBLIC Boost::headers + PUBLIC Boost::algorithm + Boost::property_tree spdlog tclap $<$:WinMM> # needed for timeGetTime diff --git a/MaterialLib/CMakeLists.txt b/MaterialLib/CMakeLists.txt index 5f33d7bdf7e..c870201ece9 100644 --- a/MaterialLib/CMakeLists.txt +++ b/MaterialLib/CMakeLists.txt @@ -38,7 +38,7 @@ ogs_add_library(MaterialLib GENERATE_EXPORT_HEADER ${SOURCES}) target_link_libraries( MaterialLib PUBLIC BaseLib Eigen3::Eigen MaterialLib_SolidModels MaterialLib_FractureModels - PRIVATE MathLib MeshLib ParameterLib exprtk Boost::headers + PRIVATE MathLib MeshLib ParameterLib exprtk Boost::math ) target_precompile_headers( diff --git a/MaterialLib/FractureModels/CMakeLists.txt b/MaterialLib/FractureModels/CMakeLists.txt index ac8fecf84c1..31a6103f501 100644 --- a/MaterialLib/FractureModels/CMakeLists.txt +++ b/MaterialLib/FractureModels/CMakeLists.txt @@ -4,4 +4,5 @@ append_source_files(SOURCES Permeability) ogs_add_library(MaterialLib_FractureModels GENERATE_EXPORT_HEADER ${SOURCES}) target_link_libraries( MaterialLib_FractureModels PUBLIC MathLib PRIVATE ParameterLib NumLib + Boost::math ) diff --git a/MaterialLib/SolidModels/CMakeLists.txt b/MaterialLib/SolidModels/CMakeLists.txt index d4e155ccb3c..c68895b48a1 100644 --- a/MaterialLib/SolidModels/CMakeLists.txt +++ b/MaterialLib/SolidModels/CMakeLists.txt @@ -2,8 +2,8 @@ get_source_files(SOURCES) ogs_add_library(MaterialLib_SolidModels ${SOURCES}) target_link_libraries( - MaterialLib_SolidModels PUBLIC MathLib PRIVATE ParameterLib - NumLib + MaterialLib_SolidModels PUBLIC MathLib Boost::math PRIVATE ParameterLib + NumLib ) if(OGS_USE_MFRONT) @@ -14,5 +14,7 @@ if(OGS_USE_MFRONT) ) endif() -target_precompile_headers(MaterialLib_SolidModels PRIVATE [["BaseLib/Error.h"]] - [["BaseLib/ConfigTree.h"]] [["BaseLib/Logging.h"]] ) +target_precompile_headers( + MaterialLib_SolidModels PRIVATE [["BaseLib/Error.h"]] + [["BaseLib/ConfigTree.h"]] [["BaseLib/Logging.h"]] +) diff --git a/MaterialLib/SolidModels/MFront/CMakeLists.txt b/MaterialLib/SolidModels/MFront/CMakeLists.txt index 0c6ec6c4138..761a4536d23 100644 --- a/MaterialLib/SolidModels/MFront/CMakeLists.txt +++ b/MaterialLib/SolidModels/MFront/CMakeLists.txt @@ -13,8 +13,7 @@ ogs_add_library(MaterialLib_SolidModels_MFront ${SOURCES}) target_link_libraries( MaterialLib_SolidModels_MFront PUBLIC BaseLib NumLib MFrontGenericInterface - Boost::headers PRIVATE MathLib MeshLib - ParameterLib + PRIVATE MathLib MeshLib ParameterLib ) target_include_directories( MaterialLib_SolidModels_MFront PUBLIC ThirdParty/MGIS/include diff --git a/NumLib/CMakeLists.txt b/NumLib/CMakeLists.txt index d41f389d485..8adbf0c68b8 100644 --- a/NumLib/CMakeLists.txt +++ b/NumLib/CMakeLists.txt @@ -19,8 +19,8 @@ ogs_add_library(NumLib GENERATE_EXPORT_HEADER ${SOURCES}) set_target_properties(NumLib PROPERTIES LINKER_LANGUAGE CXX) target_link_libraries( - NumLib PUBLIC BaseLib GeoLib MathLib MeshLib $<$:petsc> - Boost::headers + NumLib PUBLIC BaseLib GeoLib MathLib MeshLib + $<$:petsc> ) target_precompile_headers( diff --git a/ProcessLib/CMakeLists.txt b/ProcessLib/CMakeLists.txt index 44a70eb8b16..0ba3ad42c8a 100644 --- a/ProcessLib/CMakeLists.txt +++ b/ProcessLib/CMakeLists.txt @@ -18,18 +18,19 @@ append_source_files(SOURCES Output) append_source_files(SOURCES Utils) append_source_files(SOURCES Reflection) append_source_files(SOURCES Graph) -### For processes that contains both hydraulical process and mechanical process +# For processes that contains both hydraulical process and mechanical process # Define a function to check if enabled_processes contains LIE, HydroMechanics, # ThermoHydroMechanics, RichardsMechanics, or ThermoRichardsMechanics function(check_enabled_processes contains_hm_process) set(${contains_hm_process} FALSE PARENT_SCOPE) foreach(process ${_enabled_processes}) if(process STREQUAL "LIE" - OR process STREQUAL "HydroMechanics" - OR process STREQUAL "ThermoHydroMechanics" - OR process STREQUAL "RichardsMechanics" - OR process STREQUAL "TH2M" - OR process STREQUAL "ThermoRichardsMechanics") + OR process STREQUAL "HydroMechanics" + OR process STREQUAL "ThermoHydroMechanics" + OR process STREQUAL "RichardsMechanics" + OR process STREQUAL "TH2M" + OR process STREQUAL "ThermoRichardsMechanics" + ) set(${contains_hm_process} TRUE PARENT_SCOPE) return() endif() @@ -46,17 +47,15 @@ add_subdirectory(BoundaryConditionAndSourceTerm/Python) target_link_libraries( ProcessLib - PUBLIC - BaseLib - MaterialLib - MathLib - MeshGeoToolsLib - MeshLib - NumLib - Boost::headers - range-v3 - $<$:petsc> - ProcessLibBoundaryConditionAndSourceTermPython + PUBLIC BaseLib + MaterialLib + MathLib + MeshGeoToolsLib + MeshLib + NumLib + range-v3 + $<$:petsc> + ProcessLibBoundaryConditionAndSourceTermPython PRIVATE ParameterLib GitInfoLib $<$:InSituLib> ) diff --git a/ProcessLib/LIE/Common/CMakeLists.txt b/ProcessLib/LIE/Common/CMakeLists.txt index cd14160f8cf..ebad69a017a 100644 --- a/ProcessLib/LIE/Common/CMakeLists.txt +++ b/ProcessLib/LIE/Common/CMakeLists.txt @@ -1,4 +1,4 @@ get_source_files(SOURCES) ogs_add_library(LIECommon ${SOURCES}) -target_link_libraries(LIECommon PUBLIC MeshLib) +target_link_libraries(LIECommon PUBLIC MeshLib PRIVATE Boost::math) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 61d5503cddf..66b62c62662 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -112,7 +112,7 @@ target_link_libraries( TestInfoLib VTK::FiltersGeneral VTK::FiltersSources - Boost::headers # TODO move OGSMFrontThermodynamicForcesView to MathLib? + Boost::math # TODO move OGSMFrontThermodynamicForcesView to MathLib? $<$:LIE> $<$:TH2M> $<$,$>:MPI::MPI_CXX> diff --git a/Tests/xdmfdiff/CMakeLists.txt b/Tests/xdmfdiff/CMakeLists.txt index 761902f13f4..857cbfe155b 100644 --- a/Tests/xdmfdiff/CMakeLists.txt +++ b/Tests/xdmfdiff/CMakeLists.txt @@ -1,3 +1,3 @@ ogs_add_executable(xdmfdiff xdmfdiff.cpp) -target_link_libraries(xdmfdiff OgsXdmf GitInfoLib tclap) +target_link_libraries(xdmfdiff OgsXdmf GitInfoLib tclap Boost::range) install(PROGRAMS $ DESTINATION bin) diff --git a/scripts/cmake/Dependencies.cmake b/scripts/cmake/Dependencies.cmake index 20df3a23449..cc54682e716 100644 --- a/scripts/cmake/Dependencies.cmake +++ b/scripts/cmake/Dependencies.cmake @@ -193,13 +193,22 @@ endif() if(GUIX_BUILD) find_package(Boost REQUIRED) else() + # Boost libraries used by ogs, can be linked with Boost::[lib_name] + set(BOOST_INCLUDE_LIBRARIES + math + property_tree + algorithm + smart_ptr + tokenizer + assign + dynamic_bitset + range + ) CPMFindPackage( NAME Boost VERSION ${ogs.minimum_version.boost} URL https://github.com/boostorg/boost/releases/download/boost-${ogs.minimum_version.boost}/boost-${ogs.minimum_version.boost}.tar.xz - OPTIONS - "BOOST_ENABLE_CMAKE ON" - "BOOST_INCLUDE_LIBRARIES algorithm\\\;math\\\;multi_index\\\;property_tree\\\;smart_ptr" + OPTIONS "BOOST_ENABLE_CMAKE ON" ) endif() @@ -402,15 +411,16 @@ if((OGS_BUILD_TESTING OR OGS_BUILD_UTILS) AND NOT GUIX_BUILD) OgsXdmf SYSTEM PUBLIC ${xdmf_SOURCE_DIR} ${xdmf_BINARY_DIR} ) - target_link_libraries(OgsXdmf Boost::headers) + target_link_libraries(OgsXdmf Boost::tokenizer) target_include_directories( OgsXdmfCore SYSTEM PUBLIC ${xdmf_SOURCE_DIR}/core ${xdmf_BINARY_DIR}/core PRIVATE ${xdmf_SOURCE_DIR}/CMake/VersionSuite ) target_link_libraries( - OgsXdmfCore PUBLIC Boost::headers LibXml2::LibXml2 - ${HDF5_LIBRARIES} + OgsXdmfCore PUBLIC LibXml2::LibXml2 ${HDF5_LIBRARIES} Boost::variant + Boost::smart_ptr + PRIVATE Boost::tokenizer Boost::assign Boost::algorithm ) set_target_properties( From 1b35e537b09056ec64d04b955a6e8eb481aa6f62 Mon Sep 17 00:00:00 2001 From: Lars Bilke Date: Tue, 1 Oct 2024 08:23:26 +0200 Subject: [PATCH 4/4] [cmake] Fix for system-installed boost. --- scripts/cmake/Dependencies.cmake | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/scripts/cmake/Dependencies.cmake b/scripts/cmake/Dependencies.cmake index cc54682e716..f4d0a3fca08 100644 --- a/scripts/cmake/Dependencies.cmake +++ b/scripts/cmake/Dependencies.cmake @@ -190,20 +190,21 @@ if(OGS_USE_MFRONT) endif() endif() +# Boost libraries used by ogs, can be linked with Boost::[lib_name] +set(BOOST_INCLUDE_LIBRARIES + math + property_tree + algorithm + smart_ptr + tokenizer + assign + dynamic_bitset + range + variant +) if(GUIX_BUILD) find_package(Boost REQUIRED) else() - # Boost libraries used by ogs, can be linked with Boost::[lib_name] - set(BOOST_INCLUDE_LIBRARIES - math - property_tree - algorithm - smart_ptr - tokenizer - assign - dynamic_bitset - range - ) CPMFindPackage( NAME Boost VERSION ${ogs.minimum_version.boost} @@ -211,6 +212,13 @@ else() OPTIONS "BOOST_ENABLE_CMAKE ON" ) endif() +if(NOT Boost_ADDED) + # Boost from system found. There are only Boost::headers and Boost::boost + # targets. + foreach(lib ${BOOST_INCLUDE_LIBRARIES}) + add_library(Boost::${lib} ALIAS Boost::headers) + endforeach() +endif() CPMFindPackage( NAME LibXml2