diff options
26 files changed, 185 insertions, 425 deletions
diff --git a/.gitlab/.gitignore b/.gitlab/.gitignore new file mode 100644 index 0000000..d62e477 --- /dev/null +++ b/.gitlab/.gitignore @@ -0,0 +1,16 @@ +# Ignore files known to be downloaded by CI jobs. +/5.15.1-0-202009071110* +/bcc* +/cmake* +/ispc* +/jom +/llvm* +/msvc* +/ninja* +/open-watcom* +/python* +/qt* +/sccache* +/unstable-jom* +/watcom +/wix* diff --git a/.gitlab/ci/docker/fedora36/Dockerfile b/.gitlab/ci/docker/fedora36/Dockerfile index 299d48a..ea42561 100644 --- a/.gitlab/ci/docker/fedora36/Dockerfile +++ b/.gitlab/ci/docker/fedora36/Dockerfile @@ -10,6 +10,12 @@ MAINTAINER Kyle Edwards <kyle.edwards@kitware.com> COPY install_clang_tidy_headers.sh /root/install_clang_tidy_headers.sh RUN sh /root/install_clang_tidy_headers.sh +FROM fedora:36 AS iwyu +MAINTAINER Kyle Edwards <kyle.edwards@kitware.com> + +COPY install_iwyu.sh /root/install_iwyu.sh +RUN sh /root/install_iwyu.sh + FROM fedora:36 MAINTAINER Ben Boeckel <ben.boeckel@kitware.com> @@ -22,3 +28,6 @@ RUN tar -C /usr/local -xf /root/rvm.tar \ COPY --from=clang-tidy-headers /root/clang-tidy-headers.tar /root/clang-tidy-headers.tar RUN tar -C /usr/include -xf /root/clang-tidy-headers.tar \ && rm /root/clang-tidy-headers.tar +COPY --from=iwyu /root/iwyu.tar /root/iwyu.tar +RUN tar -C / -xf /root/iwyu.tar \ + && rm /root/iwyu.tar diff --git a/.gitlab/ci/docker/fedora36/install_iwyu.sh b/.gitlab/ci/docker/fedora36/install_iwyu.sh new file mode 100755 index 0000000..714bcc0 --- /dev/null +++ b/.gitlab/ci/docker/fedora36/install_iwyu.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +set -e + +# Install development tools. +dnf install --setopt=install_weak_deps=False -y \ + clang-devel \ + llvm-devel \ + zlib-devel \ + g++ \ + cmake \ + ninja-build \ + git + +cd /root +git clone "https://github.com/include-what-you-use/include-what-you-use.git" +cd include-what-you-use +readonly llvm_full_version="$( clang --version | head -n1 | cut -d' ' -f3 )" +readonly llvm_version="$( echo "$llvm_full_version" | cut -d. -f-1 )" +git checkout "clang_$llvm_version" +git apply <<EOF +diff --git a/iwyu_driver.cc b/iwyu_driver.cc +index 42fea35..fbb77a9 100644 +--- a/iwyu_driver.cc ++++ b/iwyu_driver.cc +@@ -167,6 +167,7 @@ CompilerInstance* CreateCompilerInstance(int argc, const char **argv) { + DiagnosticsEngine diagnostics(diagnostic_id, &*diagnostic_options, + diagnostic_client); + Driver driver(path, getDefaultTargetTriple(), diagnostics); ++ driver.ResourceDir = "/usr/lib64/clang/$llvm_full_version"; + driver.setTitle("include what you use"); + + // Expand out any response files passed on the command line +EOF +mkdir build +cd build + +cmake -GNinja \ + -DCMAKE_BUILD_TYPE=Release \ + "-DCMAKE_INSTALL_PREFIX=/usr/local/lib64/llvm-$llvm_version" \ + .. +ninja +DESTDIR=/root/iwyu-destdir ninja install +tar -C /root/iwyu-destdir -cf /root/iwyu.tar . diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml index a46ec22..84950d2 100644 --- a/.gitlab/os-linux.yml +++ b/.gitlab/os-linux.yml @@ -69,7 +69,7 @@ ### Fedora .fedora36: - image: "kitware/cmake:ci-fedora36-x86_64-2022-08-31" + image: "kitware/cmake:ci-fedora36-x86_64-2022-10-04" variables: GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci/long file name for testing purposes" diff --git a/Help/command/install.rst b/Help/command/install.rst index 45da99b..feff436 100644 --- a/Help/command/install.rst +++ b/Help/command/install.rst @@ -968,7 +968,7 @@ Generated Installation Script The ``install()`` command generates a file, ``cmake_install.cmake``, inside the build directory, which is used internally by the generated install target and by CPack. You can also invoke this script manually with -:option:`cmake -P <cmake_P -P>`. This script accepts several variables: +:option:`cmake -P`. This script accepts several variables: ``COMPONENT`` Set this variable to install only a single CPack component as opposed to all diff --git a/Help/envvar/DESTDIR.rst b/Help/envvar/DESTDIR.rst index 414db12..dec8430 100644 --- a/Help/envvar/DESTDIR.rst +++ b/Help/envvar/DESTDIR.rst @@ -22,7 +22,7 @@ See the :variable:`CMAKE_INSTALL_PREFIX` variable to control the installation prefix when configuring a build tree. Or, when using the :manual:`cmake(1)` command-line tool's :option:`--install <cmake --install>` mode, one may specify a different prefix using the -:option:`--prefix <cmake --prefix>` option. +:option:`--prefix <cmake--install --prefix>` option. .. note:: diff --git a/Help/generator/Ninja Multi-Config.rst b/Help/generator/Ninja Multi-Config.rst index ae075ed..2cf823a 100644 --- a/Help/generator/Ninja Multi-Config.rst +++ b/Help/generator/Ninja Multi-Config.rst @@ -20,8 +20,8 @@ are intended to be run with ``ninja -f build-<Config>.ninja``. A :variable:`CMAKE_CONFIGURATION_TYPES`. ``cmake --build . --config <Config>`` will always use ``build-<Config>.ninja`` -to build. If no :option:`--config <cmake --config>` argument is specified, -:option:`cmake --build .<cmake --build>` will use ``build.ninja``. +to build. If no :option:`--config <cmake--build --config>` argument is +specified, :option:`cmake --build . <cmake --build>` will use ``build.ninja``. Each ``build-<Config>.ninja`` file contains ``<target>`` targets as well as ``<target>:<Config>`` targets, where ``<Config>`` is the same as the diff --git a/Help/guide/user-interaction/index.rst b/Help/guide/user-interaction/index.rst index 9cc5816..3355992 100644 --- a/Help/guide/user-interaction/index.rst +++ b/Help/guide/user-interaction/index.rst @@ -511,7 +511,7 @@ command associated with the the build tool configured by the user. The :option:`--build <cmake --build>` mode also accepts -the parameter :option:`--target <cmake --target>` to +the parameter :option:`--target <cmake--build --target>` to specify a particular target to build, for example a particular library, executable or custom target, or a particular special target like ``install``: @@ -521,7 +521,7 @@ particular special target like ``install``: $ cmake --build . --target myexe The :option:`--build <cmake --build>` mode also accepts a -:option:`--config <cmake --config>` parameter +:option:`--config <cmake--build --config>` parameter in the case of multi-config generators to specify which particular configuration to build: @@ -529,13 +529,13 @@ particular configuration to build: $ cmake --build . --target myexe --config Release -The :option:`--config <cmake --config>` option has no +The :option:`--config <cmake--build --config>` option has no effect if the generator generates a buildsystem specific to a configuration which is chosen when invoking cmake with the :variable:`CMAKE_BUILD_TYPE` variable. Some buildsystems omit details of command lines invoked -during the build. The :option:`-verbose <cmake --verbose>` +during the build. The :option:`--verbose <cmake--build --verbose>` flag can be used to cause those command lines to be shown: .. code-block:: console diff --git a/Help/manual/cmake-presets.7.rst b/Help/manual/cmake-presets.7.rst index 93f929e..eb3e460 100644 --- a/Help/manual/cmake-presets.7.rst +++ b/Help/manual/cmake-presets.7.rst @@ -460,21 +460,21 @@ that may contain the following fields: ``jobs`` An optional integer. Equivalent to passing - :option:`--parallel <cmake --parallel>` or ``-j`` on the command line. + :option:`--parallel <cmake--build --parallel>` or ``-j`` on the command line. ``targets`` An optional string or array of strings. Equivalent to passing - :option:`--target <cmake --target>` or ``-t`` on the command line. + :option:`--target <cmake--build --target>` or ``-t`` on the command line. Vendors may ignore the targets property or hide build presets that explicitly specify targets. This field supports macro expansion. ``configuration`` - An optional string. Equivalent to passing :option:`--config <cmake --config>` - on the command line. + An optional string. Equivalent to passing + :option:`--config <cmake--build --config>` on the command line. ``cleanFirst`` An optional bool. If true, equivalent to passing - :option:`--clean-first <cmake --clean-first>` on the command line. + :option:`--clean-first <cmake--build --clean-first>` on the command line. ``resolvePackageReferences`` An optional string that specifies the package resolve mode. This is @@ -498,7 +498,7 @@ that may contain the following fields: .. note:: The command line parameter - :option:`--resolve-package-references <cmake --resolve-package-references>` + :option:`--resolve-package-references <cmake--build --resolve-package-references>` will take priority over this setting. If the command line parameter is not provided and this setting is not specified, an environment-specific cache variable will be evaluated to decide, if package restoration should be @@ -512,7 +512,7 @@ that may contain the following fields: ``verbose`` An optional bool. If true, equivalent to passing - :option:`--verbose <cmake --verbose>` on the command line. + :option:`--verbose <cmake--build --verbose>` on the command line. ``nativeToolOptions`` An optional array of strings. Equivalent to passing options after ``--`` @@ -981,6 +981,8 @@ fields: ``vendorName`` An optional string representing the vendor name. +.. _`Workflow Preset`: + Workflow Preset ^^^^^^^^^^^^^^^ diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index 801229e..879ad0b 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -521,6 +521,8 @@ Options Build a Project =============== +.. program:: cmake + CMake provides a command-line signature to build an already-generated project binary tree: @@ -537,6 +539,8 @@ following options: Project binary directory to be built. This is required (unless a preset is specified) and must be first. +.. program:: cmake--build + .. option:: --preset <preset>, --preset=<preset> Use a build preset to specify build options. The project binary directory @@ -572,7 +576,7 @@ following options: .. option:: --clean-first Build target ``clean`` first, then build. - (To clean only, use :option:`--target clean <cmake --target>`.) + (To clean only, use :option:`--target clean <cmake--build --target>`.) .. option:: --resolve-package-references=<value> @@ -621,6 +625,8 @@ Run :option:`cmake --build` with no options for quick help. Install a Project ================= +.. program:: cmake + CMake provides a command-line signature to install an already-generated project binary tree: @@ -636,6 +642,8 @@ The options are: Project binary directory to install. This is required and must be first. +.. program:: cmake--install + .. option:: --config <cfg> For multi-configuration generators, choose configuration ``<cfg>``. @@ -667,6 +675,8 @@ Run :option:`cmake --install` with no options for quick help. Open a Project ============== +.. program:: cmake + .. code-block:: shell cmake --open <dir> @@ -680,16 +690,20 @@ supported by some generators. Run a Script ============ -.. program:: cmake_P +.. program:: cmake .. code-block:: shell cmake [-D <var>=<value>]... -P <cmake-script-file> [-- <unparsed-options>...] +.. program:: cmake-P + .. option:: -D <var>=<value> Define a variable for script mode. +.. program:: cmake + .. option:: -P <cmake-script-file> Process the given cmake file as a script written in the CMake @@ -707,7 +721,7 @@ script (including the ``--`` itself). Run a Command-Line Tool ======================= -.. program:: cmake_E +.. program:: cmake CMake provides builtin command-line tools through the signature @@ -719,6 +733,8 @@ CMake provides builtin command-line tools through the signature Run ``cmake -E`` or ``cmake -E help`` for a summary of commands. +.. program:: cmake-E + Available commands are: .. option:: capabilities @@ -1174,6 +1190,8 @@ The following ``cmake -E`` commands are available only on Windows: Run the Find-Package Tool ========================= +.. program:: cmake--find-package + CMake provides a pkg-config like helper for Makefile-based projects: .. code-block:: shell @@ -1194,9 +1212,23 @@ autoconf-based projects (via ``share/aclocal/cmake.m4``). Run a Workflow Preset ===================== +.. program:: cmake + :manual:`CMake Presets <cmake-presets(7)>` provides a way to execute multiple build steps in order: +.. code-block:: shell + + cmake --workflow [<options>] + +The options are: + +.. option:: --workflow + + Select a :ref:`Workflow Preset` using one of the following options. + +.. program:: cmake--workflow + .. option:: --preset <preset>, --preset=<preset> Use a workflow preset to specify a workflow. The project binary directory @@ -1212,6 +1244,8 @@ build steps in order: View Help ========= +.. program:: cmake + To print selected pages from the CMake documentation, use .. code-block:: shell @@ -1220,8 +1254,6 @@ To print selected pages from the CMake documentation, use with one of the following options: -.. program:: cmake - .. include:: OPTIONS_HELP.txt To view the presets available for a project, use diff --git a/Help/release/dev/cmake-E-env-modify.rst b/Help/release/dev/cmake-E-env-modify.rst index ea4a622..08f1fb5 100644 --- a/Help/release/dev/cmake-E-env-modify.rst +++ b/Help/release/dev/cmake-E-env-modify.rst @@ -1,5 +1,5 @@ cmake-E-env-modify ------------------ -* A new ``--modify`` flag was added to :option:`cmake -E env <cmake_E env>` to support :prop_test:`ENVIRONMENT_MODIFICATION` - operations. +* A new ``--modify`` flag was added to :option:`cmake -E env <cmake-E env>` to + support :prop_test:`ENVIRONMENT_MODIFICATION` operations. diff --git a/Help/variable/CMAKE_BINARY_DIR.rst b/Help/variable/CMAKE_BINARY_DIR.rst index f9c7689..e601eb8 100644 --- a/Help/variable/CMAKE_BINARY_DIR.rst +++ b/Help/variable/CMAKE_BINARY_DIR.rst @@ -7,7 +7,7 @@ This is the full path to the top level of the current CMake build tree. For an in-source build, this would be the same as :variable:`CMAKE_SOURCE_DIR`. -When run in :option:`-P <cmake_P -P>` script mode, CMake sets the variables +When run in :option:`cmake -P` script mode, CMake sets the variables :variable:`CMAKE_BINARY_DIR`, :variable:`CMAKE_SOURCE_DIR`, :variable:`CMAKE_CURRENT_BINARY_DIR` and :variable:`CMAKE_CURRENT_SOURCE_DIR` to the current working directory. diff --git a/Help/variable/CMAKE_CURRENT_BINARY_DIR.rst b/Help/variable/CMAKE_CURRENT_BINARY_DIR.rst index 6f82dcc..15f81d2 100644 --- a/Help/variable/CMAKE_CURRENT_BINARY_DIR.rst +++ b/Help/variable/CMAKE_CURRENT_BINARY_DIR.rst @@ -9,7 +9,7 @@ create a binary directory in the build tree, and as it is being processed this variable will be set. For in-source builds this is the current source directory being processed. -When run in :option:`-P <cmake_P -P>` script mode, CMake sets the variables +When run in :option:`cmake -P` script mode, CMake sets the variables :variable:`CMAKE_BINARY_DIR`, :variable:`CMAKE_SOURCE_DIR`, :variable:`CMAKE_CURRENT_BINARY_DIR` and :variable:`CMAKE_CURRENT_SOURCE_DIR` to the current working directory. diff --git a/Help/variable/CMAKE_CURRENT_SOURCE_DIR.rst b/Help/variable/CMAKE_CURRENT_SOURCE_DIR.rst index 0678f99..5b86026 100644 --- a/Help/variable/CMAKE_CURRENT_SOURCE_DIR.rst +++ b/Help/variable/CMAKE_CURRENT_SOURCE_DIR.rst @@ -6,7 +6,7 @@ The path to the source directory currently being processed. This is the full path to the source directory that is currently being processed by cmake. -When run in :option:`-P <cmake_P -P>` script mode, CMake sets the variables +When run in :option:`cmake -P` script mode, CMake sets the variables :variable:`CMAKE_BINARY_DIR`, :variable:`CMAKE_SOURCE_DIR`, :variable:`CMAKE_CURRENT_BINARY_DIR` and :variable:`CMAKE_CURRENT_SOURCE_DIR` to the current working directory. diff --git a/Help/variable/CMAKE_INSTALL_PREFIX.rst b/Help/variable/CMAKE_INSTALL_PREFIX.rst index 1636739..c76727e 100644 --- a/Help/variable/CMAKE_INSTALL_PREFIX.rst +++ b/Help/variable/CMAKE_INSTALL_PREFIX.rst @@ -27,8 +27,8 @@ first :command:`project` invocation. The ``CMAKE_INSTALL_PREFIX`` may be defined when configuring a build tree to set its installation prefix. Or, when using the :manual:`cmake(1)` -command-line tool's :option:`--install <cmake --install>` mode, one may -specify a different prefix using the :option:`--prefix <cmake --prefix>` +command-line tool's :option:`--install <cmake --install>` mode, one may specify +a different prefix using the :option:`--prefix <cmake--install --prefix>` option: .. code-block:: shell diff --git a/Help/variable/CMAKE_SCRIPT_MODE_FILE.rst b/Help/variable/CMAKE_SCRIPT_MODE_FILE.rst index 104f4ac..313fb4e 100644 --- a/Help/variable/CMAKE_SCRIPT_MODE_FILE.rst +++ b/Help/variable/CMAKE_SCRIPT_MODE_FILE.rst @@ -1,9 +1,9 @@ CMAKE_SCRIPT_MODE_FILE ---------------------- -Full path to the :option:`cmake -P <cmake_P -P>` script file currently being +Full path to the :option:`cmake -P` script file currently being processed. -When run in :option:`cmake -P <cmake_P -P>` script mode, CMake sets this variable to +When run in :option:`cmake -P` script mode, CMake sets this variable to the full path of the script file. When run to configure a ``CMakeLists.txt`` file, this variable is not set. diff --git a/Help/variable/CMAKE_SOURCE_DIR.rst b/Help/variable/CMAKE_SOURCE_DIR.rst index 32e6e90..7210f75 100644 --- a/Help/variable/CMAKE_SOURCE_DIR.rst +++ b/Help/variable/CMAKE_SOURCE_DIR.rst @@ -7,7 +7,7 @@ This is the full path to the top level of the current CMake source tree. For an in-source build, this would be the same as :variable:`CMAKE_BINARY_DIR`. -When run in :option:`-P <cmake_P -P>` script mode, CMake sets the variables +When run in :option:`cmake -P` script mode, CMake sets the variables :variable:`CMAKE_BINARY_DIR`, :variable:`CMAKE_SOURCE_DIR`, :variable:`CMAKE_CURRENT_BINARY_DIR` and :variable:`CMAKE_CURRENT_SOURCE_DIR` to the current working directory. diff --git a/Modules/CPackIFW.cmake b/Modules/CPackIFW.cmake index 003cf3f..a4bfe1d 100644 --- a/Modules/CPackIFW.cmake +++ b/Modules/CPackIFW.cmake @@ -439,6 +439,7 @@ set(_CPACK_IFW_PREFIXES "QtIFW-") set(_CPACK_IFW_VERSIONS + "4.4" "4.3" "4.2" "4.1" diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 8f2a5cb..c268a92 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -766,7 +766,7 @@ target_link_libraries( if(CMake_USE_MACH_PARSER) target_sources( CMakeLib - PUBLIC + PRIVATE cmMachO.h cmMachO.cxx ) @@ -776,7 +776,7 @@ endif() if(CMake_USE_XCOFF_PARSER) target_sources( CMakeLib - PUBLIC + PRIVATE cmXCOFF.h cmXCOFF.cxx ) @@ -786,7 +786,7 @@ endif() if(APPLE) target_sources( CMakeLib - PUBLIC + PRIVATE cmXCodeObject.cxx cmXCode21Object.cxx cmXCodeScheme.cxx @@ -800,7 +800,7 @@ endif() if(WIN32) target_sources( CMakeLib - PUBLIC + PRIVATE cmCallVisualStudioMacro.cxx cmCallVisualStudioMacro.h ) @@ -808,7 +808,7 @@ if(WIN32) if(NOT UNIX) target_sources( CMakeLib - PUBLIC + PRIVATE cmGlobalBorlandMakefileGenerator.cxx cmGlobalBorlandMakefileGenerator.h cmGlobalMSYSMakefileGenerator.cxx @@ -871,7 +871,7 @@ endif() if(CMAKE_USE_WMAKE) target_sources( CMakeLib - PUBLIC + PRIVATE cmGlobalWatcomWMakeGenerator.cxx cmGlobalWatcomWMakeGenerator.h ) @@ -882,7 +882,7 @@ endif() if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux") target_sources( CMakeLib - PUBLIC + PRIVATE cmGlobalGhsMultiGenerator.cxx cmGlobalGhsMultiGenerator.h cmLocalGhsMultiGenerator.cxx @@ -1045,7 +1045,7 @@ option(CPACK_ENABLE_FREEBSD_PKG "Add FreeBSD pkg(8) generator to CPack." OFF) if(UNIX) target_sources( CPackLib - PUBLIC + PRIVATE CPack/cmCPackRPMGenerator.cxx ) @@ -1063,7 +1063,7 @@ if(UNIX) DOC "FreeBSD pkg(8) library") if(FREEBSD_PKG_LIBRARIES) set(ENABLE_BUILD_FREEBSD_PKG 1) - target_sources(CPackLib PUBLIC CPack/cmCPackFreeBSDGenerator.cxx) + target_sources(CPackLib PRIVATE CPack/cmCPackFreeBSDGenerator.cxx) target_include_directories(CPackLib PUBLIC ${FREEBSD_PKG_INCLUDE_DIRS}) target_link_libraries(CPackLib PUBLIC ${FREEBSD_PKG_LIBRARIES}) endif() @@ -1081,7 +1081,7 @@ endif() if(CYGWIN) target_sources( CPackLib - PUBLIC + PRIVATE CPack/cmCPackCygwinBinaryGenerator.cxx CPack/cmCPackCygwinSourceGenerator.cxx ) @@ -1092,7 +1092,7 @@ if(WIN32 OR (CYGWIN AND TARGET LibUUID::LibUUID)) set(ENABLE_BUILD_WIX_GENERATOR 1) target_sources( CPackLib - PUBLIC + PRIVATE CPack/WiX/cmCMakeToWixPath.cxx CPack/WiX/cmCMakeToWixPath.h CPack/WiX/cmCPackWIXGenerator.cxx @@ -1122,7 +1122,7 @@ endif() if(APPLE) target_sources( CPackLib - PUBLIC + PRIVATE CPack/cmCPackBundleGenerator.cxx CPack/cmCPackDragNDropGenerator.cxx CPack/cmCPackPKGGenerator.cxx diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 489d215..51d6be4 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 24) -set(CMake_VERSION_PATCH 20221004) +set(CMake_VERSION_PATCH 20221006) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 989a929..a41b237 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -235,7 +235,7 @@ if(FALSE) # CMake's bootstrap binary does not support automoc else() target_sources( CMakeGUILib - PUBLIC + PRIVATE ${UI_BUILT_SRCS} ${MOC_BUILT_SRCS} ) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index da87213..10242fd 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -3616,6 +3616,14 @@ if(BUILD_TESTING) add_subdirectory(CMakeGUI) endif() + # Run CheckSourceTree as the very last test in the CMake/CTest/CPack test + # suite. It detects if any changes have been made to the CMake source tree + # by any previous configure, build or test steps. + if(GIT_EXECUTABLE AND EXISTS "${CMake_SOURCE_DIR}/.git" + AND NOT "${CMake_SOURCE_DIR}" STREQUAL "${CMake_BINARY_DIR}") + add_subdirectory(CheckSourceTree) + endif() + # If this is not an in-source build, provide a target to wipe out # all the test build directories. This must come at the end after # all the above logic has finished adding to TEST_BUILD_DIRS diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index 9e0b891..bd2dd7e 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -59,18 +59,3 @@ if(GIT_EXECUTABLE) ) AddCMakeTest(PolicyCheck "${PolicyCheck_PreArgs}") endif() - -# Run CheckSourceTree as the very last test in the CMake/CTest/CPack test -# suite. It detects if any changes have been made to the CMake source tree -# by any previous configure, build or test steps. -# -if(GIT_EXECUTABLE) - string(REPLACE "\\" "/" ENV_HOME "$ENV{HOME}") - set(CheckSourceTree_PreArgs - "-DCMake_BINARY_DIR:PATH=${CMake_BINARY_DIR}" - "-DCMake_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}" - "-DGIT_EXECUTABLE:STRING=${GIT_EXECUTABLE}" - "-DHOME:STRING=${ENV_HOME}" - ) - AddCMakeTest(CheckSourceTree "${CheckSourceTree_PreArgs}") -endif() diff --git a/Tests/CMakeTests/CheckSourceTreeTest.cmake.in b/Tests/CMakeTests/CheckSourceTreeTest.cmake.in deleted file mode 100644 index 4f2aaea..0000000 --- a/Tests/CMakeTests/CheckSourceTreeTest.cmake.in +++ /dev/null @@ -1,365 +0,0 @@ -# Check the CMake source tree and report anything suspicious... -# -message("=============================================================================") -message("CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") -message("") -message("CMake_BINARY_DIR='${CMake_BINARY_DIR}'") -message("CMake_SOURCE_DIR='${CMake_SOURCE_DIR}'") -message("GIT_EXECUTABLE='${GIT_EXECUTABLE}'") -message("HOME='${HOME}'") -message("ENV{DASHBOARD_TEST_FROM_CTEST}='$ENV{DASHBOARD_TEST_FROM_CTEST}'") -message("") -string(REPLACE "\\" "\\\\" HOME "${HOME}") - - -# Is the build directory the same as or underneath the source directory? -# (i.e. - is it an "in source" build?) -# -set(in_source_build 0) -set(build_under_source 0) - -string(FIND "${CMake_BINARY_DIR}" "${CMake_SOURCE_DIR}/" pos) -if(pos EQUAL 0) - message("build dir is *inside* source dir") - set(build_under_source 1) -elseif(CMake_SOURCE_DIR STREQUAL "${CMake_BINARY_DIR}") - message("build dir *is* source dir") - set(in_source_build 1) -else() - string(LENGTH "${CMake_SOURCE_DIR}" src_len) - string(LENGTH "${CMake_BINARY_DIR}" bin_len) - - if(bin_len GREATER src_len) - math(EXPR substr_len "${src_len}+1") - string(SUBSTRING "${CMake_BINARY_DIR}" 0 ${substr_len} bin_dir) - if(bin_dir STREQUAL "${CMake_SOURCE_DIR}/") - message("build dir is under source dir") - set(in_source_build 1) - endif() - endif() -endif() - -message("src_len='${src_len}'") -message("bin_len='${bin_len}'") -message("substr_len='${substr_len}'") -message("bin_dir='${bin_dir}'") -message("in_source_build='${in_source_build}'") -message("build_under_source='${build_under_source}'") -message("") - -if(build_under_source) - message(STATUS "Skipping rest of test because build tree is under source tree") - return() -endif() - -# If this does not appear to be a git checkout, just pass the test here -# and now. (Do not let the test fail if it is run in a tree *exported* from a -# repository or unpacked from a .zip file source installer...) -# -set(is_git_checkout 0) -if(EXISTS "${CMake_SOURCE_DIR}/.git") - set(is_git_checkout 1) -endif() - -message("is_git_checkout='${is_git_checkout}'") -message("") - -if(NOT is_git_checkout) - message("source tree is not a git checkout... test passes by early return...") - return() -endif() - -# This test looks for the following types of changes in the source tree: -# -set(additions 0) -set(conflicts 0) -set(modifications 0) -set(nonadditions 0) - -# ov == output variable... conditionally filled in by either git below: -# -set(cmd "") -set(ov "") -set(ev "") -set(rv "") - -# If no GIT_EXECUTABLE, see if we can figure out which git was used -# for the ctest_update step on this dashboard... -# -if(is_git_checkout AND NOT GIT_EXECUTABLE) - set(ctest_ini_file "") - set(exe "") - - # Use the old name: - if(EXISTS "${CMake_BINARY_DIR}/DartConfiguration.tcl") - set(ctest_ini_file "${CMake_BINARY_DIR}/DartConfiguration.tcl") - endif() - - # But if it exists, prefer the new name: - if(EXISTS "${CMake_BINARY_DIR}/CTestConfiguration.ini") - set(ctest_ini_file "${CMake_BINARY_DIR}/CTestConfiguration.ini") - endif() - - # If there is a ctest ini file, read the update command or git command - # from it: - # - if(ctest_ini_file) - file(STRINGS "${ctest_ini_file}" line REGEX "^GITCommand: (.*)$") - string(REGEX REPLACE "^GITCommand: (.*)$" "\\1" line "${line}") - if("${line}" MATCHES "^\"") - string(REGEX REPLACE "^\"([^\"]+)\" *.*$" "\\1" line "${line}") - else() - string(REGEX REPLACE "^([^ ]+) *.*$" "\\1" line "${line}") - endif() - set(exe "${line}") - if("${exe}" STREQUAL "GITCOMMAND-NOTFOUND") - set(exe "") - endif() - if(exe) - message("info: GIT_EXECUTABLE set by 'GITCommand:' from '${ctest_ini_file}'") - endif() - - if(NOT exe) - file(STRINGS "${ctest_ini_file}" line REGEX "^UpdateCommand: (.*)$") - string(REGEX REPLACE "^UpdateCommand: (.*)$" "\\1" line "${line}") - if("${line}" MATCHES "^\"") - string(REGEX REPLACE "^\"([^\"]+)\" *.*$" "\\1" line "${line}") - else() - string(REGEX REPLACE "^([^ ]+) *.*$" "\\1" line "${line}") - endif() - set(exe "${line}") - if("${exe}" STREQUAL "GITCOMMAND-NOTFOUND") - set(exe "") - endif() - if(exe) - message("info: GIT_EXECUTABLE set by 'UpdateCommand:' from '${ctest_ini_file}'") - endif() - endif() - else() - message("info: no DartConfiguration.tcl or CTestConfiguration.ini file...") - endif() - - # If we have still not grokked the exe, look in the Update.xml file to see - # if we can parse it from there... - # - if(NOT exe) - file(GLOB_RECURSE update_xml_file "${CMake_BINARY_DIR}/Testing/Update.xml") - if(update_xml_file) - file(STRINGS "${update_xml_file}" line - REGEX "^.*<UpdateCommand>(.*)</UpdateCommand>$" LIMIT_COUNT 1) - string(REPLACE ""\;" "\"" line "${line}") - string(REGEX REPLACE "^.*<UpdateCommand>(.*)</UpdateCommand>$" "\\1" line "${line}") - if("${line}" MATCHES "^\"") - string(REGEX REPLACE "^\"([^\"]+)\" *.*$" "\\1" line "${line}") - else() - string(REGEX REPLACE "^([^ ]+) *.*$" "\\1" line "${line}") - endif() - if(line) - set(exe "${line}") - endif() - if(exe) - message("info: GIT_EXECUTABLE set by '<UpdateCommand>' from '${update_xml_file}'") - endif() - else() - message("info: no Update.xml file...") - endif() - endif() - - if(exe) - set(GIT_EXECUTABLE "${exe}") - message("GIT_EXECUTABLE='${GIT_EXECUTABLE}'") - message("") - - if(NOT EXISTS "${GIT_EXECUTABLE}") - message(FATAL_ERROR "GIT_EXECUTABLE does not exist...") - endif() - else() - message(FATAL_ERROR "could not determine GIT_EXECUTABLE...") - endif() -endif() - - -if(is_git_checkout AND GIT_EXECUTABLE) - # Check with "git status" if there are any local modifications to the - # CMake source tree: - # - message("=============================================================================") - message("This is a git checkout, using git to verify source tree....") - message("") - - execute_process(COMMAND ${GIT_EXECUTABLE} --version - WORKING_DIRECTORY ${CMake_SOURCE_DIR} - OUTPUT_VARIABLE version_output - OUTPUT_STRIP_TRAILING_WHITESPACE) - message("=== output of 'git --version' ===") - message("${version_output}") - message("=== end output ===") - message("") - - execute_process(COMMAND ${GIT_EXECUTABLE} branch -a - WORKING_DIRECTORY ${CMake_SOURCE_DIR} - OUTPUT_VARIABLE git_branch_output - OUTPUT_STRIP_TRAILING_WHITESPACE) - message("=== output of 'git branch -a' ===") - message("${git_branch_output}") - message("=== end output ===") - message("") - - execute_process(COMMAND ${GIT_EXECUTABLE} log -1 - WORKING_DIRECTORY ${CMake_SOURCE_DIR} - OUTPUT_VARIABLE git_log_output - OUTPUT_STRIP_TRAILING_WHITESPACE) - message("=== output of 'git log -1' ===") - message("${git_log_output}") - message("=== end output ===") - message("") - - message("Copy/paste this command to reproduce:") - message("cd \"${CMake_SOURCE_DIR}\" && \"${GIT_EXECUTABLE}\" status") - message("") - - set(cmd ${GIT_EXECUTABLE} status) -endif() - - -if(cmd) - # Use the HOME value passed in to the script for calling git so it can - # find its user/global config settings... - # - set(original_ENV_HOME "$ENV{HOME}") - set(ENV{HOME} "${HOME}") - - execute_process(COMMAND ${cmd} - WORKING_DIRECTORY ${CMake_SOURCE_DIR} - OUTPUT_VARIABLE ov - ERROR_VARIABLE ev - RESULT_VARIABLE rv) - - set(ENV{HOME} "${original_ENV_HOME}") - - message("Results of running ${cmd}") - message("rv='${rv}'") - message("ov='${ov}'") - message("ev='${ev}'") - message("") - - if(NOT rv STREQUAL 0) - if(is_git_checkout AND (rv STREQUAL "1")) - # Many builds of git return "1" from a "nothing is changed" git status call... - # Do not fail with an error for rv==1 with git... - else() - message(FATAL_ERROR "error: ${cmd} attempt failed... (see output above)") - endif() - endif() -else() - message(FATAL_ERROR "error: no COMMAND to run to analyze source tree...") -endif() - - -# Analyze output: -# -if(NOT ov STREQUAL "") - string(REPLACE ";" "\\\\;" lines "${ov}") - string(REPLACE "\n" "E;" lines "${lines}") - - foreach(line ${lines}) - message("'${line}'") - - # But do not consider files that exist just because some user poked around - # the file system with Windows Explorer or with the Finder from a Mac... - # ('Thumbs.db' and '.DS_Store' files...) - # - set(consider 1) - set(ignore_files_regex "^(. |.*(/|\\\\))(\\.DS_Store|Thumbs.db)E$") - if(line MATCHES "${ignore_files_regex}") - message(" line matches '${ignore_files_regex}' -- not considered") - set(consider 0) - endif() - - if(consider) - if(is_git_checkout) - if(line MATCHES "^#?[ \t]*modified:") - message(" locally modified file detected...") - set(modifications 1) - endif() - - if(line MATCHES "^(# )?Untracked") - message(" locally non-added file/directory detected...") - set(nonadditions 1) - endif() - endif() - endif() - endforeach() -endif() - - -message("=============================================================================") -message("additions='${additions}'") -message("conflicts='${conflicts}'") -message("modifications='${modifications}'") -message("nonadditions='${nonadditions}'") -message("") - - -# Decide if the test passes or fails: -# -message("=============================================================================") - -if("$ENV{DASHBOARD_TEST_FROM_CTEST}" STREQUAL "") - - # developers are allowed to have local additions and modifications... - message("interactive test run") - message("") - -else() - - message("dashboard test run") - message("") - - # but dashboard machines are not allowed to have local additions or modifications... - if(additions) - message(FATAL_ERROR "test fails: local source tree additions") - endif() - - if(modifications) - message(FATAL_ERROR "test fails: local source tree modifications") - endif() - - # - # It's a dashboard run if ctest was run with '-D ExperimentalTest' or some - # other -D arg on its command line or if ctest is running a -S script to run - # a dashboard... Running ctest like that sets the DASHBOARD_TEST_FROM_CTEST - # env var. - # - -endif() - - -# ...and nobody is allowed to have local non-additions or conflicts... -# Not even developers. -# -if(nonadditions) - if(in_source_build) - message(" -warning: test results confounded because this is an 'in-source' build - cannot -distinguish between non-added files that are in-source build products and -non-added source files that somebody forgot to 'git add'... - this is only ok -if this is intentionally an in-source dashboard build... Developers should -use out-of-source builds to verify a clean source tree with this test... - -Allowing test to pass despite the warning message... -") - else() - message(FATAL_ERROR "test fails: local source tree non-additions: use git add before committing, or remove the files from the source tree") - endif() -endif() - -if(conflicts) - message(FATAL_ERROR "test fails: local source tree conflicts: resolve before committing") -endif() - - -# Still here? Good then... -# -message("test passes") -message("") diff --git a/Tests/CheckSourceTree/CMakeLists.txt b/Tests/CheckSourceTree/CMakeLists.txt new file mode 100644 index 0000000..d5019d2 --- /dev/null +++ b/Tests/CheckSourceTree/CMakeLists.txt @@ -0,0 +1,6 @@ +add_test(NAME CMake.CheckSourceTree + COMMAND ${CMAKE_COMMAND} -D GIT_EXECUTABLE=${GIT_EXECUTABLE} + -D CMake_SOURCE_DIR=${CMake_SOURCE_DIR} + -P ${CMAKE_CURRENT_LIST_DIR}/check.cmake + ) +set_property(TEST CMake.CheckSourceTree PROPERTY RUN_SERIAL 1) diff --git a/Tests/CheckSourceTree/check.cmake b/Tests/CheckSourceTree/check.cmake new file mode 100644 index 0000000..c2e3529 --- /dev/null +++ b/Tests/CheckSourceTree/check.cmake @@ -0,0 +1,22 @@ +# Give Git access to the real home directory to get user's settings. +if(DEFINED ENV{CTEST_REAL_HOME}) + set(ENV{HOME} "$ENV{CTEST_REAL_HOME}") +endif() + +execute_process( + COMMAND "${GIT_EXECUTABLE}" status + WORKING_DIRECTORY "${CMake_SOURCE_DIR}" + OUTPUT_VARIABLE output + ERROR_VARIABLE output + RESULT_VARIABLE result + ) +string(REPLACE "\n" "\n " output " ${output}") +if(NOT result EQUAL 0) + message(FATAL_ERROR "'git status' failed (${result}):\n${output}") +endif() + +if(output MATCHES "\n[ \t#]*(Changes |new file:|modified:|Untracked )") + message(FATAL_ERROR "The source tree is not clean. 'git status' reports:\n${output}") +endif() + +message(STATUS "The source tree is clean.") |