From: DongHun Kwak Date: Fri, 8 Oct 2021 00:21:03 +0000 (+0900) Subject: Imported Upstream version 3.21.2 X-Git-Tag: upstream/3.21.2^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a507a3358f8d68a68556804c0538424137824d93;p=platform%2Fupstream%2Fcmake.git Imported Upstream version 3.21.2 --- diff --git a/Help/command/cmake_path.rst b/Help/command/cmake_path.rst index 565a37b..454c860 100644 --- a/Help/command/cmake_path.rst +++ b/Help/command/cmake_path.rst @@ -69,8 +69,8 @@ Synopsis `Native Conversion`_ cmake_path(`NATIVE_PATH`_ [NORMALIZE] ) - cmake_path(`CONVERT`_ `TO_CMAKE_PATH_LIST`_ ) - cmake_path(`CONVERT`_ `TO_NATIVE_PATH_LIST`_ ) + cmake_path(`CONVERT`_ `TO_CMAKE_PATH_LIST`_ [NORMALIZE]) + cmake_path(`CONVERT`_ `TO_NATIVE_PATH_LIST`_ [NORMALIZE]) `Hashing`_ cmake_path(`HASH`_ ) diff --git a/Help/command/get_filename_component.rst b/Help/command/get_filename_component.rst index be9d00a..4bdd388 100644 --- a/Help/command/get_filename_component.rst +++ b/Help/command/get_filename_component.rst @@ -3,7 +3,7 @@ get_filename_component Get a specific component of a full filename. -.. versionchanged:: 3.19 +.. versionchanged:: 3.20 This command been superseded by :command:`cmake_path` command, except ``REALPATH`` now offered by :ref:`file(REAL_PATH) ` command and ``PROGRAM`` now available in :command:`separate_arguments(PROGRAM)` command. diff --git a/Help/cpack_gen/dmg.rst b/Help/cpack_gen/dmg.rst index 64e9769..1f05618 100644 --- a/Help/cpack_gen/dmg.rst +++ b/Help/cpack_gen/dmg.rst @@ -105,6 +105,8 @@ on macOS: .. variable:: CPACK_DMG_FILESYSTEM + .. versionadded:: 3.21 + The filesystem format. Common values are ``APFS`` and ``HFS+``. See ``man hdiutil`` for a full list of supported formats. Defaults to ``HFS+``. diff --git a/Help/generator/Visual Studio 17 2022.rst b/Help/generator/Visual Studio 17 2022.rst index 6007365..8b97b9f 100644 --- a/Help/generator/Visual Studio 17 2022.rst +++ b/Help/generator/Visual Studio 17 2022.rst @@ -7,7 +7,7 @@ Generates Visual Studio 17 (VS 2022) project files. .. warning:: - This is experimental and based on "Visual Studio 2022 Preview 2". + This is experimental and based on "Visual Studio 2022 Preview 3.1". As of this version of CMake, VS 2022 has not been released. Project Types @@ -51,7 +51,7 @@ name (architecture). For example: Toolset Selection ^^^^^^^^^^^^^^^^^ -The ``v143`` toolset that comes with VS 17 2022 Preview 2 is selected by +The ``v143`` toolset that comes with VS 17 2022 Preview 3.1 is selected by default. The :variable:`CMAKE_GENERATOR_TOOLSET` option may be set, perhaps via the :manual:`cmake(1)` ``-T`` option, to specify another toolset. diff --git a/Help/manual/cmake-presets.7.rst b/Help/manual/cmake-presets.7.rst index db26b5a..74e9fae 100644 --- a/Help/manual/cmake-presets.7.rst +++ b/Help/manual/cmake-presets.7.rst @@ -187,8 +187,9 @@ that may contain the following fields: An optional string representing the path to the toolchain file. This field supports `macro expansion`_. If a relative path is specified, it is calculated relative to the build directory, and if not found, - relative to the source directory. Takes precedence over any `CMAKE_TOOLCHAIN_FILE` - value. This is allowed in preset files specifying version ``3`` or above. + relative to the source directory. This field takes precedence over any + :variable:`CMAKE_TOOLCHAIN_FILE` value. It is allowed in preset files + specifying version ``3`` or above. ``binaryDir`` diff --git a/Help/release/3.21.rst b/Help/release/3.21.rst index 3e70552..a5125ac 100644 --- a/Help/release/3.21.rst +++ b/Help/release/3.21.rst @@ -27,7 +27,7 @@ Generators ---------- * The :generator:`Visual Studio 17 2022` generator was added. This is - experimental and based on "Visual Studio 2022 Preview 2" because this + experimental and based on "Visual Studio 2022 Preview 3.1" because this version of VS has not been released. * The :ref:`Makefile Generators` and the :generator:`Ninja` generator @@ -304,3 +304,12 @@ Changes made since CMake 3.21.0 include the following. * The :generator:`Visual Studio 17 2022` generator is now based on "Visual Studio 2022 Preview 2". Previously it was based on "Preview 1.1". + +3.21.2 +------ + +* ``CUDA`` targets with :prop_tgt:`CUDA_SEPARABLE_COMPILATION` enabled are now + correctly generated in non-root directories. + +* The :generator:`Visual Studio 17 2022` generator is now based on + "Visual Studio 2022 Preview 3.1". Previously it was based on "Preview 2". diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index f139ff4..bb97f4a 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -33,7 +33,7 @@ function(__resolve_tool_path CMAKE_TOOL SEARCH_PATH DOCSTRING) if(NOT _CMAKE_USER_TOOL_PATH) # Find CMAKE_TOOL in the SEARCH_PATH directory by user-defined name. - find_program(_CMAKE_TOOL_WITH_PATH NAMES ${${CMAKE_TOOL}} HINTS ${SEARCH_PATH}) + find_program(_CMAKE_TOOL_WITH_PATH NAMES ${${CMAKE_TOOL}} HINTS ${SEARCH_PATH} NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH) if(_CMAKE_TOOL_WITH_PATH) # Overwrite CMAKE_TOOL with full path found in SEARCH_PATH. @@ -165,9 +165,9 @@ else() # Prepend toolchain-specific names. if("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL Clang) if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC") - set(_CMAKE_LINKER_NAMES "lld-link") + list(PREPEND _CMAKE_LINKER_NAMES "lld-link") else() - set(_CMAKE_LINKER_NAMES "ld.lld") + list(PREPEND _CMAKE_LINKER_NAMES "ld.lld") endif() list(PREPEND _CMAKE_AR_NAMES "llvm-ar") list(PREPEND _CMAKE_RANLIB_NAMES "llvm-ranlib") @@ -202,7 +202,7 @@ foreach(_CMAKE_TOOL IN LISTS _CMAKE_TOOL_VARS) endforeach() list(REMOVE_DUPLICATES _CMAKE_${_CMAKE_TOOL}_FIND_NAMES) - find_program(CMAKE_${_CMAKE_TOOL} NAMES ${_CMAKE_${_CMAKE_TOOL}_FIND_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + find_program(CMAKE_${_CMAKE_TOOL} NAMES ${_CMAKE_${_CMAKE_TOOL}_FIND_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION} NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH) unset(_CMAKE_${_CMAKE_TOOL}_FIND_NAMES) endforeach() @@ -212,7 +212,7 @@ endif() if(CMAKE_PLATFORM_HAS_INSTALLNAME) - find_program(CMAKE_INSTALL_NAME_TOOL NAMES ${_CMAKE_TOOLCHAIN_PREFIX}install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + find_program(CMAKE_INSTALL_NAME_TOOL NAMES ${_CMAKE_TOOLCHAIN_PREFIX}install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION} NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH) if(NOT CMAKE_INSTALL_NAME_TOOL) message(FATAL_ERROR "Could not find install_name_tool, please check your installation.") diff --git a/Modules/CheckLanguage.cmake b/Modules/CheckLanguage.cmake index 928881c..559c103 100644 --- a/Modules/CheckLanguage.cmake +++ b/Modules/CheckLanguage.cmake @@ -36,6 +36,9 @@ Example: include_guard(GLOBAL) +cmake_policy(PUSH) +cmake_policy(SET CMP0126 NEW) + macro(check_language lang) if(NOT DEFINED CMAKE_${lang}_COMPILER) set(_desc "Looking for a ${lang} compiler") @@ -110,3 +113,5 @@ file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\" endif() endmacro() + +cmake_policy(POP) diff --git a/Modules/Compiler/Clang-FindBinUtils.cmake b/Modules/Compiler/Clang-FindBinUtils.cmake index e6c469a..125ae78 100644 --- a/Modules/Compiler/Clang-FindBinUtils.cmake +++ b/Modules/Compiler/Clang-FindBinUtils.cmake @@ -28,6 +28,7 @@ find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR NAMES "${_CMAKE_TOOLCHAIN_PREFIX}llvm-ar-${__version_x}" "${_CMAKE_TOOLCHAIN_PREFIX}llvm-ar" HINTS ${__clang_hints} + NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH DOC "LLVM archiver" ) mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR) @@ -38,6 +39,7 @@ find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB NAMES "${_CMAKE_TOOLCHAIN_PREFIX}llvm-ranlib-${__version_x}" "${_CMAKE_TOOLCHAIN_PREFIX}llvm-ranlib" HINTS ${__clang_hints} + NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH DOC "Generate index for LLVM archive" ) mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB) diff --git a/Modules/Compiler/GNU-FindBinUtils.cmake b/Modules/Compiler/GNU-FindBinUtils.cmake index 097fbf3..4dcdd53 100644 --- a/Modules/Compiler/GNU-FindBinUtils.cmake +++ b/Modules/Compiler/GNU-FindBinUtils.cmake @@ -20,6 +20,7 @@ find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR NAMES "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar-${__version_x}" "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar${_CMAKE_COMPILER_SUFFIX}" HINTS ${__gcc_hints} + NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH DOC "A wrapper around 'ar' adding the appropriate '--plugin' option for the GCC compiler" ) mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR) @@ -30,6 +31,7 @@ find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB NAMES "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib-${__version_x}" "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib${_CMAKE_COMPILER_SUFFIX}" HINTS ${__gcc_hints} + NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH DOC "A wrapper around 'ranlib' adding the appropriate '--plugin' option for the GCC compiler" ) mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB) diff --git a/Modules/Compiler/NVHPC-C.cmake b/Modules/Compiler/NVHPC-C.cmake index a734edf..e37aad5 100644 --- a/Modules/Compiler/NVHPC-C.cmake +++ b/Modules/Compiler/NVHPC-C.cmake @@ -4,9 +4,9 @@ include(Compiler/NVHPC) # Needed so that we support `LANGUAGE` property correctly set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c) -# Required since as of NVHPC 21.03 the `-MD` flag implicitly -# implies `-E` and therefore compilation and dependency generation -# can't occur in the same invocation -set(CMAKE_C_DEPENDS_EXTRA_COMMANDS " -x c -M -MT -MD") +if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 20.11) + set(CMAKE_C17_STANDARD_COMPILE_OPTION -std=c17) + set(CMAKE_C17_EXTENSION_COMPILE_OPTION -std=gnu17) +endif() __compiler_nvhpc(C) diff --git a/Modules/Compiler/NVHPC-CXX.cmake b/Modules/Compiler/NVHPC-CXX.cmake index 98d0022..534e822 100644 --- a/Modules/Compiler/NVHPC-CXX.cmake +++ b/Modules/Compiler/NVHPC-CXX.cmake @@ -4,9 +4,9 @@ include(Compiler/NVHPC) # Needed so that we support `LANGUAGE` property correctly set(CMAKE_CXX_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c++) -# Required since as of NVHPC 21.03 the `-MD` flag implicitly -# implies `-E` and therefore compilation and dependency generation -# can't occur in the same invocation -set(CMAKE_CXX_DEPENDS_EXTRA_COMMANDS " -x c++ -M -MT -MD") +if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 20.11) + set(CMAKE_CXX20_STANDARD_COMPILE_OPTION -std=c++20) + set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION -std=gnu++20) +endif() __compiler_nvhpc(CXX) diff --git a/Modules/Compiler/NVHPC.cmake b/Modules/Compiler/NVHPC.cmake index 7048670..a85df71 100644 --- a/Modules/Compiler/NVHPC.cmake +++ b/Modules/Compiler/NVHPC.cmake @@ -12,4 +12,16 @@ include(Compiler/PGI) macro(__compiler_nvhpc lang) # Logic specific to NVHPC. + + if(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 21.07) + set(CMAKE_DEPFILE_FLAGS_${lang} "-MD -MT -MF ") + set(CMAKE_${lang}_DEPFILE_FORMAT gcc) + set(CMAKE_${lang}_DEPENDS_USE_COMPILER TRUE) + else() + # Before NVHPC 21.07 the `-MD` flag implicitly + # implies `-E` and therefore compilation and dependency generation + # can't occur in the same invocation + set(CMAKE_${lang}_DEPENDS_EXTRA_COMMANDS " ${CMAKE_${lang}_COMPILE_OPTIONS_EXPLICIT_LANGUAGE} -M -MT -MD") + endif() + endmacro() diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index c48decb..d8f0334 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -624,7 +624,8 @@ function (_MPI_interrogate_compiler LANG) # we won't match the accompanying --param-ssp-size and -Wp,-D_FORTIFY_SOURCE flags and therefore # produce inconsistent results with the regularly flags. # Similarly, aliasing flags do not belong into our flag array. - if(NOT "${_MPI_COMPILE_OPTION}" MATCHES "^-f((no-|)(stack-protector|strict-aliasing)|PI[CE]|pi[ce])") + # Also strip out `-framework` flags. + if(NOT "${_MPI_COMPILE_OPTION}" MATCHES "^-f((no-|)(stack-protector|strict-aliasing)|PI[CE]|pi[ce]|ramework)") list(APPEND MPI_COMPILE_OPTIONS_WORK "${_MPI_COMPILE_OPTION}") endif() endforeach() diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 3bc9dba..01ad5ac 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -79,10 +79,18 @@ set(PKG_CONFIG_FOUND "${PKGCONFIG_FOUND}") # Unsets the given variables macro(_pkgconfig_unset var) + # Clear normal variable (possibly set by project code). + unset(${var}) + # Store as cache variable. + # FIXME: Add a policy to switch to a normal variable. set(${var} "" CACHE INTERNAL "") endmacro() macro(_pkgconfig_set var value) + # Clear normal variable (possibly set by project code). + unset(${var}) + # Store as cache variable. + # FIXME: Add a policy to switch to a normal variable. set(${var} ${value} CACHE INTERNAL "") endmacro() diff --git a/Modules/GNUInstallDirs.cmake b/Modules/GNUInstallDirs.cmake index d81033c..ead55ca 100644 --- a/Modules/GNUInstallDirs.cmake +++ b/Modules/GNUInstallDirs.cmake @@ -350,7 +350,7 @@ mark_as_advanced( macro(GNUInstallDirs_get_absolute_install_dir absvar var) set(GGAID_extra_args ${ARGN}) list(LENGTH GGAID_extra_args GGAID_extra_arg_count) - if(GGAID_extra_arg_count GREATER 0) + if(GGAID_extra_arg_count GREATER "0") list(GET GGAID_extra_args 0 GGAID_dir) else() # Historical behavior: use ${dir} from caller's scope diff --git a/Modules/Internal/CPack/CPackRPM.cmake b/Modules/Internal/CPack/CPackRPM.cmake index 47d2a5c..cbd748b 100644 --- a/Modules/Internal/CPack/CPackRPM.cmake +++ b/Modules/Internal/CPack/CPackRPM.cmake @@ -11,9 +11,7 @@ function(set_spec_script_if_enabled TYPE PACKAGE_NAME VAR) if(PACKAGE_NAME) set(PACKAGE_NAME " -n ${PACKAGE_NAME}") endif() - set(${TYPE}_ - "%${TYPE}${PACKAGE_NAME}\n" - "${VAR}\n" PARENT_SCOPE) + set(${TYPE}_ "%${TYPE}${PACKAGE_NAME}\n${VAR}\n" PARENT_SCOPE) else() set(${TYPE} "" PARENT_SCOPE) endif() diff --git a/Modules/Platform/Android-Determine.cmake b/Modules/Platform/Android-Determine.cmake index 2d2cd5c..7b67f83 100644 --- a/Modules/Platform/Android-Determine.cmake +++ b/Modules/Platform/Android-Determine.cmake @@ -267,7 +267,7 @@ endif() if(CMAKE_ANDROID_NDK) # Identify the host platform. if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") - if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64") + if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "64") set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "darwin-x86_64") else() set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "darwin-x86") diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index d9a7894..839dc81 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -47,7 +47,9 @@ set(CMAKE_SHARED_MODULE_PREFIX "lib") set(CMAKE_SHARED_MODULE_SUFFIX ".so") set(CMAKE_MODULE_EXISTS 1) set(CMAKE_DL_LIBS "") -set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") +if(NOT "${_CURRENT_OSX_VERSION}" VERSION_LESS "10.5") + set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") +endif() foreach(lang C CXX OBJC OBJCXX) set(CMAKE_${lang}_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ") diff --git a/Modules/Platform/Haiku.cmake b/Modules/Platform/Haiku.cmake index 7e0af61..b8e3ba6 100644 --- a/Modules/Platform/Haiku.cmake +++ b/Modules/Platform/Haiku.cmake @@ -1,8 +1,3 @@ -# process only once -if(HAIKU) - return() -endif() - set(HAIKU 1) set(UNIX 1) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 0142c07..9a18184 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -432,8 +432,6 @@ set(SRCS cmQtAutoMocUic.h cmQtAutoRcc.cxx cmQtAutoRcc.h - cmQtAutoUicHelpers.cxx - cmQtAutoUicHelpers.h cmRST.cxx cmRST.h cmRuntimeDependencyArchive.cxx diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 6a005be..7cc73cc 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 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 [==[f7cf69e34a CMake 3.21.1]==]) + set(git_info [==[31c5700d43 CMake 3.21.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/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx index cc756d7..48cc0e4 100644 --- a/Source/CTest/cmCTestGenericHandler.cxx +++ b/Source/CTest/cmCTestGenericHandler.cxx @@ -68,10 +68,8 @@ void cmCTestGenericHandler::Initialize() { this->AppendXML = false; this->TestLoad = 0; - this->Options.clear(); - for (auto const& po : this->PersistentOptions) { - this->Options[po.first] = po.second; - } + this->Options = this->PersistentOptions; + this->MultiOptions = this->PersistentMultiOptions; } const char* cmCTestGenericHandler::GetOption(const std::string& op) diff --git a/Source/cmCMakePresetsFile.cxx b/Source/cmCMakePresetsFile.cxx index fd578fa..538b668 100644 --- a/Source/cmCMakePresetsFile.cxx +++ b/Source/cmCMakePresetsFile.cxx @@ -78,7 +78,8 @@ void InheritVector(std::vector& child, const std::vector& parent) template ReadFileResult VisitPreset( T& preset, std::map>& presets, - std::map cycleStatus, int version) + std::map cycleStatus, + const cmCMakePresetsFile& file) { switch (cycleStatus[preset.Name]) { case CycleStatus::InProgress: @@ -108,7 +109,7 @@ ReadFileResult VisitPreset( return ReadFileResult::USER_PRESET_INHERITANCE; } - auto result = VisitPreset(parentPreset, presets, cycleStatus, version); + auto result = VisitPreset(parentPreset, presets, cycleStatus, file); if (result != ReadFileResult::READ_OK) { return result; } @@ -128,7 +129,7 @@ ReadFileResult VisitPreset( preset.ConditionEvaluator.reset(); } - CHECK_OK(preset.VisitPresetAfterInherit(version)) + CHECK_OK(preset.VisitPresetAfterInherit(file.GetVersion(preset))) cycleStatus[preset.Name] = CycleStatus::Verified; return ReadFileResult::READ_OK; @@ -146,8 +147,7 @@ ReadFileResult ComputePresetInheritance( for (auto& it : presets) { auto& preset = it.second.Unexpanded; - auto result = - VisitPreset(preset, presets, cycleStatus, file.GetVersion(preset)); + auto result = VisitPreset(preset, presets, cycleStatus, file); if (result != ReadFileResult::READ_OK) { return result; } diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index 79c06d6..d0ad53e 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -618,6 +618,9 @@ cmGlobalVisualStudioVersionedGenerator::FindAuxToolset( if (version == "14.29.16.10" && vcToolsetVersion == "14.29.30037") { return AuxToolset::Default; } + if (version == "14.29.16.11" && vcToolsetVersion == "14.29.30133") { + return AuxToolset::Default; + } // The first two components of the default toolset version typically // match the name used by later VS versions for the SxS props files. diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 6d8376c..a3e5553 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -324,9 +324,25 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() this->LocalGenerator->MaybeRelativeToTopBinDir(dependFileNameFull)) << "\n"; + // Scan any custom commands to check if DEPFILE option is specified + bool ccGenerateDeps = false; + std::vector customCommands; + this->GeneratorTarget->GetCustomCommands(customCommands, + this->GetConfigName()); + for (cmSourceFile const* sf : customCommands) { + if (!sf->GetCustomCommand()->GetDepfile().empty()) { + ccGenerateDeps = true; + break; + } + } + std::string depsUseCompiler = "CMAKE_DEPENDS_USE_COMPILER"; - if (!this->Makefile->IsDefinitionSet(depsUseCompiler) || - this->Makefile->IsOn(depsUseCompiler)) { + bool compilerGenerateDeps = + this->GlobalGenerator->SupportsCompilerDependencies() && + (!this->Makefile->IsDefinitionSet(depsUseCompiler) || + this->Makefile->IsOn(depsUseCompiler)); + + if (compilerGenerateDeps || ccGenerateDeps) { std::string compilerDependFile = cmStrCat(this->TargetBuildDirectoryFull, "/compiler_depend.make"); *this->BuildFileStream << "# Include any dependencies generated by the " @@ -361,7 +377,9 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() "management for " << this->GeneratorTarget->GetName() << ".\n"; } + } + if (compilerGenerateDeps) { // deactivate no longer needed legacy dependency files // Write an empty dependency file. cmGeneratedFileStream legacyDepFileStream( @@ -1484,14 +1502,18 @@ void cmMakefileTargetGenerator::WriteDeviceLinkRule( } std::vector architectures = cmExpandedList(architecturesStr); + std::string const& relPath = + this->LocalGenerator->GetHomeRelativeOutputPath(); // Ensure there are no duplicates. const std::vector linkDeps = [&]() -> std::vector { std::vector deps; this->AppendTargetDepends(deps, true); this->GeneratorTarget->GetLinkDepends(deps, this->GetConfigName(), "CUDA"); - std::copy(this->Objects.begin(), this->Objects.end(), - std::back_inserter(deps)); + + for (std::string const& obj : this->Objects) { + deps.emplace_back(cmStrCat(relPath, obj)); + } std::unordered_set depsSet(deps.begin(), deps.end()); deps.clear(); @@ -1510,33 +1532,34 @@ void cmMakefileTargetGenerator::WriteDeviceLinkRule( std::string profiles; std::vector fatbinaryDepends; - std::string registerFile = cmStrCat(objectDir, "cmake_cuda_register.h"); + std::string const registerFile = + cmStrCat(objectDir, "cmake_cuda_register.h"); // Link device code for each architecture. for (const std::string& architectureKind : architectures) { - // Clang always generates real code, so strip the specifier. - const std::string architecture = - architectureKind.substr(0, architectureKind.find('-')); - const std::string cubin = - cmStrCat(relObjectDir, "sm_", architecture, ".cubin"); - - profiles += cmStrCat(" -im=profile=sm_", architecture, ",file=", cubin); - fatbinaryDepends.emplace_back(cubin); - std::string registerFileCmd; // The generated register file contains macros that when expanded // register the device routines. Because the routines are the same for // all architectures the register file will be the same too. Thus // generate it only on the first invocation to reduce overhead. - if (fatbinaryDepends.size() == 1) { - std::string registerFileRel = - this->LocalGenerator->MaybeRelativeToCurBinDir(registerFile); + if (fatbinaryDepends.empty()) { + std::string const registerFileRel = + cmStrCat(relPath, relObjectDir, "cmake_cuda_register.h"); registerFileCmd = cmStrCat(" --register-link-binaries=", registerFileRel); cleanFiles.push_back(registerFileRel); } + // Clang always generates real code, so strip the specifier. + const std::string architecture = + architectureKind.substr(0, architectureKind.find('-')); + const std::string cubin = + cmStrCat(objectDir, "sm_", architecture, ".cubin"); + + profiles += cmStrCat(" -im=profile=sm_", architecture, ",file=", cubin); + fatbinaryDepends.emplace_back(cubin); + std::string command = cmStrCat( this->Makefile->GetRequiredDefinition("CMAKE_CUDA_DEVICE_LINKER"), " -arch=sm_", architecture, registerFileCmd, " -o=$@ ", @@ -1555,7 +1578,7 @@ void cmMakefileTargetGenerator::WriteDeviceLinkRule( const std::string fatbinaryOutput = cmStrCat(objectDir, "cmake_cuda_fatbin.h"); const std::string fatbinaryOutputRel = - this->LocalGenerator->MaybeRelativeToCurBinDir(fatbinaryOutput); + cmStrCat(relPath, relObjectDir, "cmake_cuda_fatbin.h"); this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr, fatbinaryOutputRel, fatbinaryDepends, @@ -1583,9 +1606,8 @@ void cmMakefileTargetGenerator::WriteDeviceLinkRule( compileCmd, vars); commands.emplace_back(compileCmd); - this->LocalGenerator->WriteMakeRule( - *this->BuildFileStream, nullptr, output, - { cmStrCat(relObjectDir, "cmake_cuda_fatbin.h") }, commands, false); + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr, output, + { fatbinaryOutputRel }, commands, false); // Clean all the possible executable names and symlinks. this->CleanFiles.insert(cleanFiles.begin(), cleanFiles.end()); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 5a4c652..5c21d1b 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -753,10 +753,6 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatements( const std::string cubin = cmStrCat(ninjaOutputDir, "/sm_", architecture, ".cubin"); - fatbinary.Variables["PROFILES"] += - cmStrCat(" -im=profile=sm_", architecture, ",file=", cubin); - fatbinary.ExplicitDeps.emplace_back(cubin); - cmNinjaBuild dlink(this->LanguageLinkerCudaDeviceRule(config)); dlink.ExplicitDeps = explicitDeps; dlink.Outputs = { cubin }; @@ -766,11 +762,15 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatements( // the device routines. Because the routines are the same for all // architectures the register file will be the same too. Thus generate it // only on the first invocation to reduce overhead. - if (fatbinary.ExplicitDeps.size() == 1) { + if (fatbinary.ExplicitDeps.empty()) { dlink.Variables["REGISTER"] = cmStrCat( "--register-link-binaries=", ninjaOutputDir, "/cmake_cuda_register.h"); } + fatbinary.Variables["PROFILES"] += + cmStrCat(" -im=profile=sm_", architecture, ",file=", cubin); + fatbinary.ExplicitDeps.emplace_back(cubin); + this->GetGlobalGenerator()->WriteBuild(this->GetCommonFileStream(), dlink); } @@ -1156,7 +1156,10 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement( this->AddModuleDefinitionFlag(linkLineComputer.get(), vars["LINK_FLAGS"], config); - if (gt->GetPropertyAsBool("LINK_WHAT_YOU_USE")) { + if (gt->GetPropertyAsBool("LINK_WHAT_YOU_USE") && + (gt->GetType() == cmStateEnums::TargetType::EXECUTABLE || + gt->GetType() == cmStateEnums::TargetType::SHARED_LIBRARY || + gt->GetType() == cmStateEnums::TargetType::MODULE_LIBRARY)) { vars["LINK_FLAGS"] += " -Wl,--no-as-needed"; } vars["LINK_FLAGS"] = globalGen->EncodeLiteral(vars["LINK_FLAGS"]); diff --git a/Source/cmQtAutoGen.cxx b/Source/cmQtAutoGen.cxx index 898d862..57fcd2d 100644 --- a/Source/cmQtAutoGen.cxx +++ b/Source/cmQtAutoGen.cxx @@ -384,39 +384,3 @@ bool cmQtAutoGen::RccLister::list(std::string const& qrcFile, } return true; } - -bool cmQtAutoGen::FileRead(std::string& content, std::string const& filename, - std::string* error) -{ - content.clear(); - if (!cmSystemTools::FileExists(filename, true)) { - if (error != nullptr) { - *error = "Not a file."; - } - return false; - } - - unsigned long const length = cmSystemTools::FileLength(filename); - cmsys::ifstream ifs(filename.c_str(), (std::ios::in | std::ios::binary)); - - // Use lambda to save destructor calls of ifs - return [&ifs, length, &content, error]() -> bool { - if (!ifs) { - if (error != nullptr) { - *error = "Opening the file for reading failed."; - } - return false; - } - content.reserve(length); - using IsIt = std::istreambuf_iterator; - content.assign(IsIt{ ifs }, IsIt{}); - if (!ifs) { - content.clear(); - if (error != nullptr) { - *error = "Reading from the file failed."; - } - return false; - } - return true; - }(); -} diff --git a/Source/cmQtAutoGen.h b/Source/cmQtAutoGen.h index b9ae360..466a954 100644 --- a/Source/cmQtAutoGen.h +++ b/Source/cmQtAutoGen.h @@ -100,9 +100,6 @@ public: std::vector const& newOpts, bool isQt5); - static bool FileRead(std::string& content, std::string const& filename, - std::string* error = nullptr); - /** @class RccLister * @brief Lists files in qrc resource files */ diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 6cc8328..4dd78e5 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -902,13 +902,6 @@ bool cmQtAutoGenInitializer::InitScanFiles() // The reason is that their file names might be discovered from source files // at generation time. if (this->MocOrUicEnabled()) { - std::set uicIncludes; - auto collectUicIncludes = [&](std::unique_ptr const& sf) { - std::string content; - FileRead(content, sf->GetFullPath()); - this->AutoUicHelpers.CollectUicIncludes(uicIncludes, content); - }; - for (const auto& sf : this->Makefile->GetSourceFiles()) { // sf->GetExtension() is only valid after sf->ResolveFullPath() ... // Since we're iterating over source files that might be not in the @@ -921,10 +914,6 @@ bool cmQtAutoGenInitializer::InitScanFiles() std::string const& extLower = cmSystemTools::LowerCase(sf->GetExtension()); - bool const skipAutogen = sf->GetPropertyAsBool(kw.SKIP_AUTOGEN); - bool const skipUic = - (skipAutogen || sf->GetPropertyAsBool(kw.SKIP_AUTOUIC) || - !this->Uic.Enabled); if (cm->IsAHeaderExtension(extLower)) { if (!cm::contains(this->AutogenTarget.Headers, sf.get())) { auto muf = makeMUFile(sf.get(), fullPath, {}, false); @@ -932,9 +921,6 @@ bool cmQtAutoGenInitializer::InitScanFiles() addMUHeader(std::move(muf), extLower); } } - if (!skipUic && !sf->GetIsGenerated()) { - collectUicIncludes(sf); - } } else if (cm->IsACLikeSourceExtension(extLower)) { if (!cm::contains(this->AutogenTarget.Sources, sf.get())) { auto muf = makeMUFile(sf.get(), fullPath, {}, false); @@ -942,11 +928,11 @@ bool cmQtAutoGenInitializer::InitScanFiles() addMUSource(std::move(muf)); } } - if (!skipUic && !sf->GetIsGenerated()) { - collectUicIncludes(sf); - } } else if (this->Uic.Enabled && (extLower == kw.ui)) { // .ui file + bool const skipAutogen = sf->GetPropertyAsBool(kw.SKIP_AUTOGEN); + bool const skipUic = + (skipAutogen || sf->GetPropertyAsBool(kw.SKIP_AUTOUIC)); if (!skipUic) { // Check if the .ui file has uic options std::string const uicOpts = sf->GetSafeProperty(kw.AUTOUIC_OPTIONS); @@ -956,22 +942,35 @@ bool cmQtAutoGenInitializer::InitScanFiles() this->Uic.UiFilesWithOptions.emplace_back(fullPath, cmExpandedList(uicOpts)); } + + auto uiHeaderRelativePath = cmSystemTools::RelativePath( + this->LocalGen->GetCurrentSourceDirectory(), + cmSystemTools::GetFilenamePath(fullPath)); + + // Avoid creating a path containing adjacent slashes + if (!uiHeaderRelativePath.empty() && + uiHeaderRelativePath.back() != '/') { + uiHeaderRelativePath += '/'; + } + + auto uiHeaderFilePath = cmStrCat( + '/', uiHeaderRelativePath, "ui_"_s, + cmSystemTools::GetFilenameWithoutLastExtension(fullPath), ".h"_s); + + ConfigString uiHeader; + std::string uiHeaderGenex; + this->ConfigFileNamesAndGenex( + uiHeader, uiHeaderGenex, cmStrCat(this->Dir.Build, "/include"_s), + uiHeaderFilePath); + + this->Uic.UiHeaders.emplace_back( + std::make_pair(uiHeader, uiHeaderGenex)); } else { // Register skipped .ui file this->Uic.SkipUi.insert(fullPath); } } } - - for (const auto& include : uicIncludes) { - ConfigString uiHeader; - std::string uiHeaderGenex; - this->ConfigFileNamesAndGenex(uiHeader, uiHeaderGenex, - cmStrCat(this->Dir.Build, "/include"_s), - cmStrCat("/"_s, include)); - this->Uic.UiHeaders.emplace_back( - std::make_pair(uiHeader, uiHeaderGenex)); - } } // Process GENERATED sources and headers diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h index 3ec87d2..e76817b 100644 --- a/Source/cmQtAutoGenInitializer.h +++ b/Source/cmQtAutoGenInitializer.h @@ -17,7 +17,6 @@ #include "cmFilePathChecksum.h" #include "cmQtAutoGen.h" -#include "cmQtAutoUicHelpers.h" class cmGeneratorTarget; class cmGlobalGenerator; @@ -171,7 +170,6 @@ private: std::string ConfigDefault; std::vector ConfigsList; std::string TargetsFolder; - cmQtAutoUicHelpers AutoUicHelpers; /** Common directories. */ struct diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx index 0c6b5e6..568926e 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -121,6 +121,43 @@ bool cmQtAutoGenerator::MakeParentDirectory(std::string const& filename) return success; } +bool cmQtAutoGenerator::FileRead(std::string& content, + std::string const& filename, + std::string* error) +{ + content.clear(); + if (!cmSystemTools::FileExists(filename, true)) { + if (error != nullptr) { + *error = "Not a file."; + } + return false; + } + + unsigned long const length = cmSystemTools::FileLength(filename); + cmsys::ifstream ifs(filename.c_str(), (std::ios::in | std::ios::binary)); + + // Use lambda to save destructor calls of ifs + return [&ifs, length, &content, error]() -> bool { + if (!ifs) { + if (error != nullptr) { + *error = "Opening the file for reading failed."; + } + return false; + } + content.reserve(length); + using IsIt = std::istreambuf_iterator; + content.assign(IsIt{ ifs }, IsIt{}); + if (!ifs) { + content.clear(); + if (error != nullptr) { + *error = "Reading from the file failed."; + } + return false; + } + return true; + }(); +} + bool cmQtAutoGenerator::FileWrite(std::string const& filename, std::string const& content, std::string* error) diff --git a/Source/cmQtAutoGenerator.h b/Source/cmQtAutoGenerator.h index 66399d7..5c3a8ad 100644 --- a/Source/cmQtAutoGenerator.h +++ b/Source/cmQtAutoGenerator.h @@ -70,6 +70,8 @@ public: // -- File system methods static bool MakeParentDirectory(std::string const& filename); + static bool FileRead(std::string& content, std::string const& filename, + std::string* error = nullptr); static bool FileWrite(std::string const& filename, std::string const& content, std::string* error = nullptr); diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 86d54f9..2753fd5 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -30,7 +30,6 @@ #include "cmGeneratedFileStream.h" #include "cmQtAutoGen.h" #include "cmQtAutoGenerator.h" -#include "cmQtAutoUicHelpers.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmWorkerPool.h" @@ -282,7 +281,7 @@ public: std::vector Options; std::unordered_map UiFiles; std::vector SearchPaths; - cmQtAutoUicHelpers AutoUicHelpers; + cmsys::RegularExpression RegExpInclude; }; /** Uic shared variables. */ @@ -762,7 +761,11 @@ std::string cmQtAutoMocUicT::MocSettingsT::MacrosString() const return res; } -cmQtAutoMocUicT::UicSettingsT::UicSettingsT() = default; +cmQtAutoMocUicT::UicSettingsT::UicSettingsT() +{ + this->RegExpInclude.compile("(^|\n)[ \t]*#[ \t]*include[ \t]+" + "[\"<](([^ \">]+/)?ui_[^ \">/]+\\.h)[\">]"); +} cmQtAutoMocUicT::UicSettingsT::~UicSettingsT() = default; @@ -1053,7 +1056,16 @@ void cmQtAutoMocUicT::JobParseT::UicIncludes() } std::set includes; - this->UicConst().AutoUicHelpers.CollectUicIncludes(includes, this->Content); + { + const char* contentChars = this->Content.c_str(); + cmsys::RegularExpression const& regExp = this->UicConst().RegExpInclude; + cmsys::RegularExpressionMatch match; + while (regExp.find(contentChars, match)) { + includes.emplace(match.match(2)); + // Forward content pointer + contentChars += match.end(); + } + } this->CreateKeys(this->FileHandle->ParseData->Uic.Include, includes, UiUnderscoreLength); } diff --git a/Source/cmQtAutoUicHelpers.cxx b/Source/cmQtAutoUicHelpers.cxx deleted file mode 100644 index 751ae08..0000000 --- a/Source/cmQtAutoUicHelpers.cxx +++ /dev/null @@ -1,25 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmQtAutoUicHelpers.h" - -cmQtAutoUicHelpers::cmQtAutoUicHelpers() -{ - RegExpInclude.compile("(^|\n)[ \t]*#[ \t]*include[ \t]+" - "[\"<](([^ \">]+/)?ui_[^ \">/]+\\.h)[\">]"); -} - -void cmQtAutoUicHelpers::CollectUicIncludes(std::set& includes, - const std::string& content) const -{ - if (content.find("ui_") == std::string::npos) { - return; - } - - const char* contentChars = content.c_str(); - cmsys::RegularExpressionMatch match; - while (this->RegExpInclude.find(contentChars, match)) { - includes.emplace(match.match(2)); - // Forward content pointer - contentChars += match.end(); - } -} diff --git a/Source/cmQtAutoUicHelpers.h b/Source/cmQtAutoUicHelpers.h deleted file mode 100644 index 6b09a31..0000000 --- a/Source/cmQtAutoUicHelpers.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#pragma once - -#include -#include - -#include "cmsys/RegularExpression.hxx" - -class cmQtAutoUicHelpers -{ -public: - cmQtAutoUicHelpers(); - virtual ~cmQtAutoUicHelpers() = default; - void CollectUicIncludes(std::set& includes, - const std::string& content) const; - -private: - cmsys::RegularExpression RegExpInclude; -}; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 11a8b1f..bda2f91 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -4093,6 +4093,9 @@ void cmVisualStudio10TargetGenerator::WriteMidlOptions( if (this->ProjectType == csproj) { return; } + if (this->GeneratorTarget->GetType() > cmStateEnums::UTILITY) { + return; + } // This processes *any* of the .idl files specified in the project's file // list (and passed as the item metadata %(Filename) expressing the rule diff --git a/Templates/MSBuild/FlagTables/v142_CL.json b/Templates/MSBuild/FlagTables/v142_CL.json index 64eeac4..4c65ad9 100644 --- a/Templates/MSBuild/FlagTables/v142_CL.json +++ b/Templates/MSBuild/FlagTables/v142_CL.json @@ -1214,7 +1214,7 @@ "comment": "Additional Module Dependencies", "value": "", "flags": [ - "UserValue", + "UserFollowing", "SemicolonAppendable" ] }, @@ -1224,7 +1224,7 @@ "comment": "Additional Header Unit Dependencies", "value": "", "flags": [ - "UserValue", + "UserFollowing", "SemicolonAppendable" ] }, diff --git a/Templates/MSBuild/FlagTables/v143_CL.json b/Templates/MSBuild/FlagTables/v143_CL.json index 8b700aa..96f74b1 100644 --- a/Templates/MSBuild/FlagTables/v143_CL.json +++ b/Templates/MSBuild/FlagTables/v143_CL.json @@ -1214,7 +1214,7 @@ "comment": "Additional Module Dependencies", "value": "", "flags": [ - "UserValue", + "UserFollowing", "SemicolonAppendable" ] }, @@ -1224,7 +1224,7 @@ "comment": "Additional Header Unit Dependencies", "value": "", "flags": [ - "UserValue", + "UserFollowing", "SemicolonAppendable" ] }, diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt index fdb7a6e..a3fb409 100644 --- a/Tests/CudaOnly/CMakeLists.txt +++ b/Tests/CudaOnly/CMakeLists.txt @@ -15,7 +15,7 @@ add_cuda_test_macro(CudaOnly.ToolkitBeforeLang CudaOnlyToolkitBeforeLang) add_cuda_test_macro(CudaOnly.WithDefs CudaOnlyWithDefs) add_cuda_test_macro(CudaOnly.CircularLinkLine CudaOnlyCircularLinkLine) add_cuda_test_macro(CudaOnly.ResolveDeviceSymbols CudaOnlyResolveDeviceSymbols) -add_cuda_test_macro(CudaOnly.SeparateCompilation CudaOnlySeparateCompilation) +add_cuda_test_macro(CudaOnly.SeparateCompilation main/CudaOnlySeparateCompilation) if(CMake_TEST_CUDA AND NOT CMake_TEST_CUDA STREQUAL "Clang") # Clang doesn't have flags for selecting the runtime. diff --git a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt index 864ecbf..17069e3 100644 --- a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt +++ b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt @@ -34,26 +34,9 @@ add_library(CUDASeparateLibB STATIC file4.cu file5.cu) target_compile_features(CUDASeparateLibB PRIVATE cuda_std_11) target_link_libraries(CUDASeparateLibB PRIVATE CUDASeparateLibA) -add_executable(CudaOnlySeparateCompilation main.cu) -target_link_libraries(CudaOnlySeparateCompilation - PRIVATE CUDASeparateLibB) -set_target_properties(CudaOnlySeparateCompilation PROPERTIES CUDA_STANDARD 11) -set_target_properties(CudaOnlySeparateCompilation PROPERTIES CUDA_STANDARD_REQUIRED TRUE) - set_target_properties(CUDASeparateLibA CUDASeparateLibB PROPERTIES CUDA_SEPARABLE_COMPILATION ON POSITION_INDEPENDENT_CODE ON) -if (CMAKE_GENERATOR MATCHES "^Visual Studio") - #Visual Studio CUDA integration will not perform device linking - #on a target that itself does not have GenerateRelocatableDeviceCode - #enabled. - set_target_properties(CudaOnlySeparateCompilation - PROPERTIES CUDA_SEPARABLE_COMPILATION ON) -endif() - -if(APPLE) - # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. - set_property(TARGET CudaOnlySeparateCompilation PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) -endif() +add_subdirectory(main) diff --git a/Tests/CudaOnly/SeparateCompilation/main/CMakeLists.txt b/Tests/CudaOnly/SeparateCompilation/main/CMakeLists.txt new file mode 100644 index 0000000..c181078 --- /dev/null +++ b/Tests/CudaOnly/SeparateCompilation/main/CMakeLists.txt @@ -0,0 +1,18 @@ +add_executable(CudaOnlySeparateCompilation main.cu) +target_link_libraries(CudaOnlySeparateCompilation PRIVATE CUDASeparateLibB) +set_target_properties(CudaOnlySeparateCompilation PROPERTIES + CUDA_STANDARD 11 + CUDA_STANDARD_REQUIRED TRUE +) + +if(CMAKE_GENERATOR MATCHES "^Visual Studio") + # Visual Studio CUDA integration will not perform device linking + # on a target that itself does not have GenerateRelocatableDeviceCode + # enabled. + set_property(TARGET CudaOnlySeparateCompilation PROPERTY CUDA_SEPARABLE_COMPILATION ON) +endif() + +if(APPLE) + # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. + set_property(TARGET CudaOnlySeparateCompilation PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) +endif() diff --git a/Tests/CudaOnly/SeparateCompilation/main.cu b/Tests/CudaOnly/SeparateCompilation/main/main.cu similarity index 97% rename from Tests/CudaOnly/SeparateCompilation/main.cu rename to Tests/CudaOnly/SeparateCompilation/main/main.cu index 40dbe5d..2b6e8f4 100644 --- a/Tests/CudaOnly/SeparateCompilation/main.cu +++ b/Tests/CudaOnly/SeparateCompilation/main/main.cu @@ -1,8 +1,8 @@ #include -#include "file1.h" -#include "file2.h" +#include "../file1.h" +#include "../file2.h" int file4_launch_kernel(int x); int file5_launch_kernel(int x); diff --git a/Tests/QtAutogen/RerunUicOnFileChange/CMakeLists.txt b/Tests/QtAutogen/RerunUicOnFileChange/CMakeLists.txt index a9ccece..9b114e9 100644 --- a/Tests/QtAutogen/RerunUicOnFileChange/CMakeLists.txt +++ b/Tests/QtAutogen/RerunUicOnFileChange/CMakeLists.txt @@ -26,13 +26,12 @@ macro(rebuild buildName) endmacro() configure_file("${testProjectTemplateDir}/mocwidget.h" "${testProjectSrc}/mocwidget.h" COPYONLY) +configure_file("${testProjectTemplateDir}/mainwindow.h" "${testProjectSrc}/mainwindow.h" COPYONLY) configure_file("${testProjectTemplateDir}/main.cpp" "${testProjectSrc}/main.cpp" COPYONLY) -configure_file("${testProjectTemplateDir}/subdir/subdircheck.cpp" "${testProjectSrc}/subdir/subdircheck.cpp" COPYONLY) configure_file("${testProjectTemplateDir}/CMakeLists.txt.in" "${testProjectSrc}/CMakeLists.txt" @ONLY) set(Num 1) configure_file("${testProjectTemplateDir}/mainwindow.ui.in" "${testProjectSrc}/mainwindow.ui" @ONLY) -configure_file("${testProjectTemplateDir}/subdir/mainwindowsubdir.ui.in" "${testProjectSrc}/subdir/mainwindowsubdir.ui" @ONLY) if(CMAKE_GENERATOR_INSTANCE) set(_D_CMAKE_GENERATOR_INSTANCE "-DCMAKE_GENERATOR_INSTANCE=${CMAKE_GENERATOR_INSTANCE}") @@ -96,10 +95,21 @@ sleep() set(Num 2) configure_file("${testProjectTemplateDir}/mainwindow.ui.in" "${testProjectSrc}/mainwindow.ui" @ONLY) -configure_file("${testProjectTemplateDir}/subdir/mainwindowsubdir.ui.in" "${testProjectSrc}/subdir/mainwindowsubdir.ui" @ONLY) rebuild(2) execute_process(COMMAND "${testProjectBinDir}/${extra_bin_path}UicOnFileChange" RESULT_VARIABLE result) if(NOT result EQUAL "0") message(FATAL_ERROR "Rebuild of UicOnFileChange test result is: ${result}") endif() + +# Check if the generated ui_mainwindow.h rules introduce circular dependency between the generated +# ui_mainwinow.h and timestamp. +# +# The first rebuild updates a timestamp dependency file after "touching" mainwindow.h. +sleep() +execute_process(COMMAND ${CMAKE_COMMAND} -E touch "${testProjectSrc}/mainwindow.h") +rebuild(3) + +# The second rebuild detects if cycling dependency is introduced by deps file. +sleep() +rebuild(4) diff --git a/Tests/QtAutogen/RerunUicOnFileChange/UicOnFileChange/CMakeLists.txt.in b/Tests/QtAutogen/RerunUicOnFileChange/UicOnFileChange/CMakeLists.txt.in index 2a1998d..c787db1 100644 --- a/Tests/QtAutogen/RerunUicOnFileChange/UicOnFileChange/CMakeLists.txt.in +++ b/Tests/QtAutogen/RerunUicOnFileChange/UicOnFileChange/CMakeLists.txt.in @@ -5,9 +5,12 @@ include("@CMAKE_CURRENT_LIST_DIR@/../AutogenGuiTest.cmake") # Enable CMAKE_AUTOUIC for all targets set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) -add_executable(UicOnFileChange main.cpp mainwindow.ui - subdir/subdircheck.cpp subdir/mainwindowsubdir.ui +add_executable(UicOnFileChange main.cpp mainwindow.ui mainwindow.h +) +target_include_directories(UicOnFileChange PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_CURRENT_BINARY_DIR}/UicOnFileChange_autogen/include" ) -target_include_directories(UicOnFileChange PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(UicOnFileChange ${QT_QTCORE_TARGET} ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/RerunUicOnFileChange/UicOnFileChange/main.cpp b/Tests/QtAutogen/RerunUicOnFileChange/UicOnFileChange/main.cpp index 3981268..4aab2ad 100644 --- a/Tests/QtAutogen/RerunUicOnFileChange/UicOnFileChange/main.cpp +++ b/Tests/QtAutogen/RerunUicOnFileChange/UicOnFileChange/main.cpp @@ -1,11 +1,10 @@ +#include "mainwindow.h" #include "ui_mainwindow.h" -extern bool subdircheck(); - int main(int argc, char* argv[]) { MocWidget mw; Ui::Widget mwUi; mwUi.setupUi(&mw); - return mw.objectName() == "Widget2" && subdircheck() ? 0 : 1; + return mw.objectName() == "Widget2" ? 0 : 1; } diff --git a/Tests/QtAutogen/RerunUicOnFileChange/UicOnFileChange/mainwindow.h b/Tests/QtAutogen/RerunUicOnFileChange/UicOnFileChange/mainwindow.h new file mode 100644 index 0000000..24621ff --- /dev/null +++ b/Tests/QtAutogen/RerunUicOnFileChange/UicOnFileChange/mainwindow.h @@ -0,0 +1,13 @@ +#include + +#include "ui_mainwindow.h" + +class MainWindow : public QObject +{ + Q_OBJECT +public: + MainWindow() { mwUi.setupUi(&mw); } + + MocWidget mw; + Ui::Widget mwUi; +}; diff --git a/Tests/QtAutogen/RerunUicOnFileChange/UicOnFileChange/subdir/mainwindowsubdir.ui.in b/Tests/QtAutogen/RerunUicOnFileChange/UicOnFileChange/subdir/mainwindowsubdir.ui.in deleted file mode 100644 index a6a31f6..0000000 --- a/Tests/QtAutogen/RerunUicOnFileChange/UicOnFileChange/subdir/mainwindowsubdir.ui.in +++ /dev/null @@ -1,7 +0,0 @@ - - - WidgetSubdir - - - - diff --git a/Tests/QtAutogen/RerunUicOnFileChange/UicOnFileChange/subdir/subdircheck.cpp b/Tests/QtAutogen/RerunUicOnFileChange/UicOnFileChange/subdir/subdircheck.cpp deleted file mode 100644 index 3b36a10..0000000 --- a/Tests/QtAutogen/RerunUicOnFileChange/UicOnFileChange/subdir/subdircheck.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "ui_mainwindowsubdir.h" - -bool subdircheck() -{ - MocWidget mw; - Ui::WidgetSubdir mwUi; - mwUi.setupUi(&mw); - return mw.objectName() == "WidgetSubdir2"; -} diff --git a/Tests/RunCMake/BuildDepends/CustomCommandDependencies-compiler-deps-legacy.cmake b/Tests/RunCMake/BuildDepends/CustomCommandDependencies-compiler-deps-legacy.cmake new file mode 100644 index 0000000..e13efb3 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/CustomCommandDependencies-compiler-deps-legacy.cmake @@ -0,0 +1,9 @@ +enable_language(C) + +add_custom_command(OUTPUT main.c + DEPFILE main.c.d + COMMAND "${CMAKE_COMMAND}" -DINFILE=${CMAKE_CURRENT_SOURCE_DIR}/main.c -DOUTFILE=main.c -DDEPFILE=main.c.d + -P "${CMAKE_CURRENT_SOURCE_DIR}/GenerateDepFile.cmake" + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + +add_executable(main ${CMAKE_CURRENT_BINARY_DIR}/main.c) diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake index f8c20c2..27bbff6 100644 --- a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake +++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake @@ -170,6 +170,10 @@ endif() if (RunCMake_GENERATOR MATCHES "Makefiles") run_cmake(CustomCommandDependencies-BadArgs) + run_cmake_with_options(CustomCommandDependencies-compiler-deps-legacy -DCMAKE_DEPENDS_USE_COMPILER=FALSE) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(CustomCommandDependencies-compiler-deps-legacy ${CMAKE_COMMAND} --build . --config Debug) + unset(RunCMake_TEST_NO_CLEAN) endif() if(RunCMake_GENERATOR MATCHES "Make|Ninja|Visual Studio|Xcode" AND diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake index 31bd8a4..c31a645 100644 --- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake @@ -260,6 +260,7 @@ unset(CMakePresets_FILE) run_cmake_presets(GoodUserOnly) run_cmake_presets(GoodUserFromMain) run_cmake_presets(GoodUserFromUser) +run_cmake_presets(V2InheritV3Optional) # Test CMakeUserPresets.json errors run_cmake_presets(UserDuplicateInUser) diff --git a/Tests/RunCMake/CMakePresets/V2InheritV3Optional.cmake b/Tests/RunCMake/CMakePresets/V2InheritV3Optional.cmake new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/CMakePresets/V2InheritV3Optional.json.in b/Tests/RunCMake/CMakePresets/V2InheritV3Optional.json.in new file mode 100644 index 0000000..957b157 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/V2InheritV3Optional.json.in @@ -0,0 +1,8 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "default" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/V2InheritV3OptionalUser.json.in b/Tests/RunCMake/CMakePresets/V2InheritV3OptionalUser.json.in new file mode 100644 index 0000000..f18c1b9 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/V2InheritV3OptionalUser.json.in @@ -0,0 +1,11 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "V2InheritV3Optional", + "inherits": "default", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_CMP0126_NEW.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_CMP0126_NEW.cmake new file mode 100644 index 0000000..a419ab3 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_CMP0126_NEW.cmake @@ -0,0 +1,64 @@ + +cmake_policy(SET CMP0126 NEW) + +# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE, FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS +enable_language(C) + +# Prepare environment and variables +set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE) +set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo") +if(WIN32) + set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat") + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem") + set(ENV{PKG_CONFIG_PATH} "C:\\baz") +else() + set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh") + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bar:/this/directory/should/not/exist/in/the/filesystem") + set(ENV{PKG_CONFIG_PATH} "/baz") +endif() + + +find_package(PkgConfig) + + +if(NOT DEFINED CMAKE_SYSTEM_NAME + OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$" + AND NOT CMAKE_CROSSCOMPILING)) + if(EXISTS "/etc/debian_version") # is this a debian system ? + if(CMAKE_LIBRARY_ARCHITECTURE MATCHES "^(i386-linux-gnu|x86_64-linux-gnu)$") + # Cannot create directories for all the existing architectures... + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + else() + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + endif() + else() + # not debian, check the FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS properties + get_property(uselibx32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIBX32_PATHS) + get_property(uselib32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS) + get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) + if(uselibx32 AND CMAKE_INTERNAL_PLATFORM_ABI STREQUAL "ELF X32") + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/libx32/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/libx32/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + elseif(uselib32 AND CMAKE_SIZEOF_VOID_P EQUAL 4) + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib32/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib32/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + elseif(uselib64 AND CMAKE_SIZEOF_VOID_P EQUAL 8) + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + else() + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + endif() + endif() +else() + if(WIN32) + set(expected_path "C:\\baz;${CMAKE_CURRENT_SOURCE_DIR}\\pc-foo\\lib\\pkgconfig;${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar\\lib\\pkgconfig") + else() + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + endif() +endif() + + +set(FOO_FOUND FALSE) + +pkg_check_modules(FOO "${expected_path}") + +if(NOT FOO_FOUND) + message(FATAL_ERROR "Expected FOO_FOUND == 1.") +endif() diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake index e7f008c..78ccd96 100644 --- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake @@ -7,6 +7,7 @@ set(ENV{CMAKE_FRAMEWORK_PATH} "") run_cmake(PkgConfigDoesNotExist) +run_cmake(FindPkgConfig_CMP0126_NEW) run_cmake(FindPkgConfig_NO_PKGCONFIG_PATH) run_cmake(FindPkgConfig_PKGCONFIG_PATH) run_cmake(FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH) diff --git a/Tests/RunCMake/InterfaceLibrary/IncludeDirectories.cmake b/Tests/RunCMake/InterfaceLibrary/IncludeDirectories.cmake new file mode 100644 index 0000000..b94eac0 --- /dev/null +++ b/Tests/RunCMake/InterfaceLibrary/IncludeDirectories.cmake @@ -0,0 +1,7 @@ +cmake_policy(SET CMP0076 NEW) +include_directories(Inc1 Inc2) +add_library(iface INTERFACE) +target_sources(iface PRIVATE iface.c) +# Ensure the INCLUDE_DIRECTORIES property is populated. +# Since interface libraries do not actually compile anything, this should be ignored. +set_property(TARGET iface APPEND PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/Inc3 ${CMAKE_CURRENT_SOURCE_DIR}/Inc4) diff --git a/Tests/RunCMake/InterfaceLibrary/RunCMakeTest.cmake b/Tests/RunCMake/InterfaceLibrary/RunCMakeTest.cmake index 834b3c8..10a2d51 100644 --- a/Tests/RunCMake/InterfaceLibrary/RunCMakeTest.cmake +++ b/Tests/RunCMake/InterfaceLibrary/RunCMakeTest.cmake @@ -34,3 +34,4 @@ run_WithSources(ConfigSources "build1:iface") run_WithSources(EmptySources "build1:iface" "build2:iface2,merge") run_WithSources(ExcludeFromAll "build1" "build2:iface" "build3:iface2,merge") run_WithSources(PublicSources "build1" "build2:iface" "build3:iface2,merge") +run_WithSources(IncludeDirectories "build1:iface") diff --git a/Tests/RunCMake/LinkWhatYouUse/C.cmake b/Tests/RunCMake/LinkWhatYouUse/C.cmake index 4c3f428..f00db30 100644 --- a/Tests/RunCMake/LinkWhatYouUse/C.cmake +++ b/Tests/RunCMake/LinkWhatYouUse/C.cmake @@ -2,3 +2,4 @@ enable_language(C) set(CMAKE_LINK_WHAT_YOU_USE TRUE) add_executable(main main.c) target_link_libraries(main m) +add_library(foo STATIC foo.c) diff --git a/Tests/RunCMake/LinkWhatYouUse/CXX.cmake b/Tests/RunCMake/LinkWhatYouUse/CXX.cmake index 9555832..5762e94 100644 --- a/Tests/RunCMake/LinkWhatYouUse/CXX.cmake +++ b/Tests/RunCMake/LinkWhatYouUse/CXX.cmake @@ -2,3 +2,4 @@ enable_language(CXX) set(CMAKE_LINK_WHAT_YOU_USE TRUE) add_executable(main main.cxx) target_link_libraries(main m) +add_library(foo STATIC foo.cxx) diff --git a/Tests/RunCMake/LinkWhatYouUse/foo.c b/Tests/RunCMake/LinkWhatYouUse/foo.c new file mode 100644 index 0000000..c83d856 --- /dev/null +++ b/Tests/RunCMake/LinkWhatYouUse/foo.c @@ -0,0 +1,4 @@ +int foo(void) +{ + return 0; +} diff --git a/Tests/RunCMake/LinkWhatYouUse/foo.cxx b/Tests/RunCMake/LinkWhatYouUse/foo.cxx new file mode 100644 index 0000000..e05eb7e --- /dev/null +++ b/Tests/RunCMake/LinkWhatYouUse/foo.cxx @@ -0,0 +1,4 @@ +int foo() +{ + return 0; +} diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake index f07a12b..5f9b32d 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 running ctest_test() multiple times with different label arguments +# doesn't break. +function(run_changing_labels) + set(CASE_CMAKELISTS_SUFFIX_CODE [[ +add_test(NAME a COMMAND ${CMAKE_COMMAND} -E true) +set_property(TEST a PROPERTY LABELS a) +add_test(NAME b COMMAND ${CMAKE_COMMAND} -E true) +set_property(TEST b PROPERTY LABELS b) + ]]) + run_ctest(TestChangingLabels) +endfunction() +run_changing_labels() diff --git a/Tests/RunCMake/ctest_test/test.cmake.in b/Tests/RunCMake/ctest_test/test.cmake.in index 50b936d..36b1dbd 100644 --- a/Tests/RunCMake/ctest_test/test.cmake.in +++ b/Tests/RunCMake/ctest_test/test.cmake.in @@ -15,4 +15,9 @@ set(ctest_test_args "@CASE_CTEST_TEST_ARGS@") ctest_start(Experimental) ctest_configure() ctest_build() -ctest_test(${ctest_test_args}) +if("@CASE_NAME@" STREQUAL "TestChangingLabels") + ctest_test(${ctest_test_args} INCLUDE_LABEL "^a$") + ctest_test(${ctest_test_args} INCLUDE_LABEL "^b$") +else() + ctest_test(${ctest_test_args}) +endif()