Skip to content

Commit f24104b

Browse files
committed
Refactor CMakeLists.txt to remove include_directories for Catch2 and streamline include handling
1 parent f082ea5 commit f24104b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

tests/CMakeLists.txt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# https://github.com/catchorg/Catch2/blob/devel/docs/cmake-integration.md#top
55

66
find_package(Catch2 REQUIRED)
7-
include_directories(${Catch2_INCLUDE_DIRS}) # Add Catch2 include directories
87

98
add_executable(openpfc-tests
109
runtests.cpp
@@ -16,16 +15,28 @@ add_executable(openpfc-tests
1615
test_discrete_field.cpp
1716
test_field_modifier.cpp
1817
test_ic_constant.cpp
18+
test_boundary_conditions.cpp
1919
test_model.cpp
2020
test_multi_index.cpp
2121
test_simulator.cpp
2222
test_time.cpp)
2323

24+
# Link against OpenPFC and Catch2
2425
target_link_libraries(openpfc-tests PRIVATE OpenPFC Catch2::Catch2)
2526

27+
# Attach Catch2 include dirs manually for compile_commands.json
28+
get_target_property(_catch2_include_dirs Catch2::Catch2 INTERFACE_INCLUDE_DIRECTORIES)
29+
message(STATUS "Catch2 includes: ${_catch2_include_dirs}")
30+
target_include_directories(openpfc-tests PRIVATE ${_catch2_include_dirs})
31+
foreach(dir IN LISTS _catch2_include_dirs)
32+
target_compile_options(openpfc-tests PRIVATE "-isystem" "${dir}")
33+
endforeach()
34+
2635
if(OpenPFC_ENABLE_CODE_COVERAGE)
27-
target_compile_options(openpfc-tests PUBLIC --coverage)
28-
target_link_options(openpfc-tests PUBLIC --coverage)
36+
# Enable code coverage if OpenPFC_ENABLE_CODE_COVERAGE is set
37+
message(STATUS "Enabling code coverage for tests")
38+
target_compile_options(openpfc-tests PRIVATE --coverage)
39+
target_link_options(openpfc-tests PRIVATE --coverage)
2940
endif()
3041

3142
# Disable automatic test discovery during the build

0 commit comments

Comments
 (0)