Skip to content

Commit

Permalink
Conditionally enable CMake policy CMP0077
Browse files Browse the repository at this point in the history
Projects that import Bond using add_subdirectory pointed at a Git
submodule may want to set options like BOND_ENABLE_GRPC and
BOND_FIND_RAPIDJSON through a top-level CMakeLists.txt. However, this
doesn't work without creating an identical option() in the importing
project. Enabling CMP0077 in CMake 3.13+ changes the behavior of
option() to allow importing projects to set default values for the
variables without touching the cache.

Co-authored-by: Sumit Bhardwaj <[email protected]>
  • Loading branch information
bhardwajs and bhardwajs authored Jun 29, 2020
1 parent 4454534 commit 890ec38
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ cmake_minimum_required (VERSION 3.1)
project (bond)
cmake_policy (SET CMP0022 NEW)

if (POLICY CMP0077)
# Allow CMake 3.13+ to override options when using FetchContent/add_subdirectory.
cmake_policy(SET CMP0077 NEW)
endif ()

set (CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/cmake
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/cmake-modules)
Expand Down

0 comments on commit 890ec38

Please sign in to comment.