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: prevent overriding CMAKE_BUILD_TYPE if it is subdirectory #276

Merged
merged 1 commit into from
Jan 27, 2023

Conversation

recp
Copy link
Owner

@recp recp commented Jan 26, 2023

We have this configuration:

set(DEFAULT_BUILD_TYPE "Release")

...

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
  set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE)
  # Set the possible values of build type for cmake-gui
  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

this overrides parent project if parent project don't set BUILD_TYPE e.g Debug. The PR adds additional checks before set build type:

get_directory_property(hasParent PARENT_DIRECTORY)

if(NOT hasParent AND NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
...

fixes #275


references:

@recp recp merged commit c51040c into master Jan 27, 2023
@recp recp deleted the cmake-fix-buildtype branch January 27, 2023 18:01
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.

Problem in linking with OpenGL
1 participant