-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
conan-provider.cmake: introduce a new policy scope, set min cmake ver…
…sion (#645) cmake has the notion of "policy scopes" to limit the scope of the policies. this patch introduces a module-level policy scope and sets the minimum required cmake version to 3.24, so the cmake features depend on policy settings such as `if(... IN_LIST ...)` behaves as expected even if the consuming project does not declare a cmake minimum version requirement. also, this change now enforces the version requirement so the code would fail immediately if the cmake version is less than the minimum. Signed-off-by: Mustafa Kemal Gilor <[email protected]>
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
project(MyApp CXX) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
find_package(hello REQUIRED) | ||
# Request that Findbye.cmake (generated by Conan) | ||
# is used instead of bye-config.cmake | ||
find_package(bye MODULE REQUIRED) | ||
|
||
# The `find_package` will include the conan_provider.cmake file | ||
# which has policy-affecting code. We expect no changes to the current | ||
# policy scope. | ||
|
||
add_executable(app main.cpp) | ||
target_link_libraries(app hello::hello bye::bye) | ||
|
||
set(test_list a b c d e f) | ||
if("a" IN_LIST test_list) | ||
# see https://cmake.org/cmake/help/latest/policy/CMP0057.html | ||
message(ERROR "this should not happen as IN_LIST is a CMake 3.3 feature.") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters