summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2024-05-03 07:49:25 (GMT)
committerCraig Scott <craig.scott@crascit.com>2024-05-12 04:45:44 (GMT)
commit0ccc8e340d9af83f2188cad401b0fbb9a76d476b (patch)
treee75aa8a28159a8b5f51ad1b03a61bf62abc48da0
parent91e1015722e2e62249839ccb0f557b810740e6fb (diff)
downloadCMake-0ccc8e340d9af83f2188cad401b0fbb9a76d476b.zip
CMake-0ccc8e340d9af83f2188cad401b0fbb9a76d476b.tar.gz
CMake-0ccc8e340d9af83f2188cad401b0fbb9a76d476b.tar.bz2
ExternalProject: Provide ExternalProject_Add keywords through a macro
This allows things outside of ExternalProject to have access to the list of supported keywords. This will be used by FetchContent in an upcoming change. Issue: #21703
-rw-r--r--Modules/ExternalProject.cmake103
1 files changed, 54 insertions, 49 deletions
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 7ea6387..dcb5f66 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -4271,55 +4271,8 @@ function(_ep_add_test_command name)
endfunction()
-function(ExternalProject_Add name)
- cmake_policy(GET CMP0097 _EP_CMP0097
- PARENT_SCOPE # undocumented, do not use outside of CMake
- )
- 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()
- cmake_policy(GET CMP0135 _EP_CMP0135
- PARENT_SCOPE # undocumented, do not use outside of CMake
- )
-
- _ep_get_configuration_subdir_genex(cfgdir)
-
- # Add a custom target for the external project.
- set(cmf_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles)
- _ep_get_complete_stampfile(${name} complete_stamp_file)
-
- cmake_policy(PUSH)
- if(cmp0114 STREQUAL "NEW")
- # To implement CMP0114 NEW behavior with Makefile generators,
- # we need CMP0113 NEW behavior.
- cmake_policy(SET CMP0113 NEW)
- endif()
- # The "ALL" option to add_custom_target just tells it to not set the
- # EXCLUDE_FROM_ALL target property. Later, if the EXCLUDE_FROM_ALL
- # argument was passed, we explicitly set it for the target.
- add_custom_target(${name} ALL DEPENDS ${complete_stamp_file})
- cmake_policy(POP)
- set_target_properties(${name} PROPERTIES
- _EP_IS_EXTERNAL_PROJECT 1
- LABELS ${name}
- FOLDER "ExternalProjectTargets/${name}"
- _EP_CMP0114 "${cmp0114}"
- )
-
- set(keywords
+macro(_ep_get_add_keywords out_var)
+ set(${out_var}
#
# Directory options
#
@@ -4457,6 +4410,58 @@ function(ExternalProject_Add name)
#
EXTERNALPROJECT_INTERNAL_ARGUMENT_SEPARATOR
)
+endmacro()
+
+
+function(ExternalProject_Add name)
+ cmake_policy(GET CMP0097 _EP_CMP0097
+ PARENT_SCOPE # undocumented, do not use outside of CMake
+ )
+ 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()
+ cmake_policy(GET CMP0135 _EP_CMP0135
+ PARENT_SCOPE # undocumented, do not use outside of CMake
+ )
+
+ _ep_get_configuration_subdir_genex(cfgdir)
+
+ # Add a custom target for the external project.
+ set(cmf_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles)
+ _ep_get_complete_stampfile(${name} complete_stamp_file)
+
+ cmake_policy(PUSH)
+ if(cmp0114 STREQUAL "NEW")
+ # To implement CMP0114 NEW behavior with Makefile generators,
+ # we need CMP0113 NEW behavior.
+ cmake_policy(SET CMP0113 NEW)
+ endif()
+ # The "ALL" option to add_custom_target just tells it to not set the
+ # EXCLUDE_FROM_ALL target property. Later, if the EXCLUDE_FROM_ALL
+ # argument was passed, we explicitly set it for the target.
+ add_custom_target(${name} ALL DEPENDS ${complete_stamp_file})
+ cmake_policy(POP)
+ set_target_properties(${name} PROPERTIES
+ _EP_IS_EXTERNAL_PROJECT 1
+ LABELS ${name}
+ FOLDER "ExternalProjectTargets/${name}"
+ _EP_CMP0114 "${cmp0114}"
+ )
+
+ _ep_get_add_keywords(keywords)
_ep_parse_arguments(
ExternalProject_Add
"${keywords}"