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

BUILD_SHARED_LIBS support #25

Merged
merged 2 commits into from
Sep 5, 2021
Merged

BUILD_SHARED_LIBS support #25

merged 2 commits into from
Sep 5, 2021

Conversation

joseasoler
Copy link
Contributor

This PR implements the feature request described in #24. There is now only a trng4 target, and the user can choose between a static and shared build by using the BUILD_SHARED_LIBS CMake variable. When an user enables BUILD_SHARED_LIBS on Windows an error message will be shown to indicate that this is currently not supported.

I have checked that tests and examples can build and launch successfully with and without BUILD_SHARED_LIBS on Linux, and without BUILD_SHARED_LIBS on Windows. Finding trng4 through find_package is also working. I could not test the change to pvs_studio_add_target as I do not have a license but hopefully it will work fine.

Copy link
Owner

@rabauke rabauke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. This simplifies the code and seems to be more idiomatic CMake usage. I never liked the original approach with the trng4_static target.

@rabauke rabauke merged commit 69f1d58 into rabauke:master Sep 5, 2021
@MaxOremek
Copy link

On my *nix machines (openSuse 15.3 and Ubuntu 20.04) not setting the flag leads to building of just the static library. Would be nice to include in the documentation. Thank you!

@rabauke
Copy link
Owner

rabauke commented Feb 8, 2022

@MaxOremek This is the standard behavior of CMake. CMake lets you build a library either as a static or as a dynamic library. Earlier versions of TRNG implemented a hack to build build both.
I agree, this should be mentioned in the documentation although the BUILD_SHARED_LIBS is a common CMake thing.
https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html

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.

3 participants