Skip to content

Commit

Permalink
Use object libraries for test fixtures and example helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
mdpiper committed Dec 18, 2024
1 parent 383c9e3 commit 1b15085
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ include(CTest)

include_directories(${CMAKE_Fortran_MODULE_DIRECTORY})

add_library(helpers OBJECT testing_helpers.f90)

function(make_example example_name)
add_test(NAME ${example_name} COMMAND ${example_name} ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(${example_name} ${example_name}.f90 testing_helpers.f90)
add_executable(${example_name} ${example_name}.f90 $<TARGET_OBJECTS:helpers>)
target_link_libraries(${example_name} ${bmi_name})
endfunction(make_example)

Expand Down
4 changes: 3 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ include(CTest)

include_directories(${CMAKE_Fortran_MODULE_DIRECTORY})

add_library(fixtures OBJECT fixtures.f90)

function(make_test test_name)
add_test(NAME ${test_name} COMMAND ${test_name} "${CMAKE_CURRENT_SOURCE_DIR}/sample.cfg")
add_executable(${test_name} ${test_name}.f90 fixtures.f90)
add_executable(${test_name} ${test_name}.f90 $<TARGET_OBJECTS:fixtures>)
target_link_libraries(${test_name} ${bmi_name})
endfunction(make_test)

Expand Down

0 comments on commit 1b15085

Please sign in to comment.