diff --git a/Help/command/add_custom_command.rst b/Help/command/add_custom_command.rst index f1be3094d..9bc88d6e1 100644 --- a/Help/command/add_custom_command.rst +++ b/Help/command/add_custom_command.rst @@ -362,7 +362,7 @@ The options are: .. versionadded:: 3.27 - Indicate that the command's ``DEPENDS`` argument represents all files + Indicates that the command's ``DEPENDS`` argument represents all files required by the command and implicit dependencies are not required. Without this option, if any target uses the output of the custom command, @@ -376,6 +376,10 @@ The options are: Only the :ref:`Ninja Generators` actually use this information to remove unnecessary implicit dependencies. + See also the :prop_tgt:`OPTIMIZE_DEPENDENCIES` target property, which may + provide another way for reducing the impact of target dependencies in some + scenarios. + Examples: Generating Files ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/Help/command/if.rst b/Help/command/if.rst index be855e1e0..c47c71b6f 100644 --- a/Help/command/if.rst +++ b/Help/command/if.rst @@ -170,9 +170,9 @@ File Operations .. signature:: if(EXISTS ) - True if the named file or directory exists. Behavior is well-defined - only for explicit full paths (a leading ``~/`` is not expanded as - a home directory and is considered a relative path). + True if the named file or directory exists and is readable. Behavior + is well-defined only for explicit full paths (a leading ``~/`` is not + expanded as a home directory and is considered a relative path). Resolves symbolic links, i.e. if the named file or directory is a symbolic link, returns true if the target of the symbolic link exists. diff --git a/Help/guide/importing-exporting/index.rst b/Help/guide/importing-exporting/index.rst index b1812c1af..91c50ddf9 100644 --- a/Help/guide/importing-exporting/index.rst +++ b/Help/guide/importing-exporting/index.rst @@ -322,10 +322,10 @@ were built in its own tree. For example: add_executable(myexe src1.c src2.c ) target_link_libraries(myexe PRIVATE MathFunctions::MathFunctions) -Line 1 loads the target CMake file. Although we only exported a single +Line 2 loads the target CMake file. Although we only exported a single target, this file may import any number of targets. Their locations are computed relative to the file location so that the install tree may be -easily moved. Line 3 references the imported ``MathFunctions`` library. The +easily moved. Line 4 references the imported ``MathFunctions`` library. The resulting build system will link to the library from its installed location. Executables may also be exported and imported using the same process. diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index 8c3f2d7fd..86ae0a497 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -2267,9 +2267,9 @@ In the following, the phrase "the ``tgt`` filename" means the name of the section for details. Many :ref:`Find Modules` produce imported targets with the ``UNKNOWN`` type and therefore will be ignored. -On platforms that support runtime paths (``RPATH``), refer to the -:prop_tgt:`INSTALL_RPATH` target property. -On Apple platforms, refer to the :prop_tgt:`INSTALL_NAME_DIR` target property. + On platforms that support runtime paths (``RPATH``), refer to the + :prop_tgt:`INSTALL_RPATH` target property. + On Apple platforms, refer to the :prop_tgt:`INSTALL_NAME_DIR` target property. .. genex:: $ diff --git a/Help/prop_tgt/ENABLE_EXPORTS.rst b/Help/prop_tgt/ENABLE_EXPORTS.rst index 3e9b28553..e34c649de 100644 --- a/Help/prop_tgt/ENABLE_EXPORTS.rst +++ b/Help/prop_tgt/ENABLE_EXPORTS.rst @@ -27,30 +27,33 @@ varies by platform: referencing the executable since the dynamic loader will automatically bind symbols when the module is loaded. -This property is initialized by the value of the variable -:variable:`CMAKE_EXECUTABLE_ENABLE_EXPORTS` if it is set when an executable -target is created. +This property is initialized by the value of the +:variable:`CMAKE_EXECUTABLE_ENABLE_EXPORTS` variable, if it is set when an +executable target is created. If :variable:`CMAKE_EXECUTABLE_ENABLE_EXPORTS` +is not set, the :variable:`CMAKE_ENABLE_EXPORTS` variable is used to initialize +the property instead for backward compatibility reasons. +See below for alternative initialization behavior for shared library targets. .. versionadded:: 3.27 - On macOS, to link with a shared library (standard one as well as framework), - a linker import file (e.g. a text-based stubs file, with ``.tbd`` extension) - can be used instead of the shared library itself. - -The generation of these linker import files, as well as the consumption, is -controlled by this property. When this property is set to true, CMake will -generate a ``.tbd`` file for each shared library created by -:command:`add_library` command. This allow other targets to use this ``.tbd`` -file to link to the library with the :command:`target_link_libraries` -command. - -.. note:: - - For compatibility purpose, this property will be ignored if - :prop_tgt:`XCODE_ATTRIBUTE_GENERATE_TEXT_BASED_STUBS >` - target property or the - :variable:`CMAKE_XCODE_ATTRIBUTE_GENERATE_TEXT_BASED_STUBS >` - variable is set to ``NO``. - -This property is initialized by the value of the variable -:variable:`CMAKE_SHARED_LIBRARY_ENABLE_EXPORTS` if it is set when a shared -library target is created. + On Apple platforms, to link with a shared library (either a bare library or a + framework), a linker import file can be used instead of the actual shared + library. These linker import files are also known as text-based stubs, and + they have a ``.tbd`` file extension. + + The generation of these linker import files, as well as their consumption, is + controlled by this property. When this property is set to true on a shared + library target, CMake will generate a ``.tbd`` file for the library. + Other targets that link to the shared library target will then use this + ``.tbd`` file when linking rather than linking to the shared library binary. + + .. note:: + + For backward compatibility reasons, this property will be ignored if the + :prop_tgt:`XCODE_ATTRIBUTE_GENERATE_TEXT_BASED_STUBS >` + target property or the + :variable:`CMAKE_XCODE_ATTRIBUTE_GENERATE_TEXT_BASED_STUBS >` + variable is set to false. + + For shared library targets, this property is initialized by the value of the + :variable:`CMAKE_SHARED_LIBRARY_ENABLE_EXPORTS` variable, if it is set when + the target is created. diff --git a/Help/release/3.27.rst b/Help/release/3.27.rst index e98a49a0f..457b48ca3 100644 --- a/Help/release/3.27.rst +++ b/Help/release/3.27.rst @@ -33,7 +33,7 @@ Generators linker will cause a relink if they change (typically modified timestamps). See the :variable:`CMAKE_LINK_DEPENDS_USE_LINKER` variable. -* The :ref:`Visual Studio Generators` for VS 2015 and above learned to +* The :ref:`Visual Studio Generators` for VS 14 (2015) and above learned to select the Windows SDK version explicitly using a ``version=`` field in the :variable:`CMAKE_GENERATOR_PLATFORM` variable. See :ref:`Visual Studio Platform Selection`. @@ -257,6 +257,9 @@ Other Changes * :ref:`Visual Studio Generators`, for VS 15.8 (2017) and newer, now build custom commands in parallel. See policy :policy:`CMP0147`. +* :ref:`Visual Studio Generators` for VS 14 (2015) and above now prefer + to select the latest Windows SDK version. See policy :policy:`CMP0149`. + Updates ======= @@ -268,3 +271,16 @@ Changes made since CMake 3.27.0 include the following. * This version made no changes to documented features or interfaces. Some implementation updates were made to support ecosystem changes and/or fix regressions. + +3.27.2 +------ + +* :ref:`Visual Studio Generators` for VS 14 (2015) and above now prefer to + select the latest Windows SDK, as documented by policy :policy:`CMP0149`, + when targeting any version of Windows. In CMake 3.27.[0-1] the + preference was limited to targeting Windows 10 and above. + +* :ref:`Visual Studio Generators` for VS 14 (2015) and above now support + using ``version=8.1`` in the :variable:`CMAKE_GENERATOR_PLATFORM` variable + to select the Windows 8.1 SDK. In CMake 3.27.[0-1] the ``version=`` field + was limited to selecting Windows 10 SDKs. diff --git a/Help/variable/CMAKE_ADD_CUSTOM_COMMAND_DEPENDS_EXPLICIT_ONLY.rst b/Help/variable/CMAKE_ADD_CUSTOM_COMMAND_DEPENDS_EXPLICIT_ONLY.rst index 9c9bd2c22..b6a623370 100644 --- a/Help/variable/CMAKE_ADD_CUSTOM_COMMAND_DEPENDS_EXPLICIT_ONLY.rst +++ b/Help/variable/CMAKE_ADD_CUSTOM_COMMAND_DEPENDS_EXPLICIT_ONLY.rst @@ -3,9 +3,11 @@ CMAKE_ADD_CUSTOM_COMMAND_DEPENDS_EXPLICIT_ONLY .. versionadded:: 3.27 -Whether to enable DEPENDS_EXPLICIT_ONLY option by default in +Whether to enable the ``DEPENDS_EXPLICIT_ONLY`` option by default in :command:`add_custom_command`. This variable affects the default behavior of the :command:`add_custom_command` -command. Setting this variable to ``ON`` is equivalent to using the ``DEPENDS_EXPLICIT_ONLY`` -option in all uses of that command. +command. Setting this variable to ``ON`` is equivalent to using the +``DEPENDS_EXPLICIT_ONLY`` option in all uses of that command. + +See also :variable:`CMAKE_OPTIMIZE_DEPENDENCIES`. diff --git a/Help/variable/CMAKE_ENABLE_EXPORTS.rst b/Help/variable/CMAKE_ENABLE_EXPORTS.rst index d2c5ed086..da233429e 100644 --- a/Help/variable/CMAKE_ENABLE_EXPORTS.rst +++ b/Help/variable/CMAKE_ENABLE_EXPORTS.rst @@ -9,6 +9,7 @@ This variable is used to initialize the :prop_tgt:`ENABLE_EXPORTS` target property for executable targets when they are created by calls to the :command:`add_executable` command. See the property documentation for details. -This command has been superseded by the -:variable:`CMAKE_EXECUTABLE_ENABLE_EXPORTS` command. It is provided for -compatibility with older CMake code. +This variable has been superseded by the +:variable:`CMAKE_EXECUTABLE_ENABLE_EXPORTS` variable. It is provided for +backward compatibility with older CMake code, but should not be used in new +projects. diff --git a/Help/variable/CMAKE_GENERATOR_PLATFORM.rst b/Help/variable/CMAKE_GENERATOR_PLATFORM.rst index 416ff60f3..22bf655eb 100644 --- a/Help/variable/CMAKE_GENERATOR_PLATFORM.rst +++ b/Help/variable/CMAKE_GENERATOR_PLATFORM.rst @@ -50,7 +50,7 @@ Supported pairs are: .. versionadded:: 3.27 Specify the Windows SDK version to use. This is supported by VS 2015 and - above when targeting Windows 10.0+ or Windows Store. CMake will set the + above when targeting Windows or Windows Store. CMake will set the :variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION` variable to the selected SDK version. @@ -66,6 +66,10 @@ Supported pairs are: the value of :variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM`, if that variable is set. + ``8.1`` + Specify the 8.1 SDK version. This is always supported by VS 2015. + On VS 2017 and above the 8.1 SDK must be installed. + If the ``version`` field is not specified, CMake selects a version as described in the :variable:`CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION` variable documentation. diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index 27f9b0e19..c6d7b0932 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -383,6 +383,23 @@ foreach(JAVA_PROG "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}") endforeach() if(APPLE) + if(DEFINED XCODE_VERSION) + set(_FindJNI_XCODE_VERSION "${XCODE_VERSION}") + else() + # get xcode version + execute_process( + COMMAND xcodebuild -version + OUTPUT_VARIABLE _xcode_version + ) + string(REGEX REPLACE "Xcode ([0-9]+(\\.[0-9]+)*)" "\\1" _FindJNI_XCODE_VERSION ${_xcode_version}) + unset(_xcode_version) + endif() + + if(_FindJNI_XCODE_VERSION VERSION_GREATER 12.1) + set(CMAKE_FIND_FRAMEWORK "NEVER") + endif() + unset(_FindJNI_XCODE_VERSION) + if(CMAKE_FIND_FRAMEWORK STREQUAL "ONLY") set(_JNI_SEARCHES FRAMEWORK) elseif(CMAKE_FIND_FRAMEWORK STREQUAL "NEVER") diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index 76d4a9b24..f78433d95 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -2197,7 +2197,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) # retrieve various package installation directories execute_process (COMMAND ${_${_PYTHON_PREFIX}_INTERPRETER_LAUNCHER} "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c - "import sys\ntry:\n import sysconfig\n sys.stdout.write(';'.join([sysconfig.get_path('stdlib'),sysconfig.get_path('platstdlib'),sysconfig.get_path('purelib'),sysconfig.get_path('platlib')]))\nexcept Exception:\n from distutils import sysconfig\n sys.stdout.write(';'.join([sysconfig.get_python_lib(plat_specific=False,standard_lib=True),sysconfig.get_python_lib(plat_specific=True,standard_lib=True),sysconfig.get_python_lib(plat_specific=False,standard_lib=False),sysconfig.get_python_lib(plat_specific=True,standard_lib=False)]))" + "import sys\nif sys.version_info >= (3,10):\n import sysconfig\n sys.stdout.write(';'.join([sysconfig.get_path('stdlib'),sysconfig.get_path('platstdlib'),sysconfig.get_path('purelib'),sysconfig.get_path('platlib')]))\nelse:\n from distutils import sysconfig\n sys.stdout.write(';'.join([sysconfig.get_python_lib(plat_specific=False,standard_lib=True),sysconfig.get_python_lib(plat_specific=True,standard_lib=True),sysconfig.get_python_lib(plat_specific=False,standard_lib=False),sysconfig.get_python_lib(plat_specific=True,standard_lib=False)]))" RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT OUTPUT_VARIABLE _${_PYTHON_PREFIX}_LIBPATHS ERROR_QUIET) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index b01e1e713..f022ddaca 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -938,13 +938,9 @@ if(WIN32 AND NOT CYGWIN) list(APPEND _tools cmcldeps) endif() -if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR MATCHES "sparc") - # the atomic instructions are implemented using libatomic on some platforms, - # so linking to that may be required - check_library_exists(atomic __atomic_fetch_add_4 "" LIBATOMIC_NEEDED) - if(LIBATOMIC_NEEDED) - target_link_libraries(CMakeLib PUBLIC atomic) - endif() +# Some atomic instructions are implemented using libatomic on some platforms. +if(CMake_HAVE_CXX_ATOMIC_LIB) + target_link_libraries(CMakeLib PUBLIC atomic) endif() # On Apple we need CoreFoundation and CoreServices diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 748432798..e724083a8 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 27) -set(CMake_VERSION_PATCH 1) +set(CMake_VERSION_PATCH 2) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) @@ -21,7 +21,7 @@ endif() if(NOT CMake_VERSION_NO_GIT) # If this source was exported by 'git archive', use its commit info. - set(git_info [==[b5c54d9c8a CMake 3.27.1]==]) + set(git_info [==[f3d9a82110 CMake 3.27.2]==]) # Otherwise, try to identify the current development source version. if(NOT git_info MATCHES "^([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]?[0-9a-f]?)[0-9a-f]* " diff --git a/Source/Checks/cm_cxx_atomic.cxx b/Source/Checks/cm_cxx_atomic.cxx new file mode 100644 index 000000000..098a7a72b --- /dev/null +++ b/Source/Checks/cm_cxx_atomic.cxx @@ -0,0 +1,6 @@ +#include +int main() +{ + std::atomic(0).load(); + return 0; +} diff --git a/Source/Checks/cm_cxx_atomic_builtin.cxx b/Source/Checks/cm_cxx_atomic_builtin.cxx new file mode 100644 index 000000000..d284f6ca1 --- /dev/null +++ b/Source/Checks/cm_cxx_atomic_builtin.cxx @@ -0,0 +1 @@ +#include "cm_cxx_atomic.cxx" diff --git a/Source/Checks/cm_cxx_atomic_lib.cxx b/Source/Checks/cm_cxx_atomic_lib.cxx new file mode 100644 index 000000000..d284f6ca1 --- /dev/null +++ b/Source/Checks/cm_cxx_atomic_lib.cxx @@ -0,0 +1 @@ +#include "cm_cxx_atomic.cxx" diff --git a/Source/Checks/cm_cxx_features.cmake b/Source/Checks/cm_cxx_features.cmake index f5b758759..98d5eff07 100644 --- a/Source/Checks/cm_cxx_features.cmake +++ b/Source/Checks/cm_cxx_features.cmake @@ -17,6 +17,7 @@ function(cm_check_cxx_feature name) try_run(CMake_RUN_CXX_${FEATURE} CMake_COMPILE_CXX_${FEATURE} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_LIST_DIR}/cm_cxx_${name}.cxx + LINK_LIBRARIES ${cm_check_cxx_feature_LINK_LIBRARIES} CMAKE_FLAGS ${maybe_cxx_standard} OUTPUT_VARIABLE OUTPUT ) @@ -29,6 +30,7 @@ function(cm_check_cxx_feature name) try_compile(CMake_HAVE_CXX_${FEATURE} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_LIST_DIR}/cm_cxx_${name}.cxx + LINK_LIBRARIES ${cm_check_cxx_feature_LINK_LIBRARIES} CMAKE_FLAGS ${maybe_cxx_standard} OUTPUT_VARIABLE OUTPUT ) @@ -93,3 +95,12 @@ if (NOT CMAKE_CXX_STANDARD LESS "17") else() set(CMake_HAVE_CXX_FILESYSTEM FALSE) endif() + +if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR MATCHES "armv7l|sparc") + cm_check_cxx_feature(atomic_builtin) + if(NOT CMake_HAVE_CXX_ATOMIC_BUILTIN) + set(cm_check_cxx_feature_LINK_LIBRARIES atomic) + cm_check_cxx_feature(atomic_lib) # defines CMake_HAVE_CXX_ATOMIC_LIB + unset(cm_check_cxx_feature_LINK_LIBRARIES) + endif() +endif() diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 45fba8bff..8f2ebf570 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2555,8 +2555,9 @@ bool HandleGenerateCommand(std::vector const& args, return false; } const bool inputIsContent = arguments.ParsedKeywords[1] == "CONTENT"_s; - if (!inputIsContent && arguments.ParsedKeywords[1] == "INPUT") { + if (!inputIsContent && arguments.ParsedKeywords[1] != "INPUT") { status.SetError("Unknown argument to GENERATE subcommand."); + return false; } std::string const& input = inputIsContent ? *arguments.Content : *arguments.Input; diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 321f3779d..35227db43 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -544,7 +544,7 @@ bool cmGlobalVisualStudio10Generator::InitializePlatformWindows(cmMakefile*) } bool cmGlobalVisualStudio10Generator::VerifyNoGeneratorPlatformVersion( - cmMakefile*, cm::optional) const + cmMakefile*) const { return true; } diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 38942cb6c..40bdd710a 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -187,8 +187,7 @@ protected: bool InitializePlatform(cmMakefile* mf) override; virtual bool InitializePlatformWindows(cmMakefile* mf); - virtual bool VerifyNoGeneratorPlatformVersion( - cmMakefile* mf, cm::optional reason = cm::nullopt) const; + virtual bool VerifyNoGeneratorPlatformVersion(cmMakefile* mf) const; virtual bool ProcessGeneratorToolsetField(std::string const& key, std::string const& value); diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index 4300d5c9f..01294dd19 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -6,6 +6,7 @@ #include #include +#include #include "cmGlobalGenerator.h" #include "cmGlobalGeneratorFactory.h" @@ -140,14 +141,103 @@ bool cmGlobalVisualStudio14Generator::MatchesGeneratorName( bool cmGlobalVisualStudio14Generator::InitializePlatformWindows(cmMakefile* mf) { - if (cmHasLiteralPrefix(this->SystemVersion, "10.0")) { + // If a Windows SDK version is explicitly requested, search for it. + if (this->GeneratorPlatformVersion) { + std::string const& version = *this->GeneratorPlatformVersion; + + // VS 2019 and above support specifying plain "10.0". + if (version == "10.0"_s) { + if (this->Version >= VSVersion::VS16) { + this->SetWindowsTargetPlatformVersion("10.0", mf); + return true; + } + /* clang-format off */ + mf->IssueMessage(MessageType::FATAL_ERROR, cmStrCat( + "Generator\n" + " ", this->GetName(), "\n" + "given platform specification containing a\n" + " version=10.0\n" + "field. The value 10.0 is only supported by VS 2019 and above.\n" + )); + /* clang-format on */ + return false; + } + + if (cmHasLiteralPrefix(version, "10.0.")) { + return this->SelectWindows10SDK(mf); + } + + if (version == "8.1"_s) { + if (this->IsWin81SDKInstalled()) { + this->SetWindowsTargetPlatformVersion("8.1", mf); + return true; + } + /* clang-format off */ + mf->IssueMessage(MessageType::FATAL_ERROR, cmStrCat( + "Generator\n" + " ", this->GetName(), "\n" + "given platform specification containing a\n" + " version=8.1\n" + "field, but the Windows 8.1 SDK is not installed.\n" + )); + /* clang-format on */ + return false; + } + + if (version.empty()) { + /* clang-format off */ + mf->IssueMessage(MessageType::FATAL_ERROR, cmStrCat( + "Generator\n" + " ", this->GetName(), "\n" + "given platform specification with empty\n" + " version=\n" + "field.\n" + )); + /* clang-format on */ + return false; + } + + /* clang-format off */ + mf->IssueMessage(MessageType::FATAL_ERROR, cmStrCat( + "Generator\n" + " ", this->GetName(), "\n" + "given platform specification containing a\n" + " version=", version, "\n" + "field with unsupported value.\n" + )); + /* clang-format on */ + return false; + } + + // If we are targeting Windows 10+, we select a Windows 10 SDK. + // If no Windows 8.1 SDK is installed, which is possible with VS 2017 and + // higher, then we must choose a Windows 10 SDK anyway. + if (cmHasLiteralPrefix(this->SystemVersion, "10.0") || + !this->IsWin81SDKInstalled()) { return this->SelectWindows10SDK(mf); } - return this->VerifyNoGeneratorPlatformVersion(mf); + + // Under CMP0149 NEW behavior, we search for a Windows 10 SDK even + // when targeting older Windows versions, but it is not required. + if (mf->GetPolicyStatus(cmPolicies::CMP0149) == cmPolicies::NEW) { + std::string const version = this->GetWindows10SDKVersion(mf); + if (!version.empty()) { + this->SetWindowsTargetPlatformVersion(version, mf); + return true; + } + } + + // We are not targeting Windows 10+, so fall back to the Windows 8.1 SDK. + // For VS 2019 and above we must explicitly specify it. + if (this->Version >= cmGlobalVisualStudioGenerator::VSVersion::VS16 && + !cmSystemTools::VersionCompareGreater(this->SystemVersion, "8.1")) { + this->SetWindowsTargetPlatformVersion("8.1", mf); + } + return true; } bool cmGlobalVisualStudio14Generator::VerifyNoGeneratorPlatformVersion( - cmMakefile* mf, cm::optional reason) const + cmMakefile* mf) const { if (!this->GeneratorPlatformVersion) { return true; @@ -163,9 +253,6 @@ bool cmGlobalVisualStudio14Generator::VerifyNoGeneratorPlatformVersion( " " << this->SystemName << " " << this->SystemVersion << "\n" ; /* clang-format on */ - if (reason) { - e << *reason << "."; - } mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); return false; } @@ -207,16 +294,6 @@ bool cmGlobalVisualStudio14Generator::ProcessGeneratorPlatformField( bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf) { - if (this->GeneratorPlatformVersion && - this->GeneratorPlatformVersion->empty()) { - mf->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat("Generator\n ", this->GetName(), - "\ngiven platform specification with empty\n version=\n" - "field.")); - return false; - } - // Find the default version of the Windows 10 SDK. std::string const version = this->GetWindows10SDKVersion(mf); @@ -248,7 +325,8 @@ void cmGlobalVisualStudio14Generator::SetWindowsTargetPlatformVersion( std::string const& version, cmMakefile* mf) { this->WindowsTargetPlatformVersion = version; - if (!cmSystemTools::VersionCompareEqual(this->WindowsTargetPlatformVersion, + if (!this->WindowsTargetPlatformVersion.empty() && + !cmSystemTools::VersionCompareEqual(this->WindowsTargetPlatformVersion, this->SystemVersion)) { std::ostringstream e; e << "Selecting Windows SDK version " << this->WindowsTargetPlatformVersion @@ -295,6 +373,11 @@ bool cmGlobalVisualStudio14Generator::IsWindowsStoreToolsetInstalled() const cmSystemTools::KeyWOW64_32); } +bool cmGlobalVisualStudio14Generator::IsWin81SDKInstalled() const +{ + return true; +} + std::string cmGlobalVisualStudio14Generator::GetWindows10SDKMaxVersion( cmMakefile* mf) const { @@ -356,16 +439,6 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion( cmMakefile* mf) { #if defined(_WIN32) && !defined(__CYGWIN__) - // Accept specific version requests as-is. - if (this->GeneratorPlatformVersion) { - std::string const& ver = *this->GeneratorPlatformVersion; - - // VS 2019 and above support specifying plain "10.0". - if (this->Version >= VSVersion::VS16 && ver == "10.0") { - return ver; - } - } - std::vector win10Roots; { diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h index f59a32330..e9035780f 100644 --- a/Source/cmGlobalVisualStudio14Generator.h +++ b/Source/cmGlobalVisualStudio14Generator.h @@ -40,10 +40,10 @@ protected: // of the toolset is installed bool IsWindowsStoreToolsetInstalled() const; + virtual bool IsWin81SDKInstalled() const; + bool InitializePlatformWindows(cmMakefile* mf) override; - bool VerifyNoGeneratorPlatformVersion( - cmMakefile* mf, - cm::optional reason = cm::nullopt) const override; + bool VerifyNoGeneratorPlatformVersion(cmMakefile* mf) const override; bool ProcessGeneratorPlatformField(std::string const& key, std::string const& value) override; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index acb20d1d0..3125eb539 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -265,22 +265,6 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() auto new_end = std::unique(listFiles.begin(), listFiles.end()); listFiles.erase(new_end, listFiles.end()); - // Add all cmake input files which are used by the project - // so Visual Studio does not close them when reloading it. - for (const std::string& listFile : listFiles) { - if (listFile.find("/CMakeFiles/") != std::string::npos) { - continue; - } - if (!cmSystemTools::IsSubDirectory(listFile, - lg.GetMakefile()->GetHomeDirectory()) && - !cmSystemTools::IsSubDirectory( - listFile, lg.GetMakefile()->GetHomeOutputDirectory())) { - continue; - } - - tgt->AddSource(listFile); - } - auto ptr = cm::make_unique(tgt, &lg); auto* gt = ptr.get(); lg.AddGeneratorTarget(std::move(ptr)); diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index 602b42fbc..14c7d0f7d 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -901,26 +901,6 @@ cmGlobalVisualStudioVersionedGenerator::FindAuxToolset( return AuxToolset::PropsMissing; } -bool cmGlobalVisualStudioVersionedGenerator::InitializePlatformWindows( - cmMakefile* mf) -{ - // If the Win 8.1 SDK is installed then we can select a SDK matching - // the target Windows version. - if (this->IsWin81SDKInstalled()) { - // VS 2019 does not default to 8.1 so specify it explicitly when needed. - if (this->Version >= cmGlobalVisualStudioGenerator::VSVersion::VS16 && - !cmSystemTools::VersionCompareGreater(this->SystemVersion, "8.1")) { - this->SetWindowsTargetPlatformVersion("8.1", mf); - return this->VerifyNoGeneratorPlatformVersion( - mf, "with the Windows 8.1 SDK installed"); - } - return cmGlobalVisualStudio14Generator::InitializePlatformWindows(mf); - } - // Otherwise we must choose a Win 10 SDK even if we are not targeting - // Windows 10. - return this->SelectWindows10SDK(mf); -} - bool cmGlobalVisualStudioVersionedGenerator::SelectWindowsStoreToolset( std::string& toolset) const { diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.h b/Source/cmGlobalVisualStudioVersionedGenerator.h index 8712459ee..8f0345f6e 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.h +++ b/Source/cmGlobalVisualStudioVersionedGenerator.h @@ -72,10 +72,8 @@ protected: // of the toolset is installed bool IsWindowsStoreToolsetInstalled() const; - bool InitializePlatformWindows(cmMakefile* mf) override; - // Check for a Win 8 SDK known to the registry or VS installer tool. - bool IsWin81SDKInstalled() const; + bool IsWin81SDKInstalled() const override; std::string GetWindows10SDKMaxVersionDefault(cmMakefile*) const override; diff --git a/Source/cmList.cxx b/Source/cmList.cxx index 022fcd2b4..28d479110 100644 --- a/Source/cmList.cxx +++ b/Source/cmList.cxx @@ -802,32 +802,35 @@ cmList& cmList::transform(TransformAction action, return *this; } -std::string cmList::join(cm::string_view glue) const -{ - return cmJoin(this->Values, glue); -} - -std::string& cmList::append(std::string& list, cm::string_view value) +std::string& cmList::append(std::string& list, std::string&& value) { if (list.empty()) { - list = std::string(value); + list = std::move(value); } else { list += cmStrCat(cmList::element_separator, value); } return list; } +std::string& cmList::append(std::string& list, cm::string_view value) +{ + return cmList::append(list, std::string{ value }); +} -std::string& cmList::prepend(std::string& list, cm::string_view value) +std::string& cmList::prepend(std::string& list, std::string&& value) { if (list.empty()) { - list = std::string(value); + list = std::move(value); } else { list.insert(0, cmStrCat(value, cmList::element_separator)); } return list; } +std::string& cmList::prepend(std::string& list, cm::string_view value) +{ + return cmList::prepend(list, std::string{ value }); +} cmList::size_type cmList::ComputeIndex(index_type pos, bool boundCheck) const { diff --git a/Source/cmList.h b/Source/cmList.h index eba0400c9..798b9842b 100644 --- a/Source/cmList.h +++ b/Source/cmList.h @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -936,7 +935,10 @@ public: std::vector const& args, std::unique_ptr = {}); - std::string join(cm::string_view glue) const; + std::string join(cm::string_view glue) const + { + return cmList::Join(this->Values, glue); + } void swap(cmList& other) noexcept { this->Values.swap(other.Values); } @@ -1080,6 +1082,7 @@ public: // but without any intermediate expansion. So the operation is simply a // string concatenation with special handling for the CMake list item // separator + static std::string& append(std::string& list, std::string&& value); static std::string& append(std::string& list, cm::string_view value); template static std::string& append(std::string& list, InputIterator first, @@ -1089,15 +1092,11 @@ public: return list; } - return cmList::append(list, - cm::string_view{ std::accumulate( - std::next(first), last, *first, - [](std::string a, const std::string& b) { - return std::move(a) + - std::string(cmList::element_separator) + b; - }) }); + return cmList::append( + list, cmList::Join(first, last, cmList::element_separator)); } + static std::string& prepend(std::string& list, std::string&& value); static std::string& prepend(std::string& list, cm::string_view value); template static std::string& prepend(std::string& list, InputIterator first, @@ -1107,13 +1106,8 @@ public: return list; } - return cmList::prepend(list, - cm::string_view{ std::accumulate( - std::next(first), last, *first, - [](std::string a, const std::string& b) { - return std::move(a) + - std::string(cmList::element_separator) + b; - }) }); + return cmList::prepend( + list, cmList::Join(first, last, cmList::element_separator)); } // Non-members @@ -1185,6 +1179,37 @@ private: return container.begin() + delta; } + static std::string const& ToString(std::string const& s) { return s; } + static std::string ToString(cm::string_view s) { return std::string{ s }; } + + template + static std::string Join(Range const& r, cm::string_view glue) + { + if (cm::size(r) == 0) { + return std::string{}; + } + + return cmList::Join(std::begin(r), std::end(r), glue); + } + template + static std::string Join(InputIterator first, InputIterator last, + cm::string_view glue) + { + if (first == last) { + return std::string{}; + } + + const auto sep = std::string{ glue }; + + std::string joined = cmList::ToString(*first); + for (auto it = std::next(first); it != last; ++it) { + joined += sep; + joined += cmList::ToString(*it); + } + + return joined; + } + container_type Values; }; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 7ad4023de..aaf0d6794 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -68,7 +68,7 @@ #endif // List of variables that are replaced when -// rules are expanced. These variables are +// rules are expanded. These variables are // replaced in the form with GetSafeDefinition(var). // ${LANG} is replaced in the variable first with all enabled // languages. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 8d6b024a8..b3699ae73 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -52,8 +51,6 @@ #include "cmValue.h" #include "cmVisualStudioGeneratorOptions.h" -const std::string kBuildSystemSources = "Buildsystem Input Files"; - struct cmIDEFlagTable; static void ConvertToWindowsSlash(std::string& s); @@ -1954,13 +1951,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() "http://schemas.microsoft.com/developer/msbuild/2003"); for (auto const& ti : this->Tools) { - if ((this->GeneratorTarget->GetName() == - CMAKE_CHECK_BUILD_SYSTEM_TARGET) && - (ti.first == "None")) { - this->WriteBuildSystemSources(e0, ti.first, ti.second); - } else { - this->WriteGroupSources(e0, ti.first, ti.second, sourceGroups); - } + this->WriteGroupSources(e0, ti.first, ti.second, sourceGroups); } // Added files are images and the manifest. @@ -2031,18 +2022,6 @@ void cmVisualStudio10TargetGenerator::WriteGroups() "rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;" "gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms"); } - - if (this->GeneratorTarget->GetName() == - CMAKE_CHECK_BUILD_SYSTEM_TARGET) { - for (const std::string& filter : this->BuildSystemSourcesFilters) { - std::string guidName = "SG_Filter_"; - guidName += filter; - std::string guid = this->GlobalGenerator->GetGUID(guidName); - Elem e2(e1, "Filter"); - e2.Attribute("Include", filter); - e2.Element("UniqueIdentifier", "{" + guid + "}"); - } - } } } fout << '\n'; @@ -2109,39 +2088,6 @@ void cmVisualStudio10TargetGenerator::WriteGroupSources( } } -void cmVisualStudio10TargetGenerator::WriteBuildSystemSources( - Elem& e0, std::string const& name, ToolSources const& sources) -{ - const std::string srcDir = this->Makefile->GetCurrentSourceDirectory(); - const std::string::size_type srcDirLength = srcDir.length(); - - Elem e1(e0, "ItemGroup"); - e1.SetHasElements(); - for (ToolSource const& s : sources) { - cmSourceFile const* sf = s.SourceFile; - std::string const& source = sf->GetFullPath(); - - cm::filesystem::path sourcePath(source); - bool isInSrcDir = cmHasPrefix(source, srcDir); - - std::string filter = kBuildSystemSources; - if (isInSrcDir) { - std::string parentPath = sourcePath.parent_path().string(); - if (srcDir != parentPath) { - filter += parentPath.substr(srcDirLength); - } - ConvertToWindowsSlash(filter); - this->BuildSystemSourcesFilters.insert(filter); - } - - std::string path = this->ConvertPath(source, s.RelativePath); - ConvertToWindowsSlash(path); - Elem e2(e1, name); - e2.Attribute("Include", path); - e2.Element("Filter", filter); - } -} - void cmVisualStudio10TargetGenerator::WriteHeaderSource( Elem& e1, cmSourceFile const* sf, ConfigToSettings const& toolSettings) { diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index ffab91fca..2080e9eac 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -194,9 +194,6 @@ private: void WriteGroupSources(Elem& e0, std::string const& name, ToolSources const& sources, std::vector&); - void WriteBuildSystemSources(Elem& e0, std::string const& name, - ToolSources const& sources); - void AddMissingSourceGroups(std::set& groupsUsed, const std::vector& allGroups); bool IsResxHeader(const std::string& headerFile); @@ -247,7 +244,6 @@ private: std::set ASanEnabledConfigurations; std::set FuzzerEnabledConfigurations; std::map SpectreMitigation; - std::set BuildSystemSourcesFilters; cmGlobalVisualStudio10Generator* const GlobalGenerator; cmLocalVisualStudio10Generator* const LocalGenerator; std::set CSharpCustomCommandNames; diff --git a/Tests/CMakeLib/testList.cxx b/Tests/CMakeLib/testList.cxx index f6ec7208e..6d6c218e2 100644 --- a/Tests/CMakeLib/testList.cxx +++ b/Tests/CMakeLib/testList.cxx @@ -859,7 +859,7 @@ bool testStaticModifiers() } { std::string list{ "a;b;c" }; - cmList::append(list, ""); + cmList::append(list, ""_s); if (list != "a;b;c;") { result = false; @@ -894,7 +894,7 @@ bool testStaticModifiers() } { std::string list{ "a;b;c" }; - cmList::prepend(list, "d;e"); + cmList::prepend(list, "d;e"_s); if (list != "d;e;a;b;c") { result = false; @@ -902,7 +902,7 @@ bool testStaticModifiers() } { std::string list; - cmList::prepend(list, "d;e"); + cmList::prepend(list, "d;e"_s); if (list != "d;e") { result = false; @@ -910,7 +910,7 @@ bool testStaticModifiers() } { std::string list{ "a;b;c" }; - cmList::prepend(list, ""); + cmList::prepend(list, ""_s); if (list != ";a;b;c") { result = false; diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py index b66954364..8911e1889 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py +++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py @@ -896,216 +896,6 @@ def gen_check_targets(c, g, inSource): if e["id"] == "^ZERO_CHECK::@6890427a1f51a3e7e1df$": # The json files have data for Xcode. Substitute data for VS. e["sources"] = [ - { - "path": "^CMakeLists\\.txt$", - "isGenerated": None, - "fileSetName": None, - "sourceGroupName": "", - "compileGroupLanguage": None, - "backtrace": [ - { - "file": "^CMakeLists\\.txt$", - "line": None, - "command": None, - "hasParent": False, - }, - ], - }, - { - "path": "^alias/CMakeLists\\.txt$", - "isGenerated": None, - "fileSetName": None, - "sourceGroupName": "", - "compileGroupLanguage": None, - "backtrace": [ - { - "file": "^CMakeLists\\.txt$", - "line": None, - "command": None, - "hasParent": False, - }, - ], - }, - { - "path": "^codemodel-v2\\.cmake$", - "isGenerated": None, - "fileSetName": None, - "sourceGroupName": "", - "compileGroupLanguage": None, - "backtrace": [ - { - "file": "^CMakeLists\\.txt$", - "line": None, - "command": None, - "hasParent": False, - }, - ], - }, - { - "path": "^custom/CMakeLists\\.txt$", - "isGenerated": None, - "fileSetName": None, - "sourceGroupName": "", - "compileGroupLanguage": None, - "backtrace": [ - { - "file": "^CMakeLists\\.txt$", - "line": None, - "command": None, - "hasParent": False, - }, - ], - }, - { - "path": "^cxx/CMakeLists\\.txt$", - "isGenerated": None, - "fileSetName": None, - "sourceGroupName": "", - "compileGroupLanguage": None, - "backtrace": [ - { - "file": "^CMakeLists\\.txt$", - "line": None, - "command": None, - "hasParent": False, - }, - ], - }, - { - "path": "^framework/CMakeLists\\.txt$", - "isGenerated": None, - "fileSetName": None, - "sourceGroupName": "", - "compileGroupLanguage": None, - "backtrace": [ - { - "file": "^CMakeLists\\.txt$", - "line": None, - "command": None, - "hasParent": False, - }, - ], - }, - { - "path": "^dir/CMakeLists\\.txt$", - "isGenerated": None, - "fileSetName": None, - "sourceGroupName": "", - "compileGroupLanguage": None, - "backtrace": [ - { - "file": "^CMakeLists\\.txt$", - "line": None, - "command": None, - "hasParent": False, - }, - ], - }, - { - "path": "^dir/dir/CMakeLists\\.txt$", - "isGenerated": None, - "fileSetName": None, - "sourceGroupName": "", - "compileGroupLanguage": None, - "backtrace": [ - { - "file": "^CMakeLists\\.txt$", - "line": None, - "command": None, - "hasParent": False, - }, - ], - }, - { - "path": "^fileset/CMakeLists\\.txt$", - "isGenerated": None, - "fileSetName": None, - "sourceGroupName": "", - "compileGroupLanguage": None, - "backtrace": [ - { - "file": "^CMakeLists\\.txt$", - "line": None, - "command": None, - "hasParent": False, - }, - ], - }, - { - "path": "^imported/CMakeLists\\.txt$", - "isGenerated": None, - "fileSetName": None, - "sourceGroupName": "", - "compileGroupLanguage": None, - "backtrace": [ - { - "file": "^CMakeLists\\.txt$", - "line": None, - "command": None, - "hasParent": False, - }, - ], - }, - { - "path": "^include_test\\.cmake$", - "isGenerated": None, - "fileSetName": None, - "sourceGroupName": "", - "compileGroupLanguage": None, - "backtrace": [ - { - "file": "^CMakeLists\\.txt$", - "line": None, - "command": None, - "hasParent": False, - }, - ], - }, - { - "path": "^interface/CMakeLists\\.txt$", - "isGenerated": None, - "fileSetName": None, - "sourceGroupName": "", - "compileGroupLanguage": None, - "backtrace": [ - { - "file": "^CMakeLists\\.txt$", - "line": None, - "command": None, - "hasParent": False, - }, - ], - }, - { - "path": "^object/CMakeLists\\.txt$", - "isGenerated": None, - "fileSetName": None, - "sourceGroupName": "", - "compileGroupLanguage": None, - "backtrace": [ - { - "file": "^CMakeLists\\.txt$", - "line": None, - "command": None, - "hasParent": False, - }, - ], - }, - { - "path": "^subdir/CMakeLists\\.txt$", - "isGenerated": None, - "fileSetName": None, - "sourceGroupName": "", - "compileGroupLanguage": None, - "backtrace": [ - { - "file": "^CMakeLists\\.txt$", - "line": None, - "command": None, - "hasParent": False, - }, - ], - }, { "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/CMakeFiles/([0-9a-f]+/)?generate\\.stamp\\.rule$", "isGenerated": True, @@ -1123,25 +913,6 @@ def gen_check_targets(c, g, inSource): }, ] e["sourceGroups"] = [ - { - "name": "", - "sourcePaths": [ - "^CMakeLists\\.txt$", - "^alias/CMakeLists\\.txt$", - "^codemodel-v2\\.cmake$", - "^custom/CMakeLists\\.txt$", - "^cxx/CMakeLists\\.txt$", - "^framework/CMakeLists\\.txt$", - "^dir/CMakeLists\\.txt$", - "^dir/dir/CMakeLists\\.txt$", - "^fileset/CMakeLists\\.txt$", - "^imported/CMakeLists\\.txt$", - "^include_test\\.cmake$", - "^interface/CMakeLists\\.txt$", - "^object/CMakeLists\\.txt$", - "^subdir/CMakeLists\\.txt$", - ], - }, { "name": "CMake Rules", "sourcePaths": [ diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionPlatform-result.txt b/Tests/RunCMake/File_Generate/OutOfOrderArgs-result.txt similarity index 100% rename from Tests/RunCMake/GeneratorPlatform/BadVersionPlatform-result.txt rename to Tests/RunCMake/File_Generate/OutOfOrderArgs-result.txt diff --git a/Tests/RunCMake/File_Generate/OutOfOrderArgs-stderr.txt b/Tests/RunCMake/File_Generate/OutOfOrderArgs-stderr.txt new file mode 100644 index 000000000..a3f5cd5e8 --- /dev/null +++ b/Tests/RunCMake/File_Generate/OutOfOrderArgs-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at OutOfOrderArgs\.cmake:[0-9]+ \(file\): + file Unknown argument to GENERATE subcommand\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/File_Generate/OutOfOrderArgs.cmake b/Tests/RunCMake/File_Generate/OutOfOrderArgs.cmake new file mode 100644 index 000000000..7f0578b29 --- /dev/null +++ b/Tests/RunCMake/File_Generate/OutOfOrderArgs.cmake @@ -0,0 +1,4 @@ +file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output.txt" + CONDITION 1 + CONTENT "CONTENT argument" + ) diff --git a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake index 5a670ae4f..e601991a2 100644 --- a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake +++ b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake @@ -15,6 +15,7 @@ endif() run_cmake(EmptyCondition1) run_cmake(EmptyCondition2) run_cmake(BadCondition) +run_cmake(OutOfOrderArgs) run_cmake(DebugEvaluate) run_cmake(GenerateSource) run_cmake(InputAndContent) diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionMissing-stderr.txt b/Tests/RunCMake/GeneratorPlatform/BadVersionMissing-stderr.txt index d82eb0bba..41e94f359 100644 --- a/Tests/RunCMake/GeneratorPlatform/BadVersionMissing-stderr.txt +++ b/Tests/RunCMake/GeneratorPlatform/BadVersionMissing-stderr.txt @@ -6,6 +6,6 @@ given platform specification with - version=1\.2\.3\.4 + version=10\.0\.0\.0 field, but no Windows SDK with that version was found\.$ diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionPlatform-stderr.txt b/Tests/RunCMake/GeneratorPlatform/BadVersionPlatform-stderr.txt deleted file mode 100644 index d3c62e362..000000000 --- a/Tests/RunCMake/GeneratorPlatform/BadVersionPlatform-stderr.txt +++ /dev/null @@ -1,19 +0,0 @@ -^CMake Error at CMakeLists.txt:[0-9]+ \(project\): - Generator - - Visual Studio [^ -]+ - - given platform specification (containing a - - version=8\.1 - - field\. The version field is not supported when targeting - - Windows 8\.1( - - with the Windows 8\.1 SDK installed\.)?|with - - version=8\.1 - - field, but no Windows SDK with that version was found\.)$ diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionPre2019-result.txt b/Tests/RunCMake/GeneratorPlatform/BadVersionPre2019-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/BadVersionPre2019-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionPre2019-stderr.txt b/Tests/RunCMake/GeneratorPlatform/BadVersionPre2019-stderr.txt new file mode 100644 index 000000000..649b89da1 --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/BadVersionPre2019-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error at CMakeLists.txt:[0-9]+ \(project\): + Generator + + Visual Studio [^ +]+ + + given platform specification containing a + + version=10\.0 + + field\. The value 10\.0 is only supported by VS 2019 and above\.$ diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionPlatform.cmake b/Tests/RunCMake/GeneratorPlatform/BadVersionPre2019.cmake similarity index 100% rename from Tests/RunCMake/GeneratorPlatform/BadVersionPlatform.cmake rename to Tests/RunCMake/GeneratorPlatform/BadVersionPre2019.cmake diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionUnsupported-result.txt b/Tests/RunCMake/GeneratorPlatform/BadVersionUnsupported-result.txt new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/BadVersionUnsupported-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionUnsupported-stderr.txt b/Tests/RunCMake/GeneratorPlatform/BadVersionUnsupported-stderr.txt new file mode 100644 index 000000000..c165267e0 --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/BadVersionUnsupported-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error at CMakeLists.txt:[0-9]+ \(project\): + Generator + + Visual Studio [^ +]+ + + given platform specification containing a + + version=1\.2\.3\.4 + + field with unsupported value\.$ diff --git a/Tests/RunCMake/GeneratorPlatform/BadVersionUnsupported.cmake b/Tests/RunCMake/GeneratorPlatform/BadVersionUnsupported.cmake new file mode 100644 index 000000000..2fc38e5c5 --- /dev/null +++ b/Tests/RunCMake/GeneratorPlatform/BadVersionUnsupported.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "This should not be reached!") diff --git a/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake index 233eb0a2f..d8965f749 100644 --- a/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake @@ -36,12 +36,16 @@ if("${RunCMake_GENERATOR}" MATCHES "^Visual Studio (1[4567])( 20[0-9][0-9])?$") run_cmake(BadFieldUnknown) set(RunCMake_GENERATOR_PLATFORM "version=") run_cmake(BadVersionEmpty) - set(RunCMake_GENERATOR_PLATFORM "version=1.2.3.4") + set(RunCMake_GENERATOR_PLATFORM "version=10.0.0.0") run_cmake(BadVersionMissing) - set(RunCMake_GENERATOR_PLATFORM "version=8.1") - run_cmake_with_options(BadVersionPlatform -DCMAKE_SYSTEM_VERSION=8.1) + set(RunCMake_GENERATOR_PLATFORM "version=1.2.3.4") + run_cmake(BadVersionUnsupported) - if(NOT RunCMake_GENERATOR MATCHES "^Visual Studio (1[45]) ") + if(RunCMake_GENERATOR MATCHES "^Visual Studio (1[45]) ") + set(RunCMake_GENERATOR_PLATFORM "version=10.0") + run_cmake(BadVersionPre2019) + unset(RunCMake_GENERATOR_PLATFORM) + else() set(expect_version "10.0") set(RunCMake_GENERATOR_PLATFORM "version=${expect_version}") set(RunCMake_TEST_VARIANT_DESCRIPTION "-${expect_version}") @@ -61,6 +65,16 @@ if("${RunCMake_GENERATOR}" MATCHES "^Visual Studio (1[4567])( 20[0-9][0-9])?$") file(GLOB kits RELATIVE "${kitsInclude}" "${kitsInclude}/*/um/windows.h") list(TRANSFORM kits REPLACE "/.*" "") endif() + cmake_host_system_information(RESULT kitsRoot81 + QUERY WINDOWS_REGISTRY "HKLM/SOFTWARE/Microsoft/Windows Kits/Installed Roots" + VALUE "KitsRoot81" + VIEW 64_32 + ERROR_VARIABLE kitsRoot81Error + ) + if(NOT kitsRoot81Error AND EXISTS "${kitsRoot81}/include/um/windows.h") + list(PREPEND kits "8.1") + endif() + if(kits) message(STATUS "Available Kits: ${kits}") if(RunCMake_GENERATOR MATCHES "^Visual Studio 14 ") @@ -83,29 +97,28 @@ if("${RunCMake_GENERATOR}" MATCHES "^Visual Studio (1[4567])( 20[0-9][0-9])?$") message(FATAL_ERROR "Could not find any Windows SDKs to drive test cases.") endif() - if(kits) - foreach(expect_version IN LISTS kits) - set(RunCMake_GENERATOR_PLATFORM "version=${expect_version}") - set(RunCMake_TEST_VARIANT_DESCRIPTION "-${expect_version}") - run_cmake_with_options(VersionExists -DCMAKE_SYSTEM_VERSION=10.0) - unset(RunCMake_GENERATOR_PLATFORM) - endforeach() - foreach(expect_version IN LISTS kits) - set(RunCMake_TEST_VARIANT_DESCRIPTION "-CMP0149-OLD-${expect_version}") - run_cmake_with_options(VersionExists -DCMAKE_SYSTEM_VERSION=${expect_version} -DCMAKE_POLICY_DEFAULT_CMP0149=OLD) - endforeach() - if(kits MATCHES "(^|;)([0-9.]+)$") - set(expect_version "${CMAKE_MATCH_2}") - foreach(test_version IN LISTS kits) - set(RunCMake_TEST_VARIANT_DESCRIPTION "-CMP0149-NEW-${test_version}") - run_cmake_with_options(VersionExists -DCMAKE_SYSTEM_VERSION=${test_version} -DCMAKE_POLICY_DEFAULT_CMP0149=NEW) - endforeach() - endif() - foreach(expect_version IN LISTS kits) - set(RunCMake_TEST_VARIANT_DESCRIPTION "-WindowsSDKVersion-${expect_version}") - set(ENV{WindowsSDKVersion} "${expect_version}\\") - run_cmake_with_options(VersionExists -DCMAKE_SYSTEM_VERSION=10.0 -DCMAKE_POLICY_DEFAULT_CMP0149=NEW) - unset(ENV{WindowsSDKVersion}) + foreach(expect_version IN LISTS kits) + set(RunCMake_GENERATOR_PLATFORM "version=${expect_version}") + set(RunCMake_TEST_VARIANT_DESCRIPTION "-${expect_version}") + run_cmake_with_options(VersionExists -DCMAKE_SYSTEM_VERSION=10.0) + unset(RunCMake_GENERATOR_PLATFORM) + endforeach() + foreach(expect_version IN LISTS kits) + set(RunCMake_TEST_VARIANT_DESCRIPTION "-CMP0149-OLD-${expect_version}") + run_cmake_with_options(VersionExists -DCMAKE_SYSTEM_VERSION=${expect_version} -DCMAKE_POLICY_DEFAULT_CMP0149=OLD) + endforeach() + if(kits MATCHES "(^|;)([0-9.]+)$") + set(expect_version "${CMAKE_MATCH_2}") + foreach(test_version IN LISTS kits) + set(RunCMake_TEST_VARIANT_DESCRIPTION "-CMP0149-NEW-${test_version}") + run_cmake_with_options(VersionExists -DCMAKE_SYSTEM_VERSION=${test_version} -DCMAKE_POLICY_DEFAULT_CMP0149=NEW) endforeach() endif() + list(REMOVE_ITEM kits 8.1) + foreach(expect_version IN LISTS kits) + set(RunCMake_TEST_VARIANT_DESCRIPTION "-WindowsSDKVersion-${expect_version}") + set(ENV{WindowsSDKVersion} "${expect_version}\\") + run_cmake_with_options(VersionExists -DCMAKE_SYSTEM_VERSION=10.0 -DCMAKE_POLICY_DEFAULT_CMP0149=NEW) + unset(ENV{WindowsSDKVersion}) + endforeach() endif() diff --git a/Tests/RunCMake/GeneratorPlatform/VersionExists-check.cmake b/Tests/RunCMake/GeneratorPlatform/VersionExists-check.cmake index 6c3c8e542..62fb27824 100644 --- a/Tests/RunCMake/GeneratorPlatform/VersionExists-check.cmake +++ b/Tests/RunCMake/GeneratorPlatform/VersionExists-check.cmake @@ -1,9 +1,13 @@ if(actual_stdout MATCHES "CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION='([^']+)'") set(actual_version "${CMAKE_MATCH_1}") - if(NOT "${actual_version}" STREQUAL "${expect_version}") - set(RunCMake_TEST_FAILED "Actual SDK version '${actual_version}' did not match expected '${expect_version}'") - return() - endif() +elseif(actual_stdout MATCHES "CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION=''" AND RunCMake_GENERATOR MATCHES "Visual Studio 1[45] ") + set(actual_version "8.1") else() set(RunCMake_TEST_FAILED "No CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION found in output.") + return() +endif() + +if(NOT "${actual_version}" STREQUAL "${expect_version}") + set(RunCMake_TEST_FAILED "Actual SDK version '${actual_version}' did not match expected '${expect_version}'") + return() endif() diff --git a/Tests/RunCMake/VS10Project/CMakeInputs-check.cmake b/Tests/RunCMake/VS10Project/CMakeInputs-check.cmake deleted file mode 100644 index a125574d8..000000000 --- a/Tests/RunCMake/VS10Project/CMakeInputs-check.cmake +++ /dev/null @@ -1,25 +0,0 @@ -set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/ZERO_CHECK.vcxproj") -if(NOT EXISTS "${vcProjectFile}") - set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") - return() -endif() - -set(found_CMakeInputs 0) -file(STRINGS "${vcProjectFile}" lines) -foreach(line IN LISTS lines) - if(line MATCHES "<([A-Za-z0-9_]+) +Include=.*CMakeInputs.cmake") - set(rule "${CMAKE_MATCH_1}") - if(NOT rule STREQUAL "None") - set(RunCMake_TEST_FAILED "CMakeInputs.cmake referenced as ${rule} instead of None") - return() - endif() - if(found_CMakeInputs) - set(RunCMake_TEST_FAILED "CMakeInputs.cmake referenced multiple times") - return() - endif() - set(found_CMakeInputs 1) - endif() -endforeach() -if(NOT found_CMakeInputs) - set(RunCMake_TEST_FAILED "CMakeInputs.cmake not referenced") -endif() diff --git a/Tests/RunCMake/VS10Project/CMakeInputs.cmake b/Tests/RunCMake/VS10Project/CMakeInputs.cmake deleted file mode 100644 index e69de29bb..000000000 diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index cb1a5d540..669049a73 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -7,7 +7,6 @@ if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_GREA run_cmake(LanguageStandard) endif() -run_cmake(CMakeInputs) run_cmake(CustomCommandGenex) if(NOT RunCMake_GENERATOR MATCHES "^Visual Studio 1[1-5] ") run_cmake(CustomCommandParallel) diff --git a/Tests/RunCMake/add_custom_command/ConfigureFile.cmake b/Tests/RunCMake/add_custom_command/ConfigureFile.cmake new file mode 100644 index 000000000..ca53a6cac --- /dev/null +++ b/Tests/RunCMake/add_custom_command/ConfigureFile.cmake @@ -0,0 +1,9 @@ +configure_file(ConfigureFile.in foo.txt @ONLY) +add_custom_target(foo) +add_custom_command( + OUTPUT bar.txt + MAIN_DEPENDENCY ConfigureFile.in # Attach to input of configure_file + DEPENDS foo + COMMAND ${CMAKE_COMMAND} -E copy foo.txt bar.txt + ) +add_custom_target(bar DEPENDS bar.txt) diff --git a/Tests/RunCMake/add_custom_command/ConfigureFile.in b/Tests/RunCMake/add_custom_command/ConfigureFile.in new file mode 100644 index 000000000..f89fc334f --- /dev/null +++ b/Tests/RunCMake/add_custom_command/ConfigureFile.in @@ -0,0 +1 @@ +# ConfigureFile case diff --git a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake index 6c677c073..713b269ad 100644 --- a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake @@ -7,6 +7,7 @@ run_cmake(BadArgument) run_cmake(BadByproduct) run_cmake(BadOutput) run_cmake(BadCommand) +run_cmake(ConfigureFile) run_cmake(GeneratedProperty) run_cmake(LiteralQuotes) run_cmake(NoArguments) diff --git a/Utilities/cmcppdap/CMakeLists.txt b/Utilities/cmcppdap/CMakeLists.txt index 39f72a27a..b6841f118 100644 --- a/Utilities/cmcppdap/CMakeLists.txt +++ b/Utilities/cmcppdap/CMakeLists.txt @@ -33,5 +33,8 @@ if(WIN32) elseif(NOT APPLE) target_link_libraries(cmcppdap PRIVATE Threads::Threads) endif() +if(CMake_HAVE_CXX_ATOMIC_LIB) + target_link_libraries(cmcppdap PRIVATE atomic) +endif() install(FILES NOTICE DESTINATION ${CMAKE_DOC_DIR}/cmcppdap)