Merge branch 'release' into ninja-multi-per-config-sources

This commit is contained in:
Kyle Edwards
2020-10-26 15:43:57 -04:00
3663 changed files with 57168 additions and 17030 deletions

View File

@@ -20,6 +20,8 @@ SortUsingDeclarations: false
SpaceAfterTemplateKeyword: true
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^[<"]cmSTL\.hxx'
Priority: -2
- Regex: '^[<"]cmConfigure\.h'
Priority: -1
- Regex: '^<queue>'

1
.gitignore vendored
View File

@@ -5,6 +5,7 @@
*.pyc
Testing
CMakeUserPresets.json
# Visual Studio work directory
.vs/

View File

@@ -8,10 +8,15 @@ include:
- local: .gitlab/os-macos.yml
- local: .gitlab/os-windows.yml
# Post-build steps
- local: .gitlab/upload.yml
stages:
- prep
- build
- test
- test-ext
- upload
################################################################################
# Job declarations
@@ -29,6 +34,35 @@ stages:
# - dependency/needs jobs for required jobs
################################################################################
# Prep jobs
prep:source-package:
extends:
- .linux_prep_source
- .cmake_prep_source_linux
- .linux_builder_tags
- .cmake_release_artifacts
- .run_only_for_package
prep:doc-package:
extends:
- .fedora31_sphinx_package
- .cmake_prep_doc_linux
- .linux_builder_tags_qt
- .cmake_doc_artifacts
- .run_only_for_package
.upload:source-package:
extends:
- .rsync_upload
- .run_only_for_package
dependencies:
- prep:source-package
needs:
- prep:source-package
variables:
RSYNC_DESTINATION: dev
# Lint builds
build:debian10-iwyu:
@@ -51,6 +85,9 @@ build:fedora31-sphinx:
- .cmake_build_linux
- .linux_builder_tags_qt
- .run_automatically
variables:
CMAKE_CI_JOB_CONTINUOUS: "true"
CMAKE_CI_JOB_HELP: "true"
# Linux builds
@@ -62,12 +99,23 @@ build:centos6-release:
- .linux_builder_tags
- .run_manually
test:debian10-ninja:
extends:
- .debian10_ninja
- .cmake_test_linux_package
- .linux_builder_tags_qt
- .run_dependent
dependencies:
- build:centos6-release
needs:
- build:centos6-release
test:fedora31-makefiles:
extends:
- .fedora31_makefiles
- .cmake_test_linux_package
- .linux_builder_tags_qt
- .run_automatically
- .run_dependent
dependencies:
- build:centos6-release
needs:
@@ -78,7 +126,7 @@ test:cuda10.2-nvidia:
- .cuda10.2_nvidia
- .cmake_test_linux_package
- .linux_builder_tags_cuda
- .run_automatically
- .run_dependent
dependencies:
- build:centos6-release
needs:
@@ -96,9 +144,9 @@ test:fedora31-ninja:
extends:
- .fedora31_ninja
- .cmake_test_linux
- .linux_builder_tags_qt
- .linux_builder_tags_x11
- .cmake_test_artifacts
- .run_automatically
- .run_dependent
dependencies:
- build:fedora31-ninja
needs:
@@ -109,12 +157,35 @@ test:fedora31-ninja-multi:
- .fedora31_ninja_multi
- .cmake_test_linux_external
- .linux_builder_tags_qt
- .run_automatically
- .run_dependent
dependencies:
- test:fedora31-ninja
needs:
- test:fedora31-ninja
build:linux-x86_64-package:
extends:
- .linux_package_x86_64
- .cmake_build_linux_package
- .cmake_release_artifacts
- .linux_builder_tags
- .run_only_for_package
dependencies:
- prep:doc-package
needs:
- prep:doc-package
.upload:linux-x86_64-package:
extends:
- .rsync_upload
- .run_only_for_package
dependencies:
- build:linux-x86_64-package
needs:
- build:linux-x86_64-package
variables:
RSYNC_DESTINATION: dev
# macOS builds
build:macos-ninja:
@@ -131,7 +202,7 @@ test:macos-ninja:
- .cmake_test_macos
- .cmake_test_artifacts
- .macos_builder_tags
- .run_automatically
- .run_dependent
dependencies:
- build:macos-ninja
needs:
@@ -150,7 +221,7 @@ test:macos-makefiles:
- .macos_makefiles
- .cmake_test_macos
- .macos_builder_tags
- .run_automatically
- .run_dependent
dependencies:
- build:macos-makefiles
needs:
@@ -161,12 +232,35 @@ test:macos-xcode:
- .macos_xcode
- .cmake_test_macos_external
- .macos_builder_ext_tags
- .run_automatically
- .run_dependent
dependencies:
- test:macos-ninja
needs:
- test:macos-ninja
build:macos-package:
extends:
- .macos_package
- .cmake_build_macos_package
- .cmake_release_artifacts
- .macos_builder_tags_package
- .run_only_for_package
dependencies:
- prep:doc-package
needs:
- prep:doc-package
.upload:macos-package:
extends:
- .rsync_upload
- .run_only_for_package
dependencies:
- build:macos-package
needs:
- build:macos-package
variables:
RSYNC_DESTINATION: dev
# Windows builds
build:windows-vs2019-x64-ninja:
@@ -183,7 +277,7 @@ test:windows-vs2019-x64-ninja:
- .cmake_test_windows
- .windows_builder_tags
- .cmake_test_artifacts
- .run_automatically
- .run_dependent
dependencies:
- build:windows-vs2019-x64-ninja
needs:
@@ -194,7 +288,7 @@ test:windows-vs2019-x64:
- .windows_vs2019_x64
- .cmake_test_windows_external
- .windows_builder_ext_tags
- .run_automatically
- .run_dependent
dependencies:
- test:windows-vs2019-x64-ninja
needs:

View File

@@ -34,10 +34,12 @@
- build/Tests/CMake*/PseudoMemcheck/purify
- build/Tests/CMake*/PseudoMemcheck/memcheck_fail
- build/Tests/CMake*/PseudoMemcheck/BC
- build/Tests/CMake*/PseudoMemcheck/cuda-memcheck
- build/Tests/CMake*/PseudoMemcheck/valgrind.exe
- build/Tests/CMake*/PseudoMemcheck/purify.exe
- build/Tests/CMake*/PseudoMemcheck/memcheck_fail.exe
- build/Tests/CMake*/PseudoMemcheck/BC.exe
- build/Tests/CMake*/PseudoMemcheck/cuda-memcheck.exe
- build/Tests/CMake*/PseudoMemcheck/NoLog
- build/Tests/CMake*Lib/*LibTests
- build/Tests/CMake*Lib/*LibTests.exe
@@ -58,6 +60,8 @@
- build/Tests/RunCMake/
- build/Tests/CMakeOnly/
- build/Tests/CMakeTests/
- build/Tests/CMakeGUI/
- build/Tests/FortranC/
# CTest/CDash information.
- build/Testing/
@@ -70,6 +74,10 @@
paths:
# Any packages made.
- build/cmake-*-Linux-x86_64.*
- build/cmake-*-Darwin-x86_64.*
# Any source packages made.
- build/cmake-*.tar.gz
- build/cmake-*.zip
.cmake_test_artifacts:
artifacts:
@@ -77,3 +85,10 @@
paths:
# Take the install tree.
- build/install/
.cmake_doc_artifacts:
artifacts:
expire_in: 1d
paths:
# Take the install tree.
- build/install-doc/

View File

@@ -0,0 +1,3 @@
get_filename_component(CMake_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE)
include("${CMake_SOURCE_DIR}/Source/CMakeVersion.cmake")
message(STATUS ${CMake_VERSION})

2
.gitlab/ci/cmake_version.sh Executable file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env bash
cmake -P "${BASH_SOURCE%/*}/cmake_version.cmake" | cut -d ' ' -f 2

View File

@@ -0,0 +1,66 @@
set(CMake_TEST_FindALSA "ON" CACHE BOOL "")
set(CMake_TEST_FindBLAS "ON" CACHE BOOL "")
set(CMake_TEST_FindBoost "ON" CACHE BOOL "")
set(CMake_TEST_FindBoost_Python "ON" CACHE BOOL "")
set(CMake_TEST_FindBZip2 "ON" CACHE BOOL "")
set(CMake_TEST_FindCups "ON" CACHE BOOL "")
set(CMake_TEST_FindCURL "ON" CACHE BOOL "")
set(CMake_TEST_FindDoxygen_Dot "ON" CACHE BOOL "")
set(CMake_TEST_FindDoxygen "ON" CACHE BOOL "")
set(CMake_TEST_FindEXPAT "ON" CACHE BOOL "")
set(CMake_TEST_FindFontconfig "ON" CACHE BOOL "")
set(CMake_TEST_FindFreetype "ON" CACHE BOOL "")
set(CMake_TEST_FindGDAL "ON" CACHE BOOL "")
set(CMake_TEST_FindGIF "ON" CACHE BOOL "")
set(CMake_TEST_FindGit "ON" CACHE BOOL "")
set(CMake_TEST_FindGLEW "ON" CACHE BOOL "")
set(CMake_TEST_FindGnuTLS "ON" CACHE BOOL "")
set(CMake_TEST_FindGSL "ON" CACHE BOOL "")
set(CMake_TEST_FindGTest "ON" CACHE BOOL "")
set(CMake_TEST_FindGTK2 "ON" CACHE BOOL "")
set(CMake_TEST_FindIconv "ON" CACHE BOOL "")
set(CMake_TEST_FindJPEG "ON" CACHE BOOL "")
set(CMake_TEST_FindJsonCpp "ON" CACHE BOOL "")
set(CMake_TEST_FindLAPACK "ON" CACHE BOOL "")
set(CMake_TEST_FindLibArchive "ON" CACHE BOOL "")
set(CMake_TEST_FindLibinput "ON" CACHE BOOL "")
set(CMake_TEST_FindLibLZMA "ON" CACHE BOOL "")
set(CMake_TEST_FindLibUV "ON" CACHE BOOL "")
set(CMake_TEST_FindLibXml2 "ON" CACHE BOOL "")
set(CMake_TEST_FindLibXslt "ON" CACHE BOOL "")
set(CMake_TEST_FindMPI_C "ON" CACHE BOOL "")
set(CMake_TEST_FindMPI_CXX "ON" CACHE BOOL "")
set(CMake_TEST_FindMPI_Fortran "ON" CACHE BOOL "")
set(CMake_TEST_FindMPI "ON" CACHE BOOL "")
set(CMake_TEST_FindODBC "ON" CACHE BOOL "")
set(CMake_TEST_FindOpenACC "ON" CACHE BOOL "")
set(CMake_TEST_FindOpenGL "ON" CACHE BOOL "")
set(CMake_TEST_FindOpenMP_C "ON" CACHE BOOL "")
set(CMake_TEST_FindOpenMP_CXX "ON" CACHE BOOL "")
set(CMake_TEST_FindOpenMP_Fortran "ON" CACHE BOOL "")
set(CMake_TEST_FindOpenMP "ON" CACHE BOOL "")
set(CMake_TEST_FindOpenSSL "ON" CACHE BOOL "")
set(CMake_TEST_FindPatch "ON" CACHE BOOL "")
set(CMake_TEST_FindPNG "ON" CACHE BOOL "")
set(CMake_TEST_FindPostgreSQL "ON" CACHE BOOL "")
set(CMake_TEST_FindProtobuf "ON" CACHE BOOL "")
set(CMake_TEST_FindPython "ON" CACHE BOOL "")
set(CMake_TEST_FindPython_IronPython "ON" CACHE BOOL "")
set(CMake_TEST_FindPython_NumPy "ON" CACHE BOOL "")
set(CMake_TEST_FindPython_PyPy "ON" CACHE BOOL "")
set(CMake_TEST_FindRuby "ON" CACHE BOOL "")
set(CMake_TEST_FindRuby_RVM "ON" CACHE BOOL "")
set(CMake_TEST_FindSDL "ON" CACHE BOOL "")
set(CMake_TEST_FindSQLite3 "ON" CACHE BOOL "")
set(CMake_TEST_FindTIFF "ON" CACHE BOOL "")
set(CMake_TEST_FindX11 "ON" CACHE BOOL "")
set(CMake_TEST_FindXalanC "ON" CACHE BOOL "")
set(CMake_TEST_FindXercesC "ON" CACHE BOOL "")
set(CMake_TEST_Fortran_SUBMODULES "ON" CACHE BOOL "")
set(CMake_TEST_IPO_WORKS_C "ON" CACHE BOOL "")
set(CMake_TEST_IPO_WORKS_CXX "ON" CACHE BOOL "")
set(CMake_TEST_IPO_WORKS_Fortran "ON" CACHE BOOL "")
set(CMake_TEST_Qt5 "ON" CACHE BOOL "")
set(CMake_TEST_UseSWIG "ON" CACHE BOOL "")
include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake")

View File

@@ -1,4 +1,5 @@
set(BUILD_CursesDialog ON CACHE BOOL "")
set(BUILD_QtDialog ON CACHE BOOL "")
set(CMake_TEST_JSON_SCHEMA ON CACHE BOOL "")
include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake")

View File

@@ -1 +1,66 @@
set(CMake_TEST_FindALSA "ON" CACHE BOOL "")
set(CMake_TEST_FindBLAS "ON" CACHE BOOL "")
set(CMake_TEST_FindBoost "ON" CACHE BOOL "")
set(CMake_TEST_FindBoost_Python "ON" CACHE BOOL "")
set(CMake_TEST_FindBZip2 "ON" CACHE BOOL "")
set(CMake_TEST_FindCups "ON" CACHE BOOL "")
set(CMake_TEST_FindCURL "ON" CACHE BOOL "")
set(CMake_TEST_FindDoxygen_Dot "ON" CACHE BOOL "")
set(CMake_TEST_FindDoxygen "ON" CACHE BOOL "")
set(CMake_TEST_FindEXPAT "ON" CACHE BOOL "")
set(CMake_TEST_FindFontconfig "ON" CACHE BOOL "")
set(CMake_TEST_FindFreetype "ON" CACHE BOOL "")
set(CMake_TEST_FindGDAL "ON" CACHE BOOL "")
set(CMake_TEST_FindGIF "ON" CACHE BOOL "")
set(CMake_TEST_FindGit "ON" CACHE BOOL "")
set(CMake_TEST_FindGLEW "ON" CACHE BOOL "")
set(CMake_TEST_FindGnuTLS "ON" CACHE BOOL "")
set(CMake_TEST_FindGSL "ON" CACHE BOOL "")
set(CMake_TEST_FindGTest "ON" CACHE BOOL "")
set(CMake_TEST_FindGTK2 "ON" CACHE BOOL "")
set(CMake_TEST_FindIconv "ON" CACHE BOOL "")
set(CMake_TEST_FindJPEG "ON" CACHE BOOL "")
set(CMake_TEST_FindJsonCpp "ON" CACHE BOOL "")
set(CMake_TEST_FindLAPACK "ON" CACHE BOOL "")
set(CMake_TEST_FindLibArchive "ON" CACHE BOOL "")
set(CMake_TEST_FindLibinput "ON" CACHE BOOL "")
set(CMake_TEST_FindLibLZMA "ON" CACHE BOOL "")
set(CMake_TEST_FindLibUV "ON" CACHE BOOL "")
set(CMake_TEST_FindLibXml2 "ON" CACHE BOOL "")
set(CMake_TEST_FindLibXslt "ON" CACHE BOOL "")
set(CMake_TEST_FindMPI_C "ON" CACHE BOOL "")
set(CMake_TEST_FindMPI_CXX "ON" CACHE BOOL "")
set(CMake_TEST_FindMPI_Fortran "ON" CACHE BOOL "")
set(CMake_TEST_FindMPI "ON" CACHE BOOL "")
set(CMake_TEST_FindODBC "ON" CACHE BOOL "")
set(CMake_TEST_FindOpenACC "ON" CACHE BOOL "")
set(CMake_TEST_FindOpenGL "ON" CACHE BOOL "")
set(CMake_TEST_FindOpenMP_C "ON" CACHE BOOL "")
set(CMake_TEST_FindOpenMP_CXX "ON" CACHE BOOL "")
set(CMake_TEST_FindOpenMP_Fortran "ON" CACHE BOOL "")
set(CMake_TEST_FindOpenMP "ON" CACHE BOOL "")
set(CMake_TEST_FindOpenSSL "ON" CACHE BOOL "")
set(CMake_TEST_FindPatch "ON" CACHE BOOL "")
set(CMake_TEST_FindPNG "ON" CACHE BOOL "")
set(CMake_TEST_FindPostgreSQL "ON" CACHE BOOL "")
set(CMake_TEST_FindProtobuf "ON" CACHE BOOL "")
set(CMake_TEST_FindPython "ON" CACHE BOOL "")
set(CMake_TEST_FindPython_NumPy "ON" CACHE BOOL "")
set(CMake_TEST_FindPython_PyPy "ON" CACHE BOOL "")
set(CMake_TEST_FindRuby "ON" CACHE BOOL "")
set(CMake_TEST_FindRuby_RVM "ON" CACHE BOOL "")
set(CMake_TEST_FindSDL "ON" CACHE BOOL "")
set(CMake_TEST_FindSQLite3 "ON" CACHE BOOL "")
set(CMake_TEST_FindTIFF "ON" CACHE BOOL "")
set(CMake_TEST_FindX11 "ON" CACHE BOOL "")
set(CMake_TEST_FindXalanC "ON" CACHE BOOL "")
set(CMake_TEST_FindXercesC "ON" CACHE BOOL "")
set(CMake_TEST_Fortran_SUBMODULES "ON" CACHE BOOL "")
set(CMake_TEST_IPO_WORKS_C "ON" CACHE BOOL "")
set(CMake_TEST_IPO_WORKS_CXX "ON" CACHE BOOL "")
set(CMake_TEST_IPO_WORKS_Fortran "ON" CACHE BOOL "")
set(CMake_TEST_ISPC "ON" CACHE STRING "")
set(CMake_TEST_Qt5 "ON" CACHE BOOL "")
set(CMake_TEST_UseSWIG "ON" CACHE BOOL "")
include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake")

View File

@@ -1 +1,7 @@
set(CMake_TEST_ISPC "ON" CACHE STRING "")
set(CMake_TEST_GUI "ON" CACHE BOOL "")
# Cover compilation with C++11 only and not higher standards.
set(CMAKE_CXX_STANDARD "11" CACHE STRING "")
include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora31_common.cmake")

View File

@@ -1 +1,2 @@
set(CMake_TEST_ISPC "ON" CACHE STRING "")
include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake")

View File

@@ -1,8 +1,2 @@
set(SPHINX_INFO ON CACHE BOOL "")
set(SPHINX_MAN ON CACHE BOOL "")
set(SPHINX_HTML ON CACHE BOOL "")
set(SPHINX_SINGLEHTML ON CACHE BOOL "")
set(SPHINX_QTHELP ON CACHE BOOL "")
set(SPHINX_TEXT ON CACHE BOOL "")
include("${CMAKE_CURRENT_LIST_DIR}/configure_sphinx.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake")

View File

@@ -0,0 +1,13 @@
# Disable formats not wanted in the package's documentation.
set(SPHINX_INFO OFF CACHE BOOL "")
set(SPHINX_SINGLEHTML OFF CACHE BOOL "")
set(SPHINX_TEXT OFF CACHE BOOL "")
# Set the destination directory for docs that packages expect.
set(CMAKE_DOC_DIR "doc/cmake" CACHE STRING "")
# Use a custom prefix to avoid conflicting with other builds.
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install-doc" CACHE PATH "")
include("${CMAKE_CURRENT_LIST_DIR}/configure_sphinx.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake")

View File

@@ -6,4 +6,10 @@ set(Java_JAVA_EXECUTABLE "" CACHE FILEPATH "")
set(Java_JAVAC_EXECUTABLE "" CACHE FILEPATH "")
set(Java_JAR_EXECUTABLE "" CACHE FILEPATH "")
# Qt binaries get placed inside the source directory, which causes them to not
# be included in the install-time rpath, but we still want them in the
# build-time rpath. CMake sets CMAKE_BUILD_WITH_INSTALL_RPATH to ON by default,
# so set it to OFF.
set(CMAKE_BUILD_WITH_INSTALL_RPATH OFF CACHE BOOL "")
set(BUILD_QtDialog ON CACHE BOOL "")

View File

@@ -1,2 +1,3 @@
set(CMake_TEST_GUI "ON" CACHE BOOL "")
include("${CMAKE_CURRENT_LIST_DIR}/configure_macos_common.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake")

View File

@@ -1,2 +1,3 @@
set(CMake_TEST_GUI "ON" CACHE BOOL "")
include("${CMAKE_CURRENT_LIST_DIR}/configure_macos_common.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake")

View File

@@ -0,0 +1,24 @@
set(CMake_DOC_ARTIFACT_PREFIX "$ENV{CI_PROJECT_DIR}/build/install-doc" CACHE PATH "")
# Set up install destinations as expected by the packaging scripts.
set(CMAKE_INSTALL_PREFIX "/" CACHE PATH "")
set(CMAKE_DOC_DIR "doc/cmake" CACHE STRING "")
# Settings for CMake packages for macOS.
set(CPACK_DMG_FORMAT "UDBZ" CACHE STRING "")
set(CMAKE_CXX_FLAGS "-stdlib=libc++" CACHE STRING "")
set(CMAKE_C_STANDARD "11" CACHE STRING "")
set(CMAKE_CXX_STANDARD "14" CACHE STRING "")
set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "")
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE STRING "")
set(CMAKE_SKIP_BOOTSTRAP_TEST "TRUE" CACHE STRING "")
set(CPACK_SYSTEM_NAME "Darwin-x86_64" CACHE STRING "")
set(BUILD_CursesDialog "ON" CACHE BOOL "")
set(BUILD_QtDialog "TRUE" CACHE BOOL "")
set(CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL "3" CACHE STRING "")
set(CMake_INSTALL_DEPENDENCIES "ON" CACHE BOOL "")
set(CMAKE_SKIP_RPATH "TRUE" CACHE BOOL "")
set(CMake_TEST_NO_FindPackageModeMakefileTest "TRUE" CACHE BOOL "")
include("${CMAKE_CURRENT_LIST_DIR}/configure_macos_common.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake")

View File

@@ -0,0 +1,6 @@
set(SPHINX_INFO ON CACHE BOOL "")
set(SPHINX_MAN ON CACHE BOOL "")
set(SPHINX_HTML ON CACHE BOOL "")
set(SPHINX_SINGLEHTML ON CACHE BOOL "")
set(SPHINX_QTHELP ON CACHE BOOL "")
set(SPHINX_TEXT ON CACHE BOOL "")

View File

@@ -1,3 +1,4 @@
set(CMake_TEST_WIX_NO_VERIFY "ON" CACHE BOOL "")
set(CMake_TEST_GUI "ON" CACHE BOOL "")
include("${CMAKE_CURRENT_LIST_DIR}/configure_windows_common.cmake")

View File

@@ -6,7 +6,7 @@ set(cmake_args
-C "${CMAKE_CURRENT_LIST_DIR}/configure_$ENV{CMAKE_CONFIGURATION}.cmake")
# Create an entry in CDash.
ctest_start(Experimental TRACK "${ctest_track}")
ctest_start("${ctest_model}" GROUP "${ctest_group}")
# Gather update information.
find_package(Git)

View File

@@ -13,6 +13,15 @@ if (CTEST_CMAKE_GENERATOR MATCHES "Visual Studio")
"^ExternalProjectUpdateSetup$")
endif ()
if (CMAKE_HOST_WIN32)
list(APPEND test_exclusions
# This test often fails with an undiagnosed subtle race due to the test
# re-using the same objects for many files. Some copy operations fail
# to open their input with ERROR_SHARING_VIOLATION.
"^Module.ExternalData$"
)
endif()
string(REPLACE ";" "|" test_exclusions "${test_exclusions}")
if (test_exclusions)
set(test_exclusions "(${test_exclusions})")

View File

@@ -10,6 +10,11 @@ ctest_start(APPEND)
include(ProcessorCount)
ProcessorCount(nproc)
if (NOT "$ENV{CTEST_MAX_PARALLELISM}" STREQUAL "")
if (nproc GREATER "$ENV{CTEST_MAX_PARALLELISM}")
set(nproc "$ENV{CTEST_MAX_PARALLELISM}")
endif ()
endif ()
include("${CMAKE_CURRENT_LIST_DIR}/ctest_exclusions.cmake")
ctest_test(

View File

@@ -1,12 +1,13 @@
cmake_minimum_required(VERSION 3.8)
include("${CMAKE_CURRENT_LIST_DIR}/gitlab_ci.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/env_$ENV{CMAKE_CONFIGURATION}.cmake" OPTIONAL)
set(cmake_args
-C "${CMAKE_CURRENT_LIST_DIR}/configure_$ENV{CMAKE_CONFIGURATION}.cmake")
# Create an entry in CDash.
ctest_start(Experimental TRACK "${ctest_track}")
ctest_start("${ctest_model}" GROUP "${ctest_group}")
# Gather update information.
find_package(Git)
@@ -33,6 +34,11 @@ endif ()
include(ProcessorCount)
ProcessorCount(nproc)
if (NOT "$ENV{CTEST_MAX_PARALLELISM}" STREQUAL "")
if (nproc GREATER "$ENV{CTEST_MAX_PARALLELISM}")
set(nproc "$ENV{CTEST_MAX_PARALLELISM}")
endif ()
endif ()
if (CTEST_CMAKE_GENERATOR STREQUAL "Unix Makefiles")
set(CTEST_BUILD_FLAGS "-j${nproc}")

View File

@@ -4,6 +4,12 @@ MAINTAINER Ben Boeckel <ben.boeckel@kitware.com>
COPY install_iwyu.sh /root/install_iwyu.sh
RUN sh /root/install_iwyu.sh
FROM debian:10 as rvm-build
MAINTAINER Ben Boeckel <ben.boeckel@kitware.com>
COPY install_rvm.sh /root/install_rvm.sh
RUN sh /root/install_rvm.sh
FROM debian:10
MAINTAINER Ben Boeckel <ben.boeckel@kitware.com>
@@ -13,3 +19,7 @@ RUN sh /root/install_deps.sh
COPY --from=iwyu-build /root/iwyu.tar.gz /root/iwyu.tar.gz
RUN tar -C / -xf /root/iwyu.tar.gz
RUN ln -s /usr/lib/llvm-6.0/bin/include-what-you-use /usr/bin/include-what-you-use-6.0
COPY --from=rvm-build /root/rvm.tar /root/rvm.tar
RUN tar -C /usr/local -xf /root/rvm.tar \
&& rm /root/rvm.tar

View File

@@ -19,4 +19,60 @@ apt-get install -y \
clang-6.0 \
libncurses6
# Packages needed to test find modules.
apt-get install -y \
alsa-utils \
doxygen graphviz \
gnutls-dev \
libarchive-dev \
libblas-dev \
libboost-dev \
libboost-filesystem-dev \
libboost-program-options-dev \
libboost-python-dev \
libboost-thread-dev \
libbz2-dev \
libcups2-dev \
libcurl4-gnutls-dev \
libfontconfig1-dev \
libfreetype6-dev \
libgdal-dev \
libgif-dev \
libgl1-mesa-dev \
libglew-dev \
libgsl-dev \
libgtest-dev \
libgtk2.0-dev \
libinput-dev \
libjpeg-dev \
libjsoncpp-dev \
liblapack-dev \
liblzma-dev \
libopenmpi-dev openmpi-bin \
libpng-dev \
libpq-dev postgresql-server-dev-11 \
libprotobuf-dev libprotobuf-c-dev libprotoc-dev protobuf-compiler \
libsdl-dev \
libsqlite3-dev \
libtiff-dev \
libuv1-dev \
libx11-dev \
libxalan-c-dev \
libxerces-c-dev \
libxml2-dev libxml2-utils \
libxslt-dev xsltproc \
python2 python2-dev python-numpy pypy pypy-dev \
python3 python3-dev python3-numpy pypy3 pypy3-dev python3-venv \
qtbase5-dev qtbase5-dev-tools \
ruby ruby-dev \
swig \
unixodbc-dev
# CMake_TEST_FindPython_IronPython
apt-get install -y \
libmono-system-windows-forms4.0-cil
curl -L -O https://github.com/IronLanguages/ironpython2/releases/download/ipy-2.7.10/ironpython_2.7.10.deb
dpkg -i ironpython_2.7.10.deb
rm ironpython_2.7.10.deb
apt-get clean

View File

@@ -0,0 +1,19 @@
#!/bin/sh
set -e
apt-get update
apt-get install -y \
curl \
gnupg2 \
procps
gpg2 --keyserver hkp://pool.sks-keyservers.net \
--recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 \
7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable
/usr/local/rvm/bin/rvm install ruby-2.7.0
tar -C /usr/local -cf /root/rvm.tar rvm

View File

@@ -1,5 +1,18 @@
FROM fedora:31 as rvm-build
MAINTAINER Ben Boeckel <ben.boeckel@kitware.com>
COPY install_rvm.sh /root/install_rvm.sh
RUN sh /root/install_rvm.sh
FROM fedora:31
MAINTAINER Ben Boeckel <ben.boeckel@kitware.com>
COPY install_deps.sh /root/install_deps.sh
RUN sh /root/install_deps.sh
COPY install_ispc.sh /root/install_ispc.sh
RUN sh /root/install_ispc.sh
COPY --from=rvm-build /root/rvm.tar /root/rvm.tar
RUN tar -C /usr/local -xf /root/rvm.tar \
&& rm /root/rvm.tar

View File

@@ -1,5 +1,7 @@
#!/bin/sh
set -e
# Install build requirements.
dnf install --setopt=install_weak_deps=False -y \
ncurses-devel \
@@ -22,6 +24,55 @@ dnf install --setopt=install_weak_deps=False -y \
# Tools needed for the test suite.
dnf install --setopt=install_weak_deps=False -y \
findutils \
file
file \
which
# Packages needed to test find modules.
dnf install --setopt=install_weak_deps=False -y \
alsa-lib-devel \
blas-devel \
boost-devel boost-python3-devel \
bzip2-devel \
cups-devel \
doxygen \
expat-devel \
fontconfig-devel \
freetype-devel \
gdal-devel \
giflib-devel \
glew-devel \
gnutls-devel \
gsl-devel \
gtest-devel \
gtk2-devel \
jsoncpp-devel \
lapack-devel \
libarchive-devel \
libcurl-devel \
libinput-devel systemd-devel \
libjpeg-turbo-devel \
libpng-devel \
libpq-devel postgresql-server-devel \
libtiff-devel \
libuv-devel \
libxml2-devel \
libxslt-devel \
openmpi-devel \
patch \
perl \
protobuf-devel protobuf-c-devel protobuf-lite-devel \
pypy2 pypy2-devel \
pypy3 pypy3-devel \
python2 python2-devel python2-numpy \
python3 python3-devel python3-numpy \
python3-jsmin python3-jsonschema \
ruby rubygems ruby-devel \
SDL-devel \
sqlite-devel \
swig \
unixODBC-devel \
xalan-c-devel \
xerces-c-devel \
xz-devel
dnf clean all

View File

@@ -0,0 +1,14 @@
#!/bin/sh
set -e
readonly version="1.13.0"
readonly sha256sum="8ab1189bd5db596b3eee9d9465d3528b6626a7250675d67102761bb0d284cd21"
readonly filename="ispc-v$version-linux"
readonly tarball="$filename.tar.gz"
echo "$sha256sum $tarball" > ispc.sha256sum
curl -OL "https://github.com/ispc/ispc/releases/download/v$version/$tarball"
sha256sum --check ispc.sha256sum
tar --strip-components=1 -C /usr/local -xf "$tarball" "$filename/bin/ispc"

View File

@@ -0,0 +1,18 @@
#!/bin/sh
set -e
gpg2 --keyserver hkp://pool.sks-keyservers.net \
--recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 \
7D2BAF1CF37B13E2069D6956105BD0E739499BDB
dnf install --setopt=install_weak_deps=False -y \
findutils \
procps \
which
curl -sSL https://get.rvm.io | bash -s stable
/usr/local/rvm/bin/rvm install ruby-2.7.0
tar -C /usr/local -cf /root/rvm.tar rvm

View File

@@ -0,0 +1,41 @@
cmake_minimum_required(VERSION 3.17)
set(version "3.8.6")
set(sha256sum "376e18eef7e3ea467f0e3af041b01fc7e2f12855506c2ab2653ceb5e0951212e")
set(dirname "python-${version}-embed-win-x86_64")
set(tarball "${dirname}.tar.xz")
# Download the file.
file(DOWNLOAD
"https://cmake.org/files/dependencies/${tarball}"
".gitlab/${tarball}"
STATUS download_status
EXPECTED_HASH "SHA256=${sha256sum}")
# Check the download status.
list(GET download_status 0 res)
if (res)
list(GET download_status 1 err)
message(FATAL_ERROR
"Failed to download ${tarball}: ${err}")
endif ()
# Extract the file.
execute_process(
COMMAND
"${CMAKE_COMMAND}"
-E tar
xzf "${tarball}"
WORKING_DIRECTORY ".gitlab"
RESULT_VARIABLE res
ERROR_VARIABLE err
ERROR_STRIP_TRAILING_WHITESPACE)
if (res)
message(FATAL_ERROR
"Failed to extract ${tarball}: ${err}")
endif ()
# Move to a predictable directory.
file(RENAME
".gitlab/${dirname}"
".gitlab/python3")

View File

@@ -6,7 +6,11 @@ set(qt_version_minor "15")
set(qt_version_patch "0")
# This URL is only visible inside of Kitware's network. Please use your own Qt
# Account to obtain these files.
set(qt_url_root "https://paraview.org/files/dependencies/internal/qt")
if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "package")
set(qt_url_root "https://cmake.org/files/dependencies")
else ()
set(qt_url_root "https://paraview.org/files/dependencies/internal/qt")
endif ()
# Determine the ABI to fetch for Qt.
if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "vs2015")
@@ -51,15 +55,21 @@ if (qt_platform STREQUAL "windows_x86")
set(qt_subdir "${qt_version}/msvc${msvc_year}_64")
elseif (qt_platform STREQUAL "mac_x64")
set(qt_build_stamp "202005140805")
set(qt_file_name_prefix "${qt_version}-0-${qt_build_stamp}")
foreach (qt_component IN ITEMS qtbase)
if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "package")
list(APPEND qt_files
"${qt_file_name_prefix}${qt_component}-MacOS-MacOS_10_13-Clang-MacOS-MacOS_10_13-X86_64.7z")
endforeach ()
"qt-5.6.2-macosx10.7-x86_64.tar.xz")
set(qt_subdir "qt-5.6.2-macosx10.7-x86_64")
else ()
set(qt_build_stamp "202005140805")
set(qt_file_name_prefix "${qt_version}-0-${qt_build_stamp}")
set(qt_subdir "${qt_version}/clang_64")
foreach (qt_component IN ITEMS qtbase)
list(APPEND qt_files
"${qt_file_name_prefix}${qt_component}-MacOS-MacOS_10_13-Clang-MacOS-MacOS_10_13-X86_64.7z")
endforeach ()
set(qt_subdir "${qt_version}/clang_64")
endif ()
else ()
message(FATAL_ERROR
"Unknown files for ${qt_platform}")
@@ -72,7 +82,11 @@ if (NOT qt_subdir)
endif ()
# Build up the path to the file to download.
set(qt_url_path "${qt_platform}/desktop/qt5_${qt_version_nodot}/qt.qt5.${qt_version_nodot}.${qt_abi}")
if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "package")
set(qt_url_path "")
else ()
set(qt_url_path "${qt_platform}/desktop/qt5_${qt_version_nodot}/qt.qt5.${qt_version_nodot}.${qt_abi}")
endif ()
set(qt_url_prefix "${qt_url_root}/${qt_url_path}")
# Include the file containing the hashes of the files that matter.

View File

@@ -9,3 +9,5 @@ set("5.15.0-0-202005150700qtbase-Windows-Windows_10-MSVC2015-Windows-Windows_10-
set("5.15.0-0-202005150700qtwinextras-Windows-Windows_10-MSVC2015-Windows-Windows_10-X86_64.7z_hash" 4bca3a8d8c7611e211a82d86b3396f8a622abe7859d5052452414642ec191844)
set("5.15.0-0-202005140805qtbase-MacOS-MacOS_10_13-Clang-MacOS-MacOS_10_13-X86_64.7z_hash" 04d867c81d2431f288c42c9752642759460b9468477de349368dcc8de0c8ddc4)
set("qt-5.6.2-macosx10.7-x86_64.tar.xz_hash" 2b60373ea60037ce356d4c9f5a8c1df9854127a2c55118252e1a2f5a5f4e0010)

View File

@@ -0,0 +1 @@
set(ENV{MY_RUBY_HOME} "/usr/local/rvm/rubies/ruby-2.7.0")

View File

@@ -0,0 +1,2 @@
set(ENV{MY_RUBY_HOME} "/usr/local/rvm/rubies/ruby-2.7.0")
set(ENV{PATH} "/usr/lib64/openmpi/bin:$ENV{PATH}")

View File

@@ -5,10 +5,10 @@ endif ()
# Set up the source and build paths.
set(CTEST_SOURCE_DIRECTORY "$ENV{CI_PROJECT_DIR}")
set(CTEST_BINARY_DIRECTORY "${CTEST_SOURCE_DIRECTORY}/build")
if (NOT "$ENV{CTEST_SOURCE_SUBDIRECTORY}" STREQUAL "")
string(APPEND CTEST_SOURCE_DIRECTORY "/$ENV{CTEST_SOURCE_SUBDIRECTORY}")
endif ()
set(CTEST_BINARY_DIRECTORY "${CTEST_SOURCE_DIRECTORY}/build")
if ("$ENV{CMAKE_CONFIGURATION}" STREQUAL "")
message(FATAL_ERROR
@@ -19,6 +19,7 @@ endif ()
# Set the build metadata.
set(CTEST_BUILD_NAME "$ENV{CI_PROJECT_NAME}-$ENV{CMAKE_CONFIGURATION}")
set(CTEST_SITE "gitlab-ci")
set(ctest_model "Experimental")
# Default to Release builds.
if (NOT "$ENV{CMAKE_BUILD_TYPE}" STREQUAL "")
@@ -45,14 +46,26 @@ if (NOT "$ENV{CMAKE_GENERATOR_TOOLSET}" STREQUAL "")
set(CTEST_CMAKE_GENERATOR_TOOLSET "$ENV{CMAKE_GENERATOR_TOOLSET}")
endif ()
# Determine the track to submit to.
set(ctest_track "Experimental")
# Determine the group to submit to.
set(ctest_group "Experimental")
if (NOT "$ENV{CI_MERGE_REQUEST_ID}" STREQUAL "")
set(ctest_track "merge-requests")
set(ctest_group "merge-requests")
elseif (NOT "$ENV{CMAKE_CI_PROJECT_CONTINUOUS_BRANCH}" STREQUAL "" AND "$ENV{CMAKE_CI_PROJECT_CONTINUOUS_BRANCH}" STREQUAL "$ENV{CI_COMMIT_BRANCH}" AND NOT "$ENV{CMAKE_CI_JOB_CONTINUOUS}" STREQUAL "")
set(ctest_model "Continuous")
if (NOT "$ENV{CMAKE_CI_JOB_HELP}" STREQUAL "")
set(ctest_group "Continuous Help")
else()
set(ctest_group "Continuous")
endif()
string(PREPEND CTEST_BUILD_NAME "continuous-")
elseif (NOT "$ENV{CMAKE_CI_NIGHTLY}" STREQUAL "")
set(ctest_model "Nightly")
set(ctest_group "Nightly Expected")
string(PREPEND CTEST_BUILD_NAME "nightly-")
elseif ("$ENV{CI_PROJECT_PATH}" STREQUAL "cmake/cmake")
if ("$ENV{CI_COMMIT_REF_NAME}" STREQUAL "master")
set(ctest_track "master")
set(ctest_group "master")
elseif ("$ENV{CI_COMMIT_REF_NAME}" STREQUAL "release")
set(ctest_track "release")
set(ctest_group "release")
endif ()
endif ()

View File

@@ -2,17 +2,17 @@
set -e
readonly version="0.2.13"
case "$( uname -s )" in
Linux)
version="0.2.13"
shatool="sha256sum"
sha256sum="28a5499e340865b08b632306b435913beb590fbd7b49a3f887a623b459fabdeb"
platform="x86_64-unknown-linux-musl"
;;
Darwin)
version="gfe63078"
shatool="shasum -a 256"
sha256sum="f564e948abadfc9e409eb1cd7babf24c6784057d5506c3b0a04cdd37cd830ae9"
sha256sum="60a0302b1d7227f7ef56abd82266353f570d27c6e850c56c6448bf62def38888"
platform="x86_64-apple-darwin"
;;
*)
@@ -20,6 +20,7 @@ case "$( uname -s )" in
exit 1
;;
esac
readonly version
readonly shatool
readonly sha256sum
readonly platform
@@ -27,10 +28,17 @@ readonly platform
readonly filename="sccache-$version-$platform"
readonly tarball="$filename.tar.gz"
if [ "$( uname -s )" = "Darwin" ]; then
url="https://paraview.org/files/dependencies"
else
url="https://github.com/mozilla/sccache/releases/download/$version"
fi
readonly url
cd .gitlab
echo "$sha256sum $tarball" > sccache.sha256sum
curl -OL "https://github.com/mozilla/sccache/releases/download/$version/$tarball"
curl -OL "$url/$tarball"
$shatool --check sccache.sha256sum
tar xf "$tarball"
mv "$filename/sccache" .

View File

@@ -11,10 +11,29 @@
GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci"
LAUNCHER: "scl enable devtoolset-6 rh-python36 --"
.linux_prep_source:
image: "fedora:32"
variables:
GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci"
.linux_package:
variables:
GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci"
LAUNCHER: "scl enable devtoolset-6 rh-python36 --"
.linux_package_x86_64:
extends: .linux_package
image: "kitware/cmake:build-linux-x86_64-deps-2020-04-02@sha256:77e9ab183f34680990db9da5945473e288f0d6556bce79ecc1589670d656e157"
variables:
CMAKE_ARCH: x86_64
### Debian
.debian10:
image: "kitware/cmake:ci-debian10-x86_64-2020-04-27"
image: "kitware/cmake:ci-debian10-x86_64-2020-10-03"
variables:
GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci"
@@ -30,7 +49,7 @@
### Fedora
.fedora31:
image: "kitware/cmake:ci-fedora31-x86_64-2020-06-01"
image: "kitware/cmake:ci-fedora31-x86_64-2020-10-20"
variables:
GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci"
@@ -54,8 +73,22 @@
CTEST_SOURCE_SUBDIRECTORY: "Utilities/Sphinx"
CMake_SKIP_INSTALL: 1
.fedora31_sphinx_package:
extends: .fedora31
variables:
CMAKE_CONFIGURATION: fedora31_sphinx_package
CTEST_SOURCE_SUBDIRECTORY: "Utilities/Sphinx"
#### Build and test
.debian10_ninja:
extends: .debian10
variables:
CMAKE_CONFIGURATION: debian10_ninja
CTEST_NO_WARNINGS_ALLOWED: 1
.fedora31_ninja:
extends: .fedora31
@@ -112,6 +145,14 @@
- linux
- linux-3.17 # Needed to be able to load Fedora's Qt libraries.
.linux_builder_tags_x11:
tags:
- cmake
- docker
- linux
- linux-3.17 # Needed to be able to load Fedora's Qt libraries.
- x11
.linux_builder_tags_cuda:
tags:
- cmake
@@ -128,6 +169,29 @@
- cmake --version
- ninja --version
.cmake_prep_source_linux:
stage: prep
script:
- *before_script_linux
- dnf install --setopt=install_weak_deps=False -y git-core
- v="$(.gitlab/ci/cmake_version.sh)"
- mkdir -p build/
- git archive --format=tgz "--prefix=cmake-$v/" -o "build/cmake-$v.tar.gz" HEAD
- git -c core.autocrlf=true -c core.eol=crlf archive --format=zip --prefix="cmake-$v/" -o "build/cmake-$v.zip" HEAD
interruptible: true
.cmake_prep_doc_linux:
stage: prep
script:
- *before_script_linux
- "$LAUNCHER ctest -VV -S .gitlab/ci/ctest_configure.cmake"
- "$LAUNCHER ctest -VV -S .gitlab/ci/ctest_build.cmake"
interruptible: true
.cmake_build_linux:
stage: build
@@ -151,6 +215,42 @@
interruptible: true
.cmake_build_linux_package:
stage: build
script:
# Bootstrap.
- cp -v Utilities/Release/linux/$CMAKE_ARCH/cache.txt build/CMakeCache.txt
# Make sccache available.
- .gitlab/ci/sccache.sh
- export PATH=$PWD/.gitlab:$PATH
# Append sccache settings to the cache.
- echo "CMAKE_C_COMPILER_LAUNCHER:STRING=sccache" >> build/CMakeCache.txt
- echo "CMAKE_CXX_COMPILER_LAUNCHER:STRING=sccache" >> build/CMakeCache.txt
# CI settings.
- echo "CMake_TEST_INSTALL:BOOL=OFF" >> build/CMakeCache.txt
- echo "CMAKE_INSTALL_PREFIX:PATH=$PWD/build/install" >> build/CMakeCache.txt
- echo "CMAKE_SKIP_INSTALL_ALL_DEPENDENCY:BOOL=ON" >> build/CMakeCache.txt
# Appease Git. The Git in this container is old (1.7) and doesn't
# understand some things. But, it doesn't need to, so make it blind.
- mkdir -p .git/info
- echo "* -crlf" >> .git/info/attributes
- git reset --hard
# Bootstrap
- cd build/
- '$LAUNCHER ../bootstrap --parallel=$(nproc) --docdir=doc/cmake -- "-DCMake_DOC_ARTIFACT_PREFIX=$CI_PROJECT_DIR/build/install-doc"'
# FIXME: When CTest can drive an external CMake for the build as well,
# use the scripts here.
- "$LAUNCHER make -j$(nproc)"
# NOTE: This regex matches that used in the release build.
- "$LAUNCHER bin/ctest --output-on-failure -j$(nproc) -R '^(CMake\\.|CMakeLib\\.|CMakeServerLib\\.|RunCMake\\.ctest_memcheck)'"
# Make a package.
- bin/cpack -G TGZ
- bin/cpack -G STGZ
- sccache --show-stats
interruptible: true
.cmake_build_release_linux:
stage: build
@@ -168,6 +268,11 @@
- echo "CMake_TEST_INSTALL:BOOL=OFF" >> build/CMakeCache.txt
- echo "CMAKE_INSTALL_PREFIX:PATH=$PWD/build/install" >> build/CMakeCache.txt
- echo "CMAKE_SKIP_INSTALL_ALL_DEPENDENCY:BOOL=ON" >> build/CMakeCache.txt
# Appease Git. The Git in this container is old (1.7) and doesn't
# understand some things. But, it doesn't need to, so make it blind.
- mkdir -p .git/info
- echo "* -crlf" >> .git/info/attributes
- git reset --hard
# Bootstrap
- cd build/
- "$LAUNCHER ../bootstrap --parallel=$(nproc) --docdir=doc/cmake"

View File

@@ -8,6 +8,8 @@
# TODO: Factor this out so that each job selects the Xcode version to
# use so that different versions can be tested in a single pipeline.
DEVELOPER_DIR: "/Applications/Xcode-11.7.app/Contents/Developer"
# Avoid conflicting with other projects running on the same machine.
SCCACHE_SERVER_PORT: 4227
### Build and test
@@ -37,6 +39,14 @@
CTEST_NO_WARNINGS_ALLOWED: 1
CMAKE_GENERATOR: "Unix Makefiles"
.macos_package:
extends: .macos_build
variables:
CMAKE_CONFIGURATION: macos_package
CTEST_NO_WARNINGS_ALLOWED: 1
CMake_SKIP_INSTALL: 1
### External testing
.macos_xcode:
@@ -56,6 +66,15 @@
- xcode-11.7
- nonconcurrent
.macos_builder_tags_package:
tags:
- cmake # Since this is a bare runner, pin to a project.
- macos
- shell
- xcode-11.7
- nonconcurrent
- finder
.macos_builder_ext_tags:
tags:
- cmake # Since this is a bare runner, pin to a project.
@@ -91,6 +110,24 @@
interruptible: true
.cmake_build_macos_package:
stage: build
script:
- *before_script_macos
- .gitlab/ci/sccache.sh
# Allow the server to already be running.
- "sccache --start-server || :"
- sccache --show-stats
- ctest -VV -S .gitlab/ci/ctest_configure.cmake
- ctest -VV -S .gitlab/ci/ctest_build.cmake
- sccache --show-stats
- cd build
- cpack -G TGZ
- cpack -G DragNDrop
interruptible: true
.cmake_test_macos:
stage: test

View File

@@ -5,6 +5,8 @@
.windows:
variables:
GIT_CLONE_PATH: "$CI_BUILDS_DIR\\cmake ci ext\\$CI_CONCURRENT_ID"
# Avoid conflicting with other projects running on the same machine.
SCCACHE_SERVER_PORT: 4227
### Build and test
@@ -80,6 +82,9 @@
- ninja --version
- cmake -P .gitlab/ci/download_qt.cmake
- Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\qt\bin;$env:PATH"
- cmake -P .gitlab/ci/download_python3.cmake
- Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\python3;$env:PATH"
- python --version
.cmake_build_windows:
stage: build

View File

@@ -2,6 +2,13 @@
.run_manually:
rules:
- if: '$CMAKE_CI_PACKAGE == "true"'
when: never
- if: '$CMAKE_CI_NIGHTLY == "true"'
when: on_success
- if: '($CMAKE_CI_PROJECT_CONTINUOUS_BRANCH != "" && $CI_COMMIT_BRANCH == $CMAKE_CI_PROJECT_CONTINUOUS_BRANCH && $CMAKE_CI_JOB_CONTINUOUS == "true")'
when: delayed
start_in: 5 minutes
- if: '$CI_MERGE_REQUEST_ID'
when: manual
- if: '$CI_PROJECT_PATH == "cmake/cmake"'
@@ -11,8 +18,32 @@
.run_automatically:
rules:
- if: '$CMAKE_CI_PACKAGE == "true"'
when: never
- if: '$CMAKE_CI_NIGHTLY == "true"'
when: on_success
- if: '($CMAKE_CI_PROJECT_CONTINUOUS_BRANCH != "" && $CI_COMMIT_BRANCH == $CMAKE_CI_PROJECT_CONTINUOUS_BRANCH && $CMAKE_CI_JOB_CONTINUOUS == "true")'
when: on_success
- if: '$CI_MERGE_REQUEST_ID'
when: on_success
- if: '$CI_PROJECT_PATH == "cmake/cmake"'
when: on_success
- when: never
.run_dependent:
rules:
- if: '$CMAKE_CI_PACKAGE == "true"'
when: never
- if: '$CMAKE_CI_NIGHTLY == "true"'
when: on_success
- if: '$CI_MERGE_REQUEST_ID'
when: on_success
- if: '$CI_PROJECT_PATH == "cmake/cmake"'
when: on_success
- when: never
.run_only_for_package:
rules:
- if: '$CMAKE_CI_PACKAGE == "true"'
when: on_success
- when: never

18
.gitlab/upload.yml Normal file
View File

@@ -0,0 +1,18 @@
# Steps for uploading artifacts
.rsync_upload:
image: "fedora:32"
stage: upload
tags:
- docker
- linux
- build
environment:
name: rsync-upload
script:
- ls build/
- dnf install -y --setopt=install_weak_deps=False rsync openssh-clients
- chmod 400 $RSYNC_BINARY_KEY
- ssh-keygen -y -f $RSYNC_BINARY_KEY > $RSYNC_BINARY_KEY.pub
- rsync -tv --recursive -e "ssh -i $RSYNC_BINARY_KEY -o StrictHostKeyChecking=no -o LogLevel=ERROR" build/ kitware@public.kitware.com:$RSYNC_DESTINATION/

View File

@@ -1048,6 +1048,7 @@ syn keyword cmakeVariable contained
\ CMAKE_HOST_UNIX
\ CMAKE_HOST_WIN32
\ CMAKE_IGNORE_PATH
\ CMAKE_ISPC_HEADER_DIRECTORY
\ CMAKE_IMPORT_LIBRARY_PREFIX
\ CMAKE_IMPORT_LIBRARY_SUFFIX
\ CMAKE_INCLUDE_CURRENT_DIR

View File

@@ -108,6 +108,11 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE)
endif()
endif()
# Inform STL library header wrappers whether to use system versions.
configure_file(${CMake_SOURCE_DIR}/Utilities/std/cmSTL.hxx.in
${CMake_BINARY_DIR}/Utilities/cmSTL.hxx
@ONLY)
# set the internal encoding of CMake to UTF-8
set(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_UTF8)

View File

@@ -6,7 +6,9 @@
set(CTEST_PROJECT_NAME "CMake")
set(CTEST_NIGHTLY_START_TIME "1:00:00 UTC")
set(CTEST_DROP_METHOD "http")
if(NOT CTEST_DROP_METHOD STREQUAL "https")
set(CTEST_DROP_METHOD "http")
endif()
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=CMake")
set(CTEST_DROP_SITE_CDASH TRUE)

View File

@@ -53,6 +53,12 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^parisc")
endif()
endif()
# Use 64-bit off_t on 32-bit Linux
if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SIZEOF_VOID_P EQUAL 4)
# ensure 64bit offsets are used for filesystem accesses for 32bit compilation
add_definitions(-D_FILE_OFFSET_BITS=64)
endif()
# Workaround for TOC Overflow on ppc64
set(bigTocFlag "")
if(CMAKE_SYSTEM_NAME STREQUAL "AIX" AND

View File

@@ -1,6 +1,8 @@
add_compile_definitions
-----------------------
.. versionadded:: 3.12
Add preprocessor definitions to the compilation of source files.
.. code-block:: cmake

View File

@@ -102,13 +102,22 @@ The options are:
a target later in the command line (i.e. as a command argument rather
than as the command to execute).
Whenever a target is used as a command to execute or is mentioned in a
generator expression as a command argument, a target-level dependency
will be added automatically so that the mentioned target will be built
before any target using this custom command. However this does NOT add
a file-level dependency that would cause the custom command to re-run
whenever the executable is recompiled. List target names with
the ``DEPENDS`` option to add such file-level dependencies.
Whenever one of the following target based generator expressions are used as
a command to execute or is mentioned in a command argument, a target-level
dependency will be added automatically so that the mentioned target will be
built before any target using this custom command
(see policy :policy:`CMP0112`).
* ``TARGET_FILE``
* ``TARGET_LINKER_FILE``
* ``TARGET_SONAME_FILE``
* ``TARGET_PDB_FILE``
This target-level dependency does NOT add a file-level dependency that would
cause the custom command to re-run whenever the executable is recompiled.
List target names with the ``DEPENDS`` option to add such file-level
dependencies.
``COMMENT``
Display the given message before the commands are executed at

View File

@@ -81,10 +81,15 @@ The options are:
a target later in the command line (i.e. as a command argument rather
than as the command to execute).
Whenever a target is used as a command to execute or is mentioned in a
generator expression as a command argument, a target-level dependency
will be added automatically so that the mentioned target will be built
before this custom target.
Whenever one of the following target based generator expressions are used as
a command to execute or is mentioned in a command argument, a target-level
dependency will be added automatically so that the mentioned target will be
built before this custom target (see policy :policy:`CMP0112`).
* ``TARGET_FILE``
* ``TARGET_LINKER_FILE``
* ``TARGET_SONAME_FILE``
* ``TARGET_PDB_FILE``
The command and arguments are optional and if not specified an empty
target will be created.

View File

@@ -14,7 +14,7 @@ Normal Libraries
add_library(<name> [STATIC | SHARED | MODULE]
[EXCLUDE_FROM_ALL]
[source1] [source2 ...])
[<source>...])
Adds a library target called ``<name>`` to be built from the source files
listed in the command invocation. (The source files can be omitted here
@@ -64,48 +64,12 @@ See also :prop_sf:`HEADER_FILE_ONLY` on what to do if some sources are
pre-processed, and you want to have the original sources reachable from
within IDE.
Imported Libraries
^^^^^^^^^^^^^^^^^^
.. code-block:: cmake
add_library(<name> <SHARED|STATIC|MODULE|OBJECT|UNKNOWN> IMPORTED
[GLOBAL])
An :ref:`IMPORTED library target <Imported Targets>` references a library
file located outside the project. No rules are generated to build it, and
the :prop_tgt:`IMPORTED` target property is ``True``. The target name has
scope in the directory in which it is created and below, but the ``GLOBAL``
option extends visibility. It may be referenced like any target built
within the project. ``IMPORTED`` libraries are useful for convenient
reference from commands like :command:`target_link_libraries`. Details
about the imported library are specified by setting properties whose names
begin in ``IMPORTED_`` and ``INTERFACE_``.
The most important properties are:
* :prop_tgt:`IMPORTED_LOCATION` (and its per-configuration
variant :prop_tgt:`IMPORTED_LOCATION_<CONFIG>`) which specifies the
location of the main library file on disk.
* :prop_tgt:`IMPORTED_OBJECTS` (and :prop_tgt:`IMPORTED_OBJECTS_<CONFIG>`)
for object libraries, specifies the locations of object files on disk.
* :prop_tgt:`PUBLIC_HEADER` files to be installed during :command:`install` invocation
See documentation of the ``IMPORTED_*`` and ``INTERFACE_*`` properties
for more information.
An ``UNKNOWN`` library type is typically only used in the implementation of
:ref:`Find Modules`. It allows the path to an imported library (often found
using the :command:`find_library` command) to be used without having to know
what type of library it is. This is especially useful on Windows where a
static library and a DLL's import library both have the same file extension.
Object Libraries
^^^^^^^^^^^^^^^^
.. code-block:: cmake
add_library(<name> OBJECT <src>...)
add_library(<name> OBJECT [<source>...])
Creates an :ref:`Object Library <Object Libraries>`. An object library
compiles source files but does not archive or link their object files into a
@@ -129,6 +93,112 @@ systems (such as Xcode) may not like targets that have only object files, so
consider adding at least one real source file to any target that references
``$<TARGET_OBJECTS:objlib>``.
Interface Libraries
^^^^^^^^^^^^^^^^^^^
.. code-block:: cmake
add_library(<name> INTERFACE)
Creates an :ref:`Interface Library <Interface Libraries>`.
An ``INTERFACE`` library target does not compile sources and does
not produce a library artifact on disk. However, it may have
properties set on it and it may be installed and exported.
Typically, ``INTERFACE_*`` properties are populated on an interface
target using the commands:
* :command:`set_property`,
* :command:`target_link_libraries(INTERFACE)`,
* :command:`target_link_options(INTERFACE)`,
* :command:`target_include_directories(INTERFACE)`,
* :command:`target_compile_options(INTERFACE)`,
* :command:`target_compile_definitions(INTERFACE)`, and
* :command:`target_sources(INTERFACE)`,
and then it is used as an argument to :command:`target_link_libraries`
like any other target.
An interface library created with the above signature has no source files
itself and is not included as a target in the generated buildsystem.
Since CMake 3.19, an interface library target may be created with
source files:
.. code-block:: cmake
add_library(<name> INTERFACE [<source>...] [EXCLUDE_FROM_ALL])
Source files may be listed directly in the ``add_library`` call or added
later by calls to :command:`target_sources` with the ``PRIVATE`` or
``PUBLIC`` keywords.
If an interface library has source files (i.e. the :prop_tgt:`SOURCES`
target property is set), it will appear in the generated buildsystem
as a build target much like a target defined by the
:command:`add_custom_target` command. It does not compile any sources,
but does contain build rules for custom commands created by the
:command:`add_custom_command` command.
.. note::
In most command signatures where the ``INTERFACE`` keyword appears,
the items listed after it only become part of that target's usage
requirements and are not part of the target's own settings. However,
in this signature of ``add_library``, the ``INTERFACE`` keyword refers
to the library type only. Sources listed after it in the ``add_library``
call are ``PRIVATE`` to the interface library and do not appear in its
:prop_tgt:`INTERFACE_SOURCES` target property.
Imported Libraries
^^^^^^^^^^^^^^^^^^
.. code-block:: cmake
add_library(<name> <type> IMPORTED [GLOBAL])
Creates an :ref:`IMPORTED library target <Imported Targets>` called ``<name>``.
No rules are generated to build it, and the :prop_tgt:`IMPORTED` target
property is ``True``. The target name has scope in the directory in which
it is created and below, but the ``GLOBAL`` option extends visibility.
It may be referenced like any target built within the project.
``IMPORTED`` libraries are useful for convenient reference from commands
like :command:`target_link_libraries`. Details about the imported library
are specified by setting properties whose names begin in ``IMPORTED_`` and
``INTERFACE_``.
The ``<type>`` must be one of:
``STATIC``, ``SHARED``, ``MODULE``, ``UNKNOWN``
References a library file located outside the project. The
:prop_tgt:`IMPORTED_LOCATION` target property (or its per-configuration
variant :prop_tgt:`IMPORTED_LOCATION_<CONFIG>`) specifies the
location of the main library file on disk. In the case of a ``SHARED``
library on Windows, the :prop_tgt:`IMPORTED_IMPLIB` target property
(or its per-configuration variant :prop_tgt:`IMPORTED_IMPLIB_<CONFIG>`)
specifies the location of the DLL import library file (``.lib`` or
``.dll.a``) on disk, and the ``IMPORTED_LOCATION`` is the location of
the ``.dll`` runtime library (and is optional).
Additional usage requirements may be specified in ``INTERFACE_*`` properties.
An ``UNKNOWN`` library type is typically only used in the implementation of
:ref:`Find Modules`. It allows the path to an imported library (often found
using the :command:`find_library` command) to be used without having to know
what type of library it is. This is especially useful on Windows where a
static library and a DLL's import library both have the same file extension.
``OBJECT``
References a set of object files located outside the project.
The :prop_tgt:`IMPORTED_OBJECTS` target property (or its per-configuration
variant :prop_tgt:`IMPORTED_OBJECTS_<CONFIG>`) specifies the locations of
object files on disk.
Additional usage requirements may be specified in ``INTERFACE_*`` properties.
``INTERFACE``
Does not reference any library or object files on disk, but may
specify usage requirements in ``INTERFACE_*`` properties.
See documentation of the ``IMPORTED_*`` and ``INTERFACE_*`` properties
for more information.
Alias Libraries
^^^^^^^^^^^^^^^
@@ -153,35 +223,3 @@ to modify properties of ``<target>``, that is, it may not be used as the
operand of :command:`set_property`, :command:`set_target_properties`,
:command:`target_link_libraries` etc. An ``ALIAS`` target may not be
installed or exported.
Interface Libraries
^^^^^^^^^^^^^^^^^^^
.. code-block:: cmake
add_library(<name> INTERFACE [IMPORTED [GLOBAL]])
Creates an :ref:`Interface Library <Interface Libraries>`. An ``INTERFACE``
library target does not directly create build output, though it may
have properties set on it and it may be installed, exported and
imported. Typically the ``INTERFACE_*`` properties are populated on
the interface target using the commands:
* :command:`set_property`,
* :command:`target_link_libraries(INTERFACE)`,
* :command:`target_link_options(INTERFACE)`,
* :command:`target_include_directories(INTERFACE)`,
* :command:`target_compile_options(INTERFACE)`,
* :command:`target_compile_definitions(INTERFACE)`, and
* :command:`target_sources(INTERFACE)`,
and then it is used as an argument to :command:`target_link_libraries`
like any other target.
An ``INTERFACE`` :ref:`Imported Target <Imported Targets>` may also be
created with this signature. An ``IMPORTED`` library target references a
library defined outside the project. The target name has scope in the
directory in which it is created and below, but the ``GLOBAL`` option
extends visibility. It may be referenced like any target built within
the project. ``IMPORTED`` libraries are useful for convenient reference
from commands like :command:`target_link_libraries`.

View File

@@ -1,6 +1,8 @@
add_link_options
----------------
.. versionadded:: 3.13
Add options to the link step for executable, shared library or module
library targets in the current directory and below that are added after
this command is invoked.

View File

@@ -10,8 +10,9 @@ Add a test to the project to be run by :manual:`ctest(1)`.
[WORKING_DIRECTORY <dir>]
[COMMAND_EXPAND_LISTS])
Adds a test called ``<name>``. The test name may not contain spaces,
quotes, or other characters special in CMake syntax. The options are:
Adds a test called ``<name>``. The test name may contain arbitrary
characters, expressed as a :ref:`Quoted Argument` or :ref:`Bracket Argument`
if necessary. See policy :policy:`CMP0110`. The options are:
``COMMAND``
Specify the test command-line. If ``<command>`` specifies an

View File

@@ -1,6 +1,8 @@
cmake_language
--------------
.. versionadded:: 3.18
Call meta-operations on CMake commands.
Synopsis
@@ -8,8 +10,9 @@ Synopsis
.. parsed-literal::
cmake_language(`CALL`_ <command> [<args>...])
cmake_language(`CALL`_ <command> [<arg>...])
cmake_language(`EVAL`_ CODE <code>...)
cmake_language(`DEFER`_ <options>... CALL <command> [<arg>...])
Introduction
^^^^^^^^^^^^
@@ -26,7 +29,7 @@ Calling Commands
.. code-block:: cmake
cmake_language(CALL <command> [<args>...])
cmake_language(CALL <command> [<arg>...])
Calls the named ``<command>`` with the given arguments (if any).
For example, the code:
@@ -97,3 +100,121 @@ is equivalent to
)
include(${CMAKE_CURRENT_BINARY_DIR}/eval.cmake)
Deferring Calls
^^^^^^^^^^^^^^^
.. versionadded:: 3.19
.. _DEFER:
.. code-block:: cmake
cmake_language(DEFER <options>... CALL <command> [<arg>...])
Schedules a call to the named ``<command>`` with the given arguments (if any)
to occur at a later time. By default, deferred calls are executed as if
written at the end of the current directory's ``CMakeLists.txt`` file,
except that they run even after a :command:`return` call. Variable
references in arguments are evaluated at the time the deferred call is
executed.
The options are:
``DIRECTORY <dir>``
Schedule the call for the end of the given directory instead of the
current directory. The ``<dir>`` may reference either a source
directory or its corresponding binary directory. Relative paths are
treated as relative to the current source directory.
The given directory must be known to CMake, being either the top-level
directory or one added by :command:`add_subdirectory`. Furthermore,
the given directory must not yet be finished processing. This means
it can be the current directory or one of its ancestors.
``ID <id>``
Specify an identification for the deferred call.
The ``<id>`` may not be empty and may not begin with a capital letter ``A-Z``.
The ``<id>`` may begin with an underscore (``_``) only if it was generated
automatically by an earlier call that used ``ID_VAR`` to get the id.
``ID_VAR <var>``
Specify a variable in which to store the identification for the
deferred call. If ``ID <id>`` is not given, a new identification
will be generated and the generated id will start with an underscore (``_``).
The currently scheduled list of deferred calls may be retrieved:
.. code-block:: cmake
cmake_language(DEFER [DIRECTORY <dir>] GET_CALL_IDS <var>)
This will store in ``<var>`` a :ref:`semicolon-separated list <CMake Language
Lists>` of deferred call ids.
Details of a specific call may be retrieved from its id:
.. code-block:: cmake
cmake_language(DEFER [DIRECTORY <dir>] GET_CALL <id> <var>)
This will store in ``<var>`` a :ref:`semicolon-separated list <CMake Language
Lists>` in which the first element is the name of the command to be
called, and the remaining elements are its unevaluated arguments (any
contained ``;`` characters are included literally and cannot be distinguished
from multiple arguments). If multiple calls are scheduled with the same id,
this retrieves the first one. If no call is scheduled with the given id,
this stores an empty string in the variable.
Deferred calls may be canceled by their id:
.. code-block:: cmake
cmake_language(DEFER [DIRECTORY <dir>] CANCEL_CALL <id>...)
This cancels all deferred calls matching any of the given ids.
Unknown ids are silently ignored.
Deferred Call Examples
""""""""""""""""""""""
For example, the code:
.. code-block:: cmake
cmake_language(DEFER CALL message "${deferred_message}")
cmake_language(DEFER ID_VAR id CALL message "Cancelled Message")
cmake_language(DEFER CANCEL_CALL ${id})
message("Immediate Message")
set(deferred_message "Deferred Message")
prints::
Immediate Message
Deferred Message
The ``Cancelled Message`` is never printed because its command is
cancelled. The ``deferred_message`` variable reference is not evaluated
until the call site, so it can be set after the deferred call is scheduled.
In order to evaluate variable references immediately when scheduling a
deferred call, wrap it using ``cmake_language(EVAL)``. However, note that
arguments will be re-evaluated in the deferred call, though that can be
avoided by using bracket arguments. For example:
.. code-block:: cmake
set(deferred_message "Deferred Message 1")
set(re_evaluated [[${deferred_message}]])
cmake_language(EVAL CODE "
cmake_language(DEFER CALL message [[${deferred_message}]])
cmake_language(DEFER CALL message \"${re_evaluated}\")
")
message("Immediate Message")
set(deferred_message "Deferred Message 2")
also prints::
Immediate Message
Deferred Message 1
Deferred Message 2

View File

@@ -1,6 +1,8 @@
cmake_parse_arguments
---------------------
.. versionadded:: 3.5
Parse function or macro arguments.
.. code-block:: cmake

828
Help/command/cmake_path.rst Normal file
View File

@@ -0,0 +1,828 @@
cmake_path
----------
.. versionadded:: 3.19
Filesystem path manipulation command.
This command is dedicated to the manipulation of objects of type path which
represent paths on a filesystem. Only syntactic aspects of paths are handled:
the pathname may represent a non-existing path or even one that is not allowed
to exist on the current file system or OS.
For operations involving the filesystem, have a look at the :command:`file`
command.
The path name has the following syntax:
1. ``root-name`` (optional): identifies the root on a filesystem with multiple
roots (such as ``"C:"`` or ``"//myserver"``).
2. ``root-directory`` (optional): a directory separator that, if present, marks
this path as absolute. If it is missing (and the first element other than
the ``root-name`` is a ``item-name``), then the path is relative.
Zero or more of the following:
3. ``item-name``: sequence of characters that aren't directory separators. This
name may identify a file, a hard link, a symbolic link, or a directory. Two
special ``item-names`` are recognized:
* ``dot``: the item name consisting of a single dot character ``.`` is a
directory name that refers to the current directory.
* ``dot-dot``: the item name consisting of two dot characters ``..`` is a
directory name that refers to the parent directory.
4. ``directory-separator``: the forward slash character ``/``. If this
character is repeated, it is treated as a single directory separator:
``/usr///////lib`` is the same as ``/usr/lib``.
.. _FILENAME_DEF:
A path has a filename if it does not ends with a ``directory-separator``. The
filename is the last ``item-name`` of the path.
.. _EXTENSION_DEF:
A :ref:`filename <FILENAME_DEF>` can have an extension. By default, the
extension is defined as the sub-string beginning at the leftmost period
(including the period) and until the end of the pathname. When the option
``LAST_ONLY`` is specified, the extension is the sub-string beginning at the
rightmost period.
The following exceptions apply:
* If the first character in the :ref:`filename <FILENAME_DEF>` is a period,
that period is ignored (a filename like ``".profile"`` is not treated as an
extension).
* If the pathname is either ``.`` or ``..``.
.. note::
``cmake_path`` command handles paths in the format of the build system, not
the target system. So this is not generally applicable to the target system
in cross-compiling environment.
For all commands, ``<path>`` placeholder expect a variable name. An error will
be raised if the variable does not exist, except for `APPEND`_ and
`CMAKE_PATH`_ sub-commands. ``<input>`` placeholder expect a string literal.
``[<input>...]`` placeholder expect zero or more arguments. ``<output>``
placeholder expect a variable name.
.. note::
``cmake_path`` command does not support list of paths. The ``<path>``
placeholder must store only one path name.
To initialize a path variable, three possibilities can be used:
1. :command:`set` command.
2. :ref:`cmake_path(APPEND) <APPEND>` command. Can be used to build a path from
already available path fragments.
3. :ref:`cmake_path(CMAKE_PATH) <CMAKE_PATH>` command. Mainly used to build a
path variable from a native path.
.. code-block:: cmake
# To build the path "${CMAKE_CURRENT_SOURCE_DIR}/data"
set (path1 "${CMAKE_CURRENT_SOURCE_DIR}/data")
cmake_path(APPEND path2 "${CMAKE_CURRENT_SOURCE_DIR}" "data")
cmake_path(CMAKE_PATH path3 "${CMAKE_CURRENT_SOURCE_DIR}/data")
`Modification`_ and `Generation`_ sub-commands store the result in-place or in
the variable specified by ``OUTPUT_VARIABLE`` option. All other sub-commands,
except `CMAKE_PATH`_, store the result in the required ``<output>`` variable.
Sub-commands supporting ``NORMALIZE`` option will :ref:`normalize <NORMAL_PATH>`
the path.
Synopsis
^^^^^^^^
.. parsed-literal::
`Decomposition`_
cmake_path(`GET`_ <path> :ref:`ROOT_NAME <GET_ROOT_NAME>` <output>)
cmake_path(`GET`_ <path> :ref:`ROOT_DIRECTORY <GET_ROOT_DIRECTORY>` <output>)
cmake_path(`GET`_ <path> :ref:`ROOT_PATH <GET_ROOT_PATH>` <output>)
cmake_path(`GET`_ <path> :ref:`FILENAME <GET_FILENAME>` <output>)
cmake_path(`GET`_ <path> :ref:`EXTENSION <GET_EXTENSION>` [LAST_ONLY] <output>)
cmake_path(`GET`_ <path> :ref:`STEM <GET_STEM>` [LAST_ONLY] <output>)
cmake_path(`GET`_ <path> :ref:`RELATIVE_PATH <GET_RELATIVE_PATH>` <output>)
cmake_path(`GET`_ <path> :ref:`PARENT_PATH <GET_PARENT_PATH>` <output>)
`Modification`_
cmake_path(`APPEND`_ <path> [<input>...] [OUTPUT_VARIABLE <output>])
cmake_path(`CONCAT`_ <path> [<input>...] [OUTPUT_VARIABLE <output>])
cmake_path(`REMOVE_FILENAME`_ <path> [OUTPUT_VARIABLE <output>])
cmake_path(`REPLACE_FILENAME`_ <path> <input> [OUTPUT_VARIABLE <output>])
cmake_path(`REMOVE_EXTENSION`_ <path> [LAST_ONLY]
[OUTPUT_VARIABLE <output>])
cmake_path(`REPLACE_EXTENSION`_ <path> [LAST_ONLY] <input>
[OUTPUT_VARIABLE <output>])
`Generation`_
cmake_path(`NORMAL_PATH`_ <path> [OUTPUT_VARIABLE <output>])
cmake_path(`RELATIVE_PATH`_ <path> [BASE_DIRECTORY <path>]
[OUTPUT_VARIABLE <output>])
cmake_path(`PROXIMATE_PATH`_ <path> [BASE_DIRECTORY <path>]
[OUTPUT_VARIABLE <output>])
cmake_path(`ABSOLUTE_PATH`_ <path> [BASE_DIRECTORY <path>] [NORMALIZE]
[OUTPUT_VARIABLE <output>])
`Conversion`_
cmake_path(`CMAKE_PATH`_ <path> [NORMALIZE] <input>)
cmake_path(`NATIVE_PATH`_ <path> [NORMALIZE] <output>)
cmake_path(`CONVERT`_ <input> `TO_CMAKE_PATH_LIST`_ <output>)
cmake_path(`CONVERT`_ <input> `TO_NATIVE_PATH_LIST`_ <output>)
`Comparison`_
cmake_path(`COMPARE`_ <path> <OP> <input> <output>)
`Query`_
cmake_path(`HAS_ROOT_NAME`_ <path> <output>)
cmake_path(`HAS_ROOT_DIRECTORY`_ <path> <output>)
cmake_path(`HAS_ROOT_PATH`_ <path> <output>)
cmake_path(`HAS_FILENAME`_ <path> <output>)
cmake_path(`HAS_EXTENSION`_ <path> <output>)
cmake_path(`HAS_STEM`_ <path> <output>)
cmake_path(`HAS_RELATIVE_PATH`_ <path> <output>)
cmake_path(`HAS_PARENT_PATH`_ <path> <output>)
cmake_path(`IS_ABSOLUTE`_ <path> <output>)
cmake_path(`IS_RELATIVE`_ <path> <output>)
cmake_path(`IS_PREFIX`_ <path> <input> [NORMALIZE] <output>)
`Hashing`_
cmake_path(`HASH`_ <path> [NORMALIZE] <output>)
Decomposition
^^^^^^^^^^^^^
.. _GET:
.. _GET_ROOT_NAME:
.. code-block:: cmake
cmake_path(GET <path> ROOT_NAME <output>)
Returns the root name of the path. If the path does not include a root name,
returns an empty path.
.. note::
Only ``Windows`` system has the concept of ``root-name``, so on all other
systems, it is always an empty path.
For example:
.. code-block:: cmake
set (path "c:/a")
cmake_path (GET path ROOT_NAME output)
message ("Root name is \"${output}\"")
Will display::
Root name is "c:"
.. _GET_ROOT_DIRECTORY:
.. code-block:: cmake
cmake_path(GET <path> ROOT_DIRECTORY <output>)
Returns the root directory of the path. If the path does not include a root
directory, returns an empty path.
For example:
.. code-block:: cmake
set (path "c:/a")
cmake_path (GET path ROOT_DIRECTORY output)
message ("Root directory is \"${output}\"")
Will display::
Root directory is "/"
.. _GET_ROOT_PATH:
.. code-block:: cmake
cmake_path(GET <path> ROOT_PATH <output>)
Returns the root path of the path. If the path does not include a root path,
returns an empty path.
Effectively, returns the following: ``root-name root-directory``.
For example:
.. code-block:: cmake
set (path "c:/a")
cmake_path (GET path ROOT_PATH output)
message ("Root path is \"${output}\"")
Will display::
Root path is "c:/"
.. _GET_FILENAME:
.. code-block:: cmake
cmake_path(GET <path> FILENAME <output>)
Returns the :ref:`filename <FILENAME_DEF>` component of the path. If the path
ends with a ``directory-separator``, there is no filename, so returns an empty
path.
For example:
.. code-block:: cmake
set (path "/a")
cmake_path (GET path FILENAME output)
message ("First filename is \"${output}\"")
set (path "/a/")
cmake_path (GET path FILENAME output)
message ("Second filename is \"${output}\"")
Will display::
First filename is "a"
Second filename is ""
.. _GET_EXTENSION:
.. code-block:: cmake
cmake_path(GET <path> EXTENSION [LAST_ONLY] <output>)
Returns the :ref:`extension <EXTENSION_DEF>` of the filename component.
If the :ref:`filename <FILENAME_DEF>` component of the path contains a period
(``.``), and is not one of the special filesystem elements ``dot`` or
``dot-dot``, then the :ref:`extension <EXTENSION_DEF>` is returned.
For example:
.. code-block:: cmake
set (path "name.ext1.ext2")
cmake_path (GET path EXTENSION result)
message ("Full extension is \"${result}\"")
cmake_path (GET path EXTENSION LAST_ONLY result)
message ("Last extension is \"${result}\"")
Will display::
Full extension is ".ext1.ext2"
Last extension is ".ext2"
The following exceptions apply:
* If the first character in the filename is a period, that period is ignored
(a filename like ``".profile"`` is not treated as an extension).
* If the pathname is either ``.`` or ``..``, or if
:ref:`filename <FILENAME_DEF>` component does not contain the ``.``
character, then an empty path is returned.
.. _GET_STEM:
.. code-block:: cmake
cmake_path(GET <path> STEM [LAST_ONLY] <output>)
Returns the :ref:`filename <FILENAME_DEF>` component of the path stripped of
its :ref:`extension <EXTENSION_DEF>`.
For Example:
.. code-block:: cmake
set (path "name.ext1.ext2")
cmake_path (GET path STEM result)
message ("Filename without the extension is \"${result}\"")
cmake_path (GET path STEM LAST_ONLY result)
message ("Filename whiteout the last extension is \"${result}\"")
Will display::
Filename without the extension is "name"
Filename without the last extension is "name.ext1"
The following exceptions apply:
* If the first character in the filename is a period, that period is ignored
(a filename like ``".profile"`` is not treated as an extension).
* If the filename is one of the special filesystem components ``dot`` or
``dot-dot``, or if it has no periods, the function returns the entire
:ref:`filename <FILENAME_DEF>` component.
.. _GET_RELATIVE_PATH:
.. code-block:: cmake
cmake_path(GET <path> RELATIVE_PATH <output>)
Returns path relative to ``root-path``, that is, a pathname composed of
every component of ``<path>`` after ``root-path``. If ``<path>`` is an empty
path, returns an empty path.
For Example:
.. code-block:: cmake
set (path "/a/b")
cmake_path (GET path RELATIVE_PATH result)
message ("Relative path is \"${result}\"")
set (path "/")
cmake_path (GET path RELATIVE_PATH result)
message ("Relative path is \"${result}\"")
Will display::
Relative path is "a/b"
Relative path is ""
.. _GET_PARENT_PATH:
.. code-block:: cmake
cmake_path(GET <path> PARENT_PATH <output>)
Returns the path to the parent directory.
If `HAS_RELATIVE_PATH`_ sub-command returns false, the result is a copy of
``<path>``. Otherwise, the result is ``<path>`` with one fewer element.
For Example:
.. code-block:: cmake
set (path "c:/a/b")
cmake_path (GET path PARENT_PATH result)
message ("Parent path is \"${result}\"")
set (path "c:/")
cmake_path (GET path PARENT_PATH result)
message ("Parent path is \"${result}\"")
Will display::
Parent path is "c:/a"
Relative path is "c:/"
Modification
^^^^^^^^^^^^
.. _APPEND:
.. code-block:: cmake
cmake_path(APPEND <path> [<input>...] [OUTPUT_VARIABLE <output>])
Append all the ``<input>`` arguments to the ``<path>`` using ``/`` as
``directory-separator``.
For each ``<input>`` argument, the following algorithm (pseudo-code) applies:
.. code-block:: cmake
IF (<input>.is_absolute() OR
(<input>.has_root_name() AND
NOT <input>.root_name() STREQUAL <path>.root_name()))
replaces <path> with <input>
RETURN()
ENDIF()
IF (<input>.has_root_directory())
remove any root-directory and the entire relative path from <path>
ELSEIF (<path>.has_filename() OR
(NOT <path>.has_root_directory() OR <path>.is_absolute()))
appends directory-separator to <path>
ENDIF()
appends <input> omitting any root-name to <path>
.. _CONCAT:
.. code-block:: cmake
cmake_path(CONCAT <path> [<input>...] [OUTPUT_VARIABLE <output>])
Concatenates all the ``<input>`` arguments to the ``<path>`` without
``directory-separator``.
.. _REMOVE_FILENAME:
.. code-block:: cmake
cmake_path(REMOVE_FILENAME <path> [OUTPUT_VARIABLE <output>])
Removes the :ref:`filename <FILENAME_DEF>` component (as returned by
:ref:`GET ... FILENAME <GET_FILENAME>`) from ``<path>``.
After this function returns, if change is done in-place, `HAS_FILENAME`_
returns false for ``<path>``.
For Example:
.. code-block:: cmake
set (path "/a/b")
cmake_path (REMOVE_FILENAME path)
message ("First path is \"${path}\"")
cmake_path (REMOVE_FILENAME path)
message ("Second path is \"${result}\"")
Will display::
First path is "/a/"
Second path is "/a/"
.. _REPLACE_FILENAME:
.. code-block:: cmake
cmake_path(REPLACE_FILENAME <path> <input> [OUTPUT_VARIABLE <output>])
Replaces the :ref:`filename <FILENAME_DEF>` component from ``<path>`` with
``<input>``.
If ``<path>`` has no filename component (`HAS_FILENAME`_ returns false), the
path is unchanged.
Equivalent to the following:
.. code-block:: cmake
cmake_path(HAS_FILENAME path has_filename)
if (has_filename)
cmake_path(REMOVE_FILENAME path)
cmake_path(APPEND path "replacement");
endif()
.. _REMOVE_EXTENSION:
.. code-block:: cmake
cmake_path(REMOVE_EXTENSION <path> [LAST_ONLY] [OUTPUT_VARIABLE <output>])
Removes the :ref:`extension <EXTENSION_DEF>`, if any, from ``<path>``.
.. _REPLACE_EXTENSION:
.. code-block:: cmake
cmake_path(REPLACE_EXTENSION <path> [LAST_ONLY] <input>
[OUTPUT_VARIABLE <output>])
Replaces the :ref:`extension <EXTENSION_DEF>` with ``<input>``.
1. If ``<path>`` has an :ref:`extension <EXTENSION_DEF>`
(`HAS_EXTENSION`_ is true), it is removed.
2. A ``dot`` character is appended to ``<path>``, if ``<input>`` is not empty
or does not begin with a ``dot`` character.
3. ``<input>`` is appended as if `CONCAT`_ was used.
Equivalent to the following:
.. code-block:: cmake
cmake_path(REMOVE_EXTENSION path)
if (NOT "input" MATCHES "^\\.")
cmake_path(CONCAT path ".")
endif()
cmake_path(CONCAT path "input");
Generation
^^^^^^^^^^
.. _NORMAL_PATH:
.. code-block:: cmake
cmake_path(NORMAL_PATH <path> [OUTPUT_VARIABLE <output>])
Normalize ``<path>``.
A path can be normalized by following this algorithm:
1. If the path is empty, stop (normal form of an empty path is an empty
path).
2. Replace each ``directory-separator`` (which may consist of multiple
separators) with a single ``/``.
3. Replace each ``directory-separator`` character in the ``root-name`` with
``/``.
4. Remove each ``dot`` and any immediately following ``directory-separator``.
5. Remove each non-dot-dot filename immediately followed by a
``directory-separator`` and a ``dot-dot``, along with any immediately
following ``directory-separator``.
6. If there is ``root-directory``, remove all ``dot-dots`` and any
``directory-separators`` immediately following them.
7. If the last filename is ``dot-dot``, remove any trailing
``directory-separator``.
8. If the path is empty, add a ``dot`` (normal form of ``./`` is ``.``).
.. _cmake_path-RELATIVE_PATH:
.. _RELATIVE_PATH:
.. code-block:: cmake
cmake_path(RELATIVE_PATH <path> [BASE_DIRECTORY <path>]
[OUTPUT_VARIABLE <output>])
Returns ``<path>`` made relative to ``BASE_DIRECTORY`` argument. If
``BASE_DIRECTORY`` is not specified, the default base directory will be
:variable:`CMAKE_CURRENT_SOURCE_DIR`.
For reference, the algorithm used to compute the relative path is described
`here <https://en.cppreference.com/w/cpp/filesystem/path/lexically_normal>`_.
.. _PROXIMATE_PATH:
.. code-block:: cmake
cmake_path(PROXIMATE_PATH <path> [BASE_DIRECTORY <path>]
[OUTPUT_VARIABLE <output>])
If the value of `RELATIVE_PATH`_ is not an empty path, return
it. Otherwise return ``<path>``.
If ``BASE_DIRECTORY`` is not specified, the default base directory will be
:variable:`CMAKE_CURRENT_SOURCE_DIR`.
.. _ABSOLUTE_PATH:
.. code-block:: cmake
cmake_path(ABSOLUTE_PATH <path> [BASE_DIRECTORY <path>] [NORMALIZE]
[OUTPUT_VARIABLE <output>])
If ``<path>`` is a relative path (`IS_RELATIVE`_ is true), it is evaluated
relative to the given base directory specified by ``BASE_DIRECTORY`` option.
If ``BASE_DIRECTORY`` is not specifired, the default base directory will be
:variable:`CMAKE_CURRENT_SOURCE_DIR`.
When ``NORMALIZE`` option is specified, the path is :ref:`normalized
<NORMAL_PATH>` after the path computation.
Because ``cmake_path`` does not access to the filesystem, symbolic links are
not resolved. To compute a real path, use :command:`file(REAL_PATH)`
command.
Conversion
^^^^^^^^^^
.. _cmake_path-CMAKE_PATH:
.. _CMAKE_PATH:
.. code-block:: cmake
cmake_path(CMAKE_PATH <path> [NORMALIZE] <input>)
Converts a native ``<input>`` path into cmake-style path with forward-slashes
(``/``). On Windows, the long filename marker is taken into account.
When ``NORMALIZE`` option is specified, the path is :ref:`normalized
<NORMAL_PATH>` before the conversion.
For Example:
.. code-block:: cmake
set (native_path "c:\\a\\b/..\\c")
cmake_path (CMAKE_PATH path "${native_path}")
message ("CMake path is \"${path}\"")
cmake_path (CMAKE_PATH path NORMALIZE "${native_path}")
message ("Normalized CMake path is \"${path}\"")
Will display::
CMake path is "c:/a/b/../c"
Normalized CMake path is "c:/a/c"
.. _cmake_path-NATIVE_PATH:
.. _NATIVE_PATH:
.. code-block:: cmake
cmake_path(NATIVE_PATH <path> [NORMALIZE] <output>)
Converts a cmake-style ``<path>`` into a native
path with platform-specific slashes (``\`` on Windows and ``/`` elsewhere).
When ``NORMALIZE`` option is specified, the path is :ref:`normalized
<NORMAL_PATH>` before the conversion.
.. _CONVERT:
.. _cmake_path-TO_CMAKE_PATH_LIST:
.. _TO_CMAKE_PATH_LIST:
.. code-block:: cmake
cmake_path(CONVERT <input> TO_CMAKE_PATH_LIST <output> [NORMALIZE])
Converts a native ``<input>`` path into cmake-style path with forward-slashes
(``/``). On Windows, the long filename marker is taken into account. The input can
be a single path or a system search path like ``$ENV{PATH}``. A search path
will be converted to a cmake-style list separated by ``;`` characters. The
result of the conversion is stored in the ``<output>`` variable.
When ``NORMALIZE`` option is specified, the path is :ref:`normalized
<NORMAL_PATH>` before the conversion.
.. _cmake_path-TO_NATIVE_PATH_LIST:
.. _TO_NATIVE_PATH_LIST:
.. code-block:: cmake
cmake_path(CONVERT <input> TO_NATIVE_PATH_LIST <output> [NORMALIZE])
Converts a cmake-style ``<input>`` path into a native path with
platform-specific slashes (``\`` on Windows and ``/`` elsewhere). The input can
be a single path or a cmake-style list. A list will be converted into a native
search path. The result of the conversion is stored in the ``<output>``
variable.
When ``NORMALIZE`` option is specified, the path is :ref:`normalized
<NORMAL_PATH>` before the conversion.
For Example:
.. code-block:: cmake
set (paths "/a/b/c" "/x/y/z")
cmake_path (CONVERT "${paths}" TO_NATIVE_PATH_LIST native_paths)
message ("Native path list is \"${native_paths}\"")
Will display, on Windows::
Native path list is "\a\b\c;\x\y\z"
And on the all other systems::
Native path list is "/a/b/c:/x/y/z"
Comparison
^^^^^^^^^^
.. _COMPARE:
.. code-block:: cmake
cmake_path(COMPARE <path> EQUAL <input> <output>)
cmake_path(COMPARE <path> NOT_EQUAL <input> <output>)
Compares the lexical representations of the path and another path.
For testing equality, the following algorithm (pseudo-code) apply:
.. code-block:: cmake
IF (NOT <path>.root_name() STREQUAL <input>.root_name())
returns FALSE
ELSEIF (<path>.has_root_directory() XOR <input>.has_root_directory())
returns FALSE
ENDIF()
returns TRUE or FALSE if the relative portion of <path> is
lexicographically equal or not to the relative portion of <input>.
Comparison is performed path component-wise
Query
^^^^^
.. _HAS_ROOT_NAME:
.. code-block:: cmake
cmake_path(HAS_ROOT_NAME <path> <output>)
Checks if ``<path>`` has ``root-name``.
.. _HAS_ROOT_DIRECTORY:
.. code-block:: cmake
cmake_path(HAS_ROOT_DIRECTORY <path> <output>)
Checks if ``<path>`` has ``root-directory``.
.. _HAS_ROOT_PATH:
.. code-block:: cmake
cmake_path(HAS_ROOT_PATH <path> <output>)
Checks if ``<path>`` has root path.
Effectively, checks if ``<path>`` has ``root-name`` and ``root-directory``.
.. _HAS_FILENAME:
.. code-block:: cmake
cmake_path(HAS_FILENAME <path> <output>)
Checks if ``<path>`` has a :ref:`filename <FILENAME_DEF>`.
.. _HAS_EXTENSION:
.. code-block:: cmake
cmake_path(HAS_EXTENSION <path> <output>)
Checks if ``<path>`` has an :ref:`extension <EXTENSION_DEF>`. If the first
character in the filename is a period, it is not treated as an extension (for
example ".profile").
.. _HAS_STEM:
.. code-block:: cmake
cmake_path(HAS_STEM <path> <output>)
Checks if ``<path>`` has stem (:ref:`GET ... STEM <GET_STEM>` returns a non
empty path).
.. _HAS_RELATIVE_PATH:
.. code-block:: cmake
cmake_path(HAS_RELATIVE_PATH <path> <output>)
Checks if ``<path>`` has relative path (`GET_RELATIVE_PATH`_ returns a
non-empty path).
.. _HAS_PARENT_PATH:
.. code-block:: cmake
cmake_path(HAS_PARENT_PATH <path> <output>)
Checks if ``<path>`` has parent path. The result is true except if the path is
only composed of a :ref:`filename <FILENAME_DEF>`.
.. _IS_ABSOLUTE:
.. code-block:: cmake
cmake_path(IS_ABSOLUTE <path> <output>)
Checks if ``<path>`` is absolute.
An absolute path is a path that unambiguously identifies the location of a file
without reference to an additional starting location.
.. _IS_RELATIVE:
.. code-block:: cmake
cmake_path(IS_RELATIVE <path> <output>)
Checks if path is relative (i.e. not :ref:`absolute <IS_ABSOLUTE>`).
.. _IS_PREFIX:
.. code-block:: cmake
cmake_path(IS_PREFIX <path> <input> [NORMALIZE] <output>)
Checks if ``<path>`` is the prefix of ``<input>``.
When ``NORMALIZE`` option is specified, the paths are :ref:`normalized
<NORMAL_PATH>` before the check.
Hashing
^^^^^^^
.. _HASH:
.. code-block:: cmake
cmake_path(HASH <path> [NORMALIZE] <output>)
Compute hash value of ``<path>`` such that if for two paths (``p1`` and ``p2``)
are equal (:ref:`COMPARE ... EQUAL <COMPARE>`) then hash value of p1 is equal
to hash value of p2.
When ``NORMALIZE`` option is specified, the paths are :ref:`normalized
<NORMAL_PATH>` before the check.

View File

@@ -7,6 +7,7 @@ Copy a file to another location and modify its contents.
configure_file(<input> <output>
[COPYONLY] [ESCAPE_QUOTES] [@ONLY]
[NO_SOURCE_PERMISSIONS]
[NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ])
Copies an ``<input>`` file to an ``<output>`` file and substitutes
@@ -82,6 +83,11 @@ The arguments are:
Restrict variable replacement to references of the form ``@VAR@``.
This is useful for configuring scripts that use ``${VAR}`` syntax.
``NO_SOURCE_PERMISSIONS``
Does not transfer the file permissions of the original file to the copy.
The copied file permissions default to the standard 644 value
(-rw-r--r--).
``NEWLINE_STYLE <style>``
Specify the newline style for the output file. Specify
``UNIX`` or ``LF`` for ``\n`` newlines, or specify

View File

@@ -1,6 +1,8 @@
continue
--------
.. versionadded:: 3.2
Continue to the top of enclosing foreach or while loop.
.. code-block:: cmake

View File

@@ -9,7 +9,8 @@ Enable a language (CXX/C/OBJC/OBJCXX/Fortran/etc)
Enables support for the named language in CMake. This is
the same as the :command:`project` command but does not create any of the extra
variables that are created by the project command. Example languages
are ``CXX``, ``C``, ``CUDA``, ``OBJC``, ``OBJCXX``, ``Fortran``, and ``ASM``.
are ``CXX``, ``C``, ``CUDA``, ``OBJC``, ``OBJCXX``, ``Fortran``,
``ISPC``, and ``ASM``.
If enabling ``ASM``, enable it last so that CMake can check whether
compilers for other languages like ``C`` work for assembly too.

View File

@@ -23,7 +23,8 @@ Execute one or more child processes.
[ERROR_STRIP_TRAILING_WHITESPACE]
[ENCODING <name>]
[ECHO_OUTPUT_VARIABLE]
[ECHO_ERROR_VARIABLE])
[ECHO_ERROR_VARIABLE]
[COMMAND_ERROR_IS_FATAL <ANY|LAST>])
Runs the given sequence of one or more commands.
@@ -116,6 +117,19 @@ Options:
This is analogous to the ``tee`` Unix command.
``COMMAND_ERROR_IS_FATAL <ANY|LAST>``
The option following ``COMMAND_ERROR_IS_FATAL`` determines the behavior when
an error is encountered:
``ANY``
If any of the commands in the list of commands fail, the
``execute_process()`` command halts with an error.
``LAST``
If the last command in the list of commands fails, the
``execute_process()`` command halts with an error. Commands earlier in the
list will not cause a fatal error.
If more than one ``OUTPUT_*`` or ``ERROR_*`` option is given for the
same pipe the precedence is not specified.
If no ``OUTPUT_*`` or ``ERROR_*`` options are given the output will

View File

@@ -3,6 +3,21 @@ file
File manipulation command.
This command is dedicated to file and path manipulation requiring access to the
filesystem.
For other path manipulation, handling only syntactic aspects, have a look at
:command:`cmake_path` command.
.. note::
The sub-commands `RELATIVE_PATH`_, `TO_CMAKE_PATH`_ and `TO_NATIVE_PATH`_ has
been superseded, respectively, by sub-commands
:ref:`RELATIVE_PATH <cmake_path-RELATIVE_PATH>`,
:ref:`CONVERT ... TO_CMAKE_PATH_LIST <cmake_path-TO_CMAKE_PATH_LIST>` and
:ref:`CONVERT ... TO_NATIVE_PATH_LIST <cmake_path-TO_NATIVE_PATH_LIST>` of
:command:`cmake_path` command.
Synopsis
^^^^^^^^
@@ -30,13 +45,16 @@ Synopsis
file(`SIZE`_ <filename> <out-var>)
file(`READ_SYMLINK`_ <linkname> <out-var>)
file(`CREATE_LINK`_ <original> <linkname> [...])
file(`CHMOD`_ <files>... <directories>... PERMISSIONS <permissions>... [...])
file(`CHMOD_RECURSE`_ <files>... <directories>... PERMISSIONS <permissions>... [...])
`Path Conversion`_
file(`REAL_PATH`_ <path> <out-var> [BASE_DIRECTORY <dir>])
file(`RELATIVE_PATH`_ <out-var> <directory> <file>)
file({`TO_CMAKE_PATH`_ | `TO_NATIVE_PATH`_} <path> <out-var>)
`Transfer`_
file(`DOWNLOAD`_ <url> <file> [...])
file(`DOWNLOAD`_ <url> [<file>] [...])
file(`UPLOAD`_ <file> <url> [...])
`Locking`_
@@ -449,7 +467,7 @@ modified.
file(GENERATE OUTPUT output-file
<INPUT input-file|CONTENT content>
[CONDITION expression])
[CONDITION expression] [TARGET target])
Generate an output file for each build configuration supported by the current
:manual:`CMake Generator <cmake-generators(7)>`. Evaluate
@@ -479,6 +497,11 @@ from the input content to produce the output content. The options are:
with respect to the value of :variable:`CMAKE_CURRENT_BINARY_DIR`.
See policy :policy:`CMP0070`.
``TARGET <target>``
Specify which target to use when evaluating generator expressions that
require a target for evaluation (e.g. ``$<COMPILE_FEATURES:...>``,
``$<TARGET_PROPERTY:prop>``).
Exactly one ``CONTENT`` or ``INPUT`` option must be given. A specific
``OUTPUT`` file may be named by at most one invocation of ``file(GENERATE)``.
Generated files are modified and their timestamp updated on subsequent cmake
@@ -737,9 +760,70 @@ creating the link fails. It can be useful for handling situations such as
``<original>`` and ``<linkname>`` being on different drives or mount points,
which would make them unable to support a hard link.
.. _CHMOD:
.. code-block:: cmake
file(CHMOD <files>... <directories>...
[PERMISSIONS <permissions>...]
[FILE_PERMISSIONS <permissions>...]
[DIRECTORY_PERMISSIONS <permissions>...])
Set the permissions for the ``<files>...`` and ``<directories>...`` specified.
Valid permissions are ``OWNER_READ``, ``OWNER_WRITE``, ``OWNER_EXECUTE``,
``GROUP_READ``, ``GROUP_WRITE``, ``GROUP_EXECUTE``, ``WORLD_READ``,
``WORLD_WRITE``, ``WORLD_EXECUTE``.
Valid combination of keywords are:
``PERMISSIONS``
All items are changed.
``FILE_PERMISSIONS``
Only files are changed.
``DIRECTORY_PERMISSIONS``
Only directories are changed.
``PERMISSIONS`` and ``FILE_PERMISSIONS``
``FILE_PERMISSIONS`` overrides ``PERMISSIONS`` for files.
``PERMISSIONS`` and ``DIRECTORY_PERMISSIONS``
``DIRECTORY_PERMISSIONS`` overrides ``PERMISSIONS`` for directories.
``FILE_PERMISSIONS`` and ``DIRECTORY_PERMISSIONS``
Use ``FILE_PERMISSIONS`` for files and ``DIRECTORY_PERMISSIONS`` for
directories.
.. _CHMOD_RECURSE:
.. code-block:: cmake
file(CHMOD_RECURSE <files>... <directories>...
[PERMISSIONS <permissions>...]
[FILE_PERMISSIONS <permissions>...]
[DIRECTORY_PERMISSIONS <permissions>...])
Same as `CHMOD`_, but change the permissions of files and directories present in
the ``<directories>...`` recursively.
Path Conversion
^^^^^^^^^^^^^^^
.. _REAL_PATH:
.. code-block:: cmake
file(REAL_PATH <path> <out-var> [BASE_DIRECTORY <dir>])
Compute the absolute path to an existing file or directory with symlinks
resolved.
If the provided ``<path>`` is a relative path, it is evaluated relative to the
given base directory ``<dir>``. If no base directory is provided, the default
base directory will be :variable:`CMAKE_CURRENT_SOURCE_DIR`.
.. _RELATIVE_PATH:
.. code-block:: cmake
@@ -776,11 +860,14 @@ Transfer
.. code-block:: cmake
file(DOWNLOAD <url> <file> [<options>...])
file(DOWNLOAD <url> [<file>] [<options>...])
file(UPLOAD <file> <url> [<options>...])
The ``DOWNLOAD`` mode downloads the given ``<url>`` to a local ``<file>``.
The ``UPLOAD`` mode uploads a local ``<file>`` to a given ``<url>``.
The ``DOWNLOAD`` subcommand downloads the given ``<url>`` to a local ``<file>``.
If ``<file>`` is not specified for ``file(DOWNLOAD)``, the file is not saved.
This can be useful if you want to know if a file can be downloaded (for example,
to check that it exists) without actually saving it anywhere. The ``UPLOAD``
mode uploads a local ``<file>`` to a given ``<url>``.
Options to both ``DOWNLOAD`` and ``UPLOAD`` are:
@@ -853,10 +940,12 @@ Additional options to ``DOWNLOAD`` are:
Verify that the downloaded content hash matches the expected value, where
``ALGO`` is one of the algorithms supported by ``file(<HASH>)``.
If it does not match, the operation fails with an error.
If it does not match, the operation fails with an error. It is an error to
specify this if ``DOWNLOAD`` is not given a ``<file>``.
``EXPECTED_MD5 <value>``
Historical short-hand for ``EXPECTED_HASH MD5=<value>``.
Historical short-hand for ``EXPECTED_HASH MD5=<value>``. It is an error to
specify this if ``DOWNLOAD`` is not given a ``<file>``.
Locking
^^^^^^^
@@ -901,7 +990,7 @@ Archiving
file(ARCHIVE_CREATE OUTPUT <archive>
PATHS <paths>...
[FORMAT <format>]
[COMPRESSION <compression>]
[COMPRESSION <compression> [COMPRESSION_LEVEL <compression-level>]]
[MTIME <mtime>]
[VERBOSE])
@@ -919,6 +1008,10 @@ compression. The other formats use no compression by default, but can be
directed to do so with the ``COMPRESSION`` option. Valid values for
``<compression>`` are ``None``, ``BZip2``, ``GZip``, ``XZ``, and ``Zstd``.
The compression level can be specified with the ``COMPRESSION_LEVEL`` option.
The ``<compression-level>`` should be between 0-9, with the default being 0.
The ``COMPRESSION`` option must be present when ``COMPRESSION_LEVEL`` is given.
.. note::
With ``FORMAT`` set to ``raw`` only one file will be compressed with the
compression type specified by ``COMPRESSION``.

View File

@@ -34,14 +34,30 @@ Additional optional components may be listed after
whether a package is considered to be found are defined by the target
package.
.. _FIND_PACKAGE_VERSION_FORMAT:
The ``[version]`` argument requests a version with which the package found
should be compatible (format is ``major[.minor[.patch[.tweak]]]``). The
``EXACT`` option requests that the version be matched exactly. If no
``[version]`` and/or component list is given to a recursive invocation
should be compatible. There are two possible forms in which it may be
specified:
* A single version with the format ``major[.minor[.patch[.tweak]]]``.
* A version range with the format ``versionMin...[<]versionMax`` where
``versionMin`` and ``versionMax`` have the same format as the single
version. By default, both end points are included. By specifying ``<``,
the upper end point will be excluded. Version ranges are only supported
with CMake 3.19 or later.
The ``EXACT`` option requests that the version be matched exactly. This option
is incompatible with the specification of a version range.
If no ``[version]`` and/or component list is given to a recursive invocation
inside a find-module, the corresponding arguments are forwarded
automatically from the outer call (including the ``EXACT`` flag for
``[version]``). Version support is currently provided only on a
package-by-package basis (see the `Version Selection`_ section below).
When a version range is specified but the package is only designed to expect
a single version, the package will ignore the upper end point of the range and
only take the single version at the lower end of the range into account.
See the :command:`cmake_policy` command documentation for discussion
of the ``NO_POLICY_SCOPE`` option.
@@ -140,10 +156,10 @@ outlined below will find them without requiring use of additional options.
Version Selection
^^^^^^^^^^^^^^^^^
When the ``[version]`` argument is given Config mode will only find a
When the ``[version]`` argument is given, Config mode will only find a
version of the package that claims compatibility with the requested
version (format is ``major[.minor[.patch[.tweak]]]``). If the ``EXACT``
option is given only a version of the package claiming an exact match
version (see :ref:`format specification <FIND_PACKAGE_VERSION_FORMAT>`). If the
``EXACT`` option is given, only a version of the package claiming an exact match
of the requested version may be found. CMake does not establish any
convention for the meaning of version numbers. Package version
numbers are checked by "version" files provided by the packages
@@ -160,31 +176,78 @@ version file is loaded in a nested scope in which the following
variables have been defined:
``PACKAGE_FIND_NAME``
the ``<PackageName>``
The ``<PackageName>``
``PACKAGE_FIND_VERSION``
full requested version string
Full requested version string
``PACKAGE_FIND_VERSION_MAJOR``
major version if requested, else 0
Major version if requested, else 0
``PACKAGE_FIND_VERSION_MINOR``
minor version if requested, else 0
Minor version if requested, else 0
``PACKAGE_FIND_VERSION_PATCH``
patch version if requested, else 0
Patch version if requested, else 0
``PACKAGE_FIND_VERSION_TWEAK``
tweak version if requested, else 0
Tweak version if requested, else 0
``PACKAGE_FIND_VERSION_COUNT``
number of version components, 0 to 4
Number of version components, 0 to 4
When a version range is specified, the above version variables will hold
values based on the lower end of the version range. This is to preserve
compatibility with packages that have not been implemented to expect version
ranges. In addition, the version range will be described by the following
variables:
``PACKAGE_FIND_VERSION_RANGE``
Full requested version range string
``PACKAGE_FIND_VERSION_RANGE_MIN``
This specifies whether the lower end point of the version range should be
included or excluded. Currently, the only supported value for this variable
is ``INCLUDE``.
``PACKAGE_FIND_VERSION_RANGE_MAX``
This specifies whether the upper end point of the version range should be
included or excluded. The supported values for this variable are
``INCLUDE`` and ``EXCLUDE``.
``PACKAGE_FIND_VERSION_MIN``
Full requested version string of the lower end point of the range
``PACKAGE_FIND_VERSION_MIN_MAJOR``
Major version of the lower end point if requested, else 0
``PACKAGE_FIND_VERSION_MIN_MINOR``
Minor version of the lower end point if requested, else 0
``PACKAGE_FIND_VERSION_MIN_PATCH``
Patch version of the lower end point if requested, else 0
``PACKAGE_FIND_VERSION_MIN_TWEAK``
Tweak version of the lower end point if requested, else 0
``PACKAGE_FIND_VERSION_MIN_COUNT``
Number of version components of the lower end point, 0 to 4
``PACKAGE_FIND_VERSION_MAX``
Full requested version string of the upper end point of the range
``PACKAGE_FIND_VERSION_MAX_MAJOR``
Major version of the upper end point if requested, else 0
``PACKAGE_FIND_VERSION_MAX_MINOR``
Minor version of the upper end point if requested, else 0
``PACKAGE_FIND_VERSION_MAX_PATCH``
Patch version of the upper end point if requested, else 0
``PACKAGE_FIND_VERSION_MAX_TWEAK``
Tweak version of the upper end point if requested, else 0
``PACKAGE_FIND_VERSION_MAX_COUNT``
Number of version components of the upper end point, 0 to 4
Regardless of whether a single version or a version range is specified, the
variable ``PACKAGE_FIND_VERSION_COMPLETE`` will be defined and will hold
the full requested version string as specified.
The version file checks whether it satisfies the requested version and
sets these variables:
``PACKAGE_VERSION``
full provided version string
Full provided version string
``PACKAGE_VERSION_EXACT``
true if version is exact match
True if version is exact match
``PACKAGE_VERSION_COMPATIBLE``
true if version is compatible
True if version is compatible
``PACKAGE_VERSION_UNSUITABLE``
true if unsuitable as any version
True if unsuitable as any version
These variables are checked by the ``find_package`` command to determine
whether the configuration file provides an acceptable version. They
@@ -192,17 +255,17 @@ are not available after the ``find_package`` call returns. If the version
is acceptable the following variables are set:
``<PackageName>_VERSION``
full provided version string
Full provided version string
``<PackageName>_VERSION_MAJOR``
major version if provided, else 0
Major version if provided, else 0
``<PackageName>_VERSION_MINOR``
minor version if provided, else 0
Minor version if provided, else 0
``<PackageName>_VERSION_PATCH``
patch version if provided, else 0
Patch version if provided, else 0
``<PackageName>_VERSION_TWEAK``
tweak version if provided, else 0
Tweak version if provided, else 0
``<PackageName>_VERSION_COUNT``
number of version components, 0 to 4
Number of version components, 0 to 4
and the corresponding package configuration file is loaded.
When multiple package configuration files are available whose version files
@@ -391,31 +454,77 @@ defines variables to provide information about the call arguments (and
restores their original state before returning):
``CMAKE_FIND_PACKAGE_NAME``
the ``<PackageName>`` which is searched for
The ``<PackageName>`` which is searched for
``<PackageName>_FIND_REQUIRED``
true if ``REQUIRED`` option was given
True if ``REQUIRED`` option was given
``<PackageName>_FIND_QUIETLY``
true if ``QUIET`` option was given
True if ``QUIET`` option was given
``<PackageName>_FIND_VERSION``
full requested version string
Full requested version string
``<PackageName>_FIND_VERSION_MAJOR``
major version if requested, else 0
Major version if requested, else 0
``<PackageName>_FIND_VERSION_MINOR``
minor version if requested, else 0
Minor version if requested, else 0
``<PackageName>_FIND_VERSION_PATCH``
patch version if requested, else 0
Patch version if requested, else 0
``<PackageName>_FIND_VERSION_TWEAK``
tweak version if requested, else 0
Tweak version if requested, else 0
``<PackageName>_FIND_VERSION_COUNT``
number of version components, 0 to 4
Number of version components, 0 to 4
``<PackageName>_FIND_VERSION_EXACT``
true if ``EXACT`` option was given
True if ``EXACT`` option was given
``<PackageName>_FIND_COMPONENTS``
list of requested components
List of requested components
``<PackageName>_FIND_REQUIRED_<c>``
true if component ``<c>`` is required,
True if component ``<c>`` is required,
false if component ``<c>`` is optional
When a version range is specified, the above version variables will hold
values based on the lower end of the version range. This is to preserve
compatibility with packages that have not been implemented to expect version
ranges. In addition, the version range will be described by the following
variables:
``<PackageName>_FIND_VERSION_RANGE``
Full requested version range string
``<PackageName>_FIND_VERSION_RANGE_MIN``
This specifies whether the lower end point of the version range is
included or excluded. Currently, ``INCLUDE`` is the only supported value.
``<PackageName>_FIND_VERSION_RANGE_MAX``
This specifies whether the upper end point of the version range is
included or excluded. The possible values for this variable are
``INCLUDE`` or ``EXCLUDE``.
``<PackageName>_FIND_VERSION_MIN``
Full requested version string of the lower end point of the range
``<PackageName>_FIND_VERSION_MIN_MAJOR``
Major version of the lower end point if requested, else 0
``<PackageName>_FIND_VERSION_MIN_MINOR``
Minor version of the lower end point if requested, else 0
``<PackageName>_FIND_VERSION_MIN_PATCH``
Patch version of the lower end point if requested, else 0
``<PackageName>_FIND_VERSION_MIN_TWEAK``
Tweak version of the lower end point if requested, else 0
``<PackageName>_FIND_VERSION_MIN_COUNT``
Number of version components of the lower end point, 0 to 4
``<PackageName>_FIND_VERSION_MAX``
Full requested version string of the upper end point of the range
``<PackageName>_FIND_VERSION_MAX_MAJOR``
Major version of the upper end point if requested, else 0
``<PackageName>_FIND_VERSION_MAX_MINOR``
Minor version of the upper end point if requested, else 0
``<PackageName>_FIND_VERSION_MAX_PATCH``
Patch version of the upper end point if requested, else 0
``<PackageName>_FIND_VERSION_MAX_TWEAK``
Tweak version of the upper end point if requested, else 0
``<PackageName>_FIND_VERSION_MAX_COUNT``
Number of version components of the upper end point, 0 to 4
Regardless of whether a single version or a version range is specified, the
variable ``<PackageName>_FIND_VERSION_COMPLETE`` will be defined and will hold
the full requested version string as specified.
In Module mode the loaded find module is responsible to honor the
request detailed by these variables; see the find module for details.
In Config mode ``find_package`` handles ``REQUIRED``, ``QUIET``, and

View File

@@ -8,9 +8,14 @@ Get a property of ``DIRECTORY`` scope.
get_directory_property(<variable> [DIRECTORY <dir>] <prop-name>)
Stores a property of directory scope in the named ``<variable>``.
The ``DIRECTORY`` argument specifies another directory from which
to retrieve the property value instead of the current directory.
The specified directory must have already been traversed by CMake.
It may reference either a source directory, or since CMake 3.19,
a binary directory. Relative paths are treated as relative to the
current source directory. CMake must already know about the directory,
either by having added it through a call to :command:`add_subdirectory`
or being the top level directory.
If the property is not defined for the nominated directory scope,
an empty string is returned. In the case of ``INHERITED`` properties,

View File

@@ -53,3 +53,9 @@ left as a full path. If ``PROGRAM_ARGS`` is present with ``PROGRAM``, then
any command-line arguments present in the ``<FileName>`` string are split
from the program name and stored in ``<arg_var>``. This is used to
separate a program name from its arguments in a command line string.
.. note::
This command been superseded by :command:`cmake_path` command, except
``REALPATH`` now offered by :ref:`file(REAL_PATH) <REAL_PATH>` command and
``PROGRAM`` now available in :command:`separate_arguments(PROGRAM)` command.

View File

@@ -30,7 +30,9 @@ It must be one of the following:
``DIRECTORY``
Scope defaults to the current directory but another
directory (already processed by CMake) may be named by the
full or relative path ``<dir>``.
full or relative path ``<dir>``. The ``<dir>`` may reference either a
source directory, or since CMake 3.19, a binary directory.
Relative paths are treated as relative to the current source directory.
See also the :command:`get_directory_property` command.
``TARGET``
@@ -44,10 +46,11 @@ It must be one of the following:
``DIRECTORY <dir>``
The source file property will be read from the ``<dir>`` directory's
scope. CMake must already know about that source directory, either by
having added it through a call to :command:`add_subdirectory` or ``<dir>``
being the top level source directory. Relative paths are treated as
relative to the current source directory.
scope. The ``<dir>`` may reference either a source directory, or
since CMake 3.19, a binary directory. CMake must already know about
the directory, either by having added it through a call
to :command:`add_subdirectory` or ``<dir>`` being the top level directory.
Relative paths are treated as relative to the current source directory.
``TARGET_DIRECTORY <target>``
The source file property will be read from the directory scope in which

View File

@@ -1,6 +1,8 @@
include_guard
-------------
.. versionadded:: 3.10
Provides an include guard for the file currently being processed by CMake.
.. code-block:: cmake

View File

@@ -45,6 +45,9 @@ signatures that specify them. The common options are:
As absolute paths are not supported by :manual:`cpack <cpack(1)>` installer
generators, it is preferable to use relative paths throughout.
In particular, there is no need to make paths absolute by prepending
:variable:`CMAKE_INSTALL_PREFIX`; this prefix is used by default if
the DESTINATION is a relative path.
``PERMISSIONS``
Specify permissions for installed files. Valid permissions are

View File

@@ -88,7 +88,7 @@ The options are:
Selects which programming languages are needed to build the project.
Supported languages include ``C``, ``CXX`` (i.e. C++), ``CUDA``,
``OBJC`` (i.e. Objective-C), ``OBJCXX``, ``Fortran``, and ``ASM``.
``OBJC`` (i.e. Objective-C), ``OBJCXX``, ``Fortran``, ``ISPC``, and ``ASM``.
By default ``C`` and ``CXX`` are enabled if no language options are given.
Specify language ``NONE``, or use the ``LANGUAGES`` keyword and list no languages,
to skip enabling any languages.

View File

@@ -12,6 +12,7 @@ encountered in an included file (via :command:`include` or
:command:`find_package`), it causes processing of the current file to stop
and control is returned to the including file. If it is encountered in a
file which is not included by another file, e.g. a ``CMakeLists.txt``,
deferred calls scheduled by :command:`cmake_language(DEFER)` are invoked and
control is returned to the parent directory if there is one. If return is
called in a function, control is returned to the caller of the function.

View File

@@ -5,7 +5,7 @@ Parse command-line arguments into a semicolon-separated list.
.. code-block:: cmake
separate_arguments(<variable> <mode> <args>)
separate_arguments(<variable> <mode> [PROGRAM [SEPARATE_ARGS]] <args>)
Parses a space-separated string ``<args>`` into a list of items,
and stores this list in semicolon-separated standard form in ``<variable>``.
@@ -35,6 +35,36 @@ be one of the following keywords:
Proceeds as in ``WINDOWS_COMMAND`` mode if the host system is Windows.
Otherwise proceeds as in ``UNIX_COMMAND`` mode.
``PROGRAM``
The first item in ``<args>`` is assumed to be an executable and will be
searched in the system search path or left as a full path. If not found,
``<variable>`` will be empty. Otherwise, ``<variable>`` is a list of 2
elements:
0. Absolute path of the program
1. Any command-line arguments present in ``<args>`` as a string
For example:
.. code-block:: cmake
separate_arguments (out UNIX_COMMAND PROGRAM "cc -c main.c")
* First element of the list: ``/path/to/cc``
* Second element of the list: ``" -c main.c"``
``SEPARATE_ARGS``
When this sub-option of ``PROGRAM`` option is specified, command-line
arguments will be split as well and stored in ``<variable>``.
For example:
.. code-block:: cmake
separate_arguments (out UNIX_COMMAND PROGRAM SEPARATE_ARGS "cc -c main.c")
The contents of ``out`` will be: ``/path/to/cc;-c;main.c``
.. _`Parsing C Command-Line Arguments`: https://msdn.microsoft.com/library/a1y7w461.aspx
.. code-block:: cmake

View File

@@ -26,8 +26,11 @@ It must be one of the following:
Scope is unique and does not accept a name.
``DIRECTORY``
Scope defaults to the current directory but another directory
Scope defaults to the current directory but other directories
(already processed by CMake) may be named by full or relative path.
Each path may reference either a source directory, or since CMake 3.19,
a binary directory.
Relative paths are treated as relative to the current source directory.
See also the :command:`set_directory_properties` command.
``TARGET``
@@ -42,8 +45,9 @@ It must be one of the following:
``DIRECTORY <dirs>...``
The source file property will be set in each of the ``<dirs>``
directories' scopes. CMake must already know about each of these
source directories, either by having added them through a call to
directories' scopes. Each path may reference either a source directory,
or since CMake 3.19, a binary directory. CMake must already know about
each of these directories, either by having added them through a call to
:command:`add_subdirectory` or it being the top level source directory.
Relative paths are treated as relative to the current source directory.

View File

@@ -43,6 +43,19 @@ Synopsis
string(`TIMESTAMP`_ <out-var> [<format string>] [UTC])
string(`UUID`_ <out-var> ...)
`JSON`_
string(JSON <out-var> [ERROR_VARIABLE <error-var>]
{`GET`_ | `TYPE`_ | :ref:`LENGTH <JSONLENGTH>` | `REMOVE`_}
<json-string> <member|index> [<member|index> ...])
string(JSON <out-var> [ERROR_VARIABLE <error-var>]
`MEMBER`_ <json-string>
[<member|index> ...] <index>)
string(JSON <out-var> [ERROR_VARIABLE <error-var>]
`SET`_ <json-string>
<member|index> [<member|index> ...] <value>)
string(JSON <out-var> [ERROR_VARIABLE <error-var>]
`EQUAL`_ <json-string1> <json-string2>)
Search and Replace
^^^^^^^^^^^^^^^^^^
@@ -470,3 +483,93 @@ A UUID has the format ``xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx``
where each ``x`` represents a lower case hexadecimal character.
Where required, an uppercase representation can be requested
with the optional ``UPPER`` flag.
.. _JSON:
JSON
^^^^
Functionality for querying a JSON string.
.. _GET:
.. code-block:: cmake
string(JSON <out-var> [ERROR_VARIABLE <error-variable>]
GET <json-string> <member|index> [<member|index> ...])
Get an element from ``<json-string>`` at the location given
by the list of ``<member|index>`` arguments.
Array and object elements will be returned as a JSON string.
Boolean elements will be returned as ``ON`` or ``OFF``.
Null elements will be returned as an empty string.
Number and string types will be returned as strings.
.. _TYPE:
.. code-block:: cmake
string(JSON <out-var> [ERROR_VARIABLE <error-variable>]
TYPE <json-string> <member|index> [<member|index> ...])
Get the type of an element in ``<json-string>`` at the location
given by the list of ``<member|index>`` arguments. The ``<out-var>``
will be set to one of ``NULL``, ``NUMBER``, ``STRING``, ``BOOLEAN``,
``ARRAY``, or ``OBJECT``.
.. _MEMBER:
.. code-block:: cmake
string(JSON <out-var> [ERROR_VARIABLE <error-var>]
MEMBER <json-string>
[<member|index> ...] <index>)
Get the name of the ``<index>``-th member in ``<json-string>`` at the location
given by the list of ``<member|index>`` arguments.
Requires an element of object type.
.. _JSONLENGTH:
.. code-block:: cmake
string(JSON <out-var> [ERROR_VARIABLE <error-variable>]
LENGTH <json-string> <member|index> [<member|index> ...])
Get the length of an element in ``<json-string>`` at the location
given by the list of ``<member|index>`` arguments.
Requires an element of array or object type.
.. _REMOVE:
.. code-block:: cmake
string(JSON <out-var> [ERROR_VARIABLE <error-variable>]
REMOVE <json-string> <member|index> [<member|index> ...])
Remove an element from ``<json-string>`` at the location
given by the list of ``<member|index>`` arguments. The JSON string
without the removed element will be stored in ``<out-var>``.
.. _SET:
.. code-block:: cmake
string(JSON <out-var> [ERROR_VARIABLE <error-variable>]
SET <json-string> <member|index> [<member|index> ...] <value>)
Set an element in ``<json-string>`` at the location
given by the list of ``<member|index>`` arguments to ``<value>``.
The contents of ``<value>`` should be valid JSON.
.. _EQUAL:
.. code-block:: cmake
string(JSON <out-var> [ERROR_VARIABLE <error-var>]
EQUAL <json-string1> <json-string2>)
Compare the two JSON objects given by ``<json-string1>`` and ``<json-string2>``
for equality
If the optional ``ERROR_VARIABLE`` argument is given, errors will be
reported in ``<error-variable>``. If no error occurs, the ``<error-variable>``
will be set to ``NOTFOUND``. If ``ERROR_VARIABLE`` is not set a CMake error
will be issued.
When an error occurs the ``<out-var>`` will be set to
``<member|index>-[<member|index>...]-NOTFOUND`` with the path elements up to
the point where the error occurred.

View File

@@ -1,6 +1,8 @@
target_compile_features
-----------------------
.. versionadded:: 3.1
Add expected compiler features to a target.
.. code-block:: cmake

View File

@@ -1,6 +1,8 @@
target_link_directories
-----------------------
.. versionadded:: 3.13
Add link directories to a target.
.. code-block:: cmake

View File

@@ -1,6 +1,8 @@
target_link_options
-------------------
.. versionadded:: 3.13
Add options to the link step for an executable, shared library or module
library target.

View File

@@ -1,6 +1,8 @@
target_precompile_headers
-------------------------
.. versionadded:: 3.16
Add a list of header files to precompile.
Precompiling header files can speed up compilation by creating a partially

View File

@@ -1,6 +1,8 @@
target_sources
--------------
.. versionadded:: 3.1
Add sources to a target.
.. code-block:: cmake
@@ -9,19 +11,21 @@ Add sources to a target.
<INTERFACE|PUBLIC|PRIVATE> [items1...]
[<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])
Specifies sources to use when compiling a given target. Relative
source file paths are interpreted as being relative to the current
Specifies sources to use when building a target and/or its dependents.
Relative source file paths are interpreted as being relative to the current
source directory (i.e. :variable:`CMAKE_CURRENT_SOURCE_DIR`). The
named ``<target>`` must have been created by a command such as
:command:`add_executable` or :command:`add_library` and must not be an
:ref:`ALIAS target <Alias Targets>`.
The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to
specify the scope of the following arguments. ``PRIVATE`` and ``PUBLIC``
specify the scope of the items following them. ``PRIVATE`` and ``PUBLIC``
items will populate the :prop_tgt:`SOURCES` property of
``<target>``. ``PUBLIC`` and ``INTERFACE`` items will populate the
:prop_tgt:`INTERFACE_SOURCES` property of ``<target>``.
(:ref:`IMPORTED targets <Imported Targets>` only support ``INTERFACE`` items.)
``<target>``, which are used when building the target itself.
``PUBLIC`` and ``INTERFACE`` items will populate the
:prop_tgt:`INTERFACE_SOURCES` property of ``<target>``, which are used
when building dependents. (:ref:`IMPORTED targets <Imported Targets>`
only support ``INTERFACE`` items because they are not build targets.)
The following arguments specify sources. Repeated calls for the same
``<target>`` append items in the order called.

View File

@@ -7,9 +7,42 @@ Watch the CMake variable for change.
variable_watch(<variable> [<command>])
If the specified ``<variable>`` changes, a message will be printed
to inform about the change.
If the specified ``<variable>`` changes and no ``<command>`` is given,
a message will be printed to inform about the change.
Additionally, if ``<command>`` is given, this command will be executed.
If ``<command>`` is given, this command will be executed instead.
The command will receive the following arguments:
``COMMAND(<variable> <access> <value> <current_list_file> <stack>)``
``<variable>``
Name of the variable being accessed.
``<access>``
One of ``READ_ACCESS``, ``UNKNOWN_READ_ACCESS``, ``MODIFIED_ACCESS``,
``UNKNOWN_MODIFIED_ACCESS``, or ``REMOVED_ACCESS``. The ``UNKNOWN_``
values are only used when the variable has never been set. Once set,
they are never used again during the same CMake run, even if the
variable is later unset.
``<value>``
The value of the variable. On a modification, this is the new
(modified) value of the variable. On removal, the value is empty.
``<current_list_file>``
Full path to the file doing the access.
``<stack>``
List of absolute paths of all files currently on the stack of file
inclusion, with the bottom-most file first and the currently
processed file (that is, ``current_list_file``) last.
Note that for some accesses such as :command:`list(APPEND)`, the watcher
is executed twice, first with a read access and then with a write one.
Also note that an :command:`if(DEFINED)` query on the variable does not
register as an access and the watcher is not executed.
Only non-cache variables can be watched using this command. Access to
cache variables is never watched. However, the existence of a cache
variable ``var`` causes accesses to the non-cache variable ``var`` to
not use the ``UNKNOWN_`` prefix, even if a non-cache variable ``var``
has never existed.

View File

@@ -281,3 +281,10 @@ Variables specific to CPack External generator
It is invoked after (optional) staging took place and may
run an external packaging tool. The script has access to
the variables defined by the CPack config file.
.. variable:: CPACK_EXTERNAL_BUILT_PACKAGES
The ``CPACK_EXTERNAL_PACKAGE_SCRIPT`` script may set this list variable to the
full paths of generated package files. CPack will copy these files from the
staging directory back to the top build directory and possibly produce
checksum files if the :variable:`CPACK_PACKAGE_CHECKSUM` is set.

View File

@@ -29,7 +29,7 @@ macOS using PackageMaker:
.. variable:: CPACK_PACKAGEMAKER_BACKGROUND
Adds a background to Distribtion XML if specified. The value contains the
Adds a background to Distribution XML if specified. The value contains the
path to image in ``Resources`` directory.
.. variable:: CPACK_PACKAGEMAKER_BACKGROUND_ALIGNMENT

View File

@@ -68,7 +68,7 @@ macOS using ProductBuild:
.. variable:: CPACK_PRODUCTBUILD_BACKGROUND
Adds a background to Distribtion XML if specified. The value contains the
Adds a background to Distribution XML if specified. The value contains the
path to image in ``Resources`` directory.
.. variable:: CPACK_PRODUCTBUILD_BACKGROUND_ALIGNMENT

View File

@@ -286,3 +286,11 @@ Windows using WiX.
When unspecified CPack will try to locate a WiX Toolset
installation via the ``WIX`` environment variable instead.
.. variable:: CPACK_WIX_CUSTOM_XMLNS
This variable provides a list of custom namespace declarations that are necessary
for using WiX extensions. Each declaration should be in the form name=url, where
name is the plain namespace without the usual xmlns: prefix and url is an unquoted
namespace url. A list of commonly known WiX schemata can be found here:
https://wixtoolset.org/documentation/manual/v3/xsd/

View File

@@ -200,6 +200,23 @@ the notes, and revise wording. Then commit with a message such as::
Add section headers similar to the $prev release notes and move each
individual bullet into an appropriate section. Revise a few bullets.
Update Sphinx ``versionadded`` directives in documents added since
the previous release by running the `update_versions.py`_ script:
.. code-block:: shell
Utilities/Sphinx/update_versions.py --since v$prev.0 --overwrite
.. _`update_versions.py`: ../../Utilities/Sphinx/update_versions.py
Commit the changes with a message such as::
Help: Update Sphinx versionadded directives for $ver release
Run the script:
Utilities/Sphinx/update_versions.py --since v$prev.0 --overwrite
Open a merge request with the ``doc-$ver-relnotes`` branch for review
and integration. Further steps may proceed after this has been merged
to ``master``.
@@ -228,6 +245,20 @@ Commit with a message such as::
Release versions do not have the development topic section of
the CMake Release Notes index page.
Update ``.gitlab-ci.yml`` to drop the ``upload:`` jobs from the
packaging pipeline by renaming them to start in ``.``:
.. code-block:: shell
sed -i 's/^upload:/.upload:/' .gitlab-ci.yml
Commit with a message such as::
gitlab-ci: Drop package pipeline upload jobs for release branch
The package pipeline for release versions should not upload packages
automatically to our archive of nightly development versions.
Update ``Source/CMakeVersion.cmake`` to set the version to
``$major.$minor.0-rc0``:
@@ -259,13 +290,15 @@ Merge the ``release-$ver`` branch to ``master``:
git merge --no-ff release-$ver
Begin post-release development by restoring the development branch release
note infrastructure and the version date from ``origin/master``:
note infrastructure, the nightly package pipeline upload jobs, and
the version date from ``origin/master``:
.. code-block:: shell
git checkout origin/master -- \
Source/CMakeVersion.cmake Help/release/dev/0-sample-topic.rst
sed -i $'/^Releases/ i\\\n.. include:: dev.txt\\\n' Help/release/index.rst
sed -i 's/^\.upload:/upload:/' .gitlab-ci.yml
Update ``Source/CMakeVersion.cmake`` to set the version to
``$major.$minor.$date``:
@@ -299,3 +332,28 @@ announcing that post-release development is open::
before staging or merging.
.. _`CMake Discourse Forum Development Category`: https://discourse.cmake.org/c/development
Initial Post-Release Development
--------------------------------
Deprecate policies more than 8 release series old by updating the
policy range check in ``cmMakefile::SetPolicy``.
Commit with a message such as::
Add deprecation warnings for policies CMP#### and below
The OLD behaviors of all policies are deprecated, but only by
documentation. Add an explicit deprecation diagnostic for policies
introduced in CMake $OLDVER and below to encourage projects to port
away from setting policies to OLD.
Update the ``cmake_policy`` version range generated by ``install(EXPORT)``
in ``cmExportFileGenerator::GeneratePolicyHeaderCode`` to end at the
previous release. We use one release back since we now know all the
policies added for that version. Commit with a message such as::
export: Increase maximum policy version in exported files to $prev
The files generatd by `install(EXPORT)` and `export()` commands
are known to work with policies as of CMake $prev, so enable them
in sufficiently new CMake versions.

View File

@@ -260,10 +260,11 @@ This may be generated with
If the commit is a fix for the mentioned commit, consider using a ``Fixes:``
trailer in the commit message with the specified format. This trailer should
not be word-wrapped. Note that if there is also an issue for what is being
fixed, it is preferrable to link to the issue instead.
fixed, it is preferable to link to the issue instead.
If relevant, add the first release tag of CMake containing the commit after
the ``<date>``, i.e., ``commit <shorthash> (<subject>, <date>, <tag>)``.
Or, use the output of ``git describe --contains <commit>`` as the ``<tag>``.
Alternatively, the full commit ``<hash>`` may be used.

View File

@@ -35,6 +35,9 @@ Available features are:
* From ``C++14``:
* ``<cm/iomanip>``:
``cm::quoted``
* ``<cm/iterator>``:
``cm::make_reverse_iterator``, ``cm::cbegin``, ``cm::cend``,
``cm::rbegin``, ``cm::rend``, ``cm::crbegin``, ``cm::crend``
@@ -53,6 +56,9 @@ Available features are:
* ``<cm/algorithm>``:
``cm::clamp``
* ``cm/filesystem>``:
``cm::filesystem::path``
* ``<cm/iterator>``:
``cm::size``, ``cm::empty``, ``cm::data``
@@ -152,6 +158,9 @@ These are:
* ``cm::is_unique_ptr``:
Checks if a type is a ``std::unique_ptr`` type.
CMake assumes the compiler supports ``#pragma once``. Use this for all
hand-written header files.
Dynamic Memory Management
=========================

View File

@@ -1,6 +1,8 @@
ASM<DIALECT>
------------
.. versionadded:: 3.10
.. include:: ENV_VAR.txt
Preferred executable for compiling a specific dialect of assembly language
@@ -12,3 +14,11 @@ in the cache as
:variable:`CMAKE_ASM<DIALECT>_COMPILER <CMAKE_<LANG>_COMPILER>`. For subsequent
configuration runs, the environment variable will be ignored in favor of
:variable:`CMAKE_ASM<DIALECT>_COMPILER <CMAKE_<LANG>_COMPILER>`.
.. note::
Options that are required to make the compiler work correctly can be included;
they can not be changed.
.. code-block:: console
$ export ASM="custom-compiler --arg1 --arg2"

View File

@@ -1,6 +1,8 @@
ASM<DIALECT>FLAGS
-----------------
.. versionadded:: 3.10
.. include:: ENV_VAR.txt
Default compilation flags to be used when compiling a specific dialect of an

View File

@@ -1,6 +1,8 @@
CC
--
.. versionadded:: 3.10
.. include:: ENV_VAR.txt
Preferred executable for compiling ``C`` language files. Will only be used by
@@ -9,3 +11,11 @@ value for ``CC`` is stored in the cache as
:variable:`CMAKE_C_COMPILER <CMAKE_<LANG>_COMPILER>`. For any configuration run
(including the first), the environment variable will be ignored if the
:variable:`CMAKE_C_COMPILER <CMAKE_<LANG>_COMPILER>` variable is defined.
.. note::
Options that are required to make the compiler work correctly can be included;
they can not be changed.
.. code-block:: console
$ export CC="custom-compiler --arg1 --arg2"

View File

@@ -1,6 +1,8 @@
CCMAKE_COLORS
-------------
.. versionadded:: 3.18
Determines what colors are used by the CMake curses interface,
when run on a terminal that supports colors.
The syntax follows the same conventions as ``LS_COLORS``;

View File

@@ -1,6 +1,8 @@
CFLAGS
------
.. versionadded:: 3.10
.. include:: ENV_VAR.txt
Default compilation flags to be used when compiling ``C`` files. Will only be

View File

@@ -1,6 +1,8 @@
CMAKE_BUILD_PARALLEL_LEVEL
--------------------------
.. versionadded:: 3.12
.. include:: ENV_VAR.txt
Specifies the maximum number of concurrent processes to use when building

View File

@@ -1,6 +1,8 @@
CMAKE_CONFIG_TYPE
-----------------
.. versionadded:: 3.10
.. include:: ENV_VAR.txt
The default build configuration for :ref:`Build Tool Mode` and

View File

@@ -1,6 +1,8 @@
CMAKE_EXPORT_COMPILE_COMMANDS
-----------------------------
.. versionadded:: 3.17
.. include:: ENV_VAR.txt
The default value for :variable:`CMAKE_EXPORT_COMPILE_COMMANDS` when there

View File

@@ -1,6 +1,8 @@
CMAKE_GENERATOR
---------------
.. versionadded:: 3.15
.. include:: ENV_VAR.txt
Specifies the CMake default generator to use when no generator is supplied

View File

@@ -1,6 +1,8 @@
CMAKE_GENERATOR_INSTANCE
------------------------
.. versionadded:: 3.15
.. include:: ENV_VAR.txt
Default value for :variable:`CMAKE_GENERATOR_INSTANCE` if no Cache entry is

View File

@@ -1,6 +1,8 @@
CMAKE_GENERATOR_PLATFORM
------------------------
.. versionadded:: 3.15
.. include:: ENV_VAR.txt
Default value for :variable:`CMAKE_GENERATOR_PLATFORM` if no Cache entry

View File

@@ -1,6 +1,8 @@
CMAKE_GENERATOR_TOOLSET
-----------------------
.. versionadded:: 3.15
.. include:: ENV_VAR.txt
Default value for :variable:`CMAKE_GENERATOR_TOOLSET` if no Cache entry

View File

@@ -1,6 +1,8 @@
CMAKE_<LANG>_COMPILER_LAUNCHER
------------------------------
.. versionadded:: 3.17
.. include:: ENV_VAR.txt
Default compiler launcher to use for the specified language. Will only be used

View File

@@ -1,6 +1,8 @@
CMAKE_MSVCIDE_RUN_PATH
----------------------
.. versionadded:: 3.10
.. include:: ENV_VAR.txt
Extra PATH locations for custom commands when using

View File

@@ -1,6 +1,8 @@
CMAKE_NO_VERBOSE
----------------
.. versionadded:: 3.14
Disables verbose output from CMake when :envvar:`VERBOSE` environment variable
is set.

View File

@@ -1,6 +1,8 @@
CMAKE_OSX_ARCHITECTURES
-----------------------
.. versionadded:: 3.10
.. include:: ENV_VAR.txt
Target specific architectures for macOS.

Some files were not shown because too many files have changed in this diff Show More