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

CMake: Added VUL_ENABLE_INSTALL to top level cmake file. #244

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mokafolio
Copy link

@mokafolio mokafolio commented Oct 30, 2024

  • Allows you to manually control the existence of the install target (This is more in line with other vulkan sdk adjacent code bases and super useful for projects that manually pull in Vulkan-Utility-Libraries as a source dependency where you still might want the install target but added it via cmake add_subdirectory)
  • defaults to VUL_IS_TOP_LEVEL to keep the original behavior without any changes to existing client code.

- Allows you to manually control the existance of the install target
- defaults to VUL_IS_TOP_LEVEL to keep the original behavior without any
changes to client code
@@ -9,6 +9,11 @@ project(VUL LANGUAGES CXX)

string(COMPARE EQUAL ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} VUL_IS_TOP_LEVEL) # Remove when min is 3.21

# Control whether to install or not. By default its only on if this is the top level cmake project.
if(NOT DEFINED VUL_ENABLE_INSTALL)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is an if statement put around the install code? Shouldn't making the install option be FALSE if VUL_IS_TOP_LEVEL is false be sufficient?

Put another way, we do not need to guard against the variable not existing before defining it. option() does not override the value if the variable already exists.
https://cmake.org/cmake/help/latest/command/option.html

Copy link
Author

Choose a reason for hiding this comment

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

Good Question: If I recall correctly, its mainly to make the behavior consistent with older cmake versions: https://cmake.org/cmake/help/latest/policy/CMP0077.html#policy:CMP0077

I am not married to that check, if you think its too ugly, feel free to remove it!

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.

2 participants