Skip to content

Conversation

@janbraun
Copy link

@janbraun janbraun commented Apr 4, 2023

Issue: Configuring cereal with the -DTHREAD_SAFE=ON option will not lead to any change in the installation.

I would like to have a system install defaulting to thread safe code, but I am not sure how the best way to solve this issue looks like. One option would be to change the default value of CEREAL_THREAD_SAFE in macros.hpp; the other option would be to create cmake targets which set the relevant compiler flags. The first solution would still suffer from not having proper support for linking a threading library.

The implemented solution tries to adjust CMakeLists.txt in such a way that it does what I think it should have done all along:

Using target_compile_definitions and target_link_libraries, the cmake targets installed in PREFIX/cmake/cereal will be updated to include the definition and library for thread safety. This will result in projects using cmake to include cereal automatically using the thread safe code globally.

A third option could be to provide two different cmake targets, one for single threaded and for multi threaded targets.

Resolves #785

Issue: Configuring cereal with the -DTHREAD_SAFE=ON option
will not lead to any change in the installation.

Using target_compile_definitions and target_link_libraries,
the cmake targets installed in PREFIX/cmake/cereal will be
updated to include the definition and library for thread safety.
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

Successfully merging this pull request may close these issues.

The use of the "THREAD_SAFE" cmake define doesn't change the install

1 participant