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

tribits_add_option_and_define(): Error out if non-cache vars already defined (trilinos/Trilinos#10355) #564

Conversation

…defined (trilinos/Trilinos#10355)

This causes tribits_add_option_and_define(<optionName> <defineName> ...) to
error out if <optionName> or <defineName> are already defined as a non-cache
vars.  This is needed to catch tricky cases that were likely an accident where
a package's CMakeLists.txt file was trying to redefine a TriBITS-set
project-level non-cache var (e.g. HAVE_ML_SUPERLU in trilinos/Trilinos#11583)
which can casue a nasty change in behavior when using the new behvior with
CMake 3.21+ with policy CMP0126 where setting cache vars no longer hides local
vars.  (See Trilinos Issue trilinos/Trilinos#10355 and Trilinos PR
trilinos/Trilinos#11583.)

NOTE: I also changed this from a macro to a function.  There is no reason this
needed to be a macro and a function is much safer as all of the local vars
created in the funtion will not bleed into the calling scope (only the one's
we explicitly set using PARENT_SCOPE).  I also added the NOCACHE option for
cases where the <defineName> should never be made a global var and should
never be exported to other projects.  (The NOCACHE option will get used for
some non-namespaced vars from the pakages Pliris and Adelus.)
@bartlettroscoe
Copy link
Member Author

@KyleFromKitware, here is a small one to review. Should not take longer than 5 mins

@bartlettroscoe bartlettroscoe merged commit 1a6335a into TriBITSPub:master Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants