Skip to content

Commit

Permalink
[cmake] Link to specific boost libs.
Browse files Browse the repository at this point in the history
  • Loading branch information
bilke committed Oct 1, 2024
1 parent f03c767 commit 9812ed8
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 36 deletions.
1 change: 1 addition & 0 deletions Applications/FileIO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ target_link_libraries(
$<$<BOOL:${OGS_BUILD_GUI}>:QtBase>
$<$<TARGET_EXISTS:shp>:shp>
$<$<TARGET_EXISTS:SwmmInterface>:SwmmInterface>
Boost::dynamic_bitset
PRIVATE MeshLib MeshToolsLib GitInfoLib
)

Expand Down
3 changes: 2 additions & 1 deletion BaseLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
$<$<BOOL:${MSVC}>:WinMM> # needed for timeGetTime
Expand Down
2 changes: 1 addition & 1 deletion MaterialLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions MaterialLib/FractureModels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
10 changes: 6 additions & 4 deletions MaterialLib/SolidModels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -14,5 +14,7 @@ if(OGS_USE_MFRONT)
)
endif()

target_precompile_headers(MaterialLib_SolidModels PRIVATE [["BaseLib/Error.h"]]
[["BaseLib/ConfigTree.h"]] [["BaseLib/Logging.h"]] <Eigen/Core>)
target_precompile_headers(
MaterialLib_SolidModels PRIVATE [["BaseLib/Error.h"]]
[["BaseLib/ConfigTree.h"]] [["BaseLib/Logging.h"]] <Eigen/Core>
)
3 changes: 1 addition & 2 deletions MaterialLib/SolidModels/MFront/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions NumLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<$<TARGET_EXISTS:petsc>:petsc>
Boost::headers
NumLib PUBLIC BaseLib GeoLib MathLib MeshLib
$<$<TARGET_EXISTS:petsc>:petsc>
)

target_precompile_headers(
Expand Down
33 changes: 16 additions & 17 deletions ProcessLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -46,17 +47,15 @@ add_subdirectory(BoundaryConditionAndSourceTerm/Python)

target_link_libraries(
ProcessLib
PUBLIC
BaseLib
MaterialLib
MathLib
MeshGeoToolsLib
MeshLib
NumLib
Boost::headers
range-v3
$<$<TARGET_EXISTS:petsc>:petsc>
ProcessLibBoundaryConditionAndSourceTermPython
PUBLIC BaseLib
MaterialLib
MathLib
MeshGeoToolsLib
MeshLib
NumLib
range-v3
$<$<TARGET_EXISTS:petsc>:petsc>
ProcessLibBoundaryConditionAndSourceTermPython
PRIVATE ParameterLib GitInfoLib $<$<TARGET_EXISTS:InSituLib>:InSituLib>
)

Expand Down
2 changes: 1 addition & 1 deletion ProcessLib/LIE/Common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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?
$<$<TARGET_EXISTS:LIE>:LIE>
$<$<TARGET_EXISTS:TH2M>:TH2M>
$<$<AND:$<BOOL:${OGS_USE_PETSC}>,$<TARGET_EXISTS:MPI::MPI_CXX>>:MPI::MPI_CXX>
Expand Down
2 changes: 1 addition & 1 deletion Tests/xdmfdiff/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 $<TARGET_FILE:xdmfdiff> DESTINATION bin)
22 changes: 16 additions & 6 deletions scripts/cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 9812ed8

Please sign in to comment.