diff options
-rw-r--r-- | Help/command/if.rst | 7 | ||||
-rw-r--r-- | Modules/InstallRequiredSystemLibraries.cmake | 16 | ||||
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 35 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 14 | ||||
-rw-r--r-- | Source/cmNinjaUtilityTargetGenerator.cxx | 7 | ||||
-rw-r--r-- | Source/kwsys/ProcessWin32.c | 5 | ||||
-rw-r--r-- | Templates/MSBuild/FlagTables/v142_CSharp.json | 18 | ||||
-rw-r--r-- | Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/NinjaMultiConfig/Simple-targets-debug-ninja-stdout.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/NinjaMultiConfig/Simple-targets-default-ninja-stdout.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/NinjaMultiConfig/Simple-targets-release-ninja-stdout.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/UnityBuild/f.cxx | 5 | ||||
-rw-r--r-- | Tests/RunCMake/UnityBuild/unitybuild_anon_ns-build-check.cmake | 10 | ||||
-rw-r--r-- | Tests/RunCMake/UnityBuild/unitybuild_anon_ns.cmake | 2 | ||||
-rw-r--r-- | Utilities/std/cm/optional | 8 |
16 files changed, 112 insertions, 29 deletions
diff --git a/Help/command/if.rst b/Help/command/if.rst index c51d2bc..5dabe00 100644 --- a/Help/command/if.rst +++ b/Help/command/if.rst @@ -119,9 +119,10 @@ File Operations ``if(EXISTS path-to-file-or-directory)`` True if the named file or directory exists. Behavior is well-defined - only for full paths. 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. + 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. ``if(file1 IS_NEWER_THAN file2)`` True if ``file1`` is newer than ``file2`` or if one of the two files doesn't diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake index 6ecdb9c..a39393dc 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/Modules/InstallRequiredSystemLibraries.cmake @@ -101,16 +101,18 @@ endforeach() if(MSVC) file(TO_CMAKE_PATH "$ENV{SYSTEMROOT}" SYSTEMROOT) - if(CMAKE_CL_64) - if(MSVC_VERSION GREATER 1599) - # VS 10 and later: - set(CMAKE_MSVC_ARCH x64) - else() + if(MSVC_C_ARCHITECTURE_ID) + string(TOLOWER "${MSVC_C_ARCHITECTURE_ID}" CMAKE_MSVC_ARCH) + elseif(MSVC_CXX_ARCHITECTURE_ID) + string(TOLOWER "${MSVC_CXX_ARCHITECTURE_ID}" CMAKE_MSVC_ARCH) + else() + set(CMAKE_MSVC_ARCH x86) + endif() + if(CMAKE_MSVC_ARCH STREQUAL "x64") + if(MSVC_VERSION LESS 1600) # VS 9 and earlier: set(CMAKE_MSVC_ARCH amd64) endif() - else() - set(CMAKE_MSVC_ARCH x86) endif() get_filename_component(devenv_dir "${CMAKE_MAKE_PROGRAM}" PATH) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 113a9d8..2480380 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 19) -set(CMake_VERSION_PATCH 20210125) +set(CMake_VERSION_PATCH 20210127) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 86eddc2..a6d898d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2768,17 +2768,32 @@ inline void RegisterUnitySources(cmGeneratorTarget* target, cmSourceFile* sf, target->AddSourceFileToUnityBatch(sf->ResolveFullPath()); sf->SetProperty("UNITY_SOURCE_FILE", filename.c_str()); } +} -inline void IncludeFileInUnitySources(cmGeneratedFileStream& unity_file, - std::string const& sf_full_path, - cmProp beforeInclude, - cmProp afterInclude, cmProp uniqueIdName) +void cmLocalGenerator::IncludeFileInUnitySources( + cmGeneratedFileStream& unity_file, std::string const& sf_full_path, + cmProp beforeInclude, cmProp afterInclude, cmProp uniqueIdName) { - if (uniqueIdName && !uniqueIdName->empty()) { - unity_file << "#undef " << *uniqueIdName << "\n" + std::string pathToHash; + auto PathEqOrSubDir = [](std::string const& a, std::string const& b) { + return (cmSystemTools::ComparePath(a, b) || + cmSystemTools::IsSubDirectory(a, b)); + }; + const auto path = cmSystemTools::GetFilenamePath(sf_full_path); + if (PathEqOrSubDir(path, this->GetBinaryDirectory())) { + pathToHash = "BLD_" + + cmSystemTools::RelativePath(this->GetBinaryDirectory(), sf_full_path); + } else if (PathEqOrSubDir(path, this->GetSourceDirectory())) { + pathToHash = "SRC_" + + cmSystemTools::RelativePath(this->GetSourceDirectory(), sf_full_path); + } else { + pathToHash = "ABS_" + sf_full_path; + } + unity_file << "/* " << pathToHash << " */\n" + << "#undef " << *uniqueIdName << "\n" << "#define " << *uniqueIdName << " unity_" - << cmSystemTools::ComputeStringMD5(sf_full_path) << "\n"; + << cmSystemTools::ComputeStringMD5(pathToHash) << "\n"; } if (beforeInclude) { @@ -2790,9 +2805,10 @@ inline void IncludeFileInUnitySources(cmGeneratedFileStream& unity_file, if (afterInclude) { unity_file << *afterInclude << "\n"; } + unity_file << "\n"; } -std::vector<std::string> AddUnityFilesModeAuto( +std::vector<std::string> cmLocalGenerator::AddUnityFilesModeAuto( cmGeneratorTarget* target, std::string const& lang, std::vector<cmSourceFile*> const& filtered_sources, cmProp beforeInclude, cmProp afterInclude, std::string const& filename_base, size_t batchSize) @@ -2835,7 +2851,7 @@ std::vector<std::string> AddUnityFilesModeAuto( return unity_files; } -std::vector<std::string> AddUnityFilesModeGroup( +std::vector<std::string> cmLocalGenerator::AddUnityFilesModeGroup( cmGeneratorTarget* target, std::string const& lang, std::vector<cmSourceFile*> const& filtered_sources, cmProp beforeInclude, cmProp afterInclude, std::string const& filename_base) @@ -2883,7 +2899,6 @@ std::vector<std::string> AddUnityFilesModeGroup( return unity_files; } -} void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target) { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 91dd8ae..a3610fd 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -4,6 +4,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include <cstddef> #include <iosfwd> #include <map> #include <memory> @@ -27,6 +28,7 @@ class cmComputeLinkInformation; class cmCustomCommand; class cmCustomCommandGenerator; class cmCustomCommandLines; +class cmGeneratedFileStream; class cmGeneratorTarget; class cmGlobalGenerator; class cmImplicitDependsList; @@ -651,6 +653,18 @@ private: const std::string& ReuseFrom, cmGeneratorTarget* reuseTarget, std::vector<std::string> const& extensions); + void IncludeFileInUnitySources(cmGeneratedFileStream& unity_file, + std::string const& sf_full_path, + cmProp beforeInclude, cmProp afterInclude, + cmProp uniqueIdName); + std::vector<std::string> AddUnityFilesModeAuto( + cmGeneratorTarget* target, std::string const& lang, + std::vector<cmSourceFile*> const& filtered_sources, cmProp beforeInclude, + cmProp afterInclude, std::string const& filename_base, size_t batchSize); + std::vector<std::string> AddUnityFilesModeGroup( + cmGeneratorTarget* target, std::string const& lang, + std::vector<cmSourceFile*> const& filtered_sources, cmProp beforeInclude, + cmProp afterInclude, std::string const& filename_base); }; #if !defined(CMAKE_BOOTSTRAP) diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index 3995624..a18ca20 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -35,6 +35,11 @@ cmNinjaUtilityTargetGenerator::~cmNinjaUtilityTargetGenerator() = default; void cmNinjaUtilityTargetGenerator::Generate(const std::string& config) { + if (!this->GetGeneratorTarget()->Target->IsPerConfig()) { + this->WriteUtilBuildStatements(config, config); + return; + } + for (auto const& fileConfig : this->GetConfigNames()) { if (!this->GetGlobalGenerator() ->GetCrossConfigs(fileConfig) @@ -122,8 +127,6 @@ void cmNinjaUtilityTargetGenerator::WriteUtilBuildStatements( std::copy(util_outputs.begin(), util_outputs.end(), std::back_inserter(gg->GetByproductsForCleanTarget())); } - // TODO: Does this need an output config? - // Does this need to go in impl-<config>.ninja? lg->AppendTargetDepends(genTarget, deps, config, fileConfig, DependOnTargetArtifact); diff --git a/Source/kwsys/ProcessWin32.c b/Source/kwsys/ProcessWin32.c index 1267076..8f01684 100644 --- a/Source/kwsys/ProcessWin32.c +++ b/Source/kwsys/ProcessWin32.c @@ -962,7 +962,10 @@ void kwsysProcess_Execute(kwsysProcess* cp) kwsysProcessCleanup(cp, GetLastError()); return; } - SetCurrentDirectoryW(cp->WorkingDirectory); + if (!SetCurrentDirectoryW(cp->WorkingDirectory)) { + kwsysProcessCleanup(cp, GetLastError()); + return; + } } /* Setup the stdin pipe for the first process. */ diff --git a/Templates/MSBuild/FlagTables/v142_CSharp.json b/Templates/MSBuild/FlagTables/v142_CSharp.json index 5989aea..4dcea9d 100644 --- a/Templates/MSBuild/FlagTables/v142_CSharp.json +++ b/Templates/MSBuild/FlagTables/v142_CSharp.json @@ -201,6 +201,13 @@ "flags": [] }, { + "name": "DebugType", + "switch": "debug:portable", + "comment": "", + "value": "portable", + "flags": [] + }, + { "name": "Optimize", "switch": "optimize", "comment": "", @@ -264,6 +271,17 @@ "flags": [] }, { + "name": "WarningsAsErrors", + "switch": "warnaserror:", + "comment": "", + "value": "", + "flags": [ + "UserValue", + "UserRequired", + "CommaAppendable" + ] + }, + { "name": "WarningLevel", "switch": "warn:0", "comment": "", diff --git a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake index 480d628..21c2658 100644 --- a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake @@ -85,6 +85,9 @@ set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=RelWithDebInfo\\;Debug\\; run_cmake_configure(Simple) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) +run_ninja(Simple targets-default build.ninja -t targets) +run_ninja(Simple targets-debug build-Debug.ninja -t targets) +run_ninja(Simple targets-release build-Debug.ninja -t targets) run_cmake_build(Simple debug-target Debug simpleexe) run_ninja(Simple debug-target build-Debug.ninja simplestatic) get_filename_component(simpleshared_Release "${TARGET_FILE_simpleshared_Release}" NAME) diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-targets-debug-ninja-stdout.txt b/Tests/RunCMake/NinjaMultiConfig/Simple-targets-debug-ninja-stdout.txt new file mode 100644 index 0000000..f72516f --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Simple-targets-debug-ninja-stdout.txt @@ -0,0 +1,3 @@ +(rebuild_cache: phony.* +edit_cache: phony|edit_cache: phony.* +rebuild_cache: phony) diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-targets-default-ninja-stdout.txt b/Tests/RunCMake/NinjaMultiConfig/Simple-targets-default-ninja-stdout.txt new file mode 100644 index 0000000..f72516f --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Simple-targets-default-ninja-stdout.txt @@ -0,0 +1,3 @@ +(rebuild_cache: phony.* +edit_cache: phony|edit_cache: phony.* +rebuild_cache: phony) diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-targets-release-ninja-stdout.txt b/Tests/RunCMake/NinjaMultiConfig/Simple-targets-release-ninja-stdout.txt new file mode 100644 index 0000000..f72516f --- /dev/null +++ b/Tests/RunCMake/NinjaMultiConfig/Simple-targets-release-ninja-stdout.txt @@ -0,0 +1,3 @@ +(rebuild_cache: phony.* +edit_cache: phony|edit_cache: phony.* +rebuild_cache: phony) diff --git a/Tests/RunCMake/UnityBuild/f.cxx b/Tests/RunCMake/UnityBuild/f.cxx new file mode 100644 index 0000000..d5813c6 --- /dev/null +++ b/Tests/RunCMake/UnityBuild/f.cxx @@ -0,0 +1,5 @@ +int f(int x) +{ + (void)x; + return 0; +} diff --git a/Tests/RunCMake/UnityBuild/unitybuild_anon_ns-build-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_anon_ns-build-check.cmake new file mode 100644 index 0000000..746be32 --- /dev/null +++ b/Tests/RunCMake/UnityBuild/unitybuild_anon_ns-build-check.cmake @@ -0,0 +1,10 @@ +set(unitybuild_0 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_cxx.cxx") + +file(STRINGS ${unitybuild_0} src) + +foreach(expectedRegex IN ITEMS "SRC_f\\.cxx" "BLD_s1\\.cpp") + if(NOT "${src}" MATCHES "${expectedRegex}") + set(RunCMake_TEST_FAILED "Generated unity file doesn't have a match for expected unity ID regex ${expectedRegex}") + return() + endif() +endforeach() diff --git a/Tests/RunCMake/UnityBuild/unitybuild_anon_ns.cmake b/Tests/RunCMake/UnityBuild/unitybuild_anon_ns.cmake index 6f4878f..e05863d 100644 --- a/Tests/RunCMake/UnityBuild/unitybuild_anon_ns.cmake +++ b/Tests/RunCMake/UnityBuild/unitybuild_anon_ns.cmake @@ -4,7 +4,7 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/unitybuild_anon_ns_test_files.cmake) write_unity_build_anon_ns_test_files(srcs) -add_library(tgt SHARED ${srcs}) +add_library(tgt SHARED f.cxx ${srcs}) set_target_properties(tgt PROPERTIES UNITY_BUILD ON) diff --git a/Utilities/std/cm/optional b/Utilities/std/cm/optional index 0defae1..2ebc78c 100644 --- a/Utilities/std/cm/optional +++ b/Utilities/std/cm/optional @@ -313,7 +313,7 @@ bool operator!=(const optional<T>& opt, nullopt_t) noexcept } template <typename T> -bool operator<(const optional<T>& opt, nullopt_t) noexcept +bool operator<(const optional<T>& /*opt*/, nullopt_t) noexcept { return false; } @@ -331,7 +331,7 @@ bool operator>(const optional<T>& opt, nullopt_t) noexcept } template <typename T> -bool operator>=(const optional<T>& opt, nullopt_t) noexcept +bool operator>=(const optional<T>& /*opt*/, nullopt_t) noexcept { return true; } @@ -355,13 +355,13 @@ bool operator<(nullopt_t, const optional<T>& opt) noexcept } template <typename T> -bool operator<=(nullopt_t, const optional<T>& opt) noexcept +bool operator<=(nullopt_t, const optional<T>& /*opt*/) noexcept { return true; } template <typename T> -bool operator>(nullopt_t, const optional<T>& opt) noexcept +bool operator>(nullopt_t, const optional<T>& /*opt*/) noexcept { return false; } |