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 Builds as Shared library when parent CMake sets BUILD_SHARED_LIBS #2895

Closed
AidanBeltonS opened this issue Aug 6, 2024 · 2 comments
Closed

Comments

@AidanBeltonS
Copy link

Describe the bug
Catch 2 builds its libraries as a shared library, when using BUILD_SHARED_LIBS=ON and pulling the repo via FetchContent.

Expected behavior
It seems the v3 library is supposed to work only as a static library. Correct me if I am wrong. So regardless of the project that uses Catch2, the Catch2 library should build as a static not shared library.

If this is expected behaviour, please close this issue.

Reproduction steps

$ git clone https://github.com/AidanBeltonS/Catch2_reproducer
$ cd Catch2_reproducer
$ mkdir build
$ cd build
$ cmake -G Ninja .. -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
$ ninja
$ find -name "*.so"
./_deps/catch2-build/src/libCatch2Main.so
./_deps/catch2-build/src/libCatch2.so
./libMain_Object.so

Additional context
I have not encountered any specific problem with it being a shared library, however it seems like an error to have the parent CMake effect the Catch build in this way.

@horenmar
Copy link
Member

Catch2 can be built as a shared lib, but I don't try to support it past using CMake-provided utility to make every symbol visible -> if that fails, the user is on their own.

As for BUILD_SHARED_LIBS, Catch2 tries to use the standard CMake configuration options. This does mean that if you include it as a subproject, it will use the same configuration, because it is global. If you need something different, you have to undo it yourself.

@ChrisThrasher
Copy link
Collaborator

Closing as this is the intended behavior of the library and a natural side effect of the way FetchContent works.

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

3 participants