Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch2 fails to link when using a CMake multi-config generator #2892

Open
terminal-beetroot opened this issue Aug 2, 2024 · 0 comments
Open

Comments

@terminal-beetroot
Copy link

terminal-beetroot commented Aug 2, 2024

Describe the bug
When Catch2 is installed using Conan into a project using CMake, and the project uses a multi-config generator such as "Ninja Multi-Config", building the project results in linker errors having to do with missing references to Catch2 symbols.

Expected behavior
Project should link successfully.

Reproduction steps

  1. Install Catch2 using Conan:
[test_requires]
catch2/3.6.0
  1. Use Conan's CMake integration to find and link against Catch2:
add_executable(xxx_test ${SOURCES_WITHOUT_MAIN} ${TEST_SOURCES})
find_package(Catch2 REQUIRED)
target_link_libraries(xxx_test PRIVATE Catch2::Catch2WithMain)
  1. Configure + build using CMake and the "Ninja Multi-Config" generator
cmake -G "Ninja Multi-Config" -S. -B ./build --preset=conan-release && cmake --build ./build
  1. Observe link errors:
FAILED: Debug/xxx_test 
...
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../lib/Scrt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
/usr/bin/ld: CMakeFiles/xxx_test.dir/Debug/test/XXX.test.cpp.o: in function `CATCH2_INTERNAL_TEST_0()':
/home/tom/projects/xxx/projects/xxx/test/XXX.test.cpp:6:(.text+0x4e): undefined reference to `Catch::ReusableStringStream::ReusableStringStream()'
...

Platform information:

  • OS: Arch Linux
  • Compiler+version: GCC v14.1.1
  • Catch version: v3.6.0
  • Conan version: 2.5.0

Additional context

  1. When changing the generator to "Ninja" things work as expected.
  2. The following comment exists in Catch2-Target-release.cmake:
# FIXME: What is the result of this for multi-config? All configs adding themselves to path?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant