diff options
52 files changed, 379 insertions, 70 deletions
diff --git a/Help/command/ctest_test.rst b/Help/command/ctest_test.rst index 2153c90..03ec1a4 100644 --- a/Help/command/ctest_test.rst +++ b/Help/command/ctest_test.rst @@ -270,3 +270,18 @@ The following example demonstrates how to specify a custom value for the std::cout << "<CTestDetails>My Custom Details Value</CTestDetails>" << std::endl; + +Additional Labels +""""""""""""""""" + +The following example demonstrates how to add additional labels to a test +at runtime. + +.. code-block:: c++ + + std::cout << + "<CTestLabel>Custom Label 1</CTestLabel>\n" << + "<CTestLabel>Custom Label 2</CTestLabel>" << std::endl; + +Use the :prop_test:`LABELS` test property instead for labels that can be +determined at configure time. diff --git a/Help/command/source_group.rst b/Help/command/source_group.rst index 5db1ec8..a4b5bf1 100644 --- a/Help/command/source_group.rst +++ b/Help/command/source_group.rst @@ -11,6 +11,9 @@ There are two different signatures to create source groups. Defines a group into which sources will be placed in project files. This is intended to set up file tabs in Visual Studio. +The group is scoped in the directory where the command is called, +and applies to sources in targets created in that directory. + The options are: ``TREE`` diff --git a/Help/guide/tutorial/A Basic Starting Point.rst b/Help/guide/tutorial/A Basic Starting Point.rst index 20e4129..41e8479 100644 --- a/Help/guide/tutorial/A Basic Starting Point.rst +++ b/Help/guide/tutorial/A Basic Starting Point.rst @@ -8,6 +8,7 @@ required. This will be the starting point for our tutorial. Create a .. code-block:: cmake :caption: CMakeLists.txt + :name: CMakeLists.txt-start cmake_minimum_required(VERSION 3.10) @@ -35,6 +36,7 @@ to set the project name and version number. .. literalinclude:: Step2/CMakeLists.txt :caption: CMakeLists.txt + :name: CMakeLists.txt-project-VERSION :language: cmake :end-before: # specify the C++ standard @@ -43,6 +45,7 @@ code: .. literalinclude:: Step2/CMakeLists.txt :caption: CMakeLists.txt + :name: CMakeLists.txt-configure_file :language: cmake :start-after: # to the source code :end-before: # add the executable @@ -53,6 +56,7 @@ files. Add the following lines to the end of the ``CMakeLists.txt`` file: .. literalinclude:: Step2/CMakeLists.txt :caption: CMakeLists.txt + :name: CMakeLists.txt-target_include_directories :language: cmake :start-after: # so that we will find TutorialConfig.h @@ -61,6 +65,7 @@ directory with the following contents: .. literalinclude:: Step2/TutorialConfig.h.in :caption: TutorialConfig.h.in + :name: TutorialConfig.h.in :language: c++ When CMake configures this header file the values for @@ -75,6 +80,7 @@ Finally, let's print out the executable name and version number by updating .. literalinclude:: Step2/tutorial.cxx :caption: tutorial.cxx + :name: tutorial.cxx-print-version :language: c++ :start-after: { :end-before: // convert input to double @@ -88,6 +94,7 @@ Next let's add some C++11 features to our project by replacing ``atof`` with .. literalinclude:: Step2/tutorial.cxx :caption: tutorial.cxx + :name: tutorial.cxx-cxx11 :language: c++ :start-after: // convert input to double :end-before: // calculate square root @@ -102,6 +109,7 @@ call to ``add_executable``. .. literalinclude:: Step2/CMakeLists.txt :caption: CMakeLists.txt + :name: CMakeLists.txt-CXX_STANDARD :language: cmake :end-before: # configure a header file to pass some of the CMake settings diff --git a/Help/guide/tutorial/Adding Export Configuration.rst b/Help/guide/tutorial/Adding Export Configuration.rst index da0d877..e5ab6a2 100644 --- a/Help/guide/tutorial/Adding Export Configuration.rst +++ b/Help/guide/tutorial/Adding Export Configuration.rst @@ -19,6 +19,7 @@ command in ``MathFunctions/CMakeLists.txt`` to look like: .. literalinclude:: Complete/MathFunctions/CMakeLists.txt :caption: MathFunctions/CMakeLists.txt + :name: MathFunctions/CMakeLists.txt-install-TARGETS-EXPORT :language: cmake :start-after: # install rules @@ -28,6 +29,7 @@ adding the following to the bottom of the top-level ``CMakeLists.txt``: .. literalinclude:: Complete/CMakeLists.txt :caption: CMakeLists.txt + :name: CMakeLists.txt-install-EXPORT :language: cmake :start-after: # install the configuration targets :end-before: include(CMakePackageConfigHelpers) @@ -54,6 +56,7 @@ directory and from an install / package. This means converting the .. literalinclude:: Step12/MathFunctions/CMakeLists.txt :caption: MathFunctions/CMakeLists.txt + :name: MathFunctions/CMakeLists.txt-target_include_directories :language: cmake :start-after: # to find MathFunctions.h, while we don't. :end-before: # should we use our own math functions @@ -69,12 +72,14 @@ ahead and add a new file to the top-level of the project called .. literalinclude:: Step12/Config.cmake.in :caption: Config.cmake.in + :name: Config.cmake.in Then, to properly configure and install that file, add the following to the bottom of the top-level ``CMakeLists.txt``: .. literalinclude:: Step12/CMakeLists.txt :caption: CMakeLists.txt + :name: CMakeLists.txt-install-Config.cmake :language: cmake :start-after: # install the configuration targets :end-before: # generate the export @@ -86,6 +91,7 @@ the following to the bottom of the top level ``CMakeLists.txt``: .. literalinclude:: Step12/CMakeLists.txt :caption: CMakeLists.txt + :name: CMakeLists.txt-export :language: cmake :start-after: # needs to be after the install(TARGETS ) command diff --git a/Help/guide/tutorial/Adding Generator Expressions.rst b/Help/guide/tutorial/Adding Generator Expressions.rst index b21fc62..55acb34 100644 --- a/Help/guide/tutorial/Adding Generator Expressions.rst +++ b/Help/guide/tutorial/Adding Generator Expressions.rst @@ -39,6 +39,7 @@ So the following code: .. literalinclude:: Step10/CMakeLists.txt :caption: CMakeLists.txt + :name: CMakeLists.txt-CXX_STANDARD-variable-remove :language: cmake :start-after: project(Tutorial VERSION 1.0) :end-before: # control where the static and shared libraries are built so that on windows @@ -47,6 +48,7 @@ Would be replaced with: .. literalinclude:: Step11/CMakeLists.txt :caption: CMakeLists.txt + :name: CMakeLists.txt-cxx_std-feature :language: cmake :start-after: project(Tutorial VERSION 1.0) :end-before: # add compiler warning flags just when building this project via @@ -59,6 +61,7 @@ of compiler ids as seen below: .. literalinclude:: Step11/CMakeLists.txt :caption: CMakeLists.txt + :name: CMakeLists.txt-target_compile_options-genex :language: cmake :start-after: # the BUILD_INTERFACE genex :end-before: # control where the static and shared libraries are built so that on windows diff --git a/Help/guide/tutorial/Adding Support for a Testing Dashboard.rst b/Help/guide/tutorial/Adding Support for a Testing Dashboard.rst index 9cdbb34..26aae4f 100644 --- a/Help/guide/tutorial/Adding Support for a Testing Dashboard.rst +++ b/Help/guide/tutorial/Adding Support for a Testing Dashboard.rst @@ -11,6 +11,7 @@ Replace: .. code-block:: cmake :caption: CMakeLists.txt + :name: CMakeLists.txt-enable_testing-remove # enable testing enable_testing() @@ -19,6 +20,7 @@ With: .. code-block:: cmake :caption: CMakeLists.txt + :name: CMakeLists.txt-include-CTest # enable dashboard scripting include(CTest) @@ -32,6 +34,7 @@ dashboard. .. literalinclude:: Step9/CTestConfig.cmake :caption: CTestConfig.cmake + :name: CTestConfig.cmake :language: cmake The :manual:`ctest <ctest(1)>` executable will read in this file when it runs. diff --git a/Help/guide/tutorial/Adding System Introspection.rst b/Help/guide/tutorial/Adding System Introspection.rst index c11f793..7210a8d 100644 --- a/Help/guide/tutorial/Adding System Introspection.rst +++ b/Help/guide/tutorial/Adding System Introspection.rst @@ -16,6 +16,7 @@ the ``m`` library. If ``log`` and ``exp`` are not initially found, require the .. literalinclude:: Step6/MathFunctions/CMakeLists.txt :caption: MathFunctions/CMakeLists.txt + :name: MathFunctions/CMakeLists.txt-check_symbol_exists :language: cmake :start-after: # does this system provide the log and exp functions? :end-before: # add compile definitions @@ -25,6 +26,7 @@ If available, use :command:`target_compile_definitions` to specify .. literalinclude:: Step6/MathFunctions/CMakeLists.txt :caption: MathFunctions/CMakeLists.txt + :name: MathFunctions/CMakeLists.txt-target_compile_definitions :language: cmake :start-after: # add compile definitions :end-before: # install rules @@ -36,6 +38,7 @@ the ``mysqrt`` function in ``MathFunctions/mysqrt.cxx`` (don't forget the .. literalinclude:: Step6/MathFunctions/mysqrt.cxx :caption: MathFunctions/mysqrt.cxx + :name: MathFunctions/mysqrt.cxx-ifdef :language: c++ :start-after: // if we have both log and exp then use them :end-before: // do ten iterations @@ -44,6 +47,7 @@ We will also need to modify ``mysqrt.cxx`` to include ``cmath``. .. literalinclude:: Step6/MathFunctions/mysqrt.cxx :caption: MathFunctions/mysqrt.cxx + :name: MathFunctions/mysqrt.cxx-include-cmath :language: c++ :end-before: #include <iostream> diff --git a/Help/guide/tutorial/Adding Usage Requirements for a Library.rst b/Help/guide/tutorial/Adding Usage Requirements for a Library.rst index 8ef9cc6..a8e914e 100644 --- a/Help/guide/tutorial/Adding Usage Requirements for a Library.rst +++ b/Help/guide/tutorial/Adding Usage Requirements for a Library.rst @@ -23,6 +23,7 @@ doesn't. Add the following lines to the end of .. literalinclude:: Step4/MathFunctions/CMakeLists.txt :caption: MathFunctions/CMakeLists.txt + :name: MathFunctions/CMakeLists.txt-target_include_directories-INTERFACE :language: cmake :start-after: # to find MathFunctions.h @@ -32,6 +33,7 @@ remove our uses of the ``EXTRA_INCLUDES`` variable from the top-level .. literalinclude:: Step4/CMakeLists.txt :caption: CMakeLists.txt + :name: CMakeLists.txt-remove-EXTRA_INCLUDES :language: cmake :start-after: # add the MathFunctions library :end-before: # add the executable @@ -40,6 +42,7 @@ And here: .. literalinclude:: Step4/CMakeLists.txt :caption: CMakeLists.txt + :name: CMakeLists.txt-target_include_directories-remove-EXTRA_INCLUDES :language: cmake :start-after: # so that we will find TutorialConfig.h diff --git a/Help/guide/tutorial/Adding a Custom Command and Generated File.rst b/Help/guide/tutorial/Adding a Custom Command and Generated File.rst index c60379a..70c6695 100644 --- a/Help/guide/tutorial/Adding a Custom Command and Generated File.rst +++ b/Help/guide/tutorial/Adding a Custom Command and Generated File.rst @@ -28,6 +28,7 @@ First, at the top of ``MathFunctions/CMakeLists.txt``, the executable for .. literalinclude:: Step7/MathFunctions/CMakeLists.txt :caption: MathFunctions/CMakeLists.txt + :name: MathFunctions/CMakeLists.txt-add_executable-MakeTable :language: cmake :start-after: # first we add the executable that generates the table :end-before: # add the command to generate the source code @@ -37,6 +38,7 @@ by running MakeTable. .. literalinclude:: Step7/MathFunctions/CMakeLists.txt :caption: MathFunctions/CMakeLists.txt + :name: MathFunctions/CMakeLists.txt-add_custom_command-Table.h :language: cmake :start-after: # add the command to generate the source code :end-before: # add the main library @@ -47,6 +49,7 @@ of sources for the library MathFunctions. .. literalinclude:: Step7/MathFunctions/CMakeLists.txt :caption: MathFunctions/CMakeLists.txt + :name: MathFunctions/CMakeLists.txt-add_library-Table.h :language: cmake :start-after: # add the main library :end-before: # state that anybody linking @@ -56,6 +59,7 @@ directories so that ``Table.h`` can be found and included by ``mysqrt.cxx``. .. literalinclude:: Step7/MathFunctions/CMakeLists.txt :caption: MathFunctions/CMakeLists.txt + :name: MathFunctions/CMakeLists.txt-target_include_directories-Table.h :language: cmake :start-after: # state that we depend on our bin :end-before: # install rules @@ -65,6 +69,7 @@ Now let's use the generated table. First, modify ``mysqrt.cxx`` to include .. literalinclude:: Step7/MathFunctions/mysqrt.cxx :caption: MathFunctions/mysqrt.cxx + :name: MathFunctions/mysqrt.cxx :language: c++ :start-after: // a hack square root calculation using simple operations diff --git a/Help/guide/tutorial/Adding a Library.rst b/Help/guide/tutorial/Adding a Library.rst index 02f7ed1..1806361 100644 --- a/Help/guide/tutorial/Adding a Library.rst +++ b/Help/guide/tutorial/Adding a Library.rst @@ -17,6 +17,7 @@ directory: .. literalinclude:: Step3/MathFunctions/CMakeLists.txt :caption: MathFunctions/CMakeLists.txt + :name: MathFunctions/CMakeLists.txt :language: cmake To make use of the new library we will add an :command:`add_subdirectory` @@ -27,6 +28,7 @@ last few lines of the top-level ``CMakeLists.txt`` file should now look like: .. code-block:: cmake :caption: CMakeLists.txt + :name: CMakeLists.txt-add_subdirectory # add the MathFunctions library add_subdirectory(MathFunctions) @@ -50,6 +52,7 @@ occurrence. The first step is to add an option to the top-level .. literalinclude:: Step3/CMakeLists.txt :caption: CMakeLists.txt + :name: CMakeLists.txt-option :language: cmake :start-after: # should we use our own math functions :end-before: # add the MathFunctions library @@ -66,6 +69,7 @@ file to look like the following: .. literalinclude:: Step3/CMakeLists.txt :caption: CMakeLists.txt + :name: CMakeLists.txt-target_link_libraries-EXTRA_LIBS :language: cmake :start-after: # add the MathFunctions library @@ -81,6 +85,7 @@ need it: .. literalinclude:: Step3/tutorial.cxx :caption: tutorial.cxx + :name: tutorial.cxx-ifdef-include :language: c++ :start-after: // should we include the MathFunctions header :end-before: int main @@ -90,6 +95,7 @@ function is used: .. literalinclude:: Step3/tutorial.cxx :caption: tutorial.cxx + :name: tutorial.cxx-ifdef-const :language: c++ :start-after: // which square root function should we use? :end-before: std::cout << "The square root of @@ -99,6 +105,7 @@ Since the source code now requires ``USE_MYMATH`` we can add it to .. literalinclude:: Step3/TutorialConfig.h.in :caption: TutorialConfig.h.in + :name: TutorialConfig.h.in-cmakedefine :language: c++ :lines: 4 diff --git a/Help/guide/tutorial/Installing and Testing.rst b/Help/guide/tutorial/Installing and Testing.rst index 53f0363..2fc3202 100644 --- a/Help/guide/tutorial/Installing and Testing.rst +++ b/Help/guide/tutorial/Installing and Testing.rst @@ -14,6 +14,7 @@ So to the end of ``MathFunctions/CMakeLists.txt`` we add: .. literalinclude:: Step5/MathFunctions/CMakeLists.txt :caption: MathFunctions/CMakeLists.txt + :name: MathFunctions/CMakeLists.txt-install-TARGETS :language: cmake :start-after: # install rules @@ -21,6 +22,7 @@ And to the end of the top-level ``CMakeLists.txt`` we add: .. literalinclude:: Step5/CMakeLists.txt :caption: CMakeLists.txt + :name: CMakeLists.txt-install-TARGETS :language: cmake :start-after: # add the install targets :end-before: # enable testing @@ -65,6 +67,7 @@ the application is working correctly. .. literalinclude:: Step5/CMakeLists.txt :caption: CMakeLists.txt + :name: CMakeLists.txt-enable_testing :language: cmake :start-after: # enable testing diff --git a/Help/guide/tutorial/Packaging Debug and Release.rst b/Help/guide/tutorial/Packaging Debug and Release.rst index c2bf1b5..91b46a7 100644 --- a/Help/guide/tutorial/Packaging Debug and Release.rst +++ b/Help/guide/tutorial/Packaging Debug and Release.rst @@ -18,6 +18,7 @@ Set :variable:`CMAKE_DEBUG_POSTFIX` near the beginning of the top-level .. literalinclude:: Complete/CMakeLists.txt :caption: CMakeLists.txt + :name: CMakeLists.txt-CMAKE_DEBUG_POSTFIX-variable :language: cmake :start-after: project(Tutorial VERSION 1.0) :end-before: target_compile_features(tutorial_compiler_flags @@ -26,6 +27,7 @@ And the :prop_tgt:`DEBUG_POSTFIX` property on the tutorial executable: .. literalinclude:: Complete/CMakeLists.txt :caption: CMakeLists.txt + :name: CMakeLists.txt-DEBUG_POSTFIX-property :language: cmake :start-after: # add the executable :end-before: # add the binary tree to the search path for include files @@ -36,6 +38,7 @@ Let's also add version numbering to the ``MathFunctions`` library. In .. literalinclude:: Complete/MathFunctions/CMakeLists.txt :caption: MathFunctions/CMakeLists.txt + :name: MathFunctions/CMakeLists.txt-VERSION-properties :language: cmake :start-after: # setup the version numbering :end-before: # install rules @@ -72,6 +75,7 @@ projects to install. In this case, we want to install both debug and release. .. literalinclude:: Complete/MultiCPackConfig.cmake :caption: MultiCPackConfig.cmake + :name: MultiCPackConfig.cmake :language: cmake From the ``Step12`` directory, run :manual:`cpack <cpack(1)>` specifying our diff --git a/Help/guide/tutorial/Packaging an Installer.rst b/Help/guide/tutorial/Packaging an Installer.rst index f3a5e12..5eb3e3e 100644 --- a/Help/guide/tutorial/Packaging an Installer.rst +++ b/Help/guide/tutorial/Packaging an Installer.rst @@ -13,6 +13,7 @@ few lines to the bottom of our top-level ``CMakeLists.txt`` file. .. literalinclude:: Step8/CMakeLists.txt :caption: CMakeLists.txt + :name: CMakeLists.txt-include-CPack :language: cmake :start-after: # setup installer diff --git a/Help/guide/tutorial/Selecting Static or Shared Libraries.rst b/Help/guide/tutorial/Selecting Static or Shared Libraries.rst index 85dcbf5..2d5f70e 100644 --- a/Help/guide/tutorial/Selecting Static or Shared Libraries.rst +++ b/Help/guide/tutorial/Selecting Static or Shared Libraries.rst @@ -21,6 +21,7 @@ The first step is to update the starting section of the top-level .. literalinclude:: Step10/CMakeLists.txt :caption: CMakeLists.txt + :name: CMakeLists.txt-option-BUILD_SHARED_LIBS :language: cmake :end-before: # add the binary tree @@ -34,6 +35,7 @@ The end result is that ``MathFunctions/CMakeLists.txt`` should look like: .. literalinclude:: Step10/MathFunctions/CMakeLists.txt :caption: MathFunctions/CMakeLists.txt + :name: MathFunctions/CMakeLists.txt-add_library-STATIC :language: cmake :lines: 1-36,42- @@ -42,6 +44,7 @@ Next, update ``MathFunctions/mysqrt.cxx`` to use the ``mathfunctions`` and .. literalinclude:: Step10/MathFunctions/mysqrt.cxx :caption: MathFunctions/mysqrt.cxx + :name: MathFunctions/mysqrt.cxx-namespace :language: c++ We also need to make some changes in ``tutorial.cxx``, so that it no longer @@ -55,6 +58,7 @@ Finally, update ``MathFunctions/MathFunctions.h`` to use dll export defines: .. literalinclude:: Step10/MathFunctions/MathFunctions.h :caption: MathFunctions/MathFunctions.h + :name: MathFunctions/MathFunctions.h :language: c++ At this point, if you build everything, you may notice that linking fails @@ -65,6 +69,7 @@ SqrtLibrary to be ``True`` no matter the build type. .. literalinclude:: Step10/MathFunctions/CMakeLists.txt :caption: MathFunctions/CMakeLists.txt + :name: MathFunctions/CMakeLists.txt-POSITION_INDEPENDENT_CODE :language: cmake :lines: 37-42 diff --git a/Help/release/3.20.rst b/Help/release/3.20.rst index f77304f..da27174 100644 --- a/Help/release/3.20.rst +++ b/Help/release/3.20.rst @@ -362,3 +362,10 @@ Changes made since CMake 3.20.0 include the following. a special case to recognize oneAPI 2021.1 Fortran as ``IntelLLVM``. The oneAPI 2021.2 Fortran compiler defines the proper identification macro and so is identified as ``IntelLLVM`` by all CMake 3.20 versions. + +3.20.3, 3.20.4, 3.20.5 +---------------------- + +These versions made no changes to documented features or interfaces. +Some implementation updates were made to support ecosystem changes +and/or fix regressions. diff --git a/Help/release/dev/FindPkgConfig-PKG_CONFIG-args.rst b/Help/release/dev/FindPkgConfig-PKG_CONFIG-args.rst new file mode 100644 index 0000000..44c26b5 --- /dev/null +++ b/Help/release/dev/FindPkgConfig-PKG_CONFIG-args.rst @@ -0,0 +1,5 @@ +FindPkgConfig-PKG_CONFIG-args +----------------------------- + +* The :module:`FindPkgConfig` module gained a :variable:`PKG_CONFIG_ARGN` + variable to specify arguments to ``pkg-config`` calls. diff --git a/Help/release/dev/ctest-runtime-labels.rst b/Help/release/dev/ctest-runtime-labels.rst new file mode 100644 index 0000000..7ce0b64 --- /dev/null +++ b/Help/release/dev/ctest-runtime-labels.rst @@ -0,0 +1,7 @@ +ctest-runtime-labels +-------------------- + +* :manual:`ctest(1)` learned to recognize labels attached to a test at run time. + Previously it was only possible to attach labels to tests at configure time + by using the :prop_test:`LABELS` test property. + See :ref:`Additional Test Measurements` for more information. diff --git a/Help/release/dev/msvc-isystem.rst b/Help/release/dev/msvc-isystem.rst new file mode 100644 index 0000000..4a5d79f --- /dev/null +++ b/Help/release/dev/msvc-isystem.rst @@ -0,0 +1,7 @@ +msvc-isystem +------------ + +* The MSVC compilers learned to pass the ``-external:I`` flag for system + includes when using the :generator:`Ninja` and :generator:`NMake Makefiles` + generators. This became available as of Visual Studio 16.10 (toolchain + version 14.29.30037). diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake index 2197790..dd70d82 100644 --- a/Modules/CMakeCompilerIdDetection.cmake +++ b/Modules/CMakeCompilerIdDetection.cmake @@ -13,8 +13,8 @@ endfunction() function(compiler_id_detection outvar lang) - if (NOT lang STREQUAL Fortran AND NOT lang STREQUAL CSharp - AND NOT lang STREQUAL ISPC) + if (NOT "x${lang}" STREQUAL "xFortran" AND NOT "x${lang}" STREQUAL "xCSharp" + AND NOT "x${lang}" STREQUAL "xISPC") file(GLOB lang_files "${CMAKE_ROOT}/Modules/Compiler/*-DetermineCompiler.cmake") set(nonlang CXX) @@ -42,7 +42,7 @@ function(compiler_id_detection outvar lang) # Order is relevant here. For example, compilers which pretend to be # GCC must appear before the actual GCC. - if (lang STREQUAL CXX) + if ("x${lang}" STREQUAL "xCXX") list(APPEND ordered_compilers Comeau ) @@ -70,7 +70,7 @@ function(compiler_id_detection outvar lang) Fujitsu GHS ) - if (lang STREQUAL C) + if ("x${lang}" STREQUAL "xC") list(APPEND ordered_compilers TinyCC Bruce @@ -92,13 +92,13 @@ function(compiler_id_detection outvar lang) ADSP IAR ) - if (lang STREQUAL C) + if ("x${lang}" STREQUAL "xC") list(APPEND ordered_compilers SDCC ) endif() - if(lang STREQUAL CUDA) + if("x${lang}" STREQUAL "xCUDA") set(ordered_compilers NVIDIA Clang) endif() diff --git a/Modules/Compiler/MSVC-C.cmake b/Modules/Compiler/MSVC-C.cmake index 9a5104b..73cca36 100644 --- a/Modules/Compiler/MSVC-C.cmake +++ b/Modules/Compiler/MSVC-C.cmake @@ -63,3 +63,9 @@ endmacro() if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05) set(CMAKE_C_COMPILE_OPTIONS_JMC "-JMC") endif() + +# The `/external:I` flag was made non-experimental in 19.29.30036.3. +if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.29.30036.3) + set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-external:I ") + set(_CMAKE_INCLUDE_SYSTEM_FLAG_C_WARNING "-external:W0 ") +endif () diff --git a/Modules/Compiler/MSVC-CXX.cmake b/Modules/Compiler/MSVC-CXX.cmake index f1c7450..09fe851 100644 --- a/Modules/Compiler/MSVC-CXX.cmake +++ b/Modules/Compiler/MSVC-CXX.cmake @@ -79,3 +79,9 @@ endif() if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05) set(CMAKE_CXX_COMPILE_OPTIONS_JMC "-JMC") endif() + +# The `/external:I` flag was made non-experimental in 19.29.30036.3. +if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.29.30036.3) + set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-external:I ") + set(_CMAKE_INCLUDE_SYSTEM_FLAG_CXX_WARNING "-external:W0 ") +endif () diff --git a/Modules/ExternalProject-gitupdate.cmake.in b/Modules/ExternalProject-gitupdate.cmake.in index 461e323..0de2372 100644 --- a/Modules/ExternalProject-gitupdate.cmake.in +++ b/Modules/ExternalProject-gitupdate.cmake.in @@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.5) function(get_hash_for_ref ref out_var err_var) execute_process( - COMMAND "@git_EXECUTABLE@" rev-parse "${ref}^{commit}" + COMMAND "@git_EXECUTABLE@" rev-parse "${ref}^0" WORKING_DIRECTORY "@work_dir@" RESULT_VARIABLE error_code OUTPUT_VARIABLE ref_hash diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 3bc9dba..bd54fd9 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -15,6 +15,8 @@ following variables will also be set: if pkg-config executable was found ``PKG_CONFIG_EXECUTABLE`` pathname of the pkg-config program +``PKG_CONFIG_ARGN`` + list of arguments to pass to pkg-config ``PKG_CONFIG_VERSION_STRING`` version of pkg-config (since CMake 2.8.8) @@ -29,7 +31,15 @@ set(PKG_CONFIG_VERSION 1) # find pkg-config, use PKG_CONFIG if set if((NOT PKG_CONFIG_EXECUTABLE) AND (NOT "$ENV{PKG_CONFIG}" STREQUAL "")) - set(PKG_CONFIG_EXECUTABLE "$ENV{PKG_CONFIG}" CACHE FILEPATH "pkg-config executable") + separate_arguments(PKG_CONFIG_FROM_ENV_SPLIT NATIVE_COMMAND PROGRAM SEPARATE_ARGS "$ENV{PKG_CONFIG}") + list(LENGTH PKG_CONFIG_FROM_ENV_SPLIT PKG_CONFIG_FROM_ENV_SPLIT_ARGC) + if(PKG_CONFIG_FROM_ENV_SPLIT_ARGC GREATER 0) + list(GET PKG_CONFIG_FROM_ENV_SPLIT 0 PKG_CONFIG_FROM_ENV_ARGV0) + if(PKG_CONFIG_FROM_ENV_SPLIT_ARGC GREATER 1) + list(SUBLIST PKG_CONFIG_FROM_ENV_SPLIT 1 -1 PKG_CONFIG_ARGN) + endif() + set(PKG_CONFIG_EXECUTABLE "${PKG_CONFIG_FROM_ENV_ARGV0}" CACHE FILEPATH "pkg-config executable") + endif() endif() set(PKG_CONFIG_NAMES "pkg-config") @@ -43,9 +53,12 @@ find_program(PKG_CONFIG_EXECUTABLE DOC "pkg-config executable") mark_as_advanced(PKG_CONFIG_EXECUTABLE) +set(PKG_CONFIG_ARGN "${PKG_CONFIG_ARGN}" CACHE STRING "Arguments to supply to pkg-config") +mark_as_advanced(PKG_CONFIG_ARGN) + set(_PKG_CONFIG_FAILURE_MESSAGE "") if (PKG_CONFIG_EXECUTABLE) - execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --version + execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} ${PKG_CONFIG_ARGN} --version OUTPUT_VARIABLE PKG_CONFIG_VERSION_STRING OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_VARIABLE _PKG_CONFIG_VERSION_ERROR ERROR_STRIP_TRAILING_WHITESPACE RESULT_VARIABLE _PKG_CONFIG_VERSION_RESULT @@ -53,14 +66,18 @@ if (PKG_CONFIG_EXECUTABLE) if (NOT _PKG_CONFIG_VERSION_RESULT EQUAL 0) string(REPLACE "\n" "\n " _PKG_CONFIG_VERSION_ERROR " ${_PKG_CONFIG_VERSION_ERROR}") + if(PKG_CONFIG_ARGN) + string(REPLACE ";" " " PKG_CONFIG_ARGN " ${PKG_CONFIG_ARGN}") + endif() string(APPEND _PKG_CONFIG_FAILURE_MESSAGE "The command\n" - " \"${PKG_CONFIG_EXECUTABLE}\" --version\n" + " \"${PKG_CONFIG_EXECUTABLE}\"${PKG_CONFIG_ARGN} --version\n" " failed with output:\n${PKG_CONFIG_VERSION_STRING}\n" " stderr: \n${_PKG_CONFIG_VERSION_ERROR}\n" " result: \n${_PKG_CONFIG_VERSION_RESULT}" ) set(PKG_CONFIG_EXECUTABLE "") + set(PKG_CONFIG_ARGN "") unset(PKG_CONFIG_VERSION_STRING) endif () unset(_PKG_CONFIG_VERSION_RESULT) @@ -91,7 +108,7 @@ macro(_pkgconfig_invoke _pkglist _prefix _varname _regexp) set(_pkgconfig_invoke_result) execute_process( - COMMAND ${PKG_CONFIG_EXECUTABLE} ${ARGN} ${_pkglist} + COMMAND ${PKG_CONFIG_EXECUTABLE} ${PKG_CONFIG_ARGN} ${ARGN} ${_pkglist} OUTPUT_VARIABLE _pkgconfig_invoke_result RESULT_VARIABLE _pkgconfig_failed OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -533,7 +550,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma # execute the query execute_process( - COMMAND ${PKG_CONFIG_EXECUTABLE} ${_pkg_check_modules_exist_query} + COMMAND ${PKG_CONFIG_EXECUTABLE} ${PKG_CONFIG_ARGN} ${_pkg_check_modules_exist_query} RESULT_VARIABLE _pkgconfig_retval ERROR_VARIABLE _pkgconfig_error ERROR_STRIP_TRAILING_WHITESPACE) @@ -892,6 +909,18 @@ Variables Affecting Behavior .. versionadded:: 3.1 The ``PKG_CONFIG`` environment variable can be used as a hint. +.. variable:: PKG_CONFIG_ARGN + + .. versionadded:: 3.22 + + This can be set to a list of arguments to additionally pass to pkg-config + if needed. If not provided, it will be an empty string, however, if the + environment variable ``PKG_CONFIG`` is provided, this will be set to the + result of splitting the variable. + + The ``PKG_CONFIG`` environment variable can be used to provide both + ``PKG_CONFIG_EXECUTABLE`` and ``PKG_CONFIG_ARGN`` + .. variable:: PKG_CONFIG_USE_CMAKE_PREFIX_PATH .. versionadded:: 3.1 diff --git a/Modules/GNUInstallDirs.cmake b/Modules/GNUInstallDirs.cmake index f7d8c36..d81033c 100644 --- a/Modules/GNUInstallDirs.cmake +++ b/Modules/GNUInstallDirs.cmake @@ -239,6 +239,7 @@ if(NOT DEFINED CMAKE_INSTALL_LIBDIR OR (_libdir_set endif() if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$" AND NOT CMAKE_CROSSCOMPILING + AND NOT EXISTS "/etc/alpine-release" AND NOT EXISTS "/etc/arch-release") if (EXISTS "/etc/debian_version") # is this a debian system ? if(CMAKE_LIBRARY_ARCHITECTURE) diff --git a/Modules/Internal/CheckCompilerFlag.cmake b/Modules/Internal/CheckCompilerFlag.cmake index 9eb1bf0..693e28b 100644 --- a/Modules/Internal/CheckCompilerFlag.cmake +++ b/Modules/Internal/CheckCompilerFlag.cmake @@ -13,10 +13,12 @@ function(CMAKE_CHECK_COMPILER_FLAG _lang _flag _var) if(_lang STREQUAL "C") set(_lang_src "int main(void) { return 0; }") - set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for C") + set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for C" + FAIL_REGEX "-Werror=.* argument .* is not valid for C") elseif(_lang STREQUAL "CXX") set(_lang_src "int main() { return 0; }") - set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for C\\+\\+") + set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for C\\+\\+" + FAIL_REGEX "-Werror=.* argument .* is not valid for C\\+\\+") elseif(_lang STREQUAL "CUDA") set(_lang_src "__host__ int main() { return 0; }") set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for C\\+\\+" # Host GNU diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index bf802ef..d7cb1f4 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 21) -set(CMake_VERSION_PATCH 20210618) +set(CMake_VERSION_PATCH 20210622) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index a892113..50072c5 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestRunTest.h" +#include <algorithm> #include <chrono> #include <cstddef> // IWYU pragma: keep #include <cstdint> @@ -44,7 +45,9 @@ void cmCTestRunTest::CheckOutput(std::string const& line) // Check for special CTest XML tags in this line of output. // If any are found, this line is excluded from ProcessOutput. if (!line.empty() && line.find("<CTest") != std::string::npos) { + bool ctest_tag_found = false; if (this->TestHandler->CustomCompletionStatusRegex.find(line)) { + ctest_tag_found = true; this->TestResult.CustomCompletionStatus = this->TestHandler->CustomCompletionStatusRegex.match(1); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, @@ -52,6 +55,20 @@ void cmCTestRunTest::CheckOutput(std::string const& line) << "Test Details changed to '" << this->TestResult.CustomCompletionStatus << "'" << std::endl); + } else if (this->TestHandler->CustomLabelRegex.find(line)) { + ctest_tag_found = true; + auto label = this->TestHandler->CustomLabelRegex.match(1); + auto& labels = this->TestProperties->Labels; + if (std::find(labels.begin(), labels.end(), label) == labels.end()) { + labels.push_back(label); + std::sort(labels.begin(), labels.end()); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + this->GetIndex() + << ": " + << "Test Label added: '" << label << "'" << std::endl); + } + } + if (ctest_tag_found) { return; } } diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 730ec0f..aeaf696 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -312,6 +312,8 @@ cmCTestTestHandler::cmCTestTestHandler() // regex to detect <CTestDetails>...</CTestDetails> this->CustomCompletionStatusRegex.compile( "<CTestDetails>(.*)</CTestDetails>"); + // regex to detect <CTestLabel>...</CTestLabel> + this->CustomLabelRegex.compile("<CTestLabel>(.*)</CTestLabel>"); } void cmCTestTestHandler::Initialize() diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index bd51738..cc19984 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -360,6 +360,7 @@ private: size_t TotalNumberOfTests; cmsys::RegularExpression DartStuff; cmsys::RegularExpression CustomCompletionStatusRegex; + cmsys::RegularExpression CustomLabelRegex; std::ostream* LogFile; diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index fa51092..fc2665b 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1361,10 +1361,8 @@ static unsigned int cmLoadFlagTableSpecial(Json::Value entry, namespace { -unsigned long long const vsVer16_10_0 = 4503644629696790; - -cmIDEFlagTable const* cmLoadFlagTableJson( - std::string const& flagJsonPath, cm::optional<unsigned long long> vsver) +cmIDEFlagTable const* cmLoadFlagTableJson(std::string const& flagJsonPath, + cm::optional<std::string> vsVer) { cmIDEFlagTable* ret = nullptr; auto savedFlagIterator = loadedFlagJsonFiles.find(flagJsonPath); @@ -1380,17 +1378,22 @@ cmIDEFlagTable const* cmLoadFlagTableJson( if (reader.parse(stream, flags, false) && flags.isArray()) { std::vector<cmIDEFlagTable> flagTable; for (auto const& flag : flags) { + Json::Value const& vsminJson = flag["vsmin"]; + if (vsminJson.isString()) { + std::string const& vsmin = vsminJson.asString(); + if (!vsmin.empty()) { + if (!vsVer || + cmSystemTools::VersionCompareGreater(vsmin, *vsVer)) { + continue; + } + } + } cmIDEFlagTable flagEntry; flagEntry.IDEName = cmLoadFlagTableString(flag, "name"); flagEntry.commandFlag = cmLoadFlagTableString(flag, "switch"); flagEntry.comment = cmLoadFlagTableString(flag, "comment"); flagEntry.value = cmLoadFlagTableString(flag, "value"); flagEntry.special = cmLoadFlagTableSpecial(flag, "flags"); - // FIXME: Port this version check to a Json field. - if (vsver && *vsver < vsVer16_10_0 && - flagEntry.IDEName == "ExternalWarningLevel") { - continue; - } flagTable.push_back(flagEntry); } cmIDEFlagTable endFlag{ "", "", "", "", 0 }; @@ -1466,8 +1469,8 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable( } } - cm::optional<unsigned long long> vsver = this->GetVSInstanceVersion(); - if (cmIDEFlagTable const* ret = cmLoadFlagTableJson(filename, vsver)) { + cm::optional<std::string> vsVer = this->GetVSInstanceVersion(); + if (cmIDEFlagTable const* ret = cmLoadFlagTableJson(filename, vsVer)) { return ret; } diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 48fe465..b7ae1ee 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -128,10 +128,7 @@ public: std::string Encoding() override; const char* GetToolsVersion() const; - virtual cm::optional<unsigned long long> GetVSInstanceVersion() const - { - return {}; - } + virtual cm::optional<std::string> GetVSInstanceVersion() const { return {}; } bool GetSupportsUnityBuilds() const { return this->SupportsUnityBuilds; } @@ -141,6 +138,8 @@ public: virtual bool IsStdOutEncodingSupported() const { return false; } + virtual bool IsUtf8EncodingSupported() const { return false; } + static std::string GetInstalledNsightTegraVersion(); /** Return the first two components of CMAKE_SYSTEM_VERSION. */ diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index 50dc30b..c8213c5 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -391,11 +391,11 @@ bool cmGlobalVisualStudioVersionedGenerator::GetVSInstance( return vsSetupAPIHelper.GetVSInstanceInfo(dir); } -cm::optional<unsigned long long> +cm::optional<std::string> cmGlobalVisualStudioVersionedGenerator::GetVSInstanceVersion() const { - cm::optional<unsigned long long> result; - unsigned long long vsInstanceVersion; + cm::optional<std::string> result; + std::string vsInstanceVersion; if (vsSetupAPIHelper.GetVSInstanceVersion(vsInstanceVersion)) { result = vsInstanceVersion; } @@ -411,10 +411,25 @@ bool cmGlobalVisualStudioVersionedGenerator::IsStdOutEncodingSupported() const if (this->Version < cmGlobalVisualStudioGenerator::VSVersion::VS16) { return false; } - unsigned long long const vsInstanceVersion16_7_P2 = 4503631666610212; - cm::optional<unsigned long long> vsInstanceVersion = - this->GetVSInstanceVersion(); - return (vsInstanceVersion && *vsInstanceVersion > vsInstanceVersion16_7_P2); + static std::string const vsVer16_7_P2 = "16.7.30128.36"; + cm::optional<std::string> vsVer = this->GetVSInstanceVersion(); + return (vsVer && + cmSystemTools::VersionCompareGreaterEq(*vsVer, vsVer16_7_P2)); +} + +bool cmGlobalVisualStudioVersionedGenerator::IsUtf8EncodingSupported() const +{ + // Supported from Visual Studio 16.10 Preview 2. + if (this->Version > cmGlobalVisualStudioGenerator::VSVersion::VS16) { + return true; + } + if (this->Version < cmGlobalVisualStudioGenerator::VSVersion::VS16) { + return false; + } + static std::string const vsVer16_10_P2 = "16.10.31213.239"; + cm::optional<std::string> vsVer = this->GetVSInstanceVersion(); + return (vsVer && + cmSystemTools::VersionCompareGreaterEq(*vsVer, vsVer16_10_P2)); } const char* diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.h b/Source/cmGlobalVisualStudioVersionedGenerator.h index 105e495..e6c19e4 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.h +++ b/Source/cmGlobalVisualStudioVersionedGenerator.h @@ -28,13 +28,15 @@ public: bool GetVSInstance(std::string& dir) const; - cm::optional<unsigned long long> GetVSInstanceVersion() const override; + cm::optional<std::string> GetVSInstanceVersion() const override; AuxToolset FindAuxToolset(std::string& version, std::string& props) const override; bool IsStdOutEncodingSupported() const override; + bool IsUtf8EncodingSupported() const override; + const char* GetAndroidApplicationTypeRevision() const override; protected: diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3b282de..a14f085 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -878,9 +878,12 @@ std::string cmLocalGenerator::GetIncludeFlags( // Support special system include flag if it is available and the // normal flag is repeated for each directory. cmProp sysIncludeFlag = nullptr; + cmProp sysIncludeFlagWarning = nullptr; if (repeatFlag) { sysIncludeFlag = this->Makefile->GetDefinition( cmStrCat("CMAKE_INCLUDE_SYSTEM_FLAG_", lang)); + sysIncludeFlagWarning = this->Makefile->GetDefinition( + cmStrCat("_CMAKE_INCLUDE_SYSTEM_FLAG_", lang, "_WARNING")); } cmProp fwSearchFlag = this->Makefile->GetDefinition( @@ -889,6 +892,7 @@ std::string cmLocalGenerator::GetIncludeFlags( cmStrCat("CMAKE_", lang, "_SYSTEM_FRAMEWORK_SEARCH_FLAG")); bool flagUsed = false; + bool sysIncludeFlagUsed = false; std::set<std::string> emitted; #ifdef __APPLE__ emitted.insert("/System/Library/Frameworks"); @@ -915,6 +919,7 @@ std::string cmLocalGenerator::GetIncludeFlags( if (sysIncludeFlag && target && target->IsSystemIncludeDirectory(i, config, lang)) { includeFlags << *sysIncludeFlag; + sysIncludeFlagUsed = true; } else { includeFlags << includeFlag; } @@ -931,6 +936,9 @@ std::string cmLocalGenerator::GetIncludeFlags( } includeFlags << sep; } + if (sysIncludeFlagUsed && sysIncludeFlagWarning) { + includeFlags << *sysIncludeFlagWarning; + } std::string flags = includeFlags.str(); // remove trailing separators if ((sep[0] != ' ') && !flags.empty() && flags.back() == sep[0]) { diff --git a/Source/cmVSSetupHelper.cxx b/Source/cmVSSetupHelper.cxx index 9626599..969a2c2 100644 --- a/Source/cmVSSetupHelper.cxx +++ b/Source/cmVSSetupHelper.cxx @@ -258,15 +258,13 @@ bool cmVSSetupAPIHelper::GetVSInstanceInfo(std::string& vsInstallLocation) return isInstalled; } -bool cmVSSetupAPIHelper::GetVSInstanceVersion( - unsigned long long& vsInstanceVersion) +bool cmVSSetupAPIHelper::GetVSInstanceVersion(std::string& vsInstanceVersion) { - vsInstanceVersion = 0; + vsInstanceVersion.clear(); bool isInstalled = this->EnumerateAndChooseVSInstance(); if (isInstalled) { - vsInstanceVersion = - static_cast<unsigned long long>(chosenInstanceInfo.ullVersion); + vsInstanceVersion = cmsys::Encoding::ToNarrow(chosenInstanceInfo.Version); } return isInstalled; diff --git a/Source/cmVSSetupHelper.h b/Source/cmVSSetupHelper.h index 04ea46d..61a3ac7 100644 --- a/Source/cmVSSetupHelper.h +++ b/Source/cmVSSetupHelper.h @@ -88,7 +88,7 @@ struct VSInstanceInfo std::wstring VSInstallLocation; std::wstring Version; std::string VCToolsetVersion; - ULONGLONG ullVersion = 0; + ULONGLONG ullVersion = 0; // A.B.C.D = (A<<48)|(B<<32)|(C<<16)|D bool IsWin10SDKInstalled = false; bool IsWin81SDKInstalled = false; @@ -105,7 +105,7 @@ public: bool IsVSInstalled(); bool GetVSInstanceInfo(std::string& vsInstallLocation); - bool GetVSInstanceVersion(unsigned long long& vsInstanceVersion); + bool GetVSInstanceVersion(std::string& vsInstanceVersion); bool GetVCToolsetVersion(std::string& vsToolsetVersion); bool IsWin10SDKInstalled(); bool IsWin81SDKInstalled(); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index b79c6fd..82880a9 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -3543,8 +3543,6 @@ void cmVisualStudio10TargetGenerator::WriteNasmOptions( } Elem e2(e1, "NASM"); - std::vector<std::string> includes = - this->GetIncludes(configName, "ASM_NASM"); OptionsHelper nasmOptions(*(this->NasmOptions[configName]), e2); nasmOptions.OutputAdditionalIncludeDirectories("ASM_NASM"); nasmOptions.OutputFlagMap(); @@ -5115,7 +5113,9 @@ std::string cmVisualStudio10TargetGenerator::GetCMakeFilePath( void cmVisualStudio10TargetGenerator::WriteStdOutEncodingUtf8(Elem& e1) { - if (this->GlobalGenerator->IsStdOutEncodingSupported()) { + if (this->GlobalGenerator->IsUtf8EncodingSupported()) { + e1.Element("UseUtf8Encoding", "Always"); + } else if (this->GlobalGenerator->IsStdOutEncodingSupported()) { e1.Element("StdOutEncoding", "UTF-8"); } } diff --git a/Templates/MSBuild/FlagTables/v142_CL.json b/Templates/MSBuild/FlagTables/v142_CL.json index 650ff6c..c21a3de 100644 --- a/Templates/MSBuild/FlagTables/v142_CL.json +++ b/Templates/MSBuild/FlagTables/v142_CL.json @@ -572,6 +572,7 @@ "switch": "external:W0", "comment": "Turn Off All Warnings", "value": "TurnOffAllWarnings", + "vsmin": "16.10.31321.278", "flags": [] }, { @@ -579,6 +580,7 @@ "switch": "external:W1", "comment": "Level1", "value": "Level1", + "vsmin": "16.10.31321.278", "flags": [] }, { @@ -586,6 +588,7 @@ "switch": "external:W2", "comment": "Level2", "value": "Level2", + "vsmin": "16.10.31321.278", "flags": [] }, { @@ -593,6 +596,7 @@ "switch": "external:W3", "comment": "Level3", "value": "Level3", + "vsmin": "16.10.31321.278", "flags": [] }, { @@ -600,6 +604,7 @@ "switch": "external:W4", "comment": "Level4", "value": "Level4", + "vsmin": "16.10.31321.278", "flags": [] }, { @@ -1141,6 +1146,7 @@ "switch": "external:anglebrackets", "comment": "Treat Files Included with Angle Brackets as External", "value": "true", + "vsmin": "16.10.31321.278", "flags": [] }, { @@ -1148,6 +1154,7 @@ "switch": "external:templates-", "comment": "Template Diagnostics in External Headers", "value": "true", + "vsmin": "16.10.31321.278", "flags": [] }, { @@ -1277,6 +1284,7 @@ "switch": "external:env:", "comment": "External Directories Environment Variables", "value": "", + "vsmin": "16.10.31321.278", "flags": [ "UserValue", "SemicolonAppendable" diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt index c2576f3..7fddf4b 100644 --- a/Tests/BuildDepends/Project/CMakeLists.txt +++ b/Tests/BuildDepends/Project/CMakeLists.txt @@ -8,7 +8,7 @@ if(APPLE) else() execute_process( COMMAND xcodebuild -version - OUTPUT_VARIABLE _version ERROR_VARIABLE _version + OUTPUT_VARIABLE _version ERROR_VARIABLE _version_err ) if(_version MATCHES "^Xcode ([0-9]+(\\.[0-9]+)*)") set(CMake_TEST_XCODE_VERSION "${CMAKE_MATCH_1}") diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 2f9b7ff..6d73554 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -321,7 +321,7 @@ if(BUILD_TESTING) else() execute_process( COMMAND xcodebuild -version - OUTPUT_VARIABLE _version ERROR_VARIABLE _version + OUTPUT_VARIABLE _version ERROR_VARIABLE _version_err ) if(_version MATCHES "^Xcode ([0-9]+(\\.[0-9]+)*)") set(CMake_TEST_XCODE_VERSION "${CMAKE_MATCH_1}") diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt index d4c19c7..4c488e6 100644 --- a/Tests/IncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/CMakeLists.txt @@ -2,17 +2,25 @@ cmake_minimum_required (VERSION 2.6) project(IncludeDirectories) if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4) - OR (CMAKE_C_COMPILER_ID STREQUAL Clang AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") OR CMAKE_C_COMPILER_ID STREQUAL AppleClang) + OR (CMAKE_C_COMPILER_ID STREQUAL Clang AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") + OR CMAKE_C_COMPILER_ID STREQUAL AppleClang + OR ("x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC" AND + CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "19.29.30036.3" AND + NOT CMAKE_GENERATOR MATCHES "Visual Studio")) # No support for VS generators yet. AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja" OR (CMAKE_GENERATOR STREQUAL "Xcode" AND NOT XCODE_VERSION VERSION_LESS 6.0))) - include(CheckCXXCompilerFlag) - check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test) - if(run_sys_includes_test) - # The Bullseye wrapper appears to break the -isystem effect. - execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE out ERROR_VARIABLE out) - if("x${out}" MATCHES "Bullseye") - set(run_sys_includes_test 0) + if ("x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC") + set(run_sys_includes_test 1) + else () + include(CheckCXXCompilerFlag) + check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test) + if(run_sys_includes_test) + # The Bullseye wrapper appears to break the -isystem effect. + execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE out ERROR_VARIABLE out) + if("x${out}" MATCHES "Bullseye") + set(run_sys_includes_test 0) + endif() endif() endif() if (run_sys_includes_test) diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt index dee39c8..a746a68 100644 --- a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt @@ -6,9 +6,17 @@ project(SystemIncludeDirectories) add_library(systemlib systemlib.cpp) target_include_directories(systemlib PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/systemlib") +function (apply_error_flags target) + if (MSVC) + target_compile_options(${target} PRIVATE /we4101) + else () + target_compile_options(${target} PRIVATE -Werror=unused-variable) + endif () +endfunction () + add_library(upstream upstream.cpp) target_link_libraries(upstream LINK_PUBLIC systemlib) -target_compile_options(upstream PRIVATE -Werror=unused-variable) +apply_error_flags(upstream) target_include_directories(upstream SYSTEM PUBLIC $<TARGET_PROPERTY:systemlib,INTERFACE_INCLUDE_DIRECTORIES> @@ -29,7 +37,7 @@ endif() add_library(consumer consumer.cpp) target_link_libraries(consumer upstream config_specific) -target_compile_options(consumer PRIVATE -Werror=unused-variable) +apply_error_flags(consumer) add_library(iface IMPORTED INTERFACE) set_property(TARGET iface PROPERTY INTERFACE_INCLUDE_DIRECTORIES @@ -38,21 +46,21 @@ set_property(TARGET iface PROPERTY INTERFACE_INCLUDE_DIRECTORIES add_library(imported_consumer imported_consumer.cpp) target_link_libraries(imported_consumer iface) -target_compile_options(imported_consumer PRIVATE -Werror=unused-variable) +apply_error_flags(imported_consumer) add_library(imported_consumer2 imported_consumer.cpp) target_link_libraries(imported_consumer2 imported_consumer) -target_compile_options(imported_consumer2 PRIVATE -Werror=unused-variable) +apply_error_flags(imported_consumer2) # add a target which has a relative system include add_library(somelib imported_consumer.cpp) target_include_directories(somelib SYSTEM PUBLIC "systemlib_header_only") -target_compile_options(somelib PRIVATE -Werror=unused-variable) +apply_error_flags(somelib) # add a target which consumes a relative system include add_library(otherlib upstream.cpp) target_link_libraries(otherlib PUBLIC somelib) -target_compile_options(somelib PRIVATE -Werror=unused-variable) +apply_error_flags(otherlib) macro(do_try_compile error_option) set(TC_ARGS @@ -61,7 +69,11 @@ macro(do_try_compile error_option) LINK_LIBRARIES iface ) if (${error_option} STREQUAL WITH_ERROR) - list(APPEND TC_ARGS COMPILE_DEFINITIONS -Werror=unused-variable) + if (MSVC) + list(APPEND TC_ARGS COMPILE_DEFINITIONS /we4101) + else () + list(APPEND TC_ARGS COMPILE_DEFINITIONS -Werror=unused-variable) + endif () endif() try_compile(${TC_ARGS}) endmacro() diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/consumer.cpp b/Tests/IncludeDirectories/SystemIncludeDirectories/consumer.cpp index a13f08f..3da308d 100644 --- a/Tests/IncludeDirectories/SystemIncludeDirectories/consumer.cpp +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/consumer.cpp @@ -1,5 +1,6 @@ -#include "config_iface.h" +#include <config_iface.h> + #include "upstream.h" int consumer() diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/imported_consumer.cpp b/Tests/IncludeDirectories/SystemIncludeDirectories/imported_consumer.cpp index 1dbe819..53759b1 100644 --- a/Tests/IncludeDirectories/SystemIncludeDirectories/imported_consumer.cpp +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/imported_consumer.cpp @@ -1,5 +1,5 @@ -#include "systemlib.h" +#include <systemlib.h> int main() { diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.h b/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.h index a670c2a..3daf69e 100644 --- a/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.h +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.h @@ -2,7 +2,7 @@ #ifndef UPSTREAM_H #define UPSTREAM_H -#include "systemlib.h" +#include <systemlib.h> #ifdef _WIN32 __declspec(dllexport) diff --git a/Tests/IncludeDirectories/SystemIncludeDirectoriesPerLang/CMakeLists.txt b/Tests/IncludeDirectories/SystemIncludeDirectoriesPerLang/CMakeLists.txt index 70dfa01..5d58633 100644 --- a/Tests/IncludeDirectories/SystemIncludeDirectoriesPerLang/CMakeLists.txt +++ b/Tests/IncludeDirectories/SystemIncludeDirectoriesPerLang/CMakeLists.txt @@ -7,14 +7,14 @@ set_target_properties(c_interface PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "$<$<COMPILE_LANGUAGE:C>:${CMAKE_CURRENT_SOURCE_DIR}>" INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "$<$<COMPILE_LANGUAGE:C>:${CMAKE_CURRENT_SOURCE_DIR}>" ) -target_compile_options(c_interface INTERFACE "$<$<COMPILE_LANG_AND_ID:C,GNU,Clang>:-Werror=unused-variable>") +target_compile_options(c_interface INTERFACE "$<$<COMPILE_LANG_AND_ID:C,GNU,Clang>:-Werror=unused-variable>;$<$<COMPILE_LANG_AND_ID:C,MSVC>:/we4101>") add_library(cxx_interface INTERFACE) set_target_properties(cxx_interface PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/cxx_system_include>" INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/cxx_system_include>" ) -target_compile_options(cxx_interface INTERFACE "$<$<COMPILE_LANG_AND_ID:CXX,GNU,Clang>:-Werror=unused-variable>") +target_compile_options(cxx_interface INTERFACE "$<$<COMPILE_LANG_AND_ID:CXX,GNU,Clang>:-Werror=unused-variable>;$<$<COMPILE_LANG_AND_ID:C,MSVC>:/we4101>") # The C header must come before the C++ header for this test to smoke out the # failure. The order of sources is how CMake determines the include cache diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_MATCHING_ARGN.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_MATCHING_ARGN.cmake new file mode 100644 index 0000000..e49ff22 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_MATCHING_ARGN.cmake @@ -0,0 +1,17 @@ +if(WIN32) + set(ENV{PKG_CONFIG} "\"${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat\" --static --print-errors") +else() + set(ENV{PKG_CONFIG} "\"${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh\" --static --print-errors") +endif() + +find_package(PkgConfig REQUIRED) + +if(NOT PKG_CONFIG_ARGN STREQUAL "--static;--print-errors") + message(SEND_ERROR "PKG_CONFIG_ARGN has wrong value '${PKG_CONFIG_ARGN}'") +endif() + +_pkgconfig_invoke("none" "prefix" "output" "") + +if(NOT prefix_output STREQUAL "Received;--static;Received;--print-errors") + message(SEND_ERROR "prefix_output has wrong value '${prefix_output}'") +endif() diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake index e7f008c..17e046a 100644 --- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake @@ -12,6 +12,7 @@ run_cmake(FindPkgConfig_PKGCONFIG_PATH) run_cmake(FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH) run_cmake(FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH) run_cmake(FindPkgConfig_extract_frameworks) +run_cmake(FindPkgConfig_GET_MATCHING_ARGN) if(APPLE) run_cmake(FindPkgConfig_extract_frameworks_target) diff --git a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat index b038370..c91713b 100755 --- a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat +++ b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat @@ -1,5 +1,10 @@ @ECHO OFF +rem variables to get around `--static --version` printing the received +rem message and then version +set static=false +set print_errors=false + :LOOP IF "%1"=="" ( @@ -21,7 +26,19 @@ IF "%1"=="--exists" ( EXIT /B 0 ) ) +IF "%1"=="--static" ( + set static=true +) +IF "%1"=="--print-errors" ( + set print_errors=true +) SHIFT IF NOT "%~1"=="" GOTO LOOP +IF "%static%"=="true" ECHO Received --static +IF "%print_errors%"=="true" ECHO Received --print-errors + +IF "%static%"=="true" GOTO :EOF +IF "%print_errors%"=="true" GOTO :EOF + EXIT /B 255 diff --git a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh index 56bba30..4021bf7 100755 --- a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh +++ b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh @@ -4,6 +4,11 @@ # to the --exists argument with the PKG_CONFIG_PATH environment variable # and returns 1 if they are different. +# variables to get around `--static --version` printing the received +# message and then version +static=false +print_errors=false + while [ $# -gt 0 ]; do case $1 in --version) @@ -17,7 +22,21 @@ while [ $# -gt 0 ]; do echo "Found: ${PKG_CONFIG_PATH}" [ "${last}" = "${PKG_CONFIG_PATH}" ] && exit 0 || exit 1 ;; + --static) + static=true + ;; + --print-errors) + print_errors=true + ;; esac shift done + +$static && echo "Received --static" +$print_errors && echo "Received --print-errors" + +if $static || $print_errors; then + exit 0 +fi + exit 255 diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake index f07a12b..31bc075 100644 --- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake @@ -181,3 +181,16 @@ add_test( run_ctest(TestCompletionStatus) endfunction() run_completion_status() + +# Verify that test output can add additional labels +function(run_extra_labels) + set(CASE_CMAKELISTS_SUFFIX_CODE [[ +add_test( + NAME custom_labels + COMMAND ${CMAKE_COMMAND} -E + echo before\n<CTestLabel>label2</CTestLabel>\n<CTestLabel>label1</CTestLabel>\n<CTestLabel>label3</CTestLabel>\n<CTestLabel>label2</CTestLabel>\nafter) +set_tests_properties(custom_labels PROPERTIES LABELS "label1") + ]]) + run_ctest(TestExtraLabels) +endfunction() +run_extra_labels() diff --git a/Tests/RunCMake/ctest_test/TestExtraLabels-check.cmake b/Tests/RunCMake/ctest_test/TestExtraLabels-check.cmake new file mode 100644 index 0000000..beb39de --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestExtraLabels-check.cmake @@ -0,0 +1,28 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/Testing/TAG" _tag) +string(REGEX REPLACE "^([^\n]*)\n.*$" "\\1" _date "${_tag}") +file(READ "${RunCMake_TEST_BINARY_DIR}/Testing/${_date}/Test.xml" _test_contents) + +# Check labels. +STRING(REGEX MATCHALL [[<Label>label1</Label>]] matches "${_test_contents}") +list(LENGTH matches n_matches) +if(NOT n_matches EQUAL 1) + string(APPEND RunCMake_TEST_FAILED "expected 1 match for label1, found ${n_matches}") +endif() +STRING(REGEX MATCHALL [[<Label>label2</Label>]] matches "${_test_contents}") +list(LENGTH matches n_matches) +if(NOT n_matches EQUAL 1) + string(APPEND RunCMake_TEST_FAILED "expected 1 match for label2, found ${n_matches}") +endif() +STRING(REGEX MATCHALL [[<Label>label3</Label>]] matches "${_test_contents}") +list(LENGTH matches n_matches) +if(NOT n_matches EQUAL 1) + string(APPEND RunCMake_TEST_FAILED "expected 1 match for label3, found ${n_matches}") +endif() + +# Check test output. +if(NOT _test_contents MATCHES "before") + string(APPEND RunCMake_TEST_FAILED "Could not find expected string 'before' in Test.xml") +endif() +if(NOT _test_contents MATCHES "after") + string(APPEND RunCMake_TEST_FAILED "Could not find expected string 'after' in Test.xml") +endif() |