Commit 748d0245 authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'fetchcontent-reduce-boilerplate'

a94355c7 FetchContent: Add new command FetchContent_MakeAvailable()
611d5274 Sphinx: Add limited support for nested variables in docs
1a07e1b4 FetchContent: Trivial doc corrections
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !2830
parents d685a46f a94355c7
Pipeline #128966 passed with stage
in 0 seconds
fetchcontent-reduce-boilerplate
-------------------------------
* The FetchContent module gained a new :command:`FetchContent_MakeAvailable`
command. This new command accepts a list of dependency names, which it then
iterates over, populating and adding each one to the main build using the
canonical pattern. This significantly reduces the amount of boilerplate
needed in the project.
This diff is collapsed.
Confirmation project has been added
.*Confirmation script has been called
include(FetchContent)
FetchContent_Declare(
WithProject
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/WithProject
)
FetchContent_Declare(
WithoutProject
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/WithoutProject
)
# Order is important and will be verified by test output
FetchContent_MakeAvailable(WithProject WithoutProject)
get_property(addedWith GLOBAL PROPERTY FetchWithProject SET)
if(NOT addedWith)
message(SEND_ERROR "Subdir with CMakeLists.txt not added")
endif()
include(${withoutproject_SOURCE_DIR}/confirmMessage.cmake)
-- Before first[
]+-- Confirmation project has been added[
]+-- Between both[
]+-- After last
include(FetchContent)
FetchContent_Declare(
WithProject
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/WithProject
)
message(STATUS "Before first")
FetchContent_MakeAvailable(WithProject)
message(STATUS "Between both")
FetchContent_MakeAvailable(WithProject)
message(STATUS "After last")
include(FetchContent)
FetchContent_MakeAvailable(NoDetails)
......@@ -11,6 +11,9 @@ run_cmake(VarDefinitions)
run_cmake(GetProperties)
run_cmake(DirOverrides)
run_cmake(UsesTerminalOverride)
run_cmake(MakeAvailable)
run_cmake(MakeAvailableTwice)
run_cmake(MakeAvailableUndeclared)
# We need to pass through CMAKE_GENERATOR and CMAKE_MAKE_PROGRAM
# to ensure the test can run on machines where the build tool
......
cmake_minimum_required(VERSION 3.13)
project(WithProject LANGUAGES NONE)
set_property(GLOBAL PROPERTY FetchWithProject YES)
message(STATUS "Confirmation project has been added")
message(STATUS "Confirmation script has been called")
......@@ -21,6 +21,8 @@ from pygments.lexer import bygroups
# - Unix paths are recognized by '/'; support for Windows paths may be added if needed
# - (\\.) allows for \-escapes (used in manual/cmake-language.7)
# - $<..$<..$>..> nested occurence in cmake-buildsystem
# - Nested variable evaluations are only supported in a limited capacity. Only
# one level of nesting is supported and at most one nested variable can be present.
CMakeLexer.tokens["root"] = [
(r'\b(\w+)([ \t]*)(\()', bygroups(Name.Function, Text, Name.Function), '#push'), # fctn(
......@@ -34,7 +36,8 @@ CMakeLexer.tokens["root"] = [
(r'[<>]=', Punctuation), # used in FindPkgConfig.cmake
(r'\$<', Operator, '#push'), # $<...>
(r'<[^<|]+?>(\w*\.\.\.)?', Name.Variable), # <expr>
(r'(\$\w*\{)(.+?)(\})', bygroups(Operator, Name.Tag, Operator)), # ${..} $ENV{..}
(r'(\$\w*\{)([^\}\$]*)?(?:(\$\w*\{)([^\}]+?)(\}))?([^\}]*?)(\})', # ${..} $ENV{..}, possibly nested
bygroups(Operator, Name.Tag, Operator, Name.Tag, Operator, Name.Tag, Operator)),
(r'([A-Z]+\{)(.+?)(\})', bygroups(Operator, Name.Tag, Operator)), # DATA{ ...}
(r'[a-z]+(@|(://))((\\.)|[\w.+-:/\\])+', Name.Attribute), # URL, git@, ...
(r'/\w[\w\.\+-/\\]*', Name.Attribute), # absolute path
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment