Skip to content

Commit

Permalink
Fix Boost CMake usage (#194)
Browse files Browse the repository at this point in the history
* Enable Boost policy

* Fix linker errors when using boost from config

* Add changelog

* Request config

* Update 194.md
  • Loading branch information
fsimonis authored Aug 8, 2024
1 parent 1d07437 commit fe77af0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
22 changes: 19 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ set (CMAKE_CXX_STANDARD_REQUIRED YES)
set (CMAKE_CXX_EXTENSIONS NO)
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)

if(POLICY CMP0167)
cmake_policy(SET CMP0167 NEW)
endif()

if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
Expand All @@ -23,7 +27,7 @@ find_package (Threads REQUIRED)

find_package(precice 3.0 REQUIRED)

find_package(Boost 1.71.0 REQUIRED COMPONENTS log log_setup system program_options unit_test_framework)
find_package(Boost 1.71.0 CONFIG REQUIRED COMPONENTS log log_setup system program_options unit_test_framework)

# Initial attempt to find VTK without specifying components (only supported for VTK9)
find_package(VTK QUIET)
Expand Down Expand Up @@ -54,8 +58,14 @@ target_include_directories(precice-aste-run PRIVATE src thirdparty)
target_link_libraries(precice-aste-run
precice::precice
Threads::Threads
Boost::boost
Boost::log
Boost::log_setup
Boost::program_options
Boost::system
Boost::thread
Boost::unit_test_framework
MPI::MPI_CXX
${Boost_LIBRARIES}
${VTK_LIBRARIES}
)

Expand All @@ -71,7 +81,13 @@ endif()
add_executable(test-precice-aste tests/testing.cpp tests/read_test.cpp tests/write_test.cpp src/mesh.cpp src/logger.cpp)
target_include_directories(test-precice-aste PRIVATE src thirdparty)
target_link_libraries(test-precice-aste
${Boost_LIBRARIES}
Boost::boost
Boost::log
Boost::log_setup
Boost::program_options
Boost::system
Boost::thread
Boost::unit_test_framework
MPI::MPI_CXX
${VTK_LIBRARIES}
)
Expand Down
2 changes: 2 additions & 0 deletions changelog-entries/194.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fixed linker errors when FindBoost uses the CMake Config.
- Changed CMake to always find boost using its CMake Config.

0 comments on commit fe77af0

Please sign in to comment.