diff options
author | Brad King <brad.king@kitware.com> | 2020-09-14 19:05:33 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-09-18 17:46:45 (GMT) |
commit | b8ecd4df5f9259f102d82011693eca6282be5ae6 (patch) | |
tree | 435d7ae8fc75a2ca97b4b1d5fc7404fbe92a4045 /Tests/RunCMake/ExternalProject | |
parent | fe258f638276c879bbdd2ac165ac4caba0efc921 (diff) | |
download | CMake-b8ecd4df5f9259f102d82011693eca6282be5ae6.zip CMake-b8ecd4df5f9259f102d82011693eca6282be5ae6.tar.gz CMake-b8ecd4df5f9259f102d82011693eca6282be5ae6.tar.bz2 |
ExternalProject: Use CMP0114 NEW behavior with Xcode "new build system"
The ExternalProject module cannot be implemented in the Xcode "new build
system" without using CMP0114's NEW behavior. When configuring for that
build system, warn if the policy is not set to NEW and use NEW behavior
anyway.
Diffstat (limited to 'Tests/RunCMake/ExternalProject')
6 files changed, 36 insertions, 5 deletions
diff --git a/Tests/RunCMake/ExternalProject/Add_StepDependencies.cmake b/Tests/RunCMake/ExternalProject/Add_StepDependencies.cmake index 4e43ab3..bfed4fa 100644 --- a/Tests/RunCMake/ExternalProject/Add_StepDependencies.cmake +++ b/Tests/RunCMake/ExternalProject/Add_StepDependencies.cmake @@ -1,5 +1,9 @@ cmake_minimum_required(VERSION ${CMAKE_VERSION}) -cmake_policy(SET CMP0114 OLD) # Test deprecated behavior. +if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12) + cmake_policy(SET CMP0114 NEW) +else() + cmake_policy(SET CMP0114 OLD) # Test deprecated behavior. +endif() include(ExternalProject) diff --git a/Tests/RunCMake/ExternalProject/Add_StepDependencies_no_target.cmake b/Tests/RunCMake/ExternalProject/Add_StepDependencies_no_target.cmake index 7c75007..039dec6 100644 --- a/Tests/RunCMake/ExternalProject/Add_StepDependencies_no_target.cmake +++ b/Tests/RunCMake/ExternalProject/Add_StepDependencies_no_target.cmake @@ -1,5 +1,9 @@ cmake_minimum_required(VERSION ${CMAKE_VERSION}) -cmake_policy(SET CMP0114 OLD) # Test deprecated behavior. +if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12) + cmake_policy(SET CMP0114 NEW) +else() + cmake_policy(SET CMP0114 OLD) # Test deprecated behavior. +endif() include(ExternalProject) diff --git a/Tests/RunCMake/ExternalProject/CMakeLists.txt b/Tests/RunCMake/ExternalProject/CMakeLists.txt index c585733..9cb093a 100644 --- a/Tests/RunCMake/ExternalProject/CMakeLists.txt +++ b/Tests/RunCMake/ExternalProject/CMakeLists.txt @@ -1,3 +1,6 @@ cmake_minimum_required(VERSION ${CMAKE_VERSION}) project(${RunCMake_TEST} NONE) +if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12 AND NOT RunCMake_TEST STREQUAL "Xcode-CMP0114") + cmake_policy(SET CMP0114 NEW) +endif() include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake index 1e88e0b..598671f 100644 --- a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake @@ -16,8 +16,10 @@ run_cmake(SourceMissing) run_cmake(CMAKE_CACHE_ARGS) run_cmake(CMAKE_CACHE_DEFAULT_ARGS) run_cmake(CMAKE_CACHE_mix) -run_cmake(NO_DEPENDS-CMP0114-WARN) -run_cmake(NO_DEPENDS-CMP0114-OLD) +if(NOT XCODE_VERSION OR XCODE_VERSION VERSION_LESS 12) + run_cmake(NO_DEPENDS-CMP0114-WARN) + run_cmake(NO_DEPENDS-CMP0114-OLD) +endif() run_cmake(NO_DEPENDS-CMP0114-NEW) run_cmake(NO_DEPENDS-CMP0114-NEW-Direct) run_cmake(Add_StepDependencies) @@ -25,6 +27,9 @@ run_cmake(Add_StepDependencies_iface) run_cmake(Add_StepDependencies_iface_step) run_cmake(Add_StepDependencies_no_target) run_cmake(UsesTerminal) +if(XCODE_VERSION AND XCODE_VERSION VERSION_GREATER_EQUAL 12) + run_cmake(Xcode-CMP0114) +endif() macro(check_steps_missing proj) set(steps "${ARGN}") @@ -53,7 +58,9 @@ function(run_steps_CMP0114 val) run_cmake_command(Steps-CMP0114-${val}-build-install ${CMAKE_COMMAND} --build . --target proj1-install) run_cmake_command(Steps-CMP0114-${val}-build-test ${CMAKE_COMMAND} --build . --target proj1-test) endfunction() -run_steps_CMP0114(OLD) +if(NOT XCODE_VERSION OR XCODE_VERSION VERSION_LESS 12) + run_steps_CMP0114(OLD) +endif() run_steps_CMP0114(NEW) # Run both cmake and build steps. We always do a clean before the diff --git a/Tests/RunCMake/ExternalProject/Xcode-CMP0114-stderr.txt b/Tests/RunCMake/ExternalProject/Xcode-CMP0114-stderr.txt new file mode 100644 index 0000000..a616185 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Xcode-CMP0114-stderr.txt @@ -0,0 +1,11 @@ +^CMake Warning \(dev\) at .*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + Policy CMP0114 is not set to NEW. In order to support the Xcode "new build + system", this project must be updated to set policy CMP0114 to NEW. + + Since CMake is generating for the Xcode "new build system", + ExternalProject_Add will use policy CMP0114's NEW behavior anyway, but the + generated build system may not match what the project intends. +Call Stack \(most recent call first\): + Xcode-CMP0114.cmake:[0-9]+ \(ExternalProject_Add\) + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/ExternalProject/Xcode-CMP0114.cmake b/Tests/RunCMake/ExternalProject/Xcode-CMP0114.cmake new file mode 100644 index 0000000..5039daa --- /dev/null +++ b/Tests/RunCMake/ExternalProject/Xcode-CMP0114.cmake @@ -0,0 +1,2 @@ +include(ExternalProject) +ExternalProject_Add(MyProj SOURCE_DIR .) |