Skip to content

Commit

Permalink
Fix gtest linking for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
msimberg committed Apr 9, 2024
1 parent f7d52d6 commit 71eac9d
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions cmake/DLAF_AddTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,16 @@ function(DLAF_addTargetTest test_target_name)

set(IS_AN_MPI_TEST FALSE)
set(IS_AN_PIKA_TEST FALSE)
if(NOT DLAF_ATT_USE_MAIN)
set(_gtest_tgt gtest)
elseif(DLAF_ATT_USE_MAIN STREQUAL PLAIN)
set(_gtest_tgt gtest_main)
if(NOT DLAF_ATT_USE_MAIN OR DLAF_ATT_USE_MAIN STREQUAL PLAIN)

elseif(DLAF_ATT_USE_MAIN STREQUAL PIKA)
set(_gtest_tgt DLAF_gtest_pika_main)
set(IS_AN_PIKA_TEST TRUE)
elseif(DLAF_ATT_USE_MAIN STREQUAL MPI)
set(_gtest_tgt DLAF_gtest_mpi_main)
set(IS_AN_MPI_TEST TRUE)
elseif(DLAF_ATT_USE_MAIN STREQUAL MPIPIKA)
set(_gtest_tgt DLAF_gtest_mpipika_main)
set(IS_AN_MPI_TEST TRUE)
set(IS_AN_PIKA_TEST TRUE)
elseif(DLAF_ATT_USE_MAIN STREQUAL CAPI)
set(_gtest_tgt DLAF_gtest_mpi_main)
set(IS_AN_MPI_TEST TRUE)
else()
message(FATAL_ERROR "USE_MAIN=${DLAF_ATT_USE_MAIN} is not a supported option")
Expand Down Expand Up @@ -241,6 +235,22 @@ function(DLAF_addTest test_target_name)
message(FATAL_ERROR "No sources specified for this test")
endif()

if(NOT DLAF_AT_USE_MAIN)
set(_gtest_tgt gtest)
elseif(DLAF_AT_USE_MAIN STREQUAL PLAIN)
set(_gtest_tgt gtest_main)
elseif(DLAF_AT_USE_MAIN STREQUAL PIKA)
set(_gtest_tgt DLAF_gtest_pika_main)
elseif(DLAF_AT_USE_MAIN STREQUAL MPI)
set(_gtest_tgt DLAF_gtest_mpi_main)
elseif(DLAF_AT_USE_MAIN STREQUAL MPIPIKA)
set(_gtest_tgt DLAF_gtest_mpipika_main)
elseif(DLAF_AT_USE_MAIN STREQUAL CAPI)
set(_gtest_tgt DLAF_gtest_mpi_main)
else()
message(FATAL_ERROR "USE_MAIN=${DLAF_AT_USE_MAIN} is not a supported option")
endif()

### Test executable target
add_executable(${test_target_name} ${DLAF_AT_SOURCES})
target_link_libraries(
Expand Down

0 comments on commit 71eac9d

Please sign in to comment.