From 183aa5202ae40726fe7d1069822b0b8d01f48cbe Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Mon, 20 Nov 2023 23:41:46 -0600 Subject: [PATCH] fix: link tests with --no-as-needed due to JANA #255 (#1130) ### Briefly, what does this PR introduce? This fixes an issue in the linking of algorithms_test which popped up today (and likely was always there...). Until https://github.com/JeffersonLab/JANA2/pull/255 is included, we install a libJANA.so with undefined references to podio because it doesn't include it in the NEEDED section. By passing `--no-as-needed` we don't strip the podio calls from the algorithms_test executables where they are unused. ### What kind of change does this PR introduce? - [x] Bug fix (issue #__) - [ ] New feature (issue #__) - [ ] Documentation update - [ ] Other: __ ### Please check if this PR fulfills the following: - [ ] Tests for the changes have been added - [ ] Documentation has been added / updated - [ ] Changes have been communicated to collaborators ### Does this PR introduce breaking changes? What changes might users need to make to their code? No. ### Does this PR change default behavior? No. --------- Co-authored-by: Dmitry Kalinkin --- src/tests/algorithms_test/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tests/algorithms_test/CMakeLists.txt b/src/tests/algorithms_test/CMakeLists.txt index 0f603bc95f..8a240c5bd6 100644 --- a/src/tests/algorithms_test/CMakeLists.txt +++ b/src/tests/algorithms_test/CMakeLists.txt @@ -11,6 +11,10 @@ add_executable(${TEST_NAME} # Explicit linking to podio::podio is needed due to https://github.com/JeffersonLab/JANA2/issues/151 target_link_libraries(${TEST_NAME} PRIVATE Catch2::Catch2WithMain algorithms_calorimetry_library algorithms_pid_library podio::podio podio::podioRootIO) +# As-needed fails due to absent podio symbols in libJANA.so (https://github.com/JeffersonLab/JANA2/pull/255) +if (CMAKE_CXX_COMPILER_LINKER_ID MATCHES "GNU(gold)?") + target_link_options(${TEST_NAME} PRIVATE "-Wl,--no-as-needed") +endif() # Install executable install(TARGETS ${TEST_NAME} DESTINATION bin)