summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-09-14 19:05:33 (GMT)
committerBrad King <brad.king@kitware.com>2020-09-18 17:46:45 (GMT)
commitb8ecd4df5f9259f102d82011693eca6282be5ae6 (patch)
tree435d7ae8fc75a2ca97b4b1d5fc7404fbe92a4045
parentfe258f638276c879bbdd2ac165ac4caba0efc921 (diff)
downloadCMake-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.
-rw-r--r--Modules/ExternalProject.cmake12
-rw-r--r--Modules/FetchContent/CMakeLists.cmake.in1
-rw-r--r--Tests/ExternalProject/CMakeLists.txt3
-rw-r--r--Tests/ExternalProjectLocal/CMakeLists.txt3
-rw-r--r--Tests/ExternalProjectUpdate/CMakeLists.txt19
-rw-r--r--Tests/RunCMake/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/ExternalProject/Add_StepDependencies.cmake6
-rw-r--r--Tests/RunCMake/ExternalProject/Add_StepDependencies_no_target.cmake6
-rw-r--r--Tests/RunCMake/ExternalProject/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/ExternalProject/RunCMakeTest.cmake13
-rw-r--r--Tests/RunCMake/ExternalProject/Xcode-CMP0114-stderr.txt11
-rw-r--r--Tests/RunCMake/ExternalProject/Xcode-CMP0114.cmake2
12 files changed, 74 insertions, 8 deletions
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index b795784..8bbaf5a 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -3342,6 +3342,18 @@ function(ExternalProject_Add name)
cmake_policy(GET CMP0114 cmp0114
PARENT_SCOPE # undocumented, do not use outside of CMake
)
+ if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12 AND NOT cmp0114 STREQUAL "NEW")
+ message(AUTHOR_WARNING
+ "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."
+ "\n"
+ "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."
+ )
+ set(cmp0114 "NEW")
+ endif()
_ep_get_configuration_subdir_suffix(cfgdir)
diff --git a/Modules/FetchContent/CMakeLists.cmake.in b/Modules/FetchContent/CMakeLists.cmake.in
index 45e4df0..9516418 100644
--- a/Modules/FetchContent/CMakeLists.cmake.in
+++ b/Modules/FetchContent/CMakeLists.cmake.in
@@ -2,6 +2,7 @@
# file Copyright.txt or https://cmake.org/licensing for details.
cmake_minimum_required(VERSION ${CMAKE_VERSION})
+cmake_policy(SET CMP0114 NEW)
# We name the project and the target for the ExternalProject_Add() call
# to something that will highlight to the user what we are working on if
diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt
index c8850ea..29cdcc9 100644
--- a/Tests/ExternalProject/CMakeLists.txt
+++ b/Tests/ExternalProject/CMakeLists.txt
@@ -1,5 +1,8 @@
cmake_minimum_required(VERSION 2.8)
project(ExternalProjectTest NONE)
+if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12)
+ cmake_policy(SET CMP0114 NEW)
+endif()
include(ExternalProject)
diff --git a/Tests/ExternalProjectLocal/CMakeLists.txt b/Tests/ExternalProjectLocal/CMakeLists.txt
index 1075a9d..789e4fb 100644
--- a/Tests/ExternalProjectLocal/CMakeLists.txt
+++ b/Tests/ExternalProjectLocal/CMakeLists.txt
@@ -1,5 +1,8 @@
cmake_minimum_required(VERSION 2.8)
project(ExternalProjectLocalTest NONE)
+if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12)
+ cmake_policy(SET CMP0114 NEW)
+endif()
include(ExternalProject)
diff --git a/Tests/ExternalProjectUpdate/CMakeLists.txt b/Tests/ExternalProjectUpdate/CMakeLists.txt
index 9dddae2..563a6cf 100644
--- a/Tests/ExternalProjectUpdate/CMakeLists.txt
+++ b/Tests/ExternalProjectUpdate/CMakeLists.txt
@@ -1,5 +1,9 @@
cmake_minimum_required(VERSION 2.8)
project(ExternalProjectUpdateTest NONE)
+if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12)
+ cmake_policy(SET CMP0114 NEW)
+endif()
+cmake_policy(GET CMP0114 cmp0114)
include(ExternalProject)
@@ -18,8 +22,16 @@ set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER
set(base "${CMAKE_BINARY_DIR}/CMakeExternals")
set(binary_base "${base}/Build")
set_property(DIRECTORY PROPERTY EP_BASE ${base})
-set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test)
-set_property(DIRECTORY PROPERTY EP_INDEPENDENT_STEP_TARGETS update)
+if(cmp0114 STREQUAL "NEW")
+ set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test update)
+ set(TestUpdateCommand_STEP_TARGETS STEP_TARGETS update)
+ set(TestUpdateCommand_INDEPENDENT_STEP_TARGETS)
+else()
+ set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test)
+ set_property(DIRECTORY PROPERTY EP_INDEPENDENT_STEP_TARGETS update)
+ set(TestUpdateCommand_STEP_TARGETS)
+ set(TestUpdateCommand_INDEPENDENT_STEP_TARGETS INDEPENDENT_STEP_TARGETS update)
+endif()
ExternalProject_Add(TestUpdateCommand
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
@@ -28,7 +40,8 @@ ExternalProject_Add(TestUpdateCommand
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
- INDEPENDENT_STEP_TARGETS update
+ ${TestUpdateCommand_STEP_TARGETS}
+ ${TestUpdateCommand_INDEPENDENT_STEP_TARGETS}
)
add_custom_target(TestUpdateCommandDriver ALL)
add_dependencies(TestUpdateCommandDriver TestUpdateCommand-update)
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 39455b7..ff0ae62 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -569,6 +569,9 @@ add_RunCMake_test(file-GET_RUNTIME_DEPENDENCIES
add_RunCMake_test(CPackCommandLine)
add_RunCMake_test(CPackConfig)
add_RunCMake_test(CPackInstallProperties)
+if(XCODE_VERSION)
+ set(ExternalProject_ARGS -DXCODE_VERSION=${XCODE_VERSION})
+endif()
add_RunCMake_test(ExternalProject)
add_RunCMake_test(FetchContent)
set(CTestCommandLine_ARGS -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE})
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 .)