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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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!

option(VUL_ENABLE_INSTALL "Enable install" ${VUL_IS_TOP_LEVEL})
endif()

set_property(GLOBAL PROPERTY USE_FOLDERS ON) # Remove when min is 3.26, see CMP0143

set(CMAKE_CXX_STANDARD 17)
Expand All @@ -30,7 +35,7 @@ find_package(VulkanHeaders CONFIG)
add_subdirectory(src)
add_subdirectory(include)

if (VUL_IS_TOP_LEVEL)
if (VUL_ENABLE_INSTALL)
option(BUILD_TESTS "Build tests")
if (BUILD_TESTS)
enable_testing()
Expand Down