mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-07 14:20:06 -06:00
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.
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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})
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
11
Tests/RunCMake/ExternalProject/Xcode-CMP0114-stderr.txt
Normal file
11
Tests/RunCMake/ExternalProject/Xcode-CMP0114-stderr.txt
Normal file
@@ -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.$
|
||||
2
Tests/RunCMake/ExternalProject/Xcode-CMP0114.cmake
Normal file
2
Tests/RunCMake/ExternalProject/Xcode-CMP0114.cmake
Normal file
@@ -0,0 +1,2 @@
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(MyProj SOURCE_DIR .)
|
||||
Reference in New Issue
Block a user