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

Why no default for BUILD_SHARED_LIBS? #1954

Open
blozano-tt opened this issue Dec 2, 2024 · 3 comments
Open

Why no default for BUILD_SHARED_LIBS? #1954

blozano-tt opened this issue Dec 2, 2024 · 3 comments

Comments

@blozano-tt
Copy link

option(BUILD_SHARED_LIBS "Build shared library" ${BUILD_SHARED_LIBS})

According to this, CMake does not define a default.

It seems like this project should be setting this to FALSE or OFF.

https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html

@gdamore
Copy link
Contributor

gdamore commented Dec 4, 2024

I believe if BUILD_SHARED_LIBS is unset at this point, it will become OFF. So this isn't necessarily a problem.

I'm not sure what the best practice here is -- because in theory someone might have already set that variable if we are included as a sub project.

@blozano-tt
Copy link
Author

I believe if BUILD_SHARED_LIBS is unset at this point, it will become OFF. So this isn't necessarily a problem.

I'm not sure what the best practice here is -- because in theory someone might have already set that variable if we are included as a sub project.

I think you should default it to off for clarity.

Since it’s a cache variable… it’s designed to be overridden by command line, or option passing (fetch content)… and cache variables are shadowed by normal variables if there is some add_subdirectory inclusion.

Maybe ask ChatGPT to confirm :-).

@blozano-tt
Copy link
Author

blozano-tt commented Dec 4, 2024

The reason I filed the issue, is I came here to check what the default expectation is for this library…

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

2 participants