diff options
author | JinWang An <jinwang.an@samsung.com> | 2022-12-27 17:20:08 +0900 |
---|---|---|
committer | JinWang An <jinwang.an@samsung.com> | 2022-12-27 17:20:08 +0900 |
commit | 7d0194465f58c820df7f2285a2a2167818718da2 (patch) | |
tree | bc4ac1640b77e8ed65b626ab6bf102275ac589bc | |
parent | eca8e526ac4322878cf56b68577e60eb848172fb (diff) | |
download | cmake-7d0194465f58c820df7f2285a2a2167818718da2.tar.gz cmake-7d0194465f58c820df7f2285a2a2167818718da2.tar.bz2 cmake-7d0194465f58c820df7f2285a2a2167818718da2.zip |
Imported Upstream version 3.22.3upstream/3.22.3
39 files changed, 158 insertions, 80 deletions
diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst index 06da910dd..08f8d5b62 100644 --- a/Help/command/try_compile.rst +++ b/Help/command/try_compile.rst @@ -19,10 +19,6 @@ Try Compiling Whole Projects Try building a project. The success or failure of the ``try_compile``, i.e. ``TRUE`` or ``FALSE`` respectively, is returned in ``<resultVar>``. -.. versionadded:: 3.14 - The name of the ``<resultVar>`` is defined by the user. Previously, it had - a fixed name ``RESULT_VAR``. - In this form, ``<srcdir>`` should contain a complete CMake project with a ``CMakeLists.txt`` file and all sources. The ``<bindir>`` and ``<srcdir>`` will not be deleted after this command is run. Specify ``<targetName>`` to @@ -51,10 +47,6 @@ Try building an executable or static library from one or more source files variable). The success or failure of the ``try_compile``, i.e. ``TRUE`` or ``FALSE`` respectively, is returned in ``<resultVar>``. -.. versionadded:: 3.14 - The name of the ``<resultVar>`` is defined by the user. Previously, it had - a fixed name ``RESULT_VAR``. - In this form, one or more source files must be provided. If :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` is unset or is set to ``EXECUTABLE``, the sources must include a definition for ``main`` and CMake will create a diff --git a/Help/command/try_run.rst b/Help/command/try_run.rst index 404de985d..fc41cdd7b 100644 --- a/Help/command/try_run.rst +++ b/Help/command/try_run.rst @@ -30,11 +30,6 @@ executable was built, but failed to run, then ``<runResultVar>`` will be set to ``FAILED_TO_RUN``. See the :command:`try_compile` command for information on how the test project is constructed to build the source file. -.. versionadded:: 3.14 - The names of the result variables ``<runResultVar>`` and - ``<compileResultVar>`` are defined by the user. Previously, they had - fixed names ``RUN_RESULT_VAR`` and ``COMPILE_RESULT_VAR``. - The options are: ``CMAKE_FLAGS <flags>...`` diff --git a/Help/release/3.21.rst b/Help/release/3.21.rst index e1c6172b2..847f82d2c 100644 --- a/Help/release/3.21.rst +++ b/Help/release/3.21.rst @@ -334,3 +334,10 @@ Changes made since CMake 3.21.0 include the following. * The :generator:`Visual Studio 17 2022` generator is now based on the "Visual Studio 2022" release candidates. Previously it was based on preview versions. + +3.21.5, 3.21.6 +-------------- + +These versions made no changes to documented features or interfaces. +Some implementation updates were made to support ecosystem changes +and/or fix regressions. diff --git a/Help/release/3.22.rst b/Help/release/3.22.rst index a82d39695..1f773e66c 100644 --- a/Help/release/3.22.rst +++ b/Help/release/3.22.rst @@ -155,3 +155,12 @@ and/or fix regressions. * The ``OLD`` behavior of :policy:`CMP0128` was fixed to add flags even when the specified standard matches the compiler default. + +3.22.3 +------ + +* The :command:`while` command again ignores errors in condition evaluation + as CMake 3.21 and below did. This bug was fixed in 3.22.0, but exposed + errors in existing projects. The fix has been reverted to restore + compatibility. The fix may be restored in a future version of CMake + via a policy. diff --git a/Help/variable/MSVC_TOOLSET_VERSION.rst b/Help/variable/MSVC_TOOLSET_VERSION.rst index c642a9f1d..59479af69 100644 --- a/Help/variable/MSVC_TOOLSET_VERSION.rst +++ b/Help/variable/MSVC_TOOLSET_VERSION.rst @@ -17,6 +17,7 @@ Known toolset version numbers are:: 140 = VS 2015 (14.0) 141 = VS 2017 (15.0) 142 = VS 2019 (16.0) + 143 = VS 2022 (17.0) Compiler versions newer than those known to CMake will be reported as the latest known toolset version. diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index 0cb8724fb..82d56cf61 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -60,10 +60,9 @@ const char* info_language_standard_default = "INFO" ":" "standard_default[" C_VERSION "]"; const char* info_language_extensions_default = "INFO" ":" "extensions_default[" -/* !defined(_MSC_VER) to exclude Clang's MSVC compatibility mode. */ #if (defined(__clang__) || defined(__GNUC__) || defined(__xlC__) || \ defined(__TI_COMPILER_VERSION__)) && \ - !defined(__STRICT_ANSI__) && !defined(_MSC_VER) + !defined(__STRICT_ANSI__) "ON" #else "OFF" diff --git a/Modules/CMakeCUDACompilerId.cu.in b/Modules/CMakeCUDACompilerId.cu.in index becb9b4cb..d5a3b0367 100644 --- a/Modules/CMakeCUDACompilerId.cu.in +++ b/Modules/CMakeCUDACompilerId.cu.in @@ -33,9 +33,8 @@ const char* info_language_standard_default = "INFO" ":" "standard_default[" "]"; const char* info_language_extensions_default = "INFO" ":" "extensions_default[" -/* !defined(_MSC_VER) to exclude Clang's MSVC compatibility mode. */ -#if (defined(__clang__) || defined(__GNUC__)) && !defined(__STRICT_ANSI__) && \ - !defined(_MSC_VER) +#if (defined(__clang__) || defined(__GNUC__)) && \ + !defined(__STRICT_ANSI__) "ON" #else "OFF" diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index 4904249ad..f19bc97ab 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -66,10 +66,9 @@ const char* info_language_standard_default = "INFO" ":" "standard_default[" "]"; const char* info_language_extensions_default = "INFO" ":" "extensions_default[" -/* !defined(_MSC_VER) to exclude Clang's MSVC compatibility mode. */ #if (defined(__clang__) || defined(__GNUC__) || defined(__xlC__) || \ defined(__TI_COMPILER_VERSION__)) && \ - !defined(__STRICT_ANSI__) && !defined(_MSC_VER) + !defined(__STRICT_ANSI__) "ON" #else "OFF" diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 6c81754d3..6dbe62675 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -172,7 +172,10 @@ else() else() list(PREPEND _CMAKE_LINKER_NAMES "ld.lld") endif() - list(PREPEND _CMAKE_AR_NAMES "llvm-ar") + if(NOT APPLE) + # llvm-ar does not generate a symbol table that the Apple ld64 linker accepts. + list(PREPEND _CMAKE_AR_NAMES "llvm-ar") + endif() list(PREPEND _CMAKE_RANLIB_NAMES "llvm-ranlib") if("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_VERSION}" VERSION_GREATER_EQUAL 11) # llvm-strip versions prior to 11 require additional flags we do not yet add. diff --git a/Modules/Compiler/IAR-CXX.cmake b/Modules/Compiler/IAR-CXX.cmake index a3f1dbc29..7df74ad41 100644 --- a/Modules/Compiler/IAR-CXX.cmake +++ b/Modules/Compiler/IAR-CXX.cmake @@ -16,14 +16,17 @@ endif() # Whenever needed, override this default behavior using CMAKE_IAR_CXX_FLAG in your toolchain file. if(NOT CMAKE_IAR_CXX_FLAG) - set(_CMAKE_IAR_MODERNCXX_LIST 14 17) - if(${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT} IN_LIST _CMAKE_IAR_MODERNCXX_LIST OR + cmake_policy(PUSH) + cmake_policy(SET CMP0057 NEW) # if IN_LIST + + if(${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT} IN_LIST "14;17" OR ("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM" AND ${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT} EQUAL 98)) string(PREPEND CMAKE_CXX_FLAGS "--c++ ") else() string(PREPEND CMAKE_CXX_FLAGS "--eec++ ") endif() - unset(_CMAKE_IAR_MODERNCXX_LIST) + + cmake_policy(POP) endif() set(CMAKE_CXX_STANDARD_COMPILE_OPTION "") diff --git a/Modules/FindGLUT.cmake b/Modules/FindGLUT.cmake index 636f1ea3b..9c80ad7b7 100644 --- a/Modules/FindGLUT.cmake +++ b/Modules/FindGLUT.cmake @@ -55,6 +55,9 @@ function(_add_glut_target_simple) if(GLUT_LIBRARIES) target_link_libraries(GLUT::GLUT INTERFACE ${GLUT_LIBRARIES}) endif() + if(GLUT_LIBRARY_DIRS) + target_link_directories(GLUT::GLUT INTERFACE ${GLUT_LIBRARY_DIRS}) + endif() if(GLUT_LDFLAGS) target_link_options(GLUT::GLUT INTERFACE ${GLUT_LDFLAGS}) endif() diff --git a/Modules/FindGSL.cmake b/Modules/FindGSL.cmake index 3d4e7f939..485735a04 100644 --- a/Modules/FindGSL.cmake +++ b/Modules/FindGSL.cmake @@ -139,7 +139,7 @@ if( NOT GSL_VERSION ) # 2. If gsl-config is not available, try looking in gsl/gsl_version.h if( NOT GSL_VERSION AND EXISTS "${GSL_INCLUDE_DIRS}/gsl/gsl_version.h" ) file( STRINGS "${GSL_INCLUDE_DIRS}/gsl/gsl_version.h" gsl_version_h_contents REGEX "define GSL_VERSION" ) - string( REGEX REPLACE ".*([0-9]\\.[0-9][0-9]?).*" "\\1" GSL_VERSION ${gsl_version_h_contents} ) + string( REGEX REPLACE ".*define[ ]+GSL_VERSION[ ]+\"([^\"]*)\".*" "\\1" GSL_VERSION ${gsl_version_h_contents} ) endif() # might also try scraping the directory name for a regex match "gsl-X.X" diff --git a/Modules/FindMPI/test_mpi.c b/Modules/FindMPI/test_mpi.c index 70d7e1d3e..36b5dfd4e 100644 --- a/Modules/FindMPI/test_mpi.c +++ b/Modules/FindMPI/test_mpi.c @@ -7,7 +7,7 @@ #endif #if defined(MPI_VERSION) && defined(MPI_SUBVERSION) -const static char mpiver_str[] = { 'I', 'N', +static const char mpiver_str[] = { 'I', 'N', 'F', 'O', ':', 'M', 'P', 'I', diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index 0ca593e98..f0e991b33 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -1353,7 +1353,7 @@ function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_ve ${versioninfo_string} ) - if(CMAKE_MATCH_1 MATCHES "(([0-9])\\.([0-9]))[\\.0-9]*") + if(CMAKE_MATCH_1 MATCHES "(([0-9]+)\\.([0-9]+))[\\.0-9]*") set(_matlab_version_tmp "${CMAKE_MATCH_1}") endif() endif() diff --git a/Modules/Platform/Windows-Intel-C.cmake b/Modules/Platform/Windows-Intel-C.cmake index 152b27c30..e4d9b93ee 100644 --- a/Modules/Platform/Windows-Intel-C.cmake +++ b/Modules/Platform/Windows-Intel-C.cmake @@ -1,7 +1,7 @@ include(Platform/Windows-Intel) __windows_compiler_intel(C) -set(CMAKE_DEPFILE_FLAGS_C "-QMMD -QMT <DEP_TARGET> -QMF <DEP_FILE>") +set(CMAKE_DEPFILE_FLAGS_C "-QMD -QMT <DEP_TARGET> -QMF <DEP_FILE>") set(CMAKE_C_DEPFILE_FORMAT gcc) if(CMAKE_GENERATOR MATCHES "^Ninja") diff --git a/Modules/Platform/Windows-Intel-CXX.cmake b/Modules/Platform/Windows-Intel-CXX.cmake index ce33ae186..6adbb6e19 100644 --- a/Modules/Platform/Windows-Intel-CXX.cmake +++ b/Modules/Platform/Windows-Intel-CXX.cmake @@ -2,7 +2,7 @@ include(Platform/Windows-Intel) set(_COMPILE_CXX " /TP") __windows_compiler_intel(CXX) -set(CMAKE_DEPFILE_FLAGS_CXX "-QMMD -QMT <DEP_TARGET> -QMF <DEP_FILE>") +set(CMAKE_DEPFILE_FLAGS_CXX "-QMD -QMT <DEP_TARGET> -QMF <DEP_FILE>") set(CMAKE_CXX_DEPFILE_FORMAT gcc) if(CMAKE_GENERATOR MATCHES "^Ninja") diff --git a/Modules/Platform/Windows-IntelLLVM.cmake b/Modules/Platform/Windows-IntelLLVM.cmake index b9ea03799..8231e784b 100644 --- a/Modules/Platform/Windows-IntelLLVM.cmake +++ b/Modules/Platform/Windows-IntelLLVM.cmake @@ -12,6 +12,6 @@ include(Platform/Windows-MSVC) macro(__windows_compiler_intel lang) __windows_compiler_msvc(${lang}) - set(CMAKE_DEPFILE_FLAGS_${lang} "-QMMD -QMT <DEP_TARGET> -QMF <DEP_FILE>") + set(CMAKE_DEPFILE_FLAGS_${lang} "-QMD -QMT <DEP_TARGET> -QMF <DEP_FILE>") set(CMAKE_${lang}_DEPFILE_FORMAT gcc) endmacro() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index f938d9b52..405c8f48e 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 22) -set(CMake_VERSION_PATCH 2) +set(CMake_VERSION_PATCH 3) #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 [==[8428e39ed9 CMake 3.22.2]==]) + set(git_info [==[6e9eaf209d CMake 3.22.3]==]) # 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/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 8ca9a66cd..8b0f64e23 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -367,7 +367,8 @@ void cmExportFileGenerator::PopulateSourcesInterface( void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( cmGeneratorTarget const* target, cmGeneratorExpression::PreprocessContext preprocessRule, - ImportPropertyMap& properties, std::vector<std::string>& missingTargets) + ImportPropertyMap& properties, std::vector<std::string>& missingTargets, + cmTargetExport const& te) { assert(preprocessRule == cmGeneratorExpression::InstallInterface); @@ -377,7 +378,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( cmGeneratorExpression ge; std::string dirs = cmGeneratorExpression::Preprocess( - cmJoin(target->Target->GetInstallIncludeDirectoriesEntries(), ";"), + cmJoin(target->Target->GetInstallIncludeDirectoriesEntries(te), ";"), preprocessRule, true); this->ReplaceInstallPrefix(dirs); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs); diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 24e048bca..29a6a986a 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -16,6 +16,7 @@ #include "cmVersionConfig.h" class cmGeneratorTarget; +class cmTargetExport; #define STRINGIFY_HELPER(X) #X #define STRINGIFY(X) STRINGIFY_HELPER(X) @@ -146,7 +147,8 @@ protected: void PopulateIncludeDirectoriesInterface( cmGeneratorTarget const* target, cmGeneratorExpression::PreprocessContext preprocessRule, - ImportPropertyMap& properties, std::vector<std::string>& missingTargets); + ImportPropertyMap& properties, std::vector<std::string>& missingTargets, + cmTargetExport const& te); void PopulateSourcesInterface( cmGeneratorTarget const* target, cmGeneratorExpression::PreprocessContext preprocessRule, diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index e9ac8752f..4a3c565bc 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -86,7 +86,8 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) ImportPropertyMap properties; this->PopulateIncludeDirectoriesInterface( - gt, cmGeneratorExpression::InstallInterface, properties, missingTargets); + gt, cmGeneratorExpression::InstallInterface, properties, missingTargets, + *te); this->PopulateSourcesInterface(gt, cmGeneratorExpression::InstallInterface, properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", gt, diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index eaf88f64a..92e3bb5fb 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -683,7 +683,7 @@ bool HandleTargetsMode(std::vector<std::string> const& args, te->RuntimeGenerator = runtimeGenerator.get(); te->ObjectsGenerator = objectGenerator.get(); target.AddInstallIncludeDirectories( - cmMakeRange(includesArgs.GetIncludeDirs())); + *te, cmMakeRange(includesArgs.GetIncludeDirs())); te->NamelinkOnly = namelinkOnly; helper.Makefile->GetGlobalGenerator() ->GetExportSets()[exports] diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index f5f3727e5..5f138ba47 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -16,6 +16,8 @@ #include <cmext/algorithm> #include <cmext/string_view> +#include "cm_codecvt.hxx" + #include "cmComputeLinkInformation.h" #include "cmCustomCommand.h" #include "cmCustomCommandGenerator.h" @@ -2072,11 +2074,22 @@ std::string cmMakefileTargetGenerator::CreateResponseFile( const char* name, std::string const& options, std::vector<std::string>& makefile_depends) { + // FIXME: Find a better way to determine the response file encoding, + // perhaps using tool-specific platform information variables. + // For now, use the makefile encoding as a heuristic. + codecvt::Encoding responseEncoding = + this->GlobalGenerator->GetMakefileEncoding(); + // Non-MSVC tooling may not understand a BOM. + if (responseEncoding == codecvt::UTF8_WITH_BOM && + !this->Makefile->IsOn("MSVC")) { + responseEncoding = codecvt::UTF8; + } + // Create the response file. std::string responseFileNameFull = cmStrCat(this->TargetBuildDirectoryFull, '/', name); - cmGeneratedFileStream responseStream( - responseFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding()); + cmGeneratedFileStream responseStream(responseFileNameFull, false, + responseEncoding); responseStream.SetCopyIfDifferent(true); responseStream << options << "\n"; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 97d60cf03..45e23d384 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -191,7 +191,8 @@ public: cmTarget::LinkLibraryVectorType OriginalLinkLibraries; std::map<std::string, BTs<std::string>> LanguageStandardProperties; std::vector<BT<std::string>> IncludeDirectoriesEntries; - std::vector<std::string> InstallIncludeDirectoriesEntries; + std::map<cmTargetExport const*, std::vector<std::string>> + InstallIncludeDirectoriesEntries; std::vector<BT<std::string>> CompileOptionsEntries; std::vector<BT<std::string>> CompileFeaturesEntries; std::vector<BT<std::string>> CompileDefinitionsEntries; @@ -1054,15 +1055,18 @@ std::set<std::string> const& cmTarget::GetSystemIncludeDirectories() const return this->impl->SystemIncludeDirectories; } -void cmTarget::AddInstallIncludeDirectories(cmStringRange const& incs) +void cmTarget::AddInstallIncludeDirectories(cmTargetExport const& te, + cmStringRange const& incs) { - std::copy(incs.begin(), incs.end(), - std::back_inserter(this->impl->InstallIncludeDirectoriesEntries)); + std::copy( + incs.begin(), incs.end(), + std::back_inserter(this->impl->InstallIncludeDirectoriesEntries[&te])); } -cmStringRange cmTarget::GetInstallIncludeDirectoriesEntries() const +cmStringRange cmTarget::GetInstallIncludeDirectoriesEntries( + cmTargetExport const& te) const { - return cmMakeRange(this->impl->InstallIncludeDirectoriesEntries); + return cmMakeRange(this->impl->InstallIncludeDirectoriesEntries[&te]); } cmBTStringRange cmTarget::GetIncludeDirectoriesEntries() const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 3cf69429c..95aa4d350 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -26,6 +26,7 @@ class cmMakefile; class cmMessenger; class cmPropertyMap; class cmSourceFile; +class cmTargetExport; class cmTargetInternals; /** \class cmTarget @@ -232,8 +233,10 @@ public: void AddSystemIncludeDirectories(std::set<std::string> const& incs); std::set<std::string> const& GetSystemIncludeDirectories() const; - void AddInstallIncludeDirectories(cmStringRange const& incs); - cmStringRange GetInstallIncludeDirectoriesEntries() const; + void AddInstallIncludeDirectories(cmTargetExport const& te, + cmStringRange const& incs); + cmStringRange GetInstallIncludeDirectoriesEntries( + cmTargetExport const& te) const; BTs<std::string> const* GetLanguageStandardProperty( const std::string& propertyName) const; diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index b8297ce21..a93a81fda 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -79,12 +79,17 @@ bool cmWhileFunctionBlocker::Replay(std::vector<cmListFileFunction> functions, return out; }; + // FIXME(#23296): For compatibility with older versions of CMake, we + // tolerate condition errors that evaluate to false. We should add + // a policy to enforce such errors. + bool enforceError = true; std::string errorString; MessageType messageType; for (cmConditionEvaluator conditionEvaluator(mf, whileBT); - conditionEvaluator.IsTrue(expandArgs(this->Args, expandedArguments), - errorString, messageType);) { + (enforceError = /* enforce condition errors that evaluate to true */ + conditionEvaluator.IsTrue(expandArgs(this->Args, expandedArguments), + errorString, messageType));) { // Invoke all the functions that were collected in the block. for (cmListFileFunction const& fn : functions) { cmExecutionStatus status(mf); @@ -105,7 +110,7 @@ bool cmWhileFunctionBlocker::Replay(std::vector<cmListFileFunction> functions, } } - if (!errorString.empty()) { + if (!errorString.empty() && enforceError) { std::string err = "had incorrect arguments:\n "; for (auto const& i : expandedArguments) { err += " "; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 61d4ae486..6090ec4a2 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -161,11 +161,11 @@ void cmakemainMessageCallback(const std::string& m, // cannot use it to print messages. Another implementation will // be needed to print colored messages on Windows. static_cast<void>(md); - std::cerr << m << cmakemainGetStack(cm) << "\n"; + std::cerr << m << cmakemainGetStack(cm) << '\n' << std::flush; #else cmsysTerminal_cfprintf(md.desiredColor, stderr, "%s", m.c_str()); fflush(stderr); // stderr is buffered in some cases. - std::cerr << cmakemainGetStack(cm) << "\n"; + std::cerr << cmakemainGetStack(cm) << '\n' << std::flush; #endif } diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index e24ef5850..e8fb13fd0 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -580,12 +580,16 @@ if(NOT WIN32 add_RunCMake_test(SymlinkTrees) endif () -find_package(Qt4 QUIET) -find_package(Qt5Core QUIET) -if (QT4_FOUND AND Qt5Core_FOUND AND NOT Qt5Core_VERSION VERSION_LESS 5.1.0) +if(CMake_TEST_Qt4) + find_package(Qt4 QUIET) +endif() +if(CMake_TEST_Qt5) + find_package(Qt5Core QUIET) +endif() +if (CMake_TEST_Qt4 AND CMake_TEST_Qt5 AND QT4_FOUND AND Qt5Core_FOUND AND NOT Qt5Core_VERSION VERSION_LESS 5.1.0) add_RunCMake_test(IncompatibleQt) endif() -if (QT4_FOUND) +if (CMake_TEST_Qt4 AND QT4_FOUND) add_RunCMake_test(ObsoleteQtMacros -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}) endif() diff --git a/Tests/RunCMake/if/unbalanced-parenthesis-stderr.txt b/Tests/RunCMake/if/unbalanced-parenthesis-stderr.txt index 770ccb8f1..d2260a04b 100644 --- a/Tests/RunCMake/if/unbalanced-parenthesis-stderr.txt +++ b/Tests/RunCMake/if/unbalanced-parenthesis-stderr.txt @@ -1,7 +1,7 @@ CMake Error at unbalanced-parenthesis\.cmake:[0-9]+ \(if\): if given arguments: - "NOT" "\(" "IN_LIST" "some_list" + "\(" mismatched parenthesis in condition Call Stack \(most recent call first\): diff --git a/Tests/RunCMake/if/unbalanced-parenthesis.cmake b/Tests/RunCMake/if/unbalanced-parenthesis.cmake index c51c7557f..45932f662 100644 --- a/Tests/RunCMake/if/unbalanced-parenthesis.cmake +++ b/Tests/RunCMake/if/unbalanced-parenthesis.cmake @@ -1,8 +1,5 @@ -set(var_with_paren "(") -set(some_list "") - -if(NOT ${var_with_paren} IN_LIST some_list) - message(STATUS "Never prints") -else() - message(STATUS "Never prints") +set(paren "(") +if(${paren}) + message(STATUS "Condition incorrectly true") endif() +message(STATUS "Code incorrectly accepted") diff --git a/Tests/RunCMake/install/EXPORT-TargetTwice-check.cmake b/Tests/RunCMake/install/EXPORT-TargetTwice-check.cmake new file mode 100644 index 000000000..97677cad4 --- /dev/null +++ b/Tests/RunCMake/install/EXPORT-TargetTwice-check.cmake @@ -0,0 +1,19 @@ +set(pkg1_cmake "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/Export/pkg1/pkg1.cmake") +file(STRINGS "${pkg1_cmake}" pkg1_includes REGEX INTERFACE_INCLUDE_DIRECTORIES) +set(pkg1_expect [[INTERFACE_INCLUDE_DIRECTORIES "\${_IMPORT_PREFIX}/pkg1/inc"]]) +if(NOT pkg1_includes MATCHES "${pkg1_expect}") + set(RunCMake_TEST_FAILED "pkg1 has unexpected INTERFACE_INCLUDE_DIRECTORIES line: + ${pkg1_includes} +It does not match: + ${pkg1_expect}") +endif() + +set(pkg2_cmake "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/Export/pkg2/pkg2.cmake") +file(STRINGS "${pkg2_cmake}" pkg2_includes REGEX INTERFACE_INCLUDE_DIRECTORIES) +set(pkg2_expect [[INTERFACE_INCLUDE_DIRECTORIES "\${_IMPORT_PREFIX}/pkg2/inc"]]) +if(NOT pkg2_includes MATCHES "${pkg2_expect}") + set(RunCMake_TEST_FAILED "pkg2 has unexpected INTERFACE_INCLUDE_DIRECTORIES line: + ${pkg2_includes} +It does not match: + ${pkg2_expect}") +endif() diff --git a/Tests/RunCMake/install/EXPORT-TargetTwice-pkg1.txt b/Tests/RunCMake/install/EXPORT-TargetTwice-pkg1.txt new file mode 100644 index 000000000..592f79c68 --- /dev/null +++ b/Tests/RunCMake/install/EXPORT-TargetTwice-pkg1.txt @@ -0,0 +1,5 @@ +.+ +set_target_properties\(pkg1::foo PROPERTIES +.+INTERFACE_INCLUDE_DIRECTORIES "\${_IMPORT_PREFIX}/pkg1/inc" +\) +.+ diff --git a/Tests/RunCMake/install/EXPORT-TargetTwice-pkg2.txt b/Tests/RunCMake/install/EXPORT-TargetTwice-pkg2.txt new file mode 100644 index 000000000..ebfc43e34 --- /dev/null +++ b/Tests/RunCMake/install/EXPORT-TargetTwice-pkg2.txt @@ -0,0 +1,5 @@ +.+ +set_target_properties\(pkg2::foo PROPERTIES +.+INTERFACE_INCLUDE_DIRECTORIES "\${_IMPORT_PREFIX}/pkg2/inc" +\) +.+ diff --git a/Tests/RunCMake/install/EXPORT-TargetTwice.cmake b/Tests/RunCMake/install/EXPORT-TargetTwice.cmake new file mode 100644 index 000000000..cac4ff2ad --- /dev/null +++ b/Tests/RunCMake/install/EXPORT-TargetTwice.cmake @@ -0,0 +1,17 @@ +enable_language(C) + +add_library(foo STATIC empty.c) + +install(TARGETS foo + EXPORT pkg1 + ARCHIVE DESTINATION pkg1/lib + INCLUDES DESTINATION pkg1/inc + ) +install(EXPORT pkg1 DESTINATION pkg1) + +install(TARGETS foo + EXPORT pkg2 + ARCHIVE DESTINATION pkg2/lib + INCLUDES DESTINATION pkg2/inc + ) +install(EXPORT pkg2 DESTINATION pkg2) diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake index f79a3ea74..7c12d4a31 100644 --- a/Tests/RunCMake/install/RunCMakeTest.cmake +++ b/Tests/RunCMake/install/RunCMakeTest.cmake @@ -82,6 +82,7 @@ run_cmake(EXPORT-OldIFace) run_cmake(EXPORT-UnknownExport) run_cmake(EXPORT-NamelinkOnly) run_cmake(EXPORT-SeparateNamelink) +run_cmake(EXPORT-TargetTwice) run_cmake(CMP0062-OLD) run_cmake(CMP0062-NEW) run_cmake(CMP0062-WARN) diff --git a/Tests/RunCMake/while/unbalanced-parenthesis-result.txt b/Tests/RunCMake/while/unbalanced-parenthesis-result.txt deleted file mode 100644 index d00491fd7..000000000 --- a/Tests/RunCMake/while/unbalanced-parenthesis-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/while/unbalanced-parenthesis-stderr.txt b/Tests/RunCMake/while/unbalanced-parenthesis-stderr.txt deleted file mode 100644 index 9d4132c5a..000000000 --- a/Tests/RunCMake/while/unbalanced-parenthesis-stderr.txt +++ /dev/null @@ -1,8 +0,0 @@ -CMake Error at unbalanced-parenthesis.cmake:[0-9]+ \(while\): - had incorrect arguments: - - "NOT" "\(" "IN_LIST" "some_list" - - mismatched parenthesis in condition -Call Stack \(most recent call first\): - CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/while/unbalanced-parenthesis-stdout.txt b/Tests/RunCMake/while/unbalanced-parenthesis-stdout.txt new file mode 100644 index 000000000..d45e194a5 --- /dev/null +++ b/Tests/RunCMake/while/unbalanced-parenthesis-stdout.txt @@ -0,0 +1 @@ +-- Code incorrectly accepted diff --git a/Tests/RunCMake/while/unbalanced-parenthesis.cmake b/Tests/RunCMake/while/unbalanced-parenthesis.cmake index 7a12701e6..39d736b25 100644 --- a/Tests/RunCMake/while/unbalanced-parenthesis.cmake +++ b/Tests/RunCMake/while/unbalanced-parenthesis.cmake @@ -1,8 +1,7 @@ -set(var_with_paren "(") -set(some_list "") - -while(NOT ${var_with_paren} IN_LIST some_list) - message(STATUS "Never prints") +set(paren "(") +while(${paren}) + message(STATUS "Condition incorrectly true") + break() endwhile() - -message(STATUS "Never prints") +# FIXME(#23296): The above condition error is tolerated for compatibility. +message(STATUS "Code incorrectly accepted") |