From kwrobot at kitware.com Sun Sep 1 23:54:55 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Sun, 1 Sep 2019 23:54:55 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-923-g679f5a0 Message-ID: <20190902035455.BF6C9FA03F@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 679f5a0ec7d833a6f0b870534d1433796fba9ef3 (commit) from ff7c31abfd110e769e422d5005a8a41b21153fd6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=679f5a0ec7d833a6f0b870534d1433796fba9ef3 commit 679f5a0ec7d833a6f0b870534d1433796fba9ef3 Author: Kitware Robot AuthorDate: Mon Sep 2 00:01:03 2019 -0400 Commit: Kitware Robot CommitDate: Mon Sep 2 00:01:03 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 14e1aa2..c8e14b0 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 15) -set(CMake_VERSION_PATCH 20190901) +set(CMake_VERSION_PATCH 20190902) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Sep 3 00:02:37 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 3 Sep 2019 00:02:37 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-924-gcfae4c6 Message-ID: <20190903040237.4FE1012519D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via cfae4c657fb0fff18cffd294fc5516cddfc174d1 (commit) from 679f5a0ec7d833a6f0b870534d1433796fba9ef3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cfae4c657fb0fff18cffd294fc5516cddfc174d1 commit cfae4c657fb0fff18cffd294fc5516cddfc174d1 Author: Kitware Robot AuthorDate: Tue Sep 3 00:01:04 2019 -0400 Commit: Kitware Robot CommitDate: Tue Sep 3 00:01:04 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index c8e14b0..46f7cce 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 15) -set(CMake_VERSION_PATCH 20190902) +set(CMake_VERSION_PATCH 20190903) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Sep 3 09:22:24 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 3 Sep 2019 09:22:24 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-926-g917cfec Message-ID: <20190903132224.D8DB610B1FD@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 917cfecf12b77294370cf96150becbb4c0a9db1c (commit) via 9da1c33cf1613d2b5b8192c2cffefa87466b002f (commit) from cfae4c657fb0fff18cffd294fc5516cddfc174d1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=917cfecf12b77294370cf96150becbb4c0a9db1c commit 917cfecf12b77294370cf96150becbb4c0a9db1c Merge: cfae4c6 9da1c33 Author: Brad King AuthorDate: Tue Sep 3 13:21:28 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 3 09:21:47 2019 -0400 Merge topic 'fileapi-CMP0037-OLD' 9da1c33cf1 fileapi: Fix codemodel v2 target file name for CMP0037 OLD behavior Acked-by: Kitware Robot Merge-request: !3760 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9da1c33cf1613d2b5b8192c2cffefa87466b002f commit 9da1c33cf1613d2b5b8192c2cffefa87466b002f Author: Brad King AuthorDate: Fri Aug 30 10:18:28 2019 -0400 Commit: Brad King CommitDate: Fri Aug 30 10:20:12 2019 -0400 fileapi: Fix codemodel v2 target file name for CMP0037 OLD behavior With CMP0037 OLD behavior, executable and library target names may contain a slash. Avoid constructing file names with slashes. Fixes: #19653 diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 6025025..fecbf63 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -502,6 +502,12 @@ Json::Value CodemodelConfig::DumpTarget(cmGeneratorTarget* gt, { Target t(gt, this->Config); std::string prefix = "target-" + gt->GetName(); + for (char& c : prefix) { + // CMP0037 OLD behavior allows slashes in target names. Remove them. + if (c == '/' || c == '\\') { + c = '_'; + } + } if (!this->Config.empty()) { prefix += "-" + this->Config; } ----------------------------------------------------------------------- Summary of changes: Source/cmFileAPICodemodel.cxx | 6 ++++++ 1 file changed, 6 insertions(+) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Sep 3 09:32:27 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 3 Sep 2019 09:32:27 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-939-g2e6effd Message-ID: <20190903133227.3B3164C64@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 2e6effd2e0d8e60ede4aa528e771430071c546b4 (commit) via d615ce4386f98cfac4d90e136cb272ec2d635e15 (commit) via c1dbbef2395847d9b68e4c7871f97066bdbad3a3 (commit) via ea63df139efbe70b58fe95c7f0f4b6b35dd04a95 (commit) via 3b8fa496e7a9482cb4592e9f36b54f5b1bc3cdea (commit) via 7828577065afe8cf59434166ae0a0589689caea2 (commit) via cf29fa18c8f0e7e482a0668ac1f36d1928080214 (commit) via d7df3cd73f00aefd1878d2842ee8b56541ae3c44 (commit) via 8ff43de1a509b779fe6635086e16f6808a4dc765 (commit) via da5ac4bb602bafb97b4dc0e012f1d26bbab58e3a (commit) via 1ae24ee1087c62740a9ed357a81274a9f9e8e70d (commit) via 5c028c27eb807e22f7d6095da4d9b694487ede05 (commit) via d4e6b2ae25659699fccf6bc5888e87179f41b23a (commit) from 917cfecf12b77294370cf96150becbb4c0a9db1c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2e6effd2e0d8e60ede4aa528e771430071c546b4 commit 2e6effd2e0d8e60ede4aa528e771430071c546b4 Merge: d615ce4 da5ac4b Author: Brad King AuthorDate: Tue Sep 3 13:29:57 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 3 09:30:15 2019 -0400 Merge topic 'cpack-install-multiple-configurations' da5ac4bb60 cpack: Add `CPACK_INSTALL_CMAKE_CONFIGURATIONS` variable d4e6b2ae25 Refactor: Use `unique_ptr` instead of raw pointer Acked-by: Kitware Robot Merge-request: !3533 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d615ce4386f98cfac4d90e136cb272ec2d635e15 commit d615ce4386f98cfac4d90e136cb272ec2d635e15 Merge: c1dbbef 5c028c2 Author: Brad King AuthorDate: Tue Sep 3 13:26:58 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 3 09:27:39 2019 -0400 Merge topic 'xcode11-swift' 5c028c27eb Xcode: Relax swift compiler detection regex for Xcode 11 Acked-by: Kitware Robot Merge-request: !3758 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c1dbbef2395847d9b68e4c7871f97066bdbad3a3 commit c1dbbef2395847d9b68e4c7871f97066bdbad3a3 Merge: ea63df1 3b8fa49 Author: Brad King AuthorDate: Tue Sep 3 09:26:03 2019 -0400 Commit: Brad King CommitDate: Tue Sep 3 09:26:03 2019 -0400 Merge branch 'release-3.15' https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ea63df139efbe70b58fe95c7f0f4b6b35dd04a95 commit ea63df139efbe70b58fe95c7f0f4b6b35dd04a95 Merge: 917cfec 7828577 Author: Brad King AuthorDate: Tue Sep 3 13:23:22 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 3 09:23:48 2019 -0400 Merge topic 'FindBoost-1.71' 7828577065 FindBoost: Add support for Boost 1.71 cf29fa18c8 FindBoost: Unwrap compatibility INTERFACE targets for legacy variables d7df3cd73f FindBoost: Remove incorrect 1.70 timer dependency 8ff43de1a5 FindBoost: Simplify conditional block for last known version Acked-by: Kitware Robot Acked-by: Dennis Klein Merge-request: !3763 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=da5ac4bb602bafb97b4dc0e012f1d26bbab58e3a commit da5ac4bb602bafb97b4dc0e012f1d26bbab58e3a Author: Alex Turbov AuthorDate: Wed Jul 10 00:07:55 2019 +0300 Commit: Brad King CommitDate: Fri Aug 30 11:02:43 2019 -0400 cpack: Add `CPACK_INSTALL_CMAKE_CONFIGURATIONS` variable For the multi-configuration generators one can specify the list of configurations to include in the package. E.g. having a project, where debug libraries have a suffix to distinct them from the release builds, one can build the package containing both `Debug` and `Release` binaries. diff --git a/Help/manual/cpack.1.rst b/Help/manual/cpack.1.rst index 10f617e..f82c466 100644 --- a/Help/manual/cpack.1.rst +++ b/Help/manual/cpack.1.rst @@ -48,9 +48,11 @@ Options the :variable:`CPACK_GENERATOR` variable determines the default set of generators that will be used. -``-C `` - Specify the project configuration to be packaged (e.g. ``Debug``, - ``Release``, etc.). When the CMake project uses a multi-configuration +``-C `` + Specify the project configuration(s) to be packaged (e.g. ``Debug``, + ``Release``, etc.), where ```` is a + :ref:`semicolon-separated list `. + When the CMake project uses a multi-configuration generator such as Xcode or Visual Studio, this option is needed to tell ``cpack`` which built executables to include in the package. diff --git a/Help/release/dev/cpack-install-multiple-configurations.rst b/Help/release/dev/cpack-install-multiple-configurations.rst new file mode 100644 index 0000000..d1692dc --- /dev/null +++ b/Help/release/dev/cpack-install-multiple-configurations.rst @@ -0,0 +1,5 @@ +cpack-install-multiple-configurations +------------------------------------- + +* CPack learned :variable:`CPACK_INSTALL_CMAKE_CONFIGURATIONS` to control + what configurations going to be packaged for multi-configuration generators. diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index 8a6a712..1809846 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -301,6 +301,13 @@ The following variables are for advanced uses of CPack: project. Defaults to the value of :variable:`CMAKE_GENERATOR`. Few users will want to change this setting. +.. variable:: CPACK_INSTALL_CMAKE_CONFIGURATIONS + + Specify the project configurations to be packaged (e.g. ``Debug``, ``Release``, + etc.). When the CMake project uses a multi-configuration generator such as Xcode + or Visual Studio, this option can be used to specify what configurations + to include in the package. + .. variable:: CPACK_INSTALL_CMAKE_PROJECTS List of four values that specify what project to install. The four values diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 46c602e..065aadf 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -598,8 +598,34 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( componentsVector.push_back(project.Component); } - const char* buildConfigCstr = this->GetOption("CPACK_BUILD_CONFIG"); - std::string buildConfig = buildConfigCstr ? buildConfigCstr : ""; + std::vector buildConfigs; + + // Try get configuration names given via `-C` CLI option + { + const char* const buildConfigCstr = + this->GetOption("CPACK_BUILD_CONFIG"); + auto buildConfig = buildConfigCstr ? buildConfigCstr : std::string{}; + cmExpandList(buildConfig, buildConfigs); + } + + // Try get configurations requested by the user explicitly + { + const char* const configsCstr = + this->GetOption("CPACK_INSTALL_CMAKE_CONFIGURATIONS"); + auto configs = configsCstr ? configsCstr : std::string{}; + cmExpandList(configs, buildConfigs); + } + + // Remove duplicates + std::sort(buildConfigs.begin(), buildConfigs.end()); + buildConfigs.erase(std::unique(buildConfigs.begin(), buildConfigs.end()), + buildConfigs.end()); + + // Ensure we have at least one configuration. + if (buildConfigs.empty()) { + buildConfigs.emplace_back(); + } + std::unique_ptr globalGenerator( this->MakefileMap->GetCMakeInstance()->CreateGlobalGenerator( cmakeGenerator)); @@ -615,25 +641,29 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( // on windows. cmSystemTools::SetForceUnixPaths(globalGenerator->GetForceUnixPaths()); - if (!this->RunPreinstallTarget(project.ProjectName, project.Directory, - globalGenerator.get(), buildConfig)) { - return 0; - } - - cmCPackLogger(cmCPackLog::LOG_OUTPUT, - "- Install project: " << project.ProjectName << std::endl); - - // Run the installation for each component - for (std::string const& component : componentsVector) { - if (!this->InstallCMakeProject( - setDestDir, project.Directory, baseTempInstallDirectory, - default_dir_mode, component, componentInstall, - project.SubDirectory, buildConfig, absoluteDestFiles)) { + // Run the installation for the selected build configurations + for (auto const& buildConfig : buildConfigs) { + if (!this->RunPreinstallTarget(project.ProjectName, project.Directory, + globalGenerator.get(), buildConfig)) { return 0; } + + cmCPackLogger(cmCPackLog::LOG_OUTPUT, + "- Install project: " << project.ProjectName << " [" + << buildConfig << ']' + << std::endl); + // Run the installation for each component + for (std::string const& component : componentsVector) { + if (!this->InstallCMakeProject( + setDestDir, project.Directory, baseTempInstallDirectory, + default_dir_mode, component, componentInstall, + project.SubDirectory, buildConfig, absoluteDestFiles)) { + return 0; + } + } } - this->CMakeProjects.push_back(project); + this->CMakeProjects.emplace_back(std::move(project)); } } this->SetOption("CPACK_ABSOLUTE_DESTINATION_FILES", diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index d93f280..8e98961 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -36,3 +36,6 @@ run_cpack_test(MD5SUMS "DEB.MD5SUMS" false "MONOLITHIC;COMPONENT") run_cpack_test_subtests(CPACK_INSTALL_SCRIPTS "singular;plural;both" "ZIP" false "MONOLITHIC") run_cpack_test(DEB_PACKAGE_VERSION_BACK_COMPATIBILITY "DEB.DEB_PACKAGE_VERSION_BACK_COMPATIBILITY" false "MONOLITHIC;COMPONENT") run_cpack_test_subtests(EXTERNAL "none;good;good_multi;bad_major;bad_minor;invalid_good;invalid_bad;stage_and_package" "External" false "MONOLITHIC;COMPONENT") +if(RunCMake_GENERATOR MATCHES "Visual Studio|Xcode") + run_cpack_test(CPACK_INSTALL_CMAKE_CONFIGURATIONS "ZIP" false "MONOLITHIC") +endif() diff --git a/Tests/RunCMake/CPack/tests/CPACK_INSTALL_CMAKE_CONFIGURATIONS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/CPACK_INSTALL_CMAKE_CONFIGURATIONS/ExpectedFiles.cmake new file mode 100644 index 0000000..34c7f8a --- /dev/null +++ b/Tests/RunCMake/CPack/tests/CPACK_INSTALL_CMAKE_CONFIGURATIONS/ExpectedFiles.cmake @@ -0,0 +1,3 @@ +set(EXPECTED_FILES_COUNT "1") + +set(EXPECTED_FILE_CONTENT_1_LIST "foo;foo/debug.txt;foo/release.txt") diff --git a/Tests/RunCMake/CPack/tests/CPACK_INSTALL_CMAKE_CONFIGURATIONS/ZIP-stdout.txt b/Tests/RunCMake/CPack/tests/CPACK_INSTALL_CMAKE_CONFIGURATIONS/ZIP-stdout.txt new file mode 100644 index 0000000..2a3aa9e --- /dev/null +++ b/Tests/RunCMake/CPack/tests/CPACK_INSTALL_CMAKE_CONFIGURATIONS/ZIP-stdout.txt @@ -0,0 +1,3 @@ +CPack: Install projects +CPack: - Install project: CPACK_INSTALL_CMAKE_CONFIGURATIONS-MONOLITHIC-type \[Debug\] +CPack: - Install project: CPACK_INSTALL_CMAKE_CONFIGURATIONS-MONOLITHIC-type \[Release\] diff --git a/Tests/RunCMake/CPack/tests/CPACK_INSTALL_CMAKE_CONFIGURATIONS/test.cmake b/Tests/RunCMake/CPack/tests/CPACK_INSTALL_CMAKE_CONFIGURATIONS/test.cmake new file mode 100644 index 0000000..4f562cf --- /dev/null +++ b/Tests/RunCMake/CPack/tests/CPACK_INSTALL_CMAKE_CONFIGURATIONS/test.cmake @@ -0,0 +1,9 @@ +set(CMAKE_CONFIGURATION_TYPES Debug Release) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/debug.txt" "debug content") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/release.txt" "release content") + +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/debug.txt" DESTINATION "foo" CONFIGURATIONS Debug) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/release.txt" DESTINATION "foo" CONFIGURATIONS Release) + +set(CPACK_INSTALL_CMAKE_CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES}) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5c028c27eb807e22f7d6095da4d9b694487ede05 commit 5c028c27eb807e22f7d6095da4d9b694487ede05 Author: Gregor Jasny AuthorDate: Fri Aug 30 09:33:37 2019 +0200 Commit: Gregor Jasny CommitDate: Fri Aug 30 10:53:58 2019 +0200 Xcode: Relax swift compiler detection regex for Xcode 11 The Xcode 11 output: ``` CompileSwift normal x86_64 /Users/gregorj/Git/cmake/_build_xcode/Tests/SwiftOnly/CMakeFiles/3.15.20190826-g89479bd/CompilerIdSwift/CompilerId/main.swift (in target 'CompilerIdSwift' from project 'CompilerIdSwift') cd /Users/gregorj/Git/cmake/_build_xcode/Tests/SwiftOnly/CMakeFiles/3.15.20190826-g89479bd/CompilerIdSwift /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/gregorj/Git/cmake/_build_xcode/Tests/SwiftOnly/CMakeFiles/3.15.20190826-g89479bd/CompilerIdSwift/CompilerId/main.swift ... ``` The Xcode 10 output: ``` CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler cd /Users/gjasny/src/cmake/Tests/SwiftOnly /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -incremental -module-name SwiftOnly -O -enable-batch-mode -enforce-exclusivity=checked -swift-version 5.0 -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -target x86_64-apple-macosx10.14 -g -Xfrontend -serialize-debugging-options -swift-version 5 -Xlinker -rpath -Xlinker /usr/lib/swift -I /Users/gjasny/src/cmake/_build_xcode/Tests/SwiftOnly/Debug -F /Users/gjasny/src/cmake/_build_xcode/Tests/SwiftOnly/Debug -c -j24 /Users/gjasny/src/cmake/Tests/SwiftOnly/main.swift ... CompileSwift normal x86_64 /Users/gjasny/src/cmake/Tests/SwiftOnly/main.swift cd /Users/gjasny/src/cmake/Tests/SwiftOnly /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/gjasny/src/cmake/Tests/SwiftOnly/main.swift ... ``` The Xcode 11 output lacks the CompileSwiftSources action but the CompileSwift action is present for both and also look suitable. diff --git a/Modules/CMakeDetermineSwiftCompiler.cmake b/Modules/CMakeDetermineSwiftCompiler.cmake index 2fcf7b0..9aafe48 100644 --- a/Modules/CMakeDetermineSwiftCompiler.cmake +++ b/Modules/CMakeDetermineSwiftCompiler.cmake @@ -53,7 +53,7 @@ if(NOT CMAKE_Swift_COMPILER_ID_RUN) list(APPEND CMAKE_Swift_COMPILER_ID_MATCH_VENDORS Apple) set(CMAKE_Swift_COMPILER_ID_MATCH_VENDOR_REGEX_Apple "com.apple.xcode.tools.swift.compiler") - set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_REGEX "\nCompileSwiftSources[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]* -c[^\r\n]*CompilerIdSwift/CompilerId/main.swift") + set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_REGEX "\nCompileSwift[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]* -c[^\r\n]*CompilerIdSwift/CompilerId/main.swift") set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_INDEX 2) endif() https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d4e6b2ae25659699fccf6bc5888e87179f41b23a commit d4e6b2ae25659699fccf6bc5888e87179f41b23a Author: Alex Turbov AuthorDate: Tue Jul 9 17:56:47 2019 +0300 Commit: Brad King CommitDate: Mon Aug 19 15:25:06 2019 -0400 Refactor: Use `unique_ptr` instead of raw pointer diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index f3de53c..46c602e 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -600,9 +600,9 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( const char* buildConfigCstr = this->GetOption("CPACK_BUILD_CONFIG"); std::string buildConfig = buildConfigCstr ? buildConfigCstr : ""; - cmGlobalGenerator* globalGenerator = + std::unique_ptr globalGenerator( this->MakefileMap->GetCMakeInstance()->CreateGlobalGenerator( - cmakeGenerator); + cmakeGenerator)); if (!globalGenerator) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Specified package generator not found. " @@ -616,12 +616,10 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( cmSystemTools::SetForceUnixPaths(globalGenerator->GetForceUnixPaths()); if (!this->RunPreinstallTarget(project.ProjectName, project.Directory, - globalGenerator, buildConfig)) { + globalGenerator.get(), buildConfig)) { return 0; } - delete globalGenerator; - cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Install project: " << project.ProjectName << std::endl); ----------------------------------------------------------------------- Summary of changes: Help/manual/cpack.1.rst | 8 ++- .../dev/cpack-install-multiple-configurations.rst | 5 ++ Modules/CMakeDetermineSwiftCompiler.cmake | 2 +- Modules/CPack.cmake | 7 +++ Modules/FindBoost.cmake | 49 +++++++++------ Source/CPack/cmCPackGenerator.cxx | 70 +++++++++++++++------- Tests/RunCMake/CPack/RunCMakeTest.cmake | 3 + .../ExpectedFiles.cmake | 3 + .../ZIP-stdout.txt | 3 + .../CPACK_INSTALL_CMAKE_CONFIGURATIONS/test.cmake | 9 +++ .../FindBoost/CMakePackage_New/BoostConfig.cmake | 5 ++ 11 files changed, 121 insertions(+), 43 deletions(-) create mode 100644 Help/release/dev/cpack-install-multiple-configurations.rst create mode 100644 Tests/RunCMake/CPack/tests/CPACK_INSTALL_CMAKE_CONFIGURATIONS/ExpectedFiles.cmake create mode 100644 Tests/RunCMake/CPack/tests/CPACK_INSTALL_CMAKE_CONFIGURATIONS/ZIP-stdout.txt create mode 100644 Tests/RunCMake/CPack/tests/CPACK_INSTALL_CMAKE_CONFIGURATIONS/test.cmake hooks/post-receive -- CMake From kwrobot at kitware.com Tue Sep 3 09:32:27 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 3 Sep 2019 09:32:27 -0400 (EDT) Subject: [Cmake-commits] CMake branch, release, updated. v3.15.2-30-g3b8fa49 Message-ID: <20190903133227.53696113841@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, release has been updated via 3b8fa496e7a9482cb4592e9f36b54f5b1bc3cdea (commit) via 7828577065afe8cf59434166ae0a0589689caea2 (commit) via cf29fa18c8f0e7e482a0668ac1f36d1928080214 (commit) via d7df3cd73f00aefd1878d2842ee8b56541ae3c44 (commit) via 8ff43de1a509b779fe6635086e16f6808a4dc765 (commit) via 1ae24ee1087c62740a9ed357a81274a9f9e8e70d (commit) via 9da1c33cf1613d2b5b8192c2cffefa87466b002f (commit) from aeeccc3b15c6476ecdaa51d40bb9500900d11ce2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: Modules/FindBoost.cmake | 49 ++++++++++++++-------- Source/cmFileAPICodemodel.cxx | 6 +++ .../FindBoost/CMakePackage_New/BoostConfig.cmake | 5 +++ 3 files changed, 42 insertions(+), 18 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Sep 3 09:42:25 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 3 Sep 2019 09:42:25 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-958-g1f7bd00 Message-ID: <20190903134225.BEF2E10B1FD@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 1f7bd0032253296413770567a90a0a88b6cccb34 (commit) via c4f2f011084a5e64e6f3745071ea56a286758682 (commit) via 4684e64c84d49d9152ebab42c8bc4ffa57652041 (commit) via 54b69bd6426bffae6ba11b4d0d95a4ad8c31b309 (commit) via cee20ad5374e2547cad9f2847006cf753c301042 (commit) via d8e323761152dcf494606ca3436637a9cbbe1741 (commit) via dca9c33abc7ce6b041b378e1ebc43c35327027b3 (commit) via c856d4556b4ec28cb818ef3c7aca1e4a30e0499d (commit) via aaf24357802f577830659a441fdf41da83642b43 (commit) via 10507c6dc0918777d43b3f961bd18162866f0bbb (commit) via 25f29b974182ae7da36ace86e846b4c0b2807a68 (commit) via ee86770a3f9700374820f90959a9c0fa39b27409 (commit) via 0ad180d71294c513270b4d97cec40ad3af504faa (commit) via 55b0532128304cb60021831cd37adbe4eb5d3650 (commit) via 2d888e339064d39ae894b4df567441539c8c65da (commit) via fe683876952ee6172e46fe770b4f3e48c69646d1 (commit) via 079b8e29168dc081f37f79f3577a5c0690bb7051 (commit) via 6e3655db2cc8202424e54bdde83e4240eb680cc3 (commit) via df0247a3714667e0f60d64da1b30ea200c43c7d5 (commit) from 2e6effd2e0d8e60ede4aa528e771430071c546b4 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1f7bd0032253296413770567a90a0a88b6cccb34 commit 1f7bd0032253296413770567a90a0a88b6cccb34 Merge: c4f2f01 10507c6 Author: Brad King AuthorDate: Tue Sep 3 13:37:00 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 3 09:42:15 2019 -0400 Merge topic 'add-non-empty-configurations-getter' 10507c6dc0 cmMakefile: Add configurations getter with empty configuration default Acked-by: Kitware Robot Merge-request: !3759 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c4f2f011084a5e64e6f3745071ea56a286758682 commit c4f2f011084a5e64e6f3745071ea56a286758682 Merge: 4684e64 2d888e3 Author: Brad King AuthorDate: Tue Sep 3 13:37:29 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 3 09:40:44 2019 -0400 Merge topic 'rename-mutating-getfullpath-overload' 2d888e3390 cmSourceFile: Rename mutating GetFullPath() overload Acked-by: Kitware Robot Merge-request: !3757 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4684e64c84d49d9152ebab42c8bc4ffa57652041 commit 4684e64c84d49d9152ebab42c8bc4ffa57652041 Merge: 54b69bd dca9c33 Author: Brad King AuthorDate: Tue Sep 3 13:34:01 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 3 09:39:03 2019 -0400 Merge topic 'clang-ipo-support' dca9c33abc Tests: Remove old IPO test c856d4556b bindexplib: supporting llvm bitcode formats using llvm-nm 079b8e2916 Clang: prefer lld-link over link.exe 6e3655db2c Clang: add LTO support for GNU-command line clang on windows Acked-by: Kitware Robot Merge-request: !3527 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=54b69bd6426bffae6ba11b4d0d95a4ad8c31b309 commit 54b69bd6426bffae6ba11b4d0d95a4ad8c31b309 Merge: cee20ad aaf2435 Author: Brad King AuthorDate: Tue Sep 3 13:35:09 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 3 09:36:59 2019 -0400 Merge topic 'gtest-1.8.1' aaf2435780 FindGTest: Add support for googletest 1.8.1 folder structure Acked-by: Kitware Robot Merge-request: !3756 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cee20ad5374e2547cad9f2847006cf753c301042 commit cee20ad5374e2547cad9f2847006cf753c301042 Merge: d8e3237 25f29b9 Author: Brad King AuthorDate: Tue Sep 3 13:32:02 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 3 09:34:46 2019 -0400 Merge topic 'vs-cuda-custom-dir' 25f29b9741 cuda: Adapted tests to work with modified cuda toolset ee86770a3f cuda: Added docs for extended cuda toolset 0ad180d712 cuda: Extend cuda compiler detection to work with custom cuda path 55b0532128 cuda: Extend vs10 target generator to use custom cuda path df0247a371 cuda: Extend toolset argument to accept path Acked-by: Kitware Robot Merge-request: !3713 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d8e323761152dcf494606ca3436637a9cbbe1741 commit d8e323761152dcf494606ca3436637a9cbbe1741 Merge: 2e6effd fe68387 Author: Brad King AuthorDate: Tue Sep 3 13:30:36 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 3 09:33:02 2019 -0400 Merge topic 'FindPkgConfig-module-name' fe68387695 FindPkgConfig: return the module found by pkg_search_module Acked-by: Kitware Robot Merge-request: !3749 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dca9c33abc7ce6b041b378e1ebc43c35327027b3 commit dca9c33abc7ce6b041b378e1ebc43c35327027b3 Author: Zsolt Parragi AuthorDate: Thu Aug 29 11:52:18 2019 +0200 Commit: Brad King CommitDate: Fri Aug 30 11:31:06 2019 -0400 Tests: Remove old IPO test This test didn't really result in IPO compilation, there are other better tests for this. diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 34858b8..03d7a7e 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -416,7 +416,6 @@ if(BUILD_TESTING) ADD_TEST_MACRO(COnly COnly) ADD_TEST_MACRO(CxxOnly CxxOnly) ADD_TEST_MACRO(CxxSubdirC CxxSubdirC) - ADD_TEST_MACRO(IPO COnly/COnly) ADD_TEST_MACRO(OutDir runtime/OutDir) ADD_TEST_MACRO(OutName exe.OutName.exe) ADD_TEST_MACRO(ObjectLibrary UseCshared) diff --git a/Tests/IPO/CMakeLists.txt b/Tests/IPO/CMakeLists.txt deleted file mode 100644 index 6dabf86..0000000 --- a/Tests/IPO/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required (VERSION 2.8) -project(IPO NONE) - -set_property(DIRECTORY PROPERTY INTERPROCEDURAL_OPTIMIZATION 1) - -add_subdirectory(../COnly COnly) -add_subdirectory(../CxxOnly CxxOnly) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c856d4556b4ec28cb818ef3c7aca1e4a30e0499d commit c856d4556b4ec28cb818ef3c7aca1e4a30e0499d Author: Zsolt Parragi AuthorDate: Tue Aug 13 14:29:48 2019 +0200 Commit: Brad King CommitDate: Fri Aug 30 11:30:38 2019 -0400 bindexplib: supporting llvm bitcode formats using llvm-nm diff --git a/Source/bindexplib.cxx b/Source/bindexplib.cxx index a107294..7e5db26 100644 --- a/Source/bindexplib.cxx +++ b/Source/bindexplib.cxx @@ -64,9 +64,12 @@ */ #include "bindexplib.h" +#include "cmSystemTools.h" #include "cmsys/Encoding.hxx" #include "cmsys/FStream.hxx" #include +#include +#include #include #ifndef IMAGE_FILE_MACHINE_ARM @@ -301,7 +304,63 @@ private: bool IsI386; }; -bool DumpFile(const char* filename, std::set& symbols, +bool DumpFileWithLlvmNm(std::string const& nmPath, const char* filename, + std::set& symbols, + std::set& dataSymbols) +{ + std::string output; + // break up command line into a vector + std::vector command; + command.push_back(nmPath); + command.push_back("--no-weak"); + command.push_back("--defined-only"); + command.push_back("--format=posix"); + command.push_back(filename); + + // run the command + int exit_code = 0; + cmSystemTools::RunSingleCommand(command, &output, &output, &exit_code, "", + cmSystemTools::OUTPUT_NONE); + + if (exit_code != 0) { + fprintf(stderr, "llvm-nm returned an error: %s\n", output.c_str()); + return false; + } + + std::istringstream ss(output); + std::string line; + while (std::getline(ss, line)) { + if (line.empty()) { // last line + continue; + } + size_t sym_end = line.find(" "); + if (sym_end == std::string::npos) { + fprintf(stderr, "Couldn't parse llvm-nm output line: %s\n", + line.c_str()); + return false; + } + if (line.size() < sym_end + 1) { + fprintf(stderr, "Couldn't parse llvm-nm output line: %s\n", + line.c_str()); + return false; + } + const std::string sym = line.substr(0, sym_end); + const char sym_type = line[sym_end + 1]; + switch (sym_type) { + case 'D': + dataSymbols.insert(sym); + break; + case 'T': + symbols.insert(sym); + break; + } + } + + return true; +} + +bool DumpFile(std::string const& nmPath, const char* filename, + std::set& symbols, std::set& dataSymbols) { HANDLE hFile; @@ -356,16 +415,26 @@ bool DumpFile(const char* filename, std::set& symbols, (imageHeader->Machine == IMAGE_FILE_MACHINE_I386)); symbolDumper.DumpObjFile(); } else { - // check for /bigobj format + // check for /bigobj and llvm LTO format cmANON_OBJECT_HEADER_BIGOBJ* h = (cmANON_OBJECT_HEADER_BIGOBJ*)lpFileBase; if (h->Sig1 == 0x0 && h->Sig2 == 0xffff) { + // bigobj DumpSymbols symbolDumper((cmANON_OBJECT_HEADER_BIGOBJ*)lpFileBase, symbols, dataSymbols, (h->Machine == IMAGE_FILE_MACHINE_I386)); symbolDumper.DumpObjFile(); + } else if ( + // BCexCODE - llvm bitcode + (h->Sig1 == 0x4342 && h->Sig2 == 0xDEC0) || + // 0x0B17C0DE - llvm bitcode BC wrapper + (h->Sig1 == 0x0B17 && h->Sig2 == 0xC0DE)) { + + return DumpFileWithLlvmNm(nmPath, filename, symbols, dataSymbols); + } else { - printf("unrecognized file format in '%s'\n", filename); + printf("unrecognized file format in '%s, %u'\n", filename, + imageHeader->Machine); return false; } } @@ -378,7 +447,7 @@ bool DumpFile(const char* filename, std::set& symbols, bool bindexplib::AddObjectFile(const char* filename) { - return DumpFile(filename, this->Symbols, this->DataSymbols); + return DumpFile(NmPath, filename, this->Symbols, this->DataSymbols); } bool bindexplib::AddDefinitionFile(const char* filename) @@ -419,3 +488,8 @@ void bindexplib::WriteFile(FILE* file) fprintf(file, "\t%s\n", s.c_str()); } } + +void bindexplib::SetNmPath(std::string const& nm) +{ + NmPath = nm; +} diff --git a/Source/bindexplib.h b/Source/bindexplib.h index 3e22ac7..6c066c5 100644 --- a/Source/bindexplib.h +++ b/Source/bindexplib.h @@ -12,13 +12,16 @@ class bindexplib { public: - bindexplib() {} + bindexplib() { NmPath = "nm"; } bool AddDefinitionFile(const char* filename); bool AddObjectFile(const char* filename); void WriteFile(FILE* file); + void SetNmPath(std::string const& nm); + private: std::set Symbols; std::set DataSymbols; + std::string NmPath; }; #endif diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index f99fe4e..f84ec76 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -15,6 +15,7 @@ #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmGlobalUnixMakefileGenerator3.h" +#include "cmLocalCommonGenerator.h" #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" #include "cmMakefileExecutableTargetGenerator.h" @@ -1738,6 +1739,12 @@ void cmMakefileTargetGenerator::GenDefFile( this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), objlist_file), cmOutputConverter::SHELL); + const char* nm_executable = this->Makefile->GetDefinition("CMAKE_NM"); + if (nm_executable && *nm_executable) { + cmd += " --nm="; + cmd += this->LocalCommonGenerator->ConvertToOutputFormat( + nm_executable, cmOutputConverter::SHELL); + } real_link_commands.insert(real_link_commands.begin(), cmd); // create a list of obj files for the -E __create_def to read cmGeneratedFileStream fout(objlist_file); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 17a5527..df4d45d 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -20,6 +20,7 @@ #include "cmGlobalNinjaGenerator.h" #include "cmLinkLineComputer.h" #include "cmLinkLineDeviceComputer.h" +#include "cmLocalCommonGenerator.h" #include "cmLocalGenerator.h" #include "cmLocalNinjaGenerator.h" #include "cmMakefile.h" @@ -974,6 +975,13 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() std::string obj_list_file = mdi->DefFile + ".objs"; cmd += this->GetLocalGenerator()->ConvertToOutputFormat( obj_list_file, cmOutputConverter::SHELL); + + const char* nm_executable = GetMakefile()->GetDefinition("CMAKE_NM"); + if (nm_executable && *nm_executable) { + cmd += " --nm="; + cmd += this->LocalCommonGenerator->ConvertToOutputFormat( + nm_executable, cmOutputConverter::SHELL); + } preLinkCmdLines.push_back(std::move(cmd)); // create a list of obj files for the -E __create_def to read diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 2be8bae..08cad7d 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -558,8 +558,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args) #if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP) else if (args[1] == "__create_def") { if (args.size() < 4) { - std::cerr - << "__create_def Usage: -E __create_def outfile.def objlistfile\n"; + std::cerr << "__create_def Usage: -E __create_def outfile.def " + "objlistfile [-nm=nm-path]\n"; return 1; } FILE* fout = cmsys::SystemTools::Fopen(args[2].c_str(), "w+"); @@ -576,6 +576,15 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args) } std::string file; bindexplib deffile; + if (args.size() >= 5) { + auto a = args[4]; + if (cmHasLiteralPrefix(a, "--nm=")) { + deffile.SetNmPath(a.substr(5)); + std::cerr << a.substr(5) << "\n"; + } else { + std::cerr << "unknown argument: " << a << "\n"; + } + } while (cmSystemTools::GetLineFromStream(fin, file)) { std::string const& ext = cmSystemTools::GetFilenameLastExtension(file); if (cmSystemTools::LowerCase(ext) == ".def") { diff --git a/Tests/Module/CheckIPOSupported-C/CMakeLists.txt b/Tests/Module/CheckIPOSupported-C/CMakeLists.txt index 4a41a98..c5cd03e 100644 --- a/Tests/Module/CheckIPOSupported-C/CMakeLists.txt +++ b/Tests/Module/CheckIPOSupported-C/CMakeLists.txt @@ -13,8 +13,18 @@ elseif(CMake_TEST_IPO_WORKS_C) endif() add_library(foo foo.c) +if(NOT CYGWIN AND (NOT WIN32 OR "x${CMAKE_C_COMPILER_ID}" STREQUAL "xClang")) + add_library(bar SHARED bar.c) + if(WIN32) + # Bindexplib for clang supports LTO objects + set_target_properties(bar PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) + endif() +else() + # TODO: bindexplib doesn't support exporting IPO symbols with other compilers on Windows + add_library(bar STATIC bar.c) +endif() add_executable(CheckIPOSupported-C main.c) -target_link_libraries(CheckIPOSupported-C PUBLIC foo) +target_link_libraries(CheckIPOSupported-C PUBLIC foo bar) enable_testing() add_test(NAME CheckIPOSupported-C COMMAND CheckIPOSupported-C) diff --git a/Tests/Module/CheckIPOSupported-C/bar.c b/Tests/Module/CheckIPOSupported-C/bar.c new file mode 100644 index 0000000..680f213 --- /dev/null +++ b/Tests/Module/CheckIPOSupported-C/bar.c @@ -0,0 +1,4 @@ +int bar() +{ + return 0x42; +} diff --git a/Tests/Module/CheckIPOSupported-C/main.c b/Tests/Module/CheckIPOSupported-C/main.c index 99204ab..28ab26f 100644 --- a/Tests/Module/CheckIPOSupported-C/main.c +++ b/Tests/Module/CheckIPOSupported-C/main.c @@ -1,8 +1,9 @@ int foo(); +int bar(); int main() { - if (foo() == 0) { + if (foo() != bar()) { return 1; } return 0; diff --git a/Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt b/Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt index 1bb2b84..237bf1d 100644 --- a/Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt +++ b/Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt @@ -12,9 +12,20 @@ elseif(CMake_TEST_IPO_WORKS_CXX) message(FATAL_ERROR "IPO expected to work, but the check failed:\n ${ipo_output}") endif() -add_library(foo foo.cpp) + +add_library(foo STATIC foo.cpp) +if(NOT CYGWIN AND (NOT WIN32 OR "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")) + add_library(bar SHARED bar.cpp) + if(WIN32) + # Bindexplib for clang supports LTO objects + set_target_properties(bar PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON) + endif() +else() + # TODO: bindexplib doesn't support exporting IPO symbols with other compilers on Windows + add_library(bar STATIC bar.cpp) +endif() add_executable(CheckIPOSupported-CXX main.cpp) -target_link_libraries(CheckIPOSupported-CXX PUBLIC foo) +target_link_libraries(CheckIPOSupported-CXX PUBLIC foo bar) enable_testing() add_test(NAME CheckIPOSupported-CXX COMMAND CheckIPOSupported-CXX) diff --git a/Tests/Module/CheckIPOSupported-CXX/bar.cpp b/Tests/Module/CheckIPOSupported-CXX/bar.cpp new file mode 100644 index 0000000..680f213 --- /dev/null +++ b/Tests/Module/CheckIPOSupported-CXX/bar.cpp @@ -0,0 +1,4 @@ +int bar() +{ + return 0x42; +} diff --git a/Tests/Module/CheckIPOSupported-CXX/main.cpp b/Tests/Module/CheckIPOSupported-CXX/main.cpp index 99204ab..28ab26f 100644 --- a/Tests/Module/CheckIPOSupported-CXX/main.cpp +++ b/Tests/Module/CheckIPOSupported-CXX/main.cpp @@ -1,8 +1,9 @@ int foo(); +int bar(); int main() { - if (foo() == 0) { + if (foo() != bar()) { return 1; } return 0; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=aaf24357802f577830659a441fdf41da83642b43 commit aaf24357802f577830659a441fdf41da83642b43 Author: Kelby Faessler AuthorDate: Thu Aug 29 15:27:40 2019 -0400 Commit: Brad King CommitDate: Fri Aug 30 11:24:27 2019 -0400 FindGTest: Add support for googletest 1.8.1 folder structure diff --git a/Help/release/dev/gtest-1.8.1.rst b/Help/release/dev/gtest-1.8.1.rst new file mode 100644 index 0000000..2e48da4 --- /dev/null +++ b/Help/release/dev/gtest-1.8.1.rst @@ -0,0 +1,5 @@ +gtest-1.8.1 +----------- + +* The :module:`FindGTest` module has been updated to recognize + MSVC build trees generated by GTest 1.8.1. diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake index b0175fe..e015a98 100644 --- a/Modules/FindGTest.cmake +++ b/Modules/FindGTest.cmake @@ -160,6 +160,10 @@ if(MSVC) msvc/gtest-md/Release msvc/x64/Debug msvc/x64/Release + msvc/2010/gtest-md/Win32-Debug + msvc/2010/gtest-md/Win32-Release + msvc/2010/gtest-md/x64-Debug + msvc/2010/gtest-md/x64-Release ) elseif(GTEST_MSVC_SEARCH STREQUAL "MT") list(APPEND _gtest_libpath_suffixes @@ -167,6 +171,10 @@ if(MSVC) msvc/gtest/Release msvc/x64/Debug msvc/x64/Release + msvc/2010/gtest/Win32-Debug + msvc/2010/gtest/Win32-Release + msvc/2010/gtest/x64-Debug + msvc/2010/gtest/x64-Release ) endif() endif() https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=10507c6dc0918777d43b3f961bd18162866f0bbb commit 10507c6dc0918777d43b3f961bd18162866f0bbb Author: Daniel Eiband AuthorDate: Fri Aug 30 11:47:37 2019 +0200 Commit: Daniel Eiband CommitDate: Fri Aug 30 13:52:13 2019 +0200 cmMakefile: Add configurations getter with empty configuration default diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 01d4c07..6bf2f2d 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -197,11 +197,8 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) { std::set emitted; - std::vector configs; - depender->Makefile->GetConfigurations(configs); - if (configs.empty()) { - configs.emplace_back(); - } + std::vector const& configs = + depender->Makefile->GetGeneratorConfigs(); for (std::string const& it : configs) { std::vector objectFiles; depender->GetExternalObjects(objectFiles, it); diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 08db7c7..db6d675 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -423,20 +423,17 @@ Json::Value Codemodel::DumpPaths() Json::Value Codemodel::DumpConfigurations() { - std::vector configs; + Json::Value configurations = Json::arrayValue; cmGlobalGenerator* gg = this->FileAPI.GetCMakeInstance()->GetGlobalGenerator(); auto makefiles = gg->GetMakefiles(); if (!makefiles.empty()) { - makefiles[0]->GetConfigurations(configs); - if (configs.empty()) { - configs.emplace_back(); + std::vector const& configs = + makefiles[0]->GetGeneratorConfigs(); + for (std::string const& config : configs) { + configurations.append(this->DumpConfiguration(config)); } } - Json::Value configurations = Json::arrayValue; - for (std::string const& config : configs) { - configurations.append(this->DumpConfiguration(config)); - } return configurations; } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index cc37232..6de7d83 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -786,11 +786,8 @@ void cmGeneratorTarget::ComputeObjectMapping() return; } - std::vector configs; - this->Makefile->GetConfigurations(configs); - if (configs.empty()) { - configs.emplace_back(); - } + std::vector const& configs = + this->Makefile->GetGeneratorConfigs(); for (std::string const& c : configs) { std::vector sourceFiles; this->GetObjectSources(sourceFiles, c); @@ -2634,12 +2631,9 @@ cmTargetTraceDependencies::cmTargetTraceDependencies(cmGeneratorTarget* target) // Queue all the source files already specified for the target. if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { - std::vector configs; - this->Makefile->GetConfigurations(configs); - if (configs.empty()) { - configs.emplace_back(); - } std::set emitted; + std::vector const& configs = + this->Makefile->GetGeneratorConfigs(); for (std::string const& c : configs) { std::vector sources; this->GeneratorTarget->GetSourceFiles(sources, c); @@ -2825,12 +2819,9 @@ void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc) } // Queue the custom command dependencies. - std::vector configs; std::set emitted; - this->Makefile->GetConfigurations(configs); - if (configs.empty()) { - configs.emplace_back(); - } + std::vector const& configs = + this->Makefile->GetGeneratorConfigs(); for (std::string const& conf : configs) { this->FollowCommandDepends(cc, conf, emitted); } @@ -6077,11 +6068,8 @@ const cmLinkImplementation* cmGeneratorTarget::GetLinkImplementation( bool cmGeneratorTarget::GetConfigCommonSourceFiles( std::vector& files) const { - std::vector configs; - this->Makefile->GetConfigurations(configs); - if (configs.empty()) { - configs.emplace_back(); - } + std::vector const& configs = + this->Makefile->GetGeneratorConfigs(); std::vector::const_iterator it = configs.begin(); const std::string& firstConfig = *it; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 4342e9f..53ed535 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -337,12 +337,8 @@ bool cmGlobalGenerator::CheckTargetsForType() const for (cmGeneratorTarget* target : generator->GetGeneratorTargets()) { if (target->GetType() == cmStateEnums::EXECUTABLE && target->GetPropertyAsBool("WIN32_EXECUTABLE")) { - std::vector configs; - target->Makefile->GetConfigurations(configs); - if (configs.empty()) { - configs.emplace_back(); - } - + std::vector const& configs = + target->Makefile->GetGeneratorConfigs(); for (std::string const& config : configs) { if (target->GetLinkerLanguage(config) == "Swift") { this->GetCMakeInstance()->IssueMessage( @@ -2963,11 +2959,8 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) // List the source files with any per-source labels. fout << "# Source files and their labels\n"; std::vector sources; - std::vector configs; - target->Target->GetMakefile()->GetConfigurations(configs); - if (configs.empty()) { - configs.emplace_back(); - } + std::vector const& configs = + target->Target->GetMakefile()->GetGeneratorConfigs(); for (std::string const& c : configs) { target->GetSourceFiles(sources, c); } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 7177694..155e5b8 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -257,11 +257,8 @@ static void MoveSystemIncludesToEnd(std::vector>& includeDirs, void cmLocalGenerator::TraceDependencies() { - std::vector configs; - this->Makefile->GetConfigurations(configs); - if (configs.empty()) { - configs.emplace_back(); - } + std::vector const& configs = + this->Makefile->GetGeneratorConfigs(); for (std::string const& c : configs) { this->GlobalGenerator->CreateEvaluationSourceFiles(c); } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f101cdc..e65d264 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3057,6 +3057,16 @@ std::string cmMakefile::GetConfigurations(std::vector& configs, return buildType; } +std::vector cmMakefile::GetGeneratorConfigs() const +{ + std::vector configs; + GetConfigurations(configs); + if (configs.empty()) { + configs.emplace_back(); + } + return configs; +} + bool cmMakefile::IsFunctionBlocked(const cmListFileFunction& lff, cmExecutionStatus& status) { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index dcc4e77..6b9fa6b 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -292,6 +292,9 @@ public: std::string GetConfigurations(std::vector& configs, bool single = true) const; + /** Get the configurations for dependency checking. */ + std::vector GetGeneratorConfigs() const; + /** * Set the name of the library. */ https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=25f29b974182ae7da36ace86e846b4c0b2807a68 commit 25f29b974182ae7da36ace86e846b4c0b2807a68 Author: Benjamin Wozniak AuthorDate: Fri Aug 23 08:32:28 2019 +0200 Commit: Benjamin Wozniak CommitDate: Fri Aug 30 08:14:01 2019 +0200 cuda: Adapted tests to work with modified cuda toolset - cuda version is only recognized if it contains no other characters than "0123456789." - cuda path is only tested with dummy value . Otherwise a cuda toolkit must be copied to the integration test machine diff --git a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake index ef8fd25..ae75561 100644 --- a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake @@ -6,12 +6,14 @@ run_cmake(NoToolset) if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[012456]") set(RunCMake_GENERATOR_TOOLSET "Test Toolset") run_cmake(TestToolset) - set(RunCMake_GENERATOR_TOOLSET "Test Toolset,cuda=Test Cuda") + set(RunCMake_GENERATOR_TOOLSET "Test Toolset,cuda=0.0") run_cmake(TestToolsetCudaBoth) - set(RunCMake_GENERATOR_TOOLSET ",cuda=Test Cuda") - run_cmake(TestToolsetCudaOnly) - set(RunCMake_GENERATOR_TOOLSET "cuda=Test Cuda") - run_cmake(TestToolsetCudaOnly) + set(RunCMake_GENERATOR_TOOLSET ",cuda=0.0") + run_cmake(TestToolsetCudaVersionOnly) + set(RunCMake_GENERATOR_TOOLSET "cuda=0.0") + run_cmake(TestToolsetCudaVersionOnly) + set(RunCMake_GENERATOR_TOOLSET "cuda=C:\\dummy\\cuda") + run_cmake(TestToolsetCudaPathOnly) if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[2456]") set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64") run_cmake(TestToolsetHostArchBoth) diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaBoth-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaBoth-stdout.txt index 90503e2..f12c123 100644 --- a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaBoth-stdout.txt +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaBoth-stdout.txt @@ -1,2 +1,2 @@ -- CMAKE_VS_PLATFORM_TOOLSET='Test Toolset' --- CMAKE_VS_PLATFORM_TOOLSET_CUDA='Test Cuda' +-- CMAKE_VS_PLATFORM_TOOLSET_CUDA='0.0' diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-result.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-stderr.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-stderr.txt new file mode 100644 index 0000000..b17745f --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-stderr.txt @@ -0,0 +1,12 @@ +CMake Error at CMakeLists.txt:[0-9]+ \(project\): + Generator + + Visual Studio .* + + given toolset + + cuda=C:\\dummy\\cuda\\ + + cannot detect Visual Studio integration files in path + + C:/dummy/cuda/CUDAVisualStudioIntegration/extras/visual_studio_integration/MSBuildExtensions diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly.cmake new file mode 100644 index 0000000..2fc38e5 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "This should not be reached!") diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaOnly-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaVersionOnly-stdout.txt similarity index 54% rename from Tests/RunCMake/GeneratorToolset/TestToolsetCudaOnly-stdout.txt rename to Tests/RunCMake/GeneratorToolset/TestToolsetCudaVersionOnly-stdout.txt index 94e1e43..1717ff8 100644 --- a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaOnly-stdout.txt +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaVersionOnly-stdout.txt @@ -1,2 +1,2 @@ -- CMAKE_VS_PLATFORM_TOOLSET='(v[0-9]+|Windows7.1SDK)' --- CMAKE_VS_PLATFORM_TOOLSET_CUDA='Test Cuda' +-- CMAKE_VS_PLATFORM_TOOLSET_CUDA='0.0' diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaOnly.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaVersionOnly.cmake similarity index 100% rename from Tests/RunCMake/GeneratorToolset/TestToolsetCudaOnly.cmake rename to Tests/RunCMake/GeneratorToolset/TestToolsetCudaVersionOnly.cmake https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ee86770a3f9700374820f90959a9c0fa39b27409 commit ee86770a3f9700374820f90959a9c0fa39b27409 Author: Benjamin Wozniak AuthorDate: Wed Aug 21 16:14:40 2019 +0200 Commit: Benjamin Wozniak CommitDate: Fri Aug 30 08:14:00 2019 +0200 cuda: Added docs for extended cuda toolset diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 9ad1195..d6836b8 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -111,6 +111,7 @@ Variables that Provide Information /variable/CMAKE_VS_PLATFORM_NAME_DEFAULT /variable/CMAKE_VS_PLATFORM_TOOLSET /variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA + /variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR /variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE /variable/CMAKE_VS_PLATFORM_TOOLSET_VERSION /variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION diff --git a/Help/variable/CMAKE_GENERATOR_TOOLSET.rst b/Help/variable/CMAKE_GENERATOR_TOOLSET.rst index a01a8b7..222824f 100644 --- a/Help/variable/CMAKE_GENERATOR_TOOLSET.rst +++ b/Help/variable/CMAKE_GENERATOR_TOOLSET.rst @@ -40,10 +40,13 @@ The ``key=value`` pairs form a comma-separated list of options to specify generator-specific details of the toolset selection. Supported pairs are: -``cuda=`` - Specify the CUDA toolkit version to use. Supported by VS 2010 - and above with the CUDA toolkit VS integration installed. - See the :variable:`CMAKE_VS_PLATFORM_TOOLSET_CUDA` variable. +``cuda=|`` + Specify the CUDA toolkit version to use or the path to a + standalone CUDA toolkit directory. Supported by VS 2010 + and above. The version can only be used with the CUDA + toolkit VS integration globally installed. + See the :variable:`CMAKE_VS_PLATFORM_TOOLSET_CUDA` and + :variable:`CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR` variables. ``host=`` Specify the host tools architecture as ``x64`` or ``x86``. diff --git a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA.rst b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA.rst index 1604a76..67b7f74 100644 --- a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA.rst +++ b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA.rst @@ -6,7 +6,9 @@ NVIDIA CUDA Toolkit version whose Visual Studio toolset to use. The :ref:`Visual Studio Generators` for VS 2010 and above support using a CUDA toolset provided by a CUDA Toolkit. The toolset version number may be specified by a field in :variable:`CMAKE_GENERATOR_TOOLSET` of -the form ``cuda=8.0``. If none is specified CMake will choose a default -version. CMake provides the selected CUDA toolset version in this variable. +the form ``cuda=8.0``. Or it is automatically detected if a path to +a standalone CUDA directory is specified in the form ``cuda=C:\path\to\cuda``. +If none is specified CMake will choose a default version. +CMake provides the selected CUDA toolset version in this variable. The value may be empty if no CUDA Toolkit with Visual Studio integration is installed. diff --git a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst new file mode 100644 index 0000000..060648a --- /dev/null +++ b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst @@ -0,0 +1,16 @@ +CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR +----------------------------------------- + +Path to standalone NVIDIA CUDA Toolkit (eg. extracted from installer). + +The :ref:`Visual Studio Generators` for VS 2010 and above support using +a standalone (non-installed) NVIDIA CUDA toolkit. The path +may be specified by a field in :variable:`CMAKE_GENERATOR_TOOLSET` of +the form ``cuda=C:\path\to\cuda``. The given directory must at least +contain a folder ``.\nvcc`` and must provide Visual Studio integration +files in path ``.\CUDAVisualStudioIntegration\extras\ +visual_studio_integration\MSBuildExtensions\``. One can create a standalone +CUDA toolkit directory by either opening a installer with 7zip or +copying the files that are extracted by the running installer. +The value may be empty if no path to a standalone CUDA Toolkit was +specified. https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0ad180d71294c513270b4d97cec40ad3af504faa commit 0ad180d71294c513270b4d97cec40ad3af504faa Author: Benjamin Wozniak AuthorDate: Wed Aug 21 15:31:24 2019 +0200 Commit: Benjamin Wozniak CommitDate: Fri Aug 30 08:14:00 2019 +0200 cuda: Extend cuda compiler detection to work with custom cuda path diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 0fcbbb7..40658ea 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -347,8 +347,14 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} set(cuda_tools "CUDA ${CMAKE_VS_PLATFORM_TOOLSET_CUDA}") set(id_compile "CudaCompile") set(id_PostBuildEvent_Command [[echo CMAKE_CUDA_COMPILER=$(CudaToolkitBinDir)\nvcc.exe]]) - string(CONCAT id_Import_props [[]]) - string(CONCAT id_Import_targets [[]]) + if(CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR) + set(id_CudaToolkitCustomDir "${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}nvcc") + string(CONCAT id_Import_props "") + string(CONCAT id_Import_targets "") + else() + string(CONCAT id_Import_props [[]]) + string(CONCAT id_Import_targets [[]]) + endif() if(CMAKE_VS_PLATFORM_NAME STREQUAL x64) set(id_ItemDefinitionGroup_entry "64") endif() diff --git a/Modules/CompilerId/VS-10.vcxproj.in b/Modules/CompilerId/VS-10.vcxproj.in index 32c4ffc..d742274 100644 --- a/Modules/CompilerId/VS-10.vcxproj.in +++ b/Modules/CompilerId/VS-10.vcxproj.in @@ -14,6 +14,7 @@ @id_system_version@ @id_WindowsTargetPlatformVersion@ @id_WindowsSDKDesktopARMSupport@ + @id_CudaToolkitCustomDir@ @id_toolset_version_props@ https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=55b0532128304cb60021831cd37adbe4eb5d3650 commit 55b0532128304cb60021831cd37adbe4eb5d3650 Author: Benjamin Wozniak AuthorDate: Wed Aug 21 15:30:46 2019 +0200 Commit: Benjamin Wozniak CommitDate: Fri Aug 30 08:13:58 2019 +0200 cuda: Extend vs10 target generator to use custom cuda path diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 08378eb..fde214d 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -526,6 +526,13 @@ void cmVisualStudio10TargetGenerator::Generate() } e1.Element("TargetFrameworkTargetsVersion", targetFrameworkVer); } + if (!this->GlobalGenerator->GetPlatformToolsetCudaCustomDirString() + .empty()) { + e1.Element( + "CudaToolkitCustomDir", + this->GlobalGenerator->GetPlatformToolsetCudaCustomDirString() + + "nvcc"); + } } // Disable the project upgrade prompt that is displayed the first time a @@ -612,10 +619,17 @@ void cmVisualStudio10TargetGenerator::Generate() e1.SetHasElements(); if (this->GlobalGenerator->IsCudaEnabled()) { + auto customDir = + this->GlobalGenerator->GetPlatformToolsetCudaCustomDirString(); + std::string cudaPath = customDir.empty() + ? "$(VCTargetsPath)\\BuildCustomizations\\" + : customDir + + "CUDAVisualStudioIntegration\\extras\\" + "visual_studio_integration\\MSBuildExtensions\\"; Elem(e1, "Import") .Attribute("Project", - "$(VCTargetsPath)\\BuildCustomizations\\CUDA " + - this->GlobalGenerator->GetPlatformToolsetCudaString() + + std::move(cudaPath) + "CUDA " + + this->GlobalGenerator->GetPlatformToolsetCuda() + ".props"); } if (this->GlobalGenerator->IsMasmEnabled()) { @@ -698,10 +712,17 @@ void cmVisualStudio10TargetGenerator::Generate() e1.SetHasElements(); this->WriteTargetsFileReferences(e1); if (this->GlobalGenerator->IsCudaEnabled()) { + auto customDir = + this->GlobalGenerator->GetPlatformToolsetCudaCustomDirString(); + std::string cudaPath = customDir.empty() + ? "$(VCTargetsPath)\\BuildCustomizations\\" + : customDir + + "CUDAVisualStudioIntegration\\extras\\" + "visual_studio_integration\\MSBuildExtensions\\"; Elem(e1, "Import") .Attribute("Project", - "$(VCTargetsPath)\\BuildCustomizations\\CUDA " + - this->GlobalGenerator->GetPlatformToolsetCudaString() + + std::move(cudaPath) + "CUDA " + + this->GlobalGenerator->GetPlatformToolsetCuda() + ".targets"); } if (this->GlobalGenerator->IsMasmEnabled()) { https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2d888e339064d39ae894b4df567441539c8c65da commit 2d888e339064d39ae894b4df567441539c8c65da Author: Daniel Eiband AuthorDate: Thu Aug 29 17:31:44 2019 +0200 Commit: Daniel Eiband CommitDate: Thu Aug 29 22:51:58 2019 +0200 cmSourceFile: Rename mutating GetFullPath() overload Rename mutating GetFullPath() overload to ResolveFullPath(). diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index f0c1845..b20f595 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -536,7 +536,7 @@ void CCONV* cmGetSource(void* arg, const char* name) // Create a proxy source file object for this source. cmCPluginAPISourceFile* sf = new cmCPluginAPISourceFile; sf->RealSourceFile = rsf; - sf->FullPath = rsf->GetFullPath(); + sf->FullPath = rsf->ResolveFullPath(); sf->SourceName = cmSystemTools::GetFilenameWithoutLastExtension(sf->FullPath); sf->SourceExtension = diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 487d0de..6b16b93 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -371,7 +371,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( isCFile = cm->IsSourceExtension(srcext); } - std::string const& fullPath = s->GetFullPath(); + std::string const& fullPath = s->ResolveFullPath(); // Check file position relative to project root dir. const std::string relative = diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index 7f71a2c..0956729 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -223,7 +223,7 @@ std::string cmExtraCodeLiteGenerator::CollectSourceFiles( gt->GetSourceFiles(sources, makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); for (cmSourceFile* s : sources) { - std::string const& fullPath = s->GetFullPath(); + std::string const& fullPath = s->ResolveFullPath(); std::string const& extLower = cmSystemTools::LowerCase(s->GetExtension()); // check whether it is a source or a include file diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 6c94aae..43f1e12 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -524,7 +524,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(cmXMLWriter& xml) makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); for (cmSourceFile* sf : files) { // Add the file to the list of sources. - std::string const& source = sf->GetFullPath(); + std::string const& source = sf->ResolveFullPath(); cmSourceGroup* sourceGroup = makefile->FindSourceGroup(source, sourceGroups); sourceGroup->AssignSource(sf); diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index 2bfbb0d..7ac73cf 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -254,7 +254,7 @@ std::string cmExtraKateGenerator::GenerateFilesString( continue; } - tmp = sf->GetFullPath(); + tmp = sf->ResolveFullPath(); files.insert(tmp); } } diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 6f4472b..52ba968 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -243,12 +243,12 @@ void cmExtraSublimeTextGenerator::AppendTarget( makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); for (cmSourceFile* sourceFile : sourceFiles) { MapSourceFileFlags::iterator sourceFileFlagsIter = - sourceFileFlags.find(sourceFile->GetFullPath()); + sourceFileFlags.find(sourceFile->ResolveFullPath()); if (sourceFileFlagsIter == sourceFileFlags.end()) { sourceFileFlagsIter = sourceFileFlags - .insert(MapSourceFileFlags::value_type(sourceFile->GetFullPath(), - std::vector())) + .insert(MapSourceFileFlags::value_type( + sourceFile->ResolveFullPath(), std::vector())) .first; } std::vector& flags = sourceFileFlagsIter->second; diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index 2150051..ea9e672 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -112,7 +112,7 @@ bool cmFLTKWrapUICommand::InitialPass(std::vector const& args, if (classNum) { sourceListValue += ";"; } - sourceListValue += generatedSourcesClasses[classNum]->GetFullPath(); + sourceListValue += generatedSourcesClasses[classNum]->ResolveFullPath(); } std::string const varName = target + "_FLTK_UI_SRCS"; diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 08db7c7..4e34438 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -999,7 +999,7 @@ Json::Value Target::DumpSource(cmGeneratorTarget::SourceAndKind const& sk, { Json::Value source = Json::objectValue; - std::string const path = sk.Source.Value->GetFullPath(); + std::string const path = sk.Source.Value->ResolveFullPath(); source["path"] = RelativeIfUnder(this->TopSource, path); if (sk.Source.Value->GetIsGenerated()) { source["isGenerated"] = true; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index cc37232..5fbff2b 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1351,7 +1351,7 @@ bool processSources(cmGeneratorTarget const* tgt, for (std::string& src : entry.Values) { cmSourceFile* sf = mf->GetOrCreateSource(src); std::string e; - std::string fullPath = sf->GetFullPath(&e); + std::string fullPath = sf->ResolveFullPath(&e); if (fullPath.empty()) { if (!e.empty()) { cmake* cm = tgt->GetLocalGenerator()->GetCMakeInstance(); @@ -1619,7 +1619,7 @@ void cmGeneratorTarget::ComputeKindedSources(KindedSources& files, // Both names would have been auto generated from Visual Studio // where the user supplied the file name and Visual Studio // appended the suffix. - std::string resx = sf->GetFullPath(); + std::string resx = sf->ResolveFullPath(); std::string hFileName = resx.substr(0, resx.find_last_of('.')) + ".h"; files.ExpectedResxHeaders.insert(hFileName); } else if (ext == "appxmanifest") { @@ -1635,12 +1635,12 @@ void cmGeneratorTarget::ComputeKindedSources(KindedSources& files, // Both names would have been auto generated from Visual Studio // where the user supplied the file name and Visual Studio // appended the suffix. - std::string xaml = sf->GetFullPath(); + std::string xaml = sf->ResolveFullPath(); std::string hFileName = xaml + ".h"; std::string cppFileName = xaml + ".cpp"; files.ExpectedXamlHeaders.insert(hFileName); files.ExpectedXamlSources.insert(cppFileName); - } else if (header_regex.find(sf->GetFullPath())) { + } else if (header_regex.find(sf->ResolveFullPath())) { kind = SourceKindHeader; } else { kind = SourceKindExtra; @@ -2648,7 +2648,7 @@ cmTargetTraceDependencies::cmTargetTraceDependencies(cmGeneratorTarget* target) this->GlobalGenerator->GetFilenameTargetDepends(sf); if (cmContains(tgts, this->GeneratorTarget)) { std::ostringstream e; - e << "Evaluation output file\n \"" << sf->GetFullPath() + e << "Evaluation output file\n \"" << sf->ResolveFullPath() << "\"\ndepends on the sources of a target it is used in. This " "is a dependency loop and is not allowed."; this->GeneratorTarget->LocalGenerator->IssueMessage( @@ -2690,7 +2690,7 @@ void cmTargetTraceDependencies::Trace() } // Queue the source needed to generate this file, if any. - this->FollowName(sf->GetFullPath()); + this->FollowName(sf->ResolveFullPath()); // Queue dependencies added programmatically by commands. this->FollowNames(sf->GetDepends()); @@ -2711,7 +2711,7 @@ void cmTargetTraceDependencies::QueueSource(cmSourceFile* sf) this->SourceQueue.push(sf); // Make sure this file is in the target at the end. - this->NewSources.push_back(sf->GetFullPath()); + this->NewSources.push_back(sf->ResolveFullPath()); } } @@ -6095,7 +6095,7 @@ bool cmGeneratorTarget::GetConfigCommonSourceFiles( const char* sep = ""; for (cmSourceFile* f : files) { firstConfigFiles += sep; - firstConfigFiles += f->GetFullPath(); + firstConfigFiles += f->ResolveFullPath(); sep = "\n "; } @@ -6103,7 +6103,7 @@ bool cmGeneratorTarget::GetConfigCommonSourceFiles( sep = ""; for (cmSourceFile* f : configFiles) { thisConfigFiles += sep; - thisConfigFiles += f->GetFullPath(); + thisConfigFiles += f->ResolveFullPath(); sep = "\n "; } std::ostringstream e; diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index e7b20ed..658f65d 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -488,7 +488,7 @@ void cmGhsMultiTargetGenerator::WriteSources(std::ostream& fout_proj) std::set groupNames; for (auto& sf : sources) { cmSourceGroup* sourceGroup = - this->Makefile->FindSourceGroup(sf->GetFullPath(), sourceGroups); + this->Makefile->FindSourceGroup(sf->ResolveFullPath(), sourceGroups); std::string gn = sourceGroup->GetFullName(); groupFiles[gn].push_back(sf); groupNames.insert(std::move(gn)); @@ -543,7 +543,7 @@ void cmGhsMultiTargetGenerator::WriteSources(std::ostream& fout_proj) for (auto& n : groupFilesList) { std::sort(groupFiles[n].begin(), groupFiles[n].end(), [](cmSourceFile* l, cmSourceFile* r) { - return l->GetFullPath() < r->GetFullPath(); + return l->ResolveFullPath() < r->ResolveFullPath(); }); } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 4342e9f..bfccb12 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2974,7 +2974,7 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) auto const sourcesEnd = cmRemoveDuplicates(sources); for (cmSourceFile* sf : cmMakeRange(sources.cbegin(), sourcesEnd)) { Json::Value& lj_source = lj_sources.append(Json::objectValue); - std::string const& sfp = sf->GetFullPath(); + std::string const& sfp = sf->ResolveFullPath(); fout << sfp << "\n"; lj_source["file"] = sfp; if (const char* svalue = sf->GetProperty("LABELS")) { diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index b0c065f..f4c47ce 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -195,7 +195,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() if (cmSourceFile* file = mf->AddCustomCommandToOutput( stamps, no_byproducts, listFiles, no_main_dependency, commandLines, "Checking Build System", no_working_directory, true, false)) { - gt->AddSource(file->GetFullPath()); + gt->AddSource(file->ResolveFullPath()); } else { cmSystemTools::Error("Error adding rule for " + stamps[0]); } diff --git a/Source/cmJsonObjects.cxx b/Source/cmJsonObjects.cxx index 4948b01..52e28d3 100644 --- a/Source/cmJsonObjects.cxx +++ b/Source/cmJsonObjects.cxx @@ -327,7 +327,7 @@ static Json::Value DumpSourceFilesList( fileData.IsGenerated = file->GetIsGenerated(); std::vector& groupFileList = fileGroups[fileData]; - groupFileList.push_back(file->GetFullPath()); + groupFileList.push_back(file->ResolveFullPath()); } const std::string& baseDir = target->Makefile->GetCurrentSourceDirectory(); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 7177694..78133db 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1179,7 +1179,7 @@ void cmLocalGenerator::GetTargetFlags( if (sf->GetExtension() == "def") { linkFlags += defFlag; linkFlags += this->ConvertToOutputFormat( - cmSystemTools::CollapseFullPath(sf->GetFullPath()), SHELL); + cmSystemTools::CollapseFullPath(sf->ResolveFullPath()), SHELL); linkFlags += " "; } } @@ -1727,7 +1727,7 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName, // Check for a source file in this directory that matches the // dependency. if (cmSourceFile* sf = this->Makefile->GetSource(inName)) { - dep = sf->GetFullPath(); + dep = sf->ResolveFullPath(); return true; } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 795cee4..f88c3e9 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -102,7 +102,7 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() if (cmSourceFile* file = this->Makefile->AddCustomCommandToOutput( force.c_str(), no_depends, no_main_dependency, force_commands, " ", 0, true)) { - l->AddSource(file->GetFullPath()); + l->AddSource(file->ResolveFullPath()); } } } @@ -268,7 +268,7 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule() if (cmSourceFile* file = this->Makefile->GetSource(makefileIn.c_str())) { // Finalize the source file path now since we're adding this after // the generator validated all project-named sources. - file->GetFullPath(); + file->ResolveFullPath(); return file; } else { cmSystemTools::Error("Error adding rule for " + makefileIn); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f101cdc..5f09ce3 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1112,7 +1112,7 @@ void cmMakefile::AddCustomCommandOldStyle( if (sf && !sf->GetPropertyAsBool("__CMAKE_RULE")) { cmTargetMap::iterator ti = this->Targets.find(target); if (ti != this->Targets.end()) { - ti->second.AddSource(sf->GetFullPath()); + ti->second.AddSource(sf->ResolveFullPath()); } else { cmSystemTools::Error("Attempt to add a custom rule to a target " "that does not exist yet for target " + @@ -3322,7 +3322,7 @@ void cmMakefile::AddTargetObject(std::string const& tgtName, sf->SetProperty("EXTERNAL_OBJECT", "1"); #if !defined(CMAKE_BOOTSTRAP) this->SourceGroups[this->ObjectLibrariesSourceGroupIndex].AddGroupFile( - sf->GetFullPath()); + sf->ResolveFullPath()); #endif } diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index 3d8ebc3..187f0ab 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -325,7 +325,7 @@ protected: cmSourceFile* srcFile = this->Makefile->GetSource( cmSystemTools::GetFilenameWithoutExtension(path)); if (srcFile) { - if (srcFile->GetFullPath() == path) { + if (srcFile->ResolveFullPath() == path) { found = true; } else { // try to guess which include path to use @@ -334,7 +334,7 @@ protected: incpath += "/"; } incpath += path; - if (srcFile->GetFullPath() == incpath) { + if (srcFile->ResolveFullPath() == incpath) { // set the path to the guessed path info->FullPath = incpath; found = true; diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index bd96c08..155167b 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -647,7 +647,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() // Since we're iterating over source files that might be not in the // target we need to check for path errors (not existing files). std::string pathError; - std::string const& fullPath = sf->GetFullPath(&pathError); + std::string const& fullPath = sf->ResolveFullPath(&pathError); if (!pathError.empty() || fullPath.empty()) { continue; } @@ -703,7 +703,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() MUFile const& muf = *pair.second; if (muf.MocIt || muf.UicIt) { // Search for the default header file and a private header - std::string const& srcPath = muf.SF->GetFullPath(); + std::string const& srcPath = muf.SF->ResolveFullPath(); std::string basePath = cmStrCat(cmQtAutoGen::SubDirPrefix(srcPath), cmSystemTools::GetFilenameWithoutLastExtension(srcPath)); @@ -761,7 +761,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() // Since we're iterating over source files that might be not in the // target we need to check for path errors (not existing files). std::string pathError; - std::string const& fullPath = sf->GetFullPath(&pathError); + std::string const& fullPath = sf->ResolveFullPath(&pathError); if (!pathError.empty() || fullPath.empty()) { continue; } diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 5d738d5..4deb94a 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -65,7 +65,7 @@ std::string const& cmSourceFile::GetOrDetermineLanguage() this->Location.DirectoryIsAmbiguous()) { // Finalize the file location to get the extension and set the // language. - this->GetFullPath(); + this->ResolveFullPath(); } else { // Use the known extension to get the language if possible. std::string ext = @@ -94,7 +94,7 @@ cmSourceFileLocation const& cmSourceFile::GetLocation() const return this->Location; } -std::string const& cmSourceFile::GetFullPath(std::string* error) +std::string const& cmSourceFile::ResolveFullPath(std::string* error) { if (this->FullPath.empty()) { if (this->FindFullPath(error)) { @@ -269,7 +269,7 @@ const char* cmSourceFile::GetPropertyForUser(const std::string& prop) // LOCATION property we must commit now. if (prop == propLOCATION) { // Commit to a location. - this->GetFullPath(); + this->ResolveFullPath(); } // Similarly, LANGUAGE can be determined by the file extension diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index ccd5b62..774cb28 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -63,14 +63,15 @@ public: bool GetIsGenerated() const { return this->IsGenerated; } /** - * The full path to the file. The non-const version of this method - * may attempt to locate the file on disk and finalize its location. - * The const version of this method may return an empty string if - * the non-const version has not yet been called (yes this is a - * horrible interface, but is necessary for backwards - * compatibility). + * Resolves the full path to the file. Attempts to locate the file on disk + * and finalizes its location. + */ + std::string const& ResolveFullPath(std::string* error = nullptr); + + /** + * The resolved full path to the file. The returned file name might be empty + * if the path has not yet been resolved. */ - std::string const& GetFullPath(std::string* error = nullptr); std::string const& GetFullPath() const; /** https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fe683876952ee6172e46fe770b4f3e48c69646d1 commit fe683876952ee6172e46fe770b4f3e48c69646d1 Author: Christophe Giboudeaux AuthorDate: Wed Aug 28 00:52:13 2019 +0200 Commit: Christophe Giboudeaux CommitDate: Thu Aug 29 21:50:49 2019 +0200 FindPkgConfig: return the module found by pkg_search_module When running `pkg_search_module`, it may be useful to get the matching module name in order to run `pkg_get_variable`. `pkg_search_module` now defines `_MODULE_NAME` which contains the first matching module name. Fixes: #19648 diff --git a/Help/release/dev/FindPkgConfig-module-name.rst b/Help/release/dev/FindPkgConfig-module-name.rst new file mode 100644 index 0000000..9f1cd36 --- /dev/null +++ b/Help/release/dev/FindPkgConfig-module-name.rst @@ -0,0 +1,6 @@ +FindPkgConfig-module-name +------------------------- + +* The :module:`FindPkgConfig` module :command:`pkg_search_module` macro + now defines a ``_MODULE_NAME`` result variable containing the + first matching module name. diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index e05d5c8..4c9af91 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -363,6 +363,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma _pkgconfig_unset(${_prefix}_PREFIX) _pkgconfig_unset(${_prefix}_INCLUDEDIR) _pkgconfig_unset(${_prefix}_LIBDIR) + _pkgconfig_unset(${_prefix}_MODULE_NAME) _pkgconfig_unset(${_prefix}_LIBS) _pkgconfig_unset(${_prefix}_LIBS_L) _pkgconfig_unset(${_prefix}_LIBS_PATHS) @@ -480,6 +481,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma foreach (variable IN ITEMS PREFIX INCLUDEDIR LIBDIR) _pkgconfig_set("${_pkg_check_prefix}_${variable}" "${${_pkg_check_prefix}_${variable}}") endforeach () + _pkgconfig_set("${_pkg_check_prefix}_MODULE_NAME" "${_pkg_check_modules_pkg}") if (NOT ${_is_silent}) message(STATUS " Found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}") @@ -664,6 +666,10 @@ endmacro() [IMPORTED_TARGET [GLOBAL]] [...]) + If a module is found, the ``_MODULE_NAME`` variable will contain the + name of the matching module. This variable can be used if you need to run + :command:`pkg_get_variable`. + Example: .. code-block:: cmake @@ -688,6 +694,7 @@ macro(pkg_search_module _prefix _module0) if (${_prefix}_FOUND) set(_pkg_modules_found 1) + break() endif() endforeach() diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_MATCHING_MODULE_NAME.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_MATCHING_MODULE_NAME.cmake new file mode 100644 index 0000000..fc3a766 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_MATCHING_MODULE_NAME.cmake @@ -0,0 +1,28 @@ +# Prepare environment to reuse bletch.pc +file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-bletch/lib/pkgconfig" PC_PATH) +if(UNIX) + string(REPLACE "\\ " " " PC_PATH "${PC_PATH}") +endif() +set(ENV{PKG_CONFIG_PATH} "${PC_PATH}") + +find_package(PkgConfig REQUIRED) +pkg_search_module(FOO REQUIRED foo bletch bar) + +if(NOT FOO_MODULE_NAME STREQUAL "bletch") + message(FATAL_ERROR "Wrong value for FOO_MODULE_NAME. Expected: bletch, got: ${FOO_MODULE_NAME}") +endif() + +pkg_get_variable(FOO_JACKPOT ${FOO_MODULE_NAME} jackpot) + +if(NOT FOO_JACKPOT STREQUAL "bletch-lives") + message(FATAL_ERROR "Wrong value for FOO_JACKPOT. Expected: bletch-lives, got: ${FOO_JACKPOT}") +endif() + +unset(FOO_MODULE_NAME) + +# verify variable get's also set on subsequent run +pkg_search_module(FOO REQUIRED foo bletch bar) + +if(NOT FOO_MODULE_NAME STREQUAL "bletch") + message(FATAL_ERROR "Wrong value for FOO_MODULE_NAME on second run. Expected: bletch, got: ${FOO_MODULE_NAME}") +endif() diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake index 414d9b6..b77bb54 100644 --- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake @@ -19,4 +19,5 @@ if (PKG_CONFIG_FOUND) run_cmake(FindPkgConfig_cache_variables) run_cmake(FindPkgConfig_IMPORTED_TARGET) run_cmake(FindPkgConfig_VERSION_OPERATORS) + run_cmake(FindPkgConfig_GET_MATCHING_MODULE_NAME) endif () https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=079b8e29168dc081f37f79f3577a5c0690bb7051 commit 079b8e29168dc081f37f79f3577a5c0690bb7051 Author: Zsolt Parragi AuthorDate: Thu Jul 11 16:55:19 2019 +0200 Commit: Zsolt Parragi CommitDate: Tue Aug 27 20:19:29 2019 +0200 Clang: prefer lld-link over link.exe Objects compiled with -flto can only be linked with the llvm linker. Before this change, clang-cl only supperted IPO with manual linker selection. diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 773ee53..01f9dae 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -69,7 +69,12 @@ if(("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC" AND OR (CMAKE_GENERATOR MATCHES "Visual Studio" AND NOT CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")) - find_program(CMAKE_LINKER NAMES link HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xClang") + find_program(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm llvm-nm HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + set(_CMAKE_ADDITIONAL_LINKER_NAMES "lld-link") + endif() + + find_program(CMAKE_LINKER NAMES ${_CMAKE_ADDITIONAL_LINKER_NAMES} link HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) find_program(CMAKE_MT NAMES mt HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) list(APPEND _CMAKE_TOOL_VARS LINKER MT) @@ -115,6 +120,17 @@ else() list(APPEND _CMAKE_TOOL_VARS AR RANLIB STRIP LINKER NM OBJDUMP OBJCOPY READELF DLLTOOL ADDR2LINE) + + unset(_CMAKE_ADDITIONAL_AR_NAMES) + unset(_CMAKE_ADDITIONAL_RANLIB_NAMES) + unset(_CMAKE_ADDITIONAL_STRIP_NAMES) + unset(_CMAKE_ADDITIONAL_LINKER_NAMES) + unset(_CMAKE_ADDITIONAL_NM_NAMES) + unset(_CMAKE_ADDITIONAL_OBJDUMP_NAMES) + unset(_CMAKE_ADDITIONAL_OBJCOPY_NAMES) + unset(_CMAKE_ADDITIONAL_READELF_NAMES) + unset(_CMAKE_ADDITIONAL_DLLTOOL_NAMES) + unset(_CMAKE_ADDITIONAL_ADDR2LINE_NAMES) endif() if(CMAKE_PLATFORM_HAS_INSTALLNAME) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6e3655db2cc8202424e54bdde83e4240eb680cc3 commit 6e3655db2cc8202424e54bdde83e4240eb680cc3 Author: Zsolt Parragi AuthorDate: Mon Jul 8 18:52:23 2019 +0200 Commit: Zsolt Parragi CommitDate: Tue Aug 27 20:19:29 2019 +0200 Clang: add LTO support for GNU-command line clang on windows diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index 728e0b9..6a12381 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -44,15 +44,22 @@ macro(__windows_compiler_clang_gnu lang) set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_LIBRARIES 1) set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1) + set(CMAKE_${lang}_COMPILE_OPTIONS_IPO "-flto") + set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES) + set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES) + set(CMAKE_${lang}_ARCHIVE_CREATE_IPO " cr ") + set(CMAKE_${lang}_ARCHIVE_APPEND_IPO " r ") + set(CMAKE_${lang}_ARCHIVE_FINISH_IPO " ") + # Create archiving rules to support large object file lists for static libraries. set(CMAKE_${lang}_ARCHIVE_CREATE " qc ") set(CMAKE_${lang}_ARCHIVE_APPEND " q ") set(CMAKE_${lang}_ARCHIVE_FINISH " ") set(CMAKE_${lang}_CREATE_SHARED_LIBRARY - " -nostartfiles -nostdlib -o ${CMAKE_GNULD_IMAGE_VERSION} -Xlinker /implib: -Xlinker /pdb: -Xlinker /version:. ") + " -fuse-ld=lld-link -nostartfiles -nostdlib -o ${CMAKE_GNULD_IMAGE_VERSION} -Xlinker /implib: -Xlinker /pdb: -Xlinker /version:. ") set(CMAKE_${lang}_CREATE_SHARED_MODULE ${CMAKE_${lang}_CREATE_SHARED_LIBRARY}) set(CMAKE_${lang}_LINK_EXECUTABLE - " -nostartfiles -nostdlib -o -Xlinker /implib: -Xlinker /pdb: -Xlinker /version:. ${CMAKE_GNULD_IMAGE_VERSION} ") + " -fuse-ld=lld-link -nostartfiles -nostdlib -o -Xlinker /implib: -Xlinker /pdb: -Xlinker /version:. ${CMAKE_GNULD_IMAGE_VERSION} ") set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -Xclang -flto-visibility-public-std -D_MT -Xclang --dependent-lib=libcmt) set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -D_DLL -D_MT -Xclang --dependent-lib=msvcrt) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=df0247a3714667e0f60d64da1b30ea200c43c7d5 commit df0247a3714667e0f60d64da1b30ea200c43c7d5 Author: Benjamin Wozniak AuthorDate: Wed Aug 21 15:27:42 2019 +0200 Commit: Benjamin Wozniak CommitDate: Tue Aug 27 12:54:35 2019 +0200 cuda: Extend toolset argument to accept path Previously cuda could only be used with cmake if it is installed globally on the system. Sometimes this is not possible (eg docker, packaging with conan, etc.). Thus the cuda toolset argument is extended to take a path to a cuda install directory. diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 02d25fb..a90abe1 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -232,7 +232,15 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset( if (this->GeneratorToolsetCuda.empty()) { // Find the highest available version of the CUDA tools. std::vector cudaTools; - std::string const bcDir = this->VCTargetsPath + "/BuildCustomizations"; + std::string bcDir; + if (this->GeneratorToolsetCudaCustomDir.empty()) { + bcDir = this->VCTargetsPath + "/BuildCustomizations"; + } else { + bcDir = this->GetPlatformToolsetCudaCustomDirString() + + "CUDAVisualStudioIntegration\\extras\\" + "visual_studio_integration\\MSBuildExtensions"; + cmSystemTools::ConvertToUnixSlashes(bcDir); + } cmsys::Glob gl; gl.SetRelative(bcDir.c_str()); if (gl.FindFiles(bcDir + "/CUDA *.props")) { @@ -243,6 +251,24 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset( std::sort(cudaTools.begin(), cudaTools.end(), cmSystemTools::VersionCompareGreater); this->GeneratorToolsetCuda = cudaTools.at(0); + } else if (!this->GeneratorToolsetCudaCustomDir.empty()) { + // Generate an error if Visual Studio integration files are not found + // inside of custom cuda toolset. + std::ostringstream e; + /* clang-format off */ + e << + "Generator\n" + " " << this->GetName() << "\n" + "given toolset\n" + " cuda=" << this->GeneratorToolsetCudaCustomDir << "\n" + "cannot detect Visual Studio integration files in path\n" + " " << bcDir; + + /* clang-format on */ + mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); + + // Clear the configured tool-set + this->GeneratorToolsetCuda.clear(); } } @@ -319,6 +345,9 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset( if (const char* cuda = this->GetPlatformToolsetCuda()) { mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET_CUDA", cuda); } + if (const char* cudaDir = this->GetPlatformToolsetCudaCustomDir()) { + mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR", cudaDir); + } return true; } @@ -395,7 +424,17 @@ bool cmGlobalVisualStudio10Generator::ProcessGeneratorToolsetField( std::string const& key, std::string const& value) { if (key == "cuda") { - this->GeneratorToolsetCuda = value; + /* test if cuda toolset is path to custom dir or cuda version */ + auto pos = value.find_first_not_of("0123456789."); + if (pos != std::string::npos) { + this->GeneratorToolsetCudaCustomDir = value; + /* ensure trailing backslash for easy path joining */ + if (this->GeneratorToolsetCudaCustomDir.back() != '\\') { + this->GeneratorToolsetCudaCustomDir.push_back('\\'); + } + } else { + this->GeneratorToolsetCuda = value; + } return true; } if (key == "version") { @@ -643,6 +682,21 @@ cmGlobalVisualStudio10Generator::GetPlatformToolsetCudaString() const return this->GeneratorToolsetCuda; } +const char* cmGlobalVisualStudio10Generator::GetPlatformToolsetCudaCustomDir() + const +{ + if (!this->GeneratorToolsetCudaCustomDir.empty()) { + return this->GeneratorToolsetCudaCustomDir.c_str(); + } + return nullptr; +} + +std::string const& +cmGlobalVisualStudio10Generator::GetPlatformToolsetCudaCustomDirString() const +{ + return this->GeneratorToolsetCudaCustomDir; +} + bool cmGlobalVisualStudio10Generator::IsDefaultToolset( const std::string&) const { diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 1d30cd6..9adcf08 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -61,6 +61,10 @@ public: const char* GetPlatformToolsetCuda() const; std::string const& GetPlatformToolsetCudaString() const; + /** The custom cuda install directory */ + const char* GetPlatformToolsetCudaCustomDir() const; + std::string const& GetPlatformToolsetCudaCustomDirString() const; + /** Return whether we need to use No/Debug instead of false/true for GenerateDebugInformation. */ bool GetPlatformToolsetNeedsDebugEnum() const @@ -152,6 +156,7 @@ protected: std::string GeneratorToolsetVersion; std::string GeneratorToolsetHostArchitecture; std::string GeneratorToolsetCuda; + std::string GeneratorToolsetCudaCustomDir; std::string DefaultPlatformToolset; std::string DefaultPlatformToolsetHostArchitecture; std::string WindowsTargetPlatformVersion; ----------------------------------------------------------------------- Summary of changes: Help/manual/cmake-variables.7.rst | 1 + Help/release/dev/FindPkgConfig-module-name.rst | 6 ++ Help/release/dev/gtest-1.8.1.rst | 5 ++ Help/variable/CMAKE_GENERATOR_TOOLSET.rst | 11 +-- Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA.rst | 6 +- .../CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst | 16 +++++ Modules/CMakeDetermineCompilerId.cmake | 10 ++- Modules/CMakeFindBinUtils.cmake | 18 ++++- Modules/CompilerId/VS-10.vcxproj.in | 1 + Modules/FindGTest.cmake | 8 +++ Modules/FindPkgConfig.cmake | 7 ++ Modules/Platform/Windows-Clang.cmake | 11 ++- Source/bindexplib.cxx | 82 ++++++++++++++++++++-- Source/bindexplib.h | 5 +- Source/cmCPluginAPI.cxx | 2 +- Source/cmComputeTargetDepends.cxx | 7 +- Source/cmExtraCodeBlocksGenerator.cxx | 2 +- Source/cmExtraCodeLiteGenerator.cxx | 2 +- Source/cmExtraEclipseCDT4Generator.cxx | 2 +- Source/cmExtraKateGenerator.cxx | 2 +- Source/cmExtraSublimeTextGenerator.cxx | 6 +- Source/cmFLTKWrapUICommand.cxx | 2 +- Source/cmFileAPICodemodel.cxx | 15 ++-- Source/cmGeneratorTarget.cxx | 46 +++++------- Source/cmGhsMultiTargetGenerator.cxx | 4 +- Source/cmGlobalGenerator.cxx | 17 ++--- Source/cmGlobalVisualStudio10Generator.cxx | 58 ++++++++++++++- Source/cmGlobalVisualStudio10Generator.h | 5 ++ Source/cmGlobalVisualStudio8Generator.cxx | 2 +- Source/cmJsonObjects.cxx | 2 +- Source/cmLocalGenerator.cxx | 11 ++- Source/cmLocalVisualStudio7Generator.cxx | 4 +- Source/cmMakefile.cxx | 14 +++- Source/cmMakefile.h | 3 + Source/cmMakefileTargetGenerator.cxx | 7 ++ Source/cmNinjaNormalTargetGenerator.cxx | 8 +++ Source/cmOutputRequiredFilesCommand.cxx | 4 +- Source/cmQtAutoGenInitializer.cxx | 6 +- Source/cmSourceFile.cxx | 6 +- Source/cmSourceFile.h | 15 ++-- Source/cmVisualStudio10TargetGenerator.cxx | 29 ++++++-- Source/cmcmd.cxx | 13 +++- Tests/CMakeLists.txt | 1 - Tests/IPO/CMakeLists.txt | 7 -- Tests/Module/CheckIPOSupported-C/CMakeLists.txt | 12 +++- .../Module/CheckIPOSupported-C/bar.c | 2 +- Tests/Module/CheckIPOSupported-C/main.c | 3 +- Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt | 15 +++- .../Module/CheckIPOSupported-CXX/bar.cpp | 2 +- Tests/Module/CheckIPOSupported-CXX/main.cpp | 3 +- .../FindPkgConfig_GET_MATCHING_MODULE_NAME.cmake | 28 ++++++++ Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake | 1 + Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake | 12 ++-- .../TestToolsetCudaBoth-stdout.txt | 2 +- .../TestToolsetCudaPathOnly-result.txt} | 0 .../TestToolsetCudaPathOnly-stderr.txt | 12 ++++ ...oolsets.cmake => TestToolsetCudaPathOnly.cmake} | 0 ...t.txt => TestToolsetCudaVersionOnly-stdout.txt} | 2 +- ...Only.cmake => TestToolsetCudaVersionOnly.cmake} | 0 59 files changed, 443 insertions(+), 140 deletions(-) create mode 100644 Help/release/dev/FindPkgConfig-module-name.rst create mode 100644 Help/release/dev/gtest-1.8.1.rst create mode 100644 Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst delete mode 100644 Tests/IPO/CMakeLists.txt copy Modules/CheckIPOSupported/foo.c => Tests/Module/CheckIPOSupported-C/bar.c (65%) copy Modules/CheckIPOSupported/foo.c => Tests/Module/CheckIPOSupported-CXX/bar.cpp (65%) create mode 100644 Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_MATCHING_MODULE_NAME.cmake copy Tests/RunCMake/{while/MissingArgument-result.txt => GeneratorToolset/TestToolsetCudaPathOnly-result.txt} (100%) create mode 100644 Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-stderr.txt copy Tests/RunCMake/GeneratorToolset/{TwoToolsets.cmake => TestToolsetCudaPathOnly.cmake} (100%) rename Tests/RunCMake/GeneratorToolset/{TestToolsetCudaOnly-stdout.txt => TestToolsetCudaVersionOnly-stdout.txt} (54%) rename Tests/RunCMake/GeneratorToolset/{TestToolsetCudaOnly.cmake => TestToolsetCudaVersionOnly.cmake} (100%) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Sep 3 09:52:24 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 3 Sep 2019 09:52:24 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-963-g72b7629 Message-ID: <20190903135224.425E711E3F0@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 72b7629956c1718ce59db8a6a0d485b166ed6fe0 (commit) via aa3465fcd2d792880fd7e2a6754a283d6df66531 (commit) via 06d9e67fbd2b2dfc9cba12327866b2f73eab8a18 (commit) via cea2010b5c72f333d124f69ded95cc0379e4184d (commit) via e29a92f5259def88bda0c292f591fda68c0e064e (commit) from 1f7bd0032253296413770567a90a0a88b6cccb34 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=72b7629956c1718ce59db8a6a0d485b166ed6fe0 commit 72b7629956c1718ce59db8a6a0d485b166ed6fe0 Merge: aa3465f 06d9e67 Author: Brad King AuthorDate: Tue Sep 3 13:48:44 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 3 09:49:00 2019 -0400 Merge topic 'FindPython-specify-artifacts-directly' 06d9e67fbd FindPython: Add capability to specify directly artifacts cea2010b5c FindPython: Enhance python cache variables management. Acked-by: Kitware Robot Merge-request: !3690 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=aa3465fcd2d792880fd7e2a6754a283d6df66531 commit aa3465fcd2d792880fd7e2a6754a283d6df66531 Merge: 1f7bd00 e29a92f Author: Brad King AuthorDate: Tue Sep 3 13:41:22 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 3 09:43:32 2019 -0400 Merge topic 'xcode11-bundles' e29a92f525 Xcode: Make BundleTests compatible with Xcode 11 Acked-by: Kitware Robot Merge-request: !3767 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=06d9e67fbd2b2dfc9cba12327866b2f73eab8a18 commit 06d9e67fbd2b2dfc9cba12327866b2f73eab8a18 Author: Marc Chevrier AuthorDate: Thu Aug 15 09:19:43 2019 +0200 Commit: Marc Chevrier CommitDate: Mon Sep 2 17:20:53 2019 +0200 FindPython: Add capability to specify directly artifacts Fixes: #19492 diff --git a/Help/release/dev/FindPython-specify_artifacts.rst b/Help/release/dev/FindPython-specify_artifacts.rst new file mode 100644 index 0000000..7032f8b --- /dev/null +++ b/Help/release/dev/FindPython-specify_artifacts.rst @@ -0,0 +1,5 @@ +FindPython-specify_artifacts +---------------------------- + +* Modules :module:`FindPython3`, :module:`FindPython2` and :module:`FindPython` + gain the capability to specify directly artifacts. diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake index 2056e93..3cc08a1 100644 --- a/Modules/FindPython.cmake +++ b/Modules/FindPython.cmake @@ -243,6 +243,44 @@ Hints recommended to also include the component ``Interpreter`` to get expected result. +Artifacts Specification +^^^^^^^^^^^^^^^^^^^^^^^ + +To solve special cases, it is possible to specify directly the artifacts by +setting the following variables: + +``Python_EXECUTABLE`` + The path to the interpreter. + +``Python_COMPILER`` + The path to the compiler. + +``Python_LIBRARY`` + The path to the library. It will be used to compute the + variables ``Python_LIBRARIES``, ``Python_LIBRAY_DIRS`` and + ``Python_RUNTIME_LIBRARY_DIRS``. + +``Python_INCLUDE_DIR`` + The path to the directory of the ``Python`` headers. It will be used to + compute the variable ``Python_INCLUDE_DIRS``. + +``Python_NumPy_INCLUDE_DIR`` + The path to the directory of the ``NumPy`` headers. It will be used to + compute the variable ``Python_NumPy_INCLUDE_DIRS``. + +.. note:: + + All paths must be absolute. Any artifact specified with a relative path + will be ignored. + +.. note:: + + When an artifact is specified, all ``HINTS`` will be ignored and no search + will be performed for this artifact. + + If more than one artifact is specified, it is the user's responsability to + ensure the consistency of the various artifacts. + Commands ^^^^^^^^ @@ -275,6 +313,14 @@ else() set (_Python_REQUIRED_VERSIONS 3 2) set (_Python_REQUIRED_VERSION_LAST 2) + unset (_Python_INPUT_VARS) + foreach (_Python_ITEM IN ITEMS Python_EXECUTABLE Python_COMPILER Python_LIBRARY + Python_INCLUDE_DIR Python_NumPy_INCLUDE_DIR) + if (NOT DEFINED ${_Python_ITEM}) + list (APPEND _Python_INPUT_VARS ${_Python_ITEM}) + endif() + endforeach() + foreach (_Python_REQUIRED_VERSION_MAJOR IN LISTS _Python_REQUIRED_VERSIONS) set (Python_FIND_VERSION ${_Python_REQUIRED_VERSION_MAJOR}) include (${CMAKE_CURRENT_LIST_DIR}/FindPython/Support.cmake) @@ -282,6 +328,10 @@ else() _Python_REQUIRED_VERSION_MAJOR EQUAL _Python_REQUIRED_VERSION_LAST) break() endif() + # clean-up INPUT variables not set by the user + foreach (_Python_ITEM IN LISTS _Python_INPUT_VARS) + unset (${_Python_ITEM}) + endforeach() # clean-up some CACHE variables to ensure look-up restart from scratch foreach (_Python_ITEM IN LISTS _Python_CACHED_VARS) unset (${_Python_ITEM} CACHE) diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index efaf9ea..b67d563 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -268,9 +268,9 @@ function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME) endif() endif() - if (${_PYTHON_PREFIX}_EXECUTABLE AND NOT CMAKE_CROSSCOMPILING) + if (_${_PYTHON_PREFIX}_EXECUTABLE AND NOT CMAKE_CROSSCOMPILING) if (NAME STREQUAL "PREFIX") - execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig; sys.stdout.write(';'.join([sysconfig.PREFIX,sysconfig.EXEC_PREFIX,sysconfig.BASE_EXEC_PREFIX]))" + execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig; sys.stdout.write(';'.join([sysconfig.PREFIX,sysconfig.EXEC_PREFIX,sysconfig.BASE_EXEC_PREFIX]))" RESULT_VARIABLE _result OUTPUT_VARIABLE _values ERROR_QUIET @@ -281,7 +281,7 @@ function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME) list (REMOVE_DUPLICATES _values) endif() elseif (NAME STREQUAL "INCLUDES") - execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig; sys.stdout.write(';'.join([sysconfig.get_python_inc(plat_specific=True),sysconfig.get_python_inc(plat_specific=False)]))" + execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig; sys.stdout.write(';'.join([sysconfig.get_python_inc(plat_specific=True),sysconfig.get_python_inc(plat_specific=False)]))" RESULT_VARIABLE _result OUTPUT_VARIABLE _values ERROR_QUIET @@ -294,7 +294,7 @@ function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME) if (NAME STREQUAL "CONFIGDIR") set (config_flag "LIBPL") endif() - execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_config_var('${config_flag}'))" + execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_config_var('${config_flag}'))" RESULT_VARIABLE _result OUTPUT_VARIABLE _values ERROR_QUIET @@ -336,14 +336,14 @@ function (_PYTHON_GET_VERSION) if (_PGV_LIBRARY) # retrieve version and abi from library name - if (${_PYTHON_PREFIX}_LIBRARY_RELEASE) + if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE) # extract version from library name - if (${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "python([23])([0-9]+)") + if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "python([23])([0-9]+)") set (${_PGV_PREFIX}VERSION_MAJOR "${CMAKE_MATCH_1}" PARENT_SCOPE) set (${_PGV_PREFIX}VERSION_MINOR "${CMAKE_MATCH_2}" PARENT_SCOPE) set (${_PGV_PREFIX}VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}" PARENT_SCOPE) set (${_PGV_PREFIX}ABI "" PARENT_SCOPE) - elseif (${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "python([23])\\.([0-9]+)([dmu]*)") + elseif (_${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "python([23])\\.([0-9]+)([dmu]*)") set (${_PGV_PREFIX}VERSION_MAJOR "${CMAKE_MATCH_1}" PARENT_SCOPE) set (${_PGV_PREFIX}VERSION_MINOR "${CMAKE_MATCH_2}" PARENT_SCOPE) set (${_PGV_PREFIX}VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}" PARENT_SCOPE) @@ -351,9 +351,9 @@ function (_PYTHON_GET_VERSION) endif() endif() else() - if (${_PYTHON_PREFIX}_INCLUDE_DIR) + if (_${_PYTHON_PREFIX}_INCLUDE_DIR) # retrieve version from header file - file (STRINGS "${${_PYTHON_PREFIX}_INCLUDE_DIR}/patchlevel.h" version + file (STRINGS "${_${_PYTHON_PREFIX}_INCLUDE_DIR}/patchlevel.h" version REGEX "^#define[ \t]+PY_VERSION[ \t]+\"[^\"]+\"") string (REGEX REPLACE "^#define[ \t]+PY_VERSION[ \t]+\"([^\"]+)\".*" "\\1" version "${version}") @@ -369,7 +369,7 @@ function (_PYTHON_GET_VERSION) # compute ABI flags if (version_major VERSION_GREATER 2) - file (STRINGS "${${_PYTHON_PREFIX}_INCLUDE_DIR}/pyconfig.h" config REGEX "(Py_DEBUG|WITH_PYMALLOC|Py_UNICODE_SIZE|MS_WIN32)") + file (STRINGS "${_${_PYTHON_PREFIX}_INCLUDE_DIR}/pyconfig.h" config REGEX "(Py_DEBUG|WITH_PYMALLOC|Py_UNICODE_SIZE|MS_WIN32)") set (abi) if (config MATCHES "#[ ]*define[ ]+MS_WIN32") # ABI not used on Windows @@ -396,20 +396,26 @@ endfunction() function (_PYTHON_VALIDATE_INTERPRETER) - if (NOT ${_PYTHON_PREFIX}_EXECUTABLE) + if (NOT _${_PYTHON_PREFIX}_EXECUTABLE) return() endif() - cmake_parse_arguments (PARSE_ARGV 0 _PVI "EXACT" "" "") + cmake_parse_arguments (PARSE_ARGV 0 _PVI "EXACT;CHECK_EXISTS" "" "") if (_PVI_UNPARSED_ARGUMENTS) set (expected_version ${_PVI_UNPARSED_ARGUMENTS}) else() unset (expected_version) endif() + if (_PVI_CHECK_EXISTS AND NOT EXISTS "${_${_PYTHON_PREFIX}_EXECUTABLE}") + # interpreter does not exist anymore + set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "_${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") + return() + endif() + # validate ABI compatibility if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI) - execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c + execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; sys.stdout.write(sys.abiflags)" RESULT_VARIABLE result OUTPUT_VARIABLE abi @@ -421,16 +427,16 @@ function (_PYTHON_VALIDATE_INTERPRETER) endif() if (NOT abi IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS) # incompatible ABI - set_property (CACHE ${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") + set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "_${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") return() endif() endif() - get_filename_component (python_name "${${_PYTHON_PREFIX}_EXECUTABLE}" NAME) + get_filename_component (python_name "${_${_PYTHON_PREFIX}_EXECUTABLE}" NAME) if (expected_version AND NOT python_name STREQUAL "python${expected_version}${abi}${CMAKE_EXECUTABLE_SUFFIX}") # executable found must have a specific version - execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c + execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:2]]))" RESULT_VARIABLE result OUTPUT_VARIABLE version @@ -438,14 +444,14 @@ function (_PYTHON_VALIDATE_INTERPRETER) OUTPUT_STRIP_TRAILING_WHITESPACE) if (result OR (_PVI_EXACT AND NOT version VERSION_EQUAL expected_version) OR (version VERSION_LESS expected_version)) # interpreter not usable or has wrong major version - set_property (CACHE ${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") + set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "_${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") return() endif() else() if (NOT python_name STREQUAL "python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}${CMAKE_EXECUTABLE_SUFFIX}") # executable found do not have version in name # ensure major version is OK - execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c + execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; sys.stdout.write(str(sys.version_info[0]))" RESULT_VARIABLE result OUTPUT_VARIABLE version @@ -453,7 +459,7 @@ function (_PYTHON_VALIDATE_INTERPRETER) OUTPUT_STRIP_TRAILING_WHITESPACE) if (result OR NOT version EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR) # interpreter not usable or has wrong major version - set_property (CACHE ${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") + set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "_${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") return() endif() endif() @@ -462,7 +468,7 @@ function (_PYTHON_VALIDATE_INTERPRETER) if (CMAKE_SIZEOF_VOID_P AND "Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND NOT CMAKE_CROSSCOMPILING) # In this case, interpreter must have same architecture as environment - execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c + execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys, struct; sys.stdout.write(str(struct.calcsize(\"P\")))" RESULT_VARIABLE result OUTPUT_VARIABLE size @@ -470,7 +476,7 @@ function (_PYTHON_VALIDATE_INTERPRETER) OUTPUT_STRIP_TRAILING_WHITESPACE) if (result OR NOT size EQUAL CMAKE_SIZEOF_VOID_P) # interpreter not usable or has wrong architecture - set_property (CACHE ${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") + set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "_${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") return() endif() endif() @@ -478,11 +484,11 @@ endfunction() function (_PYTHON_VALIDATE_COMPILER expected_version) - if (NOT ${_PYTHON_PREFIX}_COMPILER) + if (NOT _${_PYTHON_PREFIX}_COMPILER) return() endif() - cmake_parse_arguments (_PVC "EXACT" "" "" ${ARGN}) + cmake_parse_arguments (_PVC "EXACT;CHECK_EXISTS" "" "" ${ARGN}) if (_PVC_UNPARSED_ARGUMENTS) set (major_version FALSE) set (expected_version ${_PVC_UNPARSED_ARGUMENTS}) @@ -492,6 +498,12 @@ function (_PYTHON_VALIDATE_COMPILER expected_version) set (_PVC_EXACT TRUE) endif() + if (_PVC_CHECK_EXISTS AND NOT EXISTS "${_${_PYTHON_PREFIX}_COMPILER}") + # Compiler does not exist anymore + set_property (CACHE _${_PYTHON_PREFIX}_COMPILER PROPERTY VALUE "_${_PYTHON_PREFIX}_COMPILER-NOTFOUND") + return() + endif() + # retrieve python environment version from compiler set (working_dir "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/PythonCompilerVersion.dir") if (major_version) @@ -500,7 +512,7 @@ function (_PYTHON_VALIDATE_COMPILER expected_version) else() file (WRITE "${working_dir}/version.py" "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:2]]))\n") endif() - execute_process (COMMAND "${${_PYTHON_PREFIX}_COMPILER}" /target:exe /embed "${working_dir}/version.py" + execute_process (COMMAND "${_${_PYTHON_PREFIX}_COMPILER}" /target:exe /embed "${working_dir}/version.py" WORKING_DIRECTORY "${working_dir}" OUTPUT_QUIET ERROR_QUIET @@ -514,78 +526,96 @@ function (_PYTHON_VALIDATE_COMPILER expected_version) if (result OR (_PVC_EXACT AND NOT version VERSION_EQUAL expected_version) OR (version VERSION_LESS expected_version)) # Compiler not usable or has wrong version - set_property (CACHE ${_PYTHON_PREFIX}_COMPILER PROPERTY VALUE "${_PYTHON_PREFIX}_COMPILER-NOTFOUND") + set_property (CACHE _${_PYTHON_PREFIX}_COMPILER PROPERTY VALUE "_${_PYTHON_PREFIX}_COMPILER-NOTFOUND") endif() endfunction() function (_PYTHON_VALIDATE_LIBRARY) - if (NOT ${_PYTHON_PREFIX}_LIBRARY_RELEASE) + if (NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE) return() endif() - cmake_parse_arguments (PARSE_ARGV 0 _PVL "EXACT" "" "") + cmake_parse_arguments (PARSE_ARGV 0 _PVL "EXACT;CHECK_EXISTS" "" "") if (_PVL_UNPARSED_ARGUMENTS) set (expected_version ${_PVL_UNPARSED_ARGUMENTS}) else() unset (expected_version) endif() + if (_PVL_CHECK_EXISTS AND NOT EXISTS "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}") + # library does not exist anymore + set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND") + if (WIN32) + set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_DEBUG PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_DEBUG-NOTFOUND") + endif() + set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") + return() + endif() + # retrieve version and abi from library name _python_get_version (LIBRARY PREFIX lib_) if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND NOT lib_ABI IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS) # incompatible ABI - set_property (CACHE ${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND") + set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND") else() if (expected_version) if ((_PVL_EXACT AND NOT lib_VERSION VERSION_EQUAL expected_version) OR (lib_VERSION VERSION_LESS expected_version)) # library has wrong version - set_property (CACHE ${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND") + set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND") endif() else() if (NOT lib_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR) # library has wrong major version - set_property (CACHE ${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND") + set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND") endif() endif() endif() - if (NOT ${_PYTHON_PREFIX}_LIBRARY_RELEASE) - set_property (CACHE ${_PYTHON_PREFIX}_LIBRARY_DEBUG PROPERTY VALUE "${_PYTHON_PREFIX}_LIBRARY_DEBUG-NOTFOUND") - set_property (CACHE ${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") + if (NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE) + if (WIN32) + set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_DEBUG PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_DEBUG-NOTFOUND") + endif() + set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") endif() endfunction() function (_PYTHON_VALIDATE_INCLUDE_DIR) - if (NOT ${_PYTHON_PREFIX}_INCLUDE_DIR) + if (NOT _${_PYTHON_PREFIX}_INCLUDE_DIR) return() endif() - cmake_parse_arguments (PARSE_ARGV 0 _PVID "EXACT" "" "") + cmake_parse_arguments (PARSE_ARGV 0 _PVID "EXACT;CHECK_EXISTS" "" "") if (_PVID_UNPARSED_ARGUMENTS) set (expected_version ${_PVID_UNPARSED_ARGUMENTS}) else() unset (expected_version) endif() + if (_PVID_CHECK_EXISTS AND NOT EXISTS "${_${_PYTHON_PREFIX}_INCLUDE_DIR}") + # include file does not exist anymore + set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") + return() + endif() + # retrieve version from header file _python_get_version (INCLUDE PREFIX inc_) if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND NOT inc_ABI IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS) # incompatible ABI - set_property (CACHE ${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") + set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") else() if (expected_version) if ((_PVID_EXACT AND NOT inc_VERSION VERSION_EQUAL expected_version) OR (inc_VERSION VERSION_LESS expected_version)) # include dir has wrong version - set_property (CACHE ${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") + set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") endif() else() if (NOT inc_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR) # include dir has wrong major version - set_property (CACHE ${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") + set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") endif() endif() endif() @@ -610,8 +640,7 @@ endfunction() function (_PYTHON_SET_LIBRARY_DIRS _PYTHON_SLD_RESULT) unset (_PYTHON_DIRS) - set (_PYTHON_LIBS ${ARGV}) - list (REMOVE_AT _PYTHON_LIBS 0) + set (_PYTHON_LIBS ${ARGN}) foreach (_PYTHON_LIB IN LISTS _PYTHON_LIBS) if (${_PYTHON_LIB}) get_filename_component (_PYTHON_DIR "${${_PYTHON_LIB}}" DIRECTORY) @@ -811,28 +840,31 @@ unset (_${_PYTHON_PREFIX}_CACHED_VARS) # first step, search for the interpreter if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) - list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS ${_PYTHON_PREFIX}_EXECUTABLE) + list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS _${_PYTHON_PREFIX}_EXECUTABLE) if (${_PYTHON_PREFIX}_FIND_REQUIRED_Interpreter) list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_EXECUTABLE) endif() - if (DEFINED ${_PYTHON_PREFIX}_EXECUTABLE) + if (DEFINED ${_PYTHON_PREFIX}_EXECUTABLE + AND IS_ABSOLUTE "${${_PYTHON_PREFIX}_EXECUTABLE}") + set (_${_PYTHON_PREFIX}_EXECUTABLE "${${_PYTHON_PREFIX}_EXECUTABLE}" CACHE INTERNAL "") + elseif (DEFINED _${_PYTHON_PREFIX}_EXECUTABLE) # compute interpreter signature and check validity of definition - string (MD5 __${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${${_PYTHON_PREFIX}_EXECUTABLE}") + string (MD5 __${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_EXECUTABLE}") if (__${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE STREQUAL _${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE) # check version validity if (${_PYTHON_PREFIX}_FIND_VERSION_EXACT) - _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION} EXACT) + _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION} EXACT CHECK_EXISTS) else() - _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION}) + _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION} CHECK_EXISTS) endif() else() - unset (${_PYTHON_PREFIX}_EXECUTABLE CACHE) + unset (_${_PYTHON_PREFIX}_EXECUTABLE CACHE) unset (_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE CACHE) endif() endif() - if (NOT ${_PYTHON_PREFIX}_EXECUTABLE) + if (NOT _${_PYTHON_PREFIX}_EXECUTABLE) set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION") @@ -859,7 +891,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) while (TRUE) # Virtual environments handling if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$") - find_program (${_PYTHON_PREFIX}_EXECUTABLE + find_program (_${_PYTHON_PREFIX}_EXECUTABLE NAMES ${_${_PYTHON_PREFIX}_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} @@ -871,7 +903,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NO_CMAKE_SYSTEM_PATH) _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION}) - if (${_PYTHON_PREFIX}_EXECUTABLE) + if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() if (NOT _${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "ONLY") @@ -881,7 +913,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) # Apple frameworks handling if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST") - find_program (${_PYTHON_PREFIX}_EXECUTABLE + find_program (_${_PYTHON_PREFIX}_EXECUTABLE NAMES ${_${_PYTHON_PREFIX}_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} @@ -892,13 +924,13 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION}) - if (${_PYTHON_PREFIX}_EXECUTABLE) + if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() endif() # Windows registry if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") - find_program (${_PYTHON_PREFIX}_EXECUTABLE + find_program (_${_PYTHON_PREFIX}_EXECUTABLE NAMES ${_${_PYTHON_PREFIX}_NAMES} ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} NAMES_PER_DIR @@ -908,13 +940,13 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION}) - if (${_PYTHON_PREFIX}_EXECUTABLE) + if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() endif() # try using HINTS - find_program (${_PYTHON_PREFIX}_EXECUTABLE + find_program (_${_PYTHON_PREFIX}_EXECUTABLE NAMES ${_${_PYTHON_PREFIX}_NAMES} ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} NAMES_PER_DIR @@ -923,36 +955,36 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION}) - if (${_PYTHON_PREFIX}_EXECUTABLE) + if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() # try using standard paths - find_program (${_PYTHON_PREFIX}_EXECUTABLE + find_program (_${_PYTHON_PREFIX}_EXECUTABLE NAMES ${_${_PYTHON_PREFIX}_NAMES} ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} NAMES_PER_DIR PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}) _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION}) - if (${_PYTHON_PREFIX}_EXECUTABLE) + if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() # Apple frameworks handling if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST") - find_program (${_PYTHON_PREFIX}_EXECUTABLE + find_program (_${_PYTHON_PREFIX}_EXECUTABLE NAMES ${_${_PYTHON_PREFIX}_NAMES} NAMES_PER_DIR PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} PATH_SUFFIXES bin NO_DEFAULT_PATH) _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION}) - if (${_PYTHON_PREFIX}_EXECUTABLE) + if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() endif() # Windows registry if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST") - find_program (${_PYTHON_PREFIX}_EXECUTABLE + find_program (_${_PYTHON_PREFIX}_EXECUTABLE NAMES ${_${_PYTHON_PREFIX}_NAMES} ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} NAMES_PER_DIR @@ -960,7 +992,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} NO_DEFAULT_PATH) _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION}) - if (${_PYTHON_PREFIX}_EXECUTABLE) + if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() endif() @@ -979,7 +1011,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) # Virtual environments handling if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$") - find_program (${_PYTHON_PREFIX}_EXECUTABLE + find_program (_${_PYTHON_PREFIX}_EXECUTABLE NAMES ${_${_PYTHON_PREFIX}_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} @@ -990,7 +1022,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT) - if (${_PYTHON_PREFIX}_EXECUTABLE) + if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "ONLY") @@ -1000,7 +1032,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) # Apple frameworks handling if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST") - find_program (${_PYTHON_PREFIX}_EXECUTABLE + find_program (_${_PYTHON_PREFIX}_EXECUTABLE NAMES ${_${_PYTHON_PREFIX}_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} @@ -1014,7 +1046,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) # Windows registry if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") - find_program (${_PYTHON_PREFIX}_EXECUTABLE + find_program (_${_PYTHON_PREFIX}_EXECUTABLE NAMES ${_${_PYTHON_PREFIX}_NAMES} ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} NAMES_PER_DIR @@ -1027,12 +1059,12 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) endif() _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT) - if (${_PYTHON_PREFIX}_EXECUTABLE) + if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() # try using HINTS - find_program (${_PYTHON_PREFIX}_EXECUTABLE + find_program (_${_PYTHON_PREFIX}_EXECUTABLE NAMES ${_${_PYTHON_PREFIX}_NAMES} ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} NAMES_PER_DIR @@ -1041,7 +1073,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT) - if (${_PYTHON_PREFIX}_EXECUTABLE) + if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() # try using standard paths. @@ -1051,22 +1083,22 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) # for version 3.*. So looking for names per dir will find, potentially, # systematically 'python' (i.e. version 2) even if version 3 is searched. if (CMAKE_HOST_WIN32) - find_program (${_PYTHON_PREFIX}_EXECUTABLE + find_program (_${_PYTHON_PREFIX}_EXECUTABLE NAMES ${_${_PYTHON_PREFIX}_NAMES} python ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}) else() - find_program (${_PYTHON_PREFIX}_EXECUTABLE + find_program (_${_PYTHON_PREFIX}_EXECUTABLE NAMES ${_${_PYTHON_PREFIX}_NAMES}) endif() _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT) - if (${_PYTHON_PREFIX}_EXECUTABLE) + if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() # Apple frameworks handling if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST") - find_program (${_PYTHON_PREFIX}_EXECUTABLE + find_program (_${_PYTHON_PREFIX}_EXECUTABLE NAMES ${_${_PYTHON_PREFIX}_NAMES} NAMES_PER_DIR PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} @@ -1076,7 +1108,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) # Windows registry if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST") - find_program (${_PYTHON_PREFIX}_EXECUTABLE + find_program (_${_PYTHON_PREFIX}_EXECUTABLE NAMES ${_${_PYTHON_PREFIX}_NAMES} ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} NAMES_PER_DIR @@ -1087,12 +1119,12 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) endif() _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT) - if (${_PYTHON_PREFIX}_EXECUTABLE) + if (_${_PYTHON_PREFIX}_EXECUTABLE) break() endif() endforeach() - if (NOT ${_PYTHON_PREFIX}_EXECUTABLE AND + if (NOT _${_PYTHON_PREFIX}_EXECUTABLE AND NOT _${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "ONLY") # No specific version found. Retry with generic names and standard paths. # NAMES_PER_DIR is not defined on purpose to have a chance to find @@ -1100,7 +1132,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) # For example, typical systems have 'python' for version 2.* and 'python3' # for version 3.*. So looking for names per dir will find, potentially, # systematically 'python' (i.e. version 2) even if version 3 is searched. - find_program (${_PYTHON_PREFIX}_EXECUTABLE + find_program (_${_PYTHON_PREFIX}_EXECUTABLE NAMES python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} python ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}) @@ -1109,32 +1141,35 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) endif() endif() + set (${_PYTHON_PREFIX}_EXECUTABLE "${_${_PYTHON_PREFIX}_EXECUTABLE}") + # retrieve exact version of executable found - if (${_PYTHON_PREFIX}_EXECUTABLE) - execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c + if (_${_PYTHON_PREFIX}_EXECUTABLE) + execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:3]]))" RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT OUTPUT_VARIABLE ${_PYTHON_PREFIX}_VERSION ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) if (NOT _${_PYTHON_PREFIX}_RESULT) + set (_${_PYTHON_PREFIX}_EXECUTABLE_USABLE TRUE) string (REGEX MATCHALL "[0-9]+" _${_PYTHON_PREFIX}_VERSIONS "${${_PYTHON_PREFIX}_VERSION}") list (GET _${_PYTHON_PREFIX}_VERSIONS 0 ${_PYTHON_PREFIX}_VERSION_MAJOR) list (GET _${_PYTHON_PREFIX}_VERSIONS 1 ${_PYTHON_PREFIX}_VERSION_MINOR) list (GET _${_PYTHON_PREFIX}_VERSIONS 2 ${_PYTHON_PREFIX}_VERSION_PATCH) else() # Interpreter is not usable - set_property (CACHE ${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") + set (_${_PYTHON_PREFIX}_EXECUTABLE_USABLE FALSE) unset (${_PYTHON_PREFIX}_VERSION) endif() endif() - if (${_PYTHON_PREFIX}_EXECUTABLE + if (_${_PYTHON_PREFIX}_EXECUTABLE AND _${_PYTHON_PREFIX}_EXECUTABLE_USABLE AND ${_PYTHON_PREFIX}_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR) set (${_PYTHON_PREFIX}_Interpreter_FOUND TRUE) # Use interpreter version and ABI for future searches to ensure consistency set (_${_PYTHON_PREFIX}_FIND_VERSIONS ${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR}) - execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; sys.stdout.write(sys.abiflags)" + execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; sys.stdout.write(sys.abiflags)" RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT OUTPUT_VARIABLE _${_PYTHON_PREFIX}_ABIFLAGS ERROR_QUIET @@ -1147,12 +1182,12 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) if (${_PYTHON_PREFIX}_Interpreter_FOUND) # compute and save interpreter signature - string (MD5 __${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${${_PYTHON_PREFIX}_EXECUTABLE}") + string (MD5 __${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_EXECUTABLE}") set (_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE "${__${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE}" CACHE INTERNAL "") if (NOT CMAKE_SIZEOF_VOID_P) # determine interpreter architecture - execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; print(sys.maxsize > 2**32)" + execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; print(sys.maxsize > 2**32)" RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT OUTPUT_VARIABLE ${_PYTHON_PREFIX}_IS64BIT ERROR_VARIABLE ${_PYTHON_PREFIX}_IS64BIT) @@ -1168,7 +1203,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) endif() # retrieve interpreter identity - execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -V + execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -V RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT OUTPUT_VARIABLE ${_PYTHON_PREFIX}_INTERPRETER_ID ERROR_VARIABLE ${_PYTHON_PREFIX}_INTERPRETER_ID) @@ -1181,7 +1216,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) string (REGEX REPLACE "^([^ ]+).*" "\\1" ${_PYTHON_PREFIX}_INTERPRETER_ID "${${_PYTHON_PREFIX}_INTERPRETER_ID}") if (${_PYTHON_PREFIX}_INTERPRETER_ID STREQUAL "Python") # try to get a more precise ID - execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; print(sys.copyright)" + execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; print(sys.copyright)" RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT OUTPUT_VARIABLE ${_PYTHON_PREFIX}_COPYRIGHT ERROR_QUIET) @@ -1195,7 +1230,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) endif() # retrieve various package installation directories - execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig;sys.stdout.write(';'.join([sysconfig.get_python_lib(plat_specific=False,standard_lib=True),sysconfig.get_python_lib(plat_specific=True,standard_lib=True),sysconfig.get_python_lib(plat_specific=False,standard_lib=False),sysconfig.get_python_lib(plat_specific=True,standard_lib=False)]))" + execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig;sys.stdout.write(';'.join([sysconfig.get_python_lib(plat_specific=False,standard_lib=True),sysconfig.get_python_lib(plat_specific=True,standard_lib=True),sysconfig.get_python_lib(plat_specific=False,standard_lib=False),sysconfig.get_python_lib(plat_specific=True,standard_lib=False)]))" RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT OUTPUT_VARIABLE _${_PYTHON_PREFIX}_LIBPATHS @@ -1216,35 +1251,38 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) unset (${_PYTHON_PREFIX}_INTERPRETER_ID) endif() - mark_as_advanced (${_PYTHON_PREFIX}_EXECUTABLE + mark_as_advanced (_${_PYTHON_PREFIX}_EXECUTABLE _${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE) endif() # second step, search for compiler (IronPython) if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) - list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS ${_PYTHON_PREFIX}_COMPILER) + list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS _${_PYTHON_PREFIX}_COMPILER) if (${_PYTHON_PREFIX}_FIND_REQUIRED_Compiler) list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_COMPILER) endif() - if (DEFINED ${_PYTHON_PREFIX}_COMPILER) + if (DEFINED ${_PYTHON_PREFIX}_COMPILER + AND IS_ABSOLUTE "${${_PYTHON_PREFIX}_COMPILER}") + set (_${_PYTHON_PREFIX}_COMPILER "${${_PYTHON_PREFIX}_COMPILER}" CACHE INTERNAL "") + elseif (DEFINED _${_PYTHON_PREFIX}_COMPILER) # compute compiler signature and check validity of definition - string (MD5 __${_PYTHON_PREFIX}_COMPILER_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${${_PYTHON_PREFIX}_COMPILER}") + string (MD5 __${_PYTHON_PREFIX}_COMPILER_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_COMPILER}") if (__${_PYTHON_PREFIX}_COMPILER_SIGNATURE STREQUAL _${_PYTHON_PREFIX}_COMPILER_SIGNATURE) # check version validity if (${_PYTHON_PREFIX}_FIND_VERSION_EXACT) - _python_validate_compiler (${${_PYTHON_PREFIX}_FIND_VERSION} EXACT) + _python_validate_compiler (${${_PYTHON_PREFIX}_FIND_VERSION} EXACT CHECK_EXISTS) else() - _python_validate_compiler (${${_PYTHON_PREFIX}_FIND_VERSION}) + _python_validate_compiler (${${_PYTHON_PREFIX}_FIND_VERSION} CHECK_EXISTS) endif() else() - unset (${_PYTHON_PREFIX}_COMPILER CACHE) + unset (_${_PYTHON_PREFIX}_COMPILER CACHE) unset (_${_PYTHON_PREFIX}_COMPILER_SIGNATURE CACHE) endif() endif() - if (NOT ${_PYTHON_PREFIX}_COMPILER) + if (NOT _${_PYTHON_PREFIX}_COMPILER) # IronPython specific artifacts # If IronPython interpreter is found, use its path unset (_${_PYTHON_PREFIX}_IRON_ROOT) @@ -1263,7 +1301,7 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) while (TRUE) if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") - find_program (${_PYTHON_PREFIX}_COMPILER + find_program (_${_PYTHON_PREFIX}_COMPILER NAMES ipyc HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS} PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} @@ -1271,24 +1309,24 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) _python_validate_compiler (${${_PYTHON_PREFIX}_FIND_VERSION}) - if (${_PYTHON_PREFIX}_COMPILER) + if (_${_PYTHON_PREFIX}_COMPILER) break() endif() endif() - find_program (${_PYTHON_PREFIX}_COMPILER + find_program (_${_PYTHON_PREFIX}_COMPILER NAMES ipyc HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) _python_validate_compiler (${${_PYTHON_PREFIX}_FIND_VERSION}) - if (${_PYTHON_PREFIX}_COMPILER) + if (_${_PYTHON_PREFIX}_COMPILER) break() endif() if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST") - find_program (${_PYTHON_PREFIX}_COMPILER + find_program (_${_PYTHON_PREFIX}_COMPILER NAMES ipyc PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} @@ -1301,7 +1339,7 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) # try using root dir and registry foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") - find_program (${_PYTHON_PREFIX}_COMPILER + find_program (_${_PYTHON_PREFIX}_COMPILER NAMES ipyc HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS} PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] @@ -1309,48 +1347,50 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) _python_validate_compiler (${_${_PYTHON_PREFIX}_VERSION} EXACT) - if (${_PYTHON_PREFIX}_COMPILER) + if (_${_PYTHON_PREFIX}_COMPILER) break() endif() endif() - find_program (${_PYTHON_PREFIX}_COMPILER + find_program (_${_PYTHON_PREFIX}_COMPILER NAMES ipyc HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) _python_validate_compiler (${_${_PYTHON_PREFIX}_VERSION} EXACT) - if (${_PYTHON_PREFIX}_COMPILER) + if (_${_PYTHON_PREFIX}_COMPILER) break() endif() if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST") - find_program (${_PYTHON_PREFIX}_COMPILER + find_program (_${_PYTHON_PREFIX}_COMPILER NAMES ipyc PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} NO_DEFAULT_PATH) _python_validate_compiler (${_${_PYTHON_PREFIX}_VERSION} EXACT) - if (${_PYTHON_PREFIX}_COMPILER) + if (_${_PYTHON_PREFIX}_COMPILER) break() endif() endif() endforeach() # no specific version found, re-try in standard paths - find_program (${_PYTHON_PREFIX}_COMPILER + find_program (_${_PYTHON_PREFIX}_COMPILER NAMES ipyc HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}) endif() endif() - if (${_PYTHON_PREFIX}_COMPILER) + set (${_PYTHON_PREFIX}_COMPILER "${_${_PYTHON_PREFIX}_COMPILER}") + + if (_${_PYTHON_PREFIX}_COMPILER) # retrieve python environment version from compiler set (_${_PYTHON_PREFIX}_VERSION_DIR "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/PythonCompilerVersion.dir") file (WRITE "${_${_PYTHON_PREFIX}_VERSION_DIR}/version.py" "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:3]]))\n") - execute_process (COMMAND "${${_PYTHON_PREFIX}_COMPILER}" /target:exe /embed "${_${_PYTHON_PREFIX}_VERSION_DIR}/version.py" + execute_process (COMMAND "${_${_PYTHON_PREFIX}_COMPILER}" /target:exe /embed "${_${_PYTHON_PREFIX}_VERSION_DIR}/version.py" WORKING_DIRECTORY "${_${_PYTHON_PREFIX}_VERSION_DIR}" OUTPUT_QUIET ERROR_QUIET) @@ -1360,6 +1400,7 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) OUTPUT_VARIABLE _${_PYTHON_PREFIX}_VERSION ERROR_QUIET) if (NOT _${_PYTHON_PREFIX}_RESULT) + set (_${_PYTHON_PREFIX}_COMPILER_USABLE TRUE) string (REGEX MATCHALL "[0-9]+" _${_PYTHON_PREFIX}_VERSIONS "${_${_PYTHON_PREFIX}_VERSION}") list (GET _${_PYTHON_PREFIX}_VERSIONS 0 _${_PYTHON_PREFIX}_VERSION_MAJOR) list (GET _${_PYTHON_PREFIX}_VERSIONS 1 _${_PYTHON_PREFIX}_VERSION_MINOR) @@ -1374,12 +1415,12 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) endif() else() # compiler not usable - set_property (CACHE ${_PYTHON_PREFIX}_COMPILER PROPERTY VALUE "${_PYTHON_PREFIX}_COMPILER-NOTFOUND") + set (_${_PYTHON_PREFIX}_COMPILER_USABLE FALSE) endif() file (REMOVE_RECURSE "${_${_PYTHON_PREFIX}_VERSION_DIR}") endif() - if (${_PYTHON_PREFIX}_COMPILER) + if (_${_PYTHON_PREFIX}_COMPILER AND _${_PYTHON_PREFIX}_COMPILER_USABLE) if (${_PYTHON_PREFIX}_Interpreter_FOUND) # Compiler must be compatible with interpreter if (${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR} VERSION_EQUAL ${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR}) @@ -1394,7 +1435,7 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) if (${_PYTHON_PREFIX}_Compiler_FOUND) # compute and save compiler signature - string (MD5 __${_PYTHON_PREFIX}_COMPILER_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${${_PYTHON_PREFIX}_COMPILER}") + string (MD5 __${_PYTHON_PREFIX}_COMPILER_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_COMPILER}") set (_${_PYTHON_PREFIX}_COMPILER_SIGNATURE "${__${_PYTHON_PREFIX}_COMPILER_SIGNATURE}" CACHE INTERNAL "") set (${_PYTHON_PREFIX}_COMPILER_ID IronPython) @@ -1403,7 +1444,7 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) unset (${_PYTHON_PREFIX}_COMPILER_ID) endif() - mark_as_advanced (${_PYTHON_PREFIX}_COMPILER + mark_as_advanced (_${_PYTHON_PREFIX}_COMPILER _${_PYTHON_PREFIX}_COMPILER_SIGNATURE) endif() @@ -1412,36 +1453,51 @@ endif() ## Development environment is not compatible with IronPython interpreter if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND NOT ${_PYTHON_PREFIX}_INTERPRETER_ID STREQUAL "IronPython") - list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS ${_PYTHON_PREFIX}_LIBRARY - ${_PYTHON_PREFIX}_LIBRARY_RELEASE + list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS _${_PYTHON_PREFIX}_LIBRARY_RELEASE ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE - ${_PYTHON_PREFIX}_LIBRARY_DEBUG + _${_PYTHON_PREFIX}_LIBRARY_DEBUG ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG - ${_PYTHON_PREFIX}_INCLUDE_DIR) + _${_PYTHON_PREFIX}_INCLUDE_DIR) if (${_PYTHON_PREFIX}_FIND_REQUIRED_Development) - list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_LIBRARY - ${_PYTHON_PREFIX}_INCLUDE_DIR) + list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_LIBRARIES + ${_PYTHON_PREFIX}_INCLUDE_DIRS) endif() - if (DEFINED ${_PYTHON_PREFIX}_LIBRARY_RELEASE OR DEFINED ${_PYTHON_PREFIX}_INCLUDE_DIR) + if (DEFINED _${_PYTHON_PREFIX}_LIBRARY_RELEASE OR DEFINED _${_PYTHON_PREFIX}_INCLUDE_DIR) # compute development signature and check validity of definition - string (MD5 __${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${${_PYTHON_PREFIX}_LIBRARY_RELEASE}:${${_PYTHON_PREFIX}_INCLUDE_DIR}") + string (MD5 __${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}:${_${_PYTHON_PREFIX}_INCLUDE_DIR}") + if (WIN32 AND NOT DEFINED _${_PYTHON_PREFIX}_LIBRARY_DEBUG) + set (_${_PYTHON_PREFIX}_LIBRARY_DEBUG "_${_PYTHON_PREFIX}_LIBRARY_DEBUG-NOTFOUND" CACHE INTERNAL "") + endif() + if (NOT DEFINED _${_PYTHON_PREFIX}_INCLUDE_DIR) + set (_${_PYTHON_PREFIX}_INCLUDE_DIR "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND" CACHE INTERNAL "") + endif() if (__${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE STREQUAL _${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE) # check version validity if (${_PYTHON_PREFIX}_FIND_VERSION_EXACT) - _python_validate_library (${${_PYTHON_PREFIX}_FIND_VERSION} EXACT) - _python_validate_include_dir (${${_PYTHON_PREFIX}_FIND_VERSION} EXACT) + _python_validate_library (${${_PYTHON_PREFIX}_FIND_VERSION} EXACT CHECK_EXISTS) + _python_validate_include_dir (${${_PYTHON_PREFIX}_FIND_VERSION} EXACT CHECK_EXISTS) else() - _python_validate_library (${${_PYTHON_PREFIX}_FIND_VERSION}) - _python_validate_include_dir (${${_PYTHON_PREFIX}_FIND_VERSION}) + _python_validate_library (${${_PYTHON_PREFIX}_FIND_VERSION} CHECK_EXISTS) + _python_validate_include_dir (${${_PYTHON_PREFIX}_FIND_VERSION} CHECK_EXISTS) endif() else() - unset (${_PYTHON_PREFIX}_LIBRARY_RELEASE CACHE) - unset (${_PYTHON_PREFIX}_LIBRARY_DEBUG CACHE) - unset (${_PYTHON_PREFIX}_INCLUDE_DIR CACHE) + unset (_${_PYTHON_PREFIX}_LIBRARY_RELEASE CACHE) + unset (_${_PYTHON_PREFIX}_LIBRARY_DEBUG CACHE) + unset (_${_PYTHON_PREFIX}_INCLUDE_DIR CACHE) unset (_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE CACHE) endif() endif() + if (DEFINED ${_PYTHON_PREFIX}_LIBRARY + AND IS_ABSOLUTE "${${_PYTHON_PREFIX}_LIBRARY}") + set (_${_PYTHON_PREFIX}_LIBRARY_RELEASE "${${_PYTHON_PREFIX}_LIBRARY}" CACHE INTERNAL "") + unset (_${_PYTHON_PREFIX}_LIBRARY_DEBUG CACHE) + unset (_${_PYTHON_PREFIX}_INCLUDE_DIR CACHE) + endif() + if (DEFINED ${_PYTHON_PREFIX}_INCLUDE_DIR + AND IS_ABSOLUTE "${${_PYTHON_PREFIX}_INCLUDE_DIR}") + set (_${_PYTHON_PREFIX}_INCLUDE_DIR "${${_PYTHON_PREFIX}_INCLUDE_DIR}" CACHE INTERNAL "") + endif() # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES unset (_${_PYTHON_PREFIX}_CMAKE_FIND_LIBRARY_SUFFIXES) @@ -1454,7 +1510,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() endif() - if (NOT ${_PYTHON_PREFIX}_LIBRARY_RELEASE OR NOT ${_PYTHON_PREFIX}_INCLUDE_DIR) + if (NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE OR NOT _${_PYTHON_PREFIX}_INCLUDE_DIR) # if python interpreter is found, use it to look-up for artifacts # to ensure consistency between interpreter and development environments. # If not, try to locate a compatible config tool @@ -1653,7 +1709,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() endif() - if (NOT ${_PYTHON_PREFIX}_LIBRARY_RELEASE) + if (NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE) if ((${_PYTHON_PREFIX}_Interpreter_FOUND AND NOT CMAKE_CROSSCOMPILING) OR _${_PYTHON_PREFIX}_CONFIG) # retrieve root install directory _python_get_config_var (_${_PYTHON_PREFIX}_PREFIX PREFIX) @@ -1678,7 +1734,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS list (APPEND _${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) - find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE + find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} @@ -1688,7 +1744,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() # Rely on HINTS and standard paths if interpreter or config tool failed to locate artifacts - if (NOT ${_PYTHON_PREFIX}_LIBRARY_RELEASE) + if (NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE) set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) unset (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS) @@ -1724,7 +1780,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endforeach() if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST") - find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE + find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} @@ -1738,7 +1794,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") - find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE + find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} @@ -1750,7 +1806,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() # search in HINTS locations - find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE + find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} @@ -1772,7 +1828,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() # search in all default paths - find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE + find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} NAMES_PER_DIR PATHS ${__${_PYTHON_PREFIX}_FRAMEWORK_PATHS} @@ -1789,7 +1845,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS _python_get_path_suffixes (_${_PYTHON_PREFIX}_PATH_SUFFIXES VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} LIBRARY) if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST") - find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE + find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} @@ -1803,7 +1859,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") - find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE + find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} @@ -1815,7 +1871,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() # search in HINTS locations - find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE + find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} @@ -1837,14 +1893,14 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() # search in all default paths - find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE + find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} NAMES_PER_DIR PATHS ${__${_PYTHON_PREFIX}_FRAMEWORK_PATHS} ${__${_PYTHON_PREFIX}_REGISTRY_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}) - if (${_PYTHON_PREFIX}_LIBRARY_RELEASE) + if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE) break() endif() endforeach() @@ -1855,14 +1911,20 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS # finalize library version information _python_get_version (LIBRARY PREFIX _${_PYTHON_PREFIX}_) + set (${_PYTHON_PREFIX}_LIBRARY_RELEASE "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}" CACHE FILEPATH "Path to a library." FORCE) + + if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE AND NOT EXISTS "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}") + set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND") + endif() + set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) - if (WIN32 AND ${_PYTHON_PREFIX}_LIBRARY_RELEASE) + if (WIN32 AND _${_PYTHON_PREFIX}_LIBRARY_RELEASE) # search for debug library # use release library location as a hint _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG VERSION ${_${_PYTHON_PREFIX}_VERSION} WIN32 DEBUG) - get_filename_component (_${_PYTHON_PREFIX}_PATH "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY) - find_library (${_PYTHON_PREFIX}_LIBRARY_DEBUG + get_filename_component (_${_PYTHON_PREFIX}_PATH "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY) + find_library (_${_PYTHON_PREFIX}_LIBRARY_DEBUG NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG} NAMES_PER_DIR HINTS "${_${_PYTHON_PREFIX}_PATH}" ${_${_PYTHON_PREFIX}_HINTS} @@ -1870,9 +1932,9 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() # retrieve runtime libraries - if (${_PYTHON_PREFIX}_LIBRARY_RELEASE) + if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE) _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} WIN32 POSIX LIBRARY) - get_filename_component (_${_PYTHON_PREFIX}_PATH "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY) + get_filename_component (_${_PYTHON_PREFIX}_PATH "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY) get_filename_component (_${_PYTHON_PREFIX}_PATH2 "${_${_PYTHON_PREFIX}_PATH}" DIRECTORY) _python_find_runtime_library (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} @@ -1880,9 +1942,9 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS HINTS "${_${_PYTHON_PREFIX}_PATH}" "${_${_PYTHON_PREFIX}_PATH2}" ${_${_PYTHON_PREFIX}_HINTS} PATH_SUFFIXES bin) endif() - if (${_PYTHON_PREFIX}_LIBRARY_DEBUG) + if (_${_PYTHON_PREFIX}_LIBRARY_DEBUG) _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG VERSION ${_${_PYTHON_PREFIX}_VERSION} WIN32 DEBUG) - get_filename_component (_${_PYTHON_PREFIX}_PATH "${${_PYTHON_PREFIX}_LIBRARY_DEBUG}" DIRECTORY) + get_filename_component (_${_PYTHON_PREFIX}_PATH "${_${_PYTHON_PREFIX}_LIBRARY_DEBUG}" DIRECTORY) get_filename_component (_${_PYTHON_PREFIX}_PATH2 "${_${_PYTHON_PREFIX}_PATH}" DIRECTORY) _python_find_runtime_library (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG} @@ -1892,11 +1954,11 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() # Don't search for include dir if no library was founded - if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND NOT ${_PYTHON_PREFIX}_INCLUDE_DIR) + if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE AND NOT _${_PYTHON_PREFIX}_INCLUDE_DIR) if ((${_PYTHON_PREFIX}_Interpreter_FOUND AND NOT CMAKE_CROSSCOMPILING) OR _${_PYTHON_PREFIX}_CONFIG) _python_get_config_var (_${_PYTHON_PREFIX}_INCLUDE_DIRS INCLUDES) - find_path (${_PYTHON_PREFIX}_INCLUDE_DIR + find_path (_${_PYTHON_PREFIX}_INCLUDE_DIR NAMES Python.h HINTS ${_${_PYTHON_PREFIX}_INCLUDE_DIRS} NO_SYSTEM_ENVIRONMENT_PATH @@ -1904,7 +1966,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() # Rely on HINTS and standard paths if interpreter or config tool failed to locate artifacts - if (NOT ${_PYTHON_PREFIX}_INCLUDE_DIR) + if (NOT _${_PYTHON_PREFIX}_INCLUDE_DIR) unset (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS) if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$") set (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS ENV VIRTUAL_ENV) @@ -1912,15 +1974,15 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS unset (_${_PYTHON_PREFIX}_INCLUDE_HINTS) # Use the library's install prefix as a hint - if (${${_PYTHON_PREFIX}_LIBRARY_RELEASE} MATCHES "^(.+/Frameworks/Python.framework/Versions/[0-9.]+)") + if (${_${_PYTHON_PREFIX}_LIBRARY_RELEASE} MATCHES "^(.+/Frameworks/Python.framework/Versions/[0-9.]+)") list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${CMAKE_MATCH_1}") - elseif (${${_PYTHON_PREFIX}_LIBRARY_RELEASE} MATCHES "^(.+)/lib(64|32)?/python[0-9.]+/config") + elseif (${_${_PYTHON_PREFIX}_LIBRARY_RELEASE} MATCHES "^(.+)/lib(64|32)?/python[0-9.]+/config") list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${CMAKE_MATCH_1}") - elseif (DEFINED CMAKE_LIBRARY_ARCHITECTURE AND ${${_PYTHON_PREFIX}_LIBRARY_RELEASE} MATCHES "^(.+)/lib/${CMAKE_LIBRARY_ARCHITECTURE}") + elseif (DEFINED CMAKE_LIBRARY_ARCHITECTURE AND ${_${_PYTHON_PREFIX}_LIBRARY_RELEASE} MATCHES "^(.+)/lib/${CMAKE_LIBRARY_ARCHITECTURE}") list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${CMAKE_MATCH_1}") else() # assume library is in a directory under root - get_filename_component (_${_PYTHON_PREFIX}_PREFIX "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY) + get_filename_component (_${_PYTHON_PREFIX}_PREFIX "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY) get_filename_component (_${_PYTHON_PREFIX}_PREFIX "${_${_PYTHON_PREFIX}_PREFIX}" DIRECTORY) list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${_${_PYTHON_PREFIX}_PREFIX}") endif() @@ -1930,7 +1992,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS _python_get_path_suffixes (_${_PYTHON_PREFIX}_PATH_SUFFIXES VERSION ${_${_PYTHON_PREFIX}_VERSION} INCLUDE) if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST") - find_path (${_PYTHON_PREFIX}_INCLUDE_DIR + find_path (_${_PYTHON_PREFIX}_INCLUDE_DIR NAMES Python.h HINTS ${_${_PYTHON_PREFIX}_INCLUDE_HINTS} ${_${_PYTHON_PREFIX}_HINTS} PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} @@ -1943,7 +2005,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") - find_path (${_PYTHON_PREFIX}_INCLUDE_DIR + find_path (_${_PYTHON_PREFIX}_INCLUDE_DIR NAMES Python.h HINTS ${_${_PYTHON_PREFIX}_INCLUDE_HINTS} ${_${_PYTHON_PREFIX}_HINTS} PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} @@ -1965,7 +2027,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS unset (__${_PYTHON_PREFIX}_REGISTRY_PATHS) endif() - find_path (${_PYTHON_PREFIX}_INCLUDE_DIR + find_path (_${_PYTHON_PREFIX}_INCLUDE_DIR NAMES Python.h HINTS ${_${_PYTHON_PREFIX}_INCLUDE_HINTS} ${_${_PYTHON_PREFIX}_HINTS} PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} @@ -1977,15 +2039,21 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() # search header file in standard locations - find_path (${_PYTHON_PREFIX}_INCLUDE_DIR + find_path (_${_PYTHON_PREFIX}_INCLUDE_DIR NAMES Python.h) endif() - # retrieve version from header file - _python_get_version (INCLUDE PREFIX _${_PYTHON_PREFIX}_INC_) + set (${_PYTHON_PREFIX}_INCLUDE_DIRS "${_${_PYTHON_PREFIX}_INCLUDE_DIR}") + + if (_${_PYTHON_PREFIX}_INCLUDE_DIR AND NOT EXISTS "${_${_PYTHON_PREFIX}_INCLUDE_DIR}") + set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") + endif() - if (${_PYTHON_PREFIX}_INCLUDE_DIR) - # update versionning + if (_${_PYTHON_PREFIX}_INCLUDE_DIR) + # retrieve version from header file + _python_get_version (INCLUDE PREFIX _${_PYTHON_PREFIX}_INC_) + + # update versioning if (_${_PYTHON_PREFIX}_INC_VERSION VERSION_EQUAL ${_${_PYTHON_PREFIX}_VERSION}) set (_${_PYTHON_PREFIX}_VERSION_PATCH ${_${_PYTHON_PREFIX}_INC_VERSION_PATCH}) endif() @@ -2000,10 +2068,14 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() # define public variables + set (${_PYTHON_PREFIX}_LIBRARY_DEBUG "${_${_PYTHON_PREFIX}_LIBRARY_DEBUG}" CACHE FILEPATH "Path to a library." FORCE) + include (${CMAKE_CURRENT_LIST_DIR}/../SelectLibraryConfigurations.cmake) select_library_configurations (${_PYTHON_PREFIX}) if (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE) set (${_PYTHON_PREFIX}_RUNTIME_LIBRARY "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE}") + elseif (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG) + set (${_PYTHON_PREFIX}_RUNTIME_LIBRARY "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG}") else() set (${_PYTHON_PREFIX}_RUNTIME_LIBRARY "${_PYTHON_PREFIX}_RUNTIME_LIBRARY-NOTFOUND") endif() @@ -2019,9 +2091,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG) endif() - set (${_PYTHON_PREFIX}_INCLUDE_DIRS "${${_PYTHON_PREFIX}_INCLUDE_DIR}") - - if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_INCLUDE_DIR) + if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE AND _${_PYTHON_PREFIX}_INCLUDE_DIR) if (${_PYTHON_PREFIX}_Interpreter_FOUND OR ${_PYTHON_PREFIX}_Compiler_FOUND) # development environment must be compatible with interpreter/compiler if (${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR} VERSION_EQUAL ${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR} @@ -2032,11 +2102,16 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND ${_${_PYTHON_PREFIX}_INC_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_INC_VERSION_MINOR} VERSION_EQUAL ${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR}) set (${_PYTHON_PREFIX}_Development_FOUND TRUE) endif() + if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND + (NOT _${_PYTHON_PREFIX}_ABI IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS + OR NOT _${_PYTHON_PREFIX}_INC_ABI IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS)) + set (${_PYTHON_PREFIX}_Development_FOUND FALSE) + endif() endif() if (${_PYTHON_PREFIX}_Development_FOUND) # compute and save development signature - string (MD5 __${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${${_PYTHON_PREFIX}_LIBRARY_RELEASE}:${${_PYTHON_PREFIX}_INCLUDE_DIR}") + string (MD5 __${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}:${_${_PYTHON_PREFIX}_INCLUDE_DIR}") set (_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE "${__${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE}" CACHE INTERNAL "") else() unset (_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE CACHE) @@ -2047,28 +2122,34 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS set (CMAKE_FIND_LIBRARY_SUFFIXES ${_${_PYTHON_PREFIX}_CMAKE_FIND_LIBRARY_SUFFIXES}) endif() - mark_as_advanced (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE + mark_as_advanced (_${_PYTHON_PREFIX}_LIBRARY_RELEASE + _${_PYTHON_PREFIX}_LIBRARY_DEBUG + ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG - ${_PYTHON_PREFIX}_INCLUDE_DIR + _${_PYTHON_PREFIX}_INCLUDE_DIR _${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE) endif() if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND ${_PYTHON_PREFIX}_Interpreter_FOUND) - list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS ${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR) + list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS _${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR) if (${_PYTHON_PREFIX}_FIND_REQUIRED_NumPy) - list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR) + list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_NumPy_INCLUDE_DIRS) endif() - if (DEFINED ${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR) + if (DEFINED ${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR + AND IS_ABSOLUTE "${${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}") + set (_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR "${${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}" CACHE INTERNAL "") + elseif (DEFINED _${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR) # compute numpy signature. Depends on interpreter and development signatures - string (MD5 __${_PYTHON_PREFIX}_NUMPY_SIGNATURE "${_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE}:${_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE}:${${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}") - if (NOT __${_PYTHON_PREFIX}_NUMPY_SIGNATURE STREQUAL _${_PYTHON_PREFIX}_NUMPY_SIGNATURE) - unset (${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR CACHE) + string (MD5 __${_PYTHON_PREFIX}_NUMPY_SIGNATURE "${_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE}:${_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE}:${_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}") + if (NOT __${_PYTHON_PREFIX}_NUMPY_SIGNATURE STREQUAL _${_PYTHON_PREFIX}_NUMPY_SIGNATURE + OR NOT EXISTS "${_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}") + unset (_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR CACHE) unset (_${_PYTHON_PREFIX}_NUMPY_SIGNATURE CACHE) endif() endif() - if (NOT ${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR) + if (NOT _${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR) execute_process( COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c "from __future__ import print_function\ntry: import numpy; print(numpy.get_include(), end='')\nexcept:pass\n" @@ -2078,16 +2159,20 @@ if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND ${_PYTHON_PREFIX}_Inte OUTPUT_STRIP_TRAILING_WHITESPACE) if (NOT _${_PYTHON_PREFIX}_RESULT) - find_path (${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR + find_path (_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR NAMES "numpy/arrayobject.h" "numpy/numpyconfig.h" HINTS "${_${_PYTHON_PREFIX}_NumPy_PATH}" NO_DEFAULT_PATH) endif() endif() - if(${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR) - set (${_PYTHON_PREFIX}_NumPy_INCLUDE_DIRS "${${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}") + set (${_PYTHON_PREFIX}_NumPy_INCLUDE_DIRS "${_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}") + + if(_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR AND NOT EXISTS "${_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}") + set_property (CACHE _${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR-NOTFOUND") + endif() + if (_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR) execute_process ( COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c "from __future__ import print_function\ntry: import numpy; print(numpy.__version__, end='')\nexcept:pass\n" @@ -2112,6 +2197,8 @@ if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND ${_PYTHON_PREFIX}_Inte else() unset (_${_PYTHON_PREFIX}_NUMPY_SIGNATURE CACHE) endif() + + mark_as_advanced (_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR) endif() # final validation @@ -2155,10 +2242,12 @@ if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT") set (_${_PYTHON_PREFIX}_LIBRARY_TYPE STATIC) endif() - add_library (${__name} ${_${_PYTHON_PREFIX}_LIBRARY_TYPE} IMPORTED) + if (NOT TARGET ${__name}) + add_library (${__name} ${_${_PYTHON_PREFIX}_LIBRARY_TYPE} IMPORTED) + endif() set_property (TARGET ${__name} - PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_INCLUDE_DIR}") + PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_INCLUDE_DIRS}") if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE) # System manage shared libraries in two parts: import and runtime @@ -2204,33 +2293,31 @@ if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT") endif() endmacro() - if (NOT TARGET ${_PYTHON_PREFIX}::Python) - __python_import_library (${_PYTHON_PREFIX}::Python) - endif() + __python_import_library (${_PYTHON_PREFIX}::Python) - if (NOT TARGET ${_PYTHON_PREFIX}::Module) - if (CMAKE_SYSTEM_NAME MATCHES "^(Windows.*|CYGWIN|MSYS)$") - # On Windows/CYGWIN/MSYS, Python::Module is the same as Python::Python - # but ALIAS cannot be used because the imported library is not GLOBAL. - __python_import_library (${_PYTHON_PREFIX}::Module) - else() + if (CMAKE_SYSTEM_NAME MATCHES "^(Windows.*|CYGWIN|MSYS)$") + # On Windows/CYGWIN/MSYS, Python::Module is the same as Python::Python + # but ALIAS cannot be used because the imported library is not GLOBAL. + __python_import_library (${_PYTHON_PREFIX}::Module) + else() + if (NOT TARGET ${_PYTHON_PREFIX}::Module ) add_library (${_PYTHON_PREFIX}::Module INTERFACE IMPORTED) - set_property (TARGET ${_PYTHON_PREFIX}::Module - PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_INCLUDE_DIR}") + endif() + set_property (TARGET ${_PYTHON_PREFIX}::Module + PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_INCLUDE_DIRS}") - # When available, enforce shared library generation with undefined symbols - if (APPLE) - set_property (TARGET ${_PYTHON_PREFIX}::Module - PROPERTY INTERFACE_LINK_OPTIONS "LINKER:-undefined,dynamic_lookup") - endif() - if (CMAKE_SYSTEM_NAME STREQUAL "SunOS") - set_property (TARGET ${_PYTHON_PREFIX}::Module - PROPERTY INTERFACE_LINK_OPTIONS "LINKER:-z,nodefs") - endif() - if (CMAKE_SYSTEM_NAME STREQUAL "AIX") - set_property (TARGET ${_PYTHON_PREFIX}::Module - PROPERTY INTERFACE_LINK_OPTIONS "LINKER:-b,erok") - endif() + # When available, enforce shared library generation with undefined symbols + if (APPLE) + set_property (TARGET ${_PYTHON_PREFIX}::Module + PROPERTY INTERFACE_LINK_OPTIONS "LINKER:-undefined,dynamic_lookup") + endif() + if (CMAKE_SYSTEM_NAME STREQUAL "SunOS") + set_property (TARGET ${_PYTHON_PREFIX}::Module + PROPERTY INTERFACE_LINK_OPTIONS "LINKER:-z,nodefs") + endif() + if (CMAKE_SYSTEM_NAME STREQUAL "AIX") + set_property (TARGET ${_PYTHON_PREFIX}::Module + PROPERTY INTERFACE_LINK_OPTIONS "LINKER:-b,erok") endif() endif() @@ -2269,7 +2356,7 @@ if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT") AND NOT TARGET ${_PYTHON_PREFIX}::NumPy AND TARGET ${_PYTHON_PREFIX}::Module) add_library (${_PYTHON_PREFIX}::NumPy INTERFACE IMPORTED) set_property (TARGET ${_PYTHON_PREFIX}::NumPy - PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}") + PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_NumPy_INCLUDE_DIRS}") target_link_libraries (${_PYTHON_PREFIX}::NumPy INTERFACE ${_PYTHON_PREFIX}::Module) endif() endif() diff --git a/Modules/FindPython2.cmake b/Modules/FindPython2.cmake index 82878ea..0cecdc6 100644 --- a/Modules/FindPython2.cmake +++ b/Modules/FindPython2.cmake @@ -199,6 +199,44 @@ Hints recommended to also include the component ``Interpreter`` to get expected result. +Artifacts Specification +^^^^^^^^^^^^^^^^^^^^^^^ + +To solve special cases, it is possible to specify directly the artifacts by +setting the following variables: + +``Python2_EXECUTABLE`` + The path to the interpreter. + +``Python2_COMPILER`` + The path to the compiler. + +``Python2_LIBRARY`` + The path to the library. It will be used to compute the + variables ``Python2_LIBRARIES``, ``Python2_LIBRAY_DIRS`` and + ``Python2_RUNTIME_LIBRARY_DIRS``. + +``Python2_INCLUDE_DIR`` + The path to the directory of the ``Python`` headers. It will be used to + compute the variable ``Python2_INCLUDE_DIRS``. + +``Python2_NumPy_INCLUDE_DIR`` + The path to the directory of the ``NumPy`` headers. It will be used to + compute the variable ``Python2_NumPy_INCLUDE_DIRS``. + +.. note:: + + All paths must be absolute. Any artifact specified with a relative path + will be ignored. + +.. note:: + + When an artifact is specified, all ``HINTS`` will be ignored and no search + will be performed for this artifact. + + If more than one artifact is specified, it is the user's responsability to + ensure the consistency of the various artifacts. + Commands ^^^^^^^^ diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake index 417a789..1edb9c9 100644 --- a/Modules/FindPython3.cmake +++ b/Modules/FindPython3.cmake @@ -240,6 +240,44 @@ Hints recommended to also include the component ``Interpreter`` to get expected result. +Artifacts Specification +^^^^^^^^^^^^^^^^^^^^^^^ + +To solve special cases, it is possible to specify directly the artifacts by +setting the following variables: + +``Python3_EXECUTABLE`` + The path to the interpreter. + +``Python3_COMPILER`` + The path to the compiler. + +``Python3_LIBRARY`` + The path to the library. It will be used to compute the + variables ``Python3_LIBRARIES``, ``Python3_LIBRAY_DIRS`` and + ``Python3_RUNTIME_LIBRARY_DIRS``. + +``Python3_INCLUDE_DIR`` + The path to the directory of the ``Python`` headers. It will be used to + compute the variable ``Python3_INCLUDE_DIRS``. + +``Python3_NumPy_INCLUDE_DIR`` + The path to the directory of the ``NumPy`` headers. It will be used to + compute the variable ``Python3_NumPy_INCLUDE_DIRS``. + +.. note:: + + All paths must be absolute. Any artifact specified with a relative path + will be ignored. + +.. note:: + + When an artifact is specified, all ``HINTS`` will be ignored and no search + will be performed for this artifact. + + If more than one artifact is specified, it is the user's responsability to + ensure the consistency of the various artifacts. + Commands ^^^^^^^^ diff --git a/Tests/FindPython/CMakeLists.txt b/Tests/FindPython/CMakeLists.txt index 4be2f22..868cfe0 100644 --- a/Tests/FindPython/CMakeLists.txt +++ b/Tests/FindPython/CMakeLists.txt @@ -121,6 +121,19 @@ if(CMake_TEST_FindPython) --test-command ${CMAKE_CTEST_COMMAND} -V -C $ ) + add_test(NAME FindPython.RequiredArtifacts COMMAND + ${CMAKE_CTEST_COMMAND} -C $ + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts" + "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts" + ${build_generator_args} + --build-project TestRequiredArtifacts + --build-options ${build_options} "-Dbuild_generator_args=${build_generator_args}" + "-DCMake_SOURCE_DIR=${CMake_SOURCE_DIR}" + "-DCMake_BINARY_DIR=${CMake_BINARY_DIR}" + --test-command ${CMAKE_CTEST_COMMAND} -V -C $ + ) + endif() if(CMake_TEST_FindPython_NumPy) diff --git a/Tests/FindPython/RequiredArtifacts/CMakeLists.txt b/Tests/FindPython/RequiredArtifacts/CMakeLists.txt new file mode 100644 index 0000000..39e8ea5 --- /dev/null +++ b/Tests/FindPython/RequiredArtifacts/CMakeLists.txt @@ -0,0 +1,110 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestRequiredArtifacts LANGUAGES C) + +include(CTest) + +find_package(Python2 REQUIRED COMPONENTS Interpreter Development) +if (NOT Python2_FOUND) + message (FATAL_ERROR "Fail to found Python 2") +endif() +find_package(Python3 REQUIRED COMPONENTS Interpreter Development) +if (NOT Python3_FOUND) + message (FATAL_ERROR "Fail to found Python 3") +endif() + + +add_test(NAME FindPython.RequiredArtifacts.Interpreter.VALID COMMAND + ${CMAKE_CTEST_COMMAND} -C $ + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check" + "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Interpreter.VALID" + ${build_generator_args} + --build-project TestRequiredArtifacts.Check + --build-options -DPYTHON_IS_FOUND=TRUE -DCHECK_INTERPRETER=ON + "-DPython3_EXECUTABLE=${Python3_EXECUTABLE}" + --test-command ${CMAKE_CTEST_COMMAND} -V -C $ + ) +add_test(NAME FindPython.RequiredArtifacts.Interpreter.INVALID COMMAND + ${CMAKE_CTEST_COMMAND} -C $ + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check" + "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Interpreter.INVALID" + ${build_generator_args} + --build-project TestRequiredArtifacts.Check + --build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_INTERPRETER=ON + "-DPython3_EXECUTABLE=${Python3_EXECUTABLE}-bad${CMAKE_EXECUTABLE_SUFFIX}" + --test-command ${CMAKE_CTEST_COMMAND} -V -C $ + ) + +add_test(NAME FindPython.RequiredArtifacts.Library.VALID COMMAND + ${CMAKE_CTEST_COMMAND} -C $ + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check" + "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Library.VALID" + ${build_generator_args} + --build-project TestRequiredArtifacts.Check + --build-options -DPYTHON_IS_FOUND=TRUE -DCHECK_LIBRARY=ON + "-DPython3_LIBRARY=${Python3_LIBRARY_RELEASE}" + --test-command ${CMAKE_CTEST_COMMAND} -V -C $ + ) +add_test(NAME FindPython.RequiredArtifacts.Library.INVALID COMMAND + ${CMAKE_CTEST_COMMAND} -C $ + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check" + "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Library.INVALID" + ${build_generator_args} + --build-project TestRequiredArtifacts.Check + --build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_LIBRARY=ON + "-DPython3_LIBRARY=${Python2_LIBRARY_RELEASE}" + --test-command ${CMAKE_CTEST_COMMAND} -V -C $ + ) + +add_test(NAME FindPython.RequiredArtifacts.Include.VALID COMMAND + ${CMAKE_CTEST_COMMAND} -C $ + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check" + "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Include.VALID" + ${build_generator_args} + --build-project TestRequiredArtifacts.Check + --build-options -DPYTHON_IS_FOUND=TRUE -DCHECK_INCLUDE=ON + "-DPython3_INCLUDE_DIR=${Python3_INCLUDE_DIRS}" + --test-command ${CMAKE_CTEST_COMMAND} -V -C $ + ) +add_test(NAME FindPython.RequiredArtifacts.Include.INVALID COMMAND + ${CMAKE_CTEST_COMMAND} -C $ + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check" + "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Include.INVALID" + ${build_generator_args} + --build-project TestRequiredArtifacts.Check + --build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_INCLUDE=ON + "-DPython3_INCLUDE_DIR=${Python2_INCLUDE_DIRS}" + --test-command ${CMAKE_CTEST_COMMAND} -V -C $ + ) + +add_test(NAME FindPython.RequiredArtifacts.Interpreter-Library.INVALID COMMAND + ${CMAKE_CTEST_COMMAND} -C $ + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check" + "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Interpreter-Library.INVALID" + ${build_generator_args} + --build-project TestRequiredArtifacts.Check + --build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_INTERPRETER=ON -DCHECK_LIBRARY=ON + "-DPython3_EXECUTABLE=${Python3_EXECUTABLE}" + "-DPython3_LIBRARY=${Python2_LIBRARY_RELEASE}" + --test-command ${CMAKE_CTEST_COMMAND} -V -C $ + ) + +add_test(NAME FindPython.RequiredArtifacts.Library-Include.INVALID COMMAND + ${CMAKE_CTEST_COMMAND} -C $ + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check" + "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Library-Include.INVALID" + ${build_generator_args} + --build-project TestRequiredArtifacts.Check + --build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_LIBRARY=ON -DCHECK_INCLUDE=ON + "-DPython3_LIBRARY=${Python3_LIBRARY_RELEASE}" + "-DPython3_INCLUDE_DIR=${Python2_INCLUDE_DIRS}" + --test-command ${CMAKE_CTEST_COMMAND} -V -C $ + ) diff --git a/Tests/FindPython/RequiredArtifacts/Check/CMakeLists.txt b/Tests/FindPython/RequiredArtifacts/Check/CMakeLists.txt new file mode 100644 index 0000000..b859ac5 --- /dev/null +++ b/Tests/FindPython/RequiredArtifacts/Check/CMakeLists.txt @@ -0,0 +1,41 @@ +cmake_minimum_required(VERSION 3.1) + +project(TestRequiredArtifacts.Check LANGUAGES C) + +set (components) +if (CHECK_INTERPRETER) + set (required_interpreter "${Python3_EXECUTABLE}") + list (APPEND components Interpreter) +endif() +if (CHECK_LIBRARY OR CHECK_INCLUDE) + list (APPEND components Development) + if (CHECK_LIBRARY) + set (required_library "${Python3_LIBRARY}") + endif() + if (CHECK_INCLUDE) + set (required_include "${Python3_INCLUDE_DIR}") + endif() +endif() + +find_package (Python3 COMPONENTS ${components}) + + +if (PYTHON_IS_FOUND AND NOT Python3_FOUND) + message (FATAL_ERROR "Python3 unexpectedly not found") +endif() +if (NOT PYTHON_IS_FOUND AND Python3_FOUND) + message (FATAL_ERROR "Python3 unexpectedly found") +endif() + + +if (CHECK_INTERPRETER AND NOT Python3_EXECUTABLE STREQUAL required_interpreter) + message (FATAL_ERROR "Fail to use input variable Python3_EXECUTABLE") +endif() + +if (CHECK_LIBRARY AND NOT Python3_LIBRARY_RELEASE STREQUAL required_library) + message (FATAL_ERROR "Fail to use input variable Python3_LIBRARY") +endif() + +if (CHECK_INCLUDE AND NOT Python3_INCLUDE_DIRS STREQUAL required_include) + message (FATAL_ERROR "Fail to use input variable Python3_INCLUDE_DIR") +endif() https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cea2010b5c72f333d124f69ded95cc0379e4184d commit cea2010b5c72f333d124f69ded95cc0379e4184d Author: Marc Chevrier AuthorDate: Mon Aug 12 16:26:44 2019 +0200 Commit: Marc Chevrier CommitDate: Mon Sep 2 13:19:01 2019 +0200 FindPython: Enhance python cache variables management. Ensure multiple cmake runs without cache clean-up will preserve artifacts selected on first run. This change address the issue #19492. diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index 90a8264..efaf9ea 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -261,8 +261,8 @@ function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME) else() if (NAME STREQUAL "INCLUDES") # do some clean-up - string (REGEX MATCHALL "-I[^ ]+" _values "${_values}") - string (REPLACE "-I" "" _values "${_values}") + string (REGEX MATCHALL "(-I|-iwithsysroot)[ ]*[^ ]+" _values "${_values}") + string (REGEX REPLACE "(-I|-iwithsysroot)[ ]*" "" _values "${_values}") list (REMOVE_DUPLICATES _values) endif() endif() @@ -305,13 +305,18 @@ function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME) endif() endif() + if (config_flag STREQUAL "ABIFLAGS") + set (${_PYTHON_PGCV_VALUE} "${_values}" PARENT_SCOPE) + return() + endif() + if (NOT _values OR _values STREQUAL "None") return() endif() if (NAME STREQUAL "LIBS") # do some clean-up - string (REGEX MATCHALL "-[l][^ ]+" _values "${_values}") + string (REGEX MATCHALL "-(l|framework)[ ]*[^ ]+" _values "${_values}") # remove elements relative to python library itself list (FILTER _values EXCLUDE REGEX "-lpython") list (REMOVE_DUPLICATES _values) @@ -320,6 +325,75 @@ function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME) set (${_PYTHON_PGCV_VALUE} "${_values}" PARENT_SCOPE) endfunction() +function (_PYTHON_GET_VERSION) + cmake_parse_arguments (PARSE_ARGV 0 _PGV "LIBRARY;INCLUDE" "PREFIX" "") + + unset (${_PGV_PREFIX}VERSION PARENT_SCOPE) + unset (${_PGV_PREFIX}VERSION_MAJOR PARENT_SCOPE) + unset (${_PGV_PREFIX}VERSION_MINOR PARENT_SCOPE) + unset (${_PGV_PREFIX}VERSION_PATCH PARENT_SCOPE) + unset (${_PGV_PREFIX}ABI PARENT_SCOPE) + + if (_PGV_LIBRARY) + # retrieve version and abi from library name + if (${_PYTHON_PREFIX}_LIBRARY_RELEASE) + # extract version from library name + if (${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "python([23])([0-9]+)") + set (${_PGV_PREFIX}VERSION_MAJOR "${CMAKE_MATCH_1}" PARENT_SCOPE) + set (${_PGV_PREFIX}VERSION_MINOR "${CMAKE_MATCH_2}" PARENT_SCOPE) + set (${_PGV_PREFIX}VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}" PARENT_SCOPE) + set (${_PGV_PREFIX}ABI "" PARENT_SCOPE) + elseif (${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "python([23])\\.([0-9]+)([dmu]*)") + set (${_PGV_PREFIX}VERSION_MAJOR "${CMAKE_MATCH_1}" PARENT_SCOPE) + set (${_PGV_PREFIX}VERSION_MINOR "${CMAKE_MATCH_2}" PARENT_SCOPE) + set (${_PGV_PREFIX}VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}" PARENT_SCOPE) + set (${_PGV_PREFIX}ABI "${CMAKE_MATCH_3}" PARENT_SCOPE) + endif() + endif() + else() + if (${_PYTHON_PREFIX}_INCLUDE_DIR) + # retrieve version from header file + file (STRINGS "${${_PYTHON_PREFIX}_INCLUDE_DIR}/patchlevel.h" version + REGEX "^#define[ \t]+PY_VERSION[ \t]+\"[^\"]+\"") + string (REGEX REPLACE "^#define[ \t]+PY_VERSION[ \t]+\"([^\"]+)\".*" "\\1" + version "${version}") + string (REGEX MATCHALL "[0-9]+" versions "${version}") + list (GET versions 0 version_major) + list (GET versions 1 version_minor) + list (GET versions 2 version_patch) + + set (${_PGV_PREFIX}VERSION "${version_major}.${version_minor}" PARENT_SCOPE) + set (${_PGV_PREFIX}VERSION_MAJOR ${version_major} PARENT_SCOPE) + set (${_PGV_PREFIX}VERSION_MINOR ${version_minor} PARENT_SCOPE) + set (${_PGV_PREFIX}VERSION_PATCH ${version_patch} PARENT_SCOPE) + + # compute ABI flags + if (version_major VERSION_GREATER 2) + file (STRINGS "${${_PYTHON_PREFIX}_INCLUDE_DIR}/pyconfig.h" config REGEX "(Py_DEBUG|WITH_PYMALLOC|Py_UNICODE_SIZE|MS_WIN32)") + set (abi) + if (config MATCHES "#[ ]*define[ ]+MS_WIN32") + # ABI not used on Windows + set (abi "") + else() + if (config MATCHES "#[ ]*define[ ]+Py_DEBUG[ ]+1") + string (APPEND abi "d") + endif() + if (config MATCHES "#[ ]*define[ ]+WITH_PYMALLOC[ ]+1") + string (APPEND abi "m") + endif() + if (config MATCHES "#[ ]*define[ ]+Py_UNICODE_SIZE[ ]+4") + string (APPEND abi "u") + endif() + set (${_PGV_PREFIX}ABI "${abi}" PARENT_SCOPE) + endif() + else() + # ABI not supported + set (${_PGV_PREFIX}ABI "" PARENT_SCOPE) + endif() + endif() + endif() +endfunction() + function (_PYTHON_VALIDATE_INTERPRETER) if (NOT ${_PYTHON_PREFIX}_EXECUTABLE) @@ -445,6 +519,79 @@ function (_PYTHON_VALIDATE_COMPILER expected_version) endfunction() +function (_PYTHON_VALIDATE_LIBRARY) + if (NOT ${_PYTHON_PREFIX}_LIBRARY_RELEASE) + return() + endif() + + cmake_parse_arguments (PARSE_ARGV 0 _PVL "EXACT" "" "") + if (_PVL_UNPARSED_ARGUMENTS) + set (expected_version ${_PVL_UNPARSED_ARGUMENTS}) + else() + unset (expected_version) + endif() + + # retrieve version and abi from library name + _python_get_version (LIBRARY PREFIX lib_) + + if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND NOT lib_ABI IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS) + # incompatible ABI + set_property (CACHE ${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND") + else() + if (expected_version) + if ((_PVL_EXACT AND NOT lib_VERSION VERSION_EQUAL expected_version) OR (lib_VERSION VERSION_LESS expected_version)) + # library has wrong version + set_property (CACHE ${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND") + endif() + else() + if (NOT lib_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR) + # library has wrong major version + set_property (CACHE ${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND") + endif() + endif() + endif() + + if (NOT ${_PYTHON_PREFIX}_LIBRARY_RELEASE) + set_property (CACHE ${_PYTHON_PREFIX}_LIBRARY_DEBUG PROPERTY VALUE "${_PYTHON_PREFIX}_LIBRARY_DEBUG-NOTFOUND") + set_property (CACHE ${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") + endif() +endfunction() + + +function (_PYTHON_VALIDATE_INCLUDE_DIR) + if (NOT ${_PYTHON_PREFIX}_INCLUDE_DIR) + return() + endif() + + cmake_parse_arguments (PARSE_ARGV 0 _PVID "EXACT" "" "") + if (_PVID_UNPARSED_ARGUMENTS) + set (expected_version ${_PVID_UNPARSED_ARGUMENTS}) + else() + unset (expected_version) + endif() + + # retrieve version from header file + _python_get_version (INCLUDE PREFIX inc_) + + if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND NOT inc_ABI IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS) + # incompatible ABI + set_property (CACHE ${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") + else() + if (expected_version) + if ((_PVID_EXACT AND NOT inc_VERSION VERSION_EQUAL expected_version) OR (inc_VERSION VERSION_LESS expected_version)) + # include dir has wrong version + set_property (CACHE ${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") + endif() + else() + if (NOT inc_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR) + # include dir has wrong major version + set_property (CACHE ${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND") + endif() + endif() + endif() +endfunction() + + function (_PYTHON_FIND_RUNTIME_LIBRARY _PYTHON_LIB) string (REPLACE "_RUNTIME" "" _PYTHON_LIB "${_PYTHON_LIB}") # look at runtime part on systems supporting it @@ -494,7 +641,7 @@ if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) list (APPEND ${_PYTHON_PREFIX}_FIND_COMPONENTS "Interpreter" "Development") list (REMOVE_DUPLICATES ${_PYTHON_PREFIX}_FIND_COMPONENTS) endif() -foreach (_${_PYTHON_PREFIX}_COMPONENT IN LISTS ${_PYTHON_PREFIX}_FIND_COMPONENTS) +foreach (_${_PYTHON_PREFIX}_COMPONENT IN ITEMS Interpreter Compiler Development NumPy) set (${_PYTHON_PREFIX}_${_${_PYTHON_PREFIX}_COMPONENT}_FOUND FALSE) endforeach() unset (_${_PYTHON_PREFIX}_FIND_VERSIONS) @@ -644,6 +791,20 @@ else() endif() +# Compute search signature +# This signature will be used to check validity of cached variables on new search +set (_${_PYTHON_PREFIX}_SIGNATURE "${${_PYTHON_PREFIX}_ROOT_DIR}:${${_PYTHON_PREFIX}_FIND_STRATEGY}:${${_PYTHON_PREFIX}_FIND_VIRTUALENV}") +if (NOT WIN32) + string (APPEND _${_PYTHON_PREFIX}_SIGNATURE ":${${_PYTHON_PREFIX}_USE_STATIC_LIBS}:") +endif() +if (CMAKE_HOST_APPLE) + string (APPEND _${_PYTHON_PREFIX}_SIGNATURE ":${${_PYTHON_PREFIX}_FIND_FRAMEWORK}") +endif() +if (CMAKE_HOST_WIN32) + string (APPEND _${_PYTHON_PREFIX}_SIGNATURE ":${${_PYTHON_PREFIX}_FIND_REGISTRY}") +endif() + + unset (_${_PYTHON_PREFIX}_REQUIRED_VARS) unset (_${_PYTHON_PREFIX}_CACHED_VARS) @@ -655,279 +816,296 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_EXECUTABLE) endif() - set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) + if (DEFINED ${_PYTHON_PREFIX}_EXECUTABLE) + # compute interpreter signature and check validity of definition + string (MD5 __${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${${_PYTHON_PREFIX}_EXECUTABLE}") + if (__${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE STREQUAL _${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE) + # check version validity + if (${_PYTHON_PREFIX}_FIND_VERSION_EXACT) + _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION} EXACT) + else() + _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION}) + endif() + else() + unset (${_PYTHON_PREFIX}_EXECUTABLE CACHE) + unset (_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE CACHE) + endif() + endif() - if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION") - unset (_${_PYTHON_PREFIX}_NAMES) - unset (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS) - unset (_${_PYTHON_PREFIX}_REGISTRY_PATHS) + if (NOT ${_PYTHON_PREFIX}_EXECUTABLE) + set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) - foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) - # build all executable names - _python_get_names (_${_PYTHON_PREFIX}_VERSION_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} POSIX EXECUTABLE) - list (APPEND _${_PYTHON_PREFIX}_NAMES ${_${_PYTHON_PREFIX}_VERSION_NAMES}) + if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION") + unset (_${_PYTHON_PREFIX}_NAMES) + unset (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS) + unset (_${_PYTHON_PREFIX}_REGISTRY_PATHS) - # Framework Paths - _python_get_frameworks (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_VERSION}) - list (APPEND _${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS}) + foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) + # build all executable names + _python_get_names (_${_PYTHON_PREFIX}_VERSION_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} POSIX EXECUTABLE) + list (APPEND _${_PYTHON_PREFIX}_NAMES ${_${_PYTHON_PREFIX}_VERSION_NAMES}) - # Registry Paths - _python_get_registries (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_VERSION}) - list (APPEND _${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS} - [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]) - endforeach() - list (APPEND _${_PYTHON_PREFIX}_NAMES python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} python) + # Framework Paths + _python_get_frameworks (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_VERSION}) + list (APPEND _${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS}) - while (TRUE) - # Virtual environments handling - if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$") - find_program (${_PYTHON_PREFIX}_EXECUTABLE - NAMES ${_${_PYTHON_PREFIX}_NAMES} - NAMES_PER_DIR - HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ENV VIRTUAL_ENV - PATH_SUFFIXES bin Scripts - NO_CMAKE_PATH - NO_CMAKE_ENVIRONMENT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) + # Registry Paths + _python_get_registries (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_VERSION}) + list (APPEND _${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS} + [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]) + endforeach() + list (APPEND _${_PYTHON_PREFIX}_NAMES python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} python) - _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION}) - if (${_PYTHON_PREFIX}_EXECUTABLE) - break() + while (TRUE) + # Virtual environments handling + if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$") + find_program (${_PYTHON_PREFIX}_EXECUTABLE + NAMES ${_${_PYTHON_PREFIX}_NAMES} + NAMES_PER_DIR + HINTS ${_${_PYTHON_PREFIX}_HINTS} + PATHS ENV VIRTUAL_ENV + PATH_SUFFIXES bin Scripts + NO_CMAKE_PATH + NO_CMAKE_ENVIRONMENT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + + _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION}) + if (${_PYTHON_PREFIX}_EXECUTABLE) + break() + endif() + if (NOT _${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "ONLY") + break() + endif() endif() - if (NOT _${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "ONLY") - break() + + # Apple frameworks handling + if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST") + find_program (${_PYTHON_PREFIX}_EXECUTABLE + NAMES ${_${_PYTHON_PREFIX}_NAMES} + NAMES_PER_DIR + HINTS ${_${_PYTHON_PREFIX}_HINTS} + PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} + PATH_SUFFIXES bin + NO_CMAKE_PATH + NO_CMAKE_ENVIRONMENT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION}) + if (${_PYTHON_PREFIX}_EXECUTABLE) + break() + endif() + endif() + # Windows registry + if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") + find_program (${_PYTHON_PREFIX}_EXECUTABLE + NAMES ${_${_PYTHON_PREFIX}_NAMES} + ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} + NAMES_PER_DIR + HINTS ${_${_PYTHON_PREFIX}_HINTS} + PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} + PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION}) + if (${_PYTHON_PREFIX}_EXECUTABLE) + break() + endif() endif() - endif() - # Apple frameworks handling - if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST") + # try using HINTS find_program (${_PYTHON_PREFIX}_EXECUTABLE NAMES ${_${_PYTHON_PREFIX}_NAMES} + ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} - PATH_SUFFIXES bin - NO_CMAKE_PATH - NO_CMAKE_ENVIRONMENT_PATH + PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION}) if (${_PYTHON_PREFIX}_EXECUTABLE) break() endif() - endif() - # Windows registry - if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") + # try using standard paths find_program (${_PYTHON_PREFIX}_EXECUTABLE NAMES ${_${_PYTHON_PREFIX}_NAMES} ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} NAMES_PER_DIR - HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} - PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) + PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}) _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION}) if (${_PYTHON_PREFIX}_EXECUTABLE) break() endif() - endif() - # try using HINTS - find_program (${_PYTHON_PREFIX}_EXECUTABLE - NAMES ${_${_PYTHON_PREFIX}_NAMES} - ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} - NAMES_PER_DIR - HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION}) - if (${_PYTHON_PREFIX}_EXECUTABLE) - break() - endif() - # try using standard paths - find_program (${_PYTHON_PREFIX}_EXECUTABLE - NAMES ${_${_PYTHON_PREFIX}_NAMES} - ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} - NAMES_PER_DIR - PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}) - _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION}) - if (${_PYTHON_PREFIX}_EXECUTABLE) + # Apple frameworks handling + if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST") + find_program (${_PYTHON_PREFIX}_EXECUTABLE + NAMES ${_${_PYTHON_PREFIX}_NAMES} + NAMES_PER_DIR + PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} + PATH_SUFFIXES bin + NO_DEFAULT_PATH) + _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION}) + if (${_PYTHON_PREFIX}_EXECUTABLE) + break() + endif() + endif() + # Windows registry + if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST") + find_program (${_PYTHON_PREFIX}_EXECUTABLE + NAMES ${_${_PYTHON_PREFIX}_NAMES} + ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} + NAMES_PER_DIR + PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} + PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} + NO_DEFAULT_PATH) + _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION}) + if (${_PYTHON_PREFIX}_EXECUTABLE) + break() + endif() + endif() + break() - endif() + endwhile() + else() + # look-up for various versions and locations + foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) + _python_get_names (_${_PYTHON_PREFIX}_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} POSIX EXECUTABLE) + list (APPEND _${_PYTHON_PREFIX}_NAMES python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} + python) - # Apple frameworks handling - if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST") - find_program (${_PYTHON_PREFIX}_EXECUTABLE - NAMES ${_${_PYTHON_PREFIX}_NAMES} - NAMES_PER_DIR - PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} - PATH_SUFFIXES bin - NO_DEFAULT_PATH) - _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION}) - if (${_PYTHON_PREFIX}_EXECUTABLE) - break() + _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION}) + _python_get_registries (_${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_VERSION}) + + # Virtual environments handling + if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$") + find_program (${_PYTHON_PREFIX}_EXECUTABLE + NAMES ${_${_PYTHON_PREFIX}_NAMES} + NAMES_PER_DIR + HINTS ${_${_PYTHON_PREFIX}_HINTS} + PATHS ENV VIRTUAL_ENV + PATH_SUFFIXES bin Scripts + NO_CMAKE_PATH + NO_CMAKE_ENVIRONMENT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT) + if (${_PYTHON_PREFIX}_EXECUTABLE) + break() + endif() + if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "ONLY") + continue() + endif() endif() - endif() - # Windows registry - if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST") - find_program (${_PYTHON_PREFIX}_EXECUTABLE - NAMES ${_${_PYTHON_PREFIX}_NAMES} - ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} - NAMES_PER_DIR - PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} - PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} - NO_DEFAULT_PATH) - _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION}) - if (${_PYTHON_PREFIX}_EXECUTABLE) - break() + + # Apple frameworks handling + if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST") + find_program (${_PYTHON_PREFIX}_EXECUTABLE + NAMES ${_${_PYTHON_PREFIX}_NAMES} + NAMES_PER_DIR + HINTS ${_${_PYTHON_PREFIX}_HINTS} + PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} + PATH_SUFFIXES bin + NO_CMAKE_PATH + NO_CMAKE_ENVIRONMENT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) endif() - endif() - break() - endwhile() - else() - # look-up for various versions and locations - foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) - _python_get_names (_${_PYTHON_PREFIX}_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} POSIX EXECUTABLE) - list (APPEND _${_PYTHON_PREFIX}_NAMES python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} - python) + # Windows registry + if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") + find_program (${_PYTHON_PREFIX}_EXECUTABLE + NAMES ${_${_PYTHON_PREFIX}_NAMES} + ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} + NAMES_PER_DIR + HINTS ${_${_PYTHON_PREFIX}_HINTS} + PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} + [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] + PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + endif() - _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION}) - _python_get_registries (_${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_VERSION}) + _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT) + if (${_PYTHON_PREFIX}_EXECUTABLE) + break() + endif() - # Virtual environments handling - if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$") + # try using HINTS find_program (${_PYTHON_PREFIX}_EXECUTABLE NAMES ${_${_PYTHON_PREFIX}_NAMES} + ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ENV VIRTUAL_ENV - PATH_SUFFIXES bin Scripts - NO_CMAKE_PATH - NO_CMAKE_ENVIRONMENT_PATH + PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) - _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT) if (${_PYTHON_PREFIX}_EXECUTABLE) break() endif() - if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "ONLY") - continue() + # try using standard paths. + # NAMES_PER_DIR is not defined on purpose to have a chance to find + # expected version. + # For example, typical systems have 'python' for version 2.* and 'python3' + # for version 3.*. So looking for names per dir will find, potentially, + # systematically 'python' (i.e. version 2) even if version 3 is searched. + if (CMAKE_HOST_WIN32) + find_program (${_PYTHON_PREFIX}_EXECUTABLE + NAMES ${_${_PYTHON_PREFIX}_NAMES} + python + ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}) + else() + find_program (${_PYTHON_PREFIX}_EXECUTABLE + NAMES ${_${_PYTHON_PREFIX}_NAMES}) + endif() + _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT) + if (${_PYTHON_PREFIX}_EXECUTABLE) + break() endif() - endif() - # Apple frameworks handling - if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST") - find_program (${_PYTHON_PREFIX}_EXECUTABLE - NAMES ${_${_PYTHON_PREFIX}_NAMES} - NAMES_PER_DIR - HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} - PATH_SUFFIXES bin - NO_CMAKE_PATH - NO_CMAKE_ENVIRONMENT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - endif() + # Apple frameworks handling + if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST") + find_program (${_PYTHON_PREFIX}_EXECUTABLE + NAMES ${_${_PYTHON_PREFIX}_NAMES} + NAMES_PER_DIR + PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} + PATH_SUFFIXES bin + NO_DEFAULT_PATH) + endif() - # Windows registry - if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") - find_program (${_PYTHON_PREFIX}_EXECUTABLE - NAMES ${_${_PYTHON_PREFIX}_NAMES} - ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} - NAMES_PER_DIR - HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} - [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] - PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - endif() - _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT) - if (${_PYTHON_PREFIX}_EXECUTABLE) - break() - endif() + # Windows registry + if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST") + find_program (${_PYTHON_PREFIX}_EXECUTABLE + NAMES ${_${_PYTHON_PREFIX}_NAMES} + ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} + NAMES_PER_DIR + PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} + [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] + PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} + NO_DEFAULT_PATH) + endif() - # try using HINTS - find_program (${_PYTHON_PREFIX}_EXECUTABLE - NAMES ${_${_PYTHON_PREFIX}_NAMES} - ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} - NAMES_PER_DIR - HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT) - if (${_PYTHON_PREFIX}_EXECUTABLE) - break() - endif() - # try using standard paths. - # NAMES_PER_DIR is not defined on purpose to have a chance to find - # expected version. - # For example, typical systems have 'python' for version 2.* and 'python3' - # for version 3.*. So looking for names per dir will find, potentially, - # systematically 'python' (i.e. version 2) even if version 3 is searched. - if (CMAKE_HOST_WIN32) + _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT) + if (${_PYTHON_PREFIX}_EXECUTABLE) + break() + endif() + endforeach() + + if (NOT ${_PYTHON_PREFIX}_EXECUTABLE AND + NOT _${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "ONLY") + # No specific version found. Retry with generic names and standard paths. + # NAMES_PER_DIR is not defined on purpose to have a chance to find + # expected version. + # For example, typical systems have 'python' for version 2.* and 'python3' + # for version 3.*. So looking for names per dir will find, potentially, + # systematically 'python' (i.e. version 2) even if version 3 is searched. find_program (${_PYTHON_PREFIX}_EXECUTABLE - NAMES ${_${_PYTHON_PREFIX}_NAMES} + NAMES python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} python ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}) - else() - find_program (${_PYTHON_PREFIX}_EXECUTABLE - NAMES ${_${_PYTHON_PREFIX}_NAMES}) - endif() - _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT) - if (${_PYTHON_PREFIX}_EXECUTABLE) - break() + _python_validate_interpreter () endif() - - # Apple frameworks handling - if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST") - find_program (${_PYTHON_PREFIX}_EXECUTABLE - NAMES ${_${_PYTHON_PREFIX}_NAMES} - NAMES_PER_DIR - PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} - PATH_SUFFIXES bin - NO_DEFAULT_PATH) - endif() - - # Windows registry - if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST") - find_program (${_PYTHON_PREFIX}_EXECUTABLE - NAMES ${_${_PYTHON_PREFIX}_NAMES} - ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES} - NAMES_PER_DIR - PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} - [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] - PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} - NO_DEFAULT_PATH) - endif() - - _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT) - if (${_PYTHON_PREFIX}_EXECUTABLE) - break() - endif() - endforeach() - - if (NOT ${_PYTHON_PREFIX}_EXECUTABLE AND - NOT _${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "ONLY") - # No specific version found. Retry with generic names and standard paths. - # NAMES_PER_DIR is not defined on purpose to have a chance to find - # expected version. - # For example, typical systems have 'python' for version 2.* and 'python3' - # for version 3.*. So looking for names per dir will find, potentially, - # systematically 'python' (i.e. version 2) even if version 3 is searched. - find_program (${_PYTHON_PREFIX}_EXECUTABLE - NAMES python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} - python - ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}) - - _python_validate_interpreter () endif() endif() @@ -968,6 +1146,10 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) endif() if (${_PYTHON_PREFIX}_Interpreter_FOUND) + # compute and save interpreter signature + string (MD5 __${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${${_PYTHON_PREFIX}_EXECUTABLE}") + set (_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE "${__${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE}" CACHE INTERNAL "") + if (NOT CMAKE_SIZEOF_VOID_P) # determine interpreter architecture execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; print(sys.maxsize > 2**32)" @@ -1011,29 +1193,31 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) else() set (${_PYTHON_PREFIX}_INTERPRETER_ID Python) endif() - else() - unset (${_PYTHON_PREFIX}_INTERPRETER_ID) - endif() - # retrieve various package installation directories - execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig;sys.stdout.write(';'.join([sysconfig.get_python_lib(plat_specific=False,standard_lib=True),sysconfig.get_python_lib(plat_specific=True,standard_lib=True),sysconfig.get_python_lib(plat_specific=False,standard_lib=False),sysconfig.get_python_lib(plat_specific=True,standard_lib=False)]))" + # retrieve various package installation directories + execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig;sys.stdout.write(';'.join([sysconfig.get_python_lib(plat_specific=False,standard_lib=True),sysconfig.get_python_lib(plat_specific=True,standard_lib=True),sysconfig.get_python_lib(plat_specific=False,standard_lib=False),sysconfig.get_python_lib(plat_specific=True,standard_lib=False)]))" - RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT - OUTPUT_VARIABLE _${_PYTHON_PREFIX}_LIBPATHS - ERROR_QUIET) - if (NOT _${_PYTHON_PREFIX}_RESULT) - list (GET _${_PYTHON_PREFIX}_LIBPATHS 0 ${_PYTHON_PREFIX}_STDLIB) - list (GET _${_PYTHON_PREFIX}_LIBPATHS 1 ${_PYTHON_PREFIX}_STDARCH) - list (GET _${_PYTHON_PREFIX}_LIBPATHS 2 ${_PYTHON_PREFIX}_SITELIB) - list (GET _${_PYTHON_PREFIX}_LIBPATHS 3 ${_PYTHON_PREFIX}_SITEARCH) + RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT + OUTPUT_VARIABLE _${_PYTHON_PREFIX}_LIBPATHS + ERROR_QUIET) + if (NOT _${_PYTHON_PREFIX}_RESULT) + list (GET _${_PYTHON_PREFIX}_LIBPATHS 0 ${_PYTHON_PREFIX}_STDLIB) + list (GET _${_PYTHON_PREFIX}_LIBPATHS 1 ${_PYTHON_PREFIX}_STDARCH) + list (GET _${_PYTHON_PREFIX}_LIBPATHS 2 ${_PYTHON_PREFIX}_SITELIB) + list (GET _${_PYTHON_PREFIX}_LIBPATHS 3 ${_PYTHON_PREFIX}_SITEARCH) + else() + unset (${_PYTHON_PREFIX}_STDLIB) + unset (${_PYTHON_PREFIX}_STDARCH) + unset (${_PYTHON_PREFIX}_SITELIB) + unset (${_PYTHON_PREFIX}_SITEARCH) + endif() else() - unset (${_PYTHON_PREFIX}_STDLIB) - unset (${_PYTHON_PREFIX}_STDARCH) - unset (${_PYTHON_PREFIX}_SITELIB) - unset (${_PYTHON_PREFIX}_SITEARCH) + unset (_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE CACHE) + unset (${_PYTHON_PREFIX}_INTERPRETER_ID) endif() - mark_as_advanced (${_PYTHON_PREFIX}_EXECUTABLE) + mark_as_advanced (${_PYTHON_PREFIX}_EXECUTABLE + _${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE) endif() @@ -1044,28 +1228,57 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_COMPILER) endif() - # IronPython specific artifacts - # If IronPython interpreter is found, use its path - unset (_${_PYTHON_PREFIX}_IRON_ROOT) - if (${_PYTHON_PREFIX}_Interpreter_FOUND AND ${_PYTHON_PREFIX}_INTERPRETER_ID STREQUAL "IronPython") - get_filename_component (_${_PYTHON_PREFIX}_IRON_ROOT "${${_PYTHON_PREFIX}_EXECUTABLE}" DIRECTORY) + if (DEFINED ${_PYTHON_PREFIX}_COMPILER) + # compute compiler signature and check validity of definition + string (MD5 __${_PYTHON_PREFIX}_COMPILER_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${${_PYTHON_PREFIX}_COMPILER}") + if (__${_PYTHON_PREFIX}_COMPILER_SIGNATURE STREQUAL _${_PYTHON_PREFIX}_COMPILER_SIGNATURE) + # check version validity + if (${_PYTHON_PREFIX}_FIND_VERSION_EXACT) + _python_validate_compiler (${${_PYTHON_PREFIX}_FIND_VERSION} EXACT) + else() + _python_validate_compiler (${${_PYTHON_PREFIX}_FIND_VERSION}) + endif() + else() + unset (${_PYTHON_PREFIX}_COMPILER CACHE) + unset (_${_PYTHON_PREFIX}_COMPILER_SIGNATURE CACHE) + endif() endif() - if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION") - set (_${_PYTHON_PREFIX}_REGISTRY_PATHS) + if (NOT ${_PYTHON_PREFIX}_COMPILER) + # IronPython specific artifacts + # If IronPython interpreter is found, use its path + unset (_${_PYTHON_PREFIX}_IRON_ROOT) + if (${_PYTHON_PREFIX}_Interpreter_FOUND AND ${_PYTHON_PREFIX}_INTERPRETER_ID STREQUAL "IronPython") + get_filename_component (_${_PYTHON_PREFIX}_IRON_ROOT "${${_PYTHON_PREFIX}_EXECUTABLE}" DIRECTORY) + endif() - foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) - # Registry Paths - list (APPEND _${_PYTHON_PREFIX}_REGISTRY_PATHS - [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]) - endforeach() + if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION") + set (_${_PYTHON_PREFIX}_REGISTRY_PATHS) + + foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) + # Registry Paths + list (APPEND _${_PYTHON_PREFIX}_REGISTRY_PATHS + [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]) + endforeach() + + while (TRUE) + if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") + find_program (${_PYTHON_PREFIX}_COMPILER + NAMES ipyc + HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS} + PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} + PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + _python_validate_compiler (${${_PYTHON_PREFIX}_FIND_VERSION}) + if (${_PYTHON_PREFIX}_COMPILER) + break() + endif() + endif() - while (TRUE) - if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") find_program (${_PYTHON_PREFIX}_COMPILER NAMES ipyc HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) @@ -1073,37 +1286,37 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) if (${_PYTHON_PREFIX}_COMPILER) break() endif() - endif() - find_program (${_PYTHON_PREFIX}_COMPILER - NAMES ipyc - HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS} - PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - _python_validate_compiler (${${_PYTHON_PREFIX}_FIND_VERSION}) - if (${_PYTHON_PREFIX}_COMPILER) - break() - endif() + if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST") + find_program (${_PYTHON_PREFIX}_COMPILER + NAMES ipyc + PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} + PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} + NO_DEFAULT_PATH) + endif() - if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST") - find_program (${_PYTHON_PREFIX}_COMPILER - NAMES ipyc - PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} - PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} - NO_DEFAULT_PATH) - endif() + break() + endwhile() + else() + # try using root dir and registry + foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) + if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") + find_program (${_PYTHON_PREFIX}_COMPILER + NAMES ipyc + HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS} + PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] + PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + _python_validate_compiler (${_${_PYTHON_PREFIX}_VERSION} EXACT) + if (${_PYTHON_PREFIX}_COMPILER) + break() + endif() + endif() - break() - endwhile() - else() - # try using root dir and registry - foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) - if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") find_program (${_PYTHON_PREFIX}_COMPILER NAMES ipyc HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS} - PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) @@ -1111,37 +1324,26 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) if (${_PYTHON_PREFIX}_COMPILER) break() endif() - endif() + if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST") + find_program (${_PYTHON_PREFIX}_COMPILER + NAMES ipyc + PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] + PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} + NO_DEFAULT_PATH) + _python_validate_compiler (${_${_PYTHON_PREFIX}_VERSION} EXACT) + if (${_PYTHON_PREFIX}_COMPILER) + break() + endif() + endif() + endforeach() + + # no specific version found, re-try in standard paths find_program (${_PYTHON_PREFIX}_COMPILER NAMES ipyc HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS} - PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - _python_validate_compiler (${_${_PYTHON_PREFIX}_VERSION} EXACT) - if (${_PYTHON_PREFIX}_COMPILER) - break() - endif() - - if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST") - find_program (${_PYTHON_PREFIX}_COMPILER - NAMES ipyc - PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath] - PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES} - NO_DEFAULT_PATH) - _python_validate_compiler (${_${_PYTHON_PREFIX}_VERSION} EXACT) - if (${_PYTHON_PREFIX}_COMPILER) - break() - endif() - endif() - endforeach() - - # no specific version found, re-try in standard paths - find_program (${_PYTHON_PREFIX}_COMPILER - NAMES ipyc - HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS} - PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}) + PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}) + endif() endif() if (${_PYTHON_PREFIX}_COMPILER) @@ -1191,12 +1393,18 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) endif() if (${_PYTHON_PREFIX}_Compiler_FOUND) + # compute and save compiler signature + string (MD5 __${_PYTHON_PREFIX}_COMPILER_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${${_PYTHON_PREFIX}_COMPILER}") + set (_${_PYTHON_PREFIX}_COMPILER_SIGNATURE "${__${_PYTHON_PREFIX}_COMPILER_SIGNATURE}" CACHE INTERNAL "") + set (${_PYTHON_PREFIX}_COMPILER_ID IronPython) else() + unset (_${_PYTHON_PREFIX}_COMPILER_SIGNATURE CACHE) unset (${_PYTHON_PREFIX}_COMPILER_ID) endif() - mark_as_advanced (${_PYTHON_PREFIX}_COMPILER) + mark_as_advanced (${_PYTHON_PREFIX}_COMPILER + _${_PYTHON_PREFIX}_COMPILER_SIGNATURE) endif() @@ -1215,6 +1423,26 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS ${_PYTHON_PREFIX}_INCLUDE_DIR) endif() + if (DEFINED ${_PYTHON_PREFIX}_LIBRARY_RELEASE OR DEFINED ${_PYTHON_PREFIX}_INCLUDE_DIR) + # compute development signature and check validity of definition + string (MD5 __${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${${_PYTHON_PREFIX}_LIBRARY_RELEASE}:${${_PYTHON_PREFIX}_INCLUDE_DIR}") + if (__${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE STREQUAL _${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE) + # check version validity + if (${_PYTHON_PREFIX}_FIND_VERSION_EXACT) + _python_validate_library (${${_PYTHON_PREFIX}_FIND_VERSION} EXACT) + _python_validate_include_dir (${${_PYTHON_PREFIX}_FIND_VERSION} EXACT) + else() + _python_validate_library (${${_PYTHON_PREFIX}_FIND_VERSION}) + _python_validate_include_dir (${${_PYTHON_PREFIX}_FIND_VERSION}) + endif() + else() + unset (${_PYTHON_PREFIX}_LIBRARY_RELEASE CACHE) + unset (${_PYTHON_PREFIX}_LIBRARY_DEBUG CACHE) + unset (${_PYTHON_PREFIX}_INCLUDE_DIR CACHE) + unset (_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE CACHE) + endif() + endif() + # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES unset (_${_PYTHON_PREFIX}_CMAKE_FIND_LIBRARY_SUFFIXES) if (DEFINED ${_PYTHON_PREFIX}_USE_STATIC_LIBS AND NOT WIN32) @@ -1226,116 +1454,33 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() endif() - # if python interpreter is found, use it to ensure consistency - # between interpreter and development environment. - # If not, try to locate a compatible config tool - if (NOT ${_PYTHON_PREFIX}_Interpreter_FOUND OR CMAKE_CROSSCOMPILING) - set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) - unset (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS) - if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$") - set (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS ENV VIRTUAL_ENV) - endif() - unset (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS) - - if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION") - set (_${_PYTHON_PREFIX}_CONFIG_NAMES) - - foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) - _python_get_names (_${_PYTHON_PREFIX}_VERSION_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} POSIX CONFIG) - list (APPEND _${_PYTHON_PREFIX}_CONFIG_NAMES ${_${_PYTHON_PREFIX}_VERSION_NAMES}) - - # Framework Paths - _python_get_frameworks (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_VERSION}) - list (APPEND _${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS}) - endforeach() - - # Apple frameworks handling - if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST") - find_program (${_PYTHON_PREFIX}_CONFIG - NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES} - NAMES_PER_DIR - HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} - ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} - PATH_SUFFIXES bin - NO_CMAKE_PATH - NO_CMAKE_ENVIRONMENT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - endif() - - find_program (_${_PYTHON_PREFIX}_CONFIG - NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES} - NAMES_PER_DIR - HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} - PATH_SUFFIXES bin) - - # Apple frameworks handling - if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST") - find_program (_${_PYTHON_PREFIX}_CONFIG - NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES} - NAMES_PER_DIR - PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} - PATH_SUFFIXES bin - NO_DEFAULT_PATH) - endif() - - if (_${_PYTHON_PREFIX}_CONFIG) - execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --help - RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT - OUTPUT_VARIABLE __${_PYTHON_PREFIX}_HELP - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if (_${_PYTHON_PREFIX}_RESULT) - # assume config tool is not usable - unset (_${_PYTHON_PREFIX}_CONFIG CACHE) - endif() + if (NOT ${_PYTHON_PREFIX}_LIBRARY_RELEASE OR NOT ${_PYTHON_PREFIX}_INCLUDE_DIR) + # if python interpreter is found, use it to look-up for artifacts + # to ensure consistency between interpreter and development environments. + # If not, try to locate a compatible config tool + if (NOT ${_PYTHON_PREFIX}_Interpreter_FOUND OR CMAKE_CROSSCOMPILING) + set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) + unset (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS) + if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$") + set (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS ENV VIRTUAL_ENV) endif() + unset (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS) - if (_${_PYTHON_PREFIX}_CONFIG) - execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --abiflags - RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT - OUTPUT_VARIABLE __${_PYTHON_PREFIX}_ABIFLAGS - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if (_${_PYTHON_PREFIX}_RESULT) - # assume ABI is not supported - set (__${_PYTHON_PREFIX}_ABIFLAGS "") - endif() - if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND NOT __${_PYTHON_PREFIX}_ABIFLAGS IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS) - # Wrong ABI - unset (_${_PYTHON_PREFIX}_CONFIG CACHE) - endif() - endif() + if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION") + set (_${_PYTHON_PREFIX}_CONFIG_NAMES) - if (_${_PYTHON_PREFIX}_CONFIG AND DEFINED CMAKE_LIBRARY_ARCHITECTURE) - # check that config tool match library architecture - execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --configdir - RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT - OUTPUT_VARIABLE _${_PYTHON_PREFIX}_CONFIGDIR - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if (_${_PYTHON_PREFIX}_RESULT) - unset (_${_PYTHON_PREFIX}_CONFIG CACHE) - else() - string(FIND "${_${_PYTHON_PREFIX}_CONFIGDIR}" "${CMAKE_LIBRARY_ARCHITECTURE}" _${_PYTHON_PREFIX}_RESULT) - if (_${_PYTHON_PREFIX}_RESULT EQUAL -1) - unset (_${_PYTHON_PREFIX}_CONFIG CACHE) - endif() - endif() - endif() - else() - foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) - # try to use pythonX.Y-config tool - _python_get_names (_${_PYTHON_PREFIX}_CONFIG_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} POSIX CONFIG) + foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) + _python_get_names (_${_PYTHON_PREFIX}_VERSION_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} POSIX CONFIG) + list (APPEND _${_PYTHON_PREFIX}_CONFIG_NAMES ${_${_PYTHON_PREFIX}_VERSION_NAMES}) - # Framework Paths - _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION}) + # Framework Paths + _python_get_frameworks (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_VERSION}) + list (APPEND _${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS}) + endforeach() # Apple frameworks handling if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST") - find_program (${_PYTHON_PREFIX}_CONFIG + find_program (_${_PYTHON_PREFIX}_CONFIG NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} @@ -1365,8 +1510,6 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS NO_DEFAULT_PATH) endif() - unset (_${_PYTHON_PREFIX}_CONFIG_NAMES) - if (_${_PYTHON_PREFIX}_CONFIG) execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --help RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT @@ -1379,23 +1522,20 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() endif() - if (NOT _${_PYTHON_PREFIX}_CONFIG) - continue() - endif() - - execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --abiflags - RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT - OUTPUT_VARIABLE __${_PYTHON_PREFIX}_ABIFLAGS - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if (_${_PYTHON_PREFIX}_RESULT) - # assume ABI is not supported - set (__${_PYTHON_PREFIX}_ABIFLAGS "") - endif() - if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND NOT __${_PYTHON_PREFIX}_ABIFLAGS IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS) - # Wrong ABI - unset (_${_PYTHON_PREFIX}_CONFIG CACHE) - continue() + if (_${_PYTHON_PREFIX}_CONFIG) + execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --abiflags + RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT + OUTPUT_VARIABLE __${_PYTHON_PREFIX}_ABIFLAGS + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (_${_PYTHON_PREFIX}_RESULT) + # assume ABI is not supported + set (__${_PYTHON_PREFIX}_ABIFLAGS "") + endif() + if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND NOT __${_PYTHON_PREFIX}_ABIFLAGS IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS) + # Wrong ABI + unset (_${_PYTHON_PREFIX}_CONFIG CACHE) + endif() endif() if (_${_PYTHON_PREFIX}_CONFIG AND DEFINED CMAKE_LIBRARY_ARCHITECTURE) @@ -1407,228 +1547,181 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS OUTPUT_STRIP_TRAILING_WHITESPACE) if (_${_PYTHON_PREFIX}_RESULT) unset (_${_PYTHON_PREFIX}_CONFIG CACHE) - continue() - endif() - string(FIND "${_${_PYTHON_PREFIX}_CONFIGDIR}" "${CMAKE_LIBRARY_ARCHITECTURE}" _${_PYTHON_PREFIX}_RESULT) - if (_${_PYTHON_PREFIX}_RESULT EQUAL -1) - unset (_${_PYTHON_PREFIX}_CONFIG CACHE) - continue() + else() + string(FIND "${_${_PYTHON_PREFIX}_CONFIGDIR}" "${CMAKE_LIBRARY_ARCHITECTURE}" _${_PYTHON_PREFIX}_RESULT) + if (_${_PYTHON_PREFIX}_RESULT EQUAL -1) + unset (_${_PYTHON_PREFIX}_CONFIG CACHE) + endif() endif() endif() + else() + foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) + # try to use pythonX.Y-config tool + _python_get_names (_${_PYTHON_PREFIX}_CONFIG_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} POSIX CONFIG) - if (_${_PYTHON_PREFIX}_CONFIG) - break() - endif() - endforeach() - endif() - endif() + # Framework Paths + _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION}) - if ((${_PYTHON_PREFIX}_Interpreter_FOUND AND NOT CMAKE_CROSSCOMPILING) OR _${_PYTHON_PREFIX}_CONFIG) - # retrieve root install directory - _python_get_config_var (_${_PYTHON_PREFIX}_PREFIX PREFIX) + # Apple frameworks handling + if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST") + find_program (_${_PYTHON_PREFIX}_CONFIG + NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES} + NAMES_PER_DIR + HINTS ${_${_PYTHON_PREFIX}_HINTS} + PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} + ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} + PATH_SUFFIXES bin + NO_CMAKE_PATH + NO_CMAKE_ENVIRONMENT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + endif() - # enforce current ABI - _python_get_config_var (_${_PYTHON_PREFIX}_ABIFLAGS ABIFLAGS) + find_program (_${_PYTHON_PREFIX}_CONFIG + NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES} + NAMES_PER_DIR + HINTS ${_${_PYTHON_PREFIX}_HINTS} + PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} + PATH_SUFFIXES bin) - set (_${_PYTHON_PREFIX}_HINTS "${_${_PYTHON_PREFIX}_PREFIX}") + # Apple frameworks handling + if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST") + find_program (_${_PYTHON_PREFIX}_CONFIG + NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES} + NAMES_PER_DIR + PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} + PATH_SUFFIXES bin + NO_DEFAULT_PATH) + endif() - # retrieve library - ## compute some paths and artifact names - if (_${_PYTHON_PREFIX}_CONFIG) - string (REGEX REPLACE "^.+python([0-9.]+)[a-z]*-config" "\\1" _${_PYTHON_PREFIX}_LIB_VERSION "${_${_PYTHON_PREFIX}_CONFIG}") - else() - set (_${_PYTHON_PREFIX}_LIB_VERSION "${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR}") - endif() - _python_get_path_suffixes (_${_PYTHON_PREFIX}_PATH_SUFFIXES VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} LIBRARY) - _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} POSIX LIBRARY) + unset (_${_PYTHON_PREFIX}_CONFIG_NAMES) + + if (_${_PYTHON_PREFIX}_CONFIG) + execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --help + RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT + OUTPUT_VARIABLE __${_PYTHON_PREFIX}_HELP + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (_${_PYTHON_PREFIX}_RESULT) + # assume config tool is not usable + unset (_${_PYTHON_PREFIX}_CONFIG CACHE) + endif() + endif() - _python_get_config_var (_${_PYTHON_PREFIX}_CONFIGDIR CONFIGDIR) - list (APPEND _${_PYTHON_PREFIX}_HINTS "${_${_PYTHON_PREFIX}_CONFIGDIR}") + if (NOT _${_PYTHON_PREFIX}_CONFIG) + continue() + endif() - list (APPEND _${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) + execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --abiflags + RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT + OUTPUT_VARIABLE __${_PYTHON_PREFIX}_ABIFLAGS + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (_${_PYTHON_PREFIX}_RESULT) + # assume ABI is not supported + set (__${_PYTHON_PREFIX}_ABIFLAGS "") + endif() + if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND NOT __${_PYTHON_PREFIX}_ABIFLAGS IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS) + # Wrong ABI + unset (_${_PYTHON_PREFIX}_CONFIG CACHE) + continue() + endif() - find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE - NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} - NAMES_PER_DIR - HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) + if (_${_PYTHON_PREFIX}_CONFIG AND DEFINED CMAKE_LIBRARY_ARCHITECTURE) + # check that config tool match library architecture + execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --configdir + RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT + OUTPUT_VARIABLE _${_PYTHON_PREFIX}_CONFIGDIR + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (_${_PYTHON_PREFIX}_RESULT) + unset (_${_PYTHON_PREFIX}_CONFIG CACHE) + continue() + endif() + string (FIND "${_${_PYTHON_PREFIX}_CONFIGDIR}" "${CMAKE_LIBRARY_ARCHITECTURE}" _${_PYTHON_PREFIX}_RESULT) + if (_${_PYTHON_PREFIX}_RESULT EQUAL -1) + unset (_${_PYTHON_PREFIX}_CONFIG CACHE) + continue() + endif() + endif() - # retrieve runtime library - if (${_PYTHON_PREFIX}_LIBRARY_RELEASE) - get_filename_component (_${_PYTHON_PREFIX}_PATH "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY) - get_filename_component (_${_PYTHON_PREFIX}_PATH2 "${_${_PYTHON_PREFIX}_PATH}" DIRECTORY) - _python_find_runtime_library (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE - NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} - NAMES_PER_DIR - HINTS "${_${_PYTHON_PREFIX}_PATH}" "${_${_PYTHON_PREFIX}_PATH2}" ${_${_PYTHON_PREFIX}_HINTS} - PATH_SUFFIXES bin - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) + if (_${_PYTHON_PREFIX}_CONFIG) + break() + endif() + endforeach() + endif() endif() - - # retrieve include directory - _python_get_config_var (_${_PYTHON_PREFIX}_INCLUDE_DIRS INCLUDES) - - find_path (${_PYTHON_PREFIX}_INCLUDE_DIR - NAMES Python.h - HINTS ${_${_PYTHON_PREFIX}_INCLUDE_DIRS} - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) endif() - # Rely on HINTS and standard paths if interpreter or config tool failed to locate artifacts - if (NOT ${_PYTHON_PREFIX}_LIBRARY_RELEASE OR NOT ${_PYTHON_PREFIX}_INCLUDE_DIR) - set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) - - unset (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS) - if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$") - set (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS ENV VIRTUAL_ENV) - endif() - - if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION") - unset (_${_PYTHON_PREFIX}_LIB_NAMES) - unset (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG) - unset (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS) - unset (_${_PYTHON_PREFIX}_REGISTRY_PATHS) - unset (_${_PYTHON_PREFIX}_PATH_SUFFIXES) - - foreach (_${_PYTHON_PREFIX}_LIB_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) - # library names - _python_get_names (_${_PYTHON_PREFIX}_VERSION_NAMES VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} WIN32 POSIX LIBRARY) - list (APPEND _${_PYTHON_PREFIX}_LIB_NAMES ${_${_PYTHON_PREFIX}_VERSION_NAMES}) - _python_get_names (_${_PYTHON_PREFIX}_VERSION_NAMES VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} WIN32 DEBUG) - list (APPEND _${_PYTHON_PREFIX}_LIB_NAMES_DEBUG ${_${_PYTHON_PREFIX}_VERSION_NAMES}) - - # Framework Paths - _python_get_frameworks (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_LIB_VERSION}) - list (APPEND _${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS}) + if (NOT ${_PYTHON_PREFIX}_LIBRARY_RELEASE) + if ((${_PYTHON_PREFIX}_Interpreter_FOUND AND NOT CMAKE_CROSSCOMPILING) OR _${_PYTHON_PREFIX}_CONFIG) + # retrieve root install directory + _python_get_config_var (_${_PYTHON_PREFIX}_PREFIX PREFIX) - # Registry Paths - _python_get_registries (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_LIB_VERSION}) - list (APPEND _${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS}) + # enforce current ABI + _python_get_config_var (_${_PYTHON_PREFIX}_ABIFLAGS ABIFLAGS) - # Paths suffixes - _python_get_path_suffixes (_${_PYTHON_PREFIX}_VERSION_PATHS VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} LIBRARY) - list (APPEND _${_PYTHON_PREFIX}_PATH_SUFFIXES ${_${_PYTHON_PREFIX}_VERSION_PATHS}) - endforeach() + set (_${_PYTHON_PREFIX}_HINTS "${_${_PYTHON_PREFIX}_PREFIX}") - if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST") - find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE - NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} - NAMES_PER_DIR - HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} - ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} - PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} - NO_CMAKE_PATH - NO_CMAKE_ENVIRONMENT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) + # retrieve library + ## compute some paths and artifact names + if (_${_PYTHON_PREFIX}_CONFIG) + string (REGEX REPLACE "^.+python([0-9.]+)[a-z]*-config" "\\1" _${_PYTHON_PREFIX}_VERSION "${_${_PYTHON_PREFIX}_CONFIG}") + else() + set (_${_PYTHON_PREFIX}_VERSION "${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR}") endif() + _python_get_path_suffixes (_${_PYTHON_PREFIX}_PATH_SUFFIXES VERSION ${_${_PYTHON_PREFIX}_VERSION} LIBRARY) + _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} WIN32 POSIX LIBRARY) - if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") - find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE - NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} - NAMES_PER_DIR - HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} - ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} - PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - endif() + _python_get_config_var (_${_PYTHON_PREFIX}_CONFIGDIR CONFIGDIR) + list (APPEND _${_PYTHON_PREFIX}_HINTS "${_${_PYTHON_PREFIX}_CONFIGDIR}") + + list (APPEND _${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) - # search in HINTS locations find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) + endif() - if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST") - set (__${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}) - else() - unset (__${_PYTHON_PREFIX}_FRAMEWORK_PATHS) - endif() - - if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST") - set (__${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}) - else() - unset (__${_PYTHON_PREFIX}_REGISTRY_PATHS) - endif() - - # search in all default paths - find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE - NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} - NAMES_PER_DIR - PATHS ${__${_PYTHON_PREFIX}_FRAMEWORK_PATHS} - ${__${_PYTHON_PREFIX}_REGISTRY_PATHS} - PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}) - - if (${_PYTHON_PREFIX}_LIBRARY_RELEASE) - # extract version from library name - if (${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "python([23])([0-9]+)") - set (_${_PYTHON_PREFIX}_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}") - elseif (${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "python([23])\\.([0-9]+)") - set (_${_PYTHON_PREFIX}_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}") - endif() - endif() - - if (WIN32) - # search for debug library - if (${_PYTHON_PREFIX}_LIBRARY_RELEASE) - # use library location as a hint - _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG VERSION ${_${_PYTHON_PREFIX}_VERSION} WIN32 DEBUG) - get_filename_component (_${_PYTHON_PREFIX}_PATH "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY) - find_library (${_PYTHON_PREFIX}_LIBRARY_DEBUG - NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG} - NAMES_PER_DIR - HINTS "${_${_PYTHON_PREFIX}_PATH}" ${_${_PYTHON_PREFIX}_HINTS} - NO_DEFAULT_PATH) - else() - # search first in known locations - if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") - find_library (${_PYTHON_PREFIX}_LIBRARY_DEBUG - NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG} - NAMES_PER_DIR - HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} - ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} - PATH_SUFFIXES lib libs - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - endif() - # search in all default paths - find_library (${_PYTHON_PREFIX}_LIBRARY_DEBUG - NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG} - NAMES_PER_DIR - HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} - ${__${_PYTHON_PREFIX}_REGISTRY_PATHS} - PATH_SUFFIXES lib libs) + # Rely on HINTS and standard paths if interpreter or config tool failed to locate artifacts + if (NOT ${_PYTHON_PREFIX}_LIBRARY_RELEASE) + set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) - # extract version from library name - if (${_PYTHON_PREFIX}_LIBRARY_DEBUG MATCHES "python([23])([0-9]+)") - set (_${_PYTHON_PREFIX}_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}") - elseif (${_PYTHON_PREFIX}_LIBRARY_DEBUG MATCHES "python([23])\\.([0-9]+)") - set (_${_PYTHON_PREFIX}_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}") - endif() - endif() + unset (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS) + if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$") + set (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS ENV VIRTUAL_ENV) endif() - else() - foreach (_${_PYTHON_PREFIX}_LIB_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) - _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} WIN32 POSIX LIBRARY) - _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} WIN32 DEBUG) - - _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_LIB_VERSION}) - _python_get_registries (_${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_LIB_VERSION}) - _python_get_path_suffixes (_${_PYTHON_PREFIX}_PATH_SUFFIXES VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} LIBRARY) + if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION") + unset (_${_PYTHON_PREFIX}_LIB_NAMES) + unset (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG) + unset (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS) + unset (_${_PYTHON_PREFIX}_REGISTRY_PATHS) + unset (_${_PYTHON_PREFIX}_PATH_SUFFIXES) + + foreach (_${_PYTHON_PREFIX}_LIB_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) + # library names + _python_get_names (_${_PYTHON_PREFIX}_VERSION_NAMES VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} WIN32 POSIX LIBRARY) + list (APPEND _${_PYTHON_PREFIX}_LIB_NAMES ${_${_PYTHON_PREFIX}_VERSION_NAMES}) + _python_get_names (_${_PYTHON_PREFIX}_VERSION_NAMES VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} WIN32 DEBUG) + list (APPEND _${_PYTHON_PREFIX}_LIB_NAMES_DEBUG ${_${_PYTHON_PREFIX}_VERSION_NAMES}) + + # Framework Paths + _python_get_frameworks (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_LIB_VERSION}) + list (APPEND _${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS}) + + # Registry Paths + _python_get_registries (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_LIB_VERSION}) + list (APPEND _${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS}) + + # Paths suffixes + _python_get_path_suffixes (_${_PYTHON_PREFIX}_VERSION_PATHS VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} LIBRARY) + list (APPEND _${_PYTHON_PREFIX}_PATH_SUFFIXES ${_${_PYTHON_PREFIX}_VERSION_PATHS}) + endforeach() if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST") find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE @@ -1666,111 +1759,171 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) - if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST") - set (__${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}) - else() - unset (__${_PYTHON_PREFIX}_FRAMEWORK_PATHS) - endif() + if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST") + set (__${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}) + else() + unset (__${_PYTHON_PREFIX}_FRAMEWORK_PATHS) + endif() - if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST") - set (__${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}) - else() - unset (__${_PYTHON_PREFIX}_REGISTRY_PATHS) - endif() + if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST") + set (__${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}) + else() + unset (__${_PYTHON_PREFIX}_REGISTRY_PATHS) + endif() - # search in all default paths - find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE + # search in all default paths + find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} NAMES_PER_DIR PATHS ${__${_PYTHON_PREFIX}_FRAMEWORK_PATHS} ${__${_PYTHON_PREFIX}_REGISTRY_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}) + else() + foreach (_${_PYTHON_PREFIX}_LIB_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) + _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} WIN32 POSIX LIBRARY) + _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} WIN32 DEBUG) - if (WIN32) - # search for debug library - if (${_PYTHON_PREFIX}_LIBRARY_RELEASE) - # use library location as a hint - get_filename_component (_${_PYTHON_PREFIX}_PATH "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY) - find_library (${_PYTHON_PREFIX}_LIBRARY_DEBUG - NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG} + _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_LIB_VERSION}) + _python_get_registries (_${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_LIB_VERSION}) + + _python_get_path_suffixes (_${_PYTHON_PREFIX}_PATH_SUFFIXES VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} LIBRARY) + + if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST") + find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE + NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} NAMES_PER_DIR - HINTS "${_${_PYTHON_PREFIX}_PATH}" ${_${_PYTHON_PREFIX}_HINTS} - NO_DEFAULT_PATH) - else() - # search first in known locations - if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") - find_library (${_PYTHON_PREFIX}_LIBRARY_DEBUG - NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG} - NAMES_PER_DIR - HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} - ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} - PATH_SUFFIXES lib libs - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - endif() - # search in all default paths - find_library (${_PYTHON_PREFIX}_LIBRARY_DEBUG - NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG} + HINTS ${_${_PYTHON_PREFIX}_HINTS} + PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} + ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} + PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} + NO_CMAKE_PATH + NO_CMAKE_ENVIRONMENT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + endif() + + if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST") + find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE + NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} - ${__${_PYTHON_PREFIX}_REGISTRY_PATHS} - PATH_SUFFIXES lib libs) + ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} + PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) endif() - endif() - if (${_PYTHON_PREFIX}_LIBRARY_RELEASE OR ${_PYTHON_PREFIX}_LIBRARY_DEBUG) - set (_${_PYTHON_PREFIX}_VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION}) - break() - endif() - endforeach() - endif() + # search in HINTS locations + find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE + NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} + NAMES_PER_DIR + HINTS ${_${_PYTHON_PREFIX}_HINTS} + PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} + PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) - # retrieve runtime libraries - if (${_PYTHON_PREFIX}_LIBRARY_RELEASE) - _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} WIN32 POSIX LIBRARY) - get_filename_component (_${_PYTHON_PREFIX}_PATH "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY) - get_filename_component (_${_PYTHON_PREFIX}_PATH2 "${_${_PYTHON_PREFIX}_PATH}" DIRECTORY) - _python_find_runtime_library (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE - NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} - NAMES_PER_DIR - HINTS "${_${_PYTHON_PREFIX}_PATH}" "${_${_PYTHON_PREFIX}_PATH2}" ${_${_PYTHON_PREFIX}_HINTS} - PATH_SUFFIXES bin) + if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST") + set (__${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}) + else() + unset (__${_PYTHON_PREFIX}_FRAMEWORK_PATHS) + endif() + + if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST") + set (__${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}) + else() + unset (__${_PYTHON_PREFIX}_REGISTRY_PATHS) + endif() + + # search in all default paths + find_library (${_PYTHON_PREFIX}_LIBRARY_RELEASE + NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} + NAMES_PER_DIR + PATHS ${__${_PYTHON_PREFIX}_FRAMEWORK_PATHS} + ${__${_PYTHON_PREFIX}_REGISTRY_PATHS} + PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}) + + if (${_PYTHON_PREFIX}_LIBRARY_RELEASE) + break() + endif() + endforeach() + endif() endif() - if (${_PYTHON_PREFIX}_LIBRARY_DEBUG) - _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG VERSION ${_${_PYTHON_PREFIX}_VERSION} WIN32 DEBUG) - get_filename_component (_${_PYTHON_PREFIX}_PATH "${${_PYTHON_PREFIX}_LIBRARY_DEBUG}" DIRECTORY) - get_filename_component (_${_PYTHON_PREFIX}_PATH2 "${_${_PYTHON_PREFIX}_PATH}" DIRECTORY) - _python_find_runtime_library (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG - NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG} - NAMES_PER_DIR - HINTS "${_${_PYTHON_PREFIX}_PATH}" "${_${_PYTHON_PREFIX}_PATH2}" ${_${_PYTHON_PREFIX}_HINTS} - PATH_SUFFIXES bin) + endif() + + # finalize library version information + _python_get_version (LIBRARY PREFIX _${_PYTHON_PREFIX}_) + + set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) + + if (WIN32 AND ${_PYTHON_PREFIX}_LIBRARY_RELEASE) + # search for debug library + # use release library location as a hint + _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG VERSION ${_${_PYTHON_PREFIX}_VERSION} WIN32 DEBUG) + get_filename_component (_${_PYTHON_PREFIX}_PATH "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY) + find_library (${_PYTHON_PREFIX}_LIBRARY_DEBUG + NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG} + NAMES_PER_DIR + HINTS "${_${_PYTHON_PREFIX}_PATH}" ${_${_PYTHON_PREFIX}_HINTS} + NO_DEFAULT_PATH) + endif() + + # retrieve runtime libraries + if (${_PYTHON_PREFIX}_LIBRARY_RELEASE) + _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} WIN32 POSIX LIBRARY) + get_filename_component (_${_PYTHON_PREFIX}_PATH "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY) + get_filename_component (_${_PYTHON_PREFIX}_PATH2 "${_${_PYTHON_PREFIX}_PATH}" DIRECTORY) + _python_find_runtime_library (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE + NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} + NAMES_PER_DIR + HINTS "${_${_PYTHON_PREFIX}_PATH}" "${_${_PYTHON_PREFIX}_PATH2}" ${_${_PYTHON_PREFIX}_HINTS} + PATH_SUFFIXES bin) + endif() + if (${_PYTHON_PREFIX}_LIBRARY_DEBUG) + _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG VERSION ${_${_PYTHON_PREFIX}_VERSION} WIN32 DEBUG) + get_filename_component (_${_PYTHON_PREFIX}_PATH "${${_PYTHON_PREFIX}_LIBRARY_DEBUG}" DIRECTORY) + get_filename_component (_${_PYTHON_PREFIX}_PATH2 "${_${_PYTHON_PREFIX}_PATH}" DIRECTORY) + _python_find_runtime_library (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG + NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG} + NAMES_PER_DIR + HINTS "${_${_PYTHON_PREFIX}_PATH}" "${_${_PYTHON_PREFIX}_PATH2}" ${_${_PYTHON_PREFIX}_HINTS} + PATH_SUFFIXES bin) + endif() + + # Don't search for include dir if no library was founded + if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND NOT ${_PYTHON_PREFIX}_INCLUDE_DIR) + if ((${_PYTHON_PREFIX}_Interpreter_FOUND AND NOT CMAKE_CROSSCOMPILING) OR _${_PYTHON_PREFIX}_CONFIG) + _python_get_config_var (_${_PYTHON_PREFIX}_INCLUDE_DIRS INCLUDES) + + find_path (${_PYTHON_PREFIX}_INCLUDE_DIR + NAMES Python.h + HINTS ${_${_PYTHON_PREFIX}_INCLUDE_DIRS} + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) endif() - # Don't search for include dir if no library was founded - if (${_PYTHON_PREFIX}_LIBRARY_RELEASE OR ${_PYTHON_PREFIX}_LIBRARY_DEBUG) + # Rely on HINTS and standard paths if interpreter or config tool failed to locate artifacts + if (NOT ${_PYTHON_PREFIX}_INCLUDE_DIR) + unset (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS) + if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$") + set (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS ENV VIRTUAL_ENV) + endif() unset (_${_PYTHON_PREFIX}_INCLUDE_HINTS) - foreach (_${_PYTHON_PREFIX}_LIB IN ITEMS ${_PYTHON_PREFIX}_LIBRARY_RELEASE ${_PYTHON_PREFIX}_LIBRARY_DEBUG) - if (${_${_PYTHON_PREFIX}_LIB}) - # Use the library's install prefix as a hint - if (${_${_PYTHON_PREFIX}_LIB} MATCHES "^(.+/Frameworks/Python.framework/Versions/[0-9.]+)") - list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${CMAKE_MATCH_1}") - elseif (${_${_PYTHON_PREFIX}_LIB} MATCHES "^(.+)/lib(64|32)?/python[0-9.]+/config") - list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${CMAKE_MATCH_1}") - elseif (DEFINED CMAKE_LIBRARY_ARCHITECTURE AND ${_${_PYTHON_PREFIX}_LIB} MATCHES "^(.+)/lib/${CMAKE_LIBRARY_ARCHITECTURE}") - list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${CMAKE_MATCH_1}") - else() - # assume library is in a directory under root - get_filename_component (_${_PYTHON_PREFIX}_PREFIX "${${_${_PYTHON_PREFIX}_LIB}}" DIRECTORY) - get_filename_component (_${_PYTHON_PREFIX}_PREFIX "${_${_PYTHON_PREFIX}_PREFIX}" DIRECTORY) - list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${_${_PYTHON_PREFIX}_PREFIX}") - endif() - endif() - endforeach() - list (REMOVE_DUPLICATES _${_PYTHON_PREFIX}_INCLUDE_HINTS) + # Use the library's install prefix as a hint + if (${${_PYTHON_PREFIX}_LIBRARY_RELEASE} MATCHES "^(.+/Frameworks/Python.framework/Versions/[0-9.]+)") + list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${CMAKE_MATCH_1}") + elseif (${${_PYTHON_PREFIX}_LIBRARY_RELEASE} MATCHES "^(.+)/lib(64|32)?/python[0-9.]+/config") + list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${CMAKE_MATCH_1}") + elseif (DEFINED CMAKE_LIBRARY_ARCHITECTURE AND ${${_PYTHON_PREFIX}_LIBRARY_RELEASE} MATCHES "^(.+)/lib/${CMAKE_LIBRARY_ARCHITECTURE}") + list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${CMAKE_MATCH_1}") + else() + # assume library is in a directory under root + get_filename_component (_${_PYTHON_PREFIX}_PREFIX "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY) + get_filename_component (_${_PYTHON_PREFIX}_PREFIX "${_${_PYTHON_PREFIX}_PREFIX}" DIRECTORY) + list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${_${_PYTHON_PREFIX}_PREFIX}") + endif() _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION}) _python_get_registries (_${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_VERSION}) @@ -1828,42 +1981,37 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS NAMES Python.h) endif() + # retrieve version from header file + _python_get_version (INCLUDE PREFIX _${_PYTHON_PREFIX}_INC_) + if (${_PYTHON_PREFIX}_INCLUDE_DIR) - # retrieve version from header file - file (STRINGS "${${_PYTHON_PREFIX}_INCLUDE_DIR}/patchlevel.h" _${_PYTHON_PREFIX}_VERSION - REGEX "^#define[ \t]+PY_VERSION[ \t]+\"[^\"]+\"") - string (REGEX REPLACE "^#define[ \t]+PY_VERSION[ \t]+\"([^\"]+)\".*" "\\1" - _${_PYTHON_PREFIX}_VERSION "${_${_PYTHON_PREFIX}_VERSION}") - string (REGEX MATCHALL "[0-9]+" _${_PYTHON_PREFIX}_VERSIONS "${_${_PYTHON_PREFIX}_VERSION}") - list (GET _${_PYTHON_PREFIX}_VERSIONS 0 _${_PYTHON_PREFIX}_VERSION_MAJOR) - list (GET _${_PYTHON_PREFIX}_VERSIONS 1 _${_PYTHON_PREFIX}_VERSION_MINOR) - list (GET _${_PYTHON_PREFIX}_VERSIONS 2 _${_PYTHON_PREFIX}_VERSION_PATCH) - - if (NOT ${_PYTHON_PREFIX}_Interpreter_FOUND AND NOT ${_PYTHON_PREFIX}_Compiler_FOUND) - # set public version information - set (${_PYTHON_PREFIX}_VERSION ${_${_PYTHON_PREFIX}_VERSION}) - set (${_PYTHON_PREFIX}_VERSION_MAJOR ${_${_PYTHON_PREFIX}_VERSION_MAJOR}) - set (${_PYTHON_PREFIX}_VERSION_MINOR ${_${_PYTHON_PREFIX}_VERSION_MINOR}) - set (${_PYTHON_PREFIX}_VERSION_PATCH ${_${_PYTHON_PREFIX}_VERSION_PATCH}) + # update versionning + if (_${_PYTHON_PREFIX}_INC_VERSION VERSION_EQUAL ${_${_PYTHON_PREFIX}_VERSION}) + set (_${_PYTHON_PREFIX}_VERSION_PATCH ${_${_PYTHON_PREFIX}_INC_VERSION_PATCH}) endif() endif() + if (NOT ${_PYTHON_PREFIX}_Interpreter_FOUND AND NOT ${_PYTHON_PREFIX}_Compiler_FOUND) + # set public version information + set (${_PYTHON_PREFIX}_VERSION ${_${_PYTHON_PREFIX}_VERSION}) + set (${_PYTHON_PREFIX}_VERSION_MAJOR ${_${_PYTHON_PREFIX}_VERSION_MAJOR}) + set (${_PYTHON_PREFIX}_VERSION_MINOR ${_${_PYTHON_PREFIX}_VERSION_MINOR}) + set (${_PYTHON_PREFIX}_VERSION_PATCH ${_${_PYTHON_PREFIX}_VERSION_PATCH}) + endif() + # define public variables include (${CMAKE_CURRENT_LIST_DIR}/../SelectLibraryConfigurations.cmake) select_library_configurations (${_PYTHON_PREFIX}) if (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE) set (${_PYTHON_PREFIX}_RUNTIME_LIBRARY "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE}") - elseif (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG) - set (${_PYTHON_PREFIX}_RUNTIME_LIBRARY "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG}") else() - set (${_PYTHON_PREFIX}_RUNTIME_LIBRARY "$${_PYTHON_PREFIX}_RUNTIME_LIBRARY-NOTFOUND") + set (${_PYTHON_PREFIX}_RUNTIME_LIBRARY "${_PYTHON_PREFIX}_RUNTIME_LIBRARY-NOTFOUND") endif() _python_set_library_dirs (${_PYTHON_PREFIX}_LIBRARY_DIRS ${_PYTHON_PREFIX}_LIBRARY_RELEASE ${_PYTHON_PREFIX}_LIBRARY_DEBUG) if (UNIX) - if (${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$" - OR ${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$") + if (${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$") set (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DIRS ${${_PYTHON_PREFIX}_LIBRARY_DIRS}) endif() else() @@ -1873,26 +2021,36 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS set (${_PYTHON_PREFIX}_INCLUDE_DIRS "${${_PYTHON_PREFIX}_INCLUDE_DIR}") - mark_as_advanced (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE - ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG - ${_PYTHON_PREFIX}_INCLUDE_DIR) - - if ((${_PYTHON_PREFIX}_LIBRARY_RELEASE OR ${_PYTHON_PREFIX}_LIBRARY_DEBUG) - AND ${_PYTHON_PREFIX}_INCLUDE_DIR) + if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_INCLUDE_DIR) if (${_PYTHON_PREFIX}_Interpreter_FOUND OR ${_PYTHON_PREFIX}_Compiler_FOUND) # development environment must be compatible with interpreter/compiler - if (${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR} VERSION_EQUAL ${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR}) + if (${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR} VERSION_EQUAL ${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR} + AND ${_${_PYTHON_PREFIX}_INC_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_INC_VERSION_MINOR} VERSION_EQUAL ${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR}) set (${_PYTHON_PREFIX}_Development_FOUND TRUE) endif() - elseif (${_PYTHON_PREFIX}_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR) + elseif (${_PYTHON_PREFIX}_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR + AND ${_${_PYTHON_PREFIX}_INC_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_INC_VERSION_MINOR} VERSION_EQUAL ${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR}) set (${_PYTHON_PREFIX}_Development_FOUND TRUE) endif() endif() + if (${_PYTHON_PREFIX}_Development_FOUND) + # compute and save development signature + string (MD5 __${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${${_PYTHON_PREFIX}_LIBRARY_RELEASE}:${${_PYTHON_PREFIX}_INCLUDE_DIR}") + set (_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE "${__${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE}" CACHE INTERNAL "") + else() + unset (_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE CACHE) + endif() + # Restore the original find library ordering if (DEFINED _${_PYTHON_PREFIX}_CMAKE_FIND_LIBRARY_SUFFIXES) set (CMAKE_FIND_LIBRARY_SUFFIXES ${_${_PYTHON_PREFIX}_CMAKE_FIND_LIBRARY_SUFFIXES}) endif() + + mark_as_advanced (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE + ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG + ${_PYTHON_PREFIX}_INCLUDE_DIR + _${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE) endif() if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND ${_PYTHON_PREFIX}_Interpreter_FOUND) @@ -1900,36 +2058,59 @@ if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND ${_PYTHON_PREFIX}_Inte if (${_PYTHON_PREFIX}_FIND_REQUIRED_NumPy) list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR) endif() - execute_process( + + if (DEFINED ${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR) + # compute numpy signature. Depends on interpreter and development signatures + string (MD5 __${_PYTHON_PREFIX}_NUMPY_SIGNATURE "${_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE}:${_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE}:${${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}") + if (NOT __${_PYTHON_PREFIX}_NUMPY_SIGNATURE STREQUAL _${_PYTHON_PREFIX}_NUMPY_SIGNATURE) + unset (${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR CACHE) + unset (_${_PYTHON_PREFIX}_NUMPY_SIGNATURE CACHE) + endif() + endif() + + if (NOT ${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR) + execute_process( COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c "from __future__ import print_function\ntry: import numpy; print(numpy.get_include(), end='')\nexcept:pass\n" RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT OUTPUT_VARIABLE _${_PYTHON_PREFIX}_NumPy_PATH ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - if (NOT _${_PYTHON_PREFIX}_RESULT) - find_path(${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR - NAMES "numpy/arrayobject.h" "numpy/numpyconfig.h" - HINTS "${_${_PYTHON_PREFIX}_NumPy_PATH}" - NO_DEFAULT_PATH) + + if (NOT _${_PYTHON_PREFIX}_RESULT) + find_path (${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR + NAMES "numpy/arrayobject.h" "numpy/numpyconfig.h" + HINTS "${_${_PYTHON_PREFIX}_NumPy_PATH}" + NO_DEFAULT_PATH) + endif() endif() + if(${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR) - set(${_PYTHON_PREFIX}_NumPy_INCLUDE_DIRS "${${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}") - set(${_PYTHON_PREFIX}_NumPy_FOUND TRUE) - endif() - if(${_PYTHON_PREFIX}_NumPy_FOUND) - execute_process( + set (${_PYTHON_PREFIX}_NumPy_INCLUDE_DIRS "${${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}") + + execute_process ( COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c "from __future__ import print_function\ntry: import numpy; print(numpy.__version__, end='')\nexcept:pass\n" RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT OUTPUT_VARIABLE _${_PYTHON_PREFIX}_NumPy_VERSION) if (NOT _${_PYTHON_PREFIX}_RESULT) - set(${_PYTHON_PREFIX}_NumPy_VERSION "${_${_PYTHON_PREFIX}_NumPy_VERSION}") + set (${_PYTHON_PREFIX}_NumPy_VERSION "${_${_PYTHON_PREFIX}_NumPy_VERSION}") + else() + unset (${_PYTHON_PREFIX}_NumPy_VERSION) endif() + + # final step: set NumPy founded only if Development component is founded as well + set(${_PYTHON_PREFIX}_NumPy_FOUND ${${_PYTHON_PREFIX}_Development_FOUND}) + else() + set (${_PYTHON_PREFIX}_NumPy_FOUND FALSE) endif() - # final step: set NumPy founded only if Development component is founded as well - if (NOT ${_PYTHON_PREFIX}_Development_FOUND) - set(${_PYTHON_PREFIX}_NumPy_FOUND FALSE) + + if (${_PYTHON_PREFIX}_NumPy_FOUND) + # compute and save numpy signature + string (MD5 __${_PYTHON_PREFIX}_NUMPY_SIGNATURE "${_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE}:${_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE}:${${_PYTHON_PREFIX}_NumPyINCLUDE_DIR}") + set (_${_PYTHON_PREFIX}_NUMPY_SIGNATURE "${__${_PYTHON_PREFIX}_NUMPY_SIGNATURE}" CACHE INTERNAL "") + else() + unset (_${_PYTHON_PREFIX}_NUMPY_SIGNATURE CACHE) endif() endif() @@ -1968,8 +2149,7 @@ if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT") macro (__PYTHON_IMPORT_LIBRARY __name) if (${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$" - OR ${_PYTHON_PREFIX}_LIBRARY_DEBUG MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$" - OR ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE OR ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG) + OR ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE) set (_${_PYTHON_PREFIX}_LIBRARY_TYPE SHARED) else() set (_${_PYTHON_PREFIX}_LIBRARY_TYPE STATIC) @@ -1980,8 +2160,7 @@ if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT") set_property (TARGET ${__name} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_INCLUDE_DIR}") - if ((${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE) - OR (${_PYTHON_PREFIX}_LIBRARY_DEBUG AND ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG)) + if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE) # System manage shared libraries in two parts: import and runtime if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_LIBRARY_DEBUG) set_property (TARGET ${__name} PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e29a92f5259def88bda0c292f591fda68c0e064e commit e29a92f5259def88bda0c292f591fda68c0e064e Author: Gregor Jasny AuthorDate: Sun Sep 1 10:42:39 2019 +0200 Commit: Gregor Jasny CommitDate: Sun Sep 1 10:43:26 2019 +0200 Xcode: Make BundleTests compatible with Xcode 11 diff --git a/Tests/BundleTest/BundleSubDir/CMakeLists.txt b/Tests/BundleTest/BundleSubDir/CMakeLists.txt index 2f7f2c4..5f91f20 100644 --- a/Tests/BundleTest/BundleSubDir/CMakeLists.txt +++ b/Tests/BundleTest/BundleSubDir/CMakeLists.txt @@ -35,7 +35,11 @@ install(TARGETS SecondBundle DESTINATION Applications) # installed into a location that uses this output name this will fail if the # bundle does not respect the name. Also the executable will not be found by # the test driver if this does not work. -set_target_properties(SecondBundle PROPERTIES OUTPUT_NAME SecondBundleExe) +set_target_properties(SecondBundle PROPERTIES + OUTPUT_NAME SecondBundleExe + XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "" + XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO" + ) # Express one app bundle in terms of another's SOURCES to verify that # the generators do not expose the Info.plist of one to the other. diff --git a/Tests/BundleTest/CMakeLists.txt b/Tests/BundleTest/CMakeLists.txt index 853da35..1bedc70 100644 --- a/Tests/BundleTest/CMakeLists.txt +++ b/Tests/BundleTest/CMakeLists.txt @@ -56,7 +56,11 @@ install(TARGETS BundleTest DESTINATION Applications) # installed into a location that uses this output name this will fail if the # bundle does not respect the name. Also the executable will not be found by # the test driver if this does not work. -set_target_properties(BundleTest PROPERTIES OUTPUT_NAME BundleTestExe) +set_target_properties(BundleTest PROPERTIES + OUTPUT_NAME BundleTestExe + XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "" + XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO" + ) # Test executable versioning if it is supported. if(NOT XCODE) diff --git a/Tests/CFBundleTest/CMakeLists.txt b/Tests/CFBundleTest/CMakeLists.txt index 0fe6bb7..b2b1b73 100644 --- a/Tests/CFBundleTest/CMakeLists.txt +++ b/Tests/CFBundleTest/CMakeLists.txt @@ -50,6 +50,8 @@ set_source_files_properties( set_target_properties(CFBundleTest PROPERTIES BUNDLE 1 BUNDLE_EXTENSION plugin + XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "" + XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO" XCODE_ATTRIBUTE_MACH_O_TYPE mh_bundle XCODE_ATTRIBUTE_INFOPLIST_FILE ${CMAKE_CURRENT_BINARY_DIR}/Info.plist MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist ----------------------------------------------------------------------- Summary of changes: Help/release/dev/FindPython-specify_artifacts.rst | 5 + Modules/FindPython.cmake | 50 + Modules/FindPython/Support.cmake | 1962 +++++++++++--------- Modules/FindPython2.cmake | 38 + Modules/FindPython3.cmake | 38 + Tests/BundleTest/BundleSubDir/CMakeLists.txt | 6 +- Tests/BundleTest/CMakeLists.txt | 6 +- Tests/CFBundleTest/CMakeLists.txt | 2 + Tests/FindPython/CMakeLists.txt | 13 + Tests/FindPython/RequiredArtifacts/CMakeLists.txt | 110 ++ .../RequiredArtifacts/Check/CMakeLists.txt | 41 + 11 files changed, 1421 insertions(+), 850 deletions(-) create mode 100644 Help/release/dev/FindPython-specify_artifacts.rst create mode 100644 Tests/FindPython/RequiredArtifacts/CMakeLists.txt create mode 100644 Tests/FindPython/RequiredArtifacts/Check/CMakeLists.txt hooks/post-receive -- CMake From kwrobot at kitware.com Tue Sep 3 13:22:18 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 3 Sep 2019 13:22:18 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-966-g711e1c3 Message-ID: <20190903172218.F2D98F95BE@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 711e1c3ada26d952fa6360e671379b7bf1be2f17 (commit) via de0a2354fcd2f97b1a8f7ec98b4b623e76d88c2c (commit) via 1aa0a18c41eb6b8dbfc9130eb975fa9ecd6b680c (commit) from 72b7629956c1718ce59db8a6a0d485b166ed6fe0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=711e1c3ada26d952fa6360e671379b7bf1be2f17 commit 711e1c3ada26d952fa6360e671379b7bf1be2f17 Merge: 72b7629 de0a235 Author: Brad King AuthorDate: Tue Sep 3 17:16:05 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 3 13:16:17 2019 -0400 Merge topic 'lint-updates' de0a2354fc IWYU: Add missing cstddef includes for size_t and nullptr_t 1aa0a18c41 cmCTestTestHandler: Re-order includes to follow our convention Acked-by: Kitware Robot Merge-request: !3774 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=de0a2354fcd2f97b1a8f7ec98b4b623e76d88c2c commit de0a2354fcd2f97b1a8f7ec98b4b623e76d88c2c Author: Brad King AuthorDate: Tue Sep 3 11:41:40 2019 -0400 Commit: Brad King CommitDate: Tue Sep 3 11:46:52 2019 -0400 IWYU: Add missing cstddef includes for size_t and nullptr_t The IWYU tool we use for CI now diagnoses these. diff --git a/Source/CPack/IFW/cmCPackIFWCommon.cxx b/Source/CPack/IFW/cmCPackIFWCommon.cxx index f9ce822..aa9a457 100644 --- a/Source/CPack/IFW/cmCPackIFWCommon.cxx +++ b/Source/CPack/IFW/cmCPackIFWCommon.cxx @@ -11,6 +11,7 @@ #include "cmVersionConfig.h" #include "cmXMLWriter.h" +#include #include #include #include diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 547d2f3..b90209e 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/Source/cmFileAPI.cxx b/Source/cmFileAPI.cxx index 5d9181a..8161191 100644 --- a/Source/cmFileAPI.cxx +++ b/Source/cmFileAPI.cxx @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index b9a9204..8896e15 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -5,6 +5,7 @@ #include "cmsys/RegularExpression.hxx" #include #include +#include #include #include #include diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 91dea58..d2c051e 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -5,6 +5,7 @@ #include "cmsys/RegularExpression.hxx" #include #include +#include #include #include #include diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index f8c5ada..e74fff6 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -4,6 +4,7 @@ #include "cmsys/RegularExpression.hxx" #include +#include #include #include #include diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 155167b..d6916b0 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -29,6 +29,7 @@ #include "cmsys/SystemInformation.hxx" #include +#include #include #include #include diff --git a/Source/cmString.hxx b/Source/cmString.hxx index 49bad78..226ac67 100644 --- a/Source/cmString.hxx +++ b/Source/cmString.hxx @@ -9,6 +9,7 @@ #include "cm_string_view.hxx" #include +#include #include #include #include diff --git a/Source/cmStringAlgorithms.cxx b/Source/cmStringAlgorithms.cxx index c686aa0..131a01e 100644 --- a/Source/cmStringAlgorithms.cxx +++ b/Source/cmStringAlgorithms.cxx @@ -3,6 +3,7 @@ #include "cmStringAlgorithms.h" #include +#include #include #include #include diff --git a/Source/cmUVProcessChain.h b/Source/cmUVProcessChain.h index 75f8f66..76a9c40 100644 --- a/Source/cmUVProcessChain.h +++ b/Source/cmUVProcessChain.h @@ -6,6 +6,7 @@ #include "cm_uv.h" #include +#include #include #include #include diff --git a/Source/cmXMLWriter.h b/Source/cmXMLWriter.h index 512e103..a5b06af 100644 --- a/Source/cmXMLWriter.h +++ b/Source/cmXMLWriter.h @@ -8,6 +8,7 @@ #include "cmXMLSafe.h" #include +#include #include #include #include diff --git a/Tests/CMakeLib/testString.cxx b/Tests/CMakeLib/testString.cxx index af5e41e..075892f 100644 --- a/Tests/CMakeLib/testString.cxx +++ b/Tests/CMakeLib/testString.cxx @@ -6,6 +6,7 @@ #include "cm_static_string_view.hxx" #include "cm_string_view.hxx" +#include #include #include #include https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1aa0a18c41eb6b8dbfc9130eb975fa9ecd6b680c commit 1aa0a18c41eb6b8dbfc9130eb975fa9ecd6b680c Author: Brad King AuthorDate: Tue Sep 3 11:45:34 2019 -0400 Commit: Brad King CommitDate: Tue Sep 3 11:46:52 2019 -0400 cmCTestTestHandler: Re-order includes to follow our convention diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 9181daa..547d2f3 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1,22 +1,6 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestTestHandler.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "cm_memory.hxx" @@ -38,6 +22,23 @@ #include "cmake.h" #include "cmsys/FStream.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + class cmExecutionStatus; class cmCTestSubdirCommand : public cmCommand ----------------------------------------------------------------------- Summary of changes: Source/CPack/IFW/cmCPackIFWCommon.cxx | 1 + Source/CTest/cmCTestTestHandler.cxx | 34 ++++++++++++++++++---------------- Source/cmFileAPI.cxx | 1 + Source/cmGeneratorTarget.cxx | 1 + Source/cmListCommand.cxx | 1 + Source/cmProjectCommand.cxx | 1 + Source/cmQtAutoGenInitializer.cxx | 1 + Source/cmString.hxx | 1 + Source/cmStringAlgorithms.cxx | 1 + Source/cmUVProcessChain.h | 1 + Source/cmXMLWriter.h | 1 + Tests/CMakeLib/testString.cxx | 1 + 12 files changed, 29 insertions(+), 16 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Wed Sep 4 00:02:05 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 4 Sep 2019 00:02:05 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-967-g787765d Message-ID: <20190904040205.3D110101D81@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 787765d4025cd1caa842d9bcfcf6cd71222b9d44 (commit) from 711e1c3ada26d952fa6360e671379b7bf1be2f17 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=787765d4025cd1caa842d9bcfcf6cd71222b9d44 commit 787765d4025cd1caa842d9bcfcf6cd71222b9d44 Author: Kitware Robot AuthorDate: Wed Sep 4 00:01:06 2019 -0400 Commit: Kitware Robot CommitDate: Wed Sep 4 00:01:06 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 46f7cce..5f6e9bb 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 15) -set(CMake_VERSION_PATCH 20190903) +set(CMake_VERSION_PATCH 20190904) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Wed Sep 4 08:41:53 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 4 Sep 2019 08:41:53 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-969-g2b478a9 Message-ID: <20190904124154.01ACDFA262@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 2b478a921aedd55c2596bc0cb083ffea7244bb0e (commit) via b96155f228a6f5fd1af263a927d35e3683a58766 (commit) from 787765d4025cd1caa842d9bcfcf6cd71222b9d44 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2b478a921aedd55c2596bc0cb083ffea7244bb0e commit 2b478a921aedd55c2596bc0cb083ffea7244bb0e Merge: 787765d b96155f Author: Brad King AuthorDate: Wed Sep 4 12:34:53 2019 +0000 Commit: Kitware Robot CommitDate: Wed Sep 4 08:35:11 2019 -0400 Merge topic 'fix-copy-directory-docs' b96155f228 Help: Fix copy_directory description Acked-by: Kitware Robot Merge-request: !3769 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b96155f228a6f5fd1af263a927d35e3683a58766 commit b96155f228a6f5fd1af263a927d35e3683a58766 Author: Leonid Pospelov AuthorDate: Mon Sep 2 15:21:16 2019 +0300 Commit: Leonid Pospelov CommitDate: Mon Sep 2 15:21:16 2019 +0300 Help: Fix copy_directory description diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index 26ef904..0645e41 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -462,7 +462,7 @@ Available commands are: but the files or directories it point to. ``copy_directory ... `` - Copy directories to ```` directory. + Copy content of ``...`` directories to ```` directory. If ```` directory does not exist it will be created. ``copy_directory`` does follow symlinks. ----------------------------------------------------------------------- Summary of changes: Help/manual/cmake.1.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Wed Sep 4 08:51:52 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 4 Sep 2019 08:51:52 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-971-gefbd503 Message-ID: <20190904125152.D3CACFA262@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via efbd50383386c00cde63a7b67672b8487b00980f (commit) via fb9da8e6f421263e8904e8d12586bf7b068ed3b4 (commit) from 2b478a921aedd55c2596bc0cb083ffea7244bb0e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=efbd50383386c00cde63a7b67672b8487b00980f commit efbd50383386c00cde63a7b67672b8487b00980f Merge: 2b478a9 fb9da8e Author: Brad King AuthorDate: Wed Sep 4 12:49:44 2019 +0000 Commit: Kitware Robot CommitDate: Wed Sep 4 08:50:19 2019 -0400 Merge topic 'fortran-INCLUDE-defines' fb9da8e6f4 Ninja: Pass preprocessor definitions when compiling with Intel Fortran Acked-by: Kitware Robot Merge-request: !3764 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fb9da8e6f421263e8904e8d12586bf7b068ed3b4 commit fb9da8e6f421263e8904e8d12586bf7b068ed3b4 Author: Brad King AuthorDate: Fri Aug 30 15:30:51 2019 -0400 Commit: Brad King CommitDate: Tue Sep 3 14:20:26 2019 -0400 Ninja: Pass preprocessor definitions when compiling with Intel Fortran The Intel Fortran compiler supports an extension that allows conditional compilation based on preprocessor definitions specified on the command line even when not preprocessing. Fixes: #19664 diff --git a/Modules/Compiler/Intel-Fortran.cmake b/Modules/Compiler/Intel-Fortran.cmake index 5275ddf..156b533 100644 --- a/Modules/Compiler/Intel-Fortran.cmake +++ b/Modules/Compiler/Intel-Fortran.cmake @@ -8,6 +8,8 @@ set(CMAKE_Fortran_MODDIR_FLAG "-module ") set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed") set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free") +set(CMAKE_Fortran_COMPILE_WITH_DEFINES 1) + set(CMAKE_Fortran_CREATE_PREPROCESSED_SOURCE " -E > ") set(CMAKE_Fortran_CREATE_ASSEMBLY_SOURCE " -S -o ") diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 29e8b74..90b59e7 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -108,6 +108,13 @@ bool cmNinjaTargetGenerator::UsePreprocessedSource( return lang == "Fortran"; } +bool cmNinjaTargetGenerator::CompilePreprocessedSourceWithDefines( + std::string const& lang) const +{ + return this->Makefile->IsOn( + cmStrCat("CMAKE_", lang, "_COMPILE_WITH_DEFINES")); +} + std::string cmNinjaTargetGenerator::LanguageDyndepRule( const std::string& lang) const { @@ -458,12 +465,14 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang) vars.ObjectDir = "$OBJECT_DIR"; vars.ObjectFileDir = "$OBJECT_FILE_DIR"; + cmMakefile* mf = this->GetMakefile(); + // For some cases we do an explicit preprocessor invocation. bool const explicitPP = this->NeedExplicitPreprocessing(lang); + bool const compilePPWithDefines = this->UsePreprocessedSource(lang) && + this->CompilePreprocessedSourceWithDefines(lang); bool const needDyndep = this->NeedDyndep(lang); - cmMakefile* mf = this->GetMakefile(); - std::string flags = "$FLAGS"; std::string responseFlag; @@ -517,9 +526,14 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang) // Preprocessing and compilation use the same flags. std::string ppFlags = flags; - // Move preprocessor definitions to the preprocessor rule. - ppVars.Defines = vars.Defines; - vars.Defines = ""; + if (!compilePPWithDefines) { + // Move preprocessor definitions to the preprocessor rule. + ppVars.Defines = vars.Defines; + vars.Defines = ""; + } else { + // Copy preprocessor definitions to the preprocessor rule. + ppVars.Defines = vars.Defines; + } // Copy include directories to the preprocessor rule. The Fortran // compilation rule still needs them for the INCLUDE directive. @@ -1011,6 +1025,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( ppBuild.RspFile = ppFileName + ".rsp"; bool const compilePP = this->UsePreprocessedSource(language); + bool const compilePPWithDefines = + compilePP && this->CompilePreprocessedSourceWithDefines(language); if (compilePP) { // Move compilation dependencies to the preprocessing build statement. std::swap(ppBuild.ExplicitDeps, objBuild.ExplicitDeps); @@ -1039,7 +1055,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( this->LocalGenerator->AppendFlags(vars["FLAGS"], postFlag); } - if (compilePP) { + if (compilePP && !compilePPWithDefines) { // Move preprocessor definitions to the preprocessor build statement. std::swap(ppBuild.Variables["DEFINES"], vars["DEFINES"]); } else { diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index a99d8e7..e304bc7 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -70,6 +70,7 @@ protected: std::string LanguageDyndepRule(std::string const& lang) const; bool NeedDyndep(std::string const& lang) const; bool UsePreprocessedSource(std::string const& lang) const; + bool CompilePreprocessedSourceWithDefines(std::string const& lang) const; std::string OrderDependsTargetForTarget(); diff --git a/Tests/FortranOnly/CMakeLists.txt b/Tests/FortranOnly/CMakeLists.txt index 45372dd..de887fa 100644 --- a/Tests/FortranOnly/CMakeLists.txt +++ b/Tests/FortranOnly/CMakeLists.txt @@ -112,3 +112,11 @@ if("${CMAKE_GENERATOR}" MATCHES "Makefile" AND CMAKE_MAKE_PROGRAM) ) endif() endif() + +# Test that with Intel Fortran we always compile with preprocessor +# defines even if splitting the preprocessing and compilation steps. +if(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") + add_executable(IntelIfDef IntelIfDef.f) + set_property(TARGET IntelIfDef PROPERTY Fortran_FORMAT FIXED) + target_compile_definitions(IntelIfDef PRIVATE SOME_DEF) +endif() diff --git a/Tests/FortranOnly/IntelIfDef.f b/Tests/FortranOnly/IntelIfDef.f new file mode 100644 index 0000000..d7a73d1 --- /dev/null +++ b/Tests/FortranOnly/IntelIfDef.f @@ -0,0 +1,3 @@ + INCLUDE 'IntelIfDef.inc' + PROGRAM IntelIfDef + END diff --git a/Tests/FortranOnly/IntelIfDef.inc b/Tests/FortranOnly/IntelIfDef.inc new file mode 100644 index 0000000..52edafa --- /dev/null +++ b/Tests/FortranOnly/IntelIfDef.inc @@ -0,0 +1,3 @@ +CDEC$ IF .NOT. DEFINED(SOME_DEF) +CDEC$ INCLUDE 'SOME_DEF not defined' +CDEC$ END IF ----------------------------------------------------------------------- Summary of changes: Modules/Compiler/Intel-Fortran.cmake | 2 ++ Source/cmNinjaTargetGenerator.cxx | 28 ++++++++++++++++++++++------ Source/cmNinjaTargetGenerator.h | 1 + Tests/FortranOnly/CMakeLists.txt | 8 ++++++++ Tests/FortranOnly/IntelIfDef.f | 3 +++ Tests/FortranOnly/IntelIfDef.inc | 3 +++ 6 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 Tests/FortranOnly/IntelIfDef.f create mode 100644 Tests/FortranOnly/IntelIfDef.inc hooks/post-receive -- CMake From kwrobot at kitware.com Wed Sep 4 09:01:50 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 4 Sep 2019 09:01:50 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-975-g09032f0 Message-ID: <20190904130150.B593EFAAE3@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 09032f09f8d2b4f7af658060ef434083f9d6a0d4 (commit) via 7b50b05aa9f162388fc9f57899baffdafad7d4af (commit) via 62e5f722899cfa7c51791be7697c9030aee3a19b (commit) via 383bf3b5e7609621719a8923b65d003087789e98 (commit) from efbd50383386c00cde63a7b67672b8487b00980f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=09032f09f8d2b4f7af658060ef434083f9d6a0d4 commit 09032f09f8d2b4f7af658060ef434083f9d6a0d4 Merge: 7b50b05 383bf3b Author: Brad King AuthorDate: Wed Sep 4 12:53:49 2019 +0000 Commit: Kitware Robot CommitDate: Wed Sep 4 08:53:59 2019 -0400 Merge topic 'pch-fix-vs-test' 383bf3b5e7 Precompile Headers: Fix Visual Studio 10 unit test Acked-by: Kitware Robot Merge-request: !3770 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7b50b05aa9f162388fc9f57899baffdafad7d4af commit 7b50b05aa9f162388fc9f57899baffdafad7d4af Merge: efbd503 62e5f72 Author: Brad King AuthorDate: Wed Sep 4 12:52:32 2019 +0000 Commit: Kitware Robot CommitDate: Wed Sep 4 08:52:45 2019 -0400 Merge topic 'tidy-use-using' 62e5f72289 clang-tidy: Replace typedef with using Acked-by: Kitware Robot Merge-request: !3731 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=62e5f722899cfa7c51791be7697c9030aee3a19b commit 62e5f722899cfa7c51791be7697c9030aee3a19b Author: Regina Pfeifer AuthorDate: Fri Aug 23 23:25:56 2019 +0200 Commit: Brad King CommitDate: Tue Sep 3 13:21:26 2019 -0400 clang-tidy: Replace typedef with using diff --git a/Source/CPack/cmCPackFreeBSDGenerator.cxx b/Source/CPack/cmCPackFreeBSDGenerator.cxx index a35977c..bbba8a1 100644 --- a/Source/CPack/cmCPackFreeBSDGenerator.cxx +++ b/Source/CPack/cmCPackFreeBSDGenerator.cxx @@ -131,7 +131,7 @@ public: class ManifestKeyListValue : public ManifestKey { public: - typedef std::vector VList; + using VList = std::vector; VList value; ManifestKeyListValue(const std::string& k) diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 69dac88..b4b320d 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -157,7 +157,7 @@ int main(int argc, char const* const* argv) cmsys::CommandLineArguments arg; arg.Initialize(argc, argv); - typedef cmsys::CommandLineArguments argT; + using argT = cmsys::CommandLineArguments; // Help arguments arg.AddArgument("--help", argT::NO_ARGUMENT, &help, "CPack help"); arg.AddArgument("--help-full", argT::SPACE_ARGUMENT, &helpFull, diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx index b957856..52dc0ac 100644 --- a/Source/CTest/cmCTestBZR.cxx +++ b/Source/CTest/cmCTestBZR.cxx @@ -200,8 +200,8 @@ public: private: cmCTestBZR* BZR; - typedef cmCTestBZR::Revision Revision; - typedef cmCTestBZR::Change Change; + using Revision = cmCTestBZR::Revision; + using Change = cmCTestBZR::Change; Revision Rev; std::vector Changes; Change CurChange; diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx index 560c169..b9b90c8 100644 --- a/Source/CTest/cmCTestCVS.cxx +++ b/Source/CTest/cmCTestCVS.cxx @@ -105,7 +105,7 @@ bool cmCTestCVS::UpdateImpl() class cmCTestCVS::LogParser : public cmCTestVC::LineParser { public: - typedef cmCTestCVS::Revision Revision; + using Revision = cmCTestCVS::Revision; LogParser(cmCTestCVS* cvs, const char* prefix, std::vector& revs) : CVS(cvs) , Revisions(revs) diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index f7319ef..3ae464d 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -333,7 +333,7 @@ public: this->SetLog(&git->Log, prefix); } - typedef cmCTestGIT::Change Change; + using Change = cmCTestGIT::Change; std::vector Changes; protected: @@ -456,7 +456,7 @@ public: } private: - typedef cmCTestGIT::Revision Revision; + using Revision = cmCTestGIT::Revision; enum SectionType { SectionHeader, diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx index ba2252a..297077e 100644 --- a/Source/CTest/cmCTestHG.cxx +++ b/Source/CTest/cmCTestHG.cxx @@ -174,8 +174,8 @@ public: private: cmCTestHG* HG; - typedef cmCTestHG::Revision Revision; - typedef cmCTestHG::Change Change; + using Revision = cmCTestHG::Revision; + using Change = cmCTestHG::Change; Revision Rev; std::vector Changes; Change CurChange; diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index 64354e8..9bca7cb 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -204,8 +204,8 @@ private: cmsys::RegularExpression RegexDiff; cmCTestP4* P4; - typedef cmCTestP4::Revision Revision; - typedef cmCTestP4::Change Change; + using Revision = cmCTestP4::Revision; + using Change = cmCTestP4::Change; std::vector Changes; enum SectionType { diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index dc1472b..6d8077f 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -307,8 +307,8 @@ private: cmCTestSVN* SVN; cmCTestSVN::SVNInfo& SVNRepo; - typedef cmCTestSVN::Revision Revision; - typedef cmCTestSVN::Change Change; + using Revision = cmCTestSVN::Revision; + using Change = cmCTestSVN::Change; Revision Rev; std::vector Changes; Change CurChange; diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index a178b44..f215911 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -26,7 +26,7 @@ #define SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT 120 -typedef std::vector cmCTestSubmitHandlerVectorOfChar; +using cmCTestSubmitHandlerVectorOfChar = std::vector; class cmCTestSubmitHandler::ResponseParser : public cmXMLParser { diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index b90209e..2b5a406 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -939,9 +939,9 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const // Prepare some maps to help us find setup and cleanup tests for // any given fixture - typedef ListOfTests::const_iterator TestIterator; + using TestIterator = ListOfTests::const_iterator; typedef std::multimap FixtureDependencies; - typedef FixtureDependencies::const_iterator FixtureDepsIterator; + using FixtureDepsIterator = FixtureDependencies::const_iterator; FixtureDependencies fixtureSetups; FixtureDependencies fixtureCleanups; diff --git a/Source/CTest/cmParseBlanketJSCoverage.cxx b/Source/CTest/cmParseBlanketJSCoverage.cxx index b74decb..191100c 100644 --- a/Source/CTest/cmParseBlanketJSCoverage.cxx +++ b/Source/CTest/cmParseBlanketJSCoverage.cxx @@ -13,8 +13,8 @@ class cmParseBlanketJSCoverage::JSONParser { public: - typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector - FileLinesType; + using FileLinesType = + cmCTestCoverageHandlerContainer::SingleFileCoverageVector; JSONParser(cmCTestCoverageHandlerContainer& cont) : Coverage(cont) { diff --git a/Source/CTest/cmParseCoberturaCoverage.cxx b/Source/CTest/cmParseCoberturaCoverage.cxx index e0186c9..e4f353b 100644 --- a/Source/CTest/cmParseCoberturaCoverage.cxx +++ b/Source/CTest/cmParseCoberturaCoverage.cxx @@ -142,8 +142,8 @@ private: bool InSource = false; bool SkipThisClass = false; std::vector FilePaths; - typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector - FileLinesType; + using FileLinesType = + cmCTestCoverageHandlerContainer::SingleFileCoverageVector; cmCTest* CTest; cmCTestCoverageHandlerContainer& Coverage; std::string CurFileName; diff --git a/Source/CTest/cmParseDelphiCoverage.cxx b/Source/CTest/cmParseDelphiCoverage.cxx index 9eda6f8..e8a184a 100644 --- a/Source/CTest/cmParseDelphiCoverage.cxx +++ b/Source/CTest/cmParseDelphiCoverage.cxx @@ -12,8 +12,8 @@ class cmParseDelphiCoverage::HTMLParser { public: - typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector - FileLinesType; + using FileLinesType = + cmCTestCoverageHandlerContainer::SingleFileCoverageVector; HTMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont) : CTest(ctest) , Coverage(cont) diff --git a/Source/CTest/cmParseJacocoCoverage.cxx b/Source/CTest/cmParseJacocoCoverage.cxx index 374acad..6a2d0cc 100644 --- a/Source/CTest/cmParseJacocoCoverage.cxx +++ b/Source/CTest/cmParseJacocoCoverage.cxx @@ -133,8 +133,8 @@ private: std::string FilePath; std::string PackagePath; std::string PackageName; - typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector - FileLinesType; + using FileLinesType = + cmCTestCoverageHandlerContainer::SingleFileCoverageVector; cmCTest* CTest; cmCTestCoverageHandlerContainer& Coverage; }; diff --git a/Source/cmAffinity.cxx b/Source/cmAffinity.cxx index 09b0298..fa5e4b9 100644 --- a/Source/cmAffinity.cxx +++ b/Source/cmAffinity.cxx @@ -20,7 +20,7 @@ # include # endif # if defined(__linux__) -typedef cpu_set_t cm_cpuset_t; +using cm_cpuset_t = cpu_set_t; # else typedef cpuset_t cm_cpuset_t; # endif diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h index 59aa86f..6775f9d 100644 --- a/Source/cmAlgorithms.h +++ b/Source/cmAlgorithms.h @@ -115,7 +115,7 @@ FwdIt RemoveN(FwdIt i1, FwdIt i2, size_t n) template struct BinarySearcher { - typedef typename Range::value_type argument_type; + using argument_type = typename Range::value_type; BinarySearcher(Range const& r) : m_range(r) { @@ -132,8 +132,8 @@ private: } class cmListFileBacktrace; -typedef cmRange::const_iterator> - cmBacktraceRange; +using cmBacktraceRange = + cmRange::const_iterator>; template void cmDeleteAll(Range const& r) diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index a063fd9..a6c25e1 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -333,7 +333,7 @@ bool cmArchiveWrite::AddData(const char* file, size_t size) char buffer[16384]; size_t nleft = size; while (nleft > 0) { - typedef std::streamsize ssize_type; + using ssize_type = std::streamsize; size_t const nnext = nleft > sizeof(buffer) ? sizeof(buffer) : nleft; ssize_type const nnext_s = static_cast(nnext); fin.read(buffer, nnext_s); diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index b20f595..e814d67 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -490,9 +490,9 @@ class cmCPluginAPISourceFileMap : public std::map { public: - typedef std::map derived; - typedef derived::iterator iterator; - typedef derived::value_type value_type; + using derived = std::map; + using iterator = derived::iterator; + using value_type = derived::value_type; cmCPluginAPISourceFileMap() = default; ~cmCPluginAPISourceFileMap() { diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 7fe3455..41dac85 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -41,7 +41,7 @@ class cmXMLWriter; class cmCTest { public: - typedef cmProcessOutput::Encoding Encoding; + using Encoding = cmProcessOutput::Encoding; /** Enumerate parts of the testing and submission process. */ enum Part { diff --git a/Source/cmComputeComponentGraph.h b/Source/cmComputeComponentGraph.h index 8cd4fe7..5493769 100644 --- a/Source/cmComputeComponentGraph.h +++ b/Source/cmComputeComponentGraph.h @@ -24,9 +24,9 @@ class cmComputeComponentGraph { public: // Represent the graph with an adjacency list. - typedef cmGraphNodeList NodeList; - typedef cmGraphEdgeList EdgeList; - typedef cmGraphAdjacencyList Graph; + using NodeList = cmGraphNodeList; + using EdgeList = cmGraphEdgeList; + using Graph = cmGraphAdjacencyList; cmComputeComponentGraph(Graph const& input); ~cmComputeComponentGraph(); diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 839c27a..f0ac771 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -44,7 +44,7 @@ public: bool IsFlag = false; }; - typedef std::vector EntryVector; + using EntryVector = std::vector; EntryVector const& Compute(); void SetOldLinkDirMode(bool b); @@ -111,9 +111,9 @@ private: void InferDependencies(); // Ordering constraint graph adjacency list. - typedef cmGraphNodeList NodeList; - typedef cmGraphEdgeList EdgeList; - typedef cmGraphAdjacencyList Graph; + using NodeList = cmGraphNodeList; + using EdgeList = cmGraphEdgeList; + using Graph = cmGraphAdjacencyList; Graph EntryConstraintGraph; void CleanConstraintGraph(); void DisplayConstraintGraph(); diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 784d3fa..0f71381 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -42,7 +42,7 @@ public: bool IsPath = true; cmGeneratorTarget const* Target = nullptr; }; - typedef std::vector ItemVector; + using ItemVector = std::vector; ItemVector const& GetItems() const; std::vector const& GetDirectories() const; std::vector const& GetDepends() const; diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h index 3840bd7..6087574 100644 --- a/Source/cmComputeTargetDepends.h +++ b/Source/cmComputeTargetDepends.h @@ -70,9 +70,9 @@ private: // Represent the target dependency graph. The entry at each // top-level index corresponds to a depender whose dependencies are // listed. - typedef cmGraphNodeList NodeList; - typedef cmGraphEdgeList EdgeList; - typedef cmGraphAdjacencyList Graph; + using NodeList = cmGraphNodeList; + using EdgeList = cmGraphEdgeList; + using Graph = cmGraphAdjacencyList; Graph InitialGraph; Graph FinalGraph; void DisplayGraph(Graph const& graph, const std::string& name); diff --git a/Source/cmConditionEvaluator.h b/Source/cmConditionEvaluator.h index 59e1396..082534c 100644 --- a/Source/cmConditionEvaluator.h +++ b/Source/cmConditionEvaluator.h @@ -19,7 +19,7 @@ class cmMakefile; class cmConditionEvaluator { public: - typedef std::list cmArgumentList; + using cmArgumentList = std::list; cmConditionEvaluator(cmMakefile& makefile, cmListFileContext context, cmListFileBacktrace bt); diff --git a/Source/cmCustomCommandLines.h b/Source/cmCustomCommandLines.h index 36838f2..35a15ba 100644 --- a/Source/cmCustomCommandLines.h +++ b/Source/cmCustomCommandLines.h @@ -12,18 +12,18 @@ class cmCustomCommandLine : public std::vector { public: - typedef std::vector Superclass; - typedef Superclass::iterator iterator; - typedef Superclass::const_iterator const_iterator; + using Superclass = std::vector; + using iterator = Superclass::iterator; + using const_iterator = Superclass::const_iterator; }; /** Data structure to represent a list of command lines. */ class cmCustomCommandLines : public std::vector { public: - typedef std::vector Superclass; - typedef Superclass::iterator iterator; - typedef Superclass::const_iterator const_iterator; + using Superclass = std::vector; + using iterator = Superclass::iterator; + using const_iterator = Superclass::const_iterator; }; #endif diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index b4d6419..008821d 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -24,7 +24,7 @@ */ class cmDefinitions { - typedef cmLinkedTree::iterator StackIter; + using StackIter = cmLinkedTree::iterator; public: // -- Static member functions diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index 6c77db9..8df9938 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -170,7 +170,7 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends, } // Actually write dependencies to the streams. - typedef cmDependsFortranInternals::ObjectInfoMap ObjectInfoMap; + using ObjectInfoMap = cmDependsFortranInternals::ObjectInfoMap; ObjectInfoMap const& objInfo = this->Internal->ObjectInfo; for (auto const& i : objInfo) { if (!this->WriteDependenciesReal(i.first, i.second, mod_dir, stamp_dir, @@ -222,7 +222,7 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends, void cmDependsFortran::LocateModules() { // Collect the set of modules provided and required by all sources. - typedef cmDependsFortranInternals::ObjectInfoMap ObjectInfoMap; + using ObjectInfoMap = cmDependsFortranInternals::ObjectInfoMap; ObjectInfoMap const& objInfo = this->Internal->ObjectInfo; for (auto const& infoI : objInfo) { cmFortranSourceInfo const& info = infoI.second; @@ -303,7 +303,7 @@ void cmDependsFortran::ConsiderModule(const std::string& name, const std::string& stampDir) { // Locate each required module. - typedef cmDependsFortranInternals::TargetRequiresMap TargetRequiresMap; + using TargetRequiresMap = cmDependsFortranInternals::TargetRequiresMap; TargetRequiresMap::iterator required = this->Internal->TargetRequires.find(name); if (required != this->Internal->TargetRequires.end() && @@ -321,7 +321,7 @@ bool cmDependsFortran::WriteDependenciesReal(std::string const& obj, std::ostream& makeDepends, std::ostream& internalDepends) { - typedef cmDependsFortranInternals::TargetRequiresMap TargetRequiresMap; + using TargetRequiresMap = cmDependsFortranInternals::TargetRequiresMap; // Get the source file for this object. std::string const& src = info.Source; diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index 096016d..425f1a8 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -102,7 +102,7 @@ void cmELFByteSwap(T& x) class cmELFInternal { public: - typedef cmELF::StringEntry StringEntry; + using StringEntry = cmELF::StringEntry; enum ByteOrderType { ByteOrderMSB, @@ -200,11 +200,11 @@ protected: // Configure the implementation template for 32-bit ELF files. struct cmELFTypes32 { - typedef Elf32_Ehdr ELF_Ehdr; - typedef Elf32_Shdr ELF_Shdr; - typedef Elf32_Dyn ELF_Dyn; - typedef Elf32_Half ELF_Half; - typedef KWIML_INT_uint32_t tagtype; + using ELF_Ehdr = Elf32_Ehdr; + using ELF_Shdr = Elf32_Shdr; + using ELF_Dyn = Elf32_Dyn; + using ELF_Half = Elf32_Half; + using tagtype = ::uint32_t; static const char* GetName() { return "32-bit"; } }; @@ -212,11 +212,11 @@ struct cmELFTypes32 #ifndef _SCO_DS struct cmELFTypes64 { - typedef Elf64_Ehdr ELF_Ehdr; - typedef Elf64_Shdr ELF_Shdr; - typedef Elf64_Dyn ELF_Dyn; - typedef Elf64_Half ELF_Half; - typedef KWIML_INT_uint64_t tagtype; + using ELF_Ehdr = Elf64_Ehdr; + using ELF_Shdr = Elf64_Shdr; + using ELF_Dyn = Elf64_Dyn; + using ELF_Half = Elf64_Half; + using tagtype = ::uint64_t; static const char* GetName() { return "64-bit"; } }; #endif @@ -227,11 +227,11 @@ class cmELFInternalImpl : public cmELFInternal { public: // Copy the ELF file format types from our configuration parameter. - typedef typename Types::ELF_Ehdr ELF_Ehdr; - typedef typename Types::ELF_Shdr ELF_Shdr; - typedef typename Types::ELF_Dyn ELF_Dyn; - typedef typename Types::ELF_Half ELF_Half; - typedef typename Types::tagtype tagtype; + using ELF_Ehdr = typename Types::ELF_Ehdr; + using ELF_Shdr = typename Types::ELF_Shdr; + using ELF_Dyn = typename Types::ELF_Dyn; + using ELF_Half = typename Types::ELF_Half; + using tagtype = typename Types::tagtype; // Construct with a stream and byte swap indicator. cmELFInternalImpl(cmELF* external, std::unique_ptr fin, diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx index 7f41640..74e9c55 100644 --- a/Source/cmExecProgramCommand.cxx +++ b/Source/cmExecProgramCommand.cxx @@ -11,7 +11,7 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -typedef cmProcessOutput::Encoding Encoding; +using Encoding = cmProcessOutput::Encoding; namespace { bool RunCommand(std::string command, std::string& output, int& retVal, diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 5589537..36a7dc3 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -1421,7 +1421,7 @@ bool HandleNativePathCommand(std::vector const& args, #if !defined(CMAKE_BOOTSTRAP) // Stuff for curl download/upload -typedef std::vector cmFileCommandVectorOfChar; +using cmFileCommandVectorOfChar = std::vector; size_t cmWriteToFileCallback(void* ptr, size_t size, size_t nmemb, void* data) { diff --git a/Source/cmFileLockPool.h b/Source/cmFileLockPool.h index 41203ba..dae68dd 100644 --- a/Source/cmFileLockPool.h +++ b/Source/cmFileLockPool.h @@ -72,17 +72,17 @@ private: bool IsAlreadyLocked(const std::string& filename) const; private: - typedef std::vector List; - typedef List::iterator It; - typedef List::const_iterator CIt; + using List = std::vector; + using It = List::iterator; + using CIt = List::const_iterator; List Locks; }; - typedef std::vector List; + using List = std::vector; - typedef List::iterator It; - typedef List::const_iterator CIt; + using It = List::iterator; + using CIt = List::const_iterator; List FunctionScopes; List FileScopes; diff --git a/Source/cmFileLockResult.h b/Source/cmFileLockResult.h index 8b4929a..c452814 100644 --- a/Source/cmFileLockResult.h +++ b/Source/cmFileLockResult.h @@ -21,7 +21,7 @@ public: #if defined(_WIN32) typedef DWORD Error; #else - typedef int Error; + using Error = int; #endif /** diff --git a/Source/cmFileTime.h b/Source/cmFileTime.h index d4de4e0..e9a8559 100644 --- a/Source/cmFileTime.h +++ b/Source/cmFileTime.h @@ -14,7 +14,7 @@ class cmFileTime { public: - typedef long long NSC; + using NSC = long long; static constexpr NSC NsPerS = 1000000000; cmFileTime() = default; diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index 924a14e..92c64c8 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -191,7 +191,7 @@ struct cmFindLibraryHelper std::string SuffixRegexStr; // Keep track of the best library file found so far. - typedef std::vector::size_type size_type; + using size_type = std::vector::size_type; std::string BestPath; // Support for OpenBSD shared library naming: lib.so.. diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index f6645ae..d57b38a 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -235,8 +235,8 @@ namespace std { template <> struct hash { - typedef cmFindPackageCommand::ConfigFileInfo argument_type; - typedef size_t result_type; + using argument_type = cmFindPackageCommand::ConfigFileInfo; + using result_type = size_t; result_type operator()(argument_type const& s) const noexcept { diff --git a/Source/cmFortranParser.h b/Source/cmFortranParser.h index 6a33be5..825876c 100644 --- a/Source/cmFortranParser.h +++ b/Source/cmFortranParser.h @@ -15,7 +15,7 @@ #include /* size_t */ /* Forward declare parser object type. */ -typedef struct cmFortranParser_s cmFortranParser; +using cmFortranParser = struct cmFortranParser_s; /* Functions to enter/exit #include'd files in order. */ bool cmFortranParser_FilePush(cmFortranParser* parser, const char* fname); diff --git a/Source/cmGeneratedFileStream.h b/Source/cmGeneratedFileStream.h index 5b1eb51..3d94cdc 100644 --- a/Source/cmGeneratedFileStream.h +++ b/Source/cmGeneratedFileStream.h @@ -72,8 +72,8 @@ class cmGeneratedFileStream , public cmsys::ofstream { public: - typedef cmsys::ofstream Stream; - typedef codecvt::Encoding Encoding; + using Stream = cmsys::ofstream; + using Encoding = codecvt::Encoding; /** * This constructor prepares a default stream. The open method must diff --git a/Source/cmGeneratorExpressionParser.cxx b/Source/cmGeneratorExpressionParser.cxx index 304378d..e7effca 100644 --- a/Source/cmGeneratorExpressionParser.cxx +++ b/Source/cmGeneratorExpressionParser.cxx @@ -174,8 +174,8 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression( if (!parameters.empty()) { extendText(result, colonToken); - typedef std::vector EvaluatorVector; - typedef std::vector TokenVector; + using EvaluatorVector = std::vector; + using TokenVector = std::vector; std::vector::const_iterator pit = parameters.begin(); const std::vector::const_iterator pend = parameters.end(); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 8896e15..48ffcec 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -2602,7 +2602,7 @@ private: cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; cmGlobalGenerator const* GlobalGenerator; - typedef cmGeneratorTarget::SourceEntry SourceEntry; + using SourceEntry = cmGeneratorTarget::SourceEntry; SourceEntry* CurrentEntry; std::queue SourceQueue; std::set SourcesQueued; diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 830974d..36e5d0e 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -376,7 +376,7 @@ public: virtual std::string GetEditCacheCommand() const { return ""; } // Class to track a set of dependencies. - typedef cmTargetDependSet TargetDependSet; + using TargetDependSet = cmTargetDependSet; // what targets does the specified target depend on directly // via a target_link_libraries or add_dependencies @@ -476,7 +476,7 @@ public: int RecursionDepth; protected: - typedef std::vector GeneratorVector; + using GeneratorVector = std::vector; // for a project collect all its targets by following depend // information, and also collect all the targets void GetTargetSets(TargetDependSet& projectTargets, diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h index 98358c7..9b5bf63 100644 --- a/Source/cmGlobalGhsMultiGenerator.h +++ b/Source/cmGlobalGhsMultiGenerator.h @@ -153,7 +153,7 @@ class cmGlobalGhsMultiGenerator::OrderedTargetDependSet derived; public: - typedef cmGlobalGenerator::TargetDependSet TargetDependSet; + using TargetDependSet = cmGlobalGenerator::TargetDependSet; OrderedTargetDependSet(TargetDependSet const&, std::string const& first); }; diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 26ceedd..b355775 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -3,6 +3,7 @@ #include "cmGlobalVisualStudio7Generator.h" #include "cmGeneratedFileStream.h" +#include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmLocalVisualStudio7Generator.h" #include "cmMakefile.h" diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index f4c47ce..5e60108 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -4,6 +4,7 @@ #include "cmDocumentationEntry.h" #include "cmGeneratedFileStream.h" +#include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmLocalVisualStudio7Generator.h" #include "cmMakefile.h" diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 9ccad63..3097bec 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -74,9 +74,9 @@ protected: void GenerateScriptForConfigObjectLibrary(std::ostream& os, const std::string& config, Indent indent); - typedef void (cmInstallTargetGenerator::*TweakMethod)(std::ostream&, Indent, - const std::string&, - std::string const&); + using TweakMethod = void (cmInstallTargetGenerator::*)(std::ostream&, Indent, + const std::string&, + const std::string&); void AddTweak(std::ostream& os, Indent indent, const std::string& config, std::string const& file, TweakMethod tweak); void AddTweak(std::ostream& os, Indent indent, const std::string& config, diff --git a/Source/cmInstalledFile.cxx b/Source/cmInstalledFile.cxx index 1e6c385..11f6efb 100644 --- a/Source/cmInstalledFile.cxx +++ b/Source/cmInstalledFile.cxx @@ -3,6 +3,7 @@ #include "cmInstalledFile.h" #include "cmAlgorithms.h" +#include "cmGeneratorExpression.h" #include "cmListFileCache.h" #include "cmMakefile.h" #include "cmStringAlgorithms.h" diff --git a/Source/cmInstalledFile.h b/Source/cmInstalledFile.h index eb827be..e00e666 100644 --- a/Source/cmInstalledFile.h +++ b/Source/cmInstalledFile.h @@ -5,13 +5,12 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include "cmGeneratorExpression.h" - #include #include #include #include +class cmCompiledGeneratorExpression; class cmMakefile; /** \class cmInstalledFile @@ -22,10 +21,10 @@ class cmMakefile; class cmInstalledFile { public: - typedef std::unique_ptr - CompiledGeneratorExpressionPtrType; + using CompiledGeneratorExpressionPtrType = + std::unique_ptr; - typedef std::vector ExpressionVectorType; + using ExpressionVectorType = std::vector; struct Property { diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx index 5e3c790..91c551f 100644 --- a/Source/cmLinkLineComputer.cxx +++ b/Source/cmLinkLineComputer.cxx @@ -56,7 +56,7 @@ std::string cmLinkLineComputer::ConvertToLinkReference( std::string cmLinkLineComputer::ComputeLinkLibs(cmComputeLinkInformation& cli) { std::string linkLibs; - typedef cmComputeLinkInformation::ItemVector ItemVector; + using ItemVector = cmComputeLinkInformation::ItemVector; ItemVector const& items = cli.GetItems(); for (auto const& item : items) { if (item.Target && diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx index 96af388..9c0e20f 100644 --- a/Source/cmLinkLineDeviceComputer.cxx +++ b/Source/cmLinkLineDeviceComputer.cxx @@ -51,7 +51,7 @@ bool cmLinkLineDeviceComputer::ComputeRequiresDeviceLinking( { // Determine if this item might requires device linking. // For this we only consider targets - typedef cmComputeLinkInformation::ItemVector ItemVector; + using ItemVector = cmComputeLinkInformation::ItemVector; ItemVector const& items = cli.GetItems(); std::string config = cli.GetConfig(); for (auto const& item : items) { @@ -78,7 +78,7 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries( // with device symbols only needs to be listed once as it doesn't // care about link order. std::set emitted; - typedef cmComputeLinkInformation::ItemVector ItemVector; + using ItemVector = cmComputeLinkInformation::ItemVector; ItemVector const& items = cli.GetItems(); std::string config = cli.GetConfig(); bool skipItemAfterFramework = false; diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h index 099fb6d..8b91162 100644 --- a/Source/cmLinkedTree.h +++ b/Source/cmLinkedTree.h @@ -27,9 +27,9 @@ template class cmLinkedTree { - typedef typename std::vector::size_type PositionType; - typedef T* PointerType; - typedef T& ReferenceType; + using PositionType = typename std::vector::size_type; + using PointerType = T*; + using ReferenceType = T&; public: class iterator diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index d2c051e..57eeedb 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -1080,7 +1080,7 @@ public: }; protected: - typedef std::string (*StringFilter)(const std::string& in); + using StringFilter = std::string (*)(const std::string&); StringFilter GetCompareFilter(Compare compare) { return (compare == Compare::FILE_BASENAME) ? cmSystemTools::GetFilenameName diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index df1a5bd..f0145c5 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -323,7 +323,7 @@ void cmLocalGenerator::GenerateTestFiles() tester->Compute(this); tester->Generate(fout, config, configurationTypes); } - typedef std::vector vec_t; + using vec_t = std::vector; vec_t const& children = this->Makefile->GetStateSnapshot().GetChildren(); std::string parentBinDir = this->GetCurrentBinaryDirectory(); for (cmStateSnapshot const& i : children) { diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index f88c3e9..357ccc8 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -4,6 +4,7 @@ #include "cmCustomCommand.h" #include "cmCustomCommandGenerator.h" +#include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmGlobalVisualStudio7Generator.h" #include "cmMakefile.h" diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 4b26ec6..dfe0086 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4321,7 +4321,7 @@ bool cmMakefile::HasCMP0054AlreadyBeenReported( void cmMakefile::RecordPolicies(cmPolicies::PolicyMap& pm) { /* Record the setting of every policy. */ - typedef cmPolicies::PolicyID PolicyID; + using PolicyID = cmPolicies::PolicyID; for (PolicyID pid = cmPolicies::CMP0000; pid != cmPolicies::CMPCOUNT; pid = PolicyID(pid + 1)) { pm.Set(pid, this->GetPolicyStatus(pid)); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 6b9fa6b..09f53c9 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -385,7 +385,7 @@ public: } // -- List of targets - typedef std::unordered_map cmTargetMap; + using cmTargetMap = std::unordered_map; /** Get the target map */ cmTargetMap& GetTargets() { return this->Targets; } /** Get the target map - const version */ @@ -914,7 +914,7 @@ protected: mutable cmTargetMap Targets; std::map AliasTargets; - typedef std::vector SourceFileVec; + using SourceFileVec = std::vector; SourceFileVec SourceFiles; // Because cmSourceFile names are compared in a fuzzy way (see @@ -923,7 +923,7 @@ protected: // Name portion of the cmSourceFileLocation and then compare on the list of // cmSourceFiles that might match that name. Note that on platforms which // have a case-insensitive filesystem we store the key in all lowercase. - typedef std::unordered_map SourceFileMap; + using SourceFileMap = std::unordered_map; SourceFileMap SourceFileSearchIndex; // For "Known" paths we can store a direct filename to cmSourceFile map @@ -997,7 +997,7 @@ private: friend class cmParseFileScope; std::vector ImportedTargetsOwned; - typedef std::unordered_map TargetMap; + using TargetMap = std::unordered_map; TargetMap ImportedTargets; // Internal policy stack management. @@ -1039,7 +1039,7 @@ private: cmSourceFile* LinearGetSourceFileWithOutput(const std::string& cname) const; // A map for fast output to input look up. - typedef std::unordered_map OutputToSourceMap; + using OutputToSourceMap = std::unordered_map; OutputToSourceMap OutputToSource; void UpdateOutputToSourceMap(std::vector const& outputs, diff --git a/Source/cmNinjaTypes.h b/Source/cmNinjaTypes.h index 52c05b6..89afbbd 100644 --- a/Source/cmNinjaTypes.h +++ b/Source/cmNinjaTypes.h @@ -17,8 +17,8 @@ enum cmNinjaTargetDepends DependOnTargetOrdering }; -typedef std::vector cmNinjaDeps; -typedef std::set cmNinjaOuts; +using cmNinjaDeps = std::vector; +using cmNinjaOuts = std::set; typedef std::map cmNinjaVars; class cmNinjaRule diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index 187f0ab..1a854dc 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -36,7 +36,7 @@ public: /** * The set of files on which this one depends. */ - typedef std::set DependencySetType; + using DependencySetType = std::set; DependencySetType DependencySet; /** diff --git a/Source/cmParseArgumentsCommand.cxx b/Source/cmParseArgumentsCommand.cxx index aad9f74..a4dd70d 100644 --- a/Source/cmParseArgumentsCommand.cxx +++ b/Source/cmParseArgumentsCommand.cxx @@ -37,10 +37,10 @@ static std::string JoinList(std::vector const& arg, bool escape) namespace { -typedef std::map options_map; -typedef std::map single_map; -typedef std::map> multi_map; -typedef std::set options_set; +using options_map = std::map; +using single_map = std::map; +using multi_map = std::map>; +using options_set = std::set; struct UserArgumentParser : public cmArgumentParser { diff --git a/Source/cmProcessTools.h b/Source/cmProcessTools.h index 7616316..c205a8f 100644 --- a/Source/cmProcessTools.h +++ b/Source/cmProcessTools.h @@ -17,7 +17,7 @@ class cmProcessTools { public: - typedef cmProcessOutput::Encoding Encoding; + using Encoding = cmProcessOutput::Encoding; /** Abstract interface for process output parsers. */ class OutputParser { diff --git a/Source/cmQtAutoGen.cxx b/Source/cmQtAutoGen.cxx index d890f8e..83df335 100644 --- a/Source/cmQtAutoGen.cxx +++ b/Source/cmQtAutoGen.cxx @@ -24,8 +24,8 @@ void MergeOptions(std::vector& baseOpts, std::vector const& newOpts, std::initializer_list valueOpts, bool isQt5) { - typedef std::vector::iterator Iter; - typedef std::vector::const_iterator CIter; + using Iter = std::vector::iterator; + using CIter = std::vector::const_iterator; if (newOpts.empty()) { return; } diff --git a/Source/cmQtAutoGen.h b/Source/cmQtAutoGen.h index 939ceb3..fb15586 100644 --- a/Source/cmQtAutoGen.h +++ b/Source/cmQtAutoGen.h @@ -50,7 +50,7 @@ public: std::string HelpOutput; std::vector ListOptions; }; - typedef std::shared_ptr CompilerFeaturesHandle; + using CompilerFeaturesHandle = std::shared_ptr; /// @brief AutoGen generator type enum class GenT diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h index 65666a6..84a27e4 100644 --- a/Source/cmQtAutoGenInitializer.h +++ b/Source/cmQtAutoGenInitializer.h @@ -55,7 +55,7 @@ public: bool MocIt = false; bool UicIt = false; }; - typedef std::unique_ptr MUFileHandle; + using MUFileHandle = std::unique_ptr; /// @brief Abstract moc/uic/rcc generator variables base class struct GenVarsT diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx index 3bcc1c9..80b8741 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -169,7 +169,7 @@ bool cmQtAutoGenerator::FileRead(std::string& content, return false; } content.reserve(length); - typedef std::istreambuf_iterator IsIt; + using IsIt = std::istreambuf_iterator; content.assign(IsIt{ ifs }, IsIt{}); if (!ifs) { content.clear(); diff --git a/Source/cmQtAutoMocUic.h b/Source/cmQtAutoMocUic.h index f676c57..076e460 100644 --- a/Source/cmQtAutoMocUic.h +++ b/Source/cmQtAutoMocUic.h @@ -106,7 +106,7 @@ public: std::vector Depends; } Uic; }; - typedef std::shared_ptr FileHandleT; + using FileHandleT = std::shared_ptr; typedef std::pair GetOrInsertT; public: @@ -146,7 +146,7 @@ public: bool Moc = false; bool Uic = false; }; - typedef std::shared_ptr SourceFileHandleT; + using SourceFileHandleT = std::shared_ptr; typedef std::map SourceFileMapT; /** @@ -159,7 +159,7 @@ public: std::string IncludeString; std::vector IncluderFiles; }; - typedef std::shared_ptr MappingHandleT; + using MappingHandleT = std::shared_ptr; typedef std::map MappingMapT; /** diff --git a/Source/cmScriptGenerator.h b/Source/cmScriptGenerator.h index e334d5b..eee331f 100644 --- a/Source/cmScriptGenerator.h +++ b/Source/cmScriptGenerator.h @@ -56,7 +56,7 @@ public: std::vector const& configurationTypes); protected: - typedef cmScriptGeneratorIndent Indent; + using Indent = cmScriptGeneratorIndent; virtual void GenerateScript(std::ostream& os); virtual void GenerateScriptConfigs(std::ostream& os, Indent indent); virtual void GenerateScriptActions(std::ostream& os, Indent indent); diff --git a/Source/cmSourceGroupCommand.h b/Source/cmSourceGroupCommand.h index eec4ec0..45438a9 100644 --- a/Source/cmSourceGroupCommand.h +++ b/Source/cmSourceGroupCommand.h @@ -41,7 +41,7 @@ public: private: typedef std::map> ParsedArguments; - typedef std::vector ExpectedOptions; + using ExpectedOptions = std::vector; ExpectedOptions getExpectedOptions() const; diff --git a/Source/cmStatePrivate.h b/Source/cmStatePrivate.h index ec0ed6c..4efaf97 100644 --- a/Source/cmStatePrivate.h +++ b/Source/cmStatePrivate.h @@ -48,7 +48,7 @@ struct cmStateDetail::SnapshotDataType struct cmStateDetail::PolicyStackEntry : public cmPolicies::PolicyMap { - typedef cmPolicies::PolicyMap derived; + using derived = cmPolicies::PolicyMap; PolicyStackEntry(bool w = false) : Weak(w) { diff --git a/Source/cmStateTypes.h b/Source/cmStateTypes.h index 7d6158e..d089ea7 100644 --- a/Source/cmStateTypes.h +++ b/Source/cmStateTypes.h @@ -10,7 +10,7 @@ namespace cmStateDetail { struct SnapshotDataType; -typedef cmLinkedTree::iterator PositionType; +using PositionType = cmLinkedTree::iterator; } namespace cmStateEnums { diff --git a/Source/cmString.hxx b/Source/cmString.hxx index 226ac67..050a2fd 100644 --- a/Source/cmString.hxx +++ b/Source/cmString.hxx @@ -714,7 +714,7 @@ template struct StringAdd { static const bool value = AsStringView::value; - typedef string_view temp_type; + using temp_type = string_view; template static temp_type temp(S&& s) { @@ -802,8 +802,8 @@ namespace std { template <> struct hash { - typedef cm::String argument_type; - typedef size_t result_type; + using argument_type = cm::String; + using result_type = size_t; result_type operator()(argument_type const& s) const noexcept { diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h index 5b8b878..7f442d8 100644 --- a/Source/cmStringAlgorithms.h +++ b/Source/cmStringAlgorithms.h @@ -16,7 +16,7 @@ #include /** String range type. */ -typedef cmRange::const_iterator> cmStringRange; +using cmStringRange = cmRange::const_iterator>; /** Callable string comparison struct. */ struct cmStrCmp diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 953a358..863db3f 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -25,8 +25,8 @@ class cmSystemTools : public cmsys::SystemTools { public: - typedef cmsys::SystemTools Superclass; - typedef cmProcessOutput::Encoding Encoding; + using Superclass = cmsys::SystemTools; + using Encoding = cmProcessOutput::Encoding; /** * Look for and replace registry values in a string diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 783c278..fa420af 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -108,7 +108,7 @@ public: //! how we identify a library, by name and type typedef std::pair LibraryID; - typedef std::vector LinkLibraryVectorType; + using LinkLibraryVectorType = std::vector; LinkLibraryVectorType const& GetOriginalLinkLibraries() const; //! Clear the dependency information recorded for this target, if any. diff --git a/Source/cmUVHandlePtr.h b/Source/cmUVHandlePtr.h index c09e4bf..3083b60 100644 --- a/Source/cmUVHandlePtr.h +++ b/Source/cmUVHandlePtr.h @@ -240,8 +240,8 @@ struct uv_tty_ptr : public uv_handle_ptr_ int init(uv_loop_t& loop, int fd, int readable, void* data = nullptr); }; -typedef uv_handle_ptr_ uv_stream_ptr; -typedef uv_handle_ptr_ uv_handle_ptr; +using uv_stream_ptr = uv_handle_ptr_; +using uv_handle_ptr = uv_handle_ptr_; #ifndef cmUVHandlePtr_cxx diff --git a/Source/cmUuid.cxx b/Source/cmUuid.cxx index 0dc6ca7..91c8af3 100644 --- a/Source/cmUuid.cxx +++ b/Source/cmUuid.cxx @@ -53,7 +53,7 @@ void cmUuid::CreateHashInput(std::vector const& uuidNamespace, std::string cmUuid::FromDigest(const unsigned char* digest, unsigned char version) const { - typedef unsigned char byte_t; + using byte_t = unsigned char; byte_t uuid[16] = { 0 }; memcpy(uuid, digest, 16); diff --git a/Source/cmVariableWatch.h b/Source/cmVariableWatch.h index acac2c1..32445d5 100644 --- a/Source/cmVariableWatch.h +++ b/Source/cmVariableWatch.h @@ -20,10 +20,9 @@ class cmMakefile; class cmVariableWatch { public: - typedef void (*WatchMethod)(const std::string& variable, int access_type, - void* client_data, const char* newValue, - const cmMakefile* mf); - typedef void (*DeleteData)(void* client_data); + using WatchMethod = void (*)(const std::string&, int, void*, const char*, + const cmMakefile*); + using DeleteData = void (*)(void*); cmVariableWatch(); ~cmVariableWatch(); @@ -77,7 +76,7 @@ protected: Pair& operator=(const Pair&) = delete; }; - typedef std::vector> VectorOfPairs; + using VectorOfPairs = std::vector>; typedef std::map StringToVectorOfPairs; StringToVectorOfPairs WatchMap; diff --git a/Source/cmWorkerPool.cxx b/Source/cmWorkerPool.cxx index baf326a..2e4d00b 100644 --- a/Source/cmWorkerPool.cxx +++ b/Source/cmWorkerPool.cxx @@ -25,10 +25,10 @@ class cmUVPipeBuffer { public: - typedef cmRange DataRange; - typedef std::function DataFunction; + using DataRange = cmRange; + using DataFunction = std::function; /// On error the ssize_t argument is a non zero libuv error code - typedef std::function EndFunction; + using EndFunction = std::function; public: /** diff --git a/Source/cmWorkerPool.h b/Source/cmWorkerPool.h index d708118..b541ce3 100644 --- a/Source/cmWorkerPool.h +++ b/Source/cmWorkerPool.h @@ -126,7 +126,7 @@ public: /** * Job handle type */ - typedef std::unique_ptr JobHandleT; + using JobHandleT = std::unique_ptr; /** * Fence job base class diff --git a/Source/cmXMLParser.h b/Source/cmXMLParser.h index 98ba049..1bc8d64 100644 --- a/Source/cmXMLParser.h +++ b/Source/cmXMLParser.h @@ -42,7 +42,7 @@ public: virtual int ParseChunk(const char* inputString, std::string::size_type length); virtual int CleanupParser(); - typedef void (*ReportFunction)(int, const char*, void*); + using ReportFunction = void (*)(int, const char*, void*); void SetErrorCallback(ReportFunction f, void* d) { this->ReportCallback = f; diff --git a/Source/cmake.h b/Source/cmake.h index 081e120..cc44b92 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -503,10 +503,10 @@ protected: void RunCheckForUnusedVariables(); int HandleDeleteCacheVariables(const std::string& var); - typedef std::vector RegisteredGeneratorsVector; + using RegisteredGeneratorsVector = std::vector; RegisteredGeneratorsVector Generators; - typedef std::vector - RegisteredExtraGeneratorsVector; + using RegisteredExtraGeneratorsVector = + std::vector; RegisteredExtraGeneratorsVector ExtraGenerators; void AddScriptingCommands(); void AddProjectCommands(); diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 071eec9..a79a2ff 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -339,8 +339,8 @@ static int HandleCppCheck(const std::string& runCmd, return ret; } -typedef int (*CoCompileHandler)(const std::string&, const std::string&, - const std::vector&); +using CoCompileHandler = int (*)(const std::string&, const std::string&, + const std::vector&); struct CoCompiler { diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx index b49803b..b1541e2 100644 --- a/Tests/CMakeLib/run_compile_commands.cxx +++ b/Tests/CMakeLib/run_compile_commands.cxx @@ -26,7 +26,7 @@ public: return emptyString; } }; - typedef std::vector TranslationUnitsType; + using TranslationUnitsType = std::vector; CompileCommandParser(std::istream& input) : Input(input) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=383bf3b5e7609621719a8923b65d003087789e98 commit 383bf3b5e7609621719a8923b65d003087789e98 Author: Cristian Adam AuthorDate: Mon Sep 2 14:43:23 2019 +0200 Commit: Cristian Adam CommitDate: Tue Sep 3 15:50:42 2019 +0200 Precompile Headers: Fix Visual Studio 10 unit test The unit test is more roboust, problems like c: vs C: or having relative paths of cmake_pch.cxx instead of absolute paths. diff --git a/Tests/RunCMake/VS10Project/VsPrecompileHeaders-check.cmake b/Tests/RunCMake/VS10Project/VsPrecompileHeaders-check.cmake index 82ca421..27842f9 100644 --- a/Tests/RunCMake/VS10Project/VsPrecompileHeaders-check.cmake +++ b/Tests/RunCMake/VS10Project/VsPrecompileHeaders-check.cmake @@ -1,13 +1,11 @@ -set(pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/cmake_pch.hxx") -set(pch_source "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/cmake_pch.cxx") +set(pch_header "CMakeFiles/tgt.dir/cmake_pch.hxx") +set(pch_source [=[CMakeFiles\\tgt.dir\\cmake_pch.cxx]=]) -file(TO_NATIVE_PATH "${pch_source}" pch_source_win) - -if(NOT EXISTS "${pch_header}") +if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/${pch_header}") set(RunCMake_TEST_FAILED "Generated PCH header ${pch_header} does not exist.") return() endif() -if(NOT EXISTS "${pch_source}") +if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/${pch_source}") set(RunCMake_TEST_FAILED "Generated PCH header ${pch_source} does not exist.") return() endif() @@ -29,16 +27,15 @@ foreach(line IN LISTS tgt_projects_strings) set(have_pch_create ON) endif() - if (line MATCHES "${pch_header}") + if (line MATCHES ".*${pch_header}") set(have_pch_header ON) endif() - if (line MATCHES "${pch_header}") + if (line MATCHES ".*${pch_header}") set(have_force_pch_header ON) endif() - string(FIND "${line}" "" find_pos) - if (NOT find_pos EQUAL "-1") + if (line MATCHES "") set(have_pch_source_compile ON) endif() endforeach() @@ -64,6 +61,6 @@ if (NOT have_force_pch_header) endif() if (NOT have_pch_source_compile) - set(RunCMake_TEST_FAILED "Generated project should have the block.") + set(RunCMake_TEST_FAILED "Generated project should have the block.") return() endif() ----------------------------------------------------------------------- Summary of changes: Source/CPack/cmCPackFreeBSDGenerator.cxx | 2 +- Source/CPack/cpack.cxx | 2 +- Source/CTest/cmCTestBZR.cxx | 4 +-- Source/CTest/cmCTestCVS.cxx | 2 +- Source/CTest/cmCTestGIT.cxx | 4 +-- Source/CTest/cmCTestHG.cxx | 4 +-- Source/CTest/cmCTestP4.cxx | 4 +-- Source/CTest/cmCTestSVN.cxx | 4 +-- Source/CTest/cmCTestSubmitHandler.cxx | 2 +- Source/CTest/cmCTestTestHandler.cxx | 4 +-- Source/CTest/cmParseBlanketJSCoverage.cxx | 4 +-- Source/CTest/cmParseCoberturaCoverage.cxx | 4 +-- Source/CTest/cmParseDelphiCoverage.cxx | 4 +-- Source/CTest/cmParseJacocoCoverage.cxx | 4 +-- Source/cmAffinity.cxx | 2 +- Source/cmAlgorithms.h | 6 ++-- Source/cmArchiveWrite.cxx | 2 +- Source/cmCPluginAPI.cxx | 6 ++-- Source/cmCTest.h | 2 +- Source/cmComputeComponentGraph.h | 6 ++-- Source/cmComputeLinkDepends.h | 8 +++--- Source/cmComputeLinkInformation.h | 2 +- Source/cmComputeTargetDepends.h | 6 ++-- Source/cmConditionEvaluator.h | 2 +- Source/cmCustomCommandLines.h | 12 ++++---- Source/cmDefinitions.h | 2 +- Source/cmDependsFortran.cxx | 8 +++--- Source/cmELF.cxx | 32 +++++++++++----------- Source/cmExecProgramCommand.cxx | 2 +- Source/cmFileCommand.cxx | 2 +- Source/cmFileLockPool.h | 12 ++++---- Source/cmFileLockResult.h | 2 +- Source/cmFileTime.h | 2 +- Source/cmFindLibraryCommand.cxx | 2 +- Source/cmFindPackageCommand.h | 4 +-- Source/cmFortranParser.h | 2 +- Source/cmGeneratedFileStream.h | 4 +-- Source/cmGeneratorExpressionParser.cxx | 4 +-- Source/cmGeneratorTarget.cxx | 2 +- Source/cmGlobalGenerator.h | 4 +-- Source/cmGlobalGhsMultiGenerator.h | 2 +- Source/cmGlobalVisualStudio7Generator.cxx | 1 + Source/cmGlobalVisualStudio8Generator.cxx | 1 + Source/cmInstallTargetGenerator.h | 6 ++-- Source/cmInstalledFile.cxx | 1 + Source/cmInstalledFile.h | 9 +++--- Source/cmLinkLineComputer.cxx | 2 +- Source/cmLinkLineDeviceComputer.cxx | 4 +-- Source/cmLinkedTree.h | 6 ++-- Source/cmListCommand.cxx | 2 +- Source/cmLocalGenerator.cxx | 2 +- Source/cmLocalVisualStudio7Generator.cxx | 1 + Source/cmMakefile.cxx | 2 +- Source/cmMakefile.h | 10 +++---- Source/cmNinjaTypes.h | 4 +-- Source/cmOutputRequiredFilesCommand.cxx | 2 +- Source/cmParseArgumentsCommand.cxx | 8 +++--- Source/cmProcessTools.h | 2 +- Source/cmQtAutoGen.cxx | 4 +-- Source/cmQtAutoGen.h | 2 +- Source/cmQtAutoGenInitializer.h | 2 +- Source/cmQtAutoGenerator.cxx | 2 +- Source/cmQtAutoMocUic.h | 6 ++-- Source/cmScriptGenerator.h | 2 +- Source/cmSourceGroupCommand.h | 2 +- Source/cmStatePrivate.h | 2 +- Source/cmStateTypes.h | 2 +- Source/cmString.hxx | 6 ++-- Source/cmStringAlgorithms.h | 2 +- Source/cmSystemTools.h | 4 +-- Source/cmTarget.h | 2 +- Source/cmUVHandlePtr.h | 4 +-- Source/cmUuid.cxx | 2 +- Source/cmVariableWatch.h | 9 +++--- Source/cmWorkerPool.cxx | 6 ++-- Source/cmWorkerPool.h | 2 +- Source/cmXMLParser.h | 2 +- Source/cmake.h | 6 ++-- Source/cmcmd.cxx | 4 +-- Tests/CMakeLib/run_compile_commands.cxx | 2 +- .../VS10Project/VsPrecompileHeaders-check.cmake | 19 ++++++------- 81 files changed, 172 insertions(+), 173 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Wed Sep 4 09:51:50 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 4 Sep 2019 09:51:50 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-980-gaef152b Message-ID: <20190904135150.AC362FAAE3@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via aef152b91d9f56af87ca2b9618f07228e5f3c463 (commit) via 790db8d477cfaf10b227d6d7a7ca2c0d7d8aaf62 (commit) via 7a8bd12926c32f709cc162ba931484c1b5820363 (commit) via 907d3ed824d8b82525c687747662b358accded9c (commit) via 2d357b7a682070fc98f520212d82efa821fc821c (commit) from 09032f09f8d2b4f7af658060ef434083f9d6a0d4 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=aef152b91d9f56af87ca2b9618f07228e5f3c463 commit aef152b91d9f56af87ca2b9618f07228e5f3c463 Merge: 790db8d 7a8bd12 Author: Brad King AuthorDate: Wed Sep 4 09:43:43 2019 -0400 Commit: Brad King CommitDate: Wed Sep 4 09:43:43 2019 -0400 Merge branch 'release-3.15' https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=790db8d477cfaf10b227d6d7a7ca2c0d7d8aaf62 commit 790db8d477cfaf10b227d6d7a7ca2c0d7d8aaf62 Merge: 09032f0 907d3ed Author: Brad King AuthorDate: Wed Sep 4 13:43:07 2019 +0000 Commit: Kitware Robot CommitDate: Wed Sep 4 09:43:18 2019 -0400 Merge topic 'FindBoost-1.71' 907d3ed824 FindBoost: Tolerate future Boost INTERFACE libraries 2d357b7a68 FindBoost: Clarify role of legacy variables in warning message Acked-by: Kitware Robot Merge-request: !3780 ----------------------------------------------------------------------- Summary of changes: Modules/FindBoost.cmake | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Wed Sep 4 09:51:50 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 4 Sep 2019 09:51:50 -0400 (EDT) Subject: [Cmake-commits] CMake branch, release, updated. v3.15.2-33-g7a8bd12 Message-ID: <20190904135150.D48A8102BC1@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, release has been updated via 7a8bd12926c32f709cc162ba931484c1b5820363 (commit) via 907d3ed824d8b82525c687747662b358accded9c (commit) via 2d357b7a682070fc98f520212d82efa821fc821c (commit) from 3b8fa496e7a9482cb4592e9f36b54f5b1bc3cdea (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: Modules/FindBoost.cmake | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Wed Sep 4 10:41:49 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 4 Sep 2019 10:41:49 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-982-gee15bc7 Message-ID: <20190904144149.C6E24FB77E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via ee15bc7d7e7707fd8d7db92645c2c56a5df0f681 (commit) via 26a0e200e5f4abe8268235c9fdb23a2612a1b3b1 (commit) from aef152b91d9f56af87ca2b9618f07228e5f3c463 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ee15bc7d7e7707fd8d7db92645c2c56a5df0f681 commit ee15bc7d7e7707fd8d7db92645c2c56a5df0f681 Merge: aef152b 26a0e20 Author: Brad King AuthorDate: Wed Sep 4 10:36:51 2019 -0400 Commit: Brad King CommitDate: Wed Sep 4 10:36:51 2019 -0400 Merge branch 'release-3.15' ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From kwrobot at kitware.com Wed Sep 4 10:41:49 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 4 Sep 2019 10:41:49 -0400 (EDT) Subject: [Cmake-commits] CMake branch, release, updated. v3.15.2-34-g26a0e20 Message-ID: <20190904144149.E4970FC942@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, release has been updated via 26a0e200e5f4abe8268235c9fdb23a2612a1b3b1 (commit) from 7a8bd12926c32f709cc162ba931484c1b5820363 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Wed Sep 4 11:01:46 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 4 Sep 2019 11:01:46 -0400 (EDT) Subject: [Cmake-commits] CMake annotated tag, v3.15.3, created. v3.15.3 Message-ID: <20190904150146.6930510300A@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The annotated tag, v3.15.3 has been created at 842f4e2244ec87b814624c97be6456b3d68d3f6c (tag) tagging 26a0e200e5f4abe8268235c9fdb23a2612a1b3b1 (commit) replaces v3.15.2 tagged by Brad King on Wed Sep 4 10:56:34 2019 -0400 - Log ----------------------------------------------------------------- CMake 3.15.3 -----BEGIN PGP SIGNATURE----- iQJKBAABCgA0FiEExsJlMku+vcNQtRPQLSzvEDSSFoQFAl1v0KIWHGJyYWQua2lu Z0BraXR3YXJlLmNvbQAKCRAtLO8QNJIWhJf0D/9unhBq9FGp2DD/kjXBfJFmMkyC ABguTSYX/guCHDHTMlBQx01r+fllpAihFg8m/XrU3fOuBJRLHHbMEn5WR9EmXaRq UgKYfc5f0B2DUf0bFAf1v0QLtpZgleipd26wOSloWjs94tBn6o9IV2UdBpxs9b5U Ay7IG7DPuJqFRqocuZVC9iS/H0uZ6n8kg/0patgqL2hv/wE9KVPIZAng9TVQA5hz tQEv419gpvRqA3Wgpoj/+oFgS3EcrVymaIQKE478cqnVd5WmdoP84lnDYbC7DCXe IjBlGbNPo1CTTzQ6glvzmanWRFe4fgmMrJ/nSOS09h78DZMUyPTrbTpctb3s/7e1 tvbejZgrrH+R3TJvNh4ZR2l05g3Vy9m2HQYUaPXP1viGQD3u6ymXCUqx/iQt19CG xGZFXqQR5IRAozjrZ6KNgJ/UG1ZwXwBhPeW4XNSBE/PRXoW4U8tGvwou7gCnZORg 1i7I1ABweIaU0mwk8LF3++Hv5vkcj9LsiC7TgCW8xjEhVbONTwsuUpkAXTz2VtKq Ekgk0+p5vXsiiSpUvnCOPFURk2eDJVhVXOlsY8ybnQ6ae8Ewwgoxk+W+Oa2aZ8B2 45STj193kGoWzXboBHGeIulHnvmmrxkwoXwun+oNIZm5Hc0s4n9a2ZHgpngUx+lo idvR++raJrI7BAc1Ww== =gzq0 -----END PGP SIGNATURE----- Brad King (27): Flang: Implement MSVC runtime library abstraction Merge branch 'msvc-runtime-library-flang' into release-3.15 Merge branch 'ccmake-crash-on-empty-strings-property' into release-3.15 Merge branch 'FindMPI-restore-flag-vars' into release-3.15 Merge branch 'CrayPrgEnv-update-link-type-detection' into release-3.15 CTest: Fix --show-only=json-v1 output with REQUIRED_FILES property Merge branch 'ctest-json-REQUIRED_FILES' into release-3.15 cmGlobalGenerator: Fix CheckCompilerIdCompatibility local var lifetime cmAffinity: Add include for CPU_ZERO on Alpine Linux Merge branch 'ninja_additional_clean_files_custom_target' into release-3.15 Merge branch 'libarchive-requirement' into release-3.15 Merge branch 'cmGlobalGenerator-compilerId-lifetime' into release-3.15 Merge branch 'alpine-cpu_zero' into release-3.15 Merge branch 'autogen_fix_use_after_move' into release-3.15 find_path: Fix crash on empty old-style list of names Merge branch 'backport-find-no-name' into release-3.15 fileapi: Fix codemodel v2 target file name for CMP0037 OLD behavior Merge branch 'fileapi-CMP0037-OLD' into release-3.15 FindBoost: Simplify conditional block for last known version FindBoost: Remove incorrect 1.70 timer dependency FindBoost: Unwrap compatibility INTERFACE targets for legacy variables FindBoost: Add support for Boost 1.71 Merge branch 'FindBoost-1.71' into release-3.15 FindBoost: Clarify role of legacy variables in warning message FindBoost: Tolerate future Boost INTERFACE libraries Merge branch 'FindBoost-1.71' into release-3.15 CMake 3.15.3 Chuck Atkins (1): CrayPrgEnv: Change default linking mode based on PE version M Furkan USLU (1): ccmake: handle cache entries with empty STRINGS property Marvin Schmidt (1): libarchive: We now require at least version 3.3.3 Robert Maynard (1): FindMPI: Restore MPI__COMPILE_FLAGS and MPI__COMPILE_OPTIONS Sebastian Holtermann (3): Ninja: Add support for ADDITIONAL_CLEAN_FILES in custom targets Tests: Extend MakeClean test to test various target types Autogen: Fix AUTOUIC segfault, when file includes colliding ui_*.h file ----------------------------------------------------------------------- hooks/post-receive -- CMake From kwrobot at kitware.com Thu Sep 5 00:01:31 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 5 Sep 2019 00:01:31 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-949-gf545428 Message-ID: <20190905040131.3706410F1EF@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via f545428be08531d2561feba4854793775be83c39 (commit) from ee15bc7d7e7707fd8d7db92645c2c56a5df0f681 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f545428be08531d2561feba4854793775be83c39 commit f545428be08531d2561feba4854793775be83c39 Author: Kitware Robot AuthorDate: Thu Sep 5 00:01:06 2019 -0400 Commit: Kitware Robot CommitDate: Thu Sep 5 00:01:06 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 5f6e9bb..545b0a9 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 15) -set(CMake_VERSION_PATCH 20190904) +set(CMake_VERSION_PATCH 20190905) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Thu Sep 5 08:32:07 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 5 Sep 2019 08:32:07 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-952-gfcba9c3 Message-ID: <20190905123207.EF16E1899C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via fcba9c3baa00631407f493f97afe7e9cd1b844a7 (commit) via e26f0e9dd58b839b880670d6000e7f1ebac1df94 (commit) via f7085d7b0a0d4cced41669b498a3d03c4a1e65df (commit) from f545428be08531d2561feba4854793775be83c39 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fcba9c3baa00631407f493f97afe7e9cd1b844a7 commit fcba9c3baa00631407f493f97afe7e9cd1b844a7 Merge: f545428 e26f0e9 Author: Brad King AuthorDate: Thu Sep 5 12:24:38 2019 +0000 Commit: Kitware Robot CommitDate: Thu Sep 5 08:24:50 2019 -0400 Merge topic 'cpack-zstd' e26f0e9dd5 CPack: Add generator for .tar.zst packages f7085d7b0a cmCPackArchiveGenerator: Code cleanup Acked-by: Kitware Robot Merge-request: !3752 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e26f0e9dd58b839b880670d6000e7f1ebac1df94 commit e26f0e9dd58b839b880670d6000e7f1ebac1df94 Author: Regina Pfeifer AuthorDate: Wed Aug 28 22:05:45 2019 +0200 Commit: Brad King CommitDate: Wed Sep 4 13:05:22 2019 -0400 CPack: Add generator for .tar.zst packages diff --git a/Help/cpack_gen/archive.rst b/Help/cpack_gen/archive.rst index b288aad..d455f4b 100644 --- a/Help/cpack_gen/archive.rst +++ b/Help/cpack_gen/archive.rst @@ -9,6 +9,7 @@ different formats: - TGZ (.tar.gz) - TXZ (.tar.xz) - TZ (.tar.Z) + - TZST (.tar.zst) - ZIP (.zip) Variables specific to CPack Archive generator diff --git a/Help/release/dev/cpack-zstd.rst b/Help/release/dev/cpack-zstd.rst new file mode 100644 index 0000000..e1e64a2 --- /dev/null +++ b/Help/release/dev/cpack-zstd.rst @@ -0,0 +1,5 @@ +cpack-zstd +---------- + +* The :cpack_gen:`CPack Archive Generator` learned to generate `.tar.zst` + packages with Zstandard compression. diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index e9338f2..1271b08 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -46,6 +46,12 @@ cmCPackGenerator* cmCPackArchiveGenerator::CreateTZGenerator() ".tar.Z"); } +cmCPackGenerator* cmCPackArchiveGenerator::CreateTZSTGenerator() +{ + return new cmCPackArchiveGenerator(cmArchiveWrite::CompressZstd, "paxr", + ".tar.zst"); +} + cmCPackGenerator* cmCPackArchiveGenerator::CreateZIPGenerator() { return new cmCPackArchiveGenerator(cmArchiveWrite::CompressNone, "zip", diff --git a/Source/CPack/cmCPackArchiveGenerator.h b/Source/CPack/cmCPackArchiveGenerator.h index 9bd1ede..f5be0aa 100644 --- a/Source/CPack/cmCPackArchiveGenerator.h +++ b/Source/CPack/cmCPackArchiveGenerator.h @@ -29,6 +29,7 @@ public: static cmCPackGenerator* CreateTGZGenerator(); static cmCPackGenerator* CreateTXZGenerator(); static cmCPackGenerator* CreateTZGenerator(); + static cmCPackGenerator* CreateTZSTGenerator(); static cmCPackGenerator* CreateZIPGenerator(); /** diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index f230871..4d41049 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -54,6 +54,8 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() cmCPackArchiveGenerator::CreateTXZGenerator); this->RegisterGenerator("TZ", "Tar Compress compression", cmCPackArchiveGenerator::CreateTZGenerator); + this->RegisterGenerator("TZST", "Tar Zstandard compression", + cmCPackArchiveGenerator::CreateTZSTGenerator); this->RegisterGenerator("ZIP", "ZIP file format", cmCPackArchiveGenerator::CreateZIPGenerator); } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f7085d7b0a0d4cced41669b498a3d03c4a1e65df commit f7085d7b0a0d4cced41669b498a3d03c4a1e65df Author: Regina Pfeifer AuthorDate: Wed Aug 28 21:36:38 2019 +0200 Commit: Brad King CommitDate: Wed Sep 4 13:05:22 2019 -0400 cmCPackArchiveGenerator: Code cleanup diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 2ff6c8c..decb39a 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -978,12 +978,6 @@ set(CPACK_SRCS CPack/cmCPackNSISGenerator.cxx CPack/cmCPackNuGetGenerator.cxx CPack/cmCPackSTGZGenerator.cxx - CPack/cmCPackTGZGenerator.cxx - CPack/cmCPackTXZGenerator.cxx - CPack/cmCPackTarBZip2Generator.cxx - CPack/cmCPackTarCompressGenerator.cxx - CPack/cmCPackZIPGenerator.cxx - CPack/cmCPack7zGenerator.cxx ) # CPack IFW generator set(CPACK_SRCS ${CPACK_SRCS} diff --git a/Source/CPack/cmCPack7zGenerator.cxx b/Source/CPack/cmCPack7zGenerator.cxx deleted file mode 100644 index 7413770..0000000 --- a/Source/CPack/cmCPack7zGenerator.cxx +++ /dev/null @@ -1,13 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmCPack7zGenerator.h" - -#include "cmArchiveWrite.h" -#include "cmCPackArchiveGenerator.h" - -cmCPack7zGenerator::cmCPack7zGenerator() - : cmCPackArchiveGenerator(cmArchiveWrite::CompressNone, "7zip") -{ -} - -cmCPack7zGenerator::~cmCPack7zGenerator() = default; diff --git a/Source/CPack/cmCPack7zGenerator.h b/Source/CPack/cmCPack7zGenerator.h deleted file mode 100644 index 8af4c4a..0000000 --- a/Source/CPack/cmCPack7zGenerator.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cmCPack7zGenerator_h -#define cmCPack7zGenerator_h - -#include "cmConfigure.h" // IWYU pragma: keep - -#include "cmCPackArchiveGenerator.h" -#include "cmCPackGenerator.h" - -/** \class cmCPack7zGenerator - * \brief A generator for 7z files - */ -class cmCPack7zGenerator : public cmCPackArchiveGenerator -{ -public: - cmCPackTypeMacro(cmCPack7zGenerator, cmCPackArchiveGenerator); - - /** - * Construct generator - */ - cmCPack7zGenerator(); - ~cmCPack7zGenerator() override; - -protected: - const char* GetOutputExtension() override { return ".7z"; } -}; - -#endif diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index 6c9c6b9..e9338f2 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -16,11 +16,48 @@ #include #include -cmCPackArchiveGenerator::cmCPackArchiveGenerator(cmArchiveWrite::Compress t, - std::string const& format) +cmCPackGenerator* cmCPackArchiveGenerator::Create7ZGenerator() +{ + return new cmCPackArchiveGenerator(cmArchiveWrite::CompressNone, "7zip", + ".7z"); +} + +cmCPackGenerator* cmCPackArchiveGenerator::CreateTBZ2Generator() +{ + return new cmCPackArchiveGenerator(cmArchiveWrite::CompressBZip2, "paxr", + ".tar.bz2"); +} + +cmCPackGenerator* cmCPackArchiveGenerator::CreateTGZGenerator() +{ + return new cmCPackArchiveGenerator(cmArchiveWrite::CompressGZip, "paxr", + ".tar.gz"); +} + +cmCPackGenerator* cmCPackArchiveGenerator::CreateTXZGenerator() +{ + return new cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr", + ".tar.xz"); +} + +cmCPackGenerator* cmCPackArchiveGenerator::CreateTZGenerator() +{ + return new cmCPackArchiveGenerator(cmArchiveWrite::CompressCompress, "paxr", + ".tar.Z"); +} + +cmCPackGenerator* cmCPackArchiveGenerator::CreateZIPGenerator() +{ + return new cmCPackArchiveGenerator(cmArchiveWrite::CompressNone, "zip", + ".zip"); +} + +cmCPackArchiveGenerator::cmCPackArchiveGenerator( + cmArchiveWrite::Compress compress, std::string format, std::string extension) + : Compress(compress) + , ArchiveFormat(std::move(format)) + , OutputExtension(std::move(extension)) { - this->Compress = t; - this->ArchiveFormat = format; } cmCPackArchiveGenerator::~cmCPackArchiveGenerator() = default; diff --git a/Source/CPack/cmCPackArchiveGenerator.h b/Source/CPack/cmCPackArchiveGenerator.h index 9983854..9bd1ede 100644 --- a/Source/CPack/cmCPackArchiveGenerator.h +++ b/Source/CPack/cmCPackArchiveGenerator.h @@ -24,10 +24,18 @@ class cmCPackArchiveGenerator : public cmCPackGenerator public: typedef cmCPackGenerator Superclass; + static cmCPackGenerator* Create7ZGenerator(); + static cmCPackGenerator* CreateTBZ2Generator(); + static cmCPackGenerator* CreateTGZGenerator(); + static cmCPackGenerator* CreateTXZGenerator(); + static cmCPackGenerator* CreateTZGenerator(); + static cmCPackGenerator* CreateZIPGenerator(); + /** * Construct generator */ - cmCPackArchiveGenerator(cmArchiveWrite::Compress, std::string const& format); + cmCPackArchiveGenerator(cmArchiveWrite::Compress t, std::string format, + std::string extension); ~cmCPackArchiveGenerator() override; // Used to add a header to the archive virtual int GenerateHeader(std::ostream* os); @@ -68,9 +76,19 @@ protected: * components will be put in a single installer. */ int PackageComponentsAllInOne(); - const char* GetOutputExtension() override = 0; + +private: + const char* GetNameOfClass() override { return "cmCPackArchiveGenerator"; } + + const char* GetOutputExtension() override + { + return this->OutputExtension.c_str(); + } + +private: cmArchiveWrite::Compress Compress; std::string ArchiveFormat; + std::string OutputExtension; }; #endif diff --git a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx index 553a677..22385055 100644 --- a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx +++ b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx @@ -12,6 +12,7 @@ #include "cmsys/SystemTools.hxx" cmCPackCygwinBinaryGenerator::cmCPackCygwinBinaryGenerator() + : cmCPackArchiveGenerator(cmArchiveWrite::CompressBZip2, "paxr", ".tar.bz2") { } diff --git a/Source/CPack/cmCPackCygwinBinaryGenerator.h b/Source/CPack/cmCPackCygwinBinaryGenerator.h index f87a134..47bd41e 100644 --- a/Source/CPack/cmCPackCygwinBinaryGenerator.h +++ b/Source/CPack/cmCPackCygwinBinaryGenerator.h @@ -3,15 +3,15 @@ #ifndef cmCPackCygwinBinaryGenerator_h #define cmCPackCygwinBinaryGenerator_h -#include "cmCPackTarBZip2Generator.h" +#include "cmCPackArchiveGenerator.h" /** \class cmCPackCygwinBinaryGenerator * \brief A generator for TarBZip2 files */ -class cmCPackCygwinBinaryGenerator : public cmCPackTarBZip2Generator +class cmCPackCygwinBinaryGenerator : public cmCPackArchiveGenerator { public: - cmCPackTypeMacro(cmCPackCygwinBinaryGenerator, cmCPackTarBZip2Generator); + cmCPackTypeMacro(cmCPackCygwinBinaryGenerator, cmCPackArchiveGenerator); /** * Construct generator diff --git a/Source/CPack/cmCPackCygwinSourceGenerator.cxx b/Source/CPack/cmCPackCygwinSourceGenerator.cxx index 8cae9b4..5f6aab0 100644 --- a/Source/CPack/cmCPackCygwinSourceGenerator.cxx +++ b/Source/CPack/cmCPackCygwinSourceGenerator.cxx @@ -20,6 +20,7 @@ #endif cmCPackCygwinSourceGenerator::cmCPackCygwinSourceGenerator() + : cmCPackArchiveGenerator(cmArchiveWrite::CompressBZip2, "paxr", ".tar.bz2") { } @@ -40,11 +41,8 @@ int cmCPackCygwinSourceGenerator::PackageFiles() cmStrCat(this->GetOption("CPACK_TEMPORARY_DIRECTORY"), ".tar.bz2"); packageFileNames[0] = packageDirFileName; std::string output; - // skip one parent up to the cmCPackTarBZip2Generator - // to create tar.bz2 file with the list of source - // files - this->Compress = cmArchiveWrite::CompressBZip2; - if (!this->cmCPackTarBZip2Generator::PackageFiles()) { + // create tar.bz2 file with the list of source files + if (!this->cmCPackArchiveGenerator::PackageFiles()) { return 0; } // Now create a tar file that contains the above .tar.bz2 file @@ -130,7 +128,7 @@ int cmCPackCygwinSourceGenerator::PackageFiles() packageFileNames[0] = outerTarFile; /* update the toplevel dir */ toplevel = tmpDir; - if (!this->cmCPackTarBZip2Generator::PackageFiles()) { + if (!this->cmCPackArchiveGenerator::PackageFiles()) { return 0; } return 1; diff --git a/Source/CPack/cmCPackCygwinSourceGenerator.h b/Source/CPack/cmCPackCygwinSourceGenerator.h index a909b15..98d8f0a 100644 --- a/Source/CPack/cmCPackCygwinSourceGenerator.h +++ b/Source/CPack/cmCPackCygwinSourceGenerator.h @@ -3,15 +3,15 @@ #ifndef cmCPackCygwinSourceGenerator_h #define cmCPackCygwinSourceGenerator_h -#include "cmCPackTarBZip2Generator.h" +#include "cmCPackArchiveGenerator.h" /** \class cmCPackCygwinSourceGenerator * \brief A generator for cygwin source files */ -class cmCPackCygwinSourceGenerator : public cmCPackTarBZip2Generator +class cmCPackCygwinSourceGenerator : public cmCPackArchiveGenerator { public: - cmCPackTypeMacro(cmCPackCygwinSourceGenerator, cmCPackTarBZip2Generator); + cmCPackTypeMacro(cmCPackCygwinSourceGenerator, cmCPackArchiveGenerator); /** * Construct generator diff --git a/Source/CPack/cmCPackFreeBSDGenerator.cxx b/Source/CPack/cmCPackFreeBSDGenerator.cxx index a35977c..32ced10 100644 --- a/Source/CPack/cmCPackFreeBSDGenerator.cxx +++ b/Source/CPack/cmCPackFreeBSDGenerator.cxx @@ -21,7 +21,7 @@ #include cmCPackFreeBSDGenerator::cmCPackFreeBSDGenerator() - : cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr") + : cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr", ".txz") { } @@ -276,12 +276,6 @@ void write_manifest_files(cmGeneratedFileStream& s, s << " },\n"; } -static bool has_suffix(const std::string& str, const std::string& suffix) -{ - return str.size() >= suffix.size() && - str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; -} - int cmCPackFreeBSDGenerator::PackageFiles() { if (!this->ReadListFile("Internal/CPack/CPackFreeBSD.cmake")) { @@ -327,13 +321,13 @@ int cmCPackFreeBSDGenerator::PackageFiles() pkg_create_from_manifest(output_dir.c_str(), ::TXZ, toplevel.c_str(), manifestname.c_str(), nullptr); - std::string broken_suffix = std::string("-") + - var_lookup("CPACK_TOPLEVEL_TAG") + std::string(GetOutputExtension()); + std::string broken_suffix = + cmStrCat('-', var_lookup("CPACK_TOPLEVEL_TAG"), ".txz"); for (std::string& name : packageFileNames) { cmCPackLogger(cmCPackLog::LOG_DEBUG, "Packagefile " << name << std::endl); - if (has_suffix(name, broken_suffix)) { + if (cmHasSuffix(name, broken_suffix)) { name.replace(name.size() - broken_suffix.size(), std::string::npos, - GetOutputExtension()); + ".txz"); break; } } diff --git a/Source/CPack/cmCPackFreeBSDGenerator.h b/Source/CPack/cmCPackFreeBSDGenerator.h index 99d2e24..80c53b1 100644 --- a/Source/CPack/cmCPackFreeBSDGenerator.h +++ b/Source/CPack/cmCPackFreeBSDGenerator.h @@ -28,8 +28,6 @@ public: int PackageFiles() override; protected: - const char* GetOutputExtension() override { return ".txz"; } - std::string var_lookup(const char* var_name); void write_manifest_fields(cmGeneratedFileStream&); }; diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index 2c5ab4d..f230871 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -7,10 +7,10 @@ #include "IFW/cmCPackIFWGenerator.h" #include "cmAlgorithms.h" -#include "cmCPack7zGenerator.h" #ifdef HAVE_FREEBSD_PKG # include "cmCPackFreeBSDGenerator.h" #endif +#include "cmCPackArchiveGenerator.h" #include "cmCPackDebGenerator.h" #include "cmCPackExternalGenerator.h" #include "cmCPackGenerator.h" @@ -18,11 +18,6 @@ #include "cmCPackNSISGenerator.h" #include "cmCPackNuGetGenerator.h" #include "cmCPackSTGZGenerator.h" -#include "cmCPackTGZGenerator.h" -#include "cmCPackTXZGenerator.h" -#include "cmCPackTarBZip2Generator.h" -#include "cmCPackTarCompressGenerator.h" -#include "cmCPackZIPGenerator.h" #ifdef __APPLE__ # include "cmCPackBundleGenerator.h" @@ -48,13 +43,19 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() { - if (cmCPackTGZGenerator::CanGenerate()) { + if (cmCPackArchiveGenerator::CanGenerate()) { + this->RegisterGenerator("7Z", "7-Zip file format", + cmCPackArchiveGenerator::Create7ZGenerator); + this->RegisterGenerator("TBZ2", "Tar BZip2 compression", + cmCPackArchiveGenerator::CreateTBZ2Generator); this->RegisterGenerator("TGZ", "Tar GZip compression", - cmCPackTGZGenerator::CreateGenerator); - } - if (cmCPackTXZGenerator::CanGenerate()) { + cmCPackArchiveGenerator::CreateTGZGenerator); this->RegisterGenerator("TXZ", "Tar XZ compression", - cmCPackTXZGenerator::CreateGenerator); + cmCPackArchiveGenerator::CreateTXZGenerator); + this->RegisterGenerator("TZ", "Tar Compress compression", + cmCPackArchiveGenerator::CreateTZGenerator); + this->RegisterGenerator("ZIP", "ZIP file format", + cmCPackArchiveGenerator::CreateZIPGenerator); } if (cmCPackSTGZGenerator::CanGenerate()) { this->RegisterGenerator("STGZ", "Self extracting Tar GZip compression", @@ -80,29 +81,12 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() cmCPackCygwinSourceGenerator::CreateGenerator); } #endif - - if (cmCPackZIPGenerator::CanGenerate()) { - this->RegisterGenerator("ZIP", "ZIP file format", - cmCPackZIPGenerator::CreateGenerator); - } - if (cmCPack7zGenerator::CanGenerate()) { - this->RegisterGenerator("7Z", "7-Zip file format", - cmCPack7zGenerator::CreateGenerator); - } #if defined(_WIN32) || (defined(__CYGWIN__) && defined(HAVE_LIBUUID)) if (cmCPackWIXGenerator::CanGenerate()) { this->RegisterGenerator("WIX", "MSI file format via WiX tools", cmCPackWIXGenerator::CreateGenerator); } #endif - if (cmCPackTarBZip2Generator::CanGenerate()) { - this->RegisterGenerator("TBZ2", "Tar BZip2 compression", - cmCPackTarBZip2Generator::CreateGenerator); - } - if (cmCPackTarCompressGenerator::CanGenerate()) { - this->RegisterGenerator("TZ", "Tar Compress compression", - cmCPackTarCompressGenerator::CreateGenerator); - } if (cmCPackDebGenerator::CanGenerate()) { this->RegisterGenerator("DEB", "Debian packages", cmCPackDebGenerator::CreateGenerator); diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index 4666dc2..3092508 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -8,12 +8,16 @@ #include #include +#include "cmArchiveWrite.h" #include "cmCPackGenerator.h" #include "cmCPackLog.h" #include "cmSystemTools.h" #include "cm_sys_stat.h" -cmCPackSTGZGenerator::cmCPackSTGZGenerator() = default; +cmCPackSTGZGenerator::cmCPackSTGZGenerator() + : cmCPackArchiveGenerator(cmArchiveWrite::CompressGZip, "paxr", ".sh") +{ +} cmCPackSTGZGenerator::~cmCPackSTGZGenerator() = default; diff --git a/Source/CPack/cmCPackSTGZGenerator.h b/Source/CPack/cmCPackSTGZGenerator.h index 9cf184b..55e4779 100644 --- a/Source/CPack/cmCPackSTGZGenerator.h +++ b/Source/CPack/cmCPackSTGZGenerator.h @@ -5,8 +5,8 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include "cmCPackArchiveGenerator.h" #include "cmCPackGenerator.h" -#include "cmCPackTGZGenerator.h" #include @@ -14,10 +14,10 @@ * \brief A generator for Self extractable TGZ files * */ -class cmCPackSTGZGenerator : public cmCPackTGZGenerator +class cmCPackSTGZGenerator : public cmCPackArchiveGenerator { public: - cmCPackTypeMacro(cmCPackSTGZGenerator, cmCPackTGZGenerator); + cmCPackTypeMacro(cmCPackSTGZGenerator, cmCPackArchiveGenerator); /** * Construct generator @@ -29,7 +29,6 @@ protected: int PackageFiles() override; int InitializeInternal() override; int GenerateHeader(std::ostream* os) override; - const char* GetOutputExtension() override { return ".sh"; } }; #endif diff --git a/Source/CPack/cmCPackTGZGenerator.cxx b/Source/CPack/cmCPackTGZGenerator.cxx deleted file mode 100644 index 6f4676e..0000000 --- a/Source/CPack/cmCPackTGZGenerator.cxx +++ /dev/null @@ -1,13 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmCPackTGZGenerator.h" - -#include "cmArchiveWrite.h" -#include "cmCPackArchiveGenerator.h" - -cmCPackTGZGenerator::cmCPackTGZGenerator() - : cmCPackArchiveGenerator(cmArchiveWrite::CompressGZip, "paxr") -{ -} - -cmCPackTGZGenerator::~cmCPackTGZGenerator() = default; diff --git a/Source/CPack/cmCPackTGZGenerator.h b/Source/CPack/cmCPackTGZGenerator.h deleted file mode 100644 index 7be3d9d..0000000 --- a/Source/CPack/cmCPackTGZGenerator.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cmCPackTGZGenerator_h -#define cmCPackTGZGenerator_h - -#include "cmConfigure.h" // IWYU pragma: keep - -#include "cmCPackArchiveGenerator.h" -#include "cmCPackGenerator.h" - -/** \class cmCPackTGZGenerator - * \brief A generator for TGZ files - * - */ -class cmCPackTGZGenerator : public cmCPackArchiveGenerator -{ -public: - cmCPackTypeMacro(cmCPackTGZGenerator, cmCPackArchiveGenerator); - /** - * Construct generator - */ - cmCPackTGZGenerator(); - ~cmCPackTGZGenerator() override; - -protected: - const char* GetOutputExtension() override { return ".tar.gz"; } -}; - -#endif diff --git a/Source/CPack/cmCPackTXZGenerator.cxx b/Source/CPack/cmCPackTXZGenerator.cxx deleted file mode 100644 index ccbccde..0000000 --- a/Source/CPack/cmCPackTXZGenerator.cxx +++ /dev/null @@ -1,13 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmCPackTXZGenerator.h" - -#include "cmArchiveWrite.h" -#include "cmCPackArchiveGenerator.h" - -cmCPackTXZGenerator::cmCPackTXZGenerator() - : cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr") -{ -} - -cmCPackTXZGenerator::~cmCPackTXZGenerator() = default; diff --git a/Source/CPack/cmCPackTXZGenerator.h b/Source/CPack/cmCPackTXZGenerator.h deleted file mode 100644 index 4aa5973..0000000 --- a/Source/CPack/cmCPackTXZGenerator.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cmCPackTXZGenerator_h -#define cmCPackTXZGenerator_h - -#include "cmConfigure.h" // IWYU pragma: keep - -#include "cmCPackArchiveGenerator.h" -#include "cmCPackGenerator.h" - -/** \class cmCPackTXZGenerator - * \brief A generator for TXZ files - * - */ -class cmCPackTXZGenerator : public cmCPackArchiveGenerator -{ -public: - cmCPackTypeMacro(cmCPackTXZGenerator, cmCPackArchiveGenerator); - /** - * Construct generator - */ - cmCPackTXZGenerator(); - ~cmCPackTXZGenerator() override; - -protected: - const char* GetOutputExtension() override { return ".tar.xz"; } -}; - -#endif diff --git a/Source/CPack/cmCPackTarBZip2Generator.cxx b/Source/CPack/cmCPackTarBZip2Generator.cxx deleted file mode 100644 index 85abeb1..0000000 --- a/Source/CPack/cmCPackTarBZip2Generator.cxx +++ /dev/null @@ -1,13 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmCPackTarBZip2Generator.h" - -#include "cmArchiveWrite.h" -#include "cmCPackArchiveGenerator.h" - -cmCPackTarBZip2Generator::cmCPackTarBZip2Generator() - : cmCPackArchiveGenerator(cmArchiveWrite::CompressBZip2, "paxr") -{ -} - -cmCPackTarBZip2Generator::~cmCPackTarBZip2Generator() = default; diff --git a/Source/CPack/cmCPackTarBZip2Generator.h b/Source/CPack/cmCPackTarBZip2Generator.h deleted file mode 100644 index 7975dda..0000000 --- a/Source/CPack/cmCPackTarBZip2Generator.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cmCPackTarBZip2Generator_h -#define cmCPackTarBZip2Generator_h - -#include "cmConfigure.h" // IWYU pragma: keep - -#include "cmCPackArchiveGenerator.h" -#include "cmCPackGenerator.h" - -/** \class cmCPackTarBZip2Generator - * \brief A generator for TarBZip2 files - */ -class cmCPackTarBZip2Generator : public cmCPackArchiveGenerator -{ -public: - cmCPackTypeMacro(cmCPackTarBZip2Generator, cmCPackArchiveGenerator); - /** - * Construct generator - */ - cmCPackTarBZip2Generator(); - ~cmCPackTarBZip2Generator() override; - -protected: - const char* GetOutputExtension() override { return ".tar.bz2"; } -}; - -#endif diff --git a/Source/CPack/cmCPackTarCompressGenerator.cxx b/Source/CPack/cmCPackTarCompressGenerator.cxx deleted file mode 100644 index 55a6de5..0000000 --- a/Source/CPack/cmCPackTarCompressGenerator.cxx +++ /dev/null @@ -1,13 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmCPackTarCompressGenerator.h" - -#include "cmArchiveWrite.h" -#include "cmCPackArchiveGenerator.h" - -cmCPackTarCompressGenerator::cmCPackTarCompressGenerator() - : cmCPackArchiveGenerator(cmArchiveWrite::CompressCompress, "paxr") -{ -} - -cmCPackTarCompressGenerator::~cmCPackTarCompressGenerator() = default; diff --git a/Source/CPack/cmCPackTarCompressGenerator.h b/Source/CPack/cmCPackTarCompressGenerator.h deleted file mode 100644 index 37c7f48..0000000 --- a/Source/CPack/cmCPackTarCompressGenerator.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cmCPackTarCompressGenerator_h -#define cmCPackTarCompressGenerator_h - -#include "cmConfigure.h" // IWYU pragma: keep - -#include "cmCPackArchiveGenerator.h" -#include "cmCPackGenerator.h" - -/** \class cmCPackTarCompressGenerator - * \brief A generator for TarCompress files - */ -class cmCPackTarCompressGenerator : public cmCPackArchiveGenerator -{ -public: - cmCPackTypeMacro(cmCPackTarCompressGenerator, cmCPackArchiveGenerator); - /** - * Construct generator - */ - cmCPackTarCompressGenerator(); - ~cmCPackTarCompressGenerator() override; - -protected: - const char* GetOutputExtension() override { return ".tar.Z"; } -}; - -#endif diff --git a/Source/CPack/cmCPackZIPGenerator.cxx b/Source/CPack/cmCPackZIPGenerator.cxx deleted file mode 100644 index f06494c..0000000 --- a/Source/CPack/cmCPackZIPGenerator.cxx +++ /dev/null @@ -1,13 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmCPackZIPGenerator.h" - -#include "cmArchiveWrite.h" -#include "cmCPackArchiveGenerator.h" - -cmCPackZIPGenerator::cmCPackZIPGenerator() - : cmCPackArchiveGenerator(cmArchiveWrite::CompressNone, "zip") -{ -} - -cmCPackZIPGenerator::~cmCPackZIPGenerator() = default; diff --git a/Source/CPack/cmCPackZIPGenerator.h b/Source/CPack/cmCPackZIPGenerator.h deleted file mode 100644 index 58ec79e..0000000 --- a/Source/CPack/cmCPackZIPGenerator.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cmCPackZIPGenerator_h -#define cmCPackZIPGenerator_h - -#include "cmConfigure.h" // IWYU pragma: keep - -#include "cmCPackArchiveGenerator.h" -#include "cmCPackGenerator.h" - -/** \class cmCPackZIPGenerator - * \brief A generator for ZIP files - */ -class cmCPackZIPGenerator : public cmCPackArchiveGenerator -{ -public: - cmCPackTypeMacro(cmCPackZIPGenerator, cmCPackArchiveGenerator); - - /** - * Construct generator - */ - cmCPackZIPGenerator(); - ~cmCPackZIPGenerator() override; - -protected: - const char* GetOutputExtension() override { return ".zip"; } -}; - -#endif ----------------------------------------------------------------------- Summary of changes: Help/cpack_gen/archive.rst | 1 + Help/release/dev/cpack-zstd.rst | 5 +++ Source/CMakeLists.txt | 6 ---- Source/CPack/cmCPack7zGenerator.cxx | 13 ------- Source/CPack/cmCPack7zGenerator.h | 29 --------------- Source/CPack/cmCPackArchiveGenerator.cxx | 51 ++++++++++++++++++++++++--- Source/CPack/cmCPackArchiveGenerator.h | 23 ++++++++++-- Source/CPack/cmCPackCygwinBinaryGenerator.cxx | 1 + Source/CPack/cmCPackCygwinBinaryGenerator.h | 6 ++-- Source/CPack/cmCPackCygwinSourceGenerator.cxx | 10 +++--- Source/CPack/cmCPackCygwinSourceGenerator.h | 6 ++-- Source/CPack/cmCPackFreeBSDGenerator.cxx | 16 +++------ Source/CPack/cmCPackFreeBSDGenerator.h | 2 -- Source/CPack/cmCPackGeneratorFactory.cxx | 42 ++++++++-------------- Source/CPack/cmCPackSTGZGenerator.cxx | 6 +++- Source/CPack/cmCPackSTGZGenerator.h | 7 ++-- Source/CPack/cmCPackTGZGenerator.cxx | 13 ------- Source/CPack/cmCPackTGZGenerator.h | 29 --------------- Source/CPack/cmCPackTXZGenerator.cxx | 13 ------- Source/CPack/cmCPackTXZGenerator.h | 29 --------------- Source/CPack/cmCPackTarBZip2Generator.cxx | 13 ------- Source/CPack/cmCPackTarBZip2Generator.h | 28 --------------- Source/CPack/cmCPackTarCompressGenerator.cxx | 13 ------- Source/CPack/cmCPackTarCompressGenerator.h | 28 --------------- Source/CPack/cmCPackZIPGenerator.cxx | 13 ------- Source/CPack/cmCPackZIPGenerator.h | 29 --------------- 26 files changed, 112 insertions(+), 320 deletions(-) create mode 100644 Help/release/dev/cpack-zstd.rst delete mode 100644 Source/CPack/cmCPack7zGenerator.cxx delete mode 100644 Source/CPack/cmCPack7zGenerator.h delete mode 100644 Source/CPack/cmCPackTGZGenerator.cxx delete mode 100644 Source/CPack/cmCPackTGZGenerator.h delete mode 100644 Source/CPack/cmCPackTXZGenerator.cxx delete mode 100644 Source/CPack/cmCPackTXZGenerator.h delete mode 100644 Source/CPack/cmCPackTarBZip2Generator.cxx delete mode 100644 Source/CPack/cmCPackTarBZip2Generator.h delete mode 100644 Source/CPack/cmCPackTarCompressGenerator.cxx delete mode 100644 Source/CPack/cmCPackTarCompressGenerator.h delete mode 100644 Source/CPack/cmCPackZIPGenerator.cxx delete mode 100644 Source/CPack/cmCPackZIPGenerator.h hooks/post-receive -- CMake From kwrobot at kitware.com Thu Sep 5 08:41:23 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 5 Sep 2019 08:41:23 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-957-gac4d6d4 Message-ID: <20190905124123.6C9281899C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via ac4d6d4a9d9b81773e61c643169cb2afe1bab644 (commit) via 7786a05c707dc5ffe9fdf7a6b468f56ed18c9e8a (commit) via 1353802af366bd64ba8f730e6f93d4c416107d48 (commit) via 8dfeb5d278625c55be1cc82399d29c0305ee4438 (commit) via 7114c141e27532df709fcae1266bb4ce9b6e850c (commit) from fcba9c3baa00631407f493f97afe7e9cd1b844a7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ac4d6d4a9d9b81773e61c643169cb2afe1bab644 commit ac4d6d4a9d9b81773e61c643169cb2afe1bab644 Merge: fcba9c3 7786a05 Author: Brad King AuthorDate: Thu Sep 5 12:35:29 2019 +0000 Commit: Kitware Robot CommitDate: Thu Sep 5 08:36:06 2019 -0400 Merge topic 'unity-build' 7786a05c70 Unity build: Add XCode support 1353802af3 Unity build: Add unit tests 8dfeb5d278 Unity build: Add support for Visual Studio generator 7114c141e2 Unity build: Add support for Ninja and Makefile generators Acked-by: Kitware Robot Acked-by: Stanislav Ershov Acked-by: Evgeniy Dushistov Acked-by: Viktor Kirilov Merge-request: !3611 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7786a05c707dc5ffe9fdf7a6b468f56ed18c9e8a commit 7786a05c707dc5ffe9fdf7a6b468f56ed18c9e8a Author: Cristian Adam AuthorDate: Tue Jul 30 18:31:16 2019 +0200 Commit: Cristian Adam CommitDate: Fri Aug 30 20:39:37 2019 +0200 Unity build: Add XCode support diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 427ab44..74d97e1 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2839,6 +2839,7 @@ bool cmGlobalXCodeGenerator::CreateGroups( continue; } + generator->AddUnityBuild(gtgt, ""); generator->AddPchDependencies(gtgt, ""); auto addSourceToGroup = [this, mf, gtgt, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 6249c28..c85ee2d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2266,7 +2266,11 @@ void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target, for (; begin != end; ++begin) { cmSourceFile* sf = filtered_sources[begin]; - if (!this->GetGlobalGenerator()->IsMultiConfig()) { + // Only in Visual Studio generator we keep the source files + // for explicit processing. For the rest the source files will + // not be included in the project. + if (!this->GetGlobalGenerator()->IsMultiConfig() || + this->GetGlobalGenerator()->IsXcode()) { sf->SetProperty("HEADER_FILE_ONLY", "ON"); } sf->SetProperty("UNITY_SOURCE_FILE", filename.c_str()); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1353802af366bd64ba8f730e6f93d4c416107d48 commit 1353802af366bd64ba8f730e6f93d4c416107d48 Author: Cristian Adam AuthorDate: Mon Jul 29 19:33:55 2019 +0200 Commit: Cristian Adam CommitDate: Fri Aug 30 20:39:32 2019 +0200 Unity build: Add unit tests diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 48eebcc..8fd5234 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -576,3 +576,4 @@ endif() add_RunCMake_test("CTestCommandExpandLists") add_RunCMake_test(PrecompileHeaders) +add_RunCMake_test("UnityBuild") diff --git a/Tests/RunCMake/UnityBuild/CMakeLists.txt b/Tests/RunCMake/UnityBuild/CMakeLists.txt new file mode 100644 index 0000000..77030d6 --- /dev/null +++ b/Tests/RunCMake/UnityBuild/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.15) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/UnityBuild/RunCMakeTest.cmake b/Tests/RunCMake/UnityBuild/RunCMakeTest.cmake new file mode 100644 index 0000000..8e484d0 --- /dev/null +++ b/Tests/RunCMake/UnityBuild/RunCMakeTest.cmake @@ -0,0 +1,23 @@ +include(RunCMake) + +run_cmake(unitybuild_c) +run_cmake(unitybuild_cxx) +run_cmake(unitybuild_c_and_cxx) +run_cmake(unitybuild_batchsize) +run_cmake(unitybuild_default_batchsize) +run_cmake(unitybuild_skip) +run_cmake(unitybuild_code_before_and_after_include) +run_cmake(unitybuild_c_no_unity_build) +run_cmake(unitybuild_order) + +function(run_test name) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${name}-build) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake(${name}) + run_cmake_command(${name}-build ${CMAKE_COMMAND} --build . --config Debug) + run_cmake_command(${name}-test ${CMAKE_CTEST_COMMAND} -C Debug) + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) +endfunction() + +run_test(unitybuild_runtest) diff --git a/Tests/RunCMake/UnityBuild/func.c b/Tests/RunCMake/UnityBuild/func.c new file mode 100644 index 0000000..b14c907 --- /dev/null +++ b/Tests/RunCMake/UnityBuild/func.c @@ -0,0 +1,6 @@ +#include "func.h" + +int func(void) +{ + return 0; +} diff --git a/Tests/RunCMake/UnityBuild/func.h b/Tests/RunCMake/UnityBuild/func.h new file mode 100644 index 0000000..563a980 --- /dev/null +++ b/Tests/RunCMake/UnityBuild/func.h @@ -0,0 +1,6 @@ +#ifndef func_h +#define func_h + +extern int func(void); + +#endif diff --git a/Tests/RunCMake/UnityBuild/main.c b/Tests/RunCMake/UnityBuild/main.c new file mode 100644 index 0000000..19c18d4 --- /dev/null +++ b/Tests/RunCMake/UnityBuild/main.c @@ -0,0 +1,6 @@ +#include "func.h" + +int main(void) +{ + return func(); +} diff --git a/Tests/RunCMake/UnityBuild/unitybuild_batchsize-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_batchsize-check.cmake new file mode 100644 index 0000000..32bb8e7 --- /dev/null +++ b/Tests/RunCMake/UnityBuild/unitybuild_batchsize-check.cmake @@ -0,0 +1,11 @@ +set(unitybuild_c0 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.c") +set(unitybuild_c1 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_1.c") +if(NOT EXISTS "${unitybuild_c0}") + set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_c0} does not exist.") + return() +endif() + +if(NOT EXISTS "${unitybuild_c1}") + set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_c1} does not exist.") + return() +endif() diff --git a/Tests/RunCMake/UnityBuild/unitybuild_batchsize.cmake b/Tests/RunCMake/UnityBuild/unitybuild_batchsize.cmake new file mode 100644 index 0000000..7caf251 --- /dev/null +++ b/Tests/RunCMake/UnityBuild/unitybuild_batchsize.cmake @@ -0,0 +1,16 @@ +project(unitybuild_batchsize C) + +set(srcs "") +foreach(s RANGE 1 8) + set(src "${CMAKE_CURRENT_BINARY_DIR}/s${s}.c") + file(WRITE "${src}" "int s${s}(void) { return 0; }\n") + list(APPEND srcs "${src}") +endforeach() + +add_library(tgt SHARED ${srcs}) + +set_target_properties(tgt + PROPERTIES + UNITY_BUILD ON + UNITY_BUILD_BATCH_SIZE 4 +) diff --git a/Tests/RunCMake/UnityBuild/unitybuild_c-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_c-check.cmake new file mode 100644 index 0000000..c980df0 --- /dev/null +++ b/Tests/RunCMake/UnityBuild/unitybuild_c-check.cmake @@ -0,0 +1,5 @@ +set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.c") +if(NOT EXISTS "${unitybuild_c}") + set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_c} does not exist.") + return() +endif() diff --git a/Tests/RunCMake/UnityBuild/unitybuild_c.cmake b/Tests/RunCMake/UnityBuild/unitybuild_c.cmake new file mode 100644 index 0000000..77a09cb --- /dev/null +++ b/Tests/RunCMake/UnityBuild/unitybuild_c.cmake @@ -0,0 +1,12 @@ +project(unitybuild_c C) + +set(srcs "") +foreach(s RANGE 1 8) + set(src "${CMAKE_CURRENT_BINARY_DIR}/s${s}.c") + file(WRITE "${src}" "int s${s}(void) { return 0; }\n") + list(APPEND srcs "${src}") +endforeach() + +add_library(tgt SHARED ${srcs}) + +set_target_properties(tgt PROPERTIES UNITY_BUILD ON) diff --git a/Tests/RunCMake/UnityBuild/unitybuild_c_and_cxx-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_c_and_cxx-check.cmake new file mode 100644 index 0000000..32c2992 --- /dev/null +++ b/Tests/RunCMake/UnityBuild/unitybuild_c_and_cxx-check.cmake @@ -0,0 +1,11 @@ +set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.c") +if(NOT EXISTS "${unitybuild_c}") + set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_c} does not exist.") + return() +endif() + +set(unitybuild_cxx "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.cxx") +if(NOT EXISTS "${unitybuild_cxx}") + set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_cxx} does not exist.") + return() +endif() diff --git a/Tests/RunCMake/UnityBuild/unitybuild_c_and_cxx.cmake b/Tests/RunCMake/UnityBuild/unitybuild_c_and_cxx.cmake new file mode 100644 index 0000000..073aff2 --- /dev/null +++ b/Tests/RunCMake/UnityBuild/unitybuild_c_and_cxx.cmake @@ -0,0 +1,17 @@ +project(unitybuild_c_and_cxx C CXX) + +set(srcs "") +foreach(s RANGE 1 8) + set(src_c "${CMAKE_CURRENT_BINARY_DIR}/s${s}.c") + file(WRITE "${src_c}" "int s${s}(void) { return 0; }\n") + + set(src_cxx "${CMAKE_CURRENT_BINARY_DIR}/s${s}.cxx") + file(WRITE "${src_cxx}" "int s${s}(void) { return 0; }\n") + + list(APPEND srcs "${src_c}") + list(APPEND srcs "${src_cxx}") +endforeach() + +add_library(tgt SHARED ${srcs}) + +set_target_properties(tgt PROPERTIES UNITY_BUILD ON) diff --git a/Tests/RunCMake/UnityBuild/unitybuild_c_no_unity_build-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_c_no_unity_build-check.cmake new file mode 100644 index 0000000..cb71ea3 --- /dev/null +++ b/Tests/RunCMake/UnityBuild/unitybuild_c_no_unity_build-check.cmake @@ -0,0 +1,5 @@ +set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.c") +if(EXISTS "${unitybuild_c}") + set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_c} should not exist.") + return() +endif() diff --git a/Tests/RunCMake/UnityBuild/unitybuild_c_no_unity_build.cmake b/Tests/RunCMake/UnityBuild/unitybuild_c_no_unity_build.cmake new file mode 100644 index 0000000..1185e9f --- /dev/null +++ b/Tests/RunCMake/UnityBuild/unitybuild_c_no_unity_build.cmake @@ -0,0 +1,10 @@ +project(unitybuild_c_no_unity_build C) + +set(srcs "") +foreach(s RANGE 1 8) + set(src "${CMAKE_CURRENT_BINARY_DIR}/s${s}.c") + file(WRITE "${src}" "int s${s}(void) { return 0; }\n") + list(APPEND srcs "${src}") +endforeach() + +add_library(tgt SHARED ${srcs}) diff --git a/Tests/RunCMake/UnityBuild/unitybuild_code_before_and_after_include-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_code_before_and_after_include-check.cmake new file mode 100644 index 0000000..8fcb18f --- /dev/null +++ b/Tests/RunCMake/UnityBuild/unitybuild_code_before_and_after_include-check.cmake @@ -0,0 +1,7 @@ +set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.c") +file(STRINGS ${unitybuild_c} unitybuild_c_strings) +string(REGEX MATCH "#define NOMINMAX.*#include.*s1.c.*#undef NOMINMAX" matched_code ${unitybuild_c_strings}) +if(NOT matched_code) + set(RunCMake_TEST_FAILED "Generated unity file doesn't include expected code before and after include") + return() +endif() diff --git a/Tests/RunCMake/UnityBuild/unitybuild_code_before_and_after_include.cmake b/Tests/RunCMake/UnityBuild/unitybuild_code_before_and_after_include.cmake new file mode 100644 index 0000000..cc9cc28 --- /dev/null +++ b/Tests/RunCMake/UnityBuild/unitybuild_code_before_and_after_include.cmake @@ -0,0 +1,13 @@ +project(unitybuild_code_before_and_after_include C) + +set(src "${CMAKE_CURRENT_BINARY_DIR}/s1.c") +file(WRITE "${src}" "int s1(void) { return 0; }\n") + +add_library(tgt SHARED ${src}) + +set_target_properties(tgt + PROPERTIES + UNITY_BUILD ON + UNITY_BUILD_CODE_BEFORE_INCLUDE "#define NOMINMAX" + UNITY_BUILD_CODE_AFTER_INCLUDE "#undef NOMINMAX" +) diff --git a/Tests/RunCMake/UnityBuild/unitybuild_cxx-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_cxx-check.cmake new file mode 100644 index 0000000..89a037a --- /dev/null +++ b/Tests/RunCMake/UnityBuild/unitybuild_cxx-check.cmake @@ -0,0 +1,5 @@ +set(unitybuild_cxx "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.cxx") +if(NOT EXISTS "${unitybuild_cxx}") + set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_cxx} does not exist.") + return() +endif() diff --git a/Tests/RunCMake/UnityBuild/unitybuild_cxx.cmake b/Tests/RunCMake/UnityBuild/unitybuild_cxx.cmake new file mode 100644 index 0000000..be800d7 --- /dev/null +++ b/Tests/RunCMake/UnityBuild/unitybuild_cxx.cmake @@ -0,0 +1,12 @@ +project(unitybuild_cxx CXX) + +set(srcs "") +foreach(s RANGE 1 8) + set(src "${CMAKE_CURRENT_BINARY_DIR}/s${s}.cxx") + file(WRITE "${src}" "int s${s}(void) { return 0; }\n") + list(APPEND srcs "${src}") +endforeach() + +add_library(tgt SHARED ${srcs}) + +set_target_properties(tgt PROPERTIES UNITY_BUILD ON) diff --git a/Tests/RunCMake/UnityBuild/unitybuild_default_batchsize-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_default_batchsize-check.cmake new file mode 100644 index 0000000..7dfc007 --- /dev/null +++ b/Tests/RunCMake/UnityBuild/unitybuild_default_batchsize-check.cmake @@ -0,0 +1,7 @@ +set(unitybuild_c0 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.c") +file(STRINGS ${unitybuild_c0} unitybuild_c_strings REGEX "/s[0-9]+.c\"$" ) +list(LENGTH unitybuild_c_strings number_of_includes) +if(NOT number_of_includes EQUAL 8) + set(RunCMake_TEST_FAILED "Generated unity doesn't include the expect number of files") + return() +endif() diff --git a/Tests/RunCMake/UnityBuild/unitybuild_default_batchsize.cmake b/Tests/RunCMake/UnityBuild/unitybuild_default_batchsize.cmake new file mode 100644 index 0000000..60b9875 --- /dev/null +++ b/Tests/RunCMake/UnityBuild/unitybuild_default_batchsize.cmake @@ -0,0 +1,15 @@ +project(unitybuild_default_batchsize C) + +set(srcs "") +foreach(s RANGE 1 10) + set(src "${CMAKE_CURRENT_BINARY_DIR}/s${s}.c") + file(WRITE "${src}" "int s${s}(void) { return 0; }\n") + list(APPEND srcs "${src}") +endforeach() + +add_library(tgt SHARED ${srcs}) + +set_target_properties(tgt + PROPERTIES + UNITY_BUILD ON +) diff --git a/Tests/RunCMake/UnityBuild/unitybuild_order-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_order-check.cmake new file mode 100644 index 0000000..533a89c --- /dev/null +++ b/Tests/RunCMake/UnityBuild/unitybuild_order-check.cmake @@ -0,0 +1,7 @@ +set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.c") +file(STRINGS ${unitybuild_c} unitybuild_c_strings) +string(REGEX MATCH ".*#include.*s3.c.*#include.*s1.c.*#include.*s2.c.*" matched_code ${unitybuild_c_strings}) +if(NOT matched_code) + set(RunCMake_TEST_FAILED "Generated unity file doesn't include expected oder of source files") + return() +endif() diff --git a/Tests/RunCMake/UnityBuild/unitybuild_order.cmake b/Tests/RunCMake/UnityBuild/unitybuild_order.cmake new file mode 100644 index 0000000..819603d --- /dev/null +++ b/Tests/RunCMake/UnityBuild/unitybuild_order.cmake @@ -0,0 +1,12 @@ +project(unitybuild_order C) + +set(srcs "") +foreach(s 3 1 2) + set(src "${CMAKE_CURRENT_BINARY_DIR}/s${s}.c") + file(WRITE "${src}" "int s${s}(void) { return 0; }\n") + list(APPEND srcs "${src}") +endforeach() + +add_library(tgt SHARED ${srcs}) + +set_target_properties(tgt PROPERTIES UNITY_BUILD ON) diff --git a/Tests/RunCMake/UnityBuild/unitybuild_runtest.cmake b/Tests/RunCMake/UnityBuild/unitybuild_runtest.cmake new file mode 100644 index 0000000..8816299 --- /dev/null +++ b/Tests/RunCMake/UnityBuild/unitybuild_runtest.cmake @@ -0,0 +1,8 @@ +project(unitybuild_runtest C) + +set(CMAKE_UNITY_BUILD ON) # This tests that the variable works in addition to the property + +add_executable(main main.c func.c) + +enable_testing() +add_test(NAME main COMMAND main) diff --git a/Tests/RunCMake/UnityBuild/unitybuild_skip-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_skip-check.cmake new file mode 100644 index 0000000..fdd45bc --- /dev/null +++ b/Tests/RunCMake/UnityBuild/unitybuild_skip-check.cmake @@ -0,0 +1,14 @@ +set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.c") +file(STRINGS ${unitybuild_c} unitybuild_c_strings) + +string(REGEX MATCH "\\/s[1-6].c" matched_files_1_6 ${unitybuild_c_strings}) +if(matched_files_1_6) + set(RunCMake_TEST_FAILED "Generated unity contains s1.c -> s6.c which should have been skipped") + return() +endif() + +string(REGEX MATCH "\\/s[7-8].c" matched_files_7_8 ${unitybuild_c_strings}) +if(NOT matched_files_7_8) + set(RunCMake_TEST_FAILED "Generated unity should have contained s7.c, s8.c!") + return() +endif() diff --git a/Tests/RunCMake/UnityBuild/unitybuild_skip.cmake b/Tests/RunCMake/UnityBuild/unitybuild_skip.cmake new file mode 100644 index 0000000..74524ad --- /dev/null +++ b/Tests/RunCMake/UnityBuild/unitybuild_skip.cmake @@ -0,0 +1,30 @@ +project(unitybuild_skip C) + +set(srcs "") +foreach(s RANGE 1 8) + set(src "${CMAKE_CURRENT_BINARY_DIR}/s${s}.c") + file(WRITE "${src}" "int s${s}(void) { return 0; }\n") + list(APPEND srcs "${src}") +endforeach() + +add_library(tgt SHARED ${srcs}) + +set_target_properties(tgt PROPERTIES UNITY_BUILD ON) + +set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/s1.c + PROPERTIES GENERATED ON) + +set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/s2.c + PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON) + +set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/s3.c + PROPERTIES COMPILE_OPTIONS "val") + +set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/s4.c + PROPERTIES COMPILE_DEFINITIONS "val") + +set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/s5.c + PROPERTIES COMPILE_FLAGS "val") + +set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/s6.c + PROPERTIES INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}") diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index 72154e7..dcdd177 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -34,3 +34,12 @@ endif() if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.20) run_cmake(VsSpectreMitigation) endif() + +# Visual Studio 2017 has toolset version 141 +string(REPLACE "v" "" generator_toolset "${RunCMake_GENERATOR_TOOLSET}") +if (RunCMake_GENERATOR MATCHES "Visual Studio 1[0-4] 201[0-5]" OR + (RunCMake_GENERATOR_TOOLSET AND generator_toolset VERSION_LESS "141")) + run_cmake(UnityBuildPre2017) +else() + run_cmake(UnityBuildNative) +endif() diff --git a/Tests/RunCMake/VS10Project/UnityBuildNative-check.cmake b/Tests/RunCMake/VS10Project/UnityBuildNative-check.cmake new file mode 100644 index 0000000..87f247d --- /dev/null +++ b/Tests/RunCMake/VS10Project/UnityBuildNative-check.cmake @@ -0,0 +1,45 @@ +set(unitybuild_c0 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.c") +if(NOT EXISTS "${unitybuild_c0}") + set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_c0} does not exist.") + return() +endif() + +set(tgt_project "${RunCMake_TEST_BINARY_DIR}/tgt.vcxproj") +if (NOT EXISTS "${tgt_project}") + set(RunCMake_TEST_FAILED "Generated project file ${tgt_project} doesn't exist.") + return() +endif() + +file(STRINGS ${tgt_project} tgt_projects_strings) + +foreach(line IN LISTS tgt_projects_strings) + if (line MATCHES "true") + set(have_unity_support ON) + endif() + + if (line MATCHES " block.") + return() +endif() + +string(REPLACE "\\" "/" unity_source_line "${unity_source_line}") +string(FIND "${unity_source_line}" "CMakeFiles/tgt.dir/Unity/unity_0.c" unity_source_file_position) +if (unity_source_file_position EQUAL "-1") + set(RunCMake_TEST_FAILED "Generated project should include the generated unity source file.") + return() +endif() + +list(LENGTH sources_list number_of_sources) +if(NOT number_of_sources EQUAL 8) + set(RunCMake_TEST_FAILED "Generated project doesn't include the expect number of files.") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/UnityBuildNative.cmake b/Tests/RunCMake/VS10Project/UnityBuildNative.cmake new file mode 100644 index 0000000..77a09cb --- /dev/null +++ b/Tests/RunCMake/VS10Project/UnityBuildNative.cmake @@ -0,0 +1,12 @@ +project(unitybuild_c C) + +set(srcs "") +foreach(s RANGE 1 8) + set(src "${CMAKE_CURRENT_BINARY_DIR}/s${s}.c") + file(WRITE "${src}" "int s${s}(void) { return 0; }\n") + list(APPEND srcs "${src}") +endforeach() + +add_library(tgt SHARED ${srcs}) + +set_target_properties(tgt PROPERTIES UNITY_BUILD ON) diff --git a/Tests/RunCMake/VS10Project/UnityBuildPre2017-check.cmake b/Tests/RunCMake/VS10Project/UnityBuildPre2017-check.cmake new file mode 100644 index 0000000..1c6bab8 --- /dev/null +++ b/Tests/RunCMake/VS10Project/UnityBuildPre2017-check.cmake @@ -0,0 +1,48 @@ +set(unitybuild_c0 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0.c") +if(NOT EXISTS "${unitybuild_c0}") + set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_c0} does not exist.") + return() +endif() + +set(tgt_project "${RunCMake_TEST_BINARY_DIR}/tgt.vcxproj") +if (NOT EXISTS "${tgt_project}") + set(RunCMake_TEST_FAILED "Generated project file ${tgt_project} doesn't exist.") + return() +endif() + +file(STRINGS ${tgt_project} tgt_projects_strings) + +foreach(line IN LISTS tgt_projects_strings) + if (line MATCHES "") + set(unity_source_line ${line}) + endif() + + if (line MATCHES "") + string(REGEX MATCH "" source_file ${line}) + list(APPEND sources_list ${source_file}) + endif() + + if (line MATCHES "") + list(APPEND excluded_sources_list ${source_file}) + endif() +endforeach() + +string(REPLACE "\\" "/" unity_source_line ${unity_source_line}) +string(FIND "${unity_source_line}" "CMakeFiles/tgt.dir/Unity/unity_0.c" unity_source_file_position) +if (unity_source_file_position EQUAL "-1") + set(RunCMake_TEST_FAILED "Generated project should include the generated unity source file.") + return() +endif() + +list(LENGTH sources_list number_of_sources) +if(NOT number_of_sources EQUAL 8) + set(RunCMake_TEST_FAILED "Generated project doesn't include the expect number of files.") + return() +endif() + +# Exclusions for Debug|Release|MinSizeRel|RelWithDebInfo +list(LENGTH excluded_sources_list number_of_excluded_sources) +if(NOT number_of_excluded_sources EQUAL 32) + set(RunCMake_TEST_FAILED "Generated project doesn't exclude the source files for all configurations.") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/UnityBuildPre2017.cmake b/Tests/RunCMake/VS10Project/UnityBuildPre2017.cmake new file mode 100644 index 0000000..77a09cb --- /dev/null +++ b/Tests/RunCMake/VS10Project/UnityBuildPre2017.cmake @@ -0,0 +1,12 @@ +project(unitybuild_c C) + +set(srcs "") +foreach(s RANGE 1 8) + set(src "${CMAKE_CURRENT_BINARY_DIR}/s${s}.c") + file(WRITE "${src}" "int s${s}(void) { return 0; }\n") + list(APPEND srcs "${src}") +endforeach() + +add_library(tgt SHARED ${srcs}) + +set_target_properties(tgt PROPERTIES UNITY_BUILD ON) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8dfeb5d278625c55be1cc82399d29c0305ee4438 commit 8dfeb5d278625c55be1cc82399d29c0305ee4438 Author: Cristian Adam AuthorDate: Mon Jul 29 17:44:55 2019 +0200 Commit: Cristian Adam CommitDate: Thu Aug 29 16:45:42 2019 +0200 Unity build: Add support for Visual Studio generator It works as expected in Visual Studio. Visual Studio 2017 will (partially) benefit from the build in support for unity builds. The custom unity sources are used, because the build in support doesn't allow batching of certain number of files. It can do only batching by directory. diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 6fade3e..6249c28 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2266,7 +2266,10 @@ void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target, for (; begin != end; ++begin) { cmSourceFile* sf = filtered_sources[begin]; - sf->SetProperty("HEADER_FILE_ONLY", "ON"); + if (!this->GetGlobalGenerator()->IsMultiConfig()) { + sf->SetProperty("HEADER_FILE_ONLY", "ON"); + } + sf->SetProperty("UNITY_SOURCE_FILE", filename.c_str()); if (beforeInclude) { file << beforeInclude << "\n"; @@ -2283,6 +2286,10 @@ void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target, cmSystemTools::RemoveFile(filename_tmp); target->AddSource(filename, true); + + auto unity = this->Makefile->GetOrCreateSource(filename); + unity->SetProperty("SKIP_UNITY_BUILD_INCLUSION", "ON"); + unity->SetProperty("UNITY_SOURCE_FILE", filename.c_str()); } } } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 795cee4..e9335c6 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1320,6 +1320,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, const std::string& libName, cmGeneratorTarget* target) { + this->AddUnityBuild(target, ""); this->AddPchDependencies(target, ""); std::vector configs; @@ -1508,8 +1509,11 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo( const std::string& linkLanguage = gt->GetLinkerLanguage(config.c_str()); // If HEADER_FILE_ONLY is set, we must suppress this generation in // the project file - fc.ExcludedFromBuild = - sf.GetPropertyAsBool("HEADER_FILE_ONLY") || !cmContains(acs.Configs, ci); + fc.ExcludedFromBuild = sf.GetPropertyAsBool("HEADER_FILE_ONLY") || + !cmContains(acs.Configs, ci) || + (gt->GetPropertyAsBool("UNITY_BUILD") && + sf.GetProperty("UNITY_SOURCE_FILE") && + !sf.GetPropertyAsBool("SKIP_UNITY_BUILD_INCLUSION")); if (fc.ExcludedFromBuild) { needfc = true; } diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index b4f05c7..08ad1c0 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -250,6 +250,7 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator( this->InSourceBuild = (this->Makefile->GetCurrentSourceDirectory() == this->Makefile->GetCurrentBinaryDirectory()); + this->LocalGenerator->AddUnityBuild(target, ""); this->LocalGenerator->AddPchDependencies(target, ""); } @@ -2049,6 +2050,17 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0) if (this->GeneratorTarget->GetType() > cmStateEnums::UTILITY) { return; } + + const bool haveUnityBuild = + this->GeneratorTarget->GetPropertyAsBool("UNITY_BUILD"); + + if (haveUnityBuild && + this->GlobalGenerator->GetVersion() >= + cmGlobalVisualStudioGenerator::VS15) { + Elem e1(e0, "PropertyGroup"); + e1.Element("EnableUnitySupport", "true"); + } + Elem e1(e0, "ItemGroup"); e1.SetHasElements(); @@ -2147,6 +2159,45 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0) Elem e2(e1, tool); this->WriteSource(e2, si.Source); + + bool useNativeUnityBuild = false; + if (haveUnityBuild && + this->GlobalGenerator->GetVersion() >= + cmGlobalVisualStudioGenerator::VS15) { + // Magic value taken from cmGlobalVisualStudioVersionedGenerator.cxx + static const std::string vs15 = "141"; + std::string toolset = + this->GlobalGenerator->GetPlatformToolsetString(); + cmSystemTools::ReplaceString(toolset, "v", ""); + + if (toolset.empty() || + cmSystemTools::VersionCompareGreaterEq(toolset, vs15)) { + useNativeUnityBuild = true; + } + } + + if (haveUnityBuild && strcmp(tool, "ClCompile") == 0 && + si.Source->GetProperty("UNITY_SOURCE_FILE")) { + if (useNativeUnityBuild) { + e2.Attribute( + "IncludeInUnityFile", + si.Source->GetPropertyAsBool("SKIP_UNITY_BUILD_INCLUSION") + ? "false" + : "true"); + e2.Attribute("CustomUnityFile", "true"); + + std::string unityDir = cmSystemTools::GetFilenamePath( + si.Source->GetProperty("UNITY_SOURCE_FILE")); + e2.Attribute("UnityFilesDirectory", unityDir); + } else { + // Visual Studio versions prior to 2017 do not know about unity + // builds, thus we exclude the files alredy part of unity sources. + if (!si.Source->GetPropertyAsBool("SKIP_UNITY_BUILD_INCLUSION")) { + exclude_configs = si.Configs; + } + } + } + if (si.Kind == cmGeneratorTarget::SourceKindObjectSource) { this->OutputSourceSpecificFlags(e2, si.Source); } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7114c141e27532df709fcae1266bb4ce9b6e850c commit 7114c141e27532df709fcae1266bb4ce9b6e850c Author: Cristian Adam AuthorDate: Fri Jul 26 16:08:32 2019 +0200 Commit: Cristian Adam CommitDate: Thu Aug 29 16:44:09 2019 +0200 Unity build: Add support for Ninja and Makefile generators diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 25d6b24..19afb7d 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -323,6 +323,10 @@ Properties on Targets /prop_tgt/Swift_MODULE_DIRECTORY /prop_tgt/Swift_MODULE_NAME /prop_tgt/TYPE + /prop_tgt/UNITY_BUILD + /prop_tgt/UNITY_BUILD_BATCH_SIZE + /prop_tgt/UNITY_BUILD_CODE_AFTER_INCLUDE + /prop_tgt/UNITY_BUILD_CODE_BEFORE_INCLUDE /prop_tgt/VERSION /prop_tgt/VISIBILITY_INLINES_HIDDEN /prop_tgt/VS_CONFIGURATION_TYPE @@ -450,6 +454,7 @@ Properties on Source Files /prop_sf/SKIP_AUTORCC /prop_sf/SKIP_AUTOUIC /prop_sf/SKIP_PRECOMPILE_HEADERS + /prop_sf/SKIP_UNITY_BUILD_INCLUSION /prop_sf/Swift_DEPENDENCIES_FILE /prop_sf/Swift_DIAGNOSTICS_FILE /prop_sf/SYMBOLIC diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 0ae1ebe..739e4b5 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -431,6 +431,8 @@ Variables that Control the Build /variable/CMAKE_TRY_COMPILE_CONFIGURATION /variable/CMAKE_TRY_COMPILE_PLATFORM_VARIABLES /variable/CMAKE_TRY_COMPILE_TARGET_TYPE + /variable/CMAKE_UNITY_BUILD + /variable/CMAKE_UNITY_BUILD_BATCH_SIZE /variable/CMAKE_USE_RELATIVE_PATHS /variable/CMAKE_VISIBILITY_INLINES_HIDDEN /variable/CMAKE_VS_GLOBALS diff --git a/Help/prop_sf/SKIP_UNITY_BUILD_INCLUSION.rst b/Help/prop_sf/SKIP_UNITY_BUILD_INCLUSION.rst new file mode 100644 index 0000000..53f3970 --- /dev/null +++ b/Help/prop_sf/SKIP_UNITY_BUILD_INCLUSION.rst @@ -0,0 +1,7 @@ +SKIP_UNITY_BUILD_INCLUSION +-------------------------- + +Is this source file skipped by :prop_tgt:`UNITY_BUILD` feature. + +This property helps with "ODR (One definition rule)" problems +that one would run into when using an :prop_tgt:`UNITY_BUILD`. diff --git a/Help/prop_tgt/UNITY_BUILD.rst b/Help/prop_tgt/UNITY_BUILD.rst new file mode 100644 index 0000000..d326ee2 --- /dev/null +++ b/Help/prop_tgt/UNITY_BUILD.rst @@ -0,0 +1,55 @@ +UNITY_BUILD +----------- + +Should the target source files be processed into batches for +faster compilation. This feature is known as "Unity build", +or "Jumbo build". + +The `C` and `CXX` source files are grouped separately. + +This property is initialized by the value of the +:variable:`CMAKE_UNITY_BUILD` variable if it is set when +a target is created. + +.. note :: + + It's not recommended to directly set :prop_tgt:`UNITY_BUILD` + to `ON`, but to instead set :variable:`CMAKE_UNITY_BUILD` from + the command line. However, it IS recommended to set + :prop_tgt:`UNITY_BUILD` to `OFF` if you need to ensure that a + target doesn't get a unity build. + +The batch size can be specified by setting +:prop_tgt:`UNITY_BUILD_BATCH_SIZE`. + +The batching of source files is done by adding new sources files +wich will `#include` the source files, and exclude them from +building by setting :prop_sf:`HEADER_FILE_ONLY` to `ON`. + + +ODR (One definition rule) errors +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Since multiple source files are included into one source file, +it can lead to ODR errors. This section contains properites +which help fixing these errors. + +The source files marked by :prop_sf:`GENERATED` will be skipped +from unity build. This applies also for the source files marked +with :prop_sf:`SKIP_UNITY_BUILD_INCLUSION`. + +The source files that have :prop_sf:`COMPILE_OPTIONS`, +:prop_sf:`COMPILE_DEFINITIONS`, :prop_sf:`COMPILE_FLAGS`, or +:prop_sf:`INCLUDE_DIRECTORIES` will also be skipped. + +With the :prop_tgt:`UNITY_BUILD_CODE_BEFORE_INCLUDE` and +:prop_tgt:`UNITY_BUILD_CODE_AFTER_INCLUDE` one can specify code +to be injected in the unity source file before and after every +`#include` statement. + +.. note :: + + The order of source files defined in the `CMakeLists.txt` will + be preserved into the generated unity source files. This can + be used to manually enforce a specific grouping based on the + :prop_tgt:`UNITY_BUILD_BATCH_SIZE`. diff --git a/Help/prop_tgt/UNITY_BUILD_BATCH_SIZE.rst b/Help/prop_tgt/UNITY_BUILD_BATCH_SIZE.rst new file mode 100644 index 0000000..2426689 --- /dev/null +++ b/Help/prop_tgt/UNITY_BUILD_BATCH_SIZE.rst @@ -0,0 +1,13 @@ +UNITY_BUILD_BATCH_SIZE +---------------------- + +Specifies how many source code files will be included into a +:prop_tgt:`UNITY_BUILD` source file. + +If the property is not set, CMake will use the value provided +by :variable:`CMAKE_UNITY_BUILD_BATCH_SIZE`. + +By setting it to value `0` the generated unity source file will +contain all the source files that would be otherwise be split +into multiple batches. It is not recommended to do so, since it +would affect performance. diff --git a/Help/prop_tgt/UNITY_BUILD_CODE_AFTER_INCLUDE.rst b/Help/prop_tgt/UNITY_BUILD_CODE_AFTER_INCLUDE.rst new file mode 100644 index 0000000..7795289 --- /dev/null +++ b/Help/prop_tgt/UNITY_BUILD_CODE_AFTER_INCLUDE.rst @@ -0,0 +1,8 @@ +UNITY_BUILD_CODE_AFTER_INCLUDE +------------------------------ + +Code snippet which is included verbatim by the :prop_tgt:`UNITY_BUILD` +feature just after the `#include` statement of the targeted source +files. + +This could be something like `#undef NOMINMAX`. diff --git a/Help/prop_tgt/UNITY_BUILD_CODE_BEFORE_INCLUDE.rst b/Help/prop_tgt/UNITY_BUILD_CODE_BEFORE_INCLUDE.rst new file mode 100644 index 0000000..f335463 --- /dev/null +++ b/Help/prop_tgt/UNITY_BUILD_CODE_BEFORE_INCLUDE.rst @@ -0,0 +1,8 @@ +UNITY_BUILD_CODE_BEFORE_INCLUDE +------------------------------- + +Code snippet which is included verbatim by the :prop_tgt:`UNITY_BUILD` +feature just before the `#include` statement of the targeted source +files. + +This could be something like `#define NOMINMAX`. diff --git a/Help/release/dev/unity-build.rst b/Help/release/dev/unity-build.rst new file mode 100644 index 0000000..293a375 --- /dev/null +++ b/Help/release/dev/unity-build.rst @@ -0,0 +1,6 @@ +Unity build +----------- + +* The :prop_tgt:`UNITY_BUILD` target property was added to tell + generators to batch include source files for faster compilation + times. diff --git a/Help/variable/CMAKE_UNITY_BUILD.rst b/Help/variable/CMAKE_UNITY_BUILD.rst new file mode 100644 index 0000000..3096954 --- /dev/null +++ b/Help/variable/CMAKE_UNITY_BUILD.rst @@ -0,0 +1,6 @@ +CMAKE_UNITY_BUILD +----------------- + +Default value for :prop_tgt:`UNITY_BUILD` of targets. + +By default ``CMAKE_UNITY_BUILD`` is ``OFF``. diff --git a/Help/variable/CMAKE_UNITY_BUILD_BATCH_SIZE.rst b/Help/variable/CMAKE_UNITY_BUILD_BATCH_SIZE.rst new file mode 100644 index 0000000..3ab2344 --- /dev/null +++ b/Help/variable/CMAKE_UNITY_BUILD_BATCH_SIZE.rst @@ -0,0 +1,6 @@ +CMAKE_UNITY_BUILD_BATCH_SIZE +---------------------------- + +Default value for :prop_tgt:`UNITY_BUILD_BATCH_SIZE` of targets. + +By default ``CMAKE_UNITY_BUILD_BATCH_SIZE`` is set to ``8``. diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 7177694..6fade3e 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -38,6 +38,7 @@ #include #include +#include #include #include #include @@ -2202,6 +2203,90 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target, } } +void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target, + const std::string& config) +{ + if (!target->GetPropertyAsBool("UNITY_BUILD")) { + return; + } + + const std::string buildType = cmSystemTools::UpperCase(config); + + std::string filename_base = + cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles/", + target->GetName(), ".dir/Unity/"); + + std::vector sources; + target->GetSourceFiles(sources, buildType); + + auto batchSizeString = target->GetProperty("UNITY_BUILD_BATCH_SIZE"); + const size_t unityBatchSize = + static_cast(std::atoi(batchSizeString)); + + auto beforeInclude = target->GetProperty("UNITY_BUILD_CODE_BEFORE_INCLUDE"); + auto afterInclude = target->GetProperty("UNITY_BUILD_CODE_AFTER_INCLUDE"); + + for (std::string lang : { "C", "CXX" }) { + std::vector filtered_sources; + std::copy_if(sources.begin(), sources.end(), + std::back_inserter(filtered_sources), [&](cmSourceFile* sf) { + return sf->GetLanguage() == lang && + !sf->GetPropertyAsBool("SKIP_UNITY_BUILD_INCLUSION") && + !sf->GetPropertyAsBool("GENERATED") && + !sf->GetProperty("COMPILE_OPTIONS") && + !sf->GetProperty("COMPILE_DEFINITIONS") && + !sf->GetProperty("COMPILE_FLAGS") && + !sf->GetProperty("INCLUDE_DIRECTORIES"); + }); + + size_t batchSize = unityBatchSize; + if (unityBatchSize == 0) { + batchSize = filtered_sources.size(); + } + + for (size_t itemsLeft = filtered_sources.size(), chunk = batchSize, + batch = 0; + itemsLeft > 0; itemsLeft -= chunk, ++batch) { + + chunk = std::min(itemsLeft, batchSize); + + std::string filename = cmStrCat(filename_base, "unity_", batch, + (lang == "C") ? ".c" : ".cxx"); + + const std::string filename_tmp = cmStrCat(filename, ".tmp"); + { + size_t begin = batch * batchSize; + size_t end = begin + chunk; + + cmGeneratedFileStream file( + filename_tmp, false, + this->GetGlobalGenerator()->GetMakefileEncoding()); + file << "/* generated by CMake */\n\n"; + + for (; begin != end; ++begin) { + cmSourceFile* sf = filtered_sources[begin]; + + sf->SetProperty("HEADER_FILE_ONLY", "ON"); + + if (beforeInclude) { + file << beforeInclude << "\n"; + } + + file << "#include \"" << sf->GetFullPath() << "\"\n"; + + if (afterInclude) { + file << afterInclude << "\n"; + } + } + } + cmSystemTools::CopyFileIfDifferent(filename_tmp, filename); + cmSystemTools::RemoveFile(filename_tmp); + + target->AddSource(filename, true); + } + } +} + void cmLocalGenerator::AppendIPOLinkerFlags(std::string& flags, cmGeneratorTarget* target, const std::string& config, diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index f63fe0f..515ffae 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -126,6 +126,7 @@ public: const std::string& rawFlag) const; void AddPchDependencies(cmGeneratorTarget* target, const std::string& config); + void AddUnityBuild(cmGeneratorTarget* target, const std::string& config); void AppendIPOLinkerFlags(std::string& flags, cmGeneratorTarget* target, const std::string& config, const std::string& lang); diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index bebd5c4..002addf 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -41,6 +41,7 @@ cmMakefileExecutableTargetGenerator::cmMakefileExecutableTargetGenerator( cm::make_unique(target, this->ConfigName); this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders); + this->LocalGenerator->AddUnityBuild(target, this->ConfigName); this->LocalGenerator->AddPchDependencies(target, this->ConfigName); } diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 4244402..d603dac 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -43,6 +43,7 @@ cmMakefileLibraryTargetGenerator::cmMakefileLibraryTargetGenerator( cm::make_unique(target, this->ConfigName); this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders); + this->LocalGenerator->AddUnityBuild(target, this->ConfigName); this->LocalGenerator->AddPchDependencies(target, this->ConfigName); } diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx index 556191f..d4045b3 100644 --- a/Source/cmMakefileUtilityTargetGenerator.cxx +++ b/Source/cmMakefileUtilityTargetGenerator.cxx @@ -26,6 +26,7 @@ cmMakefileUtilityTargetGenerator::cmMakefileUtilityTargetGenerator( cm::make_unique(target, this->ConfigName); this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders); + this->LocalGenerator->AddUnityBuild(target, this->ConfigName); this->LocalGenerator->AddPchDependencies(target, this->ConfigName); } diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 0e3aa3a..a4e1d61 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -60,6 +60,7 @@ cmNinjaNormalTargetGenerator::cmNinjaNormalTargetGenerator( cm::make_unique(target, this->GetConfigName()); this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders); + GetLocalGenerator()->AddUnityBuild(target, this->GetConfigName()); GetLocalGenerator()->AddPchDependencies(target, this->GetConfigName()); } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 2a09b43..10ea7dd 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -352,6 +352,8 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, initProp("Swift_MODULE_DIRECTORY"); initProp("VS_JUST_MY_CODE_DEBUGGING"); initProp("DISABLE_PRECOMPILE_HEADERS"); + initProp("UNITY_BUILD"); + initPropValue("UNITY_BUILD_BATCH_SIZE", "8"); #ifdef __APPLE__ if (this->GetGlobalGenerator()->IsXcode()) { initProp("XCODE_GENERATE_SCHEME"); ----------------------------------------------------------------------- Summary of changes: Help/manual/cmake-properties.7.rst | 5 ++ Help/manual/cmake-variables.7.rst | 2 + Help/prop_sf/SKIP_UNITY_BUILD_INCLUSION.rst | 7 ++ Help/prop_tgt/UNITY_BUILD.rst | 55 +++++++++++++ Help/prop_tgt/UNITY_BUILD_BATCH_SIZE.rst | 13 +++ Help/prop_tgt/UNITY_BUILD_CODE_AFTER_INCLUDE.rst | 8 ++ Help/prop_tgt/UNITY_BUILD_CODE_BEFORE_INCLUDE.rst | 8 ++ Help/release/dev/unity-build.rst | 6 ++ Help/variable/CMAKE_UNITY_BUILD.rst | 6 ++ Help/variable/CMAKE_UNITY_BUILD_BATCH_SIZE.rst | 6 ++ Source/cmGlobalXCodeGenerator.cxx | 1 + Source/cmLocalGenerator.cxx | 96 ++++++++++++++++++++++ Source/cmLocalGenerator.h | 1 + Source/cmLocalVisualStudio7Generator.cxx | 8 +- Source/cmMakefileExecutableTargetGenerator.cxx | 1 + Source/cmMakefileLibraryTargetGenerator.cxx | 1 + Source/cmMakefileUtilityTargetGenerator.cxx | 1 + Source/cmNinjaNormalTargetGenerator.cxx | 1 + Source/cmTarget.cxx | 2 + Source/cmVisualStudio10TargetGenerator.cxx | 51 ++++++++++++ Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/UnityBuild/CMakeLists.txt | 3 + Tests/RunCMake/UnityBuild/RunCMakeTest.cmake | 23 ++++++ Tests/RunCMake/UnityBuild/func.c | 6 ++ Tests/RunCMake/UnityBuild/func.h | 6 ++ Tests/RunCMake/UnityBuild/main.c | 6 ++ .../UnityBuild/unitybuild_batchsize-check.cmake | 11 +++ .../RunCMake/UnityBuild/unitybuild_batchsize.cmake | 16 ++++ Tests/RunCMake/UnityBuild/unitybuild_c-check.cmake | 5 ++ Tests/RunCMake/UnityBuild/unitybuild_c.cmake | 12 +++ .../UnityBuild/unitybuild_c_and_cxx-check.cmake | 11 +++ .../RunCMake/UnityBuild/unitybuild_c_and_cxx.cmake | 17 ++++ .../unitybuild_c_no_unity_build-check.cmake | 5 ++ .../UnityBuild/unitybuild_c_no_unity_build.cmake | 10 +++ ...build_code_before_and_after_include-check.cmake | 7 ++ .../unitybuild_code_before_and_after_include.cmake | 13 +++ .../RunCMake/UnityBuild/unitybuild_cxx-check.cmake | 5 ++ Tests/RunCMake/UnityBuild/unitybuild_cxx.cmake | 12 +++ .../unitybuild_default_batchsize-check.cmake | 7 ++ .../UnityBuild/unitybuild_default_batchsize.cmake | 15 ++++ .../UnityBuild/unitybuild_order-check.cmake | 7 ++ Tests/RunCMake/UnityBuild/unitybuild_order.cmake | 12 +++ Tests/RunCMake/UnityBuild/unitybuild_runtest.cmake | 8 ++ .../UnityBuild/unitybuild_skip-check.cmake | 14 ++++ Tests/RunCMake/UnityBuild/unitybuild_skip.cmake | 30 +++++++ Tests/RunCMake/VS10Project/RunCMakeTest.cmake | 9 ++ .../VS10Project/UnityBuildNative-check.cmake | 45 ++++++++++ Tests/RunCMake/VS10Project/UnityBuildNative.cmake | 12 +++ .../VS10Project/UnityBuildPre2017-check.cmake | 48 +++++++++++ Tests/RunCMake/VS10Project/UnityBuildPre2017.cmake | 12 +++ 50 files changed, 665 insertions(+), 2 deletions(-) create mode 100644 Help/prop_sf/SKIP_UNITY_BUILD_INCLUSION.rst create mode 100644 Help/prop_tgt/UNITY_BUILD.rst create mode 100644 Help/prop_tgt/UNITY_BUILD_BATCH_SIZE.rst create mode 100644 Help/prop_tgt/UNITY_BUILD_CODE_AFTER_INCLUDE.rst create mode 100644 Help/prop_tgt/UNITY_BUILD_CODE_BEFORE_INCLUDE.rst create mode 100644 Help/release/dev/unity-build.rst create mode 100644 Help/variable/CMAKE_UNITY_BUILD.rst create mode 100644 Help/variable/CMAKE_UNITY_BUILD_BATCH_SIZE.rst create mode 100644 Tests/RunCMake/UnityBuild/CMakeLists.txt create mode 100644 Tests/RunCMake/UnityBuild/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/UnityBuild/func.c create mode 100644 Tests/RunCMake/UnityBuild/func.h create mode 100644 Tests/RunCMake/UnityBuild/main.c create mode 100644 Tests/RunCMake/UnityBuild/unitybuild_batchsize-check.cmake create mode 100644 Tests/RunCMake/UnityBuild/unitybuild_batchsize.cmake create mode 100644 Tests/RunCMake/UnityBuild/unitybuild_c-check.cmake create mode 100644 Tests/RunCMake/UnityBuild/unitybuild_c.cmake create mode 100644 Tests/RunCMake/UnityBuild/unitybuild_c_and_cxx-check.cmake create mode 100644 Tests/RunCMake/UnityBuild/unitybuild_c_and_cxx.cmake create mode 100644 Tests/RunCMake/UnityBuild/unitybuild_c_no_unity_build-check.cmake create mode 100644 Tests/RunCMake/UnityBuild/unitybuild_c_no_unity_build.cmake create mode 100644 Tests/RunCMake/UnityBuild/unitybuild_code_before_and_after_include-check.cmake create mode 100644 Tests/RunCMake/UnityBuild/unitybuild_code_before_and_after_include.cmake create mode 100644 Tests/RunCMake/UnityBuild/unitybuild_cxx-check.cmake create mode 100644 Tests/RunCMake/UnityBuild/unitybuild_cxx.cmake create mode 100644 Tests/RunCMake/UnityBuild/unitybuild_default_batchsize-check.cmake create mode 100644 Tests/RunCMake/UnityBuild/unitybuild_default_batchsize.cmake create mode 100644 Tests/RunCMake/UnityBuild/unitybuild_order-check.cmake create mode 100644 Tests/RunCMake/UnityBuild/unitybuild_order.cmake create mode 100644 Tests/RunCMake/UnityBuild/unitybuild_runtest.cmake create mode 100644 Tests/RunCMake/UnityBuild/unitybuild_skip-check.cmake create mode 100644 Tests/RunCMake/UnityBuild/unitybuild_skip.cmake create mode 100644 Tests/RunCMake/VS10Project/UnityBuildNative-check.cmake create mode 100644 Tests/RunCMake/VS10Project/UnityBuildNative.cmake create mode 100644 Tests/RunCMake/VS10Project/UnityBuildPre2017-check.cmake create mode 100644 Tests/RunCMake/VS10Project/UnityBuildPre2017.cmake hooks/post-receive -- CMake From kwrobot at kitware.com Thu Sep 5 09:11:18 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 5 Sep 2019 09:11:18 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-959-g6db8f6a Message-ID: <20190905131119.18677109298@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 6db8f6a410d99e9a66847530bb520b329d2f1a9e (commit) via 3beb2c440badc293c7cf783abe0f1f5e9fb6f497 (commit) from ac4d6d4a9d9b81773e61c643169cb2afe1bab644 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6db8f6a410d99e9a66847530bb520b329d2f1a9e commit 6db8f6a410d99e9a66847530bb520b329d2f1a9e Merge: ac4d6d4 3beb2c4 Author: Brad King AuthorDate: Thu Sep 5 13:07:22 2019 +0000 Commit: Kitware Robot CommitDate: Thu Sep 5 09:07:30 2019 -0400 Merge topic 'doc-remove_directory-symlink' 3beb2c440b cmake: Document -E remove_directory symlink behavior Acked-by: Kitware Robot Merge-request: !3784 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3beb2c440badc293c7cf783abe0f1f5e9fb6f497 commit 3beb2c440badc293c7cf783abe0f1f5e9fb6f497 Author: Brad King AuthorDate: Thu Sep 5 08:30:09 2019 -0400 Commit: Brad King CommitDate: Thu Sep 5 08:31:49 2019 -0400 cmake: Document -E remove_directory symlink behavior Update documentation for the change made by commit e6c9a8bac3 (cmake: Teach -E remove_directory to remove directory symlinks, 2019-08-26). Also add a release note. Issue: #19533 diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index 0645e41..2576cde 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -536,7 +536,8 @@ Available commands are: ``remove_directory ...`` Remove ```` directories and their contents. If a directory does - not exist it will be silently ignored. + not exist it will be silently ignored. If ```` is a symlink to + a directory, just the symlink will be removed. ``rename `` Rename a file or directory (on one volume). If file with the ```` name diff --git a/Help/release/dev/remove_directory-symlink.rst b/Help/release/dev/remove_directory-symlink.rst new file mode 100644 index 0000000..0896388 --- /dev/null +++ b/Help/release/dev/remove_directory-symlink.rst @@ -0,0 +1,6 @@ +remove_directory-symlink +------------------------ + +* The :manual:`cmake(1)` ``-E remove_directory`` command-line tool, + when given the path to a symlink to a directory, now removes just + the symlink. It no longer removes content of the linked directory. ----------------------------------------------------------------------- Summary of changes: Help/manual/cmake.1.rst | 3 ++- Help/release/dev/remove_directory-symlink.rst | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 Help/release/dev/remove_directory-symlink.rst hooks/post-receive -- CMake From kwrobot at kitware.com Thu Sep 5 20:11:05 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 5 Sep 2019 20:11:05 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-961-ga2d4968 Message-ID: <20190906001105.9C5C210339B@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via a2d4968ab914d5cf02457306ec8f76177a794520 (commit) via 611eb26b9db1b0ff1e83a6983b6cdf79f2dca0d5 (commit) from 6db8f6a410d99e9a66847530bb520b329d2f1a9e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a2d4968ab914d5cf02457306ec8f76177a794520 commit a2d4968ab914d5cf02457306ec8f76177a794520 Merge: 6db8f6a 611eb26 Author: Craig Scott AuthorDate: Fri Sep 6 00:03:30 2019 +0000 Commit: Kitware Robot CommitDate: Thu Sep 5 20:03:55 2019 -0400 Merge topic 'doxygen-add-docs-USE_STAMP_FILE' 611eb26b9d FindDoxygen: add USE_STAMP_FILE option Acked-by: Kitware Robot Merge-request: !3238 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=611eb26b9db1b0ff1e83a6983b6cdf79f2dca0d5 commit 611eb26b9db1b0ff1e83a6983b6cdf79f2dca0d5 Author: Nikita Sirgienko AuthorDate: Tue Apr 16 14:37:45 2019 +0300 Commit: Craig Scott CommitDate: Fri Sep 6 09:12:09 2019 +1000 FindDoxygen: add USE_STAMP_FILE option The new option enables the behavior of only building if sources change. diff --git a/Help/release/dev/doxygen-add-docs-USE_STAMP_FILE.rst b/Help/release/dev/doxygen-add-docs-USE_STAMP_FILE.rst new file mode 100644 index 0000000..700ee6c --- /dev/null +++ b/Help/release/dev/doxygen-add-docs-USE_STAMP_FILE.rst @@ -0,0 +1,7 @@ +doxygen-add-docs-USE_STAMP_FILE +------------------------------- + +* The :command:`doxygen_add_docs` command from the :module:`FindDoxygen` + module gained a new ``USE_STAMP_FILE`` option. When this option present, + the custom target created by the command will only re-run Doxygen if any + of the source files have changed since the last successful run. diff --git a/Modules/FindDoxygen.cmake b/Modules/FindDoxygen.cmake index ebd0b24..faa03f9 100644 --- a/Modules/FindDoxygen.cmake +++ b/Modules/FindDoxygen.cmake @@ -70,6 +70,7 @@ Functions doxygen_add_docs(targetName [filesOrDirs...] [ALL] + [USE_STAMP_FILE] [WORKING_DIRECTORY dir] [COMMENT comment]) @@ -92,7 +93,19 @@ Functions the :command:`add_custom_target` command used to create the custom target internally. - If ALL is set, the target will be added to the default build target. + If ``ALL`` is set, the target will be added to the default build target. + + If ``USE_STAMP_FILE`` is set, the custom command defined by this function will + create a stamp file with the name ``.stamp`` in the current + binary directory whenever doxygen is re-run. With this option present, all + items in ```` must be files (i.e. no directories, symlinks or + wildcards) and each of the files must exist at the time + ``doxygen_add_docs()`` is called. An error will be raised if any of the + items listed is missing or is not a file when ``USE_STAMP_FILE`` is given. + A dependency will be created on each of the files so that doxygen will only + be re-run if one of the files is updated. Without the ``USE_STAMP_FILE`` + option, doxygen will always be re-run if the ```` target is built + regardless of whether anything listed in ```` has changed. The contents of the generated ``Doxyfile`` can be customized by setting CMake variables before calling ``doxygen_add_docs()``. Any variable with a name of @@ -801,7 +814,7 @@ function(doxygen_list_to_quoted_strings LIST_VARIABLE) endfunction() function(doxygen_add_docs targetName) - set(_options ALL) + set(_options ALL USE_STAMP_FILE) set(_one_value_args WORKING_DIRECTORY COMMENT) set(_multi_value_args) cmake_parse_arguments(_args @@ -978,9 +991,10 @@ doxygen_add_docs() for target ${targetName}") endif() # Build up a list of files we can identify from the inputs so we can list - # them as SOURCES in the custom target (makes them display in IDEs). We - # must do this before we transform the various DOXYGEN_... variables below - # because we need to process DOXYGEN_INPUT as a list first. + # them as DEPENDS and SOURCES in the custom command/target (the latter + # makes them display in IDEs). This must be done before we transform the + # various DOXYGEN_... variables below because we need to process + # DOXYGEN_INPUT as a list first. unset(_sources) foreach(_item IN LISTS DOXYGEN_INPUT) get_filename_component(_abs_item "${_item}" ABSOLUTE @@ -989,11 +1003,13 @@ doxygen_add_docs() for target ${targetName}") NOT IS_DIRECTORY "${_abs_item}" AND NOT IS_SYMLINK "${_abs_item}") list(APPEND _sources "${_abs_item}") + elseif(_args_USE_STAMP_FILE) + message(FATAL_ERROR "Source does not exist or is not a file:\n" + " ${_abs_item}\n" + "Only existing files may be specified when the " + "USE_STAMP_FILE option is given.") endif() endforeach() - if(_sources) - list(INSERT _sources 0 SOURCES) - endif() # Transform known list type options into space separated strings. set(_doxygen_list_options @@ -1107,15 +1123,35 @@ doxygen_add_docs() for target ${targetName}") set(_all ALL) endif() - # Add the target - add_custom_target( ${targetName} ${_all} VERBATIM - COMMAND ${CMAKE_COMMAND} -E make_directory ${_original_doxygen_output_dir} - COMMAND "${DOXYGEN_EXECUTABLE}" "${_target_doxyfile}" - WORKING_DIRECTORY "${_args_WORKING_DIRECTORY}" - DEPENDS "${_target_doxyfile}" - COMMENT "${_args_COMMENT}" - ${_sources} - ) + # Only create the stamp file if asked to. If we don't create it, + # the target will always be considered out-of-date. + if(_args_USE_STAMP_FILE) + set(__stamp_file "${CMAKE_CURRENT_BINARY_DIR}/${targetName}.stamp") + add_custom_command( + VERBATIM + OUTPUT ${__stamp_file} + COMMAND ${CMAKE_COMMAND} -E make_directory ${_original_doxygen_output_dir} + COMMAND "${DOXYGEN_EXECUTABLE}" "${_target_doxyfile}" + COMMAND ${CMAKE_COMMAND} -E touch ${__stamp_file} + WORKING_DIRECTORY "${_args_WORKING_DIRECTORY}" + DEPENDS "${_target_doxyfile}" ${_sources} + COMMENT "${_args_COMMENT}" + ) + add_custom_target(${targetName} ${_all} + DEPENDS ${__stamp_file} + SOURCES ${_sources} + ) + unset(__stamp_file) + else() + add_custom_target( ${targetName} ${_all} VERBATIM + COMMAND ${CMAKE_COMMAND} -E make_directory ${_original_doxygen_output_dir} + COMMAND "${DOXYGEN_EXECUTABLE}" "${_target_doxyfile}" + WORKING_DIRECTORY "${_args_WORKING_DIRECTORY}" + DEPENDS "${_target_doxyfile}" ${_sources} + COMMENT "${_args_COMMENT}" + SOURCES ${_sources} + ) + endif() endfunction() diff --git a/Tests/FindDoxygen/CMakeLists.txt b/Tests/FindDoxygen/CMakeLists.txt index 7ce98d5..41e6255 100644 --- a/Tests/FindDoxygen/CMakeLists.txt +++ b/Tests/FindDoxygen/CMakeLists.txt @@ -28,6 +28,16 @@ add_test(NAME FindDoxygen.AllTarget COMMAND --test-command ${CMAKE_CTEST_COMMAND} -C $ ) +add_test(NAME FindDoxygen.StampFile COMMAND + ${CMAKE_CTEST_COMMAND} -C $ + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindDoxygen/StampFile" + "${CMake_BINARY_DIR}/Tests/FindDoxygen/StampFile" + --build-target allDocTargets + ${build_generator_args} + --build-options ${build_options} +) + if(CMake_TEST_FindDoxygen_Dot) add_test(NAME FindDoxygen.DotComponentTest COMMAND ${CMAKE_CTEST_COMMAND} -C $ diff --git a/Tests/FindDoxygen/StampFile/CMakeLists.txt b/Tests/FindDoxygen/StampFile/CMakeLists.txt new file mode 100644 index 0000000..2d06540 --- /dev/null +++ b/Tests/FindDoxygen/StampFile/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.8) +project(TestFindDoxygen VERSION 1.0 LANGUAGES NONE) + +find_package(Doxygen REQUIRED) + +doxygen_add_docs(docsWithoutFilesWithStamp USE_STAMP_FILE) +if(NOT EXISTS "${PROJECT_BINARY_DIR}/Doxyfile.docsWithoutFilesWithStamp") + message(FATAL_ERROR "Missing generated file: Doxyfile.docsWithoutFilesWithStamp") +endif() +if(NOT TARGET docsWithoutFilesWithStamp) + message(FATAL_ERROR "Target docsWithoutFilesWithStamp not created") +endif() + +doxygen_add_docs(docsWithFilesWithStamp main.cpp main2.cpp USE_STAMP_FILE) +if(NOT EXISTS "${PROJECT_BINARY_DIR}/Doxyfile.docsWithFilesWithStamp") + message(FATAL_ERROR "Missing generated file: Doxyfile.docsWithFilesWithStamp") +endif() +if(NOT TARGET docsWithFilesWithStamp) + message(FATAL_ERROR "Target docsWithFilesWithStamp not created") +endif() + + +add_custom_target(allDocTargets) +add_dependencies(allDocTargets docsWithoutFilesWithStamp docsWithFilesWithStamp) diff --git a/Tests/FindDoxygen/StampFile/main.cpp b/Tests/FindDoxygen/StampFile/main.cpp new file mode 100644 index 0000000..925f0af --- /dev/null +++ b/Tests/FindDoxygen/StampFile/main.cpp @@ -0,0 +1,4 @@ +/** + * \file + * \brief One C++ file w/ sample Doxygen comment just to produce any docs... + */ diff --git a/Tests/FindDoxygen/StampFile/main2.cpp b/Tests/FindDoxygen/StampFile/main2.cpp new file mode 100644 index 0000000..925f0af --- /dev/null +++ b/Tests/FindDoxygen/StampFile/main2.cpp @@ -0,0 +1,4 @@ +/** + * \file + * \brief One C++ file w/ sample Doxygen comment just to produce any docs... + */ ----------------------------------------------------------------------- Summary of changes: .../dev/doxygen-add-docs-USE_STAMP_FILE.rst | 7 +++ Modules/FindDoxygen.cmake | 70 ++++++++++++++++------ Tests/FindDoxygen/CMakeLists.txt | 10 ++++ Tests/FindDoxygen/StampFile/CMakeLists.txt | 24 ++++++++ .../FindDoxygen/{SimpleTest => StampFile}/main.cpp | 0 .../{SimpleTest/main.cpp => StampFile/main2.cpp} | 0 6 files changed, 94 insertions(+), 17 deletions(-) create mode 100644 Help/release/dev/doxygen-add-docs-USE_STAMP_FILE.rst create mode 100644 Tests/FindDoxygen/StampFile/CMakeLists.txt copy Tests/FindDoxygen/{SimpleTest => StampFile}/main.cpp (100%) copy Tests/FindDoxygen/{SimpleTest/main.cpp => StampFile/main2.cpp} (100%) hooks/post-receive -- CMake From kwrobot at kitware.com Fri Sep 6 00:00:57 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 6 Sep 2019 00:00:57 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-962-g7772c1d Message-ID: <20190906040057.4106111D88D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 7772c1db03b2424d0b8bc0f7b89e5733d2770b1d (commit) from a2d4968ab914d5cf02457306ec8f76177a794520 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7772c1db03b2424d0b8bc0f7b89e5733d2770b1d commit 7772c1db03b2424d0b8bc0f7b89e5733d2770b1d Author: Kitware Robot AuthorDate: Fri Sep 6 00:01:04 2019 -0400 Commit: Kitware Robot CommitDate: Fri Sep 6 00:01:04 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 545b0a9..b54dbd1 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 15) -set(CMake_VERSION_PATCH 20190905) +set(CMake_VERSION_PATCH 20190906) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Fri Sep 6 12:40:39 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 6 Sep 2019 12:40:39 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-969-gca8c3d6 Message-ID: <20190906164039.B2ADA4C64@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via ca8c3d64c8accebeacf322f0574494ffddb039c5 (commit) via 45e90f62dd422a93b14b5ed9d49d26a51116d4fd (commit) via 32c9ab8a1ba1dc55275aaad4285f0006ee8d4ea0 (commit) via 5acf0de1feb83a8ec5d8f1348091501919b17cad (commit) via 0d06cc457c2b526584c52153001d88051f6b5fbd (commit) via 1d3f5ebb0d3da35d1b5b1287f39115b188ac5f6a (commit) via a1ddf2d0ba6268e29a9456948828f59d044791f1 (commit) from 7772c1db03b2424d0b8bc0f7b89e5733d2770b1d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ca8c3d64c8accebeacf322f0574494ffddb039c5 commit ca8c3d64c8accebeacf322f0574494ffddb039c5 Merge: 45e90f6 1d3f5eb Author: Brad King AuthorDate: Fri Sep 6 16:37:55 2019 +0000 Commit: Kitware Robot CommitDate: Fri Sep 6 12:38:04 2019 -0400 Merge topic 'use-using' 1d3f5ebb0d clang-tidy: Enable check modernize-use-using a1ddf2d0ba clang-tidy: Replace typedef with using Acked-by: Kitware Robot Merge-request: !3782 diff --cc Source/CPack/cmCPackArchiveGenerator.h index f5be0aa,760b03d..461df66 --- a/Source/CPack/cmCPackArchiveGenerator.h +++ b/Source/CPack/cmCPackArchiveGenerator.h @@@ -22,16 -22,8 +22,16 @@@ class cmCPackComponent class cmCPackArchiveGenerator : public cmCPackGenerator { public: - typedef cmCPackGenerator Superclass; + using Superclass = cmCPackGenerator; + static cmCPackGenerator* Create7ZGenerator(); + static cmCPackGenerator* CreateTBZ2Generator(); + static cmCPackGenerator* CreateTGZGenerator(); + static cmCPackGenerator* CreateTXZGenerator(); + static cmCPackGenerator* CreateTZGenerator(); + static cmCPackGenerator* CreateTZSTGenerator(); + static cmCPackGenerator* CreateZIPGenerator(); + /** * Construct generator */ https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=45e90f62dd422a93b14b5ed9d49d26a51116d4fd commit 45e90f62dd422a93b14b5ed9d49d26a51116d4fd Merge: 32c9ab8 5acf0de Author: Brad King AuthorDate: Fri Sep 6 16:35:00 2019 +0000 Commit: Kitware Robot CommitDate: Fri Sep 6 12:35:49 2019 -0400 Merge topic 'simplify-AppendFlags' 5acf0de1fe cmLocalGenerator: Remove AppendFlags 'const char*' overload Acked-by: Kitware Robot Merge-request: !3786 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=32c9ab8a1ba1dc55275aaad4285f0006ee8d4ea0 commit 32c9ab8a1ba1dc55275aaad4285f0006ee8d4ea0 Merge: 7772c1d 0d06cc4 Author: Brad King AuthorDate: Fri Sep 6 16:34:46 2019 +0000 Commit: Kitware Robot CommitDate: Fri Sep 6 12:35:00 2019 -0400 Merge topic 'iwyu-freebsd-pkg' 0d06cc457c CPack/FreeBSD: Cleanup include-what-you-use diagnostics Acked-by: Kitware Robot Merge-request: !3785 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5acf0de1feb83a8ec5d8f1348091501919b17cad commit 5acf0de1feb83a8ec5d8f1348091501919b17cad Author: Brad King AuthorDate: Thu Sep 5 10:31:56 2019 -0400 Commit: Brad King CommitDate: Thu Sep 5 10:31:56 2019 -0400 cmLocalGenerator: Remove AppendFlags 'const char*' overload Update call sites to ensure the `std::string` argument can be constructed safely. diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 49db505..54443f2 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -90,7 +90,7 @@ void cmCommonTargetGenerator::AppendFortranFormatFlags( } if (var) { this->LocalCommonGenerator->AppendFlags( - flags, this->Makefile->GetDefinition(var)); + flags, this->Makefile->GetSafeDefinition(var)); } } diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx index 7c36bdc..f86955d 100644 --- a/Source/cmLocalCommonGenerator.cxx +++ b/Source/cmLocalCommonGenerator.cxx @@ -35,10 +35,8 @@ std::string cmLocalCommonGenerator::GetTargetFortranFlags( std::string flags; // Enable module output if necessary. - if (const char* modout_flag = - this->Makefile->GetDefinition("CMAKE_Fortran_MODOUT_FLAG")) { - this->AppendFlags(flags, modout_flag); - } + this->AppendFlags( + flags, this->Makefile->GetSafeDefinition("CMAKE_Fortran_MODOUT_FLAG")); // Add a module output directory flag if necessary. std::string mod_dir = diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index e2402ad..9152e94 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1125,10 +1125,10 @@ void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags, this->AppendFlags(flags, this->Makefile->GetSafeDefinition(name)); } } - this->AppendFlags(flags, target->GetProperty("STATIC_LIBRARY_FLAGS")); + this->AppendFlags(flags, target->GetSafeProperty("STATIC_LIBRARY_FLAGS")); if (!config.empty()) { std::string name = "STATIC_LIBRARY_FLAGS_" + config; - this->AppendFlags(flags, target->GetProperty(name)); + this->AppendFlags(flags, target->GetSafeProperty(name)); } std::vector options; @@ -1744,7 +1744,7 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags, // Add flags for dealing with shared libraries for this language. if (shared) { this->AppendFlags(flags, - this->Makefile->GetDefinition( + this->Makefile->GetSafeDefinition( cmStrCat("CMAKE_SHARED_LIBRARY_", lang, "_FLAGS"))); } } @@ -2090,12 +2090,12 @@ void cmLocalGenerator::AddConfigVariableFlags(std::string& flags, { // Add the flags from the variable itself. std::string flagsVar = var; - this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar)); + this->AppendFlags(flags, this->Makefile->GetSafeDefinition(flagsVar)); // Add the flags from the build-type specific variable. if (!config.empty()) { flagsVar += "_"; flagsVar += cmSystemTools::UpperCase(config); - this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar)); + this->AppendFlags(flags, this->Makefile->GetSafeDefinition(flagsVar)); } } @@ -2110,14 +2110,6 @@ void cmLocalGenerator::AppendFlags(std::string& flags, } } -void cmLocalGenerator::AppendFlags(std::string& flags, - const char* newFlags) const -{ - if (newFlags && *newFlags) { - this->AppendFlags(flags, std::string(newFlags)); - } -} - void cmLocalGenerator::AppendFlagEscape(std::string& flags, const std::string& rawFlag) const { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 515ffae..7cf8cd0 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -121,7 +121,6 @@ public: //! Append flags to a string. virtual void AppendFlags(std::string& flags, const std::string& newFlags) const; - virtual void AppendFlags(std::string& flags, const char* newFlags) const; virtual void AppendFlagEscape(std::string& flags, const std::string& rawFlag) const; void AddPchDependencies(cmGeneratorTarget* target, diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 106e506..320a58b 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -831,12 +831,6 @@ void cmLocalUnixMakefileGenerator3::AppendFlags( this->cmLocalGenerator::AppendFlags(flags, newFlags); } -void cmLocalUnixMakefileGenerator3::AppendFlags(std::string& flags, - const char* newFlags) const -{ - this->cmLocalGenerator::AppendFlags(flags, newFlags); -} - void cmLocalUnixMakefileGenerator3::AppendRuleDepend( std::vector& depends, const char* ruleFileName) { diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index c8e4b0e..745e251 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -90,7 +90,6 @@ public: // append flags to a string void AppendFlags(std::string& flags, const std::string& newFlags) const override; - void AppendFlags(std::string& flags, const char* newFlags) const override; // append an echo command enum EchoColor diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 002addf..e44ca7b 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -135,7 +135,7 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule( std::string export_flag_var = cmStrCat("CMAKE_EXE_EXPORTS_", linkLanguage, "_FLAG"); this->LocalGenerator->AppendFlags( - linkFlags, this->Makefile->GetDefinition(export_flag_var)); + linkFlags, this->Makefile->GetSafeDefinition(export_flag_var)); } this->LocalGenerator->AppendFlags(linkFlags, @@ -387,10 +387,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) if (this->GeneratorTarget->GetPropertyAsBool("WIN32_EXECUTABLE")) { this->LocalGenerator->AppendFlags( - linkFlags, this->Makefile->GetDefinition("CMAKE_CREATE_WIN32_EXE")); + linkFlags, this->Makefile->GetSafeDefinition("CMAKE_CREATE_WIN32_EXE")); } else { this->LocalGenerator->AppendFlags( - linkFlags, this->Makefile->GetDefinition("CMAKE_CREATE_CONSOLE_EXE")); + linkFlags, + this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE")); } // Add symbol export flags if necessary. @@ -398,7 +399,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string export_flag_var = cmStrCat("CMAKE_EXE_EXPORTS_", linkLanguage, "_FLAG"); this->LocalGenerator->AppendFlags( - linkFlags, this->Makefile->GetDefinition(export_flag_var)); + linkFlags, this->Makefile->GetSafeDefinition(export_flag_var)); } this->LocalGenerator->AppendFlags(linkFlags, diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 4a60aa9..1f6986b 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -89,12 +89,12 @@ void cmMakefileTargetGenerator::GetTargetLinkFlags( std::string& flags, const std::string& linkLanguage) { this->LocalGenerator->AppendFlags( - flags, this->GeneratorTarget->GetProperty("LINK_FLAGS")); + flags, this->GeneratorTarget->GetSafeProperty("LINK_FLAGS")); std::string linkFlagsConfig = cmStrCat("LINK_FLAGS_", cmSystemTools::UpperCase(this->ConfigName)); this->LocalGenerator->AppendFlags( - flags, this->GeneratorTarget->GetProperty(linkFlagsConfig)); + flags, this->GeneratorTarget->GetSafeProperty(linkFlagsConfig)); std::vector opts; this->GeneratorTarget->GetLinkOptions(opts, this->ConfigName, linkLanguage); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0d06cc457c2b526584c52153001d88051f6b5fbd commit 0d06cc457c2b526584c52153001d88051f6b5fbd Author: Brad King AuthorDate: Thu Sep 5 09:03:26 2019 -0400 Commit: Brad King CommitDate: Thu Sep 5 09:03:26 2019 -0400 CPack/FreeBSD: Cleanup include-what-you-use diagnostics diff --git a/Source/CPack/cmCPackFreeBSDGenerator.cxx b/Source/CPack/cmCPackFreeBSDGenerator.cxx index 3979000..b3cb2ad 100644 --- a/Source/CPack/cmCPackFreeBSDGenerator.cxx +++ b/Source/CPack/cmCPackFreeBSDGenerator.cxx @@ -12,13 +12,13 @@ // Needed for ::open() and ::stat() #include #include -#include -#include #include #include +#include #include +#include cmCPackFreeBSDGenerator::cmCPackFreeBSDGenerator() : cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr", ".txz") diff --git a/Source/CPack/cmCPackFreeBSDGenerator.h b/Source/CPack/cmCPackFreeBSDGenerator.h index 80c53b1..9c8a934 100644 --- a/Source/CPack/cmCPackFreeBSDGenerator.h +++ b/Source/CPack/cmCPackFreeBSDGenerator.h @@ -3,11 +3,13 @@ #ifndef cmCPackFreeBSDGenerator_h #define cmCPackFreeBSDGenerator_h -#include +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCPackArchiveGenerator.h" #include "cmCPackGenerator.h" +#include + class cmGeneratedFileStream; /** \class cmCPackFreeBSDGenerator https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1d3f5ebb0d3da35d1b5b1287f39115b188ac5f6a commit 1d3f5ebb0d3da35d1b5b1287f39115b188ac5f6a Author: Regina Pfeifer AuthorDate: Wed Sep 4 18:44:53 2019 +0200 Commit: Regina Pfeifer CommitDate: Wed Sep 4 19:47:30 2019 +0200 clang-tidy: Enable check modernize-use-using Annotate the remaining typedefs with NOLINT. Unfortunately, clang-tidy is not smart enough and suggests the use of using inside extern "C" blocks. diff --git a/.clang-tidy b/.clang-tidy index 6f96c22..cfca64e 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -20,7 +20,6 @@ modernize-*,\ -modernize-use-nodiscard,\ -modernize-use-noexcept,\ -modernize-use-transparent-functors,\ --modernize-use-using,\ performance-*,\ readability-*,\ -readability-function-size,\ diff --git a/Source/cmCPluginAPI.h b/Source/cmCPluginAPI.h index adc57a2..6a95148 100644 --- a/Source/cmCPluginAPI.h +++ b/Source/cmCPluginAPI.h @@ -28,6 +28,7 @@ this is the structure of function entry points that a plugin may call. This structure must be kept in sync with the static decaled at the bottom of cmCPLuginAPI.cxx =========================================================================*/ +/* NOLINTNEXTLINE(modernize-use-using) */ typedef struct { /*========================================================================= @@ -194,12 +195,21 @@ define the different types of custom commands for a target /*========================================================================= Finally we define the key data structures and function prototypes =========================================================================*/ + +/* NOLINTNEXTLINE(modernize-use-using) */ typedef const char*(CCONV* CM_DOC_FUNCTION)(); + +/* NOLINTNEXTLINE(modernize-use-using) */ typedef int(CCONV* CM_INITIAL_PASS_FUNCTION)(void* info, void* mf, int argc, char* []); + +/* NOLINTNEXTLINE(modernize-use-using) */ typedef void(CCONV* CM_FINAL_PASS_FUNCTION)(void* info, void* mf); + +/* NOLINTNEXTLINE(modernize-use-using) */ typedef void(CCONV* CM_DESTRUCTOR_FUNCTION)(void* info); +/* NOLINTNEXTLINE(modernize-use-using) */ typedef struct { unsigned long reserved1; /* Reserved for future use. DO NOT USE. */ @@ -216,6 +226,7 @@ typedef struct void* ClientData; } cmLoadedCommandInfo; +/* NOLINTNEXTLINE(modernize-use-using) */ typedef void(CCONV* CM_INIT_FUNCTION)(cmLoadedCommandInfo*); #ifdef __cplusplus diff --git a/Source/cmListFileLexer.h b/Source/cmListFileLexer.h index 8962396..ec6b3cd 100644 --- a/Source/cmListFileLexer.h +++ b/Source/cmListFileLexer.h @@ -3,6 +3,11 @@ #ifndef cmListFileLexer_h #define cmListFileLexer_h +#ifdef __cplusplus +extern "C" { +#endif + +/* NOLINTNEXTLINE(modernize-use-using) */ typedef enum cmListFileLexer_Type_e { cmListFileLexer_Token_None, @@ -20,6 +25,7 @@ typedef enum cmListFileLexer_Type_e cmListFileLexer_Token_BadString } cmListFileLexer_Type; +/* NOLINTNEXTLINE(modernize-use-using) */ typedef struct cmListFileLexer_Token_s cmListFileLexer_Token; struct cmListFileLexer_Token_s { @@ -40,14 +46,13 @@ enum cmListFileLexer_BOM_e cmListFileLexer_BOM_UTF32BE, cmListFileLexer_BOM_UTF32LE }; + +/* NOLINTNEXTLINE(modernize-use-using) */ typedef enum cmListFileLexer_BOM_e cmListFileLexer_BOM; +/* NOLINTNEXTLINE(modernize-use-using) */ typedef struct cmListFileLexer_s cmListFileLexer; -#ifdef __cplusplus -extern "C" { -#endif - cmListFileLexer* cmListFileLexer_New(void); int cmListFileLexer_SetFileName(cmListFileLexer*, const char*, cmListFileLexer_BOM* bom); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a1ddf2d0ba6268e29a9456948828f59d044791f1 commit a1ddf2d0ba6268e29a9456948828f59d044791f1 Author: Regina Pfeifer AuthorDate: Wed Sep 4 18:03:01 2019 +0200 Commit: Regina Pfeifer CommitDate: Wed Sep 4 18:03:01 2019 +0200 clang-tidy: Replace typedef with using Automate the conversion with perl -i -0pe 's/typedef ([^;]*) ([^ ]+);/using $2 = $1;/g' then manually fix a few places. diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.h b/Source/CPack/IFW/cmCPackIFWGenerator.h index 0430122..ee3c166 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.h +++ b/Source/CPack/IFW/cmCPackIFWGenerator.h @@ -29,12 +29,12 @@ class cmCPackIFWGenerator public: cmCPackTypeMacro(cmCPackIFWGenerator, cmCPackGenerator); - typedef std::map PackagesMap; - typedef std::map RepositoriesMap; - typedef std::map ComponentsMap; - typedef std::map ComponentGoupsMap; - typedef std::map - DependenceMap; + using PackagesMap = std::map; + using RepositoriesMap = std::map; + using ComponentsMap = std::map; + using ComponentGoupsMap = std::map; + using DependenceMap = + std::map; using cmCPackIFWCommon::GetOption; using cmCPackIFWCommon::IsOn; diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.h b/Source/CPack/IFW/cmCPackIFWInstaller.h index be51fa5..467779e 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.h +++ b/Source/CPack/IFW/cmCPackIFWInstaller.h @@ -22,8 +22,8 @@ class cmCPackIFWInstaller : public cmCPackIFWCommon public: // Types - typedef std::map PackagesMap; - typedef std::vector RepositoriesVector; + using PackagesMap = std::map; + using RepositoriesVector = std::vector; public: // Constructor diff --git a/Source/CPack/IFW/cmCPackIFWRepository.h b/Source/CPack/IFW/cmCPackIFWRepository.h index 227cfae..585334c 100644 --- a/Source/CPack/IFW/cmCPackIFWRepository.h +++ b/Source/CPack/IFW/cmCPackIFWRepository.h @@ -28,7 +28,7 @@ public: Replace }; - typedef std::vector RepositoriesVector; + using RepositoriesVector = std::vector; public: // Constructor diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h index f8c7644..3b72e38 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.h +++ b/Source/CPack/WiX/cmCPackWIXGenerator.h @@ -44,9 +44,9 @@ protected: bool SupportsComponentInstallation() const override { return true; } private: - typedef std::map id_map_t; - typedef std::map ambiguity_map_t; - typedef std::set extension_set_t; + using id_map_t = std::map; + using ambiguity_map_t = std::map; + using extension_set_t = std::set; enum class DefinitionType { diff --git a/Source/CPack/WiX/cmWIXPatchParser.h b/Source/CPack/WiX/cmWIXPatchParser.h index 52c7e35..e0e3470 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.h +++ b/Source/CPack/WiX/cmWIXPatchParser.h @@ -36,8 +36,8 @@ struct cmWIXPatchElement : cmWIXPatchNode ~cmWIXPatchElement(); - typedef std::vector child_list_t; - typedef std::map attributes_t; + using child_list_t = std::vector; + using attributes_t = std::map; std::string name; child_list_t children; @@ -50,7 +50,7 @@ struct cmWIXPatchElement : cmWIXPatchNode class cmWIXPatchParser : public cmXMLParser { public: - typedef std::map fragment_map_t; + using fragment_map_t = std::map; cmWIXPatchParser(fragment_map_t& Fragments, cmCPackLog* logger); diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx index 2c99a22..751f7dc 100644 --- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx +++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx @@ -25,7 +25,7 @@ cmWIXRichTextFormatWriter::~cmWIXRichTextFormatWriter() void cmWIXRichTextFormatWriter::AddText(std::string const& text) { - typedef unsigned char rtf_byte_t; + using rtf_byte_t = unsigned char; for (size_t i = 0; i < text.size(); ++i) { rtf_byte_t c = rtf_byte_t(text[i]); diff --git a/Source/CPack/WiX/cmWIXShortcut.h b/Source/CPack/WiX/cmWIXShortcut.h index 23ddc6a..d9eecdf 100644 --- a/Source/CPack/WiX/cmWIXShortcut.h +++ b/Source/CPack/WiX/cmWIXShortcut.h @@ -28,8 +28,8 @@ public: STARTUP }; - typedef std::vector shortcut_list_t; - typedef std::map shortcut_id_map_t; + using shortcut_list_t = std::vector; + using shortcut_id_map_t = std::map; void insert(Type type, std::string const& id, cmWIXShortcut const& shortcut); @@ -46,7 +46,7 @@ public: cmInstalledFile const& installedFile); private: - typedef std::map shortcut_type_map_t; + using shortcut_type_map_t = std::map; void CreateFromProperty(std::string const& propertyName, Type type, std::string const& id, diff --git a/Source/CPack/cmCPackArchiveGenerator.h b/Source/CPack/cmCPackArchiveGenerator.h index 9983854..760b03d 100644 --- a/Source/CPack/cmCPackArchiveGenerator.h +++ b/Source/CPack/cmCPackArchiveGenerator.h @@ -22,7 +22,7 @@ class cmCPackComponent; class cmCPackArchiveGenerator : public cmCPackGenerator { public: - typedef cmCPackGenerator Superclass; + using Superclass = cmCPackGenerator; /** * Construct generator diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index 3c06d41..fc00b09 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -326,7 +326,7 @@ protected: }; #define cmCPackTypeMacro(klass, superclass) \ - typedef superclass Superclass; \ + using Superclass = superclass; \ const char* GetNameOfClass() override { return #klass; } \ static cmCPackGenerator* CreateGenerator() { return new klass; } \ class cmCPackTypeMacro_UseTrailingSemicolon diff --git a/Source/CPack/cmCPackGeneratorFactory.h b/Source/CPack/cmCPackGeneratorFactory.h index 972f0f7..da2eb8d 100644 --- a/Source/CPack/cmCPackGeneratorFactory.h +++ b/Source/CPack/cmCPackGeneratorFactory.h @@ -29,7 +29,7 @@ public: cmCPackGenerator* NewGenerator(const std::string& name); void DeleteGenerator(cmCPackGenerator* gen); - typedef cmCPackGenerator* CreateGeneratorCall(); + using CreateGeneratorCall = cmCPackGenerator*(); void RegisterGenerator(const std::string& name, const char* generatorDescription, @@ -37,7 +37,7 @@ public: void SetLogger(cmCPackLog* logger) { this->Logger = logger; } - typedef std::map DescriptionsMap; + using DescriptionsMap = std::map; const DescriptionsMap& GetGeneratorsList() const { return this->GeneratorDescriptions; @@ -47,7 +47,7 @@ private: cmCPackGenerator* NewGeneratorInternal(const std::string& name); std::vector Generators; - typedef std::map t_GeneratorCreatorsMap; + using t_GeneratorCreatorsMap = std::map; t_GeneratorCreatorsMap GeneratorCreators; DescriptionsMap GeneratorDescriptions; cmCPackLog* Logger; diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index b4b320d..08681ec 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -66,7 +66,7 @@ int cpackUnknownArgument(const char* /*unused*/, void* /*unused*/) struct cpackDefinitions { - typedef std::map MapType; + using MapType = std::map; MapType Map; cmCPackLog* Log; }; diff --git a/Source/CTest/cmCTestBuildAndTestHandler.h b/Source/CTest/cmCTestBuildAndTestHandler.h index 2d47b15..d5240aa 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.h +++ b/Source/CTest/cmCTestBuildAndTestHandler.h @@ -22,7 +22,7 @@ class cmake; class cmCTestBuildAndTestHandler : public cmCTestGenericHandler { public: - typedef cmCTestGenericHandler Superclass; + using Superclass = cmCTestGenericHandler; /* * The main entry point for this class diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 147286e..e07d7aa 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -529,7 +529,7 @@ void cmCTestBuildHandler::GenerateXMLLaunched(cmXMLWriter& xml) // Sort XML fragments in chronological order. cmFileTimeCache ftc; FragmentCompare fragmentCompare(&ftc); - typedef std::set Fragments; + using Fragments = std::set; Fragments fragments(fragmentCompare); // only report the first 50 warnings and first 50 errors diff --git a/Source/CTest/cmCTestBuildHandler.h b/Source/CTest/cmCTestBuildHandler.h index 87f1534..ce1d343 100644 --- a/Source/CTest/cmCTestBuildHandler.h +++ b/Source/CTest/cmCTestBuildHandler.h @@ -28,8 +28,8 @@ class cmXMLWriter; class cmCTestBuildHandler : public cmCTestGenericHandler { public: - typedef cmCTestGenericHandler Superclass; - typedef cmProcessOutput::Encoding Encoding; + using Superclass = cmCTestGenericHandler; + using Encoding = cmProcessOutput::Encoding; /* * The main entry point for this class @@ -111,7 +111,7 @@ private: std::vector WarningMatchRegex; std::vector WarningExceptionRegex; - typedef std::deque t_BuildProcessingQueueType; + using t_BuildProcessingQueueType = std::deque; void ProcessBuffer(const char* data, size_t length, size_t& tick, size_t tick_len, std::ostream& ofs, @@ -126,7 +126,7 @@ private: std::string SimplifySourceDir; std::string SimplifyBuildDir; size_t OutputLineCounter; - typedef std::vector t_ErrorsAndWarningsVector; + using t_ErrorsAndWarningsVector = std::vector; t_ErrorsAndWarningsVector ErrorsAndWarnings; t_ErrorsAndWarningsVector::iterator LastErrorOrWarning; size_t PostContextCount; diff --git a/Source/CTest/cmCTestConfigureHandler.h b/Source/CTest/cmCTestConfigureHandler.h index 680401c..01fe801 100644 --- a/Source/CTest/cmCTestConfigureHandler.h +++ b/Source/CTest/cmCTestConfigureHandler.h @@ -14,7 +14,7 @@ class cmCTestConfigureHandler : public cmCTestGenericHandler { public: - typedef cmCTestGenericHandler Superclass; + using Superclass = cmCTestGenericHandler; /* * The main entry point for this class diff --git a/Source/CTest/cmCTestCoverageCommand.h b/Source/CTest/cmCTestCoverageCommand.h index 08f31f7..24b96c0 100644 --- a/Source/CTest/cmCTestCoverageCommand.h +++ b/Source/CTest/cmCTestCoverageCommand.h @@ -42,7 +42,7 @@ public: */ std::string GetName() const override { return "ctest_coverage"; } - typedef cmCTestHandlerCommand Superclass; + using Superclass = cmCTestHandlerCommand; protected: cmCTestGenericHandler* InitializeHandler() override; diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h index 6492fe9..06aaef7 100644 --- a/Source/CTest/cmCTestCoverageHandler.h +++ b/Source/CTest/cmCTestCoverageHandler.h @@ -24,8 +24,8 @@ public: int Error; std::string SourceDir; std::string BinaryDir; - typedef std::vector SingleFileCoverageVector; - typedef std::map TotalCoverageMap; + using SingleFileCoverageVector = std::vector; + using TotalCoverageMap = std::map; TotalCoverageMap TotalCoverage; std::ostream* OFS; bool Quiet; @@ -37,7 +37,7 @@ public: class cmCTestCoverageHandler : public cmCTestGenericHandler { public: - typedef cmCTestGenericHandler Superclass; + using Superclass = cmCTestGenericHandler; /* * The main entry point for this class @@ -128,12 +128,12 @@ private: class LabelSet : public std::set { }; - typedef std::map LabelMapType; + using LabelMapType = std::map; LabelMapType SourceLabels; LabelMapType TargetDirs; // Map from label name to label id. - typedef std::map LabelIdMapType; + using LabelIdMapType = std::map; LabelIdMapType LabelIdMap; std::vector Labels; int GetLabelId(std::string const& label); diff --git a/Source/CTest/cmCTestGenericHandler.h b/Source/CTest/cmCTestGenericHandler.h index cf91b4f..793829e 100644 --- a/Source/CTest/cmCTestGenericHandler.h +++ b/Source/CTest/cmCTestGenericHandler.h @@ -71,7 +71,7 @@ public: cmCTestGenericHandler(); virtual ~cmCTestGenericHandler(); - typedef std::map t_StringToString; + using t_StringToString = std::map; void SetPersistentOption(const std::string& op, const char* value); void SetOption(const std::string& op, const char* value); diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h index 746d72c..4bc655b 100644 --- a/Source/CTest/cmCTestMemCheckHandler.h +++ b/Source/CTest/cmCTestMemCheckHandler.h @@ -22,7 +22,7 @@ class cmCTestMemCheckHandler : public cmCTestTestHandler friend class cmCTestRunTest; public: - typedef cmCTestTestHandler Superclass; + using Superclass = cmCTestTestHandler; void PopulateCustomVectors(cmMakefile* mf) override; diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h index b2e8cbf..4a08ad9 100644 --- a/Source/CTest/cmCTestScriptHandler.h +++ b/Source/CTest/cmCTestScriptHandler.h @@ -58,7 +58,7 @@ class cmake; class cmCTestScriptHandler : public cmCTestGenericHandler { public: - typedef cmCTestGenericHandler Superclass; + using Superclass = cmCTestGenericHandler; /** * Add a script to run, and if is should run in the current process diff --git a/Source/CTest/cmCTestSubmitCommand.h b/Source/CTest/cmCTestSubmitCommand.h index 5bbcd39..8562207 100644 --- a/Source/CTest/cmCTestSubmitCommand.h +++ b/Source/CTest/cmCTestSubmitCommand.h @@ -37,7 +37,7 @@ public: */ std::string GetName() const override { return "ctest_submit"; } - typedef cmCTestHandlerCommand Superclass; + using Superclass = cmCTestHandlerCommand; protected: cmCTestGenericHandler* InitializeHandler() override; diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h index e0fed10..31b747b 100644 --- a/Source/CTest/cmCTestSubmitHandler.h +++ b/Source/CTest/cmCTestSubmitHandler.h @@ -22,7 +22,7 @@ class cmCTestSubmitHandler : public cmCTestGenericHandler { public: - typedef cmCTestGenericHandler Superclass; + using Superclass = cmCTestGenericHandler; cmCTestSubmitHandler(); ~cmCTestSubmitHandler() override { this->LogFile = nullptr; } @@ -59,7 +59,7 @@ private: const std::string& remoteprefix, const std::string& url); - typedef std::vector cmCTestSubmitHandlerVectorOfChar; + using cmCTestSubmitHandlerVectorOfChar = std::vector; void ParseResponse(cmCTestSubmitHandlerVectorOfChar chunk); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 2b5a406..f67b11a 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -940,7 +940,7 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const // Prepare some maps to help us find setup and cleanup tests for // any given fixture using TestIterator = ListOfTests::const_iterator; - typedef std::multimap FixtureDependencies; + using FixtureDependencies = std::multimap; using FixtureDepsIterator = FixtureDependencies::const_iterator; FixtureDependencies fixtureSetups; FixtureDependencies fixtureCleanups; diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 9345185..8f1dafc 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -34,7 +34,7 @@ class cmCTestTestHandler : public cmCTestGenericHandler friend class cmCTestMultiProcessHandler; public: - typedef cmCTestGenericHandler Superclass; + using Superclass = cmCTestGenericHandler; /** * The main entry point for this class @@ -188,12 +188,11 @@ public: std::vector& extraPaths, std::vector& failed); - typedef std::vector ListOfTests; + using ListOfTests = std::vector; protected: - typedef std::set - SetOfTests; + using SetOfTests = + std::set; // compute a final test list virtual int PreProcessHandler(); @@ -222,7 +221,7 @@ protected: cmDuration ElapsedTestingTime; - typedef std::vector TestResultsVector; + using TestResultsVector = std::vector; TestResultsVector TestResults; std::vector CustomTestsIgnore; diff --git a/Source/CTest/cmCTestUpdateHandler.h b/Source/CTest/cmCTestUpdateHandler.h index 0f51d3f..57b952d 100644 --- a/Source/CTest/cmCTestUpdateHandler.h +++ b/Source/CTest/cmCTestUpdateHandler.h @@ -18,7 +18,7 @@ class cmCTestUpdateHandler : public cmCTestGenericHandler { public: - typedef cmCTestGenericHandler Superclass; + using Superclass = cmCTestGenericHandler; /* * The main entry point for this class diff --git a/Source/CTest/cmCTestUploadCommand.h b/Source/CTest/cmCTestUploadCommand.h index 2bb072f..9e49769 100644 --- a/Source/CTest/cmCTestUploadCommand.h +++ b/Source/CTest/cmCTestUploadCommand.h @@ -41,7 +41,7 @@ public: */ std::string GetName() const override { return "ctest_upload"; } - typedef cmCTestHandlerCommand Superclass; + using Superclass = cmCTestHandlerCommand; protected: cmCTestGenericHandler* InitializeHandler() override; diff --git a/Source/CTest/cmCTestUploadHandler.h b/Source/CTest/cmCTestUploadHandler.h index 4d8fab4..ff69c6e 100644 --- a/Source/CTest/cmCTestUploadHandler.h +++ b/Source/CTest/cmCTestUploadHandler.h @@ -19,7 +19,7 @@ class cmCTestUploadHandler : public cmCTestGenericHandler { public: - typedef cmCTestGenericHandler Superclass; + using Superclass = cmCTestGenericHandler; cmCTestUploadHandler(); diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h index f2fd6d9..fa4451b 100644 --- a/Source/QtDialog/QCMake.h +++ b/Source/QtDialog/QCMake.h @@ -50,7 +50,7 @@ struct QCMakeProperty }; // list of properties -typedef QList QCMakePropertyList; +using QCMakePropertyList = QList; // allow QVariant to be a property or list of properties Q_DECLARE_METATYPE(QCMakeProperty) diff --git a/Source/cmAffinity.cxx b/Source/cmAffinity.cxx index fa5e4b9..a6d89aa 100644 --- a/Source/cmAffinity.cxx +++ b/Source/cmAffinity.cxx @@ -22,7 +22,7 @@ # if defined(__linux__) using cm_cpuset_t = cpu_set_t; # else -typedef cpuset_t cm_cpuset_t; +using cm_cpuset_t = cpuset_t; # endif # endif #endif diff --git a/Source/cmCLocaleEnvironmentScope.h b/Source/cmCLocaleEnvironmentScope.h index 93032c1..aa2827e 100644 --- a/Source/cmCLocaleEnvironmentScope.h +++ b/Source/cmCLocaleEnvironmentScope.h @@ -22,7 +22,7 @@ private: std::string GetEnv(std::string const& key); void SetEnv(std::string const& key, std::string const& value); - typedef std::map backup_map_t; + using backup_map_t = std::map; backup_map_t EnvironmentBackup; }; diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index 65f22f7..a988bd8 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -212,7 +212,7 @@ protected: unsigned int CacheMinorVersion; private: - typedef std::map CacheEntryMap; + using CacheEntryMap = std::map; static void OutputHelpString(std::ostream& fout, const std::string& helpString); static void OutputWarningComment(std::ostream& fout, diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index 6b0f74e..17792d6 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -50,7 +50,7 @@ protected: void AppendOSXVerFlag(std::string& flags, const std::string& lang, const char* name, bool so); - typedef std::map ByLanguageMap; + using ByLanguageMap = std::map; std::string GetFlags(const std::string& l); ByLanguageMap FlagsByLanguage; std::string GetDefines(const std::string& l); diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h index 9a6f239..102b178 100644 --- a/Source/cmCustomCommand.h +++ b/Source/cmCustomCommand.h @@ -68,7 +68,7 @@ public: /** Backtrace of the command that created this custom command. */ cmListFileBacktrace const& GetBacktrace() const; - typedef std::pair ImplicitDependsPair; + using ImplicitDependsPair = std::pair; class ImplicitDependsList : public std::vector { }; diff --git a/Source/cmDepends.h b/Source/cmDepends.h index b7475f0..d938775 100644 --- a/Source/cmDepends.h +++ b/Source/cmDepends.h @@ -24,7 +24,7 @@ class cmLocalGenerator; class cmDepends { public: - typedef std::map> DependencyMap; + using DependencyMap = std::map>; public: /** Instances need to know the build directory name and the relative diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h index 3fc839e..cbdc276 100644 --- a/Source/cmDependsC.h +++ b/Source/cmDependsC.h @@ -59,7 +59,7 @@ protected: // Regex to transform #include lines. std::string IncludeRegexTransformString; cmsys::RegularExpression IncludeRegexTransform; - typedef std::map TransformRulesType; + using TransformRulesType = std::map; TransformRulesType TransformRules; void SetupTransforms(); void ParseTransform(std::string const& xform); diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index 8df9938..c30e0bf 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -46,11 +46,11 @@ public: std::set TargetProvides; // Map modules required by this target to locations. - typedef std::map TargetRequiresMap; + using TargetRequiresMap = std::map; TargetRequiresMap TargetRequires; // Information about each object file. - typedef std::map ObjectInfoMap; + using ObjectInfoMap = std::map; ObjectInfoMap ObjectInfo; cmFortranSourceInfo& CreateObjectInfo(const std::string& obj, diff --git a/Source/cmDuration.h b/Source/cmDuration.h index 6df1455..ccd1cc1 100644 --- a/Source/cmDuration.h +++ b/Source/cmDuration.h @@ -5,7 +5,7 @@ #include #include -typedef std::chrono::duration> cmDuration; +using cmDuration = std::chrono::duration>; /* * This function will return number of seconds in the requested type T. diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index 425f1a8..648a900 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -20,11 +20,11 @@ #elif defined(__HAIKU__) # include # include -typedef struct Elf32_Ehdr Elf32_Ehdr; -typedef struct Elf32_Shdr Elf32_Shdr; -typedef struct Elf32_Sym Elf32_Sym; -typedef struct Elf32_Rel Elf32_Rel; -typedef struct Elf32_Rela Elf32_Rela; +using Elf32_Ehdr = struct Elf32_Ehdr; +using Elf32_Shdr = struct Elf32_Shdr; +using Elf32_Sym = struct Elf32_Sym; +using Elf32_Rel = struct Elf32_Rel; +using Elf32_Rela = struct Elf32_Rela; # define ELFMAG0 0x7F # define ELFMAG1 'E' # define ELFMAG2 'L' @@ -289,9 +289,8 @@ public: } private: - // ByteSwap(ELF_Dyn) assumes d_val and d_ptr are the same size - typedef char dyn_size_assert - [sizeof(ELF_Dyn().d_un.d_val) == sizeof(ELF_Dyn().d_un.d_ptr) ? 1 : -1]; + static_assert(sizeof(ELF_Dyn().d_un.d_val) == sizeof(ELF_Dyn().d_un.d_ptr), + "ByteSwap(ELF_Dyn) assumes d_val and d_ptr are the same size"); void ByteSwap(ELF_Ehdr& elf_header) { diff --git a/Source/cmELF.h b/Source/cmELF.h index afef654..123bf9b 100644 --- a/Source/cmELF.h +++ b/Source/cmELF.h @@ -68,7 +68,7 @@ public: }; /** Represent entire dynamic section header */ - typedef std::vector> DynamicEntryList; + using DynamicEntryList = std::vector>; /** Get the type of the file opened. */ FileType GetFileType() const; diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 747503e..6fa86ab 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -62,7 +62,7 @@ public: bool GenerateImportFile(); protected: - typedef std::map ImportPropertyMap; + using ImportPropertyMap = std::map; // Generate per-configuration target information to the given output // stream. diff --git a/Source/cmExportSetMap.h b/Source/cmExportSetMap.h index 3853732..0ef07ef 100644 --- a/Source/cmExportSetMap.h +++ b/Source/cmExportSetMap.h @@ -13,7 +13,7 @@ class cmExportSet; /// A name -> cmExportSet map with overloaded operator[]. class cmExportSetMap : public std::map { - typedef std::map derived; + using derived = std::map; public: /** \brief Overloaded operator[]. diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 6b16b93..5a9c54c 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -333,7 +333,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( // Collect all used source files in the project. // Keep a list of C/C++ source files which might have an accompanying header // that should be looked for. - typedef std::map all_files_map_t; + using all_files_map_t = std::map; all_files_map_t allFiles; std::vector cFiles; diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h index bc158f6..d9ef1d1 100644 --- a/Source/cmExtraSublimeTextGenerator.h +++ b/Source/cmExtraSublimeTextGenerator.h @@ -24,7 +24,7 @@ class cmExtraSublimeTextGenerator : public cmExternalMakefileProjectGenerator { public: static cmExternalMakefileProjectGeneratorFactory* GetFactory(); - typedef std::map> MapSourceFileFlags; + using MapSourceFileFlags = std::map>; cmExtraSublimeTextGenerator(); void Generate() override; diff --git a/Source/cmFileLockResult.h b/Source/cmFileLockResult.h index c452814..81c1906 100644 --- a/Source/cmFileLockResult.h +++ b/Source/cmFileLockResult.h @@ -19,7 +19,7 @@ class cmFileLockResult { public: #if defined(_WIN32) - typedef DWORD Error; + using Error = DWORD; #else using Error = int; #endif diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 133a72b..32eb3cd 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -370,9 +370,8 @@ bool cmGeneratorExpression::IsValidTargetName(const std::string& input) void cmCompiledGeneratorExpression::GetMaxLanguageStandard( const cmGeneratorTarget* tgt, std::map& mapping) { - typedef std::map> - MapType; + using MapType = + std::map>; MapType::const_iterator it = this->MaxLanguageStandard.find(tgt); if (it != this->MaxLanguageStandard.end()) { mapping = it->second; diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 667f4a0..89b6c1c 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1473,7 +1473,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode } context->HadHeadSensitiveCondition = true; - typedef std::map> LangMap; + using LangMap = std::map>; static LangMap availableFeatures; LangMap testedFeatures; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 48ffcec..b4706a3 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1107,7 +1107,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory( config_upper = cmSystemTools::UpperCase(config); } - typedef std::map> IncludeCacheType; + using IncludeCacheType = std::map>; IncludeCacheType::const_iterator iter = this->SystemIncludesCache.find(config_upper); @@ -2606,7 +2606,7 @@ private: SourceEntry* CurrentEntry; std::queue SourceQueue; std::set SourcesQueued; - typedef std::map NameMapType; + using NameMapType = std::map; NameMapType NameMap; std::vector NewSources; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 4701071..9eb2ecf 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -531,7 +531,7 @@ public: CompileInfo const* GetCompileInfo(const std::string& config) const; - typedef std::map CompileInfoMapType; + using CompileInfoMapType = std::map; mutable CompileInfoMapType CompileInfoMap; bool IsNullImpliedByLinkLibraries(const std::string& p) const; @@ -745,7 +745,7 @@ private: { std::vector Depends; }; - typedef std::map SourceEntriesType; + using SourceEntriesType = std::map; SourceEntriesType SourceDepends; mutable std::map Objects; std::set ExplicitObjectName; @@ -775,7 +775,7 @@ private: std::string& outPrefix, std::string& outBase, std::string& outSuffix) const; - typedef std::map LinkClosureMapType; + using LinkClosureMapType = std::map; mutable LinkClosureMapType LinkClosureMap; // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. @@ -802,8 +802,8 @@ private: }; mutable std::map CompatibleInterfacesMap; - typedef std::map - cmTargetLinkInformationMap; + using cmTargetLinkInformationMap = + std::map; mutable cmTargetLinkInformationMap LinkInformation; void CheckPropertyCompatibility(cmComputeLinkInformation* info, @@ -815,7 +815,7 @@ private: }; mutable std::map LinkImplClosureMap; - typedef std::map LinkInterfaceMapType; + using LinkInterfaceMapType = std::map; mutable LinkInterfaceMapType LinkInterfaceMap; mutable LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap; @@ -843,7 +843,7 @@ private: std::string SharedDeps; }; - typedef std::map ImportInfoMapType; + using ImportInfoMapType = std::map; mutable ImportInfoMapType ImportInfoMap; void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; @@ -857,7 +857,7 @@ private: const std::string& config, const cmGeneratorTarget* head, bool usage_requirements_only) const; - typedef std::map KindedSourcesMapType; + using KindedSourcesMapType = std::map; mutable KindedSourcesMapType KindedSourcesMap; void ComputeKindedSources(KindedSources& files, std::string const& config) const; @@ -902,7 +902,7 @@ private: : public std::map { }; - typedef std::map LinkImplMapType; + using LinkImplMapType = std::map; mutable LinkImplMapType LinkImplMap; cmLinkImplementationLibraries const* GetLinkImplementationLibrariesInternal( @@ -911,17 +911,17 @@ private: cmStateEnums::ArtifactType artifact, std::string& out) const; - typedef std::map OutputInfoMapType; + using OutputInfoMapType = std::map; mutable OutputInfoMapType OutputInfoMap; - typedef std::map - ModuleDefinitionInfoMapType; + using ModuleDefinitionInfoMapType = + std::map; mutable ModuleDefinitionInfoMapType ModuleDefinitionInfoMap; void ComputeModuleDefinitionInfo(std::string const& config, ModuleDefinitionInfo& info) const; - typedef std::pair OutputNameKey; - typedef std::map OutputNameMapType; + using OutputNameKey = std::pair; + using OutputNameMapType = std::map; mutable OutputNameMapType OutputNameMap; mutable std::set UtilityItems; cmPolicies::PolicyMap PolicyMap; diff --git a/Source/cmGlobVerificationManager.h b/Source/cmGlobVerificationManager.h index 48606d3..e03d939 100644 --- a/Source/cmGlobVerificationManager.h +++ b/Source/cmGlobVerificationManager.h @@ -72,7 +72,7 @@ private: std::vector> Backtraces; }; - typedef std::map CacheEntryMap; + using CacheEntryMap = std::map; CacheEntryMap Cache; std::string VerifyScript; std::string VerifyStamp; diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 36e5d0e..d67c725 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -561,11 +561,11 @@ protected: const char* GetPredefinedTargetsFolder(); private: - typedef std::unordered_map TargetMap; - typedef std::unordered_map - GeneratorTargetMap; - typedef std::unordered_map MakefileMap; - typedef std::unordered_map LocalGeneratorMap; + using TargetMap = std::unordered_map; + using GeneratorTargetMap = + std::unordered_map; + using MakefileMap = std::unordered_map; + using LocalGeneratorMap = std::unordered_map; // Map efficiently from target name to cmTarget instance. // Do not use this structure for looping over all targets. // It contains both normal and globally visible imported targets. @@ -626,7 +626,7 @@ private: std::vector FilesReplacedDuringGenerate; // Store computed inter-target dependencies. - typedef std::map TargetDependMap; + using TargetDependMap = std::map; TargetDependMap TargetDependencies; friend class cmake; diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h index 9b5bf63..e58e65e 100644 --- a/Source/cmGlobalGhsMultiGenerator.h +++ b/Source/cmGlobalGhsMultiGenerator.h @@ -148,9 +148,8 @@ class cmGlobalGhsMultiGenerator::OrderedTargetDependSet : public std::multiset { - typedef std::multiset - derived; + using derived = + std::multiset; public: using TargetDependSet = cmGlobalGenerator::TargetDependSet; diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index db64031..f6d5998 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -426,7 +426,7 @@ private: /// The mapping from source file to assumed dependencies. std::map> AssumedSourceDependencies; - typedef std::map TargetAliasMap; + using TargetAliasMap = std::map; TargetAliasMap TargetAliases; std::map TargetDependsClosures; diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 287472c..264de54 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -220,9 +220,8 @@ protected: std::vector Marks; void WriteProgressVariables(unsigned long total, unsigned long& current); }; - typedef std::map - ProgressMapType; + using ProgressMapType = std::map; ProgressMapType ProgressMap; size_t CountProgressMarksInTarget( diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index e4cd73f..bd615ec 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -180,7 +180,7 @@ protected: const std::string&); virtual std::string WriteUtilityDepend(cmGeneratorTarget const*) = 0; std::string GetUtilityDepend(const cmGeneratorTarget* target); - typedef std::map UtilityDependsMap; + using UtilityDependsMap = std::map; UtilityDependsMap UtilityDepends; protected: @@ -213,13 +213,12 @@ class cmGlobalVisualStudioGenerator::OrderedTargetDependSet : public std::multiset { - typedef std::multiset - derived; + using derived = std::multiset; public: - typedef cmGlobalGenerator::TargetDependSet TargetDependSet; - typedef cmGlobalVisualStudioGenerator::TargetSet TargetSet; + using TargetDependSet = cmGlobalGenerator::TargetDependSet; + using TargetSet = cmGlobalVisualStudioGenerator::TargetSet; OrderedTargetDependSet(TargetDependSet const&, std::string const& first); OrderedTargetDependSet(TargetSet const&, std::string const& first); }; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 427ab44..21c2b2a 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1244,8 +1244,8 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget( // framework or bundle targets std::vector contentBuildPhases; if (isFrameworkTarget || isBundleTarget || isCFBundleTarget) { - typedef std::map> - mapOfVectorOfSourceFiles; + using mapOfVectorOfSourceFiles = + std::map>; mapOfVectorOfSourceFiles bundleFiles; for (auto sourceFile : classes) { cmGeneratorTarget::SourceFileFlags tsFlags = @@ -1292,8 +1292,8 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget( // create vector of "resource content file" build phases - only for // framework or bundle targets if (isFrameworkTarget || isBundleTarget || isCFBundleTarget) { - typedef std::map> - mapOfVectorOfSourceFiles; + using mapOfVectorOfSourceFiles = + std::map>; mapOfVectorOfSourceFiles bundleFiles; for (auto sourceFile : classes) { cmGeneratorTarget::SourceFileFlags tsFlags = @@ -3048,7 +3048,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( this->CreateObject(cmXCodeObject::XCConfigurationList); cmXCodeObject* buildConfigurations = this->CreateObject(cmXCodeObject::OBJECT_LIST); - typedef std::vector> Configs; + using Configs = std::vector>; Configs configs; std::string defaultConfigName; for (const auto& name : this->CurrentConfigurationTypes) { diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h index 4a43073..f949ae3 100644 --- a/Source/cmIDEOptions.h +++ b/Source/cmIDEOptions.h @@ -51,7 +51,7 @@ protected: // and overwrite or add new values to this map class FlagValue : public std::vector { - typedef std::vector derived; + using derived = std::vector; public: FlagValue& operator=(std::string const& r) diff --git a/Source/cmInstalledFile.h b/Source/cmInstalledFile.h index e00e666..ee809ee 100644 --- a/Source/cmInstalledFile.h +++ b/Source/cmInstalledFile.h @@ -37,7 +37,7 @@ public: ExpressionVectorType ValueExpressions; }; - typedef std::map PropertyMapType; + using PropertyMapType = std::map; cmInstalledFile(); diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index f63fe0f..8c7e7a3 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -433,8 +433,8 @@ protected: std::set EnvCPATH; - typedef std::unordered_map - GeneratorTargetMap; + using GeneratorTargetMap = + std::unordered_map; GeneratorTargetMap GeneratorTargetSearchIndex; std::vector GeneratorTargets; diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 3a30bbb..08bec70 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -109,8 +109,8 @@ private: std::string HomeRelativeOutputPath; - typedef std::map> - CustomCommandTargetMap; + using CustomCommandTargetMap = + std::map>; CustomCommandTargetMap CustomCommandTargets; std::vector CustomCommands; }; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 357ccc8..dd25716 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -30,7 +30,7 @@ public: : LocalGenerator(e) { } - typedef cmComputeLinkInformation::ItemVector ItemVector; + using ItemVector = cmComputeLinkInformation::ItemVector; void OutputLibraries(std::ostream& fout, ItemVector const& libs); void OutputObjects(std::ostream& fout, cmGeneratorTarget* t, std::string const& config, const char* isep = 0); diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index ce8eceb..671783f 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -83,8 +83,8 @@ protected: void CreateSingleVCProj(const std::string& lname, cmGeneratorTarget* tgt); private: - typedef cmVS7GeneratorOptions Options; - typedef cmLocalVisualStudio7GeneratorFCInfo FCInfo; + using Options = cmVS7GeneratorOptions; + using FCInfo = cmLocalVisualStudio7GeneratorFCInfo; std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags, const std::string& configName); void FixGlobalTargets(); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index dfe0086..411add3 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2744,12 +2744,13 @@ MessageType cmMakefile::ExpandVariablesInStringOld( return mtype; } -typedef enum +enum t_domain { NORMAL, ENVIRONMENT, CACHE -} t_domain; +}; + struct t_lookup { t_domain domain = NORMAL; diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 9eeeed0..f464128 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -223,7 +223,7 @@ protected: // Set of extra output files to be driven by the build. std::set ExtraFiles; - typedef std::map MultipleOutputPairsType; + using MultipleOutputPairsType = std::map; MultipleOutputPairsType MultipleOutputPairs; bool WriteMakeRule(std::ostream& os, const char* comment, const std::vector& outputs, diff --git a/Source/cmNinjaTypes.h b/Source/cmNinjaTypes.h index 89afbbd..bd0e83f 100644 --- a/Source/cmNinjaTypes.h +++ b/Source/cmNinjaTypes.h @@ -19,7 +19,7 @@ enum cmNinjaTargetDepends using cmNinjaDeps = std::vector; using cmNinjaOuts = std::set; -typedef std::map cmNinjaVars; +using cmNinjaVars = std::map; class cmNinjaRule { diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index 21a17e8..35ec33e 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -412,7 +412,7 @@ void cmOrderDirectories::AddOriginalDirectories( struct cmOrderDirectoriesCompare { - typedef std::pair ConflictPair; + using ConflictPair = std::pair; // The conflict pair is unique based on just the directory // (first). The second element is only used for displaying @@ -557,7 +557,7 @@ std::string const& cmOrderDirectories::GetRealPath(std::string const& dir) this->RealPaths.lower_bound(dir); if (i == this->RealPaths.end() || this->RealPaths.key_comp()(dir, i->first)) { - typedef std::map::value_type value_type; + using value_type = std::map::value_type; i = this->RealPaths.insert( i, value_type(dir, cmSystemTools::GetRealPath(dir))); } diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h index 23e61d6..2dfc4d1 100644 --- a/Source/cmOrderDirectories.h +++ b/Source/cmOrderDirectories.h @@ -75,7 +75,7 @@ private: // the index of the directory that must come first. The second // element is the index of the runtime library that added the // constraint. - typedef std::pair ConflictPair; + using ConflictPair = std::pair; struct ConflictList : public std::vector { }; diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index 1a854dc..c034fdd 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -446,10 +446,10 @@ protected: cmsys::RegularExpression IncludeFileRegularExpression; cmsys::RegularExpression ComplainFileRegularExpression; std::vector IncludeDirectories; - typedef std::map FileToPathMapType; - typedef std::map - DirectoryToFileToPathMapType; - typedef std::map DependInformationMapType; + using FileToPathMapType = std::map; + using DirectoryToFileToPathMapType = + std::map; + using DependInformationMapType = std::map; DependInformationMapType DependInformationMap; DirectoryToFileToPathMapType DirectoryToFileToPathMap; }; diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx index 3ed4c05..a3d4946 100644 --- a/Source/cmPropertyMap.cxx +++ b/Source/cmPropertyMap.cxx @@ -66,7 +66,7 @@ std::vector cmPropertyMap::GetKeys() const std::vector> cmPropertyMap::GetList() const { - typedef std::pair StringPair; + using StringPair = std::pair; std::vector kvList; kvList.reserve(Map_.size()); for (auto const& item : Map_) { diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 84359f2..14329c0 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -1237,7 +1237,7 @@ std::pair cmQtAutoMocUic::JobGenerateT::MocFindDependency( std::string const& sourceDir, std::string const& includeString) const { - typedef std::pair ResPair; + using ResPair = std::pair; // Search in vicinity of the source { ResPair res{ sourceDir + includeString, {} }; diff --git a/Source/cmQtAutoMocUic.h b/Source/cmQtAutoMocUic.h index 076e460..549b088 100644 --- a/Source/cmQtAutoMocUic.h +++ b/Source/cmQtAutoMocUic.h @@ -107,7 +107,7 @@ public: } Uic; }; using FileHandleT = std::shared_ptr; - typedef std::pair GetOrInsertT; + using GetOrInsertT = std::pair; public: ParseCacheT(); @@ -147,7 +147,7 @@ public: bool Uic = false; }; using SourceFileHandleT = std::shared_ptr; - typedef std::map SourceFileMapT; + using SourceFileMapT = std::map; /** * Meta compiler file mapping information @@ -160,7 +160,7 @@ public: std::vector IncluderFiles; }; using MappingHandleT = std::shared_ptr; - typedef std::map MappingMapT; + using MappingMapT = std::map; /** * Common settings diff --git a/Source/cmSourceGroupCommand.h b/Source/cmSourceGroupCommand.h index 45438a9..87a6114 100644 --- a/Source/cmSourceGroupCommand.h +++ b/Source/cmSourceGroupCommand.h @@ -40,7 +40,7 @@ public: cmExecutionStatus& status) override; private: - typedef std::map> ParsedArguments; + using ParsedArguments = std::map>; using ExpectedOptions = std::vector; ExpectedOptions getExpectedOptions() const; diff --git a/Source/cmString.hxx b/Source/cmString.hxx index 050a2fd..a401ad1 100644 --- a/Source/cmString.hxx +++ b/Source/cmString.hxx @@ -725,7 +725,7 @@ struct StringAdd template struct StringAdd> : std::true_type { - typedef StringOpPlus const& temp_type; + using temp_type = StringOpPlus const&; static temp_type temp(temp_type s) { return s; } }; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index fa420af..e9bcffe 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -107,7 +107,7 @@ public: cmSourceFile* AddSource(const std::string& src, bool before = false); //! how we identify a library, by name and type - typedef std::pair LibraryID; + using LibraryID = std::pair; using LinkLibraryVectorType = std::vector; LinkLibraryVectorType const& GetOriginalLinkLibraries() const; diff --git a/Source/cmVariableWatch.h b/Source/cmVariableWatch.h index 32445d5..e4b3b7c 100644 --- a/Source/cmVariableWatch.h +++ b/Source/cmVariableWatch.h @@ -77,7 +77,7 @@ protected: }; using VectorOfPairs = std::vector>; - typedef std::map StringToVectorOfPairs; + using StringToVectorOfPairs = std::map; StringToVectorOfPairs WatchMap; }; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 06e1798..101c97a 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -121,7 +121,7 @@ struct cmVisualStudio10TargetGenerator::Elem class cmVS10GeneratorOptions : public cmVisualStudioGeneratorOptions { public: - typedef cmVisualStudio10TargetGenerator::Elem Elem; + using Elem = cmVisualStudio10TargetGenerator::Elem; cmVS10GeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool, cmVS7FlagTable const* table, cmVisualStudio10TargetGenerator* g = nullptr) @@ -894,7 +894,7 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferenceCustomTags( static const std::string refpropPrefix = "VS_DOTNET_REFERENCEPROP_"; static const std::string refpropInfix = "_TAG_"; const std::string refPropFullPrefix = refpropPrefix + ref + refpropInfix; - typedef std::map CustomTags; + using CustomTags = std::map; CustomTags tags; cmPropertyMap const& props = this->GeneratorTarget->Target->GetProperties(); for (const auto& i : props.GetList()) { @@ -2349,7 +2349,7 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( } if (this->ProjectType == csproj) { std::string f = source->GetFullPath(); - typedef std::map CsPropMap; + using CsPropMap = std::map; CsPropMap sourceFileTags; // set tag if necessary std::string link; @@ -3663,7 +3663,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLibOptions( } cmComputeLinkInformation& cli = *pcli; - typedef cmComputeLinkInformation::ItemVector ItemVector; + using ItemVector = cmComputeLinkInformation::ItemVector; const ItemVector& libs = cli.GetItems(); std::string currentBinDir = this->LocalGenerator->GetCurrentBinaryDirectory(); @@ -3708,7 +3708,7 @@ void cmVisualStudio10TargetGenerator::AddLibraries( const cmComputeLinkInformation& cli, std::vector& libVec, std::vector& vsTargetVec, const std::string& config) { - typedef cmComputeLinkInformation::ItemVector ItemVector; + using ItemVector = cmComputeLinkInformation::ItemVector; ItemVector const& libs = cli.GetItems(); std::string currentBinDir = this->LocalGenerator->GetCurrentBinaryDirectory(); @@ -3934,8 +3934,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0) { cmGlobalGenerator::TargetDependSet const& unordered = this->GlobalGenerator->GetTargetDirectDepends(this->GeneratorTarget); - typedef cmGlobalVisualStudioGenerator::OrderedTargetDependSet - OrderedTargetDependSet; + using OrderedTargetDependSet = + cmGlobalVisualStudioGenerator::OrderedTargetDependSet; OrderedTargetDependSet depends(unordered, CMAKE_CHECK_BUILD_SYSTEM_TARGET); Elem e1(e0, "ItemGroup"); e1.SetHasElements(); diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 6607e77..4dd92eb 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -186,8 +186,8 @@ private: private: friend class cmVS10GeneratorOptions; - typedef cmVS10GeneratorOptions Options; - typedef std::map> OptionsMap; + using Options = cmVS10GeneratorOptions; + using OptionsMap = std::map>; OptionsMap ClOptions; OptionsMap RcOptions; OptionsMap CudaOptions; @@ -224,16 +224,16 @@ private: std::string DefaultArtifactDir; bool AddedDefaultCertificate = false; // managed C++/C# relevant members - typedef std::pair DotNetHintReference; - typedef std::vector DotNetHintReferenceList; - typedef std::map - DotNetHintReferenceMap; + using DotNetHintReference = std::pair; + using DotNetHintReferenceList = std::vector; + using DotNetHintReferenceMap = + std::map; DotNetHintReferenceMap DotNetHintReferences; - typedef std::set UsingDirectories; - typedef std::map UsingDirectoriesMap; + using UsingDirectories = std::set; + using UsingDirectoriesMap = std::map; UsingDirectoriesMap AdditionalUsingDirectories; - typedef std::map ToolSourceMap; + using ToolSourceMap = std::map; ToolSourceMap Tools; std::string GetCMakeFilePath(const char* name) const; }; diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h index a30a67f..560593e 100644 --- a/Source/cmVisualStudioGeneratorOptions.h +++ b/Source/cmVisualStudioGeneratorOptions.h @@ -14,7 +14,7 @@ class cmLocalVisualStudioGenerator; -typedef cmIDEFlagTable cmVS7FlagTable; +using cmVS7FlagTable = cmIDEFlagTable; class cmVisualStudioGeneratorOptions : public cmIDEOptions { diff --git a/Source/cmVisualStudioSlnData.h b/Source/cmVisualStudioSlnData.h index 9c1dffc..5ce7d74 100644 --- a/Source/cmVisualStudioSlnData.h +++ b/Source/cmVisualStudioSlnData.h @@ -45,9 +45,9 @@ public: const std::string& projectRelativePath); private: - typedef std::map ProjectStorage; + using ProjectStorage = std::map; ProjectStorage ProjectsByGUID; - typedef std::map ProjectStringIndex; + using ProjectStringIndex = std::map; ProjectStringIndex ProjectNameIndex; }; diff --git a/Source/cmVisualStudioSlnParser.cxx b/Source/cmVisualStudioSlnParser.cxx index 9eaee11..05ef517 100644 --- a/Source/cmVisualStudioSlnParser.cxx +++ b/Source/cmVisualStudioSlnParser.cxx @@ -51,7 +51,7 @@ public: void CopyVerbatim(const std::string& line) { this->Tag = line; } private: - typedef std::pair StringData; + using StringData = std::pair; std::string Tag; StringData Arg; std::vector Values; diff --git a/Source/cmVisualStudioSlnParser.h b/Source/cmVisualStudioSlnParser.h index d6345a8..166f788 100644 --- a/Source/cmVisualStudioSlnParser.h +++ b/Source/cmVisualStudioSlnParser.h @@ -42,7 +42,7 @@ public: DataGroupCount }; - typedef std::bitset DataGroupSet; + using DataGroupSet = std::bitset; static const DataGroupSet DataGroupProjects; static const DataGroupSet DataGroupProjectDependencies; diff --git a/Source/cmXCodeScheme.h b/Source/cmXCodeScheme.h index 8c47123..1cc5324 100644 --- a/Source/cmXCodeScheme.h +++ b/Source/cmXCodeScheme.h @@ -18,7 +18,7 @@ class cmXCodeScheme { public: - typedef std::vector TestObjects; + using TestObjects = std::vector; cmXCodeScheme(cmXCodeObject* xcObj, TestObjects tests, const std::vector& configList, diff --git a/Source/cm_string_view.hxx b/Source/cm_string_view.hxx index d368ed8..04de797 100644 --- a/Source/cm_string_view.hxx +++ b/Source/cm_string_view.hxx @@ -207,8 +207,8 @@ namespace std { template <> struct hash { - typedef cm::string_view argument_type; - typedef size_t result_type; + using argument_type = cm::string_view; + using result_type = size_t; result_type operator()(argument_type const& s) const noexcept; }; } diff --git a/Source/cm_sys_stat.h b/Source/cm_sys_stat.h index 796f027..d3b9ef2 100644 --- a/Source/cm_sys_stat.h +++ b/Source/cm_sys_stat.h @@ -4,12 +4,12 @@ #define cm_sys_stat_h #if defined(_MSC_VER) -typedef unsigned short mode_t; +using mode_t = unsigned short; #endif #if defined(WIN32) -typedef unsigned short uid_t; -typedef unsigned short gid_t; +using uid_t = unsigned short; +using gid_t = unsigned short; #endif #include diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 1746082..ace9198 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -116,7 +116,7 @@ namespace { #if !defined(CMAKE_BOOTSTRAP) -typedef std::unordered_map JsonValueMapType; +using JsonValueMapType = std::unordered_map; #endif } // namespace diff --git a/Source/cmake.h b/Source/cmake.h index cc44b92..687c105 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -133,7 +133,7 @@ public: std::unordered_set unordered; }; - typedef std::map InstalledFilesMap; + using InstalledFilesMap = std::map; static const int NO_BUILD_PARALLEL_LEVEL = -1; static const int DEFAULT_BUILD_PARALLEL_LEVEL = 0; ----------------------------------------------------------------------- Summary of changes: .clang-tidy | 1 - Source/CPack/IFW/cmCPackIFWGenerator.h | 12 +++++------ Source/CPack/IFW/cmCPackIFWInstaller.h | 4 ++-- Source/CPack/IFW/cmCPackIFWRepository.h | 2 +- Source/CPack/WiX/cmCPackWIXGenerator.h | 6 +++--- Source/CPack/WiX/cmWIXPatchParser.h | 6 +++--- Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx | 2 +- Source/CPack/WiX/cmWIXShortcut.h | 6 +++--- Source/CPack/cmCPackArchiveGenerator.h | 2 +- Source/CPack/cmCPackFreeBSDGenerator.cxx | 4 ++-- Source/CPack/cmCPackFreeBSDGenerator.h | 4 +++- Source/CPack/cmCPackGenerator.h | 2 +- Source/CPack/cmCPackGeneratorFactory.h | 6 +++--- Source/CPack/cpack.cxx | 2 +- Source/CTest/cmCTestBuildAndTestHandler.h | 2 +- Source/CTest/cmCTestBuildHandler.cxx | 2 +- Source/CTest/cmCTestBuildHandler.h | 8 ++++---- Source/CTest/cmCTestConfigureHandler.h | 2 +- Source/CTest/cmCTestCoverageCommand.h | 2 +- Source/CTest/cmCTestCoverageHandler.h | 10 ++++----- Source/CTest/cmCTestGenericHandler.h | 2 +- Source/CTest/cmCTestMemCheckHandler.h | 2 +- Source/CTest/cmCTestScriptHandler.h | 2 +- Source/CTest/cmCTestSubmitCommand.h | 2 +- Source/CTest/cmCTestSubmitHandler.h | 4 ++-- Source/CTest/cmCTestTestHandler.cxx | 2 +- Source/CTest/cmCTestTestHandler.h | 11 +++++----- Source/CTest/cmCTestUpdateHandler.h | 2 +- Source/CTest/cmCTestUploadCommand.h | 2 +- Source/CTest/cmCTestUploadHandler.h | 2 +- Source/QtDialog/QCMake.h | 2 +- Source/cmAffinity.cxx | 2 +- Source/cmCLocaleEnvironmentScope.h | 2 +- Source/cmCPluginAPI.h | 11 ++++++++++ Source/cmCacheManager.h | 2 +- Source/cmCommonTargetGenerator.cxx | 2 +- Source/cmCommonTargetGenerator.h | 2 +- Source/cmCustomCommand.h | 2 +- Source/cmDepends.h | 2 +- Source/cmDependsC.h | 2 +- Source/cmDependsFortran.cxx | 4 ++-- Source/cmDuration.h | 2 +- Source/cmELF.cxx | 15 +++++++------- Source/cmELF.h | 2 +- Source/cmExportFileGenerator.h | 2 +- Source/cmExportSetMap.h | 2 +- Source/cmExtraCodeBlocksGenerator.cxx | 2 +- Source/cmExtraSublimeTextGenerator.h | 2 +- Source/cmFileLockResult.h | 2 +- Source/cmGeneratorExpression.cxx | 5 ++--- Source/cmGeneratorExpressionNode.cxx | 2 +- Source/cmGeneratorTarget.cxx | 4 ++-- Source/cmGeneratorTarget.h | 28 +++++++++++++------------- Source/cmGlobVerificationManager.h | 2 +- Source/cmGlobalGenerator.h | 12 +++++------ Source/cmGlobalGhsMultiGenerator.h | 5 ++--- Source/cmGlobalNinjaGenerator.h | 2 +- Source/cmGlobalUnixMakefileGenerator3.h | 5 ++--- Source/cmGlobalVisualStudioGenerator.h | 11 +++++----- Source/cmGlobalXCodeGenerator.cxx | 10 ++++----- Source/cmIDEOptions.h | 2 +- Source/cmInstalledFile.h | 2 +- Source/cmListFileLexer.h | 13 ++++++++---- Source/cmLocalCommonGenerator.cxx | 6 ++---- Source/cmLocalGenerator.cxx | 18 +++++------------ Source/cmLocalGenerator.h | 5 ++--- Source/cmLocalNinjaGenerator.h | 4 ++-- Source/cmLocalUnixMakefileGenerator3.cxx | 6 ------ Source/cmLocalUnixMakefileGenerator3.h | 1 - Source/cmLocalVisualStudio7Generator.cxx | 2 +- Source/cmLocalVisualStudio7Generator.h | 4 ++-- Source/cmMakefile.cxx | 5 +++-- Source/cmMakefileExecutableTargetGenerator.cxx | 9 +++++---- Source/cmMakefileTargetGenerator.cxx | 4 ++-- Source/cmMakefileTargetGenerator.h | 2 +- Source/cmNinjaTypes.h | 2 +- Source/cmOrderDirectories.cxx | 4 ++-- Source/cmOrderDirectories.h | 2 +- Source/cmOutputRequiredFilesCommand.cxx | 8 ++++---- Source/cmPropertyMap.cxx | 2 +- Source/cmQtAutoMocUic.cxx | 2 +- Source/cmQtAutoMocUic.h | 6 +++--- Source/cmSourceGroupCommand.h | 2 +- Source/cmString.hxx | 2 +- Source/cmTarget.h | 2 +- Source/cmVariableWatch.h | 2 +- Source/cmVisualStudio10TargetGenerator.cxx | 14 ++++++------- Source/cmVisualStudio10TargetGenerator.h | 18 ++++++++--------- Source/cmVisualStudioGeneratorOptions.h | 2 +- Source/cmVisualStudioSlnData.h | 4 ++-- Source/cmVisualStudioSlnParser.cxx | 2 +- Source/cmVisualStudioSlnParser.h | 2 +- Source/cmXCodeScheme.h | 2 +- Source/cm_string_view.hxx | 4 ++-- Source/cm_sys_stat.h | 6 +++--- Source/cmake.cxx | 2 +- Source/cmake.h | 2 +- 97 files changed, 217 insertions(+), 222 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Sat Sep 7 00:00:25 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Sat, 7 Sep 2019 00:00:25 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-970-g9aecf2e Message-ID: <20190907040025.6034311E3F0@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 9aecf2e84016568d41cd199eb8a57d370f442041 (commit) from ca8c3d64c8accebeacf322f0574494ffddb039c5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9aecf2e84016568d41cd199eb8a57d370f442041 commit 9aecf2e84016568d41cd199eb8a57d370f442041 Author: Kitware Robot AuthorDate: Sat Sep 7 00:01:06 2019 -0400 Commit: Kitware Robot CommitDate: Sat Sep 7 00:01:06 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index b54dbd1..8565e4b 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 15) -set(CMake_VERSION_PATCH 20190906) +set(CMake_VERSION_PATCH 20190907) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Sat Sep 7 23:59:49 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Sat, 7 Sep 2019 23:59:49 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-971-gc52a354 Message-ID: <20190908035949.6B2D610D106@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via c52a354244086a3ad591ae01eb506ec5851bcfc2 (commit) from 9aecf2e84016568d41cd199eb8a57d370f442041 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c52a354244086a3ad591ae01eb506ec5851bcfc2 commit c52a354244086a3ad591ae01eb506ec5851bcfc2 Author: Kitware Robot AuthorDate: Sun Sep 8 00:01:20 2019 -0400 Commit: Kitware Robot CommitDate: Sun Sep 8 00:01:20 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 8565e4b..fd605fa 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 15) -set(CMake_VERSION_PATCH 20190907) +set(CMake_VERSION_PATCH 20190908) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Sun Sep 8 23:59:16 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Sun, 8 Sep 2019 23:59:16 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-972-gd803d6b Message-ID: <20190909035916.553605181@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via d803d6b59f294b1bd1bd32beb75468399560be95 (commit) from c52a354244086a3ad591ae01eb506ec5851bcfc2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d803d6b59f294b1bd1bd32beb75468399560be95 commit d803d6b59f294b1bd1bd32beb75468399560be95 Author: Kitware Robot AuthorDate: Mon Sep 9 00:01:04 2019 -0400 Commit: Kitware Robot CommitDate: Mon Sep 9 00:01:04 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index fd605fa..857e5f1 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 15) -set(CMake_VERSION_PATCH 20190908) +set(CMake_VERSION_PATCH 20190909) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Sep 9 09:49:03 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 9 Sep 2019 09:49:03 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-974-g922482d Message-ID: <20190909134904.06355F3ECF@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 922482dd3acd2af9d26476134b3386c5a7695a03 (commit) via 2d7bb13da7ec13ce73facaff07847d75d8a20e91 (commit) from d803d6b59f294b1bd1bd32beb75468399560be95 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=922482dd3acd2af9d26476134b3386c5a7695a03 commit 922482dd3acd2af9d26476134b3386c5a7695a03 Merge: d803d6b 2d7bb13 Author: Brad King AuthorDate: Mon Sep 9 13:41:20 2019 +0000 Commit: Kitware Robot CommitDate: Mon Sep 9 09:41:32 2019 -0400 Merge topic 'cuda_resolve_device_symbols_on_static_lib_collect_deps_properly' 2d7bb13da7 CUDA: static lib device linking computes required static libs Acked-by: Kitware Robot Merge-request: !3748 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2d7bb13da7ec13ce73facaff07847d75d8a20e91 commit 2d7bb13da7ec13ce73facaff07847d75d8a20e91 Author: Robert Maynard AuthorDate: Tue Aug 27 13:52:55 2019 -0400 Commit: Robert Maynard CommitDate: Thu Sep 5 10:51:02 2019 -0400 CUDA: static lib device linking computes required static libs Previously the CMake didn't compute the required set of libraries needed to properly device link a static library when CUDA_RESOLVE_DEVICE_SYMBOLS was enabled. diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx index 9c0e20f..1a602ca 100644 --- a/Source/cmLinkLineDeviceComputer.cxx +++ b/Source/cmLinkLineDeviceComputer.cxx @@ -82,6 +82,9 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries( ItemVector const& items = cli.GetItems(); std::string config = cli.GetConfig(); bool skipItemAfterFramework = false; + // Note: + // Any modification of this algorithm should be reflected also in + // cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions for (auto const& item : items) { if (skipItemAfterFramework) { skipItemAfterFramework = false; @@ -91,6 +94,7 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries( if (item.Target) { bool skip = false; switch (item.Target->GetType()) { + case cmStateEnums::SHARED_LIBRARY: case cmStateEnums::MODULE_LIBRARY: case cmStateEnums::INTERFACE_LIBRARY: skip = true; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index f0145c5..ee0d4da 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -14,6 +14,7 @@ #include "cmInstallScriptGenerator.h" #include "cmInstallTargetGenerator.h" #include "cmLinkLineComputer.h" +#include "cmLinkLineDeviceComputer.h" #include "cmMakefile.h" #include "cmRulePlaceholderExpander.h" #include "cmSourceFile.h" @@ -1152,6 +1153,12 @@ void cmLocalGenerator::GetTargetFlags( switch (target->GetType()) { case cmStateEnums::STATIC_LIBRARY: this->GetStaticLibraryFlags(linkFlags, buildType, linkLanguage, target); + if (pcli && dynamic_cast(linkLineComputer)) { + // Compute the required cuda device link libraries when + // resolving cuda device symbols + this->OutputLinkLibraries(pcli, linkLineComputer, linkLibs, + frameworkPath, linkPath); + } break; case cmStateEnums::MODULE_LIBRARY: libraryLinkVariable = "CMAKE_MODULE_LINKER_FLAGS"; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 4244402..d51bba4 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -300,19 +300,16 @@ void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules( // Collect up flags to link in needed libraries. std::string linkLibs; - if (this->GeneratorTarget->GetType() != cmStateEnums::STATIC_LIBRARY) { - - std::unique_ptr linkLineComputer( - new cmLinkLineDeviceComputer( - this->LocalGenerator, - this->LocalGenerator->GetStateSnapshot().GetDirectory())); - linkLineComputer->SetForResponse(useResponseFileForLibs); - linkLineComputer->SetUseWatcomQuote(useWatcomQuote); - linkLineComputer->SetRelink(relink); - - this->CreateLinkLibs(linkLineComputer.get(), linkLibs, - useResponseFileForLibs, depends); - } + std::unique_ptr linkLineComputer( + new cmLinkLineDeviceComputer( + this->LocalGenerator, + this->LocalGenerator->GetStateSnapshot().GetDirectory())); + linkLineComputer->SetForResponse(useResponseFileForLibs); + linkLineComputer->SetUseWatcomQuote(useWatcomQuote); + linkLineComputer->SetRelink(relink); + + this->CreateLinkLibs(linkLineComputer.get(), linkLibs, + useResponseFileForLibs, depends); // Construct object file lists that may be needed to expand the // rule. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 06e1798..209ebb1 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -3101,6 +3101,82 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions( "-Wno-deprecated-gpu-targets"); } + // For static libraries that have device linking enabled compute + // the libraries + if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY && + doDeviceLinking) { + cmComputeLinkInformation* pcli = + this->GeneratorTarget->GetLinkInformation(configName); + if (!pcli) { + cmSystemTools::Error( + "CMake can not compute cmComputeLinkInformation for target: " + + this->Name); + return false; + } + + // Would like to use: + // cmLinkLineDeviceComputer computer(this->LocalGenerator, + // this->LocalGenerator->GetStateSnapshot().GetDirectory()); + // std::string computed_libs = computer.ComputeLinkLibraries(cli, + // std::string{}); but it outputs in " " format instead of + // ";" + // Note: + // Any modification of this algorithm should be reflected also in + // cmLinkLineDeviceComputer + cmComputeLinkInformation& cli = *pcli; + std::vector libVec; + const std::string currentBinDir = + this->LocalGenerator->GetCurrentBinaryDirectory(); + const auto& libs = cli.GetItems(); + for (cmComputeLinkInformation::Item const& l : libs) { + + if (l.Target) { + auto managedType = l.Target->GetManagedType(configName); + // Do not allow C# targets to be added to the LIB listing. LIB files + // are used for linking C++ dependencies. C# libraries do not have lib + // files. Instead, they compile down to C# reference libraries (DLL + // files). The + // `` elements added to the vcxproj are enough for + // the IDE to deduce the DLL file required by other C# projects that + // need its reference library. + if (managedType == cmGeneratorTarget::ManagedType::Managed) { + continue; + } + const auto type = l.Target->GetType(); + + bool skip = false; + switch (type) { + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: + case cmStateEnums::INTERFACE_LIBRARY: + skip = true; + break; + case cmStateEnums::STATIC_LIBRARY: + skip = l.Target->GetPropertyAsBool("CUDA_RESOLVE_DEVICE_SYMBOLS"); + break; + default: + break; + } + if (skip) { + continue; + } + } + + if (l.IsPath) { + std::string path = this->LocalGenerator->MaybeConvertToRelativePath( + currentBinDir, l.Value); + ConvertToWindowsSlash(path); + if (!cmVS10IsTargetsFile(l.Value)) { + libVec.push_back(path); + } + } else { + libVec.push_back(l.Value); + } + } + + cudaLinkOptions.AddFlag("AdditionalDependencies", libVec); + } + this->CudaLinkOptions[configName] = std::move(pOptions); return true; } diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt index 796e133..64845c5 100644 --- a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt +++ b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt @@ -16,21 +16,29 @@ else() endif() #Goal for this example: -# Build a static library that defines multiple methods and kernels that -# use each other. -# Resolve the device symbols into that static library -# Verify that we can't use those device symbols from anything that links +# 1. Build two static libraries that defines multiple methods and kernels +# 2. Resolve the device symbols into the second static library, therefore +# confirming that the first static library is on the device link line +# 3. Verify that we can't use those device symbols from anything that links # to the static library -string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[compute_30] -gencode arch=compute_50,code=\\\"compute_50\\\"") +string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[sm_30] -gencode arch=compute_50,code=\\\"compute_50\\\"") set(CMAKE_CXX_STANDARD 11) set(CMAKE_CUDA_STANDARD 11) -add_library(CUDAResolveDeviceLib STATIC file1.cu file2.cu) +add_library(CUDAResolveDeviceDepsA STATIC file1.cu) +add_library(CUDAResolveDeviceDepsB STATIC file2.cu) +set_target_properties(CUDAResolveDeviceDepsA CUDAResolveDeviceDepsB + PROPERTIES + CUDA_SEPARABLE_COMPILATION ON + POSITION_INDEPENDENT_CODE ON) + +add_library(CUDAResolveDeviceLib STATIC file2_launch.cu) set_target_properties(CUDAResolveDeviceLib PROPERTIES CUDA_SEPARABLE_COMPILATION ON CUDA_RESOLVE_DEVICE_SYMBOLS ON POSITION_INDEPENDENT_CODE ON) +target_link_libraries(CUDAResolveDeviceLib PRIVATE CUDAResolveDeviceDepsA CUDAResolveDeviceDepsB) if(dump_command) add_custom_command(TARGET CUDAResolveDeviceLib POST_BUILD @@ -45,7 +53,8 @@ endif() add_executable(CudaOnlyResolveDeviceSymbols main.cu) set_target_properties(CudaOnlyResolveDeviceSymbols PROPERTIES - CUDA_SEPARABLE_COMPILATION ON) + CUDA_SEPARABLE_COMPILATION OFF + CUDA_RESOLVE_DEVICE_SYMBOLS OFF) target_link_libraries(CudaOnlyResolveDeviceSymbols PRIVATE CUDAResolveDeviceLib) diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/file1.h b/Tests/CudaOnly/ResolveDeviceSymbols/file1.h index ff1945c..b33bcae 100644 --- a/Tests/CudaOnly/ResolveDeviceSymbols/file1.h +++ b/Tests/CudaOnly/ResolveDeviceSymbols/file1.h @@ -1,7 +1,10 @@ #pragma once + struct result_type { int input; int sum; }; + +result_type __device__ file1_func(int x); diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/file2.cu b/Tests/CudaOnly/ResolveDeviceSymbols/file2.cu index 278fd6c..0e5e7aa 100644 --- a/Tests/CudaOnly/ResolveDeviceSymbols/file2.cu +++ b/Tests/CudaOnly/ResolveDeviceSymbols/file2.cu @@ -1,25 +1,9 @@ #include "file2.h" -result_type __device__ file1_func(int x); - result_type_dynamic __device__ file2_func(int x) { const result_type r = file1_func(x); const result_type_dynamic rd{ r.input, r.sum, true }; return rd; } - -static __global__ void file2_kernel(result_type_dynamic& r, int x) -{ - // call static_func which is a method that is defined in the - // static library that is always out of date - r = file2_func(x); -} - -int file2_launch_kernel(int x) -{ - result_type_dynamic r; - file2_kernel<<<1, 1>>>(r, x); - return r.sum; -} diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/file2.h b/Tests/CudaOnly/ResolveDeviceSymbols/file2.h index d2dbaa4..c6e2875 100644 --- a/Tests/CudaOnly/ResolveDeviceSymbols/file2.h +++ b/Tests/CudaOnly/ResolveDeviceSymbols/file2.h @@ -8,3 +8,5 @@ struct result_type_dynamic int sum; bool from_static; }; + +result_type_dynamic __device__ file2_func(int x); diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/file2.cu b/Tests/CudaOnly/ResolveDeviceSymbols/file2_launch.cu similarity index 62% copy from Tests/CudaOnly/ResolveDeviceSymbols/file2.cu copy to Tests/CudaOnly/ResolveDeviceSymbols/file2_launch.cu index 278fd6c..4e8da13 100644 --- a/Tests/CudaOnly/ResolveDeviceSymbols/file2.cu +++ b/Tests/CudaOnly/ResolveDeviceSymbols/file2_launch.cu @@ -1,15 +1,6 @@ #include "file2.h" -result_type __device__ file1_func(int x); - -result_type_dynamic __device__ file2_func(int x) -{ - const result_type r = file1_func(x); - const result_type_dynamic rd{ r.input, r.sum, true }; - return rd; -} - static __global__ void file2_kernel(result_type_dynamic& r, int x) { // call static_func which is a method that is defined in the @@ -17,6 +8,8 @@ static __global__ void file2_kernel(result_type_dynamic& r, int x) r = file2_func(x); } +static __global__ void file2_kernel(result_type_dynamic& r, int x); + int file2_launch_kernel(int x) { result_type_dynamic r; diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/main.cu b/Tests/CudaOnly/ResolveDeviceSymbols/main.cu index d464f96..ea842cc 100644 --- a/Tests/CudaOnly/ResolveDeviceSymbols/main.cu +++ b/Tests/CudaOnly/ResolveDeviceSymbols/main.cu @@ -1,26 +1,10 @@ #include -#include "file1.h" #include "file2.h" int file2_launch_kernel(int x); -result_type_dynamic __device__ file2_func(int x); -static __global__ void main_kernel(result_type_dynamic& r, int x) -{ - // call function that was not device linked to us, this will cause - // a runtime failure of "invalid device function" - r = file2_func(x); -} - -int main_launch_kernel(int x) -{ - result_type_dynamic r; - main_kernel<<<1, 1>>>(r, x); - return r.sum; -} - int choose_cuda_device() { int nDevices = 0; @@ -62,12 +46,10 @@ int main(int argc, char** argv) return 0; } - main_launch_kernel(1); + file2_launch_kernel(1); cudaError_t err = cudaGetLastError(); - if (err == cudaSuccess) { - // This kernel launch should fail as the file2_func was device linked - // into the static library and is not usable by the executable - std::cerr << "main_launch_kernel: kernel launch should have failed" + if (err != cudaSuccess) { + std::cerr << "file2_launch_kernel: kernel launch should have passed" << std::endl; return 1; } ----------------------------------------------------------------------- Summary of changes: Source/cmLinkLineDeviceComputer.cxx | 4 ++ Source/cmLocalGenerator.cxx | 7 ++ Source/cmMakefileLibraryTargetGenerator.cxx | 23 +++---- Source/cmVisualStudio10TargetGenerator.cxx | 76 ++++++++++++++++++++++ Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt | 23 +++++-- Tests/CudaOnly/ResolveDeviceSymbols/file1.h | 3 + Tests/CudaOnly/ResolveDeviceSymbols/file2.cu | 16 ----- Tests/CudaOnly/ResolveDeviceSymbols/file2.h | 2 + .../{file2.cu => file2_launch.cu} | 11 +--- Tests/CudaOnly/ResolveDeviceSymbols/main.cu | 24 +------ 10 files changed, 123 insertions(+), 66 deletions(-) copy Tests/CudaOnly/ResolveDeviceSymbols/{file2.cu => file2_launch.cu} (62%) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Sep 9 23:58:41 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 9 Sep 2019 23:58:41 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-975-gf9a014e Message-ID: <20190910035841.1FC392119@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via f9a014e2c810799e0c148e44a2237704fdba717d (commit) from 922482dd3acd2af9d26476134b3386c5a7695a03 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f9a014e2c810799e0c148e44a2237704fdba717d commit f9a014e2c810799e0c148e44a2237704fdba717d Author: Kitware Robot AuthorDate: Tue Sep 10 00:01:05 2019 -0400 Commit: Kitware Robot CommitDate: Tue Sep 10 00:01:05 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 857e5f1..45dd11e 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 15) -set(CMake_VERSION_PATCH 20190909) +set(CMake_VERSION_PATCH 20190910) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Sep 10 10:09:06 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 10 Sep 2019 10:09:06 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-977-gc2ead49 Message-ID: <20190910140906.2425F17B9@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via c2ead49451cdd29da50954c88d45334694026ad0 (commit) via 4d71bea02c5269c7648913e117d0863860139bd4 (commit) from f9a014e2c810799e0c148e44a2237704fdba717d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c2ead49451cdd29da50954c88d45334694026ad0 commit c2ead49451cdd29da50954c88d45334694026ad0 Merge: f9a014e 4d71bea Author: Brad King AuthorDate: Tue Sep 10 14:01:52 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 10 10:02:00 2019 -0400 Merge topic 'local-var' 4d71bea02c cmLocalGenerator::AddConfigVariableFlags: optimize string construction Acked-by: Kitware Robot Merge-request: !3793 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4d71bea02c5269c7648913e117d0863860139bd4 commit 4d71bea02c5269c7648913e117d0863860139bd4 Author: Rolf Eike Beer AuthorDate: Mon Sep 9 08:15:29 2019 +0200 Commit: Rolf Eike Beer CommitDate: Mon Sep 9 08:15:32 2019 +0200 cmLocalGenerator::AddConfigVariableFlags: optimize string construction diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 9152e94..93b26ed 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2089,12 +2089,11 @@ void cmLocalGenerator::AddConfigVariableFlags(std::string& flags, const std::string& config) { // Add the flags from the variable itself. - std::string flagsVar = var; - this->AppendFlags(flags, this->Makefile->GetSafeDefinition(flagsVar)); + this->AppendFlags(flags, this->Makefile->GetSafeDefinition(var)); // Add the flags from the build-type specific variable. if (!config.empty()) { - flagsVar += "_"; - flagsVar += cmSystemTools::UpperCase(config); + const std::string flagsVar = + cmStrCat(var, '_', cmSystemTools::UpperCase(config)); this->AppendFlags(flags, this->Makefile->GetSafeDefinition(flagsVar)); } } ----------------------------------------------------------------------- Summary of changes: Source/cmLocalGenerator.cxx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Sep 10 10:28:26 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 10 Sep 2019 10:28:26 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-986-g05d5c66 Message-ID: <20190910142826.7090CFACCA@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 05d5c66ff853f88e6dbe43bbddd18dd8babaa427 (commit) via 1c2c541b0c2e1224c00cf4648f4b7ba7f1d19ec3 (commit) via b31aa0285c586298e253b5f94490bca58dcce5a2 (commit) via 8588cdf3a021941ad15e3b289737bc9f1ecec84a (commit) via f1f57cffc73cbb518d9559308f3d36a655e5738d (commit) via 175d8c4bf6505eeb02bb588527f3ff7b5eb143b9 (commit) via 7c5ec91301f31e7caff6524ab83b5bb5c614d5d7 (commit) via d63c1e4e6e8507cb1c8425d521cf61fa4adbf4a8 (commit) via 2528b70293724b401bc1927f90f2ef91a3f3d499 (commit) from c2ead49451cdd29da50954c88d45334694026ad0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=05d5c66ff853f88e6dbe43bbddd18dd8babaa427 commit 05d5c66ff853f88e6dbe43bbddd18dd8babaa427 Merge: 1c2c541 d63c1e4 Author: Brad King AuthorDate: Tue Sep 10 14:25:40 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 10 10:27:44 2019 -0400 Merge topic 'tidy-return-brace' d63c1e4e6e clang-tidy: modernize-return-braced-init-list Acked-by: Kitware Robot Merge-request: !3790 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1c2c541b0c2e1224c00cf4648f4b7ba7f1d19ec3 commit 1c2c541b0c2e1224c00cf4648f4b7ba7f1d19ec3 Merge: b31aa02 8588cdf Author: Brad King AuthorDate: Tue Sep 10 14:25:57 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 10 10:26:55 2019 -0400 Merge topic 'clang-tidy-8-macOS' 8588cdf3a0 clang-tidy: Fix bugprone-exception-escape diagnostic in test code f1f57cffc7 clang-tidy: Fix performance-for-range-copy diagnostic in Xcode generator 175d8c4bf6 clang-tidy: Resolve performance-unnecessary-value-param diagnostics 7c5ec91301 cmGeneratedFileStreamBase: Optimize string construction in Close Acked-by: Kitware Robot Merge-request: !3796 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b31aa0285c586298e253b5f94490bca58dcce5a2 commit b31aa0285c586298e253b5f94490bca58dcce5a2 Merge: c2ead49 2528b70 Author: Brad King AuthorDate: Tue Sep 10 14:25:27 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 10 10:25:40 2019 -0400 Merge topic 'clang-tidy-8' 2528b70293 clang-tidy: Remove old entries from blacklist Acked-by: Kitware Robot Merge-request: !3787 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8588cdf3a021941ad15e3b289737bc9f1ecec84a commit 8588cdf3a021941ad15e3b289737bc9f1ecec84a Author: Brad King AuthorDate: Mon Sep 9 13:49:03 2019 -0400 Commit: Brad King CommitDate: Mon Sep 9 13:51:23 2019 -0400 clang-tidy: Fix bugprone-exception-escape diagnostic in test code diff --git a/Tests/CMakeLib/testUVProcessChainHelper.cxx b/Tests/CMakeLib/testUVProcessChainHelper.cxx index 263665d..a77ec90 100644 --- a/Tests/CMakeLib/testUVProcessChainHelper.cxx +++ b/Tests/CMakeLib/testUVProcessChainHelper.cxx @@ -44,7 +44,7 @@ int main(int argc, char** argv) } if (command == "dedup") { // Use a nested scope to free all resources before aborting below. - { + try { std::string input = getStdin(); std::set seen; std::string output; @@ -56,6 +56,7 @@ int main(int argc, char** argv) } std::cout << output << std::flush; std::cerr << "3" << std::flush; + } catch (...) { } // On Windows, the exit code of abort() is different between debug and https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f1f57cffc73cbb518d9559308f3d36a655e5738d commit f1f57cffc73cbb518d9559308f3d36a655e5738d Author: Brad King AuthorDate: Mon Sep 9 13:40:08 2019 -0400 Commit: Brad King CommitDate: Mon Sep 9 13:51:23 2019 -0400 clang-tidy: Fix performance-for-range-copy diagnostic in Xcode generator Fix diagnostics that appear on macOS with clang-tidy-8. diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 502a642..3dae824 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1254,7 +1254,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget( bundleFiles[tsFlags.MacFolder].push_back(sourceFile); } } - for (auto keySources : bundleFiles) { + for (auto const& keySources : bundleFiles) { cmXCodeObject* copyFilesBuildPhase = this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase); copyFilesBuildPhase->SetComment("Copy files"); @@ -1302,7 +1302,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTarget( bundleFiles[tsFlags.MacFolder].push_back(sourceFile); } } - for (auto keySources : bundleFiles) { + for (auto const& keySources : bundleFiles) { cmXCodeObject* copyFilesBuildPhase = this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase); copyFilesBuildPhase->SetComment("Copy files"); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=175d8c4bf6505eeb02bb588527f3ff7b5eb143b9 commit 175d8c4bf6505eeb02bb588527f3ff7b5eb143b9 Author: Brad King AuthorDate: Mon Sep 9 13:38:01 2019 -0400 Commit: Brad King CommitDate: Mon Sep 9 13:51:23 2019 -0400 clang-tidy: Resolve performance-unnecessary-value-param diagnostics Fix diagnostics that appear on macOS with clang-tidy-8. Suppress cases where we intentionally take an argument by value to let the caller choose whether to copy or move. diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 10f822f..502a642 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1433,7 +1433,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateBuildPhase( void cmGlobalXCodeGenerator::CreateCustomCommands( cmXCodeObject* buildPhases, cmXCodeObject* sourceBuildPhase, cmXCodeObject* headerBuildPhase, cmXCodeObject* resourceBuildPhase, - std::vector contentBuildPhases, + std::vector const& contentBuildPhases, cmXCodeObject* frameworkBuildPhase, cmGeneratorTarget* gtgt) { std::vector const& prebuild = gtgt->GetPreBuildCommands(); diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 71446f9..af905d0 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -122,13 +122,11 @@ private: std::string RelativeToSource(const std::string& p); std::string RelativeToBinary(const std::string& p); std::string ConvertToRelativeForMake(std::string const& p); - void CreateCustomCommands(cmXCodeObject* buildPhases, - cmXCodeObject* sourceBuildPhase, - cmXCodeObject* headerBuildPhase, - cmXCodeObject* resourceBuildPhase, - std::vector contentBuildPhases, - cmXCodeObject* frameworkBuildPhase, - cmGeneratorTarget* gtgt); + void CreateCustomCommands( + cmXCodeObject* buildPhases, cmXCodeObject* sourceBuildPhase, + cmXCodeObject* headerBuildPhase, cmXCodeObject* resourceBuildPhase, + std::vector const& contentBuildPhases, + cmXCodeObject* frameworkBuildPhase, cmGeneratorTarget* gtgt); std::string ComputeInfoPListLocation(cmGeneratorTarget* target); diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index ff3ecd9..349d5e9 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -326,6 +326,7 @@ cmListFileBacktrace::cmListFileBacktrace(cmStateSnapshot const& snapshot) { } +/* NOLINTNEXTLINE(performance-unnecessary-value-param) */ cmListFileBacktrace::cmListFileBacktrace(std::shared_ptr parent, cmListFileContext const& lfc) : TopEntry(std::make_shared(std::move(parent), lfc)) diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx index db23efd..f9f7d66 100644 --- a/Source/cmVariableWatchCommand.cxx +++ b/Source/cmVariableWatchCommand.cxx @@ -91,6 +91,7 @@ static void deleteVariableWatchCallbackData(void* client_data) class FinalAction { public: + /* NOLINTNEXTLINE(performance-unnecessary-value-param) */ FinalAction(cmMakefile* makefile, std::string variable) : Action(std::make_shared(makefile, std::move(variable))) { https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7c5ec91301f31e7caff6524ab83b5bb5c614d5d7 commit 7c5ec91301f31e7caff6524ab83b5bb5c614d5d7 Author: Brad King AuthorDate: Mon Sep 9 13:50:12 2019 -0400 Commit: Brad King CommitDate: Mon Sep 9 13:51:23 2019 -0400 cmGeneratedFileStreamBase: Optimize string construction in Close Use cmStrCat to concatenate two parts of a file name. This also avoids a bugprone-exception-escape diagnostic from clang-tidy-8 on macOS. diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index 7475e9f..491d96f 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -4,6 +4,7 @@ #include +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #if !defined(CMAKE_BOOTSTRAP) @@ -149,7 +150,7 @@ bool cmGeneratedFileStreamBase::Close() // The destination is to be replaced. Rename the temporary to the // destination atomically. if (this->Compress) { - std::string gzname = this->TempName + ".temp.gz"; + std::string gzname = cmStrCat(this->TempName, ".temp.gz"); if (this->CompressFile(this->TempName, gzname)) { this->RenameFile(gzname, resname); } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d63c1e4e6e8507cb1c8425d521cf61fa4adbf4a8 commit d63c1e4e6e8507cb1c8425d521cf61fa4adbf4a8 Author: Regina Pfeifer AuthorDate: Fri Sep 6 22:27:39 2019 +0200 Commit: Regina Pfeifer CommitDate: Fri Sep 6 22:27:39 2019 +0200 clang-tidy: modernize-return-braced-init-list diff --git a/.clang-tidy b/.clang-tidy index cfca64e..2d17145 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -15,7 +15,6 @@ misc-*,\ modernize-*,\ -modernize-avoid-c-arrays,\ -modernize-deprecated-headers,\ --modernize-return-braced-init-list,\ -modernize-use-auto,\ -modernize-use-nodiscard,\ -modernize-use-noexcept,\ diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index cf28cdb..4c8c224 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -498,7 +498,7 @@ cmCacheManager::CacheEntry* cmCacheManager::GetCacheEntry( cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator(const char* key) { - return CacheIterator(*this, key); + return { *this, key }; } const std::string* cmCacheManager::GetInitializedCacheValue( diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index a988bd8..faa60c5 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -94,7 +94,7 @@ public: }; //! return an iterator to iterate through the cache map - cmCacheManager::CacheIterator NewIterator() { return CacheIterator(*this); } + cmCacheManager::CacheIterator NewIterator() { return { *this }; } //! Load a cache for given makefile. Loads from path/CMakeCache.txt. bool LoadCache(const std::string& path, bool internal, diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 9f0396b..e9d2412 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -311,7 +311,7 @@ cmExportBuildFileGenerator::FindBuildExportInfo(cmGlobalGenerator* gg, } } - return std::make_pair(exportFiles, ns); + return { exportFiles, ns }; } void cmExportBuildFileGenerator::ComplainAboutMissingTarget( diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index e7f301e..4e3db09 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -496,7 +496,7 @@ cmExportInstallFileGenerator::FindNamespaces(cmGlobalGenerator* gg, } } - return std::make_pair(exportFiles, ns); + return { exportFiles, ns }; } void cmExportInstallFileGenerator::ComplainAboutMissingTarget( diff --git a/Source/cmFileLockResult.cxx b/Source/cmFileLockResult.cxx index 9ca5d8a..c4779f0 100644 --- a/Source/cmFileLockResult.cxx +++ b/Source/cmFileLockResult.cxx @@ -8,7 +8,7 @@ #define WINMSG_BUF_LEN (1024) cmFileLockResult cmFileLockResult::MakeOk() { - return cmFileLockResult(OK, 0); + return { OK, 0 }; } cmFileLockResult cmFileLockResult::MakeSystem() @@ -18,27 +18,27 @@ cmFileLockResult cmFileLockResult::MakeSystem() #else const Error lastError = errno; #endif - return cmFileLockResult(SYSTEM, lastError); + return { SYSTEM, lastError }; } cmFileLockResult cmFileLockResult::MakeTimeout() { - return cmFileLockResult(TIMEOUT, 0); + return { TIMEOUT, 0 }; } cmFileLockResult cmFileLockResult::MakeAlreadyLocked() { - return cmFileLockResult(ALREADY_LOCKED, 0); + return { ALREADY_LOCKED, 0 }; } cmFileLockResult cmFileLockResult::MakeInternal() { - return cmFileLockResult(INTERNAL, 0); + return { INTERNAL, 0 }; } cmFileLockResult cmFileLockResult::MakeNoFunction() { - return cmFileLockResult(NO_FUNCTION, 0); + return { NO_FUNCTION, 0 }; } bool cmFileLockResult::IsOk() const diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index b4706a3..fc7589e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4778,21 +4778,21 @@ template <> std::pair consistentProperty(bool lhs, bool rhs, CompatibleType /*unused*/) { - return std::make_pair(lhs == rhs, lhs); + return { lhs == rhs, lhs }; } std::pair consistentStringProperty(const char* lhs, const char* rhs) { const bool b = strcmp(lhs, rhs) == 0; - return std::make_pair(b, b ? lhs : nullptr); + return { b, b ? lhs : nullptr }; } std::pair consistentStringProperty(const std::string& lhs, const std::string& rhs) { const bool b = lhs == rhs; - return std::make_pair(b, b ? lhs : valueAsString(nullptr)); + return { b, b ? lhs : valueAsString(nullptr) }; } std::pair consistentNumberProperty(const char* lhs, @@ -4801,22 +4801,21 @@ std::pair consistentNumberProperty(const char* lhs, { char* pEnd; - const char* const null_ptr = nullptr; - long lnum = strtol(lhs, &pEnd, 0); if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) { - return std::pair(false, null_ptr); + return { false, nullptr }; } long rnum = strtol(rhs, &pEnd, 0); if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) { - return std::pair(false, null_ptr); + return { false, nullptr }; } if (t == NumberMaxType) { - return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); + return { true, std::max(lnum, rnum) == lnum ? lhs : rhs }; } - return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs); + + return { true, std::min(lnum, rnum) == lnum ? lhs : rhs }; } template <> @@ -4825,21 +4824,19 @@ std::pair consistentProperty(const char* lhs, CompatibleType t) { if (!lhs && !rhs) { - return std::make_pair(true, lhs); + return { true, lhs }; } if (!lhs) { - return std::make_pair(true, rhs); + return { true, rhs }; } if (!rhs) { - return std::make_pair(true, lhs); + return { true, lhs }; } - const char* const null_ptr = nullptr; - switch (t) { case BoolType: { bool same = cmIsOn(lhs) == cmIsOn(rhs); - return std::make_pair(same, same ? lhs : nullptr); + return { same, same ? lhs : nullptr }; } case StringType: return consistentStringProperty(lhs, rhs); @@ -4848,7 +4845,7 @@ std::pair consistentProperty(const char* lhs, return consistentNumberProperty(lhs, rhs, t); } assert(false && "Unreachable!"); - return std::pair(false, null_ptr); + return { false, nullptr }; } std::pair consistentProperty(const std::string& lhs, @@ -4858,31 +4855,31 @@ std::pair consistentProperty(const std::string& lhs, const std::string null_ptr = valueAsString(nullptr); if (lhs == null_ptr && rhs == null_ptr) { - return std::make_pair(true, lhs); + return { true, lhs }; } if (lhs == null_ptr) { - return std::make_pair(true, rhs); + return { true, rhs }; } if (rhs == null_ptr) { - return std::make_pair(true, lhs); + return { true, lhs }; } switch (t) { case BoolType: { bool same = cmIsOn(lhs) == cmIsOn(rhs); - return std::make_pair(same, same ? lhs : null_ptr); + return { same, same ? lhs : null_ptr }; } case StringType: return consistentStringProperty(lhs, rhs); case NumberMinType: case NumberMaxType: { auto value = consistentNumberProperty(lhs.c_str(), rhs.c_str(), t); - return std::make_pair( - value.first, value.first ? std::string(value.second) : null_ptr); + return { value.first, + value.first ? std::string(value.second) : null_ptr }; } } assert(false && "Unreachable!"); - return std::pair(false, null_ptr); + return { false, null_ptr }; } template diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index f6d5998..7aa231e 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -228,7 +228,7 @@ public: return this->GG->ConvertToNinjaPath(path); } }; - MapToNinjaPathImpl MapToNinjaPath() { return MapToNinjaPathImpl(this); } + MapToNinjaPathImpl MapToNinjaPath() { return { this }; } // -- Additional clean files void AddAdditionalCleanFile(std::string fileName); diff --git a/Source/cmScriptGenerator.h b/Source/cmScriptGenerator.h index eee331f..c8bb1ab 100644 --- a/Source/cmScriptGenerator.h +++ b/Source/cmScriptGenerator.h @@ -25,7 +25,7 @@ public: } cmScriptGeneratorIndent Next(int step = 2) const { - return cmScriptGeneratorIndent(this->Level + step); + return { this->Level + step }; } private: diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index 670161d..d576f36 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -167,7 +167,7 @@ bool cmServerProtocol::DoActivate(const cmServerRequest& /*request*/, std::pair cmServerProtocol1::ProtocolVersion() const { - return std::make_pair(1, 2); + return { 1, 2 }; } static void setErrorMessage(std::string* errorMessage, const std::string& text) diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 902287c..92d17ab 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -324,7 +324,7 @@ cmStateSnapshot cmState::Reset() this->DefineProperty("RULE_LAUNCH_LINK", cmProperty::TARGET, "", "", true); this->DefineProperty("RULE_LAUNCH_CUSTOM", cmProperty::TARGET, "", "", true); - return cmStateSnapshot(this, pos); + return { this, pos }; } void cmState::DefineProperty(const std::string& name, @@ -789,7 +789,7 @@ cmStateSnapshot cmState::CreateBaseSnapshot() assert(pos->Vars.IsValid()); pos->Parent = this->VarTree.Root(); pos->Root = this->VarTree.Root(); - return cmStateSnapshot(this, pos); + return { this, pos }; } cmStateSnapshot cmState::CreateBuildsystemDirectorySnapshot( @@ -842,7 +842,7 @@ cmStateSnapshot cmState::CreateFunctionCallSnapshot( cmLinkedTree::iterator origin = originSnapshot.Position->Vars; pos->Parent = origin; pos->Vars = this->VarTree.Push(origin); - return cmStateSnapshot(this, pos); + return { this, pos }; } cmStateSnapshot cmState::CreateMacroCallSnapshot( @@ -857,7 +857,7 @@ cmStateSnapshot cmState::CreateMacroCallSnapshot( assert(originSnapshot.Position->Vars.IsValid()); pos->BuildSystemDirectory->DirectoryEnd = pos; pos->PolicyScope = originSnapshot.Position->Policies; - return cmStateSnapshot(this, pos); + return { this, pos }; } cmStateSnapshot cmState::CreateIncludeFileSnapshot( @@ -872,7 +872,7 @@ cmStateSnapshot cmState::CreateIncludeFileSnapshot( assert(originSnapshot.Position->Vars.IsValid()); pos->BuildSystemDirectory->DirectoryEnd = pos; pos->PolicyScope = originSnapshot.Position->Policies; - return cmStateSnapshot(this, pos); + return { this, pos }; } cmStateSnapshot cmState::CreateVariableScopeSnapshot( @@ -890,7 +890,7 @@ cmStateSnapshot cmState::CreateVariableScopeSnapshot( pos->Parent = origin; pos->Vars = this->VarTree.Push(origin); assert(pos->Vars.IsValid()); - return cmStateSnapshot(this, pos); + return { this, pos }; } cmStateSnapshot cmState::CreateInlineListFileSnapshot( @@ -904,7 +904,7 @@ cmStateSnapshot cmState::CreateInlineListFileSnapshot( originSnapshot.Position->ExecutionListFile, fileName); pos->BuildSystemDirectory->DirectoryEnd = pos; pos->PolicyScope = originSnapshot.Position->Policies; - return cmStateSnapshot(this, pos); + return { this, pos }; } cmStateSnapshot cmState::CreatePolicyScopeSnapshot( @@ -916,7 +916,7 @@ cmStateSnapshot cmState::CreatePolicyScopeSnapshot( pos->Keep = false; pos->BuildSystemDirectory->DirectoryEnd = pos; pos->PolicyScope = originSnapshot.Position->Policies; - return cmStateSnapshot(this, pos); + return { this, pos }; } cmStateSnapshot cmState::Pop(cmStateSnapshot const& originSnapshot) @@ -948,7 +948,7 @@ cmStateSnapshot cmState::Pop(cmStateSnapshot const& originSnapshot) this->SnapshotData.Pop(pos); } - return cmStateSnapshot(this, prevPos); + return { this, prevPos }; } static bool ParseEntryWithoutType(const std::string& entry, std::string& var, diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx index 121923d..3c54f52 100644 --- a/Source/cmStateSnapshot.cxx +++ b/Source/cmStateSnapshot.cxx @@ -66,8 +66,7 @@ bool cmStateSnapshot::IsValid() const cmStateSnapshot cmStateSnapshot::GetBuildsystemDirectory() const { - return cmStateSnapshot(this->State, - this->Position->BuildSystemDirectory->DirectoryEnd); + return { this->State, this->Position->BuildSystemDirectory->DirectoryEnd }; } cmStateSnapshot cmStateSnapshot::GetBuildsystemDirectoryParent() const @@ -126,7 +125,7 @@ cmStateSnapshot cmStateSnapshot::GetCallStackBottom() const pos != this->State->SnapshotData.Root()) { ++pos; } - return cmStateSnapshot(this->State, pos); + return { this->State, pos }; } void cmStateSnapshot::PushPolicy(cmPolicies::PolicyMap const& entry, bool weak) @@ -426,7 +425,7 @@ cmState* cmStateSnapshot::GetState() const cmStateDirectory cmStateSnapshot::GetDirectory() const { - return cmStateDirectory(this->Position->BuildSystemDirectory, *this); + return { this->Position->BuildSystemDirectory, *this }; } void cmStateSnapshot::SetProjectName(const std::string& name) diff --git a/Source/cmXMLWriter.h b/Source/cmXMLWriter.h index a5b06af..c4103cc 100644 --- a/Source/cmXMLWriter.h +++ b/Source/cmXMLWriter.h @@ -77,14 +77,11 @@ private: void CloseStartElement(); private: - static cmXMLSafe SafeAttribute(const char* value) - { - return cmXMLSafe(value); - } + static cmXMLSafe SafeAttribute(const char* value) { return { value }; } static cmXMLSafe SafeAttribute(std::string const& value) { - return cmXMLSafe(value); + return { value }; } template diff --git a/Source/cmake.cxx b/Source/cmake.cxx index ace9198..e7c714e 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1081,20 +1081,18 @@ createExtraGenerator( const std::vector generators = i->GetSupportedGlobalGenerators(); if (i->GetName() == name) { // Match aliases - return std::make_pair(i->CreateExternalMakefileProjectGenerator(), - generators.at(0)); + return { i->CreateExternalMakefileProjectGenerator(), generators.at(0) }; } for (std::string const& g : generators) { const std::string fullName = cmExternalMakefileProjectGenerator::CreateFullGeneratorName( g, i->GetName()); if (fullName == name) { - return std::make_pair(i->CreateExternalMakefileProjectGenerator(), g); + return { i->CreateExternalMakefileProjectGenerator(), g }; } } } - return std::make_pair( - static_cast(nullptr), name); + return { nullptr, name }; } cmGlobalGenerator* cmake::CreateGlobalGenerator(const std::string& gname) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2528b70293724b401bc1927f90f2ef91a3f3d499 commit 2528b70293724b401bc1927f90f2ef91a3f3d499 Author: Regina Pfeifer AuthorDate: Thu Sep 5 17:58:58 2019 +0200 Commit: Regina Pfeifer CommitDate: Fri Sep 6 21:24:18 2019 +0200 clang-tidy: Remove old entries from blacklist Now that clang-tidy-8 is used, we can remove the checks that have been renamed. Also enable a return-braced-init-list, because we don't have any violations for that one. diff --git a/.clang-tidy b/.clang-tidy index cfca64e..32ee0a9 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -7,9 +7,6 @@ bugprone-*,\ -bugprone-too-small-loop-variable,\ google-readability-casting,\ misc-*,\ --misc-incorrect-roundings,\ --misc-macro-parentheses,\ --misc-misplaced-widening-cast,\ -misc-non-private-member-variables-in-classes,\ -misc-static-assert,\ modernize-*,\ @@ -24,7 +21,6 @@ performance-*,\ readability-*,\ -readability-function-size,\ -readability-identifier-naming,\ --readability-implicit-bool-cast,\ -readability-implicit-bool-conversion,\ -readability-inconsistent-declaration-parameter-name,\ -readability-magic-numbers,\ ----------------------------------------------------------------------- Summary of changes: .clang-tidy | 5 ---- Source/cmCacheManager.cxx | 2 +- Source/cmCacheManager.h | 2 +- Source/cmExportBuildFileGenerator.cxx | 2 +- Source/cmExportInstallFileGenerator.cxx | 2 +- Source/cmFileLockResult.cxx | 12 ++++---- Source/cmGeneratedFileStream.cxx | 3 +- Source/cmGeneratorTarget.cxx | 43 ++++++++++++++--------------- Source/cmGlobalNinjaGenerator.h | 2 +- Source/cmGlobalXCodeGenerator.cxx | 6 ++-- Source/cmGlobalXCodeGenerator.h | 12 ++++---- Source/cmListFileCache.cxx | 1 + Source/cmScriptGenerator.h | 2 +- Source/cmServerProtocol.cxx | 2 +- Source/cmState.cxx | 18 ++++++------ Source/cmStateSnapshot.cxx | 7 ++--- Source/cmVariableWatchCommand.cxx | 1 + Source/cmXMLWriter.h | 7 ++--- Source/cmake.cxx | 8 ++---- Tests/CMakeLib/testUVProcessChainHelper.cxx | 3 +- 20 files changed, 64 insertions(+), 76 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Sep 10 10:58:27 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 10 Sep 2019 10:58:27 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-988-gbbf48c4 Message-ID: <20190910145827.6E7FBF9F73@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via bbf48c494ad28d1c8ac5aa6e4cecb35c2cbf1b84 (commit) via ff5028c5318c5d404390d8114d9453fc81fa9a33 (commit) from 05d5c66ff853f88e6dbe43bbddd18dd8babaa427 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bbf48c494ad28d1c8ac5aa6e4cecb35c2cbf1b84 commit bbf48c494ad28d1c8ac5aa6e4cecb35c2cbf1b84 Merge: 05d5c66 ff5028c Author: Brad King AuthorDate: Tue Sep 10 14:54:39 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 10 10:54:55 2019 -0400 Merge topic 'windows-auto-export-incremental-build' ff5028c531 Windows: Prevent auto exports to be regenerated on every build Acked-by: Kitware Robot Merge-request: !3750 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ff5028c5318c5d404390d8114d9453fc81fa9a33 commit ff5028c5318c5d404390d8114d9453fc81fa9a33 Author: Daniel Eiband AuthorDate: Wed Aug 28 13:57:52 2019 +0200 Commit: Daniel Eiband CommitDate: Mon Sep 9 15:43:15 2019 +0200 Windows: Prevent auto exports to be regenerated on every build Check modified time stamps of input files against an existing exports file before generating the auto exports. Fixes: #19650 diff --git a/Help/release/dev/windows-auto-export-incremental-build.rst b/Help/release/dev/windows-auto-export-incremental-build.rst new file mode 100644 index 0000000..3126329 --- /dev/null +++ b/Help/release/dev/windows-auto-export-incremental-build.rst @@ -0,0 +1,6 @@ +windows-auto-export-incremental-build +------------------------------------- + +* On Windows, existing auto generated exports are now only updated if the + modified time stamp of the exports is not newer than any modified time stamp + of the input files. diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index a79a2ff..e6dd99a 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -562,19 +562,36 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args) "objlistfile [-nm=nm-path]\n"; return 1; } - FILE* fout = cmsys::SystemTools::Fopen(args[2].c_str(), "w+"); - if (!fout) { - std::cerr << "could not open output .def file: " << args[2].c_str() - << "\n"; - return 1; - } cmsys::ifstream fin(args[3].c_str(), std::ios::in | std::ios::binary); if (!fin) { std::cerr << "could not open object list file: " << args[3].c_str() << "\n"; return 1; } - std::string file; + std::vector files; + { + std::string file; + cmFileTime outTime; + bool outValid = outTime.Load(args[2]); + while (cmSystemTools::GetLineFromStream(fin, file)) { + files.push_back(file); + if (outValid) { + cmFileTime inTime; + outValid = inTime.Load(file) && inTime.Older(outTime); + } + } + if (outValid) { + // The def file already exists and all input files are older than the + // existing def file. + return 0; + } + } + FILE* fout = cmsys::SystemTools::Fopen(args[2].c_str(), "w+"); + if (!fout) { + std::cerr << "could not open output .def file: " << args[2].c_str() + << "\n"; + return 1; + } bindexplib deffile; if (args.size() >= 5) { auto a = args[4]; @@ -585,7 +602,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args) std::cerr << "unknown argument: " << a << "\n"; } } - while (cmSystemTools::GetLineFromStream(fin, file)) { + for (auto const& file : files) { std::string const& ext = cmSystemTools::GetFilenameLastExtension(file); if (cmSystemTools::LowerCase(ext) == ".def") { if (!deffile.AddDefinitionFile(file.c_str())) { diff --git a/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake index 27a609d..6c9be4b 100644 --- a/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake +++ b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake @@ -7,9 +7,13 @@ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") run_cmake(AutoExport) unset(RunCMake_TEST_OPTIONS) # don't run this test on Watcom or Borland make as it is not supported -if("${RunCMake_GENERATOR}" MATCHES "Watcom WMake|Borland Makefiles") +if(RunCMake_GENERATOR MATCHES "Watcom WMake|Borland Makefiles") return() endif() +if(RunCMake_GENERATOR MATCHES "Ninja|Visual Studio" AND + CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(EXPORTS TRUE) +endif() # we build debug so the say.exe will be found in Debug/say.exe for # Visual Studio generators if(RunCMake_GENERATOR_IS_MULTI_CONFIG) @@ -18,9 +22,36 @@ endif() # build AutoExport run_cmake_command(AutoExportBuild ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR} --config Debug --clean-first) +# save the current timestamp of exports.def +if(EXPORTS) + set(EXPORTS_DEF "${RunCMake_TEST_BINARY_DIR}/say.dir/${INTDIR}exports.def") + if(NOT EXISTS "${EXPORTS_DEF}") + set(EXPORTS_DEF + "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/say.dir/${INTDIR}exports.def") + endif() + file(TIMESTAMP "${EXPORTS_DEF}" timestamp) + if(NOT timestamp) + message(SEND_ERROR "Could not get timestamp for \"${EXPORTS_DEF}\"") + endif() +endif() # run the executable that uses symbols from the dll if(WIN32) set(EXE_EXT ".exe") endif() run_cmake_command(AutoExportRun - ${RunCMake_BINARY_DIR}/AutoExport-build/bin/${INTDIR}say${EXE_EXT}) + ${RunCMake_TEST_BINARY_DIR}/bin/${INTDIR}say${EXE_EXT}) +# build AutoExport again without modification +run_cmake_command(AutoExportBuildAgain ${CMAKE_COMMAND} --build + ${RunCMake_TEST_BINARY_DIR} --config Debug) +# compare timestamps of exports.def to make sure it has not been updated +if(EXPORTS) + file(TIMESTAMP "${EXPORTS_DEF}" timestamp_after) + if(NOT timestamp_after) + message(SEND_ERROR "Could not get timestamp for \"${EXPORTS_DEF}\"") + endif() + if (timestamp_after STREQUAL timestamp) + message(STATUS "AutoExportTimeStamp - PASSED") + else() + message(SEND_ERROR "\"${EXPORTS_DEF}\" has been updated.") + endif() +endif() diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 8fd5234..c663484 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -543,7 +543,7 @@ set(cpack_tests add_RunCMake_test_group(CPack "${cpack_tests}") # add a test to make sure symbols are exported from a shared library # for MSVC compilers CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS property is used -add_RunCMake_test(AutoExportDll) +add_RunCMake_test(AutoExportDll -DCMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID}) add_RunCMake_test(AndroidMK) ----------------------------------------------------------------------- Summary of changes: .../dev/windows-auto-export-incremental-build.rst | 6 ++++ Source/cmcmd.cxx | 33 +++++++++++++++----- Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake | 35 ++++++++++++++++++++-- Tests/RunCMake/CMakeLists.txt | 2 +- 4 files changed, 65 insertions(+), 11 deletions(-) create mode 100644 Help/release/dev/windows-auto-export-incremental-build.rst hooks/post-receive -- CMake From kwrobot at kitware.com Tue Sep 10 11:09:07 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 10 Sep 2019 11:09:07 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-993-g95d4a2d Message-ID: <20190910150907.2ECCC17B9@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 95d4a2d05562c5f0a4113527d31dadef4d7756bd (commit) via 054d626c9cca0facb372ba740b8a797d463141a3 (commit) via 5b96fd5b81bde4655e471a31bf0fc579c1d10136 (commit) via 5eaf1e1be289245267263536f5464e40d2a677c0 (commit) via 75692393628d757a3dadb090179e167cd9539e2f (commit) from bbf48c494ad28d1c8ac5aa6e4cecb35c2cbf1b84 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=95d4a2d05562c5f0a4113527d31dadef4d7756bd commit 95d4a2d05562c5f0a4113527d31dadef4d7756bd Merge: 054d626 7569239 Author: Brad King AuthorDate: Tue Sep 10 14:59:21 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 10 10:59:39 2019 -0400 Merge topic 'move-setting-GENERATE-upfront' 7569239362 cmMakefile: set GENERATED property of outputs upfront Acked-by: Kitware Robot Merge-request: !3789 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=054d626c9cca0facb372ba740b8a797d463141a3 commit 054d626c9cca0facb372ba740b8a797d463141a3 Merge: bbf48c4 5b96fd5 Author: Brad King AuthorDate: Tue Sep 10 14:58:45 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 10 10:58:53 2019 -0400 Merge topic 'MoveIfDifferent' 5b96fd5b81 use cmSystemTools::MoveFileIfDifferent() 5eaf1e1be2 cmSystemTools: introduce MoveFileIfDifferent() Acked-by: Kitware Robot Merge-request: !3794 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5b96fd5b81bde4655e471a31bf0fc579c1d10136 commit 5b96fd5b81bde4655e471a31bf0fc579c1d10136 Author: Rolf Eike Beer AuthorDate: Mon Sep 9 10:34:08 2019 +0200 Commit: Rolf Eike Beer CommitDate: Mon Sep 9 10:34:08 2019 +0200 use cmSystemTools::MoveFileIfDifferent() This is better than doing CopyFileIfDifferent() followed by RemoveFile() in two ways: - it is more efficient, as it avoids disk I/O for the data, even if the files here are usually small - it is atomic, so an abort during the copy will not leave a destination file with partial data behind diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index b4706a3..f1c48cc 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3417,8 +3417,7 @@ std::string cmGeneratorTarget::GetPchHeader(const std::string& config, file << pchEpilogue << "\n"; } } - cmSystemTools::CopyFileIfDifferent(filename_tmp, filename); - cmSystemTools::RemoveFile(filename_tmp); + cmSystemTools::MoveFileIfDifferent(filename_tmp, filename); } return inserted.first->second; } @@ -3451,8 +3450,7 @@ std::string cmGeneratorTarget::GetPchSource(const std::string& config, cmGeneratedFileStream file(filename_tmp); file << "/* generated by CMake */\n"; } - cmSystemTools::CopyFileIfDifferent(filename_tmp, filename); - cmSystemTools::RemoveFile(filename_tmp); + cmSystemTools::MoveFileIfDifferent(filename_tmp, filename); } return inserted.first->second; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 9152e94..3d8c3fb 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2275,8 +2275,7 @@ void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target, } } } - cmSystemTools::CopyFileIfDifferent(filename_tmp, filename); - cmSystemTools::RemoveFile(filename_tmp); + cmSystemTools::MoveFileIfDifferent(filename_tmp, filename); target->AddSource(filename, true); diff --git a/Source/cmUseMangledMesaCommand.cxx b/Source/cmUseMangledMesaCommand.cxx index cfc00e8..1fd386b 100644 --- a/Source/cmUseMangledMesaCommand.cxx +++ b/Source/cmUseMangledMesaCommand.cxx @@ -98,7 +98,6 @@ void CopyAndFullPathMesaHeader(const std::string& source, // close the files before attempting to copy fin.close(); fout.close(); - cmSystemTools::CopyFileIfDifferent(tempOutputFile, outFile); - cmSystemTools::RemoveFile(tempOutputFile); + cmSystemTools::MoveFileIfDifferent(tempOutputFile, outFile); } } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5eaf1e1be289245267263536f5464e40d2a677c0 commit 5eaf1e1be289245267263536f5464e40d2a677c0 Author: Rolf Eike Beer AuthorDate: Mon Sep 9 09:09:48 2019 +0200 Commit: Rolf Eike Beer CommitDate: Mon Sep 9 10:30:25 2019 +0200 cmSystemTools: introduce MoveFileIfDifferent() diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index b7287d9..074faa5 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -855,6 +855,18 @@ bool cmSystemTools::RenameFile(const std::string& oldname, #endif } +void cmSystemTools::MoveFileIfDifferent(const std::string& source, + const std::string& destination) +{ + if (FilesDiffer(source, destination)) { + if (RenameFile(source, destination)) { + return; + } + CopyFileAlways(source, destination); + } + RemoveFile(source); +} + std::string cmSystemTools::ComputeFileHash(const std::string& source, cmCryptoHash::Algo algo) { diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 863db3f..8ca4939 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -131,6 +131,10 @@ public: static bool RenameFile(const std::string& oldname, const std::string& newname); + //! Rename a file if contents are different, delete the source otherwise + static void MoveFileIfDifferent(const std::string& source, + const std::string& destination); + //! Compute the hash of a file static std::string ComputeFileHash(const std::string& source, cmCryptoHash::Algo algo); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=75692393628d757a3dadb090179e167cd9539e2f commit 75692393628d757a3dadb090179e167cd9539e2f Author: Daniel Eiband AuthorDate: Fri Sep 6 19:17:37 2019 +0200 Commit: Daniel Eiband CommitDate: Fri Sep 6 22:22:22 2019 +0200 cmMakefile: set GENERATED property of outputs upfront Setting the GENERATED property of outputs upfront is a precondition for delayed custom command creation (generator expressions in outputs). Issue: 12877 diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 411add3..d729451 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -860,7 +860,7 @@ void cmMakefile::AddCustomCommandToTarget( e << "No TARGET '" << target << "' has been created in this directory."; } - IssueMessage(messageType, e.str()); + this->IssueMessage(messageType, e.str()); } return; @@ -886,11 +886,7 @@ void cmMakefile::AddCustomCommandToTarget( } // Always create the byproduct sources and mark them generated. - for (std::string const& o : byproducts) { - if (cmSourceFile* out = this->GetOrCreateSource(o, true)) { - out->SetProperty("GENERATED", "1"); - } - } + this->CreateGeneratedSources(byproducts); // Add the command to the appropriate build step for the target. std::vector no_output; @@ -940,6 +936,10 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput( } } + // Always create the output sources and mark them generated. + this->CreateGeneratedSources(outputs, cmSourceFileLocationKind::Known); + this->CreateGeneratedSources(byproducts, cmSourceFileLocationKind::Known); + // Choose a source file on which to store the custom command. cmSourceFile* file = nullptr; if (!commandLines.empty() && !main_dependency.empty()) { @@ -987,20 +987,6 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput( file->SetProperty("__CMAKE_RULE", "1"); } - // Always create the output sources and mark them generated. - for (std::string const& o : outputs) { - if (cmSourceFile* out = - this->GetOrCreateSource(o, true, cmSourceFileLocationKind::Known)) { - out->SetProperty("GENERATED", "1"); - } - } - for (std::string const& o : byproducts) { - if (cmSourceFile* out = - this->GetOrCreateSource(o, true, cmSourceFileLocationKind::Known)) { - out->SetProperty("GENERATED", "1"); - } - } - // Attach the custom command to the file. if (file) { // Construct a complete list of dependencies. @@ -1180,6 +1166,7 @@ cmTarget* cmMakefile::AddUtilityCommand( if (excludeFromAll || this->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } + if (!comment) { // Use an empty comment to avoid generation of default comment. comment = ""; @@ -1187,6 +1174,9 @@ cmTarget* cmMakefile::AddUtilityCommand( // Store the custom command in the target. if (!commandLines.empty() || !depends.empty()) { + // Always create the byproduct sources and mark them generated. + this->CreateGeneratedSources(byproducts, cmSourceFileLocationKind::Known); + std::string force = cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles/", utilityName); std::vector forced; @@ -1205,14 +1195,6 @@ cmTarget* cmMakefile::AddUtilityCommand( } else { cmSystemTools::Error("Could not get source file entry for " + force); } - - // Always create the byproduct sources and mark them generated. - for (std::string const& byproduct : byproducts) { - if (cmSourceFile* out = this->GetOrCreateSource( - byproduct, true, cmSourceFileLocationKind::Known)) { - out->SetProperty("GENERATED", "1"); - } - } } return target; } @@ -3325,6 +3307,16 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName, return this->CreateSource(sourceName, generated, kind); } +void cmMakefile::CreateGeneratedSources( + const std::vector& outputs, cmSourceFileLocationKind kind) +{ + for (std::string const& output : outputs) { + if (cmSourceFile* out = this->GetOrCreateSource(output, true, kind)) { + out->SetProperty("GENERATED", "1"); + } + } +} + void cmMakefile::AddTargetObject(std::string const& tgtName, std::string const& objFile) { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 09f53c9..52464d6 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -1030,6 +1030,11 @@ private: bool escapeQuotes, bool noEscapes, bool atOnly, const char* filename, long line, bool replaceAt) const; + + void CreateGeneratedSources( + const std::vector& outputs, + cmSourceFileLocationKind kind = cmSourceFileLocationKind::Ambiguous); + /** * Old version of GetSourceFileWithOutput(const std::string&) kept for * backward-compatibility. It implements a linear search and support ----------------------------------------------------------------------- Summary of changes: Source/cmGeneratorTarget.cxx | 6 ++--- Source/cmLocalGenerator.cxx | 3 +-- Source/cmMakefile.cxx | 48 ++++++++++++++++---------------------- Source/cmMakefile.h | 5 ++++ Source/cmSystemTools.cxx | 12 ++++++++++ Source/cmSystemTools.h | 4 ++++ Source/cmUseMangledMesaCommand.cxx | 3 +-- 7 files changed, 45 insertions(+), 36 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Sep 10 23:58:12 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 10 Sep 2019 23:58:12 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-994-g7f46e4a Message-ID: <20190911035812.74621FA6B4@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 7f46e4a73a4d7aaa4029a04c532d2c99635383b9 (commit) from 95d4a2d05562c5f0a4113527d31dadef4d7756bd (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7f46e4a73a4d7aaa4029a04c532d2c99635383b9 commit 7f46e4a73a4d7aaa4029a04c532d2c99635383b9 Author: Kitware Robot AuthorDate: Wed Sep 11 00:01:05 2019 -0400 Commit: Kitware Robot CommitDate: Wed Sep 11 00:01:05 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 45dd11e..0d48a72 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 15) -set(CMake_VERSION_PATCH 20190910) +set(CMake_VERSION_PATCH 20190911) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Wed Sep 11 11:43:07 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 11 Sep 2019 11:43:07 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1007-gb5b10c8 Message-ID: <20190911154307.8DB1E2222@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via b5b10c8e955abb2b0f18c3e41b7892471857bcc1 (commit) via 46629d6a49d8a12378778b39bc8827ae2808f3dd (commit) via 30006e199bb6ac3649332b26c94ccf864e1416b1 (commit) via 291c83f063d310f700e3e1afa756dcdf968d0f09 (commit) via 8e973b8e8d6542b5dd15173884bde68a9a390949 (commit) via 4d5bbb7704a44e56f43585b3f811f37c5200bdd0 (commit) via 1f6a436bf4188007b87d2582367cde8f970d5e1f (commit) via 5355a60fd02417a004c6b4b6b8848ce0ff1ea9fa (commit) via cd7d7362782c2a582bcfd8a86a5523cf20ee6afb (commit) via a20d2c85d02842a23ef1105daa078a821172cb4e (commit) via b13207910e848d3c980e4b3dc176e113a3c04bbc (commit) via ca7b90dcf2fc6ef5345de162ec2532454376fe2f (commit) via eac8700c7853d88f0682492ccefc70b4246ccf4a (commit) from 7f46e4a73a4d7aaa4029a04c532d2c99635383b9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b5b10c8e955abb2b0f18c3e41b7892471857bcc1 commit b5b10c8e955abb2b0f18c3e41b7892471857bcc1 Merge: 46629d6 cd7d736 Author: Brad King AuthorDate: Wed Sep 11 15:39:43 2019 +0000 Commit: Kitware Robot CommitDate: Wed Sep 11 11:40:11 2019 -0400 Merge topic 'ctest-no-cmcommand' cd7d736278 cmCTestTestHandler: Port away from cmCommand Acked-by: Kitware Robot Merge-request: !3795 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=46629d6a49d8a12378778b39bc8827ae2808f3dd commit 46629d6a49d8a12378778b39bc8827ae2808f3dd Merge: 7f46e4a 30006e1 Author: Brad King AuthorDate: Wed Sep 11 15:38:40 2019 +0000 Commit: Kitware Robot CommitDate: Wed Sep 11 11:38:58 2019 -0400 Merge topic 'fileapiAddMoreBacktraces' 30006e199b fileapi: add backtraces for compile/link options 291c83f063 cmLocalGenerator: Add GetTargetCompileFlags overload with backtraces 8e973b8e8d cmLocalGenerator: Add GetTargetFlags overload with backtraces 4d5bbb7704 cmLocalGenerator: Add GetStaticLibraryFlags overload with backtraces 1f6a436bf4 cmLocalGenerator: Add AddCompileOptions overload with backtraces 5355a60fd0 cmLocalGenerator: Add AppendCompileOptions overload with backtraces a20d2c85d0 cmLocalGenerator: Add AppendFlags overload with backtraces b13207910e cmLocalGenerator: Clarify AddCompileOptions filter logic ... Acked-by: Kitware Robot Merge-request: !3775 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=30006e199bb6ac3649332b26c94ccf864e1416b1 commit 30006e199bb6ac3649332b26c94ccf864e1416b1 Author: Justin Goshi AuthorDate: Tue Sep 3 10:25:44 2019 -0700 Commit: Brad King CommitDate: Tue Sep 10 10:45:41 2019 -0400 fileapi: add backtraces for compile/link options diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 3ac769c..805da81 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -802,9 +802,13 @@ void Target::ProcessLanguage(std::string const& lang) { // FIXME: Add flags from end section of ExpandRuleVariable, // which may need to be factored out. - std::string flags; - lg->GetTargetCompileFlags(this->GT, this->Config, lang, flags); - cd.Flags.emplace_back(std::move(flags), JBTIndex()); + std::vector> flags = + lg->GetTargetCompileFlags(this->GT, this->Config, lang); + + cd.Flags.reserve(flags.size()); + for (const BT& f : flags) { + cd.Flags.emplace_back(this->ToJBT(f)); + } } std::set> defines = lg->GetTargetDefines(this->GT, this->Config, lang); @@ -1264,7 +1268,7 @@ Json::Value Target::DumpLinkCommandFragments() Json::Value linkFragments = Json::arrayValue; std::string linkLanguageFlags; - std::string linkFlags; + std::vector> linkFlags; std::string frameworkPath; std::string linkPath; std::string linkLibs; @@ -1275,7 +1279,6 @@ Json::Value Target::DumpLinkCommandFragments() linkLanguageFlags, linkFlags, frameworkPath, linkPath, this->GT); linkLanguageFlags = cmTrimWhitespace(linkLanguageFlags); - linkFlags = cmTrimWhitespace(linkFlags); frameworkPath = cmTrimWhitespace(frameworkPath); linkPath = cmTrimWhitespace(linkPath); linkLibs = cmTrimWhitespace(linkLibs); @@ -1286,8 +1289,11 @@ Json::Value Target::DumpLinkCommandFragments() } if (!linkFlags.empty()) { - linkFragments.append( - this->DumpCommandFragment(std::move(linkFlags), "flags")); + for (BT frag : linkFlags) { + frag.Value = cmTrimWhitespace(frag.Value); + linkFragments.append( + this->DumpCommandFragment(this->ToJBT(frag), "flags")); + } } if (!frameworkPath.empty()) { diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py index 89f63d0..2a24421 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py +++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py @@ -232,17 +232,37 @@ def check_target(c): assert is_string(obj["link"]["language"], expected["link"]["language"]) - # FIXME: Properly test commandFragments if "commandFragments" in obj["link"]: link_keys.append("commandFragments") assert is_list(obj["link"]["commandFragments"]) for f in obj["link"]["commandFragments"]: assert is_dict(f) - assert sorted(f.keys()) == ["fragment", "role"] + assert sorted(f.keys()) == ["fragment", "role"] or sorted(f.keys()) == ["backtrace", "fragment", "role"] assert is_string(f["fragment"]) assert is_string(f["role"]) assert f["role"] in ("flags", "libraries", "libraryPath", "frameworkPath") + if expected["link"]["commandFragments"] is not None: + def check_link_command_fragments(actual, expected): + assert is_dict(actual) + expected_keys = ["fragment", "role"] + + if expected["backtrace"] is not None: + expected_keys.append("backtrace") + assert actual["fragment"] == expected["fragment"] + assert actual["role"] == expected["role"] + check_backtrace(obj, actual["backtrace"], expected["backtrace"]) + + assert sorted(actual.keys()) == sorted(expected_keys) + + check_list_match(lambda a, e: is_string(a["fragment"], e["fragment"]), + obj["link"]["commandFragments"], expected["link"]["commandFragments"], + check=check_link_command_fragments, + check_exception=lambda a, e: "Link fragment: %s" % a["fragment"], + missing_exception=lambda e: "Link fragment: %s" % e["fragment"], + extra_exception=lambda a: "Link fragment: %s" % a["fragment"], + allow_extra=True) + if expected["link"]["lto"] is not None: link_keys.append("lto") assert is_bool(obj["link"]["lto"], expected["link"]["lto"]) @@ -327,15 +347,33 @@ def check_target(c): missing_exception=lambda e: "Source path: %s" % e, extra_exception=lambda a: "Source path: %s" % obj["sources"][a]["path"]) - # FIXME: Properly test compileCommandFragments if "compileCommandFragments" in actual: expected_keys.append("compileCommandFragments") assert is_list(actual["compileCommandFragments"]) for f in actual["compileCommandFragments"]: assert is_dict(f) - assert sorted(f.keys()) == ["fragment"] assert is_string(f["fragment"]) + if expected["compileCommandFragments"] is not None: + def check_compile_command_fragments(actual, expected): + assert is_dict(actual) + expected_keys = ["fragment"] + + if expected["backtrace"] is not None: + expected_keys.append("backtrace") + assert actual["fragment"] == expected["fragment"] + check_backtrace(obj, actual["backtrace"], expected["backtrace"]) + + assert sorted(actual.keys()) == sorted(expected_keys) + + check_list_match(lambda a, e: is_string(a["fragment"], e["fragment"]), + actual["compileCommandFragments"], expected["compileCommandFragments"], + check=check_compile_command_fragments, + check_exception=lambda a, e: "Compile fragment: %s" % a["fragment"], + missing_exception=lambda e: "Compile fragment: %s" % e["fragment"], + extra_exception=lambda a: "Compile fragment: %s" % a["fragment"], + allow_extra=True) + if expected["includes"] is not None: expected_keys.append("includes") @@ -931,6 +969,7 @@ def gen_check_targets(c, g, inSource): "backtrace": None, }, ], + "compileCommandFragments": None, }, ], "backtrace": [ @@ -998,6 +1037,7 @@ def gen_check_targets(c, g, inSource): "link": { "language": "C", "lto": None, + "commandFragments": None, }, "archive": None, "dependencies": [ @@ -1064,6 +1104,7 @@ def gen_check_targets(c, g, inSource): ], "includes": None, "defines": None, + "compileCommandFragments": None, }, ], "backtrace": [ @@ -1171,6 +1212,7 @@ def gen_check_targets(c, g, inSource): ], "includes": None, "defines": None, + "compileCommandFragments": None, }, ], "backtrace": [ @@ -1217,6 +1259,7 @@ def gen_check_targets(c, g, inSource): "link": { "language": "C", "lto": None, + "commandFragments": None, }, "archive": None, "dependencies": [ @@ -1317,6 +1360,7 @@ def gen_check_targets(c, g, inSource): "backtrace": None, }, ], + "compileCommandFragments": None, }, ], "backtrace": [ @@ -1367,6 +1411,7 @@ def gen_check_targets(c, g, inSource): "link": { "language": "C", "lto": True, + "commandFragments": None, }, "archive": None, "dependencies": [ @@ -1433,6 +1478,7 @@ def gen_check_targets(c, g, inSource): ], "includes": None, "defines": None, + "compileCommandFragments": None, }, ], "backtrace": [ @@ -1479,6 +1525,7 @@ def gen_check_targets(c, g, inSource): "link": { "language": "C", "lto": True, + "commandFragments": None, }, "archive": None, "dependencies": [ @@ -1574,6 +1621,7 @@ def gen_check_targets(c, g, inSource): ], "includes": None, "defines": None, + "compileCommandFragments": None, }, ], "backtrace": [ @@ -1681,6 +1729,7 @@ def gen_check_targets(c, g, inSource): ], "includes": None, "defines": None, + "compileCommandFragments": None, }, ], "backtrace": [ @@ -1727,6 +1776,7 @@ def gen_check_targets(c, g, inSource): "link": { "language": "C", "lto": None, + "commandFragments": None, }, "archive": None, "dependencies": [ @@ -1979,6 +2029,7 @@ def gen_check_targets(c, g, inSource): ], "includes": None, "defines": None, + "compileCommandFragments": None, }, ], "backtrace": [ @@ -2062,6 +2113,25 @@ def gen_check_targets(c, g, inSource): ], "includes": None, "defines": None, + "compileCommandFragments": [ + { + "fragment" : "TargetCompileOptions", + "backtrace": [ + { + "file": "^cxx/CMakeLists\\.txt$", + "line": 17, + "command": "target_compile_options", + "hasParent": True, + }, + { + "file" : "^cxx/CMakeLists\\.txt$", + "line": None, + "command": None, + "hasParent": False, + }, + ], + } + ], }, ], "backtrace": [ @@ -2129,6 +2199,26 @@ def gen_check_targets(c, g, inSource): "link": { "language": "CXX", "lto": None, + "commandFragments": [ + { + "fragment" : "TargetLinkOptions", + "role" : "flags", + "backtrace": [ + { + "file": "^cxx/CMakeLists\\.txt$", + "line": 18, + "command": "target_link_options", + "hasParent": True, + }, + { + "file" : "^cxx/CMakeLists\\.txt$", + "line": None, + "command": None, + "hasParent": False, + }, + ], + }, + ], }, "archive": None, "dependencies": [ @@ -2205,6 +2295,7 @@ def gen_check_targets(c, g, inSource): "backtrace": None, }, ], + "compileCommandFragments": None, }, ], "backtrace": [ @@ -2243,6 +2334,7 @@ def gen_check_targets(c, g, inSource): "link": { "language": "CXX", "lto": None, + "commandFragments": None, }, "archive": None, "dependencies": [ @@ -2297,6 +2389,7 @@ def gen_check_targets(c, g, inSource): ], "includes": None, "defines": None, + "compileCommandFragments": None, }, ], "backtrace": [ @@ -2331,6 +2424,7 @@ def gen_check_targets(c, g, inSource): "link": { "language": "CXX", "lto": None, + "commandFragments": None, }, "archive": None, "dependencies": [ @@ -2402,6 +2496,7 @@ def gen_check_targets(c, g, inSource): ], "includes": None, "defines": None, + "compileCommandFragments": None, }, ], "backtrace": [ @@ -2485,6 +2580,7 @@ def gen_check_targets(c, g, inSource): ], "includes": None, "defines": None, + "compileCommandFragments": None, }, ], "backtrace": [ @@ -2519,6 +2615,7 @@ def gen_check_targets(c, g, inSource): "link": { "language": "CXX", "lto": None, + "commandFragments": None, }, "archive": None, "dependencies": [ @@ -2743,6 +2840,7 @@ def gen_check_targets(c, g, inSource): ], "includes": None, "defines": None, + "compileCommandFragments": None, }, ], "backtrace": [ @@ -2777,6 +2875,7 @@ def gen_check_targets(c, g, inSource): "link": { "language": "C", "lto": None, + "commandFragments": None, }, "archive": None, "dependencies": [ @@ -2848,6 +2947,7 @@ def gen_check_targets(c, g, inSource): ], "includes": None, "defines": None, + "compileCommandFragments": None, }, ], "backtrace": [ @@ -2882,6 +2982,7 @@ def gen_check_targets(c, g, inSource): "link": { "language": "CXX", "lto": None, + "commandFragments": None, }, "archive": None, "dependencies": [ @@ -3114,6 +3215,7 @@ def gen_check_targets(c, g, inSource): ], "includes": None, "defines": None, + "compileCommandFragments": None, }, ], "backtrace": [ @@ -3221,6 +3323,7 @@ def gen_check_targets(c, g, inSource): ], "includes": None, "defines": None, + "compileCommandFragments": None, }, ], "backtrace": [ @@ -3276,6 +3379,7 @@ def gen_check_targets(c, g, inSource): "link": { "language": "C", "lto": None, + "commandFragments": None, }, "archive": None, "dependencies": [ @@ -3337,6 +3441,7 @@ def gen_check_targets(c, g, inSource): ], "includes": None, "defines": None, + "compileCommandFragments": None, }, ], "backtrace": [ @@ -3444,6 +3549,7 @@ def gen_check_targets(c, g, inSource): ], "includes": None, "defines": None, + "compileCommandFragments": None, }, ], "backtrace": [ @@ -3499,6 +3605,7 @@ def gen_check_targets(c, g, inSource): "link": { "language": "CXX", "lto": None, + "commandFragments": None, }, "archive": None, "dependencies": [ @@ -3725,6 +3832,7 @@ def gen_check_targets(c, g, inSource): ], "includes": None, "defines": None, + "compileCommandFragments": None, }, ], "backtrace": [ @@ -3759,6 +3867,7 @@ def gen_check_targets(c, g, inSource): "link": { "language": "C", "lto": None, + "commandFragments": None, }, "archive": None, "dependencies": [ @@ -3813,6 +3922,7 @@ def gen_check_targets(c, g, inSource): ], "includes": None, "defines": None, + "compileCommandFragments": None, }, ], "backtrace": [ @@ -3847,6 +3957,7 @@ def gen_check_targets(c, g, inSource): "link": { "language": "C", "lto": None, + "commandFragments": None, }, "archive": None, "dependencies": [ @@ -3901,6 +4012,7 @@ def gen_check_targets(c, g, inSource): ], "includes": None, "defines": None, + "compileCommandFragments": None, }, ], "backtrace": [ @@ -3935,6 +4047,7 @@ def gen_check_targets(c, g, inSource): "link": { "language": "C", "lto": None, + "commandFragments": None, }, "archive": None, "dependencies": [ @@ -3989,6 +4102,7 @@ def gen_check_targets(c, g, inSource): ], "includes": None, "defines": None, + "compileCommandFragments": None, }, ], "backtrace": [ @@ -4023,6 +4137,7 @@ def gen_check_targets(c, g, inSource): "link": { "language": "C", "lto": None, + "commandFragments": None, }, "archive": None, "dependencies": [ @@ -4077,6 +4192,7 @@ def gen_check_targets(c, g, inSource): ], "includes": None, "defines": None, + "compileCommandFragments": None, }, ], "backtrace": [ @@ -4111,6 +4227,7 @@ def gen_check_targets(c, g, inSource): "link": { "language": "C", "lto": None, + "commandFragments": None, }, "archive": None, "dependencies": [ @@ -4401,6 +4518,7 @@ def gen_check_targets(c, g, inSource): ], "includes": None, "defines": None, + "compileCommandFragments": None, }, ], "backtrace": [ @@ -4435,6 +4553,7 @@ def gen_check_targets(c, g, inSource): "link": { "language": "C", "lto": None, + "commandFragments": None, }, "archive": None, "dependencies": [ @@ -4748,6 +4867,7 @@ def gen_check_targets(c, g, inSource): ], }, ], + "compileCommandFragments": None, }, { "language": "CXX", @@ -4810,6 +4930,7 @@ def gen_check_targets(c, g, inSource): ], }, ], + "compileCommandFragments": None, }, ], "backtrace": [ @@ -4844,6 +4965,7 @@ def gen_check_targets(c, g, inSource): "link": { "language": "CXX", "lto": None, + "commandFragments": None, }, "archive": None, "dependencies": [ diff --git a/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt b/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt index 29b61b8..17ff455 100644 --- a/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt +++ b/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt @@ -13,3 +13,6 @@ target_link_libraries(cxx_shared_exe PRIVATE cxx_shared_lib) add_library(cxx_static_lib STATIC ../empty.cxx) add_executable(cxx_static_exe ../empty.cxx) target_link_libraries(cxx_static_exe PRIVATE cxx_static_lib) + +target_compile_options(cxx_exe PUBLIC TargetCompileOptions) +target_link_options(cxx_exe PUBLIC TargetLinkOptions) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=291c83f063d310f700e3e1afa756dcdf968d0f09 commit 291c83f063d310f700e3e1afa756dcdf968d0f09 Author: Justin Goshi AuthorDate: Tue Sep 3 10:25:44 2019 -0700 Commit: Brad King CommitDate: Tue Sep 10 10:45:41 2019 -0400 cmLocalGenerator: Add GetTargetCompileFlags overload with backtraces diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index b73f5d2..bc1ff1f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1382,6 +1382,16 @@ void cmLocalGenerator::GetTargetCompileFlags(cmGeneratorTarget* target, std::string const& lang, std::string& flags) { + std::vector> tmpFlags = + this->GetTargetCompileFlags(target, config, lang); + this->AppendFlags(flags, tmpFlags); +} + +std::vector> cmLocalGenerator::GetTargetCompileFlags( + cmGeneratorTarget* target, std::string const& config, + std::string const& lang) +{ + std::vector> flags; std::string compileFlags; cmMakefile* mf = this->GetMakefile(); @@ -1406,9 +1416,11 @@ void cmLocalGenerator::GetTargetCompileFlags(cmGeneratorTarget* target, this->AppendFlags(compileFlags, this->GetFrameworkFlags(lang, config, target)); - flags = std::move(compileFlags); - + if (!compileFlags.empty()) { + flags.emplace_back(std::move(compileFlags)); + } this->AddCompileOptions(flags, target, lang, config); + return flags; } static std::string GetFrameworkFlags(const std::string& lang, diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 89472e0..34f58bd 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -397,6 +397,9 @@ public: void GetTargetCompileFlags(cmGeneratorTarget* target, std::string const& config, std::string const& lang, std::string& flags); + std::vector> GetTargetCompileFlags(cmGeneratorTarget* target, + std::string const& config, + std::string const& lang); std::string GetFrameworkFlags(std::string const& l, std::string const& config, https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8e973b8e8d6542b5dd15173884bde68a9a390949 commit 8e973b8e8d6542b5dd15173884bde68a9a390949 Author: Justin Goshi AuthorDate: Tue Sep 3 10:25:44 2019 -0700 Commit: Brad King CommitDate: Tue Sep 10 10:45:41 2019 -0400 cmLocalGenerator: Add GetTargetFlags overload with backtraces diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 36e1115..b73f5d2 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1198,6 +1198,18 @@ void cmLocalGenerator::GetTargetFlags( std::string& linkLibs, std::string& flags, std::string& linkFlags, std::string& frameworkPath, std::string& linkPath, cmGeneratorTarget* target) { + std::vector> tmpLinkFlags; + this->GetTargetFlags(linkLineComputer, config, linkLibs, flags, tmpLinkFlags, + frameworkPath, linkPath, target); + this->AppendFlags(linkFlags, tmpLinkFlags); +} + +void cmLocalGenerator::GetTargetFlags( + cmLinkLineComputer* linkLineComputer, const std::string& config, + std::string& linkLibs, std::string& flags, + std::vector>& linkFlags, std::string& frameworkPath, + std::string& linkPath, cmGeneratorTarget* target) +{ const std::string buildType = cmSystemTools::UpperCase(config); cmComputeLinkInformation* pcli = target->GetLinkInformation(config); const char* libraryLinkVariable = @@ -1208,7 +1220,7 @@ void cmLocalGenerator::GetTargetFlags( switch (target->GetType()) { case cmStateEnums::STATIC_LIBRARY: - this->GetStaticLibraryFlags(linkFlags, buildType, linkLanguage, target); + linkFlags = this->GetStaticLibraryFlags(buildType, linkLanguage, target); if (pcli && dynamic_cast(linkLineComputer)) { // Compute the required cuda device link libraries when // resolving cuda device symbols @@ -1261,10 +1273,12 @@ void cmLocalGenerator::GetTargetFlags( } } - linkFlags = std::move(sharedLibFlags); + if (!sharedLibFlags.empty()) { + linkFlags.emplace_back(std::move(sharedLibFlags)); + } - std::vector linkOpts; - target->GetLinkOptions(linkOpts, config, linkLanguage); + std::vector> linkOpts = + target->GetLinkOptions(config, linkLanguage); // LINK_OPTIONS are escaped. this->AppendCompileOptions(linkFlags, linkOpts); if (pcli) { @@ -1340,10 +1354,12 @@ void cmLocalGenerator::GetTargetFlags( } } - linkFlags = std::move(exeFlags); + if (!exeFlags.empty()) { + linkFlags.emplace_back(std::move(exeFlags)); + } - std::vector linkOpts; - target->GetLinkOptions(linkOpts, config, linkLanguage); + std::vector> linkOpts = + target->GetLinkOptions(config, linkLanguage); // LINK_OPTIONS are escaped. this->AppendCompileOptions(linkFlags, linkOpts); } break; @@ -1351,9 +1367,14 @@ void cmLocalGenerator::GetTargetFlags( break; } - this->AppendPositionIndependentLinkerFlags(linkFlags, target, config, + std::string extraLinkFlags; + this->AppendPositionIndependentLinkerFlags(extraLinkFlags, target, config, linkLanguage); - this->AppendIPOLinkerFlags(linkFlags, target, config, linkLanguage); + this->AppendIPOLinkerFlags(extraLinkFlags, target, config, linkLanguage); + + if (!extraLinkFlags.empty()) { + linkFlags.emplace_back(std::move(extraLinkFlags)); + } } void cmLocalGenerator::GetTargetCompileFlags(cmGeneratorTarget* target, diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 0a41f2a..89472e0 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -382,6 +382,12 @@ public: std::string& flags, std::string& linkFlags, std::string& frameworkPath, std::string& linkPath, cmGeneratorTarget* target); + void GetTargetFlags(cmLinkLineComputer* linkLineComputer, + const std::string& config, std::string& linkLibs, + std::string& flags, + std::vector>& linkFlags, + std::string& frameworkPath, std::string& linkPath, + cmGeneratorTarget* target); void GetTargetDefines(cmGeneratorTarget const* target, std::string const& config, std::string const& lang, std::set& defines) const; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4d5bbb7704a44e56f43585b3f811f37c5200bdd0 commit 4d5bbb7704a44e56f43585b3f811f37c5200bdd0 Author: Justin Goshi AuthorDate: Tue Sep 3 10:25:44 2019 -0700 Commit: Brad King CommitDate: Tue Sep 10 10:45:41 2019 -0400 cmLocalGenerator: Add GetStaticLibraryFlags overload with backtraces diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 44ba79a..36e1115 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1148,8 +1148,18 @@ void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags, std::string const& linkLanguage, cmGeneratorTarget* target) { - std::string staticLibFlags; + std::vector> tmpFlags = + this->GetStaticLibraryFlags(config, linkLanguage, target); + this->AppendFlags(flags, tmpFlags); +} + +std::vector> cmLocalGenerator::GetStaticLibraryFlags( + std::string const& config, std::string const& linkLanguage, + cmGeneratorTarget* target) +{ + std::vector> flags; if (linkLanguage != "Swift") { + std::string staticLibFlags; this->AppendFlags( staticLibFlags, this->Makefile->GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS")); @@ -1158,7 +1168,12 @@ void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags, this->AppendFlags(staticLibFlags, this->Makefile->GetSafeDefinition(name)); } + if (!staticLibFlags.empty()) { + flags.emplace_back(std::move(staticLibFlags)); + } } + + std::string staticLibFlags; this->AppendFlags(staticLibFlags, target->GetSafeProperty("STATIC_LIBRARY_FLAGS")); if (!config.empty()) { @@ -1166,12 +1181,16 @@ void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags, this->AppendFlags(staticLibFlags, target->GetSafeProperty(name)); } - flags = std::move(staticLibFlags); + if (!staticLibFlags.empty()) { + flags.emplace_back(std::move(staticLibFlags)); + } - std::vector staticLibOpts; - target->GetStaticLibraryLinkOptions(staticLibOpts, config, linkLanguage); + std::vector> staticLibOpts = + target->GetStaticLibraryLinkOptions(config, linkLanguage); // STATIC_LIBRARY_OPTIONS are escaped. this->AppendCompileOptions(flags, staticLibOpts); + + return flags; } void cmLocalGenerator::GetTargetFlags( diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 52f8ac8..0a41f2a 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -371,6 +371,9 @@ public: void GetStaticLibraryFlags(std::string& flags, std::string const& config, std::string const& linkLanguage, cmGeneratorTarget* target); + std::vector> GetStaticLibraryFlags( + std::string const& config, std::string const& linkLanguage, + cmGeneratorTarget* target); /** Fill out these strings for the given target. Libraries to link, * flags, and linkflags. */ https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1f6a436bf4188007b87d2582367cde8f970d5e1f commit 1f6a436bf4188007b87d2582367cde8f970d5e1f Author: Justin Goshi AuthorDate: Tue Sep 3 10:25:44 2019 -0700 Commit: Brad King CommitDate: Tue Sep 10 10:45:41 2019 -0400 cmLocalGenerator: Add AddCompileOptions overload with backtraces diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index bd5e5a2..44ba79a 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -833,6 +833,16 @@ void cmLocalGenerator::AddCompileOptions(std::string& flags, const std::string& lang, const std::string& config) { + std::vector> tmpFlags; + this->AddCompileOptions(tmpFlags, target, lang, config); + this->AppendFlags(flags, tmpFlags); +} + +void cmLocalGenerator::AddCompileOptions(std::vector>& flags, + cmGeneratorTarget* target, + const std::string& lang, + const std::string& config) +{ std::string langFlagRegexVar = std::string("CMAKE_") + lang + "_FLAG_REGEX"; if (const char* langFlagRegexStr = @@ -843,20 +853,28 @@ void cmLocalGenerator::AddCompileOptions(std::string& flags, cmSystemTools::ParseWindowsCommandLine(targetFlags, opts); // Re-escape these flags since COMPILE_FLAGS were already parsed // as a command line above. - this->AppendCompileOptions(flags, opts, langFlagRegexStr); + std::string compileOpts; + this->AppendCompileOptions(compileOpts, opts, langFlagRegexStr); + if (!compileOpts.empty()) { + flags.emplace_back(std::move(compileOpts)); + } } - std::vector targetCompileOpts; - target->GetCompileOptions(targetCompileOpts, config, lang); + std::vector> targetCompileOpts = + target->GetCompileOptions(config, lang); // COMPILE_OPTIONS are escaped. this->AppendCompileOptions(flags, targetCompileOpts, langFlagRegexStr); } else { // Use all flags. if (const char* targetFlags = target->GetProperty("COMPILE_FLAGS")) { // COMPILE_FLAGS are not escaped for historical reasons. - this->AppendFlags(flags, targetFlags); + std::string compileFlags; + this->AppendFlags(compileFlags, targetFlags); + if (!compileFlags.empty()) { + flags.emplace_back(std::move(compileFlags)); + } } - std::vector targetCompileOpts; - target->GetCompileOptions(targetCompileOpts, config, lang); + std::vector> targetCompileOpts = + target->GetCompileOptions(config, lang); // COMPILE_OPTIONS are escaped. this->AppendCompileOptions(flags, targetCompileOpts); } @@ -885,7 +903,12 @@ void cmLocalGenerator::AddCompileOptions(std::string& flags, return; } } - this->AddCompilerRequirementFlag(flags, target, lang); + + std::string compReqFlag; + this->AddCompilerRequirementFlag(compReqFlag, target, lang); + if (!compReqFlag.empty()) { + flags.emplace_back(std::move(compReqFlag)); + } // Add compile flag for the MSVC compiler only. cmMakefile* mf = this->GetMakefile(); @@ -906,7 +929,11 @@ void cmLocalGenerator::AddCompileOptions(std::string& flags, std::string isJMCEnabled = cge->Evaluate(this, config); if (cmIsOn(isJMCEnabled)) { std::vector optVec = cmExpandedList(jmc); - this->AppendCompileOptions(flags, optVec); + std::string jmcFlags; + this->AppendCompileOptions(jmcFlags, optVec); + if (!jmcFlags.empty()) { + flags.emplace_back(std::move(jmcFlags)); + } } } } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index ec97ac2..52f8ac8 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -288,6 +288,9 @@ public: void AddCompileOptions(std::string& flags, cmGeneratorTarget* target, const std::string& lang, const std::string& config); + void AddCompileOptions(std::vector>& flags, + cmGeneratorTarget* target, const std::string& lang, + const std::string& config); std::string GetProjectName() const; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5355a60fd02417a004c6b4b6b8848ce0ff1ea9fa commit 5355a60fd02417a004c6b4b6b8848ce0ff1ea9fa Author: Justin Goshi AuthorDate: Tue Sep 3 10:25:44 2019 -0700 Commit: Brad King CommitDate: Tue Sep 10 10:45:41 2019 -0400 cmLocalGenerator: Add AppendCompileOptions overload with backtraces diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 144d995..bd5e5a2 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2422,6 +2422,30 @@ void cmLocalGenerator::AppendCompileOptions( } } +void cmLocalGenerator::AppendCompileOptions( + std::vector>& options, + const std::vector>& options_vec, const char* regex) const +{ + if (regex != nullptr) { + // Filter flags upon specified regular expressions. + cmsys::RegularExpression r(regex); + + for (BT const& opt : options_vec) { + if (r.find(opt.Value)) { + std::string flag; + this->AppendFlagEscape(flag, opt.Value); + options.emplace_back(std::move(flag), opt.Backtrace); + } + } + } else { + for (BT const& opt : options_vec) { + std::string flag; + this->AppendFlagEscape(flag, opt.Value); + options.emplace_back(std::move(flag), opt.Backtrace); + } + } +} + void cmLocalGenerator::AppendIncludeDirectories( std::vector& includes, const char* includes_list, const cmSourceFile& sourceFile) const diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 3c4e897..ec97ac2 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -199,6 +199,9 @@ public: void AppendCompileOptions(std::string& options, const std::vector& options_vec, const char* regex = nullptr) const; + void AppendCompileOptions(std::vector>& options, + const std::vector>& options_vec, + const char* regex = nullptr) const; /** * Join a set of defines into a definesString with a space separator. https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cd7d7362782c2a582bcfd8a86a5523cf20ee6afb commit cd7d7362782c2a582bcfd8a86a5523cf20ee6afb Author: Regina Pfeifer AuthorDate: Mon Sep 9 16:32:05 2019 +0200 Commit: Regina Pfeifer CommitDate: Mon Sep 9 16:32:05 2019 +0200 cmCTestTestHandler: Port away from cmCommand diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index f67b11a..a007af0 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -7,8 +7,8 @@ #include "cmAlgorithms.h" #include "cmCTest.h" #include "cmCTestMultiProcessHandler.h" -#include "cmCommand.h" #include "cmDuration.h" +#include "cmExecutionStatus.h" #include "cmGeneratedFileStream.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" @@ -40,36 +40,42 @@ #include #include -class cmExecutionStatus; +namespace { -class cmCTestSubdirCommand : public cmCommand +class cmCTestCommand { public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override + cmCTestCommand(cmCTestTestHandler* testHandler) + : TestHandler(testHandler) { - auto c = cm::make_unique(); - c->TestHandler = this->TestHandler; - return std::unique_ptr(std::move(c)); } - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& /*unused*/) override; + virtual ~cmCTestCommand() = default; + + bool operator()(std::vector const& args, + cmExecutionStatus& status) + { + cmMakefile& mf = status.GetMakefile(); + std::vector expandedArguments; + if (!mf.ExpandArguments(args, expandedArguments)) { + // There was an error expanding arguments. It was already + // reported, so we can skip this command without error. + return true; + } + return this->InitialPass(expandedArguments, status); + } + + virtual bool InitialPass(std::vector const& args, + cmExecutionStatus& status) = 0; cmCTestTestHandler* TestHandler; }; -bool cmCTestSubdirCommand::InitialPass(std::vector const& args, - cmExecutionStatus& /*unused*/) +bool cmCTestSubdirCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.empty()) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); @@ -90,8 +96,8 @@ bool cmCTestSubdirCommand::InitialPass(std::vector const& args, { cmWorkingDirectory workdir(fname); if (workdir.Failed()) { - this->SetError("Failed to change directory to " + fname + " : " + - std::strerror(workdir.GetLastResult())); + status.SetError("Failed to change directory to " + fname + " : " + + std::strerror(workdir.GetLastResult())); return false; } const char* testFilename; @@ -107,45 +113,21 @@ bool cmCTestSubdirCommand::InitialPass(std::vector const& args, } fname += "/"; fname += testFilename; - readit = this->Makefile->ReadDependentFile(fname); + readit = status.GetMakefile().ReadDependentFile(fname); } if (!readit) { - std::string m = cmStrCat("Could not find include file: ", fname); - this->SetError(m); + status.SetError(cmStrCat("Could not find include file: ", fname)); return false; } } return true; } -class cmCTestAddSubdirectoryCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - auto c = cm::make_unique(); - c->TestHandler = this->TestHandler; - return std::unique_ptr(std::move(c)); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& /*unused*/) override; - - cmCTestTestHandler* TestHandler; -}; - -bool cmCTestAddSubdirectoryCommand::InitialPass( - std::vector const& args, cmExecutionStatus& /*unused*/) +bool cmCTestAddSubdirectoryCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.empty()) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } @@ -171,28 +153,19 @@ bool cmCTestAddSubdirectoryCommand::InitialPass( } fname += "/"; fname += testFilename; - readit = this->Makefile->ReadDependentFile(fname); + readit = status.GetMakefile().ReadDependentFile(fname); } if (!readit) { - std::string m = cmStrCat("Could not find include file: ", fname); - this->SetError(m); + status.SetError(cmStrCat("Could not find include file: ", fname)); return false; } return true; } -class cmCTestAddTestCommand : public cmCommand +class cmCTestAddTestCommand : public cmCTestCommand { public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - auto c = cm::make_unique(); - c->TestHandler = this->TestHandler; - return std::unique_ptr(std::move(c)); - } + using cmCTestCommand::cmCTestCommand; /** * This is called when the command is first encountered in @@ -200,32 +173,22 @@ public: */ bool InitialPass(std::vector const& /*args*/, cmExecutionStatus& /*unused*/) override; - - cmCTestTestHandler* TestHandler; }; bool cmCTestAddTestCommand::InitialPass(std::vector const& args, - cmExecutionStatus& /*unused*/) + cmExecutionStatus& status) { if (args.size() < 2) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } return this->TestHandler->AddTest(args); } -class cmCTestSetTestsPropertiesCommand : public cmCommand +class cmCTestSetTestsPropertiesCommand : public cmCTestCommand { public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - auto c = cm::make_unique(); - c->TestHandler = this->TestHandler; - return std::unique_ptr(std::move(c)); - } + using cmCTestCommand::cmCTestCommand; /** * This is called when the command is first encountered in @@ -233,8 +196,6 @@ public: */ bool InitialPass(std::vector const& /*args*/, cmExecutionStatus& /*unused*/) override; - - cmCTestTestHandler* TestHandler; }; bool cmCTestSetTestsPropertiesCommand::InitialPass( @@ -243,18 +204,10 @@ bool cmCTestSetTestsPropertiesCommand::InitialPass( return this->TestHandler->SetTestsProperties(args); } -class cmCTestSetDirectoryPropertiesCommand : public cmCommand +class cmCTestSetDirectoryPropertiesCommand : public cmCTestCommand { public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - auto c = cm::make_unique(); - c->TestHandler = this->TestHandler; - return std::unique_ptr(std::move(c)); - } + using cmCTestCommand::cmCTestCommand; /** * This is called when the command is first encountered in @@ -262,8 +215,6 @@ public: */ bool InitialPass(std::vector const& /*unused*/, cmExecutionStatus& /*unused*/) override; - - cmCTestTestHandler* TestHandler; }; bool cmCTestSetDirectoryPropertiesCommand::InitialPass( @@ -324,6 +275,8 @@ inline int GetNextRealNumber(std::string const& in, double& val, return 0; } +} // namespace + cmCTestTestHandler::cmCTestTestHandler() { this->UseUnion = false; @@ -1688,31 +1641,23 @@ void cmCTestTestHandler::GetListOfTests() mf.AddDefinition("CTEST_CONFIGURATION_TYPE", this->CTest->GetConfigType()); // Add handler for ADD_TEST - auto newCom1 = cm::make_unique(); - newCom1->TestHandler = this; - cm.GetState()->AddBuiltinCommand("add_test", std::move(newCom1)); + cm.GetState()->AddBuiltinCommand("add_test", cmCTestAddTestCommand(this)); // Add handler for SUBDIRS - auto newCom2 = cm::make_unique(); - newCom2->TestHandler = this; - cm.GetState()->AddBuiltinCommand("subdirs", std::move(newCom2)); + cm.GetState()->AddBuiltinCommand("subdirs", cmCTestSubdirCommand); // Add handler for ADD_SUBDIRECTORY - auto newCom3 = cm::make_unique(); - newCom3->TestHandler = this; - cm.GetState()->AddBuiltinCommand("add_subdirectory", std::move(newCom3)); + cm.GetState()->AddBuiltinCommand("add_subdirectory", + cmCTestAddSubdirectoryCommand); // Add handler for SET_TESTS_PROPERTIES - auto newCom4 = cm::make_unique(); - newCom4->TestHandler = this; - cm.GetState()->AddBuiltinCommand("set_tests_properties", std::move(newCom4)); + cm.GetState()->AddBuiltinCommand("set_tests_properties", + cmCTestSetTestsPropertiesCommand(this)); // Add handler for SET_DIRECTORY_PROPERTIES cm.GetState()->RemoveBuiltinCommand("set_directory_properties"); - auto newCom5 = cm::make_unique(); - newCom5->TestHandler = this; cm.GetState()->AddBuiltinCommand("set_directory_properties", - std::move(newCom5)); + cmCTestSetDirectoryPropertiesCommand(this)); const char* testFilename; if (cmSystemTools::FileExists("CTestTestfile.cmake")) { https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a20d2c85d02842a23ef1105daa078a821172cb4e commit a20d2c85d02842a23ef1105daa078a821172cb4e Author: Justin Goshi AuthorDate: Tue Sep 3 10:25:44 2019 -0700 Commit: Brad King CommitDate: Mon Sep 9 09:43:34 2019 -0400 cmLocalGenerator: Add AppendFlags overload with backtraces diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 042c108..144d995 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2138,6 +2138,14 @@ void cmLocalGenerator::AppendFlags(std::string& flags, } } +void cmLocalGenerator::AppendFlags( + std::string& flags, const std::vector>& newFlags) const +{ + for (BT const& flag : newFlags) { + this->AppendFlags(flags, flag.Value); + } +} + void cmLocalGenerator::AppendFlagEscape(std::string& flags, const std::string& rawFlag) const { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index e6ba333..3c4e897 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -121,6 +121,8 @@ public: //! Append flags to a string. virtual void AppendFlags(std::string& flags, const std::string& newFlags) const; + virtual void AppendFlags(std::string& flags, + const std::vector>& newFlags) const; virtual void AppendFlagEscape(std::string& flags, const std::string& rawFlag) const; void AddPchDependencies(cmGeneratorTarget* target, diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 745e251..c02c0dc 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -90,6 +90,7 @@ public: // append flags to a string void AppendFlags(std::string& flags, const std::string& newFlags) const override; + using cmLocalCommonGenerator::AppendFlags; // append an echo command enum EchoColor https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b13207910e848d3c980e4b3dc176e113a3c04bbc commit b13207910e848d3c980e4b3dc176e113a3c04bbc Author: Justin Goshi AuthorDate: Tue Sep 3 10:25:44 2019 -0700 Commit: Brad King CommitDate: Mon Sep 9 09:43:34 2019 -0400 cmLocalGenerator: Clarify AddCompileOptions filter logic diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 69866c4..042c108 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -838,14 +838,17 @@ void cmLocalGenerator::AddCompileOptions(std::string& flags, if (const char* langFlagRegexStr = this->Makefile->GetDefinition(langFlagRegexVar)) { // Filter flags acceptable to this language. - std::vector opts; if (const char* targetFlags = target->GetProperty("COMPILE_FLAGS")) { + std::vector opts; cmSystemTools::ParseWindowsCommandLine(targetFlags, opts); + // Re-escape these flags since COMPILE_FLAGS were already parsed + // as a command line above. + this->AppendCompileOptions(flags, opts, langFlagRegexStr); } - target->GetCompileOptions(opts, config, lang); - // (Re-)Escape these flags. COMPILE_FLAGS were already parsed - // as a command line above, and COMPILE_OPTIONS are escaped. - this->AppendCompileOptions(flags, opts, langFlagRegexStr); + std::vector targetCompileOpts; + target->GetCompileOptions(targetCompileOpts, config, lang); + // COMPILE_OPTIONS are escaped. + this->AppendCompileOptions(flags, targetCompileOpts, langFlagRegexStr); } else { // Use all flags. if (const char* targetFlags = target->GetProperty("COMPILE_FLAGS")) { https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ca7b90dcf2fc6ef5345de162ec2532454376fe2f commit ca7b90dcf2fc6ef5345de162ec2532454376fe2f Author: Justin Goshi AuthorDate: Tue Sep 3 10:25:44 2019 -0700 Commit: Brad King CommitDate: Mon Sep 9 09:43:34 2019 -0400 cmLocalGenerator: Use local variables to collect flags diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 361b005..69866c4 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1118,20 +1118,26 @@ void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags, std::string const& linkLanguage, cmGeneratorTarget* target) { + std::string staticLibFlags; if (linkLanguage != "Swift") { this->AppendFlags( - flags, this->Makefile->GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS")); + staticLibFlags, + this->Makefile->GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS")); if (!config.empty()) { std::string name = "CMAKE_STATIC_LINKER_FLAGS_" + config; - this->AppendFlags(flags, this->Makefile->GetSafeDefinition(name)); + this->AppendFlags(staticLibFlags, + this->Makefile->GetSafeDefinition(name)); } } - this->AppendFlags(flags, target->GetSafeProperty("STATIC_LIBRARY_FLAGS")); + this->AppendFlags(staticLibFlags, + target->GetSafeProperty("STATIC_LIBRARY_FLAGS")); if (!config.empty()) { std::string name = "STATIC_LIBRARY_FLAGS_" + config; - this->AppendFlags(flags, target->GetSafeProperty(name)); + this->AppendFlags(staticLibFlags, target->GetSafeProperty(name)); } + flags = std::move(staticLibFlags); + std::vector staticLibOpts; target->GetStaticLibraryLinkOptions(staticLibOpts, config, linkLanguage); // STATIC_LIBRARY_OPTIONS are escaped. @@ -1165,13 +1171,14 @@ void cmLocalGenerator::GetTargetFlags( libraryLinkVariable = "CMAKE_MODULE_LINKER_FLAGS"; CM_FALLTHROUGH; case cmStateEnums::SHARED_LIBRARY: { + std::string sharedLibFlags; if (linkLanguage != "Swift") { - linkFlags = cmStrCat( + sharedLibFlags = cmStrCat( this->Makefile->GetSafeDefinition(libraryLinkVariable), ' '); if (!buildType.empty()) { std::string build = cmStrCat(libraryLinkVariable, '_', buildType); - linkFlags += this->Makefile->GetSafeDefinition(build); - linkFlags += " "; + sharedLibFlags += this->Makefile->GetSafeDefinition(build); + sharedLibFlags += " "; } if (this->Makefile->IsOn("WIN32") && !(this->Makefile->IsOn("CYGWIN") || @@ -1182,10 +1189,10 @@ void cmLocalGenerator::GetTargetFlags( this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG"); for (cmSourceFile* sf : sources) { if (sf->GetExtension() == "def") { - linkFlags += defFlag; - linkFlags += this->ConvertToOutputFormat( + sharedLibFlags += defFlag; + sharedLibFlags += this->ConvertToOutputFormat( cmSystemTools::CollapseFullPath(sf->ResolveFullPath()), SHELL); - linkFlags += " "; + sharedLibFlags += " "; } } } @@ -1193,18 +1200,20 @@ void cmLocalGenerator::GetTargetFlags( const char* targetLinkFlags = target->GetProperty("LINK_FLAGS"); if (targetLinkFlags) { - linkFlags += targetLinkFlags; - linkFlags += " "; + sharedLibFlags += targetLinkFlags; + sharedLibFlags += " "; } if (!buildType.empty()) { targetLinkFlags = target->GetProperty(cmStrCat("LINK_FLAGS_", buildType)); if (targetLinkFlags) { - linkFlags += targetLinkFlags; - linkFlags += " "; + sharedLibFlags += targetLinkFlags; + sharedLibFlags += " "; } } + linkFlags = std::move(sharedLibFlags); + std::vector linkOpts; target->GetLinkOptions(linkOpts, config, linkLanguage); // LINK_OPTIONS are escaped. @@ -1215,14 +1224,14 @@ void cmLocalGenerator::GetTargetFlags( } } break; case cmStateEnums::EXECUTABLE: { + std::string exeFlags; if (linkLanguage != "Swift") { - linkFlags += - this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS"); - linkFlags += " "; + exeFlags = this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS"); + exeFlags += " "; if (!buildType.empty()) { - linkFlags += this->Makefile->GetSafeDefinition( + exeFlags += this->Makefile->GetSafeDefinition( cmStrCat("CMAKE_EXE_LINKER_FLAGS_", buildType)); - linkFlags += " "; + exeFlags += " "; } if (linkLanguage.empty()) { cmSystemTools::Error( @@ -1232,19 +1241,19 @@ void cmLocalGenerator::GetTargetFlags( } if (target->GetPropertyAsBool("WIN32_EXECUTABLE")) { - linkFlags += + exeFlags += this->Makefile->GetSafeDefinition("CMAKE_CREATE_WIN32_EXE"); - linkFlags += " "; + exeFlags += " "; } else { - linkFlags += + exeFlags += this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE"); - linkFlags += " "; + exeFlags += " "; } if (target->IsExecutableWithExports()) { - linkFlags += this->Makefile->GetSafeDefinition( + exeFlags += this->Makefile->GetSafeDefinition( cmStrCat("CMAKE_EXE_EXPORTS_", linkLanguage, "_FLAG")); - linkFlags += " "; + exeFlags += " "; } } @@ -1257,31 +1266,33 @@ void cmLocalGenerator::GetTargetFlags( if (cmIsOn(this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) { std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_") + linkLanguage + std::string("_FLAGS"); - linkFlags += this->Makefile->GetSafeDefinition(sFlagVar); - linkFlags += " "; + exeFlags += this->Makefile->GetSafeDefinition(sFlagVar); + exeFlags += " "; } std::string cmp0065Flags = this->GetLinkLibsCMP0065(linkLanguage, *target); if (!cmp0065Flags.empty()) { - linkFlags += cmp0065Flags; - linkFlags += " "; + exeFlags += cmp0065Flags; + exeFlags += " "; } const char* targetLinkFlags = target->GetProperty("LINK_FLAGS"); if (targetLinkFlags) { - linkFlags += targetLinkFlags; - linkFlags += " "; + exeFlags += targetLinkFlags; + exeFlags += " "; } if (!buildType.empty()) { targetLinkFlags = target->GetProperty(cmStrCat("LINK_FLAGS_", buildType)); if (targetLinkFlags) { - linkFlags += targetLinkFlags; - linkFlags += " "; + exeFlags += targetLinkFlags; + exeFlags += " "; } } + linkFlags = std::move(exeFlags); + std::vector linkOpts; target->GetLinkOptions(linkOpts, config, linkLanguage); // LINK_OPTIONS are escaped. @@ -1301,25 +1312,32 @@ void cmLocalGenerator::GetTargetCompileFlags(cmGeneratorTarget* target, std::string const& lang, std::string& flags) { + std::string compileFlags; + cmMakefile* mf = this->GetMakefile(); // Add language-specific flags. - this->AddLanguageFlags(flags, target, lang, config); + this->AddLanguageFlags(compileFlags, target, lang, config); if (target->IsIPOEnabled(lang, config)) { - this->AppendFeatureOptions(flags, lang, "IPO"); + this->AppendFeatureOptions(compileFlags, lang, "IPO"); } - this->AddArchitectureFlags(flags, target, lang, config); + this->AddArchitectureFlags(compileFlags, target, lang, config); if (lang == "Fortran") { - this->AppendFlags(flags, this->GetTargetFortranFlags(target, config)); + this->AppendFlags(compileFlags, + this->GetTargetFortranFlags(target, config)); } - this->AddCMP0018Flags(flags, target, lang, config); - this->AddVisibilityPresetFlags(flags, target, lang); - this->AppendFlags(flags, mf->GetDefineFlags()); - this->AppendFlags(flags, this->GetFrameworkFlags(lang, config, target)); + this->AddCMP0018Flags(compileFlags, target, lang, config); + this->AddVisibilityPresetFlags(compileFlags, target, lang); + this->AppendFlags(compileFlags, mf->GetDefineFlags()); + this->AppendFlags(compileFlags, + this->GetFrameworkFlags(lang, config, target)); + + flags = std::move(compileFlags); + this->AddCompileOptions(flags, target, lang, config); } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=eac8700c7853d88f0682492ccefc70b4246ccf4a commit eac8700c7853d88f0682492ccefc70b4246ccf4a Author: Justin Goshi AuthorDate: Tue Sep 3 10:25:44 2019 -0700 Commit: Brad King CommitDate: Mon Sep 9 09:43:34 2019 -0400 cmLocalGenerator: Improve local variable names diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 25e4d01..361b005 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -852,10 +852,10 @@ void cmLocalGenerator::AddCompileOptions(std::string& flags, // COMPILE_FLAGS are not escaped for historical reasons. this->AppendFlags(flags, targetFlags); } - std::vector opts; - target->GetCompileOptions(opts, config, lang); + std::vector targetCompileOpts; + target->GetCompileOptions(targetCompileOpts, config, lang); // COMPILE_OPTIONS are escaped. - this->AppendCompileOptions(flags, opts); + this->AppendCompileOptions(flags, targetCompileOpts); } for (auto const& it : target->GetMaxLanguageStandards()) { @@ -1132,10 +1132,10 @@ void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags, this->AppendFlags(flags, target->GetSafeProperty(name)); } - std::vector options; - target->GetStaticLibraryLinkOptions(options, config, linkLanguage); + std::vector staticLibOpts; + target->GetStaticLibraryLinkOptions(staticLibOpts, config, linkLanguage); // STATIC_LIBRARY_OPTIONS are escaped. - this->AppendCompileOptions(flags, options); + this->AppendCompileOptions(flags, staticLibOpts); } void cmLocalGenerator::GetTargetFlags( @@ -1205,10 +1205,10 @@ void cmLocalGenerator::GetTargetFlags( } } - std::vector opts; - target->GetLinkOptions(opts, config, linkLanguage); + std::vector linkOpts; + target->GetLinkOptions(linkOpts, config, linkLanguage); // LINK_OPTIONS are escaped. - this->AppendCompileOptions(linkFlags, opts); + this->AppendCompileOptions(linkFlags, linkOpts); if (pcli) { this->OutputLinkLibraries(pcli, linkLineComputer, linkLibs, frameworkPath, linkPath); @@ -1282,10 +1282,10 @@ void cmLocalGenerator::GetTargetFlags( } } - std::vector opts; - target->GetLinkOptions(opts, config, linkLanguage); + std::vector linkOpts; + target->GetLinkOptions(linkOpts, config, linkLanguage); // LINK_OPTIONS are escaped. - this->AppendCompileOptions(linkFlags, opts); + this->AppendCompileOptions(linkFlags, linkOpts); } break; default: break; ----------------------------------------------------------------------- Summary of changes: Source/CTest/cmCTestTestHandler.cxx | 157 ++++++---------- Source/cmFileAPICodemodel.cxx | 20 ++- Source/cmLocalGenerator.cxx | 260 ++++++++++++++++++++------- Source/cmLocalGenerator.h | 20 +++ Source/cmLocalUnixMakefileGenerator3.h | 1 + Tests/RunCMake/FileAPI/codemodel-v2-check.py | 130 +++++++++++++- Tests/RunCMake/FileAPI/cxx/CMakeLists.txt | 3 + 7 files changed, 410 insertions(+), 181 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Thu Sep 12 00:02:43 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 12 Sep 2019 00:02:43 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1008-g5bdff30 Message-ID: <20190912040243.99A6911E2CB@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 5bdff304847995f474797b757fe7a2755de0c1fb (commit) from b5b10c8e955abb2b0f18c3e41b7892471857bcc1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5bdff304847995f474797b757fe7a2755de0c1fb commit 5bdff304847995f474797b757fe7a2755de0c1fb Author: Kitware Robot AuthorDate: Thu Sep 12 00:01:06 2019 -0400 Commit: Kitware Robot CommitDate: Thu Sep 12 00:01:06 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 0d48a72..fc86b56 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 15) -set(CMake_VERSION_PATCH 20190911) +set(CMake_VERSION_PATCH 20190912) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Thu Sep 12 09:22:33 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 12 Sep 2019 09:22:33 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1014-g9602bcf Message-ID: <20190912132233.8F935103021@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 9602bcfc62d50d7bb302b02ae3b1f9afe941bae7 (commit) via 1a1508c8b840ae016dc8db9da6be4cbe59d5f1aa (commit) via d83bff86409c0e414046d2aeb75946037e0d2de3 (commit) via a3cfb66543d307e644e4df207f2e1305200ced02 (commit) via d25a5a7ec91bfa072d3cf1a302830a54506c88c0 (commit) via 8a18bb7cdf2478d68e11a5e532b5134ea92b3678 (commit) from 5bdff304847995f474797b757fe7a2755de0c1fb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9602bcfc62d50d7bb302b02ae3b1f9afe941bae7 commit 9602bcfc62d50d7bb302b02ae3b1f9afe941bae7 Merge: 1a1508c a3cfb66 Author: Brad King AuthorDate: Thu Sep 12 13:15:31 2019 +0000 Commit: Kitware Robot CommitDate: Thu Sep 12 09:16:56 2019 -0400 Merge topic 'compile-msvc-permissive-off' a3cfb66543 Add compatibility with the cl.exe /permissive- compiler option Acked-by: Kitware Robot Merge-request: !3803 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1a1508c8b840ae016dc8db9da6be4cbe59d5f1aa commit 1a1508c8b840ae016dc8db9da6be4cbe59d5f1aa Merge: d83bff8 d25a5a7 Author: Brad King AuthorDate: Thu Sep 12 13:15:09 2019 +0000 Commit: Kitware Robot CommitDate: Thu Sep 12 09:15:38 2019 -0400 Merge topic 'modernize-use-auto' d25a5a7ec9 clang-tidy: modernize-use-auto Acked-by: Kitware Robot Merge-request: !3783 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d83bff86409c0e414046d2aeb75946037e0d2de3 commit d83bff86409c0e414046d2aeb75946037e0d2de3 Merge: 5bdff30 8a18bb7 Author: Brad King AuthorDate: Thu Sep 12 13:14:38 2019 +0000 Commit: Kitware Robot CommitDate: Thu Sep 12 09:14:48 2019 -0400 Merge topic 'free-find-commands' 8a18bb7cdf cmFind*: Port away from cmCommand Acked-by: Kitware Robot Merge-request: !3800 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a3cfb66543d307e644e4df207f2e1305200ced02 commit a3cfb66543d307e644e4df207f2e1305200ced02 Author: Alexej Harm AuthorDate: Wed Sep 11 15:26:20 2019 +0200 Commit: Alexej Harm CommitDate: Wed Sep 11 15:26:20 2019 +0200 Add compatibility with the cl.exe /permissive- compiler option diff --git a/Source/cmUVStreambuf.h b/Source/cmUVStreambuf.h index 873352b..0737629 100644 --- a/Source/cmUVStreambuf.h +++ b/Source/cmUVStreambuf.h @@ -61,7 +61,7 @@ public: cmBasicUVStreambuf* close(); protected: - typename cmBasicUVStreambuf::int_type underflow() override; + typename cmBasicUVStreambuf::int_type underflow() override; std::streamsize showmanyc() override; // FIXME: Add write support diff --git a/Utilities/Release/WiX/CustomAction/detect_nsis_overwrite.cpp b/Utilities/Release/WiX/CustomAction/detect_nsis_overwrite.cpp index 4b17875..593822a 100644 --- a/Utilities/Release/WiX/CustomAction/detect_nsis_overwrite.cpp +++ b/Utilities/Release/WiX/CustomAction/detect_nsis_overwrite.cpp @@ -10,7 +10,8 @@ std::wstring get_property(MSIHANDLE msi_handle, std::wstring const& name) { DWORD size = 0; - UINT status = MsiGetPropertyW(msi_handle, name.c_str(), L"", &size); + WCHAR value_buffer[] = L""; + UINT status = MsiGetPropertyW(msi_handle, name.c_str(), value_buffer, &size); if (status == ERROR_MORE_DATA) { std::vector buffer(size + 1); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d25a5a7ec91bfa072d3cf1a302830a54506c88c0 commit d25a5a7ec91bfa072d3cf1a302830a54506c88c0 Author: Regina Pfeifer AuthorDate: Wed Sep 4 22:17:22 2019 +0200 Commit: Regina Pfeifer CommitDate: Tue Sep 10 22:21:41 2019 +0200 clang-tidy: modernize-use-auto Set the MinTypeNameLength option to an impossibly high value in order to limit the diagnostics to iterators. Leave new expressions and cast expressions for later. diff --git a/.clang-tidy b/.clang-tidy index a6378e0..a240e9c 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -12,7 +12,6 @@ misc-*,\ modernize-*,\ -modernize-avoid-c-arrays,\ -modernize-deprecated-headers,\ --modernize-use-auto,\ -modernize-use-nodiscard,\ -modernize-use-noexcept,\ -modernize-use-transparent-functors,\ @@ -33,4 +32,6 @@ CheckOptions: value: '1' - key: modernize-use-equals-default.IgnoreMacros value: '0' + - key: modernize-use-auto.MinTypeNameLength + value: '80' ... diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index d1ffcef..94530c1 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -77,8 +77,7 @@ int cmCPackIFWGenerator::PackageFiles() if (!this->OnlineOnly && !this->DownloadedPackages.empty()) { ifwCmd.emplace_back("-i"); - std::set::iterator it = - this->DownloadedPackages.begin(); + auto it = this->DownloadedPackages.begin(); ifwArg = (*it)->Name; ++it; while (it != this->DownloadedPackages.end()) { @@ -137,8 +136,7 @@ int cmCPackIFWGenerator::PackageFiles() if (!this->Installer.Resources.empty()) { ifwCmd.emplace_back("-r"); - std::vector::iterator it = - this->Installer.Resources.begin(); + auto it = this->Installer.Resources.begin(); std::string path = this->toplevel + "/resources/"; ifwArg = path + *it; ++it; @@ -180,8 +178,7 @@ int cmCPackIFWGenerator::PackageFiles() } else if (!this->DownloadedPackages.empty() && !this->Installer.RemoteRepositories.empty()) { ifwCmd.emplace_back("-e"); - std::set::iterator it = - this->DownloadedPackages.begin(); + auto it = this->DownloadedPackages.begin(); ifwArg = (*it)->Name; ++it; while (it != this->DownloadedPackages.end()) { @@ -193,14 +190,13 @@ int cmCPackIFWGenerator::PackageFiles() ifwCmd.emplace_back("-i"); ifwArg.clear(); // Binary - std::set::iterator bit = - this->BinaryPackages.begin(); + auto bit = this->BinaryPackages.begin(); while (bit != this->BinaryPackages.end()) { ifwArg += (*bit)->Name + ","; ++bit; } // Depend - DependenceMap::iterator it = this->DependentPackages.begin(); + auto it = this->DependentPackages.begin(); ifwArg += it->second.Name; ++it; while (it != this->DependentPackages.end()) { @@ -410,7 +406,7 @@ std::string cmCPackIFWGenerator::GetComponentInstallDirNameSuffix( cmCPackComponent* cmCPackIFWGenerator::GetComponent( const std::string& projectName, const std::string& componentName) { - ComponentsMap::iterator cit = this->Components.find(componentName); + auto cit = this->Components.find(componentName); if (cit != this->Components.end()) { return &(cit->second); } @@ -422,7 +418,7 @@ cmCPackComponent* cmCPackIFWGenerator::GetComponent( } std::string name = this->GetComponentPackageName(component); - PackagesMap::iterator pit = this->Packages.find(name); + auto pit = this->Packages.find(name); if (pit != this->Packages.end()) { return component; } @@ -462,7 +458,7 @@ cmCPackComponentGroup* cmCPackIFWGenerator::GetComponentGroup( } std::string name = this->GetGroupPackageName(group); - PackagesMap::iterator pit = this->Packages.find(name); + auto pit = this->Packages.find(name); if (pit != this->Packages.end()) { return group; } @@ -593,23 +589,21 @@ std::string cmCPackIFWGenerator::GetComponentPackageName( cmCPackIFWPackage* cmCPackIFWGenerator::GetGroupPackage( cmCPackComponentGroup* group) const { - std::map::const_iterator pit = - this->GroupPackages.find(group); + auto pit = this->GroupPackages.find(group); return pit != this->GroupPackages.end() ? pit->second : nullptr; } cmCPackIFWPackage* cmCPackIFWGenerator::GetComponentPackage( cmCPackComponent* component) const { - std::map::const_iterator pit = - this->ComponentPackages.find(component); + auto pit = this->ComponentPackages.find(component); return pit != this->ComponentPackages.end() ? pit->second : nullptr; } cmCPackIFWRepository* cmCPackIFWGenerator::GetRepository( const std::string& repositoryName) { - RepositoriesMap::iterator rit = this->Repositories.find(repositoryName); + auto rit = this->Repositories.find(repositoryName); if (rit != this->Repositories.end()) { return &(rit->second); } diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx index fb75145..5fa8cce 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.cxx +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -620,7 +620,7 @@ void cmCPackIFWPackage::GeneratePackageFile() // Write dependencies if (!compDepSet.empty()) { std::ostringstream dependencies; - std::set::iterator it = compDepSet.begin(); + auto it = compDepSet.begin(); dependencies << it->NameWithCompare(); ++it; while (it != compDepSet.end()) { @@ -638,7 +638,7 @@ void cmCPackIFWPackage::GeneratePackageFile() // Write automatic dependency on if (!compAutoDepSet.empty()) { std::ostringstream dependencies; - std::set::iterator it = compAutoDepSet.begin(); + auto it = compAutoDepSet.begin(); dependencies << it->NameWithCompare(); ++it; while (it != compAutoDepSet.end()) { @@ -674,7 +674,7 @@ void cmCPackIFWPackage::GeneratePackageFile() // Replaces if (!this->Replaces.empty()) { std::ostringstream replaces; - std::vector::iterator it = this->Replaces.begin(); + auto it = this->Replaces.begin(); replaces << *it; ++it; while (it != this->Replaces.end()) { diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index 4d41049..a564eb1 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -158,8 +158,7 @@ cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator( cmCPackGenerator* cmCPackGeneratorFactory::NewGeneratorInternal( const std::string& name) { - cmCPackGeneratorFactory::t_GeneratorCreatorsMap::iterator it = - this->GeneratorCreators.find(name); + auto it = this->GeneratorCreators.find(name); if (it == this->GeneratorCreators.end()) { return nullptr; } diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index 0f621cc..e8728a3 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -184,8 +184,7 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup) // The default behavior is to have one package by component group // unless CPACK_COMPONENTS_IGNORE_GROUP is specified. if (!ignoreGroup) { - std::map::iterator mainCompGIt = - this->ComponentGroups.end(); + auto mainCompGIt = this->ComponentGroups.end(); std::map::iterator compGIt; for (compGIt = this->ComponentGroups.begin(); @@ -206,8 +205,7 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup) retval &= PackageOnePack(initialTopLevel, compGIt->first); } // Handle Orphan components (components not belonging to any groups) - std::map::iterator mainCompIt = - this->Components.end(); + auto mainCompIt = this->Components.end(); std::map::iterator compIt; for (compIt = this->Components.begin(); compIt != this->Components.end(); ++compIt) { @@ -251,8 +249,7 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup) // CPACK_COMPONENTS_IGNORE_GROUPS is set // We build 1 package per component else { - std::map::iterator mainCompIt = - this->Components.end(); + auto mainCompIt = this->Components.end(); std::map::iterator compIt; for (compIt = this->Components.begin(); compIt != this->Components.end(); diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 772fa47..d9dd931 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -1830,9 +1830,8 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch( return 0; } std::map fileMap; - std::vector::iterator fp = filesFullPath.begin(); - for (std::vector::iterator f = files.begin(); f != files.end(); - ++f, ++fp) { + auto fp = filesFullPath.begin(); + for (auto f = files.begin(); f != files.end(); ++f, ++fp) { fileMap[*f] = *fp; } @@ -1870,7 +1869,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch( this->StartCoverageLogXML(covLogXML); count++; // move on one } - std::map::iterator i = fileMap.find(file); + auto i = fileMap.find(file); // if the file should be covered write out the header for that file if (i != fileMap.end()) { // we have a new file so count it in the output @@ -2202,7 +2201,7 @@ bool cmCTestCoverageHandler::ParseBullsEyeCovsrcLine( int cmCTestCoverageHandler::GetLabelId(std::string const& label) { - LabelIdMapType::iterator i = this->LabelIdMap.find(label); + auto i = this->LabelIdMap.find(label); if (i == this->LabelIdMap.end()) { int n = int(this->Labels.size()); this->Labels.push_back(label); @@ -2273,7 +2272,7 @@ void cmCTestCoverageHandler::LoadLabels(const char* dir) void cmCTestCoverageHandler::WriteXMLLabels(cmXMLWriter& xml, std::string const& source) { - LabelMapType::const_iterator li = this->SourceLabels.find(source); + auto li = this->SourceLabels.find(source); if (li != this->SourceLabels.end() && !li->second.empty()) { xml.StartElement("Labels"); for (auto const& ls : li->second) { @@ -2316,7 +2315,7 @@ bool cmCTestCoverageHandler::IsFilteredOut(std::string const& source) // The source is filtered out if it does not have any labels in // common with the filter set. std::string shortSrc = this->CTest->GetShortPathToFile(source.c_str()); - LabelMapType::const_iterator li = this->SourceLabels.find(shortSrc); + auto li = this->SourceLabels.find(shortSrc); if (li != this->SourceLabels.end()) { return !this->IntersectsFilter(li->second); } diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx index d3020b5..cc0b4ed 100644 --- a/Source/CTest/cmCTestGenericHandler.cxx +++ b/Source/CTest/cmCTestGenericHandler.cxx @@ -23,8 +23,7 @@ cmCTestGenericHandler::~cmCTestGenericHandler() = default; void cmCTestGenericHandler::SetOption(const std::string& op, const char* value) { if (!value) { - cmCTestGenericHandler::t_StringToString::iterator remit = - this->Options.find(op); + auto remit = this->Options.find(op); if (remit != this->Options.end()) { this->Options.erase(remit); } @@ -39,8 +38,7 @@ void cmCTestGenericHandler::SetPersistentOption(const std::string& op, { this->SetOption(op, value); if (!value) { - cmCTestGenericHandler::t_StringToString::iterator remit = - this->PersistentOptions.find(op); + auto remit = this->PersistentOptions.find(op); if (remit != this->PersistentOptions.end()) { this->PersistentOptions.erase(remit); } @@ -62,8 +60,7 @@ void cmCTestGenericHandler::Initialize() const char* cmCTestGenericHandler::GetOption(const std::string& op) { - cmCTestGenericHandler::t_StringToString::iterator remit = - this->Options.find(op); + auto remit = this->Options.find(op); if (remit == this->Options.end()) { return nullptr; } diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index 9bca7cb..08c850d 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -146,8 +146,7 @@ private: cmCTestP4::User cmCTestP4::GetUserData(const std::string& username) { - std::map::const_iterator it = - Users.find(username); + auto it = Users.find(username); if (it == Users.end()) { std::vector p4_users; diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 23c6b0d..c5bb826 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -571,8 +571,7 @@ bool cmCTestRunTest::StartTest(size_t completed, size_t total) void cmCTestRunTest::ComputeArguments() { this->Arguments.clear(); // reset because this might be a rerun - std::vector::const_iterator j = - this->TestProperties->Args.begin(); + auto j = this->TestProperties->Args.begin(); ++j; // skip test name // find the test executable if (this->TestHandler->MemCheck) { diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index 6d8077f..a945111 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -169,7 +169,7 @@ void cmCTestSVN::GuessBase(SVNInfo& svninfo, slash = svninfo.URL.find('/', slash + 1)) { // If the URL suffix is a prefix of at least one path then it is the base. std::string base = cmCTest::DecodeURL(svninfo.URL.substr(slash)); - for (std::vector::const_iterator ci = changes.begin(); + for (auto ci = changes.begin(); svninfo.Base.empty() && ci != changes.end(); ++ci) { if (cmCTestSVNPathStarts(ci->Path, base)) { svninfo.Base = base; diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index f67b11a..2ece411 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -690,8 +690,7 @@ void cmCTestTestHandler::PrintLabelOrSubprojectSummary(bool doSubProject) for (std::string const& l : p.Labels) { // first check to see if the current label is a subproject label bool isSubprojectLabel = false; - std::vector::iterator subproject = - std::find(subprojects.begin(), subprojects.end(), l); + auto subproject = std::find(subprojects.begin(), subprojects.end(), l); if (subproject != subprojects.end()) { isSubprojectLabel = true; } @@ -945,8 +944,7 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const FixtureDependencies fixtureSetups; FixtureDependencies fixtureCleanups; - for (ListOfTests::const_iterator it = this->TestList.begin(); - it != this->TestList.end(); ++it) { + for (auto it = this->TestList.begin(); it != this->TestList.end(); ++it) { const cmCTestTestProperties& p = *it; for (std::string const& deps : p.FixturesSetup) { @@ -1007,8 +1005,7 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const // cleanup tests depend on this test case later. std::pair setupRange = fixtureSetups.equal_range(requiredFixtureName); - for (FixtureDepsIterator sIt = setupRange.first; - sIt != setupRange.second; ++sIt) { + for (auto sIt = setupRange.first; sIt != setupRange.second; ++sIt) { const std::string& setupTestName = sIt->second->Name; tests[i].RequireSuccessDepends.insert(setupTestName); if (!cmContains(tests[i].Depends, setupTestName)) { @@ -1031,8 +1028,7 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const !excludeSetupRegex.find(requiredFixtureName)) { std::pair fixtureRange = fixtureSetups.equal_range(requiredFixtureName); - for (FixtureDepsIterator it = fixtureRange.first; - it != fixtureRange.second; ++it) { + for (auto it = fixtureRange.first; it != fixtureRange.second; ++it) { ListOfTests::const_iterator lotIt = it->second; const cmCTestTestProperties& p = *lotIt; @@ -1063,8 +1059,7 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const !excludeCleanupRegex.find(requiredFixtureName)) { std::pair fixtureRange = fixtureCleanups.equal_range(requiredFixtureName); - for (FixtureDepsIterator it = fixtureRange.first; - it != fixtureRange.second; ++it) { + for (auto it = fixtureRange.first; it != fixtureRange.second; ++it) { ListOfTests::const_iterator lotIt = it->second; const cmCTestTestProperties& p = *lotIt; @@ -1112,8 +1107,7 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const // This cleanup test could be part of the original test list that was // passed in. It is then possible that no other test requires the // fIt fixture, so we have to check for this. - std::map>::const_iterator cIt = - fixtureRequirements.find(fixture); + auto cIt = fixtureRequirements.find(fixture); if (cIt != fixtureRequirements.end()) { const std::vector& indices = cIt->second; for (size_t index : indices) { @@ -1819,8 +1813,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformation(size_t numTests) std::sort(this->TestsToRun.begin(), this->TestsToRun.end(), std::less()); // remove duplicates - std::vector::iterator new_end = - std::unique(this->TestsToRun.begin(), this->TestsToRun.end()); + auto new_end = std::unique(this->TestsToRun.begin(), this->TestsToRun.end()); this->TestsToRun.erase(new_end, this->TestsToRun.end()); } @@ -2257,8 +2250,7 @@ bool cmCTestTestHandler::SetTestsProperties( // sort the array std::sort(rt.Labels.begin(), rt.Labels.end()); // remove duplicates - std::vector::iterator new_end = - std::unique(rt.Labels.begin(), rt.Labels.end()); + auto new_end = std::unique(rt.Labels.begin(), rt.Labels.end()); rt.Labels.erase(new_end, rt.Labels.end()); } if (key == "MEASUREMENT") { @@ -2337,8 +2329,7 @@ bool cmCTestTestHandler::SetDirectoryProperties( // sort the array std::sort(rt.Labels.begin(), rt.Labels.end()); // remove duplicates - std::vector::iterator new_end = - std::unique(rt.Labels.begin(), rt.Labels.end()); + auto new_end = std::unique(rt.Labels.begin(), rt.Labels.end()); rt.Labels.erase(new_end, rt.Labels.end()); } } diff --git a/Source/CTest/cmParseCacheCoverage.cxx b/Source/CTest/cmParseCacheCoverage.cxx index cd2bb1a..b3ef7d3 100644 --- a/Source/CTest/cmParseCacheCoverage.cxx +++ b/Source/CTest/cmParseCacheCoverage.cxx @@ -47,8 +47,7 @@ void cmParseCacheCoverage::RemoveUnCoveredFiles() { // loop over the coverage data computed and remove all files // that only have -1 or 0 for the lines. - cmCTestCoverageHandlerContainer::TotalCoverageMap::iterator ci = - this->Coverage.TotalCoverage.begin(); + auto ci = this->Coverage.TotalCoverage.begin(); while (ci != this->Coverage.TotalCoverage.end()) { cmCTestCoverageHandlerContainer::SingleFileCoverageVector& v = ci->second; bool nothing = true; diff --git a/Source/CTest/cmParseMumpsCoverage.cxx b/Source/CTest/cmParseMumpsCoverage.cxx index afd7dc3..596b72e 100644 --- a/Source/CTest/cmParseMumpsCoverage.cxx +++ b/Source/CTest/cmParseMumpsCoverage.cxx @@ -123,8 +123,7 @@ bool cmParseMumpsCoverage::LoadPackages(const char* d) bool cmParseMumpsCoverage::FindMumpsFile(std::string const& routine, std::string& filepath) { - std::map::iterator i = - this->RoutineToDirectory.find(routine); + auto i = this->RoutineToDirectory.find(routine); if (i != this->RoutineToDirectory.end()) { filepath = i->second; return true; diff --git a/Source/QtDialog/FirstConfigure.cxx b/Source/QtDialog/FirstConfigure.cxx index d9a8aff..0f09d7c 100644 --- a/Source/QtDialog/FirstConfigure.cxx +++ b/Source/QtDialog/FirstConfigure.cxx @@ -107,8 +107,7 @@ void StartCompilerSetup::setGenerators( ->GeneratorDefaultPlatform[QString::fromLocal8Bit(gen.name.c_str())] = QString::fromLocal8Bit(gen.defaultPlatform.c_str()); - std::vector::const_iterator platformIt = - gen.supportedPlatforms.cbegin(); + auto platformIt = gen.supportedPlatforms.cbegin(); while (platformIt != gen.supportedPlatforms.cend()) { this->GeneratorSupportedPlatforms.insert( diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index f1264d5..1a87028 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -20,7 +20,7 @@ bool cmAddExecutableCommand(std::vector const& args, } cmMakefile& mf = status.GetMakefile(); - std::vector::const_iterator s = args.begin(); + auto s = args.begin(); std::string const& exename = *s; diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index c067aea..dc8937a 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -34,7 +34,7 @@ bool cmAddLibraryCommand(std::vector const& args, bool importTarget = false; bool importGlobal = false; - std::vector::const_iterator s = args.begin(); + auto s = args.begin(); std::string const& libName = *s; diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h index 6775f9d..60b746c 100644 --- a/Source/cmAlgorithms.h +++ b/Source/cmAlgorithms.h @@ -165,14 +165,14 @@ typename Range::const_iterator cmRemoveIndices(Range& r, InputRange const& rem) { typename InputRange::const_iterator remIt = rem.begin(); typename InputRange::const_iterator remEnd = rem.end(); - const typename Range::iterator rangeEnd = r.end(); + const auto rangeEnd = r.end(); if (remIt == remEnd) { return rangeEnd; } - typename Range::iterator writer = r.begin(); + auto writer = r.begin(); std::advance(writer, *remIt); - typename Range::iterator pivot = writer; + auto pivot = writer; typename InputRange::value_type prevRem = *remIt; ++remIt; size_t count = 1; diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index e814d67..f19d99b 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -531,7 +531,7 @@ void CCONV* cmGetSource(void* arg, const char* name) cmMakefile* mf = static_cast(arg); if (cmSourceFile* rsf = mf->GetSource(name)) { // Lookup the proxy source file object for this source. - cmCPluginAPISourceFileMap::iterator i = cmCPluginAPISourceFiles.find(rsf); + auto i = cmCPluginAPISourceFiles.find(rsf); if (i == cmCPluginAPISourceFiles.end()) { // Create a proxy source file object for this source. cmCPluginAPISourceFile* sf = new cmCPluginAPISourceFile; diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index f51ed0b..cd54770 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1483,8 +1483,7 @@ std::vector cmCTest::GetLabelsForSubprojects() // sort the array std::sort(subprojects.begin(), subprojects.end()); // remove duplicates - std::vector::iterator new_end = - std::unique(subprojects.begin(), subprojects.end()); + auto new_end = std::unique(subprojects.begin(), subprojects.end()); subprojects.erase(new_end, subprojects.end()); return subprojects; diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 4c8c224..e28107f 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -480,7 +480,7 @@ void cmCacheManager::OutputNewlineTruncationWarning(std::ostream& fout, void cmCacheManager::RemoveCacheEntry(const std::string& key) { - CacheEntryMap::iterator i = this->Cache.find(key); + auto i = this->Cache.find(key); if (i != this->Cache.end()) { this->Cache.erase(i); } @@ -489,7 +489,7 @@ void cmCacheManager::RemoveCacheEntry(const std::string& key) cmCacheManager::CacheEntry* cmCacheManager::GetCacheEntry( const std::string& key) { - CacheEntryMap::iterator i = this->Cache.find(key); + auto i = this->Cache.find(key); if (i != this->Cache.end()) { return &i->second; } @@ -504,7 +504,7 @@ cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator(const char* key) const std::string* cmCacheManager::GetInitializedCacheValue( const std::string& key) const { - CacheEntryMap::const_iterator i = this->Cache.find(key); + auto i = this->Cache.find(key); if (i != this->Cache.end() && i->second.Initialized) { return &i->second.Value; } diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 54443f2..33286ad 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -96,7 +96,7 @@ void cmCommonTargetGenerator::AppendFortranFormatFlags( std::string cmCommonTargetGenerator::GetFlags(const std::string& l) { - ByLanguageMap::iterator i = this->FlagsByLanguage.find(l); + auto i = this->FlagsByLanguage.find(l); if (i == this->FlagsByLanguage.end()) { std::string flags; @@ -111,7 +111,7 @@ std::string cmCommonTargetGenerator::GetFlags(const std::string& l) std::string cmCommonTargetGenerator::GetDefines(const std::string& l) { - ByLanguageMap::iterator i = this->DefinesByLanguage.find(l); + auto i = this->DefinesByLanguage.find(l); if (i == this->DefinesByLanguage.end()) { std::set defines; this->LocalCommonGenerator->GetTargetDefines(this->GeneratorTarget, @@ -128,7 +128,7 @@ std::string cmCommonTargetGenerator::GetDefines(const std::string& l) std::string cmCommonTargetGenerator::GetIncludes(std::string const& l) { - ByLanguageMap::iterator i = this->IncludesByLanguage.find(l); + auto i = this->IncludesByLanguage.find(l); if (i == this->IncludesByLanguage.end()) { std::string includes; this->AddIncludeFlags(includes, l); diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index a39425c..15b0087 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -283,8 +283,7 @@ std::map::iterator cmComputeLinkDepends::AllocateLinkEntry( { std::map::value_type index_entry( item, static_cast(this->EntryList.size())); - std::map::iterator lei = - this->LinkEntryIndex.insert(index_entry).first; + auto lei = this->LinkEntryIndex.insert(index_entry).first; this->EntryList.emplace_back(); this->InferredDependSets.push_back(nullptr); this->EntryConstraintGraph.emplace_back(); @@ -294,7 +293,7 @@ std::map::iterator cmComputeLinkDepends::AllocateLinkEntry( int cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item) { // Check if the item entry has already been added. - std::map::iterator lei = this->LinkEntryIndex.find(item); + auto lei = this->LinkEntryIndex.find(item); if (lei != this->LinkEntryIndex.end()) { // Yes. We do not need to follow the item's dependencies again. return lei->second; @@ -394,8 +393,7 @@ void cmComputeLinkDepends::QueueSharedDependencies( void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) { // Check if the target already has an entry. - std::map::iterator lei = - this->LinkEntryIndex.find(dep.Item); + auto lei = this->LinkEntryIndex.find(dep.Item); if (lei == this->LinkEntryIndex.end()) { // Allocate a spot for the item entry. lei = this->AllocateLinkEntry(dep.Item); @@ -719,8 +717,7 @@ void cmComputeLinkDepends::VisitEntry(int index) // This entry has now been seen. Update its component. bool completed = false; int component = this->CCG->GetComponentMap()[index]; - std::map::iterator mi = - this->PendingComponents.find(this->ComponentOrder[component]); + auto mi = this->PendingComponents.find(this->ComponentOrder[component]); if (mi != this->PendingComponents.end()) { // The entry is in an already pending component. PendingComponent& pc = mi->second; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index dd8d246..ade0f87 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1332,8 +1332,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, std::string const& file) { // Do not depend on things that do not exist. - std::vector::iterator i = - std::find(this->Depends.begin(), this->Depends.end(), item); + auto i = std::find(this->Depends.begin(), this->Depends.end(), item); if (i != this->Depends.end()) { this->Depends.erase(i); } diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 6bf2f2d..de82782 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -140,8 +140,7 @@ void cmComputeTargetDepends::GetTargetDirectDepends(cmGeneratorTarget const* t, { // Lookup the index for this target. All targets should be known by // this point. - std::map::const_iterator tii = - this->TargetIndex.find(t); + auto tii = this->TargetIndex.find(t); assert(tii != this->TargetIndex.end()); int i = tii->second; @@ -149,7 +148,7 @@ void cmComputeTargetDepends::GetTargetDirectDepends(cmGeneratorTarget const* t, EdgeList const& nl = this->FinalGraph[i]; for (cmGraphEdge const& ni : nl) { cmGeneratorTarget const* dep = this->Targets[ni]; - cmTargetDependSet::iterator di = deps.insert(dep).first; + auto di = deps.insert(dep).first; di->SetType(ni.IsStrong()); di->SetBacktrace(ni.GetBacktrace()); } @@ -368,8 +367,7 @@ void cmComputeTargetDepends::AddTargetDepend( } else { // Lookup the index for this target. All targets should be known by // this point. - std::map::const_iterator tii = - this->TargetIndex.find(dependee); + auto tii = this->TargetIndex.find(dependee); assert(tii != this->TargetIndex.end()); int dependee_index = tii->second; diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 21df278..97469be 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -367,7 +367,7 @@ bool cmConditionEvaluator::HandleLevel0(cmArgumentList& newArgs, int reducible; do { reducible = 0; - cmArgumentList::iterator arg = newArgs.begin(); + auto arg = newArgs.begin(); while (arg != newArgs.end()) { if (IsKeyword(keyParenL, *arg)) { // search for the closing paren for this opening one @@ -393,7 +393,7 @@ bool cmConditionEvaluator::HandleLevel0(cmArgumentList& newArgs, std::vector newArgs2; // copy to the list structure - cmArgumentList::iterator argP1 = arg; + auto argP1 = arg; argP1++; cmAppend(newArgs2, argP1, argClose); newArgs2.pop_back(); @@ -424,7 +424,7 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&, int reducible; do { reducible = 0; - cmArgumentList::iterator arg = newArgs.begin(); + auto arg = newArgs.begin(); cmArgumentList::iterator argP1; cmArgumentList::iterator argP2; while (arg != newArgs.end()) { @@ -524,7 +524,7 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs, const char* def2; do { reducible = 0; - cmArgumentList::iterator arg = newArgs.begin(); + auto arg = newArgs.begin(); cmArgumentList::iterator argP1; cmArgumentList::iterator argP2; while (arg != newArgs.end()) { @@ -700,7 +700,7 @@ bool cmConditionEvaluator::HandleLevel3(cmArgumentList& newArgs, int reducible; do { reducible = 0; - cmArgumentList::iterator arg = newArgs.begin(); + auto arg = newArgs.begin(); cmArgumentList::iterator argP1; cmArgumentList::iterator argP2; while (arg != newArgs.end()) { @@ -728,7 +728,7 @@ bool cmConditionEvaluator::HandleLevel4(cmArgumentList& newArgs, bool rhs; do { reducible = 0; - cmArgumentList::iterator arg = newArgs.begin(); + auto arg = newArgs.begin(); cmArgumentList::iterator argP1; cmArgumentList::iterator argP2; while (arg != newArgs.end()) { diff --git a/Source/cmCreateTestSourceList.cxx b/Source/cmCreateTestSourceList.cxx index 4a1825f..da23519 100644 --- a/Source/cmCreateTestSourceList.cxx +++ b/Source/cmCreateTestSourceList.cxx @@ -20,7 +20,7 @@ bool cmCreateTestSourceList::InitialPass(std::vector const& args, return false; } - std::vector::const_iterator i = args.begin(); + auto i = args.begin(); std::string extraInclude; std::string function; std::vector tests; @@ -67,7 +67,7 @@ bool cmCreateTestSourceList::InitialPass(std::vector const& args, configFile += "/Templates/TestDriver.cxx.in"; // Create the test driver file - std::vector::const_iterator testsBegin = i; + auto testsBegin = i; std::vector tests_func_name; // The rest of the arguments consist of a list of test source files. diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx index 06a442b..e8f6faf 100644 --- a/Source/cmDepends.cxx +++ b/Source/cmDepends.cxx @@ -33,8 +33,7 @@ bool cmDepends::Write(std::ostream& makeDepends, std::ostream& internalDepends) cmMakefile* mf = this->LocalGenerator->GetMakefile(); cmExpandList(mf->GetSafeDefinition(srcLang), pairs); } - for (std::vector::iterator si = pairs.begin(); - si != pairs.end();) { + for (auto si = pairs.begin(); si != pairs.end();) { // Get the source and object file. std::string const& src = *si++; if (si == pairs.end()) { diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index 0f9f166..a380b41 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -438,8 +438,7 @@ void cmDependsC::TransformLine(std::string& line) if (!this->IncludeRegexTransform.find(line)) { return; } - TransformRulesType::const_iterator tri = - this->TransformRules.find(this->IncludeRegexTransform.match(3)); + auto tri = this->TransformRules.find(this->IncludeRegexTransform.match(3)); if (tri == this->TransformRules.end()) { return; } diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index c30e0bf..b657ff7 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -56,8 +56,7 @@ public: cmFortranSourceInfo& CreateObjectInfo(const std::string& obj, const std::string& src) { - std::map::iterator i = - this->ObjectInfo.find(obj); + auto i = this->ObjectInfo.find(obj); if (i == this->ObjectInfo.end()) { std::map::value_type entry( obj, cmFortranSourceInfo()); @@ -303,9 +302,7 @@ void cmDependsFortran::ConsiderModule(const std::string& name, const std::string& stampDir) { // Locate each required module. - using TargetRequiresMap = cmDependsFortranInternals::TargetRequiresMap; - TargetRequiresMap::iterator required = - this->Internal->TargetRequires.find(name); + auto required = this->Internal->TargetRequires.find(name); if (required != this->Internal->TargetRequires.end() && required->second.empty()) { // The module is provided by a CMake target. It will have a stamp file. @@ -321,8 +318,6 @@ bool cmDependsFortran::WriteDependenciesReal(std::string const& obj, std::ostream& makeDepends, std::ostream& internalDepends) { - using TargetRequiresMap = cmDependsFortranInternals::TargetRequiresMap; - // Get the source file for this object. std::string const& src = info.Source; @@ -350,8 +345,7 @@ bool cmDependsFortran::WriteDependenciesReal(std::string const& obj, // The object file should depend on timestamped files for the // modules it uses. - TargetRequiresMap::const_iterator required = - this->Internal->TargetRequires.find(i); + auto required = this->Internal->TargetRequires.find(i); if (required == this->Internal->TargetRequires.end()) { abort(); } diff --git a/Source/cmDynamicLoader.cxx b/Source/cmDynamicLoader.cxx index 0549cf9..0b72a94 100644 --- a/Source/cmDynamicLoader.cxx +++ b/Source/cmDynamicLoader.cxx @@ -39,8 +39,7 @@ void cmDynamicLoaderCache::CacheFile(const char* path, bool cmDynamicLoaderCache::GetCacheFile(const char* path, cmsys::DynamicLoader::LibraryHandle& p) { - std::map::iterator it = - this->CacheMap.find(path); + auto it = this->CacheMap.find(path); if (it != this->CacheMap.end()) { p = it->second; return true; @@ -50,8 +49,7 @@ bool cmDynamicLoaderCache::GetCacheFile(const char* path, bool cmDynamicLoaderCache::FlushCache(const char* path) { - std::map::iterator it = - this->CacheMap.find(path); + auto it = this->CacheMap.find(path); bool ret = false; if (it != this->CacheMap.end()) { cmsys::DynamicLoader::CloseLibrary(it->second); diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index 648a900..90250b6 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -585,8 +585,7 @@ cmELF::StringEntry const* cmELFInternalImpl::GetDynamicSectionString( unsigned int tag) { // Short-circuit if already checked. - std::map::iterator dssi = - this->DynamicSectionStrings.find(tag); + auto dssi = this->DynamicSectionStrings.find(tag); if (dssi != this->DynamicSectionStrings.end()) { if (dssi->second.Position > 0) { return &dssi->second; @@ -614,8 +613,7 @@ cmELF::StringEntry const* cmELFInternalImpl::GetDynamicSectionString( ELF_Shdr const& strtab = this->SectionHeaders[sec.sh_link]; // Look for the requested entry. - for (typename std::vector::iterator di = - this->DynamicSectionEntries.begin(); + for (auto di = this->DynamicSectionEntries.begin(); di != this->DynamicSectionEntries.end(); ++di) { ELF_Dyn& dyn = *di; if (static_cast(dyn.d_tag) == static_cast(tag)) { diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 70f98bf..9545814 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -1185,7 +1185,7 @@ void cmExportFileGenerator::GenerateImportedFileChecksCode( << targetName << " "; for (std::string const& li : importedLocations) { - ImportPropertyMap::const_iterator pi = properties.find(li); + auto pi = properties.find(li); if (pi != properties.end()) { os << cmExportFileGeneratorEscape(pi->second) << " "; } diff --git a/Source/cmExportSetMap.cxx b/Source/cmExportSetMap.cxx index 293e80c..5c3f84f 100644 --- a/Source/cmExportSetMap.cxx +++ b/Source/cmExportSetMap.cxx @@ -9,7 +9,7 @@ cmExportSet* cmExportSetMap::operator[](const std::string& name) { - std::map::iterator it = this->find(name); + auto it = this->find(name); if (it == this->end()) // Export set not found { it = this->insert(std::make_pair(name, new cmExportSet(name))).first; diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 5a9c54c..5a5d959 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -573,8 +573,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget( cmAppend(allIncludeDirs, cmExpandedList(systemIncludeDirs)); } - std::vector::const_iterator end = - cmRemoveDuplicates(allIncludeDirs); + auto end = cmRemoveDuplicates(allIncludeDirs); for (std::string const& str : cmMakeRange(allIncludeDirs.cbegin(), end)) { xml.StartElement("Add"); diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index 0956729..5a01eb2 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -307,7 +307,7 @@ void cmExtraCodeLiteGenerator::FindMatchingHeaderfiles( for (std::string const& ext : headerExts) { std::string hname = cmStrCat(headerBasename, '.', ext); // if it's already in the set, don't check if it exists on disk - std::set::const_iterator headerIt = otherFiles.find(hname); + auto headerIt = otherFiles.find(hname); if (headerIt != otherFiles.end()) { break; } diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 43f1e12..d398018 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -800,7 +800,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const // the list must contain only definition-value pairs: if ((defs.size() % 2) == 0) { - std::vector::const_iterator di = defs.begin(); + auto di = defs.begin(); while (di != defs.end()) { std::string def = *di; ++di; @@ -832,7 +832,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const // the list must contain only definition-value pairs: if ((defs.size() % 2) == 0) { - std::vector::const_iterator di = defs.begin(); + auto di = defs.begin(); while (di != defs.end()) { std::string def = *di; ++di; diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 52ba968..6ad8609 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -242,7 +242,7 @@ void cmExtraSublimeTextGenerator::AppendTarget( target->GetSourceFiles(sourceFiles, makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); for (cmSourceFile* sourceFile : sourceFiles) { - MapSourceFileFlags::iterator sourceFileFlagsIter = + auto sourceFileFlagsIter = sourceFileFlags.find(sourceFile->ResolveFullPath()); if (sourceFileFlagsIter == sourceFileFlags.end()) { sourceFileFlagsIter = diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 3ac769c..6cff075 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -823,8 +823,7 @@ void Target::ProcessLanguage(std::string const& lang) Json::ArrayIndex Target::AddSourceGroup(cmSourceGroup* sg, Json::ArrayIndex si) { - std::unordered_map::iterator i = - this->SourceGroupsMap.find(sg); + auto i = this->SourceGroupsMap.find(sg); if (i == this->SourceGroupsMap.end()) { auto sgIndex = static_cast(this->SourceGroups.size()); i = this->SourceGroupsMap.emplace(sg, sgIndex).first; diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 36a7dc3..e8a7810 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -91,7 +91,7 @@ std::string fix_file_url_windows(const std::string& url) bool HandleWriteImpl(std::vector const& args, bool append, cmExecutionStatus& status) { - std::vector::const_iterator i = args.begin(); + auto i = args.begin(); i++; // Get rid of subcommand @@ -663,7 +663,7 @@ bool HandleGlobImpl(std::vector const& args, bool recurse, // File commands has at least one argument assert(args.size() > 1); - std::vector::const_iterator i = args.begin(); + auto i = args.begin(); i++; // Get rid of subcommand @@ -1585,7 +1585,7 @@ bool HandleDownloadCommand(std::vector const& args, cmExecutionStatus& status) { #if !defined(CMAKE_BOOTSTRAP) - std::vector::const_iterator i = args.begin(); + auto i = args.begin(); if (args.size() < 3) { status.SetError("DOWNLOAD must be called with at least three arguments."); return false; @@ -1955,7 +1955,7 @@ bool HandleUploadCommand(std::vector const& args, status.SetError("UPLOAD must be called with at least three arguments."); return false; } - std::vector::const_iterator i = args.begin(); + auto i = args.begin(); ++i; std::string filename = *i; ++i; diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 9132760..2edf67b 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -847,8 +847,7 @@ bool cmFindPackageCommand::HandlePackageMode( // If there are files in ConsideredConfigs, it means that FooConfig.cmake // have been found, but they didn't have appropriate versions. else if (!this->ConsideredConfigs.empty()) { - std::vector::const_iterator duplicate_end = - cmRemoveDuplicates(this->ConsideredConfigs); + auto duplicate_end = cmRemoveDuplicates(this->ConsideredConfigs); e << "Could not find a configuration file for package \"" << this->Name << "\" that " << (this->VersionExact ? "exactly matches" : "is compatible with") @@ -1080,7 +1079,7 @@ void cmFindPackageCommand::AppendToFoundProperty(bool found) std::string tmp = foundProp; cmExpandList(tmp, foundContents, false); - std::vector::iterator nameIt = + auto nameIt = std::find(foundContents.begin(), foundContents.end(), this->Name); if (nameIt != foundContents.end()) { foundContents.erase(nameIt); @@ -1094,7 +1093,7 @@ void cmFindPackageCommand::AppendToFoundProperty(bool found) std::string tmp = notFoundProp; cmExpandList(tmp, notFoundContents, false); - std::vector::iterator nameIt = + auto nameIt = std::find(notFoundContents.begin(), notFoundContents.end(), this->Name); if (nameIt != notFoundContents.end()) { notFoundContents.erase(nameIt); @@ -1199,8 +1198,7 @@ void cmFindPackageCommand::FillPrefixesPackageRoot() cmSearchPath& paths = this->LabeledPaths[PathLabel::PackageRoot]; // Add the PACKAGE_ROOT_PATH from each enclosing find_package call. - for (std::deque>::const_reverse_iterator pkgPaths = - this->Makefile->FindPackageRootPathStack.rbegin(); + for (auto pkgPaths = this->Makefile->FindPackageRootPathStack.rbegin(); pkgPaths != this->Makefile->FindPackageRootPathStack.rend(); ++pkgPaths) { for (std::string const& path : *pkgPaths) { diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index 9420541..fdc5e50 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -80,8 +80,7 @@ bool cmFunctionHelperCommand::operator()( // define ARGV and ARGN std::string argvDef = cmJoin(expandedArgs, ";"); - std::vector::const_iterator eit = - expandedArgs.begin() + (this->Args.size() - 1); + auto eit = expandedArgs.begin() + (this->Args.size() - 1); std::string argnDef = cmJoin(cmMakeRange(eit, expandedArgs.end()), ";"); makefile.AddDefinition("ARGV", argvDef); makefile.MarkVariableAsUsed("ARGV"); diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 32eb3cd..7bb6a63 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -370,9 +370,7 @@ bool cmGeneratorExpression::IsValidTargetName(const std::string& input) void cmCompiledGeneratorExpression::GetMaxLanguageStandard( const cmGeneratorTarget* tgt, std::map& mapping) { - using MapType = - std::map>; - MapType::const_iterator it = this->MaxLanguageStandard.find(tgt); + auto it = this->MaxLanguageStandard.find(tgt); if (it != this->MaxLanguageStandard.end()) { mapping = it->second; } diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index df2227f..dda0abc 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -59,8 +59,7 @@ void cmGeneratorExpressionDAGChecker::Initialize() TEST_TRANSITIVE_PROPERTY_METHOD) false)) // NOLINT(*) #undef TEST_TRANSITIVE_PROPERTY_METHOD { - std::map>::const_iterator - it = top->Seen.find(this->Target); + auto it = top->Seen.find(this->Target); if (it != top->Seen.end()) { const std::set& propSet = it->second; if (propSet.find(this->Property) != propSet.end()) { diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index 11c2dcc..eb43270 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -64,8 +64,7 @@ void cmGeneratorExpressionEvaluationFile::Generate( outputFileName = this->FixRelativePath(outputFileName, PathForOutput, lg); } - std::map::iterator it = - outputFiles.find(outputFileName); + auto it = outputFiles.find(outputFileName); if (it != outputFiles.end()) { if (it->second == outputContent) { diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 7442018..c1343b2 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -30,9 +30,7 @@ std::string GeneratorExpressionContent::ProcessArbitraryContent( { std::string result; - const std::vector< - std::vector>::const_iterator pend = - this->ParamChildren.end(); + const auto pend = this->ParamChildren.end(); for (; pit != pend; ++pit) { for (cmGeneratorExpressionEvaluator* pExprEval : *pit) { if (node->RequiresLiteralInput()) { @@ -116,11 +114,8 @@ std::string GeneratorExpressionContent::EvaluateParameters( { const int numExpected = node->NumExpectedParameters(); { - std::vector>::const_iterator - pit = this->ParamChildren.begin(); - const std::vector< - std::vector>::const_iterator pend = - this->ParamChildren.end(); + auto pit = this->ParamChildren.begin(); + const auto pend = this->ParamChildren.end(); const bool acceptsArbitraryContent = node->AcceptsArbitraryContentParameter(); int counter = 1; diff --git a/Source/cmGeneratorExpressionParser.cxx b/Source/cmGeneratorExpressionParser.cxx index e7effca..ba00b94 100644 --- a/Source/cmGeneratorExpressionParser.cxx +++ b/Source/cmGeneratorExpressionParser.cxx @@ -66,8 +66,7 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression( unsigned int nestedLevel = this->NestingLevel; ++this->NestingLevel; - std::vector::const_iterator startToken = - this->it - 1; + auto startToken = this->it - 1; std::vector identifier; while (this->it->TokenType != cmGeneratorExpressionToken::EndExpression && @@ -174,13 +173,9 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression( if (!parameters.empty()) { extendText(result, colonToken); - using EvaluatorVector = std::vector; - using TokenVector = std::vector; - std::vector::const_iterator pit = parameters.begin(); - const std::vector::const_iterator pend = - parameters.end(); - std::vector::const_iterator commaIt = - commaTokens.begin(); + auto pit = parameters.begin(); + const auto pend = parameters.end(); + auto commaIt = commaTokens.begin(); assert(parameters.size() > commaTokens.size()); for (; pit != pend; ++pit, ++commaIt) { if (!pit->empty() && !emptyParamTermination) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index fc7589e..134bd4a 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -204,9 +204,8 @@ void CreatePropertyGeneratorExpressions( std::vector& items, bool evaluateForBuildsystem = false) { - std::vector::const_iterator btIt = backtraces.begin(); - for (std::vector::const_iterator it = entries.begin(); - it != entries.end(); ++it, ++btIt) { + auto btIt = backtraces.begin(); + for (auto it = entries.begin(); it != entries.end(); ++it, ++btIt) { items.push_back( CreateTargetPropertyEntry(*it, *btIt, evaluateForBuildsystem)); } @@ -471,8 +470,7 @@ std::string cmGeneratorTarget::GetOutputName( { // Lookup/compute/cache the output name for this configuration. OutputNameKey key(config, artifact); - cmGeneratorTarget::OutputNameMapType::iterator i = - this->OutputNameMap.find(key); + auto i = this->OutputNameMap.find(key); if (i == this->OutputNameMap.end()) { // Add empty name in map to detect potential recursion. OutputNameMapType::value_type entry(key, ""); @@ -716,7 +714,7 @@ void cmGeneratorTarget::AddIncludeDirectory(const std::string& src, std::vector const* cmGeneratorTarget::GetSourceDepends( cmSourceFile const* sf) const { - SourceEntriesType::const_iterator i = this->SourceDepends.find(sf); + auto i = this->SourceDepends.find(sf); if (i != this->SourceDepends.end()) { return &i->second.Depends; } @@ -925,8 +923,7 @@ void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile const* sf) bool cmGeneratorTarget::HasExplicitObjectName(cmSourceFile const* file) const { const_cast(this)->ComputeObjectMapping(); - std::set::const_iterator it = - this->ExplicitObjectName.find(file); + auto it = this->ExplicitObjectName.find(file); return it != this->ExplicitObjectName.end(); } @@ -1108,8 +1105,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory( } using IncludeCacheType = std::map>; - IncludeCacheType::const_iterator iter = - this->SystemIncludesCache.find(config_upper); + auto iter = this->SystemIncludesCache.find(config_upper); if (iter == this->SystemIncludesCache.end()) { cmGeneratorExpressionDAGChecker dagChecker( @@ -1548,7 +1544,7 @@ cmGeneratorTarget::KindedSources const& cmGeneratorTarget::GetKindedSources( // Lookup any existing link implementation for this configuration. std::string const key = cmSystemTools::UpperCase(config); - KindedSourcesMapType::iterator it = this->KindedSourcesMap.find(key); + auto it = this->KindedSourcesMap.find(key); if (it != this->KindedSourcesMap.end()) { if (!it->second.Initialized) { std::ostringstream e; @@ -1680,8 +1676,7 @@ void cmGeneratorTarget::ComputeAllConfigSources() const for (size_t ci = 0; ci < configs.size(); ++ci) { KindedSources const& sources = this->GetKindedSources(configs[ci]); for (SourceAndKind const& src : sources.Sources) { - std::map::iterator mi = - index.find(src.Source.Value); + auto mi = index.find(src.Source.Value); if (mi == index.end()) { AllConfigSource acs; acs.Source = src.Source.Value; @@ -2292,7 +2287,7 @@ cmGeneratorTarget::LinkClosure const* cmGeneratorTarget::GetLinkClosure( const std::string& config) const { std::string key(cmSystemTools::UpperCase(config)); - LinkClosureMapType::iterator i = this->LinkClosureMap.find(key); + auto i = this->LinkClosureMap.find(key); if (i == this->LinkClosureMap.end()) { LinkClosure lc; this->ComputeLinkClosure(config, lc); @@ -2474,8 +2469,7 @@ cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo( if (!config.empty()) { config_upper = cmSystemTools::UpperCase(config); } - CompileInfoMapType::const_iterator i = - this->CompileInfoMap.find(config_upper); + auto i = this->CompileInfoMap.find(config_upper); if (i == this->CompileInfoMap.end()) { CompileInfo info; this->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); @@ -2500,8 +2494,7 @@ cmGeneratorTarget::GetModuleDefinitionInfo(std::string const& config) const if (!config.empty()) { config_upper = cmSystemTools::UpperCase(config); } - ModuleDefinitionInfoMapType::const_iterator i = - this->ModuleDefinitionInfoMap.find(config_upper); + auto i = this->ModuleDefinitionInfoMap.find(config_upper); if (i == this->ModuleDefinitionInfoMap.end()) { ModuleDefinitionInfo info; this->ComputeModuleDefinitionInfo(config, info); @@ -2712,7 +2705,7 @@ void cmTargetTraceDependencies::QueueSource(cmSourceFile* sf) void cmTargetTraceDependencies::FollowName(std::string const& name) { - NameMapType::iterator i = this->NameMap.find(name); + auto i = this->NameMap.find(name); if (i == this->NameMap.end()) { // Check if we know how to generate this file. cmSourceFile* sf = this->Makefile->GetSourceFileWithOutput(name); @@ -4260,8 +4253,7 @@ void cmGeneratorTarget::GetTargetObjectNames( for (cmSourceFile const* src : objectSources) { // Find the object file name corresponding to this source file. - std::map::const_iterator map_it = - mapping.find(src); + auto map_it = mapping.find(src); // It must exist because we populated the mapping just above. assert(!map_it->second.empty()); objects.push_back(map_it->second); @@ -4285,8 +4277,7 @@ cmGeneratorTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const { struct SourceFileFlags flags; this->ConstructSourceFileFlags(); - std::map::iterator si = - this->SourceFlagsMap.find(sf); + auto si = this->SourceFlagsMap.find(sf); if (si != this->SourceFlagsMap.end()) { flags = si->second; } else { @@ -4620,7 +4611,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( if (!prop.empty()) { // Use a sorted std::vector to keep the error message sorted. std::vector props; - std::set::const_iterator i = emittedBools.find(prop); + auto i = emittedBools.find(prop); if (i != emittedBools.end()) { props.push_back(strBool); } @@ -5065,7 +5056,7 @@ cmComputeLinkInformation* cmGeneratorTarget::GetLinkInformation( { // Lookup any existing information for this configuration. std::string key(cmSystemTools::UpperCase(config)); - cmTargetLinkInformationMap::iterator i = this->LinkInformation.find(key); + auto i = this->LinkInformation.find(key); if (i == this->LinkInformation.end()) { // Compute information for this configuration. cmComputeLinkInformation* info = @@ -5466,7 +5457,7 @@ cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo( if (!config.empty()) { config_upper = cmSystemTools::UpperCase(config); } - OutputInfoMapType::iterator i = this->OutputInfoMap.find(config_upper); + auto i = this->OutputInfoMap.find(config_upper); if (i == this->OutputInfoMap.end()) { // Add empty info in map to detect potential recursion. OutputInfo info; @@ -5865,7 +5856,7 @@ cmGeneratorTarget::ImportInfo const* cmGeneratorTarget::GetImportInfo( config_upper = "NOCONFIG"; } - ImportInfoMapType::const_iterator i = this->ImportInfoMap.find(config_upper); + auto i = this->ImportInfoMap.find(config_upper); if (i == this->ImportInfoMap.end()) { ImportInfo info; this->ComputeImportInfo(config_upper, info); @@ -6069,7 +6060,7 @@ bool cmGeneratorTarget::GetConfigCommonSourceFiles( std::vector const& configs = this->Makefile->GetGeneratorConfigs(); - std::vector::const_iterator it = configs.begin(); + auto it = configs.begin(); const std::string& firstConfig = *it; this->GetSourceFilesWithoutObjectLibraries(files, firstConfig); diff --git a/Source/cmGetDirectoryPropertyCommand.cxx b/Source/cmGetDirectoryPropertyCommand.cxx index d078a7a..64438d5 100644 --- a/Source/cmGetDirectoryPropertyCommand.cxx +++ b/Source/cmGetDirectoryPropertyCommand.cxx @@ -24,7 +24,7 @@ bool cmGetDirectoryPropertyCommand(std::vector const& args, return false; } - std::vector::const_iterator i = args.begin(); + auto i = args.begin(); std::string const& variable = *i; ++i; diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 658f65d..09ed76d 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -177,8 +177,7 @@ void cmGhsMultiTargetGenerator::WriteTargetSpecifics(std::ostream& fout, void cmGhsMultiTargetGenerator::SetCompilerFlags(std::string const& config, const std::string& language) { - std::map::iterator i = - this->FlagsByLanguage.find(language); + auto i = this->FlagsByLanguage.find(language); if (i == this->FlagsByLanguage.end()) { std::string flags; const char* lang = language.c_str(); @@ -209,8 +208,7 @@ void cmGhsMultiTargetGenerator::SetCompilerFlags(std::string const& config, std::string cmGhsMultiTargetGenerator::GetDefines(const std::string& language, std::string const& config) { - std::map::iterator i = - this->DefinesByLanguage.find(language); + auto i = this->DefinesByLanguage.find(language); if (i == this->DefinesByLanguage.end()) { std::set defines; const char* lang = language.c_str(); @@ -232,8 +230,7 @@ void cmGhsMultiTargetGenerator::WriteCompilerFlags(std::ostream& fout, std::string const&, const std::string& language) { - std::map::iterator flagsByLangI = - this->FlagsByLanguage.find(language); + auto flagsByLangI = this->FlagsByLanguage.find(language); if (flagsByLangI != this->FlagsByLanguage.end()) { if (!flagsByLangI->second.empty()) { std::vector ghsCompFlags = diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 22c304e..c7a0330 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -291,8 +291,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() // Sort the list and remove duplicates. std::sort(lfiles.begin(), lfiles.end(), std::less()); #if !defined(__VMS) // The Compaq STL on VMS crashes, so accept duplicates. - std::vector::iterator new_end = - std::unique(lfiles.begin(), lfiles.end()); + auto new_end = std::unique(lfiles.begin(), lfiles.end()); lfiles.erase(new_end, lfiles.end()); #endif diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 3dae824..af5d279 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -582,10 +582,8 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile( } // sort the array - std::sort(lfiles.begin(), lfiles.end(), std::less()); - std::vector::iterator new_end = - std::unique(lfiles.begin(), lfiles.end()); - lfiles.erase(new_end, lfiles.end()); + std::sort(lfiles.begin(), lfiles.end()); + lfiles.erase(std::unique(lfiles.begin(), lfiles.end()), lfiles.end()); cmake* cm = this->GetCMakeInstance(); if (cm->DoWriteGlobVerifyTarget()) { @@ -2629,8 +2627,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget( return nullptr; } - std::map::const_iterator const i = - this->XCodeObjectMap.find(t); + auto const i = this->XCodeObjectMap.find(t); if (i == this->XCodeObjectMap.end()) { return nullptr; } @@ -2910,8 +2907,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateOrGetPBXGroup( } target += gtgt->GetName(); s = cmStrCat(target, '/', sg->GetFullName()); - std::map::iterator it = - this->GroupNameMap.find(s); + auto it = this->GroupNameMap.find(s); if (it != this->GroupNameMap.end()) { return it->second; } @@ -2956,8 +2952,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateOrGetPBXGroup( std::string curr_folder = cmStrCat(target, '/'); for (auto const& folder : cmTokenize(sg->GetFullName(), "\\")) { curr_folder += folder; - std::map::iterator i_folder = - this->GroupNameMap.find(curr_folder); + auto const i_folder = this->GroupNameMap.find(curr_folder); // Create new folder if (i_folder == this->GroupNameMap.end()) { cmXCodeObject* group = this->CreatePBXGroup(tgroup, folder); @@ -3269,8 +3264,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( std::string trel = this->ConvertToRelativeForMake(tfull); // Add this target to the post-build phases of its dependencies. - std::map::const_iterator y = - target->GetDependTargets().find(configName); + auto const y = target->GetDependTargets().find(configName); if (y != target->GetDependTargets().end()) { for (auto const& deptgt : y->second) { makefileStream << this->PostBuildMakeTarget(deptgt, configName) @@ -3290,8 +3284,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( makefileStream << trel << ":"; // List dependencies if any exist. - std::map::const_iterator x = - target->GetDependLibraries().find(configName); + auto const x = target->GetDependLibraries().find(configName); if (x != target->GetDependLibraries().end()) { for (auto const& deplib : x->second) { std::string file = this->ConvertToRelativeForMake(deplib); diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 9b58f61..e0d545d 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -368,8 +368,7 @@ void cmGraphVizWriter::WriteConnections( const std::string& targetName, std::set& insertedNodes, std::set& insertedConnections, cmGeneratedFileStream& str) const { - std::map::const_iterator targetPtrIt = - this->TargetPtrs.find(targetName); + auto targetPtrIt = this->TargetPtrs.find(targetName); if (targetPtrIt == this->TargetPtrs.end()) // not found at all { @@ -390,8 +389,7 @@ void cmGraphVizWriter::WriteConnections( for (auto const& llit : ll) { const std::string& libName = llit.first; - std::map::const_iterator libNameIt = - this->TargetNamesNodes.find(libName); + auto libNameIt = this->TargetNamesNodes.find(libName); // can happen e.g. if GRAPHVIZ_TARGET_IGNORE_REGEX is used if (libNameIt == this->TargetNamesNodes.end()) { @@ -419,8 +417,7 @@ void cmGraphVizWriter::WriteDependerConnections( const std::string& targetName, std::set& insertedNodes, std::set& insertedConnections, cmGeneratedFileStream& str) const { - std::map::const_iterator targetPtrIt = - this->TargetPtrs.find(targetName); + auto targetPtrIt = this->TargetPtrs.find(targetName); if (targetPtrIt == this->TargetPtrs.end()) // not found at all { @@ -454,8 +451,7 @@ void cmGraphVizWriter::WriteDependerConnections( for (auto const& llit : ll) { if (llit.first == targetName) { // So this target links against targetName. - std::map::const_iterator dependerNodeNameIt = - this->TargetNamesNodes.find(tptr.first); + auto dependerNodeNameIt = this->TargetNamesNodes.find(tptr.first); if (dependerNodeNameIt != this->TargetNamesNodes.end()) { std::string connectionName = @@ -487,8 +483,7 @@ void cmGraphVizWriter::WriteNode(const std::string& targetName, { if (insertedNodes.find(targetName) == insertedNodes.end()) { insertedNodes.insert(targetName); - std::map::const_iterator nameIt = - this->TargetNamesNodes.find(targetName); + auto nameIt = this->TargetNamesNodes.find(targetName); str << " \"" << nameIt->second << "\" [ label=\"" << targetName << "\" shape=\"" << getShapeForTarget(target) << "\"];" << std::endl; @@ -556,8 +551,7 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt) } } - std::map::const_iterator tarIt = - this->TargetPtrs.find(libName); + auto tarIt = this->TargetPtrs.find(libName); if (tarIt == this->TargetPtrs.end()) { std::ostringstream ostr; ostr << this->GraphNodePrefix << cnt++; diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx index 876bd95..a4d0a0d 100644 --- a/Source/cmIncludeDirectoryCommand.cxx +++ b/Source/cmIncludeDirectoryCommand.cxx @@ -22,7 +22,7 @@ bool cmIncludeDirectoryCommand::InitialPass( return true; } - std::vector::const_iterator i = args.begin(); + auto i = args.begin(); bool before = this->Makefile->IsOn("CMAKE_INCLUDE_DIRECTORIES_BEFORE"); bool system = false; diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index 11687a8..4eb5f24 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -63,7 +63,7 @@ static void FinalAction(cmMakefile& makefile, std::string const& dest, // two different options if (args.size() > 1) { // now put the files into the list - std::vector::const_iterator s = args.begin(); + auto s = args.begin(); ++s; // for each argument, get the files for (; s != args.end(); ++s) { @@ -85,7 +85,7 @@ static void FinalAction(cmMakefile& makefile, std::string const& dest, std::string const& regex = args[0]; cmSystemTools::Glob(makefile.GetCurrentSourceDirectory(), regex, files); - std::vector::iterator s = files.begin(); + auto s = files.begin(); // for each argument, get the files for (; s != files.end(); ++s) { installFiles.push_back(FindInstallSource(makefile, s->c_str())); diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx index 3eca0e0..31a18b5 100644 --- a/Source/cmInstallProgramsCommand.cxx +++ b/Source/cmInstallProgramsCommand.cxx @@ -52,7 +52,7 @@ static void FinalAction(cmMakefile& makefile, std::string const& dest, // two different options if (args.size() > 1 || files_mode) { // for each argument, get the programs - std::vector::const_iterator s = args.begin(); + auto s = args.begin(); if (files_mode) { // Skip the FILES argument in files mode. ++s; @@ -67,7 +67,7 @@ static void FinalAction(cmMakefile& makefile, std::string const& dest, cmSystemTools::Glob(makefile.GetCurrentSourceDirectory(), args[0], programs); - std::vector::iterator s = programs.begin(); + auto s = programs.begin(); // for each argument, get the programs for (; s != programs.end(); ++s) { files.push_back(FindInstallSource(makefile, s->c_str())); diff --git a/Source/cmInstallTargetsCommand.cxx b/Source/cmInstallTargetsCommand.cxx index ef07e2c..30fd03d 100644 --- a/Source/cmInstallTargetsCommand.cxx +++ b/Source/cmInstallTargetsCommand.cxx @@ -24,7 +24,7 @@ bool cmInstallTargetsCommand::InitialPass(std::vector const& args, this->Makefile->GetGlobalGenerator()->EnableInstallTarget(); cmMakefile::cmTargetMap& tgts = this->Makefile->GetTargets(); - std::vector::const_iterator s = args.begin(); + auto s = args.begin(); ++s; std::string runtime_dir = "/bin"; for (; s != args.end(); ++s) { @@ -38,7 +38,7 @@ bool cmInstallTargetsCommand::InitialPass(std::vector const& args, runtime_dir = *s; } else { - cmMakefile::cmTargetMap::iterator ti = tgts.find(*s); + auto ti = tgts.find(*s); if (ti != tgts.end()) { ti->second.SetInstallPath(args[0]); ti->second.SetRuntimeInstallPath(runtime_dir); diff --git a/Source/cmInstalledFile.cxx b/Source/cmInstalledFile.cxx index 11f6efb..7d98b90 100644 --- a/Source/cmInstalledFile.cxx +++ b/Source/cmInstalledFile.cxx @@ -74,7 +74,7 @@ bool cmInstalledFile::HasProperty(const std::string& prop) const bool cmInstalledFile::GetProperty(const std::string& prop, std::string& value) const { - PropertyMapType::const_iterator i = this->Properties.find(prop); + auto i = this->Properties.find(prop); if (i == this->Properties.end()) { return false; } diff --git a/Source/cmLinkLibrariesCommand.cxx b/Source/cmLinkLibrariesCommand.cxx index 13f6bae..bf05310 100644 --- a/Source/cmLinkLibrariesCommand.cxx +++ b/Source/cmLinkLibrariesCommand.cxx @@ -15,8 +15,7 @@ bool cmLinkLibrariesCommand::InitialPass(std::vector const& args, } // add libraries, note that there is an optional prefix // of debug and optimized than can be used - for (std::vector::const_iterator i = args.begin(); - i != args.end(); ++i) { + for (auto i = args.begin(); i != args.end(); ++i) { if (*i == "debug") { ++i; if (i == args.end()) { diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 57eeedb..b35dc6f 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -338,8 +338,7 @@ bool HandleFindCommand(std::vector const& args, return true; } - std::vector::iterator it = - std::find(varArgsExpanded.begin(), varArgsExpanded.end(), args[2]); + auto it = std::find(varArgsExpanded.begin(), varArgsExpanded.end(), args[2]); if (it != varArgsExpanded.end()) { status.GetMakefile().AddDefinition( variableName, @@ -441,13 +440,12 @@ bool HandleRemoveItemCommand(std::vector const& args, std::vector remove(args.begin() + 2, args.end()); std::sort(remove.begin(), remove.end()); - std::vector::const_iterator remEnd = - std::unique(remove.begin(), remove.end()); - std::vector::const_iterator remBegin = remove.begin(); + auto remEnd = std::unique(remove.begin(), remove.end()); + auto remBegin = remove.begin(); - std::vector::const_iterator argsEnd = + auto argsEnd = cmRemoveMatching(varArgsExpanded, cmMakeRange(remBegin, remEnd)); - std::vector::const_iterator argsBegin = varArgsExpanded.begin(); + auto argsBegin = varArgsExpanded.cbegin(); std::string value = cmJoin(cmMakeRange(argsBegin, argsEnd), ";"); status.GetMakefile().AddDefinition(listName, value); return true; @@ -491,9 +489,8 @@ bool HandleRemoveDuplicatesCommand(std::vector const& args, return true; } - std::vector::const_iterator argsEnd = - cmRemoveDuplicates(varArgsExpanded); - std::vector::const_iterator argsBegin = varArgsExpanded.begin(); + auto argsEnd = cmRemoveDuplicates(varArgsExpanded); + auto argsBegin = varArgsExpanded.cbegin(); std::string value = cmJoin(cmMakeRange(argsBegin, argsEnd), ";"); status.GetMakefile().AddDefinition(listName, value); @@ -1357,13 +1354,12 @@ bool HandleRemoveAtCommand(std::vector const& args, } std::sort(removed.begin(), removed.end()); - std::vector::const_iterator remEnd = - std::unique(removed.begin(), removed.end()); - std::vector::const_iterator remBegin = removed.begin(); + auto remEnd = std::unique(removed.begin(), removed.end()); + auto remBegin = removed.begin(); - std::vector::const_iterator argsEnd = + auto argsEnd = cmRemoveIndices(varArgsExpanded, cmMakeRange(remBegin, remEnd)); - std::vector::const_iterator argsBegin = varArgsExpanded.begin(); + auto argsBegin = varArgsExpanded.cbegin(); std::string value = cmJoin(cmMakeRange(argsBegin, argsEnd), ";"); status.GetMakefile().AddDefinition(listName, value); @@ -1456,9 +1452,9 @@ bool FilterRegex(std::vector const& args, bool includeMatches, return false; } - std::vector::iterator argsBegin = varArgsExpanded.begin(); - std::vector::iterator argsEnd = varArgsExpanded.end(); - std::vector::iterator newArgsEnd = + auto argsBegin = varArgsExpanded.begin(); + auto argsEnd = varArgsExpanded.end(); + auto newArgsEnd = std::remove_if(argsBegin, argsEnd, MatchesRegex(regex, includeMatches)); std::string value = cmJoin(cmMakeRange(argsBegin, newArgsEnd), ";"); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 5d831c9..71fe772 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -649,8 +649,7 @@ void cmLocalGenerator::AddOwnedImportedGeneratorTarget(cmGeneratorTarget* gt) cmGeneratorTarget* cmLocalGenerator::FindLocalNonAliasGeneratorTarget( const std::string& name) const { - GeneratorTargetMap::const_iterator ti = - this->GeneratorTargetSearchIndex.find(name); + auto ti = this->GeneratorTargetSearchIndex.find(name); if (ti != this->GeneratorTargetSearchIndex.end()) { return ti->second; } @@ -1641,8 +1640,7 @@ void cmLocalGenerator::AddLanguageFlagsForLinking( cmGeneratorTarget* cmLocalGenerator::FindGeneratorTargetToUse( const std::string& name) const { - GeneratorTargetMap::const_iterator imported = - this->ImportedGeneratorTargets.find(name); + auto imported = this->ImportedGeneratorTargets.find(name); if (imported != this->ImportedGeneratorTargets.end()) { return imported->second; } @@ -1843,8 +1841,7 @@ void cmLocalGenerator::AddCompilerRequirementFlag( std::vector& stds = langStdMap[lang]; - std::vector::const_iterator stdIt = - std::find(stds.begin(), stds.end(), standard); + auto stdIt = std::find(stds.begin(), stds.end(), standard); if (stdIt == stds.end()) { std::string e = lang + "_STANDARD is set to invalid value '" + standard + "'"; @@ -1853,8 +1850,7 @@ void cmLocalGenerator::AddCompilerRequirementFlag( return; } - std::vector::const_iterator defaultStdIt = - std::find(stds.begin(), stds.end(), defaultStd); + auto defaultStdIt = std::find(stds.begin(), stds.end(), defaultStd); if (defaultStdIt == stds.end()) { std::string e = "CMAKE_" + lang + "_STANDARD_DEFAULT is set to invalid value '" + std::string(defaultStd) + @@ -2720,8 +2716,7 @@ std::string& cmLocalGenerator::CreateSafeUniqueObjectFileName( const std::string& sin, std::string const& dir_max) { // Look for an existing mapped name for this object file. - std::map::iterator it = - this->UniqueObjectNamesMap.find(sin); + auto it = this->UniqueObjectNamesMap.find(sin); // If no entry exists create one. if (it == this->UniqueObjectNamesMap.end()) { diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index e28b876..1284d4d 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -386,8 +386,7 @@ std::string cmLocalNinjaGenerator::BuildCommandLine( } std::ostringstream cmd; - for (std::vector::const_iterator li = cmdLines.begin(); - li != cmdLines.end(); ++li) + for (auto li = cmdLines.begin(); li != cmdLines.end(); ++li) #ifdef _WIN32 { if (li != cmdLines.begin()) { @@ -531,8 +530,7 @@ void cmLocalNinjaGenerator::AddCustomCommandTarget(cmCustomCommand const* cc, void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements() { for (cmCustomCommand const* customCommand : this->CustomCommands) { - CustomCommandTargetMap::iterator i = - this->CustomCommandTargets.find(customCommand); + auto i = this->CustomCommandTargets.find(customCommand); assert(i != this->CustomCommandTargets.end()); // A custom command may appear on multiple targets. However, some build @@ -544,7 +542,7 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements() // // FIXME: This won't work in certain obscure scenarios involving indirect // dependencies. - std::set::iterator j = i->second.begin(); + auto j = i->second.begin(); assert(j != i->second.end()); std::vector ccTargetDeps; this->GetGlobalNinjaGenerator()->AppendTargetDependsClosure(*j, diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 320a58b..8248608 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1225,8 +1225,7 @@ std::string cmLocalUnixMakefileGenerator3::CreateMakeVariable( // see if the variable has been defined before and return // the modified version of the variable - std::map::iterator i = - this->MakeVariableMap.find(unmodified); + auto i = this->MakeVariableMap.find(unmodified); if (i != this->MakeVariableMap.end()) { return i->second; } @@ -1495,8 +1494,7 @@ void cmLocalUnixMakefileGenerator3::CheckMultipleOutputs(bool verbose) // Convert the string to a list and preserve empty entries. std::vector pairs = cmExpandedList(pairs_string, true); - for (std::vector::const_iterator i = pairs.begin(); - i != pairs.end() && (i + 1) != pairs.end();) { + for (auto i = pairs.begin(); i != pairs.end() && (i + 1) != pairs.end();) { const std::string& depender = *i++; const std::string& dependee = *i++; @@ -2019,10 +2017,9 @@ std::string cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath( if (components.size() > 1) { // Now add the rest of the components separated by the proper slash // direction for this platform. - std::vector::const_iterator compEnd = std::remove( - components.begin() + 1, components.end() - 1, std::string()); - std::vector::const_iterator compStart = - components.begin() + 1; + auto compEnd = std::remove(components.begin() + 1, components.end() - 1, + std::string()); + auto compStart = components.begin() + 1; result += cmJoin(cmMakeRange(compStart, compEnd), slash); // Only the last component can be empty to avoid double slashes. result += slash; diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index 201cc13..ef6a705 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -65,8 +65,7 @@ bool cmMacroHelperCommand::operator()( // set the value of argc std::string argcDef = std::to_string(expandedArgs.size()); - std::vector::const_iterator eit = - expandedArgs.begin() + (this->Args.size() - 1); + auto eit = expandedArgs.begin() + (this->Args.size() - 1); std::string expandedArgn = cmJoin(cmMakeRange(eit, expandedArgs.end()), ";"); std::string expandedArgv = cmJoin(expandedArgs, ";"); std::vector variables; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 411add3..5f83746 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -751,9 +751,8 @@ cmMakefile::GetExportBuildFileGenerators() const void cmMakefile::RemoveExportBuildFileGeneratorCMP0024( cmExportBuildFileGenerator* gen) { - std::vector::iterator it = - std::find(this->ExportBuildFileGenerators.begin(), - this->ExportBuildFileGenerators.end(), gen); + auto it = std::find(this->ExportBuildFileGenerators.begin(), + this->ExportBuildFileGenerators.end(), gen); if (it != this->ExportBuildFileGenerators.end()) { this->ExportBuildFileGenerators.erase(it); } @@ -829,7 +828,7 @@ void cmMakefile::AddCustomCommandToTarget( bool command_expand_lists, ObjectLibraryCommands objLibraryCommands) { // Find the target to which to add the custom command. - cmTargetMap::iterator ti = this->Targets.find(target); + auto ti = this->Targets.find(target); if (ti == this->Targets.end()) { MessageType messageType = MessageType::AUTHOR_WARNING; @@ -1034,7 +1033,7 @@ void cmMakefile::UpdateOutputToSourceMap( void cmMakefile::UpdateOutputToSourceMap(std::string const& output, cmSourceFile* source) { - OutputToSourceMap::iterator i = this->OutputToSource.find(output); + auto i = this->OutputToSource.find(output); if (i != this->OutputToSource.end()) { // Multiple custom commands produce the same output but may // be attached to a different source file (MAIN_DEPENDENCY). @@ -1110,7 +1109,7 @@ void cmMakefile::AddCustomCommandOldStyle( // then add the source to the target to make sure the rule is // included. if (sf && !sf->GetPropertyAsBool("__CMAKE_RULE")) { - cmTargetMap::iterator ti = this->Targets.find(target); + auto ti = this->Targets.find(target); if (ti != this->Targets.end()) { ti->second.AddSource(sf->ResolveFullPath()); } else { @@ -1355,9 +1354,8 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove) std::vector defs = cmExpandedList(cdefs); // Recompose the list without the definition. - std::vector::const_iterator defEnd = - std::remove(defs.begin(), defs.end(), define); - std::vector::const_iterator defBegin = defs.begin(); + auto defEnd = std::remove(defs.begin(), defs.end(), define); + auto defBegin = defs.begin(); std::string ndefs = cmJoin(cmMakeRange(defBegin, defEnd), ";"); // Store the new list. @@ -1640,7 +1638,7 @@ void cmMakefile::Configure() std::vector subdirs = this->UnConfiguredDirectories; // for each subdir recurse - std::vector::iterator sdi = subdirs.begin(); + auto sdi = subdirs.begin(); for (; sdi != subdirs.end(); ++sdi) { (*sdi)->StateSnapshot.InitializeFromParent_ForSubdirsCommand(); this->ConfigureSubDirectory(*sdi); @@ -1954,8 +1952,7 @@ void cmMakefile::AddGlobalLinkInformation(cmTarget& target) if (const char* linkLibsProp = this->GetProperty("LINK_LIBRARIES")) { std::vector linkLibs = cmExpandedList(linkLibsProp); - for (std::vector::iterator j = linkLibs.begin(); - j != linkLibs.end(); ++j) { + for (auto j = linkLibs.begin(); j != linkLibs.end(); ++j) { std::string libraryName = *j; cmTargetLinkLibraryType libType = GENERAL_LibraryType; if (libraryName == "optimized") { @@ -2024,7 +2021,7 @@ cmTarget* cmMakefile::AddExecutable(const std::string& exeName, cmTarget* cmMakefile::AddNewTarget(cmStateEnums::TargetType type, const std::string& name) { - cmTargetMap::iterator it = + auto it = this->Targets .emplace(name, cmTarget(name, type, cmTarget::VisibilityNormal, this)) .first; @@ -2071,7 +2068,7 @@ cmSourceFile* cmMakefile::GetSourceFileWithOutput( return this->LinearGetSourceFileWithOutput(name); } // Otherwise we use an efficient lookup map. - OutputToSourceMap::const_iterator o = this->OutputToSource.find(name); + auto o = this->OutputToSource.find(name); if (o != this->OutputToSource.end()) { return (*o).second; } @@ -2188,8 +2185,7 @@ cmSourceGroup* cmMakefile::FindSourceGroup( const std::string& source, std::vector& groups) const { // First search for a group that lists the file explicitly. - for (std::vector::reverse_iterator sg = groups.rbegin(); - sg != groups.rend(); ++sg) { + for (auto sg = groups.rbegin(); sg != groups.rend(); ++sg) { cmSourceGroup* result = sg->MatchChildrenFiles(source); if (result) { return result; @@ -2197,8 +2193,7 @@ cmSourceGroup* cmMakefile::FindSourceGroup( } // Now search for a group whose regex matches the file. - for (std::vector::reverse_iterator sg = groups.rbegin(); - sg != groups.rend(); ++sg) { + for (auto sg = groups.rbegin(); sg != groups.rend(); ++sg) { cmSourceGroup* result = sg->MatchChildrenRegex(source); if (result) { return result; @@ -2281,8 +2276,7 @@ void cmMakefile::ExpandVariablesCMP0019() if (const char* linkLibsProp = this->GetProperty("LINK_LIBRARIES")) { std::vector linkLibs = cmExpandedList(linkLibsProp); - for (std::vector::iterator l = linkLibs.begin(); - l != linkLibs.end(); ++l) { + for (auto l = linkLibs.begin(); l != linkLibs.end(); ++l) { std::string libName = *l; if (libName == "optimized") { ++l; @@ -3841,7 +3835,7 @@ std::vector cmMakefile::GetPropertyKeys() const cmTarget* cmMakefile::FindLocalNonAliasTarget(const std::string& name) const { - cmTargetMap::iterator i = this->Targets.find(name); + auto i = this->Targets.find(name); if (i != this->Targets.end()) { return &i->second; } @@ -3862,8 +3856,7 @@ cmTest* cmMakefile::CreateTest(const std::string& testName) cmTest* cmMakefile::GetTest(const std::string& testName) const { - std::map::const_iterator mi = - this->Tests.find(testName); + auto mi = this->Tests.find(testName); if (mi != this->Tests.end()) { return mi->second; } @@ -3908,7 +3901,7 @@ std::string cmMakefile::FormatListFileStack() const std::ostringstream tmp; size_t depth = listFiles.size(); if (depth > 0) { - std::vector::const_iterator it = listFiles.end(); + auto it = listFiles.end(); do { if (depth != listFiles.size()) { tmp << "\n "; @@ -3995,7 +3988,7 @@ cmTarget* cmMakefile::FindTargetToUse(const std::string& name, { // Look for an imported target. These take priority because they // are more local in scope and do not have to be globally unique. - TargetMap::const_iterator imported = this->ImportedTargets.find(name); + auto imported = this->ImportedTargets.find(name); if (imported != this->ImportedTargets.end()) { return imported->second; } diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 36f6809..6d71a6d 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -837,7 +837,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( } // Create the archive with the first set of objects. - std::vector::iterator osi = object_strings.begin(); + auto osi = object_strings.begin(); { vars.Objects = osi->c_str(); for (std::string const& acc : archiveCreateCommands) { diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index 35ec33e..c8cac3b 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -128,7 +128,7 @@ bool cmOrderDirectoriesConstraint::FileMayConflict(std::string const& dir, // Check if the file will be built by cmake. std::set const& files = (this->GlobalGenerator->GetDirectoryContent(dir, false)); - std::set::const_iterator fi = files.find(name); + auto fi = files.find(name); return fi != files.end(); } @@ -186,9 +186,9 @@ bool cmOrderDirectoriesConstraintSOName::FindConflict(std::string const& dir) // know the soname just look at all files that start with the // file name. Usually the soname starts with the library name. std::string base = this->FileName; - std::set::const_iterator first = files.lower_bound(base); + auto first = files.lower_bound(base); ++base.back(); - std::set::const_iterator last = files.upper_bound(base); + auto last = files.upper_bound(base); if (first != last) { return true; } @@ -380,7 +380,7 @@ void cmOrderDirectories::CollectOriginalDirectories() int cmOrderDirectories::AddOriginalDirectory(std::string const& dir) { // Add the runtime directory with a unique index. - std::map::iterator i = this->DirectoryIndex.find(dir); + auto i = this->DirectoryIndex.find(dir); if (i == this->DirectoryIndex.end()) { std::map::value_type entry( dir, static_cast(this->OriginalDirectories.size())); @@ -441,8 +441,7 @@ void cmOrderDirectories::FindConflicts() std::sort(cl.begin(), cl.end()); // Make the edge list unique so cycle detection will be reliable. - ConflictList::iterator last = - std::unique(cl.begin(), cl.end(), cmOrderDirectoriesCompare()); + auto last = std::unique(cl.begin(), cl.end(), cmOrderDirectoriesCompare()); cl.erase(last, cl.end()); } @@ -553,8 +552,7 @@ bool cmOrderDirectories::IsSameDirectory(std::string const& l, std::string const& cmOrderDirectories::GetRealPath(std::string const& dir) { - std::map::iterator i = - this->RealPaths.lower_bound(dir); + auto i = this->RealPaths.lower_bound(dir); if (i == this->RealPaths.end() || this->RealPaths.key_comp()(dir, i->first)) { using value_type = std::map::value_type; diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index c034fdd..2f4e003 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -367,8 +367,7 @@ protected: std::string fullPath = this->FullPath(file, extraPath); // Try to find the file's instance of cmDependInformation. - DependInformationMapType::const_iterator result = - this->DependInformationMap.find(fullPath); + auto result = this->DependInformationMap.find(fullPath); if (result != this->DependInformationMap.end()) { // Found an instance, return it. return result->second; @@ -398,7 +397,7 @@ protected: if (m != this->DirectoryToFileToPathMap.end()) { FileToPathMapType& map = m->second; - FileToPathMapType::iterator p = map.find(fname); + auto p = map.find(fname); if (p != map.end()) { return p->second; } diff --git a/Source/cmParseArgumentsCommand.cxx b/Source/cmParseArgumentsCommand.cxx index a4dd70d..0b320b6 100644 --- a/Source/cmParseArgumentsCommand.cxx +++ b/Source/cmParseArgumentsCommand.cxx @@ -116,8 +116,8 @@ bool cmParseArgumentsCommand(std::vector const& args, return false; } - std::vector::const_iterator argIter = args.begin(); - std::vector::const_iterator argEnd = args.end(); + auto argIter = args.begin(); + auto argEnd = args.end(); bool parseFromArgV = false; unsigned long argvStart = 0; if (*argIter == "PARSE_ARGV") { diff --git a/Source/cmPropertyDefinitionMap.cxx b/Source/cmPropertyDefinitionMap.cxx index 5daaf9b..f752ed7 100644 --- a/Source/cmPropertyDefinitionMap.cxx +++ b/Source/cmPropertyDefinitionMap.cxx @@ -10,7 +10,7 @@ void cmPropertyDefinitionMap::DefineProperty(const std::string& name, const char* FullDescription, bool chain) { - cmPropertyDefinitionMap::iterator it = this->find(name); + auto it = this->find(name); cmPropertyDefinition* prop; if (it == this->end()) { prop = &(*this)[name]; @@ -26,7 +26,7 @@ bool cmPropertyDefinitionMap::IsPropertyDefined(const std::string& name) const bool cmPropertyDefinitionMap::IsPropertyChained(const std::string& name) const { - cmPropertyDefinitionMap::const_iterator it = this->find(name); + auto it = this->find(name); if (it == this->end()) { return false; } diff --git a/Source/cmQtAutoGen.cxx b/Source/cmQtAutoGen.cxx index 83df335..f3c78d3 100644 --- a/Source/cmQtAutoGen.cxx +++ b/Source/cmQtAutoGen.cxx @@ -24,8 +24,6 @@ void MergeOptions(std::vector& baseOpts, std::vector const& newOpts, std::initializer_list valueOpts, bool isQt5) { - using Iter = std::vector::iterator; - using CIter = std::vector::const_iterator; if (newOpts.empty()) { return; } @@ -35,10 +33,10 @@ void MergeOptions(std::vector& baseOpts, } std::vector extraOpts; - for (CIter fit = newOpts.begin(), fitEnd = newOpts.end(); fit != fitEnd; + for (auto fit = newOpts.begin(), fitEnd = newOpts.end(); fit != fitEnd; ++fit) { std::string const& newOpt = *fit; - Iter existIt = std::find(baseOpts.begin(), baseOpts.end(), newOpt); + auto existIt = std::find(baseOpts.begin(), baseOpts.end(), newOpt); if (existIt != baseOpts.end()) { if (newOpt.size() >= 2) { // Acquire the option name @@ -55,8 +53,8 @@ void MergeOptions(std::vector& baseOpts, } // Test if this is a value option and change the existing value if (!optName.empty() && cmContains(valueOpts, optName)) { - const Iter existItNext(existIt + 1); - const CIter fitNext(fit + 1); + const auto existItNext(existIt + 1); + const auto fitNext(fit + 1); if ((existItNext != baseOpts.end()) && (fitNext != fitEnd)) { *existItNext = *fitNext; ++fit; diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 14329c0..40ebdde 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -1797,7 +1797,7 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) BaseConst().ProjectBinaryDir, BaseConst().ProjectSourceDir }; for (cm::string_view const& ppath : movePaths) { - std::list::iterator it = includes.begin(); + auto it = includes.begin(); while (it != includes.end()) { std::string const& path = *it; if (cmHasPrefix(path, ppath)) { diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx index 1f9aae8..aa394e5 100644 --- a/Source/cmRST.cxx +++ b/Source/cmRST.cxx @@ -320,8 +320,7 @@ std::string cmRST::ReplaceSubstitutions(std::string const& line) std::string::size_type start = this->Substitution.start(2); std::string::size_type end = this->Substitution.end(2); std::string substitute = this->Substitution.match(3); - std::map::iterator replace = - this->Replace.find(substitute); + auto replace = this->Replace.find(substitute); if (replace != this->Replace.end()) { std::pair::iterator, bool> replaced = this->Replaced.insert(substitute); @@ -451,10 +450,10 @@ void cmRST::UnindentLines(std::vector& lines) } } - std::vector::const_iterator it = lines.begin(); + auto it = lines.cbegin(); size_t leadingEmpty = std::distance(it, cmFindNot(lines, std::string())); - std::vector::const_reverse_iterator rit = lines.rbegin(); + auto rit = lines.crbegin(); size_t trailingEmpty = std::distance(rit, cmFindNot(cmReverseRange(lines), std::string())); @@ -464,7 +463,7 @@ void cmRST::UnindentLines(std::vector& lines) return; } - std::vector::iterator contentEnd = cmRotate( - lines.begin(), lines.begin() + leadingEmpty, lines.end() - trailingEmpty); + auto contentEnd = cmRotate(lines.begin(), lines.begin() + leadingEmpty, + lines.end() - trailingEmpty); lines.erase(contentEnd, lines.end()); } diff --git a/Source/cmRulePlaceholderExpander.cxx b/Source/cmRulePlaceholderExpander.cxx index 33389ca..6c954a6 100644 --- a/Source/cmRulePlaceholderExpander.cxx +++ b/Source/cmRulePlaceholderExpander.cxx @@ -235,8 +235,7 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable( cmOutputConverter::SHELL); } - std::map::iterator compIt = - this->Compilers.find(variable); + auto compIt = this->Compilers.find(variable); if (compIt != this->Compilers.end()) { std::string ret = outputConverter->ConvertToOutputForExisting( @@ -292,8 +291,7 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable( return ret; } - std::map::iterator mapIt = - this->VariableMappings.find(variable); + auto mapIt = this->VariableMappings.find(variable); if (mapIt != this->VariableMappings.end()) { if (variable.find("_FLAG") == std::string::npos) { return outputConverter->ConvertToOutputForExisting(mapIt->second); diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index 7e3a340..387c3fc 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -375,8 +375,7 @@ bool HandleTestMode(cmExecutionStatus& status, std::set& names, { // Look for tests with all names given. std::set::iterator next; - for (std::set::iterator ni = names.begin(); ni != names.end(); - ni = next) { + for (auto ni = names.begin(); ni != names.end(); ni = next) { next = ni; ++next; if (cmTest* test = status.GetMakefile().GetTest(*ni)) { diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx index 399f1da..c239a1f 100644 --- a/Source/cmSourceGroupCommand.cxx +++ b/Source/cmSourceGroupCommand.cxx @@ -284,8 +284,7 @@ bool cmSourceGroupCommand::checkSingleParameterArgumentPreconditions( const std::string& argument, const ParsedArguments& parsedArguments, std::string& errorMsg) const { - ParsedArguments::const_iterator foundArgument = - parsedArguments.find(argument); + auto foundArgument = parsedArguments.find(argument); if (foundArgument != parsedArguments.end()) { const std::vector& optionArguments = foundArgument->second; diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 92d17ab..751eb77 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -350,8 +350,7 @@ cmPropertyDefinition const* cmState::GetPropertyDefinition( bool cmState::IsPropertyDefined(const std::string& name, cmProperty::ScopeType scope) const { - std::map::const_iterator it = - this->PropertyDefinitions.find(scope); + auto it = this->PropertyDefinitions.find(scope); if (it == this->PropertyDefinitions.end()) { return false; } @@ -361,8 +360,7 @@ bool cmState::IsPropertyDefined(const std::string& name, bool cmState::IsPropertyChained(const std::string& name, cmProperty::ScopeType scope) const { - std::map::const_iterator it = - this->PropertyDefinitions.find(scope); + auto it = this->PropertyDefinitions.find(scope); if (it == this->PropertyDefinitions.end()) { return false; } @@ -371,8 +369,8 @@ bool cmState::IsPropertyChained(const std::string& name, void cmState::SetLanguageEnabled(std::string const& l) { - std::vector::iterator it = std::lower_bound( - this->EnabledLanguages.begin(), this->EnabledLanguages.end(), l); + auto it = std::lower_bound(this->EnabledLanguages.begin(), + this->EnabledLanguages.end(), l); if (it == this->EnabledLanguages.end() || *it != l) { this->EnabledLanguages.insert(it, l); } diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx index df96bd3..c14bf4a 100644 --- a/Source/cmStateDirectory.cxx +++ b/Source/cmStateDirectory.cxx @@ -175,11 +175,9 @@ cmStateDirectory::cmStateDirectory( template cmStringRange GetPropertyContent(T const& content, U contentEndPosition) { - std::vector::const_iterator end = - content.begin() + contentEndPosition; + auto end = content.begin() + contentEndPosition; - std::vector::const_reverse_iterator rbegin = - cmMakeReverseIterator(end); + auto rbegin = cmMakeReverseIterator(end); rbegin = std::find(rbegin, content.rend(), cmPropertySentinal); return cmMakeRange(rbegin.base(), end); @@ -189,17 +187,14 @@ template cmBacktraceRange GetPropertyBacktraces(T const& content, U const& backtraces, V contentEndPosition) { - std::vector::const_iterator entryEnd = - content.begin() + contentEndPosition; + auto entryEnd = content.begin() + contentEndPosition; - std::vector::const_reverse_iterator rbegin = - cmMakeReverseIterator(entryEnd); + auto rbegin = cmMakeReverseIterator(entryEnd); rbegin = std::find(rbegin, content.rend(), cmPropertySentinal); - std::vector::const_iterator it = - backtraces.begin() + std::distance(content.begin(), rbegin.base()); + auto it = backtraces.begin() + std::distance(content.begin(), rbegin.base()); - std::vector::const_iterator end = backtraces.end(); + auto end = backtraces.end(); return cmMakeRange(it, end); } @@ -271,22 +266,17 @@ void cmStateDirectory::AppendIncludeDirectoriesEntry( void cmStateDirectory::PrependIncludeDirectoriesEntry( const std::string& vec, const cmListFileBacktrace& lfbt) { - std::vector::iterator entryEnd = - this->DirectoryState->IncludeDirectories.begin() + + auto entryEnd = this->DirectoryState->IncludeDirectories.begin() + this->Snapshot_.Position->IncludeDirectoryPosition; - std::vector::reverse_iterator rend = - this->DirectoryState->IncludeDirectories.rend(); - std::vector::reverse_iterator rbegin = - cmMakeReverseIterator(entryEnd); + auto rend = this->DirectoryState->IncludeDirectories.rend(); + auto rbegin = cmMakeReverseIterator(entryEnd); rbegin = std::find(rbegin, rend, cmPropertySentinal); - std::vector::iterator entryIt = rbegin.base(); - std::vector::iterator entryBegin = - this->DirectoryState->IncludeDirectories.begin(); + auto entryIt = rbegin.base(); + auto entryBegin = this->DirectoryState->IncludeDirectories.begin(); - std::vector::iterator btIt = - this->DirectoryState->IncludeDirectoryBacktraces.begin() + + auto btIt = this->DirectoryState->IncludeDirectoryBacktraces.begin() + std::distance(entryBegin, entryIt); this->DirectoryState->IncludeDirectories.insert(entryIt, vec); @@ -446,22 +436,17 @@ void cmStateDirectory::AppendLinkDirectoriesEntry( void cmStateDirectory::PrependLinkDirectoriesEntry( const std::string& vec, const cmListFileBacktrace& lfbt) { - std::vector::iterator entryEnd = - this->DirectoryState->LinkDirectories.begin() + + auto entryEnd = this->DirectoryState->LinkDirectories.begin() + this->Snapshot_.Position->LinkDirectoriesPosition; - std::vector::reverse_iterator rend = - this->DirectoryState->LinkDirectories.rend(); - std::vector::reverse_iterator rbegin = - cmMakeReverseIterator(entryEnd); + auto rend = this->DirectoryState->LinkDirectories.rend(); + auto rbegin = cmMakeReverseIterator(entryEnd); rbegin = std::find(rbegin, rend, cmPropertySentinal); - std::vector::iterator entryIt = rbegin.base(); - std::vector::iterator entryBegin = - this->DirectoryState->LinkDirectories.begin(); + auto entryIt = rbegin.base(); + auto entryBegin = this->DirectoryState->LinkDirectories.begin(); - std::vector::iterator btIt = - this->DirectoryState->LinkDirectoriesBacktraces.begin() + + auto btIt = this->DirectoryState->LinkDirectoriesBacktraces.begin() + std::distance(entryBegin, entryIt); this->DirectoryState->LinkDirectories.insert(entryIt, vec); diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx index 3c54f52..b3e33ea 100644 --- a/Source/cmStateSnapshot.cxx +++ b/Source/cmStateSnapshot.cxx @@ -276,22 +276,18 @@ void InitializeContentFromParent(T& parentContent, T& thisContent, U& parentBacktraces, U& thisBacktraces, V& contentEndPosition) { - std::vector::const_iterator parentBegin = parentContent.begin(); - std::vector::const_iterator parentEnd = parentContent.end(); + auto parentBegin = parentContent.begin(); + auto parentEnd = parentContent.end(); - std::vector::const_reverse_iterator parentRbegin = - cmMakeReverseIterator(parentEnd); - std::vector::const_reverse_iterator parentRend = - parentContent.rend(); + auto parentRbegin = cmMakeReverseIterator(parentEnd); + auto parentRend = parentContent.rend(); parentRbegin = std::find(parentRbegin, parentRend, cmPropertySentinal); - std::vector::const_iterator parentIt = parentRbegin.base(); + auto parentIt = parentRbegin.base(); thisContent = std::vector(parentIt, parentEnd); - std::vector::const_iterator btIt = - parentBacktraces.begin() + std::distance(parentBegin, parentIt); - std::vector::const_iterator btEnd = - parentBacktraces.end(); + auto btIt = parentBacktraces.begin() + std::distance(parentBegin, parentIt); + auto btEnd = parentBacktraces.end(); thisBacktraces = std::vector(btIt, btEnd); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index b7287d9..7f2813a 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1633,8 +1633,8 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line, std::vector& err) { line.clear(); - std::vector::iterator outiter = out.begin(); - std::vector::iterator erriter = err.begin(); + auto outiter = out.begin(); + auto erriter = err.begin(); cmProcessOutput processOutput; std::string strdata; while (true) { @@ -2540,8 +2540,7 @@ bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg, // Adjust the entry list as necessary to remove the run path unsigned long entriesErased = 0; - for (cmELF::DynamicEntryList::iterator it = dentries.begin(); - it != dentries.end();) { + for (auto it = dentries.begin(); it != dentries.end();) { if (it->first == cmELF::TagRPath || it->first == cmELF::TagRunPath) { it = dentries.erase(it); entriesErased++; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 10ea7dd..2420810 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1361,13 +1361,11 @@ void cmTarget::AppendBuildInterfaceIncludes() void cmTarget::InsertInclude(std::string const& entry, cmListFileBacktrace const& bt, bool before) { - std::vector::iterator position = before - ? impl->IncludeDirectoriesEntries.begin() - : impl->IncludeDirectoriesEntries.end(); + auto position = before ? impl->IncludeDirectoriesEntries.begin() + : impl->IncludeDirectoriesEntries.end(); - std::vector::iterator btPosition = before - ? impl->IncludeDirectoriesBacktraces.begin() - : impl->IncludeDirectoriesBacktraces.end(); + auto btPosition = before ? impl->IncludeDirectoriesBacktraces.begin() + : impl->IncludeDirectoriesBacktraces.end(); impl->IncludeDirectoriesEntries.insert(position, entry); impl->IncludeDirectoriesBacktraces.insert(btPosition, bt); @@ -1376,13 +1374,11 @@ void cmTarget::InsertInclude(std::string const& entry, void cmTarget::InsertCompileOption(std::string const& entry, cmListFileBacktrace const& bt, bool before) { - std::vector::iterator position = before - ? impl->CompileOptionsEntries.begin() - : impl->CompileOptionsEntries.end(); + auto position = before ? impl->CompileOptionsEntries.begin() + : impl->CompileOptionsEntries.end(); - std::vector::iterator btPosition = before - ? impl->CompileOptionsBacktraces.begin() - : impl->CompileOptionsBacktraces.end(); + auto btPosition = before ? impl->CompileOptionsBacktraces.begin() + : impl->CompileOptionsBacktraces.end(); impl->CompileOptionsEntries.insert(position, entry); impl->CompileOptionsBacktraces.insert(btPosition, bt); @@ -1398,12 +1394,11 @@ void cmTarget::InsertCompileDefinition(std::string const& entry, void cmTarget::InsertLinkOption(std::string const& entry, cmListFileBacktrace const& bt, bool before) { - std::vector::iterator position = + auto position = before ? impl->LinkOptionsEntries.begin() : impl->LinkOptionsEntries.end(); - std::vector::iterator btPosition = before - ? impl->LinkOptionsBacktraces.begin() - : impl->LinkOptionsBacktraces.end(); + auto btPosition = before ? impl->LinkOptionsBacktraces.begin() + : impl->LinkOptionsBacktraces.end(); impl->LinkOptionsEntries.insert(position, entry); impl->LinkOptionsBacktraces.insert(btPosition, bt); @@ -1412,13 +1407,11 @@ void cmTarget::InsertLinkOption(std::string const& entry, void cmTarget::InsertLinkDirectory(std::string const& entry, cmListFileBacktrace const& bt, bool before) { - std::vector::iterator position = before - ? impl->LinkDirectoriesEntries.begin() - : impl->LinkDirectoriesEntries.end(); + auto position = before ? impl->LinkDirectoriesEntries.begin() + : impl->LinkDirectoriesEntries.end(); - std::vector::iterator btPosition = before - ? impl->LinkDirectoriesBacktraces.begin() - : impl->LinkDirectoriesBacktraces.end(); + auto btPosition = before ? impl->LinkDirectoriesBacktraces.begin() + : impl->LinkDirectoriesBacktraces.end(); impl->LinkDirectoriesEntries.insert(position, entry); impl->LinkDirectoriesBacktraces.insert(btPosition, bt); @@ -1496,8 +1489,7 @@ static void cmTargetCheckIMPORTED_GLOBAL(const cmTarget* target, cmMakefile* context) { std::vector targets = context->GetOwnedImportedTargets(); - std::vector::const_iterator it = - std::find(targets.begin(), targets.end(), target); + auto it = std::find(targets.begin(), targets.end(), target); if (it == targets.end()) { std::ostringstream e; e << "Attempt to promote imported target \"" << target->GetName() @@ -1947,7 +1939,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, (this->IsAIX() && this->IsExecutableWithExports()); // If a mapping was found, check its configurations. - for (std::vector::const_iterator mci = mappedConfigs.begin(); + for (auto mci = mappedConfigs.begin(); !*loc && !*imp && mci != mappedConfigs.end(); ++mci) { // Look for this configuration. if (mci->empty()) { @@ -2018,8 +2010,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, if (const char* iconfigs = this->GetProperty("IMPORTED_CONFIGURATIONS")) { cmExpandList(iconfigs, availableConfigs); } - for (std::vector::const_iterator aci = - availableConfigs.begin(); + for (auto aci = availableConfigs.begin(); !*loc && !*imp && aci != availableConfigs.end(); ++aci) { suffix = cmStrCat('_', cmSystemTools::UpperCase(*aci)); std::string locProp = cmStrCat(locPropBase, suffix); diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx index 25fe4ad..6b3590f 100644 --- a/Source/cmUtilitySourceCommand.cxx +++ b/Source/cmUtilitySourceCommand.cxx @@ -20,7 +20,7 @@ bool cmUtilitySourceCommand(std::vector const& args, return false; } - std::vector::const_iterator arg = args.begin(); + auto arg = args.begin(); // The first argument is the cache entry name. std::string const& cacheEntry = *arg++; diff --git a/Source/cmVariableWatch.cxx b/Source/cmVariableWatch.cxx index 3df1420..4995da9 100644 --- a/Source/cmVariableWatch.cxx +++ b/Source/cmVariableWatch.cxx @@ -66,8 +66,7 @@ bool cmVariableWatch::VariableAccessed(const std::string& variable, int access_type, const char* newValue, const cmMakefile* mf) const { - cmVariableWatch::StringToVectorOfPairs::const_iterator mit = - this->WatchMap.find(variable); + auto mit = this->WatchMap.find(variable); if (mit != this->WatchMap.end()) { // The strategy here is to copy the list of callbacks, and ignore // new callbacks that existing ones may add. diff --git a/Source/cmWriteFileCommand.cxx b/Source/cmWriteFileCommand.cxx index 5009b16..fdf07bb 100644 --- a/Source/cmWriteFileCommand.cxx +++ b/Source/cmWriteFileCommand.cxx @@ -19,7 +19,7 @@ bool cmWriteFileCommand(std::vector const& args, return false; } std::string message; - std::vector::const_iterator i = args.begin(); + auto i = args.begin(); std::string const& fileName = *i; bool overwrite = true; diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h index 0552676..d9be3d2 100644 --- a/Source/cmXCodeObject.h +++ b/Source/cmXCodeObject.h @@ -106,8 +106,7 @@ public: bool HasComment() const { return (!this->Comment.empty()); } cmXCodeObject* GetObject(const char* name) const { - std::map::const_iterator i = - this->ObjectAttributes.find(name); + auto const i = this->ObjectAttributes.find(name); if (i != this->ObjectAttributes.end()) { return i->second; } diff --git a/Source/cmake.cxx b/Source/cmake.cxx index e7c714e..170e09b 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1271,8 +1271,7 @@ int cmake::HandleDeleteCacheVariables(const std::string& var) << "Configure will be re-run and you may have to reset some variables.\n" << "The following variables have changed:\n"; /* clang-format on */ - for (std::vector::iterator i = argsSplit.begin(); - i != argsSplit.end(); ++i) { + for (auto i = argsSplit.begin(); i != argsSplit.end(); ++i) { SaveCacheEntry save; save.key = *i; warning << *i << "= "; @@ -2188,7 +2187,7 @@ int cmake::CheckBuildSystem() } // Find the newest dependency. - std::vector::iterator dep = depends.begin(); + auto dep = depends.begin(); std::string dep_newest = *dep++; for (; dep != depends.end(); ++dep) { int result = 0; @@ -2206,7 +2205,7 @@ int cmake::CheckBuildSystem() } // Find the oldest output. - std::vector::iterator out = outputs.begin(); + auto out = outputs.begin(); std::string out_oldest = *out++; for (; out != outputs.end(); ++out) { int result = 0; @@ -2308,8 +2307,7 @@ bool cmake::GetPropertyAsBool(const std::string& prop) cmInstalledFile* cmake::GetOrCreateInstalledFile(cmMakefile* mf, const std::string& name) { - std::map::iterator i = - this->InstalledFiles.find(name); + auto i = this->InstalledFiles.find(name); if (i != this->InstalledFiles.end()) { cmInstalledFile& file = i->second; @@ -2322,8 +2320,7 @@ cmInstalledFile* cmake::GetOrCreateInstalledFile(cmMakefile* mf, cmInstalledFile const* cmake::GetInstalledFile(const std::string& name) const { - std::map::const_iterator i = - this->InstalledFiles.find(name); + auto i = this->InstalledFiles.find(name); if (i != this->InstalledFiles.end()) { cmInstalledFile const& file = i->second; diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index e6dd99a..ba2ba33 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -1730,7 +1730,7 @@ bool cmVSLink::Parse(std::vector::const_iterator argBeg, { // Parse our own arguments. std::string intDir; - std::vector::const_iterator arg = argBeg; + auto arg = argBeg; while (arg != argEnd && cmHasLiteralPrefix(*arg, "-")) { if (*arg == "--") { ++arg; diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx index b1541e2..010e17a 100644 --- a/Tests/CMakeLib/run_compile_commands.cxx +++ b/Tests/CMakeLib/run_compile_commands.cxx @@ -18,7 +18,7 @@ public: public: std::string const& at(std::string const& k) const { - const_iterator i = this->find(k); + auto i = this->find(k); if (i != this->end()) { return i->second; } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8a18bb7cdf2478d68e11a5e532b5134ea92b3678 commit 8a18bb7cdf2478d68e11a5e532b5134ea92b3678 Author: Regina Pfeifer AuthorDate: Tue Sep 10 21:44:48 2019 +0200 Commit: Regina Pfeifer CommitDate: Tue Sep 10 22:13:11 2019 +0200 cmFind*: Port away from cmCommand diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 702b743..dfe130e 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -125,14 +125,11 @@ void GetScriptingCommands(cmState* state) state->AddBuiltinCommand("exec_program", cmExecProgramCommand); state->AddBuiltinCommand("execute_process", cmExecuteProcessCommand); state->AddBuiltinCommand("file", cmFileCommand); - state->AddBuiltinCommand("find_file", cm::make_unique()); - state->AddBuiltinCommand("find_library", - cm::make_unique()); - state->AddBuiltinCommand("find_package", - cm::make_unique()); - state->AddBuiltinCommand("find_path", cm::make_unique()); - state->AddBuiltinCommand("find_program", - cm::make_unique()); + state->AddBuiltinCommand("find_file", cmFindFile); + state->AddBuiltinCommand("find_library", cmFindLibrary); + state->AddBuiltinCommand("find_package", cmFindPackage); + state->AddBuiltinCommand("find_path", cmFindPath); + state->AddBuiltinCommand("find_program", cmFindProgram); state->AddBuiltinCommand("foreach", cmForEachCommand); state->AddBuiltinCommand("function", cmFunctionCommand); state->AddBuiltinCommand("get_cmake_property", cmGetCMakePropertyCommand); diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index cdc5f63..e0daa4f 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -16,7 +16,10 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -cmFindBase::cmFindBase() +class cmExecutionStatus; + +cmFindBase::cmFindBase(cmExecutionStatus& status) + : cmFindCommon(status) { this->AlreadyInCache = false; this->AlreadyInCacheWithoutMetaInfo = false; diff --git a/Source/cmFindBase.h b/Source/cmFindBase.h index 88b5b6c..f75db5f 100644 --- a/Source/cmFindBase.h +++ b/Source/cmFindBase.h @@ -10,6 +10,8 @@ #include "cmFindCommon.h" +class cmExecutionStatus; + /** \class cmFindBase * \brief Base class for most FIND_XXX commands. * @@ -19,7 +21,9 @@ class cmFindBase : public cmFindCommon { public: - cmFindBase(); + cmFindBase(cmExecutionStatus& status); + virtual ~cmFindBase() = default; + /** * This is called when the command is first encountered in * the CMakeLists.txt file. diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index 9425f99..5606838 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -8,6 +8,7 @@ #include #include "cmAlgorithms.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -24,7 +25,9 @@ cmFindCommon::PathLabel cmFindCommon::PathLabel::SystemEnvironment( cmFindCommon::PathLabel cmFindCommon::PathLabel::CMakeSystem("CMAKE_SYSTEM"); cmFindCommon::PathLabel cmFindCommon::PathLabel::Guess("GUESS"); -cmFindCommon::cmFindCommon() +cmFindCommon::cmFindCommon(cmExecutionStatus& status) + : Makefile(&status.GetMakefile()) + , Status(status) { this->FindRootPathMode = RootPathModeBoth; this->NoDefaultPath = false; @@ -51,7 +54,10 @@ cmFindCommon::cmFindCommon() this->InitializeSearchPathGroups(); } -cmFindCommon::~cmFindCommon() = default; +void cmFindCommon::SetError(std::string const& e) +{ + this->Status.SetError(e); +} void cmFindCommon::InitializeSearchPathGroups() { diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h index d95eeb1..8177eac 100644 --- a/Source/cmFindCommon.h +++ b/Source/cmFindCommon.h @@ -10,10 +10,12 @@ #include #include -#include "cmCommand.h" #include "cmPathLabel.h" #include "cmSearchPath.h" +class cmExecutionStatus; +class cmMakefile; + /** \class cmFindCommon * \brief Base class for FIND_XXX implementations. * @@ -21,11 +23,12 @@ * cmFindProgramCommand, cmFindPathCommand, cmFindLibraryCommand, * cmFindFileCommand, and cmFindPackageCommand. */ -class cmFindCommon : public cmCommand +class cmFindCommon { public: - cmFindCommon(); - ~cmFindCommon() override; + cmFindCommon(cmExecutionStatus& status); + + void SetError(std::string const& e); protected: friend class cmSearchPath; @@ -127,6 +130,9 @@ protected: bool SearchAppBundleFirst; bool SearchAppBundleOnly; bool SearchAppBundleLast; + + cmMakefile* Makefile; + cmExecutionStatus& Status; }; #endif diff --git a/Source/cmFindFileCommand.cxx b/Source/cmFindFileCommand.cxx index 9840c4f..29a2bc4 100644 --- a/Source/cmFindFileCommand.cxx +++ b/Source/cmFindFileCommand.cxx @@ -2,7 +2,16 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmFindFileCommand.h" -cmFindFileCommand::cmFindFileCommand() +class cmExecutionStatus; + +cmFindFileCommand::cmFindFileCommand(cmExecutionStatus& status) + : cmFindPathCommand(status) { this->IncludeFileInPath = true; } + +bool cmFindFile(std::vector const& args, + cmExecutionStatus& status) +{ + return cmFindFileCommand(status).InitialPass(args); +} diff --git a/Source/cmFindFileCommand.h b/Source/cmFindFileCommand.h index 152b505..7dc6e55 100644 --- a/Source/cmFindFileCommand.h +++ b/Source/cmFindFileCommand.h @@ -5,11 +5,13 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include "cm_memory.hxx" +#include +#include -#include "cmCommand.h" #include "cmFindPathCommand.h" +class cmExecutionStatus; + /** \class cmFindFileCommand * \brief Define a command to search for an executable program. * @@ -21,14 +23,10 @@ class cmFindFileCommand : public cmFindPathCommand { public: - cmFindFileCommand(); - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } + cmFindFileCommand(cmExecutionStatus& status); }; +bool cmFindFile(std::vector const& args, + cmExecutionStatus& status); + #endif diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index 92c64c8..529e5c8 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -18,15 +18,15 @@ class cmExecutionStatus; -cmFindLibraryCommand::cmFindLibraryCommand() +cmFindLibraryCommand::cmFindLibraryCommand(cmExecutionStatus& status) + : cmFindBase(status) { this->EnvironmentPath = "LIB"; this->NamesPerDirAllowed = true; } // cmFindLibraryCommand -bool cmFindLibraryCommand::InitialPass(std::vector const& argsIn, - cmExecutionStatus&) +bool cmFindLibraryCommand::InitialPass(std::vector const& argsIn) { this->VariableDocumentation = "Path to a library."; this->CMakePathName = "LIBRARY"; @@ -490,3 +490,9 @@ std::string cmFindLibraryCommand::FindFrameworkLibraryDirsPerName() // No framework found. return ""; } + +bool cmFindLibrary(std::vector const& args, + cmExecutionStatus& status) +{ + return cmFindLibraryCommand(status).InitialPass(args); +} diff --git a/Source/cmFindLibraryCommand.h b/Source/cmFindLibraryCommand.h index af17d60..b2f71b3 100644 --- a/Source/cmFindLibraryCommand.h +++ b/Source/cmFindLibraryCommand.h @@ -8,9 +8,6 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" #include "cmFindBase.h" class cmExecutionStatus; @@ -25,21 +22,9 @@ class cmExecutionStatus; class cmFindLibraryCommand : public cmFindBase { public: - cmFindLibraryCommand(); - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; + cmFindLibraryCommand(cmExecutionStatus& status); + + bool InitialPass(std::vector const& args); protected: void AddArchitecturePaths(const char* suffix); @@ -57,4 +42,7 @@ private: std::string FindFrameworkLibraryDirsPerName(); }; +bool cmFindLibrary(std::vector const& args, + cmExecutionStatus& status); + #endif diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 9132760..d99b20b 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -85,7 +85,8 @@ void cmFindPackageCommand::Sort(std::vector::iterator begin, // else do not sort } -cmFindPackageCommand::cmFindPackageCommand() +cmFindPackageCommand::cmFindPackageCommand(cmExecutionStatus& status) + : cmFindCommon(status) { this->CMakePathName = "PACKAGE"; this->Quiet = false; @@ -143,8 +144,7 @@ void cmFindPackageCommand::AppendSearchPathGroups() std::make_pair(PathLabel::SystemRegistry, cmSearchPath(this))); } -bool cmFindPackageCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +bool cmFindPackageCommand::InitialPass(std::vector const& args) { if (args.empty()) { this->SetError("called with incorrect number of arguments"); @@ -2282,3 +2282,9 @@ bool cmFindPackageCommand::SearchAppBundlePrefix(std::string const& prefix_in) } // TODO: Debug cmsys::Glob double slash problem. + +bool cmFindPackage(std::vector const& args, + cmExecutionStatus& status) +{ + return cmFindPackageCommand(status).InitialPass(args); +} diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index d57b38a..78b4985 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -3,9 +3,7 @@ #ifndef cmFindPackageCommand_h #define cmFindPackageCommand_h -#include "cmCommand.h" #include "cmConfigure.h" // IWYU pragma: keep -#include "cmPolicies.h" #include "cm_kwiml.h" #include @@ -15,7 +13,8 @@ #include #include -#include "cm_memory.hxx" +#include "cmFindCommon.h" +#include "cmPolicies.h" // IWYU insists we should forward-declare instead of including , // but we cannot forward-declare reliably because some C++ standard libraries @@ -28,8 +27,6 @@ namespace std { /* clang-format on */ #endif -#include "cmFindCommon.h" - class cmExecutionStatus; class cmSearchPath; @@ -62,22 +59,9 @@ public: std::vector::iterator end, SortOrderType order, SortDirectionType dir); - cmFindPackageCommand(); + cmFindPackageCommand(cmExecutionStatus& status); - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; + bool InitialPass(std::vector const& args); private: class PathLabel : public cmFindCommon::PathLabel @@ -246,4 +230,7 @@ struct hash }; } +bool cmFindPackage(std::vector const& args, + cmExecutionStatus& status); + #endif diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx index 41f5e51..f5e2631 100644 --- a/Source/cmFindPathCommand.cxx +++ b/Source/cmFindPathCommand.cxx @@ -11,15 +11,15 @@ class cmExecutionStatus; -cmFindPathCommand::cmFindPathCommand() +cmFindPathCommand::cmFindPathCommand(cmExecutionStatus& status) + : cmFindBase(status) { this->EnvironmentPath = "INCLUDE"; this->IncludeFileInPath = false; } // cmFindPathCommand -bool cmFindPathCommand::InitialPass(std::vector const& argsIn, - cmExecutionStatus&) +bool cmFindPathCommand::InitialPass(std::vector const& argsIn) { this->VariableDocumentation = "Path to a file."; this->CMakePathName = "INCLUDE"; @@ -145,3 +145,9 @@ std::string cmFindPathCommand::FindFrameworkHeader() } return ""; } + +bool cmFindPath(std::vector const& args, + cmExecutionStatus& status) +{ + return cmFindPathCommand(status).InitialPass(args); +} diff --git a/Source/cmFindPathCommand.h b/Source/cmFindPathCommand.h index 89e2cef..8d1ea8b 100644 --- a/Source/cmFindPathCommand.h +++ b/Source/cmFindPathCommand.h @@ -8,9 +8,6 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" #include "cmFindBase.h" class cmExecutionStatus; @@ -25,21 +22,9 @@ class cmExecutionStatus; class cmFindPathCommand : public cmFindBase { public: - cmFindPathCommand(); - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; + cmFindPathCommand(cmExecutionStatus& status); + + bool InitialPass(std::vector const& args); bool IncludeFileInPath; @@ -51,4 +36,7 @@ private: std::string FindFrameworkHeader(); }; +bool cmFindPath(std::vector const& args, + cmExecutionStatus& status); + #endif diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx index a2db65c..e0a3fbf 100644 --- a/Source/cmFindProgramCommand.cxx +++ b/Source/cmFindProgramCommand.cxx @@ -88,14 +88,14 @@ struct cmFindProgramHelper } }; -cmFindProgramCommand::cmFindProgramCommand() +cmFindProgramCommand::cmFindProgramCommand(cmExecutionStatus& status) + : cmFindBase(status) { this->NamesPerDirAllowed = true; } // cmFindProgramCommand -bool cmFindProgramCommand::InitialPass(std::vector const& argsIn, - cmExecutionStatus&) +bool cmFindProgramCommand::InitialPass(std::vector const& argsIn) { this->VariableDocumentation = "Path to a program."; this->CMakePathName = "PROGRAM"; @@ -270,3 +270,9 @@ std::string cmFindProgramCommand::GetBundleExecutable( return executable; } + +bool cmFindProgram(std::vector const& args, + cmExecutionStatus& status) +{ + return cmFindProgramCommand(status).InitialPass(args); +} diff --git a/Source/cmFindProgramCommand.h b/Source/cmFindProgramCommand.h index 40e455e..043b43c 100644 --- a/Source/cmFindProgramCommand.h +++ b/Source/cmFindProgramCommand.h @@ -8,9 +8,6 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" #include "cmFindBase.h" class cmExecutionStatus; @@ -26,21 +23,9 @@ class cmExecutionStatus; class cmFindProgramCommand : public cmFindBase { public: - cmFindProgramCommand(); - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; + cmFindProgramCommand(cmExecutionStatus& status); + + bool InitialPass(std::vector const& args); private: std::string FindProgram(); @@ -51,4 +36,7 @@ private: std::string GetBundleExecutable(std::string const& bundlePath); }; +bool cmFindProgram(std::vector const& args, + cmExecutionStatus& status); + #endif ----------------------------------------------------------------------- Summary of changes: .clang-tidy | 3 +- Source/CPack/IFW/cmCPackIFWGenerator.cxx | 28 +++++------- Source/CPack/IFW/cmCPackIFWPackage.cxx | 6 +-- Source/CPack/cmCPackGeneratorFactory.cxx | 3 +- Source/CPack/cmCPackRPMGenerator.cxx | 9 ++-- Source/CTest/cmCTestCoverageHandler.cxx | 13 +++--- Source/CTest/cmCTestGenericHandler.cxx | 9 ++-- Source/CTest/cmCTestP4.cxx | 3 +- Source/CTest/cmCTestRunTest.cxx | 3 +- Source/CTest/cmCTestSVN.cxx | 2 +- Source/CTest/cmCTestTestHandler.cxx | 27 ++++-------- Source/CTest/cmParseCacheCoverage.cxx | 3 +- Source/CTest/cmParseMumpsCoverage.cxx | 3 +- Source/QtDialog/FirstConfigure.cxx | 3 +- Source/cmAddExecutableCommand.cxx | 2 +- Source/cmAddLibraryCommand.cxx | 2 +- Source/cmAlgorithms.h | 6 +-- Source/cmCPluginAPI.cxx | 2 +- Source/cmCTest.cxx | 3 +- Source/cmCacheManager.cxx | 6 +-- Source/cmCommands.cxx | 13 +++--- Source/cmCommonTargetGenerator.cxx | 6 +-- Source/cmComputeLinkDepends.cxx | 11 ++--- Source/cmComputeLinkInformation.cxx | 3 +- Source/cmComputeTargetDepends.cxx | 8 ++-- Source/cmConditionEvaluator.cxx | 12 ++--- Source/cmCreateTestSourceList.cxx | 4 +- Source/cmDepends.cxx | 3 +- Source/cmDependsC.cxx | 3 +- Source/cmDependsFortran.cxx | 12 ++--- Source/cmDynamicLoader.cxx | 6 +-- Source/cmELF.cxx | 6 +-- Source/cmExportFileGenerator.cxx | 2 +- Source/cmExportSetMap.cxx | 2 +- Source/cmExtraCodeBlocksGenerator.cxx | 3 +- Source/cmExtraCodeLiteGenerator.cxx | 2 +- Source/cmExtraEclipseCDT4Generator.cxx | 4 +- Source/cmExtraSublimeTextGenerator.cxx | 2 +- Source/cmFileAPICodemodel.cxx | 3 +- Source/cmFileCommand.cxx | 8 ++-- Source/cmFindBase.cxx | 5 ++- Source/cmFindBase.h | 6 ++- Source/cmFindCommon.cxx | 10 ++++- Source/cmFindCommon.h | 14 ++++-- Source/cmFindFileCommand.cxx | 11 ++++- Source/cmFindFileCommand.h | 18 ++++---- Source/cmFindLibraryCommand.cxx | 12 +++-- Source/cmFindLibraryCommand.h | 24 +++------- Source/cmFindPackageCommand.cxx | 22 ++++++---- Source/cmFindPackageCommand.h | 27 +++--------- Source/cmFindPathCommand.cxx | 12 +++-- Source/cmFindPathCommand.h | 24 +++------- Source/cmFindProgramCommand.cxx | 12 +++-- Source/cmFindProgramCommand.h | 24 +++------- Source/cmFunctionCommand.cxx | 3 +- Source/cmGeneratorExpression.cxx | 4 +- Source/cmGeneratorExpressionDAGChecker.cxx | 3 +- Source/cmGeneratorExpressionEvaluationFile.cxx | 3 +- Source/cmGeneratorExpressionEvaluator.cxx | 11 ++--- Source/cmGeneratorExpressionParser.cxx | 13 ++---- Source/cmGeneratorTarget.cxx | 47 ++++++++------------ Source/cmGetDirectoryPropertyCommand.cxx | 2 +- Source/cmGhsMultiTargetGenerator.cxx | 9 ++-- Source/cmGlobalUnixMakefileGenerator3.cxx | 3 +- Source/cmGlobalXCodeGenerator.cxx | 21 +++------ Source/cmGraphVizWriter.cxx | 18 +++----- Source/cmIncludeDirectoryCommand.cxx | 2 +- Source/cmInstallFilesCommand.cxx | 4 +- Source/cmInstallProgramsCommand.cxx | 4 +- Source/cmInstallTargetsCommand.cxx | 4 +- Source/cmInstalledFile.cxx | 2 +- Source/cmLinkLibrariesCommand.cxx | 3 +- Source/cmListCommand.cxx | 32 ++++++-------- Source/cmLocalGenerator.cxx | 15 +++---- Source/cmLocalNinjaGenerator.cxx | 8 ++-- Source/cmLocalUnixMakefileGenerator3.cxx | 13 +++--- Source/cmMacroCommand.cxx | 3 +- Source/cmMakefile.cxx | 43 ++++++++---------- Source/cmMakefileLibraryTargetGenerator.cxx | 2 +- Source/cmOrderDirectories.cxx | 14 +++--- Source/cmOutputRequiredFilesCommand.cxx | 5 +-- Source/cmParseArgumentsCommand.cxx | 4 +- Source/cmPropertyDefinitionMap.cxx | 4 +- Source/cmQtAutoGen.cxx | 10 ++--- Source/cmQtAutoMocUic.cxx | 2 +- Source/cmRST.cxx | 11 +++-- Source/cmRulePlaceholderExpander.cxx | 6 +-- Source/cmSetPropertyCommand.cxx | 3 +- Source/cmSourceGroupCommand.cxx | 3 +- Source/cmState.cxx | 10 ++--- Source/cmStateDirectory.cxx | 51 ++++++++-------------- Source/cmStateSnapshot.cxx | 18 +++----- Source/cmSystemTools.cxx | 7 ++- Source/cmTarget.cxx | 45 ++++++++----------- Source/cmUVStreambuf.h | 2 +- Source/cmUtilitySourceCommand.cxx | 2 +- Source/cmVariableWatch.cxx | 3 +- Source/cmWriteFileCommand.cxx | 2 +- Source/cmXCodeObject.h | 3 +- Source/cmake.cxx | 13 +++--- Source/cmcmd.cxx | 2 +- Tests/CMakeLib/run_compile_commands.cxx | 2 +- .../WiX/CustomAction/detect_nsis_overwrite.cpp | 3 +- 103 files changed, 403 insertions(+), 564 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Fri Sep 13 00:02:11 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 13 Sep 2019 00:02:11 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1015-g729c928 Message-ID: <20190913040211.A06951252B4@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 729c928c7b59919a9d379891973bda22665c75da (commit) from 9602bcfc62d50d7bb302b02ae3b1f9afe941bae7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=729c928c7b59919a9d379891973bda22665c75da commit 729c928c7b59919a9d379891973bda22665c75da Author: Kitware Robot AuthorDate: Fri Sep 13 00:01:11 2019 -0400 Commit: Kitware Robot CommitDate: Fri Sep 13 00:01:11 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index fc86b56..e9cca30 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 15) -set(CMake_VERSION_PATCH 20190912) +set(CMake_VERSION_PATCH 20190913) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Fri Sep 13 10:02:00 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 13 Sep 2019 10:02:00 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1043-g19bcdca Message-ID: <20190913140200.129C2FD531@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 19bcdca93c3a05db12652677f8d0e310797bb375 (commit) via 0b8c0b26ce076952bfdc0392d2c93c3597974c9f (commit) via bacb50afa9ed7806a8900ab7524f2f4a4cd7d669 (commit) via a81e9a0ced25490d1384316834dff36a55d4e864 (commit) via 573cd4e4b43d8d3b75f6e7c420b5f833cdd2120e (commit) via 95f23ea5d5a07da503f8e2ab9c52c82086cdcae4 (commit) via 706400d417e6435a442af2626a8430016e24aa9d (commit) via 7f8699026211c6a3055e767125021a91da4b1393 (commit) via 56bfb8de5d1ddc3a499b03be8ae75c9832b6f878 (commit) via 83b3f76a3b13ffe2d8bdf3f67c20e36e22a6955f (commit) via b85407ae76951649907e8e5675fe17d65dfd5457 (commit) via d55319c01d5482ff31166750717252e1b49f1e69 (commit) via fb5affe0859ae1bc07d059fc11cee3daca4d8780 (commit) via 242d876d7b919fe6efb3a347dfa35a66e3ef58df (commit) via 06a2e764f0f088a212e20b85e364b5621ef639fe (commit) via b46970cfe9e0c96a9794acb49fc580565bcd6e91 (commit) via 0b95c64e43e5f60ee9c60570f359a40e4e882096 (commit) via e4c67981aca4fd736fd7503d9d105a0a6fb43828 (commit) via 36b939db682a9405790bee76f95673eeaeb445b8 (commit) via 28cf1271ed6051af46ff68f52a8c9c0435ca1234 (commit) via 41b0d60f48c3d8d882ec25b56d638b392121fcc8 (commit) via f717e1fccf2968ffeba36dc84e428abd4f8db5c0 (commit) via f0ecb123981c6b383a55f7d75e023cf4310f2074 (commit) via 482d858500a42a63c97d3dc11ae74d81a10bab3f (commit) via f6574c9a816ffda7d9ff8c3f2e4ce0485cf28894 (commit) via 2edb0b71edd36031f2fcc0b65633c1c16f8e9268 (commit) via 62d59323899330197e795872c13c1d300a97d088 (commit) via d69457077d021b7d4ea10bf2201da61222966c92 (commit) from 729c928c7b59919a9d379891973bda22665c75da (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=19bcdca93c3a05db12652677f8d0e310797bb375 commit 19bcdca93c3a05db12652677f8d0e310797bb375 Merge: 0b8c0b2 482d858 Author: Brad King AuthorDate: Fri Sep 13 13:56:02 2019 +0000 Commit: Kitware Robot CommitDate: Fri Sep 13 09:56:20 2019 -0400 Merge topic 'target-level-dependencies-via-byproducts' 482d858500 Depend: Add test for target-level dependencies via byproducts f6574c9a81 Depend: Hook up automatic target-level dependencies via byproducts 2edb0b71ed cmMakefile: Add lookup from source name to targets via byproducts 62d5932389 Refatoring: Extract AnyOutputMatches utility Acked-by: Kitware Robot Merge-request: !3806 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0b8c0b26ce076952bfdc0392d2c93c3597974c9f commit 0b8c0b26ce076952bfdc0392d2c93c3597974c9f Merge: bacb50a d694570 Author: Brad King AuthorDate: Fri Sep 13 13:53:16 2019 +0000 Commit: Kitware Robot CommitDate: Fri Sep 13 09:53:41 2019 -0400 Merge topic 'cpack-wix-start-menu' d69457077d CPackWIX: Allow omitting program menu folder and uninstall shortcut Acked-by: Kitware Robot Merge-request: !3802 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bacb50afa9ed7806a8900ab7524f2f4a4cd7d669 commit bacb50afa9ed7806a8900ab7524f2f4a4cd7d669 Merge: 729c928 a81e9a0 Author: Brad King AuthorDate: Fri Sep 13 13:52:23 2019 +0000 Commit: Kitware Robot CommitDate: Fri Sep 13 09:52:34 2019 -0400 Merge topic 'free-free-set-them-free' a81e9a0ced cmSubdirCommand: Port away from cmCommand 573cd4e4b4 cmSetTestsPropertiesCommand: Port away from cmCommand 95f23ea5d5 cmSetSourceFilesPropertiesCommand: Port away from cmCommand 706400d417 cmRemoveDefinitionsCommand: Port away from cmCommand 7f86990262 cmQTWrapUICommand: Port away from cmCommand 56bfb8de5d cmQTWrapCPPCommand: Port away from cmCommand 83b3f76a3b cmLinkLibrariesCommand: Port away from cmCommand b85407ae76 cmInstallTargetsCommand: Port away from cmCommand ... Acked-by: Kitware Robot Merge-request: !3807 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a81e9a0ced25490d1384316834dff36a55d4e864 commit a81e9a0ced25490d1384316834dff36a55d4e864 Author: Regina Pfeifer AuthorDate: Thu Sep 12 16:29:52 2019 +0200 Commit: Regina Pfeifer CommitDate: Thu Sep 12 18:16:17 2019 +0200 cmSubdirCommand: Port away from cmCommand Ref: #19499 diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 9fb07f2..38fcf5b 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -247,7 +247,7 @@ void GetProjectCommands(cmState* state) cm::make_unique()); state->AddBuiltinCommand("set_tests_properties", cmSetTestsPropertiesCommand); - state->AddBuiltinCommand("subdirs", cm::make_unique()); + state->AddBuiltinCommand("subdirs", cmSubdirCommand); state->AddBuiltinCommand( "target_compile_definitions", cm::make_unique()); diff --git a/Source/cmSubdirCommand.cxx b/Source/cmSubdirCommand.cxx index 07f8efe..2477d7a 100644 --- a/Source/cmSubdirCommand.cxx +++ b/Source/cmSubdirCommand.cxx @@ -2,22 +2,21 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmSubdirCommand.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -class cmExecutionStatus; - -// cmSubdirCommand -bool cmSubdirCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +bool cmSubdirCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.empty()) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } bool res = true; bool excludeFromAll = false; + cmMakefile& mf = status.GetMakefile(); for (std::string const& i : args) { if (i == "EXCLUDE_FROM_ALL") { @@ -30,24 +29,21 @@ bool cmSubdirCommand::InitialPass(std::vector const& args, } // if they specified a relative path then compute the full - std::string srcPath = - this->Makefile->GetCurrentSourceDirectory() + "/" + i; + std::string srcPath = mf.GetCurrentSourceDirectory() + "/" + i; if (cmSystemTools::FileIsDirectory(srcPath)) { - std::string binPath = - this->Makefile->GetCurrentBinaryDirectory() + "/" + i; - this->Makefile->AddSubDirectory(srcPath, binPath, excludeFromAll, false); + std::string binPath = mf.GetCurrentBinaryDirectory() + "/" + i; + mf.AddSubDirectory(srcPath, binPath, excludeFromAll, false); } // otherwise it is a full path else if (cmSystemTools::FileIsDirectory(i)) { // we must compute the binPath from the srcPath, we just take the last // element from the source path and use that - std::string binPath = this->Makefile->GetCurrentBinaryDirectory() + "/" + + std::string binPath = mf.GetCurrentBinaryDirectory() + "/" + cmSystemTools::GetFilenameName(i); - this->Makefile->AddSubDirectory(i, binPath, excludeFromAll, false); + mf.AddSubDirectory(i, binPath, excludeFromAll, false); } else { - std::string error = cmStrCat("Incorrect SUBDIRS command. Directory: ", i, - " does not exist."); - this->SetError(error); + status.SetError(cmStrCat("Incorrect SUBDIRS command. Directory: ", i, + " does not exist.")); res = false; } } diff --git a/Source/cmSubdirCommand.h b/Source/cmSubdirCommand.h index 3499c46..3254e84 100644 --- a/Source/cmSubdirCommand.h +++ b/Source/cmSubdirCommand.h @@ -8,36 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmSubdirCommand - * \brief Specify a list of subdirectories to build. - * - * cmSubdirCommand specifies a list of subdirectories to process - * by CMake. For each subdirectory listed, CMake will descend - * into that subdirectory and process any CMakeLists.txt found. - */ -class cmSubdirCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmSubdirCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=573cd4e4b43d8d3b75f6e7c420b5f833cdd2120e commit 573cd4e4b43d8d3b75f6e7c420b5f833cdd2120e Author: Regina Pfeifer AuthorDate: Thu Sep 12 16:28:59 2019 +0200 Commit: Regina Pfeifer CommitDate: Thu Sep 12 18:16:17 2019 +0200 cmSetTestsPropertiesCommand: Port away from cmCommand Ref: #19499 diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index b627433..9fb07f2 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -246,7 +246,7 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("set_target_properties", cm::make_unique()); state->AddBuiltinCommand("set_tests_properties", - cm::make_unique()); + cmSetTestsPropertiesCommand); state->AddBuiltinCommand("subdirs", cm::make_unique()); state->AddBuiltinCommand( "target_compile_definitions", diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx index ed909c6..de61eda 100644 --- a/Source/cmSetTestsPropertiesCommand.cxx +++ b/Source/cmSetTestsPropertiesCommand.cxx @@ -5,21 +5,25 @@ #include #include "cmAlgorithms.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmStringAlgorithms.h" #include "cmTest.h" -class cmExecutionStatus; +static bool SetOneTest(const std::string& tname, + std::vector& propertyPairs, cmMakefile* mf, + std::string& errors); -// cmSetTestsPropertiesCommand -bool cmSetTestsPropertiesCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +bool cmSetTestsPropertiesCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.empty()) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } + cmMakefile& mf = status.GetMakefile(); + // first collect up the list of files std::vector propertyPairs; int numFiles = 0; @@ -29,7 +33,7 @@ bool cmSetTestsPropertiesCommand::InitialPass( // now loop through the rest of the arguments, new style ++j; if (std::distance(j, args.end()) % 2 != 0) { - this->SetError("called with incorrect number of arguments."); + status.SetError("called with incorrect number of arguments."); return false; } cmAppend(propertyPairs, j, args.end()); @@ -38,8 +42,8 @@ bool cmSetTestsPropertiesCommand::InitialPass( numFiles++; } if (propertyPairs.empty()) { - this->SetError("called with illegal arguments, maybe " - "missing a PROPERTIES specifier?"); + status.SetError("called with illegal arguments, maybe " + "missing a PROPERTIES specifier?"); return false; } @@ -47,10 +51,9 @@ bool cmSetTestsPropertiesCommand::InitialPass( int i; for (i = 0; i < numFiles; ++i) { std::string errors; - bool ret = cmSetTestsPropertiesCommand::SetOneTest(args[i], propertyPairs, - this->Makefile, errors); + bool ret = SetOneTest(args[i], propertyPairs, &mf, errors); if (!ret) { - this->SetError(errors); + status.SetError(errors); return ret; } } @@ -58,9 +61,9 @@ bool cmSetTestsPropertiesCommand::InitialPass( return true; } -bool cmSetTestsPropertiesCommand::SetOneTest( - const std::string& tname, std::vector& propertyPairs, - cmMakefile* mf, std::string& errors) +static bool SetOneTest(const std::string& tname, + std::vector& propertyPairs, cmMakefile* mf, + std::string& errors) { if (cmTest* test = mf->GetTest(tname)) { // now loop through all the props and set them diff --git a/Source/cmSetTestsPropertiesCommand.h b/Source/cmSetTestsPropertiesCommand.h index d73e95a..4b75464 100644 --- a/Source/cmSetTestsPropertiesCommand.h +++ b/Source/cmSetTestsPropertiesCommand.h @@ -8,31 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -class cmMakefile; - -class cmSetTestsPropertiesCommand : public cmCommand -{ -public: - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the input file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - static bool SetOneTest(const std::string& tname, - std::vector& propertyPairs, - cmMakefile* mf, std::string& errors); -}; +bool cmSetTestsPropertiesCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=95f23ea5d5a07da503f8e2ab9c52c82086cdcae4 commit 95f23ea5d5a07da503f8e2ab9c52c82086cdcae4 Author: Regina Pfeifer AuthorDate: Thu Sep 12 16:28:00 2019 +0200 Commit: Regina Pfeifer CommitDate: Thu Sep 12 18:16:17 2019 +0200 cmSetSourceFilesPropertiesCommand: Port away from cmCommand Ref: #19499 diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 03aed81..b627433 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -241,9 +241,8 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("link_directories", cm::make_unique()); state->AddBuiltinCommand("project", cm::make_unique()); - state->AddBuiltinCommand( - "set_source_files_properties", - cm::make_unique()); + state->AddBuiltinCommand("set_source_files_properties", + cmSetSourceFilesPropertiesCommand); state->AddBuiltinCommand("set_target_properties", cm::make_unique()); state->AddBuiltinCommand("set_tests_properties", diff --git a/Source/cmSetSourceFilesPropertiesCommand.cxx b/Source/cmSetSourceFilesPropertiesCommand.cxx index 8e3217f..7ff604b 100644 --- a/Source/cmSetSourceFilesPropertiesCommand.cxx +++ b/Source/cmSetSourceFilesPropertiesCommand.cxx @@ -2,18 +2,23 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmSetSourceFilesPropertiesCommand.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmSourceFile.h" #include "cmStringAlgorithms.h" -class cmExecutionStatus; +static bool RunCommand(cmMakefile* mf, + std::vector::const_iterator filebeg, + std::vector::const_iterator fileend, + std::vector::const_iterator propbeg, + std::vector::const_iterator propend, + std::string& errors); -// cmSetSourceFilesPropertiesCommand -bool cmSetSourceFilesPropertiesCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +bool cmSetSourceFilesPropertiesCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 2) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } @@ -29,22 +34,24 @@ bool cmSetSourceFilesPropertiesCommand::InitialPass( ++j; } + cmMakefile& mf = status.GetMakefile(); + // now call the worker function std::string errors; - bool ret = cmSetSourceFilesPropertiesCommand::RunCommand( - this->Makefile, args.begin(), args.begin() + numFiles, - args.begin() + numFiles, args.end(), errors); + bool ret = RunCommand(&mf, args.begin(), args.begin() + numFiles, + args.begin() + numFiles, args.end(), errors); if (!ret) { - this->SetError(errors); + status.SetError(errors); } return ret; } -bool cmSetSourceFilesPropertiesCommand::RunCommand( - cmMakefile* mf, std::vector::const_iterator filebeg, - std::vector::const_iterator fileend, - std::vector::const_iterator propbeg, - std::vector::const_iterator propend, std::string& errors) +static bool RunCommand(cmMakefile* mf, + std::vector::const_iterator filebeg, + std::vector::const_iterator fileend, + std::vector::const_iterator propbeg, + std::vector::const_iterator propend, + std::string& errors) { std::vector propertyPairs; bool generated = false; diff --git a/Source/cmSetSourceFilesPropertiesCommand.h b/Source/cmSetSourceFilesPropertiesCommand.h index 6fd6c41..5eef785 100644 --- a/Source/cmSetSourceFilesPropertiesCommand.h +++ b/Source/cmSetSourceFilesPropertiesCommand.h @@ -8,34 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -class cmMakefile; - -class cmSetSourceFilesPropertiesCommand : public cmCommand -{ -public: - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the input file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - static bool RunCommand(cmMakefile* mf, - std::vector::const_iterator filebeg, - std::vector::const_iterator fileend, - std::vector::const_iterator propbeg, - std::vector::const_iterator propend, - std::string& errors); -}; +bool cmSetSourceFilesPropertiesCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=706400d417e6435a442af2626a8430016e24aa9d commit 706400d417e6435a442af2626a8430016e24aa9d Author: Regina Pfeifer AuthorDate: Thu Sep 12 10:24:55 2019 +0200 Commit: Regina Pfeifer CommitDate: Thu Sep 12 18:16:17 2019 +0200 cmRemoveDefinitionsCommand: Port away from cmCommand Ref: #19499 diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index f8a0141..03aed81 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -291,8 +291,7 @@ void GetProjectCommands(cmState* state) cm::make_unique()); state->AddBuiltinCommand("qt_wrap_cpp", cmQTWrapCPPCommand); state->AddBuiltinCommand("qt_wrap_ui", cmQTWrapUICommand); - state->AddBuiltinCommand("remove_definitions", - cm::make_unique()); + state->AddBuiltinCommand("remove_definitions", cmRemoveDefinitionsCommand); state->AddBuiltinCommand("source_group", cm::make_unique()); diff --git a/Source/cmRemoveDefinitionsCommand.cxx b/Source/cmRemoveDefinitionsCommand.cxx index 8d3f688..339ff9d 100644 --- a/Source/cmRemoveDefinitionsCommand.cxx +++ b/Source/cmRemoveDefinitionsCommand.cxx @@ -2,21 +2,15 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmRemoveDefinitionsCommand.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" -class cmExecutionStatus; - -// cmRemoveDefinitionsCommand -bool cmRemoveDefinitionsCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +bool cmRemoveDefinitionsCommand(std::vector const& args, + cmExecutionStatus& status) { - // it is OK to have no arguments - if (args.empty()) { - return true; - } - + cmMakefile& mf = status.GetMakefile(); for (std::string const& i : args) { - this->Makefile->RemoveDefineFlag(i); + mf.RemoveDefineFlag(i); } return true; } diff --git a/Source/cmRemoveDefinitionsCommand.h b/Source/cmRemoveDefinitionsCommand.h index 85d01d4..868416b 100644 --- a/Source/cmRemoveDefinitionsCommand.h +++ b/Source/cmRemoveDefinitionsCommand.h @@ -8,36 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmRemoveDefinitionsCommand - * \brief Specify a list of compiler defines - * - * cmRemoveDefinitionsCommand specifies a list of compiler defines. - * These defines will - * be removed from the compile command. - */ -class cmRemoveDefinitionsCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmRemoveDefinitionsCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7f8699026211c6a3055e767125021a91da4b1393 commit 7f8699026211c6a3055e767125021a91da4b1393 Author: Regina Pfeifer AuthorDate: Thu Sep 12 10:23:36 2019 +0200 Commit: Regina Pfeifer CommitDate: Thu Sep 12 18:16:17 2019 +0200 cmQTWrapUICommand: Port away from cmCommand Ref: #19499 diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 79e91b3..f8a0141 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -290,7 +290,7 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("load_cache", cm::make_unique()); state->AddBuiltinCommand("qt_wrap_cpp", cmQTWrapCPPCommand); - state->AddBuiltinCommand("qt_wrap_ui", cm::make_unique()); + state->AddBuiltinCommand("qt_wrap_ui", cmQTWrapUICommand); state->AddBuiltinCommand("remove_definitions", cm::make_unique()); state->AddBuiltinCommand("source_group", diff --git a/Source/cmQTWrapUICommand.cxx b/Source/cmQTWrapUICommand.cxx index 8bc914f..b7b5efa 100644 --- a/Source/cmQTWrapUICommand.cxx +++ b/Source/cmQTWrapUICommand.cxx @@ -2,52 +2,50 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmQTWrapUICommand.h" +#include + #include "cmCustomCommandLines.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmRange.h" #include "cmSourceFile.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include - -class cmExecutionStatus; - -// cmQTWrapUICommand -bool cmQTWrapUICommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +bool cmQTWrapUICommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 4) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } + cmMakefile& mf = status.GetMakefile(); + // Get the uic and moc executables to run in the custom commands. - std::string const& uic_exe = - this->Makefile->GetRequiredDefinition("QT_UIC_EXECUTABLE"); - std::string const& moc_exe = - this->Makefile->GetRequiredDefinition("QT_MOC_EXECUTABLE"); + std::string const& uic_exe = mf.GetRequiredDefinition("QT_UIC_EXECUTABLE"); + std::string const& moc_exe = mf.GetRequiredDefinition("QT_MOC_EXECUTABLE"); // Get the variable holding the list of sources. std::string const& headerList = args[1]; std::string const& sourceList = args[2]; - std::string headerListValue = this->Makefile->GetSafeDefinition(headerList); - std::string sourceListValue = this->Makefile->GetSafeDefinition(sourceList); + std::string headerListValue = mf.GetSafeDefinition(headerList); + std::string sourceListValue = mf.GetSafeDefinition(sourceList); // Create rules for all sources listed. for (std::string const& arg : cmMakeRange(args).advance(3)) { - cmSourceFile* curr = this->Makefile->GetSource(arg); + cmSourceFile* curr = mf.GetSource(arg); // if we should wrap the class if (!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE"))) { // Compute the name of the files to generate. std::string srcName = cmSystemTools::GetFilenameWithoutLastExtension(arg); - std::string hName = cmStrCat(this->Makefile->GetCurrentBinaryDirectory(), - '/', srcName, ".h"); - std::string cxxName = cmStrCat( - this->Makefile->GetCurrentBinaryDirectory(), '/', srcName, ".cxx"); - std::string mocName = cmStrCat( - this->Makefile->GetCurrentBinaryDirectory(), "/moc_", srcName, ".cxx"); + std::string hName = + cmStrCat(mf.GetCurrentBinaryDirectory(), '/', srcName, ".h"); + std::string cxxName = + cmStrCat(mf.GetCurrentBinaryDirectory(), '/', srcName, ".cxx"); + std::string mocName = + cmStrCat(mf.GetCurrentBinaryDirectory(), "/moc_", srcName, ".cxx"); // Compute the name of the ui file from which to generate others. std::string uiName; @@ -55,9 +53,9 @@ bool cmQTWrapUICommand::InitialPass(std::vector const& args, uiName = arg; } else { if (curr && curr->GetIsGenerated()) { - uiName = this->Makefile->GetCurrentBinaryDirectory(); + uiName = mf.GetCurrentBinaryDirectory(); } else { - uiName = this->Makefile->GetCurrentSourceDirectory(); + uiName = mf.GetCurrentSourceDirectory(); } uiName += "/"; uiName += arg; @@ -109,25 +107,22 @@ bool cmQTWrapUICommand::InitialPass(std::vector const& args, std::string no_main_dependency; const char* no_comment = nullptr; const char* no_working_dir = nullptr; - this->Makefile->AddCustomCommandToOutput( - hName, depends, no_main_dependency, hCommandLines, no_comment, - no_working_dir); + mf.AddCustomCommandToOutput(hName, depends, no_main_dependency, + hCommandLines, no_comment, no_working_dir); depends.push_back(hName); - this->Makefile->AddCustomCommandToOutput( - cxxName, depends, no_main_dependency, cxxCommandLines, no_comment, - no_working_dir); + mf.AddCustomCommandToOutput(cxxName, depends, no_main_dependency, + cxxCommandLines, no_comment, no_working_dir); depends.clear(); depends.push_back(hName); - this->Makefile->AddCustomCommandToOutput( - mocName, depends, no_main_dependency, mocCommandLines, no_comment, - no_working_dir); + mf.AddCustomCommandToOutput(mocName, depends, no_main_dependency, + mocCommandLines, no_comment, no_working_dir); } } // Store the final list of source files and headers. - this->Makefile->AddDefinition(sourceList, sourceListValue); - this->Makefile->AddDefinition(headerList, headerListValue); + mf.AddDefinition(sourceList, sourceListValue); + mf.AddDefinition(headerList, headerListValue); return true; } diff --git a/Source/cmQTWrapUICommand.h b/Source/cmQTWrapUICommand.h index 6a346d4..a17ef54 100644 --- a/Source/cmQTWrapUICommand.h +++ b/Source/cmQTWrapUICommand.h @@ -8,34 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmQTWrapUICommand - * \brief Create .h and .cxx files rules for Qt user interfaces files - * - * cmQTWrapUICommand is used to create wrappers for Qt classes into normal C++ - */ -class cmQTWrapUICommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmQTWrapUICommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=56bfb8de5d1ddc3a499b03be8ae75c9832b6f878 commit 56bfb8de5d1ddc3a499b03be8ae75c9832b6f878 Author: Regina Pfeifer AuthorDate: Thu Sep 12 10:22:50 2019 +0200 Commit: Regina Pfeifer CommitDate: Thu Sep 12 18:16:17 2019 +0200 cmQTWrapCPPCommand: Port away from cmCommand Ref: #19499 diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index ed6d24c..79e91b3 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -289,8 +289,7 @@ void GetProjectCommands(cmState* state) cm::make_unique()); state->AddBuiltinCommand("load_cache", cm::make_unique()); - state->AddBuiltinCommand("qt_wrap_cpp", - cm::make_unique()); + state->AddBuiltinCommand("qt_wrap_cpp", cmQTWrapCPPCommand); state->AddBuiltinCommand("qt_wrap_ui", cm::make_unique()); state->AddBuiltinCommand("remove_definitions", cm::make_unique()); diff --git a/Source/cmQTWrapCPPCommand.cxx b/Source/cmQTWrapCPPCommand.cxx index ba82813..1a5602b 100644 --- a/Source/cmQTWrapCPPCommand.cxx +++ b/Source/cmQTWrapCPPCommand.cxx @@ -2,45 +2,44 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmQTWrapCPPCommand.h" +#include + #include "cmCustomCommandLines.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmRange.h" #include "cmSourceFile.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include - -class cmExecutionStatus; - -// cmQTWrapCPPCommand -bool cmQTWrapCPPCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +bool cmQTWrapCPPCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 3) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } + cmMakefile& mf = status.GetMakefile(); + // Get the moc executable to run in the custom command. - std::string const& moc_exe = - this->Makefile->GetRequiredDefinition("QT_MOC_EXECUTABLE"); + std::string const& moc_exe = mf.GetRequiredDefinition("QT_MOC_EXECUTABLE"); // Get the variable holding the list of sources. std::string const& sourceList = args[1]; - std::string sourceListValue = this->Makefile->GetSafeDefinition(sourceList); + std::string sourceListValue = mf.GetSafeDefinition(sourceList); // Create a rule for all sources listed. for (std::string const& arg : cmMakeRange(args).advance(2)) { - cmSourceFile* curr = this->Makefile->GetSource(arg); + cmSourceFile* curr = mf.GetSource(arg); // if we should wrap the class if (!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE"))) { // Compute the name of the file to generate. std::string srcName = cmSystemTools::GetFilenameWithoutLastExtension(arg); - std::string newName = cmStrCat( - this->Makefile->GetCurrentBinaryDirectory(), "/moc_", srcName, ".cxx"); - cmSourceFile* sf = this->Makefile->GetOrCreateSource(newName, true); + std::string newName = + cmStrCat(mf.GetCurrentBinaryDirectory(), "/moc_", srcName, ".cxx"); + cmSourceFile* sf = mf.GetOrCreateSource(newName, true); if (curr) { sf->SetProperty("ABSTRACT", curr->GetProperty("ABSTRACT")); } @@ -51,9 +50,9 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector const& args, hname = arg; } else { if (curr && curr->GetIsGenerated()) { - hname = this->Makefile->GetCurrentBinaryDirectory(); + hname = mf.GetCurrentBinaryDirectory(); } else { - hname = this->Makefile->GetCurrentSourceDirectory(); + hname = mf.GetCurrentSourceDirectory(); } hname += "/"; hname += arg; @@ -81,13 +80,13 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector const& args, std::string no_main_dependency; const char* no_working_dir = nullptr; - this->Makefile->AddCustomCommandToOutput( - newName, depends, no_main_dependency, commandLines, "Qt Wrapped File", - no_working_dir); + mf.AddCustomCommandToOutput(newName, depends, no_main_dependency, + commandLines, "Qt Wrapped File", + no_working_dir); } } // Store the final list of source files. - this->Makefile->AddDefinition(sourceList, sourceListValue); + mf.AddDefinition(sourceList, sourceListValue); return true; } diff --git a/Source/cmQTWrapCPPCommand.h b/Source/cmQTWrapCPPCommand.h index 88a2210..75fa180 100644 --- a/Source/cmQTWrapCPPCommand.h +++ b/Source/cmQTWrapCPPCommand.h @@ -8,35 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmQTWrapCPPCommand - * \brief Create moc file rules for Qt classes - * - * cmQTWrapCPPCommand is used to create wrappers for Qt classes into - * normal C++ - */ -class cmQTWrapCPPCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmQTWrapCPPCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=83b3f76a3b13ffe2d8bdf3f67c20e36e22a6955f commit 83b3f76a3b13ffe2d8bdf3f67c20e36e22a6955f Author: Regina Pfeifer AuthorDate: Thu Sep 12 10:21:36 2019 +0200 Commit: Regina Pfeifer CommitDate: Thu Sep 12 18:16:17 2019 +0200 cmLinkLibrariesCommand: Port away from cmCommand Ref: #19499 diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index cb1f62b..ed6d24c 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -282,8 +282,7 @@ void GetProjectCommands(cmState* state) cmIncludeExternalMSProjectCommand); state->AddBuiltinCommand("install_programs", cmInstallProgramsCommand); state->AddBuiltinCommand("add_link_options", cmAddLinkOptionsCommand); - state->AddBuiltinCommand("link_libraries", - cm::make_unique()); + state->AddBuiltinCommand("link_libraries", cmLinkLibrariesCommand); state->AddBuiltinCommand("target_link_options", cm::make_unique()); state->AddBuiltinCommand("target_link_directories", diff --git a/Source/cmLinkLibrariesCommand.cxx b/Source/cmLinkLibrariesCommand.cxx index bf05310..cb63ceb 100644 --- a/Source/cmLinkLibrariesCommand.cxx +++ b/Source/cmLinkLibrariesCommand.cxx @@ -2,38 +2,37 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmLinkLibrariesCommand.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" -class cmExecutionStatus; - -// cmLinkLibrariesCommand -bool cmLinkLibrariesCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +bool cmLinkLibrariesCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.empty()) { return true; } + cmMakefile& mf = status.GetMakefile(); // add libraries, note that there is an optional prefix // of debug and optimized than can be used for (auto i = args.begin(); i != args.end(); ++i) { if (*i == "debug") { ++i; if (i == args.end()) { - this->SetError("The \"debug\" argument must be followed by " - "a library"); + status.SetError("The \"debug\" argument must be followed by " + "a library"); return false; } - this->Makefile->AppendProperty("LINK_LIBRARIES", "debug"); + mf.AppendProperty("LINK_LIBRARIES", "debug"); } else if (*i == "optimized") { ++i; if (i == args.end()) { - this->SetError("The \"optimized\" argument must be followed by " - "a library"); + status.SetError("The \"optimized\" argument must be followed by " + "a library"); return false; } - this->Makefile->AppendProperty("LINK_LIBRARIES", "optimized"); + mf.AppendProperty("LINK_LIBRARIES", "optimized"); } - this->Makefile->AppendProperty("LINK_LIBRARIES", i->c_str()); + mf.AppendProperty("LINK_LIBRARIES", i->c_str()); } return true; diff --git a/Source/cmLinkLibrariesCommand.h b/Source/cmLinkLibrariesCommand.h index 484ab0a..3412251 100644 --- a/Source/cmLinkLibrariesCommand.h +++ b/Source/cmLinkLibrariesCommand.h @@ -8,36 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmLinkLibrariesCommand - * \brief Specify a list of libraries to link into executables. - * - * cmLinkLibrariesCommand is used to specify a list of libraries to link - * into executable(s) or shared objects. The names of the libraries - * should be those defined by the LIBRARY(library) command(s). - */ -class cmLinkLibrariesCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmLinkLibrariesCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b85407ae76951649907e8e5675fe17d65dfd5457 commit b85407ae76951649907e8e5675fe17d65dfd5457 Author: Regina Pfeifer AuthorDate: Thu Sep 12 10:20:35 2019 +0200 Commit: Regina Pfeifer CommitDate: Thu Sep 12 18:16:17 2019 +0200 cmInstallTargetsCommand: Port away from cmCommand Ref: #19499 diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 21a007c..cb1f62b 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -237,8 +237,7 @@ void GetProjectCommands(cmState* state) cmIncludeRegularExpressionCommand); state->AddBuiltinCommand("install", cm::make_unique()); state->AddBuiltinCommand("install_files", cmInstallFilesCommand); - state->AddBuiltinCommand("install_targets", - cm::make_unique()); + state->AddBuiltinCommand("install_targets", cmInstallTargetsCommand); state->AddBuiltinCommand("link_directories", cm::make_unique()); state->AddBuiltinCommand("project", cm::make_unique()); diff --git a/Source/cmInstallTargetsCommand.cxx b/Source/cmInstallTargetsCommand.cxx index 30fd03d..44f23a5 100644 --- a/Source/cmInstallTargetsCommand.cxx +++ b/Source/cmInstallTargetsCommand.cxx @@ -5,25 +5,25 @@ #include #include +#include "cmExecutionStatus.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmTarget.h" -class cmExecutionStatus; - -// cmExecutableCommand -bool cmInstallTargetsCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +bool cmInstallTargetsCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 2) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } + cmMakefile& mf = status.GetMakefile(); + // Enable the install target. - this->Makefile->GetGlobalGenerator()->EnableInstallTarget(); + mf.GetGlobalGenerator()->EnableInstallTarget(); - cmMakefile::cmTargetMap& tgts = this->Makefile->GetTargets(); + cmMakefile::cmTargetMap& tgts = mf.GetTargets(); auto s = args.begin(); ++s; std::string runtime_dir = "/bin"; @@ -31,8 +31,8 @@ bool cmInstallTargetsCommand::InitialPass(std::vector const& args, if (*s == "RUNTIME_DIRECTORY") { ++s; if (s == args.end()) { - this->SetError("called with RUNTIME_DIRECTORY but no actual " - "directory"); + status.SetError("called with RUNTIME_DIRECTORY but no actual " + "directory"); return false; } @@ -45,14 +45,14 @@ bool cmInstallTargetsCommand::InitialPass(std::vector const& args, ti->second.SetHaveInstallRule(true); } else { std::string str = "Cannot find target: \"" + *s + "\" to install."; - this->SetError(str); + status.SetError(str); return false; } } } - this->Makefile->GetGlobalGenerator()->AddInstallComponent( - this->Makefile->GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME")); + mf.GetGlobalGenerator()->AddInstallComponent( + mf.GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME")); return true; } diff --git a/Source/cmInstallTargetsCommand.h b/Source/cmInstallTargetsCommand.h index 55e69ba..0c5850c 100644 --- a/Source/cmInstallTargetsCommand.h +++ b/Source/cmInstallTargetsCommand.h @@ -8,36 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmInstallTargetsCommand - * \brief Specifies where to install some targets - * - * cmInstallTargetsCommand specifies the relative path where a list of - * targets should be installed. The targets can be executables or - * libraries. - */ -class cmInstallTargetsCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmInstallTargetsCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d55319c01d5482ff31166750717252e1b49f1e69 commit d55319c01d5482ff31166750717252e1b49f1e69 Author: Regina Pfeifer AuthorDate: Thu Sep 12 10:19:23 2019 +0200 Commit: Regina Pfeifer CommitDate: Thu Sep 12 18:16:17 2019 +0200 cmInstallProgramsCommand: Port away from cmCommand Ref: #19499 diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 49f7c93..21a007c 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -281,8 +281,7 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("fltk_wrap_ui", cmFLTKWrapUICommand); state->AddBuiltinCommand("include_external_msproject", cmIncludeExternalMSProjectCommand); - state->AddBuiltinCommand("install_programs", - cm::make_unique()); + state->AddBuiltinCommand("install_programs", cmInstallProgramsCommand); state->AddBuiltinCommand("add_link_options", cmAddLinkOptionsCommand); state->AddBuiltinCommand("link_libraries", cm::make_unique()); diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx index 31a18b5..6bb4409 100644 --- a/Source/cmInstallProgramsCommand.cxx +++ b/Source/cmInstallProgramsCommand.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmInstallProgramsCommand.h" +#include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" #include "cmGlobalGenerator.h" #include "cmInstallFilesGenerator.h" @@ -10,30 +11,29 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -class cmExecutionStatus; - static void FinalAction(cmMakefile& makefile, std::string const& dest, std::vector const& args); static std::string FindInstallSource(cmMakefile& makefile, const char* name); -// cmExecutableCommand -bool cmInstallProgramsCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +bool cmInstallProgramsCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 2) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } + cmMakefile& mf = status.GetMakefile(); + // Enable the install target. - this->Makefile->GetGlobalGenerator()->EnableInstallTarget(); + mf.GetGlobalGenerator()->EnableInstallTarget(); - this->Makefile->GetGlobalGenerator()->AddInstallComponent( - this->Makefile->GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME")); + mf.GetGlobalGenerator()->AddInstallComponent( + mf.GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME")); std::string const& dest = args[0]; std::vector const finalArgs(args.begin() + 1, args.end()); - this->Makefile->AddFinalAction([dest, finalArgs](cmMakefile& makefile) { + mf.AddFinalAction([dest, finalArgs](cmMakefile& makefile) { FinalAction(makefile, dest, finalArgs); }); return true; diff --git a/Source/cmInstallProgramsCommand.h b/Source/cmInstallProgramsCommand.h index ccd621d..c567f3b 100644 --- a/Source/cmInstallProgramsCommand.h +++ b/Source/cmInstallProgramsCommand.h @@ -8,35 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmInstallProgramsCommand - * \brief Specifies where to install some programs - * - * cmInstallProgramsCommand specifies the relative path where a list of - * programs should be installed. - */ -class cmInstallProgramsCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmInstallProgramsCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fb5affe0859ae1bc07d059fc11cee3daca4d8780 commit fb5affe0859ae1bc07d059fc11cee3daca4d8780 Author: Regina Pfeifer AuthorDate: Thu Sep 12 10:18:01 2019 +0200 Commit: Regina Pfeifer CommitDate: Thu Sep 12 18:16:17 2019 +0200 cmInstallFilesCommand: Port away from cmCommand Ref: #19499 diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 6f01bea..49f7c93 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -236,8 +236,7 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("include_regular_expression", cmIncludeRegularExpressionCommand); state->AddBuiltinCommand("install", cm::make_unique()); - state->AddBuiltinCommand("install_files", - cm::make_unique()); + state->AddBuiltinCommand("install_files", cmInstallFilesCommand); state->AddBuiltinCommand("install_targets", cm::make_unique()); state->AddBuiltinCommand("link_directories", diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index 4eb5f24..d623943 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmInstallFilesCommand.h" +#include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" #include "cmGlobalGenerator.h" #include "cmInstallFilesGenerator.h" @@ -11,8 +12,6 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -class cmExecutionStatus; - static std::string FindInstallSource(cmMakefile& makefile, const char* name); static void CreateInstallGenerator(cmMakefile& makefile, std::string const& dest, @@ -20,16 +19,18 @@ static void CreateInstallGenerator(cmMakefile& makefile, static void FinalAction(cmMakefile& makefile, std::string const& dest, std::vector const& args); -bool cmInstallFilesCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +bool cmInstallFilesCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 2) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } + cmMakefile& mf = status.GetMakefile(); + // Enable the install target. - this->Makefile->GetGlobalGenerator()->EnableInstallTarget(); + mf.GetGlobalGenerator()->EnableInstallTarget(); std::string const& dest = args[0]; @@ -37,18 +38,18 @@ bool cmInstallFilesCommand::InitialPass(std::vector const& args, std::vector files; for (std::string const& arg : cmMakeRange(args).advance(2)) { // Find the source location for each file listed. - files.push_back(FindInstallSource(*this->Makefile, arg.c_str())); + files.push_back(FindInstallSource(mf, arg.c_str())); } - CreateInstallGenerator(*this->Makefile, dest, files); + CreateInstallGenerator(mf, dest, files); } else { std::vector finalArgs(args.begin() + 1, args.end()); - this->Makefile->AddFinalAction([dest, finalArgs](cmMakefile& makefile) { + mf.AddFinalAction([dest, finalArgs](cmMakefile& makefile) { FinalAction(makefile, dest, finalArgs); }); } - this->Makefile->GetGlobalGenerator()->AddInstallComponent( - this->Makefile->GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME")); + mf.GetGlobalGenerator()->AddInstallComponent( + mf.GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME")); return true; } diff --git a/Source/cmInstallFilesCommand.h b/Source/cmInstallFilesCommand.h index f9b84fd..f4ebbde 100644 --- a/Source/cmInstallFilesCommand.h +++ b/Source/cmInstallFilesCommand.h @@ -8,35 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmInstallFilesCommand - * \brief Specifies where to install some files - * - * cmInstallFilesCommand specifies the relative path where a list of - * files should be installed. - */ -class cmInstallFilesCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmInstallFilesCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=242d876d7b919fe6efb3a347dfa35a66e3ef58df commit 242d876d7b919fe6efb3a347dfa35a66e3ef58df Author: Regina Pfeifer AuthorDate: Thu Sep 12 10:16:43 2019 +0200 Commit: Regina Pfeifer CommitDate: Thu Sep 12 18:16:17 2019 +0200 cmIncludeRegularExpressionCommand: Port away from cmCommand Ref: #19499 diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index a82559d..6f01bea 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -233,9 +233,8 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("get_test_property", cmGetTestPropertyCommand); state->AddBuiltinCommand("include_directories", cm::make_unique()); - state->AddBuiltinCommand( - "include_regular_expression", - cm::make_unique()); + state->AddBuiltinCommand("include_regular_expression", + cmIncludeRegularExpressionCommand); state->AddBuiltinCommand("install", cm::make_unique()); state->AddBuiltinCommand("install_files", cm::make_unique()); diff --git a/Source/cmIncludeRegularExpressionCommand.cxx b/Source/cmIncludeRegularExpressionCommand.cxx index 073c95f..655ebd6 100644 --- a/Source/cmIncludeRegularExpressionCommand.cxx +++ b/Source/cmIncludeRegularExpressionCommand.cxx @@ -2,22 +2,22 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmIncludeRegularExpressionCommand.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" -class cmExecutionStatus; - -// cmIncludeRegularExpressionCommand -bool cmIncludeRegularExpressionCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +bool cmIncludeRegularExpressionCommand(std::vector const& args, + cmExecutionStatus& status) { - if ((args.empty()) || (args.size() > 2)) { - this->SetError("called with incorrect number of arguments"); + if (args.empty() || args.size() > 2) { + status.SetError("called with incorrect number of arguments"); return false; } - this->Makefile->SetIncludeRegularExpression(args[0].c_str()); + + cmMakefile& mf = status.GetMakefile(); + mf.SetIncludeRegularExpression(args[0].c_str()); if (args.size() > 1) { - this->Makefile->SetComplainRegularExpression(args[1]); + mf.SetComplainRegularExpression(args[1]); } return true; diff --git a/Source/cmIncludeRegularExpressionCommand.h b/Source/cmIncludeRegularExpressionCommand.h index 1723c8b..ca152b0 100644 --- a/Source/cmIncludeRegularExpressionCommand.h +++ b/Source/cmIncludeRegularExpressionCommand.h @@ -8,35 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmIncludeRegularExpressionCommand - * \brief Set the regular expression for following #includes. - * - * cmIncludeRegularExpressionCommand is used to specify the regular expression - * that determines whether to follow a #include file in dependency checking. - */ -class cmIncludeRegularExpressionCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmIncludeRegularExpressionCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=06a2e764f0f088a212e20b85e364b5621ef639fe commit 06a2e764f0f088a212e20b85e364b5621ef639fe Author: Regina Pfeifer AuthorDate: Thu Sep 12 10:15:29 2019 +0200 Commit: Regina Pfeifer CommitDate: Thu Sep 12 18:16:17 2019 +0200 cmIncludeExternalMSProjectCommand: Port away from cmCommand Ref: #19499 diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 2bdddc9..a82559d 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -281,9 +281,8 @@ void GetProjectCommands(cmState* state) cmAuxSourceDirectoryCommand); state->AddBuiltinCommand("export", cm::make_unique()); state->AddBuiltinCommand("fltk_wrap_ui", cmFLTKWrapUICommand); - state->AddBuiltinCommand( - "include_external_msproject", - cm::make_unique()); + state->AddBuiltinCommand("include_external_msproject", + cmIncludeExternalMSProjectCommand); state->AddBuiltinCommand("install_programs", cm::make_unique()); state->AddBuiltinCommand("add_link_options", cmAddLinkOptionsCommand); diff --git a/Source/cmIncludeExternalMSProjectCommand.cxx b/Source/cmIncludeExternalMSProjectCommand.cxx index 93134ad..fa1e8bc 100644 --- a/Source/cmIncludeExternalMSProjectCommand.cxx +++ b/Source/cmIncludeExternalMSProjectCommand.cxx @@ -2,6 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmIncludeExternalMSProjectCommand.h" +#include "cmExecutionStatus.h" + #ifdef _WIN32 # include "cmGlobalGenerator.h" # include "cmMakefile.h" @@ -11,22 +13,20 @@ # include "cmake.h" #endif -class cmExecutionStatus; - -// cmIncludeExternalMSProjectCommand -bool cmIncludeExternalMSProjectCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +bool cmIncludeExternalMSProjectCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 2) { - this->SetError("INCLUDE_EXTERNAL_MSPROJECT called with incorrect " - "number of arguments"); + status.SetError("INCLUDE_EXTERNAL_MSPROJECT called with incorrect " + "number of arguments"); return false; } + // only compile this for win32 to avoid coverage errors #ifdef _WIN32 - if (this->Makefile->GetDefinition("WIN32") || - this->Makefile->GetGlobalGenerator() - ->IsIncludeExternalMSProjectSupported()) { + cmMakefile& mf = status.GetMakefile(); + if (mf.GetDefinition("WIN32") || + mf.GetGlobalGenerator()->IsIncludeExternalMSProjectSupported()) { enum Doing { DoingNone, @@ -77,15 +77,15 @@ bool cmIncludeExternalMSProjectCommand::InitialPass( if (!customGuid.empty()) { std::string guidVariable = utility_name + "_GUID_CMAKE"; - this->Makefile->GetCMakeInstance()->AddCacheEntry( - guidVariable.c_str(), customGuid.c_str(), "Stored GUID", - cmStateEnums::INTERNAL); + mf.GetCMakeInstance()->AddCacheEntry(guidVariable.c_str(), + customGuid.c_str(), "Stored GUID", + cmStateEnums::INTERNAL); } // Create a target instance for this utility. - cmTarget* target = this->Makefile->AddNewTarget(cmStateEnums::UTILITY, - utility_name.c_str()); - if (this->Makefile->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { + cmTarget* target = + mf.AddNewTarget(cmStateEnums::UTILITY, utility_name.c_str()); + if (mf.GetPropertyAsBool("EXCLUDE_FROM_ALL")) { target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } diff --git a/Source/cmIncludeExternalMSProjectCommand.h b/Source/cmIncludeExternalMSProjectCommand.h index 9f76576..1013c44 100644 --- a/Source/cmIncludeExternalMSProjectCommand.h +++ b/Source/cmIncludeExternalMSProjectCommand.h @@ -8,36 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmIncludeExternalMSProjectCommand - * \brief Specify an external MS project file for inclusion in the workspace. - * - * cmIncludeExternalMSProjectCommand is used to specify an externally - * generated Microsoft project file for inclusion in the default workspace - * generated by CMake. - */ -class cmIncludeExternalMSProjectCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmIncludeExternalMSProjectCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b46970cfe9e0c96a9794acb49fc580565bcd6e91 commit b46970cfe9e0c96a9794acb49fc580565bcd6e91 Author: Regina Pfeifer AuthorDate: Thu Sep 12 10:14:27 2019 +0200 Commit: Regina Pfeifer CommitDate: Thu Sep 12 18:16:17 2019 +0200 cmGetTestPropertyCommand: Port away from cmCommand Ref: #19499 diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 9916282..2bdddc9 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -230,8 +230,7 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("get_source_file_property", cmGetSourceFilePropertyCommand); state->AddBuiltinCommand("get_target_property", cmGetTargetPropertyCommand); - state->AddBuiltinCommand("get_test_property", - cm::make_unique()); + state->AddBuiltinCommand("get_test_property", cmGetTestPropertyCommand); state->AddBuiltinCommand("include_directories", cm::make_unique()); state->AddBuiltinCommand( diff --git a/Source/cmGetTestPropertyCommand.cxx b/Source/cmGetTestPropertyCommand.cxx index 0b0d6eb..cf8c1d5 100644 --- a/Source/cmGetTestPropertyCommand.cxx +++ b/Source/cmGetTestPropertyCommand.cxx @@ -2,33 +2,32 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGetTestPropertyCommand.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmTest.h" -class cmExecutionStatus; - -// cmGetTestPropertyCommand -bool cmGetTestPropertyCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +bool cmGetTestPropertyCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 3) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } std::string const& testName = args[0]; std::string const& var = args[2]; - cmTest* test = this->Makefile->GetTest(testName); + cmMakefile& mf = status.GetMakefile(); + cmTest* test = mf.GetTest(testName); if (test) { const char* prop = nullptr; if (!args[1].empty()) { prop = test->GetProperty(args[1]); } if (prop) { - this->Makefile->AddDefinition(var, prop); + mf.AddDefinition(var, prop); return true; } } - this->Makefile->AddDefinition(var, "NOTFOUND"); + mf.AddDefinition(var, "NOTFOUND"); return true; } diff --git a/Source/cmGetTestPropertyCommand.h b/Source/cmGetTestPropertyCommand.h index a53a7f7..30beb8f 100644 --- a/Source/cmGetTestPropertyCommand.h +++ b/Source/cmGetTestPropertyCommand.h @@ -8,26 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -class cmGetTestPropertyCommand : public cmCommand -{ -public: - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the input file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmGetTestPropertyCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0b95c64e43e5f60ee9c60570f359a40e4e882096 commit 0b95c64e43e5f60ee9c60570f359a40e4e882096 Author: Regina Pfeifer AuthorDate: Thu Sep 12 10:13:17 2019 +0200 Commit: Regina Pfeifer CommitDate: Thu Sep 12 18:16:17 2019 +0200 cmGetTargetPropertyCommand: Port away from cmCommand Ref: #19499 diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index ff19062..9916282 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -229,8 +229,7 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("enable_testing", cmEnableTestingCommand); state->AddBuiltinCommand("get_source_file_property", cmGetSourceFilePropertyCommand); - state->AddBuiltinCommand("get_target_property", - cm::make_unique()); + state->AddBuiltinCommand("get_target_property", cmGetTargetPropertyCommand); state->AddBuiltinCommand("get_test_property", cm::make_unique()); state->AddBuiltinCommand("include_directories", diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx index 07aaf02..7f5df9c 100644 --- a/Source/cmGetTargetPropertyCommand.cxx +++ b/Source/cmGetTargetPropertyCommand.cxx @@ -4,6 +4,7 @@ #include +#include "cmExecutionStatus.h" #include "cmListFileCache.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -11,32 +12,31 @@ #include "cmTarget.h" #include "cmTargetPropertyComputer.h" -class cmExecutionStatus; class cmMessenger; -// cmSetTargetPropertyCommand -bool cmGetTargetPropertyCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +bool cmGetTargetPropertyCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() != 3) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } std::string const& var = args[0]; std::string const& targetName = args[1]; std::string prop; bool prop_exists = false; + cmMakefile& mf = status.GetMakefile(); - if (cmTarget* tgt = this->Makefile->FindTargetToUse(targetName)) { + if (cmTarget* tgt = mf.FindTargetToUse(targetName)) { if (args[2] == "ALIASED_TARGET") { - if (this->Makefile->IsAlias(targetName)) { + if (mf.IsAlias(targetName)) { prop = tgt->GetName(); prop_exists = true; } } else if (!args[2].empty()) { const char* prop_cstr = nullptr; - cmListFileBacktrace bt = this->Makefile->GetBacktrace(); - cmMessenger* messenger = this->Makefile->GetMessenger(); + cmListFileBacktrace bt = mf.GetBacktrace(); + cmMessenger* messenger = mf.GetMessenger(); if (cmTargetPropertyComputer::PassesWhitelist(tgt->GetType(), args[2], messenger, bt)) { prop_cstr = tgt->GetComputedProperty(args[2], messenger, bt); @@ -53,7 +53,7 @@ bool cmGetTargetPropertyCommand::InitialPass( bool issueMessage = false; std::ostringstream e; MessageType messageType = MessageType::AUTHOR_WARNING; - switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0045)) { + switch (mf.GetPolicyStatus(cmPolicies::CMP0045)) { case cmPolicies::WARN: issueMessage = true; e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0045) << "\n"; @@ -68,16 +68,16 @@ bool cmGetTargetPropertyCommand::InitialPass( if (issueMessage) { e << "get_target_property() called with non-existent target \"" << targetName << "\"."; - this->Makefile->IssueMessage(messageType, e.str()); + mf.IssueMessage(messageType, e.str()); if (messageType == MessageType::FATAL_ERROR) { return false; } } } if (prop_exists) { - this->Makefile->AddDefinition(var, prop); + mf.AddDefinition(var, prop); return true; } - this->Makefile->AddDefinition(var, var + "-NOTFOUND"); + mf.AddDefinition(var, var + "-NOTFOUND"); return true; } diff --git a/Source/cmGetTargetPropertyCommand.h b/Source/cmGetTargetPropertyCommand.h index 1a53195..c13078f 100644 --- a/Source/cmGetTargetPropertyCommand.h +++ b/Source/cmGetTargetPropertyCommand.h @@ -8,26 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -class cmGetTargetPropertyCommand : public cmCommand -{ -public: - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the input file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmGetTargetPropertyCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e4c67981aca4fd736fd7503d9d105a0a6fb43828 commit e4c67981aca4fd736fd7503d9d105a0a6fb43828 Author: Regina Pfeifer AuthorDate: Thu Sep 12 10:12:09 2019 +0200 Commit: Regina Pfeifer CommitDate: Thu Sep 12 18:16:17 2019 +0200 cmGetSourceFilePropertyCommand: Port away from cmCommand Ref: #19499 diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 9ce4c14..ff19062 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -228,7 +228,7 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("enable_language", cmEnableLanguageCommand); state->AddBuiltinCommand("enable_testing", cmEnableTestingCommand); state->AddBuiltinCommand("get_source_file_property", - cm::make_unique()); + cmGetSourceFilePropertyCommand); state->AddBuiltinCommand("get_target_property", cm::make_unique()); state->AddBuiltinCommand("get_test_property", diff --git a/Source/cmGetSourceFilePropertyCommand.cxx b/Source/cmGetSourceFilePropertyCommand.cxx index 5c1c8a5..eefdc6c 100644 --- a/Source/cmGetSourceFilePropertyCommand.cxx +++ b/Source/cmGetSourceFilePropertyCommand.cxx @@ -2,26 +2,25 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGetSourceFilePropertyCommand.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmSourceFile.h" -class cmExecutionStatus; - -// cmSetSourceFilePropertyCommand -bool cmGetSourceFilePropertyCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +bool cmGetSourceFilePropertyCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() != 3) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } std::string const& var = args[0]; std::string const& file = args[1]; - cmSourceFile* sf = this->Makefile->GetSource(file); + cmMakefile& mf = status.GetMakefile(); + cmSourceFile* sf = mf.GetSource(file); // for the location we must create a source file first if (!sf && args[2] == "LOCATION") { - sf = this->Makefile->CreateSource(file); + sf = mf.CreateSource(file); } if (sf) { const char* prop = nullptr; @@ -29,11 +28,11 @@ bool cmGetSourceFilePropertyCommand::InitialPass( prop = sf->GetPropertyForUser(args[2]); } if (prop) { - this->Makefile->AddDefinition(var, prop); + mf.AddDefinition(var, prop); return true; } } - this->Makefile->AddDefinition(var, "NOTFOUND"); + mf.AddDefinition(var, "NOTFOUND"); return true; } diff --git a/Source/cmGetSourceFilePropertyCommand.h b/Source/cmGetSourceFilePropertyCommand.h index 387a7f4..f0c319b 100644 --- a/Source/cmGetSourceFilePropertyCommand.h +++ b/Source/cmGetSourceFilePropertyCommand.h @@ -8,26 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -class cmGetSourceFilePropertyCommand : public cmCommand -{ -public: - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the input file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmGetSourceFilePropertyCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=36b939db682a9405790bee76f95673eeaeb445b8 commit 36b939db682a9405790bee76f95673eeaeb445b8 Author: Regina Pfeifer AuthorDate: Thu Sep 12 10:10:28 2019 +0200 Commit: Regina Pfeifer CommitDate: Thu Sep 12 18:16:17 2019 +0200 cmFLTKWrapUICommand: Port away from cmCommand Ref: #19499 diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index f30fcb5..9ce4c14 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -282,8 +282,7 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("aux_source_directory", cmAuxSourceDirectoryCommand); state->AddBuiltinCommand("export", cm::make_unique()); - state->AddBuiltinCommand("fltk_wrap_ui", - cm::make_unique()); + state->AddBuiltinCommand("fltk_wrap_ui", cmFLTKWrapUICommand); state->AddBuiltinCommand( "include_external_msproject", cm::make_unique()); diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index ea9e672..5094c3c 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -5,13 +5,13 @@ #include #include "cmCustomCommandLines.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmRange.h" #include "cmSourceFile.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -class cmExecutionStatus; class cmTarget; static void FinalAction(cmMakefile& makefile, std::string const& name) @@ -30,39 +30,40 @@ static void FinalAction(cmMakefile& makefile, std::string const& name) } } -// cmFLTKWrapUICommand -bool cmFLTKWrapUICommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +bool cmFLTKWrapUICommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 2) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } + cmMakefile& mf = status.GetMakefile(); + // what is the current source dir - std::string cdir = this->Makefile->GetCurrentSourceDirectory(); + std::string cdir = mf.GetCurrentSourceDirectory(); std::string const& fluid_exe = - this->Makefile->GetRequiredDefinition("FLTK_FLUID_EXECUTABLE"); + mf.GetRequiredDefinition("FLTK_FLUID_EXECUTABLE"); // Target that will use the generated files std::string const& target = args[0]; // get the list of GUI files from which .cxx and .h will be generated - std::string outputDirectory = this->Makefile->GetCurrentBinaryDirectory(); + std::string outputDirectory = mf.GetCurrentBinaryDirectory(); { // Some of the generated files are *.h so the directory "GUI" // where they are created have to be added to the include path std::vector outputDirectories; outputDirectories.push_back(outputDirectory); - this->Makefile->AddIncludeDirectories(outputDirectories); + mf.AddIncludeDirectories(outputDirectories); } // List of produced files. std::vector generatedSourcesClasses; for (std::string const& arg : cmMakeRange(args).advance(1)) { - cmSourceFile* curr = this->Makefile->GetSource(arg); + cmSourceFile* curr = mf.GetSource(arg); // if we should use the source GUI // to generate .cxx and .h files if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE")) { @@ -91,14 +92,12 @@ bool cmFLTKWrapUICommand::InitialPass(std::vector const& args, std::string no_main_dependency; const char* no_comment = nullptr; const char* no_working_dir = nullptr; - this->Makefile->AddCustomCommandToOutput( - cxxres, depends, no_main_dependency, commandLines, no_comment, - no_working_dir); - this->Makefile->AddCustomCommandToOutput( - hname, depends, no_main_dependency, commandLines, no_comment, - no_working_dir); - - cmSourceFile* sf = this->Makefile->GetSource(cxxres); + mf.AddCustomCommandToOutput(cxxres, depends, no_main_dependency, + commandLines, no_comment, no_working_dir); + mf.AddCustomCommandToOutput(hname, depends, no_main_dependency, + commandLines, no_comment, no_working_dir); + + cmSourceFile* sf = mf.GetSource(cxxres); sf->AddDepend(hname); sf->AddDepend(origname); generatedSourcesClasses.push_back(sf); @@ -116,9 +115,9 @@ bool cmFLTKWrapUICommand::InitialPass(std::vector const& args, } std::string const varName = target + "_FLTK_UI_SRCS"; - this->Makefile->AddDefinition(varName, sourceListValue); + mf.AddDefinition(varName, sourceListValue); - this->Makefile->AddFinalAction( + mf.AddFinalAction( [target](cmMakefile& makefile) { FinalAction(makefile, target); }); return true; } diff --git a/Source/cmFLTKWrapUICommand.h b/Source/cmFLTKWrapUICommand.h index ea8d401..bb56dbd 100644 --- a/Source/cmFLTKWrapUICommand.h +++ b/Source/cmFLTKWrapUICommand.h @@ -8,35 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmFLTKWrapUICommand - * \brief Create .h and .cxx files rules for FLTK user interfaces files - * - * cmFLTKWrapUICommand is used to create wrappers for FLTK classes into - * normal C++ - */ -class cmFLTKWrapUICommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmFLTKWrapUICommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=28cf1271ed6051af46ff68f52a8c9c0435ca1234 commit 28cf1271ed6051af46ff68f52a8c9c0435ca1234 Author: Regina Pfeifer AuthorDate: Thu Sep 12 10:09:06 2019 +0200 Commit: Regina Pfeifer CommitDate: Thu Sep 12 18:16:17 2019 +0200 cmEnableLanguageCommand: Port away from cmCommand Ref: #19499 diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 1e8ee9e..f30fcb5 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -225,8 +225,7 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("build_command", cmBuildCommand); state->AddBuiltinCommand("create_test_sourcelist", cmCreateTestSourceList); state->AddBuiltinCommand("define_property", cmDefinePropertyCommand); - state->AddBuiltinCommand("enable_language", - cm::make_unique()); + state->AddBuiltinCommand("enable_language", cmEnableLanguageCommand); state->AddBuiltinCommand("enable_testing", cmEnableTestingCommand); state->AddBuiltinCommand("get_source_file_property", cm::make_unique()); diff --git a/Source/cmEnableLanguageCommand.cxx b/Source/cmEnableLanguageCommand.cxx index ddd26de..59522c0 100644 --- a/Source/cmEnableLanguageCommand.cxx +++ b/Source/cmEnableLanguageCommand.cxx @@ -2,20 +2,19 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmEnableLanguageCommand.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" -class cmExecutionStatus; - -// cmEnableLanguageCommand -bool cmEnableLanguageCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +bool cmEnableLanguageCommand(std::vector const& args, + cmExecutionStatus& status) { - bool optional = false; - std::vector languages; if (args.empty()) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } + + bool optional = false; + std::vector languages; for (std::string const& it : args) { if (it == "OPTIONAL") { optional = true; @@ -24,6 +23,6 @@ bool cmEnableLanguageCommand::InitialPass(std::vector const& args, } } - this->Makefile->EnableLanguage(languages, optional); + status.GetMakefile().EnableLanguage(languages, optional); return true; } diff --git a/Source/cmEnableLanguageCommand.h b/Source/cmEnableLanguageCommand.h index dc43e34..1f8c4ce 100644 --- a/Source/cmEnableLanguageCommand.h +++ b/Source/cmEnableLanguageCommand.h @@ -8,37 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmEnableLanguageCommand - * \brief Specify the name for this build project. - * - * cmEnableLanguageCommand is used to specify a name for this build project. - * It is defined once per set of CMakeList.txt files (including - * all subdirectories). Currently it just sets the name of the workspace - * file for Microsoft Visual C++ - */ -class cmEnableLanguageCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmEnableLanguageCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=41b0d60f48c3d8d882ec25b56d638b392121fcc8 commit 41b0d60f48c3d8d882ec25b56d638b392121fcc8 Author: Regina Pfeifer AuthorDate: Thu Sep 12 10:08:01 2019 +0200 Commit: Regina Pfeifer CommitDate: Thu Sep 12 18:16:17 2019 +0200 cmDefinePropertyCommand: Port away from cmCommand Ref: #19499 diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index f675a93..1e8ee9e 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -224,8 +224,7 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("add_test", cmAddTestCommand); state->AddBuiltinCommand("build_command", cmBuildCommand); state->AddBuiltinCommand("create_test_sourcelist", cmCreateTestSourceList); - state->AddBuiltinCommand("define_property", - cm::make_unique()); + state->AddBuiltinCommand("define_property", cmDefinePropertyCommand); state->AddBuiltinCommand("enable_language", cm::make_unique()); state->AddBuiltinCommand("enable_testing", cmEnableTestingCommand); diff --git a/Source/cmDefinePropertyCommand.cxx b/Source/cmDefinePropertyCommand.cxx index 86a83da..f4e4fda 100644 --- a/Source/cmDefinePropertyCommand.cxx +++ b/Source/cmDefinePropertyCommand.cxx @@ -2,19 +2,17 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmDefinePropertyCommand.h" -#include - +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmProperty.h" #include "cmState.h" +#include "cmStringAlgorithms.h" -class cmExecutionStatus; - -bool cmDefinePropertyCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +bool cmDefinePropertyCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.empty()) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } @@ -37,17 +35,17 @@ bool cmDefinePropertyCommand::InitialPass(std::vector const& args, } else if (scope_arg == "CACHED_VARIABLE") { scope = cmProperty::CACHED_VARIABLE; } else { - std::ostringstream e; - e << "given invalid scope " << scope_arg << ". " - << "Valid scopes are " - << "GLOBAL, DIRECTORY, TARGET, SOURCE, " - << "TEST, VARIABLE, CACHED_VARIABLE."; - this->SetError(e.str()); + status.SetError(cmStrCat("given invalid scope ", scope_arg, + ". Valid scopes are GLOBAL, DIRECTORY, TARGET, " + "SOURCE, TEST, VARIABLE, CACHED_VARIABLE.")); return false; } // Parse remaining arguments. bool inherited = false; + std::string PropertyName; + std::string BriefDocs; + std::string FullDocs; enum Doing { DoingNone, @@ -68,39 +66,36 @@ bool cmDefinePropertyCommand::InitialPass(std::vector const& args, inherited = true; } else if (doing == DoingProperty) { doing = DoingNone; - this->PropertyName = args[i]; + PropertyName = args[i]; } else if (doing == DoingBrief) { - this->BriefDocs += args[i]; + BriefDocs += args[i]; } else if (doing == DoingFull) { - this->FullDocs += args[i]; + FullDocs += args[i]; } else { - std::ostringstream e; - e << "given invalid argument \"" << args[i] << "\"."; - this->SetError(e.str()); + status.SetError(cmStrCat("given invalid argument \"", args[i], "\".")); return false; } } // Make sure a property name was found. - if (this->PropertyName.empty()) { - this->SetError("not given a PROPERTY argument."); + if (PropertyName.empty()) { + status.SetError("not given a PROPERTY argument."); return false; } // Make sure documentation was given. - if (this->BriefDocs.empty()) { - this->SetError("not given a BRIEF_DOCS argument."); + if (BriefDocs.empty()) { + status.SetError("not given a BRIEF_DOCS argument."); return false; } - if (this->FullDocs.empty()) { - this->SetError("not given a FULL_DOCS argument."); + if (FullDocs.empty()) { + status.SetError("not given a FULL_DOCS argument."); return false; } // Actually define the property. - this->Makefile->GetState()->DefineProperty( - this->PropertyName, scope, this->BriefDocs.c_str(), this->FullDocs.c_str(), - inherited); + status.GetMakefile().GetState()->DefineProperty( + PropertyName, scope, BriefDocs.c_str(), FullDocs.c_str(), inherited); return true; } diff --git a/Source/cmDefinePropertyCommand.h b/Source/cmDefinePropertyCommand.h index 36f97df..60dd76a 100644 --- a/Source/cmDefinePropertyCommand.h +++ b/Source/cmDefinePropertyCommand.h @@ -8,31 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -class cmDefinePropertyCommand : public cmCommand -{ -public: - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the input file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - -private: - std::string PropertyName; - std::string BriefDocs; - std::string FullDocs; -}; +bool cmDefinePropertyCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f717e1fccf2968ffeba36dc84e428abd4f8db5c0 commit f717e1fccf2968ffeba36dc84e428abd4f8db5c0 Author: Regina Pfeifer AuthorDate: Thu Sep 12 10:06:03 2019 +0200 Commit: Regina Pfeifer CommitDate: Thu Sep 12 18:16:17 2019 +0200 cmCreateTestSourceList: Port away from cmCommand Ref: #19499 diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 1f6b1a2..f675a93 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -223,8 +223,7 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("add_subdirectory", cmAddSubDirectoryCommand); state->AddBuiltinCommand("add_test", cmAddTestCommand); state->AddBuiltinCommand("build_command", cmBuildCommand); - state->AddBuiltinCommand("create_test_sourcelist", - cm::make_unique()); + state->AddBuiltinCommand("create_test_sourcelist", cmCreateTestSourceList); state->AddBuiltinCommand("define_property", cm::make_unique()); state->AddBuiltinCommand("enable_language", diff --git a/Source/cmCreateTestSourceList.cxx b/Source/cmCreateTestSourceList.cxx index da23519..9d492ba 100644 --- a/Source/cmCreateTestSourceList.cxx +++ b/Source/cmCreateTestSourceList.cxx @@ -4,19 +4,17 @@ #include +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmSourceFile.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -class cmExecutionStatus; - -// cmCreateTestSourceList -bool cmCreateTestSourceList::InitialPass(std::vector const& args, - cmExecutionStatus&) +bool cmCreateTestSourceList(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 3) { - this->SetError("called with wrong number of arguments."); + status.SetError("called with wrong number of arguments."); return false; } @@ -29,14 +27,14 @@ bool cmCreateTestSourceList::InitialPass(std::vector const& args, if (*i == "EXTRA_INCLUDE") { ++i; if (i == args.end()) { - this->SetError("incorrect arguments to EXTRA_INCLUDE"); + status.SetError("incorrect arguments to EXTRA_INCLUDE"); return false; } extraInclude = cmStrCat("#include \"", *i, "\"\n"); } else if (*i == "FUNCTION") { ++i; if (i == args.end()) { - this->SetError("incorrect arguments to FUNCTION"); + status.SetError("incorrect arguments to FUNCTION"); return false; } function = cmStrCat(*i, "(&ac, &av);\n"); @@ -54,12 +52,12 @@ bool cmCreateTestSourceList::InitialPass(std::vector const& args, // Name of the test driver // make sure they specified an extension if (cmSystemTools::GetFilenameExtension(*i).size() < 2) { - this->SetError( + status.SetError( "You must specify a file extension for the test driver file."); return false; } - std::string driver = - cmStrCat(this->Makefile->GetCurrentBinaryDirectory(), '/', *i); + cmMakefile& mf = status.GetMakefile(); + std::string driver = cmStrCat(mf.GetCurrentBinaryDirectory(), '/', *i); ++i; std::string configFile = cmSystemTools::GetCMakeRoot(); @@ -121,35 +119,32 @@ bool cmCreateTestSourceList::InitialPass(std::vector const& args, numTests++; } if (!extraInclude.empty()) { - this->Makefile->AddDefinition("CMAKE_TESTDRIVER_EXTRA_INCLUDES", - extraInclude); + mf.AddDefinition("CMAKE_TESTDRIVER_EXTRA_INCLUDES", extraInclude); } if (!function.empty()) { - this->Makefile->AddDefinition("CMAKE_TESTDRIVER_ARGVC_FUNCTION", function); + mf.AddDefinition("CMAKE_TESTDRIVER_ARGVC_FUNCTION", function); } - this->Makefile->AddDefinition("CMAKE_FORWARD_DECLARE_TESTS", - forwardDeclareCode); - this->Makefile->AddDefinition("CMAKE_FUNCTION_TABLE_ENTIRES", - functionMapCode); + mf.AddDefinition("CMAKE_FORWARD_DECLARE_TESTS", forwardDeclareCode); + mf.AddDefinition("CMAKE_FUNCTION_TABLE_ENTIRES", functionMapCode); bool res = true; - if (!this->Makefile->ConfigureFile(configFile, driver, false, true, false)) { + if (!mf.ConfigureFile(configFile, driver, false, true, false)) { res = false; } // Construct the source list. std::string sourceListValue; { - cmSourceFile* sf = this->Makefile->GetOrCreateSource(driver); + cmSourceFile* sf = mf.GetOrCreateSource(driver); sf->SetProperty("ABSTRACT", "0"); sourceListValue = args[1]; } for (i = testsBegin; i != tests.end(); ++i) { - cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i); + cmSourceFile* sf = mf.GetOrCreateSource(*i); sf->SetProperty("ABSTRACT", "0"); sourceListValue += ";"; sourceListValue += *i; } - this->Makefile->AddDefinition(sourceList, sourceListValue); + mf.AddDefinition(sourceList, sourceListValue); return res; } diff --git a/Source/cmCreateTestSourceList.h b/Source/cmCreateTestSourceList.h index 5aa6af4..19503f4 100644 --- a/Source/cmCreateTestSourceList.h +++ b/Source/cmCreateTestSourceList.h @@ -8,34 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmCreateTestSourceList - * \brief Test driver generation command - * - */ - -class cmCreateTestSourceList : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmCreateTestSourceList(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f0ecb123981c6b383a55f7d75e023cf4310f2074 commit f0ecb123981c6b383a55f7d75e023cf4310f2074 Author: Regina Pfeifer AuthorDate: Thu Sep 12 10:04:07 2019 +0200 Commit: Regina Pfeifer CommitDate: Thu Sep 12 18:16:17 2019 +0200 cmBuildCommand: Port away from cmCommand Ref: #19499 diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx index e9e1d49..49c9439 100644 --- a/Source/cmBuildCommand.cxx +++ b/Source/cmBuildCommand.cxx @@ -2,32 +2,21 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmBuildCommand.h" -#include - +#include "cmExecutionStatus.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmMessageType.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" -class cmExecutionStatus; - -bool cmBuildCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) -{ - // Support the legacy signature of the command: - // - if (2 == args.size()) { - return this->TwoArgsSignature(args); - } - - return this->MainSignature(args); -} +namespace { -bool cmBuildCommand::MainSignature(std::vector const& args) +bool MainSignature(std::vector const& args, + cmExecutionStatus& status) { if (args.empty()) { - this->SetError("requires at least one argument naming a CMake variable"); + status.SetError("requires at least one argument naming a CMake variable"); return false; } @@ -63,9 +52,7 @@ bool cmBuildCommand::MainSignature(std::vector const& args) doing = DoingNone; target = args[i]; } else { - std::ostringstream e; - e << "unknown argument \"" << args[i] << "\""; - this->SetError(e.str()); + status.SetError(cmStrCat("unknown argument \"", args[i], "\"")); return false; } } @@ -82,30 +69,32 @@ bool cmBuildCommand::MainSignature(std::vector const& args) configuration = "Release"; } + cmMakefile& mf = status.GetMakefile(); if (!project_name.empty()) { - this->Makefile->IssueMessage( - MessageType::AUTHOR_WARNING, - "Ignoring PROJECT_NAME option because it has no effect."); + mf.IssueMessage(MessageType::AUTHOR_WARNING, + "Ignoring PROJECT_NAME option because it has no effect."); } - std::string makecommand = - this->Makefile->GetGlobalGenerator()->GenerateCMakeBuildCommand( - target, configuration, "", this->Makefile->IgnoreErrorsCMP0061()); + std::string makecommand = mf.GetGlobalGenerator()->GenerateCMakeBuildCommand( + target, configuration, "", mf.IgnoreErrorsCMP0061()); - this->Makefile->AddDefinition(variable, makecommand); + mf.AddDefinition(variable, makecommand); return true; } -bool cmBuildCommand::TwoArgsSignature(std::vector const& args) +bool TwoArgsSignature(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 2) { - this->SetError("called with less than two arguments"); + status.SetError("called with less than two arguments"); return false; } + cmMakefile& mf = status.GetMakefile(); + std::string const& define = args[0]; - const char* cacheValue = this->Makefile->GetDefinition(define); + const char* cacheValue = mf.GetDefinition(define); std::string configType; if (!cmSystemTools::GetEnv("CMAKE_CONFIG_TYPE", configType) || @@ -113,16 +102,28 @@ bool cmBuildCommand::TwoArgsSignature(std::vector const& args) configType = "Release"; } - std::string makecommand = - this->Makefile->GetGlobalGenerator()->GenerateCMakeBuildCommand( - "", configType, "", this->Makefile->IgnoreErrorsCMP0061()); + std::string makecommand = mf.GetGlobalGenerator()->GenerateCMakeBuildCommand( + "", configType, "", mf.IgnoreErrorsCMP0061()); if (cacheValue) { return true; } - this->Makefile->AddCacheDefinition(define, makecommand.c_str(), - "Command used to build entire project " - "from the command line.", - cmStateEnums::STRING); + mf.AddCacheDefinition(define, makecommand.c_str(), + "Command used to build entire project " + "from the command line.", + cmStateEnums::STRING); return true; } + +} // namespace + +bool cmBuildCommand(std::vector const& args, + cmExecutionStatus& status) +{ + // Support the legacy signature of the command: + if (args.size() == 2) { + return TwoArgsSignature(args, status); + } + + return MainSignature(args, status); +} diff --git a/Source/cmBuildCommand.h b/Source/cmBuildCommand.h index d373103..45aa71d 100644 --- a/Source/cmBuildCommand.h +++ b/Source/cmBuildCommand.h @@ -8,47 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmBuildCommand - * \brief build_command command - * - * cmBuildCommand implements the build_command CMake command - */ -class cmBuildCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - - /** - * The primary command signature with optional, KEYWORD-based args. - */ - virtual bool MainSignature(std::vector const& args); - - /** - * Legacy "exactly 2 args required" signature. - */ - virtual bool TwoArgsSignature(std::vector const& args); - -private: - bool IgnoreErrors() const; -}; +bool cmBuildCommand(std::vector const& args, + cmExecutionStatus& status); #endif diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index dfe130e..1f6b1a2 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -222,7 +222,7 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("add_library", cmAddLibraryCommand); state->AddBuiltinCommand("add_subdirectory", cmAddSubDirectoryCommand); state->AddBuiltinCommand("add_test", cmAddTestCommand); - state->AddBuiltinCommand("build_command", cm::make_unique()); + state->AddBuiltinCommand("build_command", cmBuildCommand); state->AddBuiltinCommand("create_test_sourcelist", cm::make_unique()); state->AddBuiltinCommand("define_property", https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=482d858500a42a63c97d3dc11ae74d81a10bab3f commit 482d858500a42a63c97d3dc11ae74d81a10bab3f Author: Daniel Eiband AuthorDate: Wed Sep 11 15:06:01 2019 +0200 Commit: Daniel Eiband CommitDate: Thu Sep 12 16:03:12 2019 +0200 Depend: Add test for target-level dependencies via byproducts Add test for target-level dependency of custom target to POST_BUILD event via byproduct. Remove explicit dependencies in test which are no longe required due to introduced dependencies on build events via byproducts. Issue: #19005 diff --git a/Tests/CustomCommandByproducts/CMakeLists.txt b/Tests/CustomCommandByproducts/CMakeLists.txt index d0bf648..bfa69ce 100644 --- a/Tests/CustomCommandByproducts/CMakeLists.txt +++ b/Tests/CustomCommandByproducts/CMakeLists.txt @@ -28,6 +28,7 @@ add_custom_target(Producer3_4 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/byproduct3.c.in byproduct3.c BYPRODUCTS byproduct3.c + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct3.c.in ) # Generate a byproduct in a custom target POST_BUILD command. @@ -36,32 +37,36 @@ add_custom_command( COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/byproduct4.c.in byproduct4.c BYPRODUCTS byproduct4.c + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct4.c.in ) -add_executable(ProducerExe ProducerExe.c) +add_executable(ProducerExe5_6_7 ProducerExe.c) # Generate a byproduct in an executable POST_BUILD command. add_custom_command( - TARGET ProducerExe POST_BUILD + TARGET ProducerExe5_6_7 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/byproduct5.c.in byproduct5.c BYPRODUCTS byproduct5.c + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct5.c.in ) # Generate a byproduct in an executable PRE_LINK command. add_custom_command( - TARGET ProducerExe PRE_LINK + TARGET ProducerExe5_6_7 PRE_LINK COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/byproduct6.c.in byproduct6.c BYPRODUCTS byproduct6.c + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct6.c.in ) # Generate a byproduct in an executable PRE_BUILD command. add_custom_command( - TARGET ProducerExe PRE_BUILD + TARGET ProducerExe5_6_7 PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/byproduct7.c.in byproduct7.c BYPRODUCTS byproduct7.c + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct7.c.in ) # Generate a byproduct in a custom command that consumes other byproducts. @@ -80,6 +85,25 @@ add_custom_command(OUTPUT timestamp8.txt ${CMAKE_CURRENT_SOURCE_DIR}/byproduct8.c.in ) +add_executable(ProducerExe9 ProducerExe.c) + +# Generate a byproduct in a custom target which depends on a byproduct of a +# POST_BUILD command (test if dependency of custom target Producer9 to +# ProducerExe9 is added). +add_custom_command( + TARGET ProducerExe9 POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_CURRENT_SOURCE_DIR}/byproduct9.c.in byproduct9a.c + BYPRODUCTS byproduct9a.c + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct9.c.in + ) +add_custom_target(Producer9 + COMMAND ${CMAKE_COMMAND} -E copy_if_different + byproduct9a.c byproduct9.c + BYPRODUCTS byproduct9.c + DEPENDS byproduct9a.c + ) + # Generate the library file of an imported target as a byproduct # of an external project. get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) @@ -136,10 +160,13 @@ add_executable(CustomCommandByproducts byproduct6.c byproduct7.c byproduct8.c timestamp8.txt + byproduct9.c ) + +# Dependencies to byproducts of custom commands other than build events are not +# yet traced (see issue #19005). add_dependencies(CustomCommandByproducts Producer2) -add_dependencies(CustomCommandByproducts Producer3_4) -add_dependencies(CustomCommandByproducts ProducerExe) + target_link_libraries(CustomCommandByproducts ExternalLibrary) if(CMAKE_GENERATOR STREQUAL "Ninja") diff --git a/Tests/CustomCommandByproducts/CustomCommandByproducts.c b/Tests/CustomCommandByproducts/CustomCommandByproducts.c index 02ad7ea..0658d05 100644 --- a/Tests/CustomCommandByproducts/CustomCommandByproducts.c +++ b/Tests/CustomCommandByproducts/CustomCommandByproducts.c @@ -6,10 +6,11 @@ extern int byproduct5(void); extern int byproduct6(void); extern int byproduct7(void); extern int byproduct8(void); +extern int byproduct9(void); extern int ExternalLibrary(void); int main(void) { return (byproduct1() + byproduct2() + byproduct3() + byproduct4() + byproduct5() + byproduct6() + byproduct7() + byproduct8() + - ExternalLibrary() + 0); + byproduct9() + ExternalLibrary() + 0); } diff --git a/Tests/CustomCommandByproducts/byproduct9.c.in b/Tests/CustomCommandByproducts/byproduct9.c.in new file mode 100644 index 0000000..11eed2c --- /dev/null +++ b/Tests/CustomCommandByproducts/byproduct9.c.in @@ -0,0 +1 @@ +int byproduct9(void) { return 0; } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f6574c9a816ffda7d9ff8c3f2e4ce0485cf28894 commit f6574c9a816ffda7d9ff8c3f2e4ce0485cf28894 Author: Daniel Eiband AuthorDate: Wed Sep 11 12:45:50 2019 +0200 Commit: Daniel Eiband CommitDate: Thu Sep 12 16:03:12 2019 +0200 Depend: Hook up automatic target-level dependencies via byproducts Target-level dependencies to utility targets are added from another target if the other target requires a byproduct of the utility target or if it requires a byproduct of PRE_BUILD, PRE_LINK, or POST_BUILD build events of a target. Issue: #19005 diff --git a/Help/command/add_custom_command.rst b/Help/command/add_custom_command.rst index ed321fc..ab2a023 100644 --- a/Help/command/add_custom_command.rst +++ b/Help/command/add_custom_command.rst @@ -68,9 +68,6 @@ The options are: order-only dependencies to ensure the byproducts will be available before their dependents build. - The ``BYPRODUCTS`` option is ignored on non-Ninja generators - except to mark byproducts ``GENERATED``. - ``COMMAND`` Specify the command-line(s) to execute at build time. If more than one ``COMMAND`` is specified they will be executed in order, @@ -111,6 +108,9 @@ The options are: an ``OUTPUT`` of another custom command in the same directory (``CMakeLists.txt`` file) CMake automatically brings the other custom command into the target in which this command is built. + A target-level dependency is added if any dependency is listed as + ``BYPRODUCTS`` of a target or any of its build events in the same + directory to ensure the byproducts will be available. If ``DEPENDS`` is not specified the command will run whenever the ``OUTPUT`` is missing; if the command does not actually create the ``OUTPUT`` then the rule will always run. diff --git a/Help/command/add_custom_target.rst b/Help/command/add_custom_target.rst index 08b9516..e74960c 100644 --- a/Help/command/add_custom_target.rst +++ b/Help/command/add_custom_target.rst @@ -49,9 +49,6 @@ The options are: order-only dependencies to ensure the byproducts will be available before their dependents build. - The ``BYPRODUCTS`` option is ignored on non-Ninja generators - except to mark byproducts ``GENERATED``. - ``COMMAND`` Specify the command-line(s) to execute at build time. If more than one ``COMMAND`` is specified they will be executed in order, @@ -86,6 +83,9 @@ The options are: :command:`add_custom_command` command calls in the same directory (``CMakeLists.txt`` file). They will be brought up to date when the target is built. + A target-level dependency is added if any dependency is a byproduct + of a target or any of its build events in the same directory to ensure + the byproducts will be available before this target is built. Use the :command:`add_dependencies` command to add dependencies on other targets. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index fa04fbb..b019e0b 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -2599,7 +2599,7 @@ private: SourceEntry* CurrentEntry; std::queue SourceQueue; std::set SourcesQueued; - using NameMapType = std::map; + using NameMapType = std::map; NameMapType NameMap; std::vector NewSources; @@ -2705,19 +2705,30 @@ void cmTargetTraceDependencies::QueueSource(cmSourceFile* sf) void cmTargetTraceDependencies::FollowName(std::string const& name) { - auto i = this->NameMap.find(name); - if (i == this->NameMap.end()) { + // Use lower bound with key comparison to not repeat the search for the + // insert position if the name could not be found (which is the common case). + auto i = this->NameMap.lower_bound(name); + if (i == this->NameMap.end() || i->first != name) { // Check if we know how to generate this file. - cmSourceFile* sf = this->Makefile->GetSourceFileWithOutput(name); - NameMapType::value_type entry(name, sf); - i = this->NameMap.insert(entry).first; - } - if (cmSourceFile* sf = i->second) { - // Record the dependency we just followed. - if (this->CurrentEntry) { - this->CurrentEntry->Depends.push_back(sf); + cmSourcesWithOutput sources = this->Makefile->GetSourcesWithOutput(name); + i = this->NameMap.emplace_hint(i, name, sources); + } + if (cmTarget* t = i->second.Target) { + // The name is a byproduct of a utility target or a PRE_BUILD, PRE_LINK, or + // POST_BUILD command. + this->GeneratorTarget->Target->AddUtility(t->GetName()); + } + if (cmSourceFile* sf = i->second.Source) { + // For now only follow the dependency if the source file is not a + // byproduct. Semantics of byproducts in a non-Ninja context will have to + // be defined first. + if (!i->second.SourceIsByproduct) { + // Record the dependency we just followed. + if (this->CurrentEntry) { + this->CurrentEntry->Depends.push_back(sf); + } + this->QueueSource(sf); } - this->QueueSource(sf); } } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2edb0b71edd36031f2fcc0b65633c1c16f8e9268 commit 2edb0b71edd36031f2fcc0b65633c1c16f8e9268 Author: Daniel Eiband AuthorDate: Wed Sep 11 12:19:43 2019 +0200 Commit: Daniel Eiband CommitDate: Thu Sep 12 16:01:45 2019 +0200 cmMakefile: Add lookup from source name to targets via byproducts Given an output source name it is now possible to query which target has a byproduct of this name or has a PRE_BUILD, PRE_LINK, or POST_BUILD build event with a byproduct of this name. In a call to GetSourceFileWithOutput a matching byproduct can now optionally be returned as fallback if there is no matching output of a custom command. Default behavior is not changed by this commit. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 3a80b02..9e64f97 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -908,6 +908,37 @@ void cmMakefile::AddCustomCommandToTarget( t.AddPostBuildCommand(cc); break; } + this->UpdateOutputToSourceMap(byproducts, &t); +} + +void cmMakefile::UpdateOutputToSourceMap( + std::vector const& byproducts, cmTarget* target) +{ + for (std::string const& o : byproducts) { + this->UpdateOutputToSourceMap(o, target); + } +} + +void cmMakefile::UpdateOutputToSourceMap(std::string const& byproduct, + cmTarget* target) +{ + SourceEntry entry; + entry.Sources.Target = target; + + auto pr = this->OutputToSource.emplace(byproduct, entry); + if (!pr.second) { + SourceEntry& current = pr.first->second; + // Has the target already been set? + if (!current.Sources.Target) { + current.Sources.Target = target; + } else { + // Multiple custom commands/targets produce the same output (source file + // or target). See also comment in other UpdateOutputToSourceMap + // overload. + // + // TODO: Warn the user about this case. + } + } } cmSourceFile* cmMakefile::AddCustomCommandToOutput( @@ -1003,35 +1034,47 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput( cc->SetDepfile(depfile); cc->SetJobPool(job_pool); file->SetCustomCommand(cc); - this->UpdateOutputToSourceMap(outputs, file); + this->UpdateOutputToSourceMap(outputs, file, false); + this->UpdateOutputToSourceMap(byproducts, file, true); } return file; } void cmMakefile::UpdateOutputToSourceMap( - std::vector const& outputs, cmSourceFile* source) + std::vector const& outputs, cmSourceFile* source, + bool byproduct) { for (std::string const& o : outputs) { - this->UpdateOutputToSourceMap(o, source); + this->UpdateOutputToSourceMap(o, source, byproduct); } } void cmMakefile::UpdateOutputToSourceMap(std::string const& output, - cmSourceFile* source) -{ - auto i = this->OutputToSource.find(output); - if (i != this->OutputToSource.end()) { - // Multiple custom commands produce the same output but may - // be attached to a different source file (MAIN_DEPENDENCY). - // LinearGetSourceFileWithOutput would return the first one, - // so keep the mapping for the first one. - // - // TODO: Warn the user about this case. However, the VS 8 generator - // triggers it for separate generate.stamp rules in ZERO_CHECK and - // individual targets. - return; + cmSourceFile* source, bool byproduct) +{ + SourceEntry entry; + entry.Sources.Source = source; + entry.Sources.SourceIsByproduct = byproduct; + + auto pr = this->OutputToSource.emplace(output, entry); + if (!pr.second) { + SourceEntry& current = pr.first->second; + // Outputs take precedence over byproducts + if (!current.Sources.Source || + (current.Sources.SourceIsByproduct && !byproduct)) { + current.Sources.Source = source; + current.Sources.SourceIsByproduct = false; + } else { + // Multiple custom commands produce the same output but may + // be attached to a different source file (MAIN_DEPENDENCY). + // LinearGetSourceFileWithOutput would return the first one, + // so keep the mapping for the first one. + // + // TODO: Warn the user about this case. However, the VS 8 generator + // triggers it for separate generate.stamp rules in ZERO_CHECK and + // individual targets. + } } - this->OutputToSource[output] = source; } cmSourceFile* cmMakefile::AddCustomCommandToOutput( @@ -1194,6 +1237,8 @@ cmTarget* cmMakefile::AddUtilityCommand( } else { cmSystemTools::Error("Could not get source file entry for " + force); } + + this->UpdateOutputToSourceMap(byproducts, target); } return target; } @@ -2007,6 +2052,7 @@ cmTarget* cmMakefile::AddNewTarget(cmStateEnums::TargetType type, this->Targets .emplace(name, cmTarget(name, type, cmTarget::VisibilityNormal, this)) .first; + this->OrderedTargets.push_back(&it->second); this->GetGlobalGenerator()->IndexTarget(&it->second); this->GetStateSnapshot().GetDirectory().AddNormalTargetName(name); return &it->second; @@ -2026,11 +2072,45 @@ bool AnyOutputMatches(const std::string& name, } return false; } + +bool AnyTargetCommandOutputMatches( + const std::string& name, const std::vector& commands) +{ + for (cmCustomCommand const& command : commands) { + if (AnyOutputMatches(name, command.GetByproducts())) { + return true; + } + } + return false; +} +} + +cmTarget* cmMakefile::LinearGetTargetWithOutput(const std::string& name) const +{ + // We go through the ordered vector of targets to get reproducible results + // should multiple names match. + for (cmTarget* t : this->OrderedTargets) { + // Does the output of any command match the source file name? + if (AnyTargetCommandOutputMatches(name, t->GetPreBuildCommands())) { + return t; + } + if (AnyTargetCommandOutputMatches(name, t->GetPreLinkCommands())) { + return t; + } + if (AnyTargetCommandOutputMatches(name, t->GetPostBuildCommands())) { + return t; + } + } + return nullptr; } cmSourceFile* cmMakefile::LinearGetSourceFileWithOutput( - const std::string& name) const + const std::string& name, cmSourceOutputKind kind, bool& byproduct) const { + // Outputs take precedence over byproducts. + byproduct = false; + cmSourceFile* fallback = nullptr; + // Look through all the source files that have custom commands and see if the // custom command has the passed source file as an output. for (cmSourceFile* src : this->SourceFiles) { @@ -2041,25 +2121,57 @@ cmSourceFile* cmMakefile::LinearGetSourceFileWithOutput( // Return the first matching output. return src; } + if (kind == cmSourceOutputKind::OutputOrByproduct) { + if (AnyOutputMatches(name, src->GetCustomCommand()->GetByproducts())) { + // Do not return the source yet as there might be a matching output. + fallback = src; + } + } } } - // otherwise return NULL - return nullptr; + // Did we find a byproduct? + byproduct = fallback != nullptr; + return fallback; } -cmSourceFile* cmMakefile::GetSourceFileWithOutput( +cmSourcesWithOutput cmMakefile::GetSourcesWithOutput( const std::string& name) const { + // Linear search? Also see GetSourceFileWithOutput for detail. + if (!cmSystemTools::FileIsFullPath(name)) { + cmSourcesWithOutput sources; + sources.Target = this->LinearGetTargetWithOutput(name); + sources.Source = this->LinearGetSourceFileWithOutput( + name, cmSourceOutputKind::OutputOrByproduct, sources.SourceIsByproduct); + return sources; + } + // Otherwise we use an efficient lookup map. + auto o = this->OutputToSource.find(name); + if (o != this->OutputToSource.end()) { + return o->second.Sources; + } + return {}; +} + +cmSourceFile* cmMakefile::GetSourceFileWithOutput( + const std::string& name, cmSourceOutputKind kind) const +{ // If the queried path is not absolute we use the backward compatible // linear-time search for an output with a matching suffix. if (!cmSystemTools::FileIsFullPath(name)) { - return this->LinearGetSourceFileWithOutput(name); + bool byproduct = false; + return this->LinearGetSourceFileWithOutput(name, kind, byproduct); } // Otherwise we use an efficient lookup map. auto o = this->OutputToSource.find(name); - if (o != this->OutputToSource.end()) { - return (*o).second; + if (o != this->OutputToSource.end() && + (!o->second.Sources.SourceIsByproduct || + kind == cmSourceOutputKind::OutputOrByproduct)) { + // Source file could also be null pointer for example if we found the + // byproduct of a utility target or a PRE_BUILD, PRE_LINK, or POST_BUILD + // command of a target. + return o->second.Sources.Source; } return nullptr; } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 52464d6..dc9318b 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -51,6 +51,24 @@ class cmTestGenerator; class cmVariableWatch; class cmake; +/** Flag if byproducts shall also be considered. */ +enum class cmSourceOutputKind +{ + OutputOnly, + OutputOrByproduct +}; + +/** Target and source file which have a specific output. */ +struct cmSourcesWithOutput +{ + /** Target with byproduct. */ + cmTarget* Target = nullptr; + + /** Source file with output or byproduct. */ + cmSourceFile* Source = nullptr; + bool SourceIsByproduct = false; +}; + /** A type-safe wrapper for a string representing a directory id. */ class cmDirectoryId { @@ -687,10 +705,19 @@ public: } /** - * Is there a source file that has the provided source file as an output? - * if so then return it + * Return the target if the provided source name is a byproduct of a utility + * target or a PRE_BUILD, PRE_LINK, or POST_BUILD command. + * Return the source file which has the provided source name as output. + */ + cmSourcesWithOutput GetSourcesWithOutput(const std::string& name) const; + + /** + * Is there a source file that has the provided source name as an output? + * If so then return it. */ - cmSourceFile* GetSourceFileWithOutput(const std::string& outName) const; + cmSourceFile* GetSourceFileWithOutput( + const std::string& name, + cmSourceOutputKind kind = cmSourceOutputKind::OutputOnly) const; //! Add a new cmTest to the list of tests for this makefile. cmTest* CreateTest(const std::string& testName); @@ -914,6 +941,9 @@ protected: mutable cmTargetMap Targets; std::map AliasTargets; + using TargetsVec = std::vector; + TargetsVec OrderedTargets; + using SourceFileVec = std::vector; SourceFileVec SourceFiles; @@ -1036,21 +1066,37 @@ private: cmSourceFileLocationKind kind = cmSourceFileLocationKind::Ambiguous); /** - * Old version of GetSourceFileWithOutput(const std::string&) kept for - * backward-compatibility. It implements a linear search and support - * relative file paths. It is used as a fall back by - * GetSourceFileWithOutput(const std::string&). + * See LinearGetSourceFileWithOutput for background information + */ + cmTarget* LinearGetTargetWithOutput(const std::string& name) const; + + /** + * Generalized old version of GetSourceFileWithOutput kept for + * backward-compatibility. It implements a linear search and supports + * relative file paths. It is used as a fall back by GetSourceFileWithOutput + * and GetSourcesWithOutput. */ - cmSourceFile* LinearGetSourceFileWithOutput(const std::string& cname) const; + cmSourceFile* LinearGetSourceFileWithOutput(const std::string& name, + cmSourceOutputKind kind, + bool& byproduct) const; + + struct SourceEntry + { + cmSourcesWithOutput Sources; + }; // A map for fast output to input look up. - using OutputToSourceMap = std::unordered_map; + using OutputToSourceMap = std::unordered_map; OutputToSourceMap OutputToSource; + void UpdateOutputToSourceMap(std::vector const& byproducts, + cmTarget* target); + void UpdateOutputToSourceMap(std::string const& byproduct, cmTarget* target); + void UpdateOutputToSourceMap(std::vector const& outputs, - cmSourceFile* source); - void UpdateOutputToSourceMap(std::string const& output, - cmSourceFile* source); + cmSourceFile* source, bool byproduct); + void UpdateOutputToSourceMap(std::string const& output, cmSourceFile* source, + bool byproduct); bool AddRequiredTargetCFeature(cmTarget* target, const std::string& feature, std::string* error = nullptr) const; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=62d59323899330197e795872c13c1d300a97d088 commit 62d59323899330197e795872c13c1d300a97d088 Author: Daniel Eiband AuthorDate: Wed Sep 11 11:32:23 2019 +0200 Commit: Daniel Eiband CommitDate: Thu Sep 12 15:49:55 2019 +0200 Refatoring: Extract AnyOutputMatches utility diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 16cc453..3a80b02 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2012,27 +2012,34 @@ cmTarget* cmMakefile::AddNewTarget(cmStateEnums::TargetType type, return &it->second; } +namespace { +bool AnyOutputMatches(const std::string& name, + const std::vector& outputs) +{ + for (std::string const& output : outputs) { + std::string::size_type pos = output.rfind(name); + // If the output matches exactly + if (pos != std::string::npos && pos == output.size() - name.size() && + (pos == 0 || output[pos - 1] == '/')) { + return true; + } + } + return false; +} +} + cmSourceFile* cmMakefile::LinearGetSourceFileWithOutput( const std::string& name) const { - std::string out; - - // look through all the source files that have custom commands - // and see if the custom command has the passed source file as an output + // Look through all the source files that have custom commands and see if the + // custom command has the passed source file as an output. for (cmSourceFile* src : this->SourceFiles) { - // does this source file have a custom command? + // Does this source file have a custom command? if (src->GetCustomCommand()) { // Does the output of the custom command match the source file name? - const std::vector& outputs = - src->GetCustomCommand()->GetOutputs(); - for (std::string const& output : outputs) { - out = output; - std::string::size_type pos = out.rfind(name); - // If the output matches exactly - if (pos != std::string::npos && pos == out.size() - name.size() && - (pos == 0 || out[pos - 1] == '/')) { - return src; - } + if (AnyOutputMatches(name, src->GetCustomCommand()->GetOutputs())) { + // Return the first matching output. + return src; } } } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d69457077d021b7d4ea10bf2201da61222966c92 commit d69457077d021b7d4ea10bf2201da61222966c92 Author: Alexej Harm AuthorDate: Wed Sep 11 15:22:47 2019 +0200 Commit: Alexej Harm CommitDate: Thu Sep 12 15:19:01 2019 +0200 CPackWIX: Allow omitting program menu folder and uninstall shortcut diff --git a/Help/cpack_gen/wix.rst b/Help/cpack_gen/wix.rst index dde4943..7fb5a12 100644 --- a/Help/cpack_gen/wix.rst +++ b/Help/cpack_gen/wix.rst @@ -95,6 +95,10 @@ Windows using WiX. If this variable is not set, it will be initialized with CPACK_PACKAGE_NAME + If this variable is set to ``.``, then application shortcuts will be + created directly in the start menu and the uninstaller shortcut will be + omitted. + .. variable:: CPACK_WIX_CULTURES Language(s) of the installer diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index b0b2df2..f784832 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -537,9 +537,16 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() } } - bool emitUninstallShortcut = - emittedShortcutTypes.find(cmWIXShortcuts::START_MENU) != - emittedShortcutTypes.end(); + bool emitUninstallShortcut = true; + const char* cpackWixProgramMenuFolder = + GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER"); + if (cpackWixProgramMenuFolder && + cm::string_view(cpackWixProgramMenuFolder) == ".") { + emitUninstallShortcut = false; + } else if (emittedShortcutTypes.find(cmWIXShortcuts::START_MENU) == + emittedShortcutTypes.end()) { + emitUninstallShortcut = false; + } if (!CreateShortcuts(std::string(), "ProductFeature", globalShortcuts, emitUninstallShortcut, fileDefinitions, @@ -733,9 +740,16 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType( { std::string directoryId; switch (type) { - case cmWIXShortcuts::START_MENU: - directoryId = "PROGRAM_MENU_FOLDER"; - break; + case cmWIXShortcuts::START_MENU: { + const char* cpackWixProgramMenuFolder = + GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER"); + if (cpackWixProgramMenuFolder && + cm::string_view(cpackWixProgramMenuFolder) == ".") { + directoryId = "ProgramMenuFolder"; + } else { + directoryId = "PROGRAM_MENU_FOLDER"; + } + } break; case cmWIXShortcuts::DESKTOP: directoryId = "DesktopFolder"; break; @@ -789,8 +803,13 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType( fileDefinitions); if (type == cmWIXShortcuts::START_MENU) { - fileDefinitions.EmitRemoveFolder("CM_REMOVE_PROGRAM_MENU_FOLDER" + - idSuffix); + const char* cpackWixProgramMenuFolder = + GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER"); + if (cpackWixProgramMenuFolder && + cm::string_view(cpackWixProgramMenuFolder) != ".") { + fileDefinitions.EmitRemoveFolder("CM_REMOVE_PROGRAM_MENU_FOLDER" + + idSuffix); + } } if (emitUninstallShortcut) { diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx index 975dffb..0a83ca2 100644 --- a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx @@ -14,10 +14,12 @@ void cmWIXDirectoriesSourceWriter::EmitStartMenuFolder( BeginElement("Directory"); AddAttribute("Id", "ProgramMenuFolder"); - BeginElement("Directory"); - AddAttribute("Id", "PROGRAM_MENU_FOLDER"); - AddAttribute("Name", startMenuFolder); - EndElement("Directory"); + if (startMenuFolder != ".") { + BeginElement("Directory"); + AddAttribute("Id", "PROGRAM_MENU_FOLDER"); + AddAttribute("Name", startMenuFolder); + EndElement("Directory"); + } EndElement("Directory"); } ----------------------------------------------------------------------- Summary of changes: Help/command/add_custom_command.rst | 6 +- Help/command/add_custom_target.rst | 6 +- Help/cpack_gen/wix.rst | 4 + Source/CPack/WiX/cmCPackWIXGenerator.cxx | 35 +++- Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx | 10 +- Source/cmBuildCommand.cxx | 75 ++++---- Source/cmBuildCommand.h | 42 +---- Source/cmCommands.cxx | 61 +++---- Source/cmCreateTestSourceList.cxx | 39 ++--- Source/cmCreateTestSourceList.h | 29 +--- Source/cmDefinePropertyCommand.cxx | 51 +++--- Source/cmDefinePropertyCommand.h | 26 +-- Source/cmEnableLanguageCommand.cxx | 17 +- Source/cmEnableLanguageCommand.h | 32 +--- Source/cmFLTKWrapUICommand.cxx | 39 ++--- Source/cmFLTKWrapUICommand.h | 30 +--- Source/cmGeneratorTarget.cxx | 35 ++-- Source/cmGetSourceFilePropertyCommand.cxx | 19 +- Source/cmGetSourceFilePropertyCommand.h | 21 +-- Source/cmGetTargetPropertyCommand.cxx | 26 +-- Source/cmGetTargetPropertyCommand.h | 21 +-- Source/cmGetTestPropertyCommand.cxx | 17 +- Source/cmGetTestPropertyCommand.h | 21 +-- Source/cmIncludeExternalMSProjectCommand.cxx | 32 ++-- Source/cmIncludeExternalMSProjectCommand.h | 31 +--- Source/cmIncludeRegularExpressionCommand.cxx | 18 +- Source/cmIncludeRegularExpressionCommand.h | 30 +--- Source/cmInstallFilesCommand.cxx | 23 +-- Source/cmInstallFilesCommand.h | 30 +--- Source/cmInstallProgramsCommand.cxx | 20 +-- Source/cmInstallProgramsCommand.h | 30 +--- Source/cmInstallTargetsCommand.cxx | 26 +-- Source/cmInstallTargetsCommand.h | 31 +--- Source/cmLinkLibrariesCommand.cxx | 23 ++- Source/cmLinkLibrariesCommand.h | 31 +--- Source/cmMakefile.cxx | 193 +++++++++++++++++---- Source/cmMakefile.h | 70 ++++++-- Source/cmQTWrapCPPCommand.cxx | 41 +++-- Source/cmQTWrapCPPCommand.h | 30 +--- Source/cmQTWrapUICommand.cxx | 63 ++++--- Source/cmQTWrapUICommand.h | 29 +--- Source/cmRemoveDefinitionsCommand.cxx | 16 +- Source/cmRemoveDefinitionsCommand.h | 31 +--- Source/cmSetSourceFilesPropertiesCommand.cxx | 35 ++-- Source/cmSetSourceFilesPropertiesCommand.h | 29 +--- Source/cmSetTestsPropertiesCommand.cxx | 31 ++-- Source/cmSetTestsPropertiesCommand.h | 26 +-- Source/cmSubdirCommand.cxx | 28 ++- Source/cmSubdirCommand.h | 31 +--- Tests/CustomCommandByproducts/CMakeLists.txt | 39 ++++- .../CustomCommandByproducts.c | 3 +- Tests/CustomCommandByproducts/byproduct9.c.in | 1 + 52 files changed, 689 insertions(+), 994 deletions(-) create mode 100644 Tests/CustomCommandByproducts/byproduct9.c.in hooks/post-receive -- CMake From kwrobot at kitware.com Sat Sep 14 00:01:35 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Sat, 14 Sep 2019 00:01:35 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1044-g8032977 Message-ID: <20190914040135.4C2781030C6@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 80329771fec7c516540e1db29d971f8f28ed593b (commit) from 19bcdca93c3a05db12652677f8d0e310797bb375 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=80329771fec7c516540e1db29d971f8f28ed593b commit 80329771fec7c516540e1db29d971f8f28ed593b Author: Kitware Robot AuthorDate: Sat Sep 14 00:01:05 2019 -0400 Commit: Kitware Robot CommitDate: Sat Sep 14 00:01:05 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index e9cca30..7384954 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 15) -set(CMake_VERSION_PATCH 20190913) +set(CMake_VERSION_PATCH 20190914) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Sun Sep 15 00:01:04 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Sun, 15 Sep 2019 00:01:04 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1045-gc6ed044 Message-ID: <20190915040105.CCDBB11EB34@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via c6ed04431988ac337ea21d74f035148b6c57f894 (commit) from 80329771fec7c516540e1db29d971f8f28ed593b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c6ed04431988ac337ea21d74f035148b6c57f894 commit c6ed04431988ac337ea21d74f035148b6c57f894 Author: Kitware Robot AuthorDate: Sun Sep 15 00:01:05 2019 -0400 Commit: Kitware Robot CommitDate: Sun Sep 15 00:01:05 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 7384954..f41a727 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 15) -set(CMake_VERSION_PATCH 20190914) +set(CMake_VERSION_PATCH 20190915) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Sep 16 00:00:30 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 16 Sep 2019 00:00:30 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1046-gbfa2eaa Message-ID: <20190916040030.82E2D113619@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via bfa2eaa617de778ecfb2a0678c9898605822260d (commit) from c6ed04431988ac337ea21d74f035148b6c57f894 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bfa2eaa617de778ecfb2a0678c9898605822260d commit bfa2eaa617de778ecfb2a0678c9898605822260d Author: Kitware Robot AuthorDate: Mon Sep 16 00:01:06 2019 -0400 Commit: Kitware Robot CommitDate: Mon Sep 16 00:01:06 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index f41a727..2aef888 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 15) -set(CMake_VERSION_PATCH 20190915) +set(CMake_VERSION_PATCH 20190916) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Sep 16 10:20:22 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 16 Sep 2019 10:20:22 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1053-g7c47894 Message-ID: <20190916142023.030676EF2D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 7c47894b459c0f71ebe32b64a619f290df6bcf44 (commit) via 1df2f8803b79c2e27d123de4f3f351bae824feef (commit) via 33588714832de46915542094c93a96096755fb55 (commit) via 7bf8eb78777e70d2d9c4dc7a3dd6875d82766592 (commit) via 5d28e361b709a781a131cb9d9da73f04484eff54 (commit) via c16641607fcf85206b3faf67ae1e1bab173bf44d (commit) via 4fb29850ad325b70fb412d4fd596c0a0d627ae8b (commit) from bfa2eaa617de778ecfb2a0678c9898605822260d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7c47894b459c0f71ebe32b64a619f290df6bcf44 commit 7c47894b459c0f71ebe32b64a619f290df6bcf44 Merge: 1df2f88 5d28e36 Author: Brad King AuthorDate: Mon Sep 16 14:16:57 2019 +0000 Commit: Kitware Robot CommitDate: Mon Sep 16 10:18:51 2019 -0400 Merge topic 'prepare-deferred-custom-command-creation' 5d28e361b7 add_custom_command: Move append functionality into class cmMakefile 4fb29850ad add_custom_command: Refactor setting implicit depends Acked-by: Kitware Robot Merge-request: !3810 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1df2f8803b79c2e27d123de4f3f351bae824feef commit 1df2f8803b79c2e27d123de4f3f351bae824feef Merge: 3358871 c166416 Author: Brad King AuthorDate: Mon Sep 16 14:16:40 2019 +0000 Commit: Kitware Robot CommitDate: Mon Sep 16 10:17:22 2019 -0400 Merge topic 'add_custom_command-genex-slash' c16641607f add_custom_command: Delay slash conversion until after genex evaluation Acked-by: Kitware Robot Merge-request: !3791 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=33588714832de46915542094c93a96096755fb55 commit 33588714832de46915542094c93a96096755fb55 Merge: bfa2eaa 7bf8eb7 Author: Brad King AuthorDate: Mon Sep 16 14:15:23 2019 +0000 Commit: Kitware Robot CommitDate: Mon Sep 16 10:15:37 2019 -0400 Merge topic 'remove-unused-class' 7bf8eb7877 Remove unused cmInstallExportAndroidMKGenerator Acked-by: Kitware Robot Merge-request: !3812 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7bf8eb78777e70d2d9c4dc7a3dd6875d82766592 commit 7bf8eb78777e70d2d9c4dc7a3dd6875d82766592 Author: Tushar Maheshwari AuthorDate: Fri Sep 13 13:23:33 2019 -0400 Commit: Brad King CommitDate: Fri Sep 13 13:24:45 2019 -0400 Remove unused cmInstallExportAndroidMKGenerator This class was added by commit 42ce9f1e71 (Add support for creating prebuilt Android.mk files, 2016-07-12, v3.7.0-rc1~126^2) but not used. diff --git a/Source/cmInstallExportAndroidMKGenerator.cxx b/Source/cmInstallExportAndroidMKGenerator.cxx deleted file mode 100644 index e8de029..0000000 --- a/Source/cmInstallExportAndroidMKGenerator.cxx +++ /dev/null @@ -1,134 +0,0 @@ - -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmInstallExportAndroidMKGenerator.h" - -#include - -#include "cmExportInstallFileGenerator.h" -#include "cmExportSet.h" -#include "cmGeneratedFileStream.h" -#include "cmGlobalGenerator.h" -#include "cmInstallFilesGenerator.h" -#include "cmInstallTargetGenerator.h" -#include "cmLocalGenerator.h" -#include "cmMakefile.h" -#include "cmMessageType.h" - -cmInstallExportAndroidMKGenerator::cmInstallExportAndroidMKGenerator( - cmExportSet* exportSet, const char* destination, - const char* file_permissions, std::vector const& configurations, - const char* component, MessageLevel message, bool exclude_from_all, - const char* filename, const char* name_space, bool exportOld) - : cmInstallExportGenerator(exportSet, destination, file_permissions, - configurations, component, message, - exclude_from_all, filename, name_space, exportOld) -{ -} - -cmInstallExportAndroidMKGenerator::~cmInstallExportAndroidMKGenerator() -{ -} - -bool cmInstallExportAndroidMKGenerator::Compute(cmLocalGenerator* lg) -{ - this->LocalGenerator = lg; - this->ExportSet->Compute(lg); - return true; -} - -void cmInstallExportAndroidMKGenerator::GenerateScript(std::ostream& os) -{ - // Skip empty sets. - if (ExportSet->GetTargetExports()->empty()) { - std::ostringstream e; - e << "INSTALL(EXPORT) given unknown export \"" << ExportSet->GetName() - << "\""; - cmSystemTools::Error(e.str()); - return; - } - - // Create the temporary directory in which to store the files. - this->ComputeTempDir(); - cmSystemTools::MakeDirectory(this->TempDir.c_str()); - - // Construct a temporary location for the file. - this->MainImportFile = cmStrCat(this->TempDir, '/', this->FileName); - - // Generate the import file for this export set. - this->EFGen->SetExportFile(this->MainImportFile.c_str()); - this->EFGen->SetNamespace(this->Namespace); - this->EFGen->SetExportOld(this->ExportOld); - if (this->ConfigurationTypes->empty()) { - if (!this->ConfigurationName.empty()) { - this->EFGen->AddConfiguration(this->ConfigurationName); - } else { - this->EFGen->AddConfiguration(""); - } - } else { - for (std::string const& config : this->ConfigurationTypes) { - this->EFGen->AddConfiguration(config); - } - } - this->EFGen->GenerateImportFile(); - - // Perform the main install script generation. - this->cmInstallGenerator::GenerateScript(os); -} - -void cmInstallExportAndroidMKGenerator::GenerateScriptConfigs( - std::ostream& os, Indent const& indent) -{ - // Create the main install rules first. - this->cmInstallGenerator::GenerateScriptConfigs(os, indent); - - // Now create a configuration-specific install rule for the import - // file of each configuration. - std::vector files; - for (auto const& pair : this->EFGen->GetConfigImportFiles()) { - files.push_back(pair.second); - std::string config_test = this->CreateConfigTest(pair.first); - os << indent << "if(" << config_test << ")\n"; - this->AddInstallRule(os, this->Destination, cmInstallType_FILES, files, - false, this->FilePermissions.c_str(), nullptr, - nullptr, nullptr, indent.Next()); - os << indent << "endif()\n"; - files.clear(); - } -} - -void cmInstallExportAndroidMKGenerator::GenerateScriptActions( - std::ostream& os, Indent const& indent) -{ - // Remove old per-configuration export files if the main changes. - std::string installedDir = - cmStrCat("$ENV{DESTDIR}", - this->ConvertToAbsoluteDestination(this->Destination), '/'); - std::string installedFile = cmStrCat(installedDir, this->FileName); - os << indent << "if(EXISTS \"" << installedFile << "\")\n"; - Indent indentN = indent.Next(); - Indent indentNN = indentN.Next(); - Indent indentNNN = indentNN.Next(); - /* clang-format off */ - os << indentN << "file(DIFFERENT EXPORT_FILE_CHANGED FILES\n" - << indentN << " \"" << installedFile << "\"\n" - << indentN << " \"" << this->MainImportFile << "\")\n"; - os << indentN << "if(EXPORT_FILE_CHANGED)\n"; - os << indentNN << "file(GLOB OLD_CONFIG_FILES \"" << installedDir - << this->EFGen->GetConfigImportFileGlob() << "\")\n"; - os << indentNN << "if(OLD_CONFIG_FILES)\n"; - os << indentNNN << "message(STATUS \"Old export file \\\"" << installedFile - << "\\\" will be replaced. Removing files [${OLD_CONFIG_FILES}].\")\n"; - os << indentNNN << "file(REMOVE ${OLD_CONFIG_FILES})\n"; - os << indentNN << "endif()\n"; - os << indentN << "endif()\n"; - os << indent << "endif()\n"; - /* clang-format on */ - - // Install the main export file. - std::vector files; - files.push_back(this->MainImportFile); - this->AddInstallRule(os, this->Destination, cmInstallType_FILES, files, - false, this->FilePermissions.c_str(), nullptr, nullptr, - nullptr, indent); -} diff --git a/Source/cmInstallExportAndroidMKGenerator.h b/Source/cmInstallExportAndroidMKGenerator.h deleted file mode 100644 index a92ff27..0000000 --- a/Source/cmInstallExportAndroidMKGenerator.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cmInstallExportAndroidMKGenerator_h -#define cmInstallExportAndroidMKGenerator_h - -#include "cmInstallExportGenerator.h" - -class cmExportInstallFileGenerator; -class cmInstallFilesGenerator; -class cmInstallTargetGenerator; -class cmExportSet; -class cmMakefile; - -/** \class cmInstallExportAndroidMKGenerator - * \brief Generate rules for creating an export files. - */ -class cmInstallExportAndroidMKGenerator : public cmInstallExportGenerator -{ -public: - cmInstallExportAndroidMKGenerator( - cmExportSet* exportSet, const char* dest, const char* file_permissions, - const std::vector& configurations, const char* component, - MessageLevel message, bool exclude_from_all, const char* filename, - const char* name_space, bool exportOld); - ~cmInstallExportAndroidMKGenerator(); - - bool Compute(cmLocalGenerator* lg) override; - -protected: - virtual void GenerateScript(std::ostream& os); - virtual void GenerateScriptConfigs(std::ostream& os, Indent const& indent); - virtual void GenerateScriptActions(std::ostream& os, Indent const& indent); - void GenerateImportFile(cmExportSet const* exportSet); - void GenerateImportFile(const char* config, cmExportSet const* exportSet); -}; - -#endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5d28e361b709a781a131cb9d9da73f04484eff54 commit 5d28e361b709a781a131cb9d9da73f04484eff54 Author: Daniel Eiband AuthorDate: Thu Sep 12 23:20:13 2019 +0200 Commit: Brad King CommitDate: Fri Sep 13 11:00:21 2019 -0400 add_custom_command: Move append functionality into class cmMakefile diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index 2a0db45..90317bd 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -13,7 +13,6 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmPolicies.h" -#include "cmSourceFile.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTarget.h" @@ -317,14 +316,9 @@ bool cmAddCustomCommandCommand(std::vector const& args, // Check for an append request. if (append) { - // Lookup an existing command. - if (cmSourceFile* sf = mf.GetSourceFileWithOutput(output[0])) { - if (cmCustomCommand* cc = sf->GetCustomCommand()) { - cc->AppendCommands(commandLines); - cc->AppendDepends(depends); - cc->AppendImplicitDepends(implicit_depends); - return true; - } + if (mf.AppendCustomCommandToOutput(output[0], depends, implicit_depends, + commandLines)) { + return true; } // No command for this output exists. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ec2e646..000d84b 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1111,6 +1111,23 @@ void cmMakefile::AddCustomCommandOldStyle( } } +bool cmMakefile::AppendCustomCommandToOutput( + const std::string& output, const std::vector& depends, + const cmImplicitDependsList& implicit_depends, + const cmCustomCommandLines& commandLines) +{ + // Lookup an existing command. + if (cmSourceFile* sf = this->GetSourceFileWithOutput(output)) { + if (cmCustomCommand* cc = sf->GetCustomCommand()) { + cc->AppendCommands(commandLines); + cc->AppendDepends(depends); + cc->AppendImplicitDepends(implicit_depends); + return true; + } + } + return false; +} + cmTarget* cmMakefile::AddUtilityCommand( const std::string& utilityName, TargetOrigin origin, bool excludeFromAll, const std::vector& depends, const char* workingDirectory, diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index f9031c1..8671bd7 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -185,6 +185,10 @@ public: const std::string& source, const cmCustomCommandLines& commandLines, const char* comment); + bool AppendCustomCommandToOutput( + const std::string& output, const std::vector& depends, + const cmImplicitDependsList& implicit_depends, + const cmCustomCommandLines& commandLines); /** * Add a define flag to the build. https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c16641607fcf85206b3faf67ae1e1bab173bf44d commit c16641607fcf85206b3faf67ae1e1bab173bf44d Author: Sebastian Lipponer AuthorDate: Fri Sep 6 22:33:47 2019 +0200 Commit: Brad King CommitDate: Fri Sep 13 10:56:26 2019 -0400 add_custom_command: Delay slash conversion until after genex evaluation Generator expressions may contain or produce backslashes. Fixes: #19553 diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index d2330e1..d7afb57 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -4,7 +4,6 @@ #include #include -#include #include "cmCustomCommand.h" #include "cmCustomCommandLines.h" @@ -248,6 +247,8 @@ bool cmAddCustomCommandCommand(std::vector const& args, // An implicit dependency starting point is also an // explicit dependency. std::string dep = copy; + // Upfront path conversion is correct because Genex + // are not supported. cmSystemTools::ConvertToUnixSlashes(dep); depends.push_back(dep); @@ -264,9 +265,7 @@ bool cmAddCustomCommandCommand(std::vector const& args, target = copy; break; case doing_depends: { - std::string dep = copy; - cmSystemTools::ConvertToUnixSlashes(dep); - depends.push_back(std::move(dep)); + depends.push_back(copy); } break; case doing_outputs: outputs.push_back(filename); diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 82cc037..6a4125b 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -58,6 +58,7 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, std::vector result = cmExpandedList(cge->Evaluate(this->LG, this->Config)); for (std::string& it : result) { + cmSystemTools::ConvertToUnixSlashes(it); if (cmSystemTools::FileIsFullPath(it)) { it = cmSystemTools::CollapseFullPath(it); } diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index 3ff2b85..9d51342 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -86,7 +86,7 @@ add_custom_target(check-part1 ALL -Dtest_colons_4=$<1:C:\\CMake> -Dtest_colons_5=$<1:C:/CMake> -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part1.cmake - COMMAND ${CMAKE_COMMAND} -E echo "check done (part 1 of 4)" + COMMAND ${CMAKE_COMMAND} -E echo "check done (part 1 of 5)" VERBATIM ) @@ -157,7 +157,7 @@ add_custom_target(check-part2 ALL -Dtest_arbitrary_content_comma_9=$<1:a,,b,,> -Dtest_arbitrary_content_comma_10=$<1:,,a,,b,,> -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part2.cmake - COMMAND ${CMAKE_COMMAND} -E echo "check done (part 2 of 4)" + COMMAND ${CMAKE_COMMAND} -E echo "check done (part 2 of 5)" VERBATIM ) @@ -251,7 +251,7 @@ add_custom_target(check-part3 ALL -Dequal22=$ -Dequal23=$ -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part3.cmake - COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 4)" + COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 5)" VERBATIM ) @@ -277,7 +277,27 @@ add_custom_target(check-part4 ALL -DWIN32=${WIN32} -DCMAKE_GENERATOR=${CMAKE_GENERATOR} -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part4.cmake - COMMAND ${CMAKE_COMMAND} -E echo "check done (part 4 of 4)" + COMMAND ${CMAKE_COMMAND} -E echo "check done (part 4 of 5)" + VERBATIM + ) + +add_custom_target(check-part5 ALL + COMMAND ${CMAKE_COMMAND} -E echo "check done (part 5 of 5)" + DEPENDS check-part5.stamp + VERBATIM + ) + +add_custom_command( + OUTPUT check-part5.stamp + DEPENDS $ + COMMAND ${CMAKE_COMMAND} -E sleep 0 + VERBATIM + ) +set_property(SOURCE check-part5.stamp PROPERTY SYMBOLIC 1) + +add_custom_command( + OUTPUT file.foo.bar + COMMAND ${CMAKE_COMMAND} -P check-part5.cmake VERBATIM ) diff --git a/Tests/GeneratorExpression/check-part5.cmake b/Tests/GeneratorExpression/check-part5.cmake new file mode 100644 index 0000000..77d1387 --- /dev/null +++ b/Tests/GeneratorExpression/check-part5.cmake @@ -0,0 +1 @@ +message(SEND_ERROR "$ genex in DEPENDS argument of 'add_custom_command()' is not empty") https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4fb29850ad325b70fb412d4fd596c0a0d627ae8b commit 4fb29850ad325b70fb412d4fd596c0a0d627ae8b Author: Daniel Eiband AuthorDate: Thu Sep 12 23:00:36 2019 +0200 Commit: Daniel Eiband CommitDate: Thu Sep 12 23:00:36 2019 +0200 add_custom_command: Refactor setting implicit depends Implicit dependencies are now passed as argument to AddCustomCommandToOutput. This is necessary to be able to delay custom command creation. diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index d2330e1..2a0db45 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -51,7 +51,7 @@ bool cmAddCustomCommandCommand(std::vector const& args, bool uses_terminal = false; bool command_expand_lists = false; std::string implicit_depends_lang; - cmCustomCommand::ImplicitDependsList implicit_depends; + cmImplicitDependsList implicit_depends; // Accumulate one command line at a time. cmCustomCommandLine currentLine; @@ -351,28 +351,10 @@ bool cmAddCustomCommandCommand(std::vector const& args, job_pool, command_expand_lists); } else if (target.empty()) { // Target is empty, use the output. - mf.AddCustomCommandToOutput(output, byproducts, depends, main_dependency, - commandLines, comment, working.c_str(), false, - escapeOldStyle, uses_terminal, - command_expand_lists, depfile, job_pool); - - // Add implicit dependency scanning requests if any were given. - if (!implicit_depends.empty()) { - bool okay = false; - if (cmSourceFile* sf = mf.GetSourceFileWithOutput(output[0])) { - if (cmCustomCommand* cc = sf->GetCustomCommand()) { - okay = true; - cc->SetImplicitDepends(implicit_depends); - } - } - if (!okay) { - std::ostringstream e; - e << "could not locate source file with a custom command producing \"" - << output[0] << "\" even though this command tried to create it!"; - status.SetError(e.str()); - return false; - } - } + mf.AddCustomCommandToOutput( + output, byproducts, depends, main_dependency, implicit_depends, + commandLines, comment, working.c_str(), false, escapeOldStyle, + uses_terminal, command_expand_lists, depfile, job_pool); } else if (!byproducts.empty()) { status.SetError("BYPRODUCTS may not be specified with SOURCE signatures"); return false; diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx index 7402eeb..fc6718d 100644 --- a/Source/cmCustomCommand.cxx +++ b/Source/cmCustomCommand.cxx @@ -88,18 +88,17 @@ cmListFileBacktrace const& cmCustomCommand::GetBacktrace() const return this->Backtrace; } -cmCustomCommand::ImplicitDependsList const& -cmCustomCommand::GetImplicitDepends() const +cmImplicitDependsList const& cmCustomCommand::GetImplicitDepends() const { return this->ImplicitDepends; } -void cmCustomCommand::SetImplicitDepends(ImplicitDependsList const& l) +void cmCustomCommand::SetImplicitDepends(cmImplicitDependsList const& l) { this->ImplicitDepends = l; } -void cmCustomCommand::AppendImplicitDepends(ImplicitDependsList const& l) +void cmCustomCommand::AppendImplicitDepends(cmImplicitDependsList const& l) { cmAppend(this->ImplicitDepends, l); } diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h index 102b178..bb5a0ed 100644 --- a/Source/cmCustomCommand.h +++ b/Source/cmCustomCommand.h @@ -14,6 +14,11 @@ class cmMakefile; +class cmImplicitDependsList + : public std::vector> +{ +}; + /** \class cmCustomCommand * \brief A class to encapsulate a custom command * @@ -68,13 +73,9 @@ public: /** Backtrace of the command that created this custom command. */ cmListFileBacktrace const& GetBacktrace() const; - using ImplicitDependsPair = std::pair; - class ImplicitDependsList : public std::vector - { - }; - void SetImplicitDepends(ImplicitDependsList const&); - void AppendImplicitDepends(ImplicitDependsList const&); - ImplicitDependsList const& GetImplicitDepends() const; + void SetImplicitDepends(cmImplicitDependsList const&); + void AppendImplicitDepends(cmImplicitDependsList const&); + cmImplicitDependsList const& GetImplicitDepends() const; /** Set/Get whether this custom command should be given access to the real console (if possible). */ @@ -99,7 +100,7 @@ private: std::vector Depends; cmCustomCommandLines CommandLines; cmListFileBacktrace Backtrace; - ImplicitDependsList ImplicitDepends; + cmImplicitDependsList ImplicitDepends; std::string Comment; std::string WorkingDirectory; std::string Depfile; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 5e60108..18ff9ac 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGlobalVisualStudio8Generator.h" +#include "cmCustomCommand.h" #include "cmDocumentationEntry.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorExpression.h" @@ -191,11 +192,13 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() // file as the main dependency because it would get // overwritten by the CreateVCProjBuildRule. // (this could be avoided with per-target source files) - std::string no_main_dependency; std::vector no_byproducts; + std::string no_main_dependency; + cmImplicitDependsList no_implicit_depends; if (cmSourceFile* file = mf->AddCustomCommandToOutput( - stamps, no_byproducts, listFiles, no_main_dependency, commandLines, - "Checking Build System", no_working_directory, true, false)) { + stamps, no_byproducts, listFiles, no_main_dependency, + no_implicit_depends, commandLines, "Checking Build System", + no_working_directory, true, false)) { gt->AddSource(file->ResolveFullPath()); } else { cmSystemTools::Error("Error adding rule for " + stamps[0]); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 16cc453..ec2e646 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -914,6 +914,7 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput( const std::vector& outputs, const std::vector& byproducts, const std::vector& depends, const std::string& main_dependency, + const cmImplicitDependsList& implicit_depends, const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace, bool escapeOldStyle, bool uses_terminal, bool command_expand_lists, const std::string& depfile, @@ -998,6 +999,7 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput( this, outputs, byproducts, depends2, commandLines, comment, workingDir); cc->SetEscapeOldStyle(escapeOldStyle); cc->SetEscapeAllowMakeVars(true); + cc->SetImplicitDepends(implicit_depends); cc->SetUsesTerminal(uses_terminal); cc->SetCommandExpandLists(command_expand_lists); cc->SetDepfile(depfile); @@ -1044,10 +1046,11 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput( std::vector outputs; outputs.push_back(output); std::vector no_byproducts; + cmImplicitDependsList no_implicit_depends; return this->AddCustomCommandToOutput( - outputs, no_byproducts, depends, main_dependency, commandLines, comment, - workingDir, replace, escapeOldStyle, uses_terminal, command_expand_lists, - depfile, job_pool); + outputs, no_byproducts, depends, main_dependency, no_implicit_depends, + commandLines, comment, workingDir, replace, escapeOldStyle, uses_terminal, + command_expand_lists, depfile, job_pool); } void cmMakefile::AddCustomCommandOldStyle( @@ -1181,11 +1184,12 @@ cmTarget* cmMakefile::AddUtilityCommand( std::vector forced; forced.push_back(force); std::string no_main_dependency; + cmImplicitDependsList no_implicit_depends; bool no_replace = false; this->AddCustomCommandToOutput( - forced, byproducts, depends, no_main_dependency, commandLines, comment, - workingDirectory, no_replace, escapeOldStyle, uses_terminal, - command_expand_lists, /*depfile=*/"", job_pool); + forced, byproducts, depends, no_main_dependency, no_implicit_depends, + commandLines, comment, workingDirectory, no_replace, escapeOldStyle, + uses_terminal, command_expand_lists, /*depfile=*/"", job_pool); cmSourceFile* sf = target->AddSourceCMP0049(force); // The output is not actually created so mark it symbolic. diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 52464d6..f9031c1 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -42,6 +42,7 @@ class cmExportBuildFileGenerator; class cmFunctionBlocker; class cmGeneratorExpressionEvaluationFile; class cmGlobalGenerator; +class cmImplicitDependsList; class cmInstallGenerator; class cmMessenger; class cmSourceFile; @@ -166,6 +167,7 @@ public: const std::vector& byproducts, const std::vector& depends, const std::string& main_dependency, + const cmImplicitDependsList& implicit_depends, const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace = false, bool escapeOldStyle = true, bool uses_terminal = false, bool command_expand_lists = false, diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index d6916b0..54304c3 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1166,10 +1166,12 @@ bool cmQtAutoGenInitializer::InitRccTargets() if (!this->Rcc.ExecutableTargetName.empty()) { ccDepends.push_back(this->Rcc.ExecutableTargetName); } - makefile->AddCustomCommandToOutput(ccOutput, ccByproducts, ccDepends, - /*main_dependency*/ std::string(), - commandLines, ccComment.c_str(), - this->Dir.Work.c_str()); + std::string no_main_dependency; + cmImplicitDependsList no_implicit_depends; + makefile->AddCustomCommandToOutput( + ccOutput, ccByproducts, ccDepends, no_main_dependency, + no_implicit_depends, commandLines, ccComment.c_str(), + this->Dir.Work.c_str()); } // Reconfigure when .qrc file changes makefile->AddCMakeDependFile(qrc.QrcFile); ----------------------------------------------------------------------- Summary of changes: Source/cmAddCustomCommandCommand.cxx | 47 +++------- Source/cmCustomCommand.cxx | 7 +- Source/cmCustomCommand.h | 17 ++-- Source/cmCustomCommandGenerator.cxx | 1 + Source/cmGlobalVisualStudio8Generator.cxx | 9 +- Source/cmInstallExportAndroidMKGenerator.cxx | 134 --------------------------- Source/cmInstallExportAndroidMKGenerator.h | 37 -------- Source/cmMakefile.cxx | 33 +++++-- Source/cmMakefile.h | 6 ++ Source/cmQtAutoGenInitializer.cxx | 10 +- Tests/GeneratorExpression/CMakeLists.txt | 28 +++++- Tests/GeneratorExpression/check-part5.cmake | 1 + 12 files changed, 94 insertions(+), 236 deletions(-) delete mode 100644 Source/cmInstallExportAndroidMKGenerator.cxx delete mode 100644 Source/cmInstallExportAndroidMKGenerator.h create mode 100644 Tests/GeneratorExpression/check-part5.cmake hooks/post-receive -- CMake From kwrobot at kitware.com Mon Sep 16 10:30:16 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 16 Sep 2019 10:30:16 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1055-g1ac4e0e Message-ID: <20190916143016.E49596EF2D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 1ac4e0ef1b29affc9e4f2cd86c4fc8c2252f2ab2 (commit) via f30523d090b343c7eff3083b8f12e3dcd4755cba (commit) from 7c47894b459c0f71ebe32b64a619f290df6bcf44 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1ac4e0ef1b29affc9e4f2cd86c4fc8c2252f2ab2 commit 1ac4e0ef1b29affc9e4f2cd86c4fc8c2252f2ab2 Merge: 7c47894 f30523d Author: Brad King AuthorDate: Mon Sep 16 14:25:33 2019 +0000 Commit: Kitware Robot CommitDate: Mon Sep 16 10:25:53 2019 -0400 Merge topic 'tidy-deprecated-headers' f30523d090 clang-tidy: modernize-deprecated-headers Acked-by: Kitware Robot Merge-request: !3792 diff --cc Source/cmFLTKWrapUICommand.cxx index 5094c3c,afeaf37..654714e --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@@ -2,10 -2,9 +2,10 @@@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmFLTKWrapUICommand.h" - #include + #include #include "cmCustomCommandLines.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmRange.h" #include "cmSourceFile.h" https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f30523d090b343c7eff3083b8f12e3dcd4755cba commit f30523d090b343c7eff3083b8f12e3dcd4755cba Author: Regina Pfeifer AuthorDate: Fri Sep 6 22:58:06 2019 +0200 Commit: Brad King CommitDate: Mon Sep 16 10:11:13 2019 -0400 clang-tidy: modernize-deprecated-headers diff --git a/.clang-tidy b/.clang-tidy index a240e9c..a520679 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -11,7 +11,6 @@ misc-*,\ -misc-static-assert,\ modernize-*,\ -modernize-avoid-c-arrays,\ --modernize-deprecated-headers,\ -modernize-use-nodiscard,\ -modernize-use-noexcept,\ -modernize-use-transparent-functors,\ diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx index b4bfea7..2393279 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx +++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx @@ -13,8 +13,8 @@ #include "cmXMLParser.h" #include "cmXMLWriter.h" +#include #include -#include #include cmCPackIFWInstaller::cmCPackIFWInstaller() = default; diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx index 5fa8cce..9f2a443 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.cxx +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -13,9 +13,9 @@ #include "cmTimestamp.h" #include "cmXMLWriter.h" +#include #include #include -#include #include //---------------------------------------------------------- CompareStruct --- diff --git a/Source/CPack/IFW/cmCPackIFWRepository.cxx b/Source/CPack/IFW/cmCPackIFWRepository.cxx index 8042167..82ddbdb 100644 --- a/Source/CPack/IFW/cmCPackIFWRepository.cxx +++ b/Source/CPack/IFW/cmCPackIFWRepository.cxx @@ -8,7 +8,7 @@ #include "cmXMLParser.h" #include "cmXMLWriter.h" -#include +#include cmCPackIFWRepository::cmCPackIFWRepository() : Update(cmCPackIFWRepository::None) diff --git a/Source/CPack/OSXScriptLauncher.cxx b/Source/CPack/OSXScriptLauncher.cxx index 00d272c..b8f12fd 100644 --- a/Source/CPack/OSXScriptLauncher.cxx +++ b/Source/CPack/OSXScriptLauncher.cxx @@ -3,8 +3,9 @@ #include "cmsys/FStream.hxx" #include "cmsys/Process.h" #include "cmsys/SystemTools.hxx" + +#include #include -#include #include #include diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index cefbc90..0e64b5a 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -13,10 +13,10 @@ #include "cm_sys_stat.h" #include "cmsys/Glob.hxx" +#include #include #include #include -#include #include namespace { diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index ca06b81..bedbfa8 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -12,9 +12,9 @@ #include "cmsys/FStream.hxx" #include "cmsys/RegularExpression.hxx" #include +#include #include #include -#include #include diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 8098edf..3f53186 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -14,10 +14,10 @@ #include "cmsys/Directory.hxx" #include "cmsys/RegularExpression.hxx" #include +#include +#include #include #include -#include -#include #include /* NSIS uses different command line syntax on Windows and others */ diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index 5dc36ab..7be6a7d 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -4,11 +4,11 @@ #include "cmsys/FStream.hxx" #include "cmsys/RegularExpression.hxx" -#include +#include +#include +#include #include #include -#include -#include #include #include "cmCPackComponentGroup.h" diff --git a/Source/CPack/cmCPackProductBuildGenerator.cxx b/Source/CPack/cmCPackProductBuildGenerator.cxx index 800af28..dae268c 100644 --- a/Source/CPack/cmCPackProductBuildGenerator.cxx +++ b/Source/CPack/cmCPackProductBuildGenerator.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackProductBuildGenerator.h" +#include #include #include -#include #include "cmCPackComponentGroup.h" #include "cmCPackLog.h" diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index e8728a3..0c1cecf 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -3,7 +3,7 @@ #include "cmCPackRPMGenerator.h" #include -#include +#include #include #include #include diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index 3092508..eb48c37 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -3,8 +3,8 @@ #include "cmCPackSTGZGenerator.h" #include "cmsys/FStream.hxx" +#include #include -#include #include #include diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 08681ec..ab44a42 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -22,10 +22,10 @@ # include "cmsys/ConsoleBuf.hxx" #endif +#include #include #include #include -#include #include #include #include diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx index 52dc0ac..4ea0c88 100644 --- a/Source/CTest/cmCTestBZR.cxx +++ b/Source/CTest/cmCTestBZR.cxx @@ -11,10 +11,10 @@ #include "cm_expat.h" #include "cmsys/RegularExpression.hxx" +#include #include #include #include -#include #include extern "C" int cmBZRXMLParserUnknownEncodingHandler(void* /*unused*/, diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index e7fb4c7..0f79670 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -14,9 +14,9 @@ #include "cmsys/Process.h" #include +#include #include #include -#include cmCTestBuildAndTestHandler::cmCTestBuildAndTestHandler() { diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index cb22fa6..02b00e3 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -11,8 +11,8 @@ #include "cmSystemTools.h" #include "cmake.h" +#include #include -#include class cmExecutionStatus; diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index e07d7aa..86abb12 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -17,9 +17,9 @@ #include "cmsys/Directory.hxx" #include "cmsys/FStream.hxx" #include "cmsys/Process.h" +#include +#include #include -#include -#include #include static const char* cmCTestErrorMatches[] = { diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index 320c184..8a56f3d 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -10,8 +10,8 @@ #include "cmSystemTools.h" #include "cmake.h" +#include #include -#include #include cmCTestConfigureCommand::cmCTestConfigureCommand() diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index d9dd931..4d76387 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -24,12 +24,12 @@ #include "cmsys/RegularExpression.hxx" #include #include +#include +#include #include #include #include #include -#include -#include #include class cmMakefile; diff --git a/Source/CTest/cmCTestCurl.cxx b/Source/CTest/cmCTestCurl.cxx index 40f5918..8793260 100644 --- a/Source/CTest/cmCTestCurl.cxx +++ b/Source/CTest/cmCTestCurl.cxx @@ -8,8 +8,8 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" +#include #include -#include cmCTestCurl::cmCTestCurl(cmCTest* ctest) { diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 3ae464d..9fd3a62 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -4,10 +4,10 @@ #include "cmsys/FStream.hxx" #include "cmsys/Process.h" -#include -#include -#include -#include +#include +#include +#include +#include #include #include "cmCTest.h" diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx index 6add717..9c5425d 100644 --- a/Source/CTest/cmCTestHandlerCommand.cxx +++ b/Source/CTest/cmCTestHandlerCommand.cxx @@ -10,9 +10,9 @@ #include "cmSystemTools.h" #include "cmWorkingDirectory.h" +#include #include #include -#include cmCTestHandlerCommand::cmCTestHandlerCommand() { diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index ac52581..ba49c29 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -5,9 +5,9 @@ #include "cmsys/FStream.hxx" #include "cmsys/Process.h" #include "cmsys/RegularExpression.hxx" +#include +#include #include -#include -#include #include "cmCryptoHash.h" #include "cmGeneratedFileStream.h" diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 259240f..ba196f0 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -12,9 +12,9 @@ #include "cmsys/Glob.hxx" #include "cmsys/RegularExpression.hxx" #include +#include #include #include -#include #include struct CatToErrorType diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index af1980a..f79ba2e 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -25,15 +25,15 @@ #include #include +#include +#include #include #include #include #include -#include #include #include #include -#include #include #include #include diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index 08c850d..a6aea85 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -12,8 +12,8 @@ #include "cmsys/RegularExpression.hxx" #include +#include #include -#include #include cmCTestP4::cmCTestP4(cmCTest* ct, std::ostream& log) diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index c5bb826..3629a50 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -13,11 +13,11 @@ #include "cmsys/RegularExpression.hxx" #include #include +#include #include #include #include #include -#include #include #include "cm_memory.hxx" diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index a945111..6e5b5e7 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -12,10 +12,10 @@ #include "cmXMLWriter.h" #include "cmsys/RegularExpression.hxx" +#include +#include #include #include -#include -#include struct cmCTestSVN::Revision : public cmCTestVC::Revision { diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 81966dd..354e3c4 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -34,13 +34,13 @@ #include "cmSystemTools.h" #include "cmake.h" +#include +#include +#include #include #include #include #include -#include -#include -#include #include #ifdef _WIN32 diff --git a/Source/CTest/cmCTestSleepCommand.cxx b/Source/CTest/cmCTestSleepCommand.cxx index 2752cd3..bc4470c 100644 --- a/Source/CTest/cmCTestSleepCommand.cxx +++ b/Source/CTest/cmCTestSleepCommand.cxx @@ -4,7 +4,7 @@ #include "cmCTestScriptHandler.h" -#include +#include class cmExecutionStatus; diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx index e4a1844..844f2ca 100644 --- a/Source/CTest/cmCTestStartCommand.cxx +++ b/Source/CTest/cmCTestStartCommand.cxx @@ -8,8 +8,8 @@ #include "cmMakefile.h" #include "cmSystemTools.h" +#include #include -#include class cmExecutionStatus; diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index f215911..ca7fd2c 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -6,9 +6,9 @@ #include "cm_jsoncpp_reader.h" #include "cm_jsoncpp_value.h" #include +#include +#include #include -#include -#include #include "cmAlgorithms.h" #include "cmCTest.h" diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx index 24de5b4..3a29ad3 100644 --- a/Source/CTest/cmCTestTestCommand.cxx +++ b/Source/CTest/cmCTestTestCommand.cxx @@ -10,8 +10,8 @@ #include "cmStringAlgorithms.h" #include +#include #include -#include #include cmCTestTestCommand::cmCTestTestCommand() diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index f0c5939..10f9f9b 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -29,15 +29,15 @@ #include #include #include +#include +#include #include +#include #include #include #include #include #include -#include -#include -#include #include namespace { diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx index 773886d..00919e5 100644 --- a/Source/CTest/cmCTestVC.cxx +++ b/Source/CTest/cmCTestVC.cxx @@ -8,9 +8,9 @@ #include "cmXMLWriter.h" #include "cmsys/Process.h" +#include +#include #include -#include -#include #include cmCTestVC::cmCTestVC(cmCTest* ct, std::ostream& log) diff --git a/Source/CTest/cmParseBlanketJSCoverage.cxx b/Source/CTest/cmParseBlanketJSCoverage.cxx index 191100c..8c87700 100644 --- a/Source/CTest/cmParseBlanketJSCoverage.cxx +++ b/Source/CTest/cmParseBlanketJSCoverage.cxx @@ -7,8 +7,8 @@ #include "cmSystemTools.h" #include "cmsys/FStream.hxx" -#include -#include +#include +#include class cmParseBlanketJSCoverage::JSONParser { diff --git a/Source/CTest/cmParseCacheCoverage.cxx b/Source/CTest/cmParseCacheCoverage.cxx index b3ef7d3..da48610 100644 --- a/Source/CTest/cmParseCacheCoverage.cxx +++ b/Source/CTest/cmParseCacheCoverage.cxx @@ -7,9 +7,9 @@ #include "cmsys/Directory.hxx" #include "cmsys/FStream.hxx" +#include +#include #include -#include -#include #include cmParseCacheCoverage::cmParseCacheCoverage( diff --git a/Source/CTest/cmParseCoberturaCoverage.cxx b/Source/CTest/cmParseCoberturaCoverage.cxx index e4f353b..7c00d00 100644 --- a/Source/CTest/cmParseCoberturaCoverage.cxx +++ b/Source/CTest/cmParseCoberturaCoverage.cxx @@ -7,8 +7,8 @@ #include "cmXMLParser.h" #include "cmsys/FStream.hxx" -#include -#include +#include +#include class cmParseCoberturaCoverage::XMLParser : public cmXMLParser { diff --git a/Source/CTest/cmParseDelphiCoverage.cxx b/Source/CTest/cmParseDelphiCoverage.cxx index e8a184a..22c756c 100644 --- a/Source/CTest/cmParseDelphiCoverage.cxx +++ b/Source/CTest/cmParseDelphiCoverage.cxx @@ -6,8 +6,8 @@ #include "cmsys/FStream.hxx" #include "cmsys/Glob.hxx" -#include -#include +#include +#include class cmParseDelphiCoverage::HTMLParser { diff --git a/Source/CTest/cmParseGTMCoverage.cxx b/Source/CTest/cmParseGTMCoverage.cxx index 621ca79..1f2181b 100644 --- a/Source/CTest/cmParseGTMCoverage.cxx +++ b/Source/CTest/cmParseGTMCoverage.cxx @@ -7,9 +7,9 @@ #include "cmsys/Directory.hxx" #include "cmsys/FStream.hxx" +#include +#include #include -#include -#include #include cmParseGTMCoverage::cmParseGTMCoverage(cmCTestCoverageHandlerContainer& cont, diff --git a/Source/CTest/cmParseJacocoCoverage.cxx b/Source/CTest/cmParseJacocoCoverage.cxx index 6a2d0cc..be6348a 100644 --- a/Source/CTest/cmParseJacocoCoverage.cxx +++ b/Source/CTest/cmParseJacocoCoverage.cxx @@ -9,8 +9,8 @@ #include "cmsys/Directory.hxx" #include "cmsys/FStream.hxx" #include "cmsys/Glob.hxx" -#include -#include +#include +#include class cmParseJacocoCoverage::XMLParser : public cmXMLParser { diff --git a/Source/CTest/cmParsePHPCoverage.cxx b/Source/CTest/cmParsePHPCoverage.cxx index 870e222..8f0404d 100644 --- a/Source/CTest/cmParsePHPCoverage.cxx +++ b/Source/CTest/cmParsePHPCoverage.cxx @@ -7,8 +7,8 @@ #include "cmsys/Directory.hxx" #include "cmsys/FStream.hxx" -#include -#include +#include +#include /* To setup coverage for php. diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx index 61d2ed3..9c63a59 100644 --- a/Source/CTest/cmProcess.cxx +++ b/Source/CTest/cmProcess.cxx @@ -10,8 +10,8 @@ #include "cmStringAlgorithms.h" #include "cmsys/Process.h" +#include #include -#include #include #if defined(_WIN32) # include "cm_kwiml.h" diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index ce32898..567b4f4 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -11,9 +11,9 @@ #include "cmake.h" #include "cmsys/Encoding.hxx" +#include +#include #include -#include -#include #include #include diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx index f450a1c..47fe84c 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx @@ -15,7 +15,7 @@ #include "cmSystemTools.h" #include "cmake.h" -#include +#include #include cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx index 95026d5..028cc26 100644 --- a/Source/CursesDialog/cmCursesLongMessageForm.cxx +++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx @@ -7,8 +7,8 @@ #include "cmCursesStandardIncludes.h" #include "cmVersion.h" -#include -#include +#include +#include inline int ctrl(int z) { diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 1b25716..5f8a19e 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -19,8 +19,8 @@ #include "cmake.h" #include -#include -#include +#include +#include #include inline int ctrl(int z) diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h index d379975..f3194ab 100644 --- a/Source/CursesDialog/cmCursesMainForm.h +++ b/Source/CursesDialog/cmCursesMainForm.h @@ -9,7 +9,7 @@ #include "cmCursesStandardIncludes.h" #include "cmStateTypes.h" -#include +#include #include #include diff --git a/Source/CursesDialog/cmCursesStringWidget.cxx b/Source/CursesDialog/cmCursesStringWidget.cxx index 26724e7..3fc1858 100644 --- a/Source/CursesDialog/cmCursesStringWidget.cxx +++ b/Source/CursesDialog/cmCursesStringWidget.cxx @@ -8,8 +8,8 @@ #include "cmCursesWidget.h" #include "cmStateTypes.h" -#include -#include +#include +#include inline int ctrl(int z) { diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index 287a482..ad18cfe 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -229,8 +229,8 @@ int main(int argc, char** argv) #if defined(Q_OS_MAC) # include "cm_sys_stat.h" -# include -# include +# include +# include # include static bool cmOSXInstall(std::string const& dir, std::string const& tool) { diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx index 17bdc4a..c0be308 100644 --- a/Source/cmAddSubDirectoryCommand.cxx +++ b/Source/cmAddSubDirectoryCommand.cxx @@ -2,8 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmAddSubDirectoryCommand.h" +#include #include -#include #include "cmExecutionStatus.h" #include "cmMakefile.h" diff --git a/Source/cmAffinity.cxx b/Source/cmAffinity.cxx index a6d89aa..33768a9 100644 --- a/Source/cmAffinity.cxx +++ b/Source/cmAffinity.cxx @@ -13,7 +13,7 @@ # include # include // On some platforms CPU_ZERO needs memset but sched.h forgets string.h -# include // IWYU pragma: keep +# include // IWYU pragma: keep # if defined(__FreeBSD__) # include # include diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index a6c25e1..c45edaf 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -11,10 +11,10 @@ #include "cmsys/Encoding.hxx" #include "cmsys/FStream.hxx" +#include +#include #include #include -#include -#include #ifndef __LA_SSIZE_T # define __LA_SSIZE_T la_ssize_t diff --git a/Source/cmArchiveWrite.h b/Source/cmArchiveWrite.h index e90a603..e791761 100644 --- a/Source/cmArchiveWrite.h +++ b/Source/cmArchiveWrite.h @@ -5,8 +5,8 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include #include -#include #include #if defined(CMAKE_BOOTSTRAP) diff --git a/Source/cmAuxSourceDirectoryCommand.cxx b/Source/cmAuxSourceDirectoryCommand.cxx index 7bf19d0..111bc41 100644 --- a/Source/cmAuxSourceDirectoryCommand.cxx +++ b/Source/cmAuxSourceDirectoryCommand.cxx @@ -4,7 +4,7 @@ #include "cmsys/Directory.hxx" #include -#include +#include #include #include "cmExecutionStatus.h" diff --git a/Source/cmBase32.h b/Source/cmBase32.h index c6758d4..d85198d 100644 --- a/Source/cmBase32.h +++ b/Source/cmBase32.h @@ -5,7 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include +#include #include /** \class cmBase32Encoder diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx index 974b984..c3f6f40 100644 --- a/Source/cmCMakeHostSystemInformationCommand.cxx +++ b/Source/cmCMakeHostSystemInformationCommand.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCMakeHostSystemInformationCommand.h" -#include +#include #include "cmExecutionStatus.h" #include "cmMakefile.h" diff --git a/Source/cmCMakeMinimumRequired.cxx b/Source/cmCMakeMinimumRequired.cxx index f93c266..1b03873 100644 --- a/Source/cmCMakeMinimumRequired.cxx +++ b/Source/cmCMakeMinimumRequired.cxx @@ -2,8 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCMakeMinimumRequired.h" +#include #include -#include #include "cmExecutionStatus.h" #include "cmMakefile.h" diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index f19d99b..9c7beca 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -14,7 +14,7 @@ #include "cmState.h" #include "cmVersion.h" -#include +#include #ifdef __QNX__ # include /* for malloc/free on QNX */ diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index cd54770..5e17ce8 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -11,16 +11,16 @@ #include "cmsys/Process.h" #include "cmsys/SystemInformation.hxx" #include +#include #include -#include +#include +#include +#include +#include #include #include #include -#include -#include -#include #include -#include #include #include #if defined(_WIN32) diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 41dac85..9b11653 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -9,11 +9,11 @@ #include "cmProcessOutput.h" #include +#include #include #include #include #include -#include #include class cmCTestBuildHandler; diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index e28107f..0888a5e 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -5,9 +5,9 @@ #include "cmsys/FStream.hxx" #include "cmsys/Glob.hxx" #include +#include +#include #include -#include -#include #include #include "cmGeneratedFileStream.h" diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index b368b3a..e35fba5 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -8,9 +8,9 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" +#include #include #include -#include int cmCommandArgument_yyparse(yyscan_t yyscanner); // diff --git a/Source/cmComputeComponentGraph.cxx b/Source/cmComputeComponentGraph.cxx index 113463f..655e4ac 100644 --- a/Source/cmComputeComponentGraph.cxx +++ b/Source/cmComputeComponentGraph.cxx @@ -4,7 +4,7 @@ #include -#include +#include cmComputeComponentGraph::cmComputeComponentGraph(Graph const& input) : InputGraph(input) diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 15b0087..2ee4ca2 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -16,11 +16,11 @@ #include "cmake.h" #include -#include +#include +#include +#include #include #include -#include -#include #include #include "cm_memory.hxx" diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index ade0f87..09dbbb1 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -20,9 +20,9 @@ #include "cmake.h" #include -#include +#include +#include #include -#include #include //#define CM_COMPUTE_LINK_INFO_DEBUG diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index de82782..239fcdf 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -20,9 +20,9 @@ #include "cmTargetDepend.h" #include "cmake.h" -#include +#include +#include #include -#include #include /* diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 97469be..3ddd8ca 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -3,11 +3,11 @@ #include "cmConditionEvaluator.h" #include "cmsys/RegularExpression.hxx" +#include +#include +#include #include #include -#include -#include -#include #include #include "cmAlgorithms.h" diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 3687056..12050b3 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -3,10 +3,10 @@ #include "cmCoreTryCompile.h" #include "cmsys/Directory.hxx" +#include +#include #include #include -#include -#include #include #include "cmExportTryCompileFileGenerator.h" diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h index 681f5cc..145ff91 100644 --- a/Source/cmCryptoHash.h +++ b/Source/cmCryptoHash.h @@ -7,8 +7,8 @@ #include "cm_string_view.hxx" +#include #include -#include #include #include diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 82cc037..ca2f210 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -13,8 +13,8 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" +#include #include -#include #include cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index e688890..2a117c1 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -4,7 +4,7 @@ #include "cm_string_view.hxx" -#include +#include #include #include #include diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index b657ff7..de919f1 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -3,10 +3,10 @@ #include "cmDependsFortran.h" #include "cmsys/FStream.hxx" -#include +#include +#include #include #include -#include #include #include "cmFortranParser.h" /* Interface to parser object. */ diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx index 12d875d..63a96d0 100644 --- a/Source/cmDependsJavaParserHelper.cxx +++ b/Source/cmDependsJavaParserHelper.cxx @@ -7,10 +7,10 @@ #include "cm_string_view.hxx" #include "cmsys/FStream.hxx" +#include +#include +#include #include -#include -#include -#include #include int cmDependsJava_yyparse(yyscan_t yyscanner); diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index d4628fa..d1f3a83 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -11,8 +11,8 @@ #include "cmsys/FStream.hxx" #include "cmsys/Glob.hxx" #include -#include -#include +#include +#include #include static const char* cmDocumentationStandardOptions[][2] = { diff --git a/Source/cmDocumentationFormatter.cxx b/Source/cmDocumentationFormatter.cxx index 3e7f989..be6756a 100644 --- a/Source/cmDocumentationFormatter.cxx +++ b/Source/cmDocumentationFormatter.cxx @@ -5,9 +5,9 @@ #include "cmDocumentationEntry.h" #include "cmDocumentationSection.h" +#include #include #include -#include #include #include diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index 90250b6..12f996d 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -6,10 +6,10 @@ #include "cm_kwiml.h" #include "cm_memory.hxx" #include "cmsys/FStream.hxx" +#include #include #include #include -#include #include #include diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx index 74e9c55..207b6fd 100644 --- a/Source/cmExecProgramCommand.cxx +++ b/Source/cmExecProgramCommand.cxx @@ -3,7 +3,7 @@ #include "cmExecProgramCommand.h" #include "cmsys/Process.h" -#include +#include #include "cmExecutionStatus.h" #include "cmMakefile.h" diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx index acf2a83..12364c8 100644 --- a/Source/cmExecuteProcessCommand.cxx +++ b/Source/cmExecuteProcessCommand.cxx @@ -6,10 +6,10 @@ #include "cmsys/Process.h" #include -#include /* isspace */ +#include /* isspace */ +#include #include #include -#include #include #include "cmAlgorithms.h" diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 9545814..e588f7b 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -19,9 +19,9 @@ #include "cmTargetExport.h" #include "cmsys/FStream.hxx" -#include +#include +#include #include -#include #include #include "cm_memory.hxx" diff --git a/Source/cmExportInstallAndroidMKGenerator.cxx b/Source/cmExportInstallAndroidMKGenerator.cxx index 1b536c9..207ea41 100644 --- a/Source/cmExportInstallAndroidMKGenerator.cxx +++ b/Source/cmExportInstallAndroidMKGenerator.cxx @@ -2,8 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmExportInstallAndroidMKGenerator.h" +#include #include -#include #include "cmExportBuildAndroidMKGenerator.h" #include "cmExportSet.h" diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index 5a01eb2..e74ad0c 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -15,10 +15,10 @@ #include "cmake.h" #include "cmsys/SystemInformation.hxx" +#include #include #include #include -#include #include cmExtraCodeLiteGenerator::cmExtraCodeLiteGenerator() diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index d398018..ca612b5 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -4,10 +4,10 @@ #include "cmsys/RegularExpression.hxx" #include -#include +#include +#include #include #include -#include #include #include "cmGeneratedFileStream.h" diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index 7ac73cf..b3d869e 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -12,9 +12,9 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" +#include #include #include -#include #include cmExtraKateGenerator::cmExtraKateGenerator() = default; diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 6ad8609..f041821 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -3,9 +3,9 @@ #include "cmExtraSublimeTextGenerator.h" #include "cmsys/RegularExpression.hxx" +#include #include #include -#include #include #include "cmGeneratedFileStream.h" diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index ea9e672..afeaf37 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmFLTKWrapUICommand.h" -#include +#include #include "cmCustomCommandLines.h" #include "cmMakefile.h" diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index e8a7810..33acd05 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -9,14 +9,14 @@ #include "cmsys/RegularExpression.hxx" #include -#include +#include +#include #include -#include +#include +#include #include #include #include -#include -#include #include #include diff --git a/Source/cmFileCopier.cxx b/Source/cmFileCopier.cxx index e00e726..5b9c85a 100644 --- a/Source/cmFileCopier.cxx +++ b/Source/cmFileCopier.cxx @@ -16,8 +16,8 @@ # include "cmsys/FStream.hxx" #endif +#include #include -#include using namespace cmFSPermissions; diff --git a/Source/cmFileLock.cxx b/Source/cmFileLock.cxx index 1e472da..d380798 100644 --- a/Source/cmFileLock.cxx +++ b/Source/cmFileLock.cxx @@ -3,7 +3,7 @@ #include "cmFileLock.h" #include "cmFileLockResult.h" -#include +#include // Common implementation diff --git a/Source/cmFileLockPool.cxx b/Source/cmFileLockPool.cxx index d700a79..8db2db2 100644 --- a/Source/cmFileLockPool.cxx +++ b/Source/cmFileLockPool.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmFileLockPool.h" -#include +#include #include "cmAlgorithms.h" #include "cmFileLock.h" diff --git a/Source/cmFileLockResult.cxx b/Source/cmFileLockResult.cxx index c4779f0..9d5a6c6 100644 --- a/Source/cmFileLockResult.cxx +++ b/Source/cmFileLockResult.cxx @@ -2,8 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmFileLockResult.h" -#include -#include +#include +#include #define WINMSG_BUF_LEN (1024) cmFileLockResult cmFileLockResult::MakeOk() diff --git a/Source/cmFileLockUnix.cxx b/Source/cmFileLockUnix.cxx index 1bf5013..7393823 100644 --- a/Source/cmFileLockUnix.cxx +++ b/Source/cmFileLockUnix.cxx @@ -3,9 +3,9 @@ #include "cmFileLock.h" #include "cmSystemTools.h" -#include // errno +#include // errno +#include // SEEK_SET #include -#include // SEEK_SET #include cmFileLock::cmFileLock() = default; diff --git a/Source/cmFileMonitor.cxx b/Source/cmFileMonitor.cxx index 56ee739..7fcced2 100644 --- a/Source/cmFileMonitor.cxx +++ b/Source/cmFileMonitor.cxx @@ -6,7 +6,7 @@ #include "cmsys/SystemTools.hxx" #include -#include +#include #include #include diff --git a/Source/cmFilePathChecksum.h b/Source/cmFilePathChecksum.h index 30881ce..b7d5cd2 100644 --- a/Source/cmFilePathChecksum.h +++ b/Source/cmFilePathChecksum.h @@ -6,7 +6,7 @@ #include "cmConfigure.h" // IWYU pragma: keep #include -#include +#include #include #include diff --git a/Source/cmFileTime.cxx b/Source/cmFileTime.cxx index 253457f..f92c0ff 100644 --- a/Source/cmFileTime.cxx +++ b/Source/cmFileTime.cxx @@ -2,8 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmFileTime.h" +#include #include -#include // Use a platform-specific API to get file times efficiently. #if !defined(_WIN32) || defined(__CYGWIN__) diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index e0daa4f..7d74118 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -2,10 +2,10 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmFindBase.h" +#include #include #include #include -#include #include "cmAlgorithms.h" #include "cmMakefile.h" diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index 5606838..badec55 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include "cmAlgorithms.h" diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index 529e5c8..011e8aa 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -4,9 +4,9 @@ #include "cmsys/RegularExpression.hxx" #include +#include +#include #include -#include -#include #include #include "cmGlobalGenerator.h" diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 8f76030..8c8cf13 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -9,13 +9,13 @@ #include "cmsys/RegularExpression.hxx" #include "cmsys/String.h" #include -#include +#include +#include +#include #include #include #include #include -#include -#include #include #include "cm_memory.hxx" diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index f0633aa..3c39c46 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmForEachCommand.h" +#include +#include #include -#include -#include #include #include "cm_memory.hxx" diff --git a/Source/cmFortranParser.h b/Source/cmFortranParser.h index 825876c..6f97b42 100644 --- a/Source/cmFortranParser.h +++ b/Source/cmFortranParser.h @@ -12,7 +12,7 @@ # include #endif -#include /* size_t */ +#include /* size_t */ /* Forward declare parser object type. */ using cmFortranParser = struct cmFortranParser_s; diff --git a/Source/cmFortranParserImpl.cxx b/Source/cmFortranParserImpl.cxx index ad377de..b983b4d 100644 --- a/Source/cmFortranParserImpl.cxx +++ b/Source/cmFortranParserImpl.cxx @@ -5,10 +5,10 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include +#include +#include #include #include -#include #include #include #include diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index 491d96f..2af04b6 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGeneratedFileStream.h" -#include +#include #include "cmStringAlgorithms.h" #include "cmSystemTools.h" diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 7bb6a63..f49ed2c 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -6,7 +6,6 @@ #include #include -#include "assert.h" #include "cmAlgorithms.h" #include "cmGeneratorExpressionContext.h" #include "cmGeneratorExpressionDAGChecker.h" @@ -15,6 +14,7 @@ #include "cmGeneratorExpressionParser.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" +#include cmGeneratorExpression::cmGeneratorExpression(cmListFileBacktrace backtrace) : Backtrace(std::move(backtrace)) diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index dda0abc..76f2905 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -10,8 +10,8 @@ #include "cmStringAlgorithms.h" #include "cmake.h" +#include #include -#include #include cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker( diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h index 4530152..b10bb5b 100644 --- a/Source/cmGeneratorExpressionEvaluator.h +++ b/Source/cmGeneratorExpressionEvaluator.h @@ -5,7 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include +#include #include #include #include diff --git a/Source/cmGeneratorExpressionLexer.h b/Source/cmGeneratorExpressionLexer.h index bf24308..9e01948 100644 --- a/Source/cmGeneratorExpressionLexer.h +++ b/Source/cmGeneratorExpressionLexer.h @@ -5,7 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include +#include #include #include diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 89b6c1c..6cb7a96 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -30,15 +30,15 @@ #include "cmsys/String.h" #include -#include -#include +#include +#include +#include +#include #include #include #include #include #include -#include -#include #include std::string cmGeneratorExpressionNode::EvaluateDependentExpression( diff --git a/Source/cmGeneratorExpressionParser.cxx b/Source/cmGeneratorExpressionParser.cxx index ba00b94..a0b685e 100644 --- a/Source/cmGeneratorExpressionParser.cxx +++ b/Source/cmGeneratorExpressionParser.cxx @@ -5,8 +5,8 @@ #include "cmAlgorithms.h" #include "cmGeneratorExpressionEvaluator.h" -#include -#include +#include +#include #include cmGeneratorExpressionParser::cmGeneratorExpressionParser( diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index fa04fbb..bc344ab 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4,16 +4,16 @@ #include "cmsys/RegularExpression.hxx" #include -#include +#include +#include #include -#include +#include +#include +#include #include #include #include #include -#include -#include -#include #include #include diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9eb2ecf..4207d65 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -10,9 +10,9 @@ #include "cmPolicies.h" #include "cmStateTypes.h" +#include #include #include -#include #include #include #include diff --git a/Source/cmGetPipes.cxx b/Source/cmGetPipes.cxx index ad323f7..79f90fd 100644 --- a/Source/cmGetPipes.cxx +++ b/Source/cmGetPipes.cxx @@ -28,7 +28,7 @@ int cmGetPipes(int* fds) return 0; } #else -# include +# include # include int cmGetPipes(int* fds) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 9479424..2273c50 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -5,13 +5,13 @@ #include "cmsys/Directory.hxx" #include "cmsys/FStream.hxx" #include -#include +#include +#include +#include #include #include #include #include -#include -#include #if defined(_WIN32) && !defined(__CYGWIN__) # include diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 0b45f4b..236554f 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -18,9 +18,9 @@ #include "cmake.h" #include +#include #include #include -#include #include const char* cmGlobalGhsMultiGenerator::FILE_EXTENSION = ".gpj"; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 062eccb..9ce6324 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -7,10 +7,10 @@ #include "cm_jsoncpp_writer.h" #include "cmsys/FStream.hxx" #include -#include +#include +#include #include #include -#include #include "cm_memory.hxx" diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 264de54..6a39509 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -5,10 +5,10 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include #include #include #include -#include #include #include diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index af5d279..de04e84 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3,11 +3,11 @@ #include "cmGlobalXCodeGenerator.h" #include "cmsys/RegularExpression.hxx" -#include +#include +#include +#include #include #include -#include -#include #include "cm_memory.hxx" diff --git a/Source/cmHexFileConverter.cxx b/Source/cmHexFileConverter.cxx index 190f2e3..2fa4b55 100644 --- a/Source/cmHexFileConverter.cxx +++ b/Source/cmHexFileConverter.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmHexFileConverter.h" -#include -#include -#include +#include +#include +#include #include "cmSystemTools.h" diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 9a78c49..9b931f7 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -4,9 +4,9 @@ #include "cm_static_string_view.hxx" #include "cmsys/Glob.hxx" +#include #include #include -#include #include #include "cmArgumentParser.h" diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h index e680066..3b9268a 100644 --- a/Source/cmInstallExportGenerator.h +++ b/Source/cmInstallExportGenerator.h @@ -8,8 +8,8 @@ #include "cmInstallGenerator.h" #include "cmScriptGenerator.h" +#include #include -#include #include #include diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 7bbef35..90b0e1d 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmInstallTargetGenerator.h" -#include +#include #include #include #include diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h index 8b91162..c7453ea 100644 --- a/Source/cmLinkedTree.h +++ b/Source/cmLinkedTree.h @@ -5,7 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include +#include #include /** diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index b35dc6f..9487e3b 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -4,15 +4,15 @@ #include "cmsys/RegularExpression.hxx" #include -#include +#include #include +#include +#include // required for atoi #include #include #include #include #include -#include -#include // required for atoi #include #include diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 349d5e9..ab53df6 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -10,7 +10,7 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include +#include #include #include #include diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h index 5de1a74..9cae827 100644 --- a/Source/cmListFileCache.h +++ b/Source/cmListFileCache.h @@ -5,9 +5,9 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include #include #include -#include #include #include #include diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx index f650eb1..66fdada 100644 --- a/Source/cmLoadCommandCommand.cxx +++ b/Source/cmLoadCommandCommand.cxx @@ -2,12 +2,12 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmLoadCommandCommand.h" -#include +#include +#include +#include +#include #include -#include -#include -#include #include #include "cm_memory.hxx" diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 51eb78c..5bbb83c 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -38,15 +38,15 @@ #endif #include -#include +#include +#include #include +#include #include #include #include #include #include -#include -#include #include #include #include diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 1284d4d..0fe385f 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -3,11 +3,11 @@ #include "cmLocalNinjaGenerator.h" #include -#include +#include +#include #include #include #include -#include #include #include "cmCryptoHash.h" diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 8248608..f80695d 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -5,8 +5,8 @@ #include "cmsys/FStream.hxx" #include "cmsys/Terminal.h" #include +#include #include -#include #include #include "cm_memory.hxx" diff --git a/Source/cmLocale.h b/Source/cmLocale.h index 3580ec8..c44a42d 100644 --- a/Source/cmLocale.h +++ b/Source/cmLocale.h @@ -5,7 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include +#include #include class cmLocaleRAII diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index ef6a705..af97761 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmMacroCommand.h" -#include +#include #include #include "cm_memory.hxx" diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 16cc453..d73a285 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -5,14 +5,14 @@ #include "cmsys/FStream.hxx" #include "cmsys/RegularExpression.hxx" #include -#include +#include +#include +#include +#include #include -#include #include #include #include -#include -#include #include #include "cmAlgorithms.h" diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 52464d6..252b855 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -6,13 +6,13 @@ #include "cmConfigure.h" // IWYU pragma: keep #include "cmsys/RegularExpression.hxx" +#include #include #include #include #include #include #include -#include #include #include #include diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 6d71a6d..b37a933 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmMakefileLibraryTargetGenerator.h" +#include #include #include -#include #include #include diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 1f6986b..477badd 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmMakefileTargetGenerator.h" +#include #include #include -#include #include #include "cmAlgorithms.h" diff --git a/Source/cmMathCommand.cxx b/Source/cmMathCommand.cxx index 83c22aa..4ea3638 100644 --- a/Source/cmMathCommand.cxx +++ b/Source/cmMathCommand.cxx @@ -8,7 +8,7 @@ #include "cmMessageType.h" #include "cm_kwiml.h" -#include +#include namespace { bool HandleExprCommand(std::vector const& args, diff --git a/Source/cmNewLineStyle.cxx b/Source/cmNewLineStyle.cxx index 1ff741e..a121332 100644 --- a/Source/cmNewLineStyle.cxx +++ b/Source/cmNewLineStyle.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmNewLineStyle.h" -#include +#include cmNewLineStyle::cmNewLineStyle() = default; diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index bc2506e..97742c1 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -3,7 +3,7 @@ #include "cmNinjaNormalTargetGenerator.h" #include -#include +#include #include #include #include diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 90b59e7..37e9e0e 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -5,7 +5,7 @@ #include "cm_jsoncpp_value.h" #include "cm_jsoncpp_writer.h" #include -#include +#include #include #include #include diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index c8cac3b..e1267ec 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -11,7 +11,7 @@ #include "cmake.h" #include -#include +#include #include #include #include diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx index bf516e3..e602a6d 100644 --- a/Source/cmOutputConverter.cxx +++ b/Source/cmOutputConverter.cxx @@ -3,8 +3,8 @@ #include "cmOutputConverter.h" #include -#include -#include +#include +#include #include #include diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index 2f4e003..d9a433d 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -4,9 +4,9 @@ #include "cmsys/FStream.hxx" #include "cmsys/RegularExpression.hxx" +#include #include #include -#include #include #include "cmAlgorithms.h" diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index d33cd32..c8bc56d 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -8,11 +8,11 @@ #include "cmSystemTools.h" #include "cmVersion.h" -#include -#include +#include +#include +#include +#include #include -#include -#include #include static bool stringToId(const char* input, cmPolicies::PolicyID& pid) diff --git a/Source/cmProcessOutput.h b/Source/cmProcessOutput.h index 400354c..3db47a4 100644 --- a/Source/cmProcessOutput.h +++ b/Source/cmProcessOutput.h @@ -5,7 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include +#include #include #include diff --git a/Source/cmProcessTools.h b/Source/cmProcessTools.h index c205a8f..7d97e36 100644 --- a/Source/cmProcessTools.h +++ b/Source/cmProcessTools.h @@ -6,8 +6,8 @@ #include "cmConfigure.h" // IWYU pragma: keep #include "cmProcessOutput.h" +#include #include -#include #include /** \class cmProcessTools diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx index aa394e5..edbb3de 100644 --- a/Source/cmRST.cxx +++ b/Source/cmRST.cxx @@ -10,9 +10,9 @@ #include "cmsys/FStream.hxx" #include -#include +#include +#include #include -#include #include cmRST::cmRST(std::ostream& os, std::string docroot) diff --git a/Source/cmRulePlaceholderExpander.cxx b/Source/cmRulePlaceholderExpander.cxx index 6c954a6..0a1d109 100644 --- a/Source/cmRulePlaceholderExpander.cxx +++ b/Source/cmRulePlaceholderExpander.cxx @@ -2,8 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmRulePlaceholderExpander.h" -#include -#include +#include +#include #include #include "cmOutputConverter.h" diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx index 0e8d09d..bd75c14 100644 --- a/Source/cmSourceFileLocation.cxx +++ b/Source/cmSourceFileLocation.cxx @@ -9,7 +9,7 @@ #include "cmSystemTools.h" #include "cmake.h" -#include +#include cmSourceFileLocation::cmSourceFileLocation() = default; diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx index c239a1f..3be7fec 100644 --- a/Source/cmSourceGroupCommand.cxx +++ b/Source/cmSourceGroupCommand.cxx @@ -2,8 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmSourceGroupCommand.h" +#include #include -#include #include #include "cmAlgorithms.h" diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 751eb77..7463bf8 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -4,9 +4,9 @@ #include "cmsys/RegularExpression.hxx" #include -#include -#include -#include +#include +#include +#include #include #include "cm_memory.hxx" diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx index c14bf4a..ede00a0 100644 --- a/Source/cmStateDirectory.cxx +++ b/Source/cmStateDirectory.cxx @@ -4,7 +4,7 @@ #include "cmStateDirectory.h" #include -#include +#include #include #include diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx index b3e33ea..28d5170 100644 --- a/Source/cmStateSnapshot.cxx +++ b/Source/cmStateSnapshot.cxx @@ -4,7 +4,7 @@ #include "cmStateSnapshot.h" #include -#include +#include #include #include diff --git a/Source/cmStringAlgorithms.cxx b/Source/cmStringAlgorithms.cxx index 131a01e..bb6dcd7 100644 --- a/Source/cmStringAlgorithms.cxx +++ b/Source/cmStringAlgorithms.cxx @@ -3,10 +3,10 @@ #include "cmStringAlgorithms.h" #include +#include #include #include -#include -#include +#include std::string cmTrimWhitespace(cm::string_view str) { diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h index 7f442d8..cb6b8ba 100644 --- a/Source/cmStringAlgorithms.h +++ b/Source/cmStringAlgorithms.h @@ -8,9 +8,9 @@ #include "cmRange.h" #include "cm_string_view.hxx" #include +#include #include #include -#include #include #include #include diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 9a2de9d..ab670ca 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -6,12 +6,12 @@ #include "cmsys/RegularExpression.hxx" #include -#include +#include +#include +#include #include #include #include -#include -#include #include "cm_static_string_view.hxx" diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 86af683..62a8d8f 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -40,16 +40,16 @@ #include "cmsys/System.h" #include "cmsys/Terminal.h" #include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include #include #include diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 8ca4939..e7eef33 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -11,8 +11,8 @@ #include "cm_string_view.hxx" #include "cmsys/Process.h" #include "cmsys/SystemTools.hxx" // IWYU pragma: export +#include #include -#include #include #include diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 2420810..6637e32 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4,12 +4,12 @@ #include "cmsys/RegularExpression.hxx" #include -#include +#include +#include #include #include #include #include -#include #include #include "cm_memory.hxx" diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 4fbec90..237d90c 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -2,8 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmTargetLinkLibrariesCommand.h" +#include #include -#include #include "cmGeneratorExpression.h" #include "cmGlobalGenerator.h" diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx index a9be729..390fd16 100644 --- a/Source/cmTimestamp.cxx +++ b/Source/cmTimestamp.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmTimestamp.h" +#include #include #include -#include #include "cmStringAlgorithms.h" #include "cmSystemTools.h" diff --git a/Source/cmTimestamp.h b/Source/cmTimestamp.h index d5fbdfd..40338f8 100644 --- a/Source/cmTimestamp.h +++ b/Source/cmTimestamp.h @@ -5,8 +5,8 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include #include -#include /** \class cmTimestamp * \brief Utility class to generate string representation of a timestamp diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index 24d0f0f..73354ec 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -3,7 +3,7 @@ #include "cmTryRunCommand.h" #include "cmsys/FStream.hxx" -#include +#include #include "cmDuration.h" #include "cmMakefile.h" diff --git a/Source/cmUVHandlePtr.cxx b/Source/cmUVHandlePtr.cxx index 97c27cb..23dabb7 100644 --- a/Source/cmUVHandlePtr.cxx +++ b/Source/cmUVHandlePtr.cxx @@ -3,9 +3,9 @@ #define cmUVHandlePtr_cxx #include "cmUVHandlePtr.h" -#include +#include +#include #include -#include #include "cm_uv.h" diff --git a/Source/cmUVProcessChain.cxx b/Source/cmUVProcessChain.cxx index 56d6c09..2c37a64 100644 --- a/Source/cmUVProcessChain.cxx +++ b/Source/cmUVProcessChain.cxx @@ -7,7 +7,7 @@ #include "cmUVStreambuf.h" #include "cm_uv.h" -#include +#include #include // IWYU pragma: keep #include diff --git a/Source/cmUVProcessChain.h b/Source/cmUVProcessChain.h index 76a9c40..8a19bc3 100644 --- a/Source/cmUVProcessChain.h +++ b/Source/cmUVProcessChain.h @@ -7,13 +7,12 @@ #include #include +#include #include #include #include #include -#include - class cmUVProcessChain; class cmUVProcessChainBuilder diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx index 6b3590f..a43165c 100644 --- a/Source/cmUtilitySourceCommand.cxx +++ b/Source/cmUtilitySourceCommand.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmUtilitySourceCommand.h" -#include +#include #include "cmExecutionStatus.h" #include "cmMakefile.h" diff --git a/Source/cmUuid.cxx b/Source/cmUuid.cxx index 91c8af3..f0f2c51 100644 --- a/Source/cmUuid.cxx +++ b/Source/cmUuid.cxx @@ -5,7 +5,7 @@ #include "cmCryptoHash.h" #include -#include +#include static const std::array kUuidGroups = { { 4, 2, 2, 2, 6 } }; diff --git a/Source/cmWorkerPool.cxx b/Source/cmWorkerPool.cxx index 2e4d00b..5ac81df 100644 --- a/Source/cmWorkerPool.cxx +++ b/Source/cmWorkerPool.cxx @@ -11,10 +11,10 @@ #include #include #include +#include #include #include #include -#include #include #include "cm_memory.hxx" diff --git a/Source/cmWorkerPool.h b/Source/cmWorkerPool.h index b541ce3..bf07299 100644 --- a/Source/cmWorkerPool.h +++ b/Source/cmWorkerPool.h @@ -5,7 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include +#include #include #include #include diff --git a/Source/cmXMLParser.cxx b/Source/cmXMLParser.cxx index 4c6c35a..1f69032 100644 --- a/Source/cmXMLParser.cxx +++ b/Source/cmXMLParser.cxx @@ -4,10 +4,10 @@ #include "cm_expat.h" #include "cmsys/FStream.hxx" -#include +#include +#include #include #include -#include cmXMLParser::cmXMLParser() { diff --git a/Source/cmXMLSafe.cxx b/Source/cmXMLSafe.cxx index d9bdc02..7c3b306 100644 --- a/Source/cmXMLSafe.cxx +++ b/Source/cmXMLSafe.cxx @@ -4,9 +4,9 @@ #include "cm_utf8.h" +#include +#include #include -#include -#include cmXMLSafe::cmXMLSafe(const char* s) : Data(s) diff --git a/Source/cm_codecvt.hxx b/Source/cm_codecvt.hxx index 2060584..b2cb9e6 100644 --- a/Source/cm_codecvt.hxx +++ b/Source/cm_codecvt.hxx @@ -5,8 +5,8 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include #include -#include class codecvt : public std::codecvt { diff --git a/Source/cm_get_date.h b/Source/cm_get_date.h index 6acf8de..38a690e 100644 --- a/Source/cm_get_date.h +++ b/Source/cm_get_date.h @@ -3,7 +3,7 @@ #ifndef cm_get_date_h #define cm_get_date_h -#include +#include /* NOLINT(modernize-deprecated-headers) */ #ifdef __cplusplus extern "C" { diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 170e09b..9a66805 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -105,12 +105,12 @@ #include "cmsys/Glob.hxx" #include "cmsys/RegularExpression.hxx" #include +#include +#include #include #include #include #include -#include -#include #include namespace { diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 2b51a2a..252c6d6 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -25,10 +25,10 @@ #endif #include +#include #include -#include +#include #include -#include #include #include diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index ba2ba33..211fd4c 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -39,13 +39,13 @@ #include "cmsys/Process.h" #include "cmsys/Terminal.h" #include +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include #include class cmConnection; diff --git a/Source/ctest.cxx b/Source/ctest.cxx index a69ba15..7be6746 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -11,8 +11,8 @@ #if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP) # include "cmsys/ConsoleBuf.hxx" #endif +#include #include -#include #include #include diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx index 010e17a..4a79c80 100644 --- a/Tests/CMakeLib/run_compile_commands.cxx +++ b/Tests/CMakeLib/run_compile_commands.cxx @@ -1,9 +1,9 @@ #include "cmConfigure.h" // IWYU pragma: keep #include "cmsys/FStream.hxx" +#include #include #include -#include #include #include #include ----------------------------------------------------------------------- Summary of changes: .clang-tidy | 1 - Source/CPack/IFW/cmCPackIFWInstaller.cxx | 2 +- Source/CPack/IFW/cmCPackIFWPackage.cxx | 2 +- Source/CPack/IFW/cmCPackIFWRepository.cxx | 2 +- Source/CPack/OSXScriptLauncher.cxx | 3 ++- Source/CPack/cmCPackDebGenerator.cxx | 2 +- Source/CPack/cmCPackDragNDropGenerator.cxx | 2 +- Source/CPack/cmCPackNSISGenerator.cxx | 4 ++-- Source/CPack/cmCPackPackageMakerGenerator.cxx | 6 +++--- Source/CPack/cmCPackProductBuildGenerator.cxx | 2 +- Source/CPack/cmCPackRPMGenerator.cxx | 2 +- Source/CPack/cmCPackSTGZGenerator.cxx | 2 +- Source/CPack/cpack.cxx | 2 +- Source/CTest/cmCTestBZR.cxx | 2 +- Source/CTest/cmCTestBuildAndTestHandler.cxx | 2 +- Source/CTest/cmCTestBuildCommand.cxx | 2 +- Source/CTest/cmCTestBuildHandler.cxx | 4 ++-- Source/CTest/cmCTestConfigureCommand.cxx | 2 +- Source/CTest/cmCTestCoverageHandler.cxx | 4 ++-- Source/CTest/cmCTestCurl.cxx | 2 +- Source/CTest/cmCTestGIT.cxx | 8 ++++---- Source/CTest/cmCTestHandlerCommand.cxx | 2 +- Source/CTest/cmCTestLaunch.cxx | 4 ++-- Source/CTest/cmCTestMemCheckHandler.cxx | 2 +- Source/CTest/cmCTestMultiProcessHandler.cxx | 4 ++-- Source/CTest/cmCTestP4.cxx | 2 +- Source/CTest/cmCTestRunTest.cxx | 2 +- Source/CTest/cmCTestSVN.cxx | 4 ++-- Source/CTest/cmCTestScriptHandler.cxx | 6 +++--- Source/CTest/cmCTestSleepCommand.cxx | 2 +- Source/CTest/cmCTestStartCommand.cxx | 2 +- Source/CTest/cmCTestSubmitHandler.cxx | 4 ++-- Source/CTest/cmCTestTestCommand.cxx | 2 +- Source/CTest/cmCTestTestHandler.cxx | 6 +++--- Source/CTest/cmCTestVC.cxx | 4 ++-- Source/CTest/cmParseBlanketJSCoverage.cxx | 4 ++-- Source/CTest/cmParseCacheCoverage.cxx | 4 ++-- Source/CTest/cmParseCoberturaCoverage.cxx | 4 ++-- Source/CTest/cmParseDelphiCoverage.cxx | 4 ++-- Source/CTest/cmParseGTMCoverage.cxx | 4 ++-- Source/CTest/cmParseJacocoCoverage.cxx | 4 ++-- Source/CTest/cmParsePHPCoverage.cxx | 4 ++-- Source/CTest/cmProcess.cxx | 2 +- Source/CursesDialog/ccmake.cxx | 4 ++-- Source/CursesDialog/cmCursesCacheEntryComposite.cxx | 2 +- Source/CursesDialog/cmCursesLongMessageForm.cxx | 4 ++-- Source/CursesDialog/cmCursesMainForm.cxx | 4 ++-- Source/CursesDialog/cmCursesMainForm.h | 2 +- Source/CursesDialog/cmCursesStringWidget.cxx | 4 ++-- Source/QtDialog/CMakeSetup.cxx | 4 ++-- Source/cmAddSubDirectoryCommand.cxx | 2 +- Source/cmAffinity.cxx | 2 +- Source/cmArchiveWrite.cxx | 4 ++-- Source/cmArchiveWrite.h | 2 +- Source/cmAuxSourceDirectoryCommand.cxx | 2 +- Source/cmBase32.h | 2 +- Source/cmCMakeHostSystemInformationCommand.cxx | 2 +- Source/cmCMakeMinimumRequired.cxx | 2 +- Source/cmCPluginAPI.cxx | 2 +- Source/cmCTest.cxx | 10 +++++----- Source/cmCTest.h | 2 +- Source/cmCacheManager.cxx | 4 ++-- Source/cmCommandArgumentParserHelper.cxx | 2 +- Source/cmComputeComponentGraph.cxx | 2 +- Source/cmComputeLinkDepends.cxx | 6 +++--- Source/cmComputeLinkInformation.cxx | 4 ++-- Source/cmComputeTargetDepends.cxx | 4 ++-- Source/cmConditionEvaluator.cxx | 6 +++--- Source/cmCoreTryCompile.cxx | 4 ++-- Source/cmCryptoHash.h | 2 +- Source/cmCustomCommandGenerator.cxx | 2 +- Source/cmDefinitions.cxx | 2 +- Source/cmDependsFortran.cxx | 4 ++-- Source/cmDependsJavaParserHelper.cxx | 6 +++--- Source/cmDocumentation.cxx | 4 ++-- Source/cmDocumentationFormatter.cxx | 2 +- Source/cmELF.cxx | 2 +- Source/cmExecProgramCommand.cxx | 2 +- Source/cmExecuteProcessCommand.cxx | 4 ++-- Source/cmExportFileGenerator.cxx | 4 ++-- Source/cmExportInstallAndroidMKGenerator.cxx | 2 +- Source/cmExtraCodeLiteGenerator.cxx | 2 +- Source/cmExtraEclipseCDT4Generator.cxx | 4 ++-- Source/cmExtraKateGenerator.cxx | 2 +- Source/cmExtraSublimeTextGenerator.cxx | 2 +- Source/cmFLTKWrapUICommand.cxx | 2 +- Source/cmFileCommand.cxx | 8 ++++---- Source/cmFileCopier.cxx | 2 +- Source/cmFileLock.cxx | 2 +- Source/cmFileLockPool.cxx | 2 +- Source/cmFileLockResult.cxx | 4 ++-- Source/cmFileLockUnix.cxx | 4 ++-- Source/cmFileMonitor.cxx | 2 +- Source/cmFilePathChecksum.h | 2 +- Source/cmFileTime.cxx | 2 +- Source/cmFindBase.cxx | 2 +- Source/cmFindCommon.cxx | 2 +- Source/cmFindLibraryCommand.cxx | 4 ++-- Source/cmFindPackageCommand.cxx | 6 +++--- Source/cmForEachCommand.cxx | 4 ++-- Source/cmFortranParser.h | 2 +- Source/cmFortranParserImpl.cxx | 4 ++-- Source/cmGeneratedFileStream.cxx | 2 +- Source/cmGeneratorExpression.cxx | 2 +- Source/cmGeneratorExpressionDAGChecker.cxx | 2 +- Source/cmGeneratorExpressionEvaluator.h | 2 +- Source/cmGeneratorExpressionLexer.h | 2 +- Source/cmGeneratorExpressionNode.cxx | 8 ++++---- Source/cmGeneratorExpressionParser.cxx | 4 ++-- Source/cmGeneratorTarget.cxx | 10 +++++----- Source/cmGeneratorTarget.h | 2 +- Source/cmGetPipes.cxx | 2 +- Source/cmGlobalGenerator.cxx | 6 +++--- Source/cmGlobalGhsMultiGenerator.cxx | 2 +- Source/cmGlobalNinjaGenerator.cxx | 4 ++-- Source/cmGlobalUnixMakefileGenerator3.h | 2 +- Source/cmGlobalXCodeGenerator.cxx | 6 +++--- Source/cmHexFileConverter.cxx | 6 +++--- Source/cmInstallCommand.cxx | 2 +- Source/cmInstallExportGenerator.h | 2 +- Source/cmInstallTargetGenerator.cxx | 2 +- Source/cmLinkedTree.h | 2 +- Source/cmListCommand.cxx | 6 +++--- Source/cmListFileCache.cxx | 2 +- Source/cmListFileCache.h | 2 +- Source/cmLoadCommandCommand.cxx | 8 ++++---- Source/cmLocalGenerator.cxx | 6 +++--- Source/cmLocalNinjaGenerator.cxx | 4 ++-- Source/cmLocalUnixMakefileGenerator3.cxx | 2 +- Source/cmLocale.h | 2 +- Source/cmMacroCommand.cxx | 2 +- Source/cmMakefile.cxx | 8 ++++---- Source/cmMakefile.h | 2 +- Source/cmMakefileLibraryTargetGenerator.cxx | 2 +- Source/cmMakefileTargetGenerator.cxx | 2 +- Source/cmMathCommand.cxx | 2 +- Source/cmNewLineStyle.cxx | 2 +- Source/cmNinjaNormalTargetGenerator.cxx | 2 +- Source/cmNinjaTargetGenerator.cxx | 2 +- Source/cmOrderDirectories.cxx | 2 +- Source/cmOutputConverter.cxx | 4 ++-- Source/cmOutputRequiredFilesCommand.cxx | 2 +- Source/cmPolicies.cxx | 8 ++++---- Source/cmProcessOutput.h | 2 +- Source/cmProcessTools.h | 2 +- Source/cmRST.cxx | 4 ++-- Source/cmRulePlaceholderExpander.cxx | 4 ++-- Source/cmSourceFileLocation.cxx | 2 +- Source/cmSourceGroupCommand.cxx | 2 +- Source/cmState.cxx | 6 +++--- Source/cmStateDirectory.cxx | 2 +- Source/cmStateSnapshot.cxx | 2 +- Source/cmStringAlgorithms.cxx | 4 ++-- Source/cmStringAlgorithms.h | 2 +- Source/cmStringCommand.cxx | 6 +++--- Source/cmSystemTools.cxx | 14 +++++++------- Source/cmSystemTools.h | 2 +- Source/cmTarget.cxx | 4 ++-- Source/cmTargetLinkLibrariesCommand.cxx | 2 +- Source/cmTimestamp.cxx | 2 +- Source/cmTimestamp.h | 2 +- Source/cmTryRunCommand.cxx | 2 +- Source/cmUVHandlePtr.cxx | 4 ++-- Source/cmUVProcessChain.cxx | 2 +- Source/cmUVProcessChain.h | 3 +-- Source/cmUtilitySourceCommand.cxx | 2 +- Source/cmUuid.cxx | 2 +- Source/cmWorkerPool.cxx | 2 +- Source/cmWorkerPool.h | 2 +- Source/cmXMLParser.cxx | 4 ++-- Source/cmXMLSafe.cxx | 4 ++-- Source/cm_codecvt.hxx | 2 +- Source/cm_get_date.h | 2 +- Source/cmake.cxx | 4 ++-- Source/cmakemain.cxx | 4 ++-- Source/cmcmd.cxx | 8 ++++---- Source/ctest.cxx | 2 +- Tests/CMakeLib/run_compile_commands.cxx | 2 +- 178 files changed, 289 insertions(+), 290 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Sep 16 23:59:56 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 16 Sep 2019 23:59:56 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1056-g3bc1fea Message-ID: <20190917035956.E5E89102D55@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 3bc1feae5fe044d796e4bcd932b7228c40fde230 (commit) from 1ac4e0ef1b29affc9e4f2cd86c4fc8c2252f2ab2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3bc1feae5fe044d796e4bcd932b7228c40fde230 commit 3bc1feae5fe044d796e4bcd932b7228c40fde230 Author: Kitware Robot AuthorDate: Tue Sep 17 00:01:08 2019 -0400 Commit: Kitware Robot CommitDate: Tue Sep 17 00:01:08 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 2aef888..887d970 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 15) -set(CMake_VERSION_PATCH 20190916) +set(CMake_VERSION_PATCH 20190917) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Sep 17 11:09:46 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 17 Sep 2019 11:09:46 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1060-g42a20ef Message-ID: <20190917150946.25C3F1028F8@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 42a20ef79b86090b65de9836158db2a59c837e69 (commit) via 35b580d6033395b491c73005d785aa2c456f734e (commit) via 0301a76bb464fc3231193c4f1c957327e8258d44 (commit) via 28cb86d7962b2a9b8e49dc62bccf6187761524d9 (commit) from 3bc1feae5fe044d796e4bcd932b7228c40fde230 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=42a20ef79b86090b65de9836158db2a59c837e69 commit 42a20ef79b86090b65de9836158db2a59c837e69 Merge: 35b580d 28cb86d Author: Brad King AuthorDate: Tue Sep 17 15:08:27 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 17 11:08:43 2019 -0400 Merge topic 'allow-pkg-config-missing-libraries' 28cb86d796 FindPkgConfig: Allow libraries that can't be found with their full path Acked-by: Kitware Robot Acked-by: Rolf Eike Beer Merge-request: !3781 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=35b580d6033395b491c73005d785aa2c456f734e commit 35b580d6033395b491c73005d785aa2c456f734e Merge: 3bc1fea 0301a76 Author: Brad King AuthorDate: Tue Sep 17 15:06:52 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 17 11:07:08 2019 -0400 Merge topic 'remove-failing-modules-test' 0301a76bb4 FindEnvMod: Remove unreliable test case Acked-by: Kitware Robot Merge-request: !3823 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0301a76bb464fc3231193c4f1c957327e8258d44 commit 0301a76bb464fc3231193c4f1c957327e8258d44 Author: Chuck Atkins AuthorDate: Mon Sep 16 12:46:33 2019 -0400 Commit: Chuck Atkins CommitDate: Mon Sep 16 13:10:40 2019 -0400 FindEnvMod: Remove unreliable test case There's no way to know that loading an arbitrary module doesn't pull in extra dependent modules so the test case asserting that exactly one module was loaded isn't valid. diff --git a/Tests/FindEnvModules/EnvModules.cmake b/Tests/FindEnvModules/EnvModules.cmake index 0c81bf2..21b0042 100644 --- a/Tests/FindEnvModules/EnvModules.cmake +++ b/Tests/FindEnvModules/EnvModules.cmake @@ -18,18 +18,16 @@ if(avail_mods) message("module list") env_module_list(loaded_mods) + set(mod0_found FALSE) foreach(mod IN LISTS loaded_mods) message(" ${mod}") + if(NOT mod0_found AND mod MATCHES "^${mod0}") + set(mod0_found ${mod}) + endif() endforeach() - list(LENGTH loaded_mods num_loaded_mods) - message("Number of modules loaded: ${num_loaded_mods}") - if(NOT num_loaded_mods EQUAL 1) - message(FATAL_ERROR "Exactly 1 module should be loaded. Found ${num_loaded_mods}") - endif() - - list(GET loaded_mods 0 mod0_actual) - if(NOT (mod0_actual MATCHES "^${mod0}")) - message(FATAL_ERROR "Loaded module does not match ${mod0}. Actual: ${mod0_actual}") + if(NOT mod0_found) + message(FATAL_ERROR "Requested module ${mod0} not found in loaded modules") endif() + message("module ${mod0} found loaded as ${mod0_found}") endif() https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=28cb86d7962b2a9b8e49dc62bccf6187761524d9 commit 28cb86d7962b2a9b8e49dc62bccf6187761524d9 Author: Chuck Atkins AuthorDate: Wed Sep 4 12:36:34 2019 -0400 Commit: Chuck Atkins CommitDate: Mon Sep 16 13:02:08 2019 -0400 FindPkgConfig: Allow libraries that can't be found with their full path pkg-config's .pc files can sometimes provide libraries that are visible to the linker but not present in CMake's known search paths. In the case where CMake can find some, but not all of the library dependencies provided in a .pc file, this allows them to be passed through as "-lfoo" when the full path can't be found. This also removes the test failure cases that occured because of this scenario and adjsuts the remaining tests to account for not-found libraries diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 4c9af91..5162a44 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -214,7 +214,11 @@ function(_pkg_find_libs _prefix _no_cmake_path _no_cmake_environment_path) NAMES ${_pkg_search} ${_find_opts}) mark_as_advanced(pkgcfg_lib_${_prefix}_${_pkg_search}) - list(APPEND _libs "${pkgcfg_lib_${_prefix}_${_pkg_search}}") + if(pkgcfg_lib_${_prefix}_${_pkg_search}) + list(APPEND _libs "${pkgcfg_lib_${_prefix}_${_pkg_search}}") + else() + list(APPEND _libs ${_pkg_search}) + endif() endforeach() set(${_prefix}_LINK_LIBRARIES "${_libs}" PARENT_SCOPE) diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake index e82b05f..62bb5de 100644 --- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake @@ -39,7 +39,7 @@ foreach(i 1 2) "Name: CMakeInternalFakePackage${i} Description: Dummy package (${i}) for FindPkgConfig IMPORTED_TARGET test Version: 1.2.3 -Libs: -l${pname} +Libs: -l${pname} -l${pname}-doesnotexist ") endforeach() @@ -47,27 +47,6 @@ endforeach() # the import target find_library() calls handle the NO...PATH options correctly set(ENV{PKG_CONFIG_PATH} ${fakePkgDir}/lib/pkgconfig) -# Confirm correct behavior of NO_CMAKE_PATH, ensuring we only find the library -# for the imported target if we have both set CMAKE_PREFIX_PATH and have not -# given the NO_CMAKE_PATH option -unset(CMAKE_PREFIX_PATH) -unset(ENV{CMAKE_PREFIX_PATH}) -pkg_check_modules(FakePackage1 QUIET IMPORTED_TARGET cmakeinternalfakepackage1) -if (TARGET PkgConfig::FakePackage1) - message(FATAL_ERROR "Have import target for fake package 1 with no path prefix") -endif() - -set(CMAKE_PREFIX_PATH ${fakePkgDir}) -pkg_check_modules(FakePackage1 QUIET IMPORTED_TARGET NO_CMAKE_PATH cmakeinternalfakepackage1) -if (TARGET PkgConfig::FakePackage1) - message(FATAL_ERROR "Have import target for fake package 1 with ignored cmake path") -endif() - -pkg_check_modules(FakePackage1 REQUIRED QUIET IMPORTED_TARGET cmakeinternalfakepackage1) -if (NOT TARGET PkgConfig::FakePackage1) - message(FATAL_ERROR "No import target for fake package 1 with prefix path") -endif() - # find targets in subdir and check their visibility add_subdirectory(target_subdir) if (TARGET PkgConfig::FakePackage1_dir) @@ -82,31 +61,35 @@ endif() # combination unset(CMAKE_PREFIX_PATH) unset(ENV{CMAKE_PREFIX_PATH}) -pkg_check_modules(FakePackage2 QUIET IMPORTED_TARGET cmakeinternalfakepackage2) -if (TARGET PkgConfig::FakePackage2) - message(FATAL_ERROR "Have import target for fake package 2 with no path prefix") -endif() - set(ENV{CMAKE_PREFIX_PATH} ${fakePkgDir}) -pkg_check_modules(FakePackage2 QUIET IMPORTED_TARGET NO_CMAKE_ENVIRONMENT_PATH cmakeinternalfakepackage2) -if (TARGET PkgConfig::FakePackage2) - message(FATAL_ERROR "Have import target for fake package 2 with ignored cmake path") -endif() pkg_check_modules(FakePackage2 REQUIRED QUIET IMPORTED_TARGET cmakeinternalfakepackage2) if (NOT TARGET PkgConfig::FakePackage2) message(FATAL_ERROR "No import target for fake package 2 with prefix path") endif() +# check that 2 library entries exist +list(LENGTH FakePackage2_LINK_LIBRARIES fp2_nlibs) +if (NOT fp2_nlibs EQUAL 2) + message(FATAL_ERROR "FakePackage2_LINK_LIBRARIES has ${fp2_nlibs} entries but should have exactly 2") +endif() + # check that the full library path is also returned -if (NOT FakePackage2_LINK_LIBRARIES STREQUAL "${fakePkgDir}/lib/libcmakeinternalfakepackage2.a") +list(GET FakePackage2_LINK_LIBRARIES 0 fp2_lib0) +if (NOT fp2_lib0 STREQUAL "${fakePkgDir}/lib/libcmakeinternalfakepackage2.a") + message(FATAL_ERROR "FakePackage2_LINK_LIBRARIES has bad content on first run: ${FakePackage2_LINK_LIBRARIES}") +endif() + +# check that the library that couldn't be found still shows up +list(GET FakePackage2_LINK_LIBRARIES 1 fp2_lib1) +if (NOT fp2_lib1 STREQUAL "cmakeinternalfakepackage2-doesnotexist") message(FATAL_ERROR "FakePackage2_LINK_LIBRARIES has bad content on first run: ${FakePackage2_LINK_LIBRARIES}") endif() # the information in *_LINK_LIBRARIES is not cached, so ensure is also is present on second run unset(FakePackage2_LINK_LIBRARIES) pkg_check_modules(FakePackage2 REQUIRED QUIET IMPORTED_TARGET cmakeinternalfakepackage2) -if (NOT FakePackage2_LINK_LIBRARIES STREQUAL "${fakePkgDir}/lib/libcmakeinternalfakepackage2.a") +if (NOT FakePackage2_LINK_LIBRARIES STREQUAL "${fakePkgDir}/lib/libcmakeinternalfakepackage2.a;cmakeinternalfakepackage2-doesnotexist") message(FATAL_ERROR "FakePackage2_LINK_LIBRARIES has bad content on second run: ${FakePackage2_LINK_LIBRARIES}") endif() ----------------------------------------------------------------------- Summary of changes: Modules/FindPkgConfig.cmake | 6 ++- Tests/FindEnvModules/EnvModules.cmake | 16 ++++--- .../FindPkgConfig_IMPORTED_TARGET.cmake | 49 +++++++--------------- 3 files changed, 28 insertions(+), 43 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Sep 17 11:19:39 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 17 Sep 2019 11:19:39 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1067-ge6ddb57 Message-ID: <20190917151939.6683710A9D9@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via e6ddb57479a3620c712719c120a7337a84470d21 (commit) via 14fb0f3967f625264768dc9005e0b3e9191bd6d7 (commit) via e82e4b03418e13c7e9d7062d81ba6510fd66be9b (commit) via bd5006e8134a3ea5d949f9eedf139126af357820 (commit) via 3b409643bd0f69d38d91bba6b64250e48b276398 (commit) via 8c83f39a90b98a65a067813db1841ebcd6e0a400 (commit) via 445ff5ccdf7f888b48d12076fb42ca856482779f (commit) from 42a20ef79b86090b65de9836158db2a59c837e69 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e6ddb57479a3620c712719c120a7337a84470d21 commit e6ddb57479a3620c712719c120a7337a84470d21 Merge: 14fb0f3 3b40964 Author: Brad King AuthorDate: Tue Sep 17 15:11:55 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 17 11:12:08 2019 -0400 Merge topic 'byproduct-collapse-full-path' 3b409643bd Byproducts: Add test for collapsing of full paths in byproducts 445ff5ccdf Byproducts: collapse full paths of custom target byproducts Acked-by: Kitware Robot Merge-request: !3804 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=14fb0f3967f625264768dc9005e0b3e9191bd6d7 commit 14fb0f3967f625264768dc9005e0b3e9191bd6d7 Merge: e82e4b0 8c83f39 Author: Brad King AuthorDate: Tue Sep 17 15:10:08 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 17 11:11:06 2019 -0400 Merge topic 'smart_ptr/cmSourceFile' 8c83f39a90 cmSourceFile: use unique_ptr for CustomCommand Acked-by: Kitware Robot Acked-by: Kyle Edwards Merge-request: !3815 diff --cc Source/cmMakefile.cxx index 88d03f9,6961e8e..f35b999 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@@ -13,8 -10,13 +13,10 @@@ #include #include #include -#include -#include #include + #include "cm_memory.hxx" + #include "cmAlgorithms.h" #include "cmCommandArgumentParserHelper.h" #include "cmCustomCommand.h" https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e82e4b03418e13c7e9d7062d81ba6510fd66be9b commit e82e4b03418e13c7e9d7062d81ba6510fd66be9b Merge: 42a20ef bd5006e Author: Brad King AuthorDate: Tue Sep 17 15:09:35 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 17 11:09:56 2019 -0400 Merge topic 'iar-v850' bd5006e813 IAR: Add v850 support Acked-by: Kitware Robot Merge-request: !3821 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bd5006e8134a3ea5d949f9eedf139126af357820 commit bd5006e8134a3ea5d949f9eedf139126af357820 Author: Nico Mueller AuthorDate: Mon Sep 16 10:45:03 2019 +0200 Commit: Brad King CommitDate: Mon Sep 16 11:07:04 2019 -0400 IAR: Add v850 support Add compiler identification for V850. Issue: #17264 diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in index 542a6fe..95465ce 100644 --- a/Modules/CMakePlatformId.h.in +++ b/Modules/CMakePlatformId.h.in @@ -174,6 +174,9 @@ # elif defined(__ICC430__) # define ARCHITECTURE_ID "MSP430" +# elif defined(__ICCV850__) +# define ARCHITECTURE_ID "V850" + # else /* unknown architecture */ # define ARCHITECTURE_ID "" # endif diff --git a/Modules/Compiler/IAR-C.cmake b/Modules/Compiler/IAR-C.cmake index e03ce3f..9ad1ba0 100644 --- a/Modules/Compiler/IAR-C.cmake +++ b/Modules/Compiler/IAR-C.cmake @@ -60,6 +60,11 @@ elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430") __compiler_check_default_language_standard(C 1.10 90 5.10 99) set(CMAKE_C_OUTPUT_EXTENSION ".r43") +elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "V850") + __compiler_iar_xlink(C) + __compiler_check_default_language_standard(C 1.10 90 4.10 99) + set(CMAKE_C_OUTPUT_EXTENSION ".r85") + else() message(FATAL_ERROR "CMAKE_C_COMPILER_ARCHITECTURE_ID not detected. This should be automatic.") endif() diff --git a/Modules/Compiler/IAR-CXX.cmake b/Modules/Compiler/IAR-CXX.cmake index e8f1142..549d242 100644 --- a/Modules/Compiler/IAR-CXX.cmake +++ b/Modules/Compiler/IAR-CXX.cmake @@ -68,6 +68,10 @@ elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430") __compiler_check_default_language_standard(CXX 5.10 98) set(CMAKE_CXX_OUTPUT_EXTENSION ".r43") +elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "V850") + __compiler_iar_xlink(CXX) + __compiler_check_default_language_standard(CXX 1.10 98) + set(CMAKE_C_OUTPUT_EXTENSION ".r85") else() message(FATAL_ERROR "CMAKE_CXX_COMPILER_ARCHITECTURE_ID not detected. This should be automatic." ) endif() diff --git a/Modules/Compiler/IAR-DetermineCompiler.cmake b/Modules/Compiler/IAR-DetermineCompiler.cmake index 57ca1c9..7e17778 100644 --- a/Modules/Compiler/IAR-DetermineCompiler.cmake +++ b/Modules/Compiler/IAR-DetermineCompiler.cmake @@ -31,7 +31,7 @@ set(_compiler_id_version_compute " # define @PREFIX at COMPILER_VERSION_MINOR @MACRO_DEC@(((__VER__) / 1000) % 1000) # define @PREFIX at COMPILER_VERSION_PATCH @MACRO_DEC@((__VER__) % 1000) # define @PREFIX at COMPILER_VERSION_INTERNAL @MACRO_DEC@(__IAR_SYSTEMS_ICC__) -# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__)) +# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__) || defined(__ICCV850__)) # define @PREFIX at COMPILER_VERSION_MAJOR @MACRO_DEC@((__VER__) / 100) # define @PREFIX at COMPILER_VERSION_MINOR @MACRO_DEC@((__VER__) - (((__VER__) / 100)*100)) # define @PREFIX at COMPILER_VERSION_PATCH @MACRO_DEC@(__SUBVERSION__) diff --git a/Modules/Compiler/IAR-FindBinUtils.cmake b/Modules/Compiler/IAR-FindBinUtils.cmake index b7d4664..6258cf3 100644 --- a/Modules/Compiler/IAR-FindBinUtils.cmake +++ b/Modules/Compiler/IAR-FindBinUtils.cmake @@ -45,7 +45,8 @@ set(CMAKE_IAR_LINKER \"${CMAKE_IAR_LINKER}\") ") elseif("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR" OR - "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430") + "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430" OR + "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "V850") # Find the "xlink" linker and "xar" archiver: find_program(CMAKE_IAR_LINKER xlink HINTS ${__iar_hints} https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3b409643bd0f69d38d91bba6b64250e48b276398 commit 3b409643bd0f69d38d91bba6b64250e48b276398 Author: Daniel Eiband AuthorDate: Mon Sep 16 10:24:24 2019 +0200 Commit: Daniel Eiband CommitDate: Mon Sep 16 10:24:24 2019 +0200 Byproducts: Add test for collapsing of full paths in byproducts Add test for collapsing of full paths in byproducts and additional tests for the GENERATED source file properties set by add_custom_command and add_custom_target with relative paths. diff --git a/Tests/CustomCommandByproducts/CMakeLists.txt b/Tests/CustomCommandByproducts/CMakeLists.txt index bfa69ce..08c897c 100644 --- a/Tests/CustomCommandByproducts/CMakeLists.txt +++ b/Tests/CustomCommandByproducts/CMakeLists.txt @@ -14,20 +14,20 @@ add_custom_command( # Generate a byproduct in a rule that runs in a dependency of the consumer. add_custom_command( - OUTPUT timestamp2.txt + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/../CustomCommandByproducts/timestamp2.txt COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/byproduct2.c.in byproduct2.c - BYPRODUCTS byproduct2.c + BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/../CustomCommandByproducts/byproduct2.c COMMAND ${CMAKE_COMMAND} -E touch timestamp2.txt DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct2.c.in ) -add_custom_target(Producer2 DEPENDS timestamp2.txt) +add_custom_target(Producer2 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/timestamp2.txt) # Generate a byproduct in a custom target. add_custom_target(Producer3_4 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/byproduct3.c.in byproduct3.c - BYPRODUCTS byproduct3.c + BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/../CustomCommandByproducts/byproduct3.c DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct3.c.in ) @@ -36,7 +36,7 @@ add_custom_command( TARGET Producer3_4 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/byproduct4.c.in byproduct4.c - BYPRODUCTS byproduct4.c + BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/../CustomCommandByproducts/byproduct4.c DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct4.c.in ) diff --git a/Tests/RunCMake/add_custom_command/GeneratedProperty.cmake b/Tests/RunCMake/add_custom_command/GeneratedProperty.cmake new file mode 100644 index 0000000..628134b --- /dev/null +++ b/Tests/RunCMake/add_custom_command/GeneratedProperty.cmake @@ -0,0 +1,10 @@ +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/../GeneratedProperty-build/a" + BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/../GeneratedProperty-build/b" + COMMAND c + ) +get_source_file_property(GENERATED_A "${CMAKE_CURRENT_BINARY_DIR}/a" GENERATED) +get_source_file_property(GENERATED_B "${CMAKE_CURRENT_BINARY_DIR}/b" GENERATED) +if(NOT GENERATED_A OR NOT GENERATED_B) + message(FATAL_ERROR "failed") +endif() diff --git a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake index 0387dbb..20097b7 100644 --- a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake @@ -3,6 +3,7 @@ include(RunCMake) run_cmake(AppendNoOutput) run_cmake(AppendNotOutput) run_cmake(BadArgument) +run_cmake(GeneratedProperty) run_cmake(NoArguments) run_cmake(NoOutputOrTarget) run_cmake(OutputAndTarget) diff --git a/Tests/RunCMake/add_custom_target/GeneratedProperty.cmake b/Tests/RunCMake/add_custom_target/GeneratedProperty.cmake new file mode 100644 index 0000000..d034534 --- /dev/null +++ b/Tests/RunCMake/add_custom_target/GeneratedProperty.cmake @@ -0,0 +1,14 @@ +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/../GeneratedProperty-build/a" + COMMAND b + ) +add_custom_target(CollapseFullPath + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/a" + BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/../GeneratedProperty-build/c" + COMMAND d + ) +get_source_file_property(GENERATED_A "${CMAKE_CURRENT_BINARY_DIR}/a" GENERATED) +get_source_file_property(GENERATED_C "${CMAKE_CURRENT_BINARY_DIR}/c" GENERATED) +if(NOT GENERATED_A OR NOT GENERATED_C) + message(FATAL_ERROR "failed") +endif() diff --git a/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake index 2caed03..d80ca19 100644 --- a/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake @@ -1,6 +1,7 @@ include(RunCMake) run_cmake(CommandExpandsEmpty) +run_cmake(GeneratedProperty) run_cmake(NoArguments) run_cmake(BadTargetName) run_cmake(ByproductsNoCommand) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8c83f39a90b98a65a067813db1841ebcd6e0a400 commit 8c83f39a90b98a65a067813db1841ebcd6e0a400 Author: Tushar Maheshwari AuthorDate: Wed Aug 28 21:36:21 2019 +0530 Commit: Tushar Maheshwari CommitDate: Sat Sep 14 00:54:31 2019 +0530 cmSourceFile: use unique_ptr for CustomCommand diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 9e64f97..6961e8e 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -15,6 +15,8 @@ #include #include +#include "cm_memory.hxx" + #include "cmAlgorithms.h" #include "cmCommandArgumentParserHelper.h" #include "cmCustomCommand.h" @@ -1025,7 +1027,7 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput( depends2.push_back(main_dependency); } - cmCustomCommand* cc = new cmCustomCommand( + std::unique_ptr cc = cm::make_unique( this, outputs, byproducts, depends2, commandLines, comment, workingDir); cc->SetEscapeOldStyle(escapeOldStyle); cc->SetEscapeAllowMakeVars(true); @@ -1033,7 +1035,7 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput( cc->SetCommandExpandLists(command_expand_lists); cc->SetDepfile(depfile); cc->SetJobPool(job_pool); - file->SetCustomCommand(cc); + file->SetCustomCommand(std::move(cc)); this->UpdateOutputToSourceMap(outputs, file, false); this->UpdateOutputToSourceMap(byproducts, file, true); } diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 4deb94a..3344217 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -5,7 +5,6 @@ #include #include -#include "cmCustomCommand.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -21,11 +20,6 @@ cmSourceFile::cmSourceFile(cmMakefile* mf, const std::string& name, { } -cmSourceFile::~cmSourceFile() -{ - this->SetCustomCommand(nullptr); -} - std::string const& cmSourceFile::GetExtension() const { return this->Extension; @@ -320,19 +314,12 @@ bool cmSourceFile::GetPropertyAsBool(const std::string& prop) const return cmIsOn(this->GetProperty(prop)); } -cmCustomCommand* cmSourceFile::GetCustomCommand() -{ - return this->CustomCommand; -} - -cmCustomCommand const* cmSourceFile::GetCustomCommand() const +cmCustomCommand* cmSourceFile::GetCustomCommand() const { - return this->CustomCommand; + return this->CustomCommand.get(); } -void cmSourceFile::SetCustomCommand(cmCustomCommand* cc) +void cmSourceFile::SetCustomCommand(std::unique_ptr cc) { - cmCustomCommand* old = this->CustomCommand; - this->CustomCommand = cc; - delete old; + this->CustomCommand = std::move(cc); } diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index 774cb28..dd36d45 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -5,14 +5,15 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include "cmCustomCommand.h" #include "cmPropertyMap.h" #include "cmSourceFileLocation.h" #include "cmSourceFileLocationKind.h" +#include #include #include -class cmCustomCommand; class cmMakefile; /** \class cmSourceFile @@ -32,17 +33,11 @@ public: cmMakefile* mf, const std::string& name, cmSourceFileLocationKind kind = cmSourceFileLocationKind::Ambiguous); - ~cmSourceFile(); - - cmSourceFile(const cmSourceFile&) = delete; - cmSourceFile& operator=(const cmSourceFile&) = delete; - /** - * Get the list of the custom commands for this source file + * Get the custom command for this source file */ - cmCustomCommand* GetCustomCommand(); - cmCustomCommand const* GetCustomCommand() const; - void SetCustomCommand(cmCustomCommand* cc); + cmCustomCommand* GetCustomCommand() const; + void SetCustomCommand(std::unique_ptr cc); //! Set/Get a property of this source file void SetProperty(const std::string& prop, const char* value); @@ -114,7 +109,7 @@ public: private: cmSourceFileLocation Location; cmPropertyMap Properties; - cmCustomCommand* CustomCommand = nullptr; + std::unique_ptr CustomCommand; std::string Extension; std::string Language; std::string FullPath; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=445ff5ccdf7f888b48d12076fb42ca856482779f commit 445ff5ccdf7f888b48d12076fb42ca856482779f Author: Daniel Eiband AuthorDate: Wed Sep 11 11:22:40 2019 +0200 Commit: Daniel Eiband CommitDate: Fri Sep 13 18:09:23 2019 +0200 Byproducts: collapse full paths of custom target byproducts Collapse full paths of add_custom_target command byproducts for symmetry with byproducts passed to the add_custom_command command. diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx index caea510..ec5c1a7 100644 --- a/Source/cmAddCustomTargetCommand.cxx +++ b/Source/cmAddCustomTargetCommand.cxx @@ -127,7 +127,7 @@ bool cmAddCustomTargetCommand(std::vector const& args, } filename += copy; cmSystemTools::ConvertToUnixSlashes(filename); - byproducts.push_back(filename); + byproducts.push_back(cmSystemTools::CollapseFullPath(filename)); } break; case doing_depends: { std::string dep = copy; ----------------------------------------------------------------------- Summary of changes: Modules/CMakePlatformId.h.in | 3 +++ Modules/Compiler/IAR-C.cmake | 5 +++++ Modules/Compiler/IAR-CXX.cmake | 4 ++++ Modules/Compiler/IAR-DetermineCompiler.cmake | 2 +- Modules/Compiler/IAR-FindBinUtils.cmake | 3 ++- Source/cmAddCustomTargetCommand.cxx | 2 +- Source/cmMakefile.cxx | 6 ++++-- Source/cmSourceFile.cxx | 21 ++++----------------- Source/cmSourceFile.h | 17 ++++++----------- Tests/CustomCommandByproducts/CMakeLists.txt | 10 +++++----- .../add_custom_command/GeneratedProperty.cmake | 10 ++++++++++ .../RunCMake/add_custom_command/RunCMakeTest.cmake | 1 + .../add_custom_target/GeneratedProperty.cmake | 14 ++++++++++++++ Tests/RunCMake/add_custom_target/RunCMakeTest.cmake | 1 + 14 files changed, 61 insertions(+), 38 deletions(-) create mode 100644 Tests/RunCMake/add_custom_command/GeneratedProperty.cmake create mode 100644 Tests/RunCMake/add_custom_target/GeneratedProperty.cmake hooks/post-receive -- CMake From kwrobot at kitware.com Tue Sep 17 23:59:25 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 17 Sep 2019 23:59:25 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1068-g45b7d52 Message-ID: <20190918035925.7A440FCF67@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 45b7d5284e11cb34885b756bee8dedeb94fc16cb (commit) from e6ddb57479a3620c712719c120a7337a84470d21 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=45b7d5284e11cb34885b756bee8dedeb94fc16cb commit 45b7d5284e11cb34885b756bee8dedeb94fc16cb Author: Kitware Robot AuthorDate: Wed Sep 18 00:01:07 2019 -0400 Commit: Kitware Robot CommitDate: Wed Sep 18 00:01:07 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 887d970..1e0721f 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 15) -set(CMake_VERSION_PATCH 20190917) +set(CMake_VERSION_PATCH 20190918) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Wed Sep 18 11:39:09 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 18 Sep 2019 11:39:09 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1072-g01cce69 Message-ID: <20190918153909.E2EA41104F8@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 01cce69870ec7efbb8138f5345aa7ffed8b7ac12 (commit) via a981a9a7451bbabdc5048f982dce4b3553fe9711 (commit) via c9c1eb99fe011546b5d9390c7fbbeebfda491c65 (commit) via 729d997f1073c7a177da5b46b073a08b95adfa74 (commit) from 45b7d5284e11cb34885b756bee8dedeb94fc16cb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=01cce69870ec7efbb8138f5345aa7ffed8b7ac12 commit 01cce69870ec7efbb8138f5345aa7ffed8b7ac12 Merge: a981a9a c9c1eb9 Author: Kyle Edwards AuthorDate: Wed Sep 18 15:35:13 2019 +0000 Commit: Kitware Robot CommitDate: Wed Sep 18 11:36:03 2019 -0400 Merge topic 'smart_ptr/cmCPackGeneratorFactory' c9c1eb99fe cmCPackGeneratorFactory: rule of zero Acked-by: Kitware Robot Merge-request: !3826 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a981a9a7451bbabdc5048f982dce4b3553fe9711 commit a981a9a7451bbabdc5048f982dce4b3553fe9711 Merge: 45b7d52 729d997 Author: Brad King AuthorDate: Wed Sep 18 15:33:23 2019 +0000 Commit: Kitware Robot CommitDate: Wed Sep 18 11:34:00 2019 -0400 Merge topic 'shared-pch' 729d997f10 Precompile Headers: Add REUSE_FROM signature Acked-by: Kitware Robot Acked-by: Rickard Englund Acked-by: Viktor Kirilov Merge-request: !3762 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c9c1eb99fe011546b5d9390c7fbbeebfda491c65 commit c9c1eb99fe011546b5d9390c7fbbeebfda491c65 Author: Tushar Maheshwari AuthorDate: Sat Sep 7 14:15:08 2019 +0530 Commit: Kyle Edwards CommitDate: Tue Sep 17 13:05:26 2019 -0400 cmCPackGeneratorFactory: rule of zero diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index a564eb1..79e344b 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -6,7 +6,6 @@ #include #include "IFW/cmCPackIFWGenerator.h" -#include "cmAlgorithms.h" #ifdef HAVE_FREEBSD_PKG # include "cmCPackFreeBSDGenerator.h" #endif @@ -138,33 +137,21 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() #endif } -cmCPackGeneratorFactory::~cmCPackGeneratorFactory() -{ - cmDeleteAll(this->Generators); -} - -cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator( +std::unique_ptr cmCPackGeneratorFactory::NewGenerator( const std::string& name) { - cmCPackGenerator* gen = this->NewGeneratorInternal(name); + auto it = this->GeneratorCreators.find(name); + if (it == this->GeneratorCreators.end()) { + return nullptr; + } + std::unique_ptr gen(it->second()); if (!gen) { return nullptr; } - this->Generators.push_back(gen); gen->SetLogger(this->Logger); return gen; } -cmCPackGenerator* cmCPackGeneratorFactory::NewGeneratorInternal( - const std::string& name) -{ - auto it = this->GeneratorCreators.find(name); - if (it == this->GeneratorCreators.end()) { - return nullptr; - } - return (it->second)(); -} - void cmCPackGeneratorFactory::RegisterGenerator( const std::string& name, const char* generatorDescription, CreateGeneratorCall* createGenerator) diff --git a/Source/CPack/cmCPackGeneratorFactory.h b/Source/CPack/cmCPackGeneratorFactory.h index da2eb8d..62b7484 100644 --- a/Source/CPack/cmCPackGeneratorFactory.h +++ b/Source/CPack/cmCPackGeneratorFactory.h @@ -6,8 +6,8 @@ #include "cmConfigure.h" // IWYU pragma: keep #include +#include #include -#include class cmCPackGenerator; class cmCPackLog; @@ -20,14 +20,9 @@ class cmCPackGeneratorFactory { public: cmCPackGeneratorFactory(); - ~cmCPackGeneratorFactory(); - - cmCPackGeneratorFactory(const cmCPackGeneratorFactory&) = delete; - cmCPackGeneratorFactory& operator=(const cmCPackGeneratorFactory&) = delete; //! Get the generator - cmCPackGenerator* NewGenerator(const std::string& name); - void DeleteGenerator(cmCPackGenerator* gen); + std::unique_ptr NewGenerator(const std::string& name); using CreateGeneratorCall = cmCPackGenerator*(); @@ -44,9 +39,6 @@ public: } private: - cmCPackGenerator* NewGeneratorInternal(const std::string& name); - std::vector Generators; - using t_GeneratorCreatorsMap = std::map; t_GeneratorCreatorsMap GeneratorCreators; DescriptionsMap GeneratorDescriptions; diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index ab44a42..ce41d40 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -237,7 +238,6 @@ int main(int argc, char const* const* argv) cmCPackGeneratorFactory generators; generators.SetLogger(&log); - cmCPackGenerator* cpackGenerator = nullptr; cmDocumentation doc; doc.addCPackStandardDocSections(); @@ -360,7 +360,8 @@ int main(int argc, char const* const* argv) parsed = 0; } if (parsed) { - cpackGenerator = generators.NewGenerator(gen); + std::unique_ptr cpackGenerator = + generators.NewGenerator(gen); if (cpackGenerator) { cpackGenerator->SetTrace(trace); cpackGenerator->SetTraceExpand(traceExpand); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=729d997f1073c7a177da5b46b073a08b95adfa74 commit 729d997f1073c7a177da5b46b073a08b95adfa74 Author: Cristian Adam AuthorDate: Fri Aug 30 16:21:19 2019 +0200 Commit: Cristian Adam CommitDate: Tue Sep 17 11:58:38 2019 +0200 Precompile Headers: Add REUSE_FROM signature Add the ability to share precompiled headers artifacts between targets. Fixes: #19659 diff --git a/Help/command/target_precompile_headers.rst b/Help/command/target_precompile_headers.rst index 3e28265..7d36b11 100644 --- a/Help/command/target_precompile_headers.rst +++ b/Help/command/target_precompile_headers.rst @@ -9,9 +9,23 @@ Add a list of header files to precompile. [header1...] [ [header2...] ...]) + target_precompile_headers( REUSE_FROM ) + Adds header files to :prop_tgt:`PRECOMPILE_HEADERS` or :prop_tgt:`INTERFACE_PRECOMPILE_HEADERS` target properties. +The second signature will reuse an already precompiled header file artefact +from another target. This is done by setting the +:prop_tgt:`PRECOMPILE_HEADERS_REUSE_FROM` to ```` value. +The ```` will become a dependency of ````. + +.. note:: + + The second signature will require the same set of compiler options, + compiler flags, compiler definitions for both ````, and + ````. Compilers (e.g. GCC) will issue a warning if the + precompiled header file cannot be used (``-Winvalid-pch``). + Precompiling header files can speed up compilation by creating a partially processed version of some header files, and then using that version during compilations rather than repeatedly parsing the original headers. diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 19afb7d..0928abe 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -298,6 +298,7 @@ Properties on Targets /prop_tgt/PDB_OUTPUT_DIRECTORY /prop_tgt/POSITION_INDEPENDENT_CODE /prop_tgt/PRECOMPILE_HEADERS + /prop_tgt/PRECOMPILE_HEADERS_REUSE_FROM /prop_tgt/PREFIX /prop_tgt/PRIVATE_HEADER /prop_tgt/PROJECT_LABEL diff --git a/Help/prop_tgt/PRECOMPILE_HEADERS_REUSE_FROM.rst b/Help/prop_tgt/PRECOMPILE_HEADERS_REUSE_FROM.rst new file mode 100644 index 0000000..d740303 --- /dev/null +++ b/Help/prop_tgt/PRECOMPILE_HEADERS_REUSE_FROM.rst @@ -0,0 +1,7 @@ +PRECOMPILE_HEADERS_REUSE_FROM +----------------------------- + +Target from which to reuse the precomipled headers build artifact. + +See the second signature of :command:`target_precompile_headers` command +for more detailed information. diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index 6ddcaa3..34f5d03 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -333,10 +333,17 @@ macro(__windows_compiler_msvc lang) set(CMAKE_LINK_PCH ON) if(MSVC_VERSION GREATER_EQUAL 1910) # VS 2017 or greater - set(CMAKE_PCH_PROLOGUE "#pragma system_header") + if (NOT ${CMAKE_${lang}_COMPILER_ID} STREQUAL "Clang") + set(CMAKE_PCH_PROLOGUE "#pragma system_header") + else() + set(CMAKE_PCH_PROLOGUE "#pragma clang system_header") + endif() + endif() + if (NOT ${CMAKE_${lang}_COMPILER_ID} STREQUAL "Clang") + set(CMAKE_PCH_COPY_COMPILE_PDB ON) endif() - set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH /Yu /FI) - set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH /Yc /FI) + set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH /Yu /Fp /FI) + set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH /Yc /Fp /FI) if("x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xMSVC") set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 33286ad..19a096b 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -171,6 +171,7 @@ std::string cmCommonTargetGenerator::ComputeTargetCompilePDB() const if (this->GeneratorTarget->GetType() > cmStateEnums::OBJECT_LIBRARY) { return compilePdbPath; } + compilePdbPath = this->GeneratorTarget->GetCompilePDBPath(this->GetConfigName()); if (compilePdbPath.empty()) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2ca5706..3a321c5 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -35,6 +35,7 @@ #include "cmRange.h" #include "cmSourceFile.h" #include "cmSourceFileLocation.h" +#include "cmSourceFileLocationKind.h" #include "cmState.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -3371,57 +3372,67 @@ std::string cmGeneratorTarget::GetPchHeader(const std::string& config, } std::string& filename = inserted.first->second; + const cmGeneratorTarget* generatorTarget = this; + const char* pchReuseFrom = + generatorTarget->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM"); + if (pchReuseFrom) { + generatorTarget = + this->GetGlobalGenerator()->FindGeneratorTarget(pchReuseFrom); + } + if (this->GetGlobalGenerator()->IsMultiConfig()) { - filename = - cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), "/"); + filename = cmStrCat( + generatorTarget->LocalGenerator->GetCurrentBinaryDirectory(), "/"); } else { // For GCC we need to have the header file .h[xx] // next to the .h[xx].gch file - filename = this->ObjectDirectory; + filename = generatorTarget->ObjectDirectory; } - filename = cmStrCat(filename, "CMakeFiles/", this->GetName(), + filename = cmStrCat(filename, "CMakeFiles/", generatorTarget->GetName(), ".dir/cmake_pch", ((language == "C") ? ".h" : ".hxx")); const std::string filename_tmp = cmStrCat(filename, ".tmp"); - { + if (!pchReuseFrom) { auto pchPrologue = this->Makefile->GetDefinition("CMAKE_PCH_PROLOGUE"); auto pchEpilogue = this->Makefile->GetDefinition("CMAKE_PCH_EPILOGUE"); - cmGeneratedFileStream file( - filename_tmp, false, - this->GetGlobalGenerator()->GetMakefileEncoding()); - file << "/* generated by CMake */\n\n"; - if (pchPrologue) { - file << pchPrologue << "\n"; - } - if (this->GetGlobalGenerator()->IsXcode()) { - file << "#ifndef CMAKE_SKIP_PRECOMPILE_HEADERS\n"; - } - if (language == "CXX") { - file << "#ifdef __cplusplus\n"; - } - for (auto const& header_bt : headers) { - if (header_bt.Value.empty()) { - continue; + { + cmGeneratedFileStream file( + filename_tmp, false, + this->GetGlobalGenerator()->GetMakefileEncoding()); + file << "/* generated by CMake */\n\n"; + if (pchPrologue) { + file << pchPrologue << "\n"; } - if (header_bt.Value[0] == '<' || header_bt.Value[0] == '"') { - file << "#include " << header_bt.Value << "\n"; - } else { - file << "#include \"" << header_bt.Value << "\"\n"; + if (this->GetGlobalGenerator()->IsXcode()) { + file << "#ifndef CMAKE_SKIP_PRECOMPILE_HEADERS\n"; + } + if (language == "CXX") { + file << "#ifdef __cplusplus\n"; + } + for (auto const& header_bt : headers) { + if (header_bt.Value.empty()) { + continue; + } + if (header_bt.Value[0] == '<' || header_bt.Value[0] == '\"') { + file << "#include " << header_bt.Value << "\n"; + } else { + file << "#include \"" << header_bt.Value << "\"\n"; + } + } + if (language == "CXX") { + file << "#endif // __cplusplus\n"; + } + if (this->GetGlobalGenerator()->IsXcode()) { + file << "#endif // CMAKE_SKIP_PRECOMPILE_HEADERS\n"; + } + if (pchEpilogue) { + file << pchEpilogue << "\n"; } } - if (language == "CXX") { - file << "#endif // __cplusplus\n"; - } - if (this->GetGlobalGenerator()->IsXcode()) { - file << "#endif // CMAKE_SKIP_PRECOMPILE_HEADERS\n"; - } - if (pchEpilogue) { - file << pchEpilogue << "\n"; - } + cmSystemTools::MoveFileIfDifferent(filename_tmp, filename); } - cmSystemTools::MoveFileIfDifferent(filename_tmp, filename); } return inserted.first->second; } @@ -3440,8 +3451,18 @@ std::string cmGeneratorTarget::GetPchSource(const std::string& config, return std::string(); } std::string& filename = inserted.first->second; - filename = cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), - "/CMakeFiles/", this->GetName(), ".dir/cmake_pch"); + + const cmGeneratorTarget* generatorTarget = this; + const char* pchReuseFrom = + generatorTarget->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM"); + if (pchReuseFrom) { + generatorTarget = + this->GetGlobalGenerator()->FindGeneratorTarget(pchReuseFrom); + } + + filename = + cmStrCat(generatorTarget->LocalGenerator->GetCurrentBinaryDirectory(), + "/CMakeFiles/", generatorTarget->GetName(), ".dir/cmake_pch"); // For GCC the source extension will be tranformed into .h[xx].gch if (!this->Makefile->IsOn("CMAKE_LINK_PCH")) { @@ -3449,12 +3470,40 @@ std::string cmGeneratorTarget::GetPchSource(const std::string& config, } else { filename += ((language == "C") ? ".c" : ".cxx"); } + const std::string filename_tmp = cmStrCat(filename, ".tmp"); - { - cmGeneratedFileStream file(filename_tmp); - file << "/* generated by CMake */\n"; + if (!pchReuseFrom) { + { + cmGeneratedFileStream file(filename_tmp); + file << "/* generated by CMake */\n"; + } + cmSystemTools::MoveFileIfDifferent(filename_tmp, filename); } - cmSystemTools::MoveFileIfDifferent(filename_tmp, filename); + } + return inserted.first->second; +} + +std::string cmGeneratorTarget::GetPchFileObject(const std::string& config, + const std::string& language) +{ + if (language != "C" && language != "CXX") { + return std::string(); + } + const auto inserted = + this->PchObjectFiles.insert(std::make_pair(language + config, "")); + if (inserted.second) { + const std::string pchSource = this->GetPchSource(config, language); + if (pchSource.empty()) { + return std::string(); + } + std::string& filename = inserted.first->second; + + this->AddSource(pchSource, true); + + auto pchSf = this->Makefile->GetOrCreateSource( + pchSource, false, cmSourceFileLocationKind::Known); + + filename = cmStrCat(this->ObjectDirectory, this->GetObjectName(pchSf)); } return inserted.first->second; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 4207d65..6c36c4b 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -462,6 +462,8 @@ public: const std::string& language) const; std::string GetPchSource(const std::string& config, const std::string& language) const; + std::string GetPchFileObject(const std::string& config, + const std::string& language); bool IsSystemIncludeDirectory(const std::string& dir, const std::string& config, @@ -880,6 +882,7 @@ private: mutable std::set LinkImplicitNullProperties; mutable std::map PchHeaders; mutable std::map PchSources; + mutable std::map PchObjectFiles; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 5bbb83c..afcd69f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -4,7 +4,9 @@ #include "cmAlgorithms.h" #include "cmComputeLinkInformation.h" +#include "cmCustomCommand.h" #include "cmCustomCommandGenerator.h" +#include "cmCustomCommandLines.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorExpression.h" #include "cmGeneratorExpressionEvaluationFile.h" @@ -2255,23 +2257,124 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target, return; } + const char* pchReuseFrom = + target->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM"); + auto pch_sf = this->Makefile->GetOrCreateSource( pchSource, false, cmSourceFileLocationKind::Known); std::string pchFile = pchHeader; if (!this->GetGlobalGenerator()->IsXcode()) { + if (!pchReuseFrom) { + target->AddSource(pchSource, true); + } + // Exclude the pch files from linking if (this->Makefile->IsOn("CMAKE_LINK_PCH")) { - cmSystemTools::ReplaceString(pchFile, (lang == "C" ? ".h" : ".hxx"), - pchExtension); - pch_sf->SetProperty("OBJECT_OUTPUTS", pchFile.c_str()); + + auto replaceExtension = [](const std::string& str, + const std::string& ext) -> std::string { + auto dot_pos = str.rfind('.'); + std::string result; + if (dot_pos != std::string::npos) { + result = str.substr(0, dot_pos); + } + result += ext; + return result; + }; + + if (!pchReuseFrom) { + std::string pchSourceObj = target->GetPchFileObject(config, lang); + + pchFile = replaceExtension(pchSourceObj, pchExtension); + pch_sf->SetProperty("OBJECT_OUTPUTS", pchFile.c_str()); + } else { + auto reuseTarget = + this->GlobalGenerator->FindGeneratorTarget(pchReuseFrom); + + if (this->Makefile->IsOn("CMAKE_PCH_COPY_COMPILE_PDB")) { + + const std::string pdb_prefix = + this->GetGlobalGenerator()->IsMultiConfig() + ? cmStrCat(this->GlobalGenerator->GetCMakeCFGIntDir(), "/") + : ""; + + const std::string target_compile_pdb_dir = + cmStrCat(target->GetLocalGenerator()->GetCurrentBinaryDirectory(), + "/", target->GetName(), ".dir/"); + + const std::string copy_script = + cmStrCat(target_compile_pdb_dir, "copy_idb_pdb.cmake"); + cmGeneratedFileStream file(copy_script); + + file << "# CMake generated file\n"; + for (auto extension : { ".pdb", ".idb" }) { + const std::string from_file = cmStrCat( + reuseTarget->GetLocalGenerator()->GetCurrentBinaryDirectory(), + "/", pchReuseFrom, ".dir/${PDB_PREFIX}", pchReuseFrom, + extension); + + const std::string to_dir = cmStrCat( + target->GetLocalGenerator()->GetCurrentBinaryDirectory(), "/", + target->GetName(), ".dir/${PDB_PREFIX}"); + + file << "if (EXISTS \"" << from_file << "\")\n"; + file << " file(COPY \"" << from_file << "\"" + << " DESTINATION \"" << to_dir << "\")\n"; + file << "endif()\n"; + } + + cmCustomCommandLines commandLines; + cmCustomCommandLine currentLine; + currentLine.push_back(cmSystemTools::GetCMakeCommand()); + currentLine.push_back(cmStrCat("-DPDB_PREFIX=", pdb_prefix)); + currentLine.push_back("-P"); + currentLine.push_back(copy_script); + commandLines.push_back(std::move(currentLine)); + + const std::string no_main_dependency; + const std::vector no_deps; + const char* no_message = ""; + const char* no_current_dir = nullptr; + std::vector no_byproducts; + + std::vector outputs; + outputs.push_back(cmStrCat(target_compile_pdb_dir, pdb_prefix, + pchReuseFrom, ".pdb")); + + if (this->GetGlobalGenerator()->IsMultiConfig()) { + this->Makefile->AddCustomCommandToTarget( + target->GetName(), outputs, no_deps, commandLines, + cmTarget::PRE_BUILD, no_message, no_current_dir); + } else { + cmImplicitDependsList no_implicit_depends; + cmSourceFile* copy_rule = this->Makefile->AddCustomCommandToOutput( + outputs, no_byproducts, no_deps, no_main_dependency, + no_implicit_depends, commandLines, no_message, no_current_dir); + + if (copy_rule) { + target->AddSource(copy_rule->ResolveFullPath()); + } + } + + target->Target->SetProperty("COMPILE_PDB_OUTPUT_DIRECTORY", + target_compile_pdb_dir.c_str()); + } + + std::string pchSourceObj = reuseTarget->GetPchFileObject(config, lang); + + // Link to the pch object file + target->Target->SetProperty( + "LINK_FLAGS", + this->ConvertToOutputFormat(pchSourceObj, SHELL).c_str()); + + pchFile = replaceExtension(pchSourceObj, pchExtension); + } } else { pchFile += pchExtension; pch_sf->SetProperty("PCH_EXTENSION", pchExtension.c_str()); } - target->AddSource(pchSource, true); - for (auto& str : { std::ref(useOptionList), std::ref(createOptionList) }) { cmSystemTools::ReplaceString(str, "", pchHeader); cmSystemTools::ReplaceString(str, "", pchFile); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 6637e32..e65fb25 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1085,6 +1085,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) MAKE_STATIC_PROP(COMPILE_FEATURES); MAKE_STATIC_PROP(COMPILE_OPTIONS); MAKE_STATIC_PROP(PRECOMPILE_HEADERS); + MAKE_STATIC_PROP(PRECOMPILE_HEADERS_REUSE_FROM); MAKE_STATIC_PROP(CUDA_PTX_COMPILATION); MAKE_STATIC_PROP(EXPORT_NAME); MAKE_STATIC_PROP(IMPORTED_GLOBAL); @@ -1231,6 +1232,41 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) << impl->Name << "\")\n"; impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return; + } else if (prop == propPRECOMPILE_HEADERS_REUSE_FROM) { + if (this->GetProperty("PRECOMPILE_HEADERS")) { + std::ostringstream e; + e << "PRECOMPILE_HEADERS property is already set on target (\"" + << impl->Name << "\")\n"; + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + return; + } + auto reusedTarget = + impl->Makefile->GetCMakeInstance()->GetGlobalGenerator()->FindTarget( + value); + if (!reusedTarget) { + const std::string e( + "PRECOMPILE_HEADERS_REUSE_FROM set with non existing target"); + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e); + return; + } + + std::string reusedFrom = reusedTarget->GetSafeProperty(prop); + if (reusedFrom.empty()) { + reusedFrom = value; + } + + impl->Properties.SetProperty(prop, reusedFrom.c_str()); + + reusedTarget->SetProperty("COMPILE_PDB_NAME", reusedFrom.c_str()); + reusedTarget->SetProperty("COMPILE_PDB_OUTPUT_DIRECTORY", + cmStrCat(reusedFrom, ".dir/").c_str()); + + for (auto p : { "COMPILE_PDB_NAME", "PRECOMPILE_HEADERS", + "INTERFACE_PRECOMPILE_HEADERS" }) { + this->SetProperty(p, reusedTarget->GetProperty(p)); + } + + this->AddUtility(reusedFrom, impl->Makefile); } else { impl->Properties.SetProperty(prop, value); } @@ -1308,6 +1344,14 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, impl->LinkDirectoriesBacktraces.push_back(lfbt); } } else if (prop == "PRECOMPILE_HEADERS") { + if (this->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM")) { + std::ostringstream e; + e << "PRECOMPILE_HEADERS_REUSE_FROM property is already set on target " + "(\"" + << impl->Name << "\")\n"; + impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + return; + } if (value && *value) { impl->PrecompileHeadersEntries.emplace_back(value); cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace(); diff --git a/Source/cmTargetPrecompileHeadersCommand.cxx b/Source/cmTargetPrecompileHeadersCommand.cxx index 30cf1be..97f1bea 100644 --- a/Source/cmTargetPrecompileHeadersCommand.cxx +++ b/Source/cmTargetPrecompileHeadersCommand.cxx @@ -10,7 +10,7 @@ bool cmTargetPrecompileHeadersCommand::InitialPass( std::vector const& args, cmExecutionStatus&) { - return this->HandleArguments(args, "PRECOMPILE_HEADERS"); + return this->HandleArguments(args, "PRECOMPILE_HEADERS", PROCESS_REUSE_FROM); } void cmTargetPrecompileHeadersCommand::HandleMissingTarget( diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index 3aa845c..4bc3125 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -65,6 +65,19 @@ bool cmTargetPropCommandBase::HandleArguments( ++argIndex; } + if ((flags & PROCESS_REUSE_FROM) && args[argIndex] == "REUSE_FROM") { + if (args.size() != 3) { + this->SetError("called with incorrect number of arguments"); + return false; + } + ++argIndex; + + this->Target->SetProperty("PRECOMPILE_HEADERS_REUSE_FROM", + args[argIndex].c_str()); + + ++argIndex; + } + this->Property = prop; while (argIndex < args.size()) { diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h index 943285d..b244417 100644 --- a/Source/cmTargetPropCommandBase.h +++ b/Source/cmTargetPropCommandBase.h @@ -17,9 +17,10 @@ class cmTargetPropCommandBase : public cmCommand public: enum ArgumentFlags { - NO_FLAGS = 0, - PROCESS_BEFORE = 1, - PROCESS_SYSTEM = 2 + NO_FLAGS = 0x0, + PROCESS_BEFORE = 0x1, + PROCESS_SYSTEM = 0x2, + PROCESS_REUSE_FROM = 0x3 }; bool HandleArguments(std::vector const& args, diff --git a/Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake b/Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake new file mode 100644 index 0000000..4502456 --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.15) +project(PchReuseFrom C) + +add_library(empty empty.c) +target_precompile_headers(empty PUBLIC + + +) +target_include_directories(empty PUBLIC include) + +add_library(foo foo.c) +target_include_directories(foo PUBLIC include) +target_precompile_headers(foo REUSE_FROM empty) + +add_executable(foobar foobar.c) +target_link_libraries(foobar foo ) +set_target_properties(foobar PROPERTIES PRECOMPILE_HEADERS_REUSE_FROM foo) + +enable_testing() +add_test(NAME foobar COMMAND foobar) diff --git a/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir-build-stderr.txt b/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir-build-stderr.txt new file mode 100644 index 0000000..8cdcfd9 --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir-build-stderr.txt @@ -0,0 +1,2 @@ +^(|Warning #670: precompiled header file [^ +]* was not generated in this directory)$ diff --git a/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir.cmake b/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir.cmake new file mode 100644 index 0000000..fff74dc --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir.cmake @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.15) +project(PchReuseFromSubdir C) + +add_library(empty empty.c) +target_precompile_headers(empty PUBLIC + + +) +target_include_directories(empty PUBLIC include) + +add_library(foo foo.c) +target_include_directories(foo PUBLIC include) +target_precompile_headers(foo REUSE_FROM empty) + +subdirs(subdir) + +enable_testing() +add_test(NAME foobar COMMAND foobar) diff --git a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake index fffcc47..bd3b1b8 100644 --- a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake +++ b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake @@ -16,3 +16,5 @@ run_cmake(DisabledPch) run_test(PchInterface) run_cmake(PchPrologueEpilogue) run_test(SkipPrecompileHeaders) +run_test(PchReuseFrom) +run_test(PchReuseFromSubdir) diff --git a/Tests/RunCMake/PrecompileHeaders/empty.c b/Tests/RunCMake/PrecompileHeaders/empty.c new file mode 100644 index 0000000..30ae1c4 --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/empty.c @@ -0,0 +1,3 @@ +void nothing() +{ +} diff --git a/Tests/RunCMake/PrecompileHeaders/include/foo.h b/Tests/RunCMake/PrecompileHeaders/include/foo.h index 4a49474..fc0ae14 100644 --- a/Tests/RunCMake/PrecompileHeaders/include/foo.h +++ b/Tests/RunCMake/PrecompileHeaders/include/foo.h @@ -1,6 +1,6 @@ #ifndef foo_h #define foo_h -extern int foo(); +int foo(void); #endif diff --git a/Tests/RunCMake/PrecompileHeaders/subdir/CMakeLists.txt b/Tests/RunCMake/PrecompileHeaders/subdir/CMakeLists.txt new file mode 100644 index 0000000..fa926c4 --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/subdir/CMakeLists.txt @@ -0,0 +1,3 @@ +add_executable(foobar ../foobar.c) +target_link_libraries(foobar foo ) +set_target_properties(foobar PROPERTIES PRECOMPILE_HEADERS_REUSE_FROM foo) ----------------------------------------------------------------------- Summary of changes: Help/command/target_precompile_headers.rst | 14 +++ Help/manual/cmake-properties.7.rst | 1 + Help/prop_tgt/PRECOMPILE_HEADERS_REUSE_FROM.rst | 7 ++ Modules/Platform/Windows-MSVC.cmake | 13 +- Source/CPack/cmCPackGeneratorFactory.cxx | 25 +--- Source/CPack/cmCPackGeneratorFactory.h | 12 +- Source/CPack/cpack.cxx | 5 +- Source/cmCommonTargetGenerator.cxx | 1 + Source/cmGeneratorTarget.cxx | 131 ++++++++++++++------- Source/cmGeneratorTarget.h | 3 + Source/cmLocalGenerator.cxx | 113 +++++++++++++++++- Source/cmTarget.cxx | 44 +++++++ Source/cmTargetPrecompileHeadersCommand.cxx | 2 +- Source/cmTargetPropCommandBase.cxx | 13 ++ Source/cmTargetPropCommandBase.h | 7 +- .../RunCMake/PrecompileHeaders/PchReuseFrom.cmake | 20 ++++ .../PchReuseFromSubdir-build-stderr.txt | 2 + .../PrecompileHeaders/PchReuseFromSubdir.cmake | 18 +++ .../RunCMake/PrecompileHeaders/RunCMakeTest.cmake | 2 + Tests/RunCMake/PrecompileHeaders/empty.c | 3 + Tests/RunCMake/PrecompileHeaders/include/foo.h | 2 +- .../PrecompileHeaders/subdir/CMakeLists.txt | 3 + 22 files changed, 356 insertions(+), 85 deletions(-) create mode 100644 Help/prop_tgt/PRECOMPILE_HEADERS_REUSE_FROM.rst create mode 100644 Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake create mode 100644 Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir-build-stderr.txt create mode 100644 Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir.cmake create mode 100644 Tests/RunCMake/PrecompileHeaders/empty.c create mode 100644 Tests/RunCMake/PrecompileHeaders/subdir/CMakeLists.txt hooks/post-receive -- CMake From kwrobot at kitware.com Wed Sep 18 11:59:06 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 18 Sep 2019 11:59:06 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1075-g1423507 Message-ID: <20190918155906.448B3112098@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 1423507a71199fd76b457ad9b215a6caca70ee58 (commit) via 9c45b95ddde04d8429f08fd692d53f843a02d12b (commit) via 7f3ecbe7d7210667770d3212e2bfdb0c701cdc5d (commit) from 01cce69870ec7efbb8138f5345aa7ffed8b7ac12 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1423507a71199fd76b457ad9b215a6caca70ee58 commit 1423507a71199fd76b457ad9b215a6caca70ee58 Merge: 01cce69 9c45b95 Author: Brad King AuthorDate: Wed Sep 18 15:51:54 2019 +0000 Commit: Kitware Robot CommitDate: Wed Sep 18 11:52:14 2019 -0400 Merge topic 'command-line-make-functions' 9c45b95ddd cmMakefile: Remove unused AddUtilityCommand overload 7f3ecbe7d7 cmCustomCommandLine: Provide command line make functions Acked-by: Kitware Robot Merge-request: !3819 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9c45b95ddde04d8429f08fd692d53f843a02d12b commit 9c45b95ddde04d8429f08fd692d53f843a02d12b Author: Daniel Eiband AuthorDate: Fri Sep 13 19:45:09 2019 +0200 Commit: Daniel Eiband CommitDate: Mon Sep 16 20:45:56 2019 +0200 cmMakefile: Remove unused AddUtilityCommand overload diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 88d03f9..2c7e5e9 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1173,35 +1173,6 @@ bool cmMakefile::AppendCustomCommandToOutput( cmTarget* cmMakefile::AddUtilityCommand( const std::string& utilityName, TargetOrigin origin, bool excludeFromAll, - const std::vector& depends, const char* workingDirectory, - const char* command, const char* arg1, const char* arg2, const char* arg3, - const char* arg4) -{ - // Construct the command line for the custom command. - cmCustomCommandLine commandLine; - commandLine.push_back(command); - if (arg1) { - commandLine.push_back(arg1); - } - if (arg2) { - commandLine.push_back(arg2); - } - if (arg3) { - commandLine.push_back(arg3); - } - if (arg4) { - commandLine.push_back(arg4); - } - cmCustomCommandLines commandLines; - commandLines.push_back(std::move(commandLine)); - - // Call the real signature of this method. - return this->AddUtilityCommand(utilityName, origin, excludeFromAll, - workingDirectory, depends, commandLines); -} - -cmTarget* cmMakefile::AddUtilityCommand( - const std::string& utilityName, TargetOrigin origin, bool excludeFromAll, const char* workingDirectory, const std::vector& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle, const char* comment, bool uses_terminal, bool command_expand_lists, diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1944879..6d695a7 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -243,14 +243,6 @@ public: * Add a utility to the build. A utility target is a command that * is run every time the target is built. */ - cmTarget* AddUtilityCommand(const std::string& utilityName, - TargetOrigin origin, bool excludeFromAll, - const std::vector& depends, - const char* workingDirectory, - const char* command, const char* arg1 = nullptr, - const char* arg2 = nullptr, - const char* arg3 = nullptr, - const char* arg4 = nullptr); cmTarget* AddUtilityCommand( const std::string& utilityName, TargetOrigin origin, bool excludeFromAll, const char* workingDirectory, const std::vector& depends, https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7f3ecbe7d7210667770d3212e2bfdb0c701cdc5d commit 7f3ecbe7d7210667770d3212e2bfdb0c701cdc5d Author: Daniel Eiband AuthorDate: Fri Sep 13 19:44:37 2019 +0200 Commit: Daniel Eiband CommitDate: Mon Sep 16 20:45:41 2019 +0200 cmCustomCommandLine: Provide command line make functions Reduce boilerplate necessary to create custom command lines by introducing and applying cmMakeCommandLine and cmMakeSingleCommandLine functions. diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index decb39a..65cd6c9 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -191,6 +191,8 @@ set(SRCS cmCustomCommand.h cmCustomCommandGenerator.cxx cmCustomCommandGenerator.h + cmCustomCommandLines.cxx + cmCustomCommandLines.h cmDefinitions.cxx cmDefinitions.h cmDepends.cxx diff --git a/Source/cmCustomCommandLines.cxx b/Source/cmCustomCommandLines.cxx new file mode 100644 index 0000000..37ad75b --- /dev/null +++ b/Source/cmCustomCommandLines.cxx @@ -0,0 +1,22 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmCustomCommandLines.h" + +cmCustomCommandLine cmMakeCommandLine( + std::initializer_list ilist) +{ + cmCustomCommandLine commandLine; + commandLine.reserve(ilist.size()); + for (cm::string_view cmd : ilist) { + commandLine.emplace_back(cmd); + } + return commandLine; +} + +cmCustomCommandLines cmMakeSingleCommandLine( + std::initializer_list ilist) +{ + cmCustomCommandLines commandLines; + commandLines.push_back(cmMakeCommandLine(ilist)); + return commandLines; +} diff --git a/Source/cmCustomCommandLines.h b/Source/cmCustomCommandLines.h index 35a15ba..213aeb1 100644 --- a/Source/cmCustomCommandLines.h +++ b/Source/cmCustomCommandLines.h @@ -5,25 +5,28 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include #include #include +#include "cm_string_view.hxx" // IWYU pragma: keep + /** Data structure to represent a single command line. */ class cmCustomCommandLine : public std::vector { -public: - using Superclass = std::vector; - using iterator = Superclass::iterator; - using const_iterator = Superclass::const_iterator; }; /** Data structure to represent a list of command lines. */ class cmCustomCommandLines : public std::vector { -public: - using Superclass = std::vector; - using iterator = Superclass::iterator; - using const_iterator = Superclass::const_iterator; }; +/** Return a command line from a list of command line parts. */ +cmCustomCommandLine cmMakeCommandLine( + std::initializer_list ilist); + +/** Return a command line vector with a single command line. */ +cmCustomCommandLines cmMakeSingleCommandLine( + std::initializer_list ilist); + #endif diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index 654714e..11844e4 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -77,16 +77,15 @@ bool cmFLTKWrapUICommand(std::vector const& args, depends.push_back(fluid_exe); std::string cxxres = cmStrCat(outName, ".cxx"); - cmCustomCommandLine commandLine; - commandLine.push_back(fluid_exe); - commandLine.push_back("-c"); // instructs Fluid to run in command line - commandLine.push_back("-h"); // optionally rename .h files - commandLine.push_back(hname); - commandLine.push_back("-o"); // optionally rename .cxx files - commandLine.push_back(cxxres); - commandLine.push_back(origname); // name of the GUI fluid file - cmCustomCommandLines commandLines; - commandLines.push_back(commandLine); + cmCustomCommandLines commandLines = cmMakeSingleCommandLine({ + fluid_exe, + "-c", // instructs Fluid to run in command line + "-h", // optionally rename .h files + hname, + "-o", // optionally rename .cxx files + cxxres, + origname // name of the GUI fluid file + }); // Add command for generating the .h and .cxx files std::string no_main_dependency; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 18ff9ac..255739d 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -3,6 +3,7 @@ #include "cmGlobalVisualStudio8Generator.h" #include "cmCustomCommand.h" +#include "cmCustomCommandLines.h" #include "cmDocumentationEntry.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorExpression.h" @@ -146,12 +147,8 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() // Add a custom prebuild target to run the VerifyGlobs script. cmake* cm = this->GetCMakeInstance(); if (cm->DoWriteGlobVerifyTarget()) { - cmCustomCommandLine verifyCommandLine; - verifyCommandLine.push_back(cmSystemTools::GetCMakeCommand()); - verifyCommandLine.push_back("-P"); - verifyCommandLine.push_back(cm->GetGlobVerifyScript()); - cmCustomCommandLines verifyCommandLines; - verifyCommandLines.push_back(verifyCommandLine); + cmCustomCommandLines verifyCommandLines = cmMakeSingleCommandLine( + { cmSystemTools::GetCMakeCommand(), "-P", cm->GetGlobVerifyScript() }); std::vector byproducts; byproducts.push_back(cm->GetGlobVerifyStamp()); @@ -173,20 +170,13 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() listFiles.erase(new_end, listFiles.end()); // Create a rule to re-run CMake. - cmCustomCommandLine commandLine; - commandLine.push_back(cmSystemTools::GetCMakeCommand()); std::string argS = cmStrCat("-S", lg->GetSourceDirectory()); - commandLine.push_back(argS); std::string argB = cmStrCat("-B", lg->GetBinaryDirectory()); - commandLine.push_back(argB); - commandLine.push_back("--check-stamp-list"); - commandLine.push_back(stampList.c_str()); - commandLine.push_back("--vs-solution-file"); std::string const sln = lg->GetBinaryDirectory() + "/" + lg->GetProjectName() + ".sln"; - commandLine.push_back(sln); - cmCustomCommandLines commandLines; - commandLines.push_back(commandLine); + cmCustomCommandLines commandLines = cmMakeSingleCommandLine( + { cmSystemTools::GetCMakeCommand(), argS, argB, "--check-stamp-list", + stampList, "--vs-solution-file", sln }); // Add the rule. Note that we cannot use the CMakeLists.txt // file as the main dependency because it would get diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 6e0b804..a0ce740 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -13,6 +13,7 @@ #include "cmAlgorithms.h" #include "cmCallVisualStudioMacro.h" #include "cmCustomCommand.h" +#include "cmCustomCommandLines.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" #include "cmLocalVisualStudioGenerator.h" @@ -900,17 +901,11 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand( std::string obj_dir = gt->ObjectDirectory; std::string cmakeCommand = cmSystemTools::GetCMakeCommand(); cmSystemTools::ConvertToWindowsExtendedPath(cmakeCommand); - cmCustomCommandLine cmdl; - cmdl.push_back(cmakeCommand); - cmdl.push_back("-E"); - cmdl.push_back("__create_def"); - cmdl.push_back(mdi->DefFile); std::string obj_dir_expanded = obj_dir; cmSystemTools::ReplaceString(obj_dir_expanded, this->GetCMakeCFGIntDir(), configName.c_str()); cmSystemTools::MakeDirectory(obj_dir_expanded); std::string const objs_file = obj_dir_expanded + "/objects.txt"; - cmdl.push_back(objs_file); cmGeneratedFileStream fout(objs_file.c_str()); if (!fout) { cmSystemTools::Error("could not open " + objs_file); @@ -948,8 +943,8 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand( fout << i->GetFullPath() << "\n"; } - cmCustomCommandLines commandLines; - commandLines.push_back(cmdl); + cmCustomCommandLines commandLines = cmMakeSingleCommandLine( + { cmakeCommand, "-E", "__create_def", mdi->DefFile, objs_file }); cmCustomCommand command(gt->Target->GetMakefile(), outputs, empty, empty, commandLines, "Auto build dll exports", "."); commands.push_back(command); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index de04e84..4d41fd7 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -15,6 +15,7 @@ #include "cmComputeLinkInformation.h" #include "cmCustomCommand.h" #include "cmCustomCommandGenerator.h" +#include "cmCustomCommandLines.h" #include "cmDocumentationEntry.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorExpression.h" @@ -500,22 +501,18 @@ void cmGlobalXCodeGenerator::AddExtraTargets( const char* no_working_directory = nullptr; std::vector no_depends; cmTarget* allbuild = mf->AddUtilityCommand( - "ALL_BUILD", cmMakefile::TargetOrigin::Generator, true, no_depends, - no_working_directory, "echo", "Build all projects"); + "ALL_BUILD", cmMakefile::TargetOrigin::Generator, true, + no_working_directory, no_depends, + cmMakeSingleCommandLine({ "echo", "Build all projects" })); cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root); root->AddGeneratorTarget(allBuildGt); // Add XCODE depend helper std::string dir = root->GetCurrentBinaryDirectory(); - cmCustomCommandLine makeHelper; - makeHelper.push_back("make"); - makeHelper.push_back("-C"); - makeHelper.push_back(dir); - makeHelper.push_back("-f"); - makeHelper.push_back(this->CurrentXCodeHackMakefile); - makeHelper.push_back("OBJDIR=$(OBJDIR)"); - makeHelper.push_back(""); // placeholder, see below + cmCustomCommandLines commandLines = cmMakeSingleCommandLine( + { "make", "-C", dir, "-f", this->CurrentXCodeHackMakefile, + "OBJDIR=$(OBJDIR)", /* placeholder, see below */ "" }); // Add ZERO_CHECK bool regenerate = !this->GlobalSettingIsOn("CMAKE_SUPPRESS_REGENERATION"); @@ -530,7 +527,8 @@ void cmGlobalXCodeGenerator::AddExtraTargets( cmSystemTools::ReplaceString(file, "\\ ", " "); cmTarget* check = mf->AddUtilityCommand( CMAKE_CHECK_BUILD_SYSTEM_TARGET, cmMakefile::TargetOrigin::Generator, - true, no_depends, no_working_directory, "make", "-f", file.c_str()); + true, no_working_directory, no_depends, + cmMakeSingleCommandLine({ "make", "-f", file })); cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root); root->AddGeneratorTarget(checkGt); @@ -555,10 +553,8 @@ void cmGlobalXCodeGenerator::AddExtraTargets( // this will make sure that when the next target is built // things are up-to-date if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) { - makeHelper.back() = // fill placeholder + commandLines.front().back() = // fill placeholder this->PostBuildMakeTarget(target->GetName(), "$(CONFIGURATION)"); - cmCustomCommandLines commandLines; - commandLines.push_back(makeHelper); std::vector no_byproducts; gen->GetMakefile()->AddCustomCommandToTarget( target->GetName(), no_byproducts, no_depends, commandLines, @@ -1440,19 +1436,14 @@ void cmGlobalXCodeGenerator::CreateCustomCommands( if (gtgt->GetType() == cmStateEnums::SHARED_LIBRARY && !gtgt->IsFrameworkOnApple()) { - cmCustomCommandLines cmd; - cmd.resize(1); - cmd[0].push_back(cmSystemTools::GetCMakeCommand()); - cmd[0].push_back("-E"); - cmd[0].push_back("cmake_symlink_library"); std::string str_file = cmStrCat("$GetName(), '>'); std::string str_so_file = cmStrCat("$GetName(), '>'); std::string str_link_file = cmStrCat("$GetName(), '>'); - cmd[0].push_back(str_file); - cmd[0].push_back(str_so_file); - cmd[0].push_back(str_link_file); + cmCustomCommandLines cmd = cmMakeSingleCommandLine( + { cmSystemTools::GetCMakeCommand(), "-E", "cmake_symlink_library", + str_file, str_so_file, str_link_file }); cmCustomCommand command(this->CurrentMakefile, std::vector(), std::vector(), diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 6c7fb2b..026f494 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -92,11 +92,8 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() for (cmGeneratorTarget* l : tgts) { if (l->GetType() == cmStateEnums::GLOBAL_TARGET) { std::vector no_depends; - cmCustomCommandLine force_command; - force_command.push_back("cd"); - force_command.push_back("."); - cmCustomCommandLines force_commands; - force_commands.push_back(force_command); + cmCustomCommandLines force_commands = + cmMakeSingleCommandLine({ "cd", "." }); std::string no_main_dependency; std::string force = cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles/", l->GetName(), "_force"); @@ -246,21 +243,15 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule() std::unique(listFiles.begin(), listFiles.end()); listFiles.erase(new_end, listFiles.end()); + std::string argS = cmStrCat("-S", this->GetSourceDirectory()); + std::string argB = cmStrCat("-B", this->GetBinaryDirectory()); std::string stampName = cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles/generate.stamp"); - cmCustomCommandLine commandLine; - commandLine.push_back(cmSystemTools::GetCMakeCommand()); + cmCustomCommandLines commandLines = + cmMakeSingleCommandLine({ cmSystemTools::GetCMakeCommand(), argS, argB, + "--check-stamp-file", stampName }); std::string comment = cmStrCat("Building Custom Rule ", makefileIn); - std::string args; - args = cmStrCat("-S", this->GetSourceDirectory()); - commandLine.push_back(args); - args = cmStrCat("-B", this->GetBinaryDirectory()); - commandLine.push_back(args); - commandLine.push_back("--check-stamp-file"); - commandLine.push_back(stampName); - cmCustomCommandLines commandLines; - commandLines.push_back(commandLine); - const char* no_working_directory = 0; + const char* no_working_directory = nullptr; std::string fullpathStampName = cmSystemTools::CollapseFullPath(stampName.c_str()); this->Makefile->AddCustomCommandToOutput( diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index f3f2042..cec9c02 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -98,16 +98,11 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target, } // Add a pre-build event to create the directory. - cmCustomCommandLine command; - command.push_back(cmSystemTools::GetCMakeCommand()); - command.push_back("-E"); - command.push_back("make_directory"); - command.push_back(impDir); std::vector no_output; std::vector no_byproducts; std::vector no_depends; - cmCustomCommandLines commands; - commands.push_back(command); + cmCustomCommandLines commands = cmMakeSingleCommandLine( + { cmSystemTools::GetCMakeCommand(), "-E", "make_directory", impDir }); pcc.reset(new cmCustomCommand(0, no_output, no_byproducts, no_depends, commands, 0, 0)); pcc->SetEscapeOldStyle(false); diff --git a/Source/cmQTWrapCPPCommand.cxx b/Source/cmQTWrapCPPCommand.cxx index 1a5602b..cc4df8f 100644 --- a/Source/cmQTWrapCPPCommand.cxx +++ b/Source/cmQTWrapCPPCommand.cxx @@ -2,8 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmQTWrapCPPCommand.h" -#include - #include "cmCustomCommandLines.h" #include "cmExecutionStatus.h" #include "cmMakefile.h" @@ -65,14 +63,8 @@ bool cmQTWrapCPPCommand(std::vector const& args, sourceListValue += newName; // Create the custom command to generate the file. - cmCustomCommandLine commandLine; - commandLine.push_back(moc_exe); - commandLine.push_back("-o"); - commandLine.push_back(newName); - commandLine.push_back(hname); - - cmCustomCommandLines commandLines; - commandLines.push_back(std::move(commandLine)); + cmCustomCommandLines commandLines = + cmMakeSingleCommandLine({ moc_exe, "-o", newName, hname }); std::vector depends; depends.push_back(moc_exe); diff --git a/Source/cmQTWrapUICommand.cxx b/Source/cmQTWrapUICommand.cxx index b7b5efa..66c0228 100644 --- a/Source/cmQTWrapUICommand.cxx +++ b/Source/cmQTWrapUICommand.cxx @@ -2,8 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmQTWrapUICommand.h" -#include - #include "cmCustomCommandLines.h" #include "cmExecutionStatus.h" #include "cmMakefile.h" @@ -76,31 +74,12 @@ bool cmQTWrapUICommand(std::vector const& args, sourceListValue += mocName; // set up .ui to .h and .cxx command - cmCustomCommandLine hCommand; - hCommand.push_back(uic_exe); - hCommand.push_back("-o"); - hCommand.push_back(hName); - hCommand.push_back(uiName); - cmCustomCommandLines hCommandLines; - hCommandLines.push_back(std::move(hCommand)); - - cmCustomCommandLine cxxCommand; - cxxCommand.push_back(uic_exe); - cxxCommand.push_back("-impl"); - cxxCommand.push_back(hName); - cxxCommand.push_back("-o"); - cxxCommand.push_back(cxxName); - cxxCommand.push_back(uiName); - cmCustomCommandLines cxxCommandLines; - cxxCommandLines.push_back(std::move(cxxCommand)); - - cmCustomCommandLine mocCommand; - mocCommand.push_back(moc_exe); - mocCommand.push_back("-o"); - mocCommand.push_back(mocName); - mocCommand.push_back(hName); - cmCustomCommandLines mocCommandLines; - mocCommandLines.push_back(std::move(mocCommand)); + cmCustomCommandLines hCommandLines = + cmMakeSingleCommandLine({ uic_exe, "-o", hName, uiName }); + cmCustomCommandLines cxxCommandLines = cmMakeSingleCommandLine( + { uic_exe, "-impl", hName, "-o", cxxName, uiName }); + cmCustomCommandLines mocCommandLines = + cmMakeSingleCommandLine({ moc_exe, "-o", mocName, hName }); std::vector depends; depends.push_back(uiName); diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 54304c3..355141e 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -957,16 +957,9 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() } // Compose command lines - cmCustomCommandLines commandLines; - { - cmCustomCommandLine currentLine; - currentLine.push_back(cmSystemTools::GetCMakeCommand()); - currentLine.push_back("-E"); - currentLine.push_back("cmake_autogen"); - currentLine.push_back(this->AutogenTarget.InfoFile); - currentLine.push_back("$"); - commandLines.push_back(std::move(currentLine)); - } + cmCustomCommandLines commandLines = cmMakeSingleCommandLine( + { cmSystemTools::GetCMakeCommand(), "-E", "cmake_autogen", + this->AutogenTarget.InfoFile, "$" }); // Use PRE_BUILD on demand bool usePRE_BUILD = false; @@ -1100,22 +1093,14 @@ bool cmQtAutoGenInitializer::InitRccTargets() if (this->MultiConfig) { // Build for all configurations for (std::string const& config : this->ConfigsList) { - cmCustomCommandLine currentLine; - currentLine.push_back(cmSystemTools::GetCMakeCommand()); - currentLine.push_back("-E"); - currentLine.push_back("cmake_autorcc"); - currentLine.push_back(qrc.InfoFile); - currentLine.push_back(config); - commandLines.push_back(std::move(currentLine)); + commandLines.push_back( + cmMakeCommandLine({ cmSystemTools::GetCMakeCommand(), "-E", + "cmake_autorcc", qrc.InfoFile, config })); } } else { - cmCustomCommandLine currentLine; - currentLine.push_back(cmSystemTools::GetCMakeCommand()); - currentLine.push_back("-E"); - currentLine.push_back("cmake_autorcc"); - currentLine.push_back(qrc.InfoFile); - currentLine.push_back("$"); - commandLines.push_back(std::move(currentLine)); + commandLines.push_back( + cmMakeCommandLine({ cmSystemTools::GetCMakeCommand(), "-E", + "cmake_autorcc", qrc.InfoFile, "$" })); } std::string ccComment = cmStrCat( "Automatic RCC for ", FileProjectRelativePath(makefile, qrc.QrcFile)); ----------------------------------------------------------------------- Summary of changes: Source/CMakeLists.txt | 2 ++ Source/cmCustomCommandLines.cxx | 22 +++++++++++++++++++ Source/cmCustomCommandLines.h | 19 ++++++++++------- Source/cmFLTKWrapUICommand.cxx | 19 ++++++++--------- Source/cmGlobalVisualStudio8Generator.cxx | 22 ++++++------------- Source/cmGlobalVisualStudioGenerator.cxx | 11 +++------- Source/cmGlobalXCodeGenerator.cxx | 35 ++++++++++++------------------- Source/cmLocalVisualStudio7Generator.cxx | 25 +++++++--------------- Source/cmLocalVisualStudioGenerator.cxx | 9 ++------ Source/cmMakefile.cxx | 29 ------------------------- Source/cmMakefile.h | 8 ------- Source/cmQTWrapCPPCommand.cxx | 12 ++--------- Source/cmQTWrapUICommand.cxx | 33 ++++++----------------------- Source/cmQtAutoGenInitializer.cxx | 33 ++++++++--------------------- 14 files changed, 93 insertions(+), 186 deletions(-) create mode 100644 Source/cmCustomCommandLines.cxx hooks/post-receive -- CMake From kwrobot at kitware.com Wed Sep 18 23:58:48 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 18 Sep 2019 23:58:48 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1076-g0772d15 Message-ID: <20190919035848.CB3FCFCE2C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 0772d15c2ce5bfd95a87894ee5226d6d74fcff41 (commit) from 1423507a71199fd76b457ad9b215a6caca70ee58 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0772d15c2ce5bfd95a87894ee5226d6d74fcff41 commit 0772d15c2ce5bfd95a87894ee5226d6d74fcff41 Author: Kitware Robot AuthorDate: Thu Sep 19 00:01:06 2019 -0400 Commit: Kitware Robot CommitDate: Thu Sep 19 00:01:06 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 1e0721f..c09c1ce 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 15) -set(CMake_VERSION_PATCH 20190918) +set(CMake_VERSION_PATCH 20190919) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Thu Sep 19 09:38:37 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 19 Sep 2019 09:38:37 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1080-gcca5897 Message-ID: <20190919133837.E7C9D112098@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via cca5897318d5c747078f79cd5bb45ba74955102a (commit) via 98d53ba1d6a8815ddd2e446b7c2ba65dd1be7b82 (commit) via 13a7c858c8acfa530badcb7ad53b5494e0c37aae (commit) via 44e8b8f1f222c0227ed72d09310e30524bda9935 (commit) from 0772d15c2ce5bfd95a87894ee5226d6d74fcff41 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cca5897318d5c747078f79cd5bb45ba74955102a commit cca5897318d5c747078f79cd5bb45ba74955102a Merge: 98d53ba 13a7c85 Author: Brad King AuthorDate: Thu Sep 19 13:33:17 2019 +0000 Commit: Kitware Robot CommitDate: Thu Sep 19 09:34:23 2019 -0400 Merge topic 'CMakeFindBinUtils-install_name_tool-prefix' 13a7c858c8 Use _CMAKE_TOOLCHAIN_PREFIX for install_name_tool as well Acked-by: Kitware Robot Merge-request: !3830 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=98d53ba1d6a8815ddd2e446b7c2ba65dd1be7b82 commit 98d53ba1d6a8815ddd2e446b7c2ba65dd1be7b82 Merge: 0772d15 44e8b8f Author: Brad King AuthorDate: Thu Sep 19 13:31:52 2019 +0000 Commit: Kitware Robot CommitDate: Thu Sep 19 09:32:02 2019 -0400 Merge topic 'FindGnuTLS-target' 44e8b8f1f2 FindGnuTLS: add target GnuTLS::GnuTLS Acked-by: Kitware Robot Merge-request: !3825 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=13a7c858c8acfa530badcb7ad53b5494e0c37aae commit 13a7c858c8acfa530badcb7ad53b5494e0c37aae Author: Isuru Fernando AuthorDate: Wed Sep 18 12:05:39 2019 -0400 Commit: Isuru Fernando CommitDate: Wed Sep 18 12:05:39 2019 -0400 Use _CMAKE_TOOLCHAIN_PREFIX for install_name_tool as well diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 01f9dae..781b48c 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -134,7 +134,7 @@ else() endif() if(CMAKE_PLATFORM_HAS_INSTALLNAME) - find_program(CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + find_program(CMAKE_INSTALL_NAME_TOOL NAMES ${_CMAKE_TOOLCHAIN_PREFIX}install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) if(NOT CMAKE_INSTALL_NAME_TOOL) message(FATAL_ERROR "Could not find install_name_tool, please check your installation.") https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=44e8b8f1f222c0227ed72d09310e30524bda9935 commit 44e8b8f1f222c0227ed72d09310e30524bda9935 Author: David Callu AuthorDate: Tue Sep 17 10:22:41 2019 +0200 Commit: Brad King CommitDate: Wed Sep 18 12:03:53 2019 -0400 FindGnuTLS: add target GnuTLS::GnuTLS Also add a test case for the module. diff --git a/Help/release/dev/FindGnuTLS-target.rst b/Help/release/dev/FindGnuTLS-target.rst new file mode 100644 index 0000000..671a7b7 --- /dev/null +++ b/Help/release/dev/FindGnuTLS-target.rst @@ -0,0 +1,4 @@ +FindGnuTLS-target +----------------- + +* The :module:`FindGnuTLS` module now provides an imported target. diff --git a/Modules/FindGnuTLS.cmake b/Modules/FindGnuTLS.cmake index 123a0f5..819f000 100644 --- a/Modules/FindGnuTLS.cmake +++ b/Modules/FindGnuTLS.cmake @@ -7,16 +7,25 @@ FindGnuTLS Find the GNU Transport Layer Security library (gnutls) - - -Once done this will define - -:: - - GNUTLS_FOUND - System has gnutls - GNUTLS_INCLUDE_DIR - The gnutls include directory - GNUTLS_LIBRARIES - The libraries needed to use gnutls - GNUTLS_DEFINITIONS - Compiler switches required for using gnutls +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +This module defines :prop_tgt:`IMPORTED` target ``GnuTLS::GnuTLS``, if +gnutls has been found. + +Result Variables +^^^^^^^^^^^^^^^^ + +``GNUTLS_FOUND`` + System has gnutls +``GNUTLS_INCLUDE_DIR`` + The gnutls include directory +``GNUTLS_LIBRARIES`` + The libraries needed to use gnutls +``GNUTLS_DEFINITIONS`` + Compiler switches required for using gnutls +``GNUTLS_VERSION`` + version of gnutls. #]=======================================================================] # Note that this doesn't try to find the gnutls-extra package. @@ -34,6 +43,8 @@ if (NOT WIN32) find_package(PkgConfig QUIET) PKG_CHECK_MODULES(PC_GNUTLS QUIET gnutls) set(GNUTLS_DEFINITIONS ${PC_GNUTLS_CFLAGS_OTHER}) + set(GNUTLS_VERSION ${PC_GNUTLS_VERSION}) + # keep for backward compatibility set(GNUTLS_VERSION_STRING ${PC_GNUTLS_VERSION}) endif () @@ -59,4 +70,13 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(GnuTLS if(GNUTLS_FOUND) set(GNUTLS_LIBRARIES ${GNUTLS_LIBRARY}) set(GNUTLS_INCLUDE_DIRS ${GNUTLS_INCLUDE_DIR}) + + if(NOT TARGET GnuTLS::GnuTLS) + add_library(GnuTLS::GnuTLS UNKNOWN IMPORTED) + set_target_properties(GnuTLS::GnuTLS PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${GNUTLS_INCLUDE_DIRS}" + INTERFACE_COMPILE_DEFINITIONS "${GNUTLS_DEFINITIONS}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${GNUTLS_LIBRARIES}") + endif() endif() diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index c14107a..78ae7aa 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1394,6 +1394,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH GIF Git GLEW + GnuTLS GSL GTK2 Iconv diff --git a/Tests/FindGnuTLS/CMakeLists.txt b/Tests/FindGnuTLS/CMakeLists.txt new file mode 100644 index 0000000..059ac7b --- /dev/null +++ b/Tests/FindGnuTLS/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindGnuTLS.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $ + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindGnuTLS/Test" + "${CMake_BINARY_DIR}/Tests/FindGnuTLS/Test" + ${build_generator_args} + --build-project TestFindGnuTLS + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $ + ) diff --git a/Tests/FindGnuTLS/Test/CMakeLists.txt b/Tests/FindGnuTLS/Test/CMakeLists.txt new file mode 100644 index 0000000..c5a9819 --- /dev/null +++ b/Tests/FindGnuTLS/Test/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.4) +project(TestFindGnuTLS C) +include(CTest) + +find_package(GnuTLS REQUIRED) + +add_definitions(-DCMAKE_EXPECTED_GNUTLS_VERSION="${GNUTLS_VERSION}") + +add_executable(test_tgt main.c) +target_link_libraries(test_tgt GnuTLS::GnuTLS) +add_test(NAME test_tgt COMMAND test_tgt) + +add_executable(test_var main.c) +target_include_directories(test_var PRIVATE ${GNUTLS_INCLUDE_DIRS}) +target_link_libraries(test_var PRIVATE ${GNUTLS_LIBRARIES}) +target_compile_definitions(test_var PRIVATE ${GNUTLS_DEFINITIONS}) +add_test(NAME test_var COMMAND test_var) diff --git a/Tests/FindGnuTLS/Test/main.c b/Tests/FindGnuTLS/Test/main.c new file mode 100644 index 0000000..122fb2d --- /dev/null +++ b/Tests/FindGnuTLS/Test/main.c @@ -0,0 +1,22 @@ +#include +#include +#include + +#include + +int main() +{ + // test the linker + gnutls_session_t session; + if (gnutls_init(&session, GNUTLS_CLIENT)) { + gnutls_deinit(session); + } + + // check the version + char gnutls_version_string[16]; + snprintf(gnutls_version_string, 16, "%i.%i.%i", GNUTLS_VERSION_MAJOR, + GNUTLS_VERSION_MINOR, GNUTLS_VERSION_PATCH); + assert(strcmp(gnutls_version_string, CMAKE_EXPECTED_GNUTLS_VERSION) == 0); + + return 0; +} ----------------------------------------------------------------------- Summary of changes: Help/release/dev/FindGnuTLS-target.rst | 4 +++ Modules/CMakeFindBinUtils.cmake | 2 +- Modules/FindGnuTLS.cmake | 40 ++++++++++++++++++++------- Tests/CMakeLists.txt | 1 + Tests/{FindCURL => FindGnuTLS}/CMakeLists.txt | 8 +++--- Tests/FindGnuTLS/Test/CMakeLists.txt | 17 ++++++++++++ Tests/FindGnuTLS/Test/main.c | 22 +++++++++++++++ 7 files changed, 79 insertions(+), 15 deletions(-) create mode 100644 Help/release/dev/FindGnuTLS-target.rst copy Tests/{FindCURL => FindGnuTLS}/CMakeLists.txt (54%) create mode 100644 Tests/FindGnuTLS/Test/CMakeLists.txt create mode 100644 Tests/FindGnuTLS/Test/main.c hooks/post-receive -- CMake From kwrobot at kitware.com Thu Sep 19 11:18:34 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 19 Sep 2019 11:18:34 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1082-ge199294 Message-ID: <20190919151834.6DA3B10F384@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via e199294673665e01b1cba48625ec1b18c960c90e (commit) via 9dba84cfa5e85e51ee6d6799f03a26656063ef8b (commit) from cca5897318d5c747078f79cd5bb45ba74955102a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e199294673665e01b1cba48625ec1b18c960c90e commit e199294673665e01b1cba48625ec1b18c960c90e Merge: cca5897 9dba84c Author: Brad King AuthorDate: Thu Sep 19 15:10:14 2019 +0000 Commit: Kitware Robot CommitDate: Thu Sep 19 11:10:40 2019 -0400 Merge topic 'refactor-string-concat' 9dba84cfa5 Refactor: Use cmStrCat to construct error strings Acked-by: Kitware Robot Merge-request: !3734 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9dba84cfa5e85e51ee6d6799f03a26656063ef8b commit 9dba84cfa5e85e51ee6d6799f03a26656063ef8b Author: Asit Dhal AuthorDate: Sun Sep 15 19:11:02 2019 +0200 Commit: Brad King CommitDate: Wed Sep 18 14:18:46 2019 -0400 Refactor: Use cmStrCat to construct error strings Replace string construction using std::stringstream with cmStrCat and cmWrap. diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index c91198c..35db6a4 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -321,10 +321,9 @@ bool cmAddCustomCommandCommand(std::vector const& args, } // No command for this output exists. - std::ostringstream e; - e << "given APPEND option with output\n\"" << output[0] - << "\"\nwhich is not already a custom command output."; - status.SetError(e.str()); + status.SetError( + cmStrCat("given APPEND option with output\n\"", output[0], + "\"\nwhich is not already a custom command output.")); return false; } @@ -407,10 +406,8 @@ bool cmAddCustomCommandCommandCheckOutputs( // Make sure the output file name has no invalid characters. std::string::size_type pos = o.find_first_of("#<>"); if (pos != std::string::npos) { - std::ostringstream msg; - msg << "called with OUTPUT containing a \"" << o[pos] - << "\". This character is not allowed."; - status.SetError(msg.str()); + status.SetError(cmStrCat("called with OUTPUT containing a \"", o[pos], + "\". This character is not allowed.")); return false; } } diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx index ec5c1a7..9fd1234 100644 --- a/Source/cmAddCustomTargetCommand.cxx +++ b/Source/cmAddCustomTargetCommand.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmAddCustomTargetCommand.h" -#include #include #include "cmCustomCommandLines.h" @@ -29,11 +28,9 @@ bool cmAddCustomTargetCommand(std::vector const& args, // Check the target name. if (targetName.find_first_of("/\\") != std::string::npos) { - std::ostringstream e; - e << "called with invalid target name \"" << targetName - << "\". Target names may not contain a slash. " - << "Use ADD_CUSTOM_COMMAND to generate files."; - status.SetError(e.str()); + status.SetError(cmStrCat("called with invalid target name \"", targetName, + "\". Target names may not contain a slash. " + "Use ADD_CUSTOM_COMMAND to generate files.")); return false; } @@ -153,10 +150,9 @@ bool cmAddCustomTargetCommand(std::vector const& args, std::string::size_type pos = targetName.find_first_of("#<>"); if (pos != std::string::npos) { - std::ostringstream msg; - msg << "called with target name containing a \"" << targetName[pos] - << "\". This character is not allowed."; - status.SetError(msg.str()); + status.SetError(cmStrCat("called with target name containing a \"", + targetName[pos], + "\". This character is not allowed.")); return false; } diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx index 0ddbda8..b1fc893 100644 --- a/Source/cmAddDependenciesCommand.cxx +++ b/Source/cmAddDependenciesCommand.cxx @@ -2,12 +2,11 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmAddDependenciesCommand.h" -#include - #include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmMessageType.h" #include "cmRange.h" +#include "cmStringAlgorithms.h" #include "cmTarget.h" bool cmAddDependenciesCommand(std::vector const& args, @@ -21,10 +20,10 @@ bool cmAddDependenciesCommand(std::vector const& args, cmMakefile& mf = status.GetMakefile(); std::string const& target_name = args[0]; if (mf.IsAlias(target_name)) { - std::ostringstream e; - e << "Cannot add target-level dependencies to alias target \"" - << target_name << "\".\n"; - mf.IssueMessage(MessageType::FATAL_ERROR, e.str()); + mf.IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Cannot add target-level dependencies to alias target \"", + target_name, "\".\n")); } if (cmTarget* target = mf.FindTargetToUse(target_name)) { @@ -33,14 +32,17 @@ bool cmAddDependenciesCommand(std::vector const& args, target->AddUtility(arg, &mf); } } else { - std::ostringstream e; - e << "Cannot add target-level dependencies to non-existent target \"" - << target_name << "\".\n" - << "The add_dependencies works for top-level logical targets created " - << "by the add_executable, add_library, or add_custom_target commands. " - << "If you want to add file-level dependencies see the DEPENDS option " - << "of the add_custom_target and add_custom_command commands."; - mf.IssueMessage(MessageType::FATAL_ERROR, e.str()); + mf.IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat( + "Cannot add target-level dependencies to non-existent " + "target \"", + target_name, + "\".\nThe add_dependencies works for " + "top-level logical targets created by the add_executable, " + "add_library, or add_custom_target commands. If you want to add " + "file-level dependencies see the DEPENDS option of the " + "add_custom_target and add_custom_command commands.")); } return true; diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index 1a87028..e738bc4 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -2,13 +2,12 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmAddExecutableCommand.h" -#include - #include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmTarget.h" bool cmAddExecutableCommand(std::vector const& args, @@ -99,34 +98,30 @@ bool cmAddExecutableCommand(std::vector const& args, std::string const& aliasedName = *s; if (mf.IsAlias(aliasedName)) { - std::ostringstream e; - e << "cannot create ALIAS target \"" << exename << "\" because target \"" - << aliasedName << "\" is itself an ALIAS."; - status.SetError(e.str()); + status.SetError(cmStrCat("cannot create ALIAS target \"", exename, + "\" because target \"", aliasedName, + "\" is itself an ALIAS.")); return false; } cmTarget* aliasedTarget = mf.FindTargetToUse(aliasedName, true); if (!aliasedTarget) { - std::ostringstream e; - e << "cannot create ALIAS target \"" << exename << "\" because target \"" - << aliasedName << "\" does not already exist."; - status.SetError(e.str()); + status.SetError(cmStrCat("cannot create ALIAS target \"", exename, + "\" because target \"", aliasedName, + "\" does not already exist.")); return false; } cmStateEnums::TargetType type = aliasedTarget->GetType(); if (type != cmStateEnums::EXECUTABLE) { - std::ostringstream e; - e << "cannot create ALIAS target \"" << exename << "\" because target \"" - << aliasedName << "\" is not an executable."; - status.SetError(e.str()); + status.SetError(cmStrCat("cannot create ALIAS target \"", exename, + "\" because target \"", aliasedName, + "\" is not an executable.")); return false; } if (aliasedTarget->IsImported() && !aliasedTarget->IsImportedGloballyVisible()) { - std::ostringstream e; - e << "cannot create ALIAS target \"" << exename << "\" because target \"" - << aliasedName << "\" is imported but not globally visible."; - status.SetError(e.str()); + status.SetError(cmStrCat("cannot create ALIAS target \"", exename, + "\" because target \"", aliasedName, + "\" is imported but not globally visible.")); return false; } mf.AddAlias(exename, aliasedName); @@ -137,10 +132,9 @@ bool cmAddExecutableCommand(std::vector const& args, if (importTarget) { // Make sure the target does not already exist. if (mf.FindTargetToUse(exename)) { - std::ostringstream e; - e << "cannot create imported target \"" << exename - << "\" because another target with the same name already exists."; - status.SetError(e.str()); + status.SetError(cmStrCat( + "cannot create imported target \"", exename, + "\" because another target with the same name already exists.")); return false; } diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index dc8937a..0439c51 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -2,8 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmAddLibraryCommand.h" -#include - #include "cmAlgorithms.h" #include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" @@ -184,20 +182,16 @@ bool cmAddLibraryCommand(std::vector const& args, std::string const& aliasedName = *s; if (mf.IsAlias(aliasedName)) { - std::ostringstream e; - e << "cannot create ALIAS target \"" << libName << "\" because target \"" - << aliasedName << "\" is itself an ALIAS."; - status.SetError(e.str()); + status.SetError(cmStrCat("cannot create ALIAS target \"", libName, + "\" because target \"", aliasedName, + "\" is itself an ALIAS.")); return false; } cmTarget* aliasedTarget = mf.FindTargetToUse(aliasedName, true); if (!aliasedTarget) { - std::ostringstream e; - e << "cannot create ALIAS target \"" << libName << "\" because target \"" - << aliasedName - << "\" does not already " - "exist."; - status.SetError(e.str()); + status.SetError(cmStrCat("cannot create ALIAS target \"", libName, + "\" because target \"", aliasedName, + "\" does not already exist.")); return false; } cmStateEnums::TargetType aliasedType = aliasedTarget->GetType(); @@ -208,18 +202,16 @@ bool cmAddLibraryCommand(std::vector const& args, aliasedType != cmStateEnums::INTERFACE_LIBRARY && !(aliasedType == cmStateEnums::UNKNOWN_LIBRARY && aliasedTarget->IsImported())) { - std::ostringstream e; - e << "cannot create ALIAS target \"" << libName << "\" because target \"" - << aliasedName << "\" is not a library."; - status.SetError(e.str()); + status.SetError(cmStrCat("cannot create ALIAS target \"", libName, + "\" because target \"", aliasedName, + "\" is not a library.")); return false; } if (aliasedTarget->IsImported() && !aliasedTarget->IsImportedGloballyVisible()) { - std::ostringstream e; - e << "cannot create ALIAS target \"" << libName << "\" because target \"" - << aliasedName << "\" is imported but not globally visible."; - status.SetError(e.str()); + status.SetError(cmStrCat("cannot create ALIAS target \"", libName, + "\" because target \"", aliasedName, + "\" is imported but not globally visible.")); return false; } mf.AddAlias(libName, aliasedName); @@ -238,12 +230,13 @@ bool cmAddLibraryCommand(std::vector const& args, if ((type == cmStateEnums::SHARED_LIBRARY || type == cmStateEnums::MODULE_LIBRARY) && !mf.GetState()->GetGlobalPropertyAsBool("TARGET_SUPPORTS_SHARED_LIBS")) { - std::ostringstream w; - w << "ADD_LIBRARY called with " - << (type == cmStateEnums::SHARED_LIBRARY ? "SHARED" : "MODULE") - << " option but the target platform does not support dynamic linking. " - "Building a STATIC library instead. This may lead to problems."; - mf.IssueMessage(MessageType::AUTHOR_WARNING, w.str()); + mf.IssueMessage( + MessageType::AUTHOR_WARNING, + cmStrCat( + "ADD_LIBRARY called with ", + (type == cmStateEnums::SHARED_LIBRARY ? "SHARED" : "MODULE"), + " option but the target platform does not support dynamic linking. ", + "Building a STATIC library instead. This may lead to problems.")); type = cmStateEnums::STATIC_LIBRARY; } @@ -266,19 +259,17 @@ bool cmAddLibraryCommand(std::vector const& args, } if (type == cmStateEnums::INTERFACE_LIBRARY) { if (!cmGeneratorExpression::IsValidTargetName(libName)) { - std::ostringstream e; - e << "Invalid name for IMPORTED INTERFACE library target: " << libName; - status.SetError(e.str()); + status.SetError(cmStrCat( + "Invalid name for IMPORTED INTERFACE library target: ", libName)); return false; } } // Make sure the target does not already exist. if (mf.FindTargetToUse(libName)) { - std::ostringstream e; - e << "cannot create imported target \"" << libName - << "\" because another target with the same name already exists."; - status.SetError(e.str()); + status.SetError(cmStrCat( + "cannot create imported target \"", libName, + "\" because another target with the same name already exists.")); return false; } @@ -309,9 +300,8 @@ bool cmAddLibraryCommand(std::vector const& args, if (type == cmStateEnums::INTERFACE_LIBRARY) { if (!cmGeneratorExpression::IsValidTargetName(libName) || libName.find("::") != std::string::npos) { - std::ostringstream e; - e << "Invalid name for INTERFACE library target: " << libName; - status.SetError(e.str()); + status.SetError( + cmStrCat("Invalid name for INTERFACE library target: ", libName)); return false; } diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx index c0be308..6a1a514 100644 --- a/Source/cmAddSubDirectoryCommand.cxx +++ b/Source/cmAddSubDirectoryCommand.cxx @@ -3,7 +3,6 @@ #include "cmAddSubDirectoryCommand.h" #include -#include #include "cmExecutionStatus.h" #include "cmMakefile.h" @@ -64,13 +63,13 @@ bool cmAddSubDirectoryCommand(std::vector const& args, // error. if (!cmSystemTools::IsSubDirectory(srcPath, mf.GetCurrentSourceDirectory())) { - std::ostringstream e; - e << "not given a binary directory but the given source directory " - << "\"" << srcPath << "\" is not a subdirectory of \"" - << mf.GetCurrentSourceDirectory() << "\". " - << "When specifying an out-of-tree source a binary directory " - << "must be explicitly specified."; - status.SetError(e.str()); + status.SetError( + cmStrCat("not given a binary directory but the given source ", + "directory \"", srcPath, "\" is not a subdirectory of \"", + mf.GetCurrentSourceDirectory(), + "\". When specifying an " + "out-of-tree source a binary directory must be explicitly " + "specified.")); return false; } diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx index 7904bf5..8942113 100644 --- a/Source/cmAddTestCommand.cxx +++ b/Source/cmAddTestCommand.cxx @@ -2,10 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmAddTestCommand.h" -#include - #include "cmExecutionStatus.h" #include "cmMakefile.h" +#include "cmStringAlgorithms.h" #include "cmTest.h" #include "cmTestGenerator.h" @@ -38,10 +37,8 @@ bool cmAddTestCommand(std::vector const& args, // If the test was already added by a new-style signature do not // allow it to be duplicated. if (!test->GetOldStyle()) { - std::ostringstream e; - e << " given test name \"" << args[0] - << "\" which already exists in this directory."; - status.SetError(e.str()); + status.SetError(cmStrCat(" given test name \"", args[0], + "\" which already exists in this directory.")); return false; } } else { @@ -110,9 +107,7 @@ bool cmAddTestCommandHandleNameMode(std::vector const& args, working_directory = args[i]; doing = DoingNone; } else { - std::ostringstream e; - e << " given unknown argument:\n " << args[i] << "\n"; - status.SetError(e.str()); + status.SetError(cmStrCat(" given unknown argument:\n ", args[i], "\n")); return false; } } @@ -133,10 +128,8 @@ bool cmAddTestCommandHandleNameMode(std::vector const& args, // Require a unique test name within the directory. if (mf.GetTest(name)) { - std::ostringstream e; - e << " given test NAME \"" << name - << "\" which already exists in this directory."; - status.SetError(e.str()); + status.SetError(cmStrCat(" given test NAME \"", name, + "\" which already exists in this directory.")); return false; } diff --git a/Source/cmCMakePolicyCommand.cxx b/Source/cmCMakePolicyCommand.cxx index 9b1aea9..b7f08d2 100644 --- a/Source/cmCMakePolicyCommand.cxx +++ b/Source/cmCMakePolicyCommand.cxx @@ -2,14 +2,13 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCMakePolicyCommand.h" -#include - #include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmMessageType.h" #include "cmPolicies.h" #include "cmState.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" namespace { bool HandleSetMode(std::vector const& args, @@ -60,9 +59,7 @@ bool cmCMakePolicyCommand(std::vector const& args, return HandleGetWarningMode(args, status); } - std::ostringstream e; - e << "given unknown first argument \"" << args[0] << "\""; - status.SetError(e.str()); + status.SetError(cmStrCat("given unknown first argument \"", args[0], "\"")); return false; } @@ -82,9 +79,8 @@ bool HandleSetMode(std::vector const& args, } else if (args[2] == "NEW") { policyStatus = cmPolicies::NEW; } else { - std::ostringstream e; - e << "SET given unrecognized policy status \"" << args[2] << "\""; - status.SetError(e.str()); + status.SetError( + cmStrCat("SET given unrecognized policy status \"", args[2], "\"")); return false; } @@ -128,10 +124,9 @@ bool HandleGetMode(std::vector const& args, // Lookup the policy number. cmPolicies::PolicyID pid; if (!cmPolicies::GetPolicyID(id.c_str(), pid)) { - std::ostringstream e; - e << "GET given policy \"" << id << "\" which is not known to this " - << "version of CMake."; - status.SetError(e.str()); + status.SetError( + cmStrCat("GET given policy \"", id, + "\" which is not known to this version of CMake.")); return false; } @@ -155,12 +150,14 @@ bool HandleGetMode(std::vector const& args, case cmPolicies::REQUIRED_ALWAYS: // The policy is required to be set before anything needs it. { - std::ostringstream e; - e << cmPolicies::GetRequiredPolicyError(pid) << "\n" - << "The call to cmake_policy(GET " << id << " ...) at which this " - << "error appears requests the policy, and this version of CMake " - << "requires that the policy be set to NEW before it is checked."; - status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str()); + status.GetMakefile().IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat( + cmPolicies::GetRequiredPolicyError(pid), "\n", + "The call to cmake_policy(GET ", id, + " ...) at which this " + "error appears requests the policy, and this version of CMake ", + "requires that the policy be set to NEW before it is checked.")); } } @@ -188,10 +185,9 @@ bool HandleVersionMode(std::vector const& args, : std::string(); if (dd != std::string::npos && (version_min.empty() || version_max.empty())) { - std::ostringstream e; - e << "VERSION \"" << version_string - << R"(" does not have a version on both sides of "...".)"; - status.SetError(e.str()); + status.SetError( + cmStrCat("VERSION \"", version_string, + R"(" does not have a version on both sides of "...".)")); return false; } @@ -215,10 +211,9 @@ bool HandleGetWarningMode(std::vector const& args, // Lookup the policy number. cmPolicies::PolicyID pid; if (!cmPolicies::GetPolicyID(id.c_str(), pid)) { - std::ostringstream e; - e << "GET_WARNING given policy \"" << id - << "\" which is not known to this version of CMake."; - status.SetError(e.str()); + status.SetError( + cmStrCat("GET_WARNING given policy \"", id, + "\" which is not known to this version of CMake.")); return false; } diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx index 7e37f32..8767386 100644 --- a/Source/cmConfigureFileCommand.cxx +++ b/Source/cmConfigureFileCommand.cxx @@ -2,8 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmConfigureFileCommand.h" -#include - #include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -26,13 +24,9 @@ bool cmConfigureFileCommand(std::vector const& args, // If the input location is a directory, error out. if (cmSystemTools::FileIsDirectory(inputFile)) { - std::ostringstream e; - /* clang-format off */ - e << "input location\n" - << " " << inputFile << "\n" - << "is a directory but a file was expected."; - /* clang-format on */ - status.SetError(e.str()); + status.SetError(cmStrCat("input location\n ", inputFile, + "\n" + "is a directory but a file was expected.")); return false; } diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 33acd05..4701d29 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -274,9 +274,8 @@ bool HandleHashCommand(std::vector const& args, { #if !defined(CMAKE_BOOTSTRAP) if (args.size() != 3) { - std::ostringstream e; - e << args[0] << " requires a file name and output variable"; - status.SetError(e.str()); + status.SetError( + cmStrCat(args[0], " requires a file name and output variable")); return false; } @@ -287,16 +286,12 @@ bool HandleHashCommand(std::vector const& args, status.GetMakefile().AddDefinition(args[2], out); return true; } - std::ostringstream e; - e << args[0] << " failed to read file \"" << args[1] - << "\": " << cmSystemTools::GetLastSystemError(); - status.SetError(e.str()); + status.SetError(cmStrCat(args[0], " failed to read file \"", args[1], + "\": ", cmSystemTools::GetLastSystemError())); } return false; #else - std::ostringstream e; - e << args[0] << " not available during bootstrap"; - status.SetError(e.str()); + status.SetError(cmStrCat(args[0], " not available during bootstrap")); return false; #endif } @@ -376,30 +371,24 @@ bool HandleStringsCommand(std::vector const& args, } else if (arg_mode == arg_limit_input) { if (sscanf(args[i].c_str(), "%d", &limit_input) != 1 || limit_input < 0) { - std::ostringstream e; - e << "STRINGS option LIMIT_INPUT value \"" << args[i] - << "\" is not an unsigned integer."; - status.SetError(e.str()); + status.SetError(cmStrCat("STRINGS option LIMIT_INPUT value \"", + args[i], "\" is not an unsigned integer.")); return false; } arg_mode = arg_none; } else if (arg_mode == arg_limit_output) { if (sscanf(args[i].c_str(), "%d", &limit_output) != 1 || limit_output < 0) { - std::ostringstream e; - e << "STRINGS option LIMIT_OUTPUT value \"" << args[i] - << "\" is not an unsigned integer."; - status.SetError(e.str()); + status.SetError(cmStrCat("STRINGS option LIMIT_OUTPUT value \"", + args[i], "\" is not an unsigned integer.")); return false; } arg_mode = arg_none; } else if (arg_mode == arg_limit_count) { int count; if (sscanf(args[i].c_str(), "%d", &count) != 1 || count < 0) { - std::ostringstream e; - e << "STRINGS option LIMIT_COUNT value \"" << args[i] - << "\" is not an unsigned integer."; - status.SetError(e.str()); + status.SetError(cmStrCat("STRINGS option LIMIT_COUNT value \"", + args[i], "\" is not an unsigned integer.")); return false; } limit_count = count; @@ -407,10 +396,8 @@ bool HandleStringsCommand(std::vector const& args, } else if (arg_mode == arg_length_minimum) { int len; if (sscanf(args[i].c_str(), "%d", &len) != 1 || len < 0) { - std::ostringstream e; - e << "STRINGS option LENGTH_MINIMUM value \"" << args[i] - << "\" is not an unsigned integer."; - status.SetError(e.str()); + status.SetError(cmStrCat("STRINGS option LENGTH_MINIMUM value \"", + args[i], "\" is not an unsigned integer.")); return false; } minlen = len; @@ -418,20 +405,16 @@ bool HandleStringsCommand(std::vector const& args, } else if (arg_mode == arg_length_maximum) { int len; if (sscanf(args[i].c_str(), "%d", &len) != 1 || len < 0) { - std::ostringstream e; - e << "STRINGS option LENGTH_MAXIMUM value \"" << args[i] - << "\" is not an unsigned integer."; - status.SetError(e.str()); + status.SetError(cmStrCat("STRINGS option LENGTH_MAXIMUM value \"", + args[i], "\" is not an unsigned integer.")); return false; } maxlen = len; arg_mode = arg_none; } else if (arg_mode == arg_regex) { if (!regex.compile(args[i])) { - std::ostringstream e; - e << "STRINGS option REGEX value \"" << args[i] - << "\" could not be compiled."; - status.SetError(e.str()); + status.SetError(cmStrCat("STRINGS option REGEX value \"", args[i], + "\" could not be compiled.")); return false; } have_regex = true; @@ -448,16 +431,14 @@ bool HandleStringsCommand(std::vector const& args, } else if (args[i] == "UTF-32BE") { encoding = encoding_utf32be; } else { - std::ostringstream e; - e << "STRINGS option ENCODING \"" << args[i] << "\" not recognized."; - status.SetError(e.str()); + status.SetError(cmStrCat("STRINGS option ENCODING \"", args[i], + "\" not recognized.")); return false; } arg_mode = arg_none; } else { - std::ostringstream e; - e << "STRINGS given unknown argument \"" << args[i] << "\""; - status.SetError(e.str()); + status.SetError( + cmStrCat("STRINGS given unknown argument \"", args[i], "\"")); return false; } } @@ -479,9 +460,8 @@ bool HandleStringsCommand(std::vector const& args, cmsys::ifstream fin(fileName.c_str()); #endif if (!fin) { - std::ostringstream e; - e << "STRINGS file \"" << fileName << "\" cannot be read."; - status.SetError(e.str()); + status.SetError( + cmStrCat("STRINGS file \"", fileName, "\" cannot be read.")); return false; } @@ -963,9 +943,7 @@ bool HandleDifferentCommand(std::vector const& args, file_rhs = args[i].c_str(); doing = DoingNone; } else { - std::ostringstream e; - e << "DIFFERENT given unknown argument " << args[i]; - status.SetError(e.str()); + status.SetError(cmStrCat("DIFFERENT given unknown argument ", args[i])); return false; } } @@ -1027,9 +1005,8 @@ bool HandleRPathChangeCommand(std::vector const& args, newRPath = args[i].c_str(); doing = DoingNone; } else { - std::ostringstream e; - e << "RPATH_CHANGE given unknown argument " << args[i]; - status.SetError(e.str()); + status.SetError( + cmStrCat("RPATH_CHANGE given unknown argument ", args[i])); return false; } } @@ -1046,9 +1023,8 @@ bool HandleRPathChangeCommand(std::vector const& args, return false; } if (!cmSystemTools::FileExists(file, true)) { - std::ostringstream e; - e << "RPATH_CHANGE given FILE \"" << file << "\" that does not exist."; - status.SetError(e.str()); + status.SetError( + cmStrCat("RPATH_CHANGE given FILE \"", file, "\" that does not exist.")); return false; } bool success = true; @@ -1058,15 +1034,9 @@ bool HandleRPathChangeCommand(std::vector const& args, if (!cmSystemTools::ChangeRPath(file, oldRPath, newRPath, removeEnvironmentRPath, &emsg, &changed)) { - std::ostringstream e; - /* clang-format off */ - e << "RPATH_CHANGE could not write new RPATH:\n" - << " " << newRPath << "\n" - << "to the file:\n" - << " " << file << "\n" - << emsg; - /* clang-format on */ - status.SetError(e.str()); + status.SetError(cmStrCat("RPATH_CHANGE could not write new RPATH:\n ", + newRPath, "\nto the file:\n ", file, "\n", + emsg)); success = false; } if (success) { @@ -1098,9 +1068,8 @@ bool HandleRPathRemoveCommand(std::vector const& args, file = args[i]; doing = DoingNone; } else { - std::ostringstream e; - e << "RPATH_REMOVE given unknown argument " << args[i]; - status.SetError(e.str()); + status.SetError( + cmStrCat("RPATH_REMOVE given unknown argument ", args[i])); return false; } } @@ -1109,9 +1078,8 @@ bool HandleRPathRemoveCommand(std::vector const& args, return false; } if (!cmSystemTools::FileExists(file, true)) { - std::ostringstream e; - e << "RPATH_REMOVE given FILE \"" << file << "\" that does not exist."; - status.SetError(e.str()); + status.SetError( + cmStrCat("RPATH_REMOVE given FILE \"", file, "\" that does not exist.")); return false; } bool success = true; @@ -1119,13 +1087,9 @@ bool HandleRPathRemoveCommand(std::vector const& args, std::string emsg; bool removed; if (!cmSystemTools::RemoveRPath(file, &emsg, &removed)) { - std::ostringstream e; - /* clang-format off */ - e << "RPATH_REMOVE could not remove RPATH from file:\n" - << " " << file << "\n" - << emsg; - /* clang-format on */ - status.SetError(e.str()); + status.SetError( + cmStrCat("RPATH_REMOVE could not remove RPATH from file: \n ", file, + "\n", emsg)); success = false; } if (success) { @@ -1164,9 +1128,8 @@ bool HandleRPathCheckCommand(std::vector const& args, rpath = args[i].c_str(); doing = DoingNone; } else { - std::ostringstream e; - e << "RPATH_CHECK given unknown argument " << args[i]; - status.SetError(e.str()); + status.SetError( + cmStrCat("RPATH_CHECK given unknown argument ", args[i])); return false; } } @@ -1215,9 +1178,8 @@ bool HandleReadElfCommand(std::vector const& args, Arguments const arguments = parser.Parse(cmMakeRange(args).advance(2)); if (!cmSystemTools::FileExists(fileNameArg, true)) { - std::ostringstream e; - e << "READ_ELF given FILE \"" << fileNameArg << "\" that does not exist."; - status.SetError(e.str()); + status.SetError(cmStrCat("READ_ELF given FILE \"", fileNameArg, + "\" that does not exist.")); return false; } @@ -1311,15 +1273,8 @@ bool HandleRename(std::vector const& args, if (!cmSystemTools::RenameFile(oldname, newname)) { std::string err = cmSystemTools::GetLastSystemError(); - std::ostringstream e; - /* clang-format off */ - e << "RENAME failed to rename\n" - << " " << oldname << "\n" - << "to\n" - << " " << newname << "\n" - << "because: " << err << "\n"; - /* clang-format on */ - status.SetError(e.str()); + status.SetError(cmStrCat("RENAME failed to rename\n ", oldname, + "\nto\n ", newname, "\nbecause: ", err, "\n")); return false; } return true; @@ -1494,10 +1449,8 @@ public: bool updated = (OldPercentage != this->CurrentPercentage); if (updated) { - std::ostringstream oss; - oss << "[" << this->Text << " " << this->CurrentPercentage - << "% complete]"; - status = oss.str(); + status = + cmStrCat("[", this->Text, " ", this->CurrentPercentage, "% complete]"); } return updated; @@ -1743,9 +1696,7 @@ bool HandleDownloadCommand(std::vector const& args, msg = cmStrCat("returning early; file already exists with expected ", hashMatchMSG, '"'); if (!statusVar.empty()) { - std::ostringstream result; - result << 0 << ";\"" << msg; - status.GetMakefile().AddDefinition(statusVar, result.str()); + status.GetMakefile().AddDefinition(statusVar, cmStrCat(0, ";\"", msg)); } return true; } @@ -1891,10 +1842,9 @@ bool HandleDownloadCommand(std::vector const& args, ::curl_easy_cleanup(curl); if (!statusVar.empty()) { - std::ostringstream result; - result << static_cast(res) << ";\"" << ::curl_easy_strerror(res) - << "\""; - status.GetMakefile().AddDefinition(statusVar, result.str()); + status.GetMakefile().AddDefinition( + statusVar, + cmStrCat(static_cast(res), ";\"", ::curl_easy_strerror(res), "\"")); } ::curl_global_cleanup(); @@ -1914,14 +1864,6 @@ bool HandleDownloadCommand(std::vector const& args, } if (expectedHash != actualHash) { - std::ostringstream oss; - oss << "DOWNLOAD HASH mismatch" << std::endl - << " for file: [" << file << "]" << std::endl - << " expected hash: [" << expectedHash << "]" << std::endl - << " actual hash: [" << actualHash << "]" << std::endl - << " status: [" << static_cast(res) << ";\"" - << ::curl_easy_strerror(res) << "\"]" << std::endl; - if (!statusVar.empty() && res == 0) { status.GetMakefile().AddDefinition(statusVar, "1;HASH mismatch: " @@ -1930,7 +1872,19 @@ bool HandleDownloadCommand(std::vector const& args, " actual: " + actualHash); } - status.SetError(oss.str()); + status.SetError(cmStrCat("DOWNLOAD HASH mismatch\n" + " for file: [", + file, + "]\n" + " expected hash: [", + expectedHash, + "]\n" + " actual hash: [", + actualHash, + "]\n" + " status: [", + static_cast(res), ";\"", + ::curl_easy_strerror(res), "\"]\n")); return false; } } @@ -2180,10 +2134,9 @@ bool HandleUploadCommand(std::vector const& args, ::curl_easy_cleanup(curl); if (!statusVar.empty()) { - std::ostringstream result; - result << static_cast(res) << ";\"" << ::curl_easy_strerror(res) - << "\""; - status.GetMakefile().AddDefinition(statusVar, result.str()); + status.GetMakefile().AddDefinition( + statusVar, + cmStrCat(static_cast(res), ";\"", ::curl_easy_strerror(res), "\"")); } ::curl_global_cleanup(); @@ -2322,9 +2275,9 @@ bool HandleLockCommand(std::vector const& args, } else if (args[i] == "PROCESS") { guard = GUARD_PROCESS; } else { - std::ostringstream e; - e << merr << ", but got:\n \"" << args[i] << "\"."; - status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str()); + status.GetMakefile().IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat(merr, ", but got:\n \"", args[i], "\".")); return false; } @@ -2346,17 +2299,18 @@ bool HandleLockCommand(std::vector const& args, } long scanned; if (!cmStrToLong(args[i], &scanned) || scanned < 0) { - std::ostringstream e; - e << "TIMEOUT value \"" << args[i] << "\" is not an unsigned integer."; - status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str()); + status.GetMakefile().IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("TIMEOUT value \"", args[i], + "\" is not an unsigned integer.")); return false; } timeout = static_cast(scanned); } else { - std::ostringstream e; - e << "expected DIRECTORY, RELEASE, GUARD, RESULT_VARIABLE or TIMEOUT\n"; - e << "but got: \"" << args[i] << "\"."; - status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str()); + status.GetMakefile().IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("expected DIRECTORY, RELEASE, GUARD, RESULT_VARIABLE or ", + "TIMEOUT\nbut got: \"", args[i], "\".")); return false; } } @@ -2375,18 +2329,19 @@ bool HandleLockCommand(std::vector const& args, // Create file and directories if needed std::string parentDir = cmSystemTools::GetParentDirectory(path); if (!cmSystemTools::MakeDirectory(parentDir)) { - std::ostringstream e; - e << "directory\n \"" << parentDir << "\"\ncreation failed "; - e << "(check permissions)."; - status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str()); + status.GetMakefile().IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("directory\n \"", parentDir, + "\"\ncreation failed (check permissions).")); cmSystemTools::SetFatalErrorOccured(); return false; } FILE* file = cmsys::SystemTools::Fopen(path, "w"); if (!file) { - std::ostringstream e; - e << "file\n \"" << path << "\"\ncreation failed (check permissions)."; - status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str()); + status.GetMakefile().IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("file\n \"", path, + "\"\ncreation failed (check permissions).")); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -2419,9 +2374,9 @@ bool HandleLockCommand(std::vector const& args, const std::string result = fileLockResult.GetOutputMessage(); if (resultVariable.empty() && !fileLockResult.IsOk()) { - std::ostringstream e; - e << "error locking file\n \"" << path << "\"\n" << result << "."; - status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str()); + status.GetMakefile().IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("error locking file\n \"", path, "\"\n", result, ".")); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -2485,9 +2440,8 @@ bool HandleSizeCommand(std::vector const& args, cmExecutionStatus& status) { if (args.size() != 3) { - std::ostringstream e; - e << args[0] << " requires a file name and output variable"; - status.SetError(e.str()); + status.SetError( + cmStrCat(args[0], " requires a file name and output variable")); return false; } @@ -2498,9 +2452,8 @@ bool HandleSizeCommand(std::vector const& args, const std::string& outputVariable = args[argsIndex++]; if (!cmSystemTools::FileExists(filename, true)) { - std::ostringstream e; - e << "SIZE requested of path that is not readable:\n " << filename; - status.SetError(e.str()); + status.SetError( + cmStrCat("SIZE requested of path that is not readable:\n ", filename)); return false; } @@ -2514,9 +2467,8 @@ bool HandleReadSymlinkCommand(std::vector const& args, cmExecutionStatus& status) { if (args.size() != 3) { - std::ostringstream e; - e << args[0] << " requires a file name and output variable"; - status.SetError(e.str()); + status.SetError( + cmStrCat(args[0], " requires a file name and output variable")); return false; } @@ -2525,10 +2477,8 @@ bool HandleReadSymlinkCommand(std::vector const& args, std::string result; if (!cmSystemTools::ReadSymlink(filename, result)) { - std::ostringstream e; - e << "READ_SYMLINK requested of path that is not a symlink:\n " - << filename; - status.SetError(e.str()); + status.SetError(cmStrCat( + "READ_SYMLINK requested of path that is not a symlink:\n ", filename)); return false; } @@ -2655,10 +2605,9 @@ bool HandleGetRuntimeDependenciesCommand(std::vector const& args, std::string platform = status.GetMakefile().GetSafeDefinition("CMAKE_HOST_SYSTEM_NAME"); if (!supportedPlatforms.count(platform)) { - std::ostringstream e; - e << "GET_RUNTIME_DEPENDENCIES is not supported on system \"" << platform - << "\""; - status.SetError(e.str()); + status.SetError( + cmStrCat("GET_RUNTIME_DEPENDENCIES is not supported on system \"", + platform, "\"")); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -2718,17 +2667,13 @@ bool HandleGetRuntimeDependenciesCommand(std::vector const& args, &keywordsMissingValues); auto argIt = unrecognizedArguments.begin(); if (argIt != unrecognizedArguments.end()) { - std::ostringstream e; - e << "Unrecognized argument: \"" << *argIt << "\""; - status.SetError(e.str()); + status.SetError(cmStrCat("Unrecognized argument: \"", *argIt, "\"")); cmSystemTools::SetFatalErrorOccured(); return false; } argIt = keywordsMissingValues.begin(); if (argIt != keywordsMissingValues.end()) { - std::ostringstream e; - e << "Keyword missing value: " << *argIt; - status.SetError(e.str()); + status.SetError(cmStrCat("Keyword missing value: ", *argIt)); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -2792,9 +2737,7 @@ bool HandleGetRuntimeDependenciesCommand(std::vector const& args, } else { auto it = archive.GetUnresolvedPaths().begin(); assert(it != archive.GetUnresolvedPaths().end()); - std::ostringstream e; - e << "Could not resolve file " << *it; - status.SetError(e.str()); + status.SetError(cmStrCat("Could not resolve file ", *it)); cmSystemTools::SetFatalErrorOccured(); return false; } diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 8c8cf13..fea7e08 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -348,11 +348,10 @@ bool cmFindPackageCommand::InitialPass(std::vector const& args) } else if (doing == DoingConfigs) { if (args[i].find_first_of(":/\\") != std::string::npos || cmSystemTools::GetFilenameLastExtension(args[i]) != ".cmake") { - std::ostringstream e; - e << "given CONFIGS option followed by invalid file name \"" << args[i] - << "\". The names given must be file names without " - << "a path and with a \".cmake\" extension."; - this->SetError(e.str()); + this->SetError(cmStrCat( + "given CONFIGS option followed by invalid file name \"", args[i], + "\". The names given must be file names without " + "a path and with a \".cmake\" extension.")); return false; } this->Configs.push_back(args[i]); @@ -360,9 +359,8 @@ bool cmFindPackageCommand::InitialPass(std::vector const& args) haveVersion = true; this->Version = args[i]; } else { - std::ostringstream e; - e << "called with invalid argument \"" << args[i] << "\""; - this->SetError(e.str()); + this->SetError( + cmStrCat("called with invalid argument \"", args[i], "\"")); return false; } } @@ -372,10 +370,10 @@ bool cmFindPackageCommand::InitialPass(std::vector const& args) optionalComponents.begin(), optionalComponents.end(), std::back_inserter(doubledComponents)); if (!doubledComponents.empty()) { - std::ostringstream e; - e << "called with components that are both required and optional:\n"; - e << cmWrap(" ", doubledComponents, "", "\n") << "\n"; - this->SetError(e.str()); + this->SetError( + cmStrCat("called with components that are both required and " + "optional:\n", + cmWrap(" ", doubledComponents, "", "\n"), "\n")); return false; } @@ -459,11 +457,10 @@ bool cmFindPackageCommand::InitialPass(std::vector const& args) cmStrCat("CMAKE_DISABLE_FIND_PACKAGE_", this->Name); if (this->Makefile->IsOn(disableFindPackageVar)) { if (this->Required) { - std::ostringstream e; - e << "for module " << this->Name << " called with REQUIRED, but " - << disableFindPackageVar - << " is enabled. A REQUIRED package cannot be disabled."; - this->SetError(e.str()); + this->SetError( + cmStrCat("for module ", this->Name, " called with REQUIRED, but ", + disableFindPackageVar, + " is enabled. A REQUIRED package cannot be disabled.")); return false; } @@ -701,9 +698,9 @@ bool cmFindPackageCommand::FindModule(bool& found) this->Makefile->GetPolicyStatus(it->second); switch (status) { case cmPolicies::WARN: { - std::ostringstream e; - e << cmPolicies::GetPolicyWarning(it->second) << "\n"; - this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, e.str()); + this->Makefile->IssueMessage( + MessageType::AUTHOR_WARNING, + cmStrCat(cmPolicies::GetPolicyWarning(it->second), "\n")); CM_FALLTHROUGH; } case cmPolicies::OLD: @@ -934,10 +931,10 @@ bool cmFindPackageCommand::HandlePackageMode( } // output result if in config mode but not in quiet mode else if (!this->Quiet) { - std::ostringstream aw; - aw << "Could NOT find " << this->Name << " (missing: " << this->Name - << "_DIR)"; - this->Makefile->DisplayStatus(aw.str(), -1); + this->Makefile->DisplayStatus(cmStrCat("Could NOT find ", this->Name, + " (missing: ", this->Name, + "_DIR)"), + -1); } } diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index 3c39c46..d563a1d 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -4,7 +4,6 @@ #include #include -#include #include #include "cm_memory.hxx" @@ -146,10 +145,9 @@ bool cmForEachCommand(std::vector const& args, } if ((start > stop && step > 0) || (start < stop && step < 0) || step == 0) { - std::ostringstream str; - str << "called with incorrect range specification: start "; - str << start << ", stop " << stop << ", step " << step; - status.SetError(str.str()); + status.SetError( + cmStrCat("called with incorrect range specification: start ", start, + ", stop ", stop, ", step ", step)); return false; } std::vector range; @@ -204,10 +202,9 @@ bool HandleInMode(std::vector const& args, cmMakefile& makefile) cmExpandList(value, fb->Args, true); } } else { - std::ostringstream e; - e << "Unknown argument:\n" - << " " << args[i] << "\n"; - makefile.IssueMessage(MessageType::FATAL_ERROR, e.str()); + makefile.IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Unknown argument:\n", " ", args[i], "\n")); return true; } } diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index e8e87e7..947d893 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -2,8 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGetPropertyCommand.h" -#include - #include "cmExecutionStatus.h" #include "cmGlobalGenerator.h" #include "cmInstalledFile.h" @@ -99,11 +97,11 @@ bool cmGetPropertyCommand(std::vector const& args, } else if (args[1] == "INSTALL") { scope = cmProperty::INSTALL; } else { - std::ostringstream e; - e << "given invalid scope " << args[1] << ". " - << "Valid scopes are " - << "GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, VARIABLE, CACHE, INSTALL."; - status.SetError(e.str()); + status.SetError(cmStrCat( + "given invalid scope ", args[1], + ". " + "Valid scopes are " + "GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, VARIABLE, CACHE, INSTALL.")); return false; } @@ -138,9 +136,7 @@ bool cmGetPropertyCommand(std::vector const& args, doing = DoingNone; propertyName = args[i]; } else { - std::ostringstream e; - e << "given invalid argument \"" << args[i] << "\"."; - status.SetError(e.str()); + status.SetError(cmStrCat("given invalid argument \"", args[i], "\".")); return false; } } @@ -331,10 +327,8 @@ bool HandleTargetMode(cmExecutionStatus& status, const std::string& name, } return StoreResult(infoType, status.GetMakefile(), variable, prop_cstr); } - std::ostringstream e; - e << "could not find TARGET " << name - << ". Perhaps it has not yet been created."; - status.SetError(e.str()); + status.SetError(cmStrCat("could not find TARGET ", name, + ". Perhaps it has not yet been created.")); return false; } @@ -352,9 +346,8 @@ bool HandleSourceMode(cmExecutionStatus& status, const std::string& name, return StoreResult(infoType, status.GetMakefile(), variable, sf->GetPropertyForUser(propertyName)); } - std::ostringstream e; - e << "given SOURCE name that could not be found or created: " << name; - status.SetError(e.str()); + status.SetError( + cmStrCat("given SOURCE name that could not be found or created: ", name)); return false; } @@ -374,9 +367,7 @@ bool HandleTestMode(cmExecutionStatus& status, const std::string& name, } // If not found it is an error. - std::ostringstream e; - e << "given TEST name that does not exist: " << name; - status.SetError(e.str()); + status.SetError(cmStrCat("given TEST name that does not exist: ", name)); return false; } @@ -431,9 +422,8 @@ bool HandleInstallMode(cmExecutionStatus& status, const std::string& name, return StoreResult(infoType, status.GetMakefile(), variable, isSet ? value.c_str() : nullptr); } - std::ostringstream e; - e << "given INSTALL name that could not be found or created: " << name; - status.SetError(e.str()); + status.SetError( + cmStrCat("given INSTALL name that could not be found or created: ", name)); return false; } } diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 9b931f7..e7bb1ac 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -293,9 +293,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) if (!unknownArgs.empty()) { // Unknown argument. - std::ostringstream e; - e << "TARGETS given unknown argument \"" << unknownArgs[0] << "\"."; - this->SetError(e.str()); + this->SetError( + cmStrCat("TARGETS given unknown argument \"", unknownArgs[0], "\".")); return false; } @@ -391,9 +390,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) for (std::string const& tgt : targetList) { if (this->Makefile->IsAlias(tgt)) { - std::ostringstream e; - e << "TARGETS given target \"" << tgt << "\" which is an alias."; - this->SetError(e.str()); + this->SetError( + cmStrCat("TARGETS given target \"", tgt, "\" which is an alias.")); return false; } // Lookup this target in the current directory. @@ -414,19 +412,17 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) target->GetType() != cmStateEnums::MODULE_LIBRARY && target->GetType() != cmStateEnums::OBJECT_LIBRARY && target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { - std::ostringstream e; - e << "TARGETS given target \"" << tgt - << "\" which is not an executable, library, or module."; - this->SetError(e.str()); + this->SetError( + cmStrCat("TARGETS given target \"", tgt, + "\" which is not an executable, library, or module.")); return false; } // Store the target in the list to be installed. targets.push_back(target); } else { // Did not find the target. - std::ostringstream e; - e << "TARGETS given target \"" << tgt << "\" which does not exist."; - this->SetError(e.str()); + this->SetError( + cmStrCat("TARGETS given target \"", tgt, "\" which does not exist.")); return false; } } @@ -507,11 +503,10 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) frameworkGenerator = CreateInstallTargetGenerator( target, frameworkArgs, false, this->Makefile->GetBacktrace()); } else { - std::ostringstream e; - e << "TARGETS given no FRAMEWORK DESTINATION for shared library " - "FRAMEWORK target \"" - << target.GetName() << "\"."; - this->SetError(e.str()); + this->SetError( + cmStrCat("TARGETS given no FRAMEWORK DESTINATION for shared " + "library FRAMEWORK target \"", + target.GetName(), "\".")); return false; } } else { @@ -549,11 +544,11 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) frameworkGenerator = CreateInstallTargetGenerator( target, frameworkArgs, false, this->Makefile->GetBacktrace()); } else { - std::ostringstream e; - e << "TARGETS given no FRAMEWORK DESTINATION for static library " - "FRAMEWORK target \"" - << target.GetName() << "\"."; - this->SetError(e.str()); + this->SetError( + cmStrCat("TARGETS given no FRAMEWORK DESTINATION for static " + "library FRAMEWORK target \"", + target.GetName(), "\".")); + return false; } } else { @@ -572,10 +567,10 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) namelinkOnly = (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly); } else { - std::ostringstream e; - e << "TARGETS given no LIBRARY DESTINATION for module target \"" - << target.GetName() << "\"."; - this->SetError(e.str()); + this->SetError( + cmStrCat("TARGETS given no LIBRARY DESTINATION for module " + "target \"", + target.GetName(), "\".")); return false; } } break; @@ -586,10 +581,9 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) std::string reason; if (!this->Makefile->GetGlobalGenerator() ->HasKnownObjectFileLocation(&reason)) { - std::ostringstream e; - e << "TARGETS given OBJECT library \"" << target.GetName() - << "\" whose objects may not be installed" << reason << "."; - this->SetError(e.str()); + this->SetError( + cmStrCat("TARGETS given OBJECT library \"", target.GetName(), + "\" whose objects may not be installed", reason, ".")); return false; } @@ -619,11 +613,9 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) } } if (!bundleGenerator) { - std::ostringstream e; - e << "TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE " - "executable target \"" - << target.GetName() << "\"."; - this->SetError(e.str()); + this->SetError(cmStrCat("TARGETS given no BUNDLE DESTINATION for " + "MACOSX_BUNDLE executable target \"", + target.GetName(), "\".")); return false; } } else { @@ -708,10 +700,10 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) resourceGenerator = CreateInstallFilesGenerator( this->Makefile, absFiles, resourceArgs, false); } else { - std::ostringstream e; - e << "INSTALL TARGETS - target " << target.GetName() << " has " - << "RESOURCE files but no RESOURCE DESTINATION."; - cmSystemTools::Message(e.str(), "Warning"); + cmSystemTools::Message( + cmStrCat("INSTALL TARGETS - target ", target.GetName(), + " has RESOURCE files but no RESOURCE DESTINATION."), + "Warning"); } } } @@ -820,17 +812,15 @@ bool cmInstallCommand::HandleFilesMode(std::vector const& args) if (!unknownArgs.empty()) { // Unknown argument. - std::ostringstream e; - e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\"."; - this->SetError(e.str()); + this->SetError( + cmStrCat(args[0], " given unknown argument \"", unknownArgs[0], "\".")); return false; } std::string type = ica.GetType(); if (!type.empty() && allowedTypes.count(type) == 0) { - std::ostringstream e; - e << args[0] << " given non-type \"" << type << "\" with TYPE argument."; - this->SetError(e.str()); + this->SetError( + cmStrCat(args[0], " given non-type \"", type, "\" with TYPE argument.")); return false; } @@ -843,9 +833,8 @@ bool cmInstallCommand::HandleFilesMode(std::vector const& args) if (!ica.GetRename().empty() && filesVector.size() > 1) { // The rename option works only with one file. - std::ostringstream e; - e << args[0] << " given RENAME option with more than one file."; - this->SetError(e.str()); + this->SetError( + cmStrCat(args[0], " given RENAME option with more than one file.")); return false; } @@ -897,20 +886,16 @@ bool cmInstallCommand::HandleFilesMode(std::vector const& args) } if (!type.empty() && !ica.GetDestination().empty()) { - std::ostringstream e; - e << args[0] - << " given both TYPE and DESTINATION arguments. You may only specify " - "one."; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], + " given both TYPE and DESTINATION arguments. " + "You may only specify one.")); return false; } std::string destination = this->GetDestinationForType(&ica, type); if (destination.empty()) { // A destination is required. - std::ostringstream e; - e << args[0] << " given no DESTINATION!"; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], " given no DESTINATION!")); return false; } @@ -959,10 +944,8 @@ bool cmInstallCommand::HandleDirectoryMode( for (unsigned int i = 1; i < args.size(); ++i) { if (args[i] == "DESTINATION") { if (in_match_mode) { - std::ostringstream e; - e << args[0] << " does not allow \"" << args[i] - << "\" after PATTERN or REGEX."; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" after PATTERN or REGEX.")); return false; } @@ -970,10 +953,8 @@ bool cmInstallCommand::HandleDirectoryMode( doing = DoingDestination; } else if (args[i] == "TYPE") { if (in_match_mode) { - std::ostringstream e; - e << args[0] << " does not allow \"" << args[i] - << "\" after PATTERN or REGEX."; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" after PATTERN or REGEX.")); return false; } @@ -981,10 +962,8 @@ bool cmInstallCommand::HandleDirectoryMode( doing = DoingType; } else if (args[i] == "OPTIONAL") { if (in_match_mode) { - std::ostringstream e; - e << args[0] << " does not allow \"" << args[i] - << "\" after PATTERN or REGEX."; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" after PATTERN or REGEX.")); return false; } @@ -993,10 +972,8 @@ bool cmInstallCommand::HandleDirectoryMode( doing = DoingNone; } else if (args[i] == "MESSAGE_NEVER") { if (in_match_mode) { - std::ostringstream e; - e << args[0] << " does not allow \"" << args[i] - << "\" after PATTERN or REGEX."; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" after PATTERN or REGEX.")); return false; } @@ -1014,20 +991,16 @@ bool cmInstallCommand::HandleDirectoryMode( } else if (args[i] == "EXCLUDE") { // Add this property to the current match rule. if (!in_match_mode || doing == DoingPattern || doing == DoingRegex) { - std::ostringstream e; - e << args[0] << " does not allow \"" << args[i] - << "\" before a PATTERN or REGEX is given."; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" before a PATTERN or REGEX is given.")); return false; } literal_args += " EXCLUDE"; doing = DoingNone; } else if (args[i] == "PERMISSIONS") { if (!in_match_mode) { - std::ostringstream e; - e << args[0] << " does not allow \"" << args[i] - << "\" before a PATTERN or REGEX is given."; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" before a PATTERN or REGEX is given.")); return false; } @@ -1036,10 +1009,8 @@ bool cmInstallCommand::HandleDirectoryMode( doing = DoingPermsMatch; } else if (args[i] == "FILE_PERMISSIONS") { if (in_match_mode) { - std::ostringstream e; - e << args[0] << " does not allow \"" << args[i] - << "\" after PATTERN or REGEX."; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" after PATTERN or REGEX.")); return false; } @@ -1047,10 +1018,8 @@ bool cmInstallCommand::HandleDirectoryMode( doing = DoingPermsFile; } else if (args[i] == "DIRECTORY_PERMISSIONS") { if (in_match_mode) { - std::ostringstream e; - e << args[0] << " does not allow \"" << args[i] - << "\" after PATTERN or REGEX."; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" after PATTERN or REGEX.")); return false; } @@ -1058,10 +1027,8 @@ bool cmInstallCommand::HandleDirectoryMode( doing = DoingPermsDir; } else if (args[i] == "USE_SOURCE_PERMISSIONS") { if (in_match_mode) { - std::ostringstream e; - e << args[0] << " does not allow \"" << args[i] - << "\" after PATTERN or REGEX."; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" after PATTERN or REGEX.")); return false; } @@ -1070,10 +1037,8 @@ bool cmInstallCommand::HandleDirectoryMode( doing = DoingNone; } else if (args[i] == "FILES_MATCHING") { if (in_match_mode) { - std::ostringstream e; - e << args[0] << " does not allow \"" << args[i] - << "\" after PATTERN or REGEX."; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" after PATTERN or REGEX.")); return false; } @@ -1082,10 +1047,8 @@ bool cmInstallCommand::HandleDirectoryMode( doing = DoingNone; } else if (args[i] == "CONFIGURATIONS") { if (in_match_mode) { - std::ostringstream e; - e << args[0] << " does not allow \"" << args[i] - << "\" after PATTERN or REGEX."; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" after PATTERN or REGEX.")); return false; } @@ -1093,10 +1056,8 @@ bool cmInstallCommand::HandleDirectoryMode( doing = DoingConfigurations; } else if (args[i] == "COMPONENT") { if (in_match_mode) { - std::ostringstream e; - e << args[0] << " does not allow \"" << args[i] - << "\" after PATTERN or REGEX."; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" after PATTERN or REGEX.")); return false; } @@ -1104,10 +1065,8 @@ bool cmInstallCommand::HandleDirectoryMode( doing = DoingComponent; } else if (args[i] == "EXCLUDE_FROM_ALL") { if (in_match_mode) { - std::ostringstream e; - e << args[0] << " does not allow \"" << args[i] - << "\" after PATTERN or REGEX."; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" after PATTERN or REGEX.")); return false; } exclude_from_all = true; @@ -1124,10 +1083,8 @@ bool cmInstallCommand::HandleDirectoryMode( // Make sure the name is a directory. if (cmSystemTools::FileExists(dir) && !cmSystemTools::FileIsDirectory(dir)) { - std::ostringstream e; - e << args[0] << " given non-directory \"" << args[i] - << "\" to install."; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], " given non-directory \"", args[i], + "\" to install.")); return false; } @@ -1140,10 +1097,8 @@ bool cmInstallCommand::HandleDirectoryMode( doing = DoingNone; } else if (doing == DoingType) { if (allowedTypes.count(args[i]) == 0) { - std::ostringstream e; - e << args[0] << " given non-type \"" << args[i] - << "\" with TYPE argument."; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], " given non-type \"", args[i], + "\" with TYPE argument.")); return false; } @@ -1179,36 +1134,30 @@ bool cmInstallCommand::HandleDirectoryMode( // Check the requested permission. if (!cmInstallCommandArguments::CheckPermissions(args[i], permissions_file)) { - std::ostringstream e; - e << args[0] << " given invalid file permission \"" << args[i] - << "\"."; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], " given invalid file permission \"", + args[i], "\".")); return false; } } else if (doing == DoingPermsDir) { // Check the requested permission. if (!cmInstallCommandArguments::CheckPermissions(args[i], permissions_dir)) { - std::ostringstream e; - e << args[0] << " given invalid directory permission \"" << args[i] - << "\"."; - this->SetError(e.str()); + this->SetError(cmStrCat( + args[0], " given invalid directory permission \"", args[i], "\".")); return false; } } else if (doing == DoingPermsMatch) { // Check the requested permission. if (!cmInstallCommandArguments::CheckPermissions(args[i], literal_args)) { - std::ostringstream e; - e << args[0] << " given invalid permission \"" << args[i] << "\"."; - this->SetError(e.str()); + this->SetError( + cmStrCat(args[0], " given invalid permission \"", args[i], "\".")); return false; } } else { // Unknown argument. - std::ostringstream e; - e << args[0] << " given unknown argument \"" << args[i] << "\"."; - this->SetError(e.str()); + this->SetError( + cmStrCat(args[0], " given unknown argument \"", args[i], "\".")); return false; } } @@ -1226,19 +1175,15 @@ bool cmInstallCommand::HandleDirectoryMode( if (!destination) { if (type.empty()) { // A destination is required. - std::ostringstream e; - e << args[0] << " given no DESTINATION!"; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], " given no DESTINATION!")); return false; } destinationStr = this->GetDestinationForType(nullptr, type); destination = destinationStr.c_str(); } else if (!type.empty()) { - std::ostringstream e; - e << args[0] - << " given both TYPE and DESTINATION arguments. You may only specify " - "one."; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], + " given both TYPE and DESTINATION " + "arguments. You may only specify one.")); return false; } @@ -1280,9 +1225,8 @@ bool cmInstallCommand::HandleExportAndroidMKMode( if (!unknownArgs.empty()) { // Unknown argument. - std::ostringstream e; - e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\"."; - this->SetError(e.str()); + this->SetError( + cmStrCat(args[0], " given unknown argument \"", unknownArgs[0], "\".")); return false; } @@ -1293,39 +1237,35 @@ bool cmInstallCommand::HandleExportAndroidMKMode( // Make sure there is a destination. if (ica.GetDestination().empty()) { // A destination is required. - std::ostringstream e; - e << args[0] << " given no DESTINATION!"; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], " given no DESTINATION!")); return false; } // Check the file name. std::string fname = filename; if (fname.find_first_of(":/\\") != std::string::npos) { - std::ostringstream e; - e << args[0] << " given invalid export file name \"" << fname << "\". " - << "The FILE argument may not contain a path. " - << "Specify the path in the DESTINATION argument."; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], " given invalid export file name \"", + fname, + "\". The FILE argument may not contain a path. " + "Specify the path in the DESTINATION argument.")); return false; } // Check the file extension. if (!fname.empty() && cmSystemTools::GetFilenameLastExtension(fname) != ".mk") { - std::ostringstream e; - e << args[0] << " given invalid export file name \"" << fname << "\". " - << "The FILE argument must specify a name ending in \".mk\"."; - this->SetError(e.str()); + this->SetError(cmStrCat( + args[0], " given invalid export file name \"", fname, + R"(". The FILE argument must specify a name ending in ".mk".)")); return false; } if (fname.find_first_of(":/\\") != std::string::npos) { - std::ostringstream e; - e << args[0] << " given export name \"" << exp << "\". " - << "This name cannot be safely converted to a file name. " - << "Specify a different export name or use the FILE option to set " - << "a file name explicitly."; - this->SetError(e.str()); + this->SetError( + cmStrCat(args[0], " given export name \"", exp, + "\". " + "This name cannot be safely converted to a file name. " + "Specify a different export name or use the FILE option to set " + "a file name explicitly.")); return false; } // Use the default name @@ -1375,9 +1315,8 @@ bool cmInstallCommand::HandleExportMode(std::vector const& args) if (!unknownArgs.empty()) { // Unknown argument. - std::ostringstream e; - e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\"."; - this->SetError(e.str()); + this->SetError( + cmStrCat(args[0], " given unknown argument \"", unknownArgs[0], "\".")); return false; } @@ -1388,30 +1327,28 @@ bool cmInstallCommand::HandleExportMode(std::vector const& args) // Make sure there is a destination. if (ica.GetDestination().empty()) { // A destination is required. - std::ostringstream e; - e << args[0] << " given no DESTINATION!"; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], " given no DESTINATION!")); return false; } // Check the file name. std::string fname = filename; if (fname.find_first_of(":/\\") != std::string::npos) { - std::ostringstream e; - e << args[0] << " given invalid export file name \"" << fname << "\". " - << "The FILE argument may not contain a path. " - << "Specify the path in the DESTINATION argument."; - this->SetError(e.str()); + this->SetError(cmStrCat(args[0], " given invalid export file name \"", + fname, + "\". " + "The FILE argument may not contain a path. " + "Specify the path in the DESTINATION argument.")); return false; } // Check the file extension. if (!fname.empty() && cmSystemTools::GetFilenameLastExtension(fname) != ".cmake") { - std::ostringstream e; - e << args[0] << " given invalid export file name \"" << fname << "\". " - << "The FILE argument must specify a name ending in \".cmake\"."; - this->SetError(e.str()); + this->SetError( + cmStrCat(args[0], " given invalid export file name \"", fname, + "\". " + "The FILE argument must specify a name ending in \".cmake\".")); return false; } @@ -1420,12 +1357,12 @@ bool cmInstallCommand::HandleExportMode(std::vector const& args) fname = cmStrCat(exp, ".cmake"); if (fname.find_first_of(":/\\") != std::string::npos) { - std::ostringstream e; - e << args[0] << " given export name \"" << exp << "\". " - << "This name cannot be safely converted to a file name. " - << "Specify a different export name or use the FILE option to set " - << "a file name explicitly."; - this->SetError(e.str()); + this->SetError(cmStrCat( + args[0], " given export name \"", exp, + "\". " + "This name cannot be safely converted to a file name. " + "Specify a different export name or use the FILE option to set " + "a file name explicitly.")); return false; } } @@ -1441,12 +1378,10 @@ bool cmInstallCommand::HandleExportMode(std::vector const& args) tgt->GetPolicyStatusCMP0022() != cmPolicies::OLD); if (!newCMP0022Behavior) { - std::ostringstream e; - e << "INSTALL(EXPORT) given keyword \"" - << "EXPORT_LINK_INTERFACE_LIBRARIES" - << "\", but target \"" << te->TargetName - << "\" does not have policy CMP0022 set to NEW."; - this->SetError(e.str()); + this->SetError(cmStrCat( + "INSTALL(EXPORT) given keyword \"" + "EXPORT_LINK_INTERFACE_LIBRARIES\", but target \"", + te->TargetName, "\" does not have policy CMP0022 set to NEW.")); return false; } } @@ -1480,9 +1415,8 @@ bool cmInstallCommand::MakeFilesFullPath( // Make sure the file is not a directory. if (gpos == std::string::npos && cmSystemTools::FileIsDirectory(file)) { - std::ostringstream e; - e << modeName << " given directory \"" << relFile << "\" to install."; - this->SetError(e.str()); + this->SetError( + cmStrCat(modeName, " given directory \"", relFile, "\" to install.")); return false; } // Store the file for installation. diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 9487e3b..826abf5 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -158,10 +158,8 @@ bool HandleGetCommand(std::vector const& args, item = static_cast(nitem) + item; } if (item < 0 || nitem <= static_cast(item)) { - std::ostringstream str; - str << "index: " << item << " out of range (-" << nitem << ", " - << nitem - 1 << ")"; - status.SetError(str.str()); + status.SetError(cmStrCat("index: ", item, " out of range (-", nitem, + ", ", nitem - 1, ")")); return false; } value += varArgsExpanded[item]; @@ -366,9 +364,7 @@ bool HandleInsertCommand(std::vector const& args, if ((!GetList(varArgsExpanded, listName, status.GetMakefile()) || varArgsExpanded.empty()) && item != 0) { - std::ostringstream str; - str << "index: " << item << " out of range (0, 0)"; - status.SetError(str.str()); + status.SetError(cmStrCat("index: ", item, " out of range (0, 0)")); return false; } @@ -378,10 +374,9 @@ bool HandleInsertCommand(std::vector const& args, item = static_cast(nitem) + item; } if (item < 0 || nitem < static_cast(item)) { - std::ostringstream str; - str << "index: " << item << " out of range (-" << varArgsExpanded.size() - << ", " << varArgsExpanded.size() << ")"; - status.SetError(str.str()); + status.SetError(cmStrCat("index: ", item, " out of range (-", + varArgsExpanded.size(), ", ", + varArgsExpanded.size(), ")")); return false; } } @@ -398,10 +393,8 @@ bool HandleJoinCommand(std::vector const& args, cmExecutionStatus& status) { if (args.size() != 4) { - std::ostringstream error; - error << "sub-command JOIN requires three arguments (" << args.size() - 1 - << " found)."; - status.SetError(error.str()); + status.SetError(cmStrCat("sub-command JOIN requires three arguments (", + args.size() - 1, " found).")); return false; } @@ -596,11 +589,9 @@ protected: index = static_cast(count) + index; } if (index < 0 || count <= static_cast(index)) { - std::ostringstream str; - str << "sub-command TRANSFORM, selector " << this->Tag - << ", index: " << index << " out of range (-" << count << ", " - << count - 1 << ")."; - throw transform_error(str.str()); + throw transform_error(cmStrCat( + "sub-command TRANSFORM, selector ", this->Tag, ", index: ", index, + " out of range (-", count, ", ", count - 1, ").")); } return index; } @@ -681,17 +672,14 @@ public: makefile->ClearMatches(); if (!this->ReplaceHelper.IsRegularExpressionValid()) { - std::ostringstream error; - error - << "sub-command TRANSFORM, action REPLACE: Failed to compile regex \"" - << arguments[0] << "\"."; - throw transform_error(error.str()); + throw transform_error( + cmStrCat("sub-command TRANSFORM, action REPLACE: Failed to compile " + "regex \"", + arguments[0], "\".")); } if (!this->ReplaceHelper.IsReplaceExpressionValid()) { - std::ostringstream error; - error << "sub-command TRANSFORM, action REPLACE: " - << this->ReplaceHelper.GetError() << "."; - throw transform_error(error.str()); + throw transform_error(cmStrCat("sub-command TRANSFORM, action REPLACE: ", + this->ReplaceHelper.GetError(), ".")); } } @@ -701,10 +689,8 @@ public: std::string output; if (!this->ReplaceHelper.Replace(input, output)) { - std::ostringstream error; - error << "sub-command TRANSFORM, action REPLACE: " - << this->ReplaceHelper.GetError() << "."; - throw transform_error(error.str()); + throw transform_error(cmStrCat("sub-command TRANSFORM, action REPLACE: ", + this->ReplaceHelper.GetError(), ".")); } return output; @@ -839,19 +825,17 @@ bool HandleTransformCommand(std::vector const& args, auto descriptor = descriptors.find(args[index]); if (descriptor == descriptors.end()) { - std::ostringstream error; - error << " sub-command TRANSFORM, " << args[index] << " invalid action."; - status.SetError(error.str()); + status.SetError( + cmStrCat(" sub-command TRANSFORM, ", args[index], " invalid action.")); return false; } // Action arguments index += 1; if (args.size() < index + descriptor->Arity) { - std::ostringstream error; - error << "sub-command TRANSFORM, action " << descriptor->Name - << " expects " << descriptor->Arity << " argument(s)."; - status.SetError(error.str()); + status.SetError(cmStrCat("sub-command TRANSFORM, action ", + descriptor->Name, " expects ", descriptor->Arity, + " argument(s).")); return false; } @@ -881,10 +865,10 @@ bool HandleTransformCommand(std::vector const& args, while (args.size() > index) { if ((args[index] == REGEX || args[index] == AT || args[index] == FOR) && command.Selector) { - std::ostringstream error; - error << "sub-command TRANSFORM, selector already specified (" - << command.Selector->Tag << ")."; - status.SetError(error.str()); + status.SetError( + cmStrCat("sub-command TRANSFORM, selector already specified (", + command.Selector->Tag, ").")); + return false; } @@ -898,11 +882,10 @@ bool HandleTransformCommand(std::vector const& args, command.Selector = cm::make_unique(args[index]); if (!command.Selector->Validate()) { - std::ostringstream error; - error << "sub-command TRANSFORM, selector REGEX failed to compile " - "regex \""; - error << args[index] << "\"."; - status.SetError(error.str()); + status.SetError( + cmStrCat("sub-command TRANSFORM, selector REGEX failed to compile " + "regex \"", + args[index], "\".")); return false; } @@ -1020,11 +1003,9 @@ bool HandleTransformCommand(std::vector const& args, continue; } - std::ostringstream error; - error << "sub-command TRANSFORM, '" - << cmJoin(cmMakeRange(args).advance(index), " ") - << "': unexpected argument(s)."; - status.SetError(error.str()); + status.SetError(cmStrCat("sub-command TRANSFORM, '", + cmJoin(cmMakeRange(args).advance(index), " "), + "': unexpected argument(s).")); return false; } @@ -1261,10 +1242,8 @@ bool HandleSublistCommand(std::vector const& args, cmExecutionStatus& status) { if (args.size() != 5) { - std::ostringstream error; - error << "sub-command SUBLIST requires four arguments (" << args.size() - 1 - << " found)."; - status.SetError(error.str()); + status.SetError(cmStrCat("sub-command SUBLIST requires four arguments (", + args.size() - 1, " found).")); return false; } @@ -1285,16 +1264,12 @@ bool HandleSublistCommand(std::vector const& args, using size_type = decltype(varArgsExpanded)::size_type; if (start < 0 || size_type(start) >= varArgsExpanded.size()) { - std::ostringstream error; - error << "begin index: " << start << " is out of range 0 - " - << varArgsExpanded.size() - 1; - status.SetError(error.str()); + status.SetError(cmStrCat("begin index: ", start, " is out of range 0 - ", + varArgsExpanded.size() - 1)); return false; } if (length < -1) { - std::ostringstream error; - error << "length: " << length << " should be -1 or greater"; - status.SetError(error.str()); + status.SetError(cmStrCat("length: ", length, " should be -1 or greater")); return false; } @@ -1344,10 +1319,8 @@ bool HandleRemoveAtCommand(std::vector const& args, item = static_cast(nitem) + item; } if (item < 0 || nitem <= static_cast(item)) { - std::ostringstream str; - str << "index: " << item << " out of range (-" << nitem << ", " - << nitem - 1 << ")"; - status.SetError(str.str()); + status.SetError(cmStrCat("index: ", item, " out of range (-", nitem, + ", ", nitem - 1, ")")); return false; } removed.push_back(static_cast(item)); diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx index 66fdada..6f5df46 100644 --- a/Source/cmLoadCommandCommand.cxx +++ b/Source/cmLoadCommandCommand.cxx @@ -7,7 +7,7 @@ #include #include #include -#include + #include #include "cm_memory.hxx" @@ -207,9 +207,8 @@ bool cmLoadCommandCommand(std::vector const& args, // Try to find the program. std::string fullPath = cmSystemTools::FindFile(moduleName, path); if (fullPath.empty()) { - std::ostringstream e; - e << "Attempt to load command failed from file \"" << moduleName << "\""; - status.SetError(e.str()); + status.SetError(cmStrCat("Attempt to load command failed from file \"", + moduleName, "\"")); return false; } diff --git a/Source/cmOptionCommand.cxx b/Source/cmOptionCommand.cxx index a0a0989..22e59ac 100644 --- a/Source/cmOptionCommand.cxx +++ b/Source/cmOptionCommand.cxx @@ -2,8 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmOptionCommand.h" -#include - #include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -74,13 +72,13 @@ bool cmOptionCommand(std::vector const& args, const auto* existsAfterSet = status.GetMakefile().GetStateSnapshot().GetDefinition(args[0]); if (!existsAfterSet) { - std::ostringstream w; - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0077) - << "\n" - "For compatibility with older versions of CMake, option " - "is clearing the normal variable '" - << args[0] << "'."; - status.GetMakefile().IssueMessage(MessageType::AUTHOR_WARNING, w.str()); + status.GetMakefile().IssueMessage( + MessageType::AUTHOR_WARNING, + cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0077), + "\n" + "For compatibility with older versions of CMake, option " + "is clearing the normal variable '", + args[0], "'.")); } } return true; diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index e1267ec..916a9f7 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -465,14 +465,14 @@ void cmOrderDirectories::FindImplicitConflicts() } // Warn about the conflicts. - std::ostringstream w; - w << "Cannot generate a safe " << this->Purpose << " for target " - << this->Target->GetName() - << " because files in some directories may conflict with " - << " libraries in implicit directories:\n" - << text << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance()->IssueMessage( - MessageType::WARNING, w.str(), this->Target->GetBacktrace()); + MessageType::WARNING, + cmStrCat("Cannot generate a safe ", this->Purpose, " for target ", + this->Target->GetName(), + " because files in some directories may " + "conflict with libraries in implicit directories:\n", + text, "Some of these libraries may not be found correctly."), + this->Target->GetBacktrace()); } void cmOrderDirectories::OrderDirectories() diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index e74fff6..5fa6a21 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -8,7 +8,6 @@ #include #include #include -#include #include #include "cmMakefile.h" @@ -320,10 +319,10 @@ bool cmProjectCommand::InitialPass(std::vector const& args, } } if (!vw.empty()) { - std::ostringstream w; - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0048) - << "\nThe following variable(s) would be set to empty:" << vw; - this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, w.str()); + this->Makefile->IssueMessage( + MessageType::AUTHOR_WARNING, + cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0048), + "\nThe following variable(s) would be set to empty:", vw)); } } diff --git a/Source/cmSeparateArgumentsCommand.cxx b/Source/cmSeparateArgumentsCommand.cxx index 27f45a8..52bde7c 100644 --- a/Source/cmSeparateArgumentsCommand.cxx +++ b/Source/cmSeparateArgumentsCommand.cxx @@ -3,10 +3,10 @@ #include "cmSeparateArgumentsCommand.h" #include -#include #include "cmExecutionStatus.h" #include "cmMakefile.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" // cmSeparateArgumentsCommand @@ -56,9 +56,7 @@ bool cmSeparateArgumentsCommand(std::vector const& args, command = arg; doing = DoingNone; } else { - std::ostringstream e; - e << "given unknown argument " << arg; - status.SetError(e.str()); + status.SetError(cmStrCat("given unknown argument ", arg)); return false; } } diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index 387c3fc..112d832 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -100,11 +100,10 @@ bool cmSetPropertyCommand(std::vector const& args, } else if (scopeName == "INSTALL") { scope = cmProperty::INSTALL; } else { - std::ostringstream e; - e << "given invalid scope " << scopeName << ". " - << "Valid scopes are GLOBAL, DIRECTORY, " - "TARGET, SOURCE, TEST, CACHE, INSTALL."; - status.SetError(e.str()); + status.SetError(cmStrCat("given invalid scope ", scopeName, + ". " + "Valid scopes are GLOBAL, DIRECTORY, " + "TARGET, SOURCE, TEST, CACHE, INSTALL.")); return false; } @@ -149,9 +148,7 @@ bool cmSetPropertyCommand(std::vector const& args, propertyValue += arg; remove = false; } else { - std::ostringstream e; - e << "given invalid argument \"" << arg << "\"."; - status.SetError(e.str()); + status.SetError(cmStrCat("given invalid argument \"", arg, "\".")); return false; } } @@ -293,10 +290,8 @@ bool HandleTargetMode(cmExecutionStatus& status, return false; } } else { - std::ostringstream e; - e << "could not find TARGET " << name - << ". Perhaps it has not yet been created."; - status.SetError(e.str()); + status.SetError(cmStrCat("could not find TARGET ", name, + ". Perhaps it has not yet been created.")); return false; } } @@ -340,9 +335,8 @@ bool HandleSourceMode(cmExecutionStatus& status, return false; } } else { - std::ostringstream e; - e << "given SOURCE name that could not be found or created: " << name; - status.SetError(e.str()); + status.SetError(cmStrCat( + "given SOURCE name that could not be found or created: ", name)); return false; } } @@ -428,26 +422,23 @@ bool HandleCacheMode(cmExecutionStatus& status, { if (propertyName == "ADVANCED") { if (!remove && !cmIsOn(propertyValue) && !cmIsOff(propertyValue)) { - std::ostringstream e; - e << "given non-boolean value \"" << propertyValue - << R"(" for CACHE property "ADVANCED". )"; - status.SetError(e.str()); + status.SetError(cmStrCat("given non-boolean value \"", propertyValue, + R"(" for CACHE property "ADVANCED". )")); return false; } } else if (propertyName == "TYPE") { if (!cmState::IsCacheEntryType(propertyValue)) { - std::ostringstream e; - e << "given invalid CACHE entry TYPE \"" << propertyValue << "\""; - status.SetError(e.str()); + status.SetError( + cmStrCat("given invalid CACHE entry TYPE \"", propertyValue, "\"")); return false; } } else if (propertyName != "HELPSTRING" && propertyName != "STRINGS" && propertyName != "VALUE") { - std::ostringstream e; - e << "given invalid CACHE property " << propertyName << ". " - << "Settable CACHE properties are: " - << "ADVANCED, HELPSTRING, STRINGS, TYPE, and VALUE."; - status.SetError(e.str()); + status.SetError( + cmStrCat("given invalid CACHE property ", propertyName, + ". " + "Settable CACHE properties are: " + "ADVANCED, HELPSTRING, STRINGS, TYPE, and VALUE.")); return false; } @@ -462,10 +453,8 @@ bool HandleCacheMode(cmExecutionStatus& status, return false; } } else { - std::ostringstream e; - e << "could not find CACHE variable " << name - << ". Perhaps it has not yet been created."; - status.SetError(e.str()); + status.SetError(cmStrCat("could not find CACHE variable ", name, + ". Perhaps it has not yet been created.")); return false; } } @@ -511,9 +500,8 @@ bool HandleInstallMode(cmExecutionStatus& status, return false; } } else { - std::ostringstream e; - e << "given INSTALL name that could not be found or created: " << name; - status.SetError(e.str()); + status.SetError(cmStrCat( + "given INSTALL name that could not be found or created: ", name)); return false; } } diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index ab670ca..809d05e 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -11,7 +11,6 @@ #include #include #include -#include #include "cm_static_string_view.hxx" @@ -46,9 +45,8 @@ bool HandleHashCommand(std::vector const& args, { #if !defined(CMAKE_BOOTSTRAP) if (args.size() != 3) { - std::ostringstream e; - e << args[0] << " requires an output variable and an input string"; - status.SetError(e.str()); + status.SetError( + cmStrCat(args[0], " requires an output variable and an input string")); return false; } @@ -60,9 +58,7 @@ bool HandleHashCommand(std::vector const& args, } return false; #else - std::ostringstream e; - e << args[0] << " not available during bootstrap"; - status.SetError(e.str().c_str()); + status.SetError(cmStrCat(args[0], " not available during bootstrap")); return false; #endif } @@ -148,9 +144,7 @@ bool HandleConfigureCommand(std::vector const& args, } else if (args[i] == "ESCAPE_QUOTES") { escapeQuotes = true; } else { - std::ostringstream err; - err << "Unrecognized argument \"" << args[i] << "\""; - status.SetError(err.str()); + status.SetError(cmStrCat("Unrecognized argument \"", args[i], "\"")); return false; } } @@ -377,9 +371,7 @@ bool HandleFindCommand(std::vector const& args, pos = sstring.rfind(schar); } if (std::string::npos != pos) { - std::ostringstream s; - s << pos; - status.GetMakefile().AddDefinition(outvar, s.str()); + status.GetMakefile().AddDefinition(outvar, std::to_string(pos)); return true; } @@ -474,16 +466,12 @@ bool HandleSubstringCommand(std::vector const& args, size_t stringLength = stringValue.size(); int intStringLength = static_cast(stringLength); if (begin < 0 || begin > intStringLength) { - std::ostringstream ostr; - ostr << "begin index: " << begin << " is out of range 0 - " - << stringLength; - status.SetError(ostr.str()); + status.SetError( + cmStrCat("begin index: ", begin, " is out of range 0 - ", stringLength)); return false; } if (end < -1) { - std::ostringstream ostr; - ostr << "end index: " << end << " should be -1 or greater"; - status.SetError(ostr.str()); + status.SetError(cmStrCat("end index: ", end, " should be -1 or greater")); return false; } @@ -915,9 +903,7 @@ bool HandleUuidCommand(std::vector const& args, status.GetMakefile().AddDefinition(outputVariable, uuid); return true; #else - std::ostringstream e; - e << args[0] << " not available during bootstrap"; - status.SetError(e.str().c_str()); + status.SetError(cmStrCat(args[0], " not available during bootstrap")); return false; #endif } diff --git a/Source/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx index b64646a..94e249f 100644 --- a/Source/cmTargetCompileDefinitionsCommand.cxx +++ b/Source/cmTargetCompileDefinitionsCommand.cxx @@ -2,8 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmTargetCompileDefinitionsCommand.h" -#include - #include "cmMakefile.h" #include "cmMessageType.h" #include "cmStringAlgorithms.h" @@ -20,11 +18,10 @@ bool cmTargetCompileDefinitionsCommand::InitialPass( void cmTargetCompileDefinitionsCommand::HandleMissingTarget( const std::string& name) { - std::ostringstream e; - e << "Cannot specify compile definitions for target \"" << name - << "\" " - "which is not built by this project."; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Cannot specify compile definitions for target \"", name, + "\" which is not built by this project.")); } std::string cmTargetCompileDefinitionsCommand::Join( diff --git a/Source/cmTargetCompileFeaturesCommand.cxx b/Source/cmTargetCompileFeaturesCommand.cxx index 976c8cb..a22b94b 100644 --- a/Source/cmTargetCompileFeaturesCommand.cxx +++ b/Source/cmTargetCompileFeaturesCommand.cxx @@ -2,8 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmTargetCompileFeaturesCommand.h" -#include - #include "cmMakefile.h" #include "cmMessageType.h" #include "cmStringAlgorithms.h" @@ -20,11 +18,10 @@ bool cmTargetCompileFeaturesCommand::InitialPass( void cmTargetCompileFeaturesCommand::HandleMissingTarget( const std::string& name) { - std::ostringstream e; - e << "Cannot specify compile features for target \"" << name - << "\" " - "which is not built by this project."; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Cannot specify compile features for target \"", name, + "\" which is not built by this project.")); } std::string cmTargetCompileFeaturesCommand::Join( diff --git a/Source/cmTargetCompileOptionsCommand.cxx b/Source/cmTargetCompileOptionsCommand.cxx index 7dadb82..ccc215a 100644 --- a/Source/cmTargetCompileOptionsCommand.cxx +++ b/Source/cmTargetCompileOptionsCommand.cxx @@ -2,8 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmTargetCompileOptionsCommand.h" -#include - #include "cmListFileCache.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -21,10 +19,10 @@ bool cmTargetCompileOptionsCommand::InitialPass( void cmTargetCompileOptionsCommand::HandleMissingTarget( const std::string& name) { - std::ostringstream e; - e << "Cannot specify compile options for target \"" << name - << "\" which is not built by this project."; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Cannot specify compile options for target \"", name, + "\" which is not built by this project.")); } std::string cmTargetCompileOptionsCommand::Join( diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index d099349..7801ee8 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -3,7 +3,6 @@ #include "cmTargetIncludeDirectoriesCommand.h" #include -#include #include "cmGeneratorExpression.h" #include "cmListFileCache.h" @@ -25,10 +24,10 @@ bool cmTargetIncludeDirectoriesCommand::InitialPass( void cmTargetIncludeDirectoriesCommand::HandleMissingTarget( const std::string& name) { - std::ostringstream e; - e << "Cannot specify include directories for target \"" << name - << "\" which is not built by this project."; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Cannot specify include directories for target \"", name, + "\" which is not built by this project.")); } std::string cmTargetIncludeDirectoriesCommand::Join( diff --git a/Source/cmTargetLinkDirectoriesCommand.cxx b/Source/cmTargetLinkDirectoriesCommand.cxx index 435c392..c2ef6c1 100644 --- a/Source/cmTargetLinkDirectoriesCommand.cxx +++ b/Source/cmTargetLinkDirectoriesCommand.cxx @@ -2,8 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmTargetLinkDirectoriesCommand.h" -#include - #include "cmGeneratorExpression.h" #include "cmListFileCache.h" #include "cmMakefile.h" @@ -23,10 +21,10 @@ bool cmTargetLinkDirectoriesCommand::InitialPass( void cmTargetLinkDirectoriesCommand::HandleMissingTarget( const std::string& name) { - std::ostringstream e; - e << "Cannot specify link directories for target \"" << name - << "\" which is not built by this project."; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Cannot specify link directories for target \"", name, + "\" which is not built by this project.")); } std::string cmTargetLinkDirectoriesCommand::Join( diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 237d90c..b432599 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -256,10 +256,11 @@ bool cmTargetLinkLibrariesCommand::InitialPass( // Make sure the last argument was not a library type specifier. if (haveLLT) { - std::ostringstream e; - e << "The \"" << cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[llt] - << "\" argument must be followed by a library."; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("The \"", + cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[llt], + "\" argument must be followed by a library.")); cmSystemTools::SetFatalErrorOccured(); } @@ -284,14 +285,14 @@ bool cmTargetLinkLibrariesCommand::InitialPass( void cmTargetLinkLibrariesCommand::LinkLibraryTypeSpecifierWarning(int left, int right) { - std::ostringstream w; - w << "Link library type specifier \"" - << cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[left] - << "\" is followed by specifier \"" - << cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[right] - << "\" instead of a library name. " - << "The first specifier will be ignored."; - this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, w.str()); + this->Makefile->IssueMessage( + MessageType::AUTHOR_WARNING, + cmStrCat( + "Link library type specifier \"", + cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[left], + "\" is followed by specifier \"", + cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[right], + "\" instead of a library name. The first specifier will be ignored.")); } bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, @@ -404,12 +405,13 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, this->CurrentProcessingState != ProcessingPlainLinkInterface) { if (rejectRemoteLinking) { - std::ostringstream e; - e << "Attempt to add link library \"" << lib << "\" to target \"" - << this->Target->GetName() - << "\" which is not built in this directory.\n" - << "This is allowed only when policy CMP0079 is set to NEW."; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Attempt to add link library \"", lib, "\" to target \"", + this->Target->GetName(), + "\" which is not built in this " + "directory.\nThis is allowed only when policy CMP0079 " + "is set to NEW.")); return false; } @@ -421,29 +423,31 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, (tgt->GetType() != cmStateEnums::OBJECT_LIBRARY) && (tgt->GetType() != cmStateEnums::INTERFACE_LIBRARY) && !tgt->IsExecutableWithExports()) { - std::ostringstream e; - e << "Target \"" << lib << "\" of type " - << cmState::GetTargetTypeName(tgt->GetType()) - << " may not be linked into another target. One may link only to " - "INTERFACE, OBJECT, STATIC or SHARED libraries, or to executables " - "with the ENABLE_EXPORTS property set."; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat( + "Target \"", lib, "\" of type ", + cmState::GetTargetTypeName(tgt->GetType()), + " may not be linked into another target. One may link only to " + "INTERFACE, OBJECT, STATIC or SHARED libraries, or to ", + "executables with the ENABLE_EXPORTS property set.")); } this->Target->AddLinkLibrary(*this->Makefile, lib, libRef, llt); } if (warnRemoteInterface) { - std::ostringstream w; - /* clang-format off */ - w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0079) << "\n" - "Target\n " << this->Target->GetName() << "\nis not created in this " - "directory. For compatibility with older versions of CMake, link " - "library\n " << lib << "\nwill be looked up in the directory in " - "which the target was created rather than in this calling " - "directory."; - /* clang-format on */ - this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, w.str()); + this->Makefile->IssueMessage( + MessageType::AUTHOR_WARNING, + cmStrCat( + cmPolicies::GetPolicyWarning(cmPolicies::CMP0079), "\nTarget\n ", + this->Target->GetName(), + "\nis not created in this " + "directory. For compatibility with older versions of CMake, link " + "library\n ", + lib, + "\nwill be looked up in the directory in which " + "the target was created rather than in this calling directory.")); } // Handle (additional) case where the command was called with PRIVATE / diff --git a/Source/cmTargetLinkOptionsCommand.cxx b/Source/cmTargetLinkOptionsCommand.cxx index 2866cf1..dbd7bfe 100644 --- a/Source/cmTargetLinkOptionsCommand.cxx +++ b/Source/cmTargetLinkOptionsCommand.cxx @@ -2,8 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmTargetLinkOptionsCommand.h" -#include - #include "cmListFileCache.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -20,10 +18,10 @@ bool cmTargetLinkOptionsCommand::InitialPass( void cmTargetLinkOptionsCommand::HandleMissingTarget(const std::string& name) { - std::ostringstream e; - e << "Cannot specify link options for target \"" << name - << "\" which is not built by this project."; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Cannot specify link options for target \"", name, + "\" which is not built by this project.")); } std::string cmTargetLinkOptionsCommand::Join( diff --git a/Source/cmTargetSourcesCommand.cxx b/Source/cmTargetSourcesCommand.cxx index 2251a65..7c9d03c 100644 --- a/Source/cmTargetSourcesCommand.cxx +++ b/Source/cmTargetSourcesCommand.cxx @@ -30,11 +30,10 @@ void cmTargetSourcesCommand::HandleInterfaceContent( void cmTargetSourcesCommand::HandleMissingTarget(const std::string& name) { - std::ostringstream e; - e << "Cannot specify sources for target \"" << name - << "\" " - "which is not built by this project."; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Cannot specify sources for target \"", name, + "\" which is not built by this project.")); } std::string cmTargetSourcesCommand::Join( diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx index f9f7d66..f2c8f3c 100644 --- a/Source/cmVariableWatchCommand.cxx +++ b/Source/cmVariableWatchCommand.cxx @@ -3,13 +3,13 @@ #include "cmVariableWatchCommand.h" #include -#include #include #include "cmExecutionStatus.h" #include "cmListFileCache.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmVariableWatch.h" #include "cmake.h" @@ -58,22 +58,20 @@ static void cmVariableWatchCommandVariableAccessed(const std::string& variable, newLFF.Line = 9999; cmExecutionStatus status(*makefile); if (!makefile->ExecuteCommand(newLFF, status)) { - std::ostringstream error; - error << "Error in cmake code at\nUnknown:0:\n" - << "A command failed during the invocation of callback \"" - << data->Command << "\"."; - cmSystemTools::Error(error.str()); + cmSystemTools::Error( + cmStrCat("Error in cmake code at\nUnknown:0:\nA command failed " + "during the invocation of callback \"", + data->Command, "\".")); data->InCallback = false; return; } processed = true; } if (!processed) { - std::ostringstream msg; - msg << "Variable \"" << variable << "\" was accessed using " - << accessString << " with value \"" << (newValue ? newValue : "") - << "\"."; - makefile->IssueMessage(MessageType::LOG, msg.str()); + makefile->IssueMessage( + MessageType::LOG, + cmStrCat("Variable \"", variable, "\" was accessed using ", accessString, + " with value \"", (newValue ? newValue : ""), "\".")); } data->InCallback = false; @@ -134,9 +132,7 @@ bool cmVariableWatchCommand(std::vector const& args, command = args[1]; } if (variable == "CMAKE_CURRENT_LIST_FILE") { - std::ostringstream ostr; - ostr << "cannot be set on the variable: " << variable; - status.SetError(ostr.str()); + status.SetError(cmStrCat("cannot be set on the variable: ", variable)); return false; } ----------------------------------------------------------------------- Summary of changes: Source/cmAddCustomCommandCommand.cxx | 13 +- Source/cmAddCustomTargetCommand.cxx | 16 +- Source/cmAddDependenciesCommand.cxx | 30 +-- Source/cmAddExecutableCommand.cxx | 38 ++-- Source/cmAddLibraryCommand.cxx | 62 +++--- Source/cmAddSubDirectoryCommand.cxx | 15 +- Source/cmAddTestCommand.cxx | 19 +- Source/cmCMakePolicyCommand.cxx | 47 ++-- Source/cmConfigureFileCommand.cxx | 12 +- Source/cmFileCommand.cxx | 261 +++++++++------------- Source/cmFindPackageCommand.cxx | 45 ++-- Source/cmForEachCommand.cxx | 15 +- Source/cmGetPropertyCommand.cxx | 36 ++- Source/cmInstallCommand.cxx | 314 +++++++++++---------------- Source/cmListCommand.cxx | 111 ++++------ Source/cmLoadCommandCommand.cxx | 7 +- Source/cmOptionCommand.cxx | 16 +- Source/cmOrderDirectories.cxx | 14 +- Source/cmProjectCommand.cxx | 9 +- Source/cmSeparateArgumentsCommand.cxx | 6 +- Source/cmSetPropertyCommand.cxx | 56 ++--- Source/cmStringCommand.cxx | 32 +-- Source/cmTargetCompileDefinitionsCommand.cxx | 11 +- Source/cmTargetCompileFeaturesCommand.cxx | 11 +- Source/cmTargetCompileOptionsCommand.cxx | 10 +- Source/cmTargetIncludeDirectoriesCommand.cxx | 9 +- Source/cmTargetLinkDirectoriesCommand.cxx | 10 +- Source/cmTargetLinkLibrariesCommand.cxx | 74 ++++--- Source/cmTargetLinkOptionsCommand.cxx | 10 +- Source/cmTargetSourcesCommand.cxx | 9 +- Source/cmVariableWatchCommand.cxx | 24 +- 31 files changed, 545 insertions(+), 797 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Thu Sep 19 11:28:32 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 19 Sep 2019 11:28:32 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1098-g9c31d83 Message-ID: <20190919152833.05B39111A0D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 9c31d83aa2a3d3f5921f4a5a559e126e285b96c5 (commit) via cc0900d9cd5fe1fa224d48738965b2928c09f6e7 (commit) via 692d8e34927e43a01a799fa5593db8b50a3c0e3a (commit) via 1933ade9f1624d6fa4b8a9bf128be96c75b57c68 (commit) via 706d9738a614724a96487be074e984a7e86c48c9 (commit) via d018d27c101869e4e2449f938df89d4f97c5b73c (commit) via 77983c814725317e990315be8bc8d5b93fa6ffbd (commit) via f9e5441eb43d3238211685cded447141082e37b8 (commit) via 51676cf65590f7a9bc3ad247151ee5bdc768eb77 (commit) via 1a3f185c1a1f5f67e6c7d8d821f17619208e6311 (commit) via 726ea1d15134591c352468b64b3e92f04f2449bb (commit) via 05126d23f6a285731dfef940012c6b78feb9fa62 (commit) via f54c5ee52195ae2d73a54faef9399ab977b83a1b (commit) via 65c49e0e26488931e6ec27a1d352c07d43171f22 (commit) via dad1a6b3fbf1c9d34a6d2e5722e426234bbb5df0 (commit) via 82096911461f37f0421a7a79faa179aa9e0cb25c (commit) from e199294673665e01b1cba48625ec1b18c960c90e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9c31d83aa2a3d3f5921f4a5a559e126e285b96c5 commit 9c31d83aa2a3d3f5921f4a5a559e126e285b96c5 Merge: e199294 cc0900d Author: Brad King AuthorDate: Thu Sep 19 15:19:34 2019 +0000 Commit: Kitware Robot CommitDate: Thu Sep 19 11:19:52 2019 -0400 Merge topic 'autogen_path_prefix' cc0900d9cd Help: Add release notes for AUTOMOC_PATH_PREFIX 692d8e3492 Help: Add documentation for AUTOMOC_PATH_PREFIX 1933ade9f1 Tests: At QtAutogen.MocIncludeSymlink test 706d9738a6 Tests: Merge QtAutogen.MocIncludeStrict and MocIncludeRelaxed d018d27c10 Autogen: Add moc path prefix generation (AUTOMOC_PATH_PREFIX) 77983c8147 Autogen: Add IsHeader flag to SourceFileT class f9e5441eb4 Autogen: Abbreviate file paths in messages 51676cf655 Autogen: Split JobEvalCacheT job into separate moc and uic jobs ... Acked-by: Kitware Robot Merge-request: !3818 diff --cc Source/cmQtAutoGenInitializer.cxx index 355141e,1404554..ad4e4d5 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@@ -1093,17 -1121,26 +1114,18 @@@ bool cmQtAutoGenInitializer::InitRccTar if (this->MultiConfig) { // Build for all configurations for (std::string const& config : this->ConfigsList) { - cmCustomCommandLine currentLine; - currentLine.push_back(cmSystemTools::GetCMakeCommand()); - currentLine.push_back("-E"); - currentLine.push_back("cmake_autorcc"); - currentLine.push_back(qrc.InfoFile); - currentLine.push_back(config); - commandLines.push_back(std::move(currentLine)); + commandLines.push_back( + cmMakeCommandLine({ cmSystemTools::GetCMakeCommand(), "-E", + "cmake_autorcc", qrc.InfoFile, config })); } } else { - cmCustomCommandLine currentLine; - currentLine.push_back(cmSystemTools::GetCMakeCommand()); - currentLine.push_back("-E"); - currentLine.push_back("cmake_autorcc"); - currentLine.push_back(qrc.InfoFile); - currentLine.push_back("$"); - commandLines.push_back(std::move(currentLine)); + commandLines.push_back( + cmMakeCommandLine({ cmSystemTools::GetCMakeCommand(), "-E", + "cmake_autorcc", qrc.InfoFile, "$" })); } - std::string ccComment = cmStrCat( - "Automatic RCC for ", FileProjectRelativePath(makefile, qrc.QrcFile)); + std::string ccComment = + cmStrCat("Automatic RCC for ", + FileProjectRelativePath(this->Makefile, qrc.QrcFile)); if (qrc.Generated || this->Rcc.GlobalTarget) { // Create custom rcc target https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cc0900d9cd5fe1fa224d48738965b2928c09f6e7 commit cc0900d9cd5fe1fa224d48738965b2928c09f6e7 Author: Sebastian Holtermann AuthorDate: Sat Sep 14 10:18:51 2019 +0200 Commit: Brad King CommitDate: Wed Sep 18 11:48:23 2019 -0400 Help: Add release notes for AUTOMOC_PATH_PREFIX diff --git a/Help/release/dev/automoc_path_prefix.rst b/Help/release/dev/automoc_path_prefix.rst new file mode 100644 index 0000000..bee1b32 --- /dev/null +++ b/Help/release/dev/automoc_path_prefix.rst @@ -0,0 +1,13 @@ +automoc_path_prefix +------------------- + +* When using :prop_tgt:`AUTOMOC`, CMake now generates the ``-p`` path prefix + option for ``moc``. This ensures that ``moc`` output files are identical + on different build setups (given, that the headers compiled by ``moc`` are + in an :command:`include directory `). + Also it ensures that ``moc`` output files will compile correctly when the + source and/or build directory is a symbolic link. + + The ``moc`` path prefix generation behavior can be configured by setting + the new :variable:`CMAKE_AUTOMOC_PATH_PREFIX` variable and/or + :prop_tgt:`AUTOMOC_PATH_PREFIX` target property. https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=692d8e34927e43a01a799fa5593db8b50a3c0e3a commit 692d8e34927e43a01a799fa5593db8b50a3c0e3a Author: Sebastian Holtermann AuthorDate: Sat Sep 14 10:00:18 2019 +0200 Commit: Brad King CommitDate: Wed Sep 18 11:48:23 2019 -0400 Help: Add documentation for AUTOMOC_PATH_PREFIX diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 19afb7d..9e54e3e 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -134,6 +134,7 @@ Properties on Targets /prop_tgt/AUTOMOC_EXECUTABLE /prop_tgt/AUTOMOC_MACRO_NAMES /prop_tgt/AUTOMOC_MOC_OPTIONS + /prop_tgt/AUTOMOC_PATH_PREFIX /prop_tgt/AUTOMOC /prop_tgt/AUTOUIC /prop_tgt/AUTOUIC_EXECUTABLE diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 2d473d8..def63e4 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -342,6 +342,7 @@ Variables that Control the Build /variable/CMAKE_AUTOMOC_DEPEND_FILTERS /variable/CMAKE_AUTOMOC_MACRO_NAMES /variable/CMAKE_AUTOMOC_MOC_OPTIONS + /variable/CMAKE_AUTOMOC_PATH_PREFIX /variable/CMAKE_AUTORCC /variable/CMAKE_AUTORCC_OPTIONS /variable/CMAKE_AUTOUIC diff --git a/Help/prop_tgt/AUTOMOC_PATH_PREFIX.rst b/Help/prop_tgt/AUTOMOC_PATH_PREFIX.rst new file mode 100644 index 0000000..e2ebb3f --- /dev/null +++ b/Help/prop_tgt/AUTOMOC_PATH_PREFIX.rst @@ -0,0 +1,32 @@ +AUTOMOC_PATH_PREFIX +------------------- + +When this property is ``ON``, CMake will generate the ``-p`` path prefix +option for ``moc`` on :prop_tgt:`AUTOMOC` enabled Qt targets. + +To generate the path prefix, CMake tests if the header compiled by ``moc`` +is in any of the target +:command:`include directories `. If so, CMake will +compute the relative path accordingly. If the header is not in the +:command:`include directories `, CMake will omit +the ``-p`` path prefix option. ``moc`` usually generates a +relative include path in that case. + +:prop_tgt:`AUTOMOC_PATH_PREFIX` is initialized from the variable +:variable:`CMAKE_AUTOMOC_PATH_PREFIX`, which is ``ON`` by default. + +See the :manual:`cmake-qt(7)` manual for more information on using CMake +with Qt. + +Reproducible builds +^^^^^^^^^^^^^^^^^^^ + +For reproducible builds is is recommended to keep headers that are ``moc`` +compiled in one of the target +:command:`include directories ` and set +:prop_tgt:`AUTOMOC_PATH_PREFIX` to ``ON`` (which is the default). This ensures +that + +- ``moc`` output files are identical on different build setups, +- ``moc`` output files will compile correctly when the source and/or + build directory is a symbolic link. diff --git a/Help/variable/CMAKE_AUTOMOC_PATH_PREFIX.rst b/Help/variable/CMAKE_AUTOMOC_PATH_PREFIX.rst new file mode 100644 index 0000000..dca0b06 --- /dev/null +++ b/Help/variable/CMAKE_AUTOMOC_PATH_PREFIX.rst @@ -0,0 +1,11 @@ +CMAKE_AUTOMOC_PATH_PREFIX +------------------------- + +Whether to generate the ``-p`` path prefix option for ``moc`` on +:prop_tgt:`AUTOMOC` enabled Qt targets. + +This variable is used to initialize the :prop_tgt:`AUTOMOC_PATH_PREFIX` +property on all the targets. See that target property for additional +information. + +The default value is ``ON``. https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1933ade9f1624d6fa4b8a9bf128be96c75b57c68 commit 1933ade9f1624d6fa4b8a9bf128be96c75b57c68 Author: Sebastian Holtermann AuthorDate: Sun Sep 8 12:58:35 2019 +0200 Commit: Brad King CommitDate: Wed Sep 18 11:48:23 2019 -0400 Tests: At QtAutogen.MocIncludeSymlink test diff --git a/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt b/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt new file mode 100644 index 0000000..1627b39 --- /dev/null +++ b/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt @@ -0,0 +1,80 @@ +cmake_minimum_required(VERSION 3.15) +project(MocIncludeSymlink) +include("../AutogenCoreTest.cmake") + +# +# Tests if MocInclude can be build when +# - The source directory is a symbolic link +# - The build directory is a symbolic link +# + +# -- Utility variables +set(CS_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +set(CB_DIR "${CMAKE_CURRENT_BINARY_DIR}") + +# Absolute MocInclude path +get_filename_component(MocIncludePath "../MocInclude" ABSOLUTE) +message("MocIncludePath: ${MocIncludePath}") + +# Use nested subdirectories to ensure relatives paths are correct as well +set(BUILD_DIR_NORMAL "${CB_DIR}/Build/Normal") +set(BUILD_DIR_LINKED "${CB_DIR}/Build/Linked") + +set(SL_SOURCE_DIR "${CB_DIR}/SL_Source") +set(SL_BUILD_DIR "${CB_DIR}/SL_Build") + +# -- Utility macros +function(makeSymLink origin link) + message("Creating symbolic link\n Link: ${link}\n To: ${origin}") + file(CREATE_LINK ${origin} ${link} RESULT res SYMBOLIC) + if(NOT (${res} STREQUAL "0")) + message("Symlink creation failed.\n Link: ${link}\n To: ${origin}\n Result: ${res}") + endif() +endfunction() + +# -- Make source directory symlink +makeSymLink(${MocIncludePath} ${SL_SOURCE_DIR} linkResult) +if(NOT EXISTS ${SL_SOURCE_DIR}) + message("Directory symlink can't be created. Skipping test.") + return() +endif() + +# -- Make normal build directory +file(REMOVE_RECURSE ${BUILD_DIR_NORMAL}) +file(MAKE_DIRECTORY ${BUILD_DIR_NORMAL}) + +# -- Make linked build directory and symlink +file(REMOVE_RECURSE ${BUILD_DIR_LINKED}) +file(MAKE_DIRECTORY ${BUILD_DIR_LINKED}) +makeSymLink(${BUILD_DIR_LINKED} ${SL_BUILD_DIR} linkResult) +if(NOT EXISTS ${SL_BUILD_DIR}) + message("Directory symlink can't be created. Skipping test.") + return() +endif() + + +# -- Building +macro(buildMocInclude sourceDir binaryDir) + message("Building MocInclude\n - source dir: ${sourceDir}\n - binary dir: ${binaryDir}\n") + try_compile(result + "${binaryDir}" + "${sourceDir}" + MocInclude + CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" + "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" + "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" + OUTPUT_VARIABLE output + ) + if (result) + message(STATUS "--- Build success. ---") + else() + message(STATUS "\n### Building MocInclude failed. ###\n\n--- Output ---\n${output}") + message(FATAL_ERROR "--- Building MocInclude failed. End of output. ---") + endif() +endmacro() + +message("\nTry building with\n - symbolic link source dir\n - non symbolic build dir\n") +buildMocInclude(${SL_SOURCE_DIR} ${BUILD_DIR_NORMAL}) + +message("\nTry building with\n - symbolic link source dir\n - symbolic link build dir\n") +buildMocInclude(${SL_SOURCE_DIR} ${SL_BUILD_DIR}) diff --git a/Tests/QtAutogen/Tests.cmake b/Tests/QtAutogen/Tests.cmake index 04b50ab..2b001d4 100644 --- a/Tests/QtAutogen/Tests.cmake +++ b/Tests/QtAutogen/Tests.cmake @@ -33,6 +33,7 @@ ADD_AUTOGEN_TEST(UicSkipSource) if(QT_TEST_ALLOW_QT_MACROS) ADD_AUTOGEN_TEST(MocCMP0071) ADD_AUTOGEN_TEST(MocInclude) + ADD_AUTOGEN_TEST(MocIncludeSymlink) ADD_AUTOGEN_TEST(MocSkipSource) endif() https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=706d9738a614724a96487be074e984a7e86c48c9 commit 706d9738a614724a96487be074e984a7e86c48c9 Author: Sebastian Holtermann AuthorDate: Sat Sep 7 11:54:05 2019 +0200 Commit: Brad King CommitDate: Wed Sep 18 11:48:10 2019 -0400 Tests: Merge QtAutogen.MocIncludeStrict and MocIncludeRelaxed diff --git a/Tests/QtAutogen/MocInclude/CMakeLists.txt b/Tests/QtAutogen/MocInclude/CMakeLists.txt new file mode 100644 index 0000000..04c8baf --- /dev/null +++ b/Tests/QtAutogen/MocInclude/CMakeLists.txt @@ -0,0 +1,112 @@ +cmake_minimum_required(VERSION 3.15) +project(MocInclude) +get_filename_component(CS_REAL ${CMAKE_CURRENT_SOURCE_DIR} REALPATH) +include("${CS_REAL}/../AutogenCoreTest.cmake") + +# Test moc include patterns + +set(COM_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Common") + +macro(addCopyCommand from to) + add_custom_command( + OUTPUT ${to} + COMMAND ${CMAKE_COMMAND} -E copy ${from} ${to} + DEPENDS ${from}) +endmacro() + +# Create an executable +function(makeExecutable TARGET_NAME) + # Utility variables + set(CB_DIR "${CMAKE_CURRENT_BINARY_DIR}") + + # Copy directory + file(REMOVE_RECURSE "${CB_DIR}/InIncludes") + file(COPY "${COM_DIR}/InIncludes.in" DESTINATION "${CB_DIR}") + file(RENAME "${CB_DIR}/InIncludes.in" "${CB_DIR}/InIncludes") + + # Generate .moc file from the header externally and + # enabled SKIP_AUTOMOC on the source file + qtx_wrap_cpp(ExternDotMOC ${COM_DIR}/ExternDot.hpp OPTIONS "-p" "./") + addCopyCommand(${ExternDotMOC} + ${CB_DIR}/ExternDot.moc) + set_property( + SOURCE ${COM_DIR}/ExternDot.cpp + PROPERTY SKIP_AUTOMOC ON) + + # Generate .moc file from the GENERATED header externally + # and enabled SKIP_AUTOMOC on the source file + addCopyCommand(${COM_DIR}/ExternDotGenerated.hpp.in + ${CB_DIR}/ExternDotGenerated.hpp) + addCopyCommand(${COM_DIR}/ExternDotGenerated.cpp.in + ${CB_DIR}/ExternDotGenerated.cpp) + qtx_wrap_cpp(ExternDotGeneratedMOC + ${CB_DIR}/ExternDotGenerated.hpp + OPTIONS "-p" "./") + addCopyCommand(${ExternDotGeneratedMOC} + ${CB_DIR}/ExternDotGenerated.moc) + set_property( + SOURCE ${CB_DIR}/ExternDotGenerated.cpp + PROPERTY SKIP_AUTOMOC ON) + + # Generate header moc file externally with a custom name + # and enabled SKIP_AUTOMOC on the header + qtx_wrap_cpp(MixedCustomMOC + ${COM_DIR}/MixedCustom.hpp + OPTIONS "-p" "./") + addCopyCommand(${MixedCustomMOC} + ${CB_DIR}/MixedCustom_extMoc.cpp) + set_property( + SOURCE ${COM_DIR}/MixedCustom.hpp + PROPERTY SKIP_AUTOMOC ON) + # Custom target to depend on + add_custom_target("${TARGET_NAME}_MixedCustom" + DEPENDS ${CB_DIR}/MixedCustom_extMoc.cpp + BYPRODUCTS ${CB_DIR}/moc_MixedCustom.cpp + COMMAND ${CMAKE_COMMAND} -E copy + ${COM_DIR}/moc_MixedCustom.cpp.in + ${CB_DIR}/moc_MixedCustom.cpp) + + add_executable(${TARGET_NAME} + # Test own "*.moc" and "moc_*.cpp" includes + ${COM_DIR}/None.cpp + ${COM_DIR}/OwnDot.cpp + ${COM_DIR}/OwnUnderscore.cpp + ${COM_DIR}/OwnDotUnderscore.cpp + + # Test "moc_*.cpp" includes of other files + ${COM_DIR}/OtherUnderscore.cpp + ${COM_DIR}/OtherUnderscoreExtra.cpp + ${COM_DIR}/OtherUnderscoreSub.cpp + ${COM_DIR}/OtherUnderscoreSubDir/SubExtra.cpp + + # Test relative ../../ path for moc includes + ${COM_DIR}/DualSub/Second/Second.cpp + ${COM_DIR}/DualSubMocked.cpp + + # Test externally generated moc files + ${COM_DIR}/ExternDot.cpp + ${CB_DIR}/ExternDot.moc + + # Test externally generated moc files for GENERATED source + ${CB_DIR}/ExternDotGenerated.cpp + ${CB_DIR}/ExternDotGenerated.moc + + # Test externally generated moc files and SKIP_AUTOMOC enabled header + ${COM_DIR}/MixedSkipped.cpp + ${COM_DIR}/MixedCustom.hpp + ${COM_DIR}/MixedCustom.cpp + + # Test sources in a subdirectory + ${CB_DIR}/InIncludes/SubOwnDot.cpp + ${COM_DIR}/InIncludesMoc.cpp + ) + add_dependencies(${TARGET_NAME} "${TARGET_NAME}_MixedCustom") + target_include_directories(${TARGET_NAME} PRIVATE "${COM_DIR}") + target_include_directories(${TARGET_NAME} PRIVATE "${CB_DIR}") + target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") + target_link_libraries(${TARGET_NAME} ${QT_LIBRARIES}) + set_target_properties(${TARGET_NAME} PROPERTIES AUTOMOC ON) +endfunction() + +add_subdirectory(Strict) +add_subdirectory(Relaxed) diff --git a/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.cpp b/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.cpp new file mode 100644 index 0000000..453add1 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.cpp @@ -0,0 +1,11 @@ +#include "Second.hpp" + +Second::Second() +{ +} + +Second::~Second() +{ +} + +#include "../../moc_DualSubMocked.cpp" diff --git a/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.hpp b/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.hpp new file mode 100644 index 0000000..e1f3eac --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.hpp @@ -0,0 +1,14 @@ +#ifndef Second_HPP +#define Second_HPP + +#include + +class Second : public QObject +{ + Q_OBJECT +public: + Second(); + ~Second(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/DualSubMocked.cpp b/Tests/QtAutogen/MocInclude/Common/DualSubMocked.cpp new file mode 100644 index 0000000..1d4658d --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/DualSubMocked.cpp @@ -0,0 +1,9 @@ +#include "DualSubMocked.hpp" + +DualSubMocked::DualSubMocked() +{ +} + +DualSubMocked::~DualSubMocked() +{ +} diff --git a/Tests/QtAutogen/MocInclude/Common/DualSubMocked.hpp b/Tests/QtAutogen/MocInclude/Common/DualSubMocked.hpp new file mode 100644 index 0000000..58cb571 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/DualSubMocked.hpp @@ -0,0 +1,15 @@ +#ifndef DualSubMocked_HPP +#define DualSubMocked_HPP + +#include + +// Header moc file is included by DualSub/Second/Second.cpp +class DualSubMocked : public QObject +{ + Q_OBJECT +public: + DualSubMocked(); + ~DualSubMocked(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/ExternDot.cpp b/Tests/QtAutogen/MocInclude/Common/ExternDot.cpp new file mode 100644 index 0000000..2495aa7 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/ExternDot.cpp @@ -0,0 +1,11 @@ +#include "ExternDot.hpp" + +ExternDot::ExternDot() +{ +} + +ExternDot::~ExternDot() +{ +} + +#include "ExternDot.moc" diff --git a/Tests/QtAutogen/MocInclude/SObjA.hpp b/Tests/QtAutogen/MocInclude/Common/ExternDot.hpp similarity index 50% rename from Tests/QtAutogen/MocInclude/SObjA.hpp rename to Tests/QtAutogen/MocInclude/Common/ExternDot.hpp index 1436abc..7eaab2a 100644 --- a/Tests/QtAutogen/MocInclude/SObjA.hpp +++ b/Tests/QtAutogen/MocInclude/Common/ExternDot.hpp @@ -1,15 +1,15 @@ -#ifndef SOBJA_HPP -#define SOBJA_HPP +#ifndef ExternDot_HPP +#define ExternDot_HPP #include // Object source includes externally generated .moc file -class SObjA : public QObject +class ExternDot : public QObject { Q_OBJECT public: - SObjA(); - ~SObjA(); + ExternDot(); + ~ExternDot(); }; #endif diff --git a/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.cpp.in b/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.cpp.in new file mode 100644 index 0000000..09ce5cd --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.cpp.in @@ -0,0 +1,11 @@ +#include "ExternDotGenerated.hpp" + +ExternDotGenerated::ExternDotGenerated() +{ +} + +ExternDotGenerated::~ExternDotGenerated() +{ +} + +#include "ExternDotGenerated.moc" diff --git a/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.hpp.in b/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.hpp.in new file mode 100644 index 0000000..21c69be --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.hpp.in @@ -0,0 +1,15 @@ +#ifndef ExternDotGenerated_HPP +#define ExternDotGenerated_HPP + +#include + +// GENERATED Object source includes externally generated .moc file +class ExternDotGenerated : public QObject +{ + Q_OBJECT +public: + ExternDotGenerated(); + ~ExternDotGenerated(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.cpp b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.cpp new file mode 100644 index 0000000..af35711 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.cpp @@ -0,0 +1,43 @@ +#include "SubOwnDot.hpp" +#include "SubOwnDot_p.hpp" + +namespace InIncludes { + +class SubOwnDotLocal : public QObject +{ + Q_OBJECT +public: + SubOwnDotLocal(); + ~SubOwnDotLocal(); +}; + +SubOwnDotLocal::SubOwnDotLocal() +{ +} + +SubOwnDotLocal::~SubOwnDotLocal() +{ +} + +SubOwnDotPrivate::SubOwnDotPrivate() +{ +} + +SubOwnDotPrivate::~SubOwnDotPrivate() +{ +} + +SubOwnDot::SubOwnDot() +{ + SubOwnDotPrivate privateObj; + SubOwnDotLocal localObj; +} + +SubOwnDot::~SubOwnDot() +{ +} + +} // End of namespace + +// For the local QObject +#include "SubOwnDot.moc" diff --git a/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.hpp b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.hpp new file mode 100644 index 0000000..038ddfa --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.hpp @@ -0,0 +1,17 @@ +#ifndef InIncludes_SubOwnDot_HPP +#define InIncludes_SubOwnDot_HPP + +#include + +namespace InIncludes { + +class SubOwnDot : public QObject +{ + Q_OBJECT +public: + SubOwnDot(); + ~SubOwnDot(); +}; +} + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot_p.hpp b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot_p.hpp new file mode 100644 index 0000000..626a9a8 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot_p.hpp @@ -0,0 +1,18 @@ +#ifndef InIncludes_SubOwnDot_P_HPP +#define InIncludes_SubOwnDot_P_HPP + +#include + +namespace InIncludes { + +class SubOwnDotPrivate : public QObject +{ + Q_OBJECT +public: + SubOwnDotPrivate(); + ~SubOwnDotPrivate(); +}; + +} // End of namespace + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/InIncludesMoc.cpp b/Tests/QtAutogen/MocInclude/Common/InIncludesMoc.cpp new file mode 100644 index 0000000..88f53a4 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/InIncludesMoc.cpp @@ -0,0 +1,4 @@ + +// Moc a header that is not in the sources but in a directory that +// is in the list of include directories. +#include "InIncludes/moc_SubOwnDot.cpp" diff --git a/Tests/QtAutogen/MocInclude/Common/MixedCustom.cpp b/Tests/QtAutogen/MocInclude/Common/MixedCustom.cpp new file mode 100644 index 0000000..557cc62 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/MixedCustom.cpp @@ -0,0 +1,32 @@ +#include "MixedCustom.hpp" + +class MixedCustomLocal : public QObject +{ + Q_OBJECT + +public: + MixedCustomLocal(); + ~MixedCustomLocal(); +}; + +MixedCustomLocal::MixedCustomLocal() +{ +} + +MixedCustomLocal::~MixedCustomLocal() +{ +} + +MixedCustom::MixedCustom() +{ + MixedCustomLocal local; +} + +MixedCustom::~MixedCustom() +{ +} + +// AUTOMOC generated source moc +#include "MixedCustom.moc" +// Externally generated header moc +#include "MixedCustom_extMoc.cpp" diff --git a/Tests/QtAutogen/MocInclude/Common/MixedCustom.hpp b/Tests/QtAutogen/MocInclude/Common/MixedCustom.hpp new file mode 100644 index 0000000..6e8ff88 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/MixedCustom.hpp @@ -0,0 +1,20 @@ +#ifndef MixedCustom_HPP +#define MixedCustom_HPP + +#include + +// Object source includes +// - externally generated header moc file +// - AUTOMOC generated source .moc file +class MixedCustom : public QObject +{ + Q_OBJECT +public: + MixedCustom(); + ~MixedCustom(); +}; + +// Function forward declaration +void moc_MixedCustom(MixedCustom const& arg); + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/MixedSkipped.cpp b/Tests/QtAutogen/MocInclude/Common/MixedSkipped.cpp new file mode 100644 index 0000000..df08ff1 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/MixedSkipped.cpp @@ -0,0 +1,39 @@ +#include "MixedSkipped.hpp" +#include "MixedCustom.hpp" + +class MixedSkippedLocal : public QObject +{ + Q_OBJECT + +public: + MixedSkippedLocal(); + ~MixedSkippedLocal(); +}; + +MixedSkippedLocal::MixedSkippedLocal() +{ +} + +MixedSkippedLocal::~MixedSkippedLocal() +{ +} + +MixedSkipped::MixedSkipped() +{ + MixedSkippedLocal local; + MixedCustom externCutom; + // Call moc named function + moc_MixedCustom(externCutom); +} + +MixedSkipped::~MixedSkipped() +{ +} + +// Include AUTOMOC generated moc files +#include "MixedSkipped.moc" +#include "moc_MixedSkipped.cpp" + +// Include externally generated moc_ named file that is not a moc file +// and for which the relevant header is SKIP_AUTOMOC enabled +#include "moc_MixedCustom.cpp" diff --git a/Tests/QtAutogen/MocInclude/Common/MixedSkipped.hpp b/Tests/QtAutogen/MocInclude/Common/MixedSkipped.hpp new file mode 100644 index 0000000..5f6c664 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/MixedSkipped.hpp @@ -0,0 +1,17 @@ +#ifndef MixedSkipped_HPP +#define MixedSkipped_HPP + +#include + +// Object source includes +// - Own moc_ and .moc files. +// - externally generated moc_ file from a SKIP_AUTOMOC enabled header +class MixedSkipped : public QObject +{ + Q_OBJECT +public: + MixedSkipped(); + ~MixedSkipped(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/None.cpp b/Tests/QtAutogen/MocInclude/Common/None.cpp new file mode 100644 index 0000000..d01d5ec --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/None.cpp @@ -0,0 +1,20 @@ +#include "None.hpp" +#include "None_p.h" + +NonePrivate::NonePrivate() +{ +} + +NonePrivate::~NonePrivate() +{ +} + +None::None() + : d(new NonePrivate) +{ +} + +None::~None() +{ + delete d; +} diff --git a/Tests/QtAutogen/MocInclude/Common/None.hpp b/Tests/QtAutogen/MocInclude/Common/None.hpp new file mode 100644 index 0000000..ca0713e --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/None.hpp @@ -0,0 +1,19 @@ +#ifndef None_HPP +#define None_HPP + +#include + +// Object source comes without any _moc/.moc includes +class NonePrivate; +class None : public QObject +{ + Q_OBJECT +public: + None(); + ~None(); + +private: + NonePrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/None_p.h b/Tests/QtAutogen/MocInclude/Common/None_p.h new file mode 100644 index 0000000..e209aeb --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/None_p.h @@ -0,0 +1,14 @@ +#ifndef None_P_HPP +#define None_P_HPP + +#include + +class NonePrivate : public QObject +{ + Q_OBJECT +public: + NonePrivate(); + ~NonePrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.cpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.cpp new file mode 100644 index 0000000..219619f --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.cpp @@ -0,0 +1,44 @@ +#include "OtherUnderscore.hpp" +#include "OtherUnderscoreExtra.hpp" +#include "OtherUnderscore_p.hpp" + +class OtherUnderscoreLocal : public QObject +{ + Q_OBJECT +public: + OtherUnderscoreLocal(); + ~OtherUnderscoreLocal(); +}; + +OtherUnderscoreLocal::OtherUnderscoreLocal() +{ +} + +OtherUnderscoreLocal::~OtherUnderscoreLocal() +{ +} + +OtherUnderscorePrivate::OtherUnderscorePrivate() +{ + OtherUnderscoreLocal localObj; + OtherUnderscoreExtra extraObj; +} + +OtherUnderscorePrivate::~OtherUnderscorePrivate() +{ +} + +OtherUnderscore::OtherUnderscore() + : d(new OtherUnderscorePrivate) +{ +} + +OtherUnderscore::~OtherUnderscore() +{ + delete d; +} + +// For OtherUnderscoreLocal +#include "OtherUnderscore.moc" +// - Not the own header +#include "moc_OtherUnderscoreExtra.cpp" diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.hpp new file mode 100644 index 0000000..a4ff603 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.hpp @@ -0,0 +1,19 @@ +#ifndef OtherUnderscore_HPP +#define OtherUnderscore_HPP + +#include + +// Sources includes a moc_ includes of an extra object +class OtherUnderscorePrivate; +class OtherUnderscore : public QObject +{ + Q_OBJECT +public: + OtherUnderscore(); + ~OtherUnderscore(); + +private: + OtherUnderscorePrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.cpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.cpp new file mode 100644 index 0000000..4ccf080 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.cpp @@ -0,0 +1,20 @@ +#include "OtherUnderscoreExtra.hpp" +#include "OtherUnderscoreExtra_p.hpp" + +OtherUnderscoreExtraPrivate::OtherUnderscoreExtraPrivate() +{ +} + +OtherUnderscoreExtraPrivate::~OtherUnderscoreExtraPrivate() +{ +} + +OtherUnderscoreExtra::OtherUnderscoreExtra() + : d(new OtherUnderscoreExtraPrivate) +{ +} + +OtherUnderscoreExtra::~OtherUnderscoreExtra() +{ + delete d; +} diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.hpp new file mode 100644 index 0000000..5afe48c --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.hpp @@ -0,0 +1,18 @@ +#ifndef OtherUnderscoreEXTRA_HPP +#define OtherUnderscoreEXTRA_HPP + +#include + +class OtherUnderscoreExtraPrivate; +class OtherUnderscoreExtra : public QObject +{ + Q_OBJECT +public: + OtherUnderscoreExtra(); + ~OtherUnderscoreExtra(); + +private: + OtherUnderscoreExtraPrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra_p.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra_p.hpp new file mode 100644 index 0000000..2066ac3 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra_p.hpp @@ -0,0 +1,14 @@ +#ifndef OtherUnderscoreEXTRA_P_HPP +#define OtherUnderscoreEXTRA_P_HPP + +#include + +class OtherUnderscoreExtraPrivate : public QObject +{ + Q_OBJECT +public: + OtherUnderscoreExtraPrivate(); + ~OtherUnderscoreExtraPrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.cpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.cpp new file mode 100644 index 0000000..28850aa --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.cpp @@ -0,0 +1,45 @@ +#include "OtherUnderscoreSub.hpp" +#include "OtherUnderscoreSubDir/SubExtra.hpp" +#include "OtherUnderscoreSub_p.hpp" + +class OtherUnderscoreSubLocal : public QObject +{ + Q_OBJECT +public: + OtherUnderscoreSubLocal(); + ~OtherUnderscoreSubLocal(); +}; + +OtherUnderscoreSubLocal::OtherUnderscoreSubLocal() +{ +} + +OtherUnderscoreSubLocal::~OtherUnderscoreSubLocal() +{ +} + +OtherUnderscoreSubPrivate::OtherUnderscoreSubPrivate() +{ + OtherUnderscoreSubLocal localObj; + SubExtra extraObj; +} + +OtherUnderscoreSubPrivate::~OtherUnderscoreSubPrivate() +{ +} + +OtherUnderscoreSub::OtherUnderscoreSub() + : d(new OtherUnderscoreSubPrivate) +{ +} + +OtherUnderscoreSub::~OtherUnderscoreSub() +{ + delete d; +} + +// For OtherUnderscoreSubLocal +#include "OtherUnderscoreSub.moc" +// - Not the own header +// - in a subdirectory +#include "OtherUnderscoreSubDir/moc_SubExtra.cpp" diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.hpp new file mode 100644 index 0000000..7feaa46 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.hpp @@ -0,0 +1,19 @@ +#ifndef OtherUnderscoreSub_HPP +#define OtherUnderscoreSub_HPP + +#include + +// Sources includes a moc_ includes of an extra object in a subdirectory +class OtherUnderscoreSubPrivate; +class OtherUnderscoreSub : public QObject +{ + Q_OBJECT +public: + OtherUnderscoreSub(); + ~OtherUnderscoreSub(); + +private: + OtherUnderscoreSubPrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.cpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.cpp new file mode 100644 index 0000000..e323ed8 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.cpp @@ -0,0 +1,20 @@ +#include "SubExtra.hpp" +#include "SubExtra_p.hpp" + +SubExtraPrivate::SubExtraPrivate() +{ +} + +SubExtraPrivate::~SubExtraPrivate() +{ +} + +SubExtra::SubExtra() + : d(new SubExtraPrivate) +{ +} + +SubExtra::~SubExtra() +{ + delete d; +} diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.hpp new file mode 100644 index 0000000..5700634 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.hpp @@ -0,0 +1,18 @@ +#ifndef SubExtra_HPP +#define SubExtra_HPP + +#include + +class SubExtraPrivate; +class SubExtra : public QObject +{ + Q_OBJECT +public: + SubExtra(); + ~SubExtra(); + +private: + SubExtraPrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra_p.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra_p.hpp new file mode 100644 index 0000000..5a14a2d --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra_p.hpp @@ -0,0 +1,14 @@ +#ifndef SubExtra_P_HPP +#define SubExtra_P_HPP + +#include + +class SubExtraPrivate : public QObject +{ + Q_OBJECT +public: + SubExtraPrivate(); + ~SubExtraPrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub_p.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub_p.hpp new file mode 100644 index 0000000..7d5999c --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub_p.hpp @@ -0,0 +1,14 @@ +#ifndef OtherUnderscoreSub_P_HPP +#define OtherUnderscoreSub_P_HPP + +#include + +class OtherUnderscoreSubPrivate : public QObject +{ + Q_OBJECT +public: + OtherUnderscoreSubPrivate(); + ~OtherUnderscoreSubPrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscore_p.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore_p.hpp new file mode 100644 index 0000000..96906cf --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore_p.hpp @@ -0,0 +1,14 @@ +#ifndef OtherUnderscore_P_HPP +#define OtherUnderscore_P_HPP + +#include + +class OtherUnderscorePrivate : public QObject +{ + Q_OBJECT +public: + OtherUnderscorePrivate(); + ~OtherUnderscorePrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDot.cpp b/Tests/QtAutogen/MocInclude/Common/OwnDot.cpp new file mode 100644 index 0000000..1cce272 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OwnDot.cpp @@ -0,0 +1,39 @@ +#include "OwnDot.hpp" +#include "OwnDot_p.h" + +class OwnDotLocal : public QObject +{ + Q_OBJECT +public: + OwnDotLocal(); + ~OwnDotLocal(); +}; + +OwnDotLocal::OwnDotLocal() +{ +} + +OwnDotLocal::~OwnDotLocal() +{ +} + +OwnDotPrivate::OwnDotPrivate() +{ + OwnDotLocal localObj; +} + +OwnDotPrivate::~OwnDotPrivate() +{ +} + +OwnDot::OwnDot() + : d(new OwnDotPrivate) +{ +} + +OwnDot::~OwnDot() +{ + delete d; +} + +#include "OwnDot.moc" diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDot.hpp b/Tests/QtAutogen/MocInclude/Common/OwnDot.hpp new file mode 100644 index 0000000..6f49f12 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OwnDot.hpp @@ -0,0 +1,19 @@ +#ifndef OwnDot_HPP +#define OwnDot_HPP + +#include + +// Object source comes with a .moc include +class OwnDotPrivate; +class OwnDot : public QObject +{ + Q_OBJECT +public: + OwnDot(); + ~OwnDot(); + +private: + OwnDotPrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.cpp b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.cpp new file mode 100644 index 0000000..2a0b8ad --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.cpp @@ -0,0 +1,40 @@ +#include "OwnDotUnderscore.hpp" +#include "OwnDotUnderscore_p.h" + +class OwnDotUnderscoreLocal : public QObject +{ + Q_OBJECT +public: + OwnDotUnderscoreLocal(); + ~OwnDotUnderscoreLocal(); +}; + +OwnDotUnderscoreLocal::OwnDotUnderscoreLocal() +{ +} + +OwnDotUnderscoreLocal::~OwnDotUnderscoreLocal() +{ +} + +OwnDotUnderscorePrivate::OwnDotUnderscorePrivate() +{ + OwnDotUnderscoreLocal localObj; +} + +OwnDotUnderscorePrivate::~OwnDotUnderscorePrivate() +{ +} + +OwnDotUnderscore::OwnDotUnderscore() + : d(new OwnDotUnderscorePrivate) +{ +} + +OwnDotUnderscore::~OwnDotUnderscore() +{ + delete d; +} + +#include "OwnDotUnderscore.moc" +#include "moc_OwnDotUnderscore.cpp" diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.hpp b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.hpp new file mode 100644 index 0000000..478955c --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.hpp @@ -0,0 +1,19 @@ +#ifndef LOwnDotUnderscore_HPP +#define LOwnDotUnderscore_HPP + +#include + +// Object source comes with a .moc and a _moc include +class OwnDotUnderscorePrivate; +class OwnDotUnderscore : public QObject +{ + Q_OBJECT +public: + OwnDotUnderscore(); + ~OwnDotUnderscore(); + +private: + OwnDotUnderscorePrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore_p.h b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore_p.h new file mode 100644 index 0000000..6950b7f --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore_p.h @@ -0,0 +1,14 @@ +#ifndef OwnDotUnderscore_P_HPP +#define OwnDotUnderscore_P_HPP + +#include + +class OwnDotUnderscorePrivate : public QObject +{ + Q_OBJECT +public: + OwnDotUnderscorePrivate(); + ~OwnDotUnderscorePrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDot_p.h b/Tests/QtAutogen/MocInclude/Common/OwnDot_p.h new file mode 100644 index 0000000..f3aff32 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OwnDot_p.h @@ -0,0 +1,14 @@ +#ifndef OwnDot_P_HPP +#define OwnDot_P_HPP + +#include + +class OwnDotPrivate : public QObject +{ + Q_OBJECT +public: + OwnDotPrivate(); + ~OwnDotPrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.cpp b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.cpp new file mode 100644 index 0000000..ebbcf45 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.cpp @@ -0,0 +1,22 @@ +#include "OwnUnderscore.hpp" +#include "OwnUnderscore_p.h" + +OwnUnderscorePrivate::OwnUnderscorePrivate() +{ +} + +OwnUnderscorePrivate::~OwnUnderscorePrivate() +{ +} + +OwnUnderscore::OwnUnderscore() + : d(new OwnUnderscorePrivate) +{ +} + +OwnUnderscore::~OwnUnderscore() +{ + delete d; +} + +#include "moc_OwnUnderscore.cpp" diff --git a/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.hpp b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.hpp new file mode 100644 index 0000000..e6a6a6e --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.hpp @@ -0,0 +1,19 @@ +#ifndef OwnUnderscore_HPP +#define OwnUnderscore_HPP + +#include + +// Object source comes with a _moc include +class OwnUnderscorePrivate; +class OwnUnderscore : public QObject +{ + Q_OBJECT +public: + OwnUnderscore(); + ~OwnUnderscore(); + +private: + OwnUnderscorePrivate* const d; +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/OwnUnderscore_p.h b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore_p.h new file mode 100644 index 0000000..a3a6b00 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore_p.h @@ -0,0 +1,14 @@ +#ifndef OwnUnderscore_P_HPP +#define OwnUnderscore_P_HPP + +#include + +class OwnUnderscorePrivate : public QObject +{ + Q_OBJECT +public: + OwnUnderscorePrivate(); + ~OwnUnderscorePrivate(); +}; + +#endif diff --git a/Tests/QtAutogen/MocInclude/Common/common.cpp.in b/Tests/QtAutogen/MocInclude/Common/common.cpp.in new file mode 100644 index 0000000..b53e93d --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/common.cpp.in @@ -0,0 +1,32 @@ +#include "DualSub/Second/Second.hpp" +#include "DualSubMocked.hpp" +#include "ExternDot.hpp" +#include "ExternDotGenerated.hpp" +#include "None.hpp" +#include "OtherUnderscore.hpp" +#include "OtherUnderscoreSub.hpp" +#include "OwnDot.hpp" +#include "OwnDotUnderscore.hpp" +#include "OwnUnderscore.hpp" +#include "InIncludes/SubOwnDot.hpp" + +bool @COMMON_FUNCTION_NAME@() +{ + None objNone; + OwnUnderscore objOwnUnderscore; + OwnDot objOwnDot; + OwnDotUnderscore objOwnDotUnderscore; + + OtherUnderscore objOtherUnderscore; + OtherUnderscoreSub objOtherUnderscoreSub; + + Second second; + DualSubMocked dualSubMocked; + + ExternDot objExternDot; + ExternDotGenerated objGeneratedExternDot; + + InIncludes::SubOwnDot subOwnDot; + + return true; +} diff --git a/Tests/QtAutogen/MocInclude/Common/moc_MixedCustom.cpp.in b/Tests/QtAutogen/MocInclude/Common/moc_MixedCustom.cpp.in new file mode 100644 index 0000000..6c44793 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Common/moc_MixedCustom.cpp.in @@ -0,0 +1,5 @@ + +void moc_MixedCustom(MixedCustom const & arg) +{ + (void)arg; +} diff --git a/Tests/QtAutogen/MocInclude/EObjA.cpp b/Tests/QtAutogen/MocInclude/EObjA.cpp deleted file mode 100644 index 7681c29..0000000 --- a/Tests/QtAutogen/MocInclude/EObjA.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "EObjA.hpp" -#include "EObjAExtra.hpp" -#include "EObjA_p.hpp" - -class EObjALocal : public QObject -{ - Q_OBJECT -public: - EObjALocal(); - ~EObjALocal(); -}; - -EObjALocal::EObjALocal() -{ -} - -EObjALocal::~EObjALocal() -{ -} - -EObjAPrivate::EObjAPrivate() -{ - EObjALocal localObj; - EObjAExtra extraObj; -} - -EObjAPrivate::~EObjAPrivate() -{ -} - -EObjA::EObjA() - : d(new EObjAPrivate) -{ -} - -EObjA::~EObjA() -{ - delete d; -} - -// For EObjALocal -#include "EObjA.moc" -// - Not the own header -#include "moc_EObjAExtra.cpp" diff --git a/Tests/QtAutogen/MocInclude/EObjA.hpp b/Tests/QtAutogen/MocInclude/EObjA.hpp deleted file mode 100644 index 0939ab6..0000000 --- a/Tests/QtAutogen/MocInclude/EObjA.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef EOBJA_HPP -#define EOBJA_HPP - -#include - -// Sources includes a moc_ includes of an extra object -class EObjAPrivate; -class EObjA : public QObject -{ - Q_OBJECT -public: - EObjA(); - ~EObjA(); - -private: - EObjAPrivate* const d; -}; - -#endif diff --git a/Tests/QtAutogen/MocInclude/EObjAExtra.cpp b/Tests/QtAutogen/MocInclude/EObjAExtra.cpp deleted file mode 100644 index 369ca8f..0000000 --- a/Tests/QtAutogen/MocInclude/EObjAExtra.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "EObjAExtra.hpp" -#include "EObjAExtra_p.hpp" - -EObjAExtraPrivate::EObjAExtraPrivate() -{ -} - -EObjAExtraPrivate::~EObjAExtraPrivate() -{ -} - -EObjAExtra::EObjAExtra() - : d(new EObjAExtraPrivate) -{ -} - -EObjAExtra::~EObjAExtra() -{ - delete d; -} diff --git a/Tests/QtAutogen/MocInclude/EObjAExtra.hpp b/Tests/QtAutogen/MocInclude/EObjAExtra.hpp deleted file mode 100644 index b10681d..0000000 --- a/Tests/QtAutogen/MocInclude/EObjAExtra.hpp +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef EOBJAEXTRA_HPP -#define EOBJAEXTRA_HPP - -#include - -class EObjAExtraPrivate; -class EObjAExtra : public QObject -{ - Q_OBJECT -public: - EObjAExtra(); - ~EObjAExtra(); - -private: - EObjAExtraPrivate* const d; -}; - -#endif diff --git a/Tests/QtAutogen/MocInclude/EObjAExtra_p.hpp b/Tests/QtAutogen/MocInclude/EObjAExtra_p.hpp deleted file mode 100644 index d8bf284..0000000 --- a/Tests/QtAutogen/MocInclude/EObjAExtra_p.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef EOBJAEXTRA_P_HPP -#define EOBJAEXTRA_P_HPP - -#include - -class EObjAExtraPrivate : public QObject -{ - Q_OBJECT -public: - EObjAExtraPrivate(); - ~EObjAExtraPrivate(); -}; - -#endif diff --git a/Tests/QtAutogen/MocInclude/EObjA_p.hpp b/Tests/QtAutogen/MocInclude/EObjA_p.hpp deleted file mode 100644 index 9ef5624..0000000 --- a/Tests/QtAutogen/MocInclude/EObjA_p.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef EOBJA_P_HPP -#define EOBJA_P_HPP - -#include - -class EObjAPrivate : public QObject -{ - Q_OBJECT -public: - EObjAPrivate(); - ~EObjAPrivate(); -}; - -#endif diff --git a/Tests/QtAutogen/MocInclude/EObjB.cpp b/Tests/QtAutogen/MocInclude/EObjB.cpp deleted file mode 100644 index 3068c68..0000000 --- a/Tests/QtAutogen/MocInclude/EObjB.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "EObjB.hpp" -#include "EObjB_p.hpp" -#include "subExtra/EObjBExtra.hpp" - -class EObjBLocal : public QObject -{ - Q_OBJECT -public: - EObjBLocal(); - ~EObjBLocal(); -}; - -EObjBLocal::EObjBLocal() -{ -} - -EObjBLocal::~EObjBLocal() -{ -} - -EObjBPrivate::EObjBPrivate() -{ - EObjBLocal localObj; - EObjBExtra extraObj; -} - -EObjBPrivate::~EObjBPrivate() -{ -} - -EObjB::EObjB() - : d(new EObjBPrivate) -{ -} - -EObjB::~EObjB() -{ - delete d; -} - -// For EObjBLocal -#include "EObjB.moc" -// - Not the own header -// - in a subdirectory -#include "subExtra/moc_EObjBExtra.cpp" diff --git a/Tests/QtAutogen/MocInclude/EObjB.hpp b/Tests/QtAutogen/MocInclude/EObjB.hpp deleted file mode 100644 index 6632bdb..0000000 --- a/Tests/QtAutogen/MocInclude/EObjB.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef EOBJB_HPP -#define EOBJB_HPP - -#include - -// Sources includes a moc_ includes of an extra object in a subdirectory -class EObjBPrivate; -class EObjB : public QObject -{ - Q_OBJECT -public: - EObjB(); - ~EObjB(); - -private: - EObjBPrivate* const d; -}; - -#endif diff --git a/Tests/QtAutogen/MocInclude/EObjB_p.hpp b/Tests/QtAutogen/MocInclude/EObjB_p.hpp deleted file mode 100644 index 84b1ea2..0000000 --- a/Tests/QtAutogen/MocInclude/EObjB_p.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef EOBJB_P_HPP -#define EOBJB_P_HPP - -#include - -class EObjBPrivate : public QObject -{ - Q_OBJECT -public: - EObjBPrivate(); - ~EObjBPrivate(); -}; - -#endif diff --git a/Tests/QtAutogen/MocInclude/LObjA.cpp b/Tests/QtAutogen/MocInclude/LObjA.cpp deleted file mode 100644 index 9aae991..0000000 --- a/Tests/QtAutogen/MocInclude/LObjA.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "LObjA.hpp" -#include "LObjA_p.h" - -class LObjALocal : public QObject -{ - Q_OBJECT -public: - LObjALocal(); - ~LObjALocal(); -}; - -LObjALocal::LObjALocal() -{ -} - -LObjALocal::~LObjALocal() -{ -} - -LObjAPrivate::LObjAPrivate() -{ - LObjALocal localObj; -} - -LObjAPrivate::~LObjAPrivate() -{ -} - -LObjA::LObjA() - : d(new LObjAPrivate) -{ -} - -LObjA::~LObjA() -{ - delete d; -} - -#include "LObjA.moc" diff --git a/Tests/QtAutogen/MocInclude/LObjA.hpp b/Tests/QtAutogen/MocInclude/LObjA.hpp deleted file mode 100644 index aac670c..0000000 --- a/Tests/QtAutogen/MocInclude/LObjA.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef LOBJA_HPP -#define LOBJA_HPP - -#include - -// Object source comes with a .moc include -class LObjAPrivate; -class LObjA : public QObject -{ - Q_OBJECT -public: - LObjA(); - ~LObjA(); - -private: - LObjAPrivate* const d; -}; - -#endif diff --git a/Tests/QtAutogen/MocInclude/LObjA_p.h b/Tests/QtAutogen/MocInclude/LObjA_p.h deleted file mode 100644 index 97113d6..0000000 --- a/Tests/QtAutogen/MocInclude/LObjA_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef LOBJA_P_HPP -#define LOBJA_P_HPP - -#include - -class LObjAPrivate : public QObject -{ - Q_OBJECT -public: - LObjAPrivate(); - ~LObjAPrivate(); -}; - -#endif diff --git a/Tests/QtAutogen/MocInclude/LObjB.cpp b/Tests/QtAutogen/MocInclude/LObjB.cpp deleted file mode 100644 index 7485d8f..0000000 --- a/Tests/QtAutogen/MocInclude/LObjB.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "LObjB.hpp" -#include "LObjB_p.h" - -class LObjBLocal : public QObject -{ - Q_OBJECT -public: - LObjBLocal(); - ~LObjBLocal(); -}; - -LObjBLocal::LObjBLocal() -{ -} - -LObjBLocal::~LObjBLocal() -{ -} - -LObjBPrivate::LObjBPrivate() -{ - LObjBLocal localObj; -} - -LObjBPrivate::~LObjBPrivate() -{ -} - -LObjB::LObjB() - : d(new LObjBPrivate) -{ -} - -LObjB::~LObjB() -{ - delete d; -} - -#include "LObjB.moc" -#include "moc_LObjB.cpp" diff --git a/Tests/QtAutogen/MocInclude/LObjB.hpp b/Tests/QtAutogen/MocInclude/LObjB.hpp deleted file mode 100644 index eb4e58d..0000000 --- a/Tests/QtAutogen/MocInclude/LObjB.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef LLObjB_HPP -#define LLObjB_HPP - -#include - -// Object source comes with a .moc and a _moc include -class LObjBPrivate; -class LObjB : public QObject -{ - Q_OBJECT -public: - LObjB(); - ~LObjB(); - -private: - LObjBPrivate* const d; -}; - -#endif diff --git a/Tests/QtAutogen/MocInclude/LObjB_p.h b/Tests/QtAutogen/MocInclude/LObjB_p.h deleted file mode 100644 index b88f40e..0000000 --- a/Tests/QtAutogen/MocInclude/LObjB_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef LOBJB_P_HPP -#define LOBJB_P_HPP - -#include - -class LObjBPrivate : public QObject -{ - Q_OBJECT -public: - LObjBPrivate(); - ~LObjBPrivate(); -}; - -#endif diff --git a/Tests/QtAutogen/MocInclude/ObjA.cpp b/Tests/QtAutogen/MocInclude/ObjA.cpp deleted file mode 100644 index 6f6b90e..0000000 --- a/Tests/QtAutogen/MocInclude/ObjA.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "ObjA.hpp" -#include "ObjA_p.h" - -ObjAPrivate::ObjAPrivate() -{ -} - -ObjAPrivate::~ObjAPrivate() -{ -} - -ObjA::ObjA() - : d(new ObjAPrivate) -{ -} - -ObjA::~ObjA() -{ - delete d; -} diff --git a/Tests/QtAutogen/MocInclude/ObjA.hpp b/Tests/QtAutogen/MocInclude/ObjA.hpp deleted file mode 100644 index f16c924..0000000 --- a/Tests/QtAutogen/MocInclude/ObjA.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef OBJA_HPP -#define OBJA_HPP - -#include - -// Object source comes without any _moc/.moc includes -class ObjAPrivate; -class ObjA : public QObject -{ - Q_OBJECT -public: - ObjA(); - ~ObjA(); - -private: - ObjAPrivate* const d; -}; - -#endif diff --git a/Tests/QtAutogen/MocInclude/ObjA_p.h b/Tests/QtAutogen/MocInclude/ObjA_p.h deleted file mode 100644 index d944bc6..0000000 --- a/Tests/QtAutogen/MocInclude/ObjA_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef OBJA_P_HPP -#define OBJA_P_HPP - -#include - -class ObjAPrivate : public QObject -{ - Q_OBJECT -public: - ObjAPrivate(); - ~ObjAPrivate(); -}; - -#endif diff --git a/Tests/QtAutogen/MocInclude/ObjB.cpp b/Tests/QtAutogen/MocInclude/ObjB.cpp deleted file mode 100644 index a6f2509..0000000 --- a/Tests/QtAutogen/MocInclude/ObjB.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "ObjB.hpp" -#include "ObjB_p.h" - -ObjBPrivate::ObjBPrivate() -{ -} - -ObjBPrivate::~ObjBPrivate() -{ -} - -ObjB::ObjB() - : d(new ObjBPrivate) -{ -} - -ObjB::~ObjB() -{ - delete d; -} - -#include "moc_ObjB.cpp" diff --git a/Tests/QtAutogen/MocInclude/ObjB.hpp b/Tests/QtAutogen/MocInclude/ObjB.hpp deleted file mode 100644 index 2ac8d17..0000000 --- a/Tests/QtAutogen/MocInclude/ObjB.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef ObjB_HPP -#define ObjB_HPP - -#include - -// Object source comes with a _moc include -class ObjBPrivate; -class ObjB : public QObject -{ - Q_OBJECT -public: - ObjB(); - ~ObjB(); - -private: - ObjBPrivate* const d; -}; - -#endif diff --git a/Tests/QtAutogen/MocInclude/ObjB_p.h b/Tests/QtAutogen/MocInclude/ObjB_p.h deleted file mode 100644 index 61ba604..0000000 --- a/Tests/QtAutogen/MocInclude/ObjB_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef OBJB_P_HPP -#define OBJB_P_HPP - -#include - -class ObjBPrivate : public QObject -{ - Q_OBJECT -public: - ObjBPrivate(); - ~ObjBPrivate(); -}; - -#endif diff --git a/Tests/QtAutogen/MocInclude/Relaxed/CMakeLists.txt b/Tests/QtAutogen/MocInclude/Relaxed/CMakeLists.txt new file mode 100644 index 0000000..048b79c --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Relaxed/CMakeLists.txt @@ -0,0 +1,17 @@ +# Enable relaxed mode +set(CMAKE_AUTOMOC_RELAXED_MODE TRUE) + +# Common test +set(COMMON_FUNCTION_NAME commonRelaxed) +configure_file( + "${COM_DIR}/common.cpp.in" + "${CMAKE_CURRENT_BINARY_DIR}/commonRelaxed.cpp") + +makeExecutable(libRelaxed) +target_sources(libRelaxed PRIVATE + "${CMAKE_CURRENT_BINARY_DIR}/commonRelaxed.cpp" + RObjA.cpp + RObjB.cpp + RObjC.cpp + relaxed.cpp + ) diff --git a/Tests/QtAutogen/MocIncludeRelaxed/RObjA.cpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjA.cpp similarity index 100% rename from Tests/QtAutogen/MocIncludeRelaxed/RObjA.cpp rename to Tests/QtAutogen/MocInclude/Relaxed/RObjA.cpp diff --git a/Tests/QtAutogen/MocIncludeRelaxed/RObjA.hpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjA.hpp similarity index 100% rename from Tests/QtAutogen/MocIncludeRelaxed/RObjA.hpp rename to Tests/QtAutogen/MocInclude/Relaxed/RObjA.hpp diff --git a/Tests/QtAutogen/MocIncludeRelaxed/RObjB.cpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjB.cpp similarity index 100% rename from Tests/QtAutogen/MocIncludeRelaxed/RObjB.cpp rename to Tests/QtAutogen/MocInclude/Relaxed/RObjB.cpp diff --git a/Tests/QtAutogen/MocIncludeRelaxed/RObjB.hpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjB.hpp similarity index 100% rename from Tests/QtAutogen/MocIncludeRelaxed/RObjB.hpp rename to Tests/QtAutogen/MocInclude/Relaxed/RObjB.hpp diff --git a/Tests/QtAutogen/MocIncludeRelaxed/RObjBExtra.hpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjBExtra.hpp similarity index 100% rename from Tests/QtAutogen/MocIncludeRelaxed/RObjBExtra.hpp rename to Tests/QtAutogen/MocInclude/Relaxed/RObjBExtra.hpp diff --git a/Tests/QtAutogen/MocIncludeRelaxed/RObjC.cpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjC.cpp similarity index 100% rename from Tests/QtAutogen/MocIncludeRelaxed/RObjC.cpp rename to Tests/QtAutogen/MocInclude/Relaxed/RObjC.cpp diff --git a/Tests/QtAutogen/MocIncludeRelaxed/RObjC.hpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjC.hpp similarity index 100% rename from Tests/QtAutogen/MocIncludeRelaxed/RObjC.hpp rename to Tests/QtAutogen/MocInclude/Relaxed/RObjC.hpp diff --git a/Tests/QtAutogen/MocInclude/Relaxed/relaxed.cpp b/Tests/QtAutogen/MocInclude/Relaxed/relaxed.cpp new file mode 100644 index 0000000..5a511b6 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Relaxed/relaxed.cpp @@ -0,0 +1,21 @@ +// AUTOMOC relaxed mode objects +#include "RObjA.hpp" +#include "RObjB.hpp" +#include "RObjC.hpp" + +// Forward declaration +bool commonRelaxed(); + +int main(int argv, char** args) +{ + // Common tests + if (!commonRelaxed()) { + return -1; + } + + // Relaxed tests + RObjA rObjA; + RObjB rObjB; + RObjC rObjC; + return 0; +} diff --git a/Tests/QtAutogen/MocInclude/SObjA.cpp b/Tests/QtAutogen/MocInclude/SObjA.cpp deleted file mode 100644 index 7e75bf9..0000000 --- a/Tests/QtAutogen/MocInclude/SObjA.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "SObjA.hpp" - -SObjA::SObjA() -{ -} - -SObjA::~SObjA() -{ -} - -#include "SObjA.moc" diff --git a/Tests/QtAutogen/MocInclude/SObjB.cpp.in b/Tests/QtAutogen/MocInclude/SObjB.cpp.in deleted file mode 100644 index b1cc12a..0000000 --- a/Tests/QtAutogen/MocInclude/SObjB.cpp.in +++ /dev/null @@ -1,11 +0,0 @@ -#include "SObjB.hpp" - -SObjB::SObjB() -{ -} - -SObjB::~SObjB() -{ -} - -#include "SObjB.moc" diff --git a/Tests/QtAutogen/MocInclude/SObjB.hpp.in b/Tests/QtAutogen/MocInclude/SObjB.hpp.in deleted file mode 100644 index 5e396ae..0000000 --- a/Tests/QtAutogen/MocInclude/SObjB.hpp.in +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef SOBJB_HPP -#define SOBJB_HPP - -#include - -// Object source includes externally generated .moc file -class SObjB : public QObject -{ - Q_OBJECT -public: - SObjB(); - ~SObjB(); -}; - -#endif diff --git a/Tests/QtAutogen/MocInclude/SObjC.cpp b/Tests/QtAutogen/MocInclude/SObjC.cpp deleted file mode 100644 index 1e8d397..0000000 --- a/Tests/QtAutogen/MocInclude/SObjC.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "SObjC.hpp" - -void SObjCLocalFunction(); - -class SObjCLocal : public QObject -{ - Q_OBJECT - -public: - SObjCLocal(); - ~SObjCLocal(); -}; - -SObjCLocal::SObjCLocal() -{ -} - -SObjCLocal::~SObjCLocal() -{ -} - -SObjC::SObjC() -{ - SObjCLocal localObject; - SObjCLocalFunction(); -} - -SObjC::~SObjC() -{ -} - -#include "SObjC.moc" -#include "moc_SObjC.cpp" -// Include moc_ file for which the header is SKIP_AUTOMOC enabled -#include "moc_SObjCExtra.cpp" diff --git a/Tests/QtAutogen/MocInclude/SObjC.hpp b/Tests/QtAutogen/MocInclude/SObjC.hpp deleted file mode 100644 index def0f9d..0000000 --- a/Tests/QtAutogen/MocInclude/SObjC.hpp +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef SOBJC_HPP -#define SOBJC_HPP - -#include - -// Object source includes externally generated .moc file -class SObjC : public QObject -{ - Q_OBJECT -public: - SObjC(); - ~SObjC(); -}; - -#endif diff --git a/Tests/QtAutogen/MocInclude/SObjCExtra.cpp b/Tests/QtAutogen/MocInclude/SObjCExtra.cpp deleted file mode 100644 index 55dd1c3..0000000 --- a/Tests/QtAutogen/MocInclude/SObjCExtra.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "SObjCExtra.hpp" - -class SObjCLocalExtra : public QObject -{ - Q_OBJECT - -public: - SObjCLocalExtra(); - ~SObjCLocalExtra(); -}; - -SObjCLocalExtra::SObjCLocalExtra() -{ -} - -SObjCLocalExtra::~SObjCLocalExtra() -{ -} - -SObjCExtra::SObjCExtra() -{ -} - -SObjCExtra::~SObjCExtra() -{ -} - -// Externally generated header moc -#include "SObjCExtra_extMoc.cpp" -// AUTOMOC generated source moc -#include "SObjCExtra.moc" diff --git a/Tests/QtAutogen/MocInclude/SObjCExtra.hpp b/Tests/QtAutogen/MocInclude/SObjCExtra.hpp deleted file mode 100644 index 08545ac..0000000 --- a/Tests/QtAutogen/MocInclude/SObjCExtra.hpp +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef SOBJCEXTRA_HPP -#define SOBJCEXTRA_HPP - -#include - -// Object source includes externally generated .moc file -class SObjCExtra : public QObject -{ - Q_OBJECT -public: - SObjCExtra(); - ~SObjCExtra(); -}; - -#endif diff --git a/Tests/QtAutogen/MocInclude/SObjCExtra.moc.in b/Tests/QtAutogen/MocInclude/SObjCExtra.moc.in deleted file mode 100644 index 00fc4aa..0000000 --- a/Tests/QtAutogen/MocInclude/SObjCExtra.moc.in +++ /dev/null @@ -1,4 +0,0 @@ - -void SObjCLocalFunction() -{ -} diff --git a/Tests/QtAutogen/MocInclude/Strict/CMakeLists.txt b/Tests/QtAutogen/MocInclude/Strict/CMakeLists.txt new file mode 100644 index 0000000..12c503f --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Strict/CMakeLists.txt @@ -0,0 +1,14 @@ +# Disable relaxed mode +set(CMAKE_AUTOMOC_RELAXED_MODE FALSE) + +# Common test +set(COMMON_FUNCTION_NAME commonStrict) +configure_file( + "${COM_DIR}/common.cpp.in" + "${CMAKE_CURRENT_BINARY_DIR}/commonStrict.cpp") + +makeExecutable(libStrict) +target_sources(libStrict PRIVATE + "${CMAKE_CURRENT_BINARY_DIR}/commonStrict.cpp" + strict.cpp + ) diff --git a/Tests/QtAutogen/MocInclude/Strict/strict.cpp b/Tests/QtAutogen/MocInclude/Strict/strict.cpp new file mode 100644 index 0000000..dd24bb0 --- /dev/null +++ b/Tests/QtAutogen/MocInclude/Strict/strict.cpp @@ -0,0 +1,7 @@ +// Forward declaration +bool commonStrict(); + +int main(int argv, char** args) +{ + return commonStrict() ? 0 : -1; +} diff --git a/Tests/QtAutogen/MocInclude/main.cpp b/Tests/QtAutogen/MocInclude/main.cpp new file mode 100644 index 0000000..371c5fd --- /dev/null +++ b/Tests/QtAutogen/MocInclude/main.cpp @@ -0,0 +1,9 @@ + +// Forward declaration +bool libStrict(); +bool libRelaxed(); + +int main(int argv, char** args) +{ + return (libStrict() && libRelaxed()) ? 0 : -1; +} diff --git a/Tests/QtAutogen/MocInclude/shared.cmake b/Tests/QtAutogen/MocInclude/shared.cmake deleted file mode 100644 index 2ca2841..0000000 --- a/Tests/QtAutogen/MocInclude/shared.cmake +++ /dev/null @@ -1,71 +0,0 @@ -# Test moc include patterns -include_directories("../MocInclude") -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -# Generate .moc file externally and enabled SKIP_AUTOMOC on the file -qtx_generate_moc( - ${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjA.hpp - ${CMAKE_CURRENT_BINARY_DIR}/SObjA.moc) -set_property(SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjA.cpp PROPERTY SKIP_AUTOMOC ON) - -# Generate .moc file externally from generated source file -# and enabled SKIP_AUTOMOC on the source file -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/SObjB.hpp - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjB.hpp.in - ${CMAKE_CURRENT_BINARY_DIR}/SObjB.hpp) -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/SObjB.cpp - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjB.cpp.in - ${CMAKE_CURRENT_BINARY_DIR}/SObjB.cpp) -qtx_generate_moc( - ${CMAKE_CURRENT_BINARY_DIR}/SObjB.hpp - ${CMAKE_CURRENT_BINARY_DIR}/SObjB.moc) -set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/SObjB.cpp PROPERTY SKIP_AUTOMOC ON) - -# Generate moc file externally and enabled SKIP_AUTOMOC on the header -qtx_generate_moc( - ${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjCExtra.hpp - ${CMAKE_CURRENT_BINARY_DIR}/SObjCExtra_extMoc.cpp) -set_property( - SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjCExtra.hpp - PROPERTY SKIP_AUTOMOC ON) -# Custom target to depend on -set(SOBJC_MOC ${CMAKE_CURRENT_BINARY_DIR}/moc_SObjCExtra.cpp) -add_custom_target("${MOC_INCLUDE_NAME}_SOBJC" - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/SObjCExtra_extMoc.cpp - BYPRODUCTS ${SOBJC_MOC} - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjCExtra.moc.in - ${SOBJC_MOC}) - -# MOC_INCLUDE_NAME must be defined by the includer -add_executable(${MOC_INCLUDE_NAME} - # Common sources - ../MocInclude/ObjA.cpp - ../MocInclude/ObjB.cpp - - ../MocInclude/LObjA.cpp - ../MocInclude/LObjB.cpp - - ../MocInclude/EObjA.cpp - ../MocInclude/EObjAExtra.cpp - ../MocInclude/EObjB.cpp - ../MocInclude/subExtra/EObjBExtra.cpp - - ../MocInclude/SObjA.cpp - ${CMAKE_CURRENT_BINARY_DIR}/SObjA.moc - ${CMAKE_CURRENT_BINARY_DIR}/SObjB.cpp - ${CMAKE_CURRENT_BINARY_DIR}/SObjB.moc - ../MocInclude/SObjC.cpp - ../MocInclude/SObjCExtra.hpp - ../MocInclude/SObjCExtra.cpp - - ../MocInclude/subGlobal/GObj.cpp - main.cpp -) -add_dependencies(${MOC_INCLUDE_NAME} "${MOC_INCLUDE_NAME}_SOBJC") -target_link_libraries(${MOC_INCLUDE_NAME} ${QT_LIBRARIES}) -set_target_properties(${MOC_INCLUDE_NAME} PROPERTIES AUTOMOC ON) diff --git a/Tests/QtAutogen/MocInclude/subExtra/EObjBExtra.cpp b/Tests/QtAutogen/MocInclude/subExtra/EObjBExtra.cpp deleted file mode 100644 index c697866..0000000 --- a/Tests/QtAutogen/MocInclude/subExtra/EObjBExtra.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "EObjBExtra.hpp" -#include "EObjBExtra_p.hpp" - -EObjBExtraPrivate::EObjBExtraPrivate() -{ -} - -EObjBExtraPrivate::~EObjBExtraPrivate() -{ -} - -EObjBExtra::EObjBExtra() - : d(new EObjBExtraPrivate) -{ -} - -EObjBExtra::~EObjBExtra() -{ - delete d; -} diff --git a/Tests/QtAutogen/MocInclude/subExtra/EObjBExtra.hpp b/Tests/QtAutogen/MocInclude/subExtra/EObjBExtra.hpp deleted file mode 100644 index 3798d7f..0000000 --- a/Tests/QtAutogen/MocInclude/subExtra/EObjBExtra.hpp +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef EOBJBEXTRA_HPP -#define EOBJBEXTRA_HPP - -#include - -class EObjBExtraPrivate; -class EObjBExtra : public QObject -{ - Q_OBJECT -public: - EObjBExtra(); - ~EObjBExtra(); - -private: - EObjBExtraPrivate* const d; -}; - -#endif diff --git a/Tests/QtAutogen/MocInclude/subExtra/EObjBExtra_p.hpp b/Tests/QtAutogen/MocInclude/subExtra/EObjBExtra_p.hpp deleted file mode 100644 index 3231fac..0000000 --- a/Tests/QtAutogen/MocInclude/subExtra/EObjBExtra_p.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef EOBJBEXTRA_P_HPP -#define EOBJBEXTRA_P_HPP - -#include - -class EObjBExtraPrivate : public QObject -{ - Q_OBJECT -public: - EObjBExtraPrivate(); - ~EObjBExtraPrivate(); -}; - -#endif diff --git a/Tests/QtAutogen/MocInclude/subGlobal/GObj.cpp b/Tests/QtAutogen/MocInclude/subGlobal/GObj.cpp deleted file mode 100644 index 6b92f21..0000000 --- a/Tests/QtAutogen/MocInclude/subGlobal/GObj.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "GObj.hpp" -#include "GObj_p.hpp" - -namespace subGlobal { - -class GObjLocal : public QObject -{ - Q_OBJECT -public: - GObjLocal(); - ~GObjLocal(); -}; - -GObjLocal::GObjLocal() -{ -} - -GObjLocal::~GObjLocal() -{ -} - -GObjPrivate::GObjPrivate() -{ -} - -GObjPrivate::~GObjPrivate() -{ -} - -GObj::GObj() -{ - GObjLocal localObj; -} - -GObj::~GObj() -{ -} -} - -// For the local QObject -#include "GObj.moc" diff --git a/Tests/QtAutogen/MocInclude/subGlobal/GObj.hpp b/Tests/QtAutogen/MocInclude/subGlobal/GObj.hpp deleted file mode 100644 index 2f9ee82..0000000 --- a/Tests/QtAutogen/MocInclude/subGlobal/GObj.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef GOBJ_HPP -#define GOBJ_HPP - -#include - -namespace subGlobal { - -class GObj : public QObject -{ - Q_OBJECT -public: - GObj(); - ~GObj(); -}; -} - -#endif diff --git a/Tests/QtAutogen/MocInclude/subGlobal/GObj_p.hpp b/Tests/QtAutogen/MocInclude/subGlobal/GObj_p.hpp deleted file mode 100644 index 4a43755..0000000 --- a/Tests/QtAutogen/MocInclude/subGlobal/GObj_p.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef GOBJ_P_HPP -#define GOBJ_P_HPP - -#include - -namespace subGlobal { - -class GObjPrivate : public QObject -{ - Q_OBJECT -public: - GObjPrivate(); - ~GObjPrivate(); -}; -} - -#endif diff --git a/Tests/QtAutogen/MocIncludeRelaxed/CMakeLists.txt b/Tests/QtAutogen/MocIncludeRelaxed/CMakeLists.txt deleted file mode 100644 index 8b4da34..0000000 --- a/Tests/QtAutogen/MocIncludeRelaxed/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -cmake_minimum_required(VERSION 3.10) -project(MocIncludeRelaxed) -include("../AutogenCoreTest.cmake") - -# Test moc include patterns -set(CMAKE_AUTOMOC_RELAXED_MODE TRUE) - -# Shared executable -set(MOC_INCLUDE_NAME "mocIncludeRelaxed") -include(${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/shared.cmake) - -# Relaxed only executable -add_executable(mocIncludeRelaxedOnly - RObjA.cpp - RObjB.cpp - RObjC.cpp - RMain.cpp -) -target_link_libraries(mocIncludeRelaxedOnly ${QT_LIBRARIES}) -set_target_properties(mocIncludeRelaxedOnly PROPERTIES AUTOMOC ON) diff --git a/Tests/QtAutogen/MocIncludeRelaxed/RMain.cpp b/Tests/QtAutogen/MocIncludeRelaxed/RMain.cpp deleted file mode 100644 index 5b2c070..0000000 --- a/Tests/QtAutogen/MocIncludeRelaxed/RMain.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// Relaxed AUTOMOC objects -#include "RObjA.hpp" -#include "RObjB.hpp" -#include "RObjC.hpp" - -int main(int argv, char** args) -{ - RObjA rObjA; - RObjB rObjB; - RObjC rObjC; - return 0; -} diff --git a/Tests/QtAutogen/MocIncludeRelaxed/main.cpp b/Tests/QtAutogen/MocIncludeRelaxed/main.cpp deleted file mode 100644 index 5a3148d..0000000 --- a/Tests/QtAutogen/MocIncludeRelaxed/main.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "EObjA.hpp" -#include "EObjB.hpp" -#include "LObjA.hpp" -#include "LObjB.hpp" -#include "ObjA.hpp" -#include "ObjB.hpp" -#include "SObjA.hpp" -#include "SObjB.hpp" -#include "subGlobal/GObj.hpp" - -int main(int argv, char** args) -{ - subGlobal::GObj gObj; - ObjA objA; - ObjB objB; - LObjA lObjA; - LObjB lObjB; - EObjA eObjA; - EObjB eObjB; - SObjA sObjA; - SObjB sObjB; - return 0; -} - -// Header in global subdirectory -#include "subGlobal/moc_GObj.cpp" diff --git a/Tests/QtAutogen/MocIncludeStrict/CMakeLists.txt b/Tests/QtAutogen/MocIncludeStrict/CMakeLists.txt deleted file mode 100644 index d0aaebf..0000000 --- a/Tests/QtAutogen/MocIncludeStrict/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -cmake_minimum_required(VERSION 3.10) -project(MocIncludeStrict) -include("../AutogenCoreTest.cmake") - -# Test moc include patterns -set(CMAKE_AUTOMOC_RELAXED_MODE FALSE) - -# Shared executable -set(MOC_INCLUDE_NAME "mocIncludeStrict") -include(${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/shared.cmake) diff --git a/Tests/QtAutogen/MocIncludeStrict/main.cpp b/Tests/QtAutogen/MocIncludeStrict/main.cpp deleted file mode 100644 index 5a3148d..0000000 --- a/Tests/QtAutogen/MocIncludeStrict/main.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "EObjA.hpp" -#include "EObjB.hpp" -#include "LObjA.hpp" -#include "LObjB.hpp" -#include "ObjA.hpp" -#include "ObjB.hpp" -#include "SObjA.hpp" -#include "SObjB.hpp" -#include "subGlobal/GObj.hpp" - -int main(int argv, char** args) -{ - subGlobal::GObj gObj; - ObjA objA; - ObjB objB; - LObjA lObjA; - LObjB lObjB; - EObjA eObjA; - EObjB eObjB; - SObjA sObjA; - SObjB sObjB; - return 0; -} - -// Header in global subdirectory -#include "subGlobal/moc_GObj.cpp" diff --git a/Tests/QtAutogen/Tests.cmake b/Tests/QtAutogen/Tests.cmake index 6771828..04b50ab 100644 --- a/Tests/QtAutogen/Tests.cmake +++ b/Tests/QtAutogen/Tests.cmake @@ -32,8 +32,7 @@ ADD_AUTOGEN_TEST(UicSkipSource) if(QT_TEST_ALLOW_QT_MACROS) ADD_AUTOGEN_TEST(MocCMP0071) - ADD_AUTOGEN_TEST(MocIncludeRelaxed mocIncludeRelaxed) - ADD_AUTOGEN_TEST(MocIncludeStrict mocIncludeStrict) + ADD_AUTOGEN_TEST(MocInclude) ADD_AUTOGEN_TEST(MocSkipSource) endif() https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d018d27c101869e4e2449f938df89d4f97c5b73c commit d018d27c101869e4e2449f938df89d4f97c5b73c Author: Sebastian Holtermann AuthorDate: Fri Sep 13 15:17:24 2019 +0200 Commit: Sebastian Holtermann CommitDate: Mon Sep 16 18:18:48 2019 +0200 Autogen: Add moc path prefix generation (AUTOMOC_PATH_PREFIX) The new `AUTOMOC_PATH_PREFIX` boolean target property enables automatic generation of the path prefix `-p` option for `moc`. `AUTOMOC_PATH_PREFIX` is initialized from the variable `CMAKE_AUTOMOC_PATH_PREFIX`, which is ON by default. When `AUTOMOC_PATH_PREFIX` is enabled, CMake tests if a `moc`ed header file is in one of the include directories. If so, then the `-p` option, with the relative path of the header parent directory to the respective include directory, is added to the `moc` command. If the header file is not in an include directory, the `-p` option is omitted. Closes: #18815 "AUTOMOC: generated files include full relative path, breaking certain reproducible builds" diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake index ddfc7bd..77d8cfd 100644 --- a/Modules/CMakeGenericSystem.cmake +++ b/Modules/CMakeGenericSystem.cmake @@ -26,6 +26,7 @@ set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a") set(CMAKE_AUTOGEN_ORIGIN_DEPENDS ON) set(CMAKE_AUTOMOC_COMPILER_PREDEFINES ON) +set(CMAKE_AUTOMOC_PATH_PREFIX ON) set(CMAKE_AUTOMOC_MACRO_NAMES "Q_OBJECT" "Q_GADGET" "Q_NAMESPACE") # basically all general purpose OSs support shared libs diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 89ef588..1404554 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1376,6 +1376,8 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() ofs.Write("AM_MOC_OPTIONS", this->GenTarget->GetSafeProperty("AUTOMOC_MOC_OPTIONS")); ofs.Write("AM_MOC_RELAXED_MODE", MfDef("CMAKE_AUTOMOC_RELAXED_MODE")); + ofs.Write("AM_MOC_PATH_PREFIX", + this->GenTarget->GetSafeProperty("AUTOMOC_PATH_PREFIX")); ofs.Write("AM_MOC_MACRO_NAMES", this->GenTarget->GetSafeProperty("AUTOMOC_MACRO_NAMES")); ofs.Write("AM_MOC_DEPEND_FILTERS", diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 7d6ad47..4e4875e 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -279,12 +279,10 @@ void cmQtAutoMocUic::JobMocPredefsT::Process() { // Compose command std::vector cmd = MocConst().PredefsCmd; - // Add includes - cmAppend(cmd, MocConst().Includes); // Add definitions - for (std::string const& def : MocConst().Definitions) { - cmd.emplace_back("-D" + def); - } + cmAppend(cmd, MocConst().OptionsDefinitions); + // Add includes + cmAppend(cmd, MocConst().OptionsIncludes); // Execute command if (!RunProcess(GenT::MOC, result, cmd, reason.get())) { LogCommandError(GenT::MOC, @@ -1385,17 +1383,50 @@ void cmQtAutoMocUic::JobCompileMocT::Process() // Compose moc command std::vector cmd; - cmd.push_back(MocConst().Executable); - // Add options - cmAppend(cmd, MocConst().AllOptions); - // Add predefs include - if (!MocConst().PredefsFileAbs.empty()) { - cmd.emplace_back("--include"); - cmd.push_back(MocConst().PredefsFileAbs); + { + // Reserve large enough + cmd.reserve(MocConst().OptionsDefinitions.size() + + MocConst().OptionsIncludes.size() + + MocConst().OptionsExtra.size() + 16); + cmd.push_back(MocConst().Executable); + // Add definitions + cmAppend(cmd, MocConst().OptionsDefinitions); + // Add includes + cmAppend(cmd, MocConst().OptionsIncludes); + // Add predefs include + if (!MocConst().PredefsFileAbs.empty()) { + cmd.emplace_back("--include"); + cmd.push_back(MocConst().PredefsFileAbs); + } + // Add path prefix on demand + if (MocConst().PathPrefix && Mapping->SourceFile->IsHeader) { + for (std::string const& dir : MocConst().IncludePaths) { + cm::string_view prefix = sourceFile; + if (cmHasPrefix(prefix, dir)) { + prefix.remove_prefix(dir.size()); + if (cmHasPrefix(prefix, '/')) { + prefix.remove_prefix(1); + auto slashPos = prefix.rfind('/'); + if (slashPos != cm::string_view::npos) { + cmd.emplace_back("-p"); + cmd.emplace_back(prefix.substr(0, slashPos)); + } else { + cmd.emplace_back("-p"); + cmd.emplace_back("./"); + } + break; + } + } + } + } + // Add extra options + cmAppend(cmd, MocConst().OptionsExtra); + // Add output file + cmd.emplace_back("-o"); + cmd.push_back(outputFile); + // Add source file + cmd.push_back(sourceFile); } - cmd.emplace_back("-o"); - cmd.push_back(outputFile); - cmd.push_back(sourceFile); // Execute moc command cmWorkerPool::ProcessResultT result; @@ -1654,8 +1685,11 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) } MocConst_.Definitions = InfoGetConfigList("AM_MOC_DEFINITIONS"); MocConst_.IncludePaths = InfoGetConfigList("AM_MOC_INCLUDES"); - MocConst_.Options = InfoGetList("AM_MOC_OPTIONS"); + MocConst_.OptionsExtra = InfoGetList("AM_MOC_OPTIONS"); + MocConst_.RelaxedMode = InfoGetBool("AM_MOC_RELAXED_MODE"); + MocConst_.PathPrefix = InfoGetBool("AM_MOC_PATH_PREFIX"); + for (std::string const& item : InfoGetList("AM_MOC_MACRO_NAMES")) { MocConst_.MacroFilters.emplace_back( item, ("[\n][ \t]*{?[ \t]*" + item).append("[^a-zA-Z0-9_]")); @@ -1846,9 +1880,9 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) // Compose moc includes list { + // Compute framework paths std::set frameworkPaths; for (std::string const& path : MocConst().IncludePaths) { - MocConst_.Includes.push_back("-I" + path); // Extract framework path if (cmHasLiteralSuffix(path, ".framework/Headers")) { // Go up twice to get to the framework root @@ -1858,26 +1892,26 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) pathComponents.begin(), pathComponents.end() - 2)); } } + // Reserve options + MocConst_.OptionsIncludes.reserve(MocConst().IncludePaths.size() + + frameworkPaths.size() * 2); + // Append includes + for (std::string const& path : MocConst().IncludePaths) { + MocConst_.OptionsIncludes.emplace_back("-I" + path); + } // Append framework includes for (std::string const& path : frameworkPaths) { - MocConst_.Includes.emplace_back("-F"); - MocConst_.Includes.push_back(path); + MocConst_.OptionsIncludes.emplace_back("-F"); + MocConst_.OptionsIncludes.push_back(path); } } - // Setup single list with all options + + // Compose moc definitions list { - // Add includes - MocConst_.AllOptions.insert(MocConst_.AllOptions.end(), - MocConst().Includes.begin(), - MocConst().Includes.end()); - // Add definitions + MocConst_.OptionsDefinitions.reserve(MocConst().Definitions.size()); for (std::string const& def : MocConst().Definitions) { - MocConst_.AllOptions.push_back("-D" + def); + MocConst_.OptionsDefinitions.emplace_back("-D" + def); } - // Add options - MocConst_.AllOptions.insert(MocConst_.AllOptions.end(), - MocConst().Options.begin(), - MocConst().Options.end()); } } @@ -1971,10 +2005,18 @@ void cmQtAutoMocUic::SettingsFileRead() if (MocConst_.Enabled) { cryptoHash.Initialize(); cha(MocConst().Executable); - std::for_each(MocConst().AllOptions.begin(), MocConst().AllOptions.end(), - cha); - std::for_each(MocConst().PredefsCmd.begin(), MocConst().PredefsCmd.end(), - cha); + for (auto const& item : MocConst().OptionsDefinitions) { + cha(item); + } + for (auto const& item : MocConst().OptionsIncludes) { + cha(item); + } + for (auto const& item : MocConst().OptionsExtra) { + cha(item); + } + for (auto const& item : MocConst().PredefsCmd) { + cha(item); + } for (auto const& filter : MocConst().DependFilters) { cha(filter.Key); } diff --git a/Source/cmQtAutoMocUic.h b/Source/cmQtAutoMocUic.h index 71cd5f5..43123f2 100644 --- a/Source/cmQtAutoMocUic.h +++ b/Source/cmQtAutoMocUic.h @@ -212,16 +212,17 @@ public: bool Enabled = false; bool SettingsChanged = false; bool RelaxedMode = false; + bool PathPrefix = false; cmFileTime ExecutableTime; std::string Executable; std::string CompFileAbs; std::string PredefsFileAbs; std::unordered_set SkipList; std::vector IncludePaths; - std::vector Includes; std::vector Definitions; - std::vector Options; - std::vector AllOptions; + std::vector OptionsIncludes; + std::vector OptionsDefinitions; + std::vector OptionsExtra; std::vector PredefsCmd; std::vector DependFilters; std::vector MacroFilters; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 6637e32..86873ed 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -312,6 +312,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, initProp("AUTOMOC_MACRO_NAMES"); initProp("AUTOMOC_MOC_OPTIONS"); initProp("AUTOUIC_OPTIONS"); + initProp("AUTOMOC_PATH_PREFIX"); initProp("AUTOUIC_SEARCH_PATHS"); initProp("AUTORCC_OPTIONS"); initProp("LINK_DEPENDS_NO_SHARED"); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=77983c814725317e990315be8bc8d5b93fa6ffbd commit 77983c814725317e990315be8bc8d5b93fa6ffbd Author: Sebastian Holtermann AuthorDate: Fri Sep 13 12:51:07 2019 +0200 Commit: Sebastian Holtermann CommitDate: Mon Sep 16 18:18:48 2019 +0200 Autogen: Add IsHeader flag to SourceFileT class diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 0fe83e5..7d6ad47 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -599,7 +599,7 @@ bool cmQtAutoMocUic::JobEvalCacheMocT::EvalHeader(SourceFileHandleT source) } // Register mapping in headers map - RegisterMapping(handle, true); + RegisterMapping(handle); } return true; @@ -690,7 +690,7 @@ bool cmQtAutoMocUic::JobEvalCacheMocT::EvalSource( "This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n")); // Create mapping - if (!RegisterIncluded(incKey.Key, source, source, false)) { + if (!RegisterIncluded(incKey.Key, source, source)) { return false; } continue; @@ -701,7 +701,7 @@ bool cmQtAutoMocUic::JobEvalCacheMocT::EvalSource( continue; } // Create mapping - if (!RegisterIncluded(incKey.Key, source, std::move(headerHandle), true)) { + if (!RegisterIncluded(incKey.Key, source, std::move(headerHandle))) { return false; } } @@ -714,7 +714,7 @@ bool cmQtAutoMocUic::JobEvalCacheMocT::EvalSource( bool const ownMoc = (incKey.Base == sourceBase); if (ownMoc && !parseData.Macro.empty()) { // Create mapping for the regular use case - if (!RegisterIncluded(incKey.Key, source, source, false)) { + if (!RegisterIncluded(incKey.Key, source, source)) { return false; } continue; @@ -767,8 +767,7 @@ bool cmQtAutoMocUic::JobEvalCacheMocT::EvalSource( "This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n")); } // Create mapping - if (!RegisterIncluded(incKey.Key, source, std::move(headerHandle), - true)) { + if (!RegisterIncluded(incKey.Key, source, std::move(headerHandle))) { return false; } } @@ -798,7 +797,7 @@ bool cmQtAutoMocUic::JobEvalCacheMocT::EvalSource( MocConst().MacrosString(), " macro.")); } // Create mapping - if (!RegisterIncluded(incKey.Key, source, source, false)) { + if (!RegisterIncluded(incKey.Key, source, source)) { return false; } } @@ -843,6 +842,7 @@ bool cmQtAutoMocUic::JobEvalCacheMocT::FindIncludedHeader( if (!handle) { handle = std::make_shared(testPath); handle->FileTime = fileTime; + handle->IsHeader = true; handle->Moc = true; } headerHandle = handle; @@ -873,7 +873,7 @@ bool cmQtAutoMocUic::JobEvalCacheMocT::FindIncludedHeader( bool cmQtAutoMocUic::JobEvalCacheMocT::RegisterIncluded( std::string const& includeString, SourceFileHandleT includerFileHandle, - SourceFileHandleT sourceFileHandle, bool sourceIsHeader) const + SourceFileHandleT sourceFileHandle) const { // Check if this file is already included MappingHandleT& handle = MocEval().Includes[includeString]; @@ -915,15 +915,16 @@ bool cmQtAutoMocUic::JobEvalCacheMocT::RegisterIncluded( handle->OutputFile = Gen()->AbsoluteIncludePath(includeString); // Register mapping in sources/headers map - RegisterMapping(handle, sourceIsHeader); + RegisterMapping(handle); return true; } void cmQtAutoMocUic::JobEvalCacheMocT::RegisterMapping( - MappingHandleT mappingHandle, bool sourceIsHeader) const + MappingHandleT mappingHandle) const { - auto& regMap = - sourceIsHeader ? MocEval().HeaderMappings : MocEval().SourceMappings; + auto& regMap = mappingHandle->SourceFile->IsHeader + ? MocEval().HeaderMappings + : MocEval().SourceMappings; // Check if source file already gets mapped auto& regHandle = regMap[mappingHandle->SourceFile->FileName]; if (!regHandle) { @@ -1738,81 +1739,89 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) } } - // - Headers and sources + // Headers { - auto makeSource = [this, &LogInfoError]( - std::string const& fileName, - std::string const& fileFlags) -> SourceFileHandleT { + // Get file lists + cm::string_view const keyFiles = "AM_HEADERS"; + cm::string_view const keyFlags = "AM_HEADERS_FLAGS"; + std::vector files = InfoGetList(keyFiles); + std::vector flags = InfoGetList(keyFlags); + std::vector builds; + if (!MatchSizes(keyFiles, keyFlags, files.size(), flags.size())) { + return false; + } + if (MocConst().Enabled) { + cm::string_view const keyPaths = "AM_HEADERS_BUILD_PATHS"; + builds = InfoGetList(keyPaths); + if (!MatchSizes(keyFiles, keyPaths, files.size(), builds.size())) { + return false; + } + } + + // Process file lists + for (std::size_t ii = 0; ii != files.size(); ++ii) { + std::string& fileName(files[ii]); + std::string const& fileFlags(flags[ii]); if (fileFlags.size() != 2) { - LogInfoError("Invalid file flags string size"); - return SourceFileHandleT(); + LogInfoError(cmStrCat("Invalid flags string size ", fileFlags.size(), + "in ", keyFlags)); + return false; } cmFileTime fileTime; if (!fileTime.Load(fileName)) { - LogInfoError(cmStrCat("The source file ", this->MessagePath(fileName), + LogInfoError(cmStrCat("The header file ", this->MessagePath(fileName), " does not exist.")); - return SourceFileHandleT(); - } - SourceFileHandleT sfh = std::make_shared(fileName); - sfh->FileTime = fileTime; - sfh->Moc = (fileFlags[0] == 'M'); - sfh->Uic = (fileFlags[1] == 'U'); - return sfh; - }; - - // Headers - { - // Get file lists - cm::string_view const keyFiles = "AM_HEADERS"; - cm::string_view const keyFlags = "AM_HEADERS_FLAGS"; - std::vector files = InfoGetList(keyFiles); - std::vector flags = InfoGetList(keyFlags); - std::vector builds; - if (!MatchSizes(keyFiles, keyFlags, files.size(), flags.size())) { return false; } - if (MocConst().Enabled) { - cm::string_view const keyPaths = "AM_HEADERS_BUILD_PATHS"; - builds = InfoGetList(keyPaths); - if (!MatchSizes(keyFiles, keyPaths, files.size(), builds.size())) { - return false; - } - } - // Process file lists - for (std::size_t ii = 0; ii != files.size(); ++ii) { - std::string& fileName(files[ii]); - SourceFileHandleT sfh = makeSource(fileName, flags[ii]); - if (!sfh) { - return false; - } - if (MocConst().Enabled) { - sfh->BuildPath = std::move(builds[ii]); - if (sfh->BuildPath.empty()) { - return LogInfoError("Header file build path is empty"); - } + + SourceFileHandleT sourceHandle = std::make_shared(fileName); + sourceHandle->FileTime = fileTime; + sourceHandle->IsHeader = true; + sourceHandle->Moc = (fileFlags[0] == 'M'); + sourceHandle->Uic = (fileFlags[1] == 'U'); + + if (sourceHandle->Moc && MocConst().Enabled) { + sourceHandle->BuildPath = std::move(builds[ii]); + if (sourceHandle->BuildPath.empty()) { + return LogInfoError("Header file build path is empty"); } - BaseEval().Headers.emplace(std::move(fileName), std::move(sfh)); } + BaseEval().Headers.emplace(std::move(fileName), std::move(sourceHandle)); } + } - // Sources - { - cm::string_view const keyFiles = "AM_SOURCES"; - cm::string_view const keyFlags = "AM_SOURCES_FLAGS"; - std::vector files = InfoGetList(keyFiles); - std::vector flags = InfoGetList(keyFlags); - if (!MatchSizes(keyFiles, keyFlags, files.size(), flags.size())) { + // Sources + { + cm::string_view const keyFiles = "AM_SOURCES"; + cm::string_view const keyFlags = "AM_SOURCES_FLAGS"; + std::vector files = InfoGetList(keyFiles); + std::vector flags = InfoGetList(keyFlags); + if (!MatchSizes(keyFiles, keyFlags, files.size(), flags.size())) { + return false; + } + + // Process file lists + for (std::size_t ii = 0; ii != files.size(); ++ii) { + std::string& fileName(files[ii]); + std::string const& fileFlags(flags[ii]); + if (fileFlags.size() != 2) { + LogInfoError(cmStrCat("Invalid flags string size ", fileFlags.size(), + "in ", keyFlags)); return false; } - // Process file lists - for (std::size_t ii = 0; ii != files.size(); ++ii) { - std::string& fileName(files[ii]); - SourceFileHandleT sfh = makeSource(fileName, flags[ii]); - if (!sfh) { - return false; - } - BaseEval().Sources.emplace(std::move(fileName), std::move(sfh)); + cmFileTime fileTime; + if (!fileTime.Load(fileName)) { + LogInfoError(cmStrCat("The source file ", this->MessagePath(fileName), + " does not exist.")); + return false; } + + SourceFileHandleT sourceHandle = std::make_shared(fileName); + sourceHandle->FileTime = fileTime; + sourceHandle->IsHeader = false; + sourceHandle->Moc = (fileFlags[0] == 'M'); + sourceHandle->Uic = (fileFlags[1] == 'U'); + BaseEval().Sources.emplace(std::move(fileName), std::move(sourceHandle)); } } diff --git a/Source/cmQtAutoMocUic.h b/Source/cmQtAutoMocUic.h index d77e774..71cd5f5 100644 --- a/Source/cmQtAutoMocUic.h +++ b/Source/cmQtAutoMocUic.h @@ -136,6 +136,7 @@ public: cmFileTime FileTime; ParseCacheT::FileHandleT ParseData; std::string BuildPath; + bool IsHeader = false; bool Moc = false; bool Uic = false; }; @@ -402,10 +403,8 @@ public: cm::string_view includeBase); bool RegisterIncluded(std::string const& includeString, SourceFileHandleT includerFileHandle, - SourceFileHandleT sourceFileHandle, - bool sourceIsHeader) const; - void RegisterMapping(MappingHandleT mappingHandle, - bool sourceIsHeader) const; + SourceFileHandleT sourceFileHandle) const; + void RegisterMapping(MappingHandleT mappingHandle) const; std::string MessageHeader(cm::string_view headerBase) const; }; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f9e5441eb43d3238211685cded447141082e37b8 commit f9e5441eb43d3238211685cded447141082e37b8 Author: Sebastian Holtermann AuthorDate: Mon Sep 9 17:04:51 2019 +0200 Commit: Sebastian Holtermann CommitDate: Mon Sep 16 18:18:48 2019 +0200 Autogen: Abbreviate file paths in messages This introduces the `cmQtAutoGenerator::MessagePath` method, that abbreviates paths by placing a - "SRC:" prefix in place of the project source directory - "BIN:" prefix in place of the project binary directory The method is used in `AUTO{MOC,UIC,RCC}` when paths are displayed in messages. This makes the messages generated by `AUTO{MOC,UIC,RCC}` shorter and improves their readability. diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 7012ef6..89ef588 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1410,6 +1410,11 @@ bool cmQtAutoGenInitializer::SetupWriteRccInfo() for (Qrc const& qrc : this->Rcc.Qrcs) { InfoWriter ofs(qrc.InfoFile); if (ofs) { + // Utility lambdas + auto MfDef = [this](const char* key) { + return this->Makefile->GetSafeDefinition(key); + }; + // Write ofs.Write("# Configurations\n"); ofs.Write("ARCC_MULTI_CONFIG", this->MultiConfig ? "TRUE" : "FALSE"); @@ -1419,6 +1424,8 @@ bool cmQtAutoGenInitializer::SetupWriteRccInfo() ofs.WriteConfig("ARCC_SETTINGS_FILE", qrc.ConfigSettingsFile); ofs.Write("# Directories\n"); + ofs.Write("ARCC_CMAKE_SOURCE_DIR", MfDef("CMAKE_SOURCE_DIR")); + ofs.Write("ARCC_CMAKE_BINARY_DIR", MfDef("CMAKE_BINARY_DIR")); ofs.Write("ARCC_BUILD_DIR", this->Dir.Build); ofs.Write("ARCC_INCLUDE_DIR", this->Dir.Include); ofs.WriteConfig("ARCC_INCLUDE_DIR", this->Dir.ConfigInclude); diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx index 80b8741..086b68c 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -93,32 +93,18 @@ void cmQtAutoGenerator::Logger::Warning(GenT genType, } } -void cmQtAutoGenerator::Logger::WarningFile(GenT genType, - cm::string_view filename, - cm::string_view message) const -{ - Warning(genType, cmStrCat(" ", Quoted(filename), '\n', message)); -} - void cmQtAutoGenerator::Logger::Error(GenT genType, cm::string_view message) const { std::string msg = - cmStrCat(HeadLine(cmStrCat(GeneratorName(genType), " error")), message, - cmHasSuffix(message, '\n') ? "\n" : "\n\n"); + cmStrCat('\n', HeadLine(cmStrCat(GeneratorName(genType), " error")), + message, cmHasSuffix(message, '\n') ? "\n" : "\n\n"); { std::lock_guard lock(Mutex_); cmSystemTools::Stderr(msg); } } -void cmQtAutoGenerator::Logger::ErrorFile(GenT genType, - cm::string_view filename, - cm::string_view message) const -{ - Error(genType, cmStrCat(" ", Quoted(filename), '\n', message)); -} - void cmQtAutoGenerator::Logger::ErrorCommand( GenT genType, cm::string_view message, std::vector const& command, std::string const& output) const @@ -286,3 +272,16 @@ std::string cmQtAutoGenerator::SettingsFind(std::string const& content, } return std::string(); } + +std::string cmQtAutoGenerator::MessagePath(cm::string_view path) const +{ + std::string res; + if (cmHasPrefix(path, ProjectDirs().Source)) { + res = cmStrCat("SRC:", path.substr(ProjectDirs().Source.size())); + } else if (cmHasPrefix(path, ProjectDirs().Binary)) { + res = cmStrCat("BIN:", path.substr(ProjectDirs().Binary.size())); + } else { + res = std::string(path); + } + return cmQtAutoGen::Quoted(res); +} diff --git a/Source/cmQtAutoGenerator.h b/Source/cmQtAutoGenerator.h index 4b8b0b7..371b25c 100644 --- a/Source/cmQtAutoGenerator.h +++ b/Source/cmQtAutoGenerator.h @@ -23,9 +23,7 @@ class cmQtAutoGenerator : public cmQtAutoGen public: // -- Types - /** - * Thread safe logger - */ + /** Thread safe logger. */ class Logger { public: @@ -45,12 +43,8 @@ public: void Info(GenT genType, cm::string_view message) const; // -- Log warning void Warning(GenT genType, cm::string_view message) const; - void WarningFile(GenT genType, cm::string_view filename, - cm::string_view message) const; // -- Log error void Error(GenT genType, cm::string_view message) const; - void ErrorFile(GenT genType, cm::string_view filename, - cm::string_view message) const; void ErrorCommand(GenT genType, cm::string_view message, std::vector const& command, std::string const& output) const; @@ -64,6 +58,15 @@ public: bool ColorOutput_ = false; }; + /** Project directories. */ + struct ProjectDirsT + { + std::string Source; + std::string Binary; + std::string CurrentSource; + std::string CurrentBinary; + }; + // -- File system methods static bool MakeParentDirectory(std::string const& filename); static bool FileRead(std::string& content, std::string const& filename, @@ -91,13 +94,18 @@ public: std::string const& InfoDir() const { return InfoDir_; } std::string const& InfoConfig() const { return InfoConfig_; } + // -- Directories + ProjectDirsT const& ProjectDirs() const { return ProjectDirs_; } + // -- Utility static std::string SettingsFind(std::string const& content, const char* key); + std::string MessagePath(cm::string_view path) const; protected: // -- Abstract processing interface virtual bool Init(cmMakefile* makefile) = 0; virtual bool Process() = 0; + ProjectDirsT& ProjectDirsRef() { return ProjectDirs_; } private: // -- Info settings @@ -105,6 +113,8 @@ private: cmFileTime InfoFileTime_; std::string InfoDir_; std::string InfoConfig_; + // -- Directories + ProjectDirsT ProjectDirs_; }; #endif diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 7b65429..0fe83e5 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -234,13 +234,6 @@ void cmQtAutoMocUic::JobT::LogError(GenT genType, Gen()->Log().Error(genType, message); } -void cmQtAutoMocUic::JobT::LogFileError(GenT genType, cm::string_view filename, - cm::string_view message) const -{ - Gen()->AbortError(); - Gen()->Log().ErrorFile(genType, filename, message); -} - void cmQtAutoMocUic::JobT::LogCommandError( GenT genType, cm::string_view message, std::vector const& command, std::string const& output) const @@ -265,6 +258,7 @@ bool cmQtAutoMocUic::JobT::RunProcess(GenT genType, info.empty() || cmHasSuffix(info, '\n') ? "" : "\n", QuotedCommand(command), '\n')); } + // Run command return cmWorkerPool::JobT::RunProcess(result, command, BaseConst().AutogenBuildDir); } @@ -279,7 +273,6 @@ void cmQtAutoMocUic::JobMocPredefsT::Process() if (!Update(reason.get())) { return; } - std::string const& predefsFileRel = MocConst().PredefsFileRel; std::string const& predefsFileAbs = MocConst().PredefsFileAbs; { cmWorkerPool::ProcessResultT result; @@ -296,7 +289,7 @@ void cmQtAutoMocUic::JobMocPredefsT::Process() if (!RunProcess(GenT::MOC, result, cmd, reason.get())) { LogCommandError(GenT::MOC, cmStrCat("The content generation command for ", - Quoted(predefsFileRel), " failed.\n", + MessagePath(predefsFileAbs), " failed.\n", result.ErrorMessage), cmd, result.StdOut); return; @@ -306,19 +299,20 @@ void cmQtAutoMocUic::JobMocPredefsT::Process() // (Re)write predefs file only on demand if (cmQtAutoGenerator::FileDiffers(predefsFileAbs, result.StdOut)) { if (!cmQtAutoGenerator::FileWrite(predefsFileAbs, result.StdOut)) { - LogFileError(GenT::MOC, predefsFileAbs, - cmStrCat("Writing ", Quoted(predefsFileRel), " failed.")); + LogError( + GenT::MOC, + cmStrCat("Writing ", MessagePath(predefsFileAbs), " failed.")); return; } } else { // Touch to update the time stamp if (Log().Verbose()) { - Log().Info(GenT::MOC, "Touching " + Quoted(predefsFileRel)); + Log().Info(GenT::MOC, "Touching " + MessagePath(predefsFileAbs)); } if (!cmSystemTools::Touch(predefsFileAbs, false)) { - LogFileError( - GenT::MOC, predefsFileAbs, - cmStrCat("Touching ", Quoted(predefsFileAbs), " failed.")); + LogError( + GenT::MOC, + cmStrCat("Touching ", MessagePath(predefsFileAbs), " failed.")); return; } } @@ -326,7 +320,9 @@ void cmQtAutoMocUic::JobMocPredefsT::Process() // Read file time afterwards if (!MocEval().PredefsTime.Load(predefsFileAbs)) { - LogFileError(GenT::MOC, predefsFileAbs, "File time reading failed."); + LogError(GenT::MOC, + cmStrCat("Reading the file time of ", MessagePath(predefsFileAbs), + " failed.")); return; } } @@ -336,7 +332,7 @@ bool cmQtAutoMocUic::JobMocPredefsT::Update(std::string* reason) const // Test if the file exists if (!MocEval().PredefsTime.Load(MocConst().PredefsFileAbs)) { if (reason != nullptr) { - *reason = cmStrCat("Generating ", Quoted(MocConst().PredefsFileRel), + *reason = cmStrCat("Generating ", MessagePath(MocConst().PredefsFileAbs), ", because it doesn't exist."); } return true; @@ -345,7 +341,7 @@ bool cmQtAutoMocUic::JobMocPredefsT::Update(std::string* reason) const // Test if the settings changed if (MocConst().SettingsChanged) { if (reason != nullptr) { - *reason = cmStrCat("Generating ", Quoted(MocConst().PredefsFileRel), + *reason = cmStrCat("Generating ", MessagePath(MocConst().PredefsFileAbs), ", because the moc settings changed."); } return true; @@ -358,8 +354,9 @@ bool cmQtAutoMocUic::JobMocPredefsT::Update(std::string* reason) const if (execTime.Load(exec)) { if (MocEval().PredefsTime.Older(execTime)) { if (reason != nullptr) { - *reason = cmStrCat("Generating ", Quoted(MocConst().PredefsFileRel), - " because it is older than ", Quoted(exec), '.'); + *reason = + cmStrCat("Generating ", MessagePath(MocConst().PredefsFileAbs), + " because it is older than ", MessagePath(exec), '.'); } return true; } @@ -376,19 +373,21 @@ bool cmQtAutoMocUic::JobParseT::ReadFile() std::string const& fileName = FileHandle->FileName; // Write info if (Log().Verbose()) { - Log().Info(GenT::GEN, "Parsing " + Quoted(fileName)); + Log().Info(GenT::GEN, cmStrCat("Parsing ", MessagePath(fileName))); } // Read file content { std::string error; if (!cmQtAutoGenerator::FileRead(Content, fileName, &error)) { - LogFileError(GenT::GEN, fileName, "Could not read the file: " + error); + LogError( + GenT::GEN, + cmStrCat("Could not read ", MessagePath(fileName), ".\n", error)); return false; } } // Warn if empty if (Content.empty()) { - Log().WarningFile(GenT::GEN, fileName, "The file is empty."); + Log().Warning(GenT::GEN, cmStrCat(MessagePath(fileName), " is empty.")); return false; } return true; @@ -557,7 +556,7 @@ std::string cmQtAutoMocUic::JobEvalCacheT::MessageSearchLocations() const res.reserve(512); for (std::string const& path : SearchLocations) { res += " "; - res += Quoted(path); + res += MessagePath(path); res += '\n'; } return res; @@ -645,9 +644,9 @@ bool cmQtAutoMocUic::JobEvalCacheMocT::EvalSource( if (!sourceIncludesDotMoc && !parseData.Macro.empty() && !(relaxedMode && sourceIncludesMocUnderscore)) { LogError(GenT::MOC, - cmStrCat(sourceFile.FileName, "\ncontains a ", + cmStrCat(MessagePath(sourceFile.FileName), "\ncontains a ", Quoted(parseData.Macro), " macro, but does not include ", - Quoted(sourceBase + ".moc"), + MessagePath(sourceBase + ".moc"), "!\nConsider to\n - add #include \"", sourceBase, ".moc\"\n - enable SKIP_AUTOMOC for this file")); return false; @@ -660,8 +659,8 @@ bool cmQtAutoMocUic::JobEvalCacheMocT::EvalSource( std::string const headerBase = cmStrCat(incKey.Dir, incKey.Base); if (!FindIncludedHeader(headerHandle, sourceDirPrefix, headerBase)) { LogError(GenT::MOC, - cmStrCat(Quoted(sourceFile.FileName), - "\nincludes the moc file ", Quoted(incKey.Key), + cmStrCat(MessagePath(sourceFile.FileName), + "\nincludes the moc file ", MessagePath(incKey.Key), ",\nbut a header ", MessageHeader(headerBase), "\ncould not be found " "in the following directories\n", @@ -681,12 +680,12 @@ bool cmQtAutoMocUic::JobEvalCacheMocT::EvalSource( // Issue a warning Log().Warning( GenT::MOC, - cmStrCat(sourceFile.FileName, "\ncontains a ", Quoted(parseData.Macro), - " macro, but does not include ", Quoted(sourceBase + ".moc"), - ".\nInstead it includes ", Quoted(incKey.Key), - ".\nRunning moc on the source\n ", - Quoted(sourceFile.FileName), "!\nBetter include ", - Quoted(sourceBase + ".moc"), + cmStrCat(MessagePath(sourceFile.FileName), "\ncontains a ", + Quoted(parseData.Macro), " macro, but does not include ", + MessagePath(sourceBase + ".moc"), ".\nInstead it includes ", + MessagePath(incKey.Key), ".\nRunning moc on the source\n ", + MessagePath(sourceFile.FileName), "!\nBetter include ", + MessagePath(sourceBase + ".moc"), " for compatibility with regular mode.\n", "This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n")); @@ -729,8 +728,8 @@ bool cmQtAutoMocUic::JobEvalCacheMocT::EvalSource( LogError( GenT::MOC, cmStrCat( - Quoted(sourceFile.FileName), "\nincludes the moc file ", - Quoted(incKey.Key), + MessagePath(sourceFile.FileName), "\nincludes the moc file ", + MessagePath(incKey.Key), ",\nwhich seems to be the moc file from a different source " "file.\nCMAKE_AUTOMOC_RELAXED_MODE:\nAlso a matching header ", MessageHeader(headerBase), @@ -747,23 +746,23 @@ bool cmQtAutoMocUic::JobEvalCacheMocT::EvalSource( if (ownMoc && parseData.Macro.empty()) { Log().Warning( GenT::MOC, - cmStrCat(sourceFile.FileName, "\nincludes the moc file ", - Quoted(incKey.Key), ", but does not contain a\n", - MocConst().MacrosString(), + cmStrCat(MessagePath(sourceFile.FileName), + "\nincludes the moc file ", MessagePath(incKey.Key), + ", but does not contain a\n", MocConst().MacrosString(), " macro.\nRunning moc on the header\n ", - Quoted(headerHandle->FileName), "!\nBetter include ", - Quoted("moc_" + incKey.Base + ".cpp"), + MessagePath(headerHandle->FileName), "!\nBetter include ", + MessagePath("moc_" + incKey.Base + ".cpp"), " for a compatibility with regular mode.\n", "This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n")); } else { Log().Warning( GenT::MOC, - cmStrCat(sourceFile.FileName, "\nincludes the moc file ", - Quoted(incKey.Key), " instead of ", - Quoted("moc_" + incKey.Base + ".cpp"), + cmStrCat(MessagePath(sourceFile.FileName), + "\nincludes the moc file ", MessagePath(incKey.Key), + " instead of ", MessagePath("moc_" + incKey.Base + ".cpp"), ".\nRunning moc on the header\n ", - Quoted(headerHandle->FileName), "!\nBetter include ", - Quoted("moc_" + incKey.Base + ".cpp"), + MessagePath(headerHandle->FileName), "!\nBetter include ", + MessagePath("moc_" + incKey.Base + ".cpp"), " for compatibility with regular mode.\n", "This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n")); } @@ -781,19 +780,21 @@ bool cmQtAutoMocUic::JobEvalCacheMocT::EvalSource( if (!ownMoc) { // Don't allow .moc include other than own in regular mode LogError(GenT::MOC, - cmStrCat(sourceFile.FileName, "\nincludes the moc file ", - Quoted(incKey.Key), + cmStrCat(MessagePath(sourceFile.FileName), + "\nincludes the moc file ", MessagePath(incKey.Key), ",\nwhich seems to be the moc file from a different " "source file.\nThis is not supported. Include ", - Quoted(sourceBase + ".moc"), + MessagePath(sourceBase + ".moc"), " to run moc on this source file.")); return false; } // Accept but issue a warning if moc isn't required if (parseData.Macro.empty()) { Log().Warning(GenT::MOC, - cmStrCat(sourceFile.FileName, "\nincludes the moc file ", - Quoted(incKey.Key), ", but does not contain a ", + cmStrCat(MessagePath(sourceFile.FileName), + "\nincludes the moc file ", + MessagePath(incKey.Key), + ", but does not contain a ", MocConst().MacrosString(), " macro.")); } // Create mapping @@ -880,18 +881,19 @@ bool cmQtAutoMocUic::JobEvalCacheMocT::RegisterIncluded( // Check if the output file would be generated from different source files if (handle->SourceFile != sourceFileHandle) { std::string files = - cmStrCat(" ", Quoted(includerFileHandle->FileName), '\n'); + cmStrCat(" ", MessagePath(includerFileHandle->FileName), '\n'); for (auto const& item : handle->IncluderFiles) { - files += cmStrCat(" ", Quoted(item->FileName), '\n'); + files += cmStrCat(" ", MessagePath(item->FileName), '\n'); } LogError( GenT::MOC, cmStrCat("The source files\n", files, - "contain the same include string ", Quoted(includeString), + "contain the same include string ", + MessagePath(includeString), ", but\nthe moc file would be generated from different " "source files\n ", - Quoted(sourceFileHandle->FileName), " and\n ", - Quoted(handle->SourceFile->FileName), + MessagePath(sourceFileHandle->FileName), " and\n ", + MessagePath(handle->SourceFile->FileName), ".\nConsider to\n" " - not include the \"moc_.cpp\" file\n" " - add a directory prefix to a \".moc\" include " @@ -938,7 +940,7 @@ void cmQtAutoMocUic::JobEvalCacheMocT::RegisterMapping( std::string cmQtAutoMocUic::JobEvalCacheMocT::MessageHeader( cm::string_view headerBase) const { - return Quoted(cmStrCat( + return MessagePath(cmStrCat( headerBase, ".{", cmJoin(this->BaseConst().HeaderExtensions, ","), '}')); } @@ -976,9 +978,9 @@ bool cmQtAutoMocUic::JobEvalCacheUicT::EvalFile( UiName = cmStrCat(incKey.Base, ".ui"); if (!FindIncludedUi(sourceDirPrefix, incKey.Dir)) { LogError(GenT::UIC, - cmStrCat(sourceFile.FileName, "\nincludes the uic file ", - Quoted(incKey.Key), ",\nbut the user interface file ", - Quoted(UiName), + cmStrCat(MessagePath(sourceFile.FileName), + "\nincludes the uic file ", MessagePath(incKey.Key), + ",\nbut the user interface file ", MessagePath(UiName), "\ncould not be found in the following directories\n", MessageSearchLocations())); return false; @@ -1060,9 +1062,9 @@ bool cmQtAutoMocUic::JobEvalCacheUicT::RegisterMapping( if (handle->SourceFile != UiFileHandle) { // The output file already gets generated - from a different .ui file! std::string files = - cmStrCat(" ", Quoted(includerFileHandle->FileName), '\n'); + cmStrCat(" ", MessagePath(includerFileHandle->FileName), '\n'); for (auto const& item : handle->IncluderFiles) { - files += cmStrCat(" ", Quoted(item->FileName), '\n'); + files += cmStrCat(" ", MessagePath(item->FileName), '\n'); } LogError( GenT::UIC, @@ -1071,8 +1073,8 @@ bool cmQtAutoMocUic::JobEvalCacheUicT::RegisterMapping( Quoted(includeString), ", but\nthe uic file would be generated from different " "user interface files\n ", - Quoted(UiFileHandle->FileName), " and\n ", - Quoted(handle->SourceFile->FileName), + MessagePath(UiFileHandle->FileName), " and\n ", + MessagePath(handle->SourceFile->FileName), ".\nConsider to\n" " - add a directory prefix to a \"ui_.h\" include " "(e.g \"sub/ui_.h\")\n" @@ -1168,8 +1170,8 @@ bool cmQtAutoMocUic::JobProbeDepsMocT::Probe(MappingT const& mapping, if (!outputFileTime.Load(outputFile)) { if (reason != nullptr) { *reason = - cmStrCat("Generating ", Quoted(outputFile), - ", because it doesn't exist, from ", Quoted(sourceFile)); + cmStrCat("Generating ", MessagePath(outputFile), + ", because it doesn't exist, from ", MessagePath(sourceFile)); } return true; } @@ -1177,9 +1179,9 @@ bool cmQtAutoMocUic::JobProbeDepsMocT::Probe(MappingT const& mapping, // Test if any setting changed if (MocConst().SettingsChanged) { if (reason != nullptr) { - *reason = cmStrCat("Generating ", Quoted(outputFile), + *reason = cmStrCat("Generating ", MessagePath(outputFile), ", because the uic settings changed, from ", - Quoted(sourceFile)); + MessagePath(sourceFile)); } return true; } @@ -1187,9 +1189,9 @@ bool cmQtAutoMocUic::JobProbeDepsMocT::Probe(MappingT const& mapping, // Test if the source file is newer if (outputFileTime.Older(mapping.SourceFile->FileTime)) { if (reason != nullptr) { - *reason = cmStrCat("Generating ", Quoted(outputFile), + *reason = cmStrCat("Generating ", MessagePath(outputFile), ", because it's older than its source file, from ", - Quoted(sourceFile)); + MessagePath(sourceFile)); } return true; } @@ -1198,9 +1200,10 @@ bool cmQtAutoMocUic::JobProbeDepsMocT::Probe(MappingT const& mapping, if (!MocConst().PredefsFileAbs.empty()) { if (outputFileTime.Older(MocEval().PredefsTime)) { if (reason != nullptr) { - *reason = cmStrCat( - "Generating ", Quoted(outputFile), ", because it's older than ", - Quoted(MocConst().PredefsFileAbs), ", from ", Quoted(sourceFile)); + *reason = cmStrCat("Generating ", MessagePath(outputFile), + ", because it's older than ", + MessagePath(MocConst().PredefsFileAbs), ", from ", + MessagePath(sourceFile)); } return true; } @@ -1209,9 +1212,9 @@ bool cmQtAutoMocUic::JobProbeDepsMocT::Probe(MappingT const& mapping, // Test if the moc executable is newer if (outputFileTime.Older(MocConst().ExecutableTime)) { if (reason != nullptr) { - *reason = cmStrCat("Generating ", Quoted(outputFile), + *reason = cmStrCat("Generating ", MessagePath(outputFile), ", because it's older than the moc executable, from ", - Quoted(sourceFile)); + MessagePath(sourceFile)); } return true; } @@ -1224,17 +1227,19 @@ bool cmQtAutoMocUic::JobProbeDepsMocT::Probe(MappingT const& mapping, // Find dependency file auto const depMatch = FindDependency(sourceDir, dep); if (depMatch.first.empty()) { - Log().WarningFile(GenT::MOC, sourceFile, - "Could not find dependency file " + Quoted(dep)); + Log().Warning(GenT::MOC, + cmStrCat(MessagePath(sourceFile), " depends on ", + MessagePath(dep), + " but the file does not exist.")); continue; } // Test if dependency file is older if (outputFileTime.Older(depMatch.second)) { if (reason != nullptr) { - *reason = - cmStrCat("Generating ", Quoted(outputFile), - ", because it's older than its dependency file ", - Quoted(depMatch.first), ", from ", Quoted(sourceFile)); + *reason = cmStrCat("Generating ", MessagePath(outputFile), + ", because it's older than its dependency file ", + MessagePath(depMatch.first), ", from ", + MessagePath(sourceFile)); } return true; } @@ -1297,8 +1302,8 @@ bool cmQtAutoMocUic::JobProbeDepsUicT::Probe(MappingT const& mapping, if (!outputFileTime.Load(outputFile)) { if (reason != nullptr) { *reason = - cmStrCat("Generating ", Quoted(outputFile), - ", because it doesn't exist, from ", Quoted(sourceFile)); + cmStrCat("Generating ", MessagePath(outputFile), + ", because it doesn't exist, from ", MessagePath(sourceFile)); } return true; } @@ -1306,9 +1311,9 @@ bool cmQtAutoMocUic::JobProbeDepsUicT::Probe(MappingT const& mapping, // Test if the uic settings changed if (UicConst().SettingsChanged) { if (reason != nullptr) { - *reason = cmStrCat("Generating ", Quoted(outputFile), + *reason = cmStrCat("Generating ", MessagePath(outputFile), ", because the uic settings changed, from ", - Quoted(sourceFile)); + MessagePath(sourceFile)); } return true; } @@ -1316,9 +1321,9 @@ bool cmQtAutoMocUic::JobProbeDepsUicT::Probe(MappingT const& mapping, // Test if the source file is newer if (outputFileTime.Older(mapping.SourceFile->FileTime)) { if (reason != nullptr) { - *reason = cmStrCat("Generating ", Quoted(outputFile), + *reason = cmStrCat("Generating ", MessagePath(outputFile), " because it's older than the source file ", - Quoted(sourceFile)); + MessagePath(sourceFile)); } return true; } @@ -1326,9 +1331,9 @@ bool cmQtAutoMocUic::JobProbeDepsUicT::Probe(MappingT const& mapping, // Test if the uic executable is newer if (outputFileTime.Older(UicConst().ExecutableTime)) { if (reason != nullptr) { - *reason = cmStrCat("Generating ", Quoted(outputFile), + *reason = cmStrCat("Generating ", MessagePath(outputFile), ", because it's older than the uic executable, from ", - Quoted(sourceFile)); + MessagePath(sourceFile)); } return true; } @@ -1344,7 +1349,9 @@ void cmQtAutoMocUic::JobProbeDepsFinishT::Process() auto createDirs = [this](GenT genType, StringSet const& dirSet) { for (std::string const& dirName : dirSet) { if (!cmSystemTools::MakeDirectory(dirName)) { - this->LogFileError(genType, dirName, "Could not create directory."); + this->LogError( + genType, + cmStrCat("Creating directory ", MessagePath(dirName), " failed.")); return; } } @@ -1402,13 +1409,13 @@ void cmQtAutoMocUic::JobCompileMocT::Process() if (!Mapping->IncluderFiles.empty()) { includers = "included by\n"; for (auto const& item : Mapping->IncluderFiles) { - includers += cmStrCat(" ", Quoted(item->FileName), '\n'); + includers += cmStrCat(" ", MessagePath(item->FileName), '\n'); } } LogCommandError(GenT::MOC, cmStrCat("The moc process failed to compile\n ", - Quoted(sourceFile), "\ninto\n ", - Quoted(outputFile), '\n', includers, + MessagePath(sourceFile), "\ninto\n ", + MessagePath(outputFile), '\n', includers, result.ErrorMessage), cmd, result.StdOut); } @@ -1446,13 +1453,13 @@ void cmQtAutoMocUic::JobCompileUicT::Process() // Uic command failed std::string includers; for (auto const& item : Mapping->IncluderFiles) { - includers += cmStrCat(" ", Quoted(item->FileName), '\n'); + includers += cmStrCat(" ", MessagePath(item->FileName), '\n'); } LogCommandError(GenT::UIC, cmStrCat("The uic process failed to compile\n ", - Quoted(sourceFile), "\ninto\n ", - Quoted(outputFile), "\nincluded by\n", includers, - result.ErrorMessage), + MessagePath(sourceFile), "\ninto\n ", + MessagePath(outputFile), "\nincluded by\n", + includers, result.ErrorMessage), cmd, result.StdOut); } } @@ -1480,20 +1487,24 @@ void cmQtAutoMocUic::JobMocsCompilationT::Process() if (cmQtAutoGenerator::FileDiffers(compAbs, content)) { // Actually write mocs compilation file if (Log().Verbose()) { - Log().Info(GenT::MOC, "Generating MOC compilation " + compAbs); + Log().Info(GenT::MOC, + "Generating MOC compilation " + MessagePath(compAbs)); } if (!FileWrite(compAbs, content)) { - LogFileError(GenT::MOC, compAbs, - "mocs compilation file writing failed."); + LogError(GenT::MOC, + cmStrCat("Writing MOC compilation ", MessagePath(compAbs), + " failed.")); } } else if (MocEval().CompUpdated) { // Only touch mocs compilation file if (Log().Verbose()) { - Log().Info(GenT::MOC, "Touching mocs compilation " + compAbs); + Log().Info(GenT::MOC, + "Touching MOC compilation " + MessagePath(compAbs)); } if (!cmSystemTools::Touch(compAbs, false)) { - LogFileError(GenT::MOC, compAbs, - "mocs compilation file touching failed."); + LogError(GenT::MOC, + cmStrCat("Touching MOC compilation ", MessagePath(compAbs), + " failed.")); } } } @@ -1587,10 +1598,10 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) makefile->GetCMakeInstance()->GetHeaderExtensions(); // - Files and directories - BaseConst_.ProjectSourceDir = InfoGet("AM_CMAKE_SOURCE_DIR"); - BaseConst_.ProjectBinaryDir = InfoGet("AM_CMAKE_BINARY_DIR"); - BaseConst_.CurrentSourceDir = InfoGet("AM_CMAKE_CURRENT_SOURCE_DIR"); - BaseConst_.CurrentBinaryDir = InfoGet("AM_CMAKE_CURRENT_BINARY_DIR"); + ProjectDirsRef().Source = InfoGet("AM_CMAKE_SOURCE_DIR"); + ProjectDirsRef().Binary = InfoGet("AM_CMAKE_BINARY_DIR"); + ProjectDirsRef().CurrentSource = InfoGet("AM_CMAKE_CURRENT_SOURCE_DIR"); + ProjectDirsRef().CurrentBinary = InfoGet("AM_CMAKE_CURRENT_BINARY_DIR"); BaseConst_.AutogenBuildDir = InfoGet("AM_BUILD_DIR"); if (BaseConst_.AutogenBuildDir.empty()) { return LogInfoError("Autogen build directory missing."); @@ -1605,7 +1616,7 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) } if (!BaseConst_.CMakeExecutableTime.Load(BaseConst_.CMakeExecutable)) { return LogInfoError(cmStrCat("The CMake executable ", - Quoted(BaseConst_.CMakeExecutable), + MessagePath(BaseConst_.CMakeExecutable), " does not exist.")); } BaseConst_.ParseCacheFile = InfoGetConfig("AM_PARSE_CACHE_FILE"); @@ -1634,7 +1645,7 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) // Load the executable file time if (!MocConst_.ExecutableTime.Load(MocConst_.Executable)) { return LogInfoError(cmStrCat("The moc executable ", - Quoted(MocConst_.Executable), + MessagePath(MocConst_.Executable), " does not exist.")); } for (std::string& sfl : InfoGetList("AM_MOC_SKIP")) { @@ -1700,7 +1711,7 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) // Load the executable file time if (!UicConst_.ExecutableTime.Load(UicConst_.Executable)) { return LogInfoError(cmStrCat("The uic executable ", - Quoted(UicConst_.Executable), + MessagePath(UicConst_.Executable), " does not exist.")); } for (std::string& sfl : InfoGetList("AM_UIC_SKIP")) { @@ -1729,17 +1740,17 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) // - Headers and sources { - auto makeSource = - [&LogInfoError](std::string const& fileName, - std::string const& fileFlags) -> SourceFileHandleT { + auto makeSource = [this, &LogInfoError]( + std::string const& fileName, + std::string const& fileFlags) -> SourceFileHandleT { if (fileFlags.size() != 2) { LogInfoError("Invalid file flags string size"); return SourceFileHandleT(); } cmFileTime fileTime; if (!fileTime.Load(fileName)) { - LogInfoError("The source file " + cmQtAutoGen::Quoted(fileName) + - " does not exist."); + LogInfoError(cmStrCat("The source file ", this->MessagePath(fileName), + " does not exist.")); return SourceFileHandleT(); } SourceFileHandleT sfh = std::make_shared(fileName); @@ -1777,9 +1788,7 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) if (MocConst().Enabled) { sfh->BuildPath = std::move(builds[ii]); if (sfh->BuildPath.empty()) { - Log().ErrorFile(GenT::GEN, this->InfoFile(), - "Header file build path is empty"); - return false; + return LogInfoError("Header file build path is empty"); } } BaseEval().Headers.emplace(std::move(fileName), std::move(sfh)); @@ -1817,13 +1826,13 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) // Moc predefs file if (!MocConst_.PredefsCmd.empty()) { + std::string pathRel; if (BaseConst_.MultiConfig) { - MocConst_.PredefsFileRel = - cmStrCat("moc_predefs_", InfoConfig(), ".h"); + pathRel = cmStrCat("moc_predefs_", InfoConfig(), ".h"); } else { - MocConst_.PredefsFileRel = "moc_predefs.h"; + pathRel = "moc_predefs.h"; } - MocConst_.PredefsFileAbs = AbsoluteBuildPath(MocConst().PredefsFileRel); + MocConst_.PredefsFileAbs = AbsoluteBuildPath(pathRel); } // Compose moc includes list @@ -1887,7 +1896,7 @@ void cmQtAutoMocUic::CreateParseJobs(SourceFileMapT const& sourceMap) std::string cmQtAutoMocUic::CollapseFullPathTS(std::string const& path) const { std::lock_guard guard(CMakeLibMutex_); - return cmSystemTools::CollapseFullPath(path, BaseConst().CurrentSourceDir); + return cmSystemTools::CollapseFullPath(path, ProjectDirs().CurrentSource); } void cmQtAutoMocUic::InitJobs() @@ -2016,7 +2025,9 @@ bool cmQtAutoMocUic::SettingsFileWrite() // Only write if any setting changed if (MocConst().SettingsChanged || UicConst().SettingsChanged) { if (Log().Verbose()) { - Log().Info(GenT::GEN, "Writing settings file " + Quoted(SettingsFile_)); + Log().Info( + GenT::GEN, + cmStrCat("Writing settings file ", MessagePath(SettingsFile_))); } // Compose settings file content std::string content; @@ -2033,8 +2044,9 @@ bool cmQtAutoMocUic::SettingsFileWrite() // Write settings file std::string error; if (!cmQtAutoGenerator::FileWrite(SettingsFile_, content, &error)) { - Log().ErrorFile(GenT::GEN, SettingsFile_, - "Settings file writing failed. " + error); + Log().Error(GenT::GEN, + cmStrCat("Writing the settings file ", + MessagePath(SettingsFile_), " failed.\n", error)); // Remove old settings file to trigger a full rebuild on the next run cmSystemTools::RemoveFile(SettingsFile_); return false; @@ -2074,12 +2086,14 @@ bool cmQtAutoMocUic::ParseCacheWrite() if (BaseEval().ParseCacheChanged) { if (Log().Verbose()) { Log().Info(GenT::GEN, - "Writing parse cache file " + - Quoted(BaseConst().ParseCacheFile)); + cmStrCat("Writing the parse cache file ", + MessagePath(BaseConst().ParseCacheFile))); } if (!BaseEval().ParseCache.WriteToFile(BaseConst().ParseCacheFile)) { - Log().ErrorFile(GenT::GEN, BaseConst().ParseCacheFile, - "Parse cache file writing failed."); + Log().Error(GenT::GEN, + cmStrCat("Writing the parse cache file ", + MessagePath(BaseConst().ParseCacheFile), + " failed.")); return false; } } @@ -2090,8 +2104,10 @@ bool cmQtAutoMocUic::CreateDirectories() { // Create AUTOGEN include directory if (!cmSystemTools::MakeDirectory(BaseConst().AutogenIncludeDir)) { - Log().ErrorFile(GenT::GEN, BaseConst().AutogenIncludeDir, - "Could not create directory."); + Log().Error(GenT::GEN, + cmStrCat("Creating the AUTOGEN include directory ", + MessagePath(BaseConst().AutogenIncludeDir), + " failed.")); return false; } return true; diff --git a/Source/cmQtAutoMocUic.h b/Source/cmQtAutoMocUic.h index e480751..d77e774 100644 --- a/Source/cmQtAutoMocUic.h +++ b/Source/cmQtAutoMocUic.h @@ -169,10 +169,6 @@ public: bool MultiConfig = false; unsigned int QtVersionMajor = 4; // - Directories - std::string ProjectSourceDir; - std::string ProjectBinaryDir; - std::string CurrentSourceDir; - std::string CurrentBinaryDir; std::string AutogenBuildDir; std::string AutogenIncludeDir; // - Files @@ -218,7 +214,6 @@ public: cmFileTime ExecutableTime; std::string Executable; std::string CompFileAbs; - std::string PredefsFileRel; std::string PredefsFileAbs; std::unordered_set SkipList; std::vector IncludePaths; @@ -313,10 +308,13 @@ public: UicSettingsT const& UicConst() const { return Gen()->UicConst(); } UicEvalT& UicEval() const { return Gen()->UicEval(); } - // -- Error logging with automatic abort + // -- Logging + std::string MessagePath(cm::string_view path) const + { + return Gen()->MessagePath(path); + } + // - Error logging with automatic abort void LogError(GenT genType, cm::string_view message) const; - void LogFileError(GenT genType, cm::string_view filename, - cm::string_view message) const; void LogCommandError(GenT genType, cm::string_view message, std::vector const& command, std::string const& output) const; diff --git a/Source/cmQtAutoRcc.cxx b/Source/cmQtAutoRcc.cxx index e931346..cd3e034 100644 --- a/Source/cmQtAutoRcc.cxx +++ b/Source/cmQtAutoRcc.cxx @@ -16,7 +16,6 @@ #include cmQtAutoRcc::cmQtAutoRcc() = default; - cmQtAutoRcc::~cmQtAutoRcc() = default; bool cmQtAutoRcc::Init(cmMakefile* makefile) @@ -41,8 +40,8 @@ bool cmQtAutoRcc::Init(cmMakefile* makefile) return cmExpandedList(InfoGetConfig(key)); }; auto LogInfoError = [this](cm::string_view msg) -> bool { - this->Log().Error(GenT::RCC, - cmStrCat("In ", Quoted(this->InfoFile()), ":\n", msg)); + this->Log().Error( + GenT::RCC, cmStrCat("In ", MessagePath(this->InfoFile()), ":\n", msg)); return false; }; @@ -56,6 +55,8 @@ bool cmQtAutoRcc::Init(cmMakefile* makefile) MultiConfig_ = makefile->IsOn("ARCC_MULTI_CONFIG"); // - Directories + ProjectDirsRef().Source = InfoGet("ARCC_CMAKE_SOURCE_DIR"); + ProjectDirsRef().Binary = InfoGet("ARCC_CMAKE_BINARY_DIR"); AutogenBuildDir_ = InfoGet("ARCC_BUILD_DIR"); if (AutogenBuildDir_.empty()) { return LogInfoError("Build directory empty."); @@ -69,8 +70,8 @@ bool cmQtAutoRcc::Init(cmMakefile* makefile) // - Rcc executable RccExecutable_ = InfoGet("ARCC_RCC_EXECUTABLE"); if (!RccExecutableTime_.Load(RccExecutable_)) { - return LogInfoError(cmStrCat("The rcc executable ", Quoted(RccExecutable_), - " does not exist.")); + return LogInfoError(cmStrCat( + "The rcc executable ", MessagePath(RccExecutable_), " does not exist.")); } RccListOptions_ = InfoGetList("ARCC_RCC_LIST_OPTIONS"); @@ -185,8 +186,9 @@ bool cmQtAutoRcc::SettingsFileRead() if (!cmSystemTools::FileExists(SettingsFile_, true)) { // Touch the settings file to make sure it exists if (!cmSystemTools::Touch(SettingsFile_, true)) { - Log().ErrorFile(GenT::RCC, SettingsFile_, - "Settings file creation failed."); + Log().Error(GenT::RCC, + cmStrCat("Touching the settings file ", + MessagePath(SettingsFile_), " failed.")); return false; } } @@ -196,7 +198,9 @@ bool cmQtAutoRcc::SettingsFileRead() // Make sure the lock file exists if (!cmSystemTools::FileExists(LockFile_, true)) { if (!cmSystemTools::Touch(LockFile_, true)) { - Log().ErrorFile(GenT::RCC, LockFile_, "Lock file creation failed."); + Log().Error(GenT::RCC, + cmStrCat("Touching the lock file ", MessagePath(LockFile_), + " failed.")); return false; } } @@ -204,8 +208,9 @@ bool cmQtAutoRcc::SettingsFileRead() cmFileLockResult lockResult = LockFileLock_.Lock(LockFile_, static_cast(-1)); if (!lockResult.IsOk()) { - Log().ErrorFile(GenT::RCC, LockFile_, - "File lock failed: " + lockResult.GetOutputMessage()); + Log().Error(GenT::RCC, + cmStrCat("Locking of the lock file ", MessagePath(LockFile_), + " failed.\n", lockResult.GetOutputMessage())); return false; } } @@ -221,8 +226,10 @@ bool cmQtAutoRcc::SettingsFileRead() if (SettingsChanged_) { std::string error; if (!FileWrite(SettingsFile_, "", &error)) { - Log().ErrorFile(GenT::RCC, SettingsFile_, - "Settings file clearing failed. " + error); + Log().Error(GenT::RCC, + cmStrCat("Clearing of the settings file ", + MessagePath(SettingsFile_), " failed.\n", + error)); return false; } } @@ -239,14 +246,16 @@ bool cmQtAutoRcc::SettingsFileWrite() // Only write if any setting changed if (SettingsChanged_) { if (Log().Verbose()) { - Log().Info(GenT::RCC, "Writing settings file " + Quoted(SettingsFile_)); + Log().Info(GenT::RCC, + "Writing settings file " + MessagePath(SettingsFile_)); } // Write settings file std::string content = cmStrCat("rcc:", SettingsString_, '\n'); std::string error; if (!FileWrite(SettingsFile_, content, &error)) { - Log().ErrorFile(GenT::RCC, SettingsFile_, - "Settings file writing failed. " + error); + Log().Error(GenT::RCC, + cmStrCat("Writing of the settings file ", + MessagePath(SettingsFile_), " failed.\n", error)); // Remove old settings file to trigger a full rebuild on the next run cmSystemTools::RemoveFile(SettingsFile_); return false; @@ -263,17 +272,18 @@ bool cmQtAutoRcc::TestQrcRccFiles(bool& generate) { // Test if the rcc input file exists if (!QrcFileTime_.Load(QrcFile_)) { - Log().ErrorFile( - GenT::RCC, QrcFile_, - cmStrCat("The resources file ", Quoted(QrcFile_), " does not exist")); + Log().Error(GenT::RCC, + cmStrCat("The resources file ", MessagePath(QrcFile_), + " does not exist")); return false; } // Test if the rcc output file exists if (!RccFileTime_.Load(RccFileOutput_)) { if (Log().Verbose()) { - Reason = cmStrCat("Generating ", Quoted(RccFileOutput_), - ", because it doesn't exist, from ", Quoted(QrcFile_)); + Reason = + cmStrCat("Generating ", MessagePath(RccFileOutput_), + ", because it doesn't exist, from ", MessagePath(QrcFile_)); } generate = true; return true; @@ -282,9 +292,9 @@ bool cmQtAutoRcc::TestQrcRccFiles(bool& generate) // Test if the settings changed if (SettingsChanged_) { if (Log().Verbose()) { - Reason = cmStrCat("Generating ", Quoted(RccFileOutput_), + Reason = cmStrCat("Generating ", MessagePath(RccFileOutput_), ", because the rcc settings changed, from ", - Quoted(QrcFile_)); + MessagePath(QrcFile_)); } generate = true; return true; @@ -293,9 +303,9 @@ bool cmQtAutoRcc::TestQrcRccFiles(bool& generate) // Test if the rcc output file is older than the .qrc file if (RccFileTime_.Older(QrcFileTime_)) { if (Log().Verbose()) { - Reason = cmStrCat("Generating ", Quoted(RccFileOutput_), - ", because it is older than ", Quoted(QrcFile_), - ", from ", Quoted(QrcFile_)); + Reason = cmStrCat("Generating ", MessagePath(RccFileOutput_), + ", because it is older than ", MessagePath(QrcFile_), + ", from ", MessagePath(QrcFile_)); } generate = true; return true; @@ -304,9 +314,9 @@ bool cmQtAutoRcc::TestQrcRccFiles(bool& generate) // Test if the rcc output file is older than the rcc executable if (RccFileTime_.Older(RccExecutableTime_)) { if (Log().Verbose()) { - Reason = cmStrCat("Generating ", Quoted(RccFileOutput_), + Reason = cmStrCat("Generating ", MessagePath(RccFileOutput_), ", because it is older than the rcc executable, from ", - Quoted(QrcFile_)); + MessagePath(QrcFile_)); } generate = true; return true; @@ -322,7 +332,9 @@ bool cmQtAutoRcc::TestResources(bool& generate) std::string error; RccLister const lister(RccExecutable_, RccListOptions_); if (!lister.list(QrcFile_, Inputs_, error, Log().Verbose())) { - Log().ErrorFile(GenT::RCC, QrcFile_, error); + Log().Error( + GenT::RCC, + cmStrCat("Listing of ", MessagePath(QrcFile_), " failed.\n", error)); return false; } } @@ -332,17 +344,18 @@ bool cmQtAutoRcc::TestResources(bool& generate) // Check if the resource file exists cmFileTime fileTime; if (!fileTime.Load(resFile)) { - Log().ErrorFile(GenT::RCC, QrcFile_, - cmStrCat("Could not find the resource file\n ", - Quoted(resFile), '\n')); + Log().Error(GenT::RCC, + cmStrCat("The resource file ", MessagePath(resFile), + " listed in ", MessagePath(QrcFile_), + " does not exist.")); return false; } // Check if the resource file is newer than the rcc output file if (RccFileTime_.Older(fileTime)) { if (Log().Verbose()) { - Reason = cmStrCat("Generating ", Quoted(RccFileOutput_), - ", because it is older than ", Quoted(resFile), - ", from ", Quoted(QrcFile_)); + Reason = cmStrCat("Generating ", MessagePath(RccFileOutput_), + ", because it is older than ", MessagePath(resFile), + ", from ", MessagePath(QrcFile_)); } generate = true; break; @@ -357,12 +370,15 @@ bool cmQtAutoRcc::TestInfoFile() if (RccFileTime_.Older(InfoFileTime())) { if (Log().Verbose()) { Log().Info(GenT::RCC, - cmStrCat("Touching ", Quoted(RccFileOutput_), - " because it is older than ", Quoted(InfoFile()))); + cmStrCat("Touching ", MessagePath(RccFileOutput_), + " because it is older than ", + MessagePath(InfoFile()))); } // Touch build file if (!cmSystemTools::Touch(RccFileOutput_, false)) { - Log().ErrorFile(GenT::RCC, RccFileOutput_, "Build file touch failed"); + Log().Error( + GenT::RCC, + cmStrCat("Touching ", MessagePath(RccFileOutput_), " failed.")); return false; } BuildFileChanged_ = true; @@ -375,8 +391,9 @@ bool cmQtAutoRcc::GenerateRcc() { // Make parent directory if (!MakeParentDirectory(RccFileOutput_)) { - Log().ErrorFile(GenT::RCC, RccFileOutput_, - "Could not create parent directory"); + Log().Error(GenT::RCC, + cmStrCat("Could not create parent directory of ", + MessagePath(RccFileOutput_))); return false; } @@ -405,8 +422,8 @@ bool cmQtAutoRcc::GenerateRcc() // rcc process failed Log().ErrorCommand(GenT::RCC, cmStrCat("The rcc process failed to compile\n ", - Quoted(QrcFile_), "\ninto\n ", - Quoted(RccFileOutput_)), + MessagePath(QrcFile_), "\ninto\n ", + MessagePath(RccFileOutput_)), cmd, rccStdOut + rccStdErr); cmSystemTools::RemoveFile(RccFileOutput_); return false; @@ -443,22 +460,29 @@ bool cmQtAutoRcc::GenerateWrapper() if (fileDiffers) { // Write new wrapper file if (Log().Verbose()) { - Log().Info(GenT::RCC, "Generating RCC wrapper file " + RccFilePublic_); + Log().Info(GenT::RCC, + cmStrCat("Generating RCC wrapper file ", + MessagePath(RccFilePublic_))); } std::string error; if (!FileWrite(RccFilePublic_, content, &error)) { - Log().ErrorFile(GenT::RCC, RccFilePublic_, - "RCC wrapper file writing failed. " + error); + Log().Error(GenT::RCC, + cmStrCat("Generating RCC wrapper file ", + MessagePath(RccFilePublic_), " failed.\n", + error)); return false; } } else if (BuildFileChanged_) { // Just touch the wrapper file if (Log().Verbose()) { - Log().Info(GenT::RCC, "Touching RCC wrapper file " + RccFilePublic_); + Log().Info( + GenT::RCC, + cmStrCat("Touching RCC wrapper file ", MessagePath(RccFilePublic_))); } if (!cmSystemTools::Touch(RccFilePublic_, false)) { - Log().ErrorFile(GenT::RCC, RccFilePublic_, - "RCC wrapper file touch failed."); + Log().Error(GenT::RCC, + cmStrCat("Touching RCC wrapper file ", + MessagePath(RccFilePublic_), " failed.")); return false; } } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=51676cf65590f7a9bc3ad247151ee5bdc768eb77 commit 51676cf65590f7a9bc3ad247151ee5bdc768eb77 Author: Sebastian Holtermann AuthorDate: Thu Sep 12 13:00:59 2019 +0200 Commit: Sebastian Holtermann CommitDate: Mon Sep 16 18:18:48 2019 +0200 Autogen: Split JobEvalCacheT job into separate moc and uic jobs This splits the `JobEvalCacheT` job into separate `JobEvalCacheMocT` and `JobEvalCacheUicT` classes, that run concurrently. The `JobEvalCache*T::FindIncluded*` methods are overhauled to store probed directoriy names only if probing fails. Warning messages are refactored to show the file name and the probed directories instead of all probed file paths. This is easier to read. diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 6265777..7b65429 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -551,49 +551,35 @@ void cmQtAutoMocUic::JobParseSourceT::Process() } } -void cmQtAutoMocUic::JobEvalCacheT::Process() +std::string cmQtAutoMocUic::JobEvalCacheT::MessageSearchLocations() const { - // Evaluate for moc - if (MocConst().Enabled) { - // Evaluate headers - for (auto const& pair : BaseEval().Headers) { - if (!MocEvalHeader(pair.second)) { - return; - } - } - // Evaluate sources - for (auto const& pair : BaseEval().Sources) { - if (!MocEvalSource(pair.second)) { - return; - } - } + std::string res; + res.reserve(512); + for (std::string const& path : SearchLocations) { + res += " "; + res += Quoted(path); + res += '\n'; } - // Evaluate for uic - if (UicConst().Enabled) { - if (!UicEval(BaseEval().Headers) || !UicEval(BaseEval().Sources)) { + return res; +} + +void cmQtAutoMocUic::JobEvalCacheMocT::Process() +{ + // Evaluate headers + for (auto const& pair : BaseEval().Headers) { + if (!EvalHeader(pair.second)) { return; } } - - // Add discovered header parse jobs - Gen()->CreateParseJobs(MocEval().HeadersDiscovered); - - // Add dependency probing jobs - { - // Add fence job to ensure all parsing has finished - Gen()->WorkerPool().EmplaceJob(); - if (MocConst().Enabled) { - Gen()->WorkerPool().EmplaceJob(); - } - if (UicConst().Enabled) { - Gen()->WorkerPool().EmplaceJob(); + // Evaluate sources + for (auto const& pair : BaseEval().Sources) { + if (!EvalSource(pair.second)) { + return; } - // Add probe finish job - Gen()->WorkerPool().EmplaceJob(); } } -bool cmQtAutoMocUic::JobEvalCacheT::MocEvalHeader(SourceFileHandleT source) +bool cmQtAutoMocUic::JobEvalCacheMocT::EvalHeader(SourceFileHandleT source) { SourceFileT const& sourceFile = *source; auto const& parseData = sourceFile.ParseData->Moc; @@ -614,13 +600,13 @@ bool cmQtAutoMocUic::JobEvalCacheT::MocEvalHeader(SourceFileHandleT source) } // Register mapping in headers map - MocRegisterMapping(handle, true); + RegisterMapping(handle, true); } return true; } -bool cmQtAutoMocUic::JobEvalCacheT::MocEvalSource( +bool cmQtAutoMocUic::JobEvalCacheMocT::EvalSource( SourceFileHandleT const& source) { SourceFileT const& sourceFile = *source; @@ -631,7 +617,7 @@ bool cmQtAutoMocUic::JobEvalCacheT::MocEvalSource( return true; } - std::string const sourceDir = SubDirPrefix(sourceFile.FileName); + std::string const sourceDirPrefix = SubDirPrefix(sourceFile.FileName); std::string const sourceBase = cmSystemTools::GetFilenameWithoutLastExtension(sourceFile.FileName); @@ -658,27 +644,30 @@ bool cmQtAutoMocUic::JobEvalCacheT::MocEvalSource( // Check if this source needs to be moc processed but doesn't. if (!sourceIncludesDotMoc && !parseData.Macro.empty() && !(relaxedMode && sourceIncludesMocUnderscore)) { - LogFileError(GenT::MOC, sourceFile.FileName, - cmStrCat("The file contains a ", Quoted(parseData.Macro), - " macro, but does not include ", - Quoted(sourceBase + ".moc"), - "!\nConsider to\n - add #include \"", sourceBase, - ".moc\"\n - enable SKIP_AUTOMOC for this file")); + LogError(GenT::MOC, + cmStrCat(sourceFile.FileName, "\ncontains a ", + Quoted(parseData.Macro), " macro, but does not include ", + Quoted(sourceBase + ".moc"), + "!\nConsider to\n - add #include \"", sourceBase, + ".moc\"\n - enable SKIP_AUTOMOC for this file")); return false; } // Evaluate "moc_" includes for (IncludeKeyT const& incKey : parseData.Include.Underscore) { - std::string const headerBase = incKey.Dir + incKey.Base; - SourceFileHandleT header = MocFindIncludedHeader(sourceDir, headerBase); - if (!header) { - LogFileError(GenT::MOC, sourceFile.FileName, - cmStrCat("The file includes the moc file ", - Quoted(incKey.Key), - ",\nbut the header could not be found " - "in the following locations\n", - MocMessageTestHeaders(headerBase))); - return false; + SourceFileHandleT headerHandle; + { + std::string const headerBase = cmStrCat(incKey.Dir, incKey.Base); + if (!FindIncludedHeader(headerHandle, sourceDirPrefix, headerBase)) { + LogError(GenT::MOC, + cmStrCat(Quoted(sourceFile.FileName), + "\nincludes the moc file ", Quoted(incKey.Key), + ",\nbut a header ", MessageHeader(headerBase), + "\ncould not be found " + "in the following directories\n", + MessageSearchLocations())); + return false; + } } // The include might be handled differently in relaxed mode if (relaxedMode && !sourceIncludesDotMoc && !parseData.Macro.empty() && @@ -690,9 +679,9 @@ bool cmQtAutoMocUic::JobEvalCacheT::MocEvalSource( // used. This is for KDE4 compatibility. // Issue a warning - Log().WarningFile( - GenT::MOC, sourceFile.FileName, - cmStrCat("The file contains a ", Quoted(parseData.Macro), + Log().Warning( + GenT::MOC, + cmStrCat(sourceFile.FileName, "\ncontains a ", Quoted(parseData.Macro), " macro, but does not include ", Quoted(sourceBase + ".moc"), ".\nInstead it includes ", Quoted(incKey.Key), ".\nRunning moc on the source\n ", @@ -702,18 +691,18 @@ bool cmQtAutoMocUic::JobEvalCacheT::MocEvalSource( "This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n")); // Create mapping - if (!MocRegisterIncluded(incKey.Key, source, source, false)) { + if (!RegisterIncluded(incKey.Key, source, source, false)) { return false; } continue; } // Check if header is skipped - if (MocConst().skipped(header->FileName)) { + if (MocConst().skipped(headerHandle->FileName)) { continue; } // Create mapping - if (!MocRegisterIncluded(incKey.Key, source, std::move(header), true)) { + if (!RegisterIncluded(incKey.Key, source, std::move(headerHandle), true)) { return false; } } @@ -726,53 +715,61 @@ bool cmQtAutoMocUic::JobEvalCacheT::MocEvalSource( bool const ownMoc = (incKey.Base == sourceBase); if (ownMoc && !parseData.Macro.empty()) { // Create mapping for the regular use case - if (!MocRegisterIncluded(incKey.Key, source, source, false)) { + if (!RegisterIncluded(incKey.Key, source, source, false)) { return false; } continue; } // Try to find a header instead but issue a warning. // This is for KDE4 compatibility. - std::string const headerBase = incKey.Dir + incKey.Base; - SourceFileHandleT header = MocFindIncludedHeader(sourceDir, headerBase); - if (!header) { - LogFileError( - GenT::MOC, sourceFile.FileName, - cmStrCat("The file includes the moc file ", Quoted(incKey.Key), - ",\nwhich seems to be the moc file from a different source " - "file.\nCMAKE_AUTOMOC_RELAXED_MODE: Also a matching header" - "could not be found in the following locations\n", - MocMessageTestHeaders(headerBase))); - return false; + SourceFileHandleT headerHandle; + { + std::string const headerBase = cmStrCat(incKey.Dir, incKey.Base); + if (!FindIncludedHeader(headerHandle, sourceDirPrefix, headerBase)) { + LogError( + GenT::MOC, + cmStrCat( + Quoted(sourceFile.FileName), "\nincludes the moc file ", + Quoted(incKey.Key), + ",\nwhich seems to be the moc file from a different source " + "file.\nCMAKE_AUTOMOC_RELAXED_MODE:\nAlso a matching header ", + MessageHeader(headerBase), + "\ncould not be found in the following directories\n", + MessageSearchLocations())); + return false; + } } // Check if header is skipped - if (MocConst().skipped(header->FileName)) { + if (MocConst().skipped(headerHandle->FileName)) { continue; } // Issue a warning if (ownMoc && parseData.Macro.empty()) { - Log().WarningFile( - GenT::MOC, sourceFile.FileName, - cmStrCat("The file includes the moc file ", Quoted(incKey.Key), - ", but does not contain a\n", MocConst().MacrosString(), + Log().Warning( + GenT::MOC, + cmStrCat(sourceFile.FileName, "\nincludes the moc file ", + Quoted(incKey.Key), ", but does not contain a\n", + MocConst().MacrosString(), " macro.\nRunning moc on the header\n ", - Quoted(header->FileName), "!\nBetter include ", + Quoted(headerHandle->FileName), "!\nBetter include ", Quoted("moc_" + incKey.Base + ".cpp"), " for a compatibility with regular mode.\n", "This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n")); } else { - Log().WarningFile( - GenT::MOC, sourceFile.FileName, - cmStrCat("The file includes the moc file ", Quoted(incKey.Key), - " instead of ", Quoted("moc_" + incKey.Base + ".cpp"), + Log().Warning( + GenT::MOC, + cmStrCat(sourceFile.FileName, "\nincludes the moc file ", + Quoted(incKey.Key), " instead of ", + Quoted("moc_" + incKey.Base + ".cpp"), ".\nRunning moc on the header\n ", - Quoted(header->FileName), "!\nBetter include ", + Quoted(headerHandle->FileName), "!\nBetter include ", Quoted("moc_" + incKey.Base + ".cpp"), " for compatibility with regular mode.\n", "This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n")); } // Create mapping - if (!MocRegisterIncluded(incKey.Key, source, std::move(header), true)) { + if (!RegisterIncluded(incKey.Key, source, std::move(headerHandle), + true)) { return false; } } @@ -783,25 +780,24 @@ bool cmQtAutoMocUic::JobEvalCacheT::MocEvalSource( bool const ownMoc = (incKey.Base == sourceBase); if (!ownMoc) { // Don't allow .moc include other than own in regular mode - LogFileError( - GenT::MOC, sourceFile.FileName, - cmStrCat("The file includes the moc file ", Quoted(incKey.Key), - ",\nwhich seems to be the moc file from a different " - "source file.\nThis is not supported. Include ", - Quoted(sourceBase + ".moc"), - " to run moc on this source file.")); + LogError(GenT::MOC, + cmStrCat(sourceFile.FileName, "\nincludes the moc file ", + Quoted(incKey.Key), + ",\nwhich seems to be the moc file from a different " + "source file.\nThis is not supported. Include ", + Quoted(sourceBase + ".moc"), + " to run moc on this source file.")); return false; } // Accept but issue a warning if moc isn't required if (parseData.Macro.empty()) { - Log().WarningFile(GenT::MOC, sourceFile.FileName, - cmStrCat("The file includes the moc file ", - Quoted(incKey.Key), - ", but does not contain a ", - MocConst().MacrosString(), " macro.")); + Log().Warning(GenT::MOC, + cmStrCat(sourceFile.FileName, "\nincludes the moc file ", + Quoted(incKey.Key), ", but does not contain a ", + MocConst().MacrosString(), " macro.")); } // Create mapping - if (!MocRegisterIncluded(incKey.Key, source, source, false)) { + if (!RegisterIncluded(incKey.Key, source, source, false)) { return false; } } @@ -810,79 +806,71 @@ bool cmQtAutoMocUic::JobEvalCacheT::MocEvalSource( return true; } -cmQtAutoMocUic::SourceFileHandleT -cmQtAutoMocUic::JobEvalCacheT::MocFindIncludedHeader( - std::string const& includerDir, std::string const& includeBase) const +bool cmQtAutoMocUic::JobEvalCacheMocT::FindIncludedHeader( + SourceFileHandleT& headerHandle, cm::string_view includerDir, + cm::string_view includeBase) { - // Search in vicinity of the source - { - SourceFileHandleT res = MocFindHeader(includerDir + includeBase); - if (res) { - return res; - } - } - // Search in include directories - for (std::string const& path : MocConst().IncludePaths) { - std::string testPath = cmStrCat(path, '/', includeBase); - SourceFileHandleT res = MocFindHeader(testPath); - if (res) { - return res; - } - } - // Return without success - return SourceFileHandleT(); -} + // Clear search locations + SearchLocations.clear(); + + auto findHeader = [this, + &headerHandle](std::string const& basePath) -> bool { + bool found = false; + std::string const baseCollapsed = + this->Gen()->CollapseFullPathTS(cmStrCat(basePath, '.')); + for (std::string const& ext : this->BaseConst().HeaderExtensions) { + std::string const testPath = cmStrCat(baseCollapsed, ext); + cmFileTime fileTime; + if (!fileTime.Load(testPath)) { + // File not found + continue; + } -cmQtAutoMocUic::SourceFileHandleT cmQtAutoMocUic::JobEvalCacheT::MocFindHeader( - std::string const& basePath) const -{ - std::string testPath; - testPath.reserve(basePath.size() + 8); - for (std::string const& ext : BaseConst().HeaderExtensions) { - testPath.clear(); - testPath += basePath; - testPath += '.'; - testPath += ext; - cmFileTime fileTime; - if (fileTime.Load(testPath)) { - // Compute real path of the file - testPath = cmSystemTools::CollapseFullPath(testPath, - BaseConst().CurrentSourceDir); // Return a known file if it exists already { auto it = BaseEval().Headers.find(testPath); if (it != BaseEval().Headers.end()) { - return it->second; + headerHandle = it->second; + found = true; + break; } } + // Created and return discovered file entry - SourceFileHandleT& res = MocEval().HeadersDiscovered[testPath]; - if (!res) { - res = std::make_shared(testPath); - res->FileTime = fileTime; - res->Moc = true; + { + SourceFileHandleT& handle = MocEval().HeadersDiscovered[testPath]; + if (!handle) { + handle = std::make_shared(testPath); + handle->FileTime = fileTime; + handle->Moc = true; + } + headerHandle = handle; + found = true; + break; } - return res; } - } - // Return without success - return SourceFileHandleT(); -} + if (!found) { + this->SearchLocations.emplace_back( + cmQtAutoGen::ParentDir(baseCollapsed)); + } + return found; + }; -std::string cmQtAutoMocUic::JobEvalCacheT::MocMessageTestHeaders( - cm::string_view fileBase) const -{ - std::string const exts = - cmStrCat(".{", cmJoin(BaseConst().HeaderExtensions, ","), '}'); - // Compose result string - std::string res = cmStrCat(" ", fileBase, exts, '\n'); + // Search in vicinity of the source + if (findHeader(cmStrCat(includerDir, includeBase))) { + return true; + } + // Search in include directories for (std::string const& path : MocConst().IncludePaths) { - res += cmStrCat(" ", path, '/', fileBase, exts, '\n'); + if (findHeader(cmStrCat(path, '/', includeBase))) { + return true; + } } - return res; + // Return without success + return false; } -bool cmQtAutoMocUic::JobEvalCacheT::MocRegisterIncluded( +bool cmQtAutoMocUic::JobEvalCacheMocT::RegisterIncluded( std::string const& includeString, SourceFileHandleT includerFileHandle, SourceFileHandleT sourceFileHandle, bool sourceIsHeader) const { @@ -925,11 +913,11 @@ bool cmQtAutoMocUic::JobEvalCacheT::MocRegisterIncluded( handle->OutputFile = Gen()->AbsoluteIncludePath(includeString); // Register mapping in sources/headers map - MocRegisterMapping(handle, sourceIsHeader); + RegisterMapping(handle, sourceIsHeader); return true; } -void cmQtAutoMocUic::JobEvalCacheT::MocRegisterMapping( +void cmQtAutoMocUic::JobEvalCacheMocT::RegisterMapping( MappingHandleT mappingHandle, bool sourceIsHeader) const { auto& regMap = @@ -947,17 +935,33 @@ void cmQtAutoMocUic::JobEvalCacheT::MocRegisterMapping( } } -bool cmQtAutoMocUic::JobEvalCacheT::UicEval(SourceFileMapT const& fileMap) +std::string cmQtAutoMocUic::JobEvalCacheMocT::MessageHeader( + cm::string_view headerBase) const { - for (auto const& pair : fileMap) { - if (!UicEvalFile(pair.second)) { - return false; + return Quoted(cmStrCat( + headerBase, ".{", cmJoin(this->BaseConst().HeaderExtensions, ","), '}')); +} + +void cmQtAutoMocUic::JobEvalCacheUicT::Process() +{ + // Prepare buffers + SearchLocations.reserve((UicConst().SearchPaths.size() + 1) * 2); + + // Evaluate headers + for (auto const& pair : BaseEval().Headers) { + if (!EvalFile(pair.second)) { + return; + } + } + // Evaluate sources + for (auto const& pair : BaseEval().Sources) { + if (!EvalFile(pair.second)) { + return; } } - return true; } -bool cmQtAutoMocUic::JobEvalCacheT::UicEvalFile( +bool cmQtAutoMocUic::JobEvalCacheUicT::EvalFile( SourceFileHandleT const& sourceFileHandle) { SourceFileT const& sourceFile = *sourceFileHandle; @@ -966,17 +970,25 @@ bool cmQtAutoMocUic::JobEvalCacheT::UicEvalFile( return true; } - std::string const sourceDir = SubDirPrefix(sourceFile.FileName); + std::string const sourceDirPrefix = SubDirPrefix(sourceFile.FileName); for (IncludeKeyT const& incKey : Include) { - // Find .ui file name - SourceFileHandleT uiFileHandle = - UicFindIncludedUi(sourceFile.FileName, sourceDir, incKey); - if (!uiFileHandle || UicConst().skipped(uiFileHandle->FileName)) { + // Find .ui file + UiName = cmStrCat(incKey.Base, ".ui"); + if (!FindIncludedUi(sourceDirPrefix, incKey.Dir)) { + LogError(GenT::UIC, + cmStrCat(sourceFile.FileName, "\nincludes the uic file ", + Quoted(incKey.Key), ",\nbut the user interface file ", + Quoted(UiName), + "\ncould not be found in the following directories\n", + MessageSearchLocations())); + return false; + } + // Check if the file is skipped + if (UicConst().skipped(UiFileHandle->FileName)) { continue; } // Register mapping - if (!UicRegisterMapping(incKey.Key, std::move(uiFileHandle), - sourceFileHandle)) { + if (!RegisterMapping(incKey.Key, sourceFileHandle)) { return false; } } @@ -984,15 +996,68 @@ bool cmQtAutoMocUic::JobEvalCacheT::UicEvalFile( return true; } -bool cmQtAutoMocUic::JobEvalCacheT::UicRegisterMapping( - std::string const& includeString, SourceFileHandleT uiFileHandle, - SourceFileHandleT includerFileHandle) +bool cmQtAutoMocUic::JobEvalCacheUicT::FindIncludedUi( + cm::string_view sourceDirPrefix, cm::string_view includePrefix) +{ + // Clear locations buffer + SearchLocations.clear(); + + auto findUi = [this](std::string const& testPath) -> bool { + std::string const fullPath = this->Gen()->CollapseFullPathTS(testPath); + cmFileTime fileTime; + if (!fileTime.Load(fullPath)) { + this->SearchLocations.emplace_back(cmQtAutoGen::ParentDir(fullPath)); + return false; + } + // .ui file found in files system! + // Get or create .ui file handle + SourceFileHandleT& handle = this->UicEval().UiFiles[fullPath]; + if (!handle) { + // The file wasn't registered, yet + handle = std::make_shared(fullPath); + handle->FileTime = fileTime; + } + this->UiFileHandle = handle; + return true; + }; + + // Vicinity of the source + if (findUi(cmStrCat(sourceDirPrefix, UiName))) { + return true; + } + if (!includePrefix.empty()) { + if (findUi(cmStrCat(sourceDirPrefix, includePrefix, UiName))) { + return true; + } + } + // Additional AUTOUIC search paths + auto const& searchPaths = UicConst().SearchPaths; + if (!searchPaths.empty()) { + for (std::string const& sPath : searchPaths) { + if (findUi(cmStrCat(sPath, '/', UiName))) { + return true; + } + } + if (!includePrefix.empty()) { + for (std::string const& sPath : searchPaths) { + if (findUi(cmStrCat(sPath, '/', includePrefix, UiName))) { + return true; + } + } + } + } + + return false; +} + +bool cmQtAutoMocUic::JobEvalCacheUicT::RegisterMapping( + std::string const& includeString, SourceFileHandleT includerFileHandle) { auto& Includes = Gen()->UicEval().Includes; auto it = Includes.find(includeString); if (it != Includes.end()) { MappingHandleT const& handle = it->second; - if (handle->SourceFile != uiFileHandle) { + if (handle->SourceFile != UiFileHandle) { // The output file already gets generated - from a different .ui file! std::string files = cmStrCat(" ", Quoted(includerFileHandle->FileName), '\n'); @@ -1006,7 +1071,7 @@ bool cmQtAutoMocUic::JobEvalCacheT::UicRegisterMapping( Quoted(includeString), ", but\nthe uic file would be generated from different " "user interface files\n ", - Quoted(uiFileHandle->FileName), " and\n ", + Quoted(UiFileHandle->FileName), " and\n ", Quoted(handle->SourceFile->FileName), ".\nConsider to\n" " - add a directory prefix to a \"ui_.h\" include " @@ -1022,7 +1087,7 @@ bool cmQtAutoMocUic::JobEvalCacheT::UicRegisterMapping( MappingHandleT handle = std::make_shared(); handle->IncludeString = includeString; handle->IncluderFiles.emplace_back(std::move(includerFileHandle)); - handle->SourceFile = std::move(uiFileHandle); + handle->SourceFile = UiFileHandle; handle->OutputFile = Gen()->AbsoluteIncludePath(includeString); // Register mapping Includes.emplace(includeString, std::move(handle)); @@ -1030,69 +1095,24 @@ bool cmQtAutoMocUic::JobEvalCacheT::UicRegisterMapping( return true; } -cmQtAutoMocUic::SourceFileHandleT -cmQtAutoMocUic::JobEvalCacheT::UicFindIncludedUi( - std::string const& sourceFile, std::string const& sourceDir, - IncludeKeyT const& incKey) const +void cmQtAutoMocUic::JobEvalCacheFinishT::Process() { - std::string searchFileName = cmStrCat(incKey.Base, ".ui"); - // Collect search paths list - std::vector testFiles; - { - auto& searchPaths = UicConst().SearchPaths; - testFiles.reserve((searchPaths.size() + 1) * 2); - - // Vicinity of the source - testFiles.emplace_back(sourceDir + searchFileName); - if (!incKey.Dir.empty()) { - testFiles.emplace_back(cmStrCat(sourceDir, incKey.Dir, searchFileName)); - } - // AUTOUIC search paths - if (!searchPaths.empty()) { - for (std::string const& sPath : searchPaths) { - testFiles.emplace_back(cmStrCat(sPath, '/', searchFileName)); - } - if (!incKey.Dir.empty()) { - for (std::string const& sPath : searchPaths) { - testFiles.emplace_back( - cmStrCat(sPath, '/', incKey.Dir, searchFileName)); - } - } - } - } - - // Search for the .ui file! - for (std::string const& testFile : testFiles) { - cmFileTime fileTime; - if (fileTime.Load(testFile)) { - // .ui file found in files system! - std::string fullPath = cmSystemTools::CollapseFullPath( - testFile, BaseConst().CurrentSourceDir); - // Get or create .ui file handle - SourceFileHandleT& handle = Gen()->UicEval().UiFiles[fullPath]; - if (!handle) { - // The file wasn't registered, yet - handle = std::make_shared(fullPath); - handle->FileTime = fileTime; - } - return handle; - } - } + // Add discovered header parse jobs + Gen()->CreateParseJobs(MocEval().HeadersDiscovered); - // Log error + // Add dependency probing jobs { - std::string files; - for (std::string const& testFile : testFiles) { - files += cmStrCat(" ", Quoted(testFile), '\n'); + // Add fence job to ensure all parsing has finished + Gen()->WorkerPool().EmplaceJob(); + if (MocConst().Enabled) { + Gen()->WorkerPool().EmplaceJob(); + } + if (UicConst().Enabled) { + Gen()->WorkerPool().EmplaceJob(); } - LogFileError( - GenT::UIC, sourceFile, - cmStrCat("The file includes the uic file ", Quoted(incKey.Key), - ",\nbut the user interface file ", Quoted(searchFileName), - "\ncould not be found in the following locations\n", files)); + // Add probe finish job + Gen()->WorkerPool().EmplaceJob(); } - - return SourceFileHandleT(); } void cmQtAutoMocUic::JobProbeDepsMocT::Process() @@ -1863,18 +1883,38 @@ void cmQtAutoMocUic::CreateParseJobs(SourceFileMapT const& sourceMap) } } +/** Concurrently callable implementation of cmSystemTools::CollapseFullPath */ +std::string cmQtAutoMocUic::CollapseFullPathTS(std::string const& path) const +{ + std::lock_guard guard(CMakeLibMutex_); + return cmSystemTools::CollapseFullPath(path, BaseConst().CurrentSourceDir); +} + void cmQtAutoMocUic::InitJobs() { // Add moc_predefs.h job if (MocConst().Enabled && !MocConst().PredefsCmd.empty()) { WorkerPool().EmplaceJob(); } + // Add header parse jobs CreateParseJobs(BaseEval().Headers); // Add source parse jobs CreateParseJobs(BaseEval().Sources); - // Add evaluate job - WorkerPool().EmplaceJob(); + + // Add parse cache evaluations jobs + { + // Add a fence job to ensure all parsing has finished + WorkerPool().EmplaceJob(); + if (MocConst().Enabled) { + WorkerPool().EmplaceJob(); + } + if (UicConst().Enabled) { + WorkerPool().EmplaceJob(); + } + // Add evaluate job + WorkerPool().EmplaceJob(); + } } bool cmQtAutoMocUic::Process() diff --git a/Source/cmQtAutoMocUic.h b/Source/cmQtAutoMocUic.h index 3af1846..e480751 100644 --- a/Source/cmQtAutoMocUic.h +++ b/Source/cmQtAutoMocUic.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -384,34 +385,50 @@ public: void Process() override; }; - /** Evaluate cached file parse data. */ - class JobEvalCacheT : public JobFenceT + /** Evaluate cached file parse data - moc. */ + class JobEvalCacheT : public JobT + { + protected: + std::string MessageSearchLocations() const; + std::vector SearchLocations; + }; + + /** Evaluate cached file parse data - moc. */ + class JobEvalCacheMocT : public JobEvalCacheT { void Process() override; + bool EvalHeader(SourceFileHandleT source); + bool EvalSource(SourceFileHandleT const& source); + bool FindIncludedHeader(SourceFileHandleT& headerHandle, + cm::string_view includerDir, + cm::string_view includeBase); + bool RegisterIncluded(std::string const& includeString, + SourceFileHandleT includerFileHandle, + SourceFileHandleT sourceFileHandle, + bool sourceIsHeader) const; + void RegisterMapping(MappingHandleT mappingHandle, + bool sourceIsHeader) const; + std::string MessageHeader(cm::string_view headerBase) const; + }; - // -- Moc - bool MocEvalHeader(SourceFileHandleT source); - bool MocEvalSource(SourceFileHandleT const& source); - SourceFileHandleT MocFindIncludedHeader( - std::string const& includerDir, std::string const& includeBase) const; - SourceFileHandleT MocFindHeader(std::string const& basePath) const; - std::string MocMessageTestHeaders(cm::string_view fileBase) const; - bool MocRegisterIncluded(std::string const& includeString, - SourceFileHandleT includerFileHandle, - SourceFileHandleT sourceFileHandle, - bool sourceIsHeader) const; - void MocRegisterMapping(MappingHandleT mappingHandle, - bool sourceIsHeader) const; - - // -- Uic - bool UicEval(SourceFileMapT const& fileMap); - bool UicEvalFile(SourceFileHandleT const& sourceFileHandle); - SourceFileHandleT UicFindIncludedUi(std::string const& sourceFile, - std::string const& sourceDir, - IncludeKeyT const& incKey) const; - bool UicRegisterMapping(std::string const& includeString, - SourceFileHandleT uiFileHandle, - SourceFileHandleT includerFileHandle); + /** Evaluate cached file parse data - uic. */ + class JobEvalCacheUicT : public JobEvalCacheT + { + void Process() override; + bool EvalFile(SourceFileHandleT const& sourceFileHandle); + bool FindIncludedUi(cm::string_view sourceDirPrefix, + cm::string_view includePrefix); + bool RegisterMapping(std::string const& includeString, + SourceFileHandleT includerFileHandle); + + std::string UiName; + SourceFileHandleT UiFileHandle; + }; + + /** Evaluate cached file parse data - finish */ + class JobEvalCacheFinishT : public JobFenceT + { + void Process() override; }; /** Dependency probing base job. */ @@ -505,6 +522,7 @@ public: std::string AbsoluteIncludePath(cm::string_view relativePath) const; template void CreateParseJobs(SourceFileMapT const& sourceMap); + std::string CollapseFullPathTS(std::string const& path) const; private: // -- Utility accessors @@ -541,6 +559,8 @@ private: // -- Worker thread pool std::atomic JobError_ = ATOMIC_VAR_INIT(false); cmWorkerPool WorkerPool_; + // -- Concurrent processing + mutable std::mutex CMakeLibMutex_; }; #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1a3f185c1a1f5f67e6c7d8d821f17619208e6311 commit 1a3f185c1a1f5f67e6c7d8d821f17619208e6311 Author: Sebastian Holtermann AuthorDate: Thu Sep 12 12:14:12 2019 +0200 Commit: Sebastian Holtermann CommitDate: Mon Sep 16 18:18:48 2019 +0200 Autogen: Split JobProbeDepsT job into separate moc and uic jobs By splitting `JobProbeDepsT` into two independent `JobProbeDepsMocT`, `JobProbeDepsUicT`, the moc and uic job generation will happen concurrently. This should improve the execution speed, when both AUTOMOC and AUTOUIC are enabled. Parent directory names for moc and uic output files are are collected in a `std::unordered_set` and get created in a batch. Beforehand we tried to create the parent directory for each output file. This led to duplications of `MakeDirectory` calls when there were multiple output files in the same directory (which is the case usually). diff --git a/Source/cmQtAutoGen.cxx b/Source/cmQtAutoGen.cxx index f3c78d3..57c8825 100644 --- a/Source/cmQtAutoGen.cxx +++ b/Source/cmQtAutoGen.cxx @@ -162,6 +162,15 @@ std::string cmQtAutoGen::QuotedCommand(std::vector const& command) return res; } +std::string cmQtAutoGen::ParentDir(cm::string_view filename) +{ + auto slashPos = filename.rfind('/'); + if (slashPos == cm::string_view::npos) { + return std::string(); + } + return std::string(filename.substr(0, slashPos)); +} + std::string cmQtAutoGen::SubDirPrefix(cm::string_view filename) { auto slashPos = filename.rfind('/'); diff --git a/Source/cmQtAutoGen.h b/Source/cmQtAutoGen.h index fb15586..71969ee 100644 --- a/Source/cmQtAutoGen.h +++ b/Source/cmQtAutoGen.h @@ -80,6 +80,9 @@ public: static std::string QuotedCommand(std::vector const& command); + /// @brief Returns the parent directory of the file (thread safe) + static std::string ParentDir(cm::string_view filename); + /// @brief Returns the parent directory of the file with a "/" suffix static std::string SubDirPrefix(cm::string_view filename); diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index fe63dec..6265777 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -577,8 +577,20 @@ void cmQtAutoMocUic::JobEvalCacheT::Process() // Add discovered header parse jobs Gen()->CreateParseJobs(MocEval().HeadersDiscovered); - // Add generate job after - Gen()->WorkerPool().EmplaceJob(); + + // Add dependency probing jobs + { + // Add fence job to ensure all parsing has finished + Gen()->WorkerPool().EmplaceJob(); + if (MocConst().Enabled) { + Gen()->WorkerPool().EmplaceJob(); + } + if (UicConst().Enabled) { + Gen()->WorkerPool().EmplaceJob(); + } + // Add probe finish job + Gen()->WorkerPool().EmplaceJob(); + } } bool cmQtAutoMocUic::JobEvalCacheT::MocEvalHeader(SourceFileHandleT source) @@ -1083,57 +1095,38 @@ cmQtAutoMocUic::JobEvalCacheT::UicFindIncludedUi( return SourceFileHandleT(); } -void cmQtAutoMocUic::JobProbeDepsT::Process() +void cmQtAutoMocUic::JobProbeDepsMocT::Process() { - // Add moc compile jobs - if (MocConst().Enabled) { - for (auto const& pair : MocEval().HeaderMappings) { - // Register if this mapping is a candidate for mocs_compilation.cpp - bool const compFile = pair.second->IncludeString.empty(); - if (compFile) { - MocEval().CompFiles.emplace_back(pair.second->SourceFile->BuildPath); - } - if (!MocGenerate(pair.second, compFile)) { - return; - } + // Create moc header jobs + for (auto const& pair : MocEval().HeaderMappings) { + // Register if this mapping is a candidate for mocs_compilation.cpp + bool const compFile = pair.second->IncludeString.empty(); + if (compFile) { + MocEval().CompFiles.emplace_back(pair.second->SourceFile->BuildPath); } - for (auto const& pair : MocEval().SourceMappings) { - if (!MocGenerate(pair.second, false)) { - return; - } + if (!Generate(pair.second, compFile)) { + return; } - - // Add mocs compilations job on demand - Gen()->WorkerPool().EmplaceJob(); } - // Add uic compile jobs - if (UicConst().Enabled) { - for (auto const& pair : Gen()->UicEval().Includes) { - if (!UicGenerate(pair.second)) { - return; - } + // Create moc source jobs + for (auto const& pair : MocEval().SourceMappings) { + if (!Generate(pair.second, false)) { + return; } } - - // Add finish job - Gen()->WorkerPool().EmplaceJob(); } -bool cmQtAutoMocUic::JobProbeDepsT::MocGenerate(MappingHandleT const& mapping, +bool cmQtAutoMocUic::JobProbeDepsMocT::Generate(MappingHandleT const& mapping, bool compFile) const { std::unique_ptr reason; if (Log().Verbose()) { reason = cm::make_unique(); } - if (MocUpdate(*mapping, reason.get())) { - // Create the parent directory - if (!MakeParentDirectory(mapping->OutputFile)) { - LogFileError(GenT::MOC, mapping->OutputFile, - "Could not create parent directory."); - return false; - } + if (Probe(*mapping, reason.get())) { + // Register the parent directory for creation + MocEval().OutputDirs.emplace(cmQtAutoGen::ParentDir(mapping->OutputFile)); // Add moc job Gen()->WorkerPool().EmplaceJob(mapping, std::move(reason)); // Check if a moc job for a mocs_compilation.cpp entry was generated @@ -1144,8 +1137,8 @@ bool cmQtAutoMocUic::JobProbeDepsT::MocGenerate(MappingHandleT const& mapping, return true; } -bool cmQtAutoMocUic::JobProbeDepsT::MocUpdate(MappingT const& mapping, - std::string* reason) const +bool cmQtAutoMocUic::JobProbeDepsMocT::Probe(MappingT const& mapping, + std::string* reason) const { std::string const& sourceFile = mapping.SourceFile->FileName; std::string const& outputFile = mapping.OutputFile; @@ -1209,7 +1202,7 @@ bool cmQtAutoMocUic::JobProbeDepsT::MocUpdate(MappingT const& mapping, std::string const sourceDir = SubDirPrefix(sourceFile); for (std::string const& dep : mapping.SourceFile->ParseData->Moc.Depends) { // Find dependency file - auto const depMatch = MocFindDependency(sourceDir, dep); + auto const depMatch = FindDependency(sourceDir, dep); if (depMatch.first.empty()) { Log().WarningFile(GenT::MOC, sourceFile, "Could not find dependency file " + Quoted(dep)); @@ -1232,7 +1225,7 @@ bool cmQtAutoMocUic::JobProbeDepsT::MocUpdate(MappingT const& mapping, } std::pair -cmQtAutoMocUic::JobProbeDepsT::MocFindDependency( +cmQtAutoMocUic::JobProbeDepsMocT::FindDependency( std::string const& sourceDir, std::string const& includeString) const { using ResPair = std::pair; @@ -1254,28 +1247,27 @@ cmQtAutoMocUic::JobProbeDepsT::MocFindDependency( return ResPair(); } -bool cmQtAutoMocUic::JobProbeDepsT::UicGenerate( - MappingHandleT const& mapping) const +void cmQtAutoMocUic::JobProbeDepsUicT::Process() { - std::unique_ptr reason; - if (Log().Verbose()) { - reason = cm::make_unique(); - } - if (UicUpdate(*mapping, reason.get())) { - // Create the parent directory - if (!MakeParentDirectory(mapping->OutputFile)) { - LogFileError(GenT::UIC, mapping->OutputFile, - "Could not create parent directory."); - return false; + for (auto const& pair : Gen()->UicEval().Includes) { + MappingHandleT const& mapping = pair.second; + std::unique_ptr reason; + if (Log().Verbose()) { + reason = cm::make_unique(); + } + if (!Probe(*mapping, reason.get())) { + continue; } + + // Register the parent directory for creation + UicEval().OutputDirs.emplace(cmQtAutoGen::ParentDir(mapping->OutputFile)); // Add uic job Gen()->WorkerPool().EmplaceJob(mapping, std::move(reason)); } - return true; } -bool cmQtAutoMocUic::JobProbeDepsT::UicUpdate(MappingT const& mapping, - std::string* reason) const +bool cmQtAutoMocUic::JobProbeDepsUicT::Probe(MappingT const& mapping, + std::string* reason) const { std::string const& sourceFile = mapping.SourceFile->FileName; std::string const& outputFile = mapping.OutputFile; @@ -1324,6 +1316,40 @@ bool cmQtAutoMocUic::JobProbeDepsT::UicUpdate(MappingT const& mapping, return false; } +void cmQtAutoMocUic::JobProbeDepsFinishT::Process() +{ + // Create output directories + { + using StringSet = std::unordered_set; + auto createDirs = [this](GenT genType, StringSet const& dirSet) { + for (std::string const& dirName : dirSet) { + if (!cmSystemTools::MakeDirectory(dirName)) { + this->LogFileError(genType, dirName, "Could not create directory."); + return; + } + } + }; + if (MocConst().Enabled && UicConst().Enabled) { + StringSet outputDirs = MocEval().OutputDirs; + outputDirs.insert(UicEval().OutputDirs.begin(), + UicEval().OutputDirs.end()); + createDirs(GenT::GEN, outputDirs); + } else if (MocConst().Enabled) { + createDirs(GenT::MOC, MocEval().OutputDirs); + } else if (UicConst().Enabled) { + createDirs(GenT::UIC, UicEval().OutputDirs); + } + } + + if (MocConst().Enabled) { + // Add mocs compilations job + Gen()->WorkerPool().EmplaceJob(); + } + + // Add finish job + Gen()->WorkerPool().EmplaceJob(); +} + void cmQtAutoMocUic::JobCompileMocT::Process() { std::string const& sourceFile = Mapping->SourceFile->FileName; diff --git a/Source/cmQtAutoMocUic.h b/Source/cmQtAutoMocUic.h index 3e815cd..3af1846 100644 --- a/Source/cmQtAutoMocUic.h +++ b/Source/cmQtAutoMocUic.h @@ -243,6 +243,8 @@ public: MappingMapT Includes; // -- Discovered files SourceFileMapT HeadersDiscovered; + // -- Output directories + std::unordered_set OutputDirs; // -- Mocs compilation bool CompUpdated = false; std::vector CompFiles; @@ -277,8 +279,12 @@ public: class UicEvalT { public: + // -- Discovered files SourceFileMapT UiFiles; + // -- Mappings MappingMapT Includes; + // -- Output directories + std::unordered_set OutputDirs; }; /** Abstract job class for concurrent job processing. */ @@ -408,18 +414,32 @@ public: SourceFileHandleT includerFileHandle); }; - /** Probes file dependencies and generates moc and uic compile jobs. */ - class JobProbeDepsT : public JobFenceT + /** Dependency probing base job. */ + class JobProbeDepsT : public JobT + { + }; + + /** Probes file dependencies and generates moc compile jobs. */ + class JobProbeDepsMocT : public JobProbeDepsT { void Process() override; - // -- Moc - bool MocGenerate(MappingHandleT const& mapping, bool compFile) const; - bool MocUpdate(MappingT const& mapping, std::string* reason) const; - std::pair MocFindDependency( + bool Generate(MappingHandleT const& mapping, bool compFile) const; + bool Probe(MappingT const& mapping, std::string* reason) const; + std::pair FindDependency( std::string const& sourceDir, std::string const& includeString) const; - // -- Uic - bool UicGenerate(MappingHandleT const& mapping) const; - bool UicUpdate(MappingT const& mapping, std::string* reason) const; + }; + + /** Probes file dependencies and generates uic compile jobs. */ + class JobProbeDepsUicT : public JobProbeDepsT + { + void Process() override; + bool Probe(MappingT const& mapping, std::string* reason) const; + }; + + /** Dependency probing finish job. */ + class JobProbeDepsFinishT : public JobFenceT + { + void Process() override; }; /** Meta compiler base job. */ https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=726ea1d15134591c352468b64b3e92f04f2449bb commit 726ea1d15134591c352468b64b3e92f04f2449bb Author: Sebastian Holtermann AuthorDate: Thu Sep 12 11:06:00 2019 +0200 Commit: Sebastian Holtermann CommitDate: Mon Sep 16 18:18:48 2019 +0200 Autogen: Rename job classes diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index c305ca6..fe63dec 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -551,7 +551,7 @@ void cmQtAutoMocUic::JobParseSourceT::Process() } } -void cmQtAutoMocUic::JobEvaluateT::Process() +void cmQtAutoMocUic::JobEvalCacheT::Process() { // Evaluate for moc if (MocConst().Enabled) { @@ -578,10 +578,10 @@ void cmQtAutoMocUic::JobEvaluateT::Process() // Add discovered header parse jobs Gen()->CreateParseJobs(MocEval().HeadersDiscovered); // Add generate job after - Gen()->WorkerPool().EmplaceJob(); + Gen()->WorkerPool().EmplaceJob(); } -bool cmQtAutoMocUic::JobEvaluateT::MocEvalHeader(SourceFileHandleT source) +bool cmQtAutoMocUic::JobEvalCacheT::MocEvalHeader(SourceFileHandleT source) { SourceFileT const& sourceFile = *source; auto const& parseData = sourceFile.ParseData->Moc; @@ -608,7 +608,7 @@ bool cmQtAutoMocUic::JobEvaluateT::MocEvalHeader(SourceFileHandleT source) return true; } -bool cmQtAutoMocUic::JobEvaluateT::MocEvalSource( +bool cmQtAutoMocUic::JobEvalCacheT::MocEvalSource( SourceFileHandleT const& source) { SourceFileT const& sourceFile = *source; @@ -799,7 +799,7 @@ bool cmQtAutoMocUic::JobEvaluateT::MocEvalSource( } cmQtAutoMocUic::SourceFileHandleT -cmQtAutoMocUic::JobEvaluateT::MocFindIncludedHeader( +cmQtAutoMocUic::JobEvalCacheT::MocFindIncludedHeader( std::string const& includerDir, std::string const& includeBase) const { // Search in vicinity of the source @@ -821,7 +821,7 @@ cmQtAutoMocUic::JobEvaluateT::MocFindIncludedHeader( return SourceFileHandleT(); } -cmQtAutoMocUic::SourceFileHandleT cmQtAutoMocUic::JobEvaluateT::MocFindHeader( +cmQtAutoMocUic::SourceFileHandleT cmQtAutoMocUic::JobEvalCacheT::MocFindHeader( std::string const& basePath) const { std::string testPath; @@ -857,7 +857,7 @@ cmQtAutoMocUic::SourceFileHandleT cmQtAutoMocUic::JobEvaluateT::MocFindHeader( return SourceFileHandleT(); } -std::string cmQtAutoMocUic::JobEvaluateT::MocMessageTestHeaders( +std::string cmQtAutoMocUic::JobEvalCacheT::MocMessageTestHeaders( cm::string_view fileBase) const { std::string const exts = @@ -870,7 +870,7 @@ std::string cmQtAutoMocUic::JobEvaluateT::MocMessageTestHeaders( return res; } -bool cmQtAutoMocUic::JobEvaluateT::MocRegisterIncluded( +bool cmQtAutoMocUic::JobEvalCacheT::MocRegisterIncluded( std::string const& includeString, SourceFileHandleT includerFileHandle, SourceFileHandleT sourceFileHandle, bool sourceIsHeader) const { @@ -917,7 +917,7 @@ bool cmQtAutoMocUic::JobEvaluateT::MocRegisterIncluded( return true; } -void cmQtAutoMocUic::JobEvaluateT::MocRegisterMapping( +void cmQtAutoMocUic::JobEvalCacheT::MocRegisterMapping( MappingHandleT mappingHandle, bool sourceIsHeader) const { auto& regMap = @@ -935,7 +935,7 @@ void cmQtAutoMocUic::JobEvaluateT::MocRegisterMapping( } } -bool cmQtAutoMocUic::JobEvaluateT::UicEval(SourceFileMapT const& fileMap) +bool cmQtAutoMocUic::JobEvalCacheT::UicEval(SourceFileMapT const& fileMap) { for (auto const& pair : fileMap) { if (!UicEvalFile(pair.second)) { @@ -945,7 +945,7 @@ bool cmQtAutoMocUic::JobEvaluateT::UicEval(SourceFileMapT const& fileMap) return true; } -bool cmQtAutoMocUic::JobEvaluateT::UicEvalFile( +bool cmQtAutoMocUic::JobEvalCacheT::UicEvalFile( SourceFileHandleT const& sourceFileHandle) { SourceFileT const& sourceFile = *sourceFileHandle; @@ -972,7 +972,7 @@ bool cmQtAutoMocUic::JobEvaluateT::UicEvalFile( return true; } -bool cmQtAutoMocUic::JobEvaluateT::UicRegisterMapping( +bool cmQtAutoMocUic::JobEvalCacheT::UicRegisterMapping( std::string const& includeString, SourceFileHandleT uiFileHandle, SourceFileHandleT includerFileHandle) { @@ -1019,7 +1019,7 @@ bool cmQtAutoMocUic::JobEvaluateT::UicRegisterMapping( } cmQtAutoMocUic::SourceFileHandleT -cmQtAutoMocUic::JobEvaluateT::UicFindIncludedUi( +cmQtAutoMocUic::JobEvalCacheT::UicFindIncludedUi( std::string const& sourceFile, std::string const& sourceDir, IncludeKeyT const& incKey) const { @@ -1083,7 +1083,7 @@ cmQtAutoMocUic::JobEvaluateT::UicFindIncludedUi( return SourceFileHandleT(); } -void cmQtAutoMocUic::JobGenerateT::Process() +void cmQtAutoMocUic::JobProbeDepsT::Process() { // Add moc compile jobs if (MocConst().Enabled) { @@ -1120,8 +1120,8 @@ void cmQtAutoMocUic::JobGenerateT::Process() Gen()->WorkerPool().EmplaceJob(); } -bool cmQtAutoMocUic::JobGenerateT::MocGenerate(MappingHandleT const& mapping, - bool compFile) const +bool cmQtAutoMocUic::JobProbeDepsT::MocGenerate(MappingHandleT const& mapping, + bool compFile) const { std::unique_ptr reason; if (Log().Verbose()) { @@ -1135,7 +1135,7 @@ bool cmQtAutoMocUic::JobGenerateT::MocGenerate(MappingHandleT const& mapping, return false; } // Add moc job - Gen()->WorkerPool().EmplaceJob(mapping, std::move(reason)); + Gen()->WorkerPool().EmplaceJob(mapping, std::move(reason)); // Check if a moc job for a mocs_compilation.cpp entry was generated if (compFile) { MocEval().CompUpdated = true; @@ -1144,8 +1144,8 @@ bool cmQtAutoMocUic::JobGenerateT::MocGenerate(MappingHandleT const& mapping, return true; } -bool cmQtAutoMocUic::JobGenerateT::MocUpdate(MappingT const& mapping, - std::string* reason) const +bool cmQtAutoMocUic::JobProbeDepsT::MocUpdate(MappingT const& mapping, + std::string* reason) const { std::string const& sourceFile = mapping.SourceFile->FileName; std::string const& outputFile = mapping.OutputFile; @@ -1232,7 +1232,7 @@ bool cmQtAutoMocUic::JobGenerateT::MocUpdate(MappingT const& mapping, } std::pair -cmQtAutoMocUic::JobGenerateT::MocFindDependency( +cmQtAutoMocUic::JobProbeDepsT::MocFindDependency( std::string const& sourceDir, std::string const& includeString) const { using ResPair = std::pair; @@ -1254,7 +1254,7 @@ cmQtAutoMocUic::JobGenerateT::MocFindDependency( return ResPair(); } -bool cmQtAutoMocUic::JobGenerateT::UicGenerate( +bool cmQtAutoMocUic::JobProbeDepsT::UicGenerate( MappingHandleT const& mapping) const { std::unique_ptr reason; @@ -1269,13 +1269,13 @@ bool cmQtAutoMocUic::JobGenerateT::UicGenerate( return false; } // Add uic job - Gen()->WorkerPool().EmplaceJob(mapping, std::move(reason)); + Gen()->WorkerPool().EmplaceJob(mapping, std::move(reason)); } return true; } -bool cmQtAutoMocUic::JobGenerateT::UicUpdate(MappingT const& mapping, - std::string* reason) const +bool cmQtAutoMocUic::JobProbeDepsT::UicUpdate(MappingT const& mapping, + std::string* reason) const { std::string const& sourceFile = mapping.SourceFile->FileName; std::string const& outputFile = mapping.OutputFile; @@ -1324,7 +1324,7 @@ bool cmQtAutoMocUic::JobGenerateT::UicUpdate(MappingT const& mapping, return false; } -void cmQtAutoMocUic::JobMocT::Process() +void cmQtAutoMocUic::JobCompileMocT::Process() { std::string const& sourceFile = Mapping->SourceFile->FileName; std::string const& outputFile = Mapping->OutputFile; @@ -1368,7 +1368,7 @@ void cmQtAutoMocUic::JobMocT::Process() } } -void cmQtAutoMocUic::JobUicT::Process() +void cmQtAutoMocUic::JobCompileUicT::Process() { std::string const& sourceFile = Mapping->SourceFile->FileName; std::string const& outputFile = Mapping->OutputFile; @@ -1848,7 +1848,7 @@ void cmQtAutoMocUic::InitJobs() // Add source parse jobs CreateParseJobs(BaseEval().Sources); // Add evaluate job - WorkerPool().EmplaceJob(); + WorkerPool().EmplaceJob(); } bool cmQtAutoMocUic::Process() diff --git a/Source/cmQtAutoMocUic.h b/Source/cmQtAutoMocUic.h index 2f6ebff..3e815cd 100644 --- a/Source/cmQtAutoMocUic.h +++ b/Source/cmQtAutoMocUic.h @@ -40,9 +40,7 @@ public: public: // -- Types - /** - * Search key plus regular expression pair - */ + /** Search key plus regular expression pair. */ struct KeyExpT { KeyExpT() = default; @@ -63,9 +61,7 @@ public: cmsys::RegularExpression Exp; }; - /** - * Include string with sub parts - */ + /** Include string with sub parts. */ struct IncludeKeyT { IncludeKeyT(std::string const& key, std::size_t basePrefixLength); @@ -75,9 +71,7 @@ public: std::string Base; // Base part of the include file name }; - /** - * Source file parsing cache - */ + /** Source file parsing cache. */ class ParseCacheT { public: @@ -127,9 +121,7 @@ public: std::unordered_map Map_; }; - /** - * Source file data - */ + /** Source file data. */ class SourceFileT { public: @@ -149,9 +141,7 @@ public: using SourceFileHandleT = std::shared_ptr; using SourceFileMapT = std::map; - /** - * Meta compiler file mapping information - */ + /** Meta compiler file mapping information. */ struct MappingT { SourceFileHandleT SourceFile; @@ -162,9 +152,7 @@ public: using MappingHandleT = std::shared_ptr; using MappingMapT = std::map; - /** - * Common settings - */ + /** Common settings. */ class BaseSettingsT { public: @@ -193,9 +181,7 @@ public: std::vector HeaderExtensions; }; - /** - * Shared common variables - */ + /** Shared common variables. */ class BaseEvalT { public: @@ -209,9 +195,7 @@ public: SourceFileMapT Sources; }; - /** - * Moc settings - */ + /** Moc settings. */ class MocSettingsT { public: @@ -247,9 +231,7 @@ public: cmsys::RegularExpression RegExpInclude; }; - /** - * Moc shared variables - */ + /** Moc shared variables. */ class MocEvalT { public: @@ -266,9 +248,7 @@ public: std::vector CompFiles; }; - /** - * Uic settings - */ + /** Uic settings. */ class UicSettingsT { public: @@ -293,9 +273,7 @@ public: cmsys::RegularExpression RegExpInclude; }; - /** - * Uic shared variables - */ + /** Uic shared variables. */ class UicEvalT { public: @@ -303,15 +281,11 @@ public: MappingMapT Includes; }; - /** - * Abstract job class for concurrent job processing - */ + /** Abstract job class for concurrent job processing. */ class JobT : public cmWorkerPool::JobT { protected: - /** - * @brief Protected default constructor - */ + /** Protected default constructor. */ JobT(bool fence = false) : cmWorkerPool::JobT(fence) { @@ -340,17 +314,13 @@ public: std::vector const& command, std::string const& output) const; - /** - * @brief Run an external process. Use only during Process() call! - */ + /** @brief Run an external process. Use only during Process() call! */ bool RunProcess(GenT genType, cmWorkerPool::ProcessResultT& result, std::vector const& command, std::string* infoMessage = nullptr); }; - /** - * Fence job utility class - */ + /** Fence job utility class. */ class JobFenceT : public JobT { public: @@ -361,18 +331,14 @@ public: void Process() override{}; }; - /** - * Generate moc_predefs.h - */ + /** Generate moc_predefs.h. */ class JobMocPredefsT : public JobFenceT { void Process() override; bool Update(std::string* reason) const; }; - /** - * File parse job base class - */ + /** File parse job base class. */ class JobParseT : public JobT { public: @@ -396,9 +362,7 @@ public: std::string Content; }; - /** - * Header file parse job - */ + /** Header file parse job. */ class JobParseHeaderT : public JobParseT { public: @@ -406,9 +370,7 @@ public: void Process() override; }; - /** - * Source file parse job - */ + /** Source file parse job. */ class JobParseSourceT : public JobParseT { public: @@ -416,10 +378,8 @@ public: void Process() override; }; - /** - * Evaluate parsed files - */ - class JobEvaluateT : public JobFenceT + /** Evaluate cached file parse data. */ + class JobEvalCacheT : public JobFenceT { void Process() override; @@ -448,10 +408,8 @@ public: SourceFileHandleT includerFileHandle); }; - /** - * Generates moc/uic jobs - */ - class JobGenerateT : public JobFenceT + /** Probes file dependencies and generates moc and uic compile jobs. */ + class JobProbeDepsT : public JobFenceT { void Process() override; // -- Moc @@ -464,9 +422,7 @@ public: bool UicUpdate(MappingT const& mapping, std::string* reason) const; }; - /** - * File compiling base job - */ + /** Meta compiler base job. */ class JobCompileT : public JobT { public: @@ -481,36 +437,30 @@ public: std::unique_ptr Reason; }; - /** - * moc compiles a file - */ - class JobMocT : public JobCompileT + /** moc compiles a file. */ + class JobCompileMocT : public JobCompileT { public: using JobCompileT::JobCompileT; void Process() override; }; - /** - * uic compiles a file - */ - class JobUicT : public JobCompileT + /** uic compiles a file. */ + class JobCompileUicT : public JobCompileT { public: using JobCompileT::JobCompileT; void Process() override; }; - /// @brief Generate mocs_compilation.cpp - /// + /** Generate mocs_compilation.cpp. */ class JobMocsCompilationT : public JobFenceT { private: void Process() override; }; - /// @brief The last job - /// + /** @brief The last job. */ class JobFinishT : public JobFenceT { private: https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=05126d23f6a285731dfef940012c6b78feb9fa62 commit 05126d23f6a285731dfef940012c6b78feb9fa62 Author: Sebastian Holtermann AuthorDate: Sun Sep 8 15:27:02 2019 +0200 Commit: Sebastian Holtermann CommitDate: Mon Sep 16 18:18:48 2019 +0200 Autogen: Remove CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE sort duplication This removes code that sorts include directories for `AUTOMOC` according to `CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE`. This is possible because the included directories passed to `AUTOMOC` are already sorted, also with respect to `CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE`. diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index c6c71ab..7012ef6 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1247,8 +1247,6 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() MfDef("CMAKE_CURRENT_SOURCE_DIR")); ofs.Write("AM_CMAKE_CURRENT_BINARY_DIR", MfDef("CMAKE_CURRENT_BINARY_DIR")); - ofs.Write("AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE", - MfDef("CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE")); ofs.Write("AM_BUILD_DIR", this->Dir.Build); ofs.Write("AM_INCLUDE_DIR", this->Dir.Include); ofs.WriteConfig("AM_INCLUDE_DIR", this->Dir.ConfigInclude); diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 3e30a2f..c305ca6 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -2,14 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmQtAutoMocUic.h" -#include -#include -#include -#include -#include - -#include "cm_memory.hxx" - #include "cmAlgorithms.h" #include "cmCryptoHash.h" #include "cmGeneratedFileStream.h" @@ -17,9 +9,13 @@ #include "cmQtAutoGen.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" +#include "cm_memory.hxx" #include "cmake.h" #include "cmsys/FStream.hxx" +#include +#include +#include #if defined(__APPLE__) # include #endif @@ -1545,8 +1541,6 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) makefile->GetCMakeInstance()->GetHeaderExtensions(); // - Files and directories - BaseConst_.IncludeProjectDirsBefore = - InfoGetBool("AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE"); BaseConst_.ProjectSourceDir = InfoGet("AM_CMAKE_SOURCE_DIR"); BaseConst_.ProjectBinaryDir = InfoGet("AM_CMAKE_BINARY_DIR"); BaseConst_.CurrentSourceDir = InfoGet("AM_CMAKE_CURRENT_SOURCE_DIR"); @@ -1786,35 +1780,6 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) MocConst_.PredefsFileAbs = AbsoluteBuildPath(MocConst().PredefsFileRel); } - // Sort include directories on demand - if (BaseConst().IncludeProjectDirsBefore) { - // Move strings to temporary list - std::list includes(MocConst().IncludePaths.begin(), - MocConst().IncludePaths.end()); - MocConst_.IncludePaths.clear(); - MocConst_.IncludePaths.reserve(includes.size()); - // Append project directories only - { - std::initializer_list const movePaths = { - BaseConst().ProjectBinaryDir, BaseConst().ProjectSourceDir - }; - for (cm::string_view const& ppath : movePaths) { - auto it = includes.begin(); - while (it != includes.end()) { - std::string const& path = *it; - if (cmHasPrefix(path, ppath)) { - MocConst_.IncludePaths.push_back(path); - it = includes.erase(it); - } else { - ++it; - } - } - } - } - // Append remaining directories - MocConst_.IncludePaths.insert(MocConst_.IncludePaths.end(), - includes.begin(), includes.end()); - } // Compose moc includes list { std::set frameworkPaths; @@ -1924,7 +1889,6 @@ void cmQtAutoMocUic::SettingsFileRead() cha(MocConst().Executable); std::for_each(MocConst().AllOptions.begin(), MocConst().AllOptions.end(), cha); - cha(BaseConst().IncludeProjectDirsBefore ? "TRUE" : "FALSE"); std::for_each(MocConst().PredefsCmd.begin(), MocConst().PredefsCmd.end(), cha); for (auto const& filter : MocConst().DependFilters) { diff --git a/Source/cmQtAutoMocUic.h b/Source/cmQtAutoMocUic.h index 549b088..2f6ebff 100644 --- a/Source/cmQtAutoMocUic.h +++ b/Source/cmQtAutoMocUic.h @@ -178,7 +178,6 @@ public: // -- Attributes // - Config bool MultiConfig = false; - bool IncludeProjectDirsBefore = false; unsigned int QtVersionMajor = 4; // - Directories std::string ProjectSourceDir; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f54c5ee52195ae2d73a54faef9399ab977b83a1b commit f54c5ee52195ae2d73a54faef9399ab977b83a1b Author: Sebastian Holtermann AuthorDate: Thu Sep 12 13:15:32 2019 +0200 Commit: Sebastian Holtermann CommitDate: Mon Sep 16 18:18:48 2019 +0200 Autogen: Use CollapseFullPath instead of RealPath to support symbolic links diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 7bf56df..c6c71ab 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -5,6 +5,7 @@ #include "cmQtAutoGen.h" #include "cmQtAutoGenGlobalInitializer.h" +#include "cmAlgorithms.h" #include "cmCustomCommand.h" #include "cmCustomCommandLines.h" #include "cmFilePathChecksum.h" @@ -422,8 +423,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets() std::string const deps = this->GenTarget->GetSafeProperty("AUTOGEN_TARGET_DEPENDS"); if (!deps.empty()) { - std::vector extraDeps = cmExpandedList(deps); - for (std::string const& depName : extraDeps) { + for (std::string const& depName : cmExpandedList(deps)) { // Allow target and file dependencies auto* depTarget = this->Makefile->FindTargetToUse(depName); if (depTarget != nullptr) { @@ -642,7 +642,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() auto makeMUFile = [this, &kw](cmSourceFile* sf, std::string const& fullPath, bool muIt) -> MUFileHandle { MUFileHandle muf = cm::make_unique(); - muf->RealPath = cmSystemTools::GetRealPath(fullPath); + muf->FullPath = fullPath; muf->SF = sf; muf->Generated = sf->GetIsGenerated(); bool const skipAutogen = sf->GetPropertyAsBool(kw.SKIP_AUTOGEN); @@ -674,7 +674,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() std::vector srcFiles; this->GenTarget->GetConfigCommonSourceFiles(srcFiles); for (cmSourceFile* sf : srcFiles) { - // sf->GetExtension() is only valid after sf->GetFullPath() ... + // sf->GetExtension() is only valid after sf->ResolveFullPath() ... // Since we're iterating over source files that might be not in the // target we need to check for path errors (not existing files). std::string pathError; @@ -700,7 +700,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() !sf->GetPropertyAsBool(kw.SKIP_AUTORCC)) { // Register qrc file Qrc qrc; - qrc.QrcFile = cmSystemTools::GetRealPath(fullPath); + qrc.QrcFile = fullPath; qrc.QrcName = cmSystemTools::GetFilenameWithoutLastExtension(qrc.QrcFile); qrc.Generated = sf->GetIsGenerated(); @@ -734,10 +734,10 @@ bool cmQtAutoGenInitializer::InitScanFiles() MUFile const& muf = *pair.second; if (muf.MocIt || muf.UicIt) { // Search for the default header file and a private header - std::string const& srcPath = muf.SF->ResolveFullPath(); - std::string basePath = - cmStrCat(cmQtAutoGen::SubDirPrefix(srcPath), - cmSystemTools::GetFilenameWithoutLastExtension(srcPath)); + std::string const& srcFullPath = muf.SF->ResolveFullPath(); + std::string basePath = cmStrCat( + cmQtAutoGen::SubDirPrefix(srcFullPath), + cmSystemTools::GetFilenameWithoutLastExtension(srcFullPath)); for (auto const& suffix : suffixes) { std::string const suffixedPath = cmStrCat(basePath, suffix); for (auto const& ext : exts) { @@ -748,8 +748,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() this->Makefile->GetSource(fullPath, locationKind); if (sf != nullptr) { // Check if we know about this header already - if (this->AutogenTarget.Headers.find(sf) != - this->AutogenTarget.Headers.end()) { + if (cmContains(this->AutogenTarget.Headers, sf)) { continue; } // We only accept not-GENERATED files that do exist. @@ -789,7 +788,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() // at generation time. if (this->MocOrUicEnabled()) { for (cmSourceFile* sf : this->Makefile->GetSourceFiles()) { - // sf->GetExtension() is only valid after sf->GetFullPath() ... + // sf->GetExtension() is only valid after sf->ResolveFullPath() ... // Since we're iterating over source files that might be not in the // target we need to check for path errors (not existing files). std::string pathError; @@ -801,16 +800,14 @@ bool cmQtAutoGenInitializer::InitScanFiles() cmSystemTools::LowerCase(sf->GetExtension()); if (cm->IsHeaderExtension(extLower)) { - if (this->AutogenTarget.Headers.find(sf) == - this->AutogenTarget.Headers.end()) { + if (!cmContains(this->AutogenTarget.Headers, sf)) { auto muf = makeMUFile(sf, fullPath, false); if (muf->SkipMoc || muf->SkipUic) { this->AutogenTarget.Headers.emplace(sf, std::move(muf)); } } } else if (cm->IsSourceExtension(extLower)) { - if (this->AutogenTarget.Sources.find(sf) == - this->AutogenTarget.Sources.end()) { + if (!cmContains(this->AutogenTarget.Headers, sf)) { auto muf = makeMUFile(sf, fullPath, false); if (muf->SkipMoc || muf->SkipUic) { this->AutogenTarget.Sources.emplace(sf, std::move(muf)); @@ -818,7 +815,6 @@ bool cmQtAutoGenInitializer::InitScanFiles() } } else if (this->Uic.Enabled && (extLower == kw.ui)) { // .ui file - std::string realPath = cmSystemTools::GetRealPath(fullPath); bool const skipAutogen = sf->GetPropertyAsBool(kw.SKIP_AUTOGEN); bool const skipUic = (skipAutogen || sf->GetPropertyAsBool(kw.SKIP_AUTOUIC)); @@ -826,13 +822,12 @@ bool cmQtAutoGenInitializer::InitScanFiles() // Check if the .ui file has uic options std::string const uicOpts = sf->GetSafeProperty(kw.AUTOUIC_OPTIONS); if (!uicOpts.empty()) { - this->Uic.FileFiles.push_back(std::move(realPath)); - std::vector optsVec = cmExpandedList(uicOpts); - this->Uic.FileOptions.push_back(std::move(optsVec)); + this->Uic.FileFiles.push_back(fullPath); + this->Uic.FileOptions.push_back(cmExpandedList(uicOpts)); } } else { // Register skipped .ui file - this->Uic.SkipUi.insert(std::move(realPath)); + this->Uic.SkipUi.insert(fullPath); } } } @@ -843,7 +838,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() if (this->CMP0071Accept) { // Let the autogen target depend on the GENERATED files for (MUFile* muf : this->AutogenTarget.FilesGenerated) { - this->AutogenTarget.DependFiles.insert(muf->RealPath); + this->AutogenTarget.DependFiles.insert(muf->FullPath); } } else if (this->CMP0071Warn) { cm::string_view property; @@ -856,7 +851,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() } std::string files; for (MUFile* muf : this->AutogenTarget.FilesGenerated) { - files += cmStrCat(" ", Quoted(muf->RealPath), '\n'); + files += cmStrCat(" ", Quoted(muf->FullPath), '\n'); } this->Makefile->IssueMessage( MessageType::AUTHOR_WARNING, @@ -1280,7 +1275,7 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() } std::sort(sortedHeaders.begin(), sortedHeaders.end(), [](MUFile const* a, MUFile const* b) { - return (a->RealPath < b->RealPath); + return (a->FullPath < b->FullPath); }); } @@ -1289,13 +1284,13 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() continue; } if (muf->SkipMoc) { - moc_skip.insert(muf->RealPath); + moc_skip.insert(muf->FullPath); } if (muf->SkipUic) { - uic_skip.insert(muf->RealPath); + uic_skip.insert(muf->FullPath); } if (muf->MocIt || muf->UicIt) { - headers.emplace_back(muf->RealPath); + headers.emplace_back(muf->FullPath); headersFlags.emplace_back( cmStrCat(muf->MocIt ? 'M' : 'm', muf->UicIt ? 'U' : 'u')); } @@ -1334,7 +1329,7 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() } std::sort(sorted.begin(), sorted.end(), [](MUFile const* a, MUFile const* b) { - return (a->RealPath < b->RealPath); + return (a->FullPath < b->FullPath); }); for (MUFile const* const muf : sorted) { @@ -1342,13 +1337,13 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() continue; } if (muf->SkipMoc) { - moc_skip.insert(muf->RealPath); + moc_skip.insert(muf->FullPath); } if (muf->SkipUic) { - uic_skip.insert(muf->RealPath); + uic_skip.insert(muf->FullPath); } if (muf->MocIt || muf->UicIt) { - sources.emplace_back(muf->RealPath); + sources.emplace_back(muf->FullPath); sourcesFlags.emplace_back( cmStrCat(muf->MocIt ? 'M' : 'm', muf->UicIt ? 'U' : 'u')); } diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h index d8d4dff..bedda30 100644 --- a/Source/cmQtAutoGenInitializer.h +++ b/Source/cmQtAutoGenInitializer.h @@ -50,7 +50,7 @@ public: /// @brief Moc/Uic file struct MUFile { - std::string RealPath; + std::string FullPath; cmSourceFile* SF = nullptr; bool Generated = false; bool SkipMoc = false; diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 40ebdde..3e30a2f 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -838,7 +838,8 @@ cmQtAutoMocUic::SourceFileHandleT cmQtAutoMocUic::JobEvaluateT::MocFindHeader( cmFileTime fileTime; if (fileTime.Load(testPath)) { // Compute real path of the file - testPath = cmSystemTools::GetRealPath(testPath); + testPath = cmSystemTools::CollapseFullPath(testPath, + BaseConst().CurrentSourceDir); // Return a known file if it exists already { auto it = BaseEval().Headers.find(testPath); @@ -1057,12 +1058,13 @@ cmQtAutoMocUic::JobEvaluateT::UicFindIncludedUi( cmFileTime fileTime; if (fileTime.Load(testFile)) { // .ui file found in files system! - std::string realPath = cmSystemTools::GetRealPath(testFile); + std::string fullPath = cmSystemTools::CollapseFullPath( + testFile, BaseConst().CurrentSourceDir); // Get or create .ui file handle - SourceFileHandleT& handle = Gen()->UicEval().UiFiles[realPath]; + SourceFileHandleT& handle = Gen()->UicEval().UiFiles[fullPath]; if (!handle) { // The file wasn't registered, yet - handle = std::make_shared(realPath); + handle = std::make_shared(fullPath); handle->FileTime = fileTime; } return handle; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=65c49e0e26488931e6ec27a1d352c07d43171f22 commit 65c49e0e26488931e6ec27a1d352c07d43171f22 Author: Sebastian Holtermann AuthorDate: Thu Sep 12 10:28:14 2019 +0200 Commit: Sebastian Holtermann CommitDate: Mon Sep 16 18:18:48 2019 +0200 Autogen: Sanitize include and search directories diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index a5fc5e3..7bf56df 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -122,6 +122,41 @@ bool StaticLibraryCycle(cmGeneratorTarget const* targetOrigin, } return cycle; } + +/** Sanitizes file search paths */ +class SearchPathSanitizer +{ +public: + SearchPathSanitizer(cmMakefile* makefile) + : SourcePath_(makefile->GetCurrentSourceDirectory()) + { + } + std::vector operator()( + std::vector const& paths) const; + +private: + std::string SourcePath_; +}; + +std::vector SearchPathSanitizer::operator()( + std::vector const& paths) const +{ + std::vector res; + res.reserve(paths.size()); + for (std::string const& srcPath : paths) { + // Collapse relative paths + std::string path = cmSystemTools::CollapseFullPath(srcPath, SourcePath_); + // Remove suffix slashes + while (cmHasSuffix(path, '/')) { + path.pop_back(); + } + // Accept only non empty paths + if (!path.empty()) { + res.emplace_back(std::move(path)); + } + } + return res; +} } // End of unnamed namespace cmQtAutoGenInitializer::InfoWriter::InfoWriter(std::string const& filename) @@ -456,16 +491,16 @@ bool cmQtAutoGenInitializer::InitMoc() // Moc includes { + SearchPathSanitizer sanitizer(this->Makefile); auto GetIncludeDirs = - [this](std::string const& cfg) -> std::vector { + [this, &sanitizer](std::string const& cfg) -> std::vector { // Get the include dirs for this target, without stripping the implicit - // include dirs off, see - // https://gitlab.kitware.com/cmake/cmake/issues/13667 + // include dirs off, see issue #13667. std::vector dirs; bool const appendImplicit = (this->QtVersion.Major >= 5); this->LocalGen->GetIncludeDirectoriesImplicit( dirs, this->GenTarget, "CXX", cfg, false, appendImplicit); - return dirs; + return sanitizer(dirs); }; // Default configuration include directories @@ -531,11 +566,8 @@ bool cmQtAutoGenInitializer::InitUic() std::string const usp = this->GenTarget->GetSafeProperty("AUTOUIC_SEARCH_PATHS"); if (!usp.empty()) { - cmExpandList(usp, this->Uic.SearchPaths); - std::string const& srcDir = this->Makefile->GetCurrentSourceDirectory(); - for (std::string& path : this->Uic.SearchPaths) { - path = cmSystemTools::CollapseFullPath(path, srcDir); - } + this->Uic.SearchPaths = + SearchPathSanitizer(this->Makefile)(cmExpandedList(usp)); } } // Uic target options https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dad1a6b3fbf1c9d34a6d2e5722e426234bbb5df0 commit dad1a6b3fbf1c9d34a6d2e5722e426234bbb5df0 Author: Sebastian Holtermann AuthorDate: Thu Sep 12 09:56:41 2019 +0200 Commit: Sebastian Holtermann CommitDate: Mon Sep 16 18:18:48 2019 +0200 Autogen: Modernize by using an unnamed namespace instead of static functions diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index bf20638..a5fc5e3 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -42,7 +42,9 @@ #include "cm_memory.hxx" -static std::size_t GetParallelCPUCount() +namespace { + +std::size_t GetParallelCPUCount() { static std::size_t count = 0; // Detect only on the first call @@ -56,8 +58,8 @@ static std::size_t GetParallelCPUCount() return count; } -static std::string FileProjectRelativePath(cmMakefile* makefile, - std::string const& fileName) +std::string FileProjectRelativePath(cmMakefile* makefile, + std::string const& fileName) { std::string res; { @@ -81,9 +83,9 @@ static std::string FileProjectRelativePath(cmMakefile* makefile, * recursive STATIC_LIBRARY dependencies depends on targetOrigin * (STATIC_LIBRARY cycle). */ -static bool StaticLibraryCycle(cmGeneratorTarget const* targetOrigin, - cmGeneratorTarget const* targetDepend, - std::string const& config) +bool StaticLibraryCycle(cmGeneratorTarget const* targetOrigin, + cmGeneratorTarget const* targetDepend, + std::string const& config) { bool cycle = false; if ((targetOrigin->GetType() == cmStateEnums::STATIC_LIBRARY) && @@ -120,6 +122,7 @@ static bool StaticLibraryCycle(cmGeneratorTarget const* targetOrigin, } return cycle; } +} // End of unnamed namespace cmQtAutoGenInitializer::InfoWriter::InfoWriter(std::string const& filename) { https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=82096911461f37f0421a7a79faa179aa9e0cb25c commit 82096911461f37f0421a7a79faa179aa9e0cb25c Author: Sebastian Holtermann AuthorDate: Thu Sep 12 10:19:37 2019 +0200 Commit: Sebastian Holtermann CommitDate: Mon Sep 16 18:18:44 2019 +0200 Autogen: Compute and store generator pointers once in initializer constructor diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 54304c3..bf20638 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1,6 +1,7 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmQtAutoGenInitializer.h" + #include "cmQtAutoGen.h" #include "cmQtAutoGenGlobalInitializer.h" @@ -213,11 +214,15 @@ void cmQtAutoGenInitializer::InfoWriter::WriteNestedLists( }; cmQtAutoGenInitializer::cmQtAutoGenInitializer( - cmQtAutoGenGlobalInitializer* globalInitializer, cmGeneratorTarget* target, - IntegerVersion const& qtVersion, bool mocEnabled, bool uicEnabled, - bool rccEnabled, bool globalAutogenTarget, bool globalAutoRccTarget) + cmQtAutoGenGlobalInitializer* globalInitializer, + cmGeneratorTarget* genTarget, IntegerVersion const& qtVersion, + bool mocEnabled, bool uicEnabled, bool rccEnabled, bool globalAutogenTarget, + bool globalAutoRccTarget) : GlobalInitializer(globalInitializer) - , Target(target) + , GenTarget(genTarget) + , GlobalGen(genTarget->GetGlobalGenerator()) + , LocalGen(genTarget->GetLocalGenerator()) + , Makefile(genTarget->Makefile) , QtVersion(qtVersion) { AutogenTarget.GlobalTarget = globalAutogenTarget; @@ -229,19 +234,15 @@ cmQtAutoGenInitializer::cmQtAutoGenInitializer( bool cmQtAutoGenInitializer::InitCustomTargets() { - cmMakefile* makefile = this->Target->Target->GetMakefile(); - cmLocalGenerator* localGen = this->Target->GetLocalGenerator(); - cmGlobalGenerator* globalGen = localGen->GetGlobalGenerator(); - // Configurations - this->MultiConfig = globalGen->IsMultiConfig(); - this->ConfigDefault = makefile->GetConfigurations(this->ConfigsList); + this->MultiConfig = this->GlobalGen->IsMultiConfig(); + this->ConfigDefault = this->Makefile->GetConfigurations(this->ConfigsList); if (this->ConfigsList.empty()) { this->ConfigsList.push_back(this->ConfigDefault); } // Verbosity - this->Verbosity = makefile->GetSafeDefinition("CMAKE_AUTOGEN_VERBOSE"); + this->Verbosity = this->Makefile->GetSafeDefinition("CMAKE_AUTOGEN_VERBOSE"); if (!this->Verbosity.empty()) { unsigned long iVerb = 0; if (!cmStrToULong(this->Verbosity, &iVerb)) { @@ -253,14 +254,14 @@ bool cmQtAutoGenInitializer::InitCustomTargets() // Targets FOLDER { const char* folder = - makefile->GetState()->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER"); + this->Makefile->GetState()->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER"); if (folder == nullptr) { - folder = - makefile->GetState()->GetGlobalProperty("AUTOGEN_TARGETS_FOLDER"); + folder = this->Makefile->GetState()->GetGlobalProperty( + "AUTOGEN_TARGETS_FOLDER"); } // Inherit FOLDER property from target (#13688) if (folder == nullptr) { - folder = this->Target->GetProperty("FOLDER"); + folder = this->GenTarget->GetProperty("FOLDER"); } if (folder != nullptr) { this->TargetsFolder = folder; @@ -270,7 +271,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets() // Check status of policy CMP0071 { cmPolicies::PolicyStatus const CMP0071_status = - makefile->GetPolicyStatus(cmPolicies::CMP0071); + this->Makefile->GetPolicyStatus(cmPolicies::CMP0071); switch (CMP0071_status) { case cmPolicies::WARN: this->CMP0071Warn = true; @@ -291,18 +292,18 @@ bool cmQtAutoGenInitializer::InitCustomTargets() { // Collapsed current binary directory std::string const cbd = cmSystemTools::CollapseFullPath( - std::string(), makefile->GetCurrentBinaryDirectory()); + std::string(), this->Makefile->GetCurrentBinaryDirectory()); // Info directory - this->Dir.Info = - cmStrCat(cbd, "/CMakeFiles/", this->Target->GetName(), "_autogen.dir"); + this->Dir.Info = cmStrCat(cbd, "/CMakeFiles/", this->GenTarget->GetName(), + "_autogen.dir"); cmSystemTools::ConvertToUnixSlashes(this->Dir.Info); // Build directory - this->Dir.Build = this->Target->GetSafeProperty("AUTOGEN_BUILD_DIR"); + this->Dir.Build = this->GenTarget->GetSafeProperty("AUTOGEN_BUILD_DIR"); if (this->Dir.Build.empty()) { this->Dir.Build = - cmStrCat(cbd, '/', this->Target->GetName(), "_autogen"); + cmStrCat(cbd, '/', this->GenTarget->GetName(), "_autogen"); } cmSystemTools::ConvertToUnixSlashes(this->Dir.Build); // Cleanup build directory @@ -339,11 +340,12 @@ bool cmQtAutoGenInitializer::InitCustomTargets() } // Autogen target name - this->AutogenTarget.Name = cmStrCat(this->Target->GetName(), "_autogen"); + this->AutogenTarget.Name = + cmStrCat(this->GenTarget->GetName(), "_autogen"); // Autogen target parallel processing this->AutogenTarget.Parallel = - this->Target->GetSafeProperty("AUTOGEN_PARALLEL"); + this->GenTarget->GetSafeProperty("AUTOGEN_PARALLEL"); if (this->AutogenTarget.Parallel.empty() || (this->AutogenTarget.Parallel == "AUTO")) { // Autodetect number of CPUs @@ -377,15 +379,15 @@ bool cmQtAutoGenInitializer::InitCustomTargets() // Autogen target: Compute user defined dependencies { this->AutogenTarget.DependOrigin = - this->Target->GetPropertyAsBool("AUTOGEN_ORIGIN_DEPENDS"); + this->GenTarget->GetPropertyAsBool("AUTOGEN_ORIGIN_DEPENDS"); std::string const deps = - this->Target->GetSafeProperty("AUTOGEN_TARGET_DEPENDS"); + this->GenTarget->GetSafeProperty("AUTOGEN_TARGET_DEPENDS"); if (!deps.empty()) { std::vector extraDeps = cmExpandedList(deps); for (std::string const& depName : extraDeps) { // Allow target and file dependencies - auto* depTarget = makefile->FindTargetToUse(depName); + auto* depTarget = this->Makefile->FindTargetToUse(depName); if (depTarget != nullptr) { this->AutogenTarget.DependTargets.insert(depTarget); } else { @@ -397,13 +399,13 @@ bool cmQtAutoGenInitializer::InitCustomTargets() // CMAKE_AUTOMOC_RELAXED_MODE deprecation warning if (this->Moc.Enabled) { - if (makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE")) { - makefile->IssueMessage( + if (this->Makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE")) { + this->Makefile->IssueMessage( MessageType::AUTHOR_WARNING, cmStrCat("AUTOMOC: CMAKE_AUTOMOC_RELAXED_MODE is " "deprecated an will be removed in the future. Consider " "disabling it and converting the target ", - this->Target->GetName(), " to regular mode.")); + this->GenTarget->GetName(), " to regular mode.")); } } } @@ -415,7 +417,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets() // Add autogen include directory to the origin target INCLUDE_DIRECTORIES if (this->MocOrUicEnabled() || (this->Rcc.Enabled && this->MultiConfig)) { - this->Target->AddIncludeDirectory(this->Dir.Include, true); + this->GenTarget->AddIncludeDirectory(this->Dir.Include, true); } // Scan files @@ -438,32 +440,28 @@ bool cmQtAutoGenInitializer::InitCustomTargets() bool cmQtAutoGenInitializer::InitMoc() { - cmMakefile* makefile = this->Target->Target->GetMakefile(); - cmLocalGenerator* localGen = this->Target->GetLocalGenerator(); - // Mocs compilation file this->Moc.MocsCompilation = cmStrCat(this->Dir.Build, "/mocs_compilation.cpp"); // Moc predefs command - if (this->Target->GetPropertyAsBool("AUTOMOC_COMPILER_PREDEFINES") && + if (this->GenTarget->GetPropertyAsBool("AUTOMOC_COMPILER_PREDEFINES") && (this->QtVersion >= IntegerVersion(5, 8))) { - this->Moc.PredefsCmd = - makefile->GetSafeDefinition("CMAKE_CXX_COMPILER_PREDEFINES_COMMAND"); + this->Moc.PredefsCmd = this->Makefile->GetSafeDefinition( + "CMAKE_CXX_COMPILER_PREDEFINES_COMMAND"); } // Moc includes { - bool const appendImplicit = (this->QtVersion.Major >= 5); auto GetIncludeDirs = - [this, localGen, - appendImplicit](std::string const& cfg) -> std::vector { + [this](std::string const& cfg) -> std::vector { // Get the include dirs for this target, without stripping the implicit // include dirs off, see // https://gitlab.kitware.com/cmake/cmake/issues/13667 std::vector dirs; - localGen->GetIncludeDirectoriesImplicit(dirs, this->Target, "CXX", cfg, - false, appendImplicit); + bool const appendImplicit = (this->QtVersion.Major >= 5); + this->LocalGen->GetIncludeDirectoriesImplicit( + dirs, this->GenTarget, "CXX", cfg, false, appendImplicit); return dirs; }; @@ -483,9 +481,9 @@ bool cmQtAutoGenInitializer::InitMoc() // Moc compile definitions { auto GetCompileDefinitions = - [this, localGen](std::string const& cfg) -> std::set { + [this](std::string const& cfg) -> std::set { std::set defines; - localGen->GetTargetDefines(this->Target, cfg, "CXX", defines); + this->LocalGen->GetTargetDefines(this->GenTarget, cfg, "CXX", defines); #ifdef _WIN32 if (this->Moc.PredefsCmd.empty()) { // Add WIN32 definition if we don't have a moc_predefs.h @@ -525,15 +523,13 @@ bool cmQtAutoGenInitializer::InitMoc() bool cmQtAutoGenInitializer::InitUic() { - cmMakefile* makefile = this->Target->Target->GetMakefile(); - // Uic search paths { std::string const usp = - this->Target->GetSafeProperty("AUTOUIC_SEARCH_PATHS"); + this->GenTarget->GetSafeProperty("AUTOUIC_SEARCH_PATHS"); if (!usp.empty()) { cmExpandList(usp, this->Uic.SearchPaths); - std::string const& srcDir = makefile->GetCurrentSourceDirectory(); + std::string const& srcDir = this->Makefile->GetCurrentSourceDirectory(); for (std::string& path : this->Uic.SearchPaths) { path = cmSystemTools::CollapseFullPath(path, srcDir); } @@ -544,7 +540,7 @@ bool cmQtAutoGenInitializer::InitUic() auto UicGetOpts = [this](std::string const& cfg) -> std::vector { std::vector opts; - this->Target->GetAutoUicOptions(opts, cfg); + this->GenTarget->GetAutoUicOptions(opts, cfg); return opts; }; @@ -605,8 +601,7 @@ bool cmQtAutoGenInitializer::InitRcc() bool cmQtAutoGenInitializer::InitScanFiles() { - cmMakefile* makefile = this->Target->Target->GetMakefile(); - cmake const* cm = makefile->GetCMakeInstance(); + cmake const* cm = this->Makefile->GetCMakeInstance(); auto const& kw = this->GlobalInitializer->kw(); auto makeMUFile = [this, &kw](cmSourceFile* sf, std::string const& fullPath, @@ -642,7 +637,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() { // Scan through target files std::vector srcFiles; - this->Target->GetConfigCommonSourceFiles(srcFiles); + this->GenTarget->GetConfigCommonSourceFiles(srcFiles); for (cmSourceFile* sf : srcFiles) { // sf->GetExtension() is only valid after sf->GetFullPath() ... // Since we're iterating over source files that might be not in the @@ -690,7 +685,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() // sources meta data cache. Clear it so that OBJECT library targets that // are AUTOGEN initialized after this target get their added // mocs_compilation.cpp source acknowledged by this target. - this->Target->ClearSourcesCache(); + this->GenTarget->ClearSourcesCache(); // For source files find additional headers and private headers if (this->MocOrUicEnabled()) { @@ -714,7 +709,8 @@ bool cmQtAutoGenInitializer::InitScanFiles() std::string fullPath = cmStrCat(suffixedPath, '.', ext); auto constexpr locationKind = cmSourceFileLocationKind::Known; - cmSourceFile* sf = makefile->GetSource(fullPath, locationKind); + cmSourceFile* sf = + this->Makefile->GetSource(fullPath, locationKind); if (sf != nullptr) { // Check if we know about this header already if (this->AutogenTarget.Headers.find(sf) != @@ -728,7 +724,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() } } else if (cmSystemTools::FileExists(fullPath)) { // Create a new source file for the existing file - sf = makefile->CreateSource(fullPath, false, locationKind); + sf = this->Makefile->CreateSource(fullPath, false, locationKind); } if (sf != nullptr) { @@ -757,7 +753,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() // The reason is that their file names might be discovered from source files // at generation time. if (this->MocOrUicEnabled()) { - for (cmSourceFile* sf : makefile->GetSourceFiles()) { + for (cmSourceFile* sf : this->Makefile->GetSourceFiles()) { // sf->GetExtension() is only valid after sf->GetFullPath() ... // Since we're iterating over source files that might be not in the // target we need to check for path errors (not existing files). @@ -827,7 +823,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() for (MUFile* muf : this->AutogenTarget.FilesGenerated) { files += cmStrCat(" ", Quoted(muf->RealPath), '\n'); } - makefile->IssueMessage( + this->Makefile->IssueMessage( MessageType::AUTHOR_WARNING, cmStrCat( cmPolicies::GetPolicyWarning(cmPolicies::CMP0071), '\n', @@ -848,7 +844,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() const bool modernQt = (this->QtVersion.Major >= 5); // Target rcc options std::vector optionsTarget = - cmExpandedList(this->Target->GetSafeProperty(kw.AUTORCC_OPTIONS)); + cmExpandedList(this->GenTarget->GetSafeProperty(kw.AUTORCC_OPTIONS)); // Check if file name is unique for (Qrc& qrc : this->Rcc.Qrcs) { @@ -862,7 +858,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() } // Path checksum and file names { - cmFilePathChecksum const fpathCheckSum(makefile); + cmFilePathChecksum const fpathCheckSum(this->Makefile); for (Qrc& qrc : this->Rcc.Qrcs) { qrc.PathChecksum = fpathCheckSum.getPart(qrc.QrcFile); // RCC output file name @@ -925,12 +921,8 @@ bool cmQtAutoGenInitializer::InitScanFiles() bool cmQtAutoGenInitializer::InitAutogenTarget() { - cmMakefile* makefile = this->Target->Target->GetMakefile(); - cmLocalGenerator* localGen = this->Target->GetLocalGenerator(); - cmGlobalGenerator* globalGen = localGen->GetGlobalGenerator(); - // Register info file as generated by CMake - makefile->AddCMakeOutputFile(this->AutogenTarget.InfoFile); + this->Makefile->AddCMakeOutputFile(this->AutogenTarget.InfoFile); // Files provided by the autogen target std::vector autogenProvides; @@ -952,8 +944,8 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() } tools += "UIC"; } - autogenComment = - cmStrCat("Automatic ", tools, " for target ", this->Target->GetName()); + autogenComment = cmStrCat("Automatic ", tools, " for target ", + this->GenTarget->GetName()); } // Compose command lines @@ -970,7 +962,7 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() // Use PRE_BUILD on demand bool usePRE_BUILD = false; - if (globalGen->GetName().find("Visual Studio") != std::string::npos) { + if (this->GlobalGen->GetName().find("Visual Studio") != std::string::npos) { // Under VS use a PRE_BUILD event instead of a separate target to // reduce the number of targets loaded into the IDE. // This also works around a VS 11 bug that may skip updating the target: @@ -992,7 +984,8 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() if (usePRE_BUILD) { // Add additional autogen target dependencies to origin target for (cmTarget* depTarget : this->AutogenTarget.DependTargets) { - this->Target->Target->AddUtility(depTarget->GetName(), makefile); + this->GenTarget->Target->AddUtility(depTarget->GetName(), + this->Makefile); } // Add the pre-build command directly to bypass the OBJECT_LIBRARY @@ -1002,12 +995,12 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() // PRE_BUILD does not support file dependencies! const std::vector no_output; const std::vector no_deps; - cmCustomCommand cc(makefile, no_output, autogenProvides, no_deps, + cmCustomCommand cc(this->Makefile, no_output, autogenProvides, no_deps, commandLines, autogenComment.c_str(), this->Dir.Work.c_str()); cc.SetEscapeOldStyle(false); cc.SetEscapeAllowMakeVars(true); - this->Target->Target->AddPreBuildCommand(cc); + this->GenTarget->Target->AddPreBuildCommand(cc); } else { // Add link library target dependencies to the autogen target @@ -1018,12 +1011,12 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() std::map commonTargets; for (std::string const& config : this->ConfigsList) { cmLinkImplementationLibraries const* libs = - this->Target->GetLinkImplementationLibraries(config); + this->GenTarget->GetLinkImplementationLibraries(config); if (libs != nullptr) { for (cmLinkItem const& item : libs->Libraries) { cmGeneratorTarget const* libTarget = item.Target; if ((libTarget != nullptr) && - !StaticLibraryCycle(this->Target, libTarget, config)) { + !StaticLibraryCycle(this->GenTarget, libTarget, config)) { // Increment target config count commonTargets[libTarget]++; } @@ -1038,25 +1031,25 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() } // Create autogen target - cmTarget* autogenTarget = makefile->AddUtilityCommand( + cmTarget* autogenTarget = this->Makefile->AddUtilityCommand( this->AutogenTarget.Name, cmMakefile::TargetOrigin::Generator, true, this->Dir.Work.c_str(), /*byproducts=*/autogenProvides, std::vector(this->AutogenTarget.DependFiles.begin(), this->AutogenTarget.DependFiles.end()), commandLines, false, autogenComment.c_str()); // Create autogen generator target - localGen->AddGeneratorTarget( - new cmGeneratorTarget(autogenTarget, localGen)); + this->LocalGen->AddGeneratorTarget( + new cmGeneratorTarget(autogenTarget, this->LocalGen)); // Forward origin utilities to autogen target if (this->AutogenTarget.DependOrigin) { - for (BT const& depName : this->Target->GetUtilities()) { - autogenTarget->AddUtility(depName.Value, makefile); + for (BT const& depName : this->GenTarget->GetUtilities()) { + autogenTarget->AddUtility(depName.Value, this->Makefile); } } // Add additional autogen target dependencies to autogen target for (cmTarget* depTarget : this->AutogenTarget.DependTargets) { - autogenTarget->AddUtility(depTarget->GetName(), makefile); + autogenTarget->AddUtility(depTarget->GetName(), this->Makefile); } // Set FOLDER property in autogen target @@ -1065,11 +1058,12 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() } // Add autogen target to the origin target dependencies - this->Target->Target->AddUtility(this->AutogenTarget.Name, makefile); + this->GenTarget->Target->AddUtility(this->AutogenTarget.Name, + this->Makefile); // Add autogen target to the global autogen target dependencies if (this->AutogenTarget.GlobalTarget) { - this->GlobalInitializer->AddToGlobalAutoGen(localGen, + this->GlobalInitializer->AddToGlobalAutoGen(this->LocalGen, this->AutogenTarget.Name); } } @@ -1079,12 +1073,9 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() bool cmQtAutoGenInitializer::InitRccTargets() { - cmMakefile* makefile = this->Target->Target->GetMakefile(); - cmLocalGenerator* localGen = this->Target->GetLocalGenerator(); - for (Qrc const& qrc : this->Rcc.Qrcs) { // Register info file as generated by CMake - makefile->AddCMakeOutputFile(qrc.InfoFile); + this->Makefile->AddCMakeOutputFile(qrc.InfoFile); // Register file at target this->AddGeneratedSource(qrc.RccFile, this->Rcc); @@ -1117,41 +1108,43 @@ bool cmQtAutoGenInitializer::InitRccTargets() currentLine.push_back("$"); commandLines.push_back(std::move(currentLine)); } - std::string ccComment = cmStrCat( - "Automatic RCC for ", FileProjectRelativePath(makefile, qrc.QrcFile)); + std::string ccComment = + cmStrCat("Automatic RCC for ", + FileProjectRelativePath(this->Makefile, qrc.QrcFile)); if (qrc.Generated || this->Rcc.GlobalTarget) { // Create custom rcc target std::string ccName; { - ccName = cmStrCat(this->Target->GetName(), "_arcc_", qrc.QrcName); + ccName = cmStrCat(this->GenTarget->GetName(), "_arcc_", qrc.QrcName); if (!qrc.Unique) { ccName += cmStrCat('_', qrc.PathChecksum); } - cmTarget* autoRccTarget = makefile->AddUtilityCommand( + cmTarget* autoRccTarget = this->Makefile->AddUtilityCommand( ccName, cmMakefile::TargetOrigin::Generator, true, this->Dir.Work.c_str(), ccOutput, ccDepends, commandLines, false, ccComment.c_str()); // Create autogen generator target - localGen->AddGeneratorTarget( - new cmGeneratorTarget(autoRccTarget, localGen)); + this->LocalGen->AddGeneratorTarget( + new cmGeneratorTarget(autoRccTarget, this->LocalGen)); // Set FOLDER property in autogen target if (!this->TargetsFolder.empty()) { autoRccTarget->SetProperty("FOLDER", this->TargetsFolder.c_str()); } if (!this->Rcc.ExecutableTargetName.empty()) { - autoRccTarget->AddUtility(this->Rcc.ExecutableTargetName, makefile); + autoRccTarget->AddUtility(this->Rcc.ExecutableTargetName, + this->Makefile); } } // Add autogen target to the origin target dependencies - this->Target->Target->AddUtility(ccName, makefile); + this->GenTarget->Target->AddUtility(ccName, this->Makefile); // Add autogen target to the global autogen target dependencies if (this->Rcc.GlobalTarget) { - this->GlobalInitializer->AddToGlobalAutoRcc(localGen, ccName); + this->GlobalInitializer->AddToGlobalAutoRcc(this->LocalGen, ccName); } } else { // Create custom rcc command @@ -1168,13 +1161,13 @@ bool cmQtAutoGenInitializer::InitRccTargets() } std::string no_main_dependency; cmImplicitDependsList no_implicit_depends; - makefile->AddCustomCommandToOutput( + this->Makefile->AddCustomCommandToOutput( ccOutput, ccByproducts, ccDepends, no_main_dependency, no_implicit_depends, commandLines, ccComment.c_str(), this->Dir.Work.c_str()); } // Reconfigure when .qrc file changes - makefile->AddCMakeDependFile(qrc.QrcFile); + this->Makefile->AddCMakeDependFile(qrc.QrcFile); } } @@ -1207,9 +1200,8 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() InfoWriter ofs(this->AutogenTarget.InfoFile); if (ofs) { // Utility lambdas - cmMakefile* makefile = this->Target->Target->GetMakefile(); - auto MfDef = [makefile](const char* key) { - return makefile->GetSafeDefinition(key); + auto MfDef = [this](const char* key) { + return this->Makefile->GetSafeDefinition(key); }; // Write common settings @@ -1276,7 +1268,7 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() } // Header build paths { - cmFilePathChecksum const fpathCheckSum(makefile); + cmFilePathChecksum const fpathCheckSum(this->Makefile); std::unordered_set emitted; for (std::string const& hdr : headers) { std::string const basePath = @@ -1354,12 +1346,12 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() ofs.WriteStrings("AM_MOC_INCLUDES", this->Moc.Includes); ofs.WriteConfigStrings("AM_MOC_INCLUDES", this->Moc.ConfigIncludes); ofs.Write("AM_MOC_OPTIONS", - this->Target->GetSafeProperty("AUTOMOC_MOC_OPTIONS")); + this->GenTarget->GetSafeProperty("AUTOMOC_MOC_OPTIONS")); ofs.Write("AM_MOC_RELAXED_MODE", MfDef("CMAKE_AUTOMOC_RELAXED_MODE")); ofs.Write("AM_MOC_MACRO_NAMES", - this->Target->GetSafeProperty("AUTOMOC_MACRO_NAMES")); + this->GenTarget->GetSafeProperty("AUTOMOC_MACRO_NAMES")); ofs.Write("AM_MOC_DEPEND_FILTERS", - this->Target->GetSafeProperty("AUTOMOC_DEPEND_FILTERS")); + this->GenTarget->GetSafeProperty("AUTOMOC_DEPEND_FILTERS")); ofs.Write("AM_MOC_PREDEFS_CMD", this->Moc.PredefsCmd); } @@ -1429,8 +1421,7 @@ bool cmQtAutoGenInitializer::SetupWriteRccInfo() void cmQtAutoGenInitializer::RegisterGeneratedSource( std::string const& filename) { - cmMakefile* makefile = this->Target->Target->GetMakefile(); - cmSourceFile* gFile = makefile->GetOrCreateSource(filename, true); + cmSourceFile* gFile = this->Makefile->GetOrCreateSource(filename, true); gFile->SetProperty("GENERATED", "1"); gFile->SetProperty("SKIP_AUTOGEN", "1"); } @@ -1442,7 +1433,7 @@ bool cmQtAutoGenInitializer::AddGeneratedSource(std::string const& filename, // Register source at makefile this->RegisterGeneratedSource(filename); // Add source file to target - this->Target->AddSource(filename, prepend); + this->GenTarget->AddSource(filename, prepend); // Add source file to source group return this->AddToSourceGroup(filename, genVars.GenNameUpper); } @@ -1450,7 +1441,6 @@ bool cmQtAutoGenInitializer::AddGeneratedSource(std::string const& filename, bool cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName, cm::string_view genNameUpper) { - cmMakefile* makefile = this->Target->Target->GetMakefile(); cmSourceGroup* sourceGroup = nullptr; // Acquire source group { @@ -1462,7 +1452,8 @@ bool cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName, cmStrCat(genNameUpper, "_SOURCE_GROUP"), "AUTOGEN_SOURCE_GROUP" }; for (std::string const& prop : props) { - const char* propName = makefile->GetState()->GetGlobalProperty(prop); + const char* propName = + this->Makefile->GetState()->GetGlobalProperty(prop); if ((propName != nullptr) && (*propName != '\0')) { groupName = propName; property = prop; @@ -1472,7 +1463,7 @@ bool cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName, } // Generate a source group on demand if (!groupName.empty()) { - sourceGroup = makefile->GetOrCreateSourceGroup(groupName); + sourceGroup = this->Makefile->GetOrCreateSourceGroup(groupName); if (sourceGroup == nullptr) { cmSystemTools::Error( cmStrCat(genNameUpper, " error in ", property, @@ -1490,8 +1481,8 @@ bool cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName, void cmQtAutoGenInitializer::AddCleanFile(std::string const& fileName) { - Target->Target->AppendProperty("ADDITIONAL_CLEAN_FILES", fileName.c_str(), - false); + this->GenTarget->Target->AppendProperty("ADDITIONAL_CLEAN_FILES", + fileName.c_str(), false); } static unsigned int CharPtrToUInt(const char* const input) @@ -1504,7 +1495,7 @@ static unsigned int CharPtrToUInt(const char* const input) } static std::vector GetKnownQtVersions( - cmGeneratorTarget const* target) + cmGeneratorTarget const* genTarget) { // Qt version variable prefixes static std::initializer_list< @@ -1526,7 +1517,7 @@ static std::vector GetKnownQtVersions( } }; - cmMakefile* makefile = target->Target->GetMakefile(); + cmMakefile* makefile = genTarget->Makefile; // Read versions from variables for (auto const& keyPair : keys) { @@ -1576,22 +1567,20 @@ bool cmQtAutoGenInitializer::GetQtExecutable(GenVarsT& genVars, { auto print_err = [this, &genVars](std::string const& err) { cmSystemTools::Error(cmStrCat(genVars.GenNameUpper, " for target ", - this->Target->GetName(), ": ", err)); + this->GenTarget->GetName(), ": ", err)); }; // Custom executable { std::string const prop = cmStrCat(genVars.GenNameUpper, "_EXECUTABLE"); - std::string const val = this->Target->Target->GetSafeProperty(prop); + std::string const val = this->GenTarget->Target->GetSafeProperty(prop); if (!val.empty()) { // Evaluate generator expression { - cmListFileBacktrace lfbt = - this->Target->Target->GetMakefile()->GetBacktrace(); + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmGeneratorExpression ge(lfbt); std::unique_ptr cge = ge.Parse(val); - genVars.Executable = - cge->Evaluate(this->Target->GetLocalGenerator(), ""); + genVars.Executable = cge->Evaluate(this->LocalGen, ""); } if (genVars.Executable.empty() && !ignoreMissingTarget) { print_err(prop + " evaluates to an empty value"); @@ -1619,15 +1608,15 @@ bool cmQtAutoGenInitializer::GetQtExecutable(GenVarsT& genVars, std::string const targetName = cmStrCat(prefix, executable); // Find target - cmLocalGenerator* localGen = this->Target->GetLocalGenerator(); - cmGeneratorTarget* target = localGen->FindGeneratorTargetToUse(targetName); - if (target != nullptr) { + cmGeneratorTarget* genTarget = + this->LocalGen->FindGeneratorTargetToUse(targetName); + if (genTarget != nullptr) { genVars.ExecutableTargetName = targetName; - genVars.ExecutableTarget = target; - if (target->IsImported()) { - genVars.Executable = target->ImportedGetLocation(""); + genVars.ExecutableTarget = genTarget; + if (genTarget->IsImported()) { + genVars.Executable = genTarget->ImportedGetLocation(""); } else { - genVars.Executable = target->GetLocation(""); + genVars.Executable = genTarget->GetLocation(""); } } else { if (ignoreMissingTarget) { diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h index 84a27e4..d8d4dff 100644 --- a/Source/cmQtAutoGenInitializer.h +++ b/Source/cmQtAutoGenInitializer.h @@ -18,9 +18,12 @@ #include class cmGeneratorTarget; -class cmTarget; +class cmGlobalGenerator; +class cmLocalGenerator; +class cmMakefile; class cmQtAutoGenGlobalInitializer; class cmSourceFile; +class cmTarget; /// @brief Initializes the QtAutoGen generators class cmQtAutoGenInitializer : public cmQtAutoGen @@ -112,10 +115,10 @@ public: public: /// @return The detected Qt version and the required Qt major version static std::pair GetQtVersion( - cmGeneratorTarget const* target); + cmGeneratorTarget const* genTarget); cmQtAutoGenInitializer(cmQtAutoGenGlobalInitializer* globalInitializer, - cmGeneratorTarget* target, + cmGeneratorTarget* genTarget, IntegerVersion const& qtVersion, bool mocEnabled, bool uicEnabled, bool rccEnabled, bool globalAutogenTarget, bool globalAutoRccTarget); @@ -152,8 +155,11 @@ private: bool ignoreMissingTarget) const; private: - cmQtAutoGenGlobalInitializer* GlobalInitializer; - cmGeneratorTarget* Target; + cmQtAutoGenGlobalInitializer* GlobalInitializer = nullptr; + cmGeneratorTarget* GenTarget = nullptr; + cmGlobalGenerator* GlobalGen = nullptr; + cmLocalGenerator* LocalGen = nullptr; + cmMakefile* Makefile = nullptr; // Configuration IntegerVersion QtVersion; ----------------------------------------------------------------------- Summary of changes: Help/manual/cmake-properties.7.rst | 1 + Help/manual/cmake-variables.7.rst | 1 + Help/prop_tgt/AUTOMOC_PATH_PREFIX.rst | 32 + Help/release/dev/automoc_path_prefix.rst | 13 + Help/variable/CMAKE_AUTOMOC_PATH_PREFIX.rst | 11 + Modules/CMakeGenericSystem.cmake | 1 + Source/cmQtAutoGen.cxx | 9 + Source/cmQtAutoGen.h | 3 + Source/cmQtAutoGenInitializer.cxx | 366 ++++--- Source/cmQtAutoGenInitializer.h | 18 +- Source/cmQtAutoGenerator.cxx | 31 +- Source/cmQtAutoGenerator.h | 24 +- Source/cmQtAutoMocUic.cxx | 1129 +++++++++++--------- Source/cmQtAutoMocUic.h | 231 ++-- Source/cmQtAutoRcc.cxx | 118 +- Source/cmTarget.cxx | 1 + Tests/QtAutogen/MocInclude/CMakeLists.txt | 112 ++ .../MocInclude/Common/DualSub/Second/Second.cpp | 11 + .../MocInclude/Common/DualSub/Second/Second.hpp | 14 + .../QtAutogen/MocInclude/Common/DualSubMocked.cpp | 9 + .../QtAutogen/MocInclude/Common/DualSubMocked.hpp | 15 + Tests/QtAutogen/MocInclude/Common/ExternDot.cpp | 11 + .../MocInclude/{SObjA.hpp => Common/ExternDot.hpp} | 10 +- .../MocInclude/Common/ExternDotGenerated.cpp.in | 11 + .../MocInclude/Common/ExternDotGenerated.hpp.in | 15 + .../MocInclude/Common/InIncludes.in/SubOwnDot.cpp | 43 + .../MocInclude/Common/InIncludes.in/SubOwnDot.hpp | 17 + .../Common/InIncludes.in/SubOwnDot_p.hpp | 18 + .../QtAutogen/MocInclude/Common/InIncludesMoc.cpp | 4 + Tests/QtAutogen/MocInclude/Common/MixedCustom.cpp | 32 + Tests/QtAutogen/MocInclude/Common/MixedCustom.hpp | 20 + Tests/QtAutogen/MocInclude/Common/MixedSkipped.cpp | 39 + Tests/QtAutogen/MocInclude/Common/MixedSkipped.hpp | 17 + Tests/QtAutogen/MocInclude/Common/None.cpp | 20 + Tests/QtAutogen/MocInclude/Common/None.hpp | 19 + Tests/QtAutogen/MocInclude/Common/None_p.h | 14 + .../MocInclude/Common/OtherUnderscore.cpp | 44 + .../MocInclude/Common/OtherUnderscore.hpp | 19 + .../MocInclude/Common/OtherUnderscoreExtra.cpp | 20 + .../MocInclude/Common/OtherUnderscoreExtra.hpp | 18 + .../MocInclude/Common/OtherUnderscoreExtra_p.hpp | 14 + .../MocInclude/Common/OtherUnderscoreSub.cpp | 45 + .../MocInclude/Common/OtherUnderscoreSub.hpp | 19 + .../Common/OtherUnderscoreSubDir/SubExtra.cpp | 20 + .../Common/OtherUnderscoreSubDir/SubExtra.hpp | 18 + .../Common/OtherUnderscoreSubDir/SubExtra_p.hpp | 14 + .../MocInclude/Common/OtherUnderscoreSub_p.hpp | 14 + .../MocInclude/Common/OtherUnderscore_p.hpp | 14 + Tests/QtAutogen/MocInclude/Common/OwnDot.cpp | 39 + Tests/QtAutogen/MocInclude/Common/OwnDot.hpp | 19 + .../MocInclude/Common/OwnDotUnderscore.cpp | 40 + .../MocInclude/Common/OwnDotUnderscore.hpp | 19 + .../MocInclude/Common/OwnDotUnderscore_p.h | 14 + Tests/QtAutogen/MocInclude/Common/OwnDot_p.h | 14 + .../QtAutogen/MocInclude/Common/OwnUnderscore.cpp | 22 + .../QtAutogen/MocInclude/Common/OwnUnderscore.hpp | 19 + .../QtAutogen/MocInclude/Common/OwnUnderscore_p.h | 14 + Tests/QtAutogen/MocInclude/Common/common.cpp.in | 32 + .../MocInclude/Common/moc_MixedCustom.cpp.in | 5 + Tests/QtAutogen/MocInclude/EObjA.cpp | 44 - Tests/QtAutogen/MocInclude/EObjA.hpp | 19 - Tests/QtAutogen/MocInclude/EObjAExtra.cpp | 20 - Tests/QtAutogen/MocInclude/EObjAExtra.hpp | 18 - Tests/QtAutogen/MocInclude/EObjAExtra_p.hpp | 14 - Tests/QtAutogen/MocInclude/EObjA_p.hpp | 14 - Tests/QtAutogen/MocInclude/EObjB.cpp | 45 - Tests/QtAutogen/MocInclude/EObjB.hpp | 19 - Tests/QtAutogen/MocInclude/EObjB_p.hpp | 14 - Tests/QtAutogen/MocInclude/LObjA.cpp | 39 - Tests/QtAutogen/MocInclude/LObjA.hpp | 19 - Tests/QtAutogen/MocInclude/LObjA_p.h | 14 - Tests/QtAutogen/MocInclude/LObjB.cpp | 40 - Tests/QtAutogen/MocInclude/LObjB.hpp | 19 - Tests/QtAutogen/MocInclude/LObjB_p.h | 14 - Tests/QtAutogen/MocInclude/ObjA.cpp | 20 - Tests/QtAutogen/MocInclude/ObjA.hpp | 19 - Tests/QtAutogen/MocInclude/ObjA_p.h | 14 - Tests/QtAutogen/MocInclude/ObjB.cpp | 22 - Tests/QtAutogen/MocInclude/ObjB.hpp | 19 - Tests/QtAutogen/MocInclude/ObjB_p.h | 14 - Tests/QtAutogen/MocInclude/Relaxed/CMakeLists.txt | 17 + .../Relaxed}/RObjA.cpp | 0 .../Relaxed}/RObjA.hpp | 0 .../Relaxed}/RObjB.cpp | 0 .../Relaxed}/RObjB.hpp | 0 .../Relaxed}/RObjBExtra.hpp | 0 .../Relaxed}/RObjC.cpp | 0 .../Relaxed}/RObjC.hpp | 0 Tests/QtAutogen/MocInclude/Relaxed/relaxed.cpp | 21 + Tests/QtAutogen/MocInclude/SObjA.cpp | 11 - Tests/QtAutogen/MocInclude/SObjB.cpp.in | 11 - Tests/QtAutogen/MocInclude/SObjB.hpp.in | 15 - Tests/QtAutogen/MocInclude/SObjC.cpp | 35 - Tests/QtAutogen/MocInclude/SObjC.hpp | 15 - Tests/QtAutogen/MocInclude/SObjCExtra.cpp | 31 - Tests/QtAutogen/MocInclude/SObjCExtra.hpp | 15 - Tests/QtAutogen/MocInclude/SObjCExtra.moc.in | 4 - Tests/QtAutogen/MocInclude/Strict/CMakeLists.txt | 14 + Tests/QtAutogen/MocInclude/Strict/strict.cpp | 7 + Tests/QtAutogen/MocInclude/main.cpp | 9 + Tests/QtAutogen/MocInclude/shared.cmake | 71 -- Tests/QtAutogen/MocInclude/subExtra/EObjBExtra.cpp | 20 - Tests/QtAutogen/MocInclude/subExtra/EObjBExtra.hpp | 18 - .../QtAutogen/MocInclude/subExtra/EObjBExtra_p.hpp | 14 - Tests/QtAutogen/MocInclude/subGlobal/GObj.cpp | 41 - Tests/QtAutogen/MocInclude/subGlobal/GObj.hpp | 17 - Tests/QtAutogen/MocInclude/subGlobal/GObj_p.hpp | 17 - Tests/QtAutogen/MocIncludeRelaxed/CMakeLists.txt | 20 - Tests/QtAutogen/MocIncludeRelaxed/RMain.cpp | 12 - Tests/QtAutogen/MocIncludeRelaxed/main.cpp | 26 - Tests/QtAutogen/MocIncludeStrict/CMakeLists.txt | 10 - Tests/QtAutogen/MocIncludeStrict/main.cpp | 26 - Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt | 80 ++ Tests/QtAutogen/Tests.cmake | 4 +- 114 files changed, 2198 insertions(+), 1779 deletions(-) create mode 100644 Help/prop_tgt/AUTOMOC_PATH_PREFIX.rst create mode 100644 Help/release/dev/automoc_path_prefix.rst create mode 100644 Help/variable/CMAKE_AUTOMOC_PATH_PREFIX.rst create mode 100644 Tests/QtAutogen/MocInclude/CMakeLists.txt create mode 100644 Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.cpp create mode 100644 Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.hpp create mode 100644 Tests/QtAutogen/MocInclude/Common/DualSubMocked.cpp create mode 100644 Tests/QtAutogen/MocInclude/Common/DualSubMocked.hpp create mode 100644 Tests/QtAutogen/MocInclude/Common/ExternDot.cpp rename Tests/QtAutogen/MocInclude/{SObjA.hpp => Common/ExternDot.hpp} (50%) create mode 100644 Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.cpp.in create mode 100644 Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.hpp.in create mode 100644 Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.cpp create mode 100644 Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.hpp create mode 100644 Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot_p.hpp create mode 100644 Tests/QtAutogen/MocInclude/Common/InIncludesMoc.cpp create mode 100644 Tests/QtAutogen/MocInclude/Common/MixedCustom.cpp create mode 100644 Tests/QtAutogen/MocInclude/Common/MixedCustom.hpp create mode 100644 Tests/QtAutogen/MocInclude/Common/MixedSkipped.cpp create mode 100644 Tests/QtAutogen/MocInclude/Common/MixedSkipped.hpp create mode 100644 Tests/QtAutogen/MocInclude/Common/None.cpp create mode 100644 Tests/QtAutogen/MocInclude/Common/None.hpp create mode 100644 Tests/QtAutogen/MocInclude/Common/None_p.h create mode 100644 Tests/QtAutogen/MocInclude/Common/OtherUnderscore.cpp create mode 100644 Tests/QtAutogen/MocInclude/Common/OtherUnderscore.hpp create mode 100644 Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.cpp create mode 100644 Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.hpp create mode 100644 Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra_p.hpp create mode 100644 Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.cpp create mode 100644 Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.hpp create mode 100644 Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.cpp create mode 100644 Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.hpp create mode 100644 Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra_p.hpp create mode 100644 Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub_p.hpp create mode 100644 Tests/QtAutogen/MocInclude/Common/OtherUnderscore_p.hpp create mode 100644 Tests/QtAutogen/MocInclude/Common/OwnDot.cpp create mode 100644 Tests/QtAutogen/MocInclude/Common/OwnDot.hpp create mode 100644 Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.cpp create mode 100644 Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.hpp create mode 100644 Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore_p.h create mode 100644 Tests/QtAutogen/MocInclude/Common/OwnDot_p.h create mode 100644 Tests/QtAutogen/MocInclude/Common/OwnUnderscore.cpp create mode 100644 Tests/QtAutogen/MocInclude/Common/OwnUnderscore.hpp create mode 100644 Tests/QtAutogen/MocInclude/Common/OwnUnderscore_p.h create mode 100644 Tests/QtAutogen/MocInclude/Common/common.cpp.in create mode 100644 Tests/QtAutogen/MocInclude/Common/moc_MixedCustom.cpp.in delete mode 100644 Tests/QtAutogen/MocInclude/EObjA.cpp delete mode 100644 Tests/QtAutogen/MocInclude/EObjA.hpp delete mode 100644 Tests/QtAutogen/MocInclude/EObjAExtra.cpp delete mode 100644 Tests/QtAutogen/MocInclude/EObjAExtra.hpp delete mode 100644 Tests/QtAutogen/MocInclude/EObjAExtra_p.hpp delete mode 100644 Tests/QtAutogen/MocInclude/EObjA_p.hpp delete mode 100644 Tests/QtAutogen/MocInclude/EObjB.cpp delete mode 100644 Tests/QtAutogen/MocInclude/EObjB.hpp delete mode 100644 Tests/QtAutogen/MocInclude/EObjB_p.hpp delete mode 100644 Tests/QtAutogen/MocInclude/LObjA.cpp delete mode 100644 Tests/QtAutogen/MocInclude/LObjA.hpp delete mode 100644 Tests/QtAutogen/MocInclude/LObjA_p.h delete mode 100644 Tests/QtAutogen/MocInclude/LObjB.cpp delete mode 100644 Tests/QtAutogen/MocInclude/LObjB.hpp delete mode 100644 Tests/QtAutogen/MocInclude/LObjB_p.h delete mode 100644 Tests/QtAutogen/MocInclude/ObjA.cpp delete mode 100644 Tests/QtAutogen/MocInclude/ObjA.hpp delete mode 100644 Tests/QtAutogen/MocInclude/ObjA_p.h delete mode 100644 Tests/QtAutogen/MocInclude/ObjB.cpp delete mode 100644 Tests/QtAutogen/MocInclude/ObjB.hpp delete mode 100644 Tests/QtAutogen/MocInclude/ObjB_p.h create mode 100644 Tests/QtAutogen/MocInclude/Relaxed/CMakeLists.txt rename Tests/QtAutogen/{MocIncludeRelaxed => MocInclude/Relaxed}/RObjA.cpp (100%) rename Tests/QtAutogen/{MocIncludeRelaxed => MocInclude/Relaxed}/RObjA.hpp (100%) rename Tests/QtAutogen/{MocIncludeRelaxed => MocInclude/Relaxed}/RObjB.cpp (100%) rename Tests/QtAutogen/{MocIncludeRelaxed => MocInclude/Relaxed}/RObjB.hpp (100%) rename Tests/QtAutogen/{MocIncludeRelaxed => MocInclude/Relaxed}/RObjBExtra.hpp (100%) rename Tests/QtAutogen/{MocIncludeRelaxed => MocInclude/Relaxed}/RObjC.cpp (100%) rename Tests/QtAutogen/{MocIncludeRelaxed => MocInclude/Relaxed}/RObjC.hpp (100%) create mode 100644 Tests/QtAutogen/MocInclude/Relaxed/relaxed.cpp delete mode 100644 Tests/QtAutogen/MocInclude/SObjA.cpp delete mode 100644 Tests/QtAutogen/MocInclude/SObjB.cpp.in delete mode 100644 Tests/QtAutogen/MocInclude/SObjB.hpp.in delete mode 100644 Tests/QtAutogen/MocInclude/SObjC.cpp delete mode 100644 Tests/QtAutogen/MocInclude/SObjC.hpp delete mode 100644 Tests/QtAutogen/MocInclude/SObjCExtra.cpp delete mode 100644 Tests/QtAutogen/MocInclude/SObjCExtra.hpp delete mode 100644 Tests/QtAutogen/MocInclude/SObjCExtra.moc.in create mode 100644 Tests/QtAutogen/MocInclude/Strict/CMakeLists.txt create mode 100644 Tests/QtAutogen/MocInclude/Strict/strict.cpp create mode 100644 Tests/QtAutogen/MocInclude/main.cpp delete mode 100644 Tests/QtAutogen/MocInclude/shared.cmake delete mode 100644 Tests/QtAutogen/MocInclude/subExtra/EObjBExtra.cpp delete mode 100644 Tests/QtAutogen/MocInclude/subExtra/EObjBExtra.hpp delete mode 100644 Tests/QtAutogen/MocInclude/subExtra/EObjBExtra_p.hpp delete mode 100644 Tests/QtAutogen/MocInclude/subGlobal/GObj.cpp delete mode 100644 Tests/QtAutogen/MocInclude/subGlobal/GObj.hpp delete mode 100644 Tests/QtAutogen/MocInclude/subGlobal/GObj_p.hpp delete mode 100644 Tests/QtAutogen/MocIncludeRelaxed/CMakeLists.txt delete mode 100644 Tests/QtAutogen/MocIncludeRelaxed/RMain.cpp delete mode 100644 Tests/QtAutogen/MocIncludeRelaxed/main.cpp delete mode 100644 Tests/QtAutogen/MocIncludeStrict/CMakeLists.txt delete mode 100644 Tests/QtAutogen/MocIncludeStrict/main.cpp create mode 100644 Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt hooks/post-receive -- CMake From kwrobot at kitware.com Thu Sep 19 23:58:18 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 19 Sep 2019 23:58:18 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1099-g75b2c97 Message-ID: <20190920035818.3BA5DFC942@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 75b2c9717c0a8e850f524c7d70f4aaa6d224e404 (commit) from 9c31d83aa2a3d3f5921f4a5a559e126e285b96c5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=75b2c9717c0a8e850f524c7d70f4aaa6d224e404 commit 75b2c9717c0a8e850f524c7d70f4aaa6d224e404 Author: Kitware Robot AuthorDate: Fri Sep 20 00:01:06 2019 -0400 Commit: Kitware Robot CommitDate: Fri Sep 20 00:01:06 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index c09c1ce..9a4f63e 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 15) -set(CMake_VERSION_PATCH 20190919) +set(CMake_VERSION_PATCH 20190920) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Fri Sep 20 10:08:04 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 20 Sep 2019 10:08:04 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1103-g073cfa5 Message-ID: <20190920140804.AD9C3A2E1D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 073cfa5ae812b44e97bac2034a10c1379e8d02be (commit) via df65c92cb42376856d06977509c6d24bcc618374 (commit) via 2f702beca1768292b3ecfc54cefde85cf44d1e61 (commit) via 67f3dda69b464940c054723355272933c9d02946 (commit) from 75b2c9717c0a8e850f524c7d70f4aaa6d224e404 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=073cfa5ae812b44e97bac2034a10c1379e8d02be commit 073cfa5ae812b44e97bac2034a10c1379e8d02be Merge: df65c92 2f702be Author: Brad King AuthorDate: Fri Sep 20 10:07:40 2019 -0400 Commit: Brad King CommitDate: Fri Sep 20 10:07:40 2019 -0400 Merge branch 'release-3.15' https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=df65c92cb42376856d06977509c6d24bcc618374 commit df65c92cb42376856d06977509c6d24bcc618374 Merge: 75b2c97 67f3dda Author: Brad King AuthorDate: Fri Sep 20 14:06:40 2019 +0000 Commit: Kitware Robot CommitDate: Fri Sep 20 10:06:51 2019 -0400 Merge topic 'doc-vs-2019-toolset' 67f3dda69b Help: Document VS 2019 toolset in MSVC_TOOLSET_VERSION Acked-by: Kitware Robot Merge-request: !3841 ----------------------------------------------------------------------- Summary of changes: Help/variable/MSVC_TOOLSET_VERSION.rst | 1 + 1 file changed, 1 insertion(+) hooks/post-receive -- CMake From kwrobot at kitware.com Fri Sep 20 10:08:04 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 20 Sep 2019 10:08:04 -0400 (EDT) Subject: [Cmake-commits] CMake branch, release, updated. v3.15.3-2-g2f702be Message-ID: <20190920140804.C1E4518906@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, release has been updated via 2f702beca1768292b3ecfc54cefde85cf44d1e61 (commit) via 67f3dda69b464940c054723355272933c9d02946 (commit) from 26a0e200e5f4abe8268235c9fdb23a2612a1b3b1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: Help/variable/MSVC_TOOLSET_VERSION.rst | 1 + 1 file changed, 1 insertion(+) hooks/post-receive -- CMake From kwrobot at kitware.com Fri Sep 20 10:18:04 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 20 Sep 2019 10:18:04 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1112-g3c060ae Message-ID: <20190920141804.0A2B4A2E1D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 3c060ae6ca01464d507d6c7b6cef38639084418f (commit) via 7cf36407be6c8d5206b4c005e099519ce24f1350 (commit) via ffc7a59417619ec07728a8dea158e949155aa02b (commit) via c578caa68bf7ee55077a3efa25aba46e9e1f562a (commit) via cc3cbf91d23275cc11cf333e14f03886e54a8185 (commit) via 8e9b855a4f66da20067937735c87a2b104363872 (commit) via 1d0d4167cfa53ac85658998980c28e29d0ab537a (commit) via 56879273dc87a69e1d1491a73e0f74cd4424494c (commit) via 3327c0402a1ce31615c7ad22c5ff5d5330fb75da (commit) from 073cfa5ae812b44e97bac2034a10c1379e8d02be (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3c060ae6ca01464d507d6c7b6cef38639084418f commit 3c060ae6ca01464d507d6c7b6cef38639084418f Merge: 7cf3640 1d0d416 Author: Brad King AuthorDate: Fri Sep 20 14:09:00 2019 +0000 Commit: Kitware Robot CommitDate: Fri Sep 20 10:15:35 2019 -0400 Merge topic 'null-warning' 1d0d4167cf TestDriver: Fix -Wzero-as-null-pointer-constant warnings Acked-by: Kitware Robot Acked-by: Brad King Merge-request: !3824 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7cf36407be6c8d5206b4c005e099519ce24f1350 commit 7cf36407be6c8d5206b4c005e099519ce24f1350 Merge: ffc7a59 c578caa Author: Brad King AuthorDate: Fri Sep 20 14:10:43 2019 +0000 Commit: Kitware Robot CommitDate: Fri Sep 20 10:12:56 2019 -0400 Merge topic 'update-kwsys' c578caa68b Tests: Decouple Plugin test from KWSys 56879273dc Merge branch 'upstream-KWSys' into update-kwsys 3327c0402a KWSys 2019-09-18 (c6bc38c1) Acked-by: Kitware Robot Merge-request: !3828 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ffc7a59417619ec07728a8dea158e949155aa02b commit ffc7a59417619ec07728a8dea158e949155aa02b Merge: 073cfa5 cc3cbf9 Author: Brad King AuthorDate: Fri Sep 20 14:08:33 2019 +0000 Commit: Kitware Robot CommitDate: Fri Sep 20 10:10:16 2019 -0400 Merge topic 'cmake-e-doc-order' cc3cbf91d2 Help: Fix indentation of create_symlink note 8e9b855a4f Help: Fix ordering of cmake -E commands Acked-by: Kitware Robot Merge-request: !3833 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c578caa68bf7ee55077a3efa25aba46e9e1f562a commit c578caa68bf7ee55077a3efa25aba46e9e1f562a Author: Brad King AuthorDate: Thu Sep 19 10:10:52 2019 -0400 Commit: Brad King CommitDate: Thu Sep 19 10:42:51 2019 -0400 Tests: Decouple Plugin test from KWSys KWSys now requires C++11 but we want this test to be able to run as C++98. Copy the KWSys DynamicLoader implementation (with original notice headers and license reference) and update it to work alone. diff --git a/Tests/Plugin/CMakeLists.txt b/Tests/Plugin/CMakeLists.txt index 8e8fa07..729bba3 100644 --- a/Tests/Plugin/CMakeLists.txt +++ b/Tests/Plugin/CMakeLists.txt @@ -10,14 +10,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/lib/plugin) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/lib/static) -# We need the dynamic loader support from KWSys to load the plugin in -# the executable. -set(KWSYS_NAMESPACE kwsys) -set(KWSYS_HEADER_ROOT ${Plugin_BINARY_DIR}/include) -set(KWSYS_USE_DynamicLoader 1) -set(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_UTF8) -add_subdirectory(${Plugin_SOURCE_DIR}/../../Source/kwsys src/kwsys) - # Configure the location of plugins. configure_file(${Plugin_SOURCE_DIR}/src/example_exe.h.in ${Plugin_BINARY_DIR}/include/example_exe.h @ONLY) @@ -36,14 +28,14 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND endif() # Create an executable that exports an API for use by plugins. -add_executable(example_exe src/example_exe.cxx) +add_executable(example_exe src/example_exe.cxx src/DynamicLoader.cxx) set_target_properties(example_exe PROPERTIES ENABLE_EXPORTS 1 OUTPUT_NAME example # Test placing exe import library in unique directory. ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/exe ) -target_link_libraries(example_exe kwsys) +target_link_libraries(example_exe ${CMAKE_DL_LIBS}) # Create a plugin that uses the API provided by the executable. # This module "links" to the executable to use the symbols. diff --git a/Tests/Plugin/include/DynamicLoader.hxx b/Tests/Plugin/include/DynamicLoader.hxx new file mode 100644 index 0000000..20b37de --- /dev/null +++ b/Tests/Plugin/include/DynamicLoader.hxx @@ -0,0 +1,49 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. + See https://cmake.org/licensing#kwsys for details. */ +#ifndef DynamicLoader_hxx +#define DynamicLoader_hxx + +#include + +#if defined(__hpux) +# include +#elif defined(_WIN32) && !defined(__CYGWIN__) +# include +#elif defined(__APPLE__) +# include +# if MAC_OS_X_VERSION_MAX_ALLOWED < 1030 +# include +# endif +#elif defined(__BEOS__) +# include +#endif + +class DynamicLoader +{ +public: +#if defined(__hpux) + typedef shl_t LibraryHandle; +#elif defined(_WIN32) && !defined(__CYGWIN__) + typedef HMODULE LibraryHandle; +#elif defined(__APPLE__) +# if MAC_OS_X_VERSION_MAX_ALLOWED < 1030 + typedef NSModule LibraryHandle; +# else + typedef void* LibraryHandle; +# endif +#elif defined(__BEOS__) + typedef image_id LibraryHandle; +#else // POSIX + typedef void* LibraryHandle; +#endif + + typedef void (*SymbolPointer)(); + + static LibraryHandle OpenLibrary(const std::string&); + + static int CloseLibrary(LibraryHandle); + + static SymbolPointer GetSymbolAddress(LibraryHandle, const std::string&); +}; + +#endif diff --git a/Tests/Plugin/src/DynamicLoader.cxx b/Tests/Plugin/src/DynamicLoader.cxx new file mode 100644 index 0000000..d4a2637 --- /dev/null +++ b/Tests/Plugin/src/DynamicLoader.cxx @@ -0,0 +1,263 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. + See https://cmake.org/licensing#kwsys for details. */ +#if defined(_WIN32) +# define NOMINMAX // hide min,max to not conflict with +#endif + +#include + +#if defined(__hpux) +# include + +DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary( + const std::string& libname) +{ + return shl_load(libname.c_str(), BIND_DEFERRED | DYNAMIC_PATH, 0L); +} + +int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib) +{ + if (!lib) { + return 0; + } + return !shl_unload(lib); +} + +DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( + DynamicLoader::LibraryHandle lib, const std::string& sym) +{ + void* addr; + int status; + + /* TYPE_PROCEDURE Look for a function or procedure. (This used to be default) + * TYPE_DATA Look for a symbol in the data segment (for example, + * variables). + * TYPE_UNDEFINED Look for any symbol. + */ + status = shl_findsym(&lib, sym.c_str(), TYPE_UNDEFINED, &addr); + void* result = (status < 0) ? (void*)0 : addr; + + // Hack to cast pointer-to-data to pointer-to-function. + return *reinterpret_cast(&result); +} + +#elif defined(__APPLE__) && (MAC_OS_X_VERSION_MAX_ALLOWED < 1030) +# include + +DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary( + const std::string& libname) +{ + NSObjectFileImageReturnCode rc; + NSObjectFileImage image = 0; + + rc = NSCreateObjectFileImageFromFile(libname.c_str(), &image); + // rc == NSObjectFileImageInappropriateFile when trying to load a dylib file + if (rc != NSObjectFileImageSuccess) { + return 0; + } + NSModule handle = NSLinkModule(image, libname.c_str(), + NSLINKMODULE_OPTION_BINDNOW | + NSLINKMODULE_OPTION_RETURN_ON_ERROR); + NSDestroyObjectFileImage(image); + return handle; +} + +int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib) +{ + bool success = NSUnLinkModule(lib, NSUNLINKMODULE_OPTION_NONE); + return success; +} + +DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( + DynamicLoader::LibraryHandle lib, const std::string& sym) +{ + void* result = 0; + // Need to prepend symbols with '_' on Apple-gcc compilers + std::string rsym = '_' + sym; + + NSSymbol symbol = NSLookupSymbolInModule(lib, rsym.c_str()); + if (symbol) { + result = NSAddressOfSymbol(symbol); + } + + // Hack to cast pointer-to-data to pointer-to-function. + return *reinterpret_cast(&result); +} + +#elif defined(_WIN32) && !defined(__CYGWIN__) +# include + +# include + +DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary( + const std::string& libname) +{ + DynamicLoader::LibraryHandle lh; + int length = MultiByteToWideChar(CP_UTF8, 0, libname.c_str(), -1, NULL, 0); + wchar_t* wchars = new wchar_t[length + 1]; + wchars[0] = '\0'; + MultiByteToWideChar(CP_UTF8, 0, libname.c_str(), -1, wchars, length); + lh = LoadLibraryW(wchars); + delete[] wchars; + return lh; +} + +int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib) +{ + return (int)FreeLibrary(lib); +} + +DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( + DynamicLoader::LibraryHandle lib, const std::string& sym) +{ + void* result; +# if defined(__BORLANDC__) || defined(__WATCOMC__) + // Need to prepend symbols with '_' + std::string ssym = '_' + sym; + const char* rsym = ssym.c_str(); +# else + const char* rsym = sym.c_str(); +# endif + result = (void*)GetProcAddress(lib, rsym); +// Hack to cast pointer-to-data to pointer-to-function. +# ifdef __WATCOMC__ + return *(DynamicLoader::SymbolPointer*)(&result); +# else + return *reinterpret_cast(&result); +# endif +} + +#elif defined(__BEOS__) +# include +# include + +static image_id last_dynamic_err = B_OK; + +DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary( + const std::string& libname) +{ + // image_id's are integers, errors are negative. Add one just in case we + // get a valid image_id of zero (is that even possible?). + image_id rc = load_add_on(libname.c_str()); + if (rc < 0) { + last_dynamic_err = rc; + return 0; + } + + return rc + 1; +} + +int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib) +{ + if (!lib) { + last_dynamic_err = B_BAD_VALUE; + return 0; + } else { + // The function dlclose() returns 0 on success, and non-zero on error. + status_t rc = unload_add_on(lib - 1); + if (rc != B_OK) { + last_dynamic_err = rc; + return 0; + } + } + + return 1; +} + +DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( + DynamicLoader::LibraryHandle lib, const std::string& sym) +{ + // Hack to cast pointer-to-data to pointer-to-function. + union + { + void* pvoid; + DynamicLoader::SymbolPointer psym; + } result; + + result.psym = NULL; + + if (!lib) { + last_dynamic_err = B_BAD_VALUE; + } else { + // !!! FIXME: BeOS can do function-only lookups...does this ever + // !!! FIXME: actually _want_ a data symbol lookup, or was this union + // !!! FIXME: a leftover of dlsym()? (s/ANY/TEXT for functions only). + status_t rc = + get_image_symbol(lib - 1, sym.c_str(), B_SYMBOL_TYPE_ANY, &result.pvoid); + if (rc != B_OK) { + last_dynamic_err = rc; + result.psym = NULL; + } + } + return result.psym; +} + +#elif defined(__MINT__) +# define _GNU_SOURCE /* for program_invocation_name */ +# include +# include +# include + +DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary( + const std::string& libname) +{ + char* name = (char*)calloc(1, libname.size() + 1); + dld_init(program_invocation_name); + strncpy(name, libname.c_str(), libname.size()); + dld_link(libname.c_str()); + return (void*)name; +} + +int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib) +{ + dld_unlink_by_file((char*)lib, 0); + free(lib); + return 0; +} + +DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( + DynamicLoader::LibraryHandle lib, const std::string& sym) +{ + // Hack to cast pointer-to-data to pointer-to-function. + union + { + void* pvoid; + DynamicLoader::SymbolPointer psym; + } result; + result.pvoid = dld_get_symbol(sym.c_str()); + return result.psym; +} + +#else +# include + +DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary( + const std::string& libname) +{ + return dlopen(libname.c_str(), RTLD_LAZY); +} + +int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib) +{ + if (lib) { + // The function dlclose() returns 0 on success, and non-zero on error. + return !dlclose(lib); + } + // else + return 0; +} + +DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( + DynamicLoader::LibraryHandle lib, const std::string& sym) +{ + // Hack to cast pointer-to-data to pointer-to-function. + union + { + void* pvoid; + DynamicLoader::SymbolPointer psym; + } result; + result.pvoid = dlsym(lib, sym.c_str()); + return result.psym; +} + +#endif diff --git a/Tests/Plugin/src/example_exe.cxx b/Tests/Plugin/src/example_exe.cxx index 257a35c..fd810a9 100644 --- a/Tests/Plugin/src/example_exe.cxx +++ b/Tests/Plugin/src/example_exe.cxx @@ -1,4 +1,4 @@ -#include +#include "DynamicLoader.hxx" #include @@ -24,20 +24,17 @@ extern "C" int example_exe_function() int main() { - std::string libName = EXAMPLE_EXE_PLUGIN_DIR CONFIG_DIR "/"; - libName += kwsys::DynamicLoader::LibPrefix(); - libName += "example_mod_1"; - libName += kwsys::DynamicLoader::LibExtension(); - kwsys::DynamicLoader::LibraryHandle handle = - kwsys::DynamicLoader::OpenLibrary(libName.c_str()); + std::string const libName = EXAMPLE_EXE_PLUGIN_DIR CONFIG_DIR + "/" EXAMPLE_EXE_MOD_PREFIX "example_mod_1" EXAMPLE_EXE_MOD_SUFFIX; + DynamicLoader::LibraryHandle handle = DynamicLoader::OpenLibrary(libName); if (!handle) { // Leave the .c_str() on this one. It is needed on OpenWatcom. std::cerr << "Could not open plugin \"" << libName.c_str() << "\"!" << std::endl; return 1; } - kwsys::DynamicLoader::SymbolPointer sym = - kwsys::DynamicLoader::GetSymbolAddress(handle, "example_mod_1_function"); + DynamicLoader::SymbolPointer sym = + DynamicLoader::GetSymbolAddress(handle, "example_mod_1_function"); if (!sym) { std::cerr << "Could not get plugin symbol \"example_mod_1_function\"!" << std::endl; @@ -52,6 +49,6 @@ int main() std::cerr << "Incorrect return value from plugin!" << std::endl; return 1; } - kwsys::DynamicLoader::CloseLibrary(handle); + DynamicLoader::CloseLibrary(handle); return 0; } diff --git a/Tests/Plugin/src/example_exe.h.in b/Tests/Plugin/src/example_exe.h.in index 62f0d9f..af71021 100644 --- a/Tests/Plugin/src/example_exe.h.in +++ b/Tests/Plugin/src/example_exe.h.in @@ -2,5 +2,7 @@ #define example_exe_h #define EXAMPLE_EXE_PLUGIN_DIR "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@" +#define EXAMPLE_EXE_MOD_PREFIX "@CMAKE_SHARED_MODULE_PREFIX@" +#define EXAMPLE_EXE_MOD_SUFFIX "@CMAKE_SHARED_MODULE_SUFFIX@" #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cc3cbf91d23275cc11cf333e14f03886e54a8185 commit cc3cbf91d23275cc11cf333e14f03886e54a8185 Author: Kyle Edwards AuthorDate: Thu Sep 19 09:57:11 2019 -0400 Commit: Kyle Edwards CommitDate: Thu Sep 19 09:57:11 2019 -0400 Help: Fix indentation of create_symlink note diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index 28ebb70..754f14b 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -476,8 +476,8 @@ Available commands are: ``create_symlink `` Create a symbolic link ```` naming ````. -.. note:: - Path to where ```` symbolic link will be created has to exist beforehand. + .. note:: + Path to where ```` symbolic link will be created has to exist beforehand. ``echo [...]`` Displays arguments as text. https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8e9b855a4f66da20067937735c87a2b104363872 commit 8e9b855a4f66da20067937735c87a2b104363872 Author: Kyle Edwards AuthorDate: Wed Sep 18 15:21:10 2019 -0400 Commit: Kyle Edwards CommitDate: Wed Sep 18 15:21:10 2019 -0400 Help: Fix ordering of cmake -E commands Several of the commands were not in alphabetical order. Fix the ordering. diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index 2576cde..28ebb70 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -473,6 +473,12 @@ Available commands are: directory and it must exist. ``copy_if_different`` does follow symlinks. +``create_symlink `` + Create a symbolic link ```` naming ````. + +.. note:: + Path to where ```` symbolic link will be created has to exist beforehand. + ``echo [...]`` Displays arguments as text. @@ -485,6 +491,9 @@ Available commands are: ``environment`` Display the current environment variables. +``false`` + Do nothing, with an exit code of 1. + ``make_directory ...`` Create ```` directories. If necessary, create parent directories too. If a directory already exists it will be @@ -602,18 +611,9 @@ Available commands are: Touch a file if it exists but do not create it. If a file does not exist it will be silently ignored. -``create_symlink `` - Create a symbolic link ```` naming ````. - -.. note:: - Path to where ```` symbolic link will be created has to exist beforehand. - ``true`` Do nothing, with an exit code of 0. -``false`` - Do nothing, with an exit code of 1. - Windows-specific Command-Line Tools ----------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1d0d4167cfa53ac85658998980c28e29d0ab537a commit 1d0d4167cfa53ac85658998980c28e29d0ab537a Author: Sean McBride AuthorDate: Mon Sep 16 19:08:43 2019 -0400 Commit: Brad King CommitDate: Wed Sep 18 14:05:39 2019 -0400 TestDriver: Fix -Wzero-as-null-pointer-constant warnings diff --git a/Templates/TestDriver.cxx.in b/Templates/TestDriver.cxx.in index c58ef71..ad8bfb0 100644 --- a/Templates/TestDriver.cxx.in +++ b/Templates/TestDriver.cxx.in @@ -13,9 +13,15 @@ @CMAKE_FORWARD_DECLARE_TESTS@ #ifdef __cplusplus -#define CM_CAST(TYPE, EXPR) static_cast(EXPR) +# define CM_CAST(TYPE, EXPR) static_cast(EXPR) +# if __cplusplus >= 201103L +# define CM_NULL nullptr +# else +# define CM_NULL NULL +# endif #else -#define CM_CAST(TYPE, EXPR) (TYPE)(EXPR) +# define CM_CAST(TYPE, EXPR) (TYPE)(EXPR) +# define CM_NULL NULL #endif /* Create map. */ @@ -29,7 +35,7 @@ typedef struct /* NOLINT */ static functionMapEntry cmakeGeneratedFunctionMapEntries[] = { @CMAKE_FUNCTION_TABLE_ENTIRES@ - { NULL, NULL } /* NOLINT */ + { CM_NULL, CM_NULL } /* NOLINT */ }; static const int NumTests = CM_CAST(int, @@ -45,8 +51,8 @@ static char* lowercase(const char* string) stringSize = CM_CAST(size_t, strlen(string) + 1); new_string = CM_CAST(char*, malloc(sizeof(char) * stringSize)); - if (new_string == NULL) { /* NOLINT */ - return NULL; /* NOLINT */ + if (new_string == CM_NULL) { /* NOLINT */ + return CM_NULL; /* NOLINT */ } strcpy(new_string, string); for (p = new_string; *p != 0; ++p) { @@ -86,7 +92,7 @@ int main(int ac, char* av[]) av++; } partial_match = 0; - arg = NULL; /* NOLINT */ + arg = CM_NULL; /* NOLINT */ /* If partial match is requested. */ if (testToRun == -1 && ac > 1) { partial_match = (strcmp(av[1], "-R") == 0) ? 1 : 0; @@ -100,7 +106,7 @@ int main(int ac, char* av[]) } for (i = 0; i < NumTests && testToRun == -1; ++i) { char *test_name = lowercase(cmakeGeneratedFunctionMapEntries[i].name); - if (partial_match != 0 && strstr(test_name, arg) != NULL) { /* NOLINT */ + if (partial_match != 0 && strstr(test_name, arg) != CM_NULL) { /* NOLINT */ testToRun = i; ac -= 2; av += 2; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=56879273dc87a69e1d1491a73e0f74cd4424494c commit 56879273dc87a69e1d1491a73e0f74cd4424494c Merge: 45b7d52 3327c04 Author: Brad King AuthorDate: Wed Sep 18 09:26:40 2019 -0400 Commit: Brad King CommitDate: Wed Sep 18 09:26:40 2019 -0400 Merge branch 'upstream-KWSys' into update-kwsys # By KWSys Upstream * upstream-KWSys: KWSys 2019-09-18 (c6bc38c1) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3327c0402a1ce31615c7ad22c5ff5d5330fb75da commit 3327c0402a1ce31615c7ad22c5ff5d5330fb75da Author: KWSys Upstream AuthorDate: Wed Sep 18 08:13:53 2019 -0400 Commit: Brad King CommitDate: Wed Sep 18 09:26:35 2019 -0400 KWSys 2019-09-18 (c6bc38c1) Code extracted from: https://gitlab.kitware.com/utils/kwsys.git at commit c6bc38c11a3a11e393f0608486b08dadc8dbacc3 (master). Upstream Shortlog ----------------- Sean McBride (5): 4de1241f Fixed -Wextra-semi-stmt warning 30de8e17 Fixed -Wsign-conversion warnings by adding casts 750da75a Fixed 64 to 32 bit truncation warning by casting 419aaa35 Fixed -Wunused-macros warnings 46c55893 Replaced several 0, NULL, and KWSYS_NULLPTR with nullptr diff --git a/CommandLineArguments.cxx b/CommandLineArguments.cxx index dc9f01d..3fd1955 100644 --- a/CommandLineArguments.cxx +++ b/CommandLineArguments.cxx @@ -67,8 +67,8 @@ class CommandLineArgumentsInternal { public: CommandLineArgumentsInternal() - : UnknownArgumentCallback{ KWSYS_NULLPTR } - , ClientData{ KWSYS_NULLPTR } + : UnknownArgumentCallback{ nullptr } + , ClientData{ nullptr } , LastArgument{ 0 } { } @@ -187,7 +187,7 @@ int CommandLineArguments::Parse() switch (cs->ArgumentType) { case NO_ARGUMENT: // No value - if (!this->PopulateVariable(cs, KWSYS_NULLPTR)) { + if (!this->PopulateVariable(cs, nullptr)) { return 0; } break; @@ -340,7 +340,7 @@ void CommandLineArguments::AddCallback(const char* argument, s.Callback = callback; s.CallData = call_data; s.VariableType = CommandLineArguments::NO_VARIABLE_TYPE; - s.Variable = KWSYS_NULLPTR; + s.Variable = nullptr; s.Help = help; this->Internals->Callbacks[argument] = s; @@ -355,8 +355,8 @@ void CommandLineArguments::AddArgument(const char* argument, CommandLineArgumentsCallbackStructure s; s.Argument = argument; s.ArgumentType = type; - s.Callback = KWSYS_NULLPTR; - s.CallData = KWSYS_NULLPTR; + s.Callback = nullptr; + s.CallData = nullptr; s.VariableType = vtype; s.Variable = variable; s.Help = help; @@ -427,7 +427,7 @@ const char* CommandLineArguments::GetHelp(const char* arg) CommandLineArguments::Internal::CallbacksMap::iterator it = this->Internals->Callbacks.find(arg); if (it == this->Internals->Callbacks.end()) { - return KWSYS_NULLPTR; + return nullptr; } // Since several arguments may point to the same argument, find the one this @@ -621,7 +621,7 @@ void CommandLineArguments::PopulateVariable(bool* variable, void CommandLineArguments::PopulateVariable(int* variable, const std::string& value) { - char* res = KWSYS_NULLPTR; + char* res = nullptr; *variable = static_cast(strtol(value.c_str(), &res, 10)); // if ( res && *res ) // { @@ -632,7 +632,7 @@ void CommandLineArguments::PopulateVariable(int* variable, void CommandLineArguments::PopulateVariable(double* variable, const std::string& value) { - char* res = KWSYS_NULLPTR; + char* res = nullptr; *variable = strtod(value.c_str(), &res); // if ( res && *res ) // { @@ -669,7 +669,7 @@ void CommandLineArguments::PopulateVariable(std::vector* variable, void CommandLineArguments::PopulateVariable(std::vector* variable, const std::string& value) { - char* res = KWSYS_NULLPTR; + char* res = nullptr; variable->push_back(static_cast(strtol(value.c_str(), &res, 10))); // if ( res && *res ) // { @@ -680,7 +680,7 @@ void CommandLineArguments::PopulateVariable(std::vector* variable, void CommandLineArguments::PopulateVariable(std::vector* variable, const std::string& value) { - char* res = KWSYS_NULLPTR; + char* res = nullptr; variable->push_back(strtod(value.c_str(), &res)); // if ( res && *res ) // { diff --git a/Configure.hxx.in b/Configure.hxx.in index 92ffea3..29a2dd1 100644 --- a/Configure.hxx.in +++ b/Configure.hxx.in @@ -58,7 +58,6 @@ # define KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H \ @KWSYS_NAMESPACE at _CXX_HAS_EXT_STDIO_FILEBUF_H # define KWSYS_FALLTHROUGH @KWSYS_NAMESPACE at _FALLTHROUGH -# define KWSYS_NULLPTR @KWSYS_NAMESPACE at _NULLPTR # define KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP \ @KWSYS_NAMESPACE at _SYSTEMTOOLS_USE_TRANSLATION_MAP #endif diff --git a/ConsoleBuf.hxx.in b/ConsoleBuf.hxx.in index 73a1efb..49dbdf7 100644 --- a/ConsoleBuf.hxx.in +++ b/ConsoleBuf.hxx.in @@ -116,7 +116,7 @@ protected: DWORD charsWritten; success = ::WriteConsoleW(m_hOutput, wbuffer.c_str(), (DWORD)wbuffer.size(), - &charsWritten, NULL) == 0 + &charsWritten, nullptr) == 0 ? false : true; } else { @@ -124,8 +124,9 @@ protected: std::string buffer; success = encodeOutputBuffer(wbuffer, buffer); if (success) { - success = ::WriteFile(m_hOutput, buffer.c_str(), - (DWORD)buffer.size(), &bytesWritten, NULL) == 0 + success = + ::WriteFile(m_hOutput, buffer.c_str(), (DWORD)buffer.size(), + &bytesWritten, nullptr) == 0 ? false : true; } @@ -152,7 +153,7 @@ protected: DWORD charsRead; if (ReadConsoleW(m_hInput, wbuffer, (sizeof(wbuffer) / sizeof(wbuffer[0])), &charsRead, - NULL) == 0 || + nullptr) == 0 || charsRead == 0) { _setg(true); return Traits::eof(); @@ -168,7 +169,7 @@ protected: return Traits::eof(); } char* buffer = new char[size.LowPart]; - while (ReadFile(m_hInput, buffer, size.LowPart, &bytesRead, NULL) == + while (ReadFile(m_hInput, buffer, size.LowPart, &bytesRead, nullptr) == 0) { if (GetLastError() == ERROR_MORE_DATA) { strbuffer += std::string(buffer, bytesRead); @@ -327,11 +328,12 @@ private: } const int length = WideCharToMultiByte(m_activeOutputCodepage, 0, wbuffer.c_str(), - (int)wbuffer.size(), NULL, 0, NULL, NULL); + (int)wbuffer.size(), nullptr, 0, nullptr, nullptr); char* buf = new char[length]; const bool success = WideCharToMultiByte(m_activeOutputCodepage, 0, wbuffer.c_str(), - (int)wbuffer.size(), buf, length, NULL, NULL) > 0 + (int)wbuffer.size(), buf, length, nullptr, + nullptr) > 0 ? true : false; buffer = std::string(buf, length); @@ -356,7 +358,7 @@ private: length -= BOMsize; } const size_t wlength = static_cast(MultiByteToWideChar( - actualCodepage, 0, data, static_cast(length), NULL, 0)); + actualCodepage, 0, data, static_cast(length), nullptr, 0)); wchar_t* wbuf = new wchar_t[wlength]; const bool success = MultiByteToWideChar(actualCodepage, 0, data, static_cast(length), diff --git a/Directory.cxx b/Directory.cxx index 59530a4..e379182 100644 --- a/Directory.cxx +++ b/Directory.cxx @@ -48,7 +48,7 @@ unsigned long Directory::GetNumberOfFiles() const const char* Directory::GetFile(unsigned long dindex) const { if (dindex >= this->Internal->Files.size()) { - return KWSYS_NULLPTR; + return nullptr; } return this->Internal->Files[dindex].c_str(); } diff --git a/DynamicLoader.cxx b/DynamicLoader.cxx index b93a215..a4b8641 100644 --- a/DynamicLoader.cxx +++ b/DynamicLoader.cxx @@ -223,15 +223,15 @@ namespace KWSYS_NAMESPACE { DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary( const std::string& libname, int flags) { - CHECK_OPEN_FLAGS(flags, SearchBesideLibrary, NULL); + CHECK_OPEN_FLAGS(flags, SearchBesideLibrary, nullptr); DWORD llFlags = 0; if (flags & SearchBesideLibrary) { llFlags |= LOAD_WITH_ALTERED_SEARCH_PATH; } - return LoadLibraryExW(Encoding::ToWindowsExtendedPath(libname).c_str(), NULL, - llFlags); + return LoadLibraryExW(Encoding::ToWindowsExtendedPath(libname).c_str(), + nullptr, llFlags); } int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib) @@ -289,9 +289,9 @@ const char* DynamicLoader::LastError() DWORD error = GetLastError(); DWORD length = FormatMessageW( - FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error, + FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - lpMsgBuf, DYNLOAD_ERROR_BUFFER_SIZE, NULL); + lpMsgBuf, DYNLOAD_ERROR_BUFFER_SIZE, nullptr); static char str[DYNLOAD_ERROR_BUFFER_SIZE + 1]; @@ -305,7 +305,7 @@ const char* DynamicLoader::LastError() } if (!WideCharToMultiByte(CP_UTF8, 0, lpMsgBuf, -1, str, - DYNLOAD_ERROR_BUFFER_SIZE, NULL, NULL)) { + DYNLOAD_ERROR_BUFFER_SIZE, nullptr, nullptr)) { /* WideCharToMultiByte failed. Use a default message. */ _snprintf(str, DYNLOAD_ERROR_BUFFER_SIZE, "DynamicLoader encountered error 0x%X. " @@ -372,7 +372,7 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( DynamicLoader::SymbolPointer psym; } result; - result.psym = NULL; + result.psym = nullptr; if (!lib) { last_dynamic_err = B_BAD_VALUE; @@ -384,7 +384,7 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( get_image_symbol(lib - 1, sym.c_str(), B_SYMBOL_TYPE_ANY, &result.pvoid); if (rc != B_OK) { last_dynamic_err = rc; - result.psym = NULL; + result.psym = nullptr; } } return result.psym; @@ -412,7 +412,7 @@ namespace KWSYS_NAMESPACE { DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary( const std::string& libname, int flags) { - CHECK_OPEN_FLAGS(flags, 0, NULL); + CHECK_OPEN_FLAGS(flags, 0, nullptr); char* name = (char*)calloc(1, libname.size() + 1); dld_init(program_invocation_name); @@ -458,7 +458,7 @@ namespace KWSYS_NAMESPACE { DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary( const std::string& libname, int flags) { - CHECK_OPEN_FLAGS(flags, 0, NULL); + CHECK_OPEN_FLAGS(flags, 0, nullptr); return dlopen(libname.c_str(), RTLD_LAZY); } diff --git a/EncodingCXX.cxx b/EncodingCXX.cxx index 251deef..4593c92 100644 --- a/EncodingCXX.cxx +++ b/EncodingCXX.cxx @@ -65,7 +65,7 @@ Encoding::CommandLineArguments::CommandLineArguments(int ac, for (int i = 0; i < ac; i++) { this->argv_[i] = strdup(av[i]); } - this->argv_[ac] = KWSYS_NULLPTR; + this->argv_[ac] = nullptr; } Encoding::CommandLineArguments::CommandLineArguments(int ac, @@ -75,7 +75,7 @@ Encoding::CommandLineArguments::CommandLineArguments(int ac, for (int i = 0; i < ac; i++) { this->argv_[i] = kwsysEncoding_DupToNarrow(av[i]); } - this->argv_[ac] = KWSYS_NULLPTR; + this->argv_[ac] = nullptr; } Encoding::CommandLineArguments::~CommandLineArguments() @@ -90,7 +90,7 @@ Encoding::CommandLineArguments::CommandLineArguments( { this->argv_.resize(other.argv_.size()); for (size_t i = 0; i < this->argv_.size(); i++) { - this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : KWSYS_NULLPTR; + this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : nullptr; } } @@ -105,7 +105,7 @@ Encoding::CommandLineArguments& Encoding::CommandLineArguments::operator=( this->argv_.resize(other.argv_.size()); for (i = 0; i < this->argv_.size(); i++) { - this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : KWSYS_NULLPTR; + this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : nullptr; } } @@ -128,8 +128,9 @@ std::wstring Encoding::ToWide(const std::string& str) { std::wstring wstr; # if defined(_WIN32) - const int wlength = MultiByteToWideChar( - KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.data(), int(str.size()), NULL, 0); + const int wlength = + MultiByteToWideChar(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.data(), + int(str.size()), nullptr, 0); if (wlength > 0) { wchar_t* wdata = new wchar_t[wlength]; int r = MultiByteToWideChar(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.data(), @@ -162,12 +163,12 @@ std::string Encoding::ToNarrow(const std::wstring& str) # if defined(_WIN32) int length = WideCharToMultiByte(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.c_str(), - int(str.size()), NULL, 0, NULL, NULL); + int(str.size()), nullptr, 0, nullptr, nullptr); if (length > 0) { char* data = new char[length]; int r = WideCharToMultiByte(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.c_str(), - int(str.size()), data, length, NULL, NULL); + int(str.size()), data, length, nullptr, nullptr); if (r > 0) { nstr = std::string(data, length); } @@ -193,7 +194,7 @@ std::string Encoding::ToNarrow(const std::wstring& str) std::wstring Encoding::ToWide(const char* cstr) { std::wstring wstr; - size_t length = kwsysEncoding_mbstowcs(KWSYS_NULLPTR, cstr, 0) + 1; + size_t length = kwsysEncoding_mbstowcs(nullptr, cstr, 0) + 1; if (length > 0) { std::vector wchars(length); if (kwsysEncoding_mbstowcs(&wchars[0], cstr, length) > 0) { @@ -206,7 +207,7 @@ std::wstring Encoding::ToWide(const char* cstr) std::string Encoding::ToNarrow(const wchar_t* wcstr) { std::string str; - size_t length = kwsysEncoding_wcstombs(KWSYS_NULLPTR, wcstr, 0) + 1; + size_t length = kwsysEncoding_wcstombs(nullptr, wcstr, 0) + 1; if (length > 0) { std::vector chars(length); if (kwsysEncoding_wcstombs(&chars[0], wcstr, length) > 0) { @@ -227,9 +228,9 @@ std::wstring Encoding::ToWindowsExtendedPath(std::string const& source) /* The +3 is a workaround for a bug in some versions of GetFullPathNameW that * won't return a large enough buffer size if the input is too small */ - wfull_len = GetFullPathNameW(wsource.c_str(), 0, NULL, NULL) + 3; + wfull_len = GetFullPathNameW(wsource.c_str(), 0, nullptr, nullptr) + 3; std::vector wfull(wfull_len); - GetFullPathNameW(wsource.c_str(), wfull_len, &wfull[0], NULL); + GetFullPathNameW(wsource.c_str(), wfull_len, &wfull[0], nullptr); /* This should get the correct size without any extra padding from the * previous size workaround. */ diff --git a/Glob.cxx b/Glob.cxx index 829c138..34bb0d0 100644 --- a/Glob.cxx +++ b/Glob.cxx @@ -431,7 +431,7 @@ void Glob::SetRelative(const char* dir) const char* Glob::GetRelative() { if (this->Relative.empty()) { - return KWSYS_NULLPTR; + return nullptr; } return this->Relative.c_str(); } diff --git a/Glob.hxx.in b/Glob.hxx.in index 4c3bde1..170766f 100644 --- a/Glob.hxx.in +++ b/Glob.hxx.in @@ -54,7 +54,7 @@ public: ~Glob(); //! Find all files that match the pattern. - bool FindFiles(const std::string& inexpr, GlobMessages* messages = 0); + bool FindFiles(const std::string& inexpr, GlobMessages* messages = nullptr); //! Return the list of files that matched. std::vector& GetFiles(); diff --git a/RegularExpression.cxx b/RegularExpression.cxx index 3e10765..5e6f8da 100644 --- a/RegularExpression.cxx +++ b/RegularExpression.cxx @@ -37,7 +37,7 @@ namespace KWSYS_NAMESPACE { RegularExpression::RegularExpression(const RegularExpression& rxp) { if (!rxp.program) { - this->program = KWSYS_NULLPTR; + this->program = nullptr; return; } int ind; @@ -48,7 +48,7 @@ RegularExpression::RegularExpression(const RegularExpression& rxp) // Copy pointers into last successful "find" operation this->regmatch = rxp.regmatch; this->regmust = rxp.regmust; // Copy field - if (rxp.regmust != KWSYS_NULLPTR) { + if (rxp.regmust != nullptr) { char* dum = rxp.program; ind = 0; while (dum != rxp.regmust) { @@ -69,7 +69,7 @@ RegularExpression& RegularExpression::operator=(const RegularExpression& rxp) return *this; } if (!rxp.program) { - this->program = KWSYS_NULLPTR; + this->program = nullptr; return *this; } int ind; @@ -81,7 +81,7 @@ RegularExpression& RegularExpression::operator=(const RegularExpression& rxp) // Copy pointers into last successful "find" operation this->regmatch = rxp.regmatch; this->regmust = rxp.regmust; // Copy field - if (rxp.regmust != KWSYS_NULLPTR) { + if (rxp.regmust != nullptr) { char* dum = rxp.program; ind = 0; while (dum != rxp.regmust) { @@ -164,8 +164,8 @@ bool RegularExpression::deep_equal(const RegularExpression& rxp) const * * regstart char that must begin a match; '\0' if none obvious * reganch is the match anchored (at beginning-of-line only)? - * regmust string (pointer into program) that match must include, or NULL - * regmlen length of regmust string + * regmust string (pointer into program) that match must include, or + * nullptr regmlen length of regmust string * * Regstart and reganch permit very fast decisions on suitable starting points * for a match, cutting down the work a lot. Regmust permits fast rejection @@ -339,7 +339,7 @@ bool RegularExpression::compile(const char* exp) const char* longest; int flags; - if (exp == KWSYS_NULLPTR) { + if (exp == nullptr) { // RAISE Error, SYM(RegularExpression), SYM(No_Expr), printf("RegularExpression::compile(): No expression supplied.\n"); return false; @@ -367,13 +367,13 @@ bool RegularExpression::compile(const char* exp) // Allocate space. //#ifndef _WIN32 - if (this->program != KWSYS_NULLPTR) + if (this->program != nullptr) delete[] this->program; //#endif this->program = new char[comp.regsize]; this->progsize = static_cast(comp.regsize); - if (this->program == KWSYS_NULLPTR) { + if (this->program == nullptr) { // RAISE Error, SYM(RegularExpression), SYM(Out_Of_Memory), printf("RegularExpression::compile(): Out of memory.\n"); return false; @@ -389,7 +389,7 @@ bool RegularExpression::compile(const char* exp) // Dig out information for optimizations. this->regstart = '\0'; // Worst-case defaults. this->reganch = 0; - this->regmust = KWSYS_NULLPTR; + this->regmust = nullptr; this->regmlen = 0; scan = this->program + 1; // First BRANCH. if (OP(regnext(scan)) == END) { // Only one top-level choice. @@ -410,9 +410,9 @@ bool RegularExpression::compile(const char* exp) // absence of others. // if (flags & SPSTART) { - longest = KWSYS_NULLPTR; + longest = nullptr; size_t len = 0; - for (; scan != KWSYS_NULLPTR; scan = regnext(scan)) + for (; scan != nullptr; scan = regnext(scan)) if (OP(scan) == EXACTLY && strlen(OPERAND(scan)) >= len) { longest = OPERAND(scan); len = strlen(OPERAND(scan)); @@ -448,19 +448,19 @@ char* RegExpCompile::reg(int paren, int* flagp) if (regnpar >= RegularExpressionMatch::NSUBEXP) { // RAISE Error, SYM(RegularExpression), SYM(Too_Many_Parens), printf("RegularExpression::compile(): Too many parentheses.\n"); - return KWSYS_NULLPTR; + return nullptr; } parno = regnpar; regnpar++; ret = regnode(static_cast(OPEN + parno)); } else - ret = KWSYS_NULLPTR; + ret = nullptr; // Pick up the branches, linking them together. br = regbranch(&flags); - if (br == KWSYS_NULLPTR) - return (KWSYS_NULLPTR); - if (ret != KWSYS_NULLPTR) + if (br == nullptr) + return (nullptr); + if (ret != nullptr) regtail(ret, br); // OPEN -> first. else ret = br; @@ -470,8 +470,8 @@ char* RegExpCompile::reg(int paren, int* flagp) while (*regparse == '|') { regparse++; br = regbranch(&flags); - if (br == KWSYS_NULLPTR) - return (KWSYS_NULLPTR); + if (br == nullptr) + return (nullptr); regtail(ret, br); // BRANCH -> BRANCH. if (!(flags & HASWIDTH)) *flagp &= ~HASWIDTH; @@ -483,23 +483,23 @@ char* RegExpCompile::reg(int paren, int* flagp) regtail(ret, ender); // Hook the tails of the branches to the closing node. - for (br = ret; br != KWSYS_NULLPTR; br = regnext(br)) + for (br = ret; br != nullptr; br = regnext(br)) regoptail(br, ender); // Check for proper termination. if (paren && *regparse++ != ')') { // RAISE Error, SYM(RegularExpression), SYM(Unmatched_Parens), printf("RegularExpression::compile(): Unmatched parentheses.\n"); - return KWSYS_NULLPTR; + return nullptr; } else if (!paren && *regparse != '\0') { if (*regparse == ')') { // RAISE Error, SYM(RegularExpression), SYM(Unmatched_Parens), printf("RegularExpression::compile(): Unmatched parentheses.\n"); - return KWSYS_NULLPTR; + return nullptr; } else { // RAISE Error, SYM(RegularExpression), SYM(Internal_Error), printf("RegularExpression::compile(): Internal error.\n"); - return KWSYS_NULLPTR; + return nullptr; } // NOTREACHED } @@ -521,19 +521,19 @@ char* RegExpCompile::regbranch(int* flagp) *flagp = WORST; // Tentatively. ret = regnode(BRANCH); - chain = KWSYS_NULLPTR; + chain = nullptr; while (*regparse != '\0' && *regparse != '|' && *regparse != ')') { latest = regpiece(&flags); - if (latest == KWSYS_NULLPTR) - return (KWSYS_NULLPTR); + if (latest == nullptr) + return (nullptr); *flagp |= flags & HASWIDTH; - if (chain == KWSYS_NULLPTR) // First piece. + if (chain == nullptr) // First piece. *flagp |= flags & SPSTART; else regtail(chain, latest); chain = latest; } - if (chain == KWSYS_NULLPTR) // Loop ran zero times. + if (chain == nullptr) // Loop ran zero times. regnode(NOTHING); return (ret); @@ -556,8 +556,8 @@ char* RegExpCompile::regpiece(int* flagp) int flags; ret = regatom(&flags); - if (ret == KWSYS_NULLPTR) - return (KWSYS_NULLPTR); + if (ret == nullptr) + return (nullptr); op = *regparse; if (!ISMULT(op)) { @@ -568,7 +568,7 @@ char* RegExpCompile::regpiece(int* flagp) if (!(flags & HASWIDTH) && op != '?') { // RAISE Error, SYM(RegularExpression), SYM(Empty_Operand), printf("RegularExpression::compile() : *+ operand could be empty.\n"); - return KWSYS_NULLPTR; + return nullptr; } *flagp = (op != '+') ? (WORST | SPSTART) : (WORST | HASWIDTH); @@ -602,7 +602,7 @@ char* RegExpCompile::regpiece(int* flagp) if (ISMULT(*regparse)) { // RAISE Error, SYM(RegularExpression), SYM(Nested_Operand), printf("RegularExpression::compile(): Nested *?+.\n"); - return KWSYS_NULLPTR; + return nullptr; } return (ret); } @@ -655,7 +655,7 @@ char* RegExpCompile::regatom(int* flagp) if (rxpclass > rxpclassend + 1) { // RAISE Error, SYM(RegularExpression), SYM(Invalid_Range), printf("RegularExpression::compile(): Invalid range in [].\n"); - return KWSYS_NULLPTR; + return nullptr; } for (; rxpclass <= rxpclassend; rxpclass++) regc(static_cast(rxpclass)); @@ -668,15 +668,15 @@ char* RegExpCompile::regatom(int* flagp) if (*regparse != ']') { // RAISE Error, SYM(RegularExpression), SYM(Unmatched_Bracket), printf("RegularExpression::compile(): Unmatched [].\n"); - return KWSYS_NULLPTR; + return nullptr; } regparse++; *flagp |= HASWIDTH | SIMPLE; } break; case '(': ret = reg(1, &flags); - if (ret == KWSYS_NULLPTR) - return (KWSYS_NULLPTR); + if (ret == nullptr) + return (nullptr); *flagp |= flags & (HASWIDTH | SPSTART); break; case '\0': @@ -684,18 +684,18 @@ char* RegExpCompile::regatom(int* flagp) case ')': // RAISE Error, SYM(RegularExpression), SYM(Internal_Error), printf("RegularExpression::compile(): Internal error.\n"); // Never here - return KWSYS_NULLPTR; + return nullptr; case '?': case '+': case '*': // RAISE Error, SYM(RegularExpression), SYM(No_Operand), printf("RegularExpression::compile(): ?+* follows nothing.\n"); - return KWSYS_NULLPTR; + return nullptr; case '\\': if (*regparse == '\0') { // RAISE Error, SYM(RegularExpression), SYM(Trailing_Backslash), printf("RegularExpression::compile(): Trailing backslash.\n"); - return KWSYS_NULLPTR; + return nullptr; } ret = regnode(EXACTLY); regc(*regparse++); @@ -711,7 +711,7 @@ char* RegExpCompile::regatom(int* flagp) if (len <= 0) { // RAISE Error, SYM(RegularExpression), SYM(Internal_Error), printf("RegularExpression::compile(): Internal error.\n"); - return KWSYS_NULLPTR; + return nullptr; } ender = *(regparse + len); if (len > 1 && ISMULT(ender)) @@ -809,7 +809,7 @@ void RegExpCompile::regtail(char* p, const char* val) scan = p; for (;;) { temp = regnext(scan); - if (temp == KWSYS_NULLPTR) + if (temp == nullptr) break; scan = temp; } @@ -828,7 +828,7 @@ void RegExpCompile::regtail(char* p, const char* val) void RegExpCompile::regoptail(char* p, const char* val) { // "Operandless" and "op != BRANCH" are synonymous in practice. - if (p == KWSYS_NULLPTR || p == regdummyptr || OP(p) != BRANCH) + if (p == nullptr || p == regdummyptr || OP(p) != BRANCH) return; regtail(OPERAND(p), val); } @@ -878,14 +878,14 @@ bool RegularExpression::find(char const* string, } // If there is a "must appear" string, look for it. - if (this->regmust != KWSYS_NULLPTR) { + if (this->regmust != nullptr) { s = string; - while ((s = strchr(s, this->regmust[0])) != KWSYS_NULLPTR) { + while ((s = strchr(s, this->regmust[0])) != nullptr) { if (strncmp(s, this->regmust, this->regmlen) == 0) break; // Found it. s++; } - if (s == KWSYS_NULLPTR) // Not present. + if (s == nullptr) // Not present. return false; } @@ -903,7 +903,7 @@ bool RegularExpression::find(char const* string, s = string; if (this->regstart != '\0') // We know what char it must start with. - while ((s = strchr(s, this->regstart)) != KWSYS_NULLPTR) { + while ((s = strchr(s, this->regstart)) != nullptr) { if (regFind.regtry(s, rmatch.startp, rmatch.endp, this->program)) return true; s++; @@ -937,8 +937,8 @@ int RegExpFind::regtry(const char* string, const char** start, sp1 = start; ep = end; for (i = RegularExpressionMatch::NSUBEXP; i > 0; i--) { - *sp1++ = KWSYS_NULLPTR; - *ep++ = KWSYS_NULLPTR; + *sp1++ = nullptr; + *ep++ = nullptr; } if (regmatch(prog + 1)) { start[0] = string; @@ -966,7 +966,7 @@ int RegExpFind::regmatch(const char* prog) scan = prog; - while (scan != KWSYS_NULLPTR) { + while (scan != nullptr) { next = regnext(scan); @@ -998,14 +998,12 @@ int RegExpFind::regmatch(const char* prog) reginput += len; } break; case ANYOF: - if (*reginput == '\0' || - strchr(OPERAND(scan), *reginput) == KWSYS_NULLPTR) + if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) == nullptr) return (0); reginput++; break; case ANYBUT: - if (*reginput == '\0' || - strchr(OPERAND(scan), *reginput) != KWSYS_NULLPTR) + if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) != nullptr) return (0); reginput++; break; @@ -1034,7 +1032,7 @@ int RegExpFind::regmatch(const char* prog) // Don't set startp if some later invocation of the // same parentheses already has. // - if (regstartp[no] == KWSYS_NULLPTR) + if (regstartp[no] == nullptr) regstartp[no] = save; return (1); } else @@ -1062,7 +1060,7 @@ int RegExpFind::regmatch(const char* prog) // Don't set endp if some later invocation of the // same parentheses already has. // - if (regendp[no] == KWSYS_NULLPTR) + if (regendp[no] == nullptr) regendp[no] = save; return (1); } else @@ -1082,7 +1080,7 @@ int RegExpFind::regmatch(const char* prog) return (1); reginput = save; scan = regnext(scan); - } while (scan != KWSYS_NULLPTR && OP(scan) == BRANCH); + } while (scan != nullptr && OP(scan) == BRANCH); return (0); // NOTREACHED } @@ -1160,13 +1158,13 @@ int RegExpFind::regrepeat(const char* p) } break; case ANYOF: - while (*scan != '\0' && strchr(opnd, *scan) != KWSYS_NULLPTR) { + while (*scan != '\0' && strchr(opnd, *scan) != nullptr) { count++; scan++; } break; case ANYBUT: - while (*scan != '\0' && strchr(opnd, *scan) == KWSYS_NULLPTR) { + while (*scan != '\0' && strchr(opnd, *scan) == nullptr) { count++; scan++; } @@ -1188,11 +1186,11 @@ static const char* regnext(const char* p) int offset; if (p == regdummyptr) - return (KWSYS_NULLPTR); + return (nullptr); offset = NEXT(p); if (offset == 0) - return (KWSYS_NULLPTR); + return (nullptr); if (OP(p) == BACK) return (p - offset); @@ -1205,11 +1203,11 @@ static char* regnext(char* p) int offset; if (p == regdummyptr) - return (KWSYS_NULLPTR); + return (nullptr); offset = NEXT(p); if (offset == 0) - return (KWSYS_NULLPTR); + return (nullptr); if (OP(p) == BACK) return (p - offset); diff --git a/RegularExpression.hxx.in b/RegularExpression.hxx.in index ed86418..df7eb45 100644 --- a/RegularExpression.hxx.in +++ b/RegularExpression.hxx.in @@ -71,9 +71,9 @@ private: */ inline RegularExpressionMatch::RegularExpressionMatch() { - startp[0] = 0; - endp[0] = 0; - searchstring = 0; + startp[0] = nullptr; + endp[0] = nullptr; + searchstring = nullptr; } /** @@ -81,7 +81,7 @@ inline RegularExpressionMatch::RegularExpressionMatch() */ inline bool RegularExpressionMatch::isValid() const { - return (this->startp[0] != 0); + return (this->startp[0] != nullptr); } /** @@ -89,9 +89,9 @@ inline bool RegularExpressionMatch::isValid() const */ inline void RegularExpressionMatch::clear() { - startp[0] = 0; - endp[0] = 0; - searchstring = 0; + startp[0] = nullptr; + endp[0] = nullptr; + searchstring = nullptr; } /** @@ -135,7 +135,7 @@ inline std::string::size_type RegularExpressionMatch::end(int n) const */ inline std::string RegularExpressionMatch::match(int n) const { - if (this->startp[n] == 0) { + if (this->startp[n] == nullptr) { return std::string(); } else { return std::string( @@ -230,10 +230,11 @@ inline std::string RegularExpressionMatch::match(int n) const * into the object's private data fields. The == and != operators only check * the to see if the compiled regular expression is the same, and the * deep_equal functions also checks to see if the start and end pointers are - * the same. The is_valid function returns false if program is set to NULL, - * (i.e. there is no valid compiled expression). The set_invalid function - * sets the program to NULL (Warning: this deletes the compiled expression). - * The following examples may help clarify regular expression usage: + * the same. The is_valid function returns false if program is set to + * nullptr, (i.e. there is no valid compiled expression). The set_invalid + * function sets the program to nullptr (Warning: this deletes the compiled + * expression). The following examples may help clarify regular expression + * usage: * * * The regular expression "^hello" matches a "hello" only at the * beginning of a line. It would match "hello there" but not "hi, @@ -288,7 +289,7 @@ class @KWSYS_NAMESPACE at _EXPORT RegularExpression { public: /** - * Instantiate RegularExpression with program=NULL. + * Instantiate RegularExpression with program=nullptr. */ inline RegularExpression(); @@ -410,7 +411,7 @@ inline RegularExpression::RegularExpression() : regstart{} , reganch{} , regmust{} - , program{ 0 } + , program{ nullptr } , progsize{} { } @@ -423,7 +424,7 @@ inline RegularExpression::RegularExpression(const char* s) : regstart{} , reganch{} , regmust{} - , program{ 0 } + , program{ nullptr } , progsize{} { if (s) { @@ -439,7 +440,7 @@ inline RegularExpression::RegularExpression(const std::string& s) : regstart{} , reganch{} , regmust{} - , program{ 0 } + , program{ nullptr } , progsize{} { this->compile(s); @@ -545,7 +546,7 @@ inline bool RegularExpression::operator!=(const RegularExpression& r) const */ inline bool RegularExpression::is_valid() const { - return (this->program != 0); + return (this->program != nullptr); } inline void RegularExpression::set_invalid() @@ -553,7 +554,7 @@ inline void RegularExpression::set_invalid() //#ifndef _WIN32 delete[] this->program; //#endif - this->program = 0; + this->program = nullptr; } } // namespace @KWSYS_NAMESPACE@ diff --git a/SystemInformation.cxx b/SystemInformation.cxx index 7dc6cf4..6ec6e48 100644 --- a/SystemInformation.cxx +++ b/SystemInformation.cxx @@ -847,31 +847,16 @@ void SystemInformation::RunMemoryCheck() // SystemInformationImplementation starts here -#define STORE_TLBCACHE_INFO(x, y) x = (x < (y)) ? (y) : x -#define TLBCACHE_INFO_UNITS (15) -#define CLASSICAL_CPU_FREQ_LOOP 10000000 -#define RDTSC_INSTRUCTION _asm _emit 0x0f _asm _emit 0x31 - -// Status Flag -#define HT_NOT_CAPABLE 0 -#define HT_ENABLED 1 -#define HT_DISABLED 2 -#define HT_SUPPORTED_NOT_ENABLED 3 -#define HT_CANNOT_DETECT 4 - -// EDX[28] Bit 28 is set if HT is supported -#define HT_BIT 0x10000000 - -// EAX[11:8] Bit 8-11 contains family processor ID. -#define FAMILY_ID 0x0F00 -#define PENTIUM4_ID 0x0F00 -// EAX[23:20] Bit 20-23 contains extended family processor ID -#define EXT_FAMILY_ID 0x0F00000 -// EBX[23:16] Bit 16-23 in ebx contains the number of logical -#define NUM_LOGICAL_BITS 0x00FF0000 -// processors per physical processor when execute cpuid with -// eax set to 1 -// EBX[31:24] Bits 24-31 (8 bits) return the 8-bit unique +#if USE_CPUID +# define STORE_TLBCACHE_INFO(x, y) x = (x < (y)) ? (y) : x +# define TLBCACHE_INFO_UNITS (15) +#endif + +#if USE_ASM_INSTRUCTIONS +# define CLASSICAL_CPU_FREQ_LOOP 10000000 +# define RDTSC_INSTRUCTION _asm _emit 0x0f _asm _emit 0x31 +#endif + #define INITIAL_APIC_ID_BITS 0xFF000000 // initial APIC ID for the processor this code is running on. // Default value = 0xff if HT is not supported @@ -888,7 +873,7 @@ int LoadLines(FILE* file, std::vector& lines) char buf[bufSize] = { '\0' }; while (!feof(file) && !ferror(file)) { errno = 0; - if (fgets(buf, bufSize, file) == KWSYS_NULLPTR) { + if (fgets(buf, bufSize, file) == nullptr) { if (ferror(file) && (errno == EINTR)) { clearerr(file); } @@ -952,7 +937,7 @@ int GetFieldsFromFile(const char* fileName, const char** fieldNames, T* values) return -1; } int i = 0; - while (fieldNames[i] != NULL) { + while (fieldNames[i] != nullptr) { int ierr = NameValue(fields, fieldNames[i], values[i]); if (ierr) { return -(i + 2); @@ -966,7 +951,7 @@ int GetFieldsFromFile(const char* fileName, const char** fieldNames, T* values) template int GetFieldFromFile(const char* fileName, const char* fieldName, T& value) { - const char* fieldNames[2] = { fieldName, NULL }; + const char* fieldNames[2] = { fieldName, nullptr }; T values[1] = { T(0) }; int ierr = GetFieldsFromFile(fileName, fieldNames, values); if (ierr) { @@ -984,7 +969,7 @@ int GetFieldsFromCommand(const char* command, const char** fieldNames, T* values) { FILE* file = popen(command, "r"); - if (file == KWSYS_NULLPTR) { + if (file == nullptr) { return -1; } std::vector fields; @@ -994,7 +979,7 @@ int GetFieldsFromCommand(const char* command, const char** fieldNames, return -1; } int i = 0; - while (fieldNames[i] != KWSYS_NULLPTR) { + while (fieldNames[i] != nullptr) { int ierr = NameValue(fields, fieldNames[i], values[i]); if (ierr) { return -(i + 2); @@ -1030,8 +1015,7 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo, break; case SIGFPE: - oss << "Caught SIGFPE at " - << (sigInfo->si_addr == KWSYS_NULLPTR ? "0x" : "") + oss << "Caught SIGFPE at " << (sigInfo->si_addr == nullptr ? "0x" : "") << sigInfo->si_addr << " "; switch (sigInfo->si_code) { # if defined(FPE_INTDIV) @@ -1079,8 +1063,7 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo, break; case SIGSEGV: - oss << "Caught SIGSEGV at " - << (sigInfo->si_addr == KWSYS_NULLPTR ? "0x" : "") + oss << "Caught SIGSEGV at " << (sigInfo->si_addr == nullptr ? "0x" : "") << sigInfo->si_addr << " "; switch (sigInfo->si_code) { case SEGV_MAPERR: @@ -1098,8 +1081,7 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo, break; case SIGBUS: - oss << "Caught SIGBUS at " - << (sigInfo->si_addr == KWSYS_NULLPTR ? "0x" : "") + oss << "Caught SIGBUS at " << (sigInfo->si_addr == nullptr ? "0x" : "") << sigInfo->si_addr << " "; switch (sigInfo->si_code) { case BUS_ADRALN: @@ -1139,8 +1121,7 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo, break; case SIGILL: - oss << "Caught SIGILL at " - << (sigInfo->si_addr == KWSYS_NULLPTR ? "0x" : "") + oss << "Caught SIGILL at " << (sigInfo->si_addr == nullptr ? "0x" : "") << sigInfo->si_addr << " "; switch (sigInfo->si_code) { case ILL_ILLOPC: @@ -1324,8 +1305,8 @@ SymbolProperties::SymbolProperties() // not using an initializer list // to avoid some PGI compiler warnings this->SetBinary("???"); - this->SetBinaryBaseAddress(KWSYS_NULLPTR); - this->Address = KWSYS_NULLPTR; + this->SetBinaryBaseAddress(nullptr); + this->Address = nullptr; this->SetSourceFile("???"); this->SetFunction("???"); this->SetLineNumber(-1); @@ -1682,7 +1663,7 @@ int SystemInformationImplementation::GetFullyQualifiedDomainName( return -2; } - for (ifa = ifas; ifa != KWSYS_NULLPTR; ifa = ifa->ifa_next) { + for (ifa = ifas; ifa != nullptr; ifa = ifa->ifa_next) { int fam = ifa->ifa_addr ? ifa->ifa_addr->sa_family : -1; // Skip Loopback interfaces if (((fam == AF_INET) || (fam == AF_INET6)) && @@ -1693,7 +1674,7 @@ int SystemInformationImplementation::GetFullyQualifiedDomainName( : sizeof(struct sockaddr_in6)); ierr = getnameinfo(ifa->ifa_addr, static_cast(addrlen), host, - NI_MAXHOST, KWSYS_NULLPTR, 0, NI_NAMEREQD); + NI_MAXHOST, nullptr, 0, NI_NAMEREQD); if (ierr) { // don't report the failure now since we may succeed on another // interface. If all attempts fail then return the failure code. @@ -2577,7 +2558,7 @@ bool SystemInformationImplementation::RetrieveCPUClockSpeed() // If RDTSC is not supported, we fallback to trying to read this value // from the registry: if (!retrieved) { - HKEY hKey = NULL; + HKEY hKey = nullptr; LONG err = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", 0, @@ -2597,7 +2578,7 @@ bool SystemInformationImplementation::RetrieveCPUClockSpeed() } RegCloseKey(hKey); - hKey = NULL; + hKey = nullptr; } } #endif @@ -3628,7 +3609,7 @@ SystemInformationImplementation::GetHostMemoryTotal() #elif defined(__APPLE__) uint64_t mem; size_t len = sizeof(mem); - int ierr = sysctlbyname("hw.memsize", &mem, &len, KWSYS_NULLPTR, 0); + int ierr = sysctlbyname("hw.memsize", &mem, &len, nullptr, 0); if (ierr) { return -1; } @@ -3745,12 +3726,12 @@ SystemInformationImplementation::GetHostMemoryUsed() # endif #elif defined(__linux) // First try to use MemAvailable, but it only works on newer kernels - const char* names2[3] = { "MemTotal:", "MemAvailable:", NULL }; + const char* names2[3] = { "MemTotal:", "MemAvailable:", nullptr }; SystemInformation::LongLong values2[2] = { SystemInformation::LongLong(0) }; int ierr = GetFieldsFromFile("/proc/meminfo", names2, values2); if (ierr) { const char* names4[5] = { "MemTotal:", "MemFree:", "Buffers:", "Cached:", - NULL }; + nullptr }; SystemInformation::LongLong values4[4] = { SystemInformation::LongLong( 0) }; ierr = GetFieldsFromFile("/proc/meminfo", names4, values4); @@ -3771,8 +3752,7 @@ SystemInformationImplementation::GetHostMemoryUsed() if (psz < 1) { return -1; } - const char* names[3] = { "Pages wired down:", "Pages active:", - KWSYS_NULLPTR }; + const char* names[3] = { "Pages wired down:", "Pages active:", nullptr }; SystemInformation::LongLong values[2] = { SystemInformation::LongLong(0) }; int ierr = GetFieldsFromCommand("vm_stat", names, values); if (ierr) { @@ -3820,7 +3800,7 @@ SystemInformationImplementation::GetProcMemoryUsed() std::ostringstream oss; oss << "ps -o rss= -p " << pid; FILE* file = popen(oss.str().c_str(), "r"); - if (file == KWSYS_NULLPTR) { + if (file == nullptr) { return -1; } oss.str(""); @@ -3920,9 +3900,9 @@ std::string SystemInformationImplementation::GetProgramStack(int firstFrame, void* stack[TRACE_MAX_STACK_FRAMES]; HANDLE process = GetCurrentProcess(); - SymInitialize(process, NULL, TRUE); + SymInitialize(process, nullptr, TRUE); WORD numberOfFrames = - CaptureStackBackTrace(firstFrame, TRACE_MAX_STACK_FRAMES, stack, NULL); + CaptureStackBackTrace(firstFrame, TRACE_MAX_STACK_FRAMES, stack, nullptr); SYMBOL_INFO* symbol = static_cast( malloc(sizeof(SYMBOL_INFO) + (TRACE_MAX_FUNCTION_NAME_LENGTH - 1) * sizeof(TCHAR))); @@ -3933,7 +3913,7 @@ std::string SystemInformationImplementation::GetProgramStack(int firstFrame, line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); for (int i = 0; i < numberOfFrames; i++) { DWORD64 address = reinterpret_cast(stack[i]); - SymFromAddr(process, address, NULL, symbol); + SymFromAddr(process, address, nullptr, symbol); if (SymGetLineFromAddr64(process, address, &displacement, &line)) { oss << " at " << symbol->Name << " in " << line.FileName << " line " << line.LineNumber << std::endl; @@ -4000,13 +3980,13 @@ void SystemInformationImplementation::SetStackTraceOnError(int enable) if (enable && !saOrigValid) { // save the current actions - sigaction(SIGABRT, KWSYS_NULLPTR, &saABRTOrig); - sigaction(SIGSEGV, KWSYS_NULLPTR, &saSEGVOrig); - sigaction(SIGTERM, KWSYS_NULLPTR, &saTERMOrig); - sigaction(SIGINT, KWSYS_NULLPTR, &saINTOrig); - sigaction(SIGILL, KWSYS_NULLPTR, &saILLOrig); - sigaction(SIGBUS, KWSYS_NULLPTR, &saBUSOrig); - sigaction(SIGFPE, KWSYS_NULLPTR, &saFPEOrig); + sigaction(SIGABRT, nullptr, &saABRTOrig); + sigaction(SIGSEGV, nullptr, &saSEGVOrig); + sigaction(SIGTERM, nullptr, &saTERMOrig); + sigaction(SIGINT, nullptr, &saINTOrig); + sigaction(SIGILL, nullptr, &saILLOrig); + sigaction(SIGBUS, nullptr, &saBUSOrig); + sigaction(SIGFPE, nullptr, &saFPEOrig); // enable read, disable write saOrigValid = 1; @@ -4020,22 +4000,22 @@ void SystemInformationImplementation::SetStackTraceOnError(int enable) # endif sigemptyset(&sa.sa_mask); - sigaction(SIGABRT, &sa, KWSYS_NULLPTR); - sigaction(SIGSEGV, &sa, KWSYS_NULLPTR); - sigaction(SIGTERM, &sa, KWSYS_NULLPTR); - sigaction(SIGINT, &sa, KWSYS_NULLPTR); - sigaction(SIGILL, &sa, KWSYS_NULLPTR); - sigaction(SIGBUS, &sa, KWSYS_NULLPTR); - sigaction(SIGFPE, &sa, KWSYS_NULLPTR); + sigaction(SIGABRT, &sa, nullptr); + sigaction(SIGSEGV, &sa, nullptr); + sigaction(SIGTERM, &sa, nullptr); + sigaction(SIGINT, &sa, nullptr); + sigaction(SIGILL, &sa, nullptr); + sigaction(SIGBUS, &sa, nullptr); + sigaction(SIGFPE, &sa, nullptr); } else if (!enable && saOrigValid) { // restore previous actions - sigaction(SIGABRT, &saABRTOrig, KWSYS_NULLPTR); - sigaction(SIGSEGV, &saSEGVOrig, KWSYS_NULLPTR); - sigaction(SIGTERM, &saTERMOrig, KWSYS_NULLPTR); - sigaction(SIGINT, &saINTOrig, KWSYS_NULLPTR); - sigaction(SIGILL, &saILLOrig, KWSYS_NULLPTR); - sigaction(SIGBUS, &saBUSOrig, KWSYS_NULLPTR); - sigaction(SIGFPE, &saFPEOrig, KWSYS_NULLPTR); + sigaction(SIGABRT, &saABRTOrig, nullptr); + sigaction(SIGSEGV, &saSEGVOrig, nullptr); + sigaction(SIGTERM, &saTERMOrig, nullptr); + sigaction(SIGINT, &saINTOrig, nullptr); + sigaction(SIGILL, &saILLOrig, nullptr); + sigaction(SIGBUS, &saBUSOrig, nullptr); + sigaction(SIGFPE, &saFPEOrig, nullptr); // enable write, disable read saOrigValid = 0; @@ -4417,7 +4397,7 @@ void SystemInformationImplementation::CPUCountWindows() std::vector ProcInfo; { DWORD Length = 0; - DWORD rc = pGetLogicalProcessorInformation(NULL, &Length); + DWORD rc = pGetLogicalProcessorInformation(nullptr, &Length); assert(FALSE == rc); (void)rc; // Silence unused variable warning in Borland C++ 5.81 assert(GetLastError() == ERROR_INSUFFICIENT_BUFFER); @@ -4471,7 +4451,7 @@ bool SystemInformationImplementation::ParseSysCtl() int err = 0; uint64_t value = 0; size_t len = sizeof(value); - sysctlbyname("hw.memsize", &value, &len, KWSYS_NULLPTR, 0); + sysctlbyname("hw.memsize", &value, &len, nullptr, 0); this->TotalPhysicalMemory = static_cast(value / 1048576); // Parse values for Mac @@ -4481,7 +4461,7 @@ bool SystemInformationImplementation::ParseSysCtl() if (host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vmstat, &count) == KERN_SUCCESS) { len = sizeof(value); - err = sysctlbyname("hw.pagesize", &value, &len, KWSYS_NULLPTR, 0); + err = sysctlbyname("hw.pagesize", &value, &len, nullptr, 0); int64_t available_memory = (vmstat.free_count + vmstat.inactive_count) * value; this->AvailablePhysicalMemory = @@ -4491,10 +4471,11 @@ bool SystemInformationImplementation::ParseSysCtl() # ifdef VM_SWAPUSAGE // Virtual memory. int mib[2] = { CTL_VM, VM_SWAPUSAGE }; - size_t miblen = sizeof(mib) / sizeof(mib[0]); + unsigned int miblen = + static_cast(sizeof(mib) / sizeof(mib[0])); struct xsw_usage swap; len = sizeof(swap); - err = sysctl(mib, miblen, &swap, &len, KWSYS_NULLPTR, 0); + err = sysctl(mib, miblen, &swap, &len, nullptr, 0); if (err == 0) { this->AvailableVirtualMemory = static_cast(swap.xsu_avail / 1048576); @@ -4507,75 +4488,72 @@ bool SystemInformationImplementation::ParseSysCtl() // CPU Info len = sizeof(this->NumberOfPhysicalCPU); - sysctlbyname("hw.physicalcpu", &this->NumberOfPhysicalCPU, &len, - KWSYS_NULLPTR, 0); + sysctlbyname("hw.physicalcpu", &this->NumberOfPhysicalCPU, &len, nullptr, 0); len = sizeof(this->NumberOfLogicalCPU); - sysctlbyname("hw.logicalcpu", &this->NumberOfLogicalCPU, &len, KWSYS_NULLPTR, - 0); + sysctlbyname("hw.logicalcpu", &this->NumberOfLogicalCPU, &len, nullptr, 0); int cores_per_package = 0; len = sizeof(cores_per_package); err = sysctlbyname("machdep.cpu.cores_per_package", &cores_per_package, &len, - KWSYS_NULLPTR, 0); + nullptr, 0); // That name was not found, default to 1 this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical = err != 0 ? 1 : static_cast(cores_per_package); len = sizeof(value); - sysctlbyname("hw.cpufrequency", &value, &len, KWSYS_NULLPTR, 0); + sysctlbyname("hw.cpufrequency", &value, &len, nullptr, 0); this->CPUSpeedInMHz = static_cast(value) / 1000000; // Chip family len = sizeof(this->ChipID.Family); // Seems only the intel chips will have this name so if this fails it is // probably a PPC machine - err = sysctlbyname("machdep.cpu.family", &this->ChipID.Family, &len, - KWSYS_NULLPTR, 0); + err = + sysctlbyname("machdep.cpu.family", &this->ChipID.Family, &len, nullptr, 0); if (err != 0) // Go back to names we know but are less descriptive { this->ChipID.Family = 0; ::memset(retBuf, 0, 128); len = 32; - err = sysctlbyname("hw.machine", &retBuf, &len, KWSYS_NULLPTR, 0); + err = sysctlbyname("hw.machine", &retBuf, &len, nullptr, 0); std::string machineBuf(retBuf); if (machineBuf.find_first_of("Power") != std::string::npos) { this->ChipID.Vendor = "IBM"; len = sizeof(this->ChipID.Family); - err = sysctlbyname("hw.cputype", &this->ChipID.Family, &len, - KWSYS_NULLPTR, 0); + err = sysctlbyname("hw.cputype", &this->ChipID.Family, &len, nullptr, 0); len = sizeof(this->ChipID.Model); - err = sysctlbyname("hw.cpusubtype", &this->ChipID.Model, &len, - KWSYS_NULLPTR, 0); + err = + sysctlbyname("hw.cpusubtype", &this->ChipID.Model, &len, nullptr, 0); this->FindManufacturer(); } } else // Should be an Intel Chip. { len = sizeof(this->ChipID.Family); err = sysctlbyname("machdep.cpu.family", &this->ChipID.Family, &len, - KWSYS_NULLPTR, 0); + nullptr, 0); ::memset(retBuf, 0, 128); len = 128; - err = sysctlbyname("machdep.cpu.vendor", retBuf, &len, KWSYS_NULLPTR, 0); + err = sysctlbyname("machdep.cpu.vendor", retBuf, &len, nullptr, 0); // Chip Vendor this->ChipID.Vendor = retBuf; this->FindManufacturer(); // Chip Model len = sizeof(value); - err = sysctlbyname("machdep.cpu.model", &value, &len, KWSYS_NULLPTR, 0); + err = sysctlbyname("machdep.cpu.model", &value, &len, nullptr, 0); this->ChipID.Model = static_cast(value); // Chip Stepping len = sizeof(value); value = 0; - err = sysctlbyname("machdep.cpu.stepping", &value, &len, KWSYS_NULLPTR, 0); + err = sysctlbyname("machdep.cpu.stepping", &value, &len, nullptr, 0); if (!err) { this->ChipID.Revision = static_cast(value); } // feature string - char* buf = KWSYS_NULLPTR; + char* buf = nullptr; size_t allocSize = 128; err = 0; @@ -4592,8 +4570,7 @@ bool SystemInformationImplementation::ParseSysCtl() } buf[0] = ' '; len = allocSize - 2; // keep space for leading and trailing space - err = - sysctlbyname("machdep.cpu.features", buf + 1, &len, KWSYS_NULLPTR, 0); + err = sysctlbyname("machdep.cpu.features", buf + 1, &len, nullptr, 0); } if (!err && buf && len) { // now we can match every flags as space + flag + space @@ -4634,8 +4611,7 @@ bool SystemInformationImplementation::ParseSysCtl() // brand string ::memset(retBuf, 0, sizeof(retBuf)); len = sizeof(retBuf); - err = - sysctlbyname("machdep.cpu.brand_string", retBuf, &len, KWSYS_NULLPTR, 0); + err = sysctlbyname("machdep.cpu.brand_string", retBuf, &len, nullptr, 0); if (!err) { this->ChipID.ProcessorName = retBuf; this->ChipID.ModelName = retBuf; @@ -4643,10 +4619,10 @@ bool SystemInformationImplementation::ParseSysCtl() // Cache size len = sizeof(value); - err = sysctlbyname("hw.l1icachesize", &value, &len, KWSYS_NULLPTR, 0); + err = sysctlbyname("hw.l1icachesize", &value, &len, nullptr, 0); this->Features.L1CacheSize = static_cast(value); len = sizeof(value); - err = sysctlbyname("hw.l2cachesize", &value, &len, KWSYS_NULLPTR, 0); + err = sysctlbyname("hw.l2cachesize", &value, &len, nullptr, 0); this->Features.L2CacheSize = static_cast(value); return true; @@ -4683,7 +4659,7 @@ std::string SystemInformationImplementation::RunProcess( kwsysProcess_Execute(gp); - char* data = KWSYS_NULLPTR; + char* data = nullptr; int length; double timeout = 255; int pipe; // pipe id as returned by kwsysProcess_WaitForData() @@ -4695,7 +4671,7 @@ std::string SystemInformationImplementation::RunProcess( { buffer.append(data, length); } - kwsysProcess_WaitForExit(gp, KWSYS_NULLPTR); + kwsysProcess_WaitForExit(gp, nullptr); int result = 0; switch (kwsysProcess_GetState(gp)) { @@ -4766,7 +4742,7 @@ std::string SystemInformationImplementation::ParseValueFromKStat( for (size_t i = 0; i < args_string.size(); ++i) { args.push_back(args_string[i].c_str()); } - args.push_back(KWSYS_NULLPTR); + args.push_back(nullptr); std::string buffer = this->RunProcess(args); @@ -4965,7 +4941,7 @@ bool SystemInformationImplementation::QueryBSDMemory() # endif size_t sz = sizeof(k); - if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) { + if (sysctl(ctrl, 2, &k, &sz, nullptr, 0) != 0) { return false; } @@ -5036,7 +5012,7 @@ bool SystemInformationImplementation::QueryBSDProcessor() size_t sz = sizeof(k); int ctrl[2] = { CTL_HW, HW_NCPU }; - if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) { + if (sysctl(ctrl, 2, &k, &sz, nullptr, 0) != 0) { return false; } @@ -5046,7 +5022,7 @@ bool SystemInformationImplementation::QueryBSDProcessor() # if defined(HW_CPUSPEED) ctrl[1] = HW_CPUSPEED; - if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) { + if (sysctl(ctrl, 2, &k, &sz, nullptr, 0) != 0) { return false; } @@ -5057,7 +5033,7 @@ bool SystemInformationImplementation::QueryBSDProcessor() ctrl[0] = CTL_MACHDEP; ctrl[1] = CPU_SSE; - if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) { + if (sysctl(ctrl, 2, &k, &sz, nullptr, 0) != 0) { return false; } @@ -5068,7 +5044,7 @@ bool SystemInformationImplementation::QueryBSDProcessor() ctrl[0] = CTL_MACHDEP; ctrl[1] = CPU_SSE2; - if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) { + if (sysctl(ctrl, 2, &k, &sz, nullptr, 0) != 0) { return false; } @@ -5081,7 +5057,7 @@ bool SystemInformationImplementation::QueryBSDProcessor() char vbuf[25]; ::memset(vbuf, 0, sizeof(vbuf)); sz = sizeof(vbuf) - 1; - if (sysctl(ctrl, 2, vbuf, &sz, NULL, 0) != 0) { + if (sysctl(ctrl, 2, vbuf, &sz, nullptr, 0) != 0) { return false; } @@ -5293,7 +5269,7 @@ bool SystemInformationImplementation::QueryOSInformation() RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\ProductOptions", 0, KEY_QUERY_VALUE, &hKey); - RegQueryValueExW(hKey, L"ProductType", NULL, NULL, + RegQueryValueExW(hKey, L"ProductType", nullptr, nullptr, (LPBYTE)szProductType, &dwBufLen); RegCloseKey(hKey); @@ -5335,13 +5311,13 @@ bool SystemInformationImplementation::QueryOSInformation() // Load the Kernel32 DLL. hKernelDLL = LoadLibraryW(L"kernel32"); - if (hKernelDLL != NULL) { + if (hKernelDLL != nullptr) { // Only XP and .NET Server support IsWOW64Process so... Load // dynamically! DLLProc = (LPFNPROC)GetProcAddress(hKernelDLL, "IsWow64Process"); // If the function address is valid, call the function. - if (DLLProc != NULL) + if (DLLProc != nullptr) (DLLProc)(GetCurrentProcess(), &bIsWindows64Bit); else bIsWindows64Bit = false; @@ -5456,7 +5432,7 @@ int SystemInformationImplementation::CallSwVers(const char* arg, std::vector args; args.push_back("sw_vers"); args.push_back(arg); - args.push_back(KWSYS_NULLPTR); + args.push_back(nullptr); ver = this->RunProcess(args); this->TrimNewline(ver); #else diff --git a/SystemInformation.hxx.in b/SystemInformation.hxx.in index 5e93878..fc42e9d 100644 --- a/SystemInformation.hxx.in +++ b/SystemInformation.hxx.in @@ -115,8 +115,8 @@ public: // returns an informative general description if the installed and // available ram on this system. See the GetHostMemoryTotal, and // Get{Host,Proc}MemoryAvailable methods for more information. - std::string GetMemoryDescription(const char* hostLimitEnvVarName = NULL, - const char* procLimitEnvVarName = NULL); + std::string GetMemoryDescription(const char* hostLimitEnvVarName = nullptr, + const char* procLimitEnvVarName = nullptr); // Retrieve amount of physical memory installed on the system in KiB // units. @@ -128,7 +128,7 @@ public: // parallel. The amount of memory reported may differ from the host // total if a host wide resource limit is applied. Such reource limits // are reported to us via an application specified environment variable. - LongLong GetHostMemoryAvailable(const char* hostLimitEnvVarName = NULL); + LongLong GetHostMemoryAvailable(const char* hostLimitEnvVarName = nullptr); // Get total system RAM in units of KiB available to this process. // This may differ from the host available if a per-process resource @@ -136,8 +136,8 @@ public: // system via rlimit API. Resource limits that are not imposed via // rlimit API may be reported to us via an application specified // environment variable. - LongLong GetProcMemoryAvailable(const char* hostLimitEnvVarName = NULL, - const char* procLimitEnvVarName = NULL); + LongLong GetProcMemoryAvailable(const char* hostLimitEnvVarName = nullptr, + const char* procLimitEnvVarName = nullptr); // Get the system RAM used by all processes on the host, in units of KiB. LongLong GetHostMemoryUsed(); diff --git a/SystemTools.cxx b/SystemTools.cxx index 8571477..ce4d6ef 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -192,15 +192,15 @@ static inline char* realpath(const char* path, char* resolved_path) { const size_t maxlen = KWSYS_SYSTEMTOOLS_MAXPATH; snprintf(resolved_path, maxlen, "%s", path); - BPath normalized(resolved_path, NULL, true); + BPath normalized(resolved_path, nullptr, true); const char* resolved = normalized.Path(); - if (resolved != NULL) // NULL == No such file. + if (resolved != nullptr) // nullptr == No such file. { if (snprintf(resolved_path, maxlen, "%s", resolved) < maxlen) { return resolved_path; } } - return NULL; // something went wrong. + return nullptr; // something went wrong. } #endif @@ -273,12 +273,12 @@ inline void Realpath(const std::string& path, std::string& resolved_path, if (bufferLen) { *errorMessage = "Destination path buffer size too small."; } else if (unsigned int errorId = GetLastError()) { - LPSTR message = NULL; + LPSTR message = nullptr; DWORD size = FormatMessageA( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, errorId, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPSTR)&message, 0, NULL); + nullptr, errorId, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPSTR)&message, 0, nullptr); *errorMessage = std::string(message, size); LocalFree(message); } else { @@ -313,7 +313,7 @@ inline int Chdir(const std::string& dir) return chdir(dir.c_str()); } inline void Realpath(const std::string& path, std::string& resolved_path, - std::string* errorMessage = KWSYS_NULLPTR) + std::string* errorMessage = nullptr) { char resolved_name[KWSYS_SYSTEMTOOLS_MAXPATH]; @@ -359,7 +359,7 @@ double SystemTools::GetTime(void) 11644473600.0); #else struct timeval t; - gettimeofday(&t, KWSYS_NULLPTR); + gettimeofday(&t, nullptr); return 1.0 * double(t.tv_sec) + 0.000001 * double(t.tv_usec); #endif } @@ -389,8 +389,8 @@ struct kwsysEnvCompare #else const char* leq = strchr(l, '='); const char* req = strchr(r, '='); - size_t llen = leq ? (leq - l) : strlen(l); - size_t rlen = req ? (req - r) : strlen(r); + size_t llen = leq ? static_cast(leq - l) : strlen(l); + size_t rlen = req ? static_cast(req - r) : strlen(r); if (llen == rlen) { return strncmp(l, r, llen) < 0; } else { @@ -420,7 +420,7 @@ public: const envchar* Release(const envchar* env) { - const envchar* old = KWSYS_NULLPTR; + const envchar* old = nullptr; iterator i = this->find(env); if (i != this->end()) { old = *i; @@ -630,7 +630,7 @@ const char* SystemToolsStatic::GetEnvBuffered(const char* key) } return menv.c_str(); } - return KWSYS_NULLPTR; + return nullptr; } #endif @@ -684,7 +684,7 @@ bool SystemTools::HasEnv(const char* key) #else const char* v = getenv(key); #endif - return v != KWSYS_NULLPTR; + return v != nullptr; } bool SystemTools::HasEnv(const std::string& key) @@ -915,7 +915,7 @@ bool SystemTools::MakeDirectory(const std::string& path, const mode_t* mode) while ((pos = dir.find('/', pos)) != std::string::npos) { topdir = dir.substr(0, pos); - if (Mkdir(topdir) == 0 && mode != KWSYS_NULLPTR) { + if (Mkdir(topdir) == 0 && mode != nullptr) { SystemTools::SetPermissions(topdir, *mode); } @@ -934,7 +934,7 @@ bool SystemTools::MakeDirectory(const std::string& path, const mode_t* mode) ) { return false; } - } else if (mode != KWSYS_NULLPTR) { + } else if (mode != nullptr) { SystemTools::SetPermissions(topdir, *mode); } @@ -1055,7 +1055,7 @@ static DWORD SystemToolsMakeRegistryMode(DWORD mode, // only add the modes when on a system that supports Wow64. static FARPROC wow64p = GetProcAddress(GetModuleHandleW(L"kernel32"), "IsWow64Process"); - if (wow64p == NULL) { + if (wow64p == nullptr) { return mode; } @@ -1136,7 +1136,7 @@ bool SystemTools::ReadRegistryValue(const std::string& key, std::string& value, DWORD dwType, dwSize; dwSize = 1023; wchar_t data[1024]; - if (RegQueryValueExW(hKey, Encoding::ToWide(valuename).c_str(), NULL, + if (RegQueryValueExW(hKey, Encoding::ToWide(valuename).c_str(), nullptr, &dwType, (BYTE*)data, &dwSize) == ERROR_SUCCESS) { if (dwType == REG_SZ) { value = Encoding::ToNarrow(data); @@ -1186,7 +1186,7 @@ bool SystemTools::WriteRegistryValue(const std::string& key, wchar_t lpClass[] = L""; if (RegCreateKeyExW(primaryKey, Encoding::ToWide(second).c_str(), 0, lpClass, REG_OPTION_NON_VOLATILE, - SystemToolsMakeRegistryMode(KEY_WRITE, view), NULL, + SystemToolsMakeRegistryMode(KEY_WRITE, view), nullptr, &hKey, &dwDummy) != ERROR_SUCCESS) { return false; } @@ -1252,10 +1252,10 @@ bool SystemTools::SameFile(const std::string& file1, const std::string& file2) hFile1 = CreateFileW(Encoding::ToWide(file1).c_str(), GENERIC_READ, FILE_SHARE_READ, - NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr); hFile2 = CreateFileW(Encoding::ToWide(file2).c_str(), GENERIC_READ, FILE_SHARE_READ, - NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr); if (hFile1 == INVALID_HANDLE_VALUE || hFile2 == INVALID_HANDLE_VALUE) { if (hFile1 != INVALID_HANDLE_VALUE) { CloseHandle(hFile1); @@ -1347,7 +1347,7 @@ bool SystemTools::FileExists(const std::string& filename) // even if we do not have permission to read the file itself HANDLE handle = CreateFileW(Encoding::ToWindowsExtendedPath(filename).c_str(), 0, 0, - NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr); if (handle == INVALID_HANDLE_VALUE) { return false; @@ -1493,12 +1493,12 @@ bool SystemTools::Touch(const std::string& filename, bool create) CloseHandle(h); #elif KWSYS_CXX_HAS_UTIMENSAT // utimensat is only available on newer Unixes and macOS 10.13+ - if (utimensat(AT_FDCWD, filename.c_str(), NULL, 0) < 0) { + if (utimensat(AT_FDCWD, filename.c_str(), nullptr, 0) < 0) { return false; } #else // fall back to utimes - if (utimes(filename.c_str(), NULL) < 0) { + if (utimes(filename.c_str(), nullptr) < 0) { return false; } #endif @@ -1653,7 +1653,7 @@ char* SystemTools::AppendStrings(const char* str1, const char* str2) size_t len1 = strlen(str1); char* newstr = new char[len1 + strlen(str2) + 1]; if (!newstr) { - return KWSYS_NULLPTR; + return nullptr; } strcpy(newstr, str1); strcat(newstr + len1, str2); @@ -1676,7 +1676,7 @@ char* SystemTools::AppendStrings(const char* str1, const char* str2, size_t len1 = strlen(str1), len2 = strlen(str2); char* newstr = new char[len1 + len2 + strlen(str3) + 1]; if (!newstr) { - return KWSYS_NULLPTR; + return nullptr; } strcpy(newstr, str1); strcat(newstr + len1, str2); @@ -1726,7 +1726,7 @@ size_t SystemTools::CountChar(const char* str, char c) char* SystemTools::RemoveChars(const char* str, const char* toremove) { if (!str) { - return KWSYS_NULLPTR; + return nullptr; } char* clean_str = new char[strlen(str) + 1]; char* ptr = clean_str; @@ -1748,7 +1748,7 @@ char* SystemTools::RemoveChars(const char* str, const char* toremove) char* SystemTools::RemoveCharsButUpperHex(const char* str) { if (!str) { - return KWSYS_NULLPTR; + return nullptr; } char* clean_str = new char[strlen(str) + 1]; char* ptr = clean_str; @@ -1829,7 +1829,7 @@ bool SystemTools::StringEndsWith(const std::string& str1, const char* str2) const char* SystemTools::FindLastString(const char* str1, const char* str2) { if (!str1 || !str2) { - return KWSYS_NULLPTR; + return nullptr; } size_t len1 = strlen(str1), len2 = strlen(str2); @@ -1842,7 +1842,7 @@ const char* SystemTools::FindLastString(const char* str1, const char* str2) } while (ptr-- != str1); } - return KWSYS_NULLPTR; + return nullptr; } // Duplicate string @@ -1852,7 +1852,7 @@ char* SystemTools::DuplicateString(const char* str) char* newstr = new char[strlen(str) + 1]; return strcpy(newstr, str); } - return KWSYS_NULLPTR; + return nullptr; } // Return a cropped string @@ -3018,16 +3018,16 @@ bool SystemTools::FileIsSymlink(const std::string& name) // * a file or directory that has an associated reparse point, or // * a file that is a symbolic link. HANDLE hFile = CreateFileW( - path.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, - FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL); + path.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, + FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, nullptr); if (hFile == INVALID_HANDLE_VALUE) { return false; } byte buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; DWORD bytesReturned = 0; - if (!DeviceIoControl(hFile, FSCTL_GET_REPARSE_POINT, NULL, 0, buffer, + if (!DeviceIoControl(hFile, FSCTL_GET_REPARSE_POINT, nullptr, 0, buffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &bytesReturned, - NULL)) { + nullptr)) { CloseHandle(hFile); // Since FILE_ATTRIBUTE_REPARSE_POINT is set this file must be // a symbolic link if it is not a reparse point. @@ -3058,7 +3058,7 @@ bool SystemTools::FileIsFIFO(const std::string& name) #if defined(_WIN32) HANDLE hFile = CreateFileW(Encoding::ToWide(name).c_str(), GENERIC_READ, FILE_SHARE_READ, - NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr); if (hFile == INVALID_HANDLE_VALUE) { return false; } @@ -3219,7 +3219,7 @@ bool SystemTools::FindProgramPath(const char* argv0, std::string& pathOut, std::string SystemTools::CollapseFullPath(const std::string& in_relative) { - return SystemTools::CollapseFullPath(in_relative, KWSYS_NULLPTR); + return SystemTools::CollapseFullPath(in_relative, nullptr); } #if KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP @@ -4013,7 +4013,7 @@ bool SystemTools::GetShortPath(const std::string& path, std::string& shortPath) } std::wstring wtempPath = Encoding::ToWide(tempPath); - DWORD ret = GetShortPathNameW(wtempPath.c_str(), NULL, 0); + DWORD ret = GetShortPathNameW(wtempPath.c_str(), nullptr, 0); std::vector buffer(ret); if (ret != 0) { ret = GetShortPathNameW(wtempPath.c_str(), &buffer[0], @@ -4421,7 +4421,7 @@ std::string SystemTools::GetOperatingSystemNameAndVersion() return 0; } - lRet = RegQueryValueExW(hKey, L"ProductType", NULL, NULL, + lRet = RegQueryValueExW(hKey, L"ProductType", nullptr, nullptr, (LPBYTE)szProductType, &dwBufLen); if ((lRet != ERROR_SUCCESS) || (dwBufLen > BUFSIZE)) { diff --git a/SystemTools.hxx.in b/SystemTools.hxx.in index dd1266b..c4ab9d4 100644 --- a/SystemTools.hxx.in +++ b/SystemTools.hxx.in @@ -400,9 +400,10 @@ public: * installPrefix is a possibly null pointer to the install directory. */ static bool FindProgramPath(const char* argv0, std::string& pathOut, - std::string& errorMsg, const char* exeName = 0, - const char* buildDir = 0, - const char* installPrefix = 0); + std::string& errorMsg, + const char* exeName = nullptr, + const char* buildDir = nullptr, + const char* installPrefix = nullptr); /** * Given a path to a file or directory, convert it to a full path. @@ -420,11 +421,11 @@ public: * Get the real path for a given path, removing all symlinks. In * the event of an error (non-existent path, permissions issue, * etc.) the original path is returned if errorMessage pointer is - * NULL. Otherwise empty string is returned and errorMessage + * nullptr. Otherwise empty string is returned and errorMessage * contains error description. */ static std::string GetRealPath(const std::string& path, - std::string* errorMessage = 0); + std::string* errorMessage = nullptr); /** * Split a path name into its root component and the rest of the @@ -442,7 +443,7 @@ public: * given. */ static const char* SplitPathRootComponent(const std::string& p, - std::string* root = 0); + std::string* root = nullptr); /** * Split a path name into its basic components. The first component @@ -528,7 +529,8 @@ public: * be true when the line read had a newline character. */ static bool GetLineFromStream(std::istream& istr, std::string& line, - bool* has_newline = 0, long sizeLimit = -1); + bool* has_newline = nullptr, + long sizeLimit = -1); /** * Get the parent directory of the directory or file @@ -563,8 +565,9 @@ public: * can make a full path even if none of the directories existed * prior to calling this function. */ - static bool MakeDirectory(const char* path, const mode_t* mode = 0); - static bool MakeDirectory(const std::string& path, const mode_t* mode = 0); + static bool MakeDirectory(const char* path, const mode_t* mode = nullptr); + static bool MakeDirectory(const std::string& path, + const mode_t* mode = nullptr); /** * Copy the source file to the destination file only @@ -842,7 +845,8 @@ public: * string vector passed in. If env is set then the value * of env will be used instead of PATH. */ - static void GetPath(std::vector& path, const char* env = 0); + static void GetPath(std::vector& path, + const char* env = nullptr); /** * Read an environment variable diff --git a/hashtable.hxx.in b/hashtable.hxx.in index 0981c66..8c4b002 100644 --- a/hashtable.hxx.in +++ b/hashtable.hxx.in @@ -354,7 +354,7 @@ public: return end(); } - iterator end() { return iterator(0, this); } + iterator end() { return iterator(nullptr, this); } const_iterator begin() const { @@ -364,7 +364,7 @@ public: return end(); } - const_iterator end() const { return const_iterator(0, this); } + const_iterator end() const { return const_iterator(nullptr, this); } friend bool operator==<>(const hashtable&, const hashtable&); @@ -510,7 +510,7 @@ private: { const size_type __n_buckets = _M_next_size(__n); _M_buckets.reserve(__n_buckets); - _M_buckets.insert(_M_buckets.end(), __n_buckets, (_Node*)0); + _M_buckets.insert(_M_buckets.end(), __n_buckets, (_Node*)nullptr); _M_num_elements = 0; } @@ -544,7 +544,7 @@ private: _Node* _M_new_node(const value_type& __obj) { _Node* __n = _M_get_node(); - __n->_M_next = 0; + __n->_M_next = nullptr; try { construct(&__n->_M_val, __obj); return __n; @@ -839,9 +839,9 @@ void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::erase(iterator __first, else if (__f_bucket == __l_bucket) _M_erase_bucket(__f_bucket, __first._M_cur, __last._M_cur); else { - _M_erase_bucket(__f_bucket, __first._M_cur, 0); + _M_erase_bucket(__f_bucket, __first._M_cur, nullptr); for (size_type __n = __f_bucket + 1; __n < __l_bucket; ++__n) - _M_erase_bucket(__n, 0); + _M_erase_bucket(__n, nullptr); if (__l_bucket != _M_buckets.size()) _M_erase_bucket(__l_bucket, __last._M_cur); } @@ -873,7 +873,8 @@ void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::resize( if (__num_elements_hint > __old_n) { const size_type __n = _M_next_size(__num_elements_hint); if (__n > __old_n) { - _M_buckets_type __tmp(__n, (_Node*)(0), _M_buckets.get_allocator()); + _M_buckets_type __tmp(__n, (_Node*)(nullptr), + _M_buckets.get_allocator()); try { for (size_type __bucket = 0; __bucket < __old_n; ++__bucket) { _Node* __first = _M_buckets[__bucket]; @@ -940,12 +941,12 @@ void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::clear() { for (size_type __i = 0; __i < _M_buckets.size(); ++__i) { _Node* __cur = _M_buckets[__i]; - while (__cur != 0) { + while (__cur != nullptr) { _Node* __next = __cur->_M_next; _M_delete_node(__cur); __cur = __next; } - _M_buckets[__i] = 0; + _M_buckets[__i] = nullptr; } _M_num_elements = 0; } @@ -956,7 +957,7 @@ void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::_M_copy_from( { _M_buckets.clear(); _M_buckets.reserve(__ht._M_buckets.size()); - _M_buckets.insert(_M_buckets.end(), __ht._M_buckets.size(), (_Node*)0); + _M_buckets.insert(_M_buckets.end(), __ht._M_buckets.size(), (_Node*)nullptr); try { for (size_type __i = 0; __i < __ht._M_buckets.size(); ++__i) { const _Node* __cur = __ht._M_buckets[__i]; diff --git a/testCommandLineArguments.cxx b/testCommandLineArguments.cxx index 15f9c02..1778a9b 100644 --- a/testCommandLineArguments.cxx +++ b/testCommandLineArguments.cxx @@ -76,7 +76,7 @@ int testCommandLineArguments(int argc, char* argv[]) int some_int_variable = 10; double some_double_variable = 10.10; - char* some_string_variable = KWSYS_NULLPTR; + char* some_string_variable = nullptr; std::string some_stl_string_variable; bool some_bool_variable = false; bool some_bool_variable1 = false; @@ -203,7 +203,7 @@ int testCommandLineArguments(int argc, char* argv[]) for (cc = 0; cc < strings_argument.size(); ++cc) { delete[] strings_argument[cc]; - strings_argument[cc] = KWSYS_NULLPTR; + strings_argument[cc] = nullptr; } return res; } diff --git a/testCommandLineArguments1.cxx b/testCommandLineArguments1.cxx index 9895008..64561b1 100644 --- a/testCommandLineArguments1.cxx +++ b/testCommandLineArguments1.cxx @@ -21,7 +21,7 @@ int testCommandLineArguments1(int argc, char* argv[]) arg.Initialize(argc, argv); int n = 0; - char* m = KWSYS_NULLPTR; + char* m = nullptr; std::string p; int res = 0; @@ -55,11 +55,11 @@ int testCommandLineArguments1(int argc, char* argv[]) delete[] m; } - char** newArgv = KWSYS_NULLPTR; + char** newArgv = nullptr; int newArgc = 0; arg.GetUnusedArguments(&newArgc, &newArgv); int cc; - const char* valid_unused_args[9] = { KWSYS_NULLPTR, + const char* valid_unused_args[9] = { nullptr, "--ignored", "--second-ignored", "third-ignored", diff --git a/testConsoleBuf.cxx b/testConsoleBuf.cxx index b6ad118..4b7ddf0 100644 --- a/testConsoleBuf.cxx +++ b/testConsoleBuf.cxx @@ -51,7 +51,7 @@ static void displayError(DWORD errorCode) LPWSTR message; if (FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, errorCode, 0, (LPWSTR)&message, 0, NULL)) { + nullptr, errorCode, 0, (LPWSTR)&message, 0, nullptr)) { std::cerr << "Error message: " << kwsys::Encoding::ToNarrow(message) << std::endl; HeapFree(GetProcessHeap(), 0, message); @@ -124,7 +124,7 @@ static bool createProcess(HANDLE hIn, HANDLE hOut, HANDLE hErr) } WCHAR cmd[MAX_PATH]; - if (GetModuleFileNameW(NULL, cmd, MAX_PATH) == 0) { + if (GetModuleFileNameW(nullptr, cmd, MAX_PATH) == 0) { std::cerr << "GetModuleFileName failed!" << std::endl; return false; } @@ -136,14 +136,14 @@ static bool createProcess(HANDLE hIn, HANDLE hOut, HANDLE hErr) wcscat(cmd, L".exe"); bool success = - CreateProcessW(NULL, // No module name (use command line) + CreateProcessW(nullptr, // No module name (use command line) cmd, // Command line - NULL, // Process handle not inheritable - NULL, // Thread handle not inheritable + nullptr, // Process handle not inheritable + nullptr, // Thread handle not inheritable bInheritHandles, // Set handle inheritance dwCreationFlags, - NULL, // Use parent's environment block - NULL, // Use parent's starting directory + nullptr, // Use parent's environment block + nullptr, // Use parent's starting directory &startupInfo, // Pointer to STARTUPINFO structure &processInfo) != 0; // Pointer to PROCESS_INFORMATION structure @@ -174,7 +174,7 @@ static bool createPipe(PHANDLE readPipe, PHANDLE writePipe) SECURITY_ATTRIBUTES securityAttributes; securityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES); securityAttributes.bInheritHandle = TRUE; - securityAttributes.lpSecurityDescriptor = NULL; + securityAttributes.lpSecurityDescriptor = nullptr; return CreatePipe(readPipe, writePipe, &securityAttributes, 0) == 0 ? false : true; } @@ -194,7 +194,7 @@ static HANDLE createFile(LPCWSTR fileName) SECURITY_ATTRIBUTES securityAttributes; securityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES); securityAttributes.bInheritHandle = TRUE; - securityAttributes.lpSecurityDescriptor = NULL; + securityAttributes.lpSecurityDescriptor = nullptr; HANDLE file = CreateFileW(fileName, GENERIC_READ | GENERIC_WRITE, @@ -202,7 +202,7 @@ static HANDLE createFile(LPCWSTR fileName) &securityAttributes, CREATE_ALWAYS, // overwrite existing FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE, - NULL); // no template + nullptr); // no template if (file == INVALID_HANDLE_VALUE) { DWORD lastError = GetLastError(); std::cerr << "CreateFile(" << kwsys::Encoding::ToNarrow(fileName) << ")" @@ -288,7 +288,7 @@ static int testPipe() DWORD bytesWritten = 0; if (!WriteFile(inPipeWrite, encodedInputTestString.c_str(), (DWORD)encodedInputTestString.size(), &bytesWritten, - NULL) || + nullptr) || bytesWritten == 0) { throw std::runtime_error("WriteFile failed!"); } @@ -305,7 +305,8 @@ static int testPipe() throw std::runtime_error("WaitForSingleObject failed!"); } DWORD bytesRead = 0; - if (!ReadFile(outPipeRead, buffer, sizeof(buffer), &bytesRead, NULL) || + if (!ReadFile(outPipeRead, buffer, sizeof(buffer), &bytesRead, + nullptr) || bytesRead == 0) { throw std::runtime_error("ReadFile#1 failed!"); } @@ -313,7 +314,7 @@ static int testPipe() if ((bytesRead < encodedTestString.size() + 1 + encodedInputTestString.size() && !ReadFile(outPipeRead, buffer + bytesRead, - sizeof(buffer) - bytesRead, &bytesRead, NULL)) || + sizeof(buffer) - bytesRead, &bytesRead, nullptr)) || bytesRead == 0) { throw std::runtime_error("ReadFile#2 failed!"); } @@ -324,7 +325,7 @@ static int testPipe() encodedInputTestString.size()) == 0) { bytesRead = 0; if (!ReadFile(errPipeRead, buffer2, sizeof(buffer2), &bytesRead, - NULL) || + nullptr) || bytesRead == 0) { throw std::runtime_error("ReadFile#3 failed!"); } @@ -383,13 +384,13 @@ static int testFile() char buffer2[200]; int length; - if ((length = - WideCharToMultiByte(TestCodepage, 0, UnicodeInputTestString, -1, - buffer, sizeof(buffer), NULL, NULL)) == 0) { + if ((length = WideCharToMultiByte(TestCodepage, 0, UnicodeInputTestString, + -1, buffer, sizeof(buffer), nullptr, + nullptr)) == 0) { throw std::runtime_error("WideCharToMultiByte failed!"); } buffer[length - 1] = '\n'; - if (!WriteFile(inFile, buffer, length, &bytesWritten, NULL) || + if (!WriteFile(inFile, buffer, length, &bytesWritten, nullptr) || bytesWritten == 0) { throw std::runtime_error("WriteFile failed!"); } @@ -413,7 +414,7 @@ static int testFile() INVALID_SET_FILE_POINTER) { throw std::runtime_error("SetFilePointer#1 failed!"); } - if (!ReadFile(outFile, buffer, sizeof(buffer), &bytesRead, NULL) || + if (!ReadFile(outFile, buffer, sizeof(buffer), &bytesRead, nullptr) || bytesRead == 0) { throw std::runtime_error("ReadFile#1 failed!"); } @@ -429,7 +430,8 @@ static int testFile() throw std::runtime_error("SetFilePointer#2 failed!"); } - if (!ReadFile(errFile, buffer2, sizeof(buffer2), &bytesRead, NULL) || + if (!ReadFile(errFile, buffer2, sizeof(buffer2), &bytesRead, + nullptr) || bytesRead == 0) { throw std::runtime_error("ReadFile#2 failed!"); } @@ -519,12 +521,12 @@ static int testConsole() if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Console", 0, KEY_READ | KEY_WRITE, &hConsoleKey) == ERROR_SUCCESS) { DWORD dwordSize = sizeof(DWORD); - if (RegQueryValueExW(hConsoleKey, L"FontFamily", NULL, NULL, + if (RegQueryValueExW(hConsoleKey, L"FontFamily", nullptr, nullptr, (LPBYTE)&FontFamily, &dwordSize) == ERROR_SUCCESS) { if (FontFamily != TestFontFamily) { - RegQueryValueExW(hConsoleKey, L"FaceName", NULL, NULL, + RegQueryValueExW(hConsoleKey, L"FaceName", nullptr, nullptr, (LPBYTE)FaceName, &FaceNameSize); - RegQueryValueExW(hConsoleKey, L"FontSize", NULL, NULL, + RegQueryValueExW(hConsoleKey, L"FontSize", nullptr, nullptr, (LPBYTE)&FontSize, &dwordSize); RegSetValueExW(hConsoleKey, L"FontFamily", 0, REG_DWORD, @@ -557,10 +559,10 @@ static int testConsole() SECURITY_ATTRIBUTES securityAttributes; securityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES); securityAttributes.bInheritHandle = TRUE; - securityAttributes.lpSecurityDescriptor = NULL; + securityAttributes.lpSecurityDescriptor = nullptr; hIn = CreateFileW(L"CONIN$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, &securityAttributes, - OPEN_EXISTING, 0, NULL); + OPEN_EXISTING, 0, nullptr); if (hIn == INVALID_HANDLE_VALUE) { DWORD lastError = GetLastError(); std::cerr << "CreateFile(CONIN$)" << std::endl; @@ -568,7 +570,7 @@ static int testConsole() } hOut = CreateFileW(L"CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, &securityAttributes, - OPEN_EXISTING, 0, NULL); + OPEN_EXISTING, 0, nullptr); if (hOut == INVALID_HANDLE_VALUE) { DWORD lastError = GetLastError(); std::cerr << "CreateFile(CONOUT$)" << std::endl; @@ -630,7 +632,7 @@ static int testConsole() } # endif - if (createProcess(NULL, NULL, NULL)) { + if (createProcess(nullptr, nullptr, nullptr)) { try { DWORD status; if ((status = WaitForSingleObject(beforeInputEvent, waitTimeout)) != @@ -746,7 +748,7 @@ int testConsoleBuf(int, char* []) int ret = 0; #if defined(_WIN32) - beforeInputEvent = CreateEventW(NULL, + beforeInputEvent = CreateEventW(nullptr, FALSE, // auto-reset event FALSE, // initial state is nonsignaled BeforeInputEventName); // object name @@ -755,7 +757,7 @@ int testConsoleBuf(int, char* []) return 1; } - afterOutputEvent = CreateEventW(NULL, FALSE, FALSE, AfterOutputEventName); + afterOutputEvent = CreateEventW(nullptr, FALSE, FALSE, AfterOutputEventName); if (!afterOutputEvent) { std::cerr << "CreateEvent#2 failed " << GetLastError() << std::endl; return 1; diff --git a/testDynamicLoader.cxx b/testDynamicLoader.cxx index eff2ed7..2421ac0 100644 --- a/testDynamicLoader.cxx +++ b/testDynamicLoader.cxx @@ -21,7 +21,7 @@ // left on disk. #include -static std::string GetLibName(const char* lname, const char* subdir = NULL) +static std::string GetLibName(const char* lname, const char* subdir = nullptr) { // Construct proper name of lib std::string slname; diff --git a/testEncoding.cxx b/testEncoding.cxx index fdad1cd..988697b 100644 --- a/testEncoding.cxx +++ b/testEncoding.cxx @@ -84,7 +84,7 @@ static int testRobustEncoding() // this conversion could fail std::wstring wstr = kwsys::Encoding::ToWide(cstr); - wstr = kwsys::Encoding::ToWide(KWSYS_NULLPTR); + wstr = kwsys::Encoding::ToWide(nullptr); if (wstr != L"") { const wchar_t* wcstr = wstr.c_str(); std::cout << "ToWide(NULL) returned"; @@ -112,7 +112,7 @@ static int testRobustEncoding() std::string win_str = kwsys::Encoding::ToNarrow(cwstr); #endif - std::string str = kwsys::Encoding::ToNarrow(KWSYS_NULLPTR); + std::string str = kwsys::Encoding::ToNarrow(nullptr); if (str != "") { std::cout << "ToNarrow(NULL) returned " << str << std::endl; ret++; diff --git a/testProcess.c b/testProcess.c index f139f58..39aaa23 100644 --- a/testProcess.c +++ b/testProcess.c @@ -477,7 +477,7 @@ static int runChild2(kwsysProcess* kp, const char* cmd[], int state, printf("Error in administrating child process: [%s]\n", kwsysProcess_GetErrorString(kp)); break; - }; + } if (result) { if (exception != kwsysProcess_GetExitException(kp)) { diff --git a/testSystemTools.cxx b/testSystemTools.cxx index 88277de..1f3a15b 100644 --- a/testSystemTools.cxx +++ b/testSystemTools.cxx @@ -52,7 +52,7 @@ static const char* toUnixPaths[][2] = { { "\\\\usr\\local\\bin\\passwd", "//usr/local/bin/passwd" }, { "\\\\usr\\lo cal\\bin\\pa sswd", "//usr/lo cal/bin/pa sswd" }, { "\\\\usr\\lo\\ cal\\bin\\pa\\ sswd", "//usr/lo/ cal/bin/pa/ sswd" }, - { KWSYS_NULLPTR, KWSYS_NULLPTR } + { nullptr, nullptr } }; static bool CheckConvertToUnixSlashes(std::string const& input, @@ -71,7 +71,7 @@ static bool CheckConvertToUnixSlashes(std::string const& input, static const char* checkEscapeChars[][4] = { { "1 foo 2 bar 2", "12", "\\", "\\1 foo \\2 bar \\2" }, { " {} ", "{}", "#", " #{#} " }, - { KWSYS_NULLPTR, KWSYS_NULLPTR, KWSYS_NULLPTR, KWSYS_NULLPTR } + { nullptr, nullptr, nullptr, nullptr } }; static bool CheckEscapeChars(std::string const& input, @@ -160,7 +160,7 @@ static bool CheckFileOperations() res = false; } // calling with 0 pointer should return false - if (kwsys::SystemTools::MakeDirectory(KWSYS_NULLPTR)) { + if (kwsys::SystemTools::MakeDirectory(nullptr)) { std::cerr << "Problem with MakeDirectory(0)" << std::endl; res = false; } @@ -218,11 +218,11 @@ static bool CheckFileOperations() } // calling with 0 pointer should return false - if (kwsys::SystemTools::FileExists(KWSYS_NULLPTR)) { + if (kwsys::SystemTools::FileExists(nullptr)) { std::cerr << "Problem with FileExists(0)" << std::endl; res = false; } - if (kwsys::SystemTools::FileExists(KWSYS_NULLPTR, true)) { + if (kwsys::SystemTools::FileExists(nullptr, true)) { std::cerr << "Problem with FileExists(0) as file" << std::endl; res = false; } ----------------------------------------------------------------------- Summary of changes: Help/manual/cmake.1.rst | 18 +- Source/kwsys/CommandLineArguments.cxx | 22 +-- Source/kwsys/Configure.hxx.in | 1 - Source/kwsys/ConsoleBuf.hxx.in | 18 +- Source/kwsys/Directory.cxx | 2 +- Source/kwsys/DynamicLoader.cxx | 20 +-- Source/kwsys/EncodingCXX.cxx | 25 +-- Source/kwsys/Glob.cxx | 2 +- Source/kwsys/Glob.hxx.in | 2 +- Source/kwsys/RegularExpression.cxx | 122 +++++++------ Source/kwsys/RegularExpression.hxx.in | 37 ++-- Source/kwsys/SystemInformation.cxx | 208 ++++++++++------------- Source/kwsys/SystemInformation.hxx.in | 10 +- Source/kwsys/SystemTools.cxx | 76 ++++----- Source/kwsys/SystemTools.hxx.in | 24 +-- Source/kwsys/hashtable.hxx.in | 21 +-- Source/kwsys/testCommandLineArguments.cxx | 4 +- Source/kwsys/testCommandLineArguments1.cxx | 6 +- Source/kwsys/testConsoleBuf.cxx | 60 +++---- Source/kwsys/testDynamicLoader.cxx | 2 +- Source/kwsys/testEncoding.cxx | 4 +- Source/kwsys/testProcess.c | 2 +- Source/kwsys/testSystemTools.cxx | 10 +- Templates/TestDriver.cxx.in | 20 ++- Tests/Plugin/CMakeLists.txt | 12 +- Tests/Plugin/include/DynamicLoader.hxx | 49 ++++++ Tests/Plugin/src/DynamicLoader.cxx | 263 +++++++++++++++++++++++++++++ Tests/Plugin/src/example_exe.cxx | 17 +- Tests/Plugin/src/example_exe.h.in | 2 + 29 files changed, 676 insertions(+), 383 deletions(-) create mode 100644 Tests/Plugin/include/DynamicLoader.hxx create mode 100644 Tests/Plugin/src/DynamicLoader.cxx hooks/post-receive -- CMake From kwrobot at kitware.com Fri Sep 20 10:28:02 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 20 Sep 2019 10:28:02 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1136-g01d2944 Message-ID: <20190920142802.945DC18906@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 01d2944458289ac2601855b3fce2e3f66d850ed4 (commit) via 541e681da26d3f264ad20228b66e6cfdfec83878 (commit) via fb8341c35e43d605e4d2ece50dad6428fd9cc45d (commit) via 4ade1b00c5b2ca2e3c5ce5f5bcd7dd0a61ef7a2e (commit) via 71f088f53ae7f59e002ec893933d0f670347ea93 (commit) via 6511fa6f3309984fc10de8471017c2bb32d8d286 (commit) via 9b8a1f7c28deac892493b0a5548b08b2003238ea (commit) via 4d6334824d81086af205fe06b6fc4c4fda5224b4 (commit) via 5bd65dff7a8198279b1e592b7e48b91119dfc794 (commit) via 5d39e792ae769025866ab42d58d3363719eec5c1 (commit) via 7da17ef7973294a5207f879c0c5a3ed7ab727029 (commit) via d4d0dd0f6a0f2287fd0fbdfad8c7210515af5eaa (commit) via 0ac9dcb807d6e7b1f905bc9685f8ae217dfce38b (commit) via 0c6468178a76b6a2a11791b010ab01c97855affa (commit) via a209b31d0d088de40ba5bebdc6c9650f0583b2a6 (commit) via a583b7bc17b30c7772d6ca1909c71c0c14e6fabb (commit) via ccc9685cc1fb61242f179a02661730140b026253 (commit) via 026ef9b312047778ac0638cf2d2ef8bed6a2b3f2 (commit) via 0e1faa28cbd12d400b876f7a21d91aad5a837196 (commit) via 56c204e8eb8914b2ca273a56119cf1c40e13d75d (commit) via 3061dc6ac967e859424f81fb70bbc70a74246055 (commit) via e893ab94baa29b4a21d3edd86174cd19d8cd5a1e (commit) via f1e846fddece96d76d4d6b53ff1ca8ed197af550 (commit) via 4926ab24542d2c9e644feee88efd4a96f8bcab97 (commit) from 3c060ae6ca01464d507d6c7b6cef38639084418f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=01d2944458289ac2601855b3fce2e3f66d850ed4 commit 01d2944458289ac2601855b3fce2e3f66d850ed4 Merge: 541e681 71f088f Author: Brad King AuthorDate: Fri Sep 20 14:26:28 2019 +0000 Commit: Kitware Robot CommitDate: Fri Sep 20 10:26:41 2019 -0400 Merge topic 'smart_ptr/cmExportSet' 71f088f53a cmExportSet: subsume cmExportSetMap source files 6511fa6f33 cmExportSet: default destructor 9b8a1f7c28 cmExportSetMap: improve ownership of cmExportSet Acked-by: Kitware Robot Merge-request: !3816 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=541e681da26d3f264ad20228b66e6cfdfec83878 commit 541e681da26d3f264ad20228b66e6cfdfec83878 Merge: fb8341c 0e1faa2 Author: Brad King AuthorDate: Fri Sep 20 14:22:52 2019 +0000 Commit: Kitware Robot CommitDate: Fri Sep 20 10:24:32 2019 -0400 Merge topic 'split-custom-command-creation' 0e1faa28cb cmMakefile: Separate custom command setup from actual creation 56c204e8eb cmMakefile: Refactor AddCustomCommandOldStyle to be delay friendly 3061dc6ac9 add_custom_command: Add tests for rejecting literal quotes in commands e893ab94ba cmMakefile: Validate command line for all custom commands f1e846fdde cmMakefile: Extract custom command validation method 4926ab2454 cmMakefile: Create all generated byproducts as known sources Acked-by: Kitware Robot Merge-request: !3822 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fb8341c35e43d605e4d2ece50dad6428fd9cc45d commit fb8341c35e43d605e4d2ece50dad6428fd9cc45d Merge: 4ade1b0 a583b7b Author: Brad King AuthorDate: Fri Sep 20 14:22:45 2019 +0000 Commit: Kitware Robot CommitDate: Fri Sep 20 10:23:13 2019 -0400 Merge topic 'prepare-genex-in-byproducts' a583b7bc17 Genex: Evaluate byproduct generator expressions in cmCustomCommandGenerator ccc9685cc1 Genex: Move genex expansion of paths into AppendPaths utility 026ef9b312 Refactoring: Use ConfigName instead of property CMAKE_BUILD_TYPE Acked-by: Kitware Robot Merge-request: !3797 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4ade1b00c5b2ca2e3c5ce5f5bcd7dd0a61ef7a2e commit 4ade1b00c5b2ca2e3c5ce5f5bcd7dd0a61ef7a2e Merge: 3c060ae 4d63348 Author: Brad King AuthorDate: Fri Sep 20 14:21:47 2019 +0000 Commit: Kitware Robot CommitDate: Fri Sep 20 10:22:01 2019 -0400 Merge topic 'fileapiLinkPathAndLinkDirBacktraces' 4d6334824d fileapi: add backtraces for LINK_PATH and LINK_DIRECTORIES 5bd65dff7a cmLocalGenerator: Add OutputLinkLibraries overload with backtraces 5d39e792ae cmGeneratorTarget: Store backtrace for target LINK_DIRECTORIES property 7da17ef797 cmLinkLineComputer: Add ComputeLinkLibraries overload with backtraces d4d0dd0f6a cmLinkLineComputer: Add ComputeLinkLibs overload with backtraces 0ac9dcb807 cmLinkLineComputer: Add ComputeLinkPath overload with backtraces 0c6468178a cmComputeLinkInformation: Add GetDirectoriesWithBacktraces a209b31d0d cmComputeLinkInformation: Add AppendValues with backtraces Acked-by: Kitware Robot Merge-request: !3805 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=71f088f53ae7f59e002ec893933d0f670347ea93 commit 71f088f53ae7f59e002ec893933d0f670347ea93 Author: Tushar Maheshwari AuthorDate: Sat Sep 14 00:39:15 2019 +0530 Commit: Tushar Maheshwari CommitDate: Thu Sep 19 19:20:30 2019 +0530 cmExportSet: subsume cmExportSetMap source files diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 65cd6c9..7b580e5 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -226,8 +226,6 @@ set(SRCS cmExportTryCompileFileGenerator.cxx cmExportSet.h cmExportSet.cxx - cmExportSetMap.h - cmExportSetMap.cxx cmExternalMakefileProjectGenerator.cxx cmExternalMakefileProjectGenerator.h cmExtraCodeBlocksGenerator.cxx diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 08c6e7b..c751966 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -17,6 +17,7 @@ #include "cmake.h" #include +#include #include #include #include diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index 66dcb97..2713856 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -13,7 +13,7 @@ #include "cmArgumentParser.h" #include "cmExportBuildAndroidMKGenerator.h" #include "cmExportBuildFileGenerator.h" -#include "cmExportSetMap.h" +#include "cmExportSet.h" #include "cmGeneratedFileStream.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" @@ -23,7 +23,6 @@ #include "cmSystemTools.h" #include "cmTarget.h" -class cmExportSet; class cmExecutionStatus; #if defined(__HAIKU__) diff --git a/Source/cmExportInstallAndroidMKGenerator.cxx b/Source/cmExportInstallAndroidMKGenerator.cxx index 8f7e2dd..2d732c1 100644 --- a/Source/cmExportInstallAndroidMKGenerator.cxx +++ b/Source/cmExportInstallAndroidMKGenerator.cxx @@ -3,6 +3,7 @@ #include "cmExportInstallAndroidMKGenerator.h" #include +#include #include #include "cmExportBuildAndroidMKGenerator.h" diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 28e8244..0009b3a 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -3,7 +3,6 @@ #include "cmExportInstallFileGenerator.h" #include "cmExportSet.h" -#include "cmExportSetMap.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" @@ -19,6 +18,7 @@ #include "cmTarget.h" #include "cmTargetExport.h" +#include #include #include diff --git a/Source/cmExportSet.cxx b/Source/cmExportSet.cxx index 05f1b5d..a20aa9a 100644 --- a/Source/cmExportSet.cxx +++ b/Source/cmExportSet.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmExportSet.h" +#include #include #include "cmLocalGenerator.h" @@ -30,3 +31,14 @@ void cmExportSet::AddInstallation(cmInstallExportGenerator const* installation) { this->Installations.push_back(installation); } + +cmExportSet& cmExportSetMap::operator[](const std::string& name) +{ + auto it = this->find(name); + if (it == this->end()) // Export set not found + { + auto tup_name = std::make_tuple(name); + it = this->emplace(std::piecewise_construct, tup_name, tup_name).first; + } + return it->second; +} diff --git a/Source/cmExportSet.h b/Source/cmExportSet.h index 2eee849..f0d921f 100644 --- a/Source/cmExportSet.h +++ b/Source/cmExportSet.h @@ -5,6 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include #include #include #include @@ -49,4 +50,16 @@ private: std::vector Installations; }; +/// A name -> cmExportSet map with overloaded operator[]. +class cmExportSetMap : public std::map +{ +public: + /** \brief Overloaded operator[]. + * + * The operator is overloaded because cmExportSet has no default constructor: + * we do not want unnamed export sets. + */ + cmExportSet& operator[](const std::string& name); +}; + #endif diff --git a/Source/cmExportSetMap.cxx b/Source/cmExportSetMap.cxx deleted file mode 100644 index 68e76d5..0000000 --- a/Source/cmExportSetMap.cxx +++ /dev/null @@ -1,17 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmExportSetMap.h" - -#include -#include - -cmExportSet& cmExportSetMap::operator[](const std::string& name) -{ - auto it = this->find(name); - if (it == this->end()) // Export set not found - { - auto tup_name = std::make_tuple(name); - it = this->emplace(std::piecewise_construct, tup_name, tup_name).first; - } - return it->second; -} diff --git a/Source/cmExportSetMap.h b/Source/cmExportSetMap.h deleted file mode 100644 index 5764c0b..0000000 --- a/Source/cmExportSetMap.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cmExportSetMap_h -#define cmExportSetMap_h - -#include "cmConfigure.h" // IWYU pragma: keep - -#include -#include - -#include "cmExportSet.h" - -/// A name -> cmExportSet map with overloaded operator[]. -class cmExportSetMap : public std::map -{ - using derived = std::map; - -public: - /** \brief Overloaded operator[]. - * - * The operator is overloaded because cmExportSet has no default constructor: - * we do not want unnamed export sets. - */ - cmExportSet& operator[](const std::string& name); -}; - -#endif diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index d67c725..372e658 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -17,7 +17,7 @@ #include "cmAlgorithms.h" #include "cmCustomCommandLines.h" #include "cmDuration.h" -#include "cmExportSetMap.h" +#include "cmExportSet.h" #include "cmStateSnapshot.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 54f6cc6..0d0b453 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -11,7 +11,6 @@ #include "cmArgumentParser.h" #include "cmExportSet.h" -#include "cmExportSetMap.h" #include "cmGeneratorExpression.h" #include "cmGlobalGenerator.h" #include "cmInstallCommandArguments.h" diff --git a/bootstrap b/bootstrap index 9504250..ca5441f 100755 --- a/bootstrap +++ b/bootstrap @@ -307,7 +307,6 @@ CMAKE_CXX_SOURCES="\ cmExportFileGenerator \ cmExportInstallFileGenerator \ cmExportSet \ - cmExportSetMap \ cmExportTryCompileFileGenerator \ cmExprParserHelper \ cmExternalMakefileProjectGenerator \ https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6511fa6f3309984fc10de8471017c2bb32d8d286 commit 6511fa6f3309984fc10de8471017c2bb32d8d286 Author: Tushar Maheshwari AuthorDate: Sun Sep 8 14:44:55 2019 +0530 Commit: Tushar Maheshwari CommitDate: Thu Sep 19 19:20:29 2019 +0530 cmExportSet: default destructor diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index e9d2412..08c6e7b 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -283,7 +283,8 @@ void cmExportBuildFileGenerator::GetTargets( std::vector& targets) const { if (this->ExportSet) { - for (cmTargetExport* te : *this->ExportSet->GetTargetExports()) { + for (std::unique_ptr const& te : + this->ExportSet->GetTargetExports()) { targets.push_back(te->TargetName); } return; diff --git a/Source/cmExportInstallAndroidMKGenerator.cxx b/Source/cmExportInstallAndroidMKGenerator.cxx index 207ea41..8f7e2dd 100644 --- a/Source/cmExportInstallAndroidMKGenerator.cxx +++ b/Source/cmExportInstallAndroidMKGenerator.cxx @@ -35,7 +35,8 @@ void cmExportInstallAndroidMKGenerator::GenerateImportHeaderCode( } os << "_IMPORT_PREFIX := " << "$(LOCAL_PATH)" << path << "\n\n"; - for (cmTargetExport* te : *this->IEGen->GetExportSet()->GetTargetExports()) { + for (std::unique_ptr const& te : + this->IEGen->GetExportSet()->GetTargetExports()) { // Collect import properties for this target. if (te->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index c5aec64..28e8244 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -40,12 +40,12 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) { std::string expectedTargets; std::string sep; - for (cmTargetExport* te : - *this->IEGen->GetExportSet()->GetTargetExports()) { + for (std::unique_ptr const& te : + this->IEGen->GetExportSet()->GetTargetExports()) { expectedTargets += sep + this->Namespace + te->Target->GetExportName(); sep = " "; if (this->ExportedTargets.insert(te->Target).second) { - allTargets.push_back(te); + allTargets.push_back(te.get()); } else { std::ostringstream e; e << "install(EXPORT \"" << this->IEGen->GetExportSet()->GetName() @@ -314,9 +314,11 @@ void cmExportInstallFileGenerator::GenerateImportTargetsConfig( std::vector& missingTargets) { // Add each target in the set to the export. - for (cmTargetExport* te : *this->IEGen->GetExportSet()->GetTargetExports()) { + for (std::unique_ptr const& te : + this->IEGen->GetExportSet()->GetTargetExports()) { // Collect import properties for this target. - if (this->GetExportTargetType(te) == cmStateEnums::INTERFACE_LIBRARY) { + if (this->GetExportTargetType(te.get()) == + cmStateEnums::INTERFACE_LIBRARY) { continue; } @@ -475,10 +477,9 @@ cmExportInstallFileGenerator::FindNamespaces(cmGlobalGenerator* gg, for (auto const& expIt : exportSets) { const cmExportSet& exportSet = expIt.second; - std::vector const* targets = exportSet.GetTargetExports(); bool containsTarget = false; - for (cmTargetExport* target : *targets) { + for (auto const& target : exportSet.GetTargetExports()) { if (name == target->TargetName) { containsTarget = true; break; diff --git a/Source/cmExportSet.cxx b/Source/cmExportSet.cxx index a6fa186..05f1b5d 100644 --- a/Source/cmExportSet.cxx +++ b/Source/cmExportSet.cxx @@ -2,25 +2,28 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmExportSet.h" -#include "cmAlgorithms.h" +#include + #include "cmLocalGenerator.h" #include "cmTargetExport.h" -cmExportSet::~cmExportSet() +cmExportSet::cmExportSet(std::string name) + : Name(std::move(name)) { - cmDeleteAll(this->TargetExports); } +cmExportSet::~cmExportSet() = default; + void cmExportSet::Compute(cmLocalGenerator* lg) { - for (cmTargetExport* tgtExport : this->TargetExports) { + for (std::unique_ptr& tgtExport : this->TargetExports) { tgtExport->Target = lg->FindGeneratorTargetToUse(tgtExport->TargetName); } } -void cmExportSet::AddTargetExport(cmTargetExport* te) +void cmExportSet::AddTargetExport(std::unique_ptr te) { - this->TargetExports.push_back(te); + this->TargetExports.emplace_back(std::move(te)); } void cmExportSet::AddInstallation(cmInstallExportGenerator const* installation) diff --git a/Source/cmExportSet.h b/Source/cmExportSet.h index d654c12..2eee849 100644 --- a/Source/cmExportSet.h +++ b/Source/cmExportSet.h @@ -5,8 +5,8 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include #include -#include #include class cmInstallExportGenerator; @@ -18,10 +18,7 @@ class cmExportSet { public: /// Construct an empty export set named \a name - cmExportSet(std::string name) - : Name(std::move(name)) - { - } + cmExportSet(std::string name); /// Destructor ~cmExportSet(); @@ -30,15 +27,15 @@ public: void Compute(cmLocalGenerator* lg); - void AddTargetExport(cmTargetExport* tgt); + void AddTargetExport(std::unique_ptr tgt); void AddInstallation(cmInstallExportGenerator const* installation); std::string const& GetName() const { return this->Name; } - std::vector const* GetTargetExports() const + std::vector> const& GetTargetExports() const { - return &this->TargetExports; + return this->TargetExports; } std::vector const* GetInstallations() const @@ -47,7 +44,7 @@ public: } private: - std::vector TargetExports; + std::vector> TargetExports; std::string Name; std::vector Installations; }; diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 11d2c4b..54f6cc6 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -744,7 +744,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) // Add this install rule to an export if one was specified and // this is not a namelink-only rule. if (!exports.empty() && !namelinkOnly) { - cmTargetExport* te = new cmTargetExport; + auto te = cm::make_unique(); te->TargetName = target.GetName(); te->ArchiveGenerator = archiveGenerator; te->BundleGenerator = bundleGenerator; @@ -753,12 +753,12 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) te->LibraryGenerator = libraryGenerator; te->RuntimeGenerator = runtimeGenerator; te->ObjectsGenerator = objectGenerator; - this->Makefile->GetGlobalGenerator() - ->GetExportSets()[exports] - .AddTargetExport(te); - te->InterfaceIncludeDirectories = cmJoin(includesArgs.GetIncludeDirs(), ";"); + + this->Makefile->GetGlobalGenerator() + ->GetExportSets()[exports] + .AddTargetExport(std::move(te)); } } @@ -1433,7 +1433,7 @@ bool cmInstallCommand::HandleExportMode(std::vector const& args) cmExportSet& exportSet = this->Makefile->GetGlobalGenerator()->GetExportSets()[exp]; if (exportOld) { - for (cmTargetExport* te : *exportSet.GetTargetExports()) { + for (auto const& te : exportSet.GetTargetExports()) { cmTarget* tgt = this->Makefile->GetGlobalGenerator()->FindTarget(te->TargetName); const bool newCMP0022Behavior = diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 0b3617b..cba68be 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -123,7 +123,7 @@ size_t cmInstallExportGenerator::GetMaxConfigLength() const void cmInstallExportGenerator::GenerateScript(std::ostream& os) { // Skip empty sets. - if (ExportSet->GetTargetExports()->empty()) { + if (ExportSet->GetTargetExports().empty()) { std::ostringstream e; e << "INSTALL(EXPORT) given unknown export \"" << ExportSet->GetName() << "\""; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9b8a1f7c28deac892493b0a5548b08b2003238ea commit 9b8a1f7c28deac892493b0a5548b08b2003238ea Author: Tushar Maheshwari AuthorDate: Fri Sep 6 15:46:02 2019 +0530 Commit: Tushar Maheshwari CommitDate: Thu Sep 19 19:20:29 2019 +0530 cmExportSetMap: improve ownership of cmExportSet - use `std::piecewise_construct` to fix gcc-4.8 build. - can use `emplace(name, name)` gcc-6 onwards. diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index 4046f91..66dcb97 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -121,7 +121,7 @@ bool cmExportCommand::InitialPass(std::vector const& args, cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator(); - cmExportSet* ExportSet = nullptr; + cmExportSet* exportSet = nullptr; if (args[0] == "EXPORT") { cmExportSetMap& setMap = gg->GetExportSets(); auto const it = setMap.find(arguments.ExportSetName); @@ -131,7 +131,7 @@ bool cmExportCommand::InitialPass(std::vector const& args, this->SetError(e.str()); return false; } - ExportSet = it->second; + exportSet = &it->second; } else if (!arguments.Targets.empty() || cmContains(keywordsMissingValue, "TARGETS")) { for (std::string const& currentTarget : arguments.Targets) { @@ -180,8 +180,8 @@ bool cmExportCommand::InitialPass(std::vector const& args, ebfg->SetExportFile(fname.c_str()); ebfg->SetNamespace(arguments.Namespace); ebfg->SetAppendMode(arguments.Append); - if (ExportSet != nullptr) { - ebfg->SetExportSet(ExportSet); + if (exportSet != nullptr) { + ebfg->SetExportSet(exportSet); } else { ebfg->SetTargets(targets); } @@ -197,7 +197,7 @@ bool cmExportCommand::InitialPass(std::vector const& args, for (std::string const& ct : configurationTypes) { ebfg->AddConfiguration(ct); } - if (ExportSet != nullptr) { + if (exportSet != nullptr) { gg->AddBuildExportExportSet(ebfg); } else { gg->AddBuildExportSet(ebfg); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 4e3db09..c5aec64 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -474,9 +474,8 @@ cmExportInstallFileGenerator::FindNamespaces(cmGlobalGenerator* gg, const cmExportSetMap& exportSets = gg->GetExportSets(); for (auto const& expIt : exportSets) { - const cmExportSet* exportSet = expIt.second; - std::vector const* targets = - exportSet->GetTargetExports(); + const cmExportSet& exportSet = expIt.second; + std::vector const* targets = exportSet.GetTargetExports(); bool containsTarget = false; for (cmTargetExport* target : *targets) { @@ -488,7 +487,7 @@ cmExportInstallFileGenerator::FindNamespaces(cmGlobalGenerator* gg, if (containsTarget) { std::vector const* installs = - exportSet->GetInstallations(); + exportSet.GetInstallations(); for (cmInstallExportGenerator const* install : *installs) { exportFiles.push_back(install->GetDestinationFile()); ns = install->GetNamespace(); diff --git a/Source/cmExportSetMap.cxx b/Source/cmExportSetMap.cxx index 5c3f84f..68e76d5 100644 --- a/Source/cmExportSetMap.cxx +++ b/Source/cmExportSetMap.cxx @@ -2,30 +2,16 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmExportSetMap.h" -#include "cmAlgorithms.h" -#include "cmExportSet.h" - +#include #include -cmExportSet* cmExportSetMap::operator[](const std::string& name) +cmExportSet& cmExportSetMap::operator[](const std::string& name) { auto it = this->find(name); if (it == this->end()) // Export set not found { - it = this->insert(std::make_pair(name, new cmExportSet(name))).first; + auto tup_name = std::make_tuple(name); + it = this->emplace(std::piecewise_construct, tup_name, tup_name).first; } return it->second; } - -void cmExportSetMap::clear() -{ - cmDeleteAll(*this); - this->derived::clear(); -} - -cmExportSetMap::cmExportSetMap() = default; - -cmExportSetMap::~cmExportSetMap() -{ - this->clear(); -} diff --git a/Source/cmExportSetMap.h b/Source/cmExportSetMap.h index 0ef07ef..5764c0b 100644 --- a/Source/cmExportSetMap.h +++ b/Source/cmExportSetMap.h @@ -8,12 +8,12 @@ #include #include -class cmExportSet; +#include "cmExportSet.h" /// A name -> cmExportSet map with overloaded operator[]. -class cmExportSetMap : public std::map +class cmExportSetMap : public std::map { - using derived = std::map; + using derived = std::map; public: /** \brief Overloaded operator[]. @@ -21,17 +21,7 @@ public: * The operator is overloaded because cmExportSet has no default constructor: * we do not want unnamed export sets. */ - cmExportSet* operator[](const std::string& name); - - void clear(); - - cmExportSetMap(); - - /// Overloaded destructor deletes all member export sets. - ~cmExportSetMap(); - - cmExportSetMap(const cmExportSetMap&) = delete; - cmExportSetMap& operator=(const cmExportSetMap&) = delete; + cmExportSet& operator[](const std::string& name); }; #endif diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 9b931f7..11d2c4b 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -755,7 +755,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) te->ObjectsGenerator = objectGenerator; this->Makefile->GetGlobalGenerator() ->GetExportSets()[exports] - ->AddTargetExport(te); + .AddTargetExport(te); te->InterfaceIncludeDirectories = cmJoin(includesArgs.GetIncludeDirs(), ";"); @@ -1333,7 +1333,7 @@ bool cmInstallCommand::HandleExportAndroidMKMode( fname = "Android.mk"; } - cmExportSet* exportSet = + cmExportSet& exportSet = this->Makefile->GetGlobalGenerator()->GetExportSets()[exp]; cmInstallGenerator::MessageLevel message = @@ -1341,7 +1341,7 @@ bool cmInstallCommand::HandleExportAndroidMKMode( // Create the export install generator. cmInstallExportGenerator* exportGenerator = new cmInstallExportGenerator( - exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(), + &exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(), ica.GetConfigurations(), ica.GetComponent().c_str(), message, ica.GetExcludeFromAll(), fname.c_str(), name_space.c_str(), exportOld, true); @@ -1430,10 +1430,10 @@ bool cmInstallCommand::HandleExportMode(std::vector const& args) } } - cmExportSet* exportSet = + cmExportSet& exportSet = this->Makefile->GetGlobalGenerator()->GetExportSets()[exp]; if (exportOld) { - for (cmTargetExport* te : *exportSet->GetTargetExports()) { + for (cmTargetExport* te : *exportSet.GetTargetExports()) { cmTarget* tgt = this->Makefile->GetGlobalGenerator()->FindTarget(te->TargetName); const bool newCMP0022Behavior = @@ -1457,7 +1457,7 @@ bool cmInstallCommand::HandleExportMode(std::vector const& args) // Create the export install generator. cmInstallExportGenerator* exportGenerator = new cmInstallExportGenerator( - exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(), + &exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(), ica.GetConfigurations(), ica.GetComponent().c_str(), message, ica.GetExcludeFromAll(), fname.c_str(), name_space.c_str(), exportOld, false); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4d6334824d81086af205fe06b6fc4c4fda5224b4 commit 4d6334824d81086af205fe06b6fc4c4fda5224b4 Author: Justin Goshi AuthorDate: Wed Sep 11 11:37:48 2019 -0700 Commit: Brad King CommitDate: Wed Sep 18 14:00:39 2019 -0400 fileapi: add backtraces for LINK_PATH and LINK_DIRECTORIES diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 805da81..3cf929f 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -1270,8 +1270,8 @@ Json::Value Target::DumpLinkCommandFragments() std::string linkLanguageFlags; std::vector> linkFlags; std::string frameworkPath; - std::string linkPath; - std::string linkLibs; + std::vector> linkPath; + std::vector> linkLibs; cmLocalGenerator* lg = this->GT->GetLocalGenerator(); cmLinkLineComputer linkLineComputer(lg, lg->GetStateSnapshot().GetDirectory()); @@ -1280,8 +1280,6 @@ Json::Value Target::DumpLinkCommandFragments() this->GT); linkLanguageFlags = cmTrimWhitespace(linkLanguageFlags); frameworkPath = cmTrimWhitespace(frameworkPath); - linkPath = cmTrimWhitespace(linkPath); - linkLibs = cmTrimWhitespace(linkLibs); if (!linkLanguageFlags.empty()) { linkFragments.append( @@ -1302,13 +1300,19 @@ Json::Value Target::DumpLinkCommandFragments() } if (!linkPath.empty()) { - linkFragments.append( - this->DumpCommandFragment(std::move(linkPath), "libraryPath")); + for (BT frag : linkPath) { + frag.Value = cmTrimWhitespace(frag.Value); + linkFragments.append( + this->DumpCommandFragment(this->ToJBT(frag), "libraryPath")); + } } if (!linkLibs.empty()) { - linkFragments.append( - this->DumpCommandFragment(std::move(linkLibs), "libraries")); + for (BT frag : linkLibs) { + frag.Value = cmTrimWhitespace(frag.Value); + linkFragments.append( + this->DumpCommandFragment(this->ToJBT(frag), "libraries")); + } } return linkFragments; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index a4b482c..214e92c 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1198,17 +1198,21 @@ void cmLocalGenerator::GetTargetFlags( std::string& linkLibs, std::string& flags, std::string& linkFlags, std::string& frameworkPath, std::string& linkPath, cmGeneratorTarget* target) { - std::vector> tmpLinkFlags; - this->GetTargetFlags(linkLineComputer, config, linkLibs, flags, tmpLinkFlags, - frameworkPath, linkPath, target); - this->AppendFlags(linkFlags, tmpLinkFlags); + std::vector> linkFlagsList; + std::vector> linkPathList; + std::vector> linkLibsList; + this->GetTargetFlags(linkLineComputer, config, linkLibsList, flags, + linkFlagsList, frameworkPath, linkPathList, target); + this->AppendFlags(linkFlags, linkFlagsList); + this->AppendFlags(linkPath, linkPathList); + this->AppendFlags(linkLibs, linkLibsList); } void cmLocalGenerator::GetTargetFlags( cmLinkLineComputer* linkLineComputer, const std::string& config, - std::string& linkLibs, std::string& flags, + std::vector>& linkLibs, std::string& flags, std::vector>& linkFlags, std::string& frameworkPath, - std::string& linkPath, cmGeneratorTarget* target) + std::vector>& linkPath, cmGeneratorTarget* target) { const std::string buildType = cmSystemTools::UpperCase(config); cmComputeLinkInformation* pcli = target->GetLinkInformation(config); diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index f04f391..512df26 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -382,12 +382,11 @@ public: std::string& flags, std::string& linkFlags, std::string& frameworkPath, std::string& linkPath, cmGeneratorTarget* target); - void GetTargetFlags(cmLinkLineComputer* linkLineComputer, - const std::string& config, std::string& linkLibs, - std::string& flags, - std::vector>& linkFlags, - std::string& frameworkPath, std::string& linkPath, - cmGeneratorTarget* target); + void GetTargetFlags( + cmLinkLineComputer* linkLineComputer, const std::string& config, + std::vector>& linkLibs, std::string& flags, + std::vector>& linkFlags, std::string& frameworkPath, + std::vector>& linkPath, cmGeneratorTarget* target); void GetTargetDefines(cmGeneratorTarget const* target, std::string const& config, std::string const& lang, std::set& defines) const; diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py index 2a24421..52934f2 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py +++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py @@ -249,13 +249,13 @@ def check_target(c): if expected["backtrace"] is not None: expected_keys.append("backtrace") - assert actual["fragment"] == expected["fragment"] + assert matches(actual["fragment"], expected["fragment"]) assert actual["role"] == expected["role"] check_backtrace(obj, actual["backtrace"], expected["backtrace"]) assert sorted(actual.keys()) == sorted(expected_keys) - check_list_match(lambda a, e: is_string(a["fragment"], e["fragment"]), + check_list_match(lambda a, e: matches(a["fragment"], e["fragment"]), obj["link"]["commandFragments"], expected["link"]["commandFragments"], check=check_link_command_fragments, check_exception=lambda a, e: "Link fragment: %s" % a["fragment"], @@ -2218,6 +2218,42 @@ def gen_check_targets(c, g, inSource): }, ], }, + { + "fragment" : ".*TargetLinkDir\\\"?$", + "role" : "libraryPath", + "backtrace": [ + { + "file": "^cxx/CMakeLists\\.txt$", + "line": 19, + "command": "target_link_directories", + "hasParent": True, + }, + { + "file" : "^cxx/CMakeLists\\.txt$", + "line": None, + "command": None, + "hasParent": False, + }, + ], + }, + { + "fragment" : ".*cxx_lib.*", + "role" : "libraries", + "backtrace": [ + { + "file": "^cxx/CMakeLists\\.txt$", + "line": 6, + "command": "target_link_libraries", + "hasParent": True, + }, + { + "file" : "^cxx/CMakeLists\\.txt$", + "line": None, + "command": None, + "hasParent": False, + }, + ], + }, ], }, "archive": None, diff --git a/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt b/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt index 17ff455..b0564f5 100644 --- a/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt +++ b/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt @@ -16,3 +16,4 @@ target_link_libraries(cxx_static_exe PRIVATE cxx_static_lib) target_compile_options(cxx_exe PUBLIC TargetCompileOptions) target_link_options(cxx_exe PUBLIC TargetLinkOptions) +target_link_directories(cxx_exe PUBLIC "${CMAKE_BINARY_DIR}/TargetLinkDir") https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5bd65dff7a8198279b1e592b7e48b91119dfc794 commit 5bd65dff7a8198279b1e592b7e48b91119dfc794 Author: Justin Goshi AuthorDate: Wed Sep 11 11:15:08 2019 -0700 Commit: Brad King CommitDate: Wed Sep 18 14:00:39 2019 -0400 cmLocalGenerator: Add OutputLinkLibraries overload with backtraces diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 9f22277..a4b482c 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1526,6 +1526,19 @@ void cmLocalGenerator::OutputLinkLibraries( std::string& linkLibraries, std::string& frameworkPath, std::string& linkPath) { + std::vector> linkLibrariesList; + std::vector> linkPathList; + this->OutputLinkLibraries(pcli, linkLineComputer, linkLibrariesList, + frameworkPath, linkPathList); + pcli->AppendValues(linkLibraries, linkLibrariesList); + pcli->AppendValues(linkPath, linkPathList); +} + +void cmLocalGenerator::OutputLinkLibraries( + cmComputeLinkInformation* pcli, cmLinkLineComputer* linkLineComputer, + std::vector>& linkLibraries, std::string& frameworkPath, + std::vector>& linkPath) +{ cmComputeLinkInformation& cli = *pcli; std::string linkLanguage = cli.GetLinkLanguage(); @@ -1557,10 +1570,9 @@ void cmLocalGenerator::OutputLinkLibraries( cmStrCat("CMAKE_", linkLanguage, "_FRAMEWORK_SEARCH_FLAG")); frameworkPath = linkLineComputer->ComputeFrameworkPath(cli, fwSearchFlag); - linkPath = - linkLineComputer->ComputeLinkPath(cli, libPathFlag, libPathTerminator); - - linkLibraries = linkLineComputer->ComputeLinkLibraries(cli, stdLibString); + linkLineComputer->ComputeLinkPath(cli, libPathFlag, libPathTerminator, + linkPath); + linkLineComputer->ComputeLinkLibraries(cli, stdLibString, linkLibraries); } std::string cmLocalGenerator::GetLinkLibsCMP0065( diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 34f58bd..f04f391 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -430,6 +430,11 @@ protected: cmLinkLineComputer* linkLineComputer, std::string& linkLibraries, std::string& frameworkPath, std::string& linkPath); + void OutputLinkLibraries(cmComputeLinkInformation* pcli, + cmLinkLineComputer* linkLineComputer, + std::vector>& linkLibraries, + std::string& frameworkPath, + std::vector>& linkPath); // Handle old-style install rules stored in the targets. void GenerateTargetInstallRules( https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5d39e792ae769025866ab42d58d3363719eec5c1 commit 5d39e792ae769025866ab42d58d3363719eec5c1 Author: Justin Goshi AuthorDate: Wed Sep 11 11:07:43 2019 -0700 Commit: Brad King CommitDate: Wed Sep 18 14:00:39 2019 -0400 cmGeneratorTarget: Store backtrace for target LINK_DIRECTORIES property diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e4659b7..76b72b5 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3692,7 +3692,7 @@ void processLinkDirectories(cmGeneratorTarget const* tgt, // in case projects set the LINK_DIRECTORIES property directly. cmSystemTools::ConvertToUnixSlashes(entryDirectory); if (uniqueDirectories.insert(entryDirectory).second) { - directories.emplace_back(entryDirectory); + directories.emplace_back(entryDirectory, entry.Backtrace); if (debugDirectories) { usedDirectories += " * " + entryDirectory + "\n"; } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7da17ef7973294a5207f879c0c5a3ed7ab727029 commit 7da17ef7973294a5207f879c0c5a3ed7ab727029 Author: Justin Goshi AuthorDate: Wed Sep 11 11:04:36 2019 -0700 Commit: Brad King CommitDate: Wed Sep 18 14:00:37 2019 -0400 cmLinkLineComputer: Add ComputeLinkLibraries overload with backtraces diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx index dec25ff..0dc6236 100644 --- a/Source/cmLinkLineComputer.cxx +++ b/Source/cmLinkLineComputer.cxx @@ -222,13 +222,30 @@ std::string cmLinkLineComputer::ComputeFrameworkPath( std::string cmLinkLineComputer::ComputeLinkLibraries( cmComputeLinkInformation& cli, std::string const& stdLibString) { - std::ostringstream fout; - fout << this->ComputeRPath(cli); + std::string linkLibraries; + std::vector> linkLibrariesList; + this->ComputeLinkLibraries(cli, stdLibString, linkLibrariesList); + cli.AppendValues(linkLibraries, linkLibrariesList); + return linkLibraries; +} + +void cmLinkLineComputer::ComputeLinkLibraries( + cmComputeLinkInformation& cli, std::string const& stdLibString, + std::vector>& linkLibraries) +{ + std::ostringstream rpathOut; + rpathOut << this->ComputeRPath(cli); + + std::string rpath = rpathOut.str(); + if (!rpath.empty()) { + linkLibraries.emplace_back(std::move(rpath)); + } // Write the library flags to the build rule. - fout << this->ComputeLinkLibs(cli); + this->ComputeLinkLibs(cli, linkLibraries); // Add the linker runtime search path if any. + std::ostringstream fout; std::string rpath_link = cli.GetRPathLinkString(); if (!cli.GetRPathLinkFlag().empty() && !rpath_link.empty()) { fout << cli.GetRPathLinkFlag(); @@ -241,7 +258,10 @@ std::string cmLinkLineComputer::ComputeLinkLibraries( fout << stdLibString << " "; } - return fout.str(); + std::string remainingLibs = fout.str(); + if (!remainingLibs.empty()) { + linkLibraries.emplace_back(remainingLibs); + } } std::string cmLinkLineComputer::GetLinkerLanguage(cmGeneratorTarget* target, diff --git a/Source/cmLinkLineComputer.h b/Source/cmLinkLineComputer.h index a6e0ebf..f426976 100644 --- a/Source/cmLinkLineComputer.h +++ b/Source/cmLinkLineComputer.h @@ -45,8 +45,12 @@ public: std::string ComputeFrameworkPath(cmComputeLinkInformation& cli, std::string const& fwSearchFlag); - virtual std::string ComputeLinkLibraries(cmComputeLinkInformation& cli, - std::string const& stdLibString); + std::string ComputeLinkLibraries(cmComputeLinkInformation& cli, + std::string const& stdLibString); + + virtual void ComputeLinkLibraries( + cmComputeLinkInformation& cli, std::string const& stdLibString, + std::vector>& linkLibraries); virtual std::string GetLinkerLanguage(cmGeneratorTarget* target, std::string const& config); diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx index 1a602ca..d845652 100644 --- a/Source/cmLinkLineDeviceComputer.cxx +++ b/Source/cmLinkLineDeviceComputer.cxx @@ -4,13 +4,14 @@ #include "cmLinkLineDeviceComputer.h" #include -#include #include #include "cmAlgorithms.h" #include "cmComputeLinkInformation.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" +#include "cmLinkItem.h" +#include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmStateDirectory.h" @@ -67,12 +68,10 @@ bool cmLinkLineDeviceComputer::ComputeRequiresDeviceLinking( return false; } -std::string cmLinkLineDeviceComputer::ComputeLinkLibraries( - cmComputeLinkInformation& cli, std::string const& stdLibString) +void cmLinkLineDeviceComputer::ComputeLinkLibraries( + cmComputeLinkInformation& cli, std::string const& stdLibString, + std::vector>& linkLibraries) { - // Write the library flags to the build rule. - std::ostringstream fout; - // Generate the unique set of link items when device linking. // The nvcc device linker is designed so that each static library // with device symbols only needs to be listed once as it doesn't @@ -110,7 +109,7 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries( } } - std::string out; + BT linkLib; if (item.IsPath) { // nvcc understands absolute paths to libraries ending in '.a' or '.lib'. // These should be passed to nvlink. Other extensions need to be left @@ -118,7 +117,7 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries( // can tolerate '.so' or '.dylib' it cannot tolerate '.so.1'. if (cmHasLiteralSuffix(item.Value, ".a") || cmHasLiteralSuffix(item.Value, ".lib")) { - out += this->ConvertToOutputFormat( + linkLib.Value += this->ConvertToOutputFormat( this->ConvertToLinkReference(item.Value)); } } else if (item.Value == "-framework") { @@ -127,19 +126,33 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries( skipItemAfterFramework = true; continue; } else if (cmLinkItemValidForDevice(item.Value)) { - out += item.Value; + linkLib.Value += item.Value; } - if (emitted.insert(out).second) { - fout << out << " "; + if (emitted.insert(linkLib.Value).second) { + linkLib.Value += " "; + + const cmLinkImplementation* linkImpl = + cli.GetTarget()->GetLinkImplementation(cli.GetConfig()); + + for (const cmLinkImplItem& iter : linkImpl->Libraries) { + if (iter.Target != nullptr && + iter.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { + std::string libPath = iter.Target->GetLocation(cli.GetConfig()); + if (item.Value == libPath) { + linkLib.Backtrace = iter.Backtrace; + break; + } + } + } + + linkLibraries.emplace_back(linkLib); } } if (!stdLibString.empty()) { - fout << stdLibString << " "; + linkLibraries.emplace_back(cmStrCat(stdLibString, ' ')); } - - return fout.str(); } std::string cmLinkLineDeviceComputer::GetLinkerLanguage(cmGeneratorTarget*, diff --git a/Source/cmLinkLineDeviceComputer.h b/Source/cmLinkLineDeviceComputer.h index 0ea5f69..a9b01cd 100644 --- a/Source/cmLinkLineDeviceComputer.h +++ b/Source/cmLinkLineDeviceComputer.h @@ -7,6 +7,7 @@ #include "cmConfigure.h" // IWYU pragma: keep #include +#include #include "cmLinkLineComputer.h" @@ -15,6 +16,8 @@ class cmGeneratorTarget; class cmLocalGenerator; class cmOutputConverter; class cmStateDirectory; +template +class BT; class cmLinkLineDeviceComputer : public cmLinkLineComputer { @@ -29,8 +32,9 @@ public: bool ComputeRequiresDeviceLinking(cmComputeLinkInformation& cli); - std::string ComputeLinkLibraries(cmComputeLinkInformation& cli, - std::string const& stdLibString) override; + void ComputeLinkLibraries( + cmComputeLinkInformation& cli, std::string const& stdLibString, + std::vector>& linkLibraries) override; std::string GetLinkerLanguage(cmGeneratorTarget* target, std::string const& config) override; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d4d0dd0f6a0f2287fd0fbdfad8c7210515af5eaa commit d4d0dd0f6a0f2287fd0fbdfad8c7210515af5eaa Author: Justin Goshi AuthorDate: Fri Sep 13 10:59:53 2019 -0700 Commit: Brad King CommitDate: Wed Sep 18 13:59:36 2019 -0400 cmLinkLineComputer: Add ComputeLinkLibs overload with backtraces diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 71af43f..d3345d9 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -70,6 +70,8 @@ public: std::string GetConfig() const { return this->Config; } + const cmGeneratorTarget* GetTarget() { return this->Target; } + private: void AddItem(std::string const& item, const cmGeneratorTarget* tgt); void AddSharedDepItem(std::string const& item, cmGeneratorTarget const* tgt); diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx index d5225db..dec25ff 100644 --- a/Source/cmLinkLineComputer.cxx +++ b/Source/cmLinkLineComputer.cxx @@ -9,6 +9,7 @@ #include "cmComputeLinkInformation.h" #include "cmGeneratorTarget.h" +#include "cmLinkItem.h" #include "cmListFileCache.h" #include "cmOutputConverter.h" #include "cmStateDirectory.h" @@ -58,6 +59,15 @@ std::string cmLinkLineComputer::ConvertToLinkReference( std::string cmLinkLineComputer::ComputeLinkLibs(cmComputeLinkInformation& cli) { std::string linkLibs; + std::vector> linkLibsList; + this->ComputeLinkLibs(cli, linkLibsList); + cli.AppendValues(linkLibs, linkLibsList); + return linkLibs; +} + +void cmLinkLineComputer::ComputeLinkLibs( + cmComputeLinkInformation& cli, std::vector>& linkLibraries) +{ using ItemVector = cmComputeLinkInformation::ItemVector; ItemVector const& items = cli.GetItems(); for (auto const& item : items) { @@ -66,17 +76,32 @@ std::string cmLinkLineComputer::ComputeLinkLibs(cmComputeLinkInformation& cli) continue; } + BT linkLib; if (item.IsPath) { - linkLibs += cli.GetLibLinkFileFlag(); - linkLibs += + linkLib.Value += cli.GetLibLinkFileFlag(); + linkLib.Value += this->ConvertToOutputFormat(this->ConvertToLinkReference(item.Value)); } else { - linkLibs += item.Value; + linkLib.Value += item.Value; + } + linkLib.Value += " "; + + const cmLinkImplementation* linkImpl = + cli.GetTarget()->GetLinkImplementation(cli.GetConfig()); + + for (const cmLinkImplItem& iter : linkImpl->Libraries) { + if (iter.Target != nullptr && + iter.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { + std::string libPath = iter.Target->GetLocation(cli.GetConfig()); + if (item.Value == libPath) { + linkLib.Backtrace = iter.Backtrace; + break; + } + } } - linkLibs += " "; - } - return linkLibs; + linkLibraries.emplace_back(linkLib); + } } std::string cmLinkLineComputer::ConvertToOutputFormat(std::string const& input) diff --git a/Source/cmLinkLineComputer.h b/Source/cmLinkLineComputer.h index 5e0f795..a6e0ebf 100644 --- a/Source/cmLinkLineComputer.h +++ b/Source/cmLinkLineComputer.h @@ -53,6 +53,8 @@ public: protected: std::string ComputeLinkLibs(cmComputeLinkInformation& cli); + void ComputeLinkLibs(cmComputeLinkInformation& cli, + std::vector>& linkLibraries); std::string ComputeRPath(cmComputeLinkInformation& cli); std::string ConvertToOutputFormat(std::string const& input); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0ac9dcb807d6e7b1f905bc9685f8ae217dfce38b commit 0ac9dcb807d6e7b1f905bc9685f8ae217dfce38b Author: Justin Goshi AuthorDate: Wed Sep 11 10:37:03 2019 -0700 Commit: Brad King CommitDate: Wed Sep 18 13:59:07 2019 -0400 cmLinkLineComputer: Add ComputeLinkPath overload with backtraces diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx index 91c551f..d5225db 100644 --- a/Source/cmLinkLineComputer.cxx +++ b/Source/cmLinkLineComputer.cxx @@ -4,10 +4,12 @@ #include "cmLinkLineComputer.h" #include +#include #include #include "cmComputeLinkInformation.h" #include "cmGeneratorTarget.h" +#include "cmListFileCache.h" #include "cmOutputConverter.h" #include "cmStateDirectory.h" #include "cmStateTypes.h" @@ -63,6 +65,7 @@ std::string cmLinkLineComputer::ComputeLinkLibs(cmComputeLinkInformation& cli) item.Target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } + if (item.IsPath) { linkLibs += cli.GetLibLinkFileFlag(); linkLibs += @@ -72,6 +75,7 @@ std::string cmLinkLineComputer::ComputeLinkLibs(cmComputeLinkInformation& cli) } linkLibs += " "; } + return linkLibs; } @@ -101,8 +105,19 @@ std::string cmLinkLineComputer::ComputeLinkPath( std::string const& libPathTerminator) { std::string linkPath; + std::vector> linkPathList; + this->ComputeLinkPath(cli, libPathFlag, libPathTerminator, linkPathList); + cli.AppendValues(linkPath, linkPathList); + return linkPath; +} +void cmLinkLineComputer::ComputeLinkPath( + cmComputeLinkInformation& cli, std::string const& libPathFlag, + std::string const& libPathTerminator, std::vector>& linkPath) +{ if (cli.GetLinkLanguage() == "Swift") { + std::string linkPathNoBT; + for (const cmComputeLinkInformation::Item& item : cli.GetItems()) { const cmGeneratorTarget* target = item.Target; if (!target) { @@ -116,20 +131,23 @@ std::string cmLinkLineComputer::ComputeLinkPath( type = cmStateEnums::ImportLibraryArtifact; } - linkPath += cmStrCat(" ", libPathFlag, - item.Target->GetDirectory(cli.GetConfig(), type), - libPathTerminator, " "); + linkPathNoBT += cmStrCat( + " ", libPathFlag, item.Target->GetDirectory(cli.GetConfig(), type), + libPathTerminator, " "); } } - } - for (std::string const& libDir : cli.GetDirectories()) { - linkPath += - cmStrCat(" ", libPathFlag, this->ConvertToOutputForExisting(libDir), - libPathTerminator, " "); + if (!linkPathNoBT.empty()) { + linkPath.emplace_back(std::move(linkPathNoBT)); + } } - return linkPath; + for (BT libDir : cli.GetDirectoriesWithBacktraces()) { + libDir.Value = cmStrCat(" ", libPathFlag, + this->ConvertToOutputForExisting(libDir.Value), + libPathTerminator, " "); + linkPath.emplace_back(libDir); + } } std::string cmLinkLineComputer::ComputeRPath(cmComputeLinkInformation& cli) diff --git a/Source/cmLinkLineComputer.h b/Source/cmLinkLineComputer.h index 2355c32..5e0f795 100644 --- a/Source/cmLinkLineComputer.h +++ b/Source/cmLinkLineComputer.h @@ -7,12 +7,15 @@ #include "cmConfigure.h" // IWYU pragma: keep #include +#include #include "cmStateDirectory.h" class cmComputeLinkInformation; class cmGeneratorTarget; class cmOutputConverter; +template +class BT; class cmLinkLineComputer { @@ -34,6 +37,11 @@ public: std::string const& libPathFlag, std::string const& libPathTerminator); + void ComputeLinkPath(cmComputeLinkInformation& cli, + std::string const& libPathFlag, + std::string const& libPathTerminator, + std::vector>& linkPath); + std::string ComputeFrameworkPath(cmComputeLinkInformation& cli, std::string const& fwSearchFlag); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0c6468178a76b6a2a11791b010ab01c97855affa commit 0c6468178a76b6a2a11791b010ab01c97855affa Author: Justin Goshi AuthorDate: Wed Sep 11 10:31:05 2019 -0700 Commit: Brad King CommitDate: Wed Sep 18 09:58:41 2019 -0400 cmComputeLinkInformation: Add GetDirectoriesWithBacktraces diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index ed0bb85..6ee6455 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -431,6 +431,28 @@ std::vector const& cmComputeLinkInformation::GetDirectories() return this->OrderLinkerSearchPath->GetOrderedDirectories(); } +std::vector> +cmComputeLinkInformation::GetDirectoriesWithBacktraces() +{ + std::vector> directoriesWithBacktraces; + + std::vector> targetLinkDirectores = + this->Target->GetLinkDirectories(this->Config, this->LinkLanguage); + + const std::vector& orderedDirectories = this->GetDirectories(); + for (const std::string& dir : orderedDirectories) { + auto result = + std::find(targetLinkDirectores.begin(), targetLinkDirectores.end(), dir); + if (result != targetLinkDirectores.end()) { + directoriesWithBacktraces.emplace_back(std::move(*result)); + } else { + directoriesWithBacktraces.emplace_back(dir); + } + } + + return directoriesWithBacktraces; +} + std::string cmComputeLinkInformation::GetRPathLinkString() const { // If there is no separate linker runtime search flag (-rpath-link) diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index ee36a71..71af43f 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -48,6 +48,7 @@ public: void AppendValues(std::string& result, std::vector>& values); ItemVector const& GetItems() const; std::vector const& GetDirectories() const; + std::vector> GetDirectoriesWithBacktraces(); std::vector const& GetDepends() const; std::vector const& GetFrameworkPaths() const; std::string GetLinkLanguage() const { return this->LinkLanguage; } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a209b31d0d088de40ba5bebdc6c9650f0583b2a6 commit a209b31d0d088de40ba5bebdc6c9650f0583b2a6 Author: Justin Goshi AuthorDate: Wed Sep 11 10:28:38 2019 -0700 Commit: Brad King CommitDate: Wed Sep 18 09:57:30 2019 -0400 cmComputeLinkInformation: Add AppendValues with backtraces diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index dd8d246..ed0bb85 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -6,6 +6,7 @@ #include "cmComputeLinkDepends.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" +#include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -406,6 +407,18 @@ cmComputeLinkInformation::~cmComputeLinkInformation() delete this->OrderDependentRPath; } +void cmComputeLinkInformation::AppendValues( + std::string& result, std::vector>& values) +{ + for (BT& p : values) { + if (result.empty()) { + result.append(" "); + } + + result.append(p.Value); + } +} + cmComputeLinkInformation::ItemVector const& cmComputeLinkInformation::GetItems() const { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 0f71381..ee36a71 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -17,6 +17,8 @@ class cmGlobalGenerator; class cmMakefile; class cmOrderDirectories; class cmake; +template +class BT; /** \class cmComputeLinkInformation * \brief Compute link information for a target in one configuration. @@ -43,6 +45,7 @@ public: cmGeneratorTarget const* Target = nullptr; }; using ItemVector = std::vector; + void AppendValues(std::string& result, std::vector>& values); ItemVector const& GetItems() const; std::vector const& GetDirectories() const; std::vector const& GetDepends() const; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a583b7bc17b30c7772d6ca1909c71c0c14e6fabb commit a583b7bc17b30c7772d6ca1909c71c0c14e6fabb Author: Daniel Eiband AuthorDate: Wed Sep 11 18:18:47 2019 +0200 Commit: Daniel Eiband CommitDate: Tue Sep 17 22:58:31 2019 +0200 Genex: Evaluate byproduct generator expressions in cmCustomCommandGenerator Evaluate and expand generator expressions in byproducts of custom commands. Note that it is still not possible to use generator expressions in byproducts of the commands `add_custom_command` and `add_custom_target`. These commands still reject the input. This is a preparation step for OUTPUT generator expression support. Issue: #12877 diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index d5d7041..ddb855b 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -72,6 +72,8 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, this->CommandLines.push_back(std::move(argv)); } + AppendPaths(cc.GetByproducts(), *this->GE, this->LG, this->Config, + this->Byproducts); AppendPaths(cc.GetDepends(), *this->GE, this->LG, this->Config, this->Depends); @@ -248,7 +250,7 @@ std::vector const& cmCustomCommandGenerator::GetOutputs() const std::vector const& cmCustomCommandGenerator::GetByproducts() const { - return this->CC.GetByproducts(); + return this->Byproducts; } std::vector const& cmCustomCommandGenerator::GetDepends() const diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h index 766f4b8..d614302 100644 --- a/Source/cmCustomCommandGenerator.h +++ b/Source/cmCustomCommandGenerator.h @@ -23,6 +23,7 @@ class cmCustomCommandGenerator cmGeneratorExpression* GE; cmCustomCommandLines CommandLines; std::vector> EmulatorsWithArguments; + std::vector Byproducts; std::vector Depends; std::string WorkingDirectory; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 84e95ef..482af22 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -221,7 +221,8 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() this->GeneratorTarget->GetPostBuildCommands()); for (const auto& be : buildEventCommands) { - const std::vector& byproducts = be.GetByproducts(); + cmCustomCommandGenerator beg(be, this->ConfigName, this->LocalGenerator); + const std::vector& byproducts = beg.GetByproducts(); for (std::string const& byproduct : byproducts) { this->CleanFiles.insert( this->LocalGenerator->MaybeConvertToRelativePath(currentBinDir, https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ccc9685cc1fb61242f179a02661730140b026253 commit ccc9685cc1fb61242f179a02661730140b026253 Author: Daniel Eiband AuthorDate: Wed Sep 11 18:05:06 2019 +0200 Commit: Daniel Eiband CommitDate: Tue Sep 17 22:58:31 2019 +0200 Genex: Move genex expansion of paths into AppendPaths utility Refactored internals of cmCustomCommandGenerator to make processing of path lists (evaluation of generator expressions and expansion into a list) available as AppendPaths utility function to be used for byproduct generator expression support. diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 2c0cbfd..d5d7041 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -17,6 +17,26 @@ #include #include +namespace { +void AppendPaths(const std::vector& inputs, + cmGeneratorExpression& ge, cmLocalGenerator* lg, + std::string const& config, std::vector& output) +{ + for (std::string const& in : inputs) { + std::unique_ptr cge = ge.Parse(in); + std::vector result = + cmExpandedList(cge->Evaluate(lg, config)); + for (std::string& it : result) { + cmSystemTools::ConvertToUnixSlashes(it); + if (cmSystemTools::FileIsFullPath(it)) { + it = cmSystemTools::CollapseFullPath(it); + } + } + cmAppend(output, result); + } +} +} + cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, std::string config, cmLocalGenerator* lg) @@ -46,25 +66,14 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, // lists on an empty command may have left this empty. // FIXME: Should we define behavior for removing empty commands? if (argv.empty()) { - argv.push_back(std::string()); + argv.emplace_back(); } this->CommandLines.push_back(std::move(argv)); } - std::vector depends = this->CC.GetDepends(); - for (std::string const& d : depends) { - std::unique_ptr cge = this->GE->Parse(d); - std::vector result = - cmExpandedList(cge->Evaluate(this->LG, this->Config)); - for (std::string& it : result) { - cmSystemTools::ConvertToUnixSlashes(it); - if (cmSystemTools::FileIsFullPath(it)) { - it = cmSystemTools::CollapseFullPath(it); - } - } - cmAppend(this->Depends, result); - } + AppendPaths(cc.GetDepends(), *this->GE, this->LG, this->Config, + this->Depends); const std::string& workingdirectory = this->CC.GetWorkingDirectory(); if (!workingdirectory.empty()) { https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=026ef9b312047778ac0638cf2d2ef8bed6a2b3f2 commit 026ef9b312047778ac0638cf2d2ef8bed6a2b3f2 Author: Daniel Eiband AuthorDate: Wed Sep 11 17:56:42 2019 +0200 Commit: Daniel Eiband CommitDate: Tue Sep 17 22:58:31 2019 +0200 Refactoring: Use ConfigName instead of property CMAKE_BUILD_TYPE Use memorized `this->ConfigName` instead of retrieving the value of property CMAKE_BUILD_TYPE. diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index f80695d..0be1de5 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -161,8 +161,7 @@ void cmLocalUnixMakefileGenerator3::GetLocalObjectFiles( continue; } std::vector objectSources; - gt->GetObjectSources( - objectSources, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); + gt->GetObjectSources(objectSources, this->ConfigName); // Compute full path to object file directory for this target. std::string dir = cmStrCat(gt->LocalGenerator->GetCurrentBinaryDirectory(), '/', this->GetTargetDirectory(gt), '/'); @@ -1864,9 +1863,8 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo( << "_TARGET_INCLUDE_PATH\n"; std::vector includes; - const std::string& config = - this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - this->GetIncludeDirectories(includes, target, implicitLang.first, config); + this->GetIncludeDirectories(includes, target, implicitLang.first, + this->ConfigName); std::string binaryDir = this->GetState()->GetBinaryDirectory(); if (this->Makefile->IsOn("CMAKE_DEPENDS_IN_PROJECT_ONLY")) { std::string const& sourceDir = this->GetState()->GetSourceDirectory(); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 477badd..84e95ef 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -150,16 +150,13 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() { // -- Write the custom commands for this target - const std::string& config = - this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - // Evaluates generator expressions and expands prop_value auto evaluatedFiles = - [this, &config](const char* prop_value) -> std::vector { + [this](const char* prop_value) -> std::vector { std::vector files; cmGeneratorExpression ge; std::unique_ptr cge = ge.Parse(prop_value); - cmExpandList(cge->Evaluate(this->LocalGenerator, config, false, + cmExpandList(cge->Evaluate(this->LocalGenerator, this->ConfigName, false, this->GeneratorTarget, nullptr, nullptr), files); return files; @@ -191,7 +188,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() // First generate the object rule files. Save a list of all object // files for this target. std::vector customCommands; - this->GeneratorTarget->GetCustomCommands(customCommands, config); + this->GeneratorTarget->GetCustomCommands(customCommands, this->ConfigName); std::string currentBinDir = this->LocalGenerator->GetCurrentBinaryDirectory(); for (cmSourceFile const* sf : customCommands) { @@ -233,17 +230,17 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() } } std::vector headerSources; - this->GeneratorTarget->GetHeaderSources(headerSources, config); + this->GeneratorTarget->GetHeaderSources(headerSources, this->ConfigName); this->OSXBundleGenerator->GenerateMacOSXContentStatements( headerSources, this->MacOSXContentGenerator); std::vector extraSources; - this->GeneratorTarget->GetExtraSources(extraSources, config); + this->GeneratorTarget->GetExtraSources(extraSources, this->ConfigName); this->OSXBundleGenerator->GenerateMacOSXContentStatements( extraSources, this->MacOSXContentGenerator); const char* pchExtension = this->Makefile->GetDefinition("CMAKE_PCH_EXTENSION"); std::vector externalObjects; - this->GeneratorTarget->GetExternalObjects(externalObjects, config); + this->GeneratorTarget->GetExternalObjects(externalObjects, this->ConfigName); for (cmSourceFile const* sf : externalObjects) { auto const& objectFileName = sf->GetFullPath(); if (!cmSystemTools::StringEndsWith(objectFileName, pchExtension)) { @@ -251,7 +248,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() } } std::vector objectSources; - this->GeneratorTarget->GetObjectSources(objectSources, config); + this->GeneratorTarget->GetObjectSources(objectSources, this->ConfigName); for (cmSourceFile const* sf : objectSources) { // Generate this object file's rule file. this->WriteObjectRuleFiles(*sf); @@ -1610,10 +1607,8 @@ void cmMakefileTargetGenerator::CreateLinkLibs( { std::string frameworkPath; std::string linkPath; - const std::string& config = - this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); cmComputeLinkInformation* pcli = - this->GeneratorTarget->GetLinkInformation(config); + this->GeneratorTarget->GetLinkInformation(this->ConfigName); this->LocalGenerator->OutputLinkLibraries(pcli, linkLineComputer, linkLibs, frameworkPath, linkPath); linkLibs = frameworkPath + linkPath + linkLibs; @@ -1706,13 +1701,12 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags, bool useResponseFile = this->Makefile->IsOn(responseVar); std::vector includes; - const std::string& config = - this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget, - lang, config); + lang, this->ConfigName); std::string includeFlags = this->LocalGenerator->GetIncludeFlags( - includes, this->GeneratorTarget, lang, false, useResponseFile, config); + includes, this->GeneratorTarget, lang, false, useResponseFile, + this->ConfigName); if (includeFlags.empty()) { return; } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 37e9e0e..84a98fd 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -777,11 +777,9 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements() << cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType()) << " target " << this->GetTargetName() << "\n\n"; - const std::string& config = - this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); { std::vector customCommands; - this->GeneratorTarget->GetCustomCommands(customCommands, config); + this->GeneratorTarget->GetCustomCommands(customCommands, this->ConfigName); for (cmSourceFile const* sf : customCommands) { cmCustomCommand const* cc = sf->GetCustomCommand(); this->GetLocalGenerator()->AddCustomCommandTarget( @@ -793,13 +791,13 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements() } { std::vector headerSources; - this->GeneratorTarget->GetHeaderSources(headerSources, config); + this->GeneratorTarget->GetHeaderSources(headerSources, this->ConfigName); this->OSXBundleGenerator->GenerateMacOSXContentStatements( headerSources, this->MacOSXContentGenerator.get()); } { std::vector extraSources; - this->GeneratorTarget->GetExtraSources(extraSources, config); + this->GeneratorTarget->GetExtraSources(extraSources, this->ConfigName); this->OSXBundleGenerator->GenerateMacOSXContentStatements( extraSources, this->MacOSXContentGenerator.get()); } @@ -808,7 +806,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements() GetMakefile()->GetDefinition("CMAKE_PCH_EXTENSION"); std::vector externalObjects; - this->GeneratorTarget->GetExternalObjects(externalObjects, config); + this->GeneratorTarget->GetExternalObjects(externalObjects, + this->ConfigName); for (cmSourceFile const* sf : externalObjects) { const auto objectFileName = this->GetSourceFilePath(sf); if (!cmSystemTools::StringEndsWith(objectFileName, pchExtension)) { @@ -863,7 +862,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements() { std::vector objectSources; - this->GeneratorTarget->GetObjectSources(objectSources, config); + this->GeneratorTarget->GetObjectSources(objectSources, this->ConfigName); for (cmSourceFile const* sf : objectSources) { this->WriteObjectBuildStatement(sf); } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0e1faa28cbd12d400b876f7a21d91aad5a837196 commit 0e1faa28cbd12d400b876f7a21d91aad5a837196 Author: Daniel Eiband AuthorDate: Sat Sep 14 22:59:05 2019 +0200 Commit: Daniel Eiband CommitDate: Tue Sep 17 22:52:32 2019 +0200 cmMakefile: Separate custom command setup from actual creation Refactor custom command manipulation functions to consist of a setup and a commit stage. The commit stage will be delayed to generate time. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 19cd068..b3a0678 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -910,6 +910,21 @@ cmTarget* cmMakefile::AddCustomCommandToTarget( // Always create the byproduct sources and mark them generated. this->CreateGeneratedSources(byproducts); + this->CommitCustomCommandToTarget( + t, byproducts, depends, commandLines, type, comment, workingDir, + escapeOldStyle, uses_terminal, depfile, job_pool, command_expand_lists); + + return t; +} + +void cmMakefile::CommitCustomCommandToTarget( + cmTarget* target, const std::vector& byproducts, + const std::vector& depends, + const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type, + const char* comment, const char* workingDir, bool escapeOldStyle, + bool uses_terminal, const std::string& depfile, const std::string& job_pool, + bool command_expand_lists) +{ // Add the command to the appropriate build step for the target. std::vector no_output; cmCustomCommand cc(this, no_output, byproducts, depends, commandLines, @@ -922,18 +937,16 @@ cmTarget* cmMakefile::AddCustomCommandToTarget( cc.SetJobPool(job_pool); switch (type) { case cmTarget::PRE_BUILD: - t->AddPreBuildCommand(cc); + target->AddPreBuildCommand(cc); break; case cmTarget::PRE_LINK: - t->AddPreLinkCommand(cc); + target->AddPreLinkCommand(cc); break; case cmTarget::POST_BUILD: - t->AddPostBuildCommand(cc); + target->AddPostBuildCommand(cc); break; } - this->UpdateOutputToSourceMap(byproducts, t); - - return t; + this->UpdateOutputToSourceMap(byproducts, target); } void cmMakefile::UpdateOutputToSourceMap( @@ -967,6 +980,23 @@ void cmMakefile::UpdateOutputToSourceMap(std::string const& byproduct, } cmSourceFile* cmMakefile::AddCustomCommandToOutput( + const std::string& output, const std::vector& depends, + const std::string& main_dependency, const cmCustomCommandLines& commandLines, + const char* comment, const char* workingDir, bool replace, + bool escapeOldStyle, bool uses_terminal, bool command_expand_lists, + const std::string& depfile, const std::string& job_pool) +{ + std::vector outputs; + outputs.push_back(output); + std::vector no_byproducts; + cmImplicitDependsList no_implicit_depends; + return this->AddCustomCommandToOutput( + outputs, no_byproducts, depends, main_dependency, no_implicit_depends, + commandLines, comment, workingDir, replace, escapeOldStyle, uses_terminal, + command_expand_lists, depfile, job_pool); +} + +cmSourceFile* cmMakefile::AddCustomCommandToOutput( const std::vector& outputs, const std::vector& byproducts, const std::vector& depends, const std::string& main_dependency, @@ -991,6 +1021,22 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput( this->CreateGeneratedSources(outputs); this->CreateGeneratedSources(byproducts); + return this->CommitCustomCommandToOutput( + outputs, byproducts, depends, main_dependency, implicit_depends, + commandLines, comment, workingDir, replace, escapeOldStyle, uses_terminal, + command_expand_lists, depfile, job_pool); +} + +cmSourceFile* cmMakefile::CommitCustomCommandToOutput( + const std::vector& outputs, + const std::vector& byproducts, + const std::vector& depends, const std::string& main_dependency, + const cmImplicitDependsList& implicit_depends, + const cmCustomCommandLines& commandLines, const char* comment, + const char* workingDir, bool replace, bool escapeOldStyle, + bool uses_terminal, bool command_expand_lists, const std::string& depfile, + const std::string& job_pool) +{ // Choose a source file on which to store the custom command. cmSourceFile* file = nullptr; if (!commandLines.empty() && !main_dependency.empty()) { @@ -1099,23 +1145,6 @@ void cmMakefile::UpdateOutputToSourceMap(std::string const& output, } } -cmSourceFile* cmMakefile::AddCustomCommandToOutput( - const std::string& output, const std::vector& depends, - const std::string& main_dependency, const cmCustomCommandLines& commandLines, - const char* comment, const char* workingDir, bool replace, - bool escapeOldStyle, bool uses_terminal, bool command_expand_lists, - const std::string& depfile, const std::string& job_pool) -{ - std::vector outputs; - outputs.push_back(output); - std::vector no_byproducts; - cmImplicitDependsList no_implicit_depends; - return this->AddCustomCommandToOutput( - outputs, no_byproducts, depends, main_dependency, no_implicit_depends, - commandLines, comment, workingDir, replace, escapeOldStyle, uses_terminal, - command_expand_lists, depfile, job_pool); -} - void cmMakefile::AddCustomCommandOldStyle( const std::string& target, const std::vector& outputs, const std::vector& depends, const std::string& source, @@ -1188,19 +1217,34 @@ bool cmMakefile::AppendCustomCommandToOutput( const cmImplicitDependsList& implicit_depends, const cmCustomCommandLines& commandLines) { + // Check as good as we can if there will be a command for this output. + if (!this->MightHaveCustomCommand(output)) { + return false; + } + + // Validate custom commands. + if (this->ValidateCustomCommand(commandLines)) { + // Add command factory to allow generator expressions in output. + this->CommitAppendCustomCommandToOutput(output, depends, implicit_depends, + commandLines); + } + + return true; +} + +void cmMakefile::CommitAppendCustomCommandToOutput( + const std::string& output, const std::vector& depends, + const cmImplicitDependsList& implicit_depends, + const cmCustomCommandLines& commandLines) +{ // Lookup an existing command. if (cmSourceFile* sf = this->GetSourceFileWithOutput(output)) { if (cmCustomCommand* cc = sf->GetCustomCommand()) { - // Validate custom commands. - if (this->ValidateCustomCommand(commandLines)) { - cc->AppendCommands(commandLines); - cc->AppendDepends(depends); - cc->AppendImplicitDepends(implicit_depends); - } - return true; + cc->AppendCommands(commandLines); + cc->AppendDepends(depends); + cc->AppendImplicitDepends(implicit_depends); } } - return false; } cmTarget* cmMakefile::AddUtilityCommand( @@ -1261,11 +1305,6 @@ cmTarget* cmMakefile::AddUtilityCommand( target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } - if (!comment) { - // Use an empty comment to avoid generation of default comment. - comment = ""; - } - // Validate custom commands. if (!this->ValidateCustomCommand(commandLines) || (commandLines.empty() && depends.empty())) { @@ -1277,27 +1316,58 @@ cmTarget* cmMakefile::AddUtilityCommand( std::string force = cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles/", utilityName); + this->CreateGeneratedSource(force); + std::string forceCMP0049 = target->GetSourceCMP0049(force); + { + cmSourceFile* sf = nullptr; + if (!forceCMP0049.empty()) { + sf = this->GetOrCreateSource(forceCMP0049, false, + cmSourceFileLocationKind::Known); + } + // The output is not actually created so mark it symbolic. + if (sf) { + sf->SetProperty("SYMBOLIC", "1"); + } else { + cmSystemTools::Error("Could not get source file entry for " + force); + } + } + + if (!comment) { + // Use an empty comment to avoid generation of default comment. + comment = ""; + } + + this->CommitUtilityCommand(target, force, forceCMP0049, workingDirectory, + byproducts, depends, commandLines, escapeOldStyle, + comment, uses_terminal, command_expand_lists, + job_pool); + + return target; +} + +void cmMakefile::CommitUtilityCommand( + cmTarget* target, const std::string& force, const std::string& forceCMP0049, + const char* workingDirectory, const std::vector& byproducts, + const std::vector& depends, + const cmCustomCommandLines& commandLines, bool escapeOldStyle, + const char* comment, bool uses_terminal, bool command_expand_lists, + const std::string& job_pool) +{ std::vector forced; forced.push_back(force); std::string no_main_dependency; cmImplicitDependsList no_implicit_depends; bool no_replace = false; - this->AddCustomCommandToOutput( + cmSourceFile* sf = this->AddCustomCommandToOutput( forced, byproducts, depends, no_main_dependency, no_implicit_depends, commandLines, comment, workingDirectory, no_replace, escapeOldStyle, uses_terminal, command_expand_lists, /*depfile=*/"", job_pool); - cmSourceFile* sf = target->AddSourceCMP0049(force); - - // The output is not actually created so mark it symbolic. + if (!forceCMP0049.empty()) { + target->AddSource(forceCMP0049); + } if (sf) { - sf->SetProperty("SYMBOLIC", "1"); - } else { - cmSystemTools::Error("Could not get source file entry for " + force); + this->UpdateOutputToSourceMap(byproducts, target); } - - this->UpdateOutputToSourceMap(byproducts, target); - - return target; } static void s_AddDefineFlag(std::string const& flag, std::string& dflags) @@ -2233,6 +2303,18 @@ cmSourceFile* cmMakefile::GetSourceFileWithOutput( return nullptr; } +bool cmMakefile::MightHaveCustomCommand(const std::string& name) const +{ + // This will have to be changed for delaying custom command creation, because + // GetSourceFileWithOutput requires the command to be already created. + if (cmSourceFile* sf = this->GetSourceFileWithOutput(name)) { + if (sf->GetCustomCommand()) { + return true; + } + } + return false; +} + #if !defined(CMAKE_BOOTSTRAP) cmSourceGroup* cmMakefile::GetSourceGroup( const std::vector& name) const @@ -3477,14 +3559,19 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName, return this->CreateSource(sourceName, generated, kind); } +void cmMakefile::CreateGeneratedSource(const std::string& output) +{ + if (cmSourceFile* out = this->GetOrCreateSource( + output, true, cmSourceFileLocationKind::Known)) { + out->SetProperty("GENERATED", "1"); + } +} + void cmMakefile::CreateGeneratedSources( const std::vector& outputs) { for (std::string const& output : outputs) { - if (cmSourceFile* out = this->GetOrCreateSource( - output, true, cmSourceFileLocationKind::Known)) { - out->SetProperty("GENERATED", "1"); - } + this->CreateGeneratedSource(output); } } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index ed118db..19a71ad 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -181,18 +181,18 @@ public: const std::string& job_pool = "", bool command_expand_lists = false, ObjectLibraryCommands objLibraryCommands = RejectObjectLibraryCommands); cmSourceFile* AddCustomCommandToOutput( - const std::vector& outputs, - const std::vector& byproducts, - const std::vector& depends, + const std::string& output, const std::vector& depends, const std::string& main_dependency, - const cmImplicitDependsList& implicit_depends, const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace = false, bool escapeOldStyle = true, bool uses_terminal = false, bool command_expand_lists = false, const std::string& depfile = "", const std::string& job_pool = ""); cmSourceFile* AddCustomCommandToOutput( - const std::string& output, const std::vector& depends, + const std::vector& outputs, + const std::vector& byproducts, + const std::vector& depends, const std::string& main_dependency, + const cmImplicitDependsList& implicit_depends, const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace = false, bool escapeOldStyle = true, bool uses_terminal = false, bool command_expand_lists = false, @@ -1069,6 +1069,39 @@ private: bool ValidateCustomCommand(const cmCustomCommandLines& commandLines) const; + void CommitCustomCommandToTarget( + cmTarget* target, const std::vector& byproducts, + const std::vector& depends, + const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type, + const char* comment, const char* workingDir, bool escapeOldStyle, + bool uses_terminal, const std::string& depfile, + const std::string& job_pool, bool command_expand_lists); + cmSourceFile* CommitCustomCommandToOutput( + const std::vector& outputs, + const std::vector& byproducts, + const std::vector& depends, + const std::string& main_dependency, + const cmImplicitDependsList& implicit_depends, + const cmCustomCommandLines& commandLines, const char* comment, + const char* workingDir, bool replace, bool escapeOldStyle, + bool uses_terminal, bool command_expand_lists, const std::string& depfile, + const std::string& job_pool); + void CommitAppendCustomCommandToOutput( + const std::string& output, const std::vector& depends, + const cmImplicitDependsList& implicit_depends, + const cmCustomCommandLines& commandLines); + + void CommitUtilityCommand(cmTarget* target, const std::string& force, + const std::string& forceCMP0049, + const char* workingDirectory, + const std::vector& byproducts, + const std::vector& depends, + const cmCustomCommandLines& commandLines, + bool escapeOldStyle, const char* comment, + bool uses_terminal, bool command_expand_lists, + const std::string& job_pool); + + void CreateGeneratedSource(const std::string& output); void CreateGeneratedSources(const std::vector& outputs); /** @@ -1104,6 +1137,11 @@ private: void UpdateOutputToSourceMap(std::string const& output, cmSourceFile* source, bool byproduct); + /** + * Return if the provided source file might have a custom command. + */ + bool MightHaveCustomCommand(const std::string& name) const; + bool AddRequiredTargetCFeature(cmTarget* target, const std::string& feature, std::string* error = nullptr) const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 6637e32..83d69a4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -694,13 +694,9 @@ std::string cmTargetInternals::ProcessSourceItemCMP0049(const std::string& s) return src; } -cmSourceFile* cmTarget::AddSourceCMP0049(const std::string& s) +std::string cmTarget::GetSourceCMP0049(const std::string& s) { - std::string src = impl->ProcessSourceItemCMP0049(s); - if (!s.empty() && src.empty()) { - return nullptr; - } - return this->AddSource(src); + return impl->ProcessSourceItemCMP0049(s); } struct CreateLocation diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e9bcffe..f4726d3 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -103,7 +103,7 @@ public: //! Add sources to the target. void AddSources(std::vector const& srcs); void AddTracedSources(std::vector const& srcs); - cmSourceFile* AddSourceCMP0049(const std::string& src); + std::string GetSourceCMP0049(const std::string& src); cmSourceFile* AddSource(const std::string& src, bool before = false); //! how we identify a library, by name and type https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=56c204e8eb8914b2ca273a56119cf1c40e13d75d commit 56c204e8eb8914b2ca273a56119cf1c40e13d75d Author: Daniel Eiband AuthorDate: Sat Sep 14 22:01:20 2019 +0200 Commit: Daniel Eiband CommitDate: Tue Sep 17 22:52:32 2019 +0200 cmMakefile: Refactor AddCustomCommandOldStyle to be delay friendly Custom command functions consist of two parts: setup and commit. Only the commit part will be delayed to generate time. This change puts the commit part of AddCustomCommandOldStyle into a lambda. When delayed, it will not be possible to break the loop over the outputs if an error occurs which seems reasonable. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 6707b1c..19cd068 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1134,41 +1134,50 @@ void cmMakefile::AddCustomCommandOldStyle( return; } - // Each output must get its own copy of this rule. - cmsys::RegularExpression sourceFiles("\\.(C|M|c|c\\+\\+|cc|cpp|cxx|cu|m|mm|" - "rc|def|r|odl|idl|hpj|bat|h|h\\+\\+|" - "hm|hpp|hxx|in|txx|inl)$"); - for (std::string const& oi : outputs) { - // Get the name of this output. - const char* output = oi.c_str(); - cmSourceFile* sf; - - // Choose whether to use a main dependency. - if (sourceFiles.find(source)) { - // The source looks like a real file. Use it as the main dependency. - sf = this->AddCustomCommandToOutput(output, depends, source, - commandLines, comment, nullptr); - } else { - // The source may not be a real file. Do not use a main dependency. - std::string no_main_dependency; - std::vector depends2 = depends; - depends2.push_back(source); - sf = this->AddCustomCommandToOutput(output, depends2, no_main_dependency, - commandLines, comment, nullptr); - } + auto ti = this->Targets.find(target); + cmTarget* t = ti != this->Targets.end() ? &ti->second : nullptr; + auto addRuleFileToTarget = [=](cmSourceFile* sf) { // If the rule was added to the source (and not a .rule file), // then add the source to the target to make sure the rule is // included. - if (sf && !sf->GetPropertyAsBool("__CMAKE_RULE")) { - auto ti = this->Targets.find(target); - if (ti != this->Targets.end()) { - ti->second.AddSource(sf->ResolveFullPath()); + if (!sf->GetPropertyAsBool("__CMAKE_RULE")) { + if (t) { + t->AddSource(sf->ResolveFullPath()); } else { cmSystemTools::Error("Attempt to add a custom rule to a target " "that does not exist yet for target " + target); - return; + } + } + }; + + // Each output must get its own copy of this rule. + cmsys::RegularExpression sourceFiles("\\.(C|M|c|c\\+\\+|cc|cpp|cxx|cu|m|mm|" + "rc|def|r|odl|idl|hpj|bat|h|h\\+\\+|" + "hm|hpp|hxx|in|txx|inl)$"); + + // Choose whether to use a main dependency. + if (sourceFiles.find(source)) { + // The source looks like a real file. Use it as the main dependency. + for (std::string const& output : outputs) { + cmSourceFile* sf = this->AddCustomCommandToOutput( + output, depends, source, commandLines, comment, nullptr); + if (sf) { + addRuleFileToTarget(sf); + } + } + } else { + std::string no_main_dependency; + std::vector depends2 = depends; + depends2.push_back(source); + + // The source may not be a real file. Do not use a main dependency. + for (std::string const& output : outputs) { + cmSourceFile* sf = this->AddCustomCommandToOutput( + output, depends2, no_main_dependency, commandLines, comment, nullptr); + if (sf) { + addRuleFileToTarget(sf); } } } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3061dc6ac967e859424f81fb70bbc70a74246055 commit 3061dc6ac967e859424f81fb70bbc70a74246055 Author: Daniel Eiband AuthorDate: Sat Sep 14 21:44:42 2019 +0200 Commit: Daniel Eiband CommitDate: Tue Sep 17 22:52:32 2019 +0200 add_custom_command: Add tests for rejecting literal quotes in commands diff --git a/Tests/RunCMake/add_custom_command/AppendLiteralQuotes-result.txt b/Tests/RunCMake/add_custom_command/AppendLiteralQuotes-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/add_custom_command/AppendLiteralQuotes-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_custom_command/AppendLiteralQuotes-stderr.txt b/Tests/RunCMake/add_custom_command/AppendLiteralQuotes-stderr.txt new file mode 100644 index 0000000..503385f --- /dev/null +++ b/Tests/RunCMake/add_custom_command/AppendLiteralQuotes-stderr.txt @@ -0,0 +1,7 @@ +CMake Error at AppendLiteralQuotes.cmake:2 \(add_custom_command\): + COMMAND may not contain literal quotes: + + "c" + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/add_custom_command/AppendLiteralQuotes.cmake b/Tests/RunCMake/add_custom_command/AppendLiteralQuotes.cmake new file mode 100644 index 0000000..038fb3f --- /dev/null +++ b/Tests/RunCMake/add_custom_command/AppendLiteralQuotes.cmake @@ -0,0 +1,2 @@ +add_custom_command(OUTPUT a COMMAND b) +add_custom_command(OUTPUT a COMMAND "\"c\"" APPEND) diff --git a/Tests/RunCMake/add_custom_command/LiteralQuotes-result.txt b/Tests/RunCMake/add_custom_command/LiteralQuotes-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/add_custom_command/LiteralQuotes-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_custom_command/LiteralQuotes-stderr.txt b/Tests/RunCMake/add_custom_command/LiteralQuotes-stderr.txt new file mode 100644 index 0000000..e7d6155 --- /dev/null +++ b/Tests/RunCMake/add_custom_command/LiteralQuotes-stderr.txt @@ -0,0 +1,7 @@ +CMake Error at LiteralQuotes.cmake:1 \(add_custom_command\): + COMMAND may not contain literal quotes: + + "b" + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/add_custom_command/LiteralQuotes.cmake b/Tests/RunCMake/add_custom_command/LiteralQuotes.cmake new file mode 100644 index 0000000..046ddd9 --- /dev/null +++ b/Tests/RunCMake/add_custom_command/LiteralQuotes.cmake @@ -0,0 +1 @@ +add_custom_command(OUTPUT a COMMAND "\"b\"") diff --git a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake index 20097b7..270df2f 100644 --- a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake @@ -1,15 +1,18 @@ include(RunCMake) +run_cmake(AppendLiteralQuotes) run_cmake(AppendNoOutput) run_cmake(AppendNotOutput) run_cmake(BadArgument) run_cmake(GeneratedProperty) +run_cmake(LiteralQuotes) run_cmake(NoArguments) run_cmake(NoOutputOrTarget) run_cmake(OutputAndTarget) run_cmake(SourceByproducts) run_cmake(SourceUsesTerminal) run_cmake(TargetImported) +run_cmake(TargetLiteralQuotes) run_cmake(TargetNotInDir) if(${RunCMake_GENERATOR} MATCHES "Visual Studio ([^89]|[89][0-9])") diff --git a/Tests/RunCMake/add_custom_command/TargetLiteralQuotes-result.txt b/Tests/RunCMake/add_custom_command/TargetLiteralQuotes-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/add_custom_command/TargetLiteralQuotes-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_custom_command/TargetLiteralQuotes-stderr.txt b/Tests/RunCMake/add_custom_command/TargetLiteralQuotes-stderr.txt new file mode 100644 index 0000000..c4589b4 --- /dev/null +++ b/Tests/RunCMake/add_custom_command/TargetLiteralQuotes-stderr.txt @@ -0,0 +1,7 @@ +CMake Error at TargetLiteralQuotes.cmake:2 \(add_custom_command\): + COMMAND may not contain literal quotes: + + "b" + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/add_custom_command/TargetLiteralQuotes.cmake b/Tests/RunCMake/add_custom_command/TargetLiteralQuotes.cmake new file mode 100644 index 0000000..5f11ed1 --- /dev/null +++ b/Tests/RunCMake/add_custom_command/TargetLiteralQuotes.cmake @@ -0,0 +1,2 @@ +add_library(a) +add_custom_command(TARGET a POST_BUILD COMMAND "\"b\"") diff --git a/Tests/RunCMake/add_custom_target/LiteralQuotes-result.txt b/Tests/RunCMake/add_custom_target/LiteralQuotes-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/add_custom_target/LiteralQuotes-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_custom_target/LiteralQuotes-stderr.txt b/Tests/RunCMake/add_custom_target/LiteralQuotes-stderr.txt new file mode 100644 index 0000000..bc5187a --- /dev/null +++ b/Tests/RunCMake/add_custom_target/LiteralQuotes-stderr.txt @@ -0,0 +1,7 @@ +CMake Error at LiteralQuotes.cmake:1 \(add_custom_target\): + COMMAND may not contain literal quotes: + + "b" + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/add_custom_target/LiteralQuotes.cmake b/Tests/RunCMake/add_custom_target/LiteralQuotes.cmake new file mode 100644 index 0000000..9870608 --- /dev/null +++ b/Tests/RunCMake/add_custom_target/LiteralQuotes.cmake @@ -0,0 +1 @@ +add_custom_target(a COMMAND "\"b\"") diff --git a/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake index d80ca19..49c7d3e 100644 --- a/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake @@ -5,6 +5,7 @@ run_cmake(GeneratedProperty) run_cmake(NoArguments) run_cmake(BadTargetName) run_cmake(ByproductsNoCommand) +run_cmake(LiteralQuotes) run_cmake(UsesTerminalNoCommand) function(run_TargetOrder) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e893ab94baa29b4a21d3edd86174cd19d8cd5a1e commit e893ab94baa29b4a21d3edd86174cd19d8cd5a1e Author: Daniel Eiband AuthorDate: Sat Sep 14 15:29:59 2019 +0200 Commit: Daniel Eiband CommitDate: Tue Sep 17 22:50:25 2019 +0200 cmMakefile: Validate command line for all custom commands diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 6462c26..6707b1c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -837,7 +837,7 @@ bool cmMakefile::ValidateCustomCommand( return true; } -void cmMakefile::AddCustomCommandToTarget( +cmTarget* cmMakefile::AddCustomCommandToTarget( const std::string& target, const std::vector& byproducts, const std::vector& depends, const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type, @@ -880,26 +880,31 @@ void cmMakefile::AddCustomCommandToTarget( this->IssueMessage(messageType, e.str()); } - return; + return nullptr; } - cmTarget& t = ti->second; + cmTarget* t = &ti->second; if (objLibraryCommands == RejectObjectLibraryCommands && - t.GetType() == cmStateEnums::OBJECT_LIBRARY) { + t->GetType() == cmStateEnums::OBJECT_LIBRARY) { std::ostringstream e; e << "Target \"" << target << "\" is an OBJECT library " "that may not have PRE_BUILD, PRE_LINK, or POST_BUILD commands."; this->IssueMessage(MessageType::FATAL_ERROR, e.str()); - return; + return nullptr; } - if (t.GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (t->GetType() == cmStateEnums::INTERFACE_LIBRARY) { std::ostringstream e; e << "Target \"" << target << "\" is an INTERFACE library " "that may not have PRE_BUILD, PRE_LINK, or POST_BUILD commands."; this->IssueMessage(MessageType::FATAL_ERROR, e.str()); - return; + return nullptr; + } + + // Validate custom commands. + if (!this->ValidateCustomCommand(commandLines)) { + return t; } // Always create the byproduct sources and mark them generated. @@ -917,16 +922,18 @@ void cmMakefile::AddCustomCommandToTarget( cc.SetJobPool(job_pool); switch (type) { case cmTarget::PRE_BUILD: - t.AddPreBuildCommand(cc); + t->AddPreBuildCommand(cc); break; case cmTarget::PRE_LINK: - t.AddPreLinkCommand(cc); + t->AddPreLinkCommand(cc); break; case cmTarget::POST_BUILD: - t.AddPostBuildCommand(cc); + t->AddPostBuildCommand(cc); break; } - this->UpdateOutputToSourceMap(byproducts, &t); + this->UpdateOutputToSourceMap(byproducts, t); + + return t; } void cmMakefile::UpdateOutputToSourceMap( @@ -1175,9 +1182,12 @@ bool cmMakefile::AppendCustomCommandToOutput( // Lookup an existing command. if (cmSourceFile* sf = this->GetSourceFileWithOutput(output)) { if (cmCustomCommand* cc = sf->GetCustomCommand()) { - cc->AppendCommands(commandLines); - cc->AppendDepends(depends); - cc->AppendImplicitDepends(implicit_depends); + // Validate custom commands. + if (this->ValidateCustomCommand(commandLines)) { + cc->AppendCommands(commandLines); + cc->AppendDepends(depends); + cc->AppendImplicitDepends(implicit_depends); + } return true; } } @@ -1247,33 +1257,37 @@ cmTarget* cmMakefile::AddUtilityCommand( comment = ""; } - // Store the custom command in the target. - if (!commandLines.empty() || !depends.empty()) { - // Always create the byproduct sources and mark them generated. - this->CreateGeneratedSources(byproducts); - - std::string force = - cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles/", utilityName); - std::vector forced; - forced.push_back(force); - std::string no_main_dependency; - cmImplicitDependsList no_implicit_depends; - bool no_replace = false; - this->AddCustomCommandToOutput( - forced, byproducts, depends, no_main_dependency, no_implicit_depends, - commandLines, comment, workingDirectory, no_replace, escapeOldStyle, - uses_terminal, command_expand_lists, /*depfile=*/"", job_pool); - cmSourceFile* sf = target->AddSourceCMP0049(force); - - // The output is not actually created so mark it symbolic. - if (sf) { - sf->SetProperty("SYMBOLIC", "1"); - } else { - cmSystemTools::Error("Could not get source file entry for " + force); - } + // Validate custom commands. + if (!this->ValidateCustomCommand(commandLines) || + (commandLines.empty() && depends.empty())) { + return target; + } + + // Always create the byproduct sources and mark them generated. + this->CreateGeneratedSources(byproducts); - this->UpdateOutputToSourceMap(byproducts, target); + std::string force = + cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles/", utilityName); + std::vector forced; + forced.push_back(force); + std::string no_main_dependency; + cmImplicitDependsList no_implicit_depends; + bool no_replace = false; + this->AddCustomCommandToOutput( + forced, byproducts, depends, no_main_dependency, no_implicit_depends, + commandLines, comment, workingDirectory, no_replace, escapeOldStyle, + uses_terminal, command_expand_lists, /*depfile=*/"", job_pool); + cmSourceFile* sf = target->AddSourceCMP0049(force); + + // The output is not actually created so mark it symbolic. + if (sf) { + sf->SetProperty("SYMBOLIC", "1"); + } else { + cmSystemTools::Error("Could not get source file entry for " + force); } + + this->UpdateOutputToSourceMap(byproducts, target); + return target; } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 4a1af7d..ed118db 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -172,7 +172,7 @@ public: }; /** Add a custom command to the build. */ - void AddCustomCommandToTarget( + cmTarget* AddCustomCommandToTarget( const std::string& target, const std::vector& byproducts, const std::vector& depends, const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type, https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f1e846fddece96d76d4d6b53ff1ca8ed197af550 commit f1e846fddece96d76d4d6b53ff1ca8ed197af550 Author: Daniel Eiband AuthorDate: Sat Sep 14 14:16:14 2019 +0200 Commit: Daniel Eiband CommitDate: Tue Sep 17 22:50:25 2019 +0200 cmMakefile: Extract custom command validation method diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 564ac56..6462c26 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -821,6 +821,22 @@ void cmMakefile::ConfigureFinalPass() } } +bool cmMakefile::ValidateCustomCommand( + const cmCustomCommandLines& commandLines) const +{ + // TODO: More strict? + for (cmCustomCommandLine const& cl : commandLines) { + if (!cl.empty() && !cl[0].empty() && cl[0][0] == '"') { + std::ostringstream e; + e << "COMMAND may not contain literal quotes:\n " << cl[0] << "\n"; + this->IssueMessage(MessageType::FATAL_ERROR, e.str()); + return false; + } + } + + return true; +} + void cmMakefile::AddCustomCommandToTarget( const std::string& target, const std::vector& byproducts, const std::vector& depends, @@ -959,14 +975,9 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput( return nullptr; } - // Validate custom commands. TODO: More strict? - for (cmCustomCommandLine const& cl : commandLines) { - if (!cl.empty() && !cl[0].empty() && cl[0][0] == '"') { - std::ostringstream e; - e << "COMMAND may not contain literal quotes:\n " << cl[0] << "\n"; - this->IssueMessage(MessageType::FATAL_ERROR, e.str()); - return nullptr; - } + // Validate custom commands. + if (!this->ValidateCustomCommand(commandLines)) { + return nullptr; } // Always create the output sources and mark them generated. diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 28f5452..4a1af7d 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -1067,6 +1067,8 @@ private: bool atOnly, const char* filename, long line, bool replaceAt) const; + bool ValidateCustomCommand(const cmCustomCommandLines& commandLines) const; + void CreateGeneratedSources(const std::vector& outputs); /** https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4926ab24542d2c9e644feee88efd4a96f8bcab97 commit 4926ab24542d2c9e644feee88efd4a96f8bcab97 Author: Daniel Eiband AuthorDate: Fri Sep 6 19:17:37 2019 +0200 Commit: Daniel Eiband CommitDate: Tue Sep 17 22:50:25 2019 +0200 cmMakefile: Create all generated byproducts as known sources diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f35b999..564ac56 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -970,8 +970,8 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput( } // Always create the output sources and mark them generated. - this->CreateGeneratedSources(outputs, cmSourceFileLocationKind::Known); - this->CreateGeneratedSources(byproducts, cmSourceFileLocationKind::Known); + this->CreateGeneratedSources(outputs); + this->CreateGeneratedSources(byproducts); // Choose a source file on which to store the custom command. cmSourceFile* file = nullptr; @@ -1239,7 +1239,7 @@ cmTarget* cmMakefile::AddUtilityCommand( // Store the custom command in the target. if (!commandLines.empty() || !depends.empty()) { // Always create the byproduct sources and mark them generated. - this->CreateGeneratedSources(byproducts, cmSourceFileLocationKind::Known); + this->CreateGeneratedSources(byproducts); std::string force = cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles/", utilityName); @@ -3444,10 +3444,11 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName, } void cmMakefile::CreateGeneratedSources( - const std::vector& outputs, cmSourceFileLocationKind kind) + const std::vector& outputs) { for (std::string const& output : outputs) { - if (cmSourceFile* out = this->GetOrCreateSource(output, true, kind)) { + if (cmSourceFile* out = this->GetOrCreateSource( + output, true, cmSourceFileLocationKind::Known)) { out->SetProperty("GENERATED", "1"); } } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1944879..28f5452 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -1067,9 +1067,7 @@ private: bool atOnly, const char* filename, long line, bool replaceAt) const; - void CreateGeneratedSources( - const std::vector& outputs, - cmSourceFileLocationKind kind = cmSourceFileLocationKind::Ambiguous); + void CreateGeneratedSources(const std::vector& outputs); /** * See LinearGetSourceFileWithOutput for background information ----------------------------------------------------------------------- Summary of changes: Source/CMakeLists.txt | 2 - Source/cmComputeLinkInformation.cxx | 35 +++ Source/cmComputeLinkInformation.h | 6 + Source/cmCustomCommandGenerator.cxx | 41 ++- Source/cmCustomCommandGenerator.h | 1 + Source/cmExportBuildFileGenerator.cxx | 4 +- Source/cmExportCommand.cxx | 13 +- Source/cmExportInstallAndroidMKGenerator.cxx | 4 +- Source/cmExportInstallFileGenerator.cxx | 22 +- Source/cmExportSet.cxx | 27 +- Source/cmExportSet.h | 28 +- Source/cmExportSetMap.cxx | 31 --- Source/cmExportSetMap.h | 37 --- Source/cmFileAPICodemodel.cxx | 20 +- Source/cmGeneratorTarget.cxx | 2 +- Source/cmGlobalGenerator.h | 2 +- Source/cmInstallCommand.cxx | 21 +- Source/cmInstallExportGenerator.cxx | 2 +- Source/cmLinkLineComputer.cxx | 99 +++++-- Source/cmLinkLineComputer.h | 18 +- Source/cmLinkLineDeviceComputer.cxx | 41 ++- Source/cmLinkLineDeviceComputer.h | 8 +- Source/cmLocalGenerator.cxx | 36 ++- Source/cmLocalGenerator.h | 16 +- Source/cmLocalUnixMakefileGenerator3.cxx | 8 +- Source/cmMakefile.cxx | 306 ++++++++++++++------- Source/cmMakefile.h | 54 +++- Source/cmMakefileTargetGenerator.cxx | 31 +-- Source/cmNinjaTargetGenerator.cxx | 13 +- Source/cmTarget.cxx | 8 +- Source/cmTarget.h | 2 +- Tests/RunCMake/FileAPI/codemodel-v2-check.py | 40 ++- Tests/RunCMake/FileAPI/cxx/CMakeLists.txt | 1 + .../AppendLiteralQuotes-result.txt} | 0 .../AppendLiteralQuotes-stderr.txt | 7 + .../add_custom_command/AppendLiteralQuotes.cmake | 2 + .../LiteralQuotes-result.txt} | 0 .../add_custom_command/LiteralQuotes-stderr.txt | 7 + .../add_custom_command/LiteralQuotes.cmake | 1 + .../RunCMake/add_custom_command/RunCMakeTest.cmake | 3 + .../TargetLiteralQuotes-result.txt} | 0 .../TargetLiteralQuotes-stderr.txt | 7 + .../add_custom_command/TargetLiteralQuotes.cmake | 2 + .../LiteralQuotes-result.txt} | 0 .../add_custom_target/LiteralQuotes-stderr.txt | 7 + .../RunCMake/add_custom_target/LiteralQuotes.cmake | 1 + .../RunCMake/add_custom_target/RunCMakeTest.cmake | 1 + bootstrap | 1 - 48 files changed, 684 insertions(+), 334 deletions(-) delete mode 100644 Source/cmExportSetMap.cxx delete mode 100644 Source/cmExportSetMap.h copy Tests/RunCMake/{while/MissingArgument-result.txt => add_custom_command/AppendLiteralQuotes-result.txt} (100%) create mode 100644 Tests/RunCMake/add_custom_command/AppendLiteralQuotes-stderr.txt create mode 100644 Tests/RunCMake/add_custom_command/AppendLiteralQuotes.cmake copy Tests/RunCMake/{while/MissingArgument-result.txt => add_custom_command/LiteralQuotes-result.txt} (100%) create mode 100644 Tests/RunCMake/add_custom_command/LiteralQuotes-stderr.txt create mode 100644 Tests/RunCMake/add_custom_command/LiteralQuotes.cmake copy Tests/RunCMake/{while/MissingArgument-result.txt => add_custom_command/TargetLiteralQuotes-result.txt} (100%) create mode 100644 Tests/RunCMake/add_custom_command/TargetLiteralQuotes-stderr.txt create mode 100644 Tests/RunCMake/add_custom_command/TargetLiteralQuotes.cmake copy Tests/RunCMake/{while/MissingArgument-result.txt => add_custom_target/LiteralQuotes-result.txt} (100%) create mode 100644 Tests/RunCMake/add_custom_target/LiteralQuotes-stderr.txt create mode 100644 Tests/RunCMake/add_custom_target/LiteralQuotes.cmake hooks/post-receive -- CMake From kwrobot at kitware.com Fri Sep 20 10:38:00 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 20 Sep 2019 10:38:00 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1140-gdf0586d Message-ID: <20190920143800.12BFBA475F@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via df0586d8d5c99d870369f1f60f63431deb98a6ba (commit) via cd607ef5606cef0ffac822afe1dafa2615a5554d (commit) via 9d2ac86f45e6f05e8873a0cb3e5e61545fb7c8a7 (commit) via 14da7aedf2a3a8f5d25be9c577aaff01fa1f70b6 (commit) from 01d2944458289ac2601855b3fce2e3f66d850ed4 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=df0586d8d5c99d870369f1f60f63431deb98a6ba commit df0586d8d5c99d870369f1f60f63431deb98a6ba Merge: cd607ef 9d2ac86 Author: Brad King AuthorDate: Fri Sep 20 14:27:58 2019 +0000 Commit: Kitware Robot CommitDate: Fri Sep 20 10:29:16 2019 -0400 Merge topic 'pch-source-list' 9d2ac86f45 Precompile Headers: Add precompile header file to source list Acked-by: Kitware Robot Merge-request: !3832 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cd607ef5606cef0ffac822afe1dafa2615a5554d commit cd607ef5606cef0ffac822afe1dafa2615a5554d Merge: 01d2944 14da7ae Author: Brad King AuthorDate: Fri Sep 20 14:26:43 2019 +0000 Commit: Kitware Robot CommitDate: Fri Sep 20 10:28:04 2019 -0400 Merge topic 'smart_ptr/cmComputeLinkDepends' 14da7aedf2 cmComputeLinkDepends: remove manual memory deallocation Acked-by: Kitware Robot Merge-request: !3831 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9d2ac86f45e6f05e8873a0cb3e5e61545fb7c8a7 commit 9d2ac86f45e6f05e8873a0cb3e5e61545fb7c8a7 Author: Cristian Adam AuthorDate: Wed Sep 18 18:22:11 2019 +0200 Commit: Cristian Adam CommitDate: Thu Sep 19 13:23:00 2019 +0200 Precompile Headers: Add precompile header file to source list The precompile header file will be added to the list of files, and be part of the newly "Precompile Header File" source group. Also make sure the sources have the header as dependency. diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index afcd69f..521677a 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2375,6 +2375,14 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target, pch_sf->SetProperty("PCH_EXTENSION", pchExtension.c_str()); } + // Add pchHeader to source files, which will + // be grouped as "Precompile Header File" + auto pchHeader_sf = this->Makefile->GetOrCreateSource( + pchHeader, false, cmSourceFileLocationKind::Known); + std::string err; + pchHeader_sf->ResolveFullPath(&err); + target->AddSource(pchHeader); + for (auto& str : { std::ref(useOptionList), std::ref(createOptionList) }) { cmSystemTools::ReplaceString(str, "", pchHeader); cmSystemTools::ReplaceString(str, "", pchFile); @@ -2399,7 +2407,8 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target, } if (!this->GetGlobalGenerator()->IsXcode()) { - sf->SetProperty("OBJECT_DEPENDS", pchFile.c_str()); + sf->AppendProperty("OBJECT_DEPENDS", pchFile.c_str()); + sf->AppendProperty("OBJECT_DEPENDS", pchHeader.c_str()); sf->SetProperty("COMPILE_OPTIONS", useOptionList.c_str()); } } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index c593939..acae17a 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -104,6 +104,7 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator, this->AddSourceGroup("", "^.*$"); this->AddSourceGroup("Source Files", CM_SOURCE_REGEX); this->AddSourceGroup("Header Files", CM_HEADER_REGEX); + this->AddSourceGroup("Precompile Header File", CM_PCH_REGEX); this->AddSourceGroup("CMake Rules", "\\.rule$"); this->AddSourceGroup("Resources", CM_RESOURCE_REGEX); this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$"); diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index dd36d45..ff465c7 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -135,6 +135,8 @@ private: "hpj" \ "|bat)$" +#define CM_PCH_REGEX "cmake_pch\\.(h|hxx)$" + #define CM_RESOURCE_REGEX "\\.(pdf|plist|png|jpeg|jpg|storyboard|xcassets)$" #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=14da7aedf2a3a8f5d25be9c577aaff01fa1f70b6 commit 14da7aedf2a3a8f5d25be9c577aaff01fa1f70b6 Author: Tushar Maheshwari AuthorDate: Sun Sep 8 17:33:03 2019 +0530 Commit: Brad King CommitDate: Wed Sep 18 14:32:56 2019 -0400 cmComputeLinkDepends: remove manual memory deallocation - Replace owning raw `DependSetList` pointer with direct object. - Use an extra `bool Initialized` flag to imitate `nullptr` semantics. diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 2ee4ca2..08113de 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmComputeLinkDepends.h" -#include "cmAlgorithms.h" #include "cmComputeComponentGraph.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" @@ -201,10 +200,7 @@ cmComputeLinkDepends::cmComputeLinkDepends(const cmGeneratorTarget* target, this->CCG = nullptr; } -cmComputeLinkDepends::~cmComputeLinkDepends() -{ - cmDeleteAll(this->InferredDependSets); -} +cmComputeLinkDepends::~cmComputeLinkDepends() = default; void cmComputeLinkDepends::SetOldLinkDirMode(bool b) { @@ -285,7 +281,7 @@ std::map::iterator cmComputeLinkDepends::AllocateLinkEntry( item, static_cast(this->EntryList.size())); auto lei = this->LinkEntryIndex.insert(index_entry).first; this->EntryList.emplace_back(); - this->InferredDependSets.push_back(nullptr); + this->InferredDependSets.emplace_back(); this->EntryConstraintGraph.emplace_back(); return lei; } @@ -325,7 +321,7 @@ int cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item) this->BFSQueue.push(qe); } else if (!entry.IsFlag) { // The item dependencies are not known. We need to infer them. - this->InferredDependSets[index] = new DependSetList; + this->InferredDependSets[index].Initialized = true; } } @@ -538,7 +534,7 @@ void cmComputeLinkDepends::AddLinkEntries(int depender_index, } // If this item needs to have dependencies inferred, do so. - if (this->InferredDependSets[dependee_index]) { + if (this->InferredDependSets[dependee_index].Initialized) { // Make sure an entry exists to hold the set for the item. dependSets[dependee_index]; } @@ -546,7 +542,7 @@ void cmComputeLinkDepends::AddLinkEntries(int depender_index, // Store the inferred dependency sets discovered for this list. for (auto const& dependSet : dependSets) { - this->InferredDependSets[dependSet.first]->push_back(dependSet.second); + this->InferredDependSets[dependSet.first].push_back(dependSet.second); } } @@ -573,14 +569,14 @@ void cmComputeLinkDepends::InferDependencies() depender_index < this->InferredDependSets.size(); ++depender_index) { // Skip items for which dependencies do not need to be inferred or // for which the inferred dependency sets are empty. - DependSetList* sets = this->InferredDependSets[depender_index]; - if (!sets || sets->empty()) { + DependSetList& sets = this->InferredDependSets[depender_index]; + if (!sets.Initialized || sets.empty()) { continue; } // Intersect the sets for this item. - DependSet common = sets->front(); - for (DependSet const& i : cmMakeRange(*sets).advance(1)) { + DependSet common = sets.front(); + for (DependSet const& i : cmMakeRange(sets).advance(1)) { DependSet intersection; std::set_intersection(common.begin(), common.end(), i.begin(), i.end(), std::inserter(intersection, intersection.begin())); diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index f0ac771..203cc68 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -106,8 +106,9 @@ private: }; struct DependSetList : public std::vector { + bool Initialized = false; }; - std::vector InferredDependSets; + std::vector InferredDependSets; void InferDependencies(); // Ordering constraint graph adjacency list. ----------------------------------------------------------------------- Summary of changes: Source/cmComputeLinkDepends.cxx | 22 +++++++++------------- Source/cmComputeLinkDepends.h | 3 ++- Source/cmLocalGenerator.cxx | 11 ++++++++++- Source/cmMakefile.cxx | 1 + Source/cmSourceFile.h | 2 ++ 5 files changed, 24 insertions(+), 15 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Fri Sep 20 10:48:02 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 20 Sep 2019 10:48:02 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1143-gebb9346 Message-ID: <20190920144802.39B5AA2E1D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via ebb9346490741ddc2ce6f552bc1be57dfc730cfa (commit) via 4a08690ccf01dc36d44a55d1645d8281909ea092 (commit) via c688b401d3adaacc820ef4b589010e8aefa808b1 (commit) from df0586d8d5c99d870369f1f60f63431deb98a6ba (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ebb9346490741ddc2ce6f552bc1be57dfc730cfa commit ebb9346490741ddc2ce6f552bc1be57dfc730cfa Merge: df0586d 4a08690 Author: Brad King AuthorDate: Fri Sep 20 14:38:15 2019 +0000 Commit: Kitware Robot CommitDate: Fri Sep 20 10:38:43 2019 -0400 Merge topic 'cmake-system-headers' 4a08690ccf cmstd: Extend header c688b401d3 cmstd: Modernize CMake system headers Acked-by: Kitware Robot Merge-request: !3776 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4a08690ccf01dc36d44a55d1645d8281909ea092 commit 4a08690ccf01dc36d44a55d1645d8281909ea092 Author: Marc Chevrier AuthorDate: Thu Sep 5 12:47:02 2019 +0200 Commit: Brad King CommitDate: Fri Sep 20 10:01:56 2019 -0400 cmstd: Extend header diff --git a/Utilities/std/cm/iterator b/Utilities/std/cm/iterator index 083bce3..718f1d6 100644 --- a/Utilities/std/cm/iterator +++ b/Utilities/std/cm/iterator @@ -15,6 +15,11 @@ using std::make_reverse_iterator; using std::cbegin; using std::cend; + +using std::rbegin; +using std::rend; +using std::crbegin; +using std::crend; #else template std::reverse_iterator make_reverse_iterator(Iter it) @@ -44,10 +49,91 @@ constexpr auto cend(C const& c) noexcept(noexcept(std::end(c))) { return std::end(c); } + +// std::r{begin,end} backport from C++14 +template +# if !defined(_MSC_VER) || _MSC_VER >= 1900 +constexpr +# endif + auto + rbegin(C& c) -> decltype(c.rbegin()) +{ + return c.rbegin(); +} +template +# if !defined(_MSC_VER) || _MSC_VER >= 1900 +constexpr +# endif + auto + rbegin(C const& c) -> decltype(c.rbegin()) +{ + return c.rbegin(); +} +template +# if !defined(_MSC_VER) || _MSC_VER >= 1900 +constexpr +# endif + std::reverse_iterator + rbegin(T (&arr)[N]) +{ + return std::reverse_iterator(arr + N); +} + +template +# if !defined(_MSC_VER) || _MSC_VER >= 1900 +constexpr +# endif + auto + rend(C& c) -> decltype(c.rend()) +{ + return c.rend(); +} +template +# if !defined(_MSC_VER) || _MSC_VER >= 1900 +constexpr +# endif + auto + rend(C const& c) -> decltype(c.rend()) +{ + return c.rend(); +} +template +# if !defined(_MSC_VER) || _MSC_VER >= 1900 +constexpr +# endif + std::reverse_iterator + rend(T (&arr)[N]) +{ + return std::reverse_iterator(arr); +} + +// std::cr{begin,end} backport from C++14 +template +# if !defined(_MSC_VER) || _MSC_VER >= 1900 +constexpr +# endif + auto + crbegin(C const& c) -> decltype(cm::rbegin(c)) +{ + return cm::rbegin(c); +} + +template +# if !defined(_MSC_VER) || _MSC_VER >= 1900 +constexpr +# endif + auto + crend(C const& c) -> decltype(cm::rend(c)) +{ + return cm::rend(c); +} #endif #if __cplusplus >= 201703L || defined(_MSVC_LANG) && _MSVC_LANG >= 201703L using std::size; + +using std::empty; +using std::data; #else // std::size backport from C++17. @@ -71,6 +157,58 @@ constexpr return N; } +// std::empty backport from C++17. +template +# if defined(_MSC_VER) && _MSC_VER < 1900 +auto empty(C const& c) +# else +constexpr auto empty(C const& c) noexcept(noexcept(c.empty())) +# endif + -> decltype(c.empty()) +{ + return c.empty(); +} +template +# if defined(_MSC_VER) && _MSC_VER < 1900 +bool empty(const T (&)[N]) +# else +constexpr bool empty(const T (&)[N]) noexcept +# endif +{ + return false; +} + +// std::data backport from C++17. +template +# if defined(_MSC_VER) && _MSC_VER < 1900 +auto data(C const& c) +# else +constexpr auto data(C const& c) noexcept(noexcept(c.data())) +# endif + -> decltype(c.data()) +{ + return c.data(); +} +template +# if defined(_MSC_VER) && _MSC_VER < 1900 +auto data(C& c) +# else +constexpr auto data(C& c) noexcept(noexcept(c.data())) +# endif + -> decltype(c.data()) +{ + return c.data(); +} +template +# if defined(_MSC_VER) && _MSC_VER < 1900 +T* data(T (&)[N]) +# else +constexpr T* data(T (&arr)[N]) noexcept +# endif +{ + return arr; +} + #endif } // namespace cm https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c688b401d3adaacc820ef4b589010e8aefa808b1 commit c688b401d3adaacc820ef4b589010e8aefa808b1 Author: Marc Chevrier AuthorDate: Sun Aug 4 10:49:16 2019 +0200 Commit: Brad King CommitDate: Fri Sep 20 10:01:37 2019 -0400 cmstd: Modernize CMake system headers Provide a standardized way to handle the C++ "standard" headers customized to be used with current CMake C++ standard constraints. Offer under directory `cm` headers which can be used as direct replacements of the standard ones. For example: #include can be used safely for CMake development in place of the `` standard header. Fixes: #19491 diff --git a/CMakeLists.txt b/CMakeLists.txt index 21e8c46..da99a6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -368,11 +368,24 @@ macro (CMAKE_BUILD_UTILITIES) # Setup third-party libraries. # Everything in the tree should be able to include files from the # Utilities directory. + if (CMAKE_SYSTEM_NAME STREQUAL "AIX" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # using -isystem option generate error "template with C linkage" + include_directories("${CMake_SOURCE_DIR}/Utilities/std") + else() + include_directories(SYSTEM "${CMake_SOURCE_DIR}/Utilities/std") + endif() + include_directories( ${CMake_BINARY_DIR}/Utilities ${CMake_SOURCE_DIR}/Utilities ) + #--------------------------------------------------------------------- + # Build CMake std library for CMake and CTest. + set(CMAKE_STD_LIBRARY cmstd) + add_subdirectory(Utilities/std) + CMAKE_SET_TARGET_FOLDER(cmstd "Utilities/std") + # check for the use of system libraries versus builtin ones # (a macro defined in this file) CMAKE_HANDLE_SYSTEM_LIBRARIES() diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 65cd6c9..c7648f1 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -439,9 +439,6 @@ set(SRCS cmXMLWriter.h cmake.cxx cmake.h - cm_string_view.cxx - cm_string_view.hxx - cm_static_string_view.hxx cmCommand.cxx cmCommand.h @@ -683,13 +680,13 @@ set(SRCS cmWriteFileCommand.cxx cmWriteFileCommand.h + cm_static_string_view.hxx cm_get_date.h cm_get_date.c cm_utf8.h cm_utf8.c cm_codecvt.hxx cm_codecvt.cxx - cm_thread.hxx cmDuration.h cmDuration.cxx @@ -855,6 +852,7 @@ endforeach() # create a library used by the command line and the GUI add_library(CMakeLib ${SRCS}) target_link_libraries(CMakeLib cmsys + ${CMAKE_STD_LIBRARY} ${CMAKE_EXPAT_LIBRARIES} ${CMAKE_ZLIB_LIBRARIES} ${CMAKE_TAR_LIBRARIES} ${CMAKE_CURL_LIBRARIES} diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index f784832..683f275 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -11,8 +11,9 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmUuid.h" -#include "cm_string_view.hxx" + #include +#include #include "cmWIXDirectoriesSourceWriter.h" #include "cmWIXFeaturesSourceWriter.h" diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx index dd3caf9..7705d83 100644 --- a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx @@ -9,10 +9,10 @@ #include "cmSystemTools.h" #include "cmUuid.h" -#include "cm_sys_stat.h" - #include "cmCMakeToWixPath.h" +#include "cm_sys_stat.h" + cmWIXFilesSourceWriter::cmWIXFilesSourceWriter(cmCPackLog* logger, std::string const& filename, GuidType componentGuidType) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 0e64b5a..4f299f7 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -10,9 +10,11 @@ #include "cmGeneratedFileStream.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include "cm_sys_stat.h" #include "cmsys/Glob.hxx" + +#include "cm_sys_stat.h" + #include #include #include diff --git a/Source/CPack/cmCPackExternalGenerator.cxx b/Source/CPack/cmCPackExternalGenerator.cxx index 5dc6ace..05e5c21 100644 --- a/Source/CPack/cmCPackExternalGenerator.cxx +++ b/Source/CPack/cmCPackExternalGenerator.cxx @@ -17,7 +17,7 @@ #include #include -#include "cm_memory.hxx" +#include int cmCPackExternalGenerator::InitializeInternal() { diff --git a/Source/CPack/cmCPackExternalGenerator.h b/Source/CPack/cmCPackExternalGenerator.h index 176d6a9..b77e45b 100644 --- a/Source/CPack/cmCPackExternalGenerator.h +++ b/Source/CPack/cmCPackExternalGenerator.h @@ -4,6 +4,7 @@ #define cmCPackExternalGenerator_h #include "cmCPackGenerator.h" + #include "cm_sys_stat.h" #include diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index fc00b09..33026c1 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -10,9 +10,10 @@ #include #include +#include "cm_sys_stat.h" + #include "cmCPackComponentGroup.h" #include "cmSystemTools.h" -#include "cm_sys_stat.h" class cmCPackLog; class cmGlobalGenerator; diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index 992299a..cd65694 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -4,13 +4,14 @@ #include +#include "cm_sys_stat.h" + #include "cmCPackGenerator.h" #include "cmCPackLog.h" #include "cmDuration.h" #include "cmGeneratedFileStream.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include "cm_sys_stat.h" cmCPackOSXX11Generator::cmCPackOSXX11Generator() = default; diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index eb48c37..eb1e24c 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -8,11 +8,12 @@ #include #include +#include "cm_sys_stat.h" + #include "cmArchiveWrite.h" #include "cmCPackGenerator.h" #include "cmCPackLog.h" #include "cmSystemTools.h" -#include "cm_sys_stat.h" cmCPackSTGZGenerator::cmCPackSTGZGenerator() : cmCPackArchiveGenerator(cmArchiveWrite::CompressGZip, "paxr", ".sh") diff --git a/Source/CTest/cmCTestBuildCommand.h b/Source/CTest/cmCTestBuildCommand.h index a62c301..14f70bf 100644 --- a/Source/CTest/cmCTestBuildCommand.h +++ b/Source/CTest/cmCTestBuildCommand.h @@ -12,7 +12,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmCTestBuildHandler; class cmCTestGenericHandler; diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx index b9b90c8..5baeecd 100644 --- a/Source/CTest/cmCTestCVS.cxx +++ b/Source/CTest/cmCTestCVS.cxx @@ -7,10 +7,12 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmXMLWriter.h" -#include "cm_string_view.hxx" #include "cmsys/FStream.hxx" #include "cmsys/RegularExpression.hxx" + +#include + #include cmCTestCVS::cmCTestCVS(cmCTest* ct, std::ostream& log) diff --git a/Source/CTest/cmCTestConfigureCommand.h b/Source/CTest/cmCTestConfigureCommand.h index 4677c83..36ca7d5 100644 --- a/Source/CTest/cmCTestConfigureCommand.h +++ b/Source/CTest/cmCTestConfigureCommand.h @@ -11,7 +11,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmCTestGenericHandler; diff --git a/Source/CTest/cmCTestCoverageCommand.h b/Source/CTest/cmCTestCoverageCommand.h index 24b96c0..75aefdf 100644 --- a/Source/CTest/cmCTestCoverageCommand.h +++ b/Source/CTest/cmCTestCoverageCommand.h @@ -12,7 +12,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmCTestGenericHandler; diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h index 84250cb..4232b9e 100644 --- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h +++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h @@ -12,7 +12,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmExecutionStatus; diff --git a/Source/CTest/cmCTestMemCheckCommand.h b/Source/CTest/cmCTestMemCheckCommand.h index 837a687..5dad4e7 100644 --- a/Source/CTest/cmCTestMemCheckCommand.h +++ b/Source/CTest/cmCTestMemCheckCommand.h @@ -7,7 +7,7 @@ #include -#include "cm_memory.hxx" +#include #include "cmCTestTestCommand.h" #include "cmCommand.h" diff --git a/Source/CTest/cmCTestReadCustomFilesCommand.h b/Source/CTest/cmCTestReadCustomFilesCommand.h index db2ac5e..8199cbc 100644 --- a/Source/CTest/cmCTestReadCustomFilesCommand.h +++ b/Source/CTest/cmCTestReadCustomFilesCommand.h @@ -12,7 +12,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmExecutionStatus; diff --git a/Source/CTest/cmCTestRunScriptCommand.h b/Source/CTest/cmCTestRunScriptCommand.h index 6961f6e..d262a83 100644 --- a/Source/CTest/cmCTestRunScriptCommand.h +++ b/Source/CTest/cmCTestRunScriptCommand.h @@ -12,7 +12,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmExecutionStatus; diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 3629a50..d8a5923 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -20,7 +20,7 @@ #include #include -#include "cm_memory.hxx" +#include cmCTestRunTest::cmCTestRunTest(cmCTestMultiProcessHandler& multiHandler) : MultiTestHandler(multiHandler) diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 354e3c4..c988e3a 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -5,7 +5,7 @@ #include "cmsys/Directory.hxx" #include "cmsys/Process.h" -#include "cm_memory.hxx" +#include #include "cmCTest.h" #include "cmCTestBuildCommand.h" diff --git a/Source/CTest/cmCTestSleepCommand.h b/Source/CTest/cmCTestSleepCommand.h index 7b17081..b98079d 100644 --- a/Source/CTest/cmCTestSleepCommand.h +++ b/Source/CTest/cmCTestSleepCommand.h @@ -12,7 +12,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmExecutionStatus; diff --git a/Source/CTest/cmCTestStartCommand.h b/Source/CTest/cmCTestStartCommand.h index 7c71f36..598c937 100644 --- a/Source/CTest/cmCTestStartCommand.h +++ b/Source/CTest/cmCTestStartCommand.h @@ -13,7 +13,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmExecutionStatus; diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index d16aac0..2e2cf1a 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -13,7 +13,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmExecutionStatus; diff --git a/Source/CTest/cmCTestTestCommand.h b/Source/CTest/cmCTestTestCommand.h index d74136c..a9ba3ab 100644 --- a/Source/CTest/cmCTestTestCommand.h +++ b/Source/CTest/cmCTestTestCommand.h @@ -11,7 +11,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmCTestGenericHandler; diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 10f9f9b..ee0d8c8 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestTestHandler.h" -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmCTest.h" diff --git a/Source/CTest/cmCTestUpdateCommand.h b/Source/CTest/cmCTestUpdateCommand.h index 55c4b80..5b0e07e 100644 --- a/Source/CTest/cmCTestUpdateCommand.h +++ b/Source/CTest/cmCTestUpdateCommand.h @@ -11,7 +11,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmCTestGenericHandler; diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx index a6a3542..c4cb233 100644 --- a/Source/CTest/cmCTestUpdateHandler.cxx +++ b/Source/CTest/cmCTestUpdateHandler.cxx @@ -20,7 +20,7 @@ #include #include -#include "cm_memory.hxx" +#include static const char* cmCTestUpdateHandlerUpdateStrings[] = { "Unknown", "CVS", "SVN", "BZR", "GIT", "HG", "P4" diff --git a/Source/CTest/cmCTestUploadCommand.h b/Source/CTest/cmCTestUploadCommand.h index 9e49769..39314f2 100644 --- a/Source/CTest/cmCTestUploadCommand.h +++ b/Source/CTest/cmCTestUploadCommand.h @@ -12,7 +12,7 @@ #include #include -#include "cm_memory.hxx" +#include class cmCTestGenericHandler; diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h index 60b746c..06ea9f6 100644 --- a/Source/cmAlgorithms.h +++ b/Source/cmAlgorithms.h @@ -238,81 +238,4 @@ typename Range::const_iterator cmFindNot(Range const& r, T const& t) return std::find_if(r.begin(), r.end(), [&t](T const& i) { return i != t; }); } -template -std::reverse_iterator cmMakeReverseIterator(Iter it) -{ - return std::reverse_iterator(it); -} - -namespace cm { - -#if __cplusplus >= 201703L || defined(_MSVC_LANG) && _MSVC_LANG >= 201703L - -using std::size; - -#else - -// std::size backport from C++17. -template -# if !defined(_MSC_VER) || _MSC_VER >= 1900 -constexpr -# endif - auto - size(C const& c) -> decltype(c.size()) -{ - return c.size(); -} - -template -# if !defined(_MSC_VER) || _MSC_VER >= 1900 -constexpr -# endif - std::size_t - size(const T (&)[N]) throw() -{ - return N; -} - -#endif - -template -int isize(const T& t) -{ - return static_cast(cm::size(t)); -} - -#if __cplusplus >= 201402L || defined(_MSVC_LANG) && _MSVC_LANG >= 201402L - -using std::cbegin; -using std::cend; - -#else - -// std::c{begin,end} backport from C++14 -template -# if defined(_MSC_VER) && _MSC_VER < 1900 -auto cbegin(C const& c) -# else -constexpr auto cbegin(C const& c) noexcept(noexcept(std::begin(c))) -# endif - -> decltype(std::begin(c)) -{ - return std::begin(c); -} - -template -# if defined(_MSC_VER) && _MSC_VER < 1900 -auto cend(C const& c) -# else -constexpr auto cend(C const& c) noexcept(noexcept(std::end(c))) -# endif - -> decltype(std::end(c)) -{ - return std::end(c); -} - -#endif - -} // namespace cm - #endif diff --git a/Source/cmArgumentParser.h b/Source/cmArgumentParser.h index 6cfe946..b6798bc 100644 --- a/Source/cmArgumentParser.h +++ b/Source/cmArgumentParser.h @@ -6,7 +6,7 @@ #include "cmConfigure.h" // IWYU pragma: keep #include "cm_static_string_view.hxx" -#include "cm_string_view.hxx" +#include #include #include diff --git a/Source/cmBinUtilsLinuxELFLinker.cxx b/Source/cmBinUtilsLinuxELFLinker.cxx index 6316a29..a1125a9 100644 --- a/Source/cmBinUtilsLinuxELFLinker.cxx +++ b/Source/cmBinUtilsLinuxELFLinker.cxx @@ -15,7 +15,7 @@ #include -#include "cm_memory.hxx" +#include static std::string ReplaceOrigin(const std::string& rpath, const std::string& origin) diff --git a/Source/cmBinUtilsMacOSMachOLinker.cxx b/Source/cmBinUtilsMacOSMachOLinker.cxx index 7ff8584..b1f718b 100644 --- a/Source/cmBinUtilsMacOSMachOLinker.cxx +++ b/Source/cmBinUtilsMacOSMachOLinker.cxx @@ -12,7 +12,7 @@ #include #include -#include "cm_memory.hxx" +#include cmBinUtilsMacOSMachOLinker::cmBinUtilsMacOSMachOLinker( cmRuntimeDependencyArchive* archive) diff --git a/Source/cmBinUtilsWindowsPELinker.cxx b/Source/cmBinUtilsWindowsPELinker.cxx index 5a9ad66..bfafaeb 100644 --- a/Source/cmBinUtilsWindowsPELinker.cxx +++ b/Source/cmBinUtilsWindowsPELinker.cxx @@ -12,7 +12,7 @@ #include #include -#include "cm_memory.hxx" +#include #ifdef _WIN32 # include diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 5e17ce8..1031f40 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -29,7 +29,7 @@ # include // IWYU pragma: keep #endif -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmCTestBuildAndTestHandler.h" diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 38fcf5b..262590b 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -1,7 +1,7 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cm_memory.hxx" +#include #include "cmCommands.h" #include "cmPolicies.h" diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 2ee4ca2..ce2c0ae 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -23,7 +23,7 @@ #include #include -#include "cm_memory.hxx" +#include /* diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx index f9f9581..ff683ad 100644 --- a/Source/cmCryptoHash.cxx +++ b/Source/cmCryptoHash.cxx @@ -6,7 +6,7 @@ #include "cm_rhash.h" #include "cmsys/FStream.hxx" -#include "cm_memory.hxx" +#include static unsigned int const cmCryptoHashAlgoToId[] = { /* clang-format needs this comment to break after the opening brace */ diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h index 145ff91..05552bd 100644 --- a/Source/cmCryptoHash.h +++ b/Source/cmCryptoHash.h @@ -5,7 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include "cm_string_view.hxx" +#include #include #include diff --git a/Source/cmCustomCommandLines.h b/Source/cmCustomCommandLines.h index 213aeb1..ead5792 100644 --- a/Source/cmCustomCommandLines.h +++ b/Source/cmCustomCommandLines.h @@ -9,7 +9,7 @@ #include #include -#include "cm_string_view.hxx" // IWYU pragma: keep +#include // IWYU pragma: keep /** Data structure to represent a single command line. */ class cmCustomCommandLine : public std::vector diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index 2a117c1..32f47b0 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmDefinitions.h" -#include "cm_string_view.hxx" +#include #include #include diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index 008821d..72e88b5 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -5,11 +5,12 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include "cm_string_view.hxx" - #include "cmLinkedTree.h" + #include "cmString.hxx" +#include + #include #include #include diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx index 63a96d0..18b49b8 100644 --- a/Source/cmDependsJavaParserHelper.cxx +++ b/Source/cmDependsJavaParserHelper.cxx @@ -5,8 +5,8 @@ #include "cmDependsJavaLexer.h" #include "cmSystemTools.h" -#include "cm_string_view.hxx" #include "cmsys/FStream.hxx" +#include #include #include #include diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index 12f996d..06b5511 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -4,8 +4,8 @@ #include "cmAlgorithms.h" #include "cm_kwiml.h" -#include "cm_memory.hxx" #include "cmsys/FStream.hxx" +#include #include #include #include diff --git a/Source/cmExportCommand.h b/Source/cmExportCommand.h index 50463af..819a3c3 100644 --- a/Source/cmExportCommand.h +++ b/Source/cmExportCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index e588f7b..f9a28cd 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -24,7 +24,7 @@ #include #include -#include "cm_memory.hxx" +#include static std::string cmExportFileGeneratorEscape(std::string const& str) { diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx index bab394a..fd2401e 100644 --- a/Source/cmExportLibraryDependenciesCommand.cxx +++ b/Source/cmExportLibraryDependenciesCommand.cxx @@ -6,7 +6,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmExecutionStatus.h" #include "cmGeneratedFileStream.h" diff --git a/Source/cmFSPermissions.h b/Source/cmFSPermissions.h index 7a6e708..fef72e6 100644 --- a/Source/cmFSPermissions.h +++ b/Source/cmFSPermissions.h @@ -5,10 +5,10 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include "cm_sys_stat.h" - #include +#include "cm_sys_stat.h" + namespace cmFSPermissions { // Table of permissions flags. diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 4701d29..c7a0e55 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -20,7 +20,9 @@ #include #include -#include "cm_memory.hxx" +#include + +#include "cm_sys_stat.h" #include "cmAlgorithms.h" #include "cmArgumentParser.h" @@ -44,7 +46,6 @@ #include "cmSubcommandTable.h" #include "cmSystemTools.h" #include "cmTimestamp.h" -#include "cm_sys_stat.h" #include "cmake.h" #if !defined(CMAKE_BOOTSTRAP) diff --git a/Source/cmFileCopier.h b/Source/cmFileCopier.h index 263a365..8fc481c 100644 --- a/Source/cmFileCopier.h +++ b/Source/cmFileCopier.h @@ -6,9 +6,10 @@ #include "cmConfigure.h" // IWYU pragma: keep #include "cmFileTimeCache.h" -#include "cm_sys_stat.h" #include "cmsys/RegularExpression.hxx" +#include "cm_sys_stat.h" + #include #include diff --git a/Source/cmFileTimes.cxx b/Source/cmFileTimes.cxx index 3824e9b..54ac4ed 100644 --- a/Source/cmFileTimes.cxx +++ b/Source/cmFileTimes.cxx @@ -2,11 +2,11 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmFileTimes.h" -#include "cm_sys_stat.h" - #include -#include "cm_memory.hxx" +#include + +#include "cm_sys_stat.h" #if defined(_WIN32) # include "cmSystemTools.h" diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index fea7e08..17e9869 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -18,7 +18,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmMakefile.h" diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index d563a1d..44392ba 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -6,9 +6,10 @@ #include #include -#include "cm_memory.hxx" +#include +#include + #include "cm_static_string_view.hxx" -#include "cm_string_view.hxx" #include "cmExecutionStatus.h" #include "cmFunctionBlocker.h" diff --git a/Source/cmFunctionBlocker.h b/Source/cmFunctionBlocker.h index 87bdccd..59bb892 100644 --- a/Source/cmFunctionBlocker.h +++ b/Source/cmFunctionBlocker.h @@ -7,7 +7,7 @@ #include -#include "cm_string_view.hxx" +#include #include "cmListFileCache.h" diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index fdc5e50..b3ddfe0 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -5,9 +5,10 @@ #include #include -#include "cm_memory.hxx" +#include +#include + #include "cm_static_string_view.hxx" -#include "cm_string_view.hxx" #include "cmAlgorithms.h" #include "cmExecutionStatus.h" diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h index 06ebeac..c3bc4c8 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.h +++ b/Source/cmGeneratorExpressionEvaluationFile.h @@ -10,9 +10,10 @@ #include #include +#include "cm_sys_stat.h" + #include "cmGeneratorExpression.h" #include "cmPolicies.h" -#include "cm_sys_stat.h" class cmLocalGenerator; diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 6cb7a96..d524867 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -29,12 +29,13 @@ #include "cmsys/RegularExpression.hxx" #include "cmsys/String.h" +#include + #include #include #include #include #include -#include #include #include #include diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 3a321c5..136996e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -17,6 +17,8 @@ #include #include +#include + #include "cmAlgorithms.h" #include "cmComputeLinkInformation.h" #include "cmCustomCommand.h" @@ -42,7 +44,6 @@ #include "cmTarget.h" #include "cmTargetLinkLibraryType.h" #include "cmTargetPropertyComputer.h" -#include "cm_string_view.hxx" #include "cmake.h" class cmMessenger; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 9ce6324..7bba874 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -12,7 +12,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmDocumentationEntry.h" diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index c7a0330..0b211b8 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -7,7 +7,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmDocumentationEntry.h" diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index b355775..92316d3 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -11,10 +11,11 @@ #include "cmState.h" #include "cmStringAlgorithms.h" #include "cmUuid.h" -#include "cm_string_view.hxx" #include "cmake.h" #include "cmsys/Encoding.hxx" +#include + #include #include #include diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index a0ce740..61e8f58 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -10,7 +10,8 @@ #include #include -#include "cmAlgorithms.h" +#include + #include "cmCallVisualStudioMacro.h" #include "cmCustomCommand.h" #include "cmCustomCommandLines.h" diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 4d41fd7..643cc99 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -9,7 +9,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmComputeLinkInformation.h" diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index f719041..b36d96b 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -2,9 +2,10 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmIfCommand.h" -#include "cm_memory.hxx" +#include +#include + #include "cm_static_string_view.hxx" -#include "cm_string_view.hxx" #include "cmConditionEvaluator.h" #include "cmExecutionStatus.h" diff --git a/Source/cmIncludeDirectoryCommand.h b/Source/cmIncludeDirectoryCommand.h index 4df94eb..bcaae9d 100644 --- a/Source/cmIncludeDirectoryCommand.h +++ b/Source/cmIncludeDirectoryCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h index 28bf443..9ffb842 100644 --- a/Source/cmInstallCommand.h +++ b/Source/cmInstallCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" diff --git a/Source/cmLinkDirectoriesCommand.h b/Source/cmLinkDirectoriesCommand.h index 1a439de..489d90f 100644 --- a/Source/cmLinkDirectoriesCommand.h +++ b/Source/cmLinkDirectoriesCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 826abf5..7bf35c3 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -16,7 +16,8 @@ #include #include -#include "cm_memory.hxx" +#include + #include "cm_static_string_view.hxx" #include "cmAlgorithms.h" diff --git a/Source/cmLoadCacheCommand.h b/Source/cmLoadCacheCommand.h index 45e52f0..37f0372 100644 --- a/Source/cmLoadCacheCommand.h +++ b/Source/cmLoadCacheCommand.h @@ -9,7 +9,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx index 6f5df46..1e02632 100644 --- a/Source/cmLoadCommandCommand.cxx +++ b/Source/cmLoadCommandCommand.cxx @@ -10,7 +10,7 @@ #include -#include "cm_memory.hxx" +#include #include "cmCPluginAPI.cxx" #include "cmCPluginAPI.h" diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index afcd69f..840f55f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -30,7 +30,6 @@ #include "cmTarget.h" #include "cmTestGenerator.h" #include "cmVersion.h" -#include "cm_string_view.hxx" #include "cmake.h" #include "cmsys/RegularExpression.hxx" @@ -39,6 +38,8 @@ # include "cmCryptoHash.h" #endif +#include + #include #include #include diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index f80695d..6c1dfc9 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -9,7 +9,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmCustomCommand.h" // IWYU pragma: keep diff --git a/Source/cmMachO.cxx b/Source/cmMachO.cxx index bec3ad8..ee5eb00 100644 --- a/Source/cmMachO.cxx +++ b/Source/cmMachO.cxx @@ -9,7 +9,7 @@ #include #include -#include "cm_memory.hxx" +#include // Include the Mach-O format information system header. #include diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index af97761..ba9947a 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -5,9 +5,10 @@ #include #include -#include "cm_memory.hxx" +#include +#include + #include "cm_static_string_view.hxx" -#include "cm_string_view.hxx" #include "cmAlgorithms.h" #include "cmExecutionStatus.h" diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index c593939..c67c367 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -10,12 +10,11 @@ #include #include #include -#include -#include #include #include -#include "cm_memory.hxx" +#include +#include #include "cmAlgorithms.h" #include "cmCommandArgumentParserHelper.h" diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 6d695a7..bf405a5 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -17,7 +17,7 @@ #include #include -#include "cm_string_view.hxx" +#include #include "cmAlgorithms.h" #include "cmListFileCache.h" diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index e44ca7b..91bd47e 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmGeneratedFileStream.h" diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index b37a933..faa0d67 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmGeneratedFileStream.h" diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx index d4045b3..47e2665 100644 --- a/Source/cmMakefileUtilityTargetGenerator.cxx +++ b/Source/cmMakefileUtilityTargetGenerator.cxx @@ -7,7 +7,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmGeneratedFileStream.h" #include "cmGeneratorTarget.h" diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 97742c1..bd5abd1 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -10,7 +10,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmCustomCommand.h" // IWYU pragma: keep diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 37e9e0e..8c88f6c 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -11,7 +11,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmComputeLinkInformation.h" diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h index 671efe7..c2053c7 100644 --- a/Source/cmOutputConverter.h +++ b/Source/cmOutputConverter.h @@ -6,7 +6,8 @@ #include "cmConfigure.h" // IWYU pragma: keep #include "cmStateSnapshot.h" -#include "cm_string_view.hxx" + +#include #include diff --git a/Source/cmParseArgumentsCommand.cxx b/Source/cmParseArgumentsCommand.cxx index 0b320b6..c802fb4 100644 --- a/Source/cmParseArgumentsCommand.cxx +++ b/Source/cmParseArgumentsCommand.cxx @@ -14,7 +14,7 @@ #include "cmRange.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include "cm_string_view.hxx" +#include static std::string EscapeArg(const std::string& arg) { diff --git a/Source/cmProjectCommand.h b/Source/cmProjectCommand.h index 8b9bcc8..ffbd330 100644 --- a/Source/cmProjectCommand.h +++ b/Source/cmProjectCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" diff --git a/Source/cmQtAutoGen.h b/Source/cmQtAutoGen.h index 71969ee..2a28c1e 100644 --- a/Source/cmQtAutoGen.h +++ b/Source/cmQtAutoGen.h @@ -5,7 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include "cm_string_view.hxx" +#include #include #include diff --git a/Source/cmQtAutoGenGlobalInitializer.cxx b/Source/cmQtAutoGenGlobalInitializer.cxx index abc69d0..576a034 100644 --- a/Source/cmQtAutoGenGlobalInitializer.cxx +++ b/Source/cmQtAutoGenGlobalInitializer.cxx @@ -17,7 +17,7 @@ #include "cmSystemTools.h" #include "cmTarget.h" -#include "cm_memory.hxx" +#include #include diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index ad4e4d5..9045722 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -41,7 +41,7 @@ #include #include -#include "cm_memory.hxx" +#include namespace { diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h index bedda30..7ce9fad 100644 --- a/Source/cmQtAutoGenInitializer.h +++ b/Source/cmQtAutoGenInitializer.h @@ -6,7 +6,8 @@ #include "cmConfigure.h" // IWYU pragma: keep #include "cmGeneratedFileStream.h" #include "cmQtAutoGen.h" -#include "cm_string_view.hxx" + +#include #include #include diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx index 086b68c..eb829fa 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -2,7 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmQtAutoGenerator.h" -#include "cm_memory.hxx" +#include + #include "cmsys/FStream.hxx" #include "cmGlobalGenerator.h" diff --git a/Source/cmQtAutoGenerator.h b/Source/cmQtAutoGenerator.h index 371b25c..f60acb0 100644 --- a/Source/cmQtAutoGenerator.h +++ b/Source/cmQtAutoGenerator.h @@ -7,7 +7,8 @@ #include "cmFileTime.h" #include "cmQtAutoGen.h" -#include "cm_string_view.hxx" + +#include #include #include diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 4e4875e..5cd1ba1 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -2,6 +2,12 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmQtAutoMocUic.h" +#include +#include +#include + +#include + #include "cmAlgorithms.h" #include "cmCryptoHash.h" #include "cmGeneratedFileStream.h" @@ -9,13 +15,9 @@ #include "cmQtAutoGen.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include "cm_memory.hxx" #include "cmake.h" #include "cmsys/FStream.hxx" -#include -#include -#include #if defined(__APPLE__) # include #endif diff --git a/Source/cmQtAutoMocUic.h b/Source/cmQtAutoMocUic.h index 43123f2..15b66ca 100644 --- a/Source/cmQtAutoMocUic.h +++ b/Source/cmQtAutoMocUic.h @@ -9,9 +9,10 @@ #include "cmQtAutoGen.h" #include "cmQtAutoGenerator.h" #include "cmWorkerPool.h" -#include "cm_string_view.hxx" #include "cmsys/RegularExpression.hxx" +#include + #include #include #include diff --git a/Source/cmQtAutoRcc.cxx b/Source/cmQtAutoRcc.cxx index cd3e034..1bf8ca4 100644 --- a/Source/cmQtAutoRcc.cxx +++ b/Source/cmQtAutoRcc.cxx @@ -11,7 +11,8 @@ #include "cmQtAutoGen.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include "cm_string_view.hxx" + +#include #include diff --git a/Source/cmRuntimeDependencyArchive.cxx b/Source/cmRuntimeDependencyArchive.cxx index 1b3f387..ed2e3e4 100644 --- a/Source/cmRuntimeDependencyArchive.cxx +++ b/Source/cmRuntimeDependencyArchive.cxx @@ -27,7 +27,7 @@ #include #include -#include "cm_memory.hxx" +#include #if defined(_WIN32) static void AddVisualStudioPath(std::vector& paths, diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx index 9df1883..f150cf3 100644 --- a/Source/cmServer.cxx +++ b/Source/cmServer.cxx @@ -20,7 +20,8 @@ #include #include -#include "cm_memory.hxx" +#include +#include void on_signal(uv_signal_t* signal, int signum) { diff --git a/Source/cmServer.h b/Source/cmServer.h index ab2ad23..9b12604 100644 --- a/Source/cmServer.h +++ b/Source/cmServer.h @@ -5,11 +5,12 @@ #include "cmConfigure.h" // IWYU pragma: keep #include "cm_jsoncpp_value.h" -#include "cm_thread.hxx" #include "cm_uv.h" #include "cmUVHandlePtr.h" +#include + #include #include #include diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index d576f36..f889129 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -23,7 +23,7 @@ #include #include -#include "cm_memory.hxx" +#include // Get rid of some windows macros: #undef max diff --git a/Source/cmSetTargetPropertiesCommand.h b/Source/cmSetTargetPropertiesCommand.h index 7e4606e..e77b752 100644 --- a/Source/cmSetTargetPropertiesCommand.h +++ b/Source/cmSetTargetPropertiesCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" diff --git a/Source/cmSourceGroupCommand.h b/Source/cmSourceGroupCommand.h index 87a6114..6273d92 100644 --- a/Source/cmSourceGroupCommand.h +++ b/Source/cmSourceGroupCommand.h @@ -9,7 +9,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 7463bf8..93ad2d7 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -9,7 +9,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCacheManager.h" #include "cmCommand.h" diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx index ede00a0..1262f53 100644 --- a/Source/cmStateDirectory.cxx +++ b/Source/cmStateDirectory.cxx @@ -5,9 +5,10 @@ #include #include -#include #include +#include + #include "cmAlgorithms.h" #include "cmProperty.h" #include "cmPropertyMap.h" @@ -177,7 +178,7 @@ cmStringRange GetPropertyContent(T const& content, U contentEndPosition) { auto end = content.begin() + contentEndPosition; - auto rbegin = cmMakeReverseIterator(end); + auto rbegin = cm::make_reverse_iterator(end); rbegin = std::find(rbegin, content.rend(), cmPropertySentinal); return cmMakeRange(rbegin.base(), end); @@ -189,7 +190,7 @@ cmBacktraceRange GetPropertyBacktraces(T const& content, U const& backtraces, { auto entryEnd = content.begin() + contentEndPosition; - auto rbegin = cmMakeReverseIterator(entryEnd); + auto rbegin = cm::make_reverse_iterator(entryEnd); rbegin = std::find(rbegin, content.rend(), cmPropertySentinal); auto it = backtraces.begin() + std::distance(content.begin(), rbegin.base()); @@ -270,7 +271,7 @@ void cmStateDirectory::PrependIncludeDirectoriesEntry( this->Snapshot_.Position->IncludeDirectoryPosition; auto rend = this->DirectoryState->IncludeDirectories.rend(); - auto rbegin = cmMakeReverseIterator(entryEnd); + auto rbegin = cm::make_reverse_iterator(entryEnd); rbegin = std::find(rbegin, rend, cmPropertySentinal); auto entryIt = rbegin.base(); @@ -440,7 +441,7 @@ void cmStateDirectory::PrependLinkDirectoriesEntry( this->Snapshot_.Position->LinkDirectoriesPosition; auto rend = this->DirectoryState->LinkDirectories.rend(); - auto rbegin = cmMakeReverseIterator(entryEnd); + auto rbegin = cm::make_reverse_iterator(entryEnd); rbegin = std::find(rbegin, rend, cmPropertySentinal); auto entryIt = rbegin.base(); diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx index 28d5170..645907c 100644 --- a/Source/cmStateSnapshot.cxx +++ b/Source/cmStateSnapshot.cxx @@ -5,10 +5,10 @@ #include #include -#include #include -#include "cmAlgorithms.h" +#include + #include "cmDefinitions.h" #include "cmListFileCache.h" #include "cmPropertyMap.h" @@ -279,7 +279,7 @@ void InitializeContentFromParent(T& parentContent, T& thisContent, auto parentBegin = parentContent.begin(); auto parentEnd = parentContent.end(); - auto parentRbegin = cmMakeReverseIterator(parentEnd); + auto parentRbegin = cm::make_reverse_iterator(parentEnd); auto parentRend = parentContent.rend(); parentRbegin = std::find(parentRbegin, parentRend, cmPropertySentinal); auto parentIt = parentRbegin.base(); diff --git a/Source/cmStateSnapshot.h b/Source/cmStateSnapshot.h index da39127..021fd53 100644 --- a/Source/cmStateSnapshot.h +++ b/Source/cmStateSnapshot.h @@ -9,7 +9,7 @@ #include #include -#include "cm_string_view.hxx" +#include #include "cmLinkedTree.h" #include "cmPolicies.h" diff --git a/Source/cmString.hxx b/Source/cmString.hxx index a401ad1..6223b78 100644 --- a/Source/cmString.hxx +++ b/Source/cmString.hxx @@ -6,7 +6,7 @@ #include "cmConfigure.h" // IWYU pragma: keep #include "cm_static_string_view.hxx" -#include "cm_string_view.hxx" +#include #include #include diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h index cb6b8ba..6631e98 100644 --- a/Source/cmStringAlgorithms.h +++ b/Source/cmStringAlgorithms.h @@ -6,7 +6,9 @@ #include "cmConfigure.h" // IWYU pragma: keep #include "cmRange.h" -#include "cm_string_view.hxx" + +#include + #include #include #include diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 809d05e..28616c2 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -9,12 +9,12 @@ #include #include #include -#include #include +#include + #include "cm_static_string_view.hxx" -#include "cmAlgorithms.h" #include "cmCryptoHash.h" #include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" diff --git a/Source/cmSubcommandTable.h b/Source/cmSubcommandTable.h index 21342bb..6e39a1f 100644 --- a/Source/cmSubcommandTable.h +++ b/Source/cmSubcommandTable.h @@ -6,7 +6,8 @@ #include "cmConfigure.h" // IWYU pragma: keep #include "cm_static_string_view.hxx" -#include "cm_string_view.hxx" + +#include #include #include diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index e7eef33..108215c 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -8,9 +8,9 @@ #include "cmCryptoHash.h" #include "cmDuration.h" #include "cmProcessOutput.h" -#include "cm_string_view.hxx" #include "cmsys/Process.h" #include "cmsys/SystemTools.hxx" // IWYU pragma: export +#include #include #include #include diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8900ebf..ca12c87 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -12,7 +12,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmAlgorithms.h" #include "cmCustomCommand.h" diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h index 25af21d..f85dc0a 100644 --- a/Source/cmTargetCompileDefinitionsCommand.h +++ b/Source/cmTargetCompileDefinitionsCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" #include "cmTargetPropCommandBase.h" diff --git a/Source/cmTargetCompileFeaturesCommand.h b/Source/cmTargetCompileFeaturesCommand.h index 07948fa..39597ca 100644 --- a/Source/cmTargetCompileFeaturesCommand.h +++ b/Source/cmTargetCompileFeaturesCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" #include "cmTargetPropCommandBase.h" diff --git a/Source/cmTargetCompileOptionsCommand.h b/Source/cmTargetCompileOptionsCommand.h index a571cfb..b328ba2 100644 --- a/Source/cmTargetCompileOptionsCommand.h +++ b/Source/cmTargetCompileOptionsCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" #include "cmTargetPropCommandBase.h" diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h index 6defab2..f6481db 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.h +++ b/Source/cmTargetIncludeDirectoriesCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" #include "cmTargetPropCommandBase.h" diff --git a/Source/cmTargetLinkDirectoriesCommand.h b/Source/cmTargetLinkDirectoriesCommand.h index a2fcfa9..a651d73 100644 --- a/Source/cmTargetLinkDirectoriesCommand.h +++ b/Source/cmTargetLinkDirectoriesCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" #include "cmTargetPropCommandBase.h" diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index 6698ce0..caf2cf4 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" #include "cmTargetLinkLibraryType.h" diff --git a/Source/cmTargetLinkOptionsCommand.h b/Source/cmTargetLinkOptionsCommand.h index 3710739..918a8d7 100644 --- a/Source/cmTargetLinkOptionsCommand.h +++ b/Source/cmTargetLinkOptionsCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" #include "cmTargetPropCommandBase.h" diff --git a/Source/cmTargetPrecompileHeadersCommand.h b/Source/cmTargetPrecompileHeadersCommand.h index 1ddf2af..7e4558e 100644 --- a/Source/cmTargetPrecompileHeadersCommand.h +++ b/Source/cmTargetPrecompileHeadersCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" diff --git a/Source/cmTargetSourcesCommand.h b/Source/cmTargetSourcesCommand.h index 90fd45f..1cff8c3 100644 --- a/Source/cmTargetSourcesCommand.h +++ b/Source/cmTargetSourcesCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" #include "cmTargetPropCommandBase.h" diff --git a/Source/cmTryCompileCommand.h b/Source/cmTryCompileCommand.h index ec9f8b8..e525e85 100644 --- a/Source/cmTryCompileCommand.h +++ b/Source/cmTryCompileCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" #include "cmCoreTryCompile.h" diff --git a/Source/cmTryRunCommand.h b/Source/cmTryRunCommand.h index bacfcdb..c53a694 100644 --- a/Source/cmTryRunCommand.h +++ b/Source/cmTryRunCommand.h @@ -8,7 +8,7 @@ #include #include -#include "cm_memory.hxx" +#include #include "cmCommand.h" #include "cmCoreTryCompile.h" diff --git a/Source/cmUVProcessChain.cxx b/Source/cmUVProcessChain.cxx index 2c37a64..3adc47a 100644 --- a/Source/cmUVProcessChain.cxx +++ b/Source/cmUVProcessChain.cxx @@ -13,7 +13,7 @@ #include #include -#include "cm_memory.hxx" +#include struct cmUVProcessChain::InternalData { diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ba72294..4b83595 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -21,7 +21,7 @@ #include #include -#include "cm_memory.hxx" +#include static void ConvertToWindowsSlash(std::string& s); diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index 3e423e9..1139aa9 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -1,5 +1,7 @@ #include "cmVisualStudioGeneratorOptions.h" +#include + #include "cmAlgorithms.h" #include "cmLocalVisualStudioGenerator.h" #include "cmOutputConverter.h" @@ -269,8 +271,8 @@ void cmVisualStudioGeneratorOptions::FixManifestUACFlags() } if (keyValue[1].front() == '\'' && keyValue[1].back() == '\'') { - keyValue[1] = - keyValue[1].substr(1, std::max(0, cm::isize(keyValue[1]) - 2)); + keyValue[1] = keyValue[1].substr( + 1, std::max(std::string::size_type(0), keyValue[1].length() - 2)); } if (keyValue[0] == "level") { diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index a396852..bd71546 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -2,9 +2,10 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmWhileCommand.h" -#include "cm_memory.hxx" +#include +#include + #include "cm_static_string_view.hxx" -#include "cm_string_view.hxx" #include "cmConditionEvaluator.h" #include "cmExecutionStatus.h" diff --git a/Source/cmWorkerPool.cxx b/Source/cmWorkerPool.cxx index 5ac81df..9d279ab 100644 --- a/Source/cmWorkerPool.cxx +++ b/Source/cmWorkerPool.cxx @@ -17,7 +17,7 @@ #include #include -#include "cm_memory.hxx" +#include /** * @brief libuv pipe buffer class diff --git a/Source/cmWorkerPool.h b/Source/cmWorkerPool.h index bf07299..9179922 100644 --- a/Source/cmWorkerPool.h +++ b/Source/cmWorkerPool.h @@ -10,7 +10,7 @@ #include #include -#include "cm_memory.hxx" +#include // -- Types class cmWorkerPoolInternal; diff --git a/Source/cmWriteFileCommand.cxx b/Source/cmWriteFileCommand.cxx index fdf07bb..264dd3f 100644 --- a/Source/cmWriteFileCommand.cxx +++ b/Source/cmWriteFileCommand.cxx @@ -2,13 +2,14 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmWriteFileCommand.h" +#include "cm_sys_stat.h" + #include "cmsys/FStream.hxx" #include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include "cm_sys_stat.h" // cmLibraryCommand bool cmWriteFileCommand(std::vector const& args, diff --git a/Source/cm_static_string_view.hxx b/Source/cm_static_string_view.hxx index 1bef0c6..8351cd7 100644 --- a/Source/cm_static_string_view.hxx +++ b/Source/cm_static_string_view.hxx @@ -5,7 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include "cm_string_view.hxx" +#include #include diff --git a/Source/cm_sys_stat.h b/Source/cm_sys_stat.h index d3b9ef2..eb874c7 100644 --- a/Source/cm_sys_stat.h +++ b/Source/cm_sys_stat.h @@ -14,6 +14,6 @@ using gid_t = unsigned short; #include // include sys/stat.h after sys/types.h -#include +#include // IWYU pragma: export #endif diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 9a66805..96d903e 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2,7 +2,13 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmake.h" -#include "cm_memory.hxx" +#include +#include +#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW) +# include +#endif + +#include "cm_sys_stat.h" #include "cmAlgorithms.h" #include "cmCommands.h" @@ -28,8 +34,6 @@ #include "cmUtils.hxx" #include "cmVersionConfig.h" #include "cmWorkingDirectory.h" -#include "cm_string_view.hxx" -#include "cm_sys_stat.h" #if !defined(CMAKE_BOOTSTRAP) # include "cm_jsoncpp_writer.h" diff --git a/Tests/CMakeLib/testArgumentParser.cxx b/Tests/CMakeLib/testArgumentParser.cxx index 788fece..909f71b 100644 --- a/Tests/CMakeLib/testArgumentParser.cxx +++ b/Tests/CMakeLib/testArgumentParser.cxx @@ -4,7 +4,7 @@ #include "cmArgumentParser.h" #include "cm_static_string_view.hxx" -#include "cm_string_view.hxx" +#include #include #include diff --git a/Tests/CMakeLib/testOptional.cxx b/Tests/CMakeLib/testOptional.cxx index a5e30fb..cefe9fa 100644 --- a/Tests/CMakeLib/testOptional.cxx +++ b/Tests/CMakeLib/testOptional.cxx @@ -1,9 +1,8 @@ -#include "cm_optional.hxx" -#include "cm_utility.hxx" +#include +#include #include #include -#include #include class EventLogger; diff --git a/Tests/CMakeLib/testString.cxx b/Tests/CMakeLib/testString.cxx index 075892f..3b47a9c 100644 --- a/Tests/CMakeLib/testString.cxx +++ b/Tests/CMakeLib/testString.cxx @@ -4,7 +4,7 @@ #include "cmString.hxx" #include "cm_static_string_view.hxx" -#include "cm_string_view.hxx" +#include #include #include diff --git a/Tests/CMakeLib/testStringAlgorithms.cxx b/Tests/CMakeLib/testStringAlgorithms.cxx index a92a910..4e48f6e 100644 --- a/Tests/CMakeLib/testStringAlgorithms.cxx +++ b/Tests/CMakeLib/testStringAlgorithms.cxx @@ -3,7 +3,8 @@ #include // IWYU pragma: keep -#include "cm_string_view.hxx" +#include + #include #include #include diff --git a/Tests/CMakeLib/testUVProcessChain.cxx b/Tests/CMakeLib/testUVProcessChain.cxx index 63c9943..8cee49d 100644 --- a/Tests/CMakeLib/testUVProcessChain.cxx +++ b/Tests/CMakeLib/testUVProcessChain.cxx @@ -15,7 +15,7 @@ #include -#include "cm_memory.hxx" +#include struct ExpectedStatus { diff --git a/Utilities/IWYU/mapping.imp b/Utilities/IWYU/mapping.imp index 78026fa..ef31e8b 100644 --- a/Utilities/IWYU/mapping.imp +++ b/Utilities/IWYU/mapping.imp @@ -95,7 +95,6 @@ { include: [ "", public, "\"cm_kwiml.h\"", public ] }, # Self-sufficient wrapper for - { include: [ "", public, "\"cm_sys_stat.h\"", public ] }, { symbol: [ "mode_t", private, "\"cm_sys_stat.h\"", public ] }, # Wrappers for 3rd-party libraries used from the system. diff --git a/Utilities/std/.gitattributes b/Utilities/std/.gitattributes new file mode 100644 index 0000000..cd20549 --- /dev/null +++ b/Utilities/std/.gitattributes @@ -0,0 +1 @@ +cm/* our-c-style diff --git a/Utilities/std/CMakeLists.txt b/Utilities/std/CMakeLists.txt new file mode 100644 index 0000000..63c0a60 --- /dev/null +++ b/Utilities/std/CMakeLists.txt @@ -0,0 +1,10 @@ + +# source files for CMake std library +set(SRCS cm/bits/string_view.cxx + cm/memory + cm/optional + cm/shared_mutex + cm/string_view + cm/utility) + +add_library(cmstd STATIC ${SRCS}) diff --git a/Source/cm_string_view.cxx b/Utilities/std/cm/bits/string_view.cxx similarity index 99% rename from Source/cm_string_view.cxx rename to Utilities/std/cm/bits/string_view.cxx index 61fa80e..3b283da 100644 --- a/Source/cm_string_view.cxx +++ b/Utilities/std/cm/bits/string_view.cxx @@ -1,7 +1,7 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cm_string_view.hxx" +#include // IWYU pragma: associated #ifndef CMake_HAVE_CXX_STRING_VIEW diff --git a/Utilities/std/cm/iterator b/Utilities/std/cm/iterator new file mode 100644 index 0000000..083bce3 --- /dev/null +++ b/Utilities/std/cm/iterator @@ -0,0 +1,78 @@ +// -*-c++-*- +// vim: set ft=cpp: + +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cm_iterator +#define cm_iterator + +#include // IWYU pragma: export + +namespace cm { + +#if __cplusplus >= 201402L || defined(_MSVC_LANG) && _MSVC_LANG >= 201402L +using std::make_reverse_iterator; + +using std::cbegin; +using std::cend; +#else +template +std::reverse_iterator make_reverse_iterator(Iter it) +{ + return std::reverse_iterator(it); +} + +// std::c{begin,end} backport from C++14 +template +# if defined(_MSC_VER) && _MSC_VER < 1900 +auto cbegin(C const& c) +# else +constexpr auto cbegin(C const& c) noexcept(noexcept(std::begin(c))) +# endif + -> decltype(std::begin(c)) +{ + return std::begin(c); +} + +template +# if defined(_MSC_VER) && _MSC_VER < 1900 +auto cend(C const& c) +# else +constexpr auto cend(C const& c) noexcept(noexcept(std::end(c))) +# endif + -> decltype(std::end(c)) +{ + return std::end(c); +} +#endif + +#if __cplusplus >= 201703L || defined(_MSVC_LANG) && _MSVC_LANG >= 201703L +using std::size; +#else + +// std::size backport from C++17. +template +# if !defined(_MSC_VER) || _MSC_VER >= 1900 +constexpr +# endif + auto + size(C const& c) -> decltype(c.size()) +{ + return c.size(); +} + +template +# if !defined(_MSC_VER) || _MSC_VER >= 1900 +constexpr +# endif + std::size_t + size(const T (&)[N]) throw() +{ + return N; +} + +#endif + +} // namespace cm + +#endif diff --git a/Source/cm_memory.hxx b/Utilities/std/cm/memory similarity index 85% rename from Source/cm_memory.hxx rename to Utilities/std/cm/memory index 9f5e678..8ebded2 100644 --- a/Source/cm_memory.hxx +++ b/Utilities/std/cm/memory @@ -1,9 +1,10 @@ +// -*-c++-*- +// vim: set ft=cpp: + /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cm_memory_hxx -#define cm_memory_hxx - -#include "cmConfigure.h" // IWYU pragma: keep +#ifndef cm_memory +#define cm_memory #include // IWYU pragma: export #if !defined(CMake_HAVE_CXX_MAKE_UNIQUE) diff --git a/Source/cm_optional.hxx b/Utilities/std/cm/optional similarity index 97% rename from Source/cm_optional.hxx rename to Utilities/std/cm/optional index 295571d..80b0951 100644 --- a/Source/cm_optional.hxx +++ b/Utilities/std/cm/optional @@ -1,20 +1,21 @@ +// -*-c++-*- +// vim: set ft=cpp: + /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cm_optional_hxx -#define cm_optional_hxx - -#include "cmConfigure.h" // IWYU pragma: keep +#ifndef cm_optional +#define cm_optional #if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) # define CMake_HAVE_CXX_OPTIONAL #endif #if defined(CMake_HAVE_CXX_OPTIONAL) -# include +# include // IWYU pragma: export #else -# include "cm_utility.hxx" # include -# include + +# include #endif namespace cm { diff --git a/Source/cm_thread.hxx b/Utilities/std/cm/shared_mutex similarity index 52% rename from Source/cm_thread.hxx rename to Utilities/std/cm/shared_mutex index b1f0645..2ac9447 100644 --- a/Source/cm_thread.hxx +++ b/Utilities/std/cm/shared_mutex @@ -1,18 +1,36 @@ +// -*-c++-*- +// vim: set ft=cpp: + /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef CM_THREAD_HXX -#define CM_THREAD_HXX +#ifndef cm_shared_mutex +#define cm_shared_mutex -#include "cmConfigure.h" // IWYU pragma: keep -#include "cm_uv.h" +#if __cplusplus >= 201402L || defined(_MSVC_LANG) && _MSVC_LANG >= 201402L +# define CMake_HAVE_CXX_SHARED_LOCK +#endif +#if __cplusplus >= 201703L || defined(_MSVC_LANG) && _MSVC_LANG >= 201703L +# define CMake_HAVE_CXX_SHARED_MUTEX +#endif -namespace cm { +#if defined(CMake_HAVE_CXX_SHARED_LOCK) +# include // IWYU pragma: export +#endif +#if !defined(CMake_HAVE_CXX_SHARED_MUTEX) +# include "cm_uv.h" +#endif +namespace cm { +#if defined(CMake_HAVE_CXX_SHARED_MUTEX) +using std::shared_mutex; +#else class shared_mutex { uv_rwlock_t _M_; public: + using native_handle_type = uv_rwlock_t*; + shared_mutex() { uv_rwlock_init(&_M_); } ~shared_mutex() { uv_rwlock_destroy(&_M_); } @@ -20,18 +38,27 @@ public: shared_mutex& operator=(shared_mutex const&) = delete; void lock() { uv_rwlock_wrlock(&_M_); } + bool try_lock() { return uv_rwlock_trywrlock(&_M_) == 0; } void unlock() { uv_rwlock_wrunlock(&_M_); } void lock_shared() { uv_rwlock_rdlock(&_M_); } void unlock_shared() { uv_rwlock_rdunlock(&_M_); } + + native_handle_type native_handle() { return &_M_; } }; +#endif +#if defined(CMake_HAVE_CXX_SHARED_LOCK) +using std::shared_lock; +#else template class shared_lock { T& _mutex; public: + using mutex_type = T; + shared_lock(T& m) : _mutex(m) { @@ -43,6 +70,7 @@ public: shared_lock(shared_lock const&) = delete; shared_lock& operator=(shared_lock const&) = delete; }; +#endif } #endif diff --git a/Source/cm_string_view.hxx b/Utilities/std/cm/string_view similarity index 98% rename from Source/cm_string_view.hxx rename to Utilities/std/cm/string_view index 04de797..4d359cb 100644 --- a/Source/cm_string_view.hxx +++ b/Utilities/std/cm/string_view @@ -1,16 +1,17 @@ +// -*-c++-*- +// vim: set ft=cpp: + /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cm_string_view_hxx -#define cm_string_view_hxx - -#include "cmConfigure.h" // IWYU pragma: keep +#ifndef cm_string_view +#define cm_string_view #if __cplusplus >= 201703L || defined(_MSVC_LANG) && _MSVC_LANG >= 201703L # define CMake_HAVE_CXX_STRING_VIEW #endif #ifdef CMake_HAVE_CXX_STRING_VIEW -# include +# include // IWYU pragma: export namespace cm { using std::string_view; } diff --git a/Source/cm_utility.hxx b/Utilities/std/cm/utility similarity index 75% rename from Source/cm_utility.hxx rename to Utilities/std/cm/utility index 99d7f8b..3acac4f 100644 --- a/Source/cm_utility.hxx +++ b/Utilities/std/cm/utility @@ -1,17 +1,16 @@ +// -*-c++-*- +// vim: set ft=cpp: + /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cm_utility_hxx -#define cm_utility_hxx - -#include "cmConfigure.h" // IWYU pragma: keep +#ifndef cm_utility +#define cm_utility #if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) # define CMake_HAVE_CXX_IN_PLACE #endif -#if defined(CMake_HAVE_CXX_IN_PLACE) -# include -#endif +#include // IWYU pragma: export namespace cm { diff --git a/bootstrap b/bootstrap index 9504250..123e256 100755 --- a/bootstrap +++ b/bootstrap @@ -453,7 +453,6 @@ CMAKE_CXX_SOURCES="\ cmake \ cmakemain \ cmcmd \ - cm_string_view \ " if ${cmake_system_mingw}; then @@ -464,6 +463,17 @@ if ${cmake_system_mingw}; then " fi +CMAKE_STD_CXX_HEADERS="\ + memory \ + optional \ + shared_mutex \ + string_view \ + utility \ +" +CMAKE_STD_CXX_SOURCES="\ + string_view \ +" + LexerParser_CXX_SOURCES="\ cmCommandArgumentLexer \ cmCommandArgumentParser \ @@ -1346,6 +1356,8 @@ cmake_compiler_settings_comment="/* * * Sources: * ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} + * STD Sources: + * ${CMAKE_STD_CXX_HEADERS} ${CMAKE_STD_CXX_SOURCES} * LexerParser Sources: * ${LexerParser_CXX_SOURCES} ${LexerParser_C_SOURCES} * kwSys Sources: @@ -1412,9 +1424,12 @@ done cmake_generate_file "${cmake_bootstrap_dir}/cmThirdParty.h" "" # Generate Makefile -dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h" +dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.hxx `cmake_escape \"${cmake_source_dir}\"`/Source/*.h" +for h in ${CMAKE_STD_CXX_HEADERS}; do + dep="${dep} `cmake_escape \"${cmake_source_dir}\"`/Utilities/std/cm/${h}" +done objs="" -for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${LexerParser_CXX_SOURCES} ${LexerParser_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}; do +for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${CMAKE_STD_CXX_SOURCES} ${LexerParser_CXX_SOURCES} ${LexerParser_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}; do objs="${objs} ${a}.o" done for a in ${LIBUV_C_SOURCES}; do @@ -1498,6 +1513,7 @@ cmake_cxx_flags="${cmake_cxx_flags} \ -I`cmake_escape \"${cmake_bootstrap_dir}\"` \ -I`cmake_escape \"${cmake_source_dir}/Source\"` \ -I`cmake_escape \"${cmake_source_dir}/Source/LexerParser\"` \ + -I`cmake_escape \"${cmake_source_dir}/Utilities/std\"` \ -I`cmake_escape \"${cmake_source_dir}/Utilities\"`" echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile" echo " ${cmake_cxx_compiler} ${cmake_ld_flags} ${cmake_cxx_flags} ${objs} ${libs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile" @@ -1512,6 +1528,12 @@ for a in ${CMAKE_C_SOURCES}; do echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" echo " ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile" done +for a in ${CMAKE_STD_CXX_SOURCES}; do + src=`cmake_escape "${cmake_source_dir}/Utilities/std/cm/bits/${a}.cxx"` + src_flags=`eval echo \\${cmake_cxx_flags_\${a}}` + echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile" + echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile" +done for a in ${LexerParser_CXX_SOURCES}; do src=`cmake_escape "${cmake_source_dir}/Source/LexerParser/${a}.cxx"` src_flags=`eval echo \\${cmake_cxx_flags_\${a}}` ----------------------------------------------------------------------- Summary of changes: CMakeLists.txt | 13 ++ Source/CMakeLists.txt | 6 +- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 3 +- Source/CPack/WiX/cmWIXFilesSourceWriter.cxx | 4 +- Source/CPack/cmCPackDebGenerator.cxx | 4 +- Source/CPack/cmCPackExternalGenerator.cxx | 2 +- Source/CPack/cmCPackExternalGenerator.h | 1 + Source/CPack/cmCPackGenerator.h | 3 +- Source/CPack/cmCPackOSXX11Generator.cxx | 3 +- Source/CPack/cmCPackSTGZGenerator.cxx | 3 +- Source/CTest/cmCTestBuildCommand.h | 2 +- Source/CTest/cmCTestCVS.cxx | 4 +- Source/CTest/cmCTestConfigureCommand.h | 2 +- Source/CTest/cmCTestCoverageCommand.h | 2 +- Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h | 2 +- Source/CTest/cmCTestMemCheckCommand.h | 2 +- Source/CTest/cmCTestReadCustomFilesCommand.h | 2 +- Source/CTest/cmCTestRunScriptCommand.h | 2 +- Source/CTest/cmCTestRunTest.cxx | 2 +- Source/CTest/cmCTestScriptHandler.cxx | 2 +- Source/CTest/cmCTestSleepCommand.h | 2 +- Source/CTest/cmCTestStartCommand.h | 2 +- Source/CTest/cmCTestSubmitCommand.cxx | 2 +- Source/CTest/cmCTestTestCommand.h | 2 +- Source/CTest/cmCTestTestHandler.cxx | 2 +- Source/CTest/cmCTestUpdateCommand.h | 2 +- Source/CTest/cmCTestUpdateHandler.cxx | 2 +- Source/CTest/cmCTestUploadCommand.h | 2 +- Source/cmAlgorithms.h | 77 -------- Source/cmArgumentParser.h | 2 +- Source/cmBinUtilsLinuxELFLinker.cxx | 2 +- Source/cmBinUtilsMacOSMachOLinker.cxx | 2 +- Source/cmBinUtilsWindowsPELinker.cxx | 2 +- Source/cmCTest.cxx | 2 +- Source/cmCommands.cxx | 2 +- Source/cmComputeLinkDepends.cxx | 2 +- Source/cmCryptoHash.cxx | 2 +- Source/cmCryptoHash.h | 2 +- Source/cmCustomCommandLines.h | 2 +- Source/cmDefinitions.cxx | 2 +- Source/cmDefinitions.h | 5 +- Source/cmDependsJavaParserHelper.cxx | 2 +- Source/cmELF.cxx | 2 +- Source/cmExportCommand.h | 2 +- Source/cmExportFileGenerator.cxx | 2 +- Source/cmExportLibraryDependenciesCommand.cxx | 2 +- Source/cmFSPermissions.h | 4 +- Source/cmFileCommand.cxx | 5 +- Source/cmFileCopier.h | 3 +- Source/cmFileTimes.cxx | 6 +- Source/cmFindPackageCommand.cxx | 2 +- Source/cmForEachCommand.cxx | 5 +- Source/cmFunctionBlocker.h | 2 +- Source/cmFunctionCommand.cxx | 5 +- Source/cmGeneratorExpressionEvaluationFile.h | 3 +- Source/cmGeneratorExpressionNode.cxx | 3 +- Source/cmGeneratorTarget.cxx | 3 +- Source/cmGlobalNinjaGenerator.cxx | 2 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 2 +- Source/cmGlobalVisualStudio7Generator.cxx | 3 +- Source/cmGlobalVisualStudioGenerator.cxx | 3 +- Source/cmGlobalXCodeGenerator.cxx | 2 +- Source/cmIfCommand.cxx | 5 +- Source/cmIncludeDirectoryCommand.h | 2 +- Source/cmInstallCommand.h | 2 +- Source/cmLinkDirectoriesCommand.h | 2 +- Source/cmListCommand.cxx | 3 +- Source/cmLoadCacheCommand.h | 2 +- Source/cmLoadCommandCommand.cxx | 2 +- Source/cmLocalGenerator.cxx | 3 +- Source/cmLocalUnixMakefileGenerator3.cxx | 2 +- Source/cmMachO.cxx | 2 +- Source/cmMacroCommand.cxx | 5 +- Source/cmMakefile.cxx | 5 +- Source/cmMakefile.h | 2 +- Source/cmMakefileExecutableTargetGenerator.cxx | 2 +- Source/cmMakefileLibraryTargetGenerator.cxx | 2 +- Source/cmMakefileUtilityTargetGenerator.cxx | 2 +- Source/cmNinjaNormalTargetGenerator.cxx | 2 +- Source/cmNinjaTargetGenerator.cxx | 2 +- Source/cmOutputConverter.h | 3 +- Source/cmParseArgumentsCommand.cxx | 2 +- Source/cmProjectCommand.h | 2 +- Source/cmQtAutoGen.h | 2 +- Source/cmQtAutoGenGlobalInitializer.cxx | 2 +- Source/cmQtAutoGenInitializer.cxx | 2 +- Source/cmQtAutoGenInitializer.h | 3 +- Source/cmQtAutoGenerator.cxx | 3 +- Source/cmQtAutoGenerator.h | 3 +- Source/cmQtAutoMocUic.cxx | 10 +- Source/cmQtAutoMocUic.h | 3 +- Source/cmQtAutoRcc.cxx | 3 +- Source/cmRuntimeDependencyArchive.cxx | 2 +- Source/cmServer.cxx | 3 +- Source/cmServer.h | 3 +- Source/cmServerProtocol.cxx | 2 +- Source/cmSetTargetPropertiesCommand.h | 2 +- Source/cmSourceGroupCommand.h | 2 +- Source/cmState.cxx | 2 +- Source/cmStateDirectory.cxx | 11 +- Source/cmStateSnapshot.cxx | 6 +- Source/cmStateSnapshot.h | 2 +- Source/cmString.hxx | 2 +- Source/cmStringAlgorithms.h | 4 +- Source/cmStringCommand.cxx | 4 +- Source/cmSubcommandTable.h | 3 +- Source/cmSystemTools.h | 2 +- Source/cmTarget.cxx | 2 +- Source/cmTargetCompileDefinitionsCommand.h | 2 +- Source/cmTargetCompileFeaturesCommand.h | 2 +- Source/cmTargetCompileOptionsCommand.h | 2 +- Source/cmTargetIncludeDirectoriesCommand.h | 2 +- Source/cmTargetLinkDirectoriesCommand.h | 2 +- Source/cmTargetLinkLibrariesCommand.h | 2 +- Source/cmTargetLinkOptionsCommand.h | 2 +- Source/cmTargetPrecompileHeadersCommand.h | 2 +- Source/cmTargetSourcesCommand.h | 2 +- Source/cmTryCompileCommand.h | 2 +- Source/cmTryRunCommand.h | 2 +- Source/cmUVProcessChain.cxx | 2 +- Source/cmVisualStudio10TargetGenerator.cxx | 2 +- Source/cmVisualStudioGeneratorOptions.cxx | 6 +- Source/cmWhileCommand.cxx | 5 +- Source/cmWorkerPool.cxx | 2 +- Source/cmWorkerPool.h | 2 +- Source/cmWriteFileCommand.cxx | 3 +- Source/cm_static_string_view.hxx | 2 +- Source/cm_sys_stat.h | 2 +- Source/cmake.cxx | 10 +- Tests/CMakeLib/testArgumentParser.cxx | 2 +- Tests/CMakeLib/testOptional.cxx | 5 +- Tests/CMakeLib/testString.cxx | 2 +- Tests/CMakeLib/testStringAlgorithms.cxx | 3 +- Tests/CMakeLib/testUVProcessChain.cxx | 2 +- Utilities/IWYU/mapping.imp | 1 - Utilities/std/.gitattributes | 1 + Utilities/std/CMakeLists.txt | 10 + .../std/cm/bits/string_view.cxx | 2 +- Utilities/std/cm/iterator | 216 +++++++++++++++++++++ Source/cm_memory.hxx => Utilities/std/cm/memory | 9 +- .../cm_optional.hxx => Utilities/std/cm/optional | 15 +- .../cm_thread.hxx => Utilities/std/cm/shared_mutex | 38 +++- .../std/cm/string_view | 11 +- Source/cm_utility.hxx => Utilities/std/cm/utility | 13 +- bootstrap | 28 ++- 145 files changed, 528 insertions(+), 272 deletions(-) create mode 100644 Utilities/std/.gitattributes create mode 100644 Utilities/std/CMakeLists.txt rename Source/cm_string_view.cxx => Utilities/std/cm/bits/string_view.cxx (99%) create mode 100644 Utilities/std/cm/iterator rename Source/cm_memory.hxx => Utilities/std/cm/memory (85%) rename Source/cm_optional.hxx => Utilities/std/cm/optional (97%) rename Source/cm_thread.hxx => Utilities/std/cm/shared_mutex (52%) rename Source/cm_string_view.hxx => Utilities/std/cm/string_view (98%) rename Source/cm_utility.hxx => Utilities/std/cm/utility (75%) hooks/post-receive -- CMake From kwrobot at kitware.com Fri Sep 20 23:57:39 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 20 Sep 2019 23:57:39 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1144-g47a12c6 Message-ID: <20190921035739.86A5DA475F@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 47a12c658591c0ea26b7e0022d230188b8cb1909 (commit) from ebb9346490741ddc2ce6f552bc1be57dfc730cfa (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=47a12c658591c0ea26b7e0022d230188b8cb1909 commit 47a12c658591c0ea26b7e0022d230188b8cb1909 Author: Kitware Robot AuthorDate: Sat Sep 21 00:02:32 2019 -0400 Commit: Kitware Robot CommitDate: Sat Sep 21 00:02:32 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 9a4f63e..a8ced71 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 15) -set(CMake_VERSION_PATCH 20190920) +set(CMake_VERSION_PATCH 20190921) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Sun Sep 22 00:02:50 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Sun, 22 Sep 2019 00:02:50 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1145-gde14d38 Message-ID: <20190922040250.C23B5FACF5@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via de14d38cd287a95ffc880a2ba4dde417bdd45b88 (commit) from 47a12c658591c0ea26b7e0022d230188b8cb1909 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=de14d38cd287a95ffc880a2ba4dde417bdd45b88 commit de14d38cd287a95ffc880a2ba4dde417bdd45b88 Author: Kitware Robot AuthorDate: Sun Sep 22 00:01:05 2019 -0400 Commit: Kitware Robot CommitDate: Sun Sep 22 00:01:05 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index a8ced71..2d0dcf1 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 15) -set(CMake_VERSION_PATCH 20190921) +set(CMake_VERSION_PATCH 20190922) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Sep 23 00:02:16 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 23 Sep 2019 00:02:16 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1146-gaebb1af Message-ID: <20190923040216.BC3B310B020@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via aebb1af7a2ca9c20b6ed5bbb4dc1fed233223481 (commit) from de14d38cd287a95ffc880a2ba4dde417bdd45b88 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=aebb1af7a2ca9c20b6ed5bbb4dc1fed233223481 commit aebb1af7a2ca9c20b6ed5bbb4dc1fed233223481 Author: Kitware Robot AuthorDate: Mon Sep 23 00:01:06 2019 -0400 Commit: Kitware Robot CommitDate: Mon Sep 23 00:01:06 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 2d0dcf1..495ea3d 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 15) -set(CMake_VERSION_PATCH 20190922) +set(CMake_VERSION_PATCH 20190923) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Sep 23 10:42:03 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 23 Sep 2019 10:42:03 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1150-g3d1fb99 Message-ID: <20190923144203.7D6A9FAB1C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 3d1fb997e5322d6b6e7c4b0b467792995428ebb7 (commit) via ba315f2035bc048068b36ae22cc3e2c4bbc19d21 (commit) via 5ffb2dbff65bdd5db713ba0c177cecc122cac0d8 (commit) via 1059f9a96da377af771fe643abc1d060db6d64bb (commit) from aebb1af7a2ca9c20b6ed5bbb4dc1fed233223481 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3d1fb997e5322d6b6e7c4b0b467792995428ebb7 commit 3d1fb997e5322d6b6e7c4b0b467792995428ebb7 Merge: aebb1af ba315f2 Author: Brad King AuthorDate: Mon Sep 23 14:32:30 2019 +0000 Commit: Kitware Robot CommitDate: Mon Sep 23 10:32:42 2019 -0400 Merge topic 'HP-UX_Port_GCC' ba315f2035 bootstrap: Require GCC 4.9 or higher on HP-UX 5ffb2dbff6 libuv: Add partial port to HP-UX 1059f9a96d jsoncpp: Fix compilation on HP-UX 11.31 ia64 with GCC 4.9.3 Acked-by: Kitware Robot Merge-request: !3508 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ba315f2035bc048068b36ae22cc3e2c4bbc19d21 commit ba315f2035bc048068b36ae22cc3e2c4bbc19d21 Author: Brad King AuthorDate: Fri Sep 20 10:15:23 2019 -0400 Commit: Brad King CommitDate: Fri Sep 20 10:30:01 2019 -0400 bootstrap: Require GCC 4.9 or higher on HP-UX Revise for future removal of the early rejection checks on HP-UX. Our code may now work with GCC 4.9 on HP-UX when manually using `env CXXFLAGS=-D_GLIBCXX_USE_C99` to make the C++11 `std::to_string` available on this platform. However, without nightly testing we cannot officially enable support for the platform. Issue: #17137 Co-Author: Earle Lowe diff --git a/bootstrap b/bootstrap index ded4637..4f387bc 100755 --- a/bootstrap +++ b/bootstrap @@ -1059,6 +1059,10 @@ echo ' #error "On Solaris we need C99." #endif +#if defined(__hpux) && !(defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 409) +#error "On HP-UX we need GCC 4.9 or higher." +#endif + #include int main(int argc, char* argv[]) @@ -1127,6 +1131,10 @@ echo ' #error "SunPro <= 5.13 mode not supported due to bug in move semantics." #endif +#if defined(__hpux) && !(defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 409) +#error "On HP-UX we need GCC 4.9 or higher." +#endif + #if __cplusplus > 201103L #include int check_cxx14() https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5ffb2dbff65bdd5db713ba0c177cecc122cac0d8 commit 5ffb2dbff65bdd5db713ba0c177cecc122cac0d8 Author: Earle Lowe AuthorDate: Tue Jul 2 18:20:41 2019 -0400 Commit: Brad King CommitDate: Fri Sep 20 10:30:01 2019 -0400 libuv: Add partial port to HP-UX Port enough of libuv to HP-UX 11.31 ia64 with GCC 4.9.3 to work for CMake. diff --git a/Utilities/cmlibuv/CMakeLists.txt b/Utilities/cmlibuv/CMakeLists.txt index 2e781f1..fe2ef75 100644 --- a/Utilities/cmlibuv/CMakeLists.txt +++ b/Utilities/cmlibuv/CMakeLists.txt @@ -300,6 +300,23 @@ if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") ) endif() +if(CMAKE_SYSTEM_NAME STREQUAL "HP-UX") + list(APPEND uv_libraries + rt + ) + list(APPEND uv_headers + include/uv/posix.h + ) + list(APPEND uv_defines + _XOPEN_SOURCE_EXTENDED + ) + list(APPEND uv_sources + src/unix/hpux.c + src/unix/no-fsevents.c + src/unix/posix-poll.c + ) +endif() + include_directories( ${uv_includes} ${KWSYS_HEADER_ROOT} diff --git a/Utilities/cmlibuv/include/uv/unix.h b/Utilities/cmlibuv/include/uv/unix.h index 011abcf..4e26108 100644 --- a/Utilities/cmlibuv/include/uv/unix.h +++ b/Utilities/cmlibuv/include/uv/unix.h @@ -55,6 +55,8 @@ # include "aix.h" #elif defined(__sun) # include "sunos.h" +#elif defined(__hpux) +# include "posix.h" #elif defined(__APPLE__) # include "darwin.h" #elif defined(__DragonFly__) || \ diff --git a/Utilities/cmlibuv/src/unix/core.c b/Utilities/cmlibuv/src/unix/core.c index 93df7af..cf7dea0 100644 --- a/Utilities/cmlibuv/src/unix/core.c +++ b/Utilities/cmlibuv/src/unix/core.c @@ -587,7 +587,7 @@ int uv__nonblock_ioctl(int fd, int set) { } -#if !defined(__CYGWIN__) && !defined(__MSYS__) && !defined(__HAIKU__) +#if !defined(__hpux) && !defined(__CYGWIN__) && !defined(__MSYS__) && !defined(__HAIKU__) int uv__cloexec_ioctl(int fd, int set) { int r; diff --git a/Utilities/cmlibuv/src/unix/fs.c b/Utilities/cmlibuv/src/unix/fs.c index 3023b1e..5fb34f1b 100644 --- a/Utilities/cmlibuv/src/unix/fs.c +++ b/Utilities/cmlibuv/src/unix/fs.c @@ -234,7 +234,7 @@ static ssize_t uv__fs_futime(uv_fs_t* req) { #endif } -#if defined(__sun) && (_XOPEN_SOURCE < 600 || defined(CMAKE_BOOTSTRAP)) +#if (defined(__sun) || defined(__hpux)) && (_XOPEN_SOURCE < 600 || defined(CMAKE_BOOTSTRAP)) static char* uv__mkdtemp(char *template) { if (!mktemp(template) || mkdir(template, 0700)) diff --git a/Utilities/cmlibuv/src/unix/posix-hrtime.c b/Utilities/cmlibuv/src/unix/hpux.c similarity index 63% copy from Utilities/cmlibuv/src/unix/posix-hrtime.c copy to Utilities/cmlibuv/src/unix/hpux.c index a264250..4d3f628 100644 --- a/Utilities/cmlibuv/src/unix/posix-hrtime.c +++ b/Utilities/cmlibuv/src/unix/hpux.c @@ -22,39 +22,9 @@ #include "uv.h" #include "internal.h" -#if defined(__APPLE__) -/* Special case for CMake bootstrap: no clock_gettime on macOS < 10.12 */ - -#ifndef CMAKE_BOOTSTRAP -#error "This code path meant only for use during CMake bootstrap." -#endif - -#include -#include - -uint64_t uv__hrtime(uv_clocktype_t type) { - static mach_timebase_info_data_t info; - - if ((ACCESS_ONCE(uint32_t, info.numer) == 0 || - ACCESS_ONCE(uint32_t, info.denom) == 0) && - mach_timebase_info(&info) != KERN_SUCCESS) - abort(); - - return mach_absolute_time() * info.numer / info.denom; -} - -#else - #include #include -#undef NANOSEC -#define NANOSEC ((uint64_t) 1e9) - uint64_t uv__hrtime(uv_clocktype_t type) { - struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - return (((uint64_t) ts.tv_sec) * NANOSEC + ts.tv_nsec); + return (uint64_t) gethrtime(); } - -#endif diff --git a/Utilities/cmlibuv/src/unix/posix-hrtime.c b/Utilities/cmlibuv/src/unix/posix-hrtime.c index a264250..870b45c 100644 --- a/Utilities/cmlibuv/src/unix/posix-hrtime.c +++ b/Utilities/cmlibuv/src/unix/posix-hrtime.c @@ -43,6 +43,20 @@ uint64_t uv__hrtime(uv_clocktype_t type) { return mach_absolute_time() * info.numer / info.denom; } +#elif defined(__hpux) +/* Special case for CMake bootstrap: no CLOCK_MONOTONIC on HP-UX */ + +#ifndef CMAKE_BOOTSTRAP +#error "This code path meant only for use during CMake bootstrap." +#endif + +#include +#include + +uint64_t uv__hrtime(uv_clocktype_t type) { + return (uint64_t) gethrtime(); +} + #else #include diff --git a/Utilities/cmlibuv/src/unix/thread.c b/Utilities/cmlibuv/src/unix/thread.c index cd0b7aa..0453221 100644 --- a/Utilities/cmlibuv/src/unix/thread.c +++ b/Utilities/cmlibuv/src/unix/thread.c @@ -700,7 +700,7 @@ int uv_cond_init(uv_cond_t* cond) { if (err) return UV__ERR(err); -#if !(defined(__ANDROID_API__) && __ANDROID_API__ < 21) +#if !(defined(__ANDROID_API__) && __ANDROID_API__ < 21) && !defined(__hpux) err = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); if (err) goto error2; diff --git a/Utilities/cmlibuv/src/unix/tty.c b/Utilities/cmlibuv/src/unix/tty.c index b8bc283..db479d6 100644 --- a/Utilities/cmlibuv/src/unix/tty.c +++ b/Utilities/cmlibuv/src/unix/tty.c @@ -200,7 +200,7 @@ skip: static void uv__tty_make_raw(struct termios* tio) { assert(tio != NULL); -#if defined __sun || defined __MVS__ +#if defined __sun || defined __MVS__ || defined __hpux /* * This implementation of cfmakeraw for Solaris and derivatives is taken from * http://www.perkin.org.uk/posts/solaris-portability-cfmakeraw.html. diff --git a/bootstrap b/bootstrap index ca5441f..ded4637 100755 --- a/bootstrap +++ b/bootstrap @@ -1435,6 +1435,9 @@ else *Darwin*) uv_c_flags="${uv_c_flags} -D_DARWIN_USE_64_BIT_INODE=1 -D_DARWIN_UNLIMITED_SELECT=1" ;; + *HP-UX*) + uv_c_flags="${uv_c_flags} -D_XOPEN_SOURCE_EXTENDED" + ;; *Linux*) uv_c_flags="${uv_c_flags} -D_GNU_SOURCE" libs="${libs} -ldl -lrt" https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1059f9a96da377af771fe643abc1d060db6d64bb commit 1059f9a96da377af771fe643abc1d060db6d64bb Author: Earle Lowe AuthorDate: Tue Jul 2 18:20:41 2019 -0400 Commit: Brad King CommitDate: Fri Sep 20 10:30:01 2019 -0400 jsoncpp: Fix compilation on HP-UX 11.31 ia64 with GCC 4.9.3 In particular, fix the `isfinite` definition. diff --git a/Utilities/cmjsoncpp/src/lib_json/json_writer.cpp b/Utilities/cmjsoncpp/src/lib_json/json_writer.cpp index 6e6e57e..fc86505 100644 --- a/Utilities/cmjsoncpp/src/lib_json/json_writer.cpp +++ b/Utilities/cmjsoncpp/src/lib_json/json_writer.cpp @@ -30,7 +30,7 @@ #define isfinite finite #endif #elif defined(__hpux) -#if !defined(isfinite) +#if !defined(isfinite) && !defined(__GNUC__) #if defined(__ia64) && !defined(finite) #define isfinite(x) ((sizeof(x) == sizeof(float) ? \ _Isfinitef(x) : _IsFinite(x))) @@ -86,10 +86,11 @@ // HP-UX #if defined(__hpux) # if !defined(isfinite) -# if defined(__ia64) && !defined(finite) +# if defined(__ia64) && !defined(finite) && !defined(__GNUC__) # define isfinite(x) ((sizeof(x) == sizeof(float) ? \ _Isfinitef(x) : _Isfinite(x))) # else +# include # define isfinite finite # endif # endif ----------------------------------------------------------------------- Summary of changes: Utilities/cmjsoncpp/src/lib_json/json_writer.cpp | 5 +++-- Utilities/cmlibuv/CMakeLists.txt | 17 +++++++++++++++++ Utilities/cmlibuv/include/uv/unix.h | 2 ++ Utilities/cmlibuv/src/unix/core.c | 2 +- Utilities/cmlibuv/src/unix/fs.c | 2 +- .../cmlibuv/src/unix/{sysinfo-loadavg.c => hpux.c} | 12 +++--------- Utilities/cmlibuv/src/unix/posix-hrtime.c | 14 ++++++++++++++ Utilities/cmlibuv/src/unix/thread.c | 2 +- Utilities/cmlibuv/src/unix/tty.c | 2 +- bootstrap | 11 +++++++++++ 10 files changed, 54 insertions(+), 15 deletions(-) copy Utilities/cmlibuv/src/unix/{sysinfo-loadavg.c => hpux.c} (82%) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Sep 23 11:02:00 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 23 Sep 2019 11:02:00 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1154-g17c5b32 Message-ID: <20190923150200.45F66FAB1C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 17c5b32dc296101e51c2633d96931f867b03970d (commit) via 15163c92349d39f5d0f97578f62e1d1d0194c60b (commit) via 71e677392bb15b1ed87e98b75d19122cdc249c77 (commit) via 8d0cec747cfbad582119c590efc8c390b6f2bbc0 (commit) from 3d1fb997e5322d6b6e7c4b0b467792995428ebb7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=17c5b32dc296101e51c2633d96931f867b03970d commit 17c5b32dc296101e51c2633d96931f867b03970d Merge: 15163c9 8d0cec7 Author: Brad King AuthorDate: Mon Sep 23 14:52:46 2019 +0000 Commit: Kitware Robot CommitDate: Mon Sep 23 10:53:12 2019 -0400 Merge topic 'smart_ptr/cmDependsC' 8d0cec747c cmDependsC: remove cmDeleteAll call Acked-by: Kitware Robot Merge-request: !3842 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=15163c92349d39f5d0f97578f62e1d1d0194c60b commit 15163c92349d39f5d0f97578f62e1d1d0194c60b Merge: 3d1fb99 71e6773 Author: Brad King AuthorDate: Mon Sep 23 14:51:40 2019 +0000 Commit: Kitware Robot CommitDate: Mon Sep 23 10:51:55 2019 -0400 Merge topic 'object-library-sources' 71e677392b Do not collect objects from dependencies of object libraries Acked-by: Kitware Robot Merge-request: !3843 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=71e677392bb15b1ed87e98b75d19122cdc249c77 commit 71e677392bb15b1ed87e98b75d19122cdc249c77 Author: Brad King AuthorDate: Fri Sep 20 12:02:47 2019 -0400 Commit: Brad King CommitDate: Fri Sep 20 12:48:46 2019 -0400 Do not collect objects from dependencies of object libraries Object libraries do not link and therefore do not need to consider the object files from "linked" dependencies on other object libraries. This was an oversight in commit 57538224d0 (objlib: Link object-files from `OBJECT` libraries, 2017-12-14, v3.12.0-rc1~419^2~2). Fixes: #19744 Inspired-by: Julien Finet diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 18ca478..8e3db2b 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1454,11 +1454,14 @@ std::vector> cmGeneratorTarget::GetSourceFilePaths( this, linkInterfaceSourcesEntries, files, uniqueSrcs, debugSources); // Collect TARGET_OBJECTS of direct object link-dependencies. - std::vector linkObjectsEntries; - AddObjectEntries(this, config, &dagChecker, linkObjectsEntries); + bool contextDependentObjects = false; std::vector::size_type numFilesBefore2 = files.size(); - bool contextDependentObjects = - processSources(this, linkObjectsEntries, files, uniqueSrcs, debugSources); + if (this->GetType() != cmStateEnums::OBJECT_LIBRARY) { + std::vector linkObjectsEntries; + AddObjectEntries(this, config, &dagChecker, linkObjectsEntries); + contextDependentObjects = processSources(this, linkObjectsEntries, files, + uniqueSrcs, debugSources); + } if (!contextDependentDirectSources && !(contextDependentInterfaceSources && numFilesBefore < files.size()) && https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8d0cec747cfbad582119c590efc8c390b6f2bbc0 commit 8d0cec747cfbad582119c590efc8c390b6f2bbc0 Author: Tushar Maheshwari AuthorDate: Sun Sep 8 16:20:06 2019 +0530 Commit: Tushar Maheshwari CommitDate: Fri Sep 20 20:39:43 2019 +0530 cmDependsC: remove cmDeleteAll call diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index a380b41..012a0b1 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -5,7 +5,6 @@ #include "cmsys/FStream.hxx" #include -#include "cmAlgorithms.h" #include "cmFileTime.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" @@ -67,7 +66,6 @@ cmDependsC::cmDependsC(cmLocalGenerator* lg, const std::string& targetDir, cmDependsC::~cmDependsC() { this->WriteCacheFile(); - cmDeleteAll(this->FileCache); } bool cmDependsC::WriteDependencies(const std::set& sources, @@ -172,9 +170,9 @@ bool cmDependsC::WriteDependencies(const std::set& sources, // Check whether this file is already in the cache auto fileIt = this->FileCache.find(fullName); if (fileIt != this->FileCache.end()) { - fileIt->second->Used = true; + fileIt->second.Used = true; dependencies.insert(fullName); - for (UnscannedEntry const& inc : fileIt->second->UnscannedEntries) { + for (UnscannedEntry const& inc : fileIt->second.UnscannedEntries) { if (this->Encountered.find(inc.FileName) == this->Encountered.end()) { this->Encountered.insert(inc.FileName); @@ -260,8 +258,7 @@ void cmDependsC::ReadCacheFile() if (res && newer) // cache is newer than the parsed file { - cacheEntry = new cmIncludeLines; - this->FileCache[line] = cacheEntry; + cacheEntry = &this->FileCache[line]; } // file doesn't exist, check that the regular expressions // haven't changed @@ -313,10 +310,10 @@ void cmDependsC::WriteCacheFile() const cacheOut << this->IncludeRegexTransformString << "\n\n"; for (auto const& fileIt : this->FileCache) { - if (fileIt.second->Used) { + if (fileIt.second.Used) { cacheOut << fileIt.first << std::endl; - for (UnscannedEntry const& inc : fileIt.second->UnscannedEntries) { + for (UnscannedEntry const& inc : fileIt.second.UnscannedEntries) { cacheOut << inc.FileName << std::endl; if (inc.QuotedLocation.empty()) { cacheOut << "-" << std::endl; @@ -332,9 +329,8 @@ void cmDependsC::WriteCacheFile() const void cmDependsC::Scan(std::istream& is, const std::string& directory, const std::string& fullName) { - cmIncludeLines* newCacheEntry = new cmIncludeLines; - newCacheEntry->Used = true; - this->FileCache[fullName] = newCacheEntry; + cmIncludeLines& newCacheEntry = this->FileCache[fullName]; + newCacheEntry.Used = true; // Read one line at a time. std::string line; @@ -370,7 +366,7 @@ void cmDependsC::Scan(std::istream& is, const std::string& directory, // This kind of problem will be fixed when a more // preprocessor-like implementation of this scanner is created. if (this->IncludeRegexScan.find(entry.FileName)) { - newCacheEntry->UnscannedEntries.push_back(entry); + newCacheEntry.UnscannedEntries.push_back(entry); if (this->Encountered.find(entry.FileName) == this->Encountered.end()) { this->Encountered.insert(entry.FileName); diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h index cbdc276..7d732d9 100644 --- a/Source/cmDependsC.h +++ b/Source/cmDependsC.h @@ -84,7 +84,7 @@ protected: std::set Encountered; std::queue Unscanned; - std::map FileCache; + std::map FileCache; std::map HeaderLocationCache; std::string CacheFileName; ----------------------------------------------------------------------- Summary of changes: Source/cmDependsC.cxx | 20 ++++++++------------ Source/cmDependsC.h | 2 +- Source/cmGeneratorTarget.cxx | 11 +++++++---- 3 files changed, 16 insertions(+), 17 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Sep 24 00:01:43 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 24 Sep 2019 00:01:43 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1155-ga3492c0 Message-ID: <20190924040143.95385FAB1C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via a3492c094a4288ede26225e4a06d5d8175936ed1 (commit) from 17c5b32dc296101e51c2633d96931f867b03970d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a3492c094a4288ede26225e4a06d5d8175936ed1 commit a3492c094a4288ede26225e4a06d5d8175936ed1 Author: Kitware Robot AuthorDate: Tue Sep 24 00:01:06 2019 -0400 Commit: Kitware Robot CommitDate: Tue Sep 24 00:01:06 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 495ea3d..f85707d 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 15) -set(CMake_VERSION_PATCH 20190923) +set(CMake_VERSION_PATCH 20190924) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Sep 24 10:31:31 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 24 Sep 2019 10:31:31 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1171-g28bd7e4 Message-ID: <20190924143131.513D811EB33@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 28bd7e41b8792365c8730bdbffed825d70e50471 (commit) via 004876b2144db09bb8d328985ca208ccf6ef30c4 (commit) via a9347999077156fd6d45a1be47c23cb298aa21e2 (commit) via c4afe766f70e42f6d293f9626093049443f8962b (commit) via de5f123d3afd2dc4b82c66f760615e4034675418 (commit) via 158f3795b812d6ae2f9a67550b53b071c285e623 (commit) via 920f0dd83ad473d291e5ceb519ed7155ca92168a (commit) via 1dd31297cad93b5b9a8fd1ab2b5bb9916ffe5d18 (commit) via d5c63f073f290d4778426825e586240dca7ca0a6 (commit) via 42e413bcbbd32cbae6705269ae0f7a0583819be9 (commit) via 77aa75b8dc76fce51973d6337473fb388b855ea4 (commit) via 9c521088df3c45764fd9bfc1c10c9bfe63b63e78 (commit) via fcfec154acea01518aa436d76f576d7cfea65fa2 (commit) via d038beec21fde74977e6ce6604f7fc913066dad6 (commit) via fdc3ba45832456fc17cff58850b16a02cee30e7c (commit) via 8098bd5768d012ceb078fdefdc1b35e1b74e984a (commit) from a3492c094a4288ede26225e4a06d5d8175936ed1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=28bd7e41b8792365c8730bdbffed825d70e50471 commit 28bd7e41b8792365c8730bdbffed825d70e50471 Merge: 004876b 158f379 Author: Brad King AuthorDate: Tue Sep 24 14:29:13 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 24 10:30:39 2019 -0400 Merge topic 'iar-v850-asm' 158f3795b8 IAR: Add v850 assembler support Acked-by: Kitware Robot Merge-request: !3856 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=004876b2144db09bb8d328985ca208ccf6ef30c4 commit 004876b2144db09bb8d328985ca208ccf6ef30c4 Merge: a934799 de5f123 Author: Brad King AuthorDate: Tue Sep 24 14:28:19 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 24 10:29:30 2019 -0400 Merge topic 'FindThreads-lib-name' de5f123d3a FindThreads: Do not hard-code '-l' flag on library name Acked-by: Kitware Robot Merge-request: !3857 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a9347999077156fd6d45a1be47c23cb298aa21e2 commit a9347999077156fd6d45a1be47c23cb298aa21e2 Merge: c4afe76 8098bd5 Author: Brad King AuthorDate: Tue Sep 24 14:27:50 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 24 10:28:21 2019 -0400 Merge topic 'FindOpenSSL-static-deps' 8098bd5768 FindOpenSSL: add pthread and dl dependencies to static lib on Linux Acked-by: Kitware Robot Merge-request: !3820 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c4afe766f70e42f6d293f9626093049443f8962b commit c4afe766f70e42f6d293f9626093049443f8962b Merge: a3492c0 920f0dd Author: Brad King AuthorDate: Tue Sep 24 14:27:06 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 24 10:27:17 2019 -0400 Merge topic 'free-free-set-them-free' 920f0dd83a cmInstallCommand: Port away from cmCommand 1dd31297ca cmTargetLinkLibrariesCommand: Port away from cmCommand d5c63f073f cmSourceGroupCommand: Port away from cmCommand 42e413bcbb cmSetTargetPropertiesCommand: Port away from cmCommand 77aa75b8dc cmProjectCommand: Port away from cmCommand 9c521088df cmLoadCacheCommand: Port away from cmCommand fcfec154ac cmLinkDirectoriesCommand: Port away from cmCommand d038beec21 cmIncludeDirectoryCommand: Port away from cmCommand ... Acked-by: Kitware Robot Merge-request: !3829 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=de5f123d3afd2dc4b82c66f760615e4034675418 commit de5f123d3afd2dc4b82c66f760615e4034675418 Author: Alan W. Irwin AuthorDate: Mon Sep 23 10:42:30 2019 -0400 Commit: Brad King CommitDate: Mon Sep 23 10:43:27 2019 -0400 FindThreads: Do not hard-code '-l' flag on library name When not using the `-pthread` flag we instead return a library to link by name. Previously we hard-coded the `-l` flag before the library name. When used with `target_link_libraries`, the hard-coded `-l` flag is preserved rather than transformed into the link option preferred by the toolchain in use. Drop the explicit `-l` part to let CMake's generators produce the proper way to link the threads library for the current toolchain. Fixes: #19747 diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index b0c91b2..d39fe33 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -77,7 +77,7 @@ macro(_check_threads_lib LIBNAME FUNCNAME VARNAME) if(NOT Threads_FOUND) CHECK_LIBRARY_EXISTS(${LIBNAME} ${FUNCNAME} "" ${VARNAME}) if(${VARNAME}) - set(CMAKE_THREAD_LIBS_INIT "-l${LIBNAME}") + set(CMAKE_THREAD_LIBS_INIT "${LIBNAME}") set(CMAKE_HAVE_THREADS_LIBRARY 1) set(Threads_FOUND TRUE) endif() @@ -88,7 +88,7 @@ endmacro() # Do NOT even think about using it outside of this file! macro(_check_pthreads_flag) if(NOT Threads_FOUND) - # If we did not found -lpthread, -lpthread, or -lthread, look for -pthread + # If we did not find a thread library look for -pthread compiler option. if(NOT DEFINED THREADS_HAVE_PTHREAD_ARG) message(STATUS "Check if compiler accepts -pthread") if(CMAKE_C_COMPILER_LOADED) @@ -164,7 +164,7 @@ if(CMAKE_HAVE_PTHREAD_H) _check_threads_lib(pthreads pthread_create CMAKE_HAVE_PTHREADS_CREATE) _check_threads_lib(pthread pthread_create CMAKE_HAVE_PTHREAD_CREATE) if(CMAKE_SYSTEM_NAME MATCHES "SunOS") - # On sun also check for -lthread + # On sun also check for thread library with thr_create _check_threads_lib(thread thr_create CMAKE_HAVE_THR_CREATE) endif() endif() @@ -195,7 +195,7 @@ if(CMAKE_USE_PTHREADS_INIT) # are available. CHECK_LIBRARY_EXISTS(cma pthread_attr_create "" CMAKE_HAVE_HP_CMA) if(CMAKE_HAVE_HP_CMA) - set(CMAKE_THREAD_LIBS_INIT "-lcma") + set(CMAKE_THREAD_LIBS_INIT "cma") set(CMAKE_HP_PTHREADS_INIT 1) set(Threads_FOUND TRUE) endif() https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=158f3795b812d6ae2f9a67550b53b071c285e623 commit 158f3795b812d6ae2f9a67550b53b071c285e623 Author: Nico Mueller AuthorDate: Mon Sep 23 11:57:54 2019 +0200 Commit: Nico Mueller CommitDate: Mon Sep 23 13:14:14 2019 +0200 IAR: Add v850 assembler support Assembler compiler configuration for 'v850' architecture Issue: #17264 diff --git a/Modules/Compiler/IAR-ASM.cmake b/Modules/Compiler/IAR-ASM.cmake index 437678e..413d9e2 100644 --- a/Modules/Compiler/IAR-ASM.cmake +++ b/Modules/Compiler/IAR-ASM.cmake @@ -37,6 +37,11 @@ elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430") __compiler_iar_xlink(ASM) set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s43;asm;msa) +elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "V850") + set(CMAKE_ASM_COMPILE_OBJECT " -S -o ") + __compiler_iar_xlink(ASM) + set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS r85;asm;msa) + else() message(FATAL_ERROR "CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID not detected. This should be automatic.") endif() https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=920f0dd83ad473d291e5ceb519ed7155ca92168a commit 920f0dd83ad473d291e5ceb519ed7155ca92168a Author: Regina Pfeifer AuthorDate: Wed Sep 18 22:45:42 2019 +0200 Commit: Regina Pfeifer CommitDate: Sat Sep 21 05:20:59 2019 +0200 cmInstallCommand: Port away from cmCommand diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index cc9448d..88d17f1 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -234,7 +234,7 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("include_directories", cmIncludeDirectoryCommand); state->AddBuiltinCommand("include_regular_expression", cmIncludeRegularExpressionCommand); - state->AddBuiltinCommand("install", cm::make_unique()); + state->AddBuiltinCommand("install", cmInstallCommand); state->AddBuiltinCommand("install_files", cmInstallFilesCommand); state->AddBuiltinCommand("install_targets", cmInstallTargetsCommand); state->AddBuiltinCommand("link_directories", cmLinkDirectoriesCommand); diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index f7050d4..27d0dfb 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -4,12 +4,14 @@ #include "cm_static_string_view.hxx" #include "cmsys/Glob.hxx" +#include #include #include #include #include #include "cmArgumentParser.h" +#include "cmExecutionStatus.h" #include "cmExportSet.h" #include "cmGeneratorExpression.h" #include "cmGlobalGenerator.h" @@ -26,13 +28,61 @@ #include "cmPolicies.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" +#include "cmSubcommandTable.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cmTargetExport.h" -class cmExecutionStatus; +namespace { -static cmInstallTargetGenerator* CreateInstallTargetGenerator( +class Helper +{ +public: + Helper(cmExecutionStatus& status) + : Status(status) + , Makefile(&status.GetMakefile()) + { + this->DefaultComponentName = this->Makefile->GetSafeDefinition( + "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); + if (this->DefaultComponentName.empty()) { + this->DefaultComponentName = "Unspecified"; + } + } + + void SetError(std::string const& err) { this->Status.SetError(err); } + + bool MakeFilesFullPath(const char* modeName, + const std::vector& relFiles, + std::vector& absFiles); + bool CheckCMP0006(bool& failure); + + std::string GetDestination(const cmInstallCommandArguments* args, + const std::string& varName, + const std::string& guess); + std::string GetRuntimeDestination(const cmInstallCommandArguments* args); + std::string GetSbinDestination(const cmInstallCommandArguments* args); + std::string GetArchiveDestination(const cmInstallCommandArguments* args); + std::string GetLibraryDestination(const cmInstallCommandArguments* args); + std::string GetIncludeDestination(const cmInstallCommandArguments* args); + std::string GetSysconfDestination(const cmInstallCommandArguments* args); + std::string GetSharedStateDestination(const cmInstallCommandArguments* args); + std::string GetLocalStateDestination(const cmInstallCommandArguments* args); + std::string GetRunStateDestination(const cmInstallCommandArguments* args); + std::string GetDataRootDestination(const cmInstallCommandArguments* args); + std::string GetDataDestination(const cmInstallCommandArguments* args); + std::string GetInfoDestination(const cmInstallCommandArguments* args); + std::string GetLocaleDestination(const cmInstallCommandArguments* args); + std::string GetManDestination(const cmInstallCommandArguments* args); + std::string GetDocDestination(const cmInstallCommandArguments* args); + std::string GetDestinationForType(const cmInstallCommandArguments* args, + const std::string& type); + + cmExecutionStatus& Status; + cmMakefile* Makefile; + std::string DefaultComponentName; +}; + +cmInstallTargetGenerator* CreateInstallTargetGenerator( cmTarget& target, const cmInstallCommandArguments& args, bool impLib, cmListFileBacktrace const& backtrace, const std::string& destination, bool forceOpt = false, bool namelink = false) @@ -51,7 +101,7 @@ static cmInstallTargetGenerator* CreateInstallTargetGenerator( return g; } -static cmInstallTargetGenerator* CreateInstallTargetGenerator( +cmInstallTargetGenerator* CreateInstallTargetGenerator( cmTarget& target, const cmInstallCommandArguments& args, bool impLib, cmListFileBacktrace const& backtrace, bool forceOpt = false, bool namelink = false) @@ -61,7 +111,7 @@ static cmInstallTargetGenerator* CreateInstallTargetGenerator( namelink); } -static cmInstallFilesGenerator* CreateInstallFilesGenerator( +cmInstallFilesGenerator* CreateInstallFilesGenerator( cmMakefile* mf, const std::vector& absFiles, const cmInstallCommandArguments& args, bool programs, const std::string& destination) @@ -74,7 +124,7 @@ static cmInstallFilesGenerator* CreateInstallFilesGenerator( args.GetExcludeFromAll(), args.GetRename().c_str(), args.GetOptional()); } -static cmInstallFilesGenerator* CreateInstallFilesGenerator( +cmInstallFilesGenerator* CreateInstallFilesGenerator( cmMakefile* mf, const std::vector& absFiles, const cmInstallCommandArguments& args, bool programs) { @@ -82,68 +132,18 @@ static cmInstallFilesGenerator* CreateInstallFilesGenerator( args.GetDestination()); } -static const std::set allowedTypes{ +std::set const allowedTypes{ "BIN", "SBIN", "LIB", "INCLUDE", "SYSCONF", "SHAREDSTATE", "LOCALSTATE", "RUNSTATE", "DATA", "INFO", "LOCALE", "MAN", "DOC", }; -// cmInstallCommand -bool cmInstallCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +bool HandleScriptMode(std::vector const& args, + cmExecutionStatus& status) { - // Allow calling with no arguments so that arguments may be built up - // using a variable that may be left empty. - if (args.empty()) { - return true; - } - - // Enable the install target. - this->Makefile->GetGlobalGenerator()->EnableInstallTarget(); - - this->DefaultComponentName = - this->Makefile->GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"); - if (this->DefaultComponentName.empty()) { - this->DefaultComponentName = "Unspecified"; - } - - std::string const& mode = args[0]; - - // Switch among the command modes. - if (mode == "SCRIPT") { - return this->HandleScriptMode(args); - } - if (mode == "CODE") { - return this->HandleScriptMode(args); - } - if (mode == "TARGETS") { - return this->HandleTargetsMode(args); - } - if (mode == "FILES") { - return this->HandleFilesMode(args); - } - if (mode == "PROGRAMS") { - return this->HandleFilesMode(args); - } - if (mode == "DIRECTORY") { - return this->HandleDirectoryMode(args); - } - if (mode == "EXPORT") { - return this->HandleExportMode(args); - } - if (mode == "EXPORT_ANDROID_MK") { - return this->HandleExportAndroidMKMode(args); - } - - // Unknown mode. - std::string e = cmStrCat("called with unknown mode ", args[0]); - this->SetError(e); - return false; -} + Helper helper(status); -bool cmInstallCommand::HandleScriptMode(std::vector const& args) -{ - std::string component = this->DefaultComponentName; + std::string component = helper.DefaultComponentName; int componentCount = 0; bool doing_script = false; bool doing_code = false; @@ -163,9 +163,9 @@ bool cmInstallCommand::HandleScriptMode(std::vector const& args) } if (componentCount > 1) { - this->SetError("given more than one COMPONENT for the SCRIPT or CODE " - "signature of the INSTALL command. " - "Use multiple INSTALL commands with one COMPONENT each."); + status.SetError("given more than one COMPONENT for the SCRIPT or CODE " + "signature of the INSTALL command. " + "Use multiple INSTALL commands with one COMPONENT each."); return false; } @@ -187,40 +187,43 @@ bool cmInstallCommand::HandleScriptMode(std::vector const& args) std::string script = arg; if (!cmSystemTools::FileIsFullPath(script)) { script = - cmStrCat(this->Makefile->GetCurrentSourceDirectory(), '/', arg); + cmStrCat(helper.Makefile->GetCurrentSourceDirectory(), '/', arg); } if (cmSystemTools::FileIsDirectory(script)) { - this->SetError("given a directory as value of SCRIPT argument."); + status.SetError("given a directory as value of SCRIPT argument."); return false; } - this->Makefile->AddInstallGenerator(new cmInstallScriptGenerator( + helper.Makefile->AddInstallGenerator(new cmInstallScriptGenerator( script.c_str(), false, component.c_str(), exclude_from_all)); } else if (doing_code) { doing_code = false; std::string const& code = arg; - this->Makefile->AddInstallGenerator(new cmInstallScriptGenerator( + helper.Makefile->AddInstallGenerator(new cmInstallScriptGenerator( code.c_str(), true, component.c_str(), exclude_from_all)); } } if (doing_script) { - this->SetError("given no value for SCRIPT argument."); + status.SetError("given no value for SCRIPT argument."); return false; } if (doing_code) { - this->SetError("given no value for CODE argument."); + status.SetError("given no value for CODE argument."); return false; } // Tell the global generator about any installation component names // specified. - this->Makefile->GetGlobalGenerator()->AddInstallComponent(component); + helper.Makefile->GetGlobalGenerator()->AddInstallComponent(component); return true; } -bool cmInstallCommand::HandleTargetsMode(std::vector const& args) +bool HandleTargetsMode(std::vector const& args, + cmExecutionStatus& status) { + Helper helper(status); + // This is the TARGETS mode. std::vector targets; @@ -260,21 +263,21 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) std::vector targetList; std::string exports; std::vector unknownArgs; - cmInstallCommandArguments genericArgs(this->DefaultComponentName); + cmInstallCommandArguments genericArgs(helper.DefaultComponentName); genericArgs.Bind("TARGETS"_s, targetList); genericArgs.Bind("EXPORT"_s, exports); genericArgs.Parse(genericArgVector, &unknownArgs); bool success = genericArgs.Finalize(); - cmInstallCommandArguments archiveArgs(this->DefaultComponentName); - cmInstallCommandArguments libraryArgs(this->DefaultComponentName); - cmInstallCommandArguments runtimeArgs(this->DefaultComponentName); - cmInstallCommandArguments objectArgs(this->DefaultComponentName); - cmInstallCommandArguments frameworkArgs(this->DefaultComponentName); - cmInstallCommandArguments bundleArgs(this->DefaultComponentName); - cmInstallCommandArguments privateHeaderArgs(this->DefaultComponentName); - cmInstallCommandArguments publicHeaderArgs(this->DefaultComponentName); - cmInstallCommandArguments resourceArgs(this->DefaultComponentName); + cmInstallCommandArguments archiveArgs(helper.DefaultComponentName); + cmInstallCommandArguments libraryArgs(helper.DefaultComponentName); + cmInstallCommandArguments runtimeArgs(helper.DefaultComponentName); + cmInstallCommandArguments objectArgs(helper.DefaultComponentName); + cmInstallCommandArguments frameworkArgs(helper.DefaultComponentName); + cmInstallCommandArguments bundleArgs(helper.DefaultComponentName); + cmInstallCommandArguments privateHeaderArgs(helper.DefaultComponentName); + cmInstallCommandArguments publicHeaderArgs(helper.DefaultComponentName); + cmInstallCommandArguments resourceArgs(helper.DefaultComponentName); cmInstallCommandIncludesArgument includesArgs; // now parse the args for specific parts of the target (e.g. LIBRARY, @@ -292,7 +295,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) if (!unknownArgs.empty()) { // Unknown argument. - this->SetError( + status.SetError( cmStrCat("TARGETS given unknown argument \"", unknownArgs[0], "\".")); return false; } @@ -328,7 +331,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) objectArgs.GetNamelinkOnly() || frameworkArgs.GetNamelinkOnly() || bundleArgs.GetNamelinkOnly() || privateHeaderArgs.GetNamelinkOnly() || publicHeaderArgs.GetNamelinkOnly() || resourceArgs.GetNamelinkOnly()) { - this->SetError( + status.SetError( "TARGETS given NAMELINK_ONLY option not in LIBRARY group. " "The NAMELINK_ONLY option may be specified only following LIBRARY."); return false; @@ -337,7 +340,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) objectArgs.GetNamelinkSkip() || frameworkArgs.GetNamelinkSkip() || bundleArgs.GetNamelinkSkip() || privateHeaderArgs.GetNamelinkSkip() || publicHeaderArgs.GetNamelinkSkip() || resourceArgs.GetNamelinkSkip()) { - this->SetError( + status.SetError( "TARGETS given NAMELINK_SKIP option not in LIBRARY group. " "The NAMELINK_SKIP option may be specified only following LIBRARY."); return false; @@ -350,15 +353,15 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) privateHeaderArgs.HasNamelinkComponent() || publicHeaderArgs.HasNamelinkComponent() || resourceArgs.HasNamelinkComponent()) { - this->SetError( + status.SetError( "TARGETS given NAMELINK_COMPONENT option not in LIBRARY group. " "The NAMELINK_COMPONENT option may be specified only following " "LIBRARY."); return false; } if (libraryArgs.GetNamelinkOnly() && libraryArgs.GetNamelinkSkip()) { - this->SetError("TARGETS given NAMELINK_ONLY and NAMELINK_SKIP. " - "At most one of these two options may be specified."); + status.SetError("TARGETS given NAMELINK_ONLY and NAMELINK_SKIP. " + "At most one of these two options may be specified."); return false; } if (!genericArgs.GetType().empty() || !archiveArgs.GetType().empty() || @@ -366,7 +369,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) !objectArgs.GetType().empty() || !frameworkArgs.GetType().empty() || !bundleArgs.GetType().empty() || !privateHeaderArgs.GetType().empty() || !publicHeaderArgs.GetType().empty() || !resourceArgs.GetType().empty()) { - this->SetError( + status.SetError( "TARGETS given TYPE option. The TYPE option may only be specified in " " install(FILES) and install(DIRECTORIES)."); return false; @@ -388,17 +391,17 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) for (std::string const& tgt : targetList) { - if (this->Makefile->IsAlias(tgt)) { - this->SetError( + if (helper.Makefile->IsAlias(tgt)) { + status.SetError( cmStrCat("TARGETS given target \"", tgt, "\" which is an alias.")); return false; } // Lookup this target in the current directory. - cmTarget* target = this->Makefile->FindLocalNonAliasTarget(tgt); + cmTarget* target = helper.Makefile->FindLocalNonAliasTarget(tgt); if (!target) { // If no local target has been found, find it in the global scope. cmTarget* const global_target = - this->Makefile->GetGlobalGenerator()->FindTarget(tgt, true); + helper.Makefile->GetGlobalGenerator()->FindTarget(tgt, true); if (global_target && !global_target->IsImported()) { target = global_target; } @@ -411,7 +414,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) target->GetType() != cmStateEnums::MODULE_LIBRARY && target->GetType() != cmStateEnums::OBJECT_LIBRARY && target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { - this->SetError( + status.SetError( cmStrCat("TARGETS given target \"", tgt, "\" which is not an executable, library, or module.")); return false; @@ -420,7 +423,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) targets.push_back(target); } else { // Did not find the target. - this->SetError( + status.SetError( cmStrCat("TARGETS given target \"", tgt, "\" which does not exist.")); return false; } @@ -472,20 +475,20 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) if (!archiveArgs.GetDestination().empty()) { // The import library uses the ARCHIVE properties. archiveGenerator = CreateInstallTargetGenerator( - target, archiveArgs, true, this->Makefile->GetBacktrace()); + target, archiveArgs, true, helper.Makefile->GetBacktrace()); } if (!runtimeArgs.GetDestination().empty()) { // The DLL uses the RUNTIME properties. runtimeGenerator = CreateInstallTargetGenerator( - target, runtimeArgs, false, this->Makefile->GetBacktrace()); + target, runtimeArgs, false, helper.Makefile->GetBacktrace()); } if ((archiveGenerator == nullptr) && (runtimeGenerator == nullptr)) { archiveGenerator = CreateInstallTargetGenerator( - target, archiveArgs, true, this->Makefile->GetBacktrace(), - this->GetArchiveDestination(nullptr)); + target, archiveArgs, true, helper.Makefile->GetBacktrace(), + helper.GetArchiveDestination(nullptr)); runtimeGenerator = CreateInstallTargetGenerator( - target, runtimeArgs, false, this->Makefile->GetBacktrace(), - this->GetRuntimeDestination(nullptr)); + target, runtimeArgs, false, helper.Makefile->GetBacktrace(), + helper.GetRuntimeDestination(nullptr)); } } else { // This is a non-DLL platform. @@ -500,9 +503,9 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) // Use the FRAMEWORK properties. if (!frameworkArgs.GetDestination().empty()) { frameworkGenerator = CreateInstallTargetGenerator( - target, frameworkArgs, false, this->Makefile->GetBacktrace()); + target, frameworkArgs, false, helper.Makefile->GetBacktrace()); } else { - this->SetError( + status.SetError( cmStrCat("TARGETS given no FRAMEWORK DESTINATION for shared " "library FRAMEWORK target \"", target.GetName(), "\".")); @@ -512,15 +515,15 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) // The shared library uses the LIBRARY properties. if (namelinkMode != cmInstallTargetGenerator::NamelinkModeOnly) { libraryGenerator = CreateInstallTargetGenerator( - target, libraryArgs, false, this->Makefile->GetBacktrace(), - this->GetLibraryDestination(&libraryArgs)); + target, libraryArgs, false, helper.Makefile->GetBacktrace(), + helper.GetLibraryDestination(&libraryArgs)); libraryGenerator->SetNamelinkMode( cmInstallTargetGenerator::NamelinkModeSkip); } if (namelinkMode != cmInstallTargetGenerator::NamelinkModeSkip) { namelinkGenerator = CreateInstallTargetGenerator( - target, libraryArgs, false, this->Makefile->GetBacktrace(), - this->GetLibraryDestination(&libraryArgs), false, true); + target, libraryArgs, false, helper.Makefile->GetBacktrace(), + helper.GetLibraryDestination(&libraryArgs), false, true); namelinkGenerator->SetNamelinkMode( cmInstallTargetGenerator::NamelinkModeOnly); } @@ -541,32 +544,31 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) // Use the FRAMEWORK properties. if (!frameworkArgs.GetDestination().empty()) { frameworkGenerator = CreateInstallTargetGenerator( - target, frameworkArgs, false, this->Makefile->GetBacktrace()); + target, frameworkArgs, false, helper.Makefile->GetBacktrace()); } else { - this->SetError( + status.SetError( cmStrCat("TARGETS given no FRAMEWORK DESTINATION for static " "library FRAMEWORK target \"", target.GetName(), "\".")); - return false; } } else { // Static libraries use ARCHIVE properties. archiveGenerator = CreateInstallTargetGenerator( - target, archiveArgs, false, this->Makefile->GetBacktrace(), - this->GetArchiveDestination(&archiveArgs)); + target, archiveArgs, false, helper.Makefile->GetBacktrace(), + helper.GetArchiveDestination(&archiveArgs)); } } break; case cmStateEnums::MODULE_LIBRARY: { // Modules use LIBRARY properties. if (!libraryArgs.GetDestination().empty()) { libraryGenerator = CreateInstallTargetGenerator( - target, libraryArgs, false, this->Makefile->GetBacktrace()); + target, libraryArgs, false, helper.Makefile->GetBacktrace()); libraryGenerator->SetNamelinkMode(namelinkMode); namelinkOnly = (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly); } else { - this->SetError( + status.SetError( cmStrCat("TARGETS given no LIBRARY DESTINATION for module " "target \"", target.GetName(), "\".")); @@ -578,16 +580,16 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) if (!objectArgs.GetDestination().empty()) { // Verify that we know where the objects are to install them. std::string reason; - if (!this->Makefile->GetGlobalGenerator() + if (!helper.Makefile->GetGlobalGenerator() ->HasKnownObjectFileLocation(&reason)) { - this->SetError( + status.SetError( cmStrCat("TARGETS given OBJECT library \"", target.GetName(), "\" whose objects may not be installed", reason, ".")); return false; } objectGenerator = CreateInstallTargetGenerator( - target, objectArgs, false, this->Makefile->GetBacktrace()); + target, objectArgs, false, helper.Makefile->GetBacktrace()); } else { // Installing an OBJECT library without a destination transforms // it to an INTERFACE library. It installs no files but can be @@ -599,29 +601,29 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) // Application bundles use the BUNDLE properties. if (!bundleArgs.GetDestination().empty()) { bundleGenerator = CreateInstallTargetGenerator( - target, bundleArgs, false, this->Makefile->GetBacktrace()); + target, bundleArgs, false, helper.Makefile->GetBacktrace()); } else if (!runtimeArgs.GetDestination().empty()) { bool failure = false; - if (this->CheckCMP0006(failure)) { + if (helper.CheckCMP0006(failure)) { // For CMake 2.4 compatibility fallback to the RUNTIME // properties. bundleGenerator = CreateInstallTargetGenerator( - target, runtimeArgs, false, this->Makefile->GetBacktrace()); + target, runtimeArgs, false, helper.Makefile->GetBacktrace()); } else if (failure) { return false; } } if (!bundleGenerator) { - this->SetError(cmStrCat("TARGETS given no BUNDLE DESTINATION for " - "MACOSX_BUNDLE executable target \"", - target.GetName(), "\".")); + status.SetError(cmStrCat("TARGETS given no BUNDLE DESTINATION for " + "MACOSX_BUNDLE executable target \"", + target.GetName(), "\".")); return false; } } else { // Executables use the RUNTIME properties. runtimeGenerator = CreateInstallTargetGenerator( - target, runtimeArgs, false, this->Makefile->GetBacktrace(), - this->GetRuntimeDestination(&runtimeArgs)); + target, runtimeArgs, false, helper.Makefile->GetBacktrace(), + helper.GetRuntimeDestination(&runtimeArgs)); } // On DLL platforms an executable may also have an import @@ -632,7 +634,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) target.IsExecutableWithExports()) { // The import library uses the ARCHIVE properties. archiveGenerator = CreateInstallTargetGenerator( - target, archiveArgs, true, this->Makefile->GetBacktrace(), true); + target, archiveArgs, true, helper.Makefile->GetBacktrace(), true); } } break; case cmStateEnums::INTERFACE_LIBRARY: @@ -662,42 +664,42 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) if ((files) && (*files)) { std::vector relFiles = cmExpandedList(files); std::vector absFiles; - if (!this->MakeFilesFullPath("PRIVATE_HEADER", relFiles, absFiles)) { + if (!helper.MakeFilesFullPath("PRIVATE_HEADER", relFiles, absFiles)) { return false; } // Create the files install generator. privateHeaderGenerator = CreateInstallFilesGenerator( - this->Makefile, absFiles, privateHeaderArgs, false, - this->GetIncludeDestination(&privateHeaderArgs)); + helper.Makefile, absFiles, privateHeaderArgs, false, + helper.GetIncludeDestination(&privateHeaderArgs)); } files = target.GetProperty("PUBLIC_HEADER"); if ((files) && (*files)) { std::vector relFiles = cmExpandedList(files); std::vector absFiles; - if (!this->MakeFilesFullPath("PUBLIC_HEADER", relFiles, absFiles)) { + if (!helper.MakeFilesFullPath("PUBLIC_HEADER", relFiles, absFiles)) { return false; } // Create the files install generator. publicHeaderGenerator = CreateInstallFilesGenerator( - this->Makefile, absFiles, publicHeaderArgs, false, - this->GetIncludeDestination(&publicHeaderArgs)); + helper.Makefile, absFiles, publicHeaderArgs, false, + helper.GetIncludeDestination(&publicHeaderArgs)); } files = target.GetProperty("RESOURCE"); if ((files) && (*files)) { std::vector relFiles = cmExpandedList(files); std::vector absFiles; - if (!this->MakeFilesFullPath("RESOURCE", relFiles, absFiles)) { + if (!helper.MakeFilesFullPath("RESOURCE", relFiles, absFiles)) { return false; } // Create the files install generator. if (!resourceArgs.GetDestination().empty()) { resourceGenerator = CreateInstallFilesGenerator( - this->Makefile, absFiles, resourceArgs, false); + helper.Makefile, absFiles, resourceArgs, false); } else { cmSystemTools::Message( cmStrCat("INSTALL TARGETS - target ", target.GetName(), @@ -721,16 +723,16 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) installsPublicHeader || publicHeaderGenerator != nullptr; installsResource = installsResource || resourceGenerator; - this->Makefile->AddInstallGenerator(archiveGenerator); - this->Makefile->AddInstallGenerator(libraryGenerator); - this->Makefile->AddInstallGenerator(namelinkGenerator); - this->Makefile->AddInstallGenerator(runtimeGenerator); - this->Makefile->AddInstallGenerator(objectGenerator); - this->Makefile->AddInstallGenerator(frameworkGenerator); - this->Makefile->AddInstallGenerator(bundleGenerator); - this->Makefile->AddInstallGenerator(privateHeaderGenerator); - this->Makefile->AddInstallGenerator(publicHeaderGenerator); - this->Makefile->AddInstallGenerator(resourceGenerator); + helper.Makefile->AddInstallGenerator(archiveGenerator); + helper.Makefile->AddInstallGenerator(libraryGenerator); + helper.Makefile->AddInstallGenerator(namelinkGenerator); + helper.Makefile->AddInstallGenerator(runtimeGenerator); + helper.Makefile->AddInstallGenerator(objectGenerator); + helper.Makefile->AddInstallGenerator(frameworkGenerator); + helper.Makefile->AddInstallGenerator(bundleGenerator); + helper.Makefile->AddInstallGenerator(privateHeaderGenerator); + helper.Makefile->AddInstallGenerator(publicHeaderGenerator); + helper.Makefile->AddInstallGenerator(resourceGenerator); // Add this install rule to an export if one was specified and // this is not a namelink-only rule. @@ -747,7 +749,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) te->InterfaceIncludeDirectories = cmJoin(includesArgs.GetIncludeDirs(), ";"); - this->Makefile->GetGlobalGenerator() + helper.Makefile->GetGlobalGenerator() ->GetExportSets()[exports] .AddTargetExport(std::move(te)); } @@ -756,54 +758,57 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) // Tell the global generator about any installation component names // specified if (installsArchive) { - this->Makefile->GetGlobalGenerator()->AddInstallComponent( + helper.Makefile->GetGlobalGenerator()->AddInstallComponent( archiveArgs.GetComponent()); } if (installsLibrary) { - this->Makefile->GetGlobalGenerator()->AddInstallComponent( + helper.Makefile->GetGlobalGenerator()->AddInstallComponent( libraryArgs.GetComponent()); } if (installsNamelink) { - this->Makefile->GetGlobalGenerator()->AddInstallComponent( + helper.Makefile->GetGlobalGenerator()->AddInstallComponent( libraryArgs.GetNamelinkComponent()); } if (installsRuntime) { - this->Makefile->GetGlobalGenerator()->AddInstallComponent( + helper.Makefile->GetGlobalGenerator()->AddInstallComponent( runtimeArgs.GetComponent()); } if (installsObject) { - this->Makefile->GetGlobalGenerator()->AddInstallComponent( + helper.Makefile->GetGlobalGenerator()->AddInstallComponent( objectArgs.GetComponent()); } if (installsFramework) { - this->Makefile->GetGlobalGenerator()->AddInstallComponent( + helper.Makefile->GetGlobalGenerator()->AddInstallComponent( frameworkArgs.GetComponent()); } if (installsBundle) { - this->Makefile->GetGlobalGenerator()->AddInstallComponent( + helper.Makefile->GetGlobalGenerator()->AddInstallComponent( bundleArgs.GetComponent()); } if (installsPrivateHeader) { - this->Makefile->GetGlobalGenerator()->AddInstallComponent( + helper.Makefile->GetGlobalGenerator()->AddInstallComponent( privateHeaderArgs.GetComponent()); } if (installsPublicHeader) { - this->Makefile->GetGlobalGenerator()->AddInstallComponent( + helper.Makefile->GetGlobalGenerator()->AddInstallComponent( publicHeaderArgs.GetComponent()); } if (installsResource) { - this->Makefile->GetGlobalGenerator()->AddInstallComponent( + helper.Makefile->GetGlobalGenerator()->AddInstallComponent( resourceArgs.GetComponent()); } return true; } -bool cmInstallCommand::HandleFilesMode(std::vector const& args) +bool HandleFilesMode(std::vector const& args, + cmExecutionStatus& status) { + Helper helper(status); + // This is the FILES mode. bool programs = (args[0] == "PROGRAMS"); - cmInstallCommandArguments ica(this->DefaultComponentName); + cmInstallCommandArguments ica(helper.DefaultComponentName); std::vector files; ica.Bind(programs ? "PROGRAMS"_s : "FILES"_s, files); std::vector unknownArgs; @@ -811,14 +816,14 @@ bool cmInstallCommand::HandleFilesMode(std::vector const& args) if (!unknownArgs.empty()) { // Unknown argument. - this->SetError( + status.SetError( cmStrCat(args[0], " given unknown argument \"", unknownArgs[0], "\".")); return false; } std::string type = ica.GetType(); if (!type.empty() && allowedTypes.count(type) == 0) { - this->SetError( + status.SetError( cmStrCat(args[0], " given non-type \"", type, "\" with TYPE argument.")); return false; } @@ -832,27 +837,27 @@ bool cmInstallCommand::HandleFilesMode(std::vector const& args) if (!ica.GetRename().empty() && filesVector.size() > 1) { // The rename option works only with one file. - this->SetError( + status.SetError( cmStrCat(args[0], " given RENAME option with more than one file.")); return false; } std::vector absFiles; - if (!this->MakeFilesFullPath(args[0].c_str(), filesVector, absFiles)) { + if (!helper.MakeFilesFullPath(args[0].c_str(), filesVector, absFiles)) { return false; } - cmPolicies::PolicyStatus status = - this->Makefile->GetPolicyStatus(cmPolicies::CMP0062); + cmPolicies::PolicyStatus policyStatus = + helper.Makefile->GetPolicyStatus(cmPolicies::CMP0062); - cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator(); + cmGlobalGenerator* gg = helper.Makefile->GetGlobalGenerator(); for (std::string const& file : filesVector) { if (gg->IsExportedTargetsFile(file)) { const char* modal = nullptr; std::ostringstream e; MessageType messageType = MessageType::AUTHOR_WARNING; - switch (status) { + switch (policyStatus) { case cmPolicies::WARN: e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0062) << "\n"; modal = "should"; @@ -872,7 +877,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector const& args) << " not be installed with the " "install() command. Use the install(EXPORT) mechanism " "instead. See the cmake-packages(7) manual for more.\n"; - this->Makefile->IssueMessage(messageType, e.str()); + helper.Makefile->IssueMessage(messageType, e.str()); if (messageType == MessageType::FATAL_ERROR) { return false; } @@ -885,34 +890,36 @@ bool cmInstallCommand::HandleFilesMode(std::vector const& args) } if (!type.empty() && !ica.GetDestination().empty()) { - this->SetError(cmStrCat(args[0], - " given both TYPE and DESTINATION arguments. " - "You may only specify one.")); + status.SetError(cmStrCat(args[0], + " given both TYPE and DESTINATION arguments. " + "You may only specify one.")); return false; } - std::string destination = this->GetDestinationForType(&ica, type); + std::string destination = helper.GetDestinationForType(&ica, type); if (destination.empty()) { // A destination is required. - this->SetError(cmStrCat(args[0], " given no DESTINATION!")); + status.SetError(cmStrCat(args[0], " given no DESTINATION!")); return false; } // Create the files install generator. - this->Makefile->AddInstallGenerator(CreateInstallFilesGenerator( - this->Makefile, absFiles, ica, programs, destination)); + helper.Makefile->AddInstallGenerator(CreateInstallFilesGenerator( + helper.Makefile, absFiles, ica, programs, destination)); // Tell the global generator about any installation component names // specified. - this->Makefile->GetGlobalGenerator()->AddInstallComponent( + helper.Makefile->GetGlobalGenerator()->AddInstallComponent( ica.GetComponent()); return true; } -bool cmInstallCommand::HandleDirectoryMode( - std::vector const& args) +bool HandleDirectoryMode(std::vector const& args, + cmExecutionStatus& status) { + Helper helper(status); + enum Doing { DoingNone, @@ -937,14 +944,14 @@ bool cmInstallCommand::HandleDirectoryMode( std::string permissions_file; std::string permissions_dir; std::vector configurations; - std::string component = this->DefaultComponentName; + std::string component = helper.DefaultComponentName; std::string literal_args; std::string type; for (unsigned int i = 1; i < args.size(); ++i) { if (args[i] == "DESTINATION") { if (in_match_mode) { - this->SetError(cmStrCat(args[0], " does not allow \"", args[i], - "\" after PATTERN or REGEX.")); + status.SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" after PATTERN or REGEX.")); return false; } @@ -952,8 +959,8 @@ bool cmInstallCommand::HandleDirectoryMode( doing = DoingDestination; } else if (args[i] == "TYPE") { if (in_match_mode) { - this->SetError(cmStrCat(args[0], " does not allow \"", args[i], - "\" after PATTERN or REGEX.")); + status.SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" after PATTERN or REGEX.")); return false; } @@ -961,8 +968,8 @@ bool cmInstallCommand::HandleDirectoryMode( doing = DoingType; } else if (args[i] == "OPTIONAL") { if (in_match_mode) { - this->SetError(cmStrCat(args[0], " does not allow \"", args[i], - "\" after PATTERN or REGEX.")); + status.SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" after PATTERN or REGEX.")); return false; } @@ -971,8 +978,8 @@ bool cmInstallCommand::HandleDirectoryMode( doing = DoingNone; } else if (args[i] == "MESSAGE_NEVER") { if (in_match_mode) { - this->SetError(cmStrCat(args[0], " does not allow \"", args[i], - "\" after PATTERN or REGEX.")); + status.SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" after PATTERN or REGEX.")); return false; } @@ -990,16 +997,16 @@ bool cmInstallCommand::HandleDirectoryMode( } else if (args[i] == "EXCLUDE") { // Add this property to the current match rule. if (!in_match_mode || doing == DoingPattern || doing == DoingRegex) { - this->SetError(cmStrCat(args[0], " does not allow \"", args[i], - "\" before a PATTERN or REGEX is given.")); + status.SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" before a PATTERN or REGEX is given.")); return false; } literal_args += " EXCLUDE"; doing = DoingNone; } else if (args[i] == "PERMISSIONS") { if (!in_match_mode) { - this->SetError(cmStrCat(args[0], " does not allow \"", args[i], - "\" before a PATTERN or REGEX is given.")); + status.SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" before a PATTERN or REGEX is given.")); return false; } @@ -1008,8 +1015,8 @@ bool cmInstallCommand::HandleDirectoryMode( doing = DoingPermsMatch; } else if (args[i] == "FILE_PERMISSIONS") { if (in_match_mode) { - this->SetError(cmStrCat(args[0], " does not allow \"", args[i], - "\" after PATTERN or REGEX.")); + status.SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" after PATTERN or REGEX.")); return false; } @@ -1017,8 +1024,8 @@ bool cmInstallCommand::HandleDirectoryMode( doing = DoingPermsFile; } else if (args[i] == "DIRECTORY_PERMISSIONS") { if (in_match_mode) { - this->SetError(cmStrCat(args[0], " does not allow \"", args[i], - "\" after PATTERN or REGEX.")); + status.SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" after PATTERN or REGEX.")); return false; } @@ -1026,8 +1033,8 @@ bool cmInstallCommand::HandleDirectoryMode( doing = DoingPermsDir; } else if (args[i] == "USE_SOURCE_PERMISSIONS") { if (in_match_mode) { - this->SetError(cmStrCat(args[0], " does not allow \"", args[i], - "\" after PATTERN or REGEX.")); + status.SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" after PATTERN or REGEX.")); return false; } @@ -1036,8 +1043,8 @@ bool cmInstallCommand::HandleDirectoryMode( doing = DoingNone; } else if (args[i] == "FILES_MATCHING") { if (in_match_mode) { - this->SetError(cmStrCat(args[0], " does not allow \"", args[i], - "\" after PATTERN or REGEX.")); + status.SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" after PATTERN or REGEX.")); return false; } @@ -1046,8 +1053,8 @@ bool cmInstallCommand::HandleDirectoryMode( doing = DoingNone; } else if (args[i] == "CONFIGURATIONS") { if (in_match_mode) { - this->SetError(cmStrCat(args[0], " does not allow \"", args[i], - "\" after PATTERN or REGEX.")); + status.SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" after PATTERN or REGEX.")); return false; } @@ -1055,8 +1062,8 @@ bool cmInstallCommand::HandleDirectoryMode( doing = DoingConfigurations; } else if (args[i] == "COMPONENT") { if (in_match_mode) { - this->SetError(cmStrCat(args[0], " does not allow \"", args[i], - "\" after PATTERN or REGEX.")); + status.SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" after PATTERN or REGEX.")); return false; } @@ -1064,8 +1071,8 @@ bool cmInstallCommand::HandleDirectoryMode( doing = DoingComponent; } else if (args[i] == "EXCLUDE_FROM_ALL") { if (in_match_mode) { - this->SetError(cmStrCat(args[0], " does not allow \"", args[i], - "\" after PATTERN or REGEX.")); + status.SetError(cmStrCat(args[0], " does not allow \"", args[i], + "\" after PATTERN or REGEX.")); return false; } exclude_from_all = true; @@ -1076,14 +1083,14 @@ bool cmInstallCommand::HandleDirectoryMode( std::string::size_type gpos = cmGeneratorExpression::Find(dir); if (gpos != 0 && !cmSystemTools::FileIsFullPath(dir)) { dir = - cmStrCat(this->Makefile->GetCurrentSourceDirectory(), '/', args[i]); + cmStrCat(helper.Makefile->GetCurrentSourceDirectory(), '/', args[i]); } // Make sure the name is a directory. if (cmSystemTools::FileExists(dir) && !cmSystemTools::FileIsDirectory(dir)) { - this->SetError(cmStrCat(args[0], " given non-directory \"", args[i], - "\" to install.")); + status.SetError(cmStrCat(args[0], " given non-directory \"", args[i], + "\" to install.")); return false; } @@ -1096,8 +1103,8 @@ bool cmInstallCommand::HandleDirectoryMode( doing = DoingNone; } else if (doing == DoingType) { if (allowedTypes.count(args[i]) == 0) { - this->SetError(cmStrCat(args[0], " given non-type \"", args[i], - "\" with TYPE argument.")); + status.SetError(cmStrCat(args[0], " given non-type \"", args[i], + "\" with TYPE argument.")); return false; } @@ -1133,15 +1140,15 @@ bool cmInstallCommand::HandleDirectoryMode( // Check the requested permission. if (!cmInstallCommandArguments::CheckPermissions(args[i], permissions_file)) { - this->SetError(cmStrCat(args[0], " given invalid file permission \"", - args[i], "\".")); + status.SetError(cmStrCat(args[0], " given invalid file permission \"", + args[i], "\".")); return false; } } else if (doing == DoingPermsDir) { // Check the requested permission. if (!cmInstallCommandArguments::CheckPermissions(args[i], permissions_dir)) { - this->SetError(cmStrCat( + status.SetError(cmStrCat( args[0], " given invalid directory permission \"", args[i], "\".")); return false; } @@ -1149,13 +1156,13 @@ bool cmInstallCommand::HandleDirectoryMode( // Check the requested permission. if (!cmInstallCommandArguments::CheckPermissions(args[i], literal_args)) { - this->SetError( + status.SetError( cmStrCat(args[0], " given invalid permission \"", args[i], "\".")); return false; } } else { // Unknown argument. - this->SetError( + status.SetError( cmStrCat(args[0], " given unknown argument \"", args[i], "\".")); return false; } @@ -1174,40 +1181,42 @@ bool cmInstallCommand::HandleDirectoryMode( if (!destination) { if (type.empty()) { // A destination is required. - this->SetError(cmStrCat(args[0], " given no DESTINATION!")); + status.SetError(cmStrCat(args[0], " given no DESTINATION!")); return false; } - destinationStr = this->GetDestinationForType(nullptr, type); + destinationStr = helper.GetDestinationForType(nullptr, type); destination = destinationStr.c_str(); } else if (!type.empty()) { - this->SetError(cmStrCat(args[0], - " given both TYPE and DESTINATION " - "arguments. You may only specify one.")); + status.SetError(cmStrCat(args[0], + " given both TYPE and DESTINATION " + "arguments. You may only specify one.")); return false; } cmInstallGenerator::MessageLevel message = - cmInstallGenerator::SelectMessageLevel(this->Makefile, message_never); + cmInstallGenerator::SelectMessageLevel(helper.Makefile, message_never); // Create the directory install generator. - this->Makefile->AddInstallGenerator(new cmInstallDirectoryGenerator( + helper.Makefile->AddInstallGenerator(new cmInstallDirectoryGenerator( dirs, destination, permissions_file.c_str(), permissions_dir.c_str(), configurations, component.c_str(), message, exclude_from_all, literal_args.c_str(), optional)); // Tell the global generator about any installation component names // specified. - this->Makefile->GetGlobalGenerator()->AddInstallComponent(component); + helper.Makefile->GetGlobalGenerator()->AddInstallComponent(component); return true; } -bool cmInstallCommand::HandleExportAndroidMKMode( - std::vector const& args) +bool HandleExportAndroidMKMode(std::vector const& args, + cmExecutionStatus& status) { #ifndef CMAKE_BOOTSTRAP + Helper helper(status); + // This is the EXPORT mode. - cmInstallCommandArguments ica(this->DefaultComponentName); + cmInstallCommandArguments ica(helper.DefaultComponentName); std::string exp; std::string name_space; @@ -1224,7 +1233,7 @@ bool cmInstallCommand::HandleExportAndroidMKMode( if (!unknownArgs.empty()) { // Unknown argument. - this->SetError( + status.SetError( cmStrCat(args[0], " given unknown argument \"", unknownArgs[0], "\".")); return false; } @@ -1236,30 +1245,30 @@ bool cmInstallCommand::HandleExportAndroidMKMode( // Make sure there is a destination. if (ica.GetDestination().empty()) { // A destination is required. - this->SetError(cmStrCat(args[0], " given no DESTINATION!")); + status.SetError(cmStrCat(args[0], " given no DESTINATION!")); return false; } // Check the file name. std::string fname = filename; if (fname.find_first_of(":/\\") != std::string::npos) { - this->SetError(cmStrCat(args[0], " given invalid export file name \"", - fname, - "\". The FILE argument may not contain a path. " - "Specify the path in the DESTINATION argument.")); + status.SetError(cmStrCat(args[0], " given invalid export file name \"", + fname, + "\". The FILE argument may not contain a path. " + "Specify the path in the DESTINATION argument.")); return false; } // Check the file extension. if (!fname.empty() && cmSystemTools::GetFilenameLastExtension(fname) != ".mk") { - this->SetError(cmStrCat( + status.SetError(cmStrCat( args[0], " given invalid export file name \"", fname, R"(". The FILE argument must specify a name ending in ".mk".)")); return false; } if (fname.find_first_of(":/\\") != std::string::npos) { - this->SetError( + status.SetError( cmStrCat(args[0], " given export name \"", exp, "\". " "This name cannot be safely converted to a file name. " @@ -1273,10 +1282,10 @@ bool cmInstallCommand::HandleExportAndroidMKMode( } cmExportSet& exportSet = - this->Makefile->GetGlobalGenerator()->GetExportSets()[exp]; + helper.Makefile->GetGlobalGenerator()->GetExportSets()[exp]; cmInstallGenerator::MessageLevel message = - cmInstallGenerator::SelectMessageLevel(this->Makefile); + cmInstallGenerator::SelectMessageLevel(helper.Makefile); // Create the export install generator. cmInstallExportGenerator* exportGenerator = new cmInstallExportGenerator( @@ -1284,20 +1293,23 @@ bool cmInstallCommand::HandleExportAndroidMKMode( ica.GetConfigurations(), ica.GetComponent().c_str(), message, ica.GetExcludeFromAll(), fname.c_str(), name_space.c_str(), exportOld, true); - this->Makefile->AddInstallGenerator(exportGenerator); + helper.Makefile->AddInstallGenerator(exportGenerator); return true; #else static_cast(args); - this->SetError("EXPORT_ANDROID_MK not supported in bootstrap cmake"); + status.SetError("EXPORT_ANDROID_MK not supported in bootstrap cmake"); return false; #endif } -bool cmInstallCommand::HandleExportMode(std::vector const& args) +bool HandleExportMode(std::vector const& args, + cmExecutionStatus& status) { + Helper helper(status); + // This is the EXPORT mode. - cmInstallCommandArguments ica(this->DefaultComponentName); + cmInstallCommandArguments ica(helper.DefaultComponentName); std::string exp; std::string name_space; @@ -1314,7 +1326,7 @@ bool cmInstallCommand::HandleExportMode(std::vector const& args) if (!unknownArgs.empty()) { // Unknown argument. - this->SetError( + status.SetError( cmStrCat(args[0], " given unknown argument \"", unknownArgs[0], "\".")); return false; } @@ -1326,25 +1338,25 @@ bool cmInstallCommand::HandleExportMode(std::vector const& args) // Make sure there is a destination. if (ica.GetDestination().empty()) { // A destination is required. - this->SetError(cmStrCat(args[0], " given no DESTINATION!")); + status.SetError(cmStrCat(args[0], " given no DESTINATION!")); return false; } // Check the file name. std::string fname = filename; if (fname.find_first_of(":/\\") != std::string::npos) { - this->SetError(cmStrCat(args[0], " given invalid export file name \"", - fname, - "\". " - "The FILE argument may not contain a path. " - "Specify the path in the DESTINATION argument.")); + status.SetError(cmStrCat(args[0], " given invalid export file name \"", + fname, + "\". " + "The FILE argument may not contain a path. " + "Specify the path in the DESTINATION argument.")); return false; } // Check the file extension. if (!fname.empty() && cmSystemTools::GetFilenameLastExtension(fname) != ".cmake") { - this->SetError( + status.SetError( cmStrCat(args[0], " given invalid export file name \"", fname, "\". " "The FILE argument must specify a name ending in \".cmake\".")); @@ -1356,7 +1368,7 @@ bool cmInstallCommand::HandleExportMode(std::vector const& args) fname = cmStrCat(exp, ".cmake"); if (fname.find_first_of(":/\\") != std::string::npos) { - this->SetError(cmStrCat( + status.SetError(cmStrCat( args[0], " given export name \"", exp, "\". " "This name cannot be safely converted to a file name. " @@ -1367,17 +1379,17 @@ bool cmInstallCommand::HandleExportMode(std::vector const& args) } cmExportSet& exportSet = - this->Makefile->GetGlobalGenerator()->GetExportSets()[exp]; + helper.Makefile->GetGlobalGenerator()->GetExportSets()[exp]; if (exportOld) { for (auto const& te : exportSet.GetTargetExports()) { cmTarget* tgt = - this->Makefile->GetGlobalGenerator()->FindTarget(te->TargetName); + helper.Makefile->GetGlobalGenerator()->FindTarget(te->TargetName); const bool newCMP0022Behavior = (tgt && tgt->GetPolicyStatusCMP0022() != cmPolicies::WARN && tgt->GetPolicyStatusCMP0022() != cmPolicies::OLD); if (!newCMP0022Behavior) { - this->SetError(cmStrCat( + status.SetError(cmStrCat( "INSTALL(EXPORT) given keyword \"" "EXPORT_LINK_INTERFACE_LIBRARIES\", but target \"", te->TargetName, "\" does not have policy CMP0022 set to NEW.")); @@ -1387,7 +1399,7 @@ bool cmInstallCommand::HandleExportMode(std::vector const& args) } cmInstallGenerator::MessageLevel message = - cmInstallGenerator::SelectMessageLevel(this->Makefile); + cmInstallGenerator::SelectMessageLevel(helper.Makefile); // Create the export install generator. cmInstallExportGenerator* exportGenerator = new cmInstallExportGenerator( @@ -1395,14 +1407,14 @@ bool cmInstallCommand::HandleExportMode(std::vector const& args) ica.GetConfigurations(), ica.GetComponent().c_str(), message, ica.GetExcludeFromAll(), fname.c_str(), name_space.c_str(), exportOld, false); - this->Makefile->AddInstallGenerator(exportGenerator); + helper.Makefile->AddInstallGenerator(exportGenerator); return true; } -bool cmInstallCommand::MakeFilesFullPath( - const char* modeName, const std::vector& relFiles, - std::vector& absFiles) +bool Helper::MakeFilesFullPath(const char* modeName, + const std::vector& relFiles, + std::vector& absFiles) { for (std::string const& relFile : relFiles) { std::string file = relFile; @@ -1424,7 +1436,7 @@ bool cmInstallCommand::MakeFilesFullPath( return true; } -bool cmInstallCommand::CheckCMP0006(bool& failure) +bool Helper::CheckCMP0006(bool& failure) { switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0006)) { case cmPolicies::WARN: @@ -1449,9 +1461,9 @@ bool cmInstallCommand::CheckCMP0006(bool& failure) return false; } -std::string cmInstallCommand::GetDestination( - const cmInstallCommandArguments* args, const std::string& varName, - const std::string& guess) +std::string Helper::GetDestination(const cmInstallCommandArguments* args, + const std::string& varName, + const std::string& guess) { if (args && !args->GetDestination().empty()) { return args->GetDestination(); @@ -1463,55 +1475,54 @@ std::string cmInstallCommand::GetDestination( return guess; } -std::string cmInstallCommand::GetRuntimeDestination( +std::string Helper::GetRuntimeDestination( const cmInstallCommandArguments* args) { return this->GetDestination(args, "CMAKE_INSTALL_BINDIR", "bin"); } -std::string cmInstallCommand::GetSbinDestination( - const cmInstallCommandArguments* args) +std::string Helper::GetSbinDestination(const cmInstallCommandArguments* args) { return this->GetDestination(args, "CMAKE_INSTALL_SBINDIR", "sbin"); } -std::string cmInstallCommand::GetArchiveDestination( +std::string Helper::GetArchiveDestination( const cmInstallCommandArguments* args) { return this->GetDestination(args, "CMAKE_INSTALL_LIBDIR", "lib"); } -std::string cmInstallCommand::GetLibraryDestination( +std::string Helper::GetLibraryDestination( const cmInstallCommandArguments* args) { return this->GetDestination(args, "CMAKE_INSTALL_LIBDIR", "lib"); } -std::string cmInstallCommand::GetIncludeDestination( +std::string Helper::GetIncludeDestination( const cmInstallCommandArguments* args) { return this->GetDestination(args, "CMAKE_INSTALL_INCLUDEDIR", "include"); } -std::string cmInstallCommand::GetSysconfDestination( +std::string Helper::GetSysconfDestination( const cmInstallCommandArguments* args) { return this->GetDestination(args, "CMAKE_INSTALL_SYSCONFDIR", "etc"); } -std::string cmInstallCommand::GetSharedStateDestination( +std::string Helper::GetSharedStateDestination( const cmInstallCommandArguments* args) { return this->GetDestination(args, "CMAKE_INSTALL_SHAREDSTATEDIR", "com"); } -std::string cmInstallCommand::GetLocalStateDestination( +std::string Helper::GetLocalStateDestination( const cmInstallCommandArguments* args) { return this->GetDestination(args, "CMAKE_INSTALL_LOCALSTATEDIR", "var"); } -std::string cmInstallCommand::GetRunStateDestination( +std::string Helper::GetRunStateDestination( const cmInstallCommandArguments* args) { return this->GetDestination(args, "CMAKE_INSTALL_RUNSTATEDIR", @@ -1519,49 +1530,44 @@ std::string cmInstallCommand::GetRunStateDestination( "/run"); } -std::string cmInstallCommand::GetDataRootDestination( +std::string Helper::GetDataRootDestination( const cmInstallCommandArguments* args) { return this->GetDestination(args, "CMAKE_INSTALL_DATAROOTDIR", "share"); } -std::string cmInstallCommand::GetDataDestination( - const cmInstallCommandArguments* args) +std::string Helper::GetDataDestination(const cmInstallCommandArguments* args) { return this->GetDestination(args, "CMAKE_INSTALL_DATADIR", this->GetDataRootDestination(nullptr)); } -std::string cmInstallCommand::GetInfoDestination( - const cmInstallCommandArguments* args) +std::string Helper::GetInfoDestination(const cmInstallCommandArguments* args) { return this->GetDestination(args, "CMAKE_INSTALL_INFODIR", this->GetDataRootDestination(nullptr) + "/info"); } -std::string cmInstallCommand::GetLocaleDestination( - const cmInstallCommandArguments* args) +std::string Helper::GetLocaleDestination(const cmInstallCommandArguments* args) { return this->GetDestination(args, "CMAKE_INSTALL_LOCALEDIR", this->GetDataRootDestination(nullptr) + "/locale"); } -std::string cmInstallCommand::GetManDestination( - const cmInstallCommandArguments* args) +std::string Helper::GetManDestination(const cmInstallCommandArguments* args) { return this->GetDestination(args, "CMAKE_INSTALL_MANDIR", this->GetDataRootDestination(nullptr) + "/man"); } -std::string cmInstallCommand::GetDocDestination( - const cmInstallCommandArguments* args) +std::string Helper::GetDocDestination(const cmInstallCommandArguments* args) { return this->GetDestination(args, "CMAKE_INSTALL_DOCDIR", this->GetDataRootDestination(nullptr) + "/doc"); } -std::string cmInstallCommand::GetDestinationForType( +std::string Helper::GetDestinationForType( const cmInstallCommandArguments* args, const std::string& type) { if (args && !args->GetDestination().empty()) { @@ -1608,3 +1614,31 @@ std::string cmInstallCommand::GetDestinationForType( } return ""; } + +} // namespace + +bool cmInstallCommand(std::vector const& args, + cmExecutionStatus& status) +{ + // Allow calling with no arguments so that arguments may be built up + // using a variable that may be left empty. + if (args.empty()) { + return true; + } + + // Enable the install target. + status.GetMakefile().GetGlobalGenerator()->EnableInstallTarget(); + + static cmSubcommandTable const subcommand{ + { "SCRIPT"_s, HandleScriptMode }, + { "CODE"_s, HandleScriptMode }, + { "TARGETS"_s, HandleTargetsMode }, + { "FILES"_s, HandleFilesMode }, + { "PROGRAMS"_s, HandleFilesMode }, + { "DIRECTORY"_s, HandleDirectoryMode }, + { "EXPORT"_s, HandleExportMode }, + { "EXPORT_ANDROID_MK"_s, HandleExportAndroidMKMode }, + }; + + return subcommand(args[0], args, status); +} diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h index 9ffb842..32f00ce 100644 --- a/Source/cmInstallCommand.h +++ b/Source/cmInstallCommand.h @@ -8,71 +8,9 @@ #include #include -#include - -#include "cmCommand.h" - class cmExecutionStatus; -class cmInstallCommandArguments; - -/** \class cmInstallCommand - * \brief Specifies where to install some files - * - * cmInstallCommand is a general-purpose interface command for - * specifying install rules. - */ -class cmInstallCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - -private: - bool HandleScriptMode(std::vector const& args); - bool HandleTargetsMode(std::vector const& args); - bool HandleFilesMode(std::vector const& args); - bool HandleDirectoryMode(std::vector const& args); - bool HandleExportMode(std::vector const& args); - bool HandleExportAndroidMKMode(std::vector const& args); - bool MakeFilesFullPath(const char* modeName, - const std::vector& relFiles, - std::vector& absFiles); - bool CheckCMP0006(bool& failure); - - std::string GetDestination(const cmInstallCommandArguments* args, - const std::string& varName, - const std::string& guess); - std::string GetRuntimeDestination(const cmInstallCommandArguments* args); - std::string GetSbinDestination(const cmInstallCommandArguments* args); - std::string GetArchiveDestination(const cmInstallCommandArguments* args); - std::string GetLibraryDestination(const cmInstallCommandArguments* args); - std::string GetIncludeDestination(const cmInstallCommandArguments* args); - std::string GetSysconfDestination(const cmInstallCommandArguments* args); - std::string GetSharedStateDestination(const cmInstallCommandArguments* args); - std::string GetLocalStateDestination(const cmInstallCommandArguments* args); - std::string GetRunStateDestination(const cmInstallCommandArguments* args); - std::string GetDataRootDestination(const cmInstallCommandArguments* args); - std::string GetDataDestination(const cmInstallCommandArguments* args); - std::string GetInfoDestination(const cmInstallCommandArguments* args); - std::string GetLocaleDestination(const cmInstallCommandArguments* args); - std::string GetManDestination(const cmInstallCommandArguments* args); - std::string GetDocDestination(const cmInstallCommandArguments* args); - std::string GetDestinationForType(const cmInstallCommandArguments* args, - const std::string& type); - std::string DefaultComponentName; -}; +bool cmInstallCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1dd31297cad93b5b9a8fd1ab2b5bb9916ffe5d18 commit 1dd31297cad93b5b9a8fd1ab2b5bb9916ffe5d18 Author: Regina Pfeifer AuthorDate: Wed Sep 18 17:40:31 2019 +0200 Commit: Regina Pfeifer CommitDate: Sat Sep 21 05:15:26 2019 +0200 cmTargetLinkLibrariesCommand: Port away from cmCommand diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 6a91674..cc9448d 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -257,7 +257,7 @@ void GetProjectCommands(cmState* state) "target_include_directories", cm::make_unique()); state->AddBuiltinCommand("target_link_libraries", - cm::make_unique()); + cmTargetLinkLibrariesCommand); state->AddBuiltinCommand("target_sources", cm::make_unique()); state->AddBuiltinCommand("try_compile", diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index b432599..0d2383a 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -5,6 +5,7 @@ #include #include +#include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" @@ -15,44 +16,64 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTarget.h" +#include "cmTargetLinkLibraryType.h" #include "cmake.h" -class cmExecutionStatus; +namespace { -const char* cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[3] = { - "general", "debug", "optimized" +enum ProcessingState +{ + ProcessingLinkLibraries, + ProcessingPlainLinkInterface, + ProcessingKeywordLinkInterface, + ProcessingPlainPublicInterface, + ProcessingKeywordPublicInterface, + ProcessingPlainPrivateInterface, + ProcessingKeywordPrivateInterface }; -// cmTargetLinkLibrariesCommand -bool cmTargetLinkLibrariesCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +const char* LinkLibraryTypeNames[3] = { "general", "debug", "optimized" }; + +} // namespace + +static void LinkLibraryTypeSpecifierWarning(cmMakefile& mf, int left, + int right); + +static bool HandleLibrary(cmMakefile& mf, cmTarget* target, + ProcessingState currentProcessingState, + const std::string& lib, cmTargetLinkLibraryType llt); + +bool cmTargetLinkLibrariesCommand(std::vector const& args, + cmExecutionStatus& status) { // Must have at least one argument. if (args.empty()) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } + + cmMakefile& mf = status.GetMakefile(); + // Alias targets cannot be on the LHS of this command. - if (this->Makefile->IsAlias(args[0])) { - this->SetError("can not be used on an ALIAS target."); + if (mf.IsAlias(args[0])) { + status.SetError("can not be used on an ALIAS target."); return false; } // Lookup the target for which libraries are specified. - this->Target = - this->Makefile->GetCMakeInstance()->GetGlobalGenerator()->FindTarget( - args[0]); - if (!this->Target) { + cmTarget* target = + mf.GetCMakeInstance()->GetGlobalGenerator()->FindTarget(args[0]); + if (!target) { const std::vector& importedTargets = - this->Makefile->GetOwnedImportedTargets(); + mf.GetOwnedImportedTargets(); for (cmTarget* importedTarget : importedTargets) { if (importedTarget->GetName() == args[0]) { - this->Target = importedTarget; + target = importedTarget; break; } } } - if (!this->Target) { + if (!target) { MessageType t = MessageType::FATAL_ERROR; // fail by default std::ostringstream e; e << "Cannot specify link libraries for target \"" << args[0] << "\" " @@ -60,7 +81,7 @@ bool cmTargetLinkLibrariesCommand::InitialPass( // The bad target is the only argument. Check how policy CMP0016 is set, // and accept, warn or fail respectively: if (args.size() < 2) { - switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0016)) { + switch (mf.GetPolicyStatus(cmPolicies::CMP0016)) { case cmPolicies::WARN: t = MessageType::AUTHOR_WARNING; // Print the warning. @@ -84,10 +105,10 @@ bool cmTargetLinkLibrariesCommand::InitialPass( // Now actually print the message. switch (t) { case MessageType::AUTHOR_WARNING: - this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, e.str()); + mf.IssueMessage(MessageType::AUTHOR_WARNING, e.str()); break; case MessageType::FATAL_ERROR: - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + mf.IssueMessage(MessageType::FATAL_ERROR, e.str()); cmSystemTools::SetFatalErrorOccured(); break; default: @@ -97,11 +118,11 @@ bool cmTargetLinkLibrariesCommand::InitialPass( } // Having a UTILITY library on the LHS is a bug. - if (this->Target->GetType() == cmStateEnums::UTILITY) { + if (target->GetType() == cmStateEnums::UTILITY) { std::ostringstream e; const char* modal = nullptr; MessageType messageType = MessageType::AUTHOR_WARNING; - switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0039)) { + switch (mf.GetPolicyStatus(cmPolicies::CMP0039)) { case cmPolicies::WARN: e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0039) << "\n"; modal = "should"; @@ -114,9 +135,9 @@ bool cmTargetLinkLibrariesCommand::InitialPass( messageType = MessageType::FATAL_ERROR; } if (modal) { - e << "Utility target \"" << this->Target->GetName() << "\" " << modal + e << "Utility target \"" << target->GetName() << "\" " << modal << " not be used as the target of a target_link_libraries call."; - this->Makefile->IssueMessage(messageType, e.str()); + mf.IssueMessage(messageType, e.str()); if (messageType == MessageType::FATAL_ERROR) { return false; } @@ -134,15 +155,15 @@ bool cmTargetLinkLibrariesCommand::InitialPass( // Start with primary linking and switch to link interface // specification if the keyword is encountered as the first argument. - this->CurrentProcessingState = ProcessingLinkLibraries; + ProcessingState currentProcessingState = ProcessingLinkLibraries; // Add libraries, note that there is an optional prefix // of debug and optimized that can be used. for (unsigned int i = 1; i < args.size(); ++i) { if (args[i] == "LINK_INTERFACE_LIBRARIES") { - this->CurrentProcessingState = ProcessingPlainLinkInterface; + currentProcessingState = ProcessingPlainLinkInterface; if (i != 1) { - this->Makefile->IssueMessage( + mf.IssueMessage( MessageType::FATAL_ERROR, "The LINK_INTERFACE_LIBRARIES option must appear as the second " "argument, just after the target name."); @@ -150,84 +171,83 @@ bool cmTargetLinkLibrariesCommand::InitialPass( } } else if (args[i] == "INTERFACE") { if (i != 1 && - this->CurrentProcessingState != ProcessingKeywordPrivateInterface && - this->CurrentProcessingState != ProcessingKeywordPublicInterface && - this->CurrentProcessingState != ProcessingKeywordLinkInterface) { - this->Makefile->IssueMessage( + currentProcessingState != ProcessingKeywordPrivateInterface && + currentProcessingState != ProcessingKeywordPublicInterface && + currentProcessingState != ProcessingKeywordLinkInterface) { + mf.IssueMessage( MessageType::FATAL_ERROR, "The INTERFACE, PUBLIC or PRIVATE option must appear as the second " "argument, just after the target name."); return true; } - this->CurrentProcessingState = ProcessingKeywordLinkInterface; + currentProcessingState = ProcessingKeywordLinkInterface; } else if (args[i] == "LINK_PUBLIC") { if (i != 1 && - this->CurrentProcessingState != ProcessingPlainPrivateInterface && - this->CurrentProcessingState != ProcessingPlainPublicInterface) { - this->Makefile->IssueMessage( + currentProcessingState != ProcessingPlainPrivateInterface && + currentProcessingState != ProcessingPlainPublicInterface) { + mf.IssueMessage( MessageType::FATAL_ERROR, "The LINK_PUBLIC or LINK_PRIVATE option must appear as the second " "argument, just after the target name."); return true; } - this->CurrentProcessingState = ProcessingPlainPublicInterface; + currentProcessingState = ProcessingPlainPublicInterface; } else if (args[i] == "PUBLIC") { if (i != 1 && - this->CurrentProcessingState != ProcessingKeywordPrivateInterface && - this->CurrentProcessingState != ProcessingKeywordPublicInterface && - this->CurrentProcessingState != ProcessingKeywordLinkInterface) { - this->Makefile->IssueMessage( + currentProcessingState != ProcessingKeywordPrivateInterface && + currentProcessingState != ProcessingKeywordPublicInterface && + currentProcessingState != ProcessingKeywordLinkInterface) { + mf.IssueMessage( MessageType::FATAL_ERROR, "The INTERFACE, PUBLIC or PRIVATE option must appear as the second " "argument, just after the target name."); return true; } - this->CurrentProcessingState = ProcessingKeywordPublicInterface; + currentProcessingState = ProcessingKeywordPublicInterface; } else if (args[i] == "LINK_PRIVATE") { - if (i != 1 && - this->CurrentProcessingState != ProcessingPlainPublicInterface && - this->CurrentProcessingState != ProcessingPlainPrivateInterface) { - this->Makefile->IssueMessage( + if (i != 1 && currentProcessingState != ProcessingPlainPublicInterface && + currentProcessingState != ProcessingPlainPrivateInterface) { + mf.IssueMessage( MessageType::FATAL_ERROR, "The LINK_PUBLIC or LINK_PRIVATE option must appear as the second " "argument, just after the target name."); return true; } - this->CurrentProcessingState = ProcessingPlainPrivateInterface; + currentProcessingState = ProcessingPlainPrivateInterface; } else if (args[i] == "PRIVATE") { if (i != 1 && - this->CurrentProcessingState != ProcessingKeywordPrivateInterface && - this->CurrentProcessingState != ProcessingKeywordPublicInterface && - this->CurrentProcessingState != ProcessingKeywordLinkInterface) { - this->Makefile->IssueMessage( + currentProcessingState != ProcessingKeywordPrivateInterface && + currentProcessingState != ProcessingKeywordPublicInterface && + currentProcessingState != ProcessingKeywordLinkInterface) { + mf.IssueMessage( MessageType::FATAL_ERROR, "The INTERFACE, PUBLIC or PRIVATE option must appear as the second " "argument, just after the target name."); return true; } - this->CurrentProcessingState = ProcessingKeywordPrivateInterface; + currentProcessingState = ProcessingKeywordPrivateInterface; } else if (args[i] == "debug") { if (haveLLT) { - this->LinkLibraryTypeSpecifierWarning(llt, DEBUG_LibraryType); + LinkLibraryTypeSpecifierWarning(mf, llt, DEBUG_LibraryType); } llt = DEBUG_LibraryType; haveLLT = true; } else if (args[i] == "optimized") { if (haveLLT) { - this->LinkLibraryTypeSpecifierWarning(llt, OPTIMIZED_LibraryType); + LinkLibraryTypeSpecifierWarning(mf, llt, OPTIMIZED_LibraryType); } llt = OPTIMIZED_LibraryType; haveLLT = true; } else if (args[i] == "general") { if (haveLLT) { - this->LinkLibraryTypeSpecifierWarning(llt, GENERAL_LibraryType); + LinkLibraryTypeSpecifierWarning(mf, llt, GENERAL_LibraryType); } llt = GENERAL_LibraryType; haveLLT = true; } else if (haveLLT) { // The link type was specified by the previous argument. haveLLT = false; - if (!this->HandleLibrary(args[i], llt)) { + if (!HandleLibrary(mf, target, currentProcessingState, args[i], llt)) { return false; } } else { @@ -239,7 +259,7 @@ bool cmTargetLinkLibrariesCommand::InitialPass( // with old versions of CMake and new) llt = GENERAL_LibraryType; std::string linkType = cmStrCat(args[0], "_LINK_TYPE"); - const char* linkTypeString = this->Makefile->GetDefinition(linkType); + const char* linkTypeString = mf.GetDefinition(linkType); if (linkTypeString) { if (strcmp(linkTypeString, "debug") == 0) { llt = DEBUG_LibraryType; @@ -248,7 +268,7 @@ bool cmTargetLinkLibrariesCommand::InitialPass( llt = OPTIMIZED_LibraryType; } } - if (!this->HandleLibrary(args[i], llt)) { + if (!HandleLibrary(mf, target, currentProcessingState, args[i], llt)) { return false; } } @@ -256,16 +276,14 @@ bool cmTargetLinkLibrariesCommand::InitialPass( // Make sure the last argument was not a library type specifier. if (haveLLT) { - this->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat("The \"", - cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[llt], - "\" argument must be followed by a library.")); + mf.IssueMessage(MessageType::FATAL_ERROR, + cmStrCat("The \"", LinkLibraryTypeNames[llt], + "\" argument must be followed by a library.")); cmSystemTools::SetFatalErrorOccured(); } const cmPolicies::PolicyStatus policy22Status = - this->Target->GetPolicyStatusCMP0022(); + target->GetPolicyStatusCMP0022(); // If any of the LINK_ options were given, make sure the // LINK_INTERFACE_LIBRARIES target property exists. @@ -274,41 +292,40 @@ bool cmTargetLinkLibrariesCommand::InitialPass( // result in an empty link interface. if ((policy22Status == cmPolicies::OLD || policy22Status == cmPolicies::WARN) && - this->CurrentProcessingState != ProcessingLinkLibraries && - !this->Target->GetProperty("LINK_INTERFACE_LIBRARIES")) { - this->Target->SetProperty("LINK_INTERFACE_LIBRARIES", ""); + currentProcessingState != ProcessingLinkLibraries && + !target->GetProperty("LINK_INTERFACE_LIBRARIES")) { + target->SetProperty("LINK_INTERFACE_LIBRARIES", ""); } return true; } -void cmTargetLinkLibrariesCommand::LinkLibraryTypeSpecifierWarning(int left, - int right) +static void LinkLibraryTypeSpecifierWarning(cmMakefile& mf, int left, + int right) { - this->Makefile->IssueMessage( + mf.IssueMessage( MessageType::AUTHOR_WARNING, cmStrCat( - "Link library type specifier \"", - cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[left], - "\" is followed by specifier \"", - cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[right], + "Link library type specifier \"", LinkLibraryTypeNames[left], + "\" is followed by specifier \"", LinkLibraryTypeNames[right], "\" instead of a library name. The first specifier will be ignored.")); } -bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, - cmTargetLinkLibraryType llt) +static bool HandleLibrary(cmMakefile& mf, cmTarget* target, + ProcessingState currentProcessingState, + const std::string& lib, cmTargetLinkLibraryType llt) { - if (this->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY && - this->CurrentProcessingState != ProcessingKeywordLinkInterface) { - this->Makefile->IssueMessage( + if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY && + currentProcessingState != ProcessingKeywordLinkInterface) { + mf.IssueMessage( MessageType::FATAL_ERROR, "INTERFACE library can only be used with the INTERFACE keyword of " "target_link_libraries"); return false; } - if (this->Target->IsImported() && - this->CurrentProcessingState != ProcessingKeywordLinkInterface) { - this->Makefile->IssueMessage( + if (target->IsImported() && + currentProcessingState != ProcessingKeywordLinkInterface) { + mf.IssueMessage( MessageType::FATAL_ERROR, "IMPORTED library can only be used with the INTERFACE keyword of " "target_link_libraries"); @@ -316,19 +333,18 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, } cmTarget::TLLSignature sig = - (this->CurrentProcessingState == ProcessingPlainPrivateInterface || - this->CurrentProcessingState == ProcessingPlainPublicInterface || - this->CurrentProcessingState == ProcessingKeywordPrivateInterface || - this->CurrentProcessingState == ProcessingKeywordPublicInterface || - this->CurrentProcessingState == ProcessingKeywordLinkInterface) + (currentProcessingState == ProcessingPlainPrivateInterface || + currentProcessingState == ProcessingPlainPublicInterface || + currentProcessingState == ProcessingKeywordPrivateInterface || + currentProcessingState == ProcessingKeywordPublicInterface || + currentProcessingState == ProcessingKeywordLinkInterface) ? cmTarget::KeywordTLLSignature : cmTarget::PlainTLLSignature; - if (!this->Target->PushTLLCommandTrace( - sig, this->Makefile->GetExecutionContext())) { + if (!target->PushTLLCommandTrace(sig, mf.GetExecutionContext())) { std::ostringstream e; const char* modal = nullptr; MessageType messageType = MessageType::AUTHOR_WARNING; - switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0023)) { + switch (mf.GetPolicyStatus(cmPolicies::CMP0023)) { case cmPolicies::WARN: e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0023) << "\n"; modal = "should"; @@ -349,14 +365,14 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, e << "The " << existingSig << " signature for target_link_libraries has " "already been used with the target \"" - << this->Target->GetName() + << target->GetName() << "\". All uses of target_link_libraries with a target " << modal << " be either all-keyword or all-plain.\n"; - this->Target->GetTllSignatureTraces(e, - sig == cmTarget::KeywordTLLSignature - ? cmTarget::PlainTLLSignature - : cmTarget::KeywordTLLSignature); - this->Makefile->IssueMessage(messageType, e.str()); + target->GetTllSignatureTraces(e, + sig == cmTarget::KeywordTLLSignature + ? cmTarget::PlainTLLSignature + : cmTarget::KeywordTLLSignature); + mf.IssueMessage(messageType, e.str()); if (messageType == MessageType::FATAL_ERROR) { return false; } @@ -366,9 +382,9 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, bool warnRemoteInterface = false; bool rejectRemoteLinking = false; bool encodeRemoteReference = false; - if (this->Makefile != this->Target->GetMakefile()) { + if (&mf != target->GetMakefile()) { // The LHS target was created in another directory. - switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0079)) { + switch (mf.GetPolicyStatus(cmPolicies::CMP0079)) { case cmPolicies::WARN: warnRemoteInterface = true; CM_FALLTHROUGH; @@ -389,7 +405,7 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, // same directory as the target was created. Add a suffix to // the name to tell ResolveLinkItem to look up the name in the // caller's directory. - cmDirectoryId const dirId = this->Makefile->GetDirectoryId(); + cmDirectoryId const dirId = mf.GetDirectoryId(); libRef = lib + CMAKE_DIRECTORY_ID_SEP + dirId.String; } else { // This is an absolute path or a library name added by a caller @@ -401,21 +417,21 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, // Handle normal case where the command was called with another keyword than // INTERFACE / LINK_INTERFACE_LIBRARIES or none at all. (The "LINK_LIBRARIES" // property of the target on the LHS shall be populated.) - if (this->CurrentProcessingState != ProcessingKeywordLinkInterface && - this->CurrentProcessingState != ProcessingPlainLinkInterface) { + if (currentProcessingState != ProcessingKeywordLinkInterface && + currentProcessingState != ProcessingPlainLinkInterface) { if (rejectRemoteLinking) { - this->Makefile->IssueMessage( + mf.IssueMessage( MessageType::FATAL_ERROR, cmStrCat("Attempt to add link library \"", lib, "\" to target \"", - this->Target->GetName(), + target->GetName(), "\" which is not built in this " "directory.\nThis is allowed only when policy CMP0079 " "is set to NEW.")); return false; } - cmTarget* tgt = this->Makefile->GetGlobalGenerator()->FindTarget(lib); + cmTarget* tgt = mf.GetGlobalGenerator()->FindTarget(lib); if (tgt && (tgt->GetType() != cmStateEnums::STATIC_LIBRARY) && (tgt->GetType() != cmStateEnums::SHARED_LIBRARY) && @@ -423,7 +439,7 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, (tgt->GetType() != cmStateEnums::OBJECT_LIBRARY) && (tgt->GetType() != cmStateEnums::INTERFACE_LIBRARY) && !tgt->IsExecutableWithExports()) { - this->Makefile->IssueMessage( + mf.IssueMessage( MessageType::FATAL_ERROR, cmStrCat( "Target \"", lib, "\" of type ", @@ -433,15 +449,15 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, "executables with the ENABLE_EXPORTS property set.")); } - this->Target->AddLinkLibrary(*this->Makefile, lib, libRef, llt); + target->AddLinkLibrary(mf, lib, libRef, llt); } if (warnRemoteInterface) { - this->Makefile->IssueMessage( + mf.IssueMessage( MessageType::AUTHOR_WARNING, cmStrCat( cmPolicies::GetPolicyWarning(cmPolicies::CMP0079), "\nTarget\n ", - this->Target->GetName(), + target->GetName(), "\nis not created in this " "directory. For compatibility with older versions of CMake, link " "library\n ", @@ -454,18 +470,17 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, // LINK_PRIVATE and stop its processing. (The "INTERFACE_LINK_LIBRARIES" // property of the target on the LHS shall only be populated if it is a // STATIC library.) - if (this->CurrentProcessingState == ProcessingKeywordPrivateInterface || - this->CurrentProcessingState == ProcessingPlainPrivateInterface) { - if (this->Target->GetType() == cmStateEnums::STATIC_LIBRARY || - this->Target->GetType() == cmStateEnums::OBJECT_LIBRARY) { + if (currentProcessingState == ProcessingKeywordPrivateInterface || + currentProcessingState == ProcessingPlainPrivateInterface) { + if (target->GetType() == cmStateEnums::STATIC_LIBRARY || + target->GetType() == cmStateEnums::OBJECT_LIBRARY) { std::string configLib = - this->Target->GetDebugGeneratorExpressions(libRef, llt); + target->GetDebugGeneratorExpressions(libRef, llt); if (cmGeneratorExpression::IsValidTargetName(lib) || cmGeneratorExpression::Find(lib) != std::string::npos) { configLib = "$"; } - this->Target->AppendProperty("INTERFACE_LINK_LIBRARIES", - configLib.c_str()); + target->AppendProperty("INTERFACE_LINK_LIBRARIES", configLib.c_str()); } return true; } @@ -473,23 +488,23 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, // Handle general case where the command was called with another keyword than // PRIVATE / LINK_PRIVATE or none at all. (The "INTERFACE_LINK_LIBRARIES" // property of the target on the LHS shall be populated.) - this->Target->AppendProperty( + target->AppendProperty( "INTERFACE_LINK_LIBRARIES", - this->Target->GetDebugGeneratorExpressions(libRef, llt).c_str()); + target->GetDebugGeneratorExpressions(libRef, llt).c_str()); // Stop processing if called without any keyword. - if (this->CurrentProcessingState == ProcessingLinkLibraries) { + if (currentProcessingState == ProcessingLinkLibraries) { return true; } // Stop processing if policy CMP0022 is set to NEW. const cmPolicies::PolicyStatus policy22Status = - this->Target->GetPolicyStatusCMP0022(); + target->GetPolicyStatusCMP0022(); if (policy22Status != cmPolicies::OLD && policy22Status != cmPolicies::WARN) { return true; } // Stop processing if called with an INTERFACE library on the LHS. - if (this->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { return true; } @@ -499,7 +514,7 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, { // Get the list of configurations considered to be DEBUG. std::vector debugConfigs = - this->Makefile->GetCMakeInstance()->GetDebugConfigs(); + mf.GetCMakeInstance()->GetDebugConfigs(); std::string prop; // Include this library in the link interface for the target. @@ -507,19 +522,19 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, // Put in the DEBUG configuration interfaces. for (std::string const& dc : debugConfigs) { prop = cmStrCat("LINK_INTERFACE_LIBRARIES_", dc); - this->Target->AppendProperty(prop, libRef.c_str()); + target->AppendProperty(prop, libRef.c_str()); } } if (llt == OPTIMIZED_LibraryType || llt == GENERAL_LibraryType) { // Put in the non-DEBUG configuration interfaces. - this->Target->AppendProperty("LINK_INTERFACE_LIBRARIES", libRef.c_str()); + target->AppendProperty("LINK_INTERFACE_LIBRARIES", libRef.c_str()); // Make sure the DEBUG configuration interfaces exist so that the // general one will not be used as a fall-back. for (std::string const& dc : debugConfigs) { prop = cmStrCat("LINK_INTERFACE_LIBRARIES_", dc); - if (!this->Target->GetProperty(prop)) { - this->Target->SetProperty(prop, ""); + if (!target->GetProperty(prop)) { + target->SetProperty(prop, ""); } } } diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index caf2cf4..4b2deab 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -8,61 +8,9 @@ #include #include -#include - -#include "cmCommand.h" -#include "cmTargetLinkLibraryType.h" - class cmExecutionStatus; -class cmTarget; - -/** \class cmTargetLinkLibrariesCommand - * \brief Specify a list of libraries to link into executables. - * - * cmTargetLinkLibrariesCommand is used to specify a list of libraries to link - * into executable(s) or shared objects. The names of the libraries - * should be those defined by the LIBRARY(library) command(s). - * - * Additionally, it allows to propagate usage-requirements (including link - * libraries) from one target into another. - */ -class cmTargetLinkLibrariesCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - -private: - void LinkLibraryTypeSpecifierWarning(int left, int right); - static const char* LinkLibraryTypeNames[3]; - - cmTarget* Target = nullptr; - enum ProcessingState - { - ProcessingLinkLibraries, - ProcessingPlainLinkInterface, - ProcessingKeywordLinkInterface, - ProcessingPlainPublicInterface, - ProcessingKeywordPublicInterface, - ProcessingPlainPrivateInterface, - ProcessingKeywordPrivateInterface - }; - - ProcessingState CurrentProcessingState = ProcessingLinkLibraries; - bool HandleLibrary(const std::string& lib, cmTargetLinkLibraryType llt); -}; +bool cmTargetLinkLibrariesCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d5c63f073f290d4778426825e586240dca7ca0a6 commit d5c63f073f290d4778426825e586240dca7ca0a6 Author: Regina Pfeifer AuthorDate: Wed Sep 18 17:39:47 2019 +0200 Commit: Regina Pfeifer CommitDate: Sat Sep 21 05:14:42 2019 +0200 cmSourceGroupCommand: Port away from cmCommand diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 8e3a2cc..6a91674 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -288,8 +288,7 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("qt_wrap_cpp", cmQTWrapCPPCommand); state->AddBuiltinCommand("qt_wrap_ui", cmQTWrapUICommand); state->AddBuiltinCommand("remove_definitions", cmRemoveDefinitionsCommand); - state->AddBuiltinCommand("source_group", - cm::make_unique()); + state->AddBuiltinCommand("source_group", cmSourceGroupCommand); state->AddDisallowedCommand( "export_library_dependencies", cmExportLibraryDependenciesCommand, diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx index 3be7fec..3a13e57 100644 --- a/Source/cmSourceGroupCommand.cxx +++ b/Source/cmSourceGroupCommand.cxx @@ -3,16 +3,22 @@ #include "cmSourceGroupCommand.h" #include +#include #include #include #include "cmAlgorithms.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmSourceGroup.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" namespace { + +using ParsedArguments = std::map>; +using ExpectedOptions = std::vector; + const std::string kTreeOptionName = "TREE"; const std::string kPrefixOptionName = "PREFIX"; const std::string kFilesOptionName = "FILES"; @@ -117,13 +123,8 @@ bool addFilesToItsSourceGroups(const std::string& root, return true; } -} -class cmExecutionStatus; - -// cmSourceGroupCommand -cmSourceGroupCommand::ExpectedOptions -cmSourceGroupCommand::getExpectedOptions() const +ExpectedOptions getExpectedOptions() { ExpectedOptions options; @@ -135,15 +136,14 @@ cmSourceGroupCommand::getExpectedOptions() const return options; } -bool cmSourceGroupCommand::isExpectedOption( - const std::string& argument, const ExpectedOptions& expectedOptions) +bool isExpectedOption(const std::string& argument, + const ExpectedOptions& expectedOptions) { return cmContains(expectedOptions, argument); } -void cmSourceGroupCommand::parseArguments( - const std::vector& args, - cmSourceGroupCommand::ParsedArguments& parsedArguments) +void parseArguments(const std::vector& args, + ParsedArguments& parsedArguments) { const ExpectedOptions expectedOptions = getExpectedOptions(); size_t i = 0; @@ -172,21 +172,35 @@ void cmSourceGroupCommand::parseArguments( } } -bool cmSourceGroupCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +} // namespace + +static bool checkArgumentsPreconditions(const ParsedArguments& parsedArguments, + std::string& errorMsg); + +static bool processTree(cmMakefile& mf, ParsedArguments& parsedArguments, + std::string& errorMsg); + +static bool checkSingleParameterArgumentPreconditions( + const std::string& argument, const ParsedArguments& parsedArguments, + std::string& errorMsg); + +bool cmSourceGroupCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.empty()) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } + cmMakefile& mf = status.GetMakefile(); + // If only two arguments are given, the pre-1.8 version of the // command is being invoked. if (args.size() == 2 && args[1] != "FILES") { - cmSourceGroup* sg = this->Makefile->GetOrCreateSourceGroup(args[0]); + cmSourceGroup* sg = mf.GetOrCreateSourceGroup(args[0]); if (!sg) { - this->SetError("Could not create or find source group"); + status.SetError("Could not create or find source group"); return false; } @@ -204,21 +218,21 @@ bool cmSourceGroupCommand::InitialPass(std::vector const& args, } if (parsedArguments.find(kTreeOptionName) != parsedArguments.end()) { - if (!processTree(parsedArguments, errorMsg)) { - this->SetError(errorMsg); + if (!processTree(mf, parsedArguments, errorMsg)) { + status.SetError(errorMsg); return false; } } else { if (parsedArguments.find(kSourceGroupOptionName) == parsedArguments.end()) { - this->SetError("Missing source group name."); + status.SetError("Missing source group name."); return false; } - cmSourceGroup* sg = this->Makefile->GetOrCreateSourceGroup(args[0]); + cmSourceGroup* sg = mf.GetOrCreateSourceGroup(args[0]); if (!sg) { - this->SetError("Could not create or find source group"); + status.SetError("Could not create or find source group"); return false; } @@ -234,8 +248,7 @@ bool cmSourceGroupCommand::InitialPass(std::vector const& args, for (auto const& filesArg : filesArguments) { std::string src = filesArg; if (!cmSystemTools::FileIsFullPath(src)) { - src = - cmStrCat(this->Makefile->GetCurrentSourceDirectory(), '/', filesArg); + src = cmStrCat(mf.GetCurrentSourceDirectory(), '/', filesArg); } src = cmSystemTools::CollapseFullPath(src); sg->AddGroupFile(src); @@ -245,8 +258,8 @@ bool cmSourceGroupCommand::InitialPass(std::vector const& args, return true; } -bool cmSourceGroupCommand::checkArgumentsPreconditions( - const ParsedArguments& parsedArguments, std::string& errorMsg) const +static bool checkArgumentsPreconditions(const ParsedArguments& parsedArguments, + std::string& errorMsg) { return checkSingleParameterArgumentPreconditions( kPrefixOptionName, parsedArguments, errorMsg) && @@ -256,8 +269,8 @@ bool cmSourceGroupCommand::checkArgumentsPreconditions( parsedArguments, errorMsg); } -bool cmSourceGroupCommand::processTree(ParsedArguments& parsedArguments, - std::string& errorMsg) +static bool processTree(cmMakefile& mf, ParsedArguments& parsedArguments, + std::string& errorMsg) { const std::string root = cmSystemTools::CollapseFullPath(parsedArguments[kTreeOptionName].front()); @@ -265,9 +278,8 @@ bool cmSourceGroupCommand::processTree(ParsedArguments& parsedArguments, ? "" : parsedArguments[kPrefixOptionName].front(); - const std::vector filesVector = - prepareFilesPathsForTree(parsedArguments[kFilesOptionName], - this->Makefile->GetCurrentSourceDirectory()); + const std::vector filesVector = prepareFilesPathsForTree( + parsedArguments[kFilesOptionName], mf.GetCurrentSourceDirectory()); if (!rootIsPrefix(root, filesVector, errorMsg)) { return false; @@ -276,13 +288,13 @@ bool cmSourceGroupCommand::processTree(ParsedArguments& parsedArguments, std::set sourceGroupPaths = getSourceGroupFilesPaths(root, filesVector); - return addFilesToItsSourceGroups(root, sourceGroupPaths, prefix, - *(this->Makefile), errorMsg); + return addFilesToItsSourceGroups(root, sourceGroupPaths, prefix, mf, + errorMsg); } -bool cmSourceGroupCommand::checkSingleParameterArgumentPreconditions( +static bool checkSingleParameterArgumentPreconditions( const std::string& argument, const ParsedArguments& parsedArguments, - std::string& errorMsg) const + std::string& errorMsg) { auto foundArgument = parsedArguments.find(argument); if (foundArgument != parsedArguments.end()) { diff --git a/Source/cmSourceGroupCommand.h b/Source/cmSourceGroupCommand.h index 6273d92..ad39701 100644 --- a/Source/cmSourceGroupCommand.h +++ b/Source/cmSourceGroupCommand.h @@ -5,59 +5,12 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include #include #include -#include - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmSourceGroupCommand - * \brief Adds a cmSourceGroup to the cmMakefile. - * - * cmSourceGroupCommand is used to define cmSourceGroups which split up - * source files in to named, organized groups in the generated makefiles. - */ -class cmSourceGroupCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - -private: - using ParsedArguments = std::map>; - using ExpectedOptions = std::vector; - - ExpectedOptions getExpectedOptions() const; - - bool isExpectedOption(const std::string& argument, - const ExpectedOptions& expectedOptions); - - void parseArguments(const std::vector& args, - cmSourceGroupCommand::ParsedArguments& parsedArguments); - - bool processTree(ParsedArguments& parsedArguments, std::string& errorMsg); - - bool checkArgumentsPreconditions(const ParsedArguments& parsedArguments, - std::string& errorMsg) const; - bool checkSingleParameterArgumentPreconditions( - const std::string& argument, const ParsedArguments& parsedArguments, - std::string& errorMsg) const; -}; +bool cmSourceGroupCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=42e413bcbbd32cbae6705269ae0f7a0583819be9 commit 42e413bcbbd32cbae6705269ae0f7a0583819be9 Author: Regina Pfeifer AuthorDate: Wed Sep 18 17:38:07 2019 +0200 Commit: Regina Pfeifer CommitDate: Sat Sep 21 05:14:05 2019 +0200 cmSetTargetPropertiesCommand: Port away from cmCommand diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index d01972d..8e3a2cc 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -242,7 +242,7 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("set_source_files_properties", cmSetSourceFilesPropertiesCommand); state->AddBuiltinCommand("set_target_properties", - cm::make_unique()); + cmSetTargetPropertiesCommand); state->AddBuiltinCommand("set_tests_properties", cmSetTestsPropertiesCommand); state->AddBuiltinCommand("subdirs", cmSubdirCommand); diff --git a/Source/cmSetTargetPropertiesCommand.cxx b/Source/cmSetTargetPropertiesCommand.cxx index b4360e4..8d917db 100644 --- a/Source/cmSetTargetPropertiesCommand.cxx +++ b/Source/cmSetTargetPropertiesCommand.cxx @@ -5,31 +5,32 @@ #include #include "cmAlgorithms.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmStringAlgorithms.h" #include "cmTarget.h" -class cmExecutionStatus; +static bool SetOneTarget(const std::string& tname, + std::vector& propertyPairs, + cmMakefile* mf); -// cmSetTargetPropertiesCommand -bool cmSetTargetPropertiesCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +bool cmSetTargetPropertiesCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 2) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } // first collect up the list of files std::vector propertyPairs; int numFiles = 0; - std::vector::const_iterator j; - for (j = args.begin(); j != args.end(); ++j) { + for (auto j = args.begin(); j != args.end(); ++j) { if (*j == "PROPERTIES") { // now loop through the rest of the arguments, new style ++j; if (std::distance(j, args.end()) % 2 != 0) { - this->SetError("called with incorrect number of arguments."); + status.SetError("called with incorrect number of arguments."); return false; } cmAppend(propertyPairs, j, args.end()); @@ -38,33 +39,32 @@ bool cmSetTargetPropertiesCommand::InitialPass( numFiles++; } if (propertyPairs.empty()) { - this->SetError("called with illegal arguments, maybe missing " - "a PROPERTIES specifier?"); + status.SetError("called with illegal arguments, maybe missing " + "a PROPERTIES specifier?"); return false; } + cmMakefile& mf = status.GetMakefile(); + // now loop over all the targets - int i; - for (i = 0; i < numFiles; ++i) { - if (this->Makefile->IsAlias(args[i])) { - this->SetError("can not be used on an ALIAS target."); + for (int i = 0; i < numFiles; ++i) { + if (mf.IsAlias(args[i])) { + status.SetError("can not be used on an ALIAS target."); return false; } - bool ret = cmSetTargetPropertiesCommand::SetOneTarget( - args[i], propertyPairs, this->Makefile); + bool ret = SetOneTarget(args[i], propertyPairs, &mf); if (!ret) { - std::string message = - cmStrCat("Can not find target to add properties to: ", args[i]); - this->SetError(message); + status.SetError( + cmStrCat("Can not find target to add properties to: ", args[i])); return false; } } return true; } -bool cmSetTargetPropertiesCommand::SetOneTarget( - const std::string& tname, std::vector& propertyPairs, - cmMakefile* mf) +static bool SetOneTarget(const std::string& tname, + std::vector& propertyPairs, + cmMakefile* mf) { if (cmTarget* target = mf->FindTargetToUse(tname)) { // now loop through all the props and set them diff --git a/Source/cmSetTargetPropertiesCommand.h b/Source/cmSetTargetPropertiesCommand.h index e77b752..9d40c74 100644 --- a/Source/cmSetTargetPropertiesCommand.h +++ b/Source/cmSetTargetPropertiesCommand.h @@ -8,34 +8,9 @@ #include #include -#include - -#include "cmCommand.h" - class cmExecutionStatus; -class cmMakefile; - -class cmSetTargetPropertiesCommand : public cmCommand -{ -public: - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the input file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - /** - * Used by this command and cmSetPropertiesCommand - */ - static bool SetOneTarget(const std::string& tname, - std::vector& propertyPairs, - cmMakefile* mf); -}; +bool cmSetTargetPropertiesCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=77aa75b8dc76fce51973d6337473fb388b855ea4 commit 77aa75b8dc76fce51973d6337473fb388b855ea4 Author: Regina Pfeifer AuthorDate: Wed Sep 18 17:37:04 2019 +0200 Commit: Regina Pfeifer CommitDate: Sat Sep 21 05:13:30 2019 +0200 cmProjectCommand: Port away from cmCommand diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index a975856..d01972d 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -238,7 +238,7 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("install_files", cmInstallFilesCommand); state->AddBuiltinCommand("install_targets", cmInstallTargetsCommand); state->AddBuiltinCommand("link_directories", cmLinkDirectoriesCommand); - state->AddBuiltinCommand("project", cm::make_unique()); + state->AddBuiltinCommand("project", cmProjectCommand); state->AddBuiltinCommand("set_source_files_properties", cmSetSourceFilesPropertiesCommand); state->AddBuiltinCommand("set_target_properties", diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 5fa6a21..373e767 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -10,6 +10,7 @@ #include #include +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmMessageType.h" #include "cmPolicies.h" @@ -17,40 +18,39 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -class cmExecutionStatus; +static bool IncludeByVariable(cmExecutionStatus& status, + const std::string& variable); +static void TopLevelCMakeVarCondSet(cmMakefile& mf, std::string const& name, + std::string const& value); -// cmProjectCommand -bool cmProjectCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +bool cmProjectCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.empty()) { - this->SetError("PROJECT called with incorrect number of arguments"); + status.SetError("PROJECT called with incorrect number of arguments"); return false; } - if (!this->IncludeByVariable("CMAKE_PROJECT_INCLUDE_BEFORE")) { + cmMakefile& mf = status.GetMakefile(); + if (!IncludeByVariable(status, "CMAKE_PROJECT_INCLUDE_BEFORE")) { return false; } std::string const& projectName = args[0]; - this->Makefile->SetProjectName(projectName); + mf.SetProjectName(projectName); - this->Makefile->AddCacheDefinition( - projectName + "_BINARY_DIR", - this->Makefile->GetCurrentBinaryDirectory().c_str(), - "Value Computed by CMake", cmStateEnums::STATIC); - this->Makefile->AddCacheDefinition( - projectName + "_SOURCE_DIR", - this->Makefile->GetCurrentSourceDirectory().c_str(), - "Value Computed by CMake", cmStateEnums::STATIC); + mf.AddCacheDefinition(projectName + "_BINARY_DIR", + mf.GetCurrentBinaryDirectory().c_str(), + "Value Computed by CMake", cmStateEnums::STATIC); + mf.AddCacheDefinition(projectName + "_SOURCE_DIR", + mf.GetCurrentSourceDirectory().c_str(), + "Value Computed by CMake", cmStateEnums::STATIC); - this->Makefile->AddDefinition("PROJECT_BINARY_DIR", - this->Makefile->GetCurrentBinaryDirectory()); - this->Makefile->AddDefinition("PROJECT_SOURCE_DIR", - this->Makefile->GetCurrentSourceDirectory()); + mf.AddDefinition("PROJECT_BINARY_DIR", mf.GetCurrentBinaryDirectory()); + mf.AddDefinition("PROJECT_SOURCE_DIR", mf.GetCurrentSourceDirectory()); - this->Makefile->AddDefinition("PROJECT_NAME", projectName); + mf.AddDefinition("PROJECT_NAME", projectName); // Set the CMAKE_PROJECT_NAME variable to be the highest-level // project name in the tree. If there are two project commands @@ -58,12 +58,10 @@ bool cmProjectCommand::InitialPass(std::vector const& args, // CMakeLists.txt file, then go with the last one, so that // CMAKE_PROJECT_NAME will match PROJECT_NAME, and cmake --build // will work. - if (!this->Makefile->GetDefinition("CMAKE_PROJECT_NAME") || - (this->Makefile->IsRootMakefile())) { - this->Makefile->AddDefinition("CMAKE_PROJECT_NAME", projectName); - this->Makefile->AddCacheDefinition( - "CMAKE_PROJECT_NAME", projectName.c_str(), "Value Computed by CMake", - cmStateEnums::STATIC); + if (!mf.GetDefinition("CMAKE_PROJECT_NAME") || mf.IsRootMakefile()) { + mf.AddDefinition("CMAKE_PROJECT_NAME", projectName); + mf.AddCacheDefinition("CMAKE_PROJECT_NAME", projectName.c_str(), + "Value Computed by CMake", cmStateEnums::STATIC); } bool haveVersion = false; @@ -90,9 +88,8 @@ bool cmProjectCommand::InitialPass(std::vector const& args, for (size_t i = 1; i < args.size(); ++i) { if (args[i] == "LANGUAGES") { if (haveLanguages) { - this->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - "LANGUAGES may be specified at most once."); + mf.IssueMessage(MessageType::FATAL_ERROR, + "LANGUAGES may be specified at most once."); cmSystemTools::SetFatalErrorOccured(); return true; } @@ -106,12 +103,12 @@ bool cmProjectCommand::InitialPass(std::vector const& args, "the following parameters must be specified after LANGUAGES " "keyword: ", cmJoin(languages, ", "), '.'); - this->Makefile->IssueMessage(MessageType::WARNING, msg); + mf.IssueMessage(MessageType::WARNING, msg); } } else if (args[i] == "VERSION") { if (haveVersion) { - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, - "VERSION may be specified at most once."); + mf.IssueMessage(MessageType::FATAL_ERROR, + "VERSION may be specified at most once."); cmSystemTools::SetFatalErrorOccured(); return true; } @@ -120,8 +117,8 @@ bool cmProjectCommand::InitialPass(std::vector const& args, missedValueReporter(); } doing = DoingVersion; - missedValueReporter = [this, &resetReporter]() { - this->Makefile->IssueMessage( + missedValueReporter = [&mf, &resetReporter]() { + mf.IssueMessage( MessageType::WARNING, "VERSION keyword not followed by a value or was followed by a " "value that expanded to nothing."); @@ -129,9 +126,8 @@ bool cmProjectCommand::InitialPass(std::vector const& args, }; } else if (args[i] == "DESCRIPTION") { if (haveDescription) { - this->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - "DESCRIPTION may be specified at most once."); + mf.IssueMessage(MessageType::FATAL_ERROR, + "DESCRIPTION may be specified at most once."); cmSystemTools::SetFatalErrorOccured(); return true; } @@ -140,8 +136,8 @@ bool cmProjectCommand::InitialPass(std::vector const& args, missedValueReporter(); } doing = DoingDescription; - missedValueReporter = [this, &resetReporter]() { - this->Makefile->IssueMessage( + missedValueReporter = [&mf, &resetReporter]() { + mf.IssueMessage( MessageType::WARNING, "DESCRIPTION keyword not followed by a value or was followed " "by a value that expanded to nothing."); @@ -149,16 +145,15 @@ bool cmProjectCommand::InitialPass(std::vector const& args, }; } else if (args[i] == "HOMEPAGE_URL") { if (haveHomepage) { - this->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - "HOMEPAGE_URL may be specified at most once."); + mf.IssueMessage(MessageType::FATAL_ERROR, + "HOMEPAGE_URL may be specified at most once."); cmSystemTools::SetFatalErrorOccured(); return true; } haveHomepage = true; doing = DoingHomepage; - missedValueReporter = [this, &resetReporter]() { - this->Makefile->IssueMessage( + missedValueReporter = [&mf, &resetReporter]() { + mf.IssueMessage( MessageType::WARNING, "HOMEPAGE_URL keyword not followed by a value or was followed " "by a value that expanded to nothing."); @@ -190,10 +185,9 @@ bool cmProjectCommand::InitialPass(std::vector const& args, if ((haveVersion || haveDescription || haveHomepage) && !haveLanguages && !languages.empty()) { - this->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - "project with VERSION, DESCRIPTION or HOMEPAGE_URL must " - "use LANGUAGES before language names."); + mf.IssueMessage(MessageType::FATAL_ERROR, + "project with VERSION, DESCRIPTION or HOMEPAGE_URL must " + "use LANGUAGES before language names."); cmSystemTools::SetFatalErrorOccured(); return true; } @@ -202,13 +196,12 @@ bool cmProjectCommand::InitialPass(std::vector const& args, } cmPolicies::PolicyStatus const cmp0048 = - this->Makefile->GetPolicyStatus(cmPolicies::CMP0048); + mf.GetPolicyStatus(cmPolicies::CMP0048); if (haveVersion) { // Set project VERSION variables to given values if (cmp0048 == cmPolicies::OLD || cmp0048 == cmPolicies::WARN) { - this->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - "VERSION not allowed unless CMP0048 is set to NEW"); + mf.IssueMessage(MessageType::FATAL_ERROR, + "VERSION not allowed unless CMP0048 is set to NEW"); cmSystemTools::SetFatalErrorOccured(); return true; } @@ -217,13 +210,13 @@ bool cmProjectCommand::InitialPass(std::vector const& args, R"(^([0-9]+(\.[0-9]+(\.[0-9]+(\.[0-9]+)?)?)?)?$)"); if (!vx.find(version)) { std::string e = R"(VERSION ")" + version + R"(" format invalid.)"; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e); + mf.IssueMessage(MessageType::FATAL_ERROR, e); cmSystemTools::SetFatalErrorOccured(); return true; } cmPolicies::PolicyStatus const cmp0096 = - this->Makefile->GetPolicyStatus(cmPolicies::CMP0096); + mf.GetPolicyStatus(cmPolicies::CMP0096); constexpr std::size_t MAX_VERSION_COMPONENTS = 4u; std::string version_string; @@ -257,34 +250,30 @@ bool cmProjectCommand::InitialPass(std::vector const& args, std::string vv; vv = projectName + "_VERSION"; - this->Makefile->AddDefinition("PROJECT_VERSION", version_string); - this->Makefile->AddDefinition(vv, version_string); + mf.AddDefinition("PROJECT_VERSION", version_string); + mf.AddDefinition(vv, version_string); vv = projectName + "_VERSION_MAJOR"; - this->Makefile->AddDefinition("PROJECT_VERSION_MAJOR", - version_components[0]); - this->Makefile->AddDefinition(vv, version_components[0]); + mf.AddDefinition("PROJECT_VERSION_MAJOR", version_components[0]); + mf.AddDefinition(vv, version_components[0]); vv = projectName + "_VERSION_MINOR"; - this->Makefile->AddDefinition("PROJECT_VERSION_MINOR", - version_components[1]); - this->Makefile->AddDefinition(vv, version_components[1]); + mf.AddDefinition("PROJECT_VERSION_MINOR", version_components[1]); + mf.AddDefinition(vv, version_components[1]); vv = projectName + "_VERSION_PATCH"; - this->Makefile->AddDefinition("PROJECT_VERSION_PATCH", - version_components[2]); - this->Makefile->AddDefinition(vv, version_components[2]); + mf.AddDefinition("PROJECT_VERSION_PATCH", version_components[2]); + mf.AddDefinition(vv, version_components[2]); vv = projectName + "_VERSION_TWEAK"; - this->Makefile->AddDefinition("PROJECT_VERSION_TWEAK", - version_components[3]); - this->Makefile->AddDefinition(vv, version_components[3]); + mf.AddDefinition("PROJECT_VERSION_TWEAK", version_components[3]); + mf.AddDefinition(vv, version_components[3]); // Also, try set top level variables - TopLevelCMakeVarCondSet("CMAKE_PROJECT_VERSION", version_string.c_str()); - TopLevelCMakeVarCondSet("CMAKE_PROJECT_VERSION_MAJOR", - version_components[0].c_str()); - TopLevelCMakeVarCondSet("CMAKE_PROJECT_VERSION_MINOR", - version_components[1].c_str()); - TopLevelCMakeVarCondSet("CMAKE_PROJECT_VERSION_PATCH", - version_components[2].c_str()); - TopLevelCMakeVarCondSet("CMAKE_PROJECT_VERSION_TWEAK", - version_components[3].c_str()); + TopLevelCMakeVarCondSet(mf, "CMAKE_PROJECT_VERSION", version_string); + TopLevelCMakeVarCondSet(mf, "CMAKE_PROJECT_VERSION_MAJOR", + version_components[0]); + TopLevelCMakeVarCondSet(mf, "CMAKE_PROJECT_VERSION_MINOR", + version_components[1]); + TopLevelCMakeVarCondSet(mf, "CMAKE_PROJECT_VERSION_PATCH", + version_components[2]); + TopLevelCMakeVarCondSet(mf, "CMAKE_PROJECT_VERSION_TWEAK", + version_components[3]); } else if (cmp0048 != cmPolicies::OLD) { // Set project VERSION variables to empty std::vector vv = { "PROJECT_VERSION", @@ -297,7 +286,7 @@ bool cmProjectCommand::InitialPass(std::vector const& args, projectName + "_VERSION_MINOR", projectName + "_VERSION_PATCH", projectName + "_VERSION_TWEAK" }; - if (this->Makefile->IsRootMakefile()) { + if (mf.IsRootMakefile()) { vv.emplace_back("CMAKE_PROJECT_VERSION"); vv.emplace_back("CMAKE_PROJECT_VERSION_MAJOR"); vv.emplace_back("CMAKE_PROJECT_VERSION_MINOR"); @@ -306,7 +295,7 @@ bool cmProjectCommand::InitialPass(std::vector const& args, } std::string vw; for (std::string const& i : vv) { - const char* const v = this->Makefile->GetDefinition(i); + const char* const v = mf.GetDefinition(i); if (v && *v) { if (cmp0048 == cmPolicies::WARN) { if (!injectedProjectCommand) { @@ -314,51 +303,54 @@ bool cmProjectCommand::InitialPass(std::vector const& args, vw += i; } } else { - this->Makefile->AddDefinition(i, ""); + mf.AddDefinition(i, ""); } } } if (!vw.empty()) { - this->Makefile->IssueMessage( + mf.IssueMessage( MessageType::AUTHOR_WARNING, cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0048), "\nThe following variable(s) would be set to empty:", vw)); } } - this->Makefile->AddDefinition("PROJECT_DESCRIPTION", description); - this->Makefile->AddDefinition(projectName + "_DESCRIPTION", description); - TopLevelCMakeVarCondSet("CMAKE_PROJECT_DESCRIPTION", description.c_str()); + mf.AddDefinition("PROJECT_DESCRIPTION", description); + mf.AddDefinition(projectName + "_DESCRIPTION", description); + TopLevelCMakeVarCondSet(mf, "CMAKE_PROJECT_DESCRIPTION", description); - this->Makefile->AddDefinition("PROJECT_HOMEPAGE_URL", homepage); - this->Makefile->AddDefinition(projectName + "_HOMEPAGE_URL", homepage); - TopLevelCMakeVarCondSet("CMAKE_PROJECT_HOMEPAGE_URL", homepage.c_str()); + mf.AddDefinition("PROJECT_HOMEPAGE_URL", homepage); + mf.AddDefinition(projectName + "_HOMEPAGE_URL", homepage); + TopLevelCMakeVarCondSet(mf, "CMAKE_PROJECT_HOMEPAGE_URL", homepage); if (languages.empty()) { // if no language is specified do c and c++ languages = { "C", "CXX" }; } - this->Makefile->EnableLanguage(languages, false); + mf.EnableLanguage(languages, false); - if (!this->IncludeByVariable("CMAKE_PROJECT_INCLUDE")) { + if (!IncludeByVariable(status, "CMAKE_PROJECT_INCLUDE")) { return false; } - if (!this->IncludeByVariable("CMAKE_PROJECT_" + projectName + "_INCLUDE")) { + if (!IncludeByVariable(status, + "CMAKE_PROJECT_" + projectName + "_INCLUDE")) { return false; } return true; } -bool cmProjectCommand::IncludeByVariable(const std::string& variable) +static bool IncludeByVariable(cmExecutionStatus& status, + const std::string& variable) { - const char* const include = this->Makefile->GetDefinition(variable); + cmMakefile& mf = status.GetMakefile(); + const char* const include = mf.GetDefinition(variable); if (!include) { return true; } - const bool readit = this->Makefile->ReadDependentFile(include); + const bool readit = mf.ReadDependentFile(include); if (readit) { return true; } @@ -367,24 +359,20 @@ bool cmProjectCommand::IncludeByVariable(const std::string& variable) return true; } - std::string m = cmStrCat("could not find file:\n" - " ", - include); - this->SetError(m); + status.SetError(cmStrCat("could not find file:\n ", include)); return false; } -void cmProjectCommand::TopLevelCMakeVarCondSet(const char* const name, - const char* const value) +static void TopLevelCMakeVarCondSet(cmMakefile& mf, std::string const& name, + std::string const& value) { // Set the CMAKE_PROJECT_XXX variable to be the highest-level // project name in the tree. If there are two project commands // in the same CMakeLists.txt file, and it is the top level // CMakeLists.txt file, then go with the last one. - if (!this->Makefile->GetDefinition(name) || - (this->Makefile->IsRootMakefile())) { - this->Makefile->AddDefinition(name, value); - this->Makefile->AddCacheDefinition(name, value, "Value Computed by CMake", - cmStateEnums::STATIC); + if (!mf.GetDefinition(name) || mf.IsRootMakefile()) { + mf.AddDefinition(name, value); + mf.AddCacheDefinition(name, value.c_str(), "Value Computed by CMake", + cmStateEnums::STATIC); } } diff --git a/Source/cmProjectCommand.h b/Source/cmProjectCommand.h index ffbd330..c06b459 100644 --- a/Source/cmProjectCommand.h +++ b/Source/cmProjectCommand.h @@ -8,41 +8,9 @@ #include #include -#include - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmProjectCommand - * \brief Specify the name for this build project. - * - * cmProjectCommand is used to specify a name for this build project. - * It is defined once per set of CMakeList.txt files (including - * all subdirectories). Currently it just sets the name of the workspace - * file for Microsoft Visual C++ - */ -class cmProjectCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - -private: - bool IncludeByVariable(const std::string& variable); - void TopLevelCMakeVarCondSet(const char* name, const char* value); -}; +bool cmProjectCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9c521088df3c45764fd9bfc1c10c9bfe63b63e78 commit 9c521088df3c45764fd9bfc1c10c9bfe63b63e78 Author: Regina Pfeifer AuthorDate: Wed Sep 18 17:35:37 2019 +0200 Commit: Regina Pfeifer CommitDate: Sat Sep 21 05:12:54 2019 +0200 cmLoadCacheCommand: Port away from cmCommand diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index aba092e..a975856 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -284,8 +284,7 @@ void GetProjectCommands(cmState* state) cm::make_unique()); state->AddBuiltinCommand("target_link_directories", cm::make_unique()); - state->AddBuiltinCommand("load_cache", - cm::make_unique()); + state->AddBuiltinCommand("load_cache", cmLoadCacheCommand); state->AddBuiltinCommand("qt_wrap_cpp", cmQTWrapCPPCommand); state->AddBuiltinCommand("qt_wrap_ui", cmQTWrapUICommand); state->AddBuiltinCommand("remove_definitions", cmRemoveDefinitionsCommand); diff --git a/Source/cmLoadCacheCommand.cxx b/Source/cmLoadCacheCommand.cxx index 3fd7343..cca1633 100644 --- a/Source/cmLoadCacheCommand.cxx +++ b/Source/cmLoadCacheCommand.cxx @@ -3,24 +3,30 @@ #include "cmLoadCacheCommand.h" #include "cmsys/FStream.hxx" +#include +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmake.h" -class cmExecutionStatus; +static bool ReadWithPrefix(std::vector const& args, + cmExecutionStatus& status); -// cmLoadCacheCommand -bool cmLoadCacheCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +static void CheckLine(cmMakefile& mf, std::string const& prefix, + std::set const& variablesToRead, + const char* line); + +bool cmLoadCacheCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.empty()) { - this->SetError("called with wrong number of arguments."); + status.SetError("called with wrong number of arguments."); } if (args.size() >= 2 && args[1] == "READ_WITH_PREFIX") { - return this->ReadWithPrefix(args); + return ReadWithPrefix(args, status); } // Cache entries to be excluded from the import list. @@ -59,24 +65,26 @@ bool cmLoadCacheCommand::InitialPass(std::vector const& args, } } + cmMakefile& mf = status.GetMakefile(); + // Loop over each build directory listed in the arguments. Each // directory has a cache file. for (std::string const& arg : args) { if ((arg == "EXCLUDE") || (arg == "INCLUDE_INTERNALS")) { break; } - this->Makefile->GetCMakeInstance()->LoadCache(arg, false, excludes, - includes); + mf.GetCMakeInstance()->LoadCache(arg, false, excludes, includes); } return true; } -bool cmLoadCacheCommand::ReadWithPrefix(std::vector const& args) +static bool ReadWithPrefix(std::vector const& args, + cmExecutionStatus& status) { // Make sure we have a prefix. if (args.size() < 3) { - this->SetError("READ_WITH_PREFIX form must specify a prefix."); + status.SetError("READ_WITH_PREFIX form must specify a prefix."); return false; } @@ -84,17 +92,19 @@ bool cmLoadCacheCommand::ReadWithPrefix(std::vector const& args) std::string cacheFile = args[0] + "/CMakeCache.txt"; if (!cmSystemTools::FileExists(cacheFile)) { std::string e = "Cannot load cache file from " + cacheFile; - this->SetError(e); + status.SetError(e); return false; } // Prepare the table of variables to read. - this->Prefix = args[2]; - this->VariablesToRead.insert(args.begin() + 3, args.end()); + std::string const prefix = args[2]; + std::set const variablesToRead(args.begin() + 3, args.end()); // Read the cache file. cmsys::ifstream fin(cacheFile.c_str()); + cmMakefile& mf = status.GetMakefile(); + // This is a big hack read loop to overcome a buggy ifstream // implementation on HP-UX. This should work on all platforms even // for small buffer sizes. @@ -123,7 +133,7 @@ bool cmLoadCacheCommand::ReadWithPrefix(std::vector const& args) } if (i != end) { // Completed a line. - this->CheckLine(line.c_str()); + CheckLine(mf, prefix, variablesToRead, line.c_str()); line.clear(); // Skip the newline character. @@ -134,13 +144,15 @@ bool cmLoadCacheCommand::ReadWithPrefix(std::vector const& args) } if (!line.empty()) { // Partial last line. - this->CheckLine(line.c_str()); + CheckLine(mf, prefix, variablesToRead, line.c_str()); } return true; } -void cmLoadCacheCommand::CheckLine(const char* line) +static void CheckLine(cmMakefile& mf, std::string const& prefix, + std::set const& variablesToRead, + const char* line) { // Check one line of the cache file. std::string var; @@ -148,14 +160,14 @@ void cmLoadCacheCommand::CheckLine(const char* line) cmStateEnums::CacheEntryType type = cmStateEnums::UNINITIALIZED; if (cmake::ParseCacheEntry(line, var, value, type)) { // Found a real entry. See if this one was requested. - if (this->VariablesToRead.find(var) != this->VariablesToRead.end()) { + if (variablesToRead.find(var) != variablesToRead.end()) { // This was requested. Set this variable locally with the given // prefix. - var = this->Prefix + var; + var = prefix + var; if (!value.empty()) { - this->Makefile->AddDefinition(var, value); + mf.AddDefinition(var, value); } else { - this->Makefile->RemoveDefinition(var); + mf.RemoveDefinition(var); } } } diff --git a/Source/cmLoadCacheCommand.h b/Source/cmLoadCacheCommand.h index 37f0372..7cee663 100644 --- a/Source/cmLoadCacheCommand.h +++ b/Source/cmLoadCacheCommand.h @@ -5,45 +5,12 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include #include #include -#include - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmLoadCacheCommand - * \brief load a cache file - * - * cmLoadCacheCommand loads the non internal values of a cache file - */ -class cmLoadCacheCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - -protected: - std::set VariablesToRead; - std::string Prefix; - - bool ReadWithPrefix(std::vector const& args); - void CheckLine(const char* line); -}; +bool cmLoadCacheCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fcfec154acea01518aa436d76f576d7cfea65fa2 commit fcfec154acea01518aa436d76f576d7cfea65fa2 Author: Regina Pfeifer AuthorDate: Wed Sep 18 17:34:23 2019 +0200 Commit: Regina Pfeifer CommitDate: Sat Sep 21 05:12:31 2019 +0200 cmLinkDirectoriesCommand: Port away from cmCommand diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index a8a77c2..aba092e 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -237,8 +237,7 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("install", cm::make_unique()); state->AddBuiltinCommand("install_files", cmInstallFilesCommand); state->AddBuiltinCommand("install_targets", cmInstallTargetsCommand); - state->AddBuiltinCommand("link_directories", - cm::make_unique()); + state->AddBuiltinCommand("link_directories", cmLinkDirectoriesCommand); state->AddBuiltinCommand("project", cm::make_unique()); state->AddBuiltinCommand("set_source_files_properties", cmSetSourceFilesPropertiesCommand); diff --git a/Source/cmLinkDirectoriesCommand.cxx b/Source/cmLinkDirectoriesCommand.cxx index 57b69c8..2914046 100644 --- a/Source/cmLinkDirectoriesCommand.cxx +++ b/Source/cmLinkDirectoriesCommand.cxx @@ -4,6 +4,7 @@ #include +#include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -11,17 +12,18 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -class cmExecutionStatus; +static void AddLinkDir(cmMakefile& mf, std::string const& dir, + std::vector& directories); -// cmLinkDirectoriesCommand -bool cmLinkDirectoriesCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +bool cmLinkDirectoriesCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.empty()) { return true; } - bool before = this->Makefile->IsOn("CMAKE_LINK_DIRECTORIES_BEFORE"); + cmMakefile& mf = status.GetMakefile(); + bool before = mf.IsOn("CMAKE_LINK_DIRECTORIES_BEFORE"); auto i = args.cbegin(); if ((*i) == "BEFORE") { @@ -34,16 +36,16 @@ bool cmLinkDirectoriesCommand::InitialPass( std::vector directories; for (; i != args.cend(); ++i) { - this->AddLinkDir(*i, directories); + AddLinkDir(mf, *i, directories); } - this->Makefile->AddLinkDirectory(cmJoin(directories, ";"), before); + mf.AddLinkDirectory(cmJoin(directories, ";"), before); return true; } -void cmLinkDirectoriesCommand::AddLinkDir( - std::string const& dir, std::vector& directories) +static void AddLinkDir(cmMakefile& mf, std::string const& dir, + std::vector& directories) { std::string unixPath = dir; cmSystemTools::ConvertToUnixSlashes(unixPath); @@ -56,10 +58,10 @@ void cmLinkDirectoriesCommand::AddLinkDir( << " " << unixPath << "\n" << "as a link directory.\n"; /* clang-format on */ - switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0015)) { + switch (mf.GetPolicyStatus(cmPolicies::CMP0015)) { case cmPolicies::WARN: e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0015); - this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, e.str()); + mf.IssueMessage(MessageType::AUTHOR_WARNING, e.str()); break; case cmPolicies::OLD: // OLD behavior does not convert @@ -67,7 +69,7 @@ void cmLinkDirectoriesCommand::AddLinkDir( case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_ALWAYS: e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0015); - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + mf.IssueMessage(MessageType::FATAL_ERROR, e.str()); CM_FALLTHROUGH; case cmPolicies::NEW: // NEW behavior converts @@ -75,9 +77,7 @@ void cmLinkDirectoriesCommand::AddLinkDir( break; } if (convertToAbsolute) { - std::string tmp = - cmStrCat(this->Makefile->GetCurrentSourceDirectory(), '/', unixPath); - unixPath = tmp; + unixPath = cmStrCat(mf.GetCurrentSourceDirectory(), '/', unixPath); } } directories.push_back(unixPath); diff --git a/Source/cmLinkDirectoriesCommand.h b/Source/cmLinkDirectoriesCommand.h index 489d90f..a7caa5c 100644 --- a/Source/cmLinkDirectoriesCommand.h +++ b/Source/cmLinkDirectoriesCommand.h @@ -8,41 +8,9 @@ #include #include -#include - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmLinkDirectoriesCommand - * \brief Define a list of directories containing files to link. - * - * cmLinkDirectoriesCommand is used to specify a list - * of directories containing files to link into executable(s). - * Note that the command supports the use of CMake built-in variables - * such as CMAKE_BINARY_DIR and CMAKE_SOURCE_DIR. - */ -class cmLinkDirectoriesCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - -private: - void AddLinkDir(std::string const& dir, - std::vector& directories); -}; +bool cmLinkDirectoriesCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d038beec21fde74977e6ce6604f7fc913066dad6 commit d038beec21fde74977e6ce6604f7fc913066dad6 Author: Regina Pfeifer AuthorDate: Wed Sep 18 17:31:38 2019 +0200 Commit: Regina Pfeifer CommitDate: Sat Sep 21 05:11:44 2019 +0200 cmIncludeDirectoryCommand: Port away from cmCommand diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index f569c2b..a8a77c2 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -231,8 +231,7 @@ void GetProjectCommands(cmState* state) cmGetSourceFilePropertyCommand); state->AddBuiltinCommand("get_target_property", cmGetTargetPropertyCommand); state->AddBuiltinCommand("get_test_property", cmGetTestPropertyCommand); - state->AddBuiltinCommand("include_directories", - cm::make_unique()); + state->AddBuiltinCommand("include_directories", cmIncludeDirectoryCommand); state->AddBuiltinCommand("include_regular_expression", cmIncludeRegularExpressionCommand); state->AddBuiltinCommand("install", cm::make_unique()); diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx index a4d0a0d..170aea1 100644 --- a/Source/cmIncludeDirectoryCommand.cxx +++ b/Source/cmIncludeDirectoryCommand.cxx @@ -7,24 +7,28 @@ #include #include "cmAlgorithms.h" +#include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" #include "cmMakefile.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -class cmExecutionStatus; +static void GetIncludes(cmMakefile& mf, const std::string& arg, + std::vector& incs); +static void NormalizeInclude(cmMakefile& mf, std::string& inc); -// cmIncludeDirectoryCommand -bool cmIncludeDirectoryCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +bool cmIncludeDirectoryCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.empty()) { return true; } + cmMakefile& mf = status.GetMakefile(); + auto i = args.begin(); - bool before = this->Makefile->IsOn("CMAKE_INCLUDE_DIRECTORIES_BEFORE"); + bool before = mf.IsOn("CMAKE_INCLUDE_DIRECTORIES_BEFORE"); bool system = false; if ((*i) == "BEFORE") { @@ -45,13 +49,13 @@ bool cmIncludeDirectoryCommand::InitialPass( continue; } if (i->empty()) { - this->SetError("given empty-string as include directory."); + status.SetError("given empty-string as include directory."); return false; } std::vector includes; - this->GetIncludes(*i, includes); + GetIncludes(mf, *i, includes); if (before) { cmAppend(beforeIncludes, includes); @@ -64,9 +68,9 @@ bool cmIncludeDirectoryCommand::InitialPass( } std::reverse(beforeIncludes.begin(), beforeIncludes.end()); - this->Makefile->AddIncludeDirectories(afterIncludes); - this->Makefile->AddIncludeDirectories(beforeIncludes, before); - this->Makefile->AddSystemIncludeDirectories(systemIncludes); + mf.AddIncludeDirectories(afterIncludes); + mf.AddIncludeDirectories(beforeIncludes, before); + mf.AddSystemIncludeDirectories(systemIncludes); return true; } @@ -83,8 +87,8 @@ bool cmIncludeDirectoryCommand::InitialPass( // output from a program and passing it into a command the cleanup doesn't // always happen // -void cmIncludeDirectoryCommand::GetIncludes(const std::string& arg, - std::vector& incs) +static void GetIncludes(cmMakefile& mf, const std::string& arg, + std::vector& incs) { // break apart any line feed arguments std::string::size_type pos = 0; @@ -92,7 +96,7 @@ void cmIncludeDirectoryCommand::GetIncludes(const std::string& arg, while ((pos = arg.find('\n', lastPos)) != std::string::npos) { if (pos) { std::string inc = arg.substr(lastPos, pos); - this->NormalizeInclude(inc); + NormalizeInclude(mf, inc); if (!inc.empty()) { incs.push_back(std::move(inc)); } @@ -100,13 +104,13 @@ void cmIncludeDirectoryCommand::GetIncludes(const std::string& arg, lastPos = pos + 1; } std::string inc = arg.substr(lastPos); - this->NormalizeInclude(inc); + NormalizeInclude(mf, inc); if (!inc.empty()) { incs.push_back(std::move(inc)); } } -void cmIncludeDirectoryCommand::NormalizeInclude(std::string& inc) +static void NormalizeInclude(cmMakefile& mf, std::string& inc) { std::string::size_type b = inc.find_first_not_of(" \r"); std::string::size_type e = inc.find_last_not_of(" \r"); @@ -119,13 +123,9 @@ void cmIncludeDirectoryCommand::NormalizeInclude(std::string& inc) if (!cmIsOff(inc)) { cmSystemTools::ConvertToUnixSlashes(inc); - - if (!cmSystemTools::FileIsFullPath(inc)) { - if (!cmGeneratorExpression::StartsWithGeneratorExpression(inc)) { - std::string tmp = - cmStrCat(this->Makefile->GetCurrentSourceDirectory(), '/', inc); - inc = tmp; - } + if (!cmSystemTools::FileIsFullPath(inc) && + !cmGeneratorExpression::StartsWithGeneratorExpression(inc)) { + inc = cmStrCat(mf.GetCurrentSourceDirectory(), '/', inc); } } } diff --git a/Source/cmIncludeDirectoryCommand.h b/Source/cmIncludeDirectoryCommand.h index bcaae9d..66caff7 100644 --- a/Source/cmIncludeDirectoryCommand.h +++ b/Source/cmIncludeDirectoryCommand.h @@ -8,40 +8,9 @@ #include #include -#include - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmIncludeDirectoryCommand - * \brief Add include directories to the build. - * - * cmIncludeDirectoryCommand is used to specify directory locations - * to search for included files. - */ -class cmIncludeDirectoryCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - -protected: - // used internally - void GetIncludes(const std::string& arg, std::vector& incs); - void NormalizeInclude(std::string& inc); -}; +bool cmIncludeDirectoryCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fdc3ba45832456fc17cff58850b16a02cee30e7c commit fdc3ba45832456fc17cff58850b16a02cee30e7c Author: Regina Pfeifer AuthorDate: Wed Sep 18 17:30:04 2019 +0200 Commit: Regina Pfeifer CommitDate: Sat Sep 21 05:11:08 2019 +0200 cmExportCommand: Port away from cmCommand diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 262590b..f569c2b 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -275,7 +275,7 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("add_compile_options", cmAddCompileOptionsCommand); state->AddBuiltinCommand("aux_source_directory", cmAuxSourceDirectoryCommand); - state->AddBuiltinCommand("export", cm::make_unique()); + state->AddBuiltinCommand("export", cmExportCommand); state->AddBuiltinCommand("fltk_wrap_ui", cmFLTKWrapUICommand); state->AddBuiltinCommand("include_external_msproject", cmIncludeExternalMSProjectCommand); diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index 2713856..79af6e9 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -11,6 +11,7 @@ #include "cmAlgorithms.h" #include "cmArgumentParser.h" +#include "cmExecutionStatus.h" #include "cmExportBuildAndroidMKGenerator.h" #include "cmExportBuildFileGenerator.h" #include "cmExportSet.h" @@ -23,23 +24,31 @@ #include "cmSystemTools.h" #include "cmTarget.h" -class cmExecutionStatus; - #if defined(__HAIKU__) # include # include #endif -bool cmExportCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +#if defined(_WIN32) && !defined(__CYGWIN__) +# include +#endif + +static bool HandlePackage(std::vector const& args, + cmExecutionStatus& status); + +static void StorePackageRegistry(cmMakefile& mf, std::string const& package, + const char* content, const char* hash); + +bool cmExportCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 2) { - this->SetError("called with too few arguments"); + status.SetError("called with too few arguments"); return false; } if (args[0] == "PACKAGE") { - return this->HandlePackage(args); + return HandlePackage(args, status); } struct Arguments @@ -72,7 +81,7 @@ bool cmExportCommand::InitialPass(std::vector const& args, parser.Parse(args, &unknownArgs, &keywordsMissingValue); if (!unknownArgs.empty()) { - this->SetError("Unknown argument: \"" + unknownArgs.front() + "\"."); + status.SetError("Unknown argument: \"" + unknownArgs.front() + "\"."); return false; } @@ -84,7 +93,7 @@ bool cmExportCommand::InitialPass(std::vector const& args, } if (arguments.Filename.empty() && fname.empty()) { if (args[0] != "EXPORT") { - this->SetError("FILE option missing."); + status.SetError("FILE option missing."); return false; } fname = arguments.ExportSetName + ".cmake"; @@ -95,30 +104,32 @@ bool cmExportCommand::InitialPass(std::vector const& args, std::ostringstream e; e << "FILE option given filename \"" << arguments.Filename << "\" which does not have an extension of \".cmake\".\n"; - this->SetError(e.str()); + status.SetError(e.str()); return false; } fname = arguments.Filename; } + cmMakefile& mf = status.GetMakefile(); + // Get the file to write. if (cmSystemTools::FileIsFullPath(fname)) { - if (!this->Makefile->CanIWriteThisFile(fname)) { + if (!mf.CanIWriteThisFile(fname)) { std::ostringstream e; e << "FILE option given filename \"" << fname << "\" which is in the source tree.\n"; - this->SetError(e.str()); + status.SetError(e.str()); return false; } } else { // Interpret relative paths with respect to the current build dir. - std::string dir = this->Makefile->GetCurrentBinaryDirectory(); + std::string const& dir = mf.GetCurrentBinaryDirectory(); fname = dir + "/" + fname; } std::vector targets; - cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator(); + cmGlobalGenerator* gg = mf.GetGlobalGenerator(); cmExportSet* exportSet = nullptr; if (args[0] == "EXPORT") { @@ -127,32 +138,32 @@ bool cmExportCommand::InitialPass(std::vector const& args, if (it == setMap.end()) { std::ostringstream e; e << "Export set \"" << arguments.ExportSetName << "\" not found."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } exportSet = &it->second; } else if (!arguments.Targets.empty() || cmContains(keywordsMissingValue, "TARGETS")) { for (std::string const& currentTarget : arguments.Targets) { - if (this->Makefile->IsAlias(currentTarget)) { + if (mf.IsAlias(currentTarget)) { std::ostringstream e; e << "given ALIAS target \"" << currentTarget << "\" which may not be exported."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } if (cmTarget* target = gg->FindTarget(currentTarget)) { if (target->GetType() == cmStateEnums::UTILITY) { - this->SetError("given custom target \"" + currentTarget + - "\" which may not be exported."); + status.SetError("given custom target \"" + currentTarget + + "\" which may not be exported."); return false; } } else { std::ostringstream e; e << "given target \"" << currentTarget << "\" which is not built by this project."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } targets.push_back(currentTarget); @@ -165,7 +176,7 @@ bool cmExportCommand::InitialPass(std::vector const& args, } } } else { - this->SetError("EXPORT or TARGETS specifier missing."); + status.SetError("EXPORT or TARGETS specifier missing."); return false; } @@ -184,12 +195,12 @@ bool cmExportCommand::InitialPass(std::vector const& args, } else { ebfg->SetTargets(targets); } - this->Makefile->AddExportBuildFileGenerator(ebfg); + mf.AddExportBuildFileGenerator(ebfg); ebfg->SetExportOld(arguments.ExportOld); // Compute the set of configurations exported. std::vector configurationTypes; - this->Makefile->GetConfigurations(configurationTypes); + mf.GetConfigurations(configurationTypes); if (configurationTypes.empty()) { configurationTypes.emplace_back(); } @@ -205,7 +216,8 @@ bool cmExportCommand::InitialPass(std::vector const& args, return true; } -bool cmExportCommand::HandlePackage(std::vector const& args) +static bool HandlePackage(std::vector const& args, + cmExecutionStatus& status) { // Parse PACKAGE mode arguments. enum Doing @@ -222,14 +234,14 @@ bool cmExportCommand::HandlePackage(std::vector const& args) } else { std::ostringstream e; e << "PACKAGE given unknown argument: " << args[i]; - this->SetError(e.str()); + status.SetError(e.str()); return false; } } // Verify the package name. if (package.empty()) { - this->SetError("PACKAGE must be given a package name."); + status.SetError("PACKAGE must be given a package name."); return false; } const char* packageExpr = "^[A-Za-z0-9_.-]+$"; @@ -238,16 +250,18 @@ bool cmExportCommand::HandlePackage(std::vector const& args) std::ostringstream e; e << "PACKAGE given invalid package name \"" << package << "\". " << "Package names must match \"" << packageExpr << "\"."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } + cmMakefile& mf = status.GetMakefile(); + // CMP0090 decides both the default and what variable changes it. - switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0090)) { + switch (mf.GetPolicyStatus(cmPolicies::CMP0090)) { case cmPolicies::WARN: case cmPolicies::OLD: // Default is to export, but can be disabled. - if (this->Makefile->IsOn("CMAKE_EXPORT_NO_PACKAGE_REGISTRY")) { + if (mf.IsOn("CMAKE_EXPORT_NO_PACKAGE_REGISTRY")) { return true; } break; @@ -255,7 +269,7 @@ bool cmExportCommand::HandlePackage(std::vector const& args) case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::NEW: // Default is to not export, but can be enabled. - if (!this->Makefile->IsOn("CMAKE_EXPORT_PACKAGE_REGISTRY")) { + if (!mf.IsOn("CMAKE_EXPORT_PACKAGE_REGISTRY")) { return true; } break; @@ -264,22 +278,17 @@ bool cmExportCommand::HandlePackage(std::vector const& args) // We store the current build directory in the registry as a value // named by a hash of its own content. This is deterministic and is // unique with high probability. - const std::string& outDir = this->Makefile->GetCurrentBinaryDirectory(); + const std::string& outDir = mf.GetCurrentBinaryDirectory(); std::string hash = cmSystemTools::ComputeStringMD5(outDir); -#if defined(_WIN32) && !defined(__CYGWIN__) - this->StorePackageRegistryWin(package, outDir.c_str(), hash.c_str()); -#else - this->StorePackageRegistryDir(package, outDir.c_str(), hash.c_str()); -#endif + StorePackageRegistry(mf, package, outDir.c_str(), hash.c_str()); return true; } #if defined(_WIN32) && !defined(__CYGWIN__) -# include -void cmExportCommand::ReportRegistryError(std::string const& msg, - std::string const& key, long err) +static void ReportRegistryError(cmMakefile& mf, std::string const& msg, + std::string const& key, long err) { std::ostringstream e; e << msg << "\n" @@ -291,12 +300,11 @@ void cmExportCommand::ReportRegistryError(std::string const& msg, e << "Windows reported:\n" << " " << cmsys::Encoding::ToNarrow(winmsg); } - this->Makefile->IssueMessage(MessageType::WARNING, e.str()); + mf.IssueMessage(MessageType::WARNING, e.str()); } -void cmExportCommand::StorePackageRegistryWin(std::string const& package, - const char* content, - const char* hash) +static void StorePackageRegistry(cmMakefile& mf, std::string const& package, + const char* content, const char* hash) { std::string key = cmStrCat("Software\\Kitware\\CMake\\Packages\\", package); HKEY hKey; @@ -304,7 +312,7 @@ void cmExportCommand::StorePackageRegistryWin(std::string const& package, RegCreateKeyExW(HKEY_CURRENT_USER, cmsys::Encoding::ToWide(key).c_str(), 0, 0, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, 0, &hKey, 0); if (err != ERROR_SUCCESS) { - this->ReportRegistryError("Cannot create/open registry key", key, err); + ReportRegistryError(mf, "Cannot create/open registry key", key, err); return; } @@ -317,14 +325,13 @@ void cmExportCommand::StorePackageRegistryWin(std::string const& package, if (err != ERROR_SUCCESS) { std::ostringstream msg; msg << "Cannot set registry value \"" << hash << "\" under key"; - this->ReportRegistryError(msg.str(), key, err); + ReportRegistryError(mf, msg.str(), key, err); return; } } #else -void cmExportCommand::StorePackageRegistryDir(std::string const& package, - const char* content, - const char* hash) +static void StorePackageRegistry(cmMakefile& mf, std::string const& package, + const char* content, const char* hash) { # if defined(__HAIKU__) char dir[B_PATH_NAME_LENGTH]; @@ -356,7 +363,7 @@ void cmExportCommand::StorePackageRegistryDir(std::string const& package, << " " << fname << "\n" << cmSystemTools::GetLastSystemError() << "\n"; /* clang-format on */ - this->Makefile->IssueMessage(MessageType::WARNING, e.str()); + mf.IssueMessage(MessageType::WARNING, e.str()); } } } diff --git a/Source/cmExportCommand.h b/Source/cmExportCommand.h index 819a3c3..9655628 100644 --- a/Source/cmExportCommand.h +++ b/Source/cmExportCommand.h @@ -8,38 +8,9 @@ #include #include -#include - -#include "cmCommand.h" - class cmExecutionStatus; -class cmExportCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - -private: - bool HandlePackage(std::vector const& args); - void StorePackageRegistryWin(std::string const& package, const char* content, - const char* hash); - void StorePackageRegistryDir(std::string const& package, const char* content, - const char* hash); - void ReportRegistryError(std::string const& msg, std::string const& key, - long err); -}; +bool cmExportCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8098bd5768d012ceb078fdefdc1b35e1b74e984a commit 8098bd5768d012ceb078fdefdc1b35e1b74e984a Author: David Callu AuthorDate: Fri Sep 13 10:58:57 2019 +0200 Commit: David Callu CommitDate: Fri Sep 20 22:39:20 2019 +0200 FindOpenSSL: add pthread and dl dependencies to static lib on Linux diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index 5f947fe..33ceab7 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -35,10 +35,14 @@ This module will set the following variables in your project: The OpenSSL include directory. ``OPENSSL_CRYPTO_LIBRARY`` The OpenSSL crypto library. +``OPENSSL_CRYPTO_LIBRARIES`` + The OpenSSL crypto library and its dependencies. ``OPENSSL_SSL_LIBRARY`` The OpenSSL SSL library. +``OPENSSL_SSL_LIBRARIES`` + The OpenSSL SSL library and its dependencies. ``OPENSSL_LIBRARIES`` - All OpenSSL libraries. + All OpenSSL libraries and their dependencies. ``OPENSSL_VERSION`` This is set to ``$major.$minor.$revision$patch`` (e.g. ``0.9.8s``). @@ -50,6 +54,32 @@ Set ``OPENSSL_USE_STATIC_LIBS`` to ``TRUE`` to look for static libraries. Set ``OPENSSL_MSVC_STATIC_RT`` set ``TRUE`` to choose the MT version of the lib. #]=======================================================================] +macro(_OpenSSL_test_and_find_dependencies ssl_library crypto_library) + if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND + (("${ssl_library}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$") OR + ("${crypto_library}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$"))) + set(_OpenSSL_has_dependencies TRUE) + find_package(Threads) + else() + set(_OpenSSL_has_dependencies FALSE) + endif() +endmacro() + +function(_OpenSSL_add_dependencies libraries_var library) + if(CMAKE_THREAD_LIBS_INIT) + list(APPEND ${libraries_var} ${CMAKE_THREAD_LIBS_INIT}) + endif() + list(APPEND ${libraries_var} ${CMAKE_DL_LIBS}) + set(${libraries_var} ${${libraries_var}} PARENT_SCOPE) +endfunction() + +function(_OpenSSL_target_add_dependencies target) + if(_OpenSSL_has_dependencies) + set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads ) + set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS} ) + endif() +endfunction() + if (UNIX) find_package(PkgConfig QUIET) pkg_check_modules(_OPENSSL QUIET openssl) @@ -306,10 +336,15 @@ else() mark_as_advanced(OPENSSL_CRYPTO_LIBRARY OPENSSL_SSL_LIBRARY) - # compat defines - set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY}) - set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY}) +endif() +# compat defines +set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY}) +set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY}) +_OpenSSL_test_and_find_dependencies("${OPENSSL_SSL_LIBRARY}" "${OPENSSL_CRYPTO_LIBRARY}") +if(_OpenSSL_has_dependencies) + _OpenSSL_add_dependencies( OPENSSL_SSL_LIBRARIES "${OPENSSL_SSL_LIBRARY}" ) + _OpenSSL_add_dependencies( OPENSSL_CRYPTO_LIBRARIES "${OPENSSL_CRYPTO_LIBRARY}" ) endif() function(from_hex HEX DEC) @@ -379,7 +414,8 @@ if(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h") endif () endif () -set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY} ) +set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES} ) +list(REMOVE_DUPLICATES OPENSSL_LIBRARIES) foreach(_comp IN LISTS OpenSSL_FIND_COMPONENTS) if(_comp STREQUAL "Crypto") @@ -451,6 +487,7 @@ if(OPENSSL_FOUND) IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" IMPORTED_LOCATION_DEBUG "${LIB_EAY_LIBRARY_DEBUG}") endif() + _OpenSSL_target_add_dependencies(OpenSSL::Crypto) endif() if(NOT TARGET OpenSSL::SSL AND @@ -484,6 +521,7 @@ if(OPENSSL_FOUND) set_target_properties(OpenSSL::SSL PROPERTIES INTERFACE_LINK_LIBRARIES OpenSSL::Crypto) endif() + _OpenSSL_target_add_dependencies(OpenSSL::SSL) endif() endif() ----------------------------------------------------------------------- Summary of changes: Modules/Compiler/IAR-ASM.cmake | 5 + Modules/FindOpenSSL.cmake | 48 ++- Modules/FindThreads.cmake | 8 +- Source/cmCommands.cxx | 22 +- Source/cmExportCommand.cxx | 103 +++--- Source/cmExportCommand.h | 33 +- Source/cmIncludeDirectoryCommand.cxx | 44 +-- Source/cmIncludeDirectoryCommand.h | 35 +- Source/cmInstallCommand.cxx | 594 +++++++++++++++++--------------- Source/cmInstallCommand.h | 66 +--- Source/cmLinkDirectoriesCommand.cxx | 30 +- Source/cmLinkDirectoriesCommand.h | 36 +- Source/cmLoadCacheCommand.cxx | 52 +-- Source/cmLoadCacheCommand.h | 37 +- Source/cmProjectCommand.cxx | 196 +++++------ Source/cmProjectCommand.h | 36 +- Source/cmSetTargetPropertiesCommand.cxx | 44 +-- Source/cmSetTargetPropertiesCommand.h | 29 +- Source/cmSourceGroupCommand.cxx | 80 +++-- Source/cmSourceGroupCommand.h | 51 +-- Source/cmTargetLinkLibrariesCommand.cxx | 261 +++++++------- Source/cmTargetLinkLibrariesCommand.h | 56 +-- 22 files changed, 815 insertions(+), 1051 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Sep 24 10:41:28 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 24 Sep 2019 10:41:28 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1185-gdcc117b Message-ID: <20190924144128.30ECB10767F@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via dcc117b9446cfc3d6c8bf191545aac8d1519abca (commit) via 908fc3605b7029126c24b5c5f581758bd00905c6 (commit) via 13c7a16cde47b4c5fc2bf62f9bfc497b123e9c94 (commit) via a6093ed18d323741c48b6c3e72c4b94c05914731 (commit) via 7dcf9cb83c2082168f218be8f21b95b77cc95a86 (commit) via acb9511044a230126289c1e99cfed134c3be3c52 (commit) via c7c59dae82594557dc2fddc4ef881dafeaad076a (commit) via c12222db86859a5a5ce9163a5309bb0da10ec616 (commit) via 1811411fecf3d9769ad7a13f6ecd01c5351df9c4 (commit) via edb0bbd18b5c3dac16ab7d219f787513203529e4 (commit) via 8456f60dbc13b9fbd0490371c871a1e85a72c3a8 (commit) via f4afcd5c6bee7604e031aaab2fa38a9e9ba93900 (commit) via 61fdf326d8e762aaaef22d8ecce443674d5205e6 (commit) via 0965bd9c064a5a595ca1bde01e8dba425ea2b916 (commit) from 28bd7e41b8792365c8730bdbffed825d70e50471 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dcc117b9446cfc3d6c8bf191545aac8d1519abca commit dcc117b9446cfc3d6c8bf191545aac8d1519abca Merge: 908fc36 acb9511 Author: Brad King AuthorDate: Tue Sep 24 14:33:13 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 24 10:34:38 2019 -0400 Merge topic 'pch-relative-includes' acb9511044 Precompile headers: Treat headers as relative to current source directory Acked-by: Kitware Robot Merge-request: !3840 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=908fc3605b7029126c24b5c5f581758bd00905c6 commit 908fc3605b7029126c24b5c5f581758bd00905c6 Merge: 13c7a16 7dcf9cb Author: Brad King AuthorDate: Tue Sep 24 14:31:25 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 24 10:33:41 2019 -0400 Merge topic 'add-genex-evaluate-utility' 7dcf9cb83c cmGeneratorExpression: Add cmGeneratorExpression::Evaluate utility c7c59dae82 cmCustomCommandGenerator: Replace generator expression member c12222db86 cmGeneratorExpression: Remove Evaluate overload by parameter re-ordering 1811411fec cmGeneratorExpression: Move quiet flag to cmCompiledGeneratorExpression edb0bbd18b cmGeneratorTarget: Remove unused virtual signature of TargetPropertyEntry Acked-by: Kitware Robot Merge-request: !3852 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=13c7a16cde47b4c5fc2bf62f9bfc497b123e9c94 commit 13c7a16cde47b4c5fc2bf62f9bfc497b123e9c94 Merge: a6093ed f4afcd5 Author: Brad King AuthorDate: Tue Sep 24 14:30:57 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 24 10:32:43 2019 -0400 Merge topic 'miscellaneous-refactorings' f4afcd5c6b VS: Remove call to ConvertToWindowsExtendedPath with result discarded 61fdf326d8 cmState: Avoid lowering command name twice 0965bd9c06 Generators: Remove function declarations which do not have a definition Acked-by: Kitware Robot Merge-request: !3847 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a6093ed18d323741c48b6c3e72c4b94c05914731 commit a6093ed18d323741c48b6c3e72c4b94c05914731 Merge: 28bd7e4 8456f60 Author: Brad King AuthorDate: Tue Sep 24 14:30:46 2019 +0000 Commit: Kitware Robot CommitDate: Tue Sep 24 10:31:27 2019 -0400 Merge topic 'update-cached-is-generated-property' 8456f60dbc cmSourceFile: Remove non-const GetProperties accessor Acked-by: Kitware Robot Merge-request: !3848 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7dcf9cb83c2082168f218be8f21b95b77cc95a86 commit 7dcf9cb83c2082168f218be8f21b95b77cc95a86 Author: Daniel Eiband AuthorDate: Sun Sep 22 09:53:44 2019 +0200 Commit: Daniel Eiband CommitDate: Mon Sep 23 21:19:15 2019 +0200 cmGeneratorExpression: Add cmGeneratorExpression::Evaluate utility cmGeneratorExpression::Evaluate is a shortcut when only the evaluated string is needed or an instance of cmCompiledGeneratorExpression cannot be cached. Fixes: #19686 diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 1bc3452..1f31069 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -36,6 +36,31 @@ std::unique_ptr cmGeneratorExpression::Parse( return this->Parse(std::string(input ? input : "")); } +std::string cmGeneratorExpression::Evaluate( + std::string input, cmLocalGenerator* lg, const std::string& config, + cmGeneratorTarget const* headTarget, + cmGeneratorExpressionDAGChecker* dagChecker, + cmGeneratorTarget const* currentTarget, std::string const& language) +{ + if (Find(input) != std::string::npos) { + cmCompiledGeneratorExpression cge(cmListFileBacktrace(), std::move(input)); + return cge.Evaluate(lg, config, headTarget, dagChecker, currentTarget, + language); + } + return input; +} + +std::string cmGeneratorExpression::Evaluate( + const char* input, cmLocalGenerator* lg, const std::string& config, + cmGeneratorTarget const* headTarget, + cmGeneratorExpressionDAGChecker* dagChecker, + cmGeneratorTarget const* currentTarget, std::string const& language) +{ + return input ? Evaluate(std::string(input), lg, config, headTarget, + dagChecker, currentTarget, language) + : ""; +} + const std::string& cmCompiledGeneratorExpression::Evaluate( cmLocalGenerator* lg, const std::string& config, const cmGeneratorTarget* headTarget, diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index 322bf5c..de5c705 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -45,6 +45,19 @@ public: std::unique_ptr Parse( const char* input) const; + static std::string Evaluate( + std::string input, cmLocalGenerator* lg, const std::string& config, + cmGeneratorTarget const* headTarget = nullptr, + cmGeneratorExpressionDAGChecker* dagChecker = nullptr, + cmGeneratorTarget const* currentTarget = nullptr, + std::string const& language = std::string()); + static std::string Evaluate( + const char* input, cmLocalGenerator* lg, const std::string& config, + cmGeneratorTarget const* headTarget = nullptr, + cmGeneratorExpressionDAGChecker* dagChecker = nullptr, + cmGeneratorTarget const* currentTarget = nullptr, + std::string const& language = std::string()); + enum PreprocessContext { StripAllGeneratorExpressions, diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index b66d9d5..350d28f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -487,9 +487,8 @@ std::string cmGeneratorTarget::GetOutputName( } // Now evaluate genex and update the previously-prepared map entry. - cmGeneratorExpression ge; - std::unique_ptr cge = ge.Parse(outName); - i->second = cge->Evaluate(this->LocalGenerator, config); + i->second = + cmGeneratorExpression::Evaluate(outName, this->LocalGenerator, config); } else if (i->second.empty()) { // An empty map entry indicates we have been called recursively // from the above block. @@ -709,9 +708,8 @@ void handleSystemIncludesDep(cmLocalGenerator* lg, { if (const char* dirs = depTgt->GetProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")) { - cmGeneratorExpression ge; - cmExpandList(ge.Parse(dirs)->Evaluate(lg, config, headTarget, dagChecker, - depTgt, language), + cmExpandList(cmGeneratorExpression::Evaluate(dirs, lg, config, headTarget, + dagChecker, depTgt, language), result); } if (!depTgt->IsImported() || excludeImported) { @@ -720,9 +718,8 @@ void handleSystemIncludesDep(cmLocalGenerator* lg, if (const char* dirs = depTgt->GetProperty("INTERFACE_INCLUDE_DIRECTORIES")) { - cmGeneratorExpression ge; - cmExpandList(ge.Parse(dirs)->Evaluate(lg, config, headTarget, dagChecker, - depTgt, language), + cmExpandList(cmGeneratorExpression::Evaluate(dirs, lg, config, headTarget, + dagChecker, depTgt, language), result); } } @@ -1092,9 +1089,9 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory( std::vector result; for (std::string const& it : this->Target->GetSystemIncludeDirectories()) { - cmGeneratorExpression ge; - cmExpandList(ge.Parse(it)->Evaluate(this->LocalGenerator, config, this, - &dagChecker, nullptr, language), + cmExpandList(cmGeneratorExpression::Evaluate(it, this->LocalGenerator, + config, this, &dagChecker, + nullptr, language), result); } @@ -2515,13 +2512,12 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector& result, if (!prop) { return; } - cmGeneratorExpression ge; cmGeneratorExpressionDAGChecker dagChecker(this, "AUTOUIC_OPTIONS", nullptr, nullptr); - cmExpandList( - ge.Parse(prop)->Evaluate(this->LocalGenerator, config, this, &dagChecker), - result); + cmExpandList(cmGeneratorExpression::Evaluate(prop, this->LocalGenerator, + config, this, &dagChecker), + result); } void processILibs(const std::string& config, @@ -5552,18 +5548,15 @@ bool cmGeneratorTarget::ComputeOutputDir(const std::string& config, // Select an output directory. if (const char* config_outdir = this->GetProperty(configProp)) { // Use the user-specified per-configuration output directory. - cmGeneratorExpression ge; - std::unique_ptr cge = - ge.Parse(config_outdir); - out = cge->Evaluate(this->LocalGenerator, config); + out = cmGeneratorExpression::Evaluate(config_outdir, this->LocalGenerator, + config); // Skip per-configuration subdirectory. conf.clear(); } else if (const char* outdir = this->GetProperty(propertyName)) { // Use the user-specified output directory. - cmGeneratorExpression ge; - std::unique_ptr cge = ge.Parse(outdir); - out = cge->Evaluate(this->LocalGenerator, config); + out = + cmGeneratorExpression::Evaluate(outdir, this->LocalGenerator, config); // Skip per-configuration subdirectory if the value contained a // generator expression. @@ -5631,18 +5624,15 @@ bool cmGeneratorTarget::ComputePDBOutputDir(const std::string& kind, // Select an output directory. if (const char* config_outdir = this->GetProperty(configProp)) { // Use the user-specified per-configuration output directory. - cmGeneratorExpression ge; - std::unique_ptr cge = - ge.Parse(config_outdir); - out = cge->Evaluate(this->LocalGenerator, config); + out = cmGeneratorExpression::Evaluate(config_outdir, this->LocalGenerator, + config); // Skip per-configuration subdirectory. conf.clear(); } else if (const char* outdir = this->GetProperty(propertyName)) { // Use the user-specified output directory. - cmGeneratorExpression ge; - std::unique_ptr cge = ge.Parse(outdir); - out = cge->Evaluate(this->LocalGenerator, config); + out = + cmGeneratorExpression::Evaluate(outdir, this->LocalGenerator, config); // Skip per-configuration subdirectory if the value contained a // generator expression. @@ -5697,8 +5687,7 @@ bool cmGeneratorTarget::GetRPATH(const std::string& config, return false; } - cmGeneratorExpression ge; - rpath = ge.Parse(value)->Evaluate(this->LocalGenerator, config); + rpath = cmGeneratorExpression::Evaluate(value, this->LocalGenerator, config); return true; } diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 92316d3..7faafba 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -663,10 +663,8 @@ std::set cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( for (std::string const& i : configs) { const char* propertyValue = target->Target->GetMakefile()->GetDefinition(propertyName); - cmGeneratorExpression ge; - std::unique_ptr cge = - ge.Parse(propertyValue); - if (cmIsOn(cge->Evaluate(target->GetLocalGenerator(), i))) { + if (cmIsOn(cmGeneratorExpression::Evaluate( + propertyValue, target->GetLocalGenerator(), i))) { activeConfigs.insert(i); } } diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 255739d..f25d2e2 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -284,11 +284,9 @@ bool cmGlobalVisualStudio8Generator::DeployInhibited( cmGeneratorTarget const& target, const char* config) const { bool rVal = false; - if (const char* propStr = target.GetProperty("VS_NO_SOLUTION_DEPLOY")) { - cmGeneratorExpression ge; - std::unique_ptr cge = ge.Parse(propStr); - std::string prop = cge->Evaluate(target.LocalGenerator, config); - rVal = cmIsOn(prop); + if (const char* prop = target.GetProperty("VS_NO_SOLUTION_DEPLOY")) { + rVal = cmIsOn( + cmGeneratorExpression::Evaluate(prop, target.LocalGenerator, config)); } return rVal; } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 643cc99..2c3d3ad 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2381,10 +2381,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, std::string attribute = prop.substr(16); this->FilterConfigurationAttribute(configName, attribute); if (!attribute.empty()) { - cmGeneratorExpression ge; - std::string processed = - ge.Parse(gtgt->GetProperty(prop)) - ->Evaluate(this->CurrentLocalGenerator, configName); + std::string processed = cmGeneratorExpression::Evaluate( + gtgt->GetProperty(prop), this->CurrentLocalGenerator, configName); buildSettings->AddAttribute(attribute, this->CreateString(processed)); } @@ -3118,10 +3116,9 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( std::string attribute = var.substr(22); this->FilterConfigurationAttribute(config.first, attribute); if (!attribute.empty()) { - cmGeneratorExpression ge; - std::string processed = - ge.Parse(this->CurrentMakefile->GetDefinition(var)) - ->Evaluate(this->CurrentLocalGenerator, config.first); + std::string processed = cmGeneratorExpression::Evaluate( + this->CurrentMakefile->GetDefinition(var), + this->CurrentLocalGenerator, config.first); buildSettingsForCfg->AddAttribute(attribute, this->CreateString(processed)); } diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx index 1d8210c..259c7f7 100644 --- a/Source/cmInstallDirectoryGenerator.cxx +++ b/Source/cmInstallDirectoryGenerator.cxx @@ -9,8 +9,6 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include - cmInstallDirectoryGenerator::cmInstallDirectoryGenerator( std::vector const& dirs, const char* dest, const char* file_permissions, const char* dir_permissions, @@ -64,10 +62,9 @@ void cmInstallDirectoryGenerator::GenerateScriptForConfig( std::ostream& os, const std::string& config, Indent indent) { std::vector dirs; - cmGeneratorExpression ge; for (std::string const& d : this->Directories) { - std::unique_ptr cge = ge.Parse(d); - cmExpandList(cge->Evaluate(this->LocalGenerator, config), dirs); + cmExpandList( + cmGeneratorExpression::Evaluate(d, this->LocalGenerator, config), dirs); } // Make sure all dirs have absolute paths. @@ -97,6 +94,6 @@ void cmInstallDirectoryGenerator::AddDirectoryInstallRule( std::string cmInstallDirectoryGenerator::GetDestination( std::string const& config) const { - cmGeneratorExpression ge; - return ge.Parse(this->Destination)->Evaluate(this->LocalGenerator, config); + return cmGeneratorExpression::Evaluate(this->Destination, + this->LocalGenerator, config); } diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index c4048d4..f5b69a5 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -6,8 +6,6 @@ #include "cmInstallType.h" #include "cmStringAlgorithms.h" -#include - class cmLocalGenerator; cmInstallFilesGenerator::cmInstallFilesGenerator( @@ -51,8 +49,8 @@ bool cmInstallFilesGenerator::Compute(cmLocalGenerator* lg) std::string cmInstallFilesGenerator::GetDestination( std::string const& config) const { - cmGeneratorExpression ge; - return ge.Parse(this->Destination)->Evaluate(this->LocalGenerator, config); + return cmGeneratorExpression::Evaluate(this->Destination, + this->LocalGenerator, config); } void cmInstallFilesGenerator::AddFilesInstallRule( @@ -82,10 +80,9 @@ void cmInstallFilesGenerator::GenerateScriptForConfig( std::ostream& os, const std::string& config, Indent indent) { std::vector files; - cmGeneratorExpression ge; for (std::string const& f : this->Files) { - std::unique_ptr cge = ge.Parse(f); - cmExpandList(cge->Evaluate(this->LocalGenerator, config), files); + cmExpandList( + cmGeneratorExpression::Evaluate(f, this->LocalGenerator, config), files); } this->AddFilesInstallRule(os, config, indent, files); } diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx index b7b7817..ea29455 100644 --- a/Source/cmInstallScriptGenerator.cxx +++ b/Source/cmInstallScriptGenerator.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmInstallScriptGenerator.h" -#include #include #include @@ -79,11 +78,9 @@ void cmInstallScriptGenerator::GenerateScriptForConfig( std::ostream& os, const std::string& config, Indent indent) { if (this->AllowGenex) { - cmGeneratorExpression ge; - std::unique_ptr cge = - ge.Parse(this->Script); this->AddScriptInstallRule(os, indent, - cge->Evaluate(this->LocalGenerator, config)); + cmGeneratorExpression::Evaluate( + this->Script, this->LocalGenerator, config)); } else { this->AddScriptInstallRule(os, indent, this->Script); } diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 90b0e1d..0cd04cc 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -4,7 +4,6 @@ #include #include -#include #include #include #include @@ -375,9 +374,8 @@ void cmInstallTargetGenerator::GetInstallObjectNames( std::string cmInstallTargetGenerator::GetDestination( std::string const& config) const { - cmGeneratorExpression ge; - return ge.Parse(this->Destination) - ->Evaluate(this->Target->GetLocalGenerator(), config); + return cmGeneratorExpression::Evaluate( + this->Destination, this->Target->GetLocalGenerator(), config); } std::string cmInstallTargetGenerator::GetInstallFilename( diff --git a/Source/cmJsonObjects.cxx b/Source/cmJsonObjects.cxx index 52e28d3..79180cb 100644 --- a/Source/cmJsonObjects.cxx +++ b/Source/cmJsonObjects.cxx @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -357,10 +356,8 @@ static Json::Value DumpCTestInfo(cmLocalGenerator* lg, cmTest* testInfo, } // Remove any config specific variables from the output. - cmGeneratorExpression ge; - auto cge = ge.Parse(command); - const std::string& processed = cge->Evaluate(lg, config); - result[kCTEST_COMMAND] = processed; + result[kCTEST_COMMAND] = + cmGeneratorExpression::Evaluate(command, lg, config); // Build up the list of properties that may have been specified Json::Value properties = Json::arrayValue; @@ -369,9 +366,8 @@ static Json::Value DumpCTestInfo(cmLocalGenerator* lg, cmTest* testInfo, entry[kKEY_KEY] = prop.first; // Remove config variables from the value too. - auto cge_value = ge.Parse(prop.second); - const std::string& processed_value = cge_value->Evaluate(lg, config); - entry[kVALUE_KEY] = processed_value; + entry[kVALUE_KEY] = + cmGeneratorExpression::Evaluate(prop.second, lg, config); properties.append(entry); } result[kPROPERTIES_KEY] = properties; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 19962e3..93e074d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -48,7 +48,6 @@ #include #include #include -#include #include #include #include @@ -925,10 +924,8 @@ void cmLocalGenerator::AddCompileOptions(std::vector>& flags, // to ON if (char const* jmcExprGen = target->GetProperty("VS_JUST_MY_CODE_DEBUGGING")) { - cmGeneratorExpression ge; - std::unique_ptr cge = - ge.Parse(jmcExprGen); - std::string isJMCEnabled = cge->Evaluate(this, config); + std::string isJMCEnabled = + cmGeneratorExpression::Evaluate(jmcExprGen, this, config); if (cmIsOn(isJMCEnabled)) { std::vector optVec = cmExpandedList(jmc); std::string jmcFlags; @@ -1710,10 +1707,8 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, if (!msvcRuntimeLibraryValue) { msvcRuntimeLibraryValue = msvcRuntimeLibraryDefault; } - cmGeneratorExpression ge; - std::unique_ptr cge = - ge.Parse(msvcRuntimeLibraryValue); - std::string const msvcRuntimeLibrary = cge->Evaluate(this, config, target); + std::string const msvcRuntimeLibrary = cmGeneratorExpression::Evaluate( + msvcRuntimeLibraryValue, this, config, target); if (!msvcRuntimeLibrary.empty()) { if (const char* msvcRuntimeLibraryOptions = this->Makefile->GetDefinition( diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 0fe385f..82dc943 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -608,12 +608,10 @@ void cmLocalNinjaGenerator::AdditionalCleanFiles() this->Makefile->GetProperty("ADDITIONAL_CLEAN_FILES")) { std::vector cleanFiles; { - cmGeneratorExpression ge; - auto cge = ge.Parse(prop_value); - cmExpandList( - cge->Evaluate(this, - this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")), - cleanFiles); + cmExpandList(cmGeneratorExpression::Evaluate( + prop_value, this, + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")), + cleanFiles); } std::string const& binaryDir = this->GetCurrentBinaryDirectory(); cmGlobalNinjaGenerator* gg = this->GetGlobalNinjaGenerator(); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index a7be04e..1d87e93 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1083,12 +1083,10 @@ void cmLocalUnixMakefileGenerator3::AppendDirectoryCleanCommand( // Look for additional files registered for cleaning in this directory. if (const char* prop_value = this->Makefile->GetProperty("ADDITIONAL_CLEAN_FILES")) { - cmGeneratorExpression ge; - std::unique_ptr cge = ge.Parse(prop_value); - cmExpandList( - cge->Evaluate(this, - this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")), - cleanFiles); + cmExpandList(cmGeneratorExpression::Evaluate( + prop_value, this, + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")), + cleanFiles); } if (cleanFiles.empty()) { return; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index fa361bb..d352f8e 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -154,11 +154,10 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() auto evaluatedFiles = [this](const char* prop_value) -> std::vector { std::vector files; - cmGeneratorExpression ge; - std::unique_ptr cge = ge.Parse(prop_value); - cmExpandList(cge->Evaluate(this->LocalGenerator, this->ConfigName, - this->GeneratorTarget, nullptr, nullptr), - files); + cmExpandList( + cmGeneratorExpression::Evaluate(prop_value, this->LocalGenerator, + this->ConfigName, this->GeneratorTarget), + files); return files; }; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index bee044e..613e7aa 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1317,14 +1317,11 @@ void cmNinjaTargetGenerator::AdditionalCleanFiles() this->GeneratorTarget->GetProperty("ADDITIONAL_CLEAN_FILES")) { cmLocalNinjaGenerator* lg = this->LocalGenerator; std::vector cleanFiles; - { - cmGeneratorExpression ge; - auto cge = ge.Parse(prop_value); - cmExpandList(cge->Evaluate( - lg, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"), - this->GeneratorTarget, nullptr, nullptr), - cleanFiles); - } + cmExpandList(cmGeneratorExpression::Evaluate( + prop_value, lg, + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"), + this->GeneratorTarget), + cleanFiles); std::string const& binaryDir = lg->GetCurrentBinaryDirectory(); cmGlobalNinjaGenerator* gg = lg->GetGlobalNinjaGenerator(); for (std::string const& cleanFile : cleanFiles) { diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 4b83595..34aac49 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1139,10 +1139,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues(Elem& e0) std::string configType; if (const char* vsConfigurationType = this->GeneratorTarget->GetProperty("VS_CONFIGURATION_TYPE")) { - cmGeneratorExpression ge; - std::unique_ptr cge = - ge.Parse(vsConfigurationType); - configType = cge->Evaluate(this->LocalGenerator, c); + configType = cmGeneratorExpression::Evaluate(vsConfigurationType, + this->LocalGenerator, c); } else { switch (this->GeneratorTarget->GetType()) { case cmStateEnums::SHARED_LIBRARY: @@ -2447,49 +2445,32 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions( if (ttype <= cmStateEnums::UTILITY) { if (const char* workingDir = this->GeneratorTarget->GetProperty( "VS_DEBUGGER_WORKING_DIRECTORY")) { - cmGeneratorExpression ge; - std::unique_ptr cge = - ge.Parse(workingDir); - std::string genWorkingDir = - cge->Evaluate(this->LocalGenerator, config); - + std::string genWorkingDir = cmGeneratorExpression::Evaluate( + workingDir, this->LocalGenerator, config); e1.WritePlatformConfigTag("LocalDebuggerWorkingDirectory", cond, genWorkingDir); } if (const char* environment = this->GeneratorTarget->GetProperty("VS_DEBUGGER_ENVIRONMENT")) { - cmGeneratorExpression ge; - std::unique_ptr cge = - ge.Parse(environment); - std::string genEnvironment = - cge->Evaluate(this->LocalGenerator, config); - + std::string genEnvironment = cmGeneratorExpression::Evaluate( + environment, this->LocalGenerator, config); e1.WritePlatformConfigTag("LocalDebuggerEnvironment", cond, genEnvironment); } if (const char* debuggerCommand = this->GeneratorTarget->GetProperty("VS_DEBUGGER_COMMAND")) { - - cmGeneratorExpression ge; - std::unique_ptr cge = - ge.Parse(debuggerCommand); - std::string genDebuggerCommand = - cge->Evaluate(this->LocalGenerator, config); - + std::string genDebuggerCommand = cmGeneratorExpression::Evaluate( + debuggerCommand, this->LocalGenerator, config); e1.WritePlatformConfigTag("LocalDebuggerCommand", cond, genDebuggerCommand); } if (const char* commandArguments = this->GeneratorTarget->GetProperty( "VS_DEBUGGER_COMMAND_ARGUMENTS")) { - cmGeneratorExpression ge; - std::unique_ptr cge = - ge.Parse(commandArguments); - std::string genCommandArguments = - cge->Evaluate(this->LocalGenerator, config); - + std::string genCommandArguments = cmGeneratorExpression::Evaluate( + commandArguments, this->LocalGenerator, config); e1.WritePlatformConfigTag("LocalDebuggerCommandArguments", cond, genCommandArguments); } @@ -3479,22 +3460,16 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( if (const char* nativeLibDirectoriesExpression = this->GeneratorTarget->GetProperty("ANDROID_NATIVE_LIB_DIRECTORIES")) { - cmGeneratorExpression ge; - std::unique_ptr cge = - ge.Parse(nativeLibDirectoriesExpression); - std::string nativeLibDirs = - cge->Evaluate(this->LocalGenerator, configName); + std::string nativeLibDirs = cmGeneratorExpression::Evaluate( + nativeLibDirectoriesExpression, this->LocalGenerator, configName); e2.Element("NativeLibDirectories", nativeLibDirs); } if (const char* nativeLibDependenciesExpression = this->GeneratorTarget->GetProperty( "ANDROID_NATIVE_LIB_DEPENDENCIES")) { - cmGeneratorExpression ge; - std::unique_ptr cge = - ge.Parse(nativeLibDependenciesExpression); - std::string nativeLibDeps = - cge->Evaluate(this->LocalGenerator, configName); + std::string nativeLibDeps = cmGeneratorExpression::Evaluate( + nativeLibDependenciesExpression, this->LocalGenerator, configName); e2.Element("NativeLibDependencies", nativeLibDeps); } @@ -3505,11 +3480,8 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( if (const char* jarDirectoriesExpression = this->GeneratorTarget->GetProperty("ANDROID_JAR_DIRECTORIES")) { - cmGeneratorExpression ge; - std::unique_ptr cge = - ge.Parse(jarDirectoriesExpression); - std::string jarDirectories = - cge->Evaluate(this->LocalGenerator, configName); + std::string jarDirectories = cmGeneratorExpression::Evaluate( + jarDirectoriesExpression, this->LocalGenerator, configName); e2.Element("JarDirectories", jarDirectories); } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=acb9511044a230126289c1e99cfed134c3be3c52 commit acb9511044a230126289c1e99cfed134c3be3c52 Author: Cristian Adam AuthorDate: Thu Sep 19 23:56:31 2019 +0200 Commit: Brad King CommitDate: Mon Sep 23 11:13:13 2019 -0400 Precompile headers: Treat headers as relative to current source directory Teach `target_precompile_headers` to treat relative paths the same way as `target_sources`. Fixes: #19733 diff --git a/Help/command/target_precompile_headers.rst b/Help/command/target_precompile_headers.rst index 7d36b11..3a32f41 100644 --- a/Help/command/target_precompile_headers.rst +++ b/Help/command/target_precompile_headers.rst @@ -48,17 +48,32 @@ See the :manual:`cmake-generator-expressions(7)` manual for available expressions. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. +Usage +^^^^^ + .. code-block:: cmake target_precompile_headers( PUBLIC - "project_header.h" + project_header.h PRIVATE + [["other_header.h"]] ) -Header files will be double quoted if they are not specified with double -quotes or angle brackets. +The list of header files is used to generate a header file named +``cmake_pch.h|xx`` which is used to generate the precompiled header file +(``.pch``, ``.gch``, ``.pchi``) artifact. The ``cmake_pch.h|xx`` header +file will be force included (``-include`` for GCC, ``/FI`` for MSVC) to +all source files, so sources do not need to have ``#include "pch.h"``. + +Header file names specified with angle brackets (e.g. ````) or +explicit double quotes (escaped for the :manual:`cmake-language(7)`, +e.g. ``[["other_header.h"]]``) will be treated as is, and include directories +must be available for the compiler to find them. Other header file names +(e.g. ``project_header.h``) are interpreted as being relative to the current +source directory (e.g. :variable:`CMAKE_CURRENT_SOURCE_DIR`) and will be +included by absolute path. See Also ^^^^^^^^ diff --git a/Source/cmTargetPrecompileHeadersCommand.cxx b/Source/cmTargetPrecompileHeadersCommand.cxx index 97f1bea..5751fff 100644 --- a/Source/cmTargetPrecompileHeadersCommand.cxx +++ b/Source/cmTargetPrecompileHeadersCommand.cxx @@ -2,17 +2,29 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmTargetPrecompileHeadersCommand.h" +#include "cmGeneratorExpression.h" #include "cmMakefile.h" #include "cmMessageType.h" #include "cmStringAlgorithms.h" +#include "cmSystemTools.h" #include "cmTarget.h" +#include + bool cmTargetPrecompileHeadersCommand::InitialPass( std::vector const& args, cmExecutionStatus&) { return this->HandleArguments(args, "PRECOMPILE_HEADERS", PROCESS_REUSE_FROM); } +void cmTargetPrecompileHeadersCommand::HandleInterfaceContent( + cmTarget* tgt, const std::vector& content, bool prepend, + bool system) +{ + cmTargetPropCommandBase::HandleInterfaceContent( + tgt, ConvertToAbsoluteContent(tgt, content, true), prepend, system); +} + void cmTargetPrecompileHeadersCommand::HandleMissingTarget( const std::string& name) { @@ -31,6 +43,33 @@ std::string cmTargetPrecompileHeadersCommand::Join( bool cmTargetPrecompileHeadersCommand::HandleDirectContent( cmTarget* tgt, const std::vector& content, bool, bool) { - tgt->AppendProperty("PRECOMPILE_HEADERS", this->Join(content).c_str()); + tgt->AppendProperty( + "PRECOMPILE_HEADERS", + this->Join(ConvertToAbsoluteContent(tgt, content, false)).c_str()); return true; } + +std::vector +cmTargetPrecompileHeadersCommand::ConvertToAbsoluteContent( + cmTarget* /*tgt*/, const std::vector& content, + bool /*isInterfaceContent*/) +{ + std::vector absoluteContent; + absoluteContent.reserve(content.size()); + for (std::string const& src : content) { + std::string absoluteSrc; + // Use '' and '"foo.h"' includes and absolute paths as-is. + // Interpret relative paths with respect to the source directory. + // If the path starts in a generator expression, assume it is absolute. + if (cmHasLiteralPrefix(src, "<") || cmHasLiteralPrefix(src, "\"") || + cmSystemTools::FileIsFullPath(src) || + cmGeneratorExpression::Find(src) == 0) { + absoluteSrc = src; + } else { + absoluteSrc = + cmStrCat(this->Makefile->GetCurrentSourceDirectory(), '/', src); + } + absoluteContent.emplace_back(std::move(absoluteSrc)); + } + return absoluteContent; +} diff --git a/Source/cmTargetPrecompileHeadersCommand.h b/Source/cmTargetPrecompileHeadersCommand.h index 7e4558e..00dc928 100644 --- a/Source/cmTargetPrecompileHeadersCommand.h +++ b/Source/cmTargetPrecompileHeadersCommand.h @@ -28,6 +28,11 @@ public: bool InitialPass(std::vector const& args, cmExecutionStatus& status) override; +protected: + void HandleInterfaceContent(cmTarget* tgt, + const std::vector& content, + bool prepend, bool system) override; + private: void HandleMissingTarget(const std::string& name) override; @@ -36,6 +41,10 @@ private: bool prepend, bool system) override; std::string Join(const std::vector& content) override; + + std::vector ConvertToAbsoluteContent( + cmTarget* tgt, const std::vector& content, + bool isInterfaceContent); }; #endif diff --git a/Tests/RunCMake/PrecompileHeaders/DisabledPch.cmake b/Tests/RunCMake/PrecompileHeaders/DisabledPch.cmake index ee47980..59ee14b 100644 --- a/Tests/RunCMake/PrecompileHeaders/DisabledPch.cmake +++ b/Tests/RunCMake/PrecompileHeaders/DisabledPch.cmake @@ -4,7 +4,7 @@ project(DisabledPch C) add_library(foo foo.c) target_include_directories(foo PUBLIC include) target_precompile_headers(foo PUBLIC - foo.h + include/foo.h \"string.h\" ) diff --git a/Tests/RunCMake/PrecompileHeaders/PchInterface-check.cmake b/Tests/RunCMake/PrecompileHeaders/PchInterface-check.cmake index cbd6ede..caeb22b 100644 --- a/Tests/RunCMake/PrecompileHeaders/PchInterface-check.cmake +++ b/Tests/RunCMake/PrecompileHeaders/PchInterface-check.cmake @@ -18,19 +18,14 @@ endif() file(STRINGS ${foo_pch_header} foo_pch_header_strings) -if (NOT "#include \"foo.h\"" IN_LIST foo_pch_header_strings OR - NOT "#include " IN_LIST foo_pch_header_strings OR - NOT "#include \"string.h\"" IN_LIST foo_pch_header_strings) - set(RunCMake_TEST_FAILED "Generated foo pch header ${foo_pch_header} has bad content") +if (NOT foo_pch_header_strings MATCHES ";#include \"[^\"]*PrecompileHeaders/include/foo.h\";#include \"foo2.h\";#include ;#include \"string.h\"(;|$)") + set(RunCMake_TEST_FAILED "Generated foo pch header\n ${foo_pch_header}\nhas bad content:\n ${foo_pch_header_strings}") return() endif() file(STRINGS ${foobar_pch_header} foobar_pch_header_strings) -if (NOT "#include \"foo.h\"" IN_LIST foobar_pch_header_strings OR - NOT "#include " IN_LIST foobar_pch_header_strings OR - NOT "#include \"string.h\"" IN_LIST foobar_pch_header_strings OR - NOT "#include \"bar.h\"" IN_LIST foobar_pch_header_strings) - set(RunCMake_TEST_FAILED "Generated foobar pch header ${foobar_pch_header} has bad content") +if (NOT foobar_pch_header_strings MATCHES ";#include \"[^\"]*PrecompileHeaders/include/foo.h\";#include \"foo2.h\";#include ;#include \"string.h\";#include \"[^\"]*PrecompileHeaders/include/bar.h\"(;|$)") + set(RunCMake_TEST_FAILED "Generated foobar pch header\n ${foobar_pch_header}\nhas bad content:\n ${foobar_pch_header_strings}") return() endif() diff --git a/Tests/RunCMake/PrecompileHeaders/PchInterface.cmake b/Tests/RunCMake/PrecompileHeaders/PchInterface.cmake index 9041b09..a1e0792 100644 --- a/Tests/RunCMake/PrecompileHeaders/PchInterface.cmake +++ b/Tests/RunCMake/PrecompileHeaders/PchInterface.cmake @@ -4,14 +4,15 @@ project(PchInterface C) add_library(foo foo.c) target_include_directories(foo PUBLIC include) target_precompile_headers(foo PUBLIC - foo.h + include/foo.h + \"foo2.h\" \"string.h\" ) add_library(bar INTERFACE) target_include_directories(bar INTERFACE include) -target_precompile_headers(bar INTERFACE bar.h) +target_precompile_headers(bar INTERFACE include/bar.h) add_executable(foobar foobar.c) target_link_libraries(foobar foo bar) diff --git a/Tests/RunCMake/PrecompileHeaders/foo.c b/Tests/RunCMake/PrecompileHeaders/foo.c index 974a248..85ea230 100644 --- a/Tests/RunCMake/PrecompileHeaders/foo.c +++ b/Tests/RunCMake/PrecompileHeaders/foo.c @@ -1,6 +1,12 @@ #include "foo.h" +#include "foo2.h" int foo() { return 0; } + +int foo2() +{ + return 0; +} diff --git a/Tests/RunCMake/PrecompileHeaders/foobar.c b/Tests/RunCMake/PrecompileHeaders/foobar.c index 6dbf8ce..7a135ea 100644 --- a/Tests/RunCMake/PrecompileHeaders/foobar.c +++ b/Tests/RunCMake/PrecompileHeaders/foobar.c @@ -1,7 +1,8 @@ #include "bar.h" #include "foo.h" +#include "foo2.h" int main() { - return foo() + bar(); + return foo() + foo2() + bar(); } diff --git a/Tests/RunCMake/PrecompileHeaders/include/foo2.h b/Tests/RunCMake/PrecompileHeaders/include/foo2.h new file mode 100644 index 0000000..4bf9c81 --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/include/foo2.h @@ -0,0 +1,6 @@ +#ifndef foo2_h +#define foo2_h + +int foo2(void); + +#endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c7c59dae82594557dc2fddc4ef881dafeaad076a commit c7c59dae82594557dc2fddc4ef881dafeaad076a Author: Daniel Eiband AuthorDate: Sun Sep 22 00:17:22 2019 +0200 Commit: Daniel Eiband CommitDate: Sun Sep 22 09:51:20 2019 +0200 cmCustomCommandGenerator: Replace generator expression member Replace generator expression member variable by stack variable in the constructor. diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index ddb855b..7f3e052 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -19,7 +19,7 @@ namespace { void AppendPaths(const std::vector& inputs, - cmGeneratorExpression& ge, cmLocalGenerator* lg, + cmGeneratorExpression const& ge, cmLocalGenerator* lg, std::string const& config, std::vector& output) { for (std::string const& in : inputs) { @@ -45,15 +45,15 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, , LG(lg) , OldStyle(cc.GetEscapeOldStyle()) , MakeVars(cc.GetEscapeAllowMakeVars()) - , GE(new cmGeneratorExpression(cc.GetBacktrace())) , EmulatorsWithArguments(cc.GetCommandLines().size()) { + cmGeneratorExpression ge(cc.GetBacktrace()); + const cmCustomCommandLines& cmdlines = this->CC.GetCommandLines(); for (cmCustomCommandLine const& cmdline : cmdlines) { cmCustomCommandLine argv; for (std::string const& clarg : cmdline) { - std::unique_ptr cge = - this->GE->Parse(clarg); + std::unique_ptr cge = ge.Parse(clarg); std::string parsed_arg = cge->Evaluate(this->LG, this->Config); if (this->CC.GetCommandExpandLists()) { cmAppend(argv, cmExpandedList(parsed_arg)); @@ -72,15 +72,14 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, this->CommandLines.push_back(std::move(argv)); } - AppendPaths(cc.GetByproducts(), *this->GE, this->LG, this->Config, + AppendPaths(cc.GetByproducts(), ge, this->LG, this->Config, this->Byproducts); - AppendPaths(cc.GetDepends(), *this->GE, this->LG, this->Config, - this->Depends); + AppendPaths(cc.GetDepends(), ge, this->LG, this->Config, this->Depends); const std::string& workingdirectory = this->CC.GetWorkingDirectory(); if (!workingdirectory.empty()) { std::unique_ptr cge = - this->GE->Parse(workingdirectory); + ge.Parse(workingdirectory); this->WorkingDirectory = cge->Evaluate(this->LG, this->Config); // Convert working directory to a full path. if (!this->WorkingDirectory.empty()) { @@ -93,11 +92,6 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, this->FillEmulatorsWithArguments(); } -cmCustomCommandGenerator::~cmCustomCommandGenerator() -{ - delete this->GE; -} - unsigned int cmCustomCommandGenerator::GetNumberOfCommands() const { return static_cast(this->CC.GetCommandLines().size()); diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h index d614302..50f292e 100644 --- a/Source/cmCustomCommandGenerator.h +++ b/Source/cmCustomCommandGenerator.h @@ -10,7 +10,6 @@ #include class cmCustomCommand; -class cmGeneratorExpression; class cmLocalGenerator; class cmCustomCommandGenerator @@ -20,7 +19,6 @@ class cmCustomCommandGenerator cmLocalGenerator* LG; bool OldStyle; bool MakeVars; - cmGeneratorExpression* GE; cmCustomCommandLines CommandLines; std::vector> EmulatorsWithArguments; std::vector Byproducts; @@ -34,7 +32,6 @@ class cmCustomCommandGenerator public: cmCustomCommandGenerator(cmCustomCommand const& cc, std::string config, cmLocalGenerator* lg); - ~cmCustomCommandGenerator(); cmCustomCommandGenerator(const cmCustomCommandGenerator&) = delete; cmCustomCommandGenerator& operator=(const cmCustomCommandGenerator&) = delete; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c12222db86859a5a5ce9163a5309bb0da10ec616 commit c12222db86859a5a5ce9163a5309bb0da10ec616 Author: Daniel Eiband AuthorDate: Sun Sep 22 00:06:45 2019 +0200 Commit: Daniel Eiband CommitDate: Sun Sep 22 09:51:19 2019 +0200 cmGeneratorExpression: Remove Evaluate overload by parameter re-ordering Simplify by re-ordering parameters of cmCompiledGeneratorExpression::Evaluate so that frequently used parameters are before less frequently used parameters. This allows with little extra arguments to get rid of one Evaluate overload, which makes it easier to implement the cmGeneratorExpression::Evaluate utility. The latter would otherwise need four overloads. diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 5852360..4027d4b 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -75,7 +75,7 @@ std::string cmExportTryCompileFileGenerator::FindTargets( cmGeneratorTarget gDummyHead(&dummyHead, tgt->GetLocalGenerator()); std::string result = cge->Evaluate(tgt->GetLocalGenerator(), this->Config, - &gDummyHead, tgt, &dagChecker, language); + &gDummyHead, &dagChecker, tgt, language); const std::set& allTargets = cge->GetAllTargetsSeen(); diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 9472d9a..1bc3452 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -40,17 +40,7 @@ const std::string& cmCompiledGeneratorExpression::Evaluate( cmLocalGenerator* lg, const std::string& config, const cmGeneratorTarget* headTarget, cmGeneratorExpressionDAGChecker* dagChecker, - std::string const& language) const -{ - return this->Evaluate(lg, config, headTarget, headTarget, dagChecker, - language); -} - -const std::string& cmCompiledGeneratorExpression::Evaluate( - cmLocalGenerator* lg, const std::string& config, - const cmGeneratorTarget* headTarget, const cmGeneratorTarget* currentTarget, - cmGeneratorExpressionDAGChecker* dagChecker, - std::string const& language) const + const cmGeneratorTarget* currentTarget, std::string const& language) const { cmGeneratorExpressionContext context( lg, config, this->Quiet, headTarget, @@ -391,7 +381,7 @@ const std::string& cmGeneratorExpressionInterpreter::Evaluate( nullptr); return this->CompiledGeneratorExpression->Evaluate( - this->LocalGenerator, this->Config, this->HeadTarget, &dagChecker, + this->LocalGenerator, this->Config, this->HeadTarget, &dagChecker, nullptr, this->Language); } diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index 7ed024a..322bf5c 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -90,13 +90,8 @@ public: const std::string& Evaluate( cmLocalGenerator* lg, const std::string& config, cmGeneratorTarget const* headTarget = nullptr, - cmGeneratorTarget const* currentTarget = nullptr, cmGeneratorExpressionDAGChecker* dagChecker = nullptr, - std::string const& language = std::string()) const; - const std::string& Evaluate( - cmLocalGenerator* lg, const std::string& config, - cmGeneratorTarget const* headTarget, - cmGeneratorExpressionDAGChecker* dagChecker, + cmGeneratorTarget const* currentTarget = nullptr, std::string const& language = std::string()) const; /** Get set of targets found during evaluations. */ diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 419a82c..641cbaf 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -45,15 +45,15 @@ std::string cmGeneratorExpressionNode::EvaluateDependentExpression( std::string const& prop, cmLocalGenerator* lg, cmGeneratorExpressionContext* context, cmGeneratorTarget const* headTarget, - cmGeneratorTarget const* currentTarget, - cmGeneratorExpressionDAGChecker* dagChecker) + cmGeneratorExpressionDAGChecker* dagChecker, + cmGeneratorTarget const* currentTarget) { cmGeneratorExpression ge(context->Backtrace); std::unique_ptr cge = ge.Parse(prop); cge->SetEvaluateForBuildsystem(context->EvaluateForBuildsystem); cge->SetQuiet(context->Quiet); std::string result = - cge->Evaluate(lg, context->Config, headTarget, currentTarget, dagChecker, + cge->Evaluate(lg, context->Config, headTarget, dagChecker, currentTarget, context->Language); if (cge->GetHadContextSensitiveCondition()) { context->HadContextSensitiveCondition = true; @@ -478,13 +478,13 @@ protected: } return this->EvaluateDependentExpression( - expression, context->LG, context, context->HeadTarget, - context->CurrentTarget, &dagChecker); + expression, context->LG, context, context->HeadTarget, &dagChecker, + context->CurrentTarget); } return this->EvaluateDependentExpression( - expression, context->LG, context, context->HeadTarget, - context->CurrentTarget, dagCheckerParent); + expression, context->LG, context, context->HeadTarget, dagCheckerParent, + context->CurrentTarget); } }; @@ -1332,7 +1332,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if (!interfacePropertyName.empty()) { result = this->EvaluateDependentExpression(result, context->LG, context, - target, target, &dagChecker); + target, &dagChecker, target); std::string linkedTargetsContent = getLinkedTargetsContent( target, interfacePropertyName, context, &dagChecker); if (!linkedTargetsContent.empty()) { diff --git a/Source/cmGeneratorExpressionNode.h b/Source/cmGeneratorExpressionNode.h index 7a36924..13e8484 100644 --- a/Source/cmGeneratorExpressionNode.h +++ b/Source/cmGeneratorExpressionNode.h @@ -43,8 +43,8 @@ struct cmGeneratorExpressionNode static std::string EvaluateDependentExpression( std::string const& prop, cmLocalGenerator* lg, cmGeneratorExpressionContext* context, const cmGeneratorTarget* headTarget, - const cmGeneratorTarget* currentTarget, - cmGeneratorExpressionDAGChecker* dagChecker); + cmGeneratorExpressionDAGChecker* dagChecker, + const cmGeneratorTarget* currentTarget); static const cmGeneratorExpressionNode* GetNode( const std::string& identifier); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 454bcbc..b66d9d5 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -112,7 +112,8 @@ public: cmGeneratorExpressionDAGChecker* dagChecker, std::string const& language) const override { - return this->ge->Evaluate(lg, config, headTarget, dagChecker, language); + return this->ge->Evaluate(lg, config, headTarget, dagChecker, nullptr, + language); } cmListFileBacktrace GetBacktrace() const override @@ -709,8 +710,8 @@ void handleSystemIncludesDep(cmLocalGenerator* lg, if (const char* dirs = depTgt->GetProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")) { cmGeneratorExpression ge; - cmExpandList(ge.Parse(dirs)->Evaluate(lg, config, headTarget, depTgt, - dagChecker, language), + cmExpandList(ge.Parse(dirs)->Evaluate(lg, config, headTarget, dagChecker, + depTgt, language), result); } if (!depTgt->IsImported() || excludeImported) { @@ -720,8 +721,8 @@ void handleSystemIncludesDep(cmLocalGenerator* lg, if (const char* dirs = depTgt->GetProperty("INTERFACE_INCLUDE_DIRECTORIES")) { cmGeneratorExpression ge; - cmExpandList(ge.Parse(dirs)->Evaluate(lg, config, headTarget, depTgt, - dagChecker, language), + cmExpandList(ge.Parse(dirs)->Evaluate(lg, config, headTarget, dagChecker, + depTgt, language), result); } } @@ -1093,7 +1094,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory( for (std::string const& it : this->Target->GetSystemIncludeDirectories()) { cmGeneratorExpression ge; cmExpandList(ge.Parse(it)->Evaluate(this->LocalGenerator, config, this, - &dagChecker, language), + &dagChecker, nullptr, language), result); } @@ -1199,7 +1200,7 @@ std::string cmGeneratorTarget::EvaluateInterfaceProperty( if (const char* p = this->GetProperty(prop)) { result = cmGeneratorExpressionNode::EvaluateDependentExpression( - p, context->LG, context, headTarget, this, &dagChecker); + p, context->LG, context, headTarget, &dagChecker, this); } if (cmLinkInterfaceLibraries const* iface = @@ -5287,7 +5288,7 @@ void cmGeneratorTarget::ExpandLinkItems( std::vector libs; std::unique_ptr cge = ge.Parse(value); cmExpandList( - cge->Evaluate(this->LocalGenerator, config, headTarget, this, &dagChecker), + cge->Evaluate(this->LocalGenerator, config, headTarget, &dagChecker, this), libs); this->LookupLinkItems(libs, cge->GetBacktrace(), items); hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition(); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1811411fecf3d9769ad7a13f6ecd01c5351df9c4 commit 1811411fecf3d9769ad7a13f6ecd01c5351df9c4 Author: Daniel Eiband AuthorDate: Sat Sep 21 23:39:48 2019 +0200 Commit: Daniel Eiband CommitDate: Sun Sep 22 09:49:41 2019 +0200 cmGeneratorExpression: Move quiet flag to cmCompiledGeneratorExpression The quiet flag is false for all but one call to Evaluate. Make the quiet flag a setter of cmCompiledGeneratorExpression to be able to remove it from the Evaluate function signature. diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index f9a28cd..e142560 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -380,7 +380,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( this->ReplaceInstallPrefix(dirs); std::unique_ptr cge = ge.Parse(dirs); std::string exportDirs = - cge->Evaluate(target->GetLocalGenerator(), "", false, target); + cge->Evaluate(target->GetLocalGenerator(), "", target); if (cge->GetHadContextSensitiveCondition()) { cmLocalGenerator* lg = target->GetLocalGenerator(); diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 5631d60..5852360 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -74,9 +74,8 @@ std::string cmExportTryCompileFileGenerator::FindTargets( cmGeneratorTarget gDummyHead(&dummyHead, tgt->GetLocalGenerator()); - std::string result = - cge->Evaluate(tgt->GetLocalGenerator(), this->Config, false, &gDummyHead, - tgt, &dagChecker, language); + std::string result = cge->Evaluate(tgt->GetLocalGenerator(), this->Config, + &gDummyHead, tgt, &dagChecker, language); const std::set& allTargets = cge->GetAllTargetsSeen(); diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index f49ed2c..9472d9a 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -21,40 +21,41 @@ cmGeneratorExpression::cmGeneratorExpression(cmListFileBacktrace backtrace) { } +cmGeneratorExpression::~cmGeneratorExpression() = default; + std::unique_ptr cmGeneratorExpression::Parse( - std::string const& input) + std::string input) const { return std::unique_ptr( - new cmCompiledGeneratorExpression(this->Backtrace, input)); + new cmCompiledGeneratorExpression(this->Backtrace, std::move(input))); } std::unique_ptr cmGeneratorExpression::Parse( - const char* input) + const char* input) const { return this->Parse(std::string(input ? input : "")); } -cmGeneratorExpression::~cmGeneratorExpression() = default; - const std::string& cmCompiledGeneratorExpression::Evaluate( - cmLocalGenerator* lg, const std::string& config, bool quiet, + cmLocalGenerator* lg, const std::string& config, const cmGeneratorTarget* headTarget, cmGeneratorExpressionDAGChecker* dagChecker, std::string const& language) const { - return this->Evaluate(lg, config, quiet, headTarget, headTarget, dagChecker, + return this->Evaluate(lg, config, headTarget, headTarget, dagChecker, language); } const std::string& cmCompiledGeneratorExpression::Evaluate( - cmLocalGenerator* lg, const std::string& config, bool quiet, + cmLocalGenerator* lg, const std::string& config, const cmGeneratorTarget* headTarget, const cmGeneratorTarget* currentTarget, cmGeneratorExpressionDAGChecker* dagChecker, std::string const& language) const { cmGeneratorExpressionContext context( - lg, config, quiet, headTarget, currentTarget ? currentTarget : headTarget, - this->EvaluateForBuildsystem, this->Backtrace, language); + lg, config, this->Quiet, headTarget, + currentTarget ? currentTarget : headTarget, this->EvaluateForBuildsystem, + this->Backtrace, language); return this->EvaluateWithContext(context, dagChecker); } @@ -97,9 +98,10 @@ cmCompiledGeneratorExpression::cmCompiledGeneratorExpression( cmListFileBacktrace backtrace, std::string input) : Backtrace(std::move(backtrace)) , Input(std::move(input)) + , EvaluateForBuildsystem(false) + , Quiet(false) , HadContextSensitiveCondition(false) , HadHeadSensitiveCondition(false) - , EvaluateForBuildsystem(false) { cmGeneratorExpressionLexer l; std::vector tokens = l.Tokenize(this->Input); @@ -377,10 +379,10 @@ void cmCompiledGeneratorExpression::GetMaxLanguageStandard( } const std::string& cmGeneratorExpressionInterpreter::Evaluate( - const char* expression, const std::string& property) + std::string expression, const std::string& property) { this->CompiledGeneratorExpression = - this->GeneratorExpression.Parse(expression); + this->GeneratorExpression.Parse(std::move(expression)); // Specify COMPILE_OPTIONS to DAGchecker, same semantic as COMPILE_FLAGS cmGeneratorExpressionDAGChecker dagChecker( @@ -389,6 +391,12 @@ const std::string& cmGeneratorExpressionInterpreter::Evaluate( nullptr); return this->CompiledGeneratorExpression->Evaluate( - this->LocalGenerator, this->Config, false, this->HeadTarget, &dagChecker, + this->LocalGenerator, this->Config, this->HeadTarget, &dagChecker, this->Language); } + +const std::string& cmGeneratorExpressionInterpreter::Evaluate( + const char* expression, const std::string& property) +{ + return this->Evaluate(std::string(expression ? expression : ""), property); +} diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index ef76651..7ed024a 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -41,8 +41,9 @@ public: cmGeneratorExpression& operator=(cmGeneratorExpression const&) = delete; std::unique_ptr Parse( - std::string const& input); - std::unique_ptr Parse(const char* input); + std::string input) const; + std::unique_ptr Parse( + const char* input) const; enum PreprocessContext { @@ -87,13 +88,13 @@ public: cmCompiledGeneratorExpression const&) = delete; const std::string& Evaluate( - cmLocalGenerator* lg, const std::string& config, bool quiet = false, + cmLocalGenerator* lg, const std::string& config, cmGeneratorTarget const* headTarget = nullptr, cmGeneratorTarget const* currentTarget = nullptr, cmGeneratorExpressionDAGChecker* dagChecker = nullptr, std::string const& language = std::string()) const; const std::string& Evaluate( - cmLocalGenerator* lg, const std::string& config, bool quiet, + cmLocalGenerator* lg, const std::string& config, cmGeneratorTarget const* headTarget, cmGeneratorExpressionDAGChecker* dagChecker, std::string const& language = std::string()) const; @@ -135,6 +136,8 @@ public: this->EvaluateForBuildsystem = eval; } + void SetQuiet(bool quiet) { this->Quiet = quiet; } + void GetMaxLanguageStandard(cmGeneratorTarget const* tgt, std::map& mapping); @@ -152,6 +155,8 @@ private: std::vector Evaluators; const std::string Input; bool NeedsEvaluation; + bool EvaluateForBuildsystem; + bool Quiet; mutable std::set DependTargets; mutable std::set AllTargetsSeen; @@ -163,7 +168,6 @@ private: mutable bool HadContextSensitiveCondition; mutable bool HadHeadSensitiveCondition; mutable std::set SourceSensitiveTargets; - bool EvaluateForBuildsystem; }; class cmGeneratorExpressionInterpreter @@ -172,11 +176,11 @@ public: cmGeneratorExpressionInterpreter(cmLocalGenerator* localGenerator, std::string config, cmGeneratorTarget const* headTarget, - std::string lang = std::string()) + std::string language = std::string()) : LocalGenerator(localGenerator) , Config(std::move(config)) , HeadTarget(headTarget) - , Language(std::move(lang)) + , Language(std::move(language)) { } @@ -185,13 +189,10 @@ public: cmGeneratorExpressionInterpreter& operator=( cmGeneratorExpressionInterpreter const&) = delete; + const std::string& Evaluate(std::string expression, + const std::string& property); const std::string& Evaluate(const char* expression, const std::string& property); - const std::string& Evaluate(const std::string& expression, - const std::string& property) - { - return this->Evaluate(expression.c_str(), property); - } protected: cmGeneratorExpression GeneratorExpression; diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index eb43270..aa2c1a6 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -37,8 +37,8 @@ void cmGeneratorExpressionEvaluationFile::Generate( { std::string rawCondition = this->Condition->GetInput(); if (!rawCondition.empty()) { - std::string condResult = this->Condition->Evaluate( - lg, config, false, nullptr, nullptr, nullptr, lang); + std::string condResult = + this->Condition->Evaluate(lg, config, nullptr, nullptr, nullptr, lang); if (condResult == "0") { return; } @@ -54,9 +54,9 @@ void cmGeneratorExpressionEvaluationFile::Generate( } std::string outputFileName = this->OutputFileExpr->Evaluate( - lg, config, false, nullptr, nullptr, nullptr, lang); - const std::string& outputContent = inputExpression->Evaluate( - lg, config, false, nullptr, nullptr, nullptr, lang); + lg, config, nullptr, nullptr, nullptr, lang); + const std::string& outputContent = + inputExpression->Evaluate(lg, config, nullptr, nullptr, nullptr, lang); if (cmSystemTools::FileIsFullPath(outputFileName)) { outputFileName = cmSystemTools::CollapseFullPath(outputFileName); @@ -100,8 +100,8 @@ void cmGeneratorExpressionEvaluationFile::CreateOutputFile( gg->GetEnabledLanguages(enabledLanguages); for (std::string const& le : enabledLanguages) { - std::string name = this->OutputFileExpr->Evaluate( - lg, config, false, nullptr, nullptr, nullptr, le); + std::string name = this->OutputFileExpr->Evaluate(lg, config, nullptr, + nullptr, nullptr, le); cmSourceFile* sf = lg->GetMakefile()->GetOrCreateSource( name, false, cmSourceFileLocationKind::Known); // Tell TraceDependencies that the file is not expected to exist diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index d524867..419a82c 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -51,9 +51,10 @@ std::string cmGeneratorExpressionNode::EvaluateDependentExpression( cmGeneratorExpression ge(context->Backtrace); std::unique_ptr cge = ge.Parse(prop); cge->SetEvaluateForBuildsystem(context->EvaluateForBuildsystem); + cge->SetQuiet(context->Quiet); std::string result = - cge->Evaluate(lg, context->Config, context->Quiet, headTarget, - currentTarget, dagChecker, context->Language); + cge->Evaluate(lg, context->Config, headTarget, currentTarget, dagChecker, + context->Language); if (cge->GetHadContextSensitiveCondition()) { context->HadContextSensitiveCondition = true; } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 372b83d..454bcbc 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -112,8 +112,7 @@ public: cmGeneratorExpressionDAGChecker* dagChecker, std::string const& language) const override { - return this->ge->Evaluate(lg, config, false, headTarget, dagChecker, - language); + return this->ge->Evaluate(lg, config, headTarget, dagChecker, language); } cmListFileBacktrace GetBacktrace() const override @@ -710,8 +709,8 @@ void handleSystemIncludesDep(cmLocalGenerator* lg, if (const char* dirs = depTgt->GetProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")) { cmGeneratorExpression ge; - cmExpandList(ge.Parse(dirs)->Evaluate(lg, config, false, headTarget, - depTgt, dagChecker, language), + cmExpandList(ge.Parse(dirs)->Evaluate(lg, config, headTarget, depTgt, + dagChecker, language), result); } if (!depTgt->IsImported() || excludeImported) { @@ -721,8 +720,8 @@ void handleSystemIncludesDep(cmLocalGenerator* lg, if (const char* dirs = depTgt->GetProperty("INTERFACE_INCLUDE_DIRECTORIES")) { cmGeneratorExpression ge; - cmExpandList(ge.Parse(dirs)->Evaluate(lg, config, false, headTarget, - depTgt, dagChecker, language), + cmExpandList(ge.Parse(dirs)->Evaluate(lg, config, headTarget, depTgt, + dagChecker, language), result); } } @@ -1093,8 +1092,8 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory( std::vector result; for (std::string const& it : this->Target->GetSystemIncludeDirectories()) { cmGeneratorExpression ge; - cmExpandList(ge.Parse(it)->Evaluate(this->LocalGenerator, config, false, - this, &dagChecker, language), + cmExpandList(ge.Parse(it)->Evaluate(this->LocalGenerator, config, this, + &dagChecker, language), result); } @@ -1290,7 +1289,7 @@ void AddObjectEntries(cmGeneratorTarget const* headTarget, EvaluatedTargetPropertyEntry ee(lib, lib.Backtrace); cmExpandList(cge->Evaluate(headTarget->GetLocalGenerator(), config, - false, headTarget, dagChecker), + headTarget, dagChecker), ee.Values); if (cge->GetHadContextSensitiveCondition()) { ee.ContextDependent = true; @@ -2519,9 +2518,9 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector& result, cmGeneratorExpressionDAGChecker dagChecker(this, "AUTOUIC_OPTIONS", nullptr, nullptr); - cmExpandList(ge.Parse(prop)->Evaluate(this->LocalGenerator, config, false, - this, &dagChecker), - result); + cmExpandList( + ge.Parse(prop)->Evaluate(this->LocalGenerator, config, this, &dagChecker), + result); } void processILibs(const std::string& config, @@ -2790,7 +2789,8 @@ void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc) // Check for target references in generator expressions. for (std::string const& cl : cCmdLine) { const std::unique_ptr cge = ge.Parse(cl); - cge->Evaluate(this->GeneratorTarget->GetLocalGenerator(), "", true); + cge->SetQuiet(true); + cge->Evaluate(this->GeneratorTarget->GetLocalGenerator(), ""); std::set geTargets = cge->GetTargets(); targets.insert(geTargets.begin(), geTargets.end()); } @@ -5286,9 +5286,9 @@ void cmGeneratorTarget::ExpandLinkItems( } std::vector libs; std::unique_ptr cge = ge.Parse(value); - cmExpandList(cge->Evaluate(this->LocalGenerator, config, false, headTarget, - this, &dagChecker), - libs); + cmExpandList( + cge->Evaluate(this->LocalGenerator, config, headTarget, this, &dagChecker), + libs); this->LookupLinkItems(libs, cge->GetBacktrace(), items); hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition(); } @@ -6358,7 +6358,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( cmGeneratorExpression ge(*btIt); std::unique_ptr const cge = ge.Parse(*le); std::string const& evaluated = - cge->Evaluate(this->LocalGenerator, config, false, head, &dagChecker); + cge->Evaluate(this->LocalGenerator, config, head, &dagChecker); cmExpandList(evaluated, llibs); if (cge->GetHadHeadSensitiveCondition()) { impl.HadHeadSensitiveCondition = true; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index e059548..19962e3 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1713,8 +1713,7 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, cmGeneratorExpression ge; std::unique_ptr cge = ge.Parse(msvcRuntimeLibraryValue); - std::string const msvcRuntimeLibrary = - cge->Evaluate(this, config, false, target); + std::string const msvcRuntimeLibrary = cge->Evaluate(this, config, target); if (!msvcRuntimeLibrary.empty()) { if (const char* msvcRuntimeLibraryOptions = this->Makefile->GetDefinition( diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 482af22..fa361bb 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -156,7 +156,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() std::vector files; cmGeneratorExpression ge; std::unique_ptr cge = ge.Parse(prop_value); - cmExpandList(cge->Evaluate(this->LocalGenerator, this->ConfigName, false, + cmExpandList(cge->Evaluate(this->LocalGenerator, this->ConfigName, this->GeneratorTarget, nullptr, nullptr), files); return files; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 2ab5adf..bee044e 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1322,7 +1322,7 @@ void cmNinjaTargetGenerator::AdditionalCleanFiles() auto cge = ge.Parse(prop_value); cmExpandList(cge->Evaluate( lg, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"), - false, this->GeneratorTarget, nullptr, nullptr), + this->GeneratorTarget, nullptr, nullptr), cleanFiles); } std::string const& binaryDir = lg->GetCurrentBinaryDirectory(); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=edb0bbd18b5c3dac16ab7d219f787513203529e4 commit edb0bbd18b5c3dac16ab7d219f787513203529e4 Author: Daniel Eiband AuthorDate: Sat Sep 21 22:23:41 2019 +0200 Commit: Daniel Eiband CommitDate: Sat Sep 21 22:40:57 2019 +0200 cmGeneratorTarget: Remove unused virtual signature of TargetPropertyEntry Remove unused virtual Evaluate signature of TargetPropertyEntry. Also remove the boolean parameter quiet. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 18ca478..372b83d 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -84,16 +84,10 @@ public: virtual ~TargetPropertyEntry() = default; virtual const std::string& Evaluate( - cmLocalGenerator* lg, const std::string& config, bool quiet = false, - cmGeneratorTarget const* headTarget = nullptr, - cmGeneratorTarget const* currentTarget = nullptr, - cmGeneratorExpressionDAGChecker* dagChecker = nullptr, - std::string const& language = std::string()) const = 0; - virtual const std::string& Evaluate( - cmLocalGenerator* lg, const std::string& config, bool quiet, + cmLocalGenerator* lg, const std::string& config, cmGeneratorTarget const* headTarget, cmGeneratorExpressionDAGChecker* dagChecker, - std::string const& language = std::string()) const = 0; + std::string const& language) const = 0; virtual cmListFileBacktrace GetBacktrace() const = 0; virtual std::string const& GetInput() const = 0; @@ -113,23 +107,12 @@ public: { } - const std::string& Evaluate( - cmLocalGenerator* lg, const std::string& config, bool quiet = false, - cmGeneratorTarget const* headTarget = nullptr, - cmGeneratorTarget const* currentTarget = nullptr, - cmGeneratorExpressionDAGChecker* dagChecker = nullptr, - std::string const& language = std::string()) const override - { - return this->ge->Evaluate(lg, config, quiet, headTarget, currentTarget, - dagChecker, language); - } - const std::string& Evaluate( - cmLocalGenerator* lg, const std::string& config, bool quiet, - cmGeneratorTarget const* headTarget, - cmGeneratorExpressionDAGChecker* dagChecker, - std::string const& language = std::string()) const override + const std::string& Evaluate(cmLocalGenerator* lg, const std::string& config, + cmGeneratorTarget const* headTarget, + cmGeneratorExpressionDAGChecker* dagChecker, + std::string const& language) const override { - return this->ge->Evaluate(lg, config, quiet, headTarget, dagChecker, + return this->ge->Evaluate(lg, config, false, headTarget, dagChecker, language); } @@ -161,15 +144,7 @@ public: { } - const std::string& Evaluate(cmLocalGenerator*, const std::string&, bool, - cmGeneratorTarget const*, - cmGeneratorTarget const*, - cmGeneratorExpressionDAGChecker*, - std::string const&) const override - { - return this->PropertyValue; - } - const std::string& Evaluate(cmLocalGenerator*, const std::string&, bool, + const std::string& Evaluate(cmLocalGenerator*, const std::string&, cmGeneratorTarget const*, cmGeneratorExpressionDAGChecker*, std::string const&) const override @@ -198,7 +173,7 @@ cmGeneratorTarget::TargetPropertyEntry* CreateTargetPropertyEntry( return new TargetPropertyEntryGenex(std::move(cge)); } - return new TargetPropertyEntryString(propertyValue, backtrace); + return new TargetPropertyEntryString(propertyValue, std::move(backtrace)); } void CreatePropertyGeneratorExpressions( @@ -245,7 +220,7 @@ EvaluatedTargetPropertyEntry EvaluateTargetPropertyEntry( cmGeneratorTarget::TargetPropertyEntry* entry) { EvaluatedTargetPropertyEntry ee(entry->LinkImplItem, entry->GetBacktrace()); - cmExpandList(entry->Evaluate(thisTarget->GetLocalGenerator(), config, false, + cmExpandList(entry->Evaluate(thisTarget->GetLocalGenerator(), config, thisTarget, dagChecker, lang), ee.Values); if (entry->GetHadContextSensitiveCondition()) { https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8456f60dbc13b9fbd0490371c871a1e85a72c3a8 commit 8456f60dbc13b9fbd0490371c871a1e85a72c3a8 Author: Daniel Eiband AuthorDate: Sat Sep 21 13:31:36 2019 +0200 Commit: Daniel Eiband CommitDate: Sat Sep 21 13:31:36 2019 +0200 cmSourceFile: Remove non-const GetProperties accessor Manipulating the property map of cmSourceFile directly may invalidate the class invariant of the cached value IsGenerated. Provide the setter SetProperties which also updates IsGenerated. diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 9c7beca..1eaf48b 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -561,7 +561,7 @@ void* CCONV cmAddSource(void* arg, void* arg2) // Create the real cmSourceFile instance and copy over saved information. cmSourceFile* rsf = mf->GetOrCreateSource(osf->FullPath); - rsf->GetProperties() = osf->Properties; + rsf->SetProperties(osf->Properties); for (std::string const& d : osf->Depends) { rsf->AddDepend(d); } diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 3344217..bd68d04 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -314,6 +314,13 @@ bool cmSourceFile::GetPropertyAsBool(const std::string& prop) const return cmIsOn(this->GetProperty(prop)); } +void cmSourceFile::SetProperties(cmPropertyMap properties) +{ + this->Properties = std::move(properties); + + this->IsGenerated = this->GetPropertyAsBool(propGENERATED); +} + cmCustomCommand* cmSourceFile::GetCustomCommand() const { return this->CustomCommand.get(); diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index ff465c7..3b18fdb 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -94,8 +94,9 @@ public: void AddDepend(const std::string& d) { this->Depends.push_back(d); } // Get the properties - cmPropertyMap& GetProperties() { return this->Properties; } const cmPropertyMap& GetProperties() const { return this->Properties; } + // Set the properties + void SetProperties(cmPropertyMap properties); /** * Check whether the given source file location could refer to this https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f4afcd5c6bee7604e031aaab2fa38a9e9ba93900 commit f4afcd5c6bee7604e031aaab2fa38a9e9ba93900 Author: Daniel Eiband AuthorDate: Thu Aug 29 10:25:34 2019 +0200 Commit: Daniel Eiband CommitDate: Sat Sep 21 12:56:10 2019 +0200 VS: Remove call to ConvertToWindowsExtendedPath with result discarded Remove call to ConvertToWindowsExtendedPath. The call has no side effect and the return value is discarded. diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 61e8f58..108a44f 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -901,7 +901,6 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand( gt->LocalGenerator->ComputeObjectFilenames(mapping, gt); std::string obj_dir = gt->ObjectDirectory; std::string cmakeCommand = cmSystemTools::GetCMakeCommand(); - cmSystemTools::ConvertToWindowsExtendedPath(cmakeCommand); std::string obj_dir_expanded = obj_dir; cmSystemTools::ReplaceString(obj_dir_expanded, this->GetCMakeCFGIntDir(), configName.c_str()); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=61fdf326d8e762aaaef22d8ecce443674d5205e6 commit 61fdf326d8e762aaaef22d8ecce443674d5205e6 Author: Daniel Eiband AuthorDate: Sat Sep 21 12:51:25 2019 +0200 Commit: Daniel Eiband CommitDate: Sat Sep 21 12:56:05 2019 +0200 cmState: Avoid lowering command name twice The given command given to GetCommand is already lower case so we can use GetCommandByExactName directly. diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 93ad2d7..6de312c 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -503,7 +503,7 @@ void cmState::AddScriptedCommand(std::string const& name, Command command) std::string sName = cmSystemTools::LowerCase(name); // if the command already exists, give a new name to the old command. - if (Command oldCmd = this->GetCommand(sName)) { + if (Command oldCmd = this->GetCommandByExactName(sName)) { this->ScriptedCommands["_" + sName] = oldCmd; } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0965bd9c064a5a595ca1bde01e8dba425ea2b916 commit 0965bd9c064a5a595ca1bde01e8dba425ea2b916 Author: Daniel Eiband AuthorDate: Sat Sep 21 12:48:26 2019 +0200 Commit: Daniel Eiband CommitDate: Sat Sep 21 12:55:37 2019 +0200 Generators: Remove function declarations which do not have a definition diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 372e658..3075c1a 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -555,8 +555,6 @@ protected: cmTarget* FindTargetImpl(std::string const& name) const; cmGeneratorTarget* FindGeneratorTargetImpl(std::string const& name) const; - cmGeneratorTarget* FindImportedGeneratorTargetImpl( - std::string const& name) const; const char* GetPredefinedTargetsFolder(); diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 08bec70..f64534c 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -93,7 +93,6 @@ private: void WriteProcessedMakefile(std::ostream& os); void WritePools(std::ostream& os); - void WriteCustomCommandRule(); void WriteCustomCommandBuildStatement(cmCustomCommand const* cc, const cmNinjaDeps& orderOnlyDeps); ----------------------------------------------------------------------- Summary of changes: Help/command/target_precompile_headers.rst | 21 +++- Source/cmCPluginAPI.cxx | 2 +- Source/cmCustomCommandGenerator.cxx | 20 ++-- Source/cmCustomCommandGenerator.h | 3 - Source/cmExportFileGenerator.cxx | 2 +- Source/cmExportTryCompileFileGenerator.cxx | 5 +- Source/cmGeneratorExpression.cxx | 61 +++++++---- Source/cmGeneratorExpression.h | 43 ++++---- Source/cmGeneratorExpressionEvaluationFile.cxx | 14 +-- Source/cmGeneratorExpressionNode.cxx | 19 ++-- Source/cmGeneratorExpressionNode.h | 4 +- Source/cmGeneratorTarget.cxx | 111 +++++++-------------- Source/cmGlobalGenerator.h | 2 - Source/cmGlobalVisualStudio7Generator.cxx | 6 +- Source/cmGlobalVisualStudio8Generator.cxx | 8 +- Source/cmGlobalVisualStudioGenerator.cxx | 1 - Source/cmGlobalXCodeGenerator.cxx | 13 +-- Source/cmInstallDirectoryGenerator.cxx | 11 +- Source/cmInstallFilesGenerator.cxx | 11 +- Source/cmInstallScriptGenerator.cxx | 7 +- Source/cmInstallTargetGenerator.cxx | 6 +- Source/cmJsonObjects.cxx | 12 +-- Source/cmLocalGenerator.cxx | 14 +-- Source/cmLocalNinjaGenerator.cxx | 10 +- Source/cmLocalNinjaGenerator.h | 1 - Source/cmLocalUnixMakefileGenerator3.cxx | 10 +- Source/cmMakefileTargetGenerator.cxx | 9 +- Source/cmNinjaTargetGenerator.cxx | 13 +-- Source/cmSourceFile.cxx | 7 ++ Source/cmSourceFile.h | 3 +- Source/cmState.cxx | 2 +- Source/cmTargetPrecompileHeadersCommand.cxx | 41 +++++++- Source/cmTargetPrecompileHeadersCommand.h | 9 ++ Source/cmVisualStudio10TargetGenerator.cxx | 60 +++-------- Tests/RunCMake/PrecompileHeaders/DisabledPch.cmake | 2 +- .../PrecompileHeaders/PchInterface-check.cmake | 13 +-- .../RunCMake/PrecompileHeaders/PchInterface.cmake | 5 +- Tests/RunCMake/PrecompileHeaders/foo.c | 6 ++ Tests/RunCMake/PrecompileHeaders/foobar.c | 3 +- Tests/RunCMake/PrecompileHeaders/include/foo2.h | 6 ++ 40 files changed, 298 insertions(+), 298 deletions(-) create mode 100644 Tests/RunCMake/PrecompileHeaders/include/foo2.h hooks/post-receive -- CMake From kwrobot at kitware.com Wed Sep 25 00:01:13 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 25 Sep 2019 00:01:13 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1186-ga6b3791 Message-ID: <20190925040113.872701252F7@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via a6b379181495794d47cae256dfd94f43fbfe5d48 (commit) from dcc117b9446cfc3d6c8bf191545aac8d1519abca (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a6b379181495794d47cae256dfd94f43fbfe5d48 commit a6b379181495794d47cae256dfd94f43fbfe5d48 Author: Kitware Robot AuthorDate: Wed Sep 25 00:01:07 2019 -0400 Commit: Kitware Robot CommitDate: Wed Sep 25 00:01:07 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index f85707d..d24c2c0 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 15) -set(CMake_VERSION_PATCH 20190924) +set(CMake_VERSION_PATCH 20190925) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Wed Sep 25 12:40:54 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 25 Sep 2019 12:40:54 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1188-g76ae4c5 Message-ID: <20190925164054.56651109298@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 76ae4c58394c5ec67916f5031e1fe7afca085cfb (commit) via 0578239d3a62ffb01a9b8cdb58f704b29725a1ee (commit) from a6b379181495794d47cae256dfd94f43fbfe5d48 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=76ae4c58394c5ec67916f5031e1fe7afca085cfb commit 76ae4c58394c5ec67916f5031e1fe7afca085cfb Merge: a6b3791 0578239 Author: Brad King AuthorDate: Wed Sep 25 16:38:58 2019 +0000 Commit: Kitware Robot CommitDate: Wed Sep 25 12:39:14 2019 -0400 Merge topic 'vs-16.4-custom-commands' 0578239d3a VS: Tell VS 16.4 not to verify SYMBOLIC custom command outputs Acked-by: Kitware Robot Merge-request: !3860 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0578239d3a62ffb01a9b8cdb58f704b29725a1ee commit 0578239d3a62ffb01a9b8cdb58f704b29725a1ee Author: Brad King AuthorDate: Mon Sep 23 15:30:15 2019 -0400 Commit: Brad King CommitDate: Tue Sep 24 10:41:20 2019 -0400 VS: Tell VS 16.4 not to verify SYMBOLIC custom command outputs VS 16.4 introduces an additional check on `CustomBuild` rules that warns if the outputs of the command are not created. However, CMake supports marking outputs with the `SYMBOLIC` property to indicate that they will not actually be generated. That property is used by Makefile and Ninja generators but has not been needed by the VS generators before. Teach the VS generator to disable `VerifyInputsAndOutputsExist` in custom build rules that have a symbolic output. Fixes: #19737 diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 7d25713..7a90176 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1438,6 +1438,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule( } // output files for custom command std::stringstream outputs; + bool symbolic = false; { const char* sep = ""; for (std::string const& o : ccg.GetOutputs()) { @@ -1445,6 +1446,12 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule( ConvertToWindowsSlash(out); outputs << sep << out; sep = ";"; + if (!symbolic) { + if (cmSourceFile* sf = this->Makefile->GetSource( + o, cmSourceFileLocationKind::Known)) { + symbolic = sf->GetPropertyAsBool("SYMBOLIC"); + } + } } } if (this->ProjectType == csproj) { @@ -1454,7 +1461,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule( outputs.str(), comment); } else { this->WriteCustomRuleCpp(*spe2, c, script, additional_inputs.str(), - outputs.str(), comment); + outputs.str(), comment, symbolic); } } } @@ -1462,7 +1469,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule( void cmVisualStudio10TargetGenerator::WriteCustomRuleCpp( Elem& e2, std::string const& config, std::string const& script, std::string const& additional_inputs, std::string const& outputs, - std::string const& comment) + std::string const& comment, bool symbolic) { const std::string cond = this->CalcCondition(config); e2.WritePlatformConfigTag("Message", cond, comment); @@ -1474,6 +1481,13 @@ void cmVisualStudio10TargetGenerator::WriteCustomRuleCpp( // VS >= 11 let us turn off linking of custom command outputs. e2.WritePlatformConfigTag("LinkObjects", cond, "false"); } + if (symbolic && + this->LocalGenerator->GetVersion() >= + cmGlobalVisualStudioGenerator::VS16) { + // VS >= 16.4 warn if outputs are not created, but one of our + // outputs is marked SYMBOLIC and not expected to be created. + e2.WritePlatformConfigTag("VerifyInputsAndOutputsExist", cond, "false"); + } } void cmVisualStudio10TargetGenerator::WriteCustomRuleCSharp( diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 6607e77..d453d1a 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -142,7 +142,7 @@ private: std::string const& script, std::string const& additional_inputs, std::string const& outputs, - std::string const& comment); + std::string const& comment, bool symbolic); void WriteCustomRuleCSharp(Elem& e0, std::string const& config, std::string const& commandName, std::string const& script, ----------------------------------------------------------------------- Summary of changes: Source/cmVisualStudio10TargetGenerator.cxx | 18 ++++++++++++++++-- Source/cmVisualStudio10TargetGenerator.h | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Wed Sep 25 12:50:50 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 25 Sep 2019 12:50:50 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1190-gb42cb1f Message-ID: <20190925165050.D5BC7109298@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via b42cb1ff80dc056da4036c7b65109d1a77d84bf4 (commit) via 5a35a9c70d1dc92ec70a6ff454bc9441fa410968 (commit) from 76ae4c58394c5ec67916f5031e1fe7afca085cfb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b42cb1ff80dc056da4036c7b65109d1a77d84bf4 commit b42cb1ff80dc056da4036c7b65109d1a77d84bf4 Merge: 76ae4c5 5a35a9c Author: Brad King AuthorDate: Wed Sep 25 12:40:49 2019 -0400 Commit: Brad King CommitDate: Wed Sep 25 12:40:49 2019 -0400 Merge branch 'release-3.15' ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From kwrobot at kitware.com Wed Sep 25 12:50:50 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 25 Sep 2019 12:50:50 -0400 (EDT) Subject: [Cmake-commits] CMake branch, release, updated. v3.15.3-4-g5a35a9c Message-ID: <20190925165050.EE41F11EB33@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, release has been updated via 5a35a9c70d1dc92ec70a6ff454bc9441fa410968 (commit) via 0578239d3a62ffb01a9b8cdb58f704b29725a1ee (commit) from 2f702beca1768292b3ecfc54cefde85cf44d1e61 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: Source/cmVisualStudio10TargetGenerator.cxx | 18 ++++++++++++++++-- Source/cmVisualStudio10TargetGenerator.h | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Thu Sep 26 09:31:09 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 26 Sep 2019 09:31:09 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1197-g5fa625d Message-ID: <20190926133109.5B2CA112533@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 5fa625d611414ac567fd7a6bb5b3b416ea93eca2 (commit) via 67e6b55c5885c445b5b78b41a66529553dcab069 (commit) via 33c7ea513dc8a7e1322c5c37003c7c515bd8ad99 (commit) via 53be31e19c0dc0f517825d1be056c55d7729a4b7 (commit) via 0aa8a2ab8b00c0889df3d0fa1be47ad5a0b9db22 (commit) via d5a6a133680e4d5798522a4b29ae6bced1f2db3a (commit) via b2c67a7703836a0015a7e4bf3837dbb613061a74 (commit) from b42cb1ff80dc056da4036c7b65109d1a77d84bf4 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5fa625d611414ac567fd7a6bb5b3b416ea93eca2 commit 5fa625d611414ac567fd7a6bb5b3b416ea93eca2 Merge: 67e6b55 33c7ea5 Author: Kyle Edwards AuthorDate: Thu Sep 26 13:22:18 2019 +0000 Commit: Kitware Robot CommitDate: Thu Sep 26 09:23:31 2019 -0400 Merge topic 'cpack-DEB-use-CPACK_PACKAGE_DESCRIPTION_FILE' 33c7ea513d CPackDeb: Use `CPACK_PACKAGE_DESCRIPTION_FILE` 53be31e19c Refactor: Use `list` commands instead of old-way string ops b2c67a7703 Style: Remove spaces after command call and `(` Acked-by: Kitware Robot Merge-request: !3541 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=67e6b55c5885c445b5b78b41a66529553dcab069 commit 67e6b55c5885c445b5b78b41a66529553dcab069 Merge: b42cb1f 0aa8a2a Author: Kyle Edwards AuthorDate: Thu Sep 26 13:22:00 2019 +0000 Commit: Kitware Robot CommitDate: Thu Sep 26 09:22:13 2019 -0400 Merge topic 'ctest-argument-parser' 0aa8a2ab8b cmCTest*Command: Port to cmArgumentParser d5a6a13368 cmArgumentParser: Record parsed keywords Acked-by: Kitware Robot Merge-request: !3835 diff --cc Source/CTest/cmCTestCoverageCommand.h index 75aefdf,f7b6315..fcffa75 --- a/Source/CTest/cmCTestCoverageCommand.h +++ b/Source/CTest/cmCTestCoverageCommand.h @@@ -8,11 -8,11 +8,11 @@@ #include "cmCTestHandlerCommand.h" #include "cmCommand.h" - #include #include #include + #include -#include "cm_memory.hxx" +#include class cmCTestGenericHandler; diff --cc Source/CTest/cmCTestMemCheckCommand.h index 5dad4e7,200cc2e..8f4ffb8 --- a/Source/CTest/cmCTestMemCheckCommand.h +++ b/Source/CTest/cmCTestMemCheckCommand.h @@@ -5,9 -5,10 +5,10 @@@ #include "cmConfigure.h" // IWYU pragma: keep + #include #include -#include "cm_memory.hxx" +#include #include "cmCTestTestCommand.h" #include "cmCommand.h" diff --cc Source/CTest/cmCTestUploadCommand.h index 39314f2,a962497..f78f0ec --- a/Source/CTest/cmCTestUploadCommand.h +++ b/Source/CTest/cmCTestUploadCommand.h @@@ -8,11 -8,11 +8,11 @@@ #include "cmCTestHandlerCommand.h" #include "cmCommand.h" - #include #include #include + #include -#include "cm_memory.hxx" +#include class cmCTestGenericHandler; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=33c7ea513dc8a7e1322c5c37003c7c515bd8ad99 commit 33c7ea513dc8a7e1322c5c37003c7c515bd8ad99 Author: Alex Turbov AuthorDate: Thu Jul 11 19:31:59 2019 +0300 Commit: Alex Turbov CommitDate: Sun Sep 22 00:31:24 2019 +0200 CPackDeb: Use `CPACK_PACKAGE_DESCRIPTION_FILE` Also, handle per-component description nicely. diff --git a/Help/cpack_gen/deb.rst b/Help/cpack_gen/deb.rst index 23f0515..db71c87 100644 --- a/Help/cpack_gen/deb.rst +++ b/Help/cpack_gen/deb.rst @@ -179,16 +179,24 @@ List of CPack DEB generator specific variables: * Default : ``CPACK_PACKAGE_CONTACT`` .. variable:: CPACK_DEBIAN_PACKAGE_DESCRIPTION - CPACK_COMPONENT__DESCRIPTION + CPACK_DEBIAN__DESCRIPTION The Debian package description * Mandatory : YES * Default : - - :variable:`CPACK_DEBIAN_PACKAGE_DESCRIPTION` if set or - - :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY` + - :variable:`CPACK_DEBIAN__DESCRIPTION` (component + based installers only) if set, or :variable:`CPACK_DEBIAN_PACKAGE_DESCRIPTION` if set, or + - :variable:`CPACK_COMPONENT__DESCRIPTION` (component + based installers only) if set, or :variable:`CPACK_PACKAGE_DESCRIPTION` if set, or + - content of the file specified in :variable:`CPACK_PACKAGE_DESCRIPTION_FILE` if set + If after that description is not set, :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY` going to be + used if set. Otherwise, :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY` will be added as the first + line of description as defined in `Debian Policy Manual`_. + +.. _Debian Policy Manual: https://www.debian.org/doc/debian-policy/ch-controlfields.html#description .. variable:: CPACK_DEBIAN_PACKAGE_SECTION CPACK_DEBIAN__PACKAGE_SECTION diff --git a/Modules/Internal/CPack/CPackDeb.cmake b/Modules/Internal/CPack/CPackDeb.cmake index e22f623..ad8e078 100644 --- a/Modules/Internal/CPack/CPackDeb.cmake +++ b/Modules/Internal/CPack/CPackDeb.cmake @@ -56,6 +56,67 @@ function(extract_so_info shared_object libname version) endif() endfunction() +function(cpack_deb_check_description SUMMARY LINES RESULT_VARIABLE) + set(_result TRUE) + + # Get the summary line + if(NOT SUMMARY MATCHES "^[^\\s].*$") + set(_result FALSE) + set(${RESULT_VARIABLE} ${_result} PARENT_SCOPE) + return() + endif() + + foreach(_line IN LISTS LINES) + if(NOT _line MATCHES "^ +[^ ]+.*$") + set(_result FALSE) + break() + endif() + endforeach() + + set(${RESULT_VARIABLE} ${_result} PARENT_SCOPE) +endfunction() + +function(cpack_deb_format_package_description TEXT OUTPUT_VAR) + # Turn the possible multi-line string into a list + string(UUID uuid NAMESPACE 00000000-0000-0000-0000-000000000000 TYPE SHA1) + string(REPLACE ";" "${uuid}" _text "${TEXT}") + string(REPLACE "\n" ";" _lines "${_text}") + list(POP_FRONT _lines _summary) + + # Check if reformatting required + cpack_deb_check_description("${_summary}" "${_lines}" _result) + if(_result) + # Ok, no formatting required + set(${OUTPUT_VAR} "${TEXT}" PARENT_SCOPE) + return() + endif() + + # Format the summary line + string(STRIP "${_summary}" _summary) + + # Make sure the rest formatted properly + set(_result) + foreach(_line IN LISTS _lines) + string(STRIP "${_line}" _line_strip) + if(NOT _line_strip) + # Replace empty lines w/ a _single full stop character_ + set(_line " .") + else() + # Prepend the normal lines w/ a single space. + # If the line already starts w/ at least one space, + # it'll become _verbatim_ (assuming it supposed to be + # verbatim in the original text). + string(PREPEND _line " ") + endif() + list(APPEND _result "${_line}") + endforeach() + + list(PREPEND _result "${_summary}") + list(JOIN _result "\n" _result) + string(REPLACE "${uuid}" ";" _result "${_result}") + set(${OUTPUT_VAR} "${_result}" PARENT_SCOPE) +endfunction() + function(cpack_deb_prepare_package_vars) # CPACK_DEBIAN_PACKAGE_SHLIBDEPS # If specify OFF, only user depends are used @@ -436,26 +497,53 @@ function(cpack_deb_prepare_package_vars) endif() # Description: (mandatory) - if(NOT CPACK_DEB_PACKAGE_COMPONENT) - if(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION) - if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) - message(FATAL_ERROR "CPackDeb: Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION") - endif() - set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) - endif() + # Try package description first + if(CPACK_DEB_PACKAGE_COMPONENT) + cpack_deb_variable_fallback("CPACK_DEBIAN_PACKAGE_DESCRIPTION" + "CPACK_DEBIAN_${_local_component_name}_DESCRIPTION" + "CPACK_COMPONENT_${_local_component_name}_DESCRIPTION") else() - set(component_description_var CPACK_COMPONENT_${_local_component_name}_DESCRIPTION) - - # component description overrides package description - if(${component_description_var}) - set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${${component_description_var}}) - elseif(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION) - if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) - message(FATAL_ERROR "CPackDeb: Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION or ${component_description_var}") - endif() + cpack_deb_variable_fallback("CPACK_DEBIAN_PACKAGE_DESCRIPTION" + "CPACK_DEBIAN_PACKAGE_DESCRIPTION" + "CPACK_PACKAGE_DESCRIPTION") + endif() + + # Still no description? ... and description file has set ... + if(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION AND CPACK_PACKAGE_DESCRIPTION_FILE) + # Read `CPACK_PACKAGE_DESCRIPTION_FILE` then... + file(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_DEBIAN_PACKAGE_DESCRIPTION) + endif() + + # Still no description? #2 + if(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION) + # Try to get `CPACK_PACKAGE_DESCRIPTION_SUMMARY` as the last hope + if(CPACK_PACKAGE_DESCRIPTION_SUMMARY) set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) + else() + # Giving up! Report an error... + set(_description_failure_message + "CPackDeb: Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION") + if(CPACK_DEB_PACKAGE_COMPONENT) + string(APPEND _description_failure_message + " or CPACK_DEBIAN_${_local_component_name}_DESCRIPTION") + endif() + message(FATAL_ERROR _description_failure_message) endif() + + # Ok, description has set. According to the `Debian Policy Manual`_ the frist + # line is a pacakge summary. Try to get it as well... + # See also: https://www.debian.org/doc/debian-policy/ch-controlfields.html#description + elseif(CPACK_PACKAGE_DESCRIPTION_SUMMARY) + # Merge summary w/ the detailed description + string(PREPEND CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}\n") endif() + # assert(CPACK_DEBIAN_PACKAGE_DESCRIPTION) + + # Make sure description is properly formatted + cpack_deb_format_package_description( + "${CPACK_DEBIAN_PACKAGE_DESCRIPTION}" + CPACK_DEBIAN_PACKAGE_DESCRIPTION + ) # Homepage: (optional) if(NOT CPACK_DEBIAN_PACKAGE_HOMEPAGE AND CMAKE_PROJECT_HOMEPAGE_URL) diff --git a/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description1.cmake.in b/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description1.cmake.in index 74d816c..67b108b 100644 --- a/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description1.cmake.in +++ b/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description1.cmake.in @@ -15,8 +15,9 @@ set(CPACK_COMPONENTS_IGNORE_GROUPS 1) #set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1) # overriding previous descriptions -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "main description") -set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION "applications_description") -set(CPACK_COMPONENT_HEADERS_DESCRIPTION "headers_description") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "main description") # This become a summary line (the first one) of all descriptions +set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION "applications_description") +set(CPACK_COMPONENT_HEADERS_DESCRIPTION "headers_description") # libraries does not have any description and should inherit from CPACK_PACKAGE_DESCRIPTION_SUMMARY +# plus content of the `CPACK_PACKAGE_DESCRIPTION_FILE`. unset(CPACK_COMPONENT_LIBRARIES_DESCRIPTION) diff --git a/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description2.cmake.in b/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description2.cmake.in index cda79bc..d877325 100644 --- a/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description2.cmake.in +++ b/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description2.cmake.in @@ -15,12 +15,12 @@ set(CPACK_COMPONENTS_IGNORE_GROUPS 1) #set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1) # overriding previous descriptions -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "main description 2") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "main description 2") -# Components do not have any description +# Components do not have any description. +# So, content of `CPACK_PACKAGE_DESCRIPTION_FILE` gonna used +# after summary line. unset(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION) unset(CPACK_COMPONENT_HEADERS_DESCRIPTION) -unset(CPACK_COMPONENT_LIBRARIES_DESCRIPTION) - -set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION "library description") +set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION "library description") diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake index f74137c..86a74b2 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake @@ -48,26 +48,26 @@ if(DPKGDEB_EXECUTABLE) DPKGDEB_OUTPUT "${dpkg_output}" METAENTRY "Package:") - dpkgdeb_return_specific_metaentry(dpkg_description - DPKGDEB_OUTPUT "${dpkg_output}" - METAENTRY "Description:") + get_package_description("${dpkg_output}" dpkg_description) message(STATUS "package='${dpkg_package_name}', description='${dpkg_description}'") if(dpkg_package_name STREQUAL "mylib-applications") - if(NOT "${dpkg_description}" STREQUAL "applications_description") + set(expected_description "main description\n applications_description") + if(NOT dpkg_description STREQUAL expected_description) set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all} - "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: ${dpkg_description} != applications_description") + "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: `${dpkg_description}` != `${expected_description}`") endif() elseif(dpkg_package_name STREQUAL "mylib-headers") - if(NOT dpkg_description STREQUAL "headers_description") + set(expected_description "main description\n headers_description") + if(NOT dpkg_description STREQUAL expected_description) set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all} - "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: ${dpkg_description} != headers_description") + "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: `${dpkg_description}` != `${expected_description}`") endif() elseif(dpkg_package_name STREQUAL "mylib-libraries") - if(NOT dpkg_description STREQUAL "main description") + if(NOT dpkg_description MATCHES "main description\n.*") set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all} - "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: ${dpkg_description} != 'main description'") + "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: `${dpkg_description}` =~ `main description.*`") endif() else() set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all} diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake index 241dda5..d53c73d 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake @@ -48,26 +48,20 @@ if(DPKGDEB_EXECUTABLE) DPKGDEB_OUTPUT "${dpkg_output}" METAENTRY "Package:") - dpkgdeb_return_specific_metaentry(dpkg_description - DPKGDEB_OUTPUT "${dpkg_output}" - METAENTRY "Description:") + get_package_description("${dpkg_output}" dpkg_description) message(STATUS "package='${dpkg_package_name}', description='${dpkg_description}'") - if(dpkg_package_name STREQUAL "mylib-applications") - if(NOT dpkg_description STREQUAL "main description 2") - set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all} - "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: ${dpkg_description} != applications_description") - endif() - elseif(dpkg_package_name STREQUAL "mylib-headers") - if(NOT dpkg_description STREQUAL "main description 2") + if(dpkg_package_name STREQUAL "mylib-applications" OR dpkg_package_name STREQUAL "mylib-headers") + if(NOT dpkg_description MATCHES "main description 2\n.*") set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all} - "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: ${dpkg_description} != headers_description") + "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: `${dpkg_description}` =~ `main description 2`") endif() elseif(dpkg_package_name STREQUAL "mylib-libraries") - if(NOT dpkg_description STREQUAL "library description") + set(expected_description "main description 2\n library description") + if(NOT dpkg_description STREQUAL expected_description) set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all} - "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: ${dpkg_description} != 'main description'") + "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: `${dpkg_description}` != `${expected_description}`") endif() else() set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all} diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult.cmake index 2093e7e..b172da2 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult.cmake @@ -200,4 +200,29 @@ function(dpkgdeb_return_specific_metaentry output) endif() endfunction() +function(get_package_description DPKG_OUTPUT RESULT_VAR) + string(UUID uuid NAMESPACE 00000000-0000-0000-0000-000000000000 TYPE SHA1) + string(REPLACE ";" "${uuid}" DPKG_OUTPUT "${DPKG_OUTPUT}") + string(REPLACE "\n" ";" DPKG_OUTPUT "${DPKG_OUTPUT}") + + unset(_actual_description) + set(_parse_description FALSE) + foreach(_line IN LISTS DPKG_OUTPUT) + if(_line MATCHES " Description:.*") + set(_parse_description TRUE) + string(REPLACE " Description: " "" _line "${_line}") + list(APPEND _actual_description "${_line}") + elseif(_parse_description) + if(_line MATCHES " [A-Z][A-Za-z\-]+: .*") + set(_parse_description FALSE) + else() + list(APPEND _actual_description "${_line}") + endif() + endif() + endforeach() + list(JOIN _actual_description "\n" _actual_description) + + set(${RESULT_VAR} "${_actual_description}" PARENT_SCOPE) +endfunction() + cmake_policy(POP) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 8fd5234..13fbecf 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -510,6 +510,7 @@ set(cpack_tests DEB.TIMESTAMPS DEB.MD5SUMS DEB.DEB_PACKAGE_VERSION_BACK_COMPATIBILITY + DEB.DEB_DESCRIPTION RPM.CUSTOM_BINARY_SPEC_FILE RPM.CUSTOM_NAMES diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 8e98961..b0b7a99 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -39,3 +39,10 @@ run_cpack_test_subtests(EXTERNAL "none;good;good_multi;bad_major;bad_minor;inval if(RunCMake_GENERATOR MATCHES "Visual Studio|Xcode") run_cpack_test(CPACK_INSTALL_CMAKE_CONFIGURATIONS "ZIP" false "MONOLITHIC") endif() +run_cpack_test_subtests( + DEB_DESCRIPTION + "CPACK_DEBIAN_PACKAGE_DESCRIPTION;CPACK_PACKAGE_DESCRIPTION;CPACK_PACKAGE_DESCRIPTION_FILE" + "DEB.DEB_DESCRIPTION" + false + "MONOLITHIC;COMPONENT" +) diff --git a/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/ExpectedFiles.cmake new file mode 100644 index 0000000..39f18a3 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/ExpectedFiles.cmake @@ -0,0 +1,16 @@ +set(EXPECTED_FILES_COUNT_MONOLITHIC "1") +set(EXPECTED_FILES_COUNT_COMPONENT "2") +set(EXPECTED_FILES_COUNT "${EXPECTED_FILES_COUNT_${PACKAGING_TYPE}}") + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(EXPECTED_FILE_1 "deb_description-0.1.1-*-satu.deb") + set(EXPECTED_FILE_2 "deb_description-0.1.1-*-dua.deb") + set(EXPECTED_FILE_CONTENT_1_LIST "/satu;/satu/CMakeLists.txt") + set(EXPECTED_FILE_CONTENT_2_LIST "/dua;/dua/CMakeLists.txt") + +elseif(PACKAGING_TYPE STREQUAL "MONOLITHIC") + set(EXPECTED_FILE_CONTENT_1_LIST "/dua;/dua/CMakeLists.txt;/satu;/satu/CMakeLists.txt") + +endif() + +# kate: indent-width 2; diff --git a/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake new file mode 100644 index 0000000..e9ac13a --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake @@ -0,0 +1,65 @@ +function(checkPackageDescription FILE EXPECTED_DESCRIPTION) + getPackageInfo("${FILE}" "_file_info") + string(UUID uuid NAMESPACE 00000000-0000-0000-0000-000000000000 TYPE SHA1) + string(REPLACE ";" "${uuid}" _file_info "${_file_info}") + string(REPLACE ";" "${uuid}" EXPECTED_DESCRIPTION "${EXPECTED_DESCRIPTION}") + string(REPLACE "\n" ";" _file_info "${_file_info}") + + set(_actual_description) + set(_parse_description FALSE) + foreach(_line IN LISTS _file_info) + if(_line MATCHES " Description:.*") + set(_parse_description TRUE) + list(APPEND _actual_description "${_line}") + elseif(_parse_description) + if(_line MATCHES " [A-Z][A-Za-z\-]+: .*") + set(_parse_description FALSE) + else() + list(APPEND _actual_description "${_line}") + endif() + endif() + endforeach() + list(JOIN _actual_description "\n" _actual_description) + + if(NOT _actual_description STREQUAL EXPECTED_DESCRIPTION) + set(_error "---[BEGIN Expected description]---\n${EXPECTED_DESCRIPTION}---[END Expected description]---\n") + string(APPEND _error "---[BEGIN Actual description]---\n${_actual_description}---[END Actual description]---\n") + string(REPLACE "${uuid}" ";" _error "${_error}") + message(FATAL_ERROR "${_error}") + endif() +endfunction() + +# ALERT The output of `dpkg -I *.deb` indented by one space +set(_expected_description [[ Description: This is the summary line + This is the Debian package multiline description. + . + It must be formatted properly! Otherwise, the result `*.deb` + package become broken and cant be installed! + . + It may contains `;` characters (even like this `;;;;`). Example: + . + - one; + - two; + - three; + . + ... and they are properly handled by the automatic description formatter! + . + See also: https://www.debian.org/doc/debian-policy/ch-controlfields.html#description]]) + +# ATTENTION The code in `cmCPackGenerator.cxx` to read `CPACK_PACKAGE_DESCRIPTION_FILE` +# has a BUG: it appends the `\n` character to every line of the +# input, even if there was no EOL (e.g. at the last line of the file). +# That is WHY for this sub-test the one more pre-formatted "empty" +# line required! +# NOTE For component based installers content of the file gonna read by +# `CPackDeb` module and the `file(READ...)` command so no the mentioned +# workaround required! +if(RunCMake_SUBTEST_SUFFIX STREQUAL "CPACK_PACKAGE_DESCRIPTION_FILE" AND PACKAGING_TYPE STREQUAL "MONOLITHIC") + string(APPEND _expected_description "\n ." ) +endif() + +foreach(_file_no RANGE 1 ${EXPECTED_FILES_COUNT}) + checkPackageDescription("${FOUND_FILE_${_file_no}}" "${_expected_description}") +endforeach() + +# kate: indent-width 2; diff --git a/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/test.cmake b/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/test.cmake new file mode 100644 index 0000000..ce3f651 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/test.cmake @@ -0,0 +1,45 @@ +install(FILES CMakeLists.txt DESTINATION satu COMPONENT satu) +install(FILES CMakeLists.txt DESTINATION dua COMPONENT dua) + +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "This is the summary line") +set(_description [[This is the Debian package multiline description. + +It must be formatted properly! Otherwise, the result `*.deb` +package become broken and cant be installed! + +It may contains `;` characters (even like this `;;;;`). Example: + + - one; + - two; + - three; + +... and they are properly handled by the automatic description formatter! + +See also: https://www.debian.org/doc/debian-policy/ch-controlfields.html#description]]) + +if(RunCMake_SUBTEST_SUFFIX STREQUAL "CPACK_DEBIAN_PACKAGE_DESCRIPTION") + if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(CPACK_DEBIAN_SATU_DESCRIPTION "${_description}") + set(CPACK_DEBIAN_DUA_DESCRIPTION "${_description}") + else() + set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${_description}") + endif() + +elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "CPACK_PACKAGE_DESCRIPTION") + # NOTE Documented fallback variable + if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(CPACK_COMPONENT_SATU_DESCRIPTION "${_description}") + set(CPACK_COMPONENT_DUA_DESCRIPTION "${_description}") + else() + set(CPACK_PACKAGE_DESCRIPTION "${_description}") + endif() + +elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "CPACK_PACKAGE_DESCRIPTION_FILE") + # NOTE Getting the description from the file + set(_file "${CMAKE_CURRENT_BINARY_DIR}/description.txt") + file(WRITE "${_file}" "${_description}") + set(CPACK_PACKAGE_DESCRIPTION_FILE "${_file}") + +endif() + +# kate: indent-width 2; diff --git a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake index b4bdb61..c47b40e 100644 --- a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake @@ -8,6 +8,9 @@ endfunction() if(GENERATOR_TYPE STREQUAL "DEB") set(name_ "Package") set(group_ "Section") + # NOTE For a Debian package the first line of the `Description` + # field is generated by CMake and gonna be ignored + set(ignore_rest_cond_ ".*\n") elseif(GENERATOR_TYPE STREQUAL "RPM") set(name_ "Name") set(group_ "Group") @@ -33,6 +36,6 @@ if(GENERATOR_TYPE STREQUAL "RPM") endif() # check package description -checkPackageInfo_("description" "${FOUND_FILE_1}" ".*Description${whitespaces_}:${whitespaces_}Description for pkg_1") -checkPackageInfo_("description" "${FOUND_FILE_2}" ".*Description${whitespaces_}:${whitespaces_}Description for pkg_2") -checkPackageInfo_("description" "${FOUND_FILE_3}" ".*Description${whitespaces_}:${whitespaces_}Description for pkg_3") +checkPackageInfo_("description" "${FOUND_FILE_1}" ".*Description${whitespaces_}:${ignore_rest_cond_}${whitespaces_}Description for pkg_1") +checkPackageInfo_("description" "${FOUND_FILE_2}" ".*Description${whitespaces_}:${ignore_rest_cond_}${whitespaces_}Description for pkg_2") +checkPackageInfo_("description" "${FOUND_FILE_3}" ".*Description${whitespaces_}:${ignore_rest_cond_}${whitespaces_}Description for pkg_3") https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=53be31e19c0dc0f517825d1be056c55d7729a4b7 commit 53be31e19c0dc0f517825d1be056c55d7729a4b7 Author: Alex Turbov AuthorDate: Thu Jul 11 02:26:48 2019 +0300 Commit: Alex Turbov CommitDate: Sat Sep 21 23:06:30 2019 +0200 Refactor: Use `list` commands instead of old-way string ops diff --git a/Modules/Internal/CPack/CPackDeb.cmake b/Modules/Internal/CPack/CPackDeb.cmake index 51e505b..e22f623 100644 --- a/Modules/Internal/CPack/CPackDeb.cmake +++ b/Modules/Internal/CPack/CPackDeb.cmake @@ -210,7 +210,7 @@ function(cpack_deb_prepare_package_vars) if(_TMP_VERSION MATCHES "dpkg-shlibdeps version ([0-9]+\\.[0-9]+\\.[0-9]+)") set(SHLIBDEPS_EXECUTABLE_VERSION "${CMAKE_MATCH_1}") else() - set(SHLIBDEPS_EXECUTABLE_VERSION "") + unset(SHLIBDEPS_EXECUTABLE_VERSION) endif() if(CPACK_DEBIAN_PACKAGE_DEBUG) @@ -388,7 +388,7 @@ function(cpack_deb_prepare_package_vars) # if per-component variable, overrides the global CPACK_DEBIAN_PACKAGE_${variable_type_} # automatic dependency discovery will be performed afterwards. if(CPACK_DEB_PACKAGE_COMPONENT) - foreach(value_type_ DEPENDS RECOMMENDS SUGGESTS PREDEPENDS ENHANCES BREAKS CONFLICTS PROVIDES REPLACES SOURCE SECTION PRIORITY NAME) + foreach(value_type_ IN ITEMS DEPENDS RECOMMENDS SUGGESTS PREDEPENDS ENHANCES BREAKS CONFLICTS PROVIDES REPLACES SOURCE SECTION PRIORITY NAME) set(_component_var "CPACK_DEBIAN_${_local_component_name}_PACKAGE_${value_type_}") # if set, overrides the global variable @@ -402,21 +402,15 @@ function(cpack_deb_prepare_package_vars) endforeach() if(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS) - set(COMPONENT_DEPENDS "") - foreach(_PACK ${CPACK_COMPONENT_${_local_component_name}_DEPENDS}) + unset(COMPONENT_DEPENDS) + foreach(_PACK IN LISTS CPACK_COMPONENT_${_local_component_name}_DEPENDS) get_component_package_name(_PACK_NAME "${_PACK}") - if(COMPONENT_DEPENDS) - set(COMPONENT_DEPENDS "${_PACK_NAME} (= ${CPACK_DEBIAN_PACKAGE_VERSION}), ${COMPONENT_DEPENDS}") - else() - set(COMPONENT_DEPENDS "${_PACK_NAME} (= ${CPACK_DEBIAN_PACKAGE_VERSION})") - endif() + list(PREPEND COMPONENT_DEPENDS "${_PACK_NAME} (= ${CPACK_DEBIAN_PACKAGE_VERSION})") endforeach() + list(JOIN COMPONENT_DEPENDS ", " COMPONENT_DEPENDS) if(COMPONENT_DEPENDS) - if(CPACK_DEBIAN_PACKAGE_DEPENDS) - set(CPACK_DEBIAN_PACKAGE_DEPENDS "${COMPONENT_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_DEPENDS}") - else() - set(CPACK_DEBIAN_PACKAGE_DEPENDS "${COMPONENT_DEPENDS}") - endif() + list(PREPEND CPACK_DEBIAN_PACKAGE_DEPENDS ${COMPONENT_DEPENDS}) + list(JOIN CPACK_DEBIAN_PACKAGE_DEPENDS ", " CPACK_DEBIAN_PACKAGE_DEPENDS) endif() endif() endif() @@ -424,12 +418,9 @@ function(cpack_deb_prepare_package_vars) # at this point, the CPACK_DEBIAN_PACKAGE_DEPENDS is properly set # to the minimal dependency of the package # Append automatically discovered dependencies . - if(NOT "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}" STREQUAL "") - if(CPACK_DEBIAN_PACKAGE_DEPENDS) - set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}") - else() - set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}") - endif() + if(CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS) + list(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}) + list(JOIN CPACK_DEBIAN_PACKAGE_DEPENDS ", " CPACK_DEBIAN_PACKAGE_DEPENDS) endif() if(NOT CPACK_DEBIAN_PACKAGE_DEPENDS) @@ -519,7 +510,7 @@ function(cpack_deb_prepare_package_vars) # Are we packaging components ? if(CPACK_DEB_PACKAGE_COMPONENT) # override values with per component version if set - foreach(VAR_NAME_ "PACKAGE_CONTROL_EXTRA" "PACKAGE_CONTROL_STRICT_PERMISSION") + foreach(VAR_NAME_ IN ITEMS PACKAGE_CONTROL_EXTRA PACKAGE_CONTROL_STRICT_PERMISSION) if(CPACK_DEBIAN_${_local_component_name}_${VAR_NAME_}) set(CPACK_DEBIAN_${VAR_NAME_} "${CPACK_DEBIAN_${_local_component_name}_${VAR_NAME_}}") endif() @@ -527,12 +518,12 @@ function(cpack_deb_prepare_package_vars) get_component_package_name(CPACK_DEBIAN_PACKAGE_NAME ${_local_component_name}) endif() - set(CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "") - if(NOT CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY) set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY "=") endif() + unset(CPACK_DEBIAN_PACKAGE_SHLIBS_LIST) + if(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS) if(READELF_EXECUTABLE) foreach(_FILE IN LISTS CPACK_DEB_SHARED_OBJECT_FILES) @@ -544,9 +535,7 @@ function(cpack_deb_prepare_package_vars) message(AUTHOR_WARNING "Shared library '${_FILE}' is missing soname or soversion. Library will not be added to DEBIAN/shlibs control file.") endif() endforeach() - if(CPACK_DEBIAN_PACKAGE_SHLIBS_LIST) - string(REPLACE ";" "\n" CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "${CPACK_DEBIAN_PACKAGE_SHLIBS_LIST}") - endif() + list(JOIN CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "\n" CPACK_DEBIAN_PACKAGE_SHLIBS_LIST) else() message(FATAL_ERROR "Readelf utility is not available. CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS option is not available.") endif() @@ -554,7 +543,7 @@ function(cpack_deb_prepare_package_vars) # add ldconfig call in default postrm and postint set(CPACK_ADD_LDCONFIG_CALL 0) - foreach(_FILE ${CPACK_DEB_SHARED_OBJECT_FILES}) + foreach(_FILE IN LISTS CPACK_DEB_SHARED_OBJECT_FILES) get_filename_component(_DIR ${_FILE} DIRECTORY) # all files in CPACK_DEB_SHARED_OBJECT_FILES have dot at the beginning if(_DIR STREQUAL "./lib" OR _DIR STREQUAL "./usr/lib") @@ -565,12 +554,12 @@ function(cpack_deb_prepare_package_vars) if(CPACK_ADD_LDCONFIG_CALL) set(CPACK_DEBIAN_GENERATE_POSTINST 1) set(CPACK_DEBIAN_GENERATE_POSTRM 1) - foreach(f ${PACKAGE_CONTROL_EXTRA}) + foreach(f IN LISTS PACKAGE_CONTROL_EXTRA) get_filename_component(n "${f}" NAME) - if("${n}" STREQUAL "postinst") + if(n STREQUAL "postinst") set(CPACK_DEBIAN_GENERATE_POSTINST 0) endif() - if("${n}" STREQUAL "postrm") + if(n STREQUAL "postrm") set(CPACK_DEBIAN_GENERATE_POSTRM 0) endif() endforeach() @@ -671,7 +660,7 @@ function(cpack_deb_prepare_package_vars) if(BUILD_IDS) set(GEN_DBGSYMDIR "${DBGSYMDIR}" PARENT_SCOPE) set(GEN_CPACK_DBGSYM_OUTPUT_FILE_NAME "${CPACK_DBGSYM_OUTPUT_FILE_NAME}" PARENT_SCOPE) - string(REPLACE ";" " " BUILD_IDS "${BUILD_IDS}") + list(JOIN BUILD_IDS " " BUILD_IDS) set(GEN_BUILD_IDS "${BUILD_IDS}" PARENT_SCOPE) endif() endfunction() https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0aa8a2ab8b00c0889df3d0fa1be47ad5a0b9db22 commit 0aa8a2ab8b00c0889df3d0fa1be47ad5a0b9db22 Author: Regina Pfeifer AuthorDate: Thu Sep 19 13:11:55 2019 +0200 Commit: Regina Pfeifer CommitDate: Fri Sep 20 13:27:30 2019 +0200 cmCTest*Command: Port to cmArgumentParser diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index 02b00e3..ce690f9 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -9,6 +9,7 @@ #include "cmMessageType.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" +#include "cm_static_string_view.hxx" #include "cmake.h" #include @@ -16,17 +17,15 @@ class cmExecutionStatus; -cmCTestBuildCommand::cmCTestBuildCommand() +void cmCTestBuildCommand::BindArguments() { - this->GlobalGenerator = nullptr; - this->Arguments[ctb_NUMBER_ERRORS] = "NUMBER_ERRORS"; - this->Arguments[ctb_NUMBER_WARNINGS] = "NUMBER_WARNINGS"; - this->Arguments[ctb_TARGET] = "TARGET"; - this->Arguments[ctb_CONFIGURATION] = "CONFIGURATION"; - this->Arguments[ctb_FLAGS] = "FLAGS"; - this->Arguments[ctb_PROJECT_NAME] = "PROJECT_NAME"; - this->Arguments[ctb_LAST] = nullptr; - this->Last = ctb_LAST; + this->cmCTestHandlerCommand::BindArguments(); + this->Bind("NUMBER_ERRORS"_s, this->NumberErrors); + this->Bind("NUMBER_WARNINGS"_s, this->NumberWarnings); + this->Bind("TARGET"_s, this->Target); + this->Bind("CONFIGURATION"_s, this->Configuration); + this->Bind("FLAGS"_s, this->Flags); + this->Bind("PROJECT_NAME"_s, this->ProjectName); } cmCTestBuildCommand::~cmCTestBuildCommand() @@ -60,20 +59,17 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() // const char* ctestBuildConfiguration = this->Makefile->GetDefinition("CTEST_BUILD_CONFIGURATION"); - const char* cmakeBuildConfiguration = - (this->Values[ctb_CONFIGURATION] && *this->Values[ctb_CONFIGURATION]) - ? this->Values[ctb_CONFIGURATION] + const char* cmakeBuildConfiguration = !this->Configuration.empty() + ? this->Configuration.c_str() : ((ctestBuildConfiguration && *ctestBuildConfiguration) ? ctestBuildConfiguration : this->CTest->GetConfigType().c_str()); - const char* cmakeBuildAdditionalFlags = - (this->Values[ctb_FLAGS] && *this->Values[ctb_FLAGS]) - ? this->Values[ctb_FLAGS] + const char* cmakeBuildAdditionalFlags = !this->Flags.empty() + ? this->Flags.c_str() : this->Makefile->GetDefinition("CTEST_BUILD_FLAGS"); - const char* cmakeBuildTarget = - (this->Values[ctb_TARGET] && *this->Values[ctb_TARGET]) - ? this->Values[ctb_TARGET] + const char* cmakeBuildTarget = !this->Target.empty() + ? this->Target.c_str() : this->Makefile->GetDefinition("CTEST_BUILD_TARGET"); if (cmakeGeneratorName && *cmakeGeneratorName) { @@ -153,16 +149,13 @@ bool cmCTestBuildCommand::InitialPass(std::vector const& args, cmExecutionStatus& status) { bool ret = cmCTestHandlerCommand::InitialPass(args, status); - if (this->Values[ctb_NUMBER_ERRORS] && *this->Values[ctb_NUMBER_ERRORS]) { + if (!this->NumberErrors.empty()) { this->Makefile->AddDefinition( - this->Values[ctb_NUMBER_ERRORS], - std::to_string(this->Handler->GetTotalErrors())); + this->NumberErrors, std::to_string(this->Handler->GetTotalErrors())); } - if (this->Values[ctb_NUMBER_WARNINGS] && - *this->Values[ctb_NUMBER_WARNINGS]) { + if (!this->NumberWarnings.empty()) { this->Makefile->AddDefinition( - this->Values[ctb_NUMBER_WARNINGS], - std::to_string(this->Handler->GetTotalWarnings())); + this->NumberWarnings, std::to_string(this->Handler->GetTotalWarnings())); } return ret; } diff --git a/Source/CTest/cmCTestBuildCommand.h b/Source/CTest/cmCTestBuildCommand.h index a62c301..2c1f9fb 100644 --- a/Source/CTest/cmCTestBuildCommand.h +++ b/Source/CTest/cmCTestBuildCommand.h @@ -27,7 +27,6 @@ class cmGlobalGenerator; class cmCTestBuildCommand : public cmCTestHandlerCommand { public: - cmCTestBuildCommand(); ~cmCTestBuildCommand() override; /** @@ -49,23 +48,19 @@ public: bool InitialPass(std::vector const& args, cmExecutionStatus& status) override; - cmGlobalGenerator* GlobalGenerator; + cmGlobalGenerator* GlobalGenerator = nullptr; protected: cmCTestBuildHandler* Handler; - enum - { - ctb_BUILD = ct_LAST, - ctb_NUMBER_ERRORS, - ctb_NUMBER_WARNINGS, - ctb_TARGET, - ctb_CONFIGURATION, - ctb_FLAGS, - ctb_PROJECT_NAME, - ctb_LAST - }; - + void BindArguments() override; cmCTestGenericHandler* InitializeHandler() override; + + std::string NumberErrors; + std::string NumberWarnings; + std::string Target; + std::string Configuration; + std::string Flags; + std::string ProjectName; }; #endif diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index 8a56f3d..948b9fb 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -8,25 +8,25 @@ #include "cmMakefile.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" +#include "cm_static_string_view.hxx" #include "cmake.h" #include #include #include -cmCTestConfigureCommand::cmCTestConfigureCommand() +void cmCTestConfigureCommand::BindArguments() { - this->Arguments[ctc_OPTIONS] = "OPTIONS"; - this->Arguments[ctc_LAST] = nullptr; - this->Last = ctc_LAST; + this->cmCTestHandlerCommand::BindArguments(); + this->Bind("OPTIONS"_s, this->Options); } cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() { std::vector options; - if (this->Values[ctc_OPTIONS]) { - cmExpandList(this->Values[ctc_OPTIONS], options); + if (!this->Options.empty()) { + cmExpandList(this->Options, options); } if (this->CTest->GetCTestConfiguration("BuildDirectory").empty()) { diff --git a/Source/CTest/cmCTestConfigureCommand.h b/Source/CTest/cmCTestConfigureCommand.h index 4677c83..f42f192 100644 --- a/Source/CTest/cmCTestConfigureCommand.h +++ b/Source/CTest/cmCTestConfigureCommand.h @@ -23,8 +23,6 @@ class cmCTestGenericHandler; class cmCTestConfigureCommand : public cmCTestHandlerCommand { public: - cmCTestConfigureCommand(); - /** * This is a virtual constructor for the command. */ @@ -42,14 +40,10 @@ public: std::string GetName() const override { return "ctest_configure"; } protected: + void BindArguments() override; cmCTestGenericHandler* InitializeHandler() override; - enum - { - ctc_FIRST = ct_LAST, - ctc_OPTIONS, - ctc_LAST - }; + std::string Options; }; #endif diff --git a/Source/CTest/cmCTestCoverageCommand.cxx b/Source/CTest/cmCTestCoverageCommand.cxx index 07aae76..b66bba7 100644 --- a/Source/CTest/cmCTestCoverageCommand.cxx +++ b/Source/CTest/cmCTestCoverageCommand.cxx @@ -2,14 +2,26 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestCoverageCommand.h" +#include + +#include "cmAlgorithms.h" #include "cmCTest.h" #include "cmCTestCoverageHandler.h" +#include "cm_static_string_view.hxx" class cmCTestGenericHandler; -cmCTestCoverageCommand::cmCTestCoverageCommand() +void cmCTestCoverageCommand::BindArguments() +{ + this->cmCTestHandlerCommand::BindArguments(); + this->Bind("LABELS"_s, this->Labels); +} + +void cmCTestCoverageCommand::CheckArguments( + std::vector const& keywords) { - this->LabelsMentioned = false; + this->LabelsMentioned = + !this->Labels.empty() || cmContains(keywords, "LABELS"); } cmCTestGenericHandler* cmCTestCoverageCommand::InitializeHandler() @@ -24,34 +36,10 @@ cmCTestGenericHandler* cmCTestCoverageCommand::InitializeHandler() // If a LABELS option was given, select only files with the labels. if (this->LabelsMentioned) { - handler->SetLabelFilter(this->Labels); + handler->SetLabelFilter( + std::set(this->Labels.begin(), this->Labels.end())); } handler->SetQuiet(this->Quiet); return handler; } - -bool cmCTestCoverageCommand::CheckArgumentKeyword(std::string const& arg) -{ - // Look for arguments specific to this command. - if (arg == "LABELS") { - this->ArgumentDoing = ArgumentDoingLabels; - this->LabelsMentioned = true; - return true; - } - - // Look for other arguments. - return this->Superclass::CheckArgumentKeyword(arg); -} - -bool cmCTestCoverageCommand::CheckArgumentValue(std::string const& arg) -{ - // Handle states specific to this command. - if (this->ArgumentDoing == ArgumentDoingLabels) { - this->Labels.insert(arg); - return true; - } - - // Look for other arguments. - return this->Superclass::CheckArgumentValue(arg); -} diff --git a/Source/CTest/cmCTestCoverageCommand.h b/Source/CTest/cmCTestCoverageCommand.h index 24b96c0..f7b6315 100644 --- a/Source/CTest/cmCTestCoverageCommand.h +++ b/Source/CTest/cmCTestCoverageCommand.h @@ -8,9 +8,9 @@ #include "cmCTestHandlerCommand.h" #include "cmCommand.h" -#include #include #include +#include #include "cm_memory.hxx" @@ -24,8 +24,6 @@ class cmCTestGenericHandler; class cmCTestCoverageCommand : public cmCTestHandlerCommand { public: - cmCTestCoverageCommand(); - /** * This is a virtual constructor for the command. */ @@ -42,22 +40,13 @@ public: */ std::string GetName() const override { return "ctest_coverage"; } - using Superclass = cmCTestHandlerCommand; - protected: + void BindArguments() override; + void CheckArguments(std::vector const& keywords) override; cmCTestGenericHandler* InitializeHandler() override; - bool CheckArgumentKeyword(std::string const& arg) override; - bool CheckArgumentValue(std::string const& arg) override; - - enum - { - ArgumentDoingLabels = Superclass::ArgumentDoingLast1, - ArgumentDoingLast2 - }; - bool LabelsMentioned; - std::set Labels; + std::vector Labels; }; #endif diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx index 9c5425d..3f9ce4e 100644 --- a/Source/CTest/cmCTestHandlerCommand.cxx +++ b/Source/CTest/cmCTestHandlerCommand.cxx @@ -7,31 +7,16 @@ #include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmWorkingDirectory.h" +#include "cm_static_string_view.hxx" +#include #include #include #include -cmCTestHandlerCommand::cmCTestHandlerCommand() -{ - const size_t INIT_SIZE = 100; - size_t cc; - this->Arguments.reserve(INIT_SIZE); - for (cc = 0; cc < INIT_SIZE; ++cc) { - this->Arguments.push_back(nullptr); - } - this->Arguments[ct_RETURN_VALUE] = "RETURN_VALUE"; - this->Arguments[ct_CAPTURE_CMAKE_ERROR] = "CAPTURE_CMAKE_ERROR"; - this->Arguments[ct_SOURCE] = "SOURCE"; - this->Arguments[ct_BUILD] = "BUILD"; - this->Arguments[ct_SUBMIT_INDEX] = "SUBMIT_INDEX"; - this->Last = ct_LAST; - this->AppendXML = false; - this->Quiet = false; -} - namespace { // class to save and restore the error state for ctest_* commands // if a ctest_* command has a CAPTURE_CMAKE_ERROR then put the error @@ -90,30 +75,30 @@ bool cmCTestHandlerCommand::InitialPass(std::vector const& args, // save error state and restore it if needed SaveRestoreErrorState errorState; // Allocate space for argument values. - this->Values.clear(); - this->Values.resize(this->Last, nullptr); + this->BindArguments(); // Process input arguments. - this->ArgumentDoing = ArgumentDoingNone; - // look at all arguments and do not short circuit on the first - // bad one so that CAPTURE_CMAKE_ERROR can override setting the - // global error state - bool foundBadArgument = false; - for (std::string const& arg : args) { - // Check this argument. - if (!this->CheckArgumentKeyword(arg) && !this->CheckArgumentValue(arg)) { - std::ostringstream e; - e << "called with unknown argument \"" << arg << "\"."; - this->SetError(e.str()); - foundBadArgument = true; - } - // note bad argument - if (this->ArgumentDoing == ArgumentDoingError) { - foundBadArgument = true; - } + std::vector unparsedArguments; + std::vector keywordsMissingValue; + std::vector parsedKeywords; + this->Parse(args, &unparsedArguments, &keywordsMissingValue, + &parsedKeywords); + this->CheckArguments(keywordsMissingValue); + + std::sort(parsedKeywords.begin(), parsedKeywords.end()); + auto it = std::adjacent_find(parsedKeywords.begin(), parsedKeywords.end()); + if (it != parsedKeywords.end()) { + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Called with more than one value for ", *it)); + } + + bool const foundBadArgument = !unparsedArguments.empty(); + if (foundBadArgument) { + this->SetError(cmStrCat("called with unknown argument \"", + unparsedArguments.front(), "\".")); } - bool captureCMakeError = (this->Values[ct_CAPTURE_CMAKE_ERROR] && - *this->Values[ct_CAPTURE_CMAKE_ERROR]); + bool const captureCMakeError = !this->CaptureCMakeError.empty(); // now that arguments are parsed check to see if there is a // CAPTURE_CMAKE_ERROR specified let the errorState object know. if (captureCMakeError) { @@ -123,8 +108,7 @@ bool cmCTestHandlerCommand::InitialPass(std::vector const& args, if (foundBadArgument) { // store the cmake error if (captureCMakeError) { - this->Makefile->AddDefinition(this->Values[ct_CAPTURE_CMAKE_ERROR], - "-1"); + this->Makefile->AddDefinition(this->CaptureCMakeError, "-1"); std::string const err = this->GetName() + " " + status.GetError(); if (!cmSystemTools::FindLastString(err.c_str(), "unknown error.")) { cmCTestLog(this->CTest, ERROR_MESSAGE, err << " error from command\n"); @@ -146,10 +130,9 @@ bool cmCTestHandlerCommand::InitialPass(std::vector const& args, this->CTest->SetConfigType(ctestConfigType); } - if (this->Values[ct_BUILD]) { + if (!this->Build.empty()) { this->CTest->SetCTestConfiguration( - "BuildDirectory", - cmSystemTools::CollapseFullPath(this->Values[ct_BUILD]).c_str(), + "BuildDirectory", cmSystemTools::CollapseFullPath(this->Build).c_str(), this->Quiet); } else { std::string const& bdir = @@ -163,13 +146,11 @@ bool cmCTestHandlerCommand::InitialPass(std::vector const& args, "CTEST_BINARY_DIRECTORY not set" << std::endl;); } } - if (this->Values[ct_SOURCE]) { + if (!this->Source.empty()) { cmCTestLog(this->CTest, DEBUG, - "Set source directory to: " << this->Values[ct_SOURCE] - << std::endl); + "Set source directory to: " << this->Source << std::endl); this->CTest->SetCTestConfiguration( - "SourceDirectory", - cmSystemTools::CollapseFullPath(this->Values[ct_SOURCE]).c_str(), + "SourceDirectory", cmSystemTools::CollapseFullPath(this->Source).c_str(), this->Quiet); } else { this->CTest->SetCTestConfiguration( @@ -192,8 +173,7 @@ bool cmCTestHandlerCommand::InitialPass(std::vector const& args, "Cannot instantiate test handler " << this->GetName() << std::endl); if (captureCMakeError) { - this->Makefile->AddDefinition(this->Values[ct_CAPTURE_CMAKE_ERROR], - "-1"); + this->Makefile->AddDefinition(this->CaptureCMakeError, "-1"); std::string const& err = status.GetError(); if (!cmSystemTools::FindLastString(err.c_str(), "unknown error.")) { cmCTestLog(this->CTest, ERROR_MESSAGE, err << " error from command\n"); @@ -203,11 +183,11 @@ bool cmCTestHandlerCommand::InitialPass(std::vector const& args, return false; } - handler->SetAppendXML(this->AppendXML); + handler->SetAppendXML(this->Append); handler->PopulateCustomVectors(this->Makefile); - if (this->Values[ct_SUBMIT_INDEX]) { - handler->SetSubmitIndex(atoi(this->Values[ct_SUBMIT_INDEX])); + if (!this->SubmitIndex.empty()) { + handler->SetSubmitIndex(atoi(this->SubmitIndex.c_str())); } cmWorkingDirectory workdir( this->CTest->GetCTestConfiguration("BuildDirectory")); @@ -216,8 +196,7 @@ bool cmCTestHandlerCommand::InitialPass(std::vector const& args, this->CTest->GetCTestConfiguration("BuildDirectory") + " : " + std::strerror(workdir.GetLastResult())); if (captureCMakeError) { - this->Makefile->AddDefinition(this->Values[ct_CAPTURE_CMAKE_ERROR], - "-1"); + this->Makefile->AddDefinition(this->CaptureCMakeError, "-1"); cmCTestLog(this->CTest, ERROR_MESSAGE, this->GetName() << " " << status.GetError() << "\n"); // return success because failure is recorded in CAPTURE_CMAKE_ERROR @@ -227,9 +206,8 @@ bool cmCTestHandlerCommand::InitialPass(std::vector const& args, } int res = handler->ProcessHandler(); - if (this->Values[ct_RETURN_VALUE] && *this->Values[ct_RETURN_VALUE]) { - this->Makefile->AddDefinition(this->Values[ct_RETURN_VALUE], - std::to_string(res)); + if (!this->ReturnValue.empty()) { + this->Makefile->AddDefinition(this->ReturnValue, std::to_string(res)); } this->ProcessAdditionalValues(handler); // log the error message if there was an error @@ -245,8 +223,7 @@ bool cmCTestHandlerCommand::InitialPass(std::vector const& args, } } // store the captured cmake error state 0 or -1 - this->Makefile->AddDefinition(this->Values[ct_CAPTURE_CMAKE_ERROR], - returnString); + this->Makefile->AddDefinition(this->CaptureCMakeError, returnString); } return true; } @@ -255,47 +232,17 @@ void cmCTestHandlerCommand::ProcessAdditionalValues(cmCTestGenericHandler*) { } -bool cmCTestHandlerCommand::CheckArgumentKeyword(std::string const& arg) +void cmCTestHandlerCommand::BindArguments() { - // Look for non-value arguments common to all commands. - if (arg == "APPEND") { - this->ArgumentDoing = ArgumentDoingNone; - this->AppendXML = true; - return true; - } - if (arg == "QUIET") { - this->ArgumentDoing = ArgumentDoingNone; - this->Quiet = true; - return true; - } - - // Check for a keyword in our argument/value table. - for (unsigned int k = 0; k < this->Arguments.size(); ++k) { - if (this->Arguments[k] && arg == this->Arguments[k]) { - this->ArgumentDoing = ArgumentDoingKeyword; - this->ArgumentIndex = k; - return true; - } - } - return false; + this->Bind("APPEND"_s, this->Append); + this->Bind("QUIET"_s, this->Quiet); + this->Bind("RETURN_VALUE"_s, this->ReturnValue); + this->Bind("CAPTURE_CMAKE_ERROR"_s, this->CaptureCMakeError); + this->Bind("SOURCE"_s, this->Source); + this->Bind("BUILD"_s, this->Build); + this->Bind("SUBMIT_INDEX"_s, this->SubmitIndex); } -bool cmCTestHandlerCommand::CheckArgumentValue(std::string const& arg) +void cmCTestHandlerCommand::CheckArguments(std::vector const&) { - if (this->ArgumentDoing == ArgumentDoingKeyword) { - this->ArgumentDoing = ArgumentDoingNone; - unsigned int k = this->ArgumentIndex; - if (this->Values[k]) { - std::ostringstream e; - e << "Called with more than one value for " << this->Arguments[k]; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); - this->ArgumentDoing = ArgumentDoingError; - return true; - } - this->Values[k] = arg.c_str(); - cmCTestLog(this->CTest, DEBUG, - "Set " << this->Arguments[k] << " to " << arg << "\n"); - return true; - } - return false; } diff --git a/Source/CTest/cmCTestHandlerCommand.h b/Source/CTest/cmCTestHandlerCommand.h index 79d61f3..5bbc569 100644 --- a/Source/CTest/cmCTestHandlerCommand.h +++ b/Source/CTest/cmCTestHandlerCommand.h @@ -5,9 +5,9 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include "cmArgumentParser.h" #include "cmCTestCommand.h" -#include #include #include @@ -19,11 +19,11 @@ class cmExecutionStatus; * * cmCTestHandlerCommand defineds the command to test the project. */ -class cmCTestHandlerCommand : public cmCTestCommand +class cmCTestHandlerCommand + : public cmCTestCommand + , public cmArgumentParser { public: - cmCTestHandlerCommand(); - /** * The name of the command as specified in CMakeList.txt. */ @@ -36,42 +36,22 @@ public: bool InitialPass(std::vector const& args, cmExecutionStatus& status) override; - enum - { - ct_NONE, - ct_RETURN_VALUE, - ct_CAPTURE_CMAKE_ERROR, - ct_BUILD, - ct_SOURCE, - ct_SUBMIT_INDEX, - ct_LAST - }; - protected: virtual cmCTestGenericHandler* InitializeHandler() = 0; virtual void ProcessAdditionalValues(cmCTestGenericHandler* handler); // Command argument handling. - virtual bool CheckArgumentKeyword(std::string const& arg); - virtual bool CheckArgumentValue(std::string const& arg); - enum - { - ArgumentDoingNone, - ArgumentDoingError, - ArgumentDoingKeyword, - ArgumentDoingLast1 - }; - int ArgumentDoing; - unsigned int ArgumentIndex; - - bool AppendXML; - bool Quiet; - - std::string ReturnVariable; - std::vector Arguments; - std::vector Values; - size_t Last; + virtual void BindArguments(); + virtual void CheckArguments(std::vector const& keywords); + + bool Append = false; + bool Quiet = false; + std::string CaptureCMakeError; + std::string ReturnValue; + std::string Build; + std::string Source; + std::string SubmitIndex; }; #define CTEST_COMMAND_APPEND_OPTION_DOCS \ diff --git a/Source/CTest/cmCTestMemCheckCommand.cxx b/Source/CTest/cmCTestMemCheckCommand.cxx index 804efa5..abad5fc 100644 --- a/Source/CTest/cmCTestMemCheckCommand.cxx +++ b/Source/CTest/cmCTestMemCheckCommand.cxx @@ -2,18 +2,15 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestMemCheckCommand.h" -#include -#include - #include "cmCTest.h" #include "cmCTestMemCheckHandler.h" #include "cmMakefile.h" +#include "cm_static_string_view.hxx" -cmCTestMemCheckCommand::cmCTestMemCheckCommand() +void cmCTestMemCheckCommand::BindArguments() { - this->Arguments[ctm_DEFECT_COUNT] = "DEFECT_COUNT"; - this->Arguments[ctm_LAST] = nullptr; - this->Last = ctm_LAST; + this->cmCTestTestCommand::BindArguments(); + this->Bind("DEFECT_COUNT"_s, this->DefectCount); } cmCTestGenericHandler* cmCTestMemCheckCommand::InitializeActualHandler() @@ -43,9 +40,9 @@ cmCTestGenericHandler* cmCTestMemCheckCommand::InitializeActualHandler() void cmCTestMemCheckCommand::ProcessAdditionalValues( cmCTestGenericHandler* handler) { - if (this->Values[ctm_DEFECT_COUNT] && *this->Values[ctm_DEFECT_COUNT]) { + if (!this->DefectCount.empty()) { this->Makefile->AddDefinition( - this->Values[ctm_DEFECT_COUNT], + this->DefectCount, std::to_string( static_cast(handler)->GetDefectCount())); } diff --git a/Source/CTest/cmCTestMemCheckCommand.h b/Source/CTest/cmCTestMemCheckCommand.h index 837a687..200cc2e 100644 --- a/Source/CTest/cmCTestMemCheckCommand.h +++ b/Source/CTest/cmCTestMemCheckCommand.h @@ -5,6 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include #include #include "cm_memory.hxx" @@ -22,8 +23,6 @@ class cmCTestGenericHandler; class cmCTestMemCheckCommand : public cmCTestTestCommand { public: - cmCTestMemCheckCommand(); - /** * This is a virtual constructor for the command. */ @@ -36,15 +35,13 @@ public: } protected: + void BindArguments() override; + cmCTestGenericHandler* InitializeActualHandler() override; void ProcessAdditionalValues(cmCTestGenericHandler* handler) override; - enum - { - ctm_DEFECT_COUNT = ctt_LAST, - ctm_LAST - }; + std::string DefectCount; }; #endif diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index d16aac0..2368276 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -2,14 +2,18 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestSubmitCommand.h" +#include "cmAlgorithms.h" #include "cmCTest.h" #include "cmCTestSubmitHandler.h" #include "cmCommand.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmRange.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" +#include "cm_static_string_view.hxx" +#include #include #include @@ -17,18 +21,6 @@ class cmExecutionStatus; -cmCTestSubmitCommand::cmCTestSubmitCommand() -{ - this->PartsMentioned = false; - this->FilesMentioned = false; - this->InternalTest = false; - this->RetryCount = ""; - this->RetryDelay = ""; - this->CDashUpload = false; - this->Arguments[cts_BUILD_ID] = "BUILD_ID"; - this->Last = cts_LAST; -} - /** * This is a virtual constructor for the command. */ @@ -106,13 +98,18 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() // without any of the default parts. // handler->SelectParts(std::set()); - handler->SelectFiles(this->Files); + handler->SelectFiles( + std::set(this->Files.begin(), this->Files.end())); } // If a PARTS option was given, select only the named parts for submission. // if (this->PartsMentioned) { - handler->SelectParts(this->Parts); + auto parts = + cmMakeRange(this->Parts).transform([this](std::string const& arg) { + return this->CTest->GetPartFromName(arg.c_str()); + }); + handler->SelectParts(std::set(parts.begin(), parts.end())); } // Pass along any HTTPHEADER to the handler if this option was given. @@ -140,133 +137,61 @@ bool cmCTestSubmitCommand::InitialPass(std::vector const& args, bool ret = this->cmCTestHandlerCommand::InitialPass(args, status); - if (this->Values[cts_BUILD_ID] && *this->Values[cts_BUILD_ID]) { - this->Makefile->AddDefinition(this->Values[cts_BUILD_ID], - this->CTest->GetBuildID()); + if (!this->BuildID.empty()) { + this->Makefile->AddDefinition(this->BuildID, this->CTest->GetBuildID()); } return ret; } -bool cmCTestSubmitCommand::CheckArgumentKeyword(std::string const& arg) +void cmCTestSubmitCommand::BindArguments() { if (this->CDashUpload) { // Arguments specific to the CDASH_UPLOAD signature. - if (arg == "CDASH_UPLOAD") { - this->ArgumentDoing = ArgumentDoingCDashUpload; - return true; - } - - if (arg == "CDASH_UPLOAD_TYPE") { - this->ArgumentDoing = ArgumentDoingCDashUploadType; - return true; - } + this->Bind("CDASH_UPLOAD", this->CDashUploadFile); + this->Bind("CDASH_UPLOAD_TYPE", this->CDashUploadType); } else { // Arguments that cannot be used with CDASH_UPLOAD. - if (arg == "PARTS") { - this->ArgumentDoing = ArgumentDoingParts; - this->PartsMentioned = true; - return true; - } - - if (arg == "FILES") { - this->ArgumentDoing = ArgumentDoingFiles; - this->FilesMentioned = true; - return true; - } + this->Bind("PARTS"_s, this->Parts); + this->Bind("FILES"_s, this->Files); } // Arguments used by both modes. - if (arg == "HTTPHEADER") { - this->ArgumentDoing = ArgumentDoingHttpHeader; - return true; - } - - if (arg == "RETRY_COUNT") { - this->ArgumentDoing = ArgumentDoingRetryCount; - return true; - } - - if (arg == "RETRY_DELAY") { - this->ArgumentDoing = ArgumentDoingRetryDelay; - return true; - } - - if (arg == "SUBMIT_URL") { - this->ArgumentDoing = ArgumentDoingSubmitURL; - return true; - } - - if (arg == "INTERNAL_TEST_CHECKSUM") { - this->InternalTest = true; - return true; - } + this->Bind("BUILD_ID"_s, this->BuildID); + this->Bind("HTTPHEADER"_s, this->HttpHeaders); + this->Bind("RETRY_COUNT"_s, this->RetryCount); + this->Bind("RETRY_DELAY"_s, this->RetryDelay); + this->Bind("SUBMIT_URL"_s, this->SubmitURL); + this->Bind("INTERNAL_TEST_CHECKSUM", this->InternalTest); // Look for other arguments. - return this->Superclass::CheckArgumentKeyword(arg); + this->cmCTestHandlerCommand::BindArguments(); } -bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg) +void cmCTestSubmitCommand::CheckArguments( + std::vector const& keywords) { - // Handle states specific to this command. - if (this->ArgumentDoing == ArgumentDoingParts) { + this->PartsMentioned = !this->Parts.empty() || cmContains(keywords, "PARTS"); + this->FilesMentioned = !this->Files.empty() || cmContains(keywords, "FILES"); + + cmEraseIf(this->Parts, [this](std::string const& arg) -> bool { cmCTest::Part p = this->CTest->GetPartFromName(arg.c_str()); - if (p != cmCTest::PartCount) { - this->Parts.insert(p); - } else { + if (p == cmCTest::PartCount) { std::ostringstream e; e << "Part name \"" << arg << "\" is invalid."; this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); - this->ArgumentDoing = ArgumentDoingError; + return true; } - return true; - } + return false; + }); - if (this->ArgumentDoing == ArgumentDoingFiles) { - if (cmSystemTools::FileExists(arg)) { - this->Files.insert(arg); - } else { + cmEraseIf(this->Files, [this](std::string const& arg) -> bool { + if (!cmSystemTools::FileExists(arg)) { std::ostringstream e; e << "File \"" << arg << "\" does not exist. Cannot submit " << "a non-existent file."; this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); - this->ArgumentDoing = ArgumentDoingError; + return true; } - return true; - } - - if (this->ArgumentDoing == ArgumentDoingHttpHeader) { - this->HttpHeaders.push_back(arg); - return true; - } - - if (this->ArgumentDoing == ArgumentDoingRetryCount) { - this->RetryCount = arg; - return true; - } - - if (this->ArgumentDoing == ArgumentDoingRetryDelay) { - this->RetryDelay = arg; - return true; - } - - if (this->ArgumentDoing == ArgumentDoingCDashUpload) { - this->ArgumentDoing = ArgumentDoingNone; - this->CDashUploadFile = arg; - return true; - } - - if (this->ArgumentDoing == ArgumentDoingCDashUploadType) { - this->ArgumentDoing = ArgumentDoingNone; - this->CDashUploadType = arg; - return true; - } - - if (this->ArgumentDoing == ArgumentDoingSubmitURL) { - this->ArgumentDoing = ArgumentDoingNone; - this->SubmitURL = arg; - return true; - } - - // Look for other arguments. - return this->Superclass::CheckArgumentValue(arg); + return false; + }); } diff --git a/Source/CTest/cmCTestSubmitCommand.h b/Source/CTest/cmCTestSubmitCommand.h index 8562207..249f844 100644 --- a/Source/CTest/cmCTestSubmitCommand.h +++ b/Source/CTest/cmCTestSubmitCommand.h @@ -5,11 +5,9 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include "cmCTest.h" #include "cmCTestHandlerCommand.h" #include -#include #include #include @@ -26,7 +24,6 @@ class cmExecutionStatus; class cmCTestSubmitCommand : public cmCTestHandlerCommand { public: - cmCTestSubmitCommand(); std::unique_ptr Clone() override; bool InitialPass(std::vector const& args, @@ -37,45 +34,26 @@ public: */ std::string GetName() const override { return "ctest_submit"; } - using Superclass = cmCTestHandlerCommand; - protected: + void BindArguments() override; + void CheckArguments(std::vector const& keywords) override; cmCTestGenericHandler* InitializeHandler() override; - bool CheckArgumentKeyword(std::string const& arg) override; - bool CheckArgumentValue(std::string const& arg) override; - - enum - { - ArgumentDoingParts = Superclass::ArgumentDoingLast1, - ArgumentDoingFiles, - ArgumentDoingRetryDelay, - ArgumentDoingRetryCount, - ArgumentDoingCDashUpload, - ArgumentDoingCDashUploadType, - ArgumentDoingHttpHeader, - ArgumentDoingSubmitURL, - ArgumentDoingLast2 - }; - - enum - { - cts_BUILD_ID = ct_LAST, - cts_LAST - }; + bool CDashUpload = false; + bool FilesMentioned = false; + bool InternalTest = false; + bool PartsMentioned = false; - bool PartsMentioned; - std::set Parts; - bool FilesMentioned; - bool InternalTest; - std::set Files; - std::string RetryCount; - std::string RetryDelay; - bool CDashUpload; + std::string BuildID; std::string CDashUploadFile; std::string CDashUploadType; - std::vector HttpHeaders; + std::string RetryCount; + std::string RetryDelay; std::string SubmitURL; + + std::vector Files; + std::vector HttpHeaders; + std::vector Parts; }; #endif diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx index 3a29ad3..c277db8 100644 --- a/Source/CTest/cmCTestTestCommand.cxx +++ b/Source/CTest/cmCTestTestCommand.cxx @@ -8,30 +8,29 @@ #include "cmDuration.h" #include "cmMakefile.h" #include "cmStringAlgorithms.h" +#include "cm_static_string_view.hxx" #include #include #include -#include -cmCTestTestCommand::cmCTestTestCommand() +void cmCTestTestCommand::BindArguments() { - this->Arguments[ctt_START] = "START"; - this->Arguments[ctt_END] = "END"; - this->Arguments[ctt_STRIDE] = "STRIDE"; - this->Arguments[ctt_EXCLUDE] = "EXCLUDE"; - this->Arguments[ctt_INCLUDE] = "INCLUDE"; - this->Arguments[ctt_EXCLUDE_LABEL] = "EXCLUDE_LABEL"; - this->Arguments[ctt_INCLUDE_LABEL] = "INCLUDE_LABEL"; - this->Arguments[ctt_EXCLUDE_FIXTURE] = "EXCLUDE_FIXTURE"; - this->Arguments[ctt_EXCLUDE_FIXTURE_SETUP] = "EXCLUDE_FIXTURE_SETUP"; - this->Arguments[ctt_EXCLUDE_FIXTURE_CLEANUP] = "EXCLUDE_FIXTURE_CLEANUP"; - this->Arguments[ctt_PARALLEL_LEVEL] = "PARALLEL_LEVEL"; - this->Arguments[ctt_SCHEDULE_RANDOM] = "SCHEDULE_RANDOM"; - this->Arguments[ctt_STOP_TIME] = "STOP_TIME"; - this->Arguments[ctt_TEST_LOAD] = "TEST_LOAD"; - this->Arguments[ctt_LAST] = nullptr; - this->Last = ctt_LAST; + this->cmCTestHandlerCommand::BindArguments(); + this->Bind("START"_s, this->Start); + this->Bind("END"_s, this->End); + this->Bind("STRIDE"_s, this->Stride); + this->Bind("EXCLUDE"_s, this->Exclude); + this->Bind("INCLUDE"_s, this->Include); + this->Bind("EXCLUDE_LABEL"_s, this->ExcludeLabel); + this->Bind("INCLUDE_LABEL"_s, this->IncludeLabel); + this->Bind("EXCLUDE_FIXTURE"_s, this->ExcludeFixture); + this->Bind("EXCLUDE_FIXTURE_SETUP"_s, this->ExcludeFixtureSetup); + this->Bind("EXCLUDE_FIXTURE_CLEANUP"_s, this->ExcludeFixtureCleanup); + this->Bind("PARALLEL_LEVEL"_s, this->ParallelLevel); + this->Bind("SCHEDULE_RANDOM"_s, this->ScheduleRandom); + this->Bind("STOP_TIME"_s, this->StopTime); + this->Bind("TEST_LOAD"_s, this->TestLoad); } cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() @@ -51,57 +50,44 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() } this->CTest->SetTimeOut(timeout); cmCTestGenericHandler* handler = this->InitializeActualHandler(); - if (this->Values[ctt_START] || this->Values[ctt_END] || - this->Values[ctt_STRIDE]) { - std::ostringstream testsToRunString; - if (this->Values[ctt_START]) { - testsToRunString << this->Values[ctt_START]; - } - testsToRunString << ","; - if (this->Values[ctt_END]) { - testsToRunString << this->Values[ctt_END]; - } - testsToRunString << ","; - if (this->Values[ctt_STRIDE]) { - testsToRunString << this->Values[ctt_STRIDE]; - } - handler->SetOption("TestsToRunInformation", - testsToRunString.str().c_str()); + if (!this->Start.empty() || !this->End.empty() || !this->Stride.empty()) { + handler->SetOption( + "TestsToRunInformation", + cmStrCat(this->Start, ',', this->End, ',', this->Stride).c_str()); } - if (this->Values[ctt_EXCLUDE]) { - handler->SetOption("ExcludeRegularExpression", this->Values[ctt_EXCLUDE]); + if (!this->Exclude.empty()) { + handler->SetOption("ExcludeRegularExpression", this->Exclude.c_str()); } - if (this->Values[ctt_INCLUDE]) { - handler->SetOption("IncludeRegularExpression", this->Values[ctt_INCLUDE]); + if (!this->Include.empty()) { + handler->SetOption("IncludeRegularExpression", this->Include.c_str()); } - if (this->Values[ctt_EXCLUDE_LABEL]) { + if (!this->ExcludeLabel.empty()) { handler->SetOption("ExcludeLabelRegularExpression", - this->Values[ctt_EXCLUDE_LABEL]); + this->ExcludeLabel.c_str()); } - if (this->Values[ctt_INCLUDE_LABEL]) { - handler->SetOption("LabelRegularExpression", - this->Values[ctt_INCLUDE_LABEL]); + if (!this->IncludeLabel.empty()) { + handler->SetOption("LabelRegularExpression", this->IncludeLabel.c_str()); } - if (this->Values[ctt_EXCLUDE_FIXTURE]) { + if (!this->ExcludeFixture.empty()) { handler->SetOption("ExcludeFixtureRegularExpression", - this->Values[ctt_EXCLUDE_FIXTURE]); + this->ExcludeFixture.c_str()); } - if (this->Values[ctt_EXCLUDE_FIXTURE_SETUP]) { + if (!this->ExcludeFixtureSetup.empty()) { handler->SetOption("ExcludeFixtureSetupRegularExpression", - this->Values[ctt_EXCLUDE_FIXTURE_SETUP]); + this->ExcludeFixtureSetup.c_str()); } - if (this->Values[ctt_EXCLUDE_FIXTURE_CLEANUP]) { + if (!this->ExcludeFixtureCleanup.empty()) { handler->SetOption("ExcludeFixtureCleanupRegularExpression", - this->Values[ctt_EXCLUDE_FIXTURE_CLEANUP]); + this->ExcludeFixtureCleanup.c_str()); } - if (this->Values[ctt_PARALLEL_LEVEL]) { - handler->SetOption("ParallelLevel", this->Values[ctt_PARALLEL_LEVEL]); + if (!this->ParallelLevel.empty()) { + handler->SetOption("ParallelLevel", this->ParallelLevel.c_str()); } - if (this->Values[ctt_SCHEDULE_RANDOM]) { - handler->SetOption("ScheduleRandom", this->Values[ctt_SCHEDULE_RANDOM]); + if (!this->ScheduleRandom.empty()) { + handler->SetOption("ScheduleRandom", this->ScheduleRandom.c_str()); } - if (this->Values[ctt_STOP_TIME]) { - this->CTest->SetStopTime(this->Values[ctt_STOP_TIME]); + if (!this->StopTime.empty()) { + this->CTest->SetStopTime(this->StopTime); } // Test load is determined by: TEST_LOAD argument, @@ -109,12 +95,12 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() // command line argument... in that order. unsigned long testLoad; const char* ctestTestLoad = this->Makefile->GetDefinition("CTEST_TEST_LOAD"); - if (this->Values[ctt_TEST_LOAD] && *this->Values[ctt_TEST_LOAD]) { - if (!cmStrToULong(this->Values[ctt_TEST_LOAD], &testLoad)) { + if (!this->TestLoad.empty()) { + if (!cmStrToULong(this->TestLoad.c_str(), &testLoad)) { testLoad = 0; cmCTestLog(this->CTest, WARNING, - "Invalid value for 'TEST_LOAD' : " - << this->Values[ctt_TEST_LOAD] << std::endl); + "Invalid value for 'TEST_LOAD' : " << this->TestLoad + << std::endl); } } else if (ctestTestLoad && *ctestTestLoad) { if (!cmStrToULong(ctestTestLoad, &testLoad)) { diff --git a/Source/CTest/cmCTestTestCommand.h b/Source/CTest/cmCTestTestCommand.h index d74136c..3d9b63e 100644 --- a/Source/CTest/cmCTestTestCommand.h +++ b/Source/CTest/cmCTestTestCommand.h @@ -23,8 +23,6 @@ class cmCTestGenericHandler; class cmCTestTestCommand : public cmCTestHandlerCommand { public: - cmCTestTestCommand(); - /** * This is a virtual constructor for the command. */ @@ -42,29 +40,24 @@ public: std::string GetName() const override { return "ctest_test"; } protected: + void BindArguments() override; virtual cmCTestGenericHandler* InitializeActualHandler(); cmCTestGenericHandler* InitializeHandler() override; - enum - { - ctt_BUILD = ct_LAST, - ctt_RETURN_VALUE, - ctt_START, - ctt_END, - ctt_STRIDE, - ctt_EXCLUDE, - ctt_INCLUDE, - ctt_EXCLUDE_LABEL, - ctt_INCLUDE_LABEL, - ctt_EXCLUDE_FIXTURE, - ctt_EXCLUDE_FIXTURE_SETUP, - ctt_EXCLUDE_FIXTURE_CLEANUP, - ctt_PARALLEL_LEVEL, - ctt_SCHEDULE_RANDOM, - ctt_STOP_TIME, - ctt_TEST_LOAD, - ctt_LAST - }; + std::string Start; + std::string End; + std::string Stride; + std::string Exclude; + std::string Include; + std::string ExcludeLabel; + std::string IncludeLabel; + std::string ExcludeFixture; + std::string ExcludeFixtureSetup; + std::string ExcludeFixtureCleanup; + std::string ParallelLevel; + std::string ScheduleRandom; + std::string StopTime; + std::string TestLoad; }; #endif diff --git a/Source/CTest/cmCTestUpdateCommand.cxx b/Source/CTest/cmCTestUpdateCommand.cxx index 65dc921..673eb9a 100644 --- a/Source/CTest/cmCTestUpdateCommand.cxx +++ b/Source/CTest/cmCTestUpdateCommand.cxx @@ -7,14 +7,11 @@ #include "cmMakefile.h" #include "cmSystemTools.h" -#include - cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler() { - if (this->Values[ct_SOURCE]) { + if (!this->Source.empty()) { this->CTest->SetCTestConfiguration( - "SourceDirectory", - cmSystemTools::CollapseFullPath(this->Values[ct_SOURCE]).c_str(), + "SourceDirectory", cmSystemTools::CollapseFullPath(this->Source).c_str(), this->Quiet); } else { this->CTest->SetCTestConfiguration( diff --git a/Source/CTest/cmCTestUpdateCommand.h b/Source/CTest/cmCTestUpdateCommand.h index 55c4b80..35db88f 100644 --- a/Source/CTest/cmCTestUpdateCommand.h +++ b/Source/CTest/cmCTestUpdateCommand.h @@ -23,8 +23,6 @@ class cmCTestGenericHandler; class cmCTestUpdateCommand : public cmCTestHandlerCommand { public: - cmCTestUpdateCommand() {} - /** * This is a virtual constructor for the command. */ diff --git a/Source/CTest/cmCTestUploadCommand.cxx b/Source/CTest/cmCTestUploadCommand.cxx index 59fbf37..9180821 100644 --- a/Source/CTest/cmCTestUploadCommand.cxx +++ b/Source/CTest/cmCTestUploadCommand.cxx @@ -2,61 +2,45 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestUploadCommand.h" +#include #include #include +#include "cmAlgorithms.h" #include "cmCTest.h" #include "cmCTestUploadHandler.h" #include "cmMakefile.h" #include "cmMessageType.h" #include "cmSystemTools.h" +#include "cm_static_string_view.hxx" -cmCTestGenericHandler* cmCTestUploadCommand::InitializeHandler() -{ - cmCTestUploadHandler* handler = this->CTest->GetUploadHandler(); - handler->Initialize(); - handler->SetFiles(this->Files); - handler->SetQuiet(this->Quiet); - return handler; -} - -bool cmCTestUploadCommand::CheckArgumentKeyword(std::string const& arg) +void cmCTestUploadCommand::BindArguments() { - if (arg == "FILES") { - this->ArgumentDoing = ArgumentDoingFiles; - return true; - } - if (arg == "QUIET") { - this->ArgumentDoing = ArgumentDoingNone; - this->Quiet = true; - return true; - } - if (arg == "CAPTURE_CMAKE_ERROR") { - this->ArgumentDoing = ArgumentDoingCaptureCMakeError; - return true; - } - return false; + this->Bind("FILES"_s, this->Files); + this->Bind("QUIET"_s, this->Quiet); + this->Bind("CAPTURE_CMAKE_ERROR"_s, this->CaptureCMakeError); } -bool cmCTestUploadCommand::CheckArgumentValue(std::string const& arg) +void cmCTestUploadCommand::CheckArguments(std::vector const&) { - if (this->ArgumentDoing == ArgumentDoingCaptureCMakeError) { - this->Values[ct_CAPTURE_CMAKE_ERROR] = arg.c_str(); - return true; - } - if (this->ArgumentDoing == ArgumentDoingFiles) { - if (cmSystemTools::FileExists(arg)) { - this->Files.insert(arg); + cmEraseIf(this->Files, [this](std::string const& arg) -> bool { + if (!cmSystemTools::FileExists(arg)) { + std::ostringstream e; + e << "File \"" << arg << "\" does not exist. Cannot submit " + << "a non-existent file."; + this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); return true; } - std::ostringstream e; - e << "File \"" << arg << "\" does not exist. Cannot submit " - << "a non-existent file."; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); - this->ArgumentDoing = ArgumentDoingError; return false; - } + }); +} - // Look for other arguments. - return this->Superclass::CheckArgumentValue(arg); +cmCTestGenericHandler* cmCTestUploadCommand::InitializeHandler() +{ + cmCTestUploadHandler* handler = this->CTest->GetUploadHandler(); + handler->Initialize(); + handler->SetFiles( + std::set(this->Files.begin(), this->Files.end())); + handler->SetQuiet(this->Quiet); + return handler; } diff --git a/Source/CTest/cmCTestUploadCommand.h b/Source/CTest/cmCTestUploadCommand.h index 9e49769..a962497 100644 --- a/Source/CTest/cmCTestUploadCommand.h +++ b/Source/CTest/cmCTestUploadCommand.h @@ -8,9 +8,9 @@ #include "cmCTestHandlerCommand.h" #include "cmCommand.h" -#include #include #include +#include #include "cm_memory.hxx" @@ -41,22 +41,12 @@ public: */ std::string GetName() const override { return "ctest_upload"; } - using Superclass = cmCTestHandlerCommand; - protected: + void BindArguments() override; + void CheckArguments(std::vector const&) override; cmCTestGenericHandler* InitializeHandler() override; - bool CheckArgumentKeyword(std::string const& arg) override; - bool CheckArgumentValue(std::string const& arg) override; - - enum - { - ArgumentDoingFiles = Superclass::ArgumentDoingLast1, - ArgumentDoingCaptureCMakeError, - ArgumentDoingLast2 - }; - - std::set Files; + std::vector Files; }; #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d5a6a133680e4d5798522a4b29ae6bced1f2db3a commit d5a6a133680e4d5798522a4b29ae6bced1f2db3a Author: Regina Pfeifer AuthorDate: Fri Sep 20 13:27:02 2019 +0200 Commit: Regina Pfeifer CommitDate: Fri Sep 20 13:27:30 2019 +0200 cmArgumentParser: Record parsed keywords diff --git a/Source/cmArgumentParser.cxx b/Source/cmArgumentParser.cxx index 751d117..4c87177 100644 --- a/Source/cmArgumentParser.cxx +++ b/Source/cmArgumentParser.cxx @@ -61,10 +61,14 @@ void Instance::Bind(MultiStringList& val) void Instance::Consume(cm::string_view arg, void* result, std::vector* unparsedArguments, - std::vector* keywordsMissingValue) + std::vector* keywordsMissingValue, + std::vector* parsedKeywords) { auto const it = this->Bindings.Find(arg); if (it != this->Bindings.end()) { + if (parsedKeywords != nullptr) { + parsedKeywords->emplace_back(arg); + } it->second(*this, result); if (this->ExpectValue && keywordsMissingValue != nullptr) { keywordsMissingValue->emplace_back(arg); diff --git a/Source/cmArgumentParser.h b/Source/cmArgumentParser.h index 6cfe946..e1773b4 100644 --- a/Source/cmArgumentParser.h +++ b/Source/cmArgumentParser.h @@ -45,7 +45,8 @@ public: void Consume(cm::string_view arg, void* result, std::vector* unparsedArguments, - std::vector* keywordsMissingValue); + std::vector* keywordsMissingValue, + std::vector* parsedKeywords); private: ActionMap const& Bindings; @@ -79,21 +80,25 @@ public: template void Parse(Result& result, Range const& args, std::vector* unparsedArguments = nullptr, - std::vector* keywordsMissingValue = nullptr) const + std::vector* keywordsMissingValue = nullptr, + std::vector* parsedKeywords = nullptr) const { ArgumentParser::Instance instance(this->Bindings); for (cm::string_view arg : args) { - instance.Consume(arg, &result, unparsedArguments, keywordsMissingValue); + instance.Consume(arg, &result, unparsedArguments, keywordsMissingValue, + parsedKeywords); } } template Result Parse(Range const& args, std::vector* unparsedArguments = nullptr, - std::vector* keywordsMissingValue = nullptr) const + std::vector* keywordsMissingValue = nullptr, + std::vector* parsedKeywords = nullptr) const { Result result; - this->Parse(result, args, unparsedArguments, keywordsMissingValue); + this->Parse(result, args, unparsedArguments, keywordsMissingValue, + parsedKeywords); return result; } @@ -116,11 +121,13 @@ public: template void Parse(Range const& args, std::vector* unparsedArguments = nullptr, - std::vector* keywordsMissingValue = nullptr) const + std::vector* keywordsMissingValue = nullptr, + std::vector* parsedKeywords = nullptr) const { ArgumentParser::Instance instance(this->Bindings); for (cm::string_view arg : args) { - instance.Consume(arg, nullptr, unparsedArguments, keywordsMissingValue); + instance.Consume(arg, nullptr, unparsedArguments, keywordsMissingValue, + parsedKeywords); } } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b2c67a7703836a0015a7e4bf3837dbb613061a74 commit b2c67a7703836a0015a7e4bf3837dbb613061a74 Author: Alex Turbov AuthorDate: Thu Jul 11 02:08:10 2019 +0300 Commit: Alex Turbov CommitDate: Sun Sep 8 20:29:36 2019 +0300 Style: Remove spaces after command call and `(` diff --git a/Modules/Internal/CPack/CPackDeb.cmake b/Modules/Internal/CPack/CPackDeb.cmake index 7791822..51e505b 100644 --- a/Modules/Internal/CPack/CPackDeb.cmake +++ b/Modules/Internal/CPack/CPackDeb.cmake @@ -102,7 +102,7 @@ function(cpack_deb_prepare_package_vars) RESULT_VARIABLE FILE_RESULT_ OUTPUT_VARIABLE INSTALL_FILE_) if(NOT FILE_RESULT_ EQUAL 0) - message (FATAL_ERROR "CPackDeb: execution of command: '${FILE_EXECUTABLE} ./${FILE_}' failed with exit code: ${FILE_RESULT_}") + message(FATAL_ERROR "CPackDeb: execution of command: '${FILE_EXECUTABLE} ./${FILE_}' failed with exit code: ${FILE_RESULT_}") endif() list(APPEND CPACK_DEB_INSTALL_FILES "${INSTALL_FILE_}") endforeach() @@ -253,7 +253,7 @@ function(cpack_deb_prepare_package_vars) message( "CPackDeb Debug: dpkg-shlibdeps warnings \n${SHLIBDEPS_ERROR}") endif() if(NOT SHLIBDEPS_RESULT EQUAL 0) - message (FATAL_ERROR "CPackDeb: dpkg-shlibdeps: '${SHLIBDEPS_ERROR}';\n" + message(FATAL_ERROR "CPackDeb: dpkg-shlibdeps: '${SHLIBDEPS_ERROR}';\n" "executed command: '${SHLIBDEPS_EXECUTABLE} ${IGNORE_MISSING_INFO_FLAG} -O ${CPACK_DEB_BINARY_FILES}';\n" "found files: '${INSTALL_FILE_}';\n" "files info: '${CPACK_DEB_INSTALL_FILES}';\n" @@ -403,7 +403,7 @@ function(cpack_deb_prepare_package_vars) if(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS) set(COMPONENT_DEPENDS "") - foreach (_PACK ${CPACK_COMPONENT_${_local_component_name}_DEPENDS}) + foreach(_PACK ${CPACK_COMPONENT_${_local_component_name}_DEPENDS}) get_component_package_name(_PACK_NAME "${_PACK}") if(COMPONENT_DEPENDS) set(COMPONENT_DEPENDS "${_PACK_NAME} (= ${CPACK_DEBIAN_PACKAGE_VERSION}), ${COMPONENT_DEPENDS}") @@ -425,11 +425,11 @@ function(cpack_deb_prepare_package_vars) # to the minimal dependency of the package # Append automatically discovered dependencies . if(NOT "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}" STREQUAL "") - if (CPACK_DEBIAN_PACKAGE_DEPENDS) + if(CPACK_DEBIAN_PACKAGE_DEPENDS) set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}") - else () + else() set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}") - endif () + endif() endif() if(NOT CPACK_DEBIAN_PACKAGE_DEPENDS) @@ -529,7 +529,7 @@ function(cpack_deb_prepare_package_vars) set(CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "") - if (NOT CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY) + if(NOT CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY) set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY "=") endif() @@ -544,7 +544,7 @@ function(cpack_deb_prepare_package_vars) message(AUTHOR_WARNING "Shared library '${_FILE}' is missing soname or soversion. Library will not be added to DEBIAN/shlibs control file.") endif() endforeach() - if (CPACK_DEBIAN_PACKAGE_SHLIBS_LIST) + if(CPACK_DEBIAN_PACKAGE_SHLIBS_LIST) string(REPLACE ";" "\n" CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "${CPACK_DEBIAN_PACKAGE_SHLIBS_LIST}") endif() else() ----------------------------------------------------------------------- Summary of changes: Help/cpack_gen/deb.rst | 14 +- Modules/Internal/CPack/CPackDeb.cmake | 177 +++++++++++++++------ Source/CTest/cmCTestBuildCommand.cxx | 45 +++--- Source/CTest/cmCTestBuildCommand.h | 23 ++- Source/CTest/cmCTestConfigureCommand.cxx | 12 +- Source/CTest/cmCTestConfigureCommand.h | 10 +- Source/CTest/cmCTestCoverageCommand.cxx | 44 ++--- Source/CTest/cmCTestCoverageCommand.h | 19 +-- Source/CTest/cmCTestHandlerCommand.cxx | 147 ++++++----------- Source/CTest/cmCTestHandlerCommand.h | 48 ++---- Source/CTest/cmCTestMemCheckCommand.cxx | 15 +- Source/CTest/cmCTestMemCheckCommand.h | 11 +- Source/CTest/cmCTestSubmitCommand.cxx | 155 +++++------------- Source/CTest/cmCTestSubmitCommand.h | 48 ++---- Source/CTest/cmCTestTestCommand.cxx | 104 ++++++------ Source/CTest/cmCTestTestCommand.h | 37 ++--- Source/CTest/cmCTestUpdateCommand.cxx | 7 +- Source/CTest/cmCTestUpdateCommand.h | 2 - Source/CTest/cmCTestUploadCommand.cxx | 64 +++----- Source/CTest/cmCTestUploadCommand.h | 18 +-- Source/cmArgumentParser.cxx | 6 +- Source/cmArgumentParser.h | 21 ++- ...LibCPackConfig-components-description1.cmake.in | 7 +- ...LibCPackConfig-components-description2.cmake.in | 10 +- ...CPackVerifyResult-components-description1.cmake | 18 +-- ...CPackVerifyResult-components-description2.cmake | 20 +-- .../CPackComponentsDEB/RunCPackVerifyResult.cmake | 25 +++ Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/CPack/RunCMakeTest.cmake | 7 + .../tests/DEB_DESCRIPTION/ExpectedFiles.cmake | 16 ++ .../CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake | 65 ++++++++ .../CPack/tests/DEB_DESCRIPTION/test.cmake | 45 ++++++ .../tests/PER_COMPONENT_FIELDS/VerifyResult.cmake | 9 +- 33 files changed, 617 insertions(+), 633 deletions(-) create mode 100644 Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/ExpectedFiles.cmake create mode 100644 Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake create mode 100644 Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/test.cmake hooks/post-receive -- CMake From kwrobot at kitware.com Thu Sep 26 09:50:24 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 26 Sep 2019 09:50:24 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1203-ga29b8d2 Message-ID: <20190926135024.51843113841@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via a29b8d285e176b40c9c5f1ce506dd97ed38f9c97 (commit) via df982c4e189c01896db487ec5edfe85d27911007 (commit) via 7847fef51056432e2e822b64d72b598a993e9524 (commit) via fd3a39461457540157ea9bee2f9ea7620dfd1c7f (commit) via a1cc6b4447787b84777fdf9a860e8c39f0f4a090 (commit) via cbb861ade85e3b7e550bb1f150513b237efc1f02 (commit) from 5fa625d611414ac567fd7a6bb5b3b416ea93eca2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a29b8d285e176b40c9c5f1ce506dd97ed38f9c97 commit a29b8d285e176b40c9c5f1ce506dd97ed38f9c97 Merge: df982c4 7847fef Author: Brad King AuthorDate: Thu Sep 26 13:49:36 2019 +0000 Commit: Kitware Robot CommitDate: Thu Sep 26 09:49:56 2019 -0400 Merge topic 'fix-vsmacro-access-violation' 7847fef510 VS: Fix access violation when calling Visual Studio macro Acked-by: Kitware Robot Merge-request: !3853 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=df982c4e189c01896db487ec5edfe85d27911007 commit df982c4e189c01896db487ec5edfe85d27911007 Merge: 5fa625d fd3a394 Author: Brad King AuthorDate: Thu Sep 26 13:47:41 2019 +0000 Commit: Kitware Robot CommitDate: Thu Sep 26 09:47:51 2019 -0400 Merge topic 'add-custom-target-byproduct-checks' fd3a394614 add_custom_command: Format files in error message in a single line a1cc6b4447 add_custom_target: Add output checks for custom target byproducts cbb861ade8 add_custom_command: Add tests for custom command output checks Acked-by: Kitware Robot Merge-request: !3850 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7847fef51056432e2e822b64d72b598a993e9524 commit 7847fef51056432e2e822b64d72b598a993e9524 Author: Daniel Eiband AuthorDate: Sun Sep 22 17:55:12 2019 +0200 Commit: Daniel Eiband CommitDate: Tue Sep 24 17:44:28 2019 +0200 VS: Fix access violation when calling Visual Studio macro Fixes: #19730 diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 92316d3..188aef2 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -45,6 +45,14 @@ static cmVS7FlagTable cmVS7ExtraFlagTable[] = { { "", "", "", "", 0 } }; +namespace { +std::string GetSLNFile(cmLocalGenerator* root) +{ + return cmStrCat(root->GetCurrentBinaryDirectory(), '/', + root->GetProjectName(), ".sln"); +} +} + cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator( cmake* cm, std::string const& platformInGeneratorName) : cmGlobalVisualStudioGenerator(cm, platformInGeneratorName) @@ -286,8 +294,10 @@ void cmGlobalVisualStudio7Generator::Generate() this->OutputSLNFile(); // If any solution or project files changed during the generation, // tell Visual Studio to reload them... - if (!cmSystemTools::GetErrorOccuredFlag()) { - this->CallVisualStudioMacro(MacroReload); + if (!cmSystemTools::GetErrorOccuredFlag() && + !this->LocalGenerators.empty()) { + this->CallVisualStudioMacro(MacroReload, + GetSLNFile(this->LocalGenerators[0])); } } @@ -298,8 +308,7 @@ void cmGlobalVisualStudio7Generator::OutputSLNFile( return; } this->CurrentProject = root->GetProjectName(); - std::string fname = cmStrCat(root->GetCurrentBinaryDirectory(), '/', - root->GetProjectName(), ".sln"); + std::string fname = GetSLNFile(root); cmGeneratedFileStream fout(fname.c_str()); fout.SetCopyIfDifferent(true); if (!fout) { diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 61e8f58..1cb8b53 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -288,11 +288,10 @@ void cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros() } void cmGlobalVisualStudioGenerator::CallVisualStudioMacro( - MacroName m, const char* vsSolutionFile) + MacroName m, const std::string& vsSolutionFile) { // If any solution or project files changed during the generation, // tell Visual Studio to reload them... - cmMakefile* mf = this->LocalGenerators[0]->GetMakefile(); std::string dir = this->GetUserMacrosDirectory(); // Only really try to call the macro if: @@ -307,27 +306,18 @@ void cmGlobalVisualStudioGenerator::CallVisualStudioMacro( if (cmSystemTools::FileExists(macrosFile.c_str()) && IsVisualStudioMacrosFileRegistered( macrosFile, this->GetUserMacrosRegKeyBase(), nextSubkeyName)) { - std::string topLevelSlnName; - if (vsSolutionFile) { - topLevelSlnName = vsSolutionFile; - } else { - topLevelSlnName = - cmStrCat(mf->GetCurrentBinaryDirectory(), '/', - this->LocalGenerators[0]->GetProjectName(), ".sln"); - } - if (m == MacroReload) { std::vector filenames; this->GetFilesReplacedDuringGenerate(filenames); if (!filenames.empty()) { std::string projects = cmJoin(filenames, ";"); cmCallVisualStudioMacro::CallMacro( - topLevelSlnName, CMAKE_VSMACROS_RELOAD_MACRONAME, projects, + vsSolutionFile, CMAKE_VSMACROS_RELOAD_MACRONAME, projects, this->GetCMakeInstance()->GetDebugOutput()); } } else if (m == MacroStop) { cmCallVisualStudioMacro::CallMacro( - topLevelSlnName, CMAKE_VSMACROS_STOP_MACRONAME, "", + vsSolutionFile, CMAKE_VSMACROS_STOP_MACRONAME, "", this->GetCMakeInstance()->GetDebugOutput()); } } diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index bd615ec..4f2007f 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -90,7 +90,7 @@ public: * Call the ReloadProjects macro if necessary based on * GetFilesReplacedDuringGenerate results. */ - void CallVisualStudioMacro(MacroName m, const char* vsSolutionFile = 0); + void CallVisualStudioMacro(MacroName m, const std::string& vsSolutionFile); // return true if target is fortran only bool TargetIsFortranOnly(const cmGeneratorTarget* gt); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 96d903e..b96eedb 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1751,7 +1751,7 @@ int cmake::Run(const std::vector& args, bool noconfigure) cmGlobalVisualStudioGenerator* gg = static_cast(this->GlobalGenerator); gg->CallVisualStudioMacro(cmGlobalVisualStudioGenerator::MacroStop, - this->VSSolutionFile.c_str()); + this->VSSolutionFile); } #endif return ret; diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index c663484..29d9b66 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -167,7 +167,7 @@ if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja") add_RunCMake_test(CompilerChange) endif() add_RunCMake_test(CompilerNotFound) -add_RunCMake_test(Configure) +add_RunCMake_test(Configure -DMSVC_IDE=${MSVC_IDE}) add_RunCMake_test(DisallowedCommands) add_RunCMake_test(ExternalData) add_RunCMake_test(FeatureSummary) diff --git a/Tests/RunCMake/Configure/RerunCMake-build3-result.txt b/Tests/RunCMake/Configure/RerunCMake-build3-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/Configure/RerunCMake-build3-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/Configure/RerunCMake-build3-stdout.txt b/Tests/RunCMake/Configure/RerunCMake-build3-stdout.txt new file mode 100644 index 0000000..dde2ea6 --- /dev/null +++ b/Tests/RunCMake/Configure/RerunCMake-build3-stdout.txt @@ -0,0 +1 @@ +Rerun error 3 diff --git a/Tests/RunCMake/Configure/RerunCMake-build4-result.txt b/Tests/RunCMake/Configure/RerunCMake-build4-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/Configure/RerunCMake-build4-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/Configure/RerunCMake-build4-stdout.txt b/Tests/RunCMake/Configure/RerunCMake-build4-stdout.txt new file mode 100644 index 0000000..b8727e1 --- /dev/null +++ b/Tests/RunCMake/Configure/RerunCMake-build4-stdout.txt @@ -0,0 +1 @@ +Rerun error 4 diff --git a/Tests/RunCMake/Configure/RerunCMake.cmake b/Tests/RunCMake/Configure/RerunCMake.cmake index 5a561bf..c0b0798 100644 --- a/Tests/RunCMake/Configure/RerunCMake.cmake +++ b/Tests/RunCMake/Configure/RerunCMake.cmake @@ -9,3 +9,9 @@ set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${depend}) file(READ ${depend} content) file(WRITE ${output} "${content}") set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS RerunCMake.txt) + +set(error ${CMAKE_CURRENT_BINARY_DIR}/CustomCMakeError.txt) +if(EXISTS ${error}) + file(READ ${error} content) + message(FATAL_ERROR "Rerun error ${content}") +endif() diff --git a/Tests/RunCMake/Configure/RunCMakeTest.cmake b/Tests/RunCMake/Configure/RunCMakeTest.cmake index 4a135be..76d843c 100644 --- a/Tests/RunCMake/Configure/RunCMakeTest.cmake +++ b/Tests/RunCMake/Configure/RunCMakeTest.cmake @@ -14,6 +14,7 @@ set(input "${RunCMake_TEST_BINARY_DIR}/CustomCMakeInput.txt") set(stamp "${RunCMake_TEST_BINARY_DIR}/CustomCMakeStamp.txt") set(depend "${RunCMake_TEST_BINARY_DIR}/CustomCMakeDepend.txt") set(output "${RunCMake_TEST_BINARY_DIR}/CustomCMakeOutput.txt") +set(error "${RunCMake_TEST_BINARY_DIR}/CustomCMakeError.txt") file(WRITE "${input}" "1") file(WRITE "${depend}" "1") run_cmake(RerunCMake) @@ -22,6 +23,22 @@ file(WRITE "${input}" "2") run_cmake_command(RerunCMake-build1 ${CMAKE_COMMAND} --build .) file(WRITE "${depend}" "2") run_cmake_command(RerunCMake-build2 ${CMAKE_COMMAND} --build .) +execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1) # handle 1s resolution +file(WRITE "${depend}" "3") +file(WRITE "${error}" "3") +set(RunCMake_TEST_OUTPUT_MERGE 1) +run_cmake_command(RerunCMake-build3 ${CMAKE_COMMAND} --build .) +if(MSVC_IDE) + # Make sure that for Visual Studio the error occurs from within the build + # system. + file(REMOVE "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/generate.stamp.list") + file(WRITE "${error}" "4") + # With Visual Studio the error must be on stdout, otherwise the error was not + # emitted by ZERO_CHECK. + set(RunCMake_TEST_OUTPUT_MERGE 0) + run_cmake_command(RerunCMake-build4 ${CMAKE_COMMAND} --build .) +endif() +unset(RunCMake_TEST_OUTPUT_MERGE) unset(RunCMake_TEST_BINARY_DIR) unset(RunCMake_TEST_NO_CLEAN) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fd3a39461457540157ea9bee2f9ea7620dfd1c7f commit fd3a39461457540157ea9bee2f9ea7620dfd1c7f Author: Daniel Eiband AuthorDate: Mon Sep 23 23:39:07 2019 +0200 Commit: Daniel Eiband CommitDate: Mon Sep 23 23:39:07 2019 +0200 add_custom_command: Format files in error message in a single line diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index 9d665c4..94de851 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -320,8 +320,8 @@ bool cmAddCustomCommandCommand(std::vector const& args, // No command for this output exists. status.SetError( - cmStrCat("given APPEND option with output\n\"", output[0], - "\"\nwhich is not already a custom command output.")); + cmStrCat("given APPEND option with output\n ", output[0], + "\nwhich is not already a custom command output.")); return false; } diff --git a/Source/cmCheckCustomOutputs.cxx b/Source/cmCheckCustomOutputs.cxx index a401738..7645c88 100644 --- a/Source/cmCheckCustomOutputs.cxx +++ b/Source/cmCheckCustomOutputs.cxx @@ -17,8 +17,8 @@ bool cmCheckCustomOutputs(const std::vector& outputs, // directory during an out of source build. if (!mf.CanIWriteThisFile(o)) { status.SetError( - cmStrCat("attempted to have a file\n\"", o, - "\"\nin a source directory as an output of custom command.")); + cmStrCat("attempted to have a file\n ", o, + "\nin a source directory as an output of custom command.")); cmSystemTools::SetFatalErrorOccured(); return false; } diff --git a/Tests/RunCMake/add_custom_command/AppendNotOutput-stderr.txt b/Tests/RunCMake/add_custom_command/AppendNotOutput-stderr.txt index cd542d8..b7ee23a 100644 --- a/Tests/RunCMake/add_custom_command/AppendNotOutput-stderr.txt +++ b/Tests/RunCMake/add_custom_command/AppendNotOutput-stderr.txt @@ -1,7 +1,7 @@ CMake Error at AppendNotOutput.cmake:1 \(add_custom_command\): add_custom_command given APPEND option with output - .*RunCMake/add_custom_command/AppendNotOutput-build/out.* + .*RunCMake/add_custom_command/AppendNotOutput-build/out which is not already a custom command output. Call Stack \(most recent call first\): diff --git a/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt b/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt index 97b9cca..086e397 100644 --- a/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt +++ b/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt @@ -29,7 +29,7 @@ Call Stack \(most recent call first\): CMake Error at BadByproduct.cmake:6 \(add_custom_command\): add_custom_command attempted to have a file - .*/f".* + .*RunCMake/add_custom_command/f in a source directory as an output of custom command. Call Stack \(most recent call first\): diff --git a/Tests/RunCMake/add_custom_command/BadOutput-stderr.txt b/Tests/RunCMake/add_custom_command/BadOutput-stderr.txt index 584aa88..731e58d 100644 --- a/Tests/RunCMake/add_custom_command/BadOutput-stderr.txt +++ b/Tests/RunCMake/add_custom_command/BadOutput-stderr.txt @@ -29,7 +29,7 @@ Call Stack \(most recent call first\): CMake Error at BadOutput.cmake:6 \(add_custom_command\): add_custom_command attempted to have a file - .*/e".* + .*RunCMake/add_custom_command/e in a source directory as an output of custom command. Call Stack \(most recent call first\): diff --git a/Tests/RunCMake/add_custom_target/BadByproduct-stderr.txt b/Tests/RunCMake/add_custom_target/BadByproduct-stderr.txt index 7390e6a..0f58550 100644 --- a/Tests/RunCMake/add_custom_target/BadByproduct-stderr.txt +++ b/Tests/RunCMake/add_custom_target/BadByproduct-stderr.txt @@ -29,7 +29,7 @@ Call Stack \(most recent call first\): CMake Error at BadByproduct.cmake:6 \(add_custom_target\): add_custom_target attempted to have a file - .*/j".* + .*RunCMake/add_custom_target/j in a source directory as an output of custom command. Call Stack \(most recent call first\): https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a1cc6b4447787b84777fdf9a860e8c39f0f4a090 commit a1cc6b4447787b84777fdf9a860e8c39f0f4a090 Author: Daniel Eiband AuthorDate: Mon Sep 23 22:18:36 2019 +0200 Commit: Daniel Eiband CommitDate: Mon Sep 23 22:18:36 2019 +0200 add_custom_target: Add output checks for custom target byproducts Use the output checks for byproducts of add_custom_command also for byproducts of add_custom_target. diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 8ed7b2f..71a7dbd 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -168,6 +168,8 @@ set(SRCS cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.h cmCacheManager.cxx cmCacheManager.h + cmCheckCustomOutputs.h + cmCheckCustomOutputs.cxx cmCLocaleEnvironmentScope.h cmCLocaleEnvironmentScope.cxx cmCommandArgumentParserHelper.cxx diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index defefaf..9d665c4 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -5,6 +5,7 @@ #include #include +#include "cmCheckCustomOutputs.h" #include "cmCustomCommand.h" #include "cmCustomCommandLines.h" #include "cmExecutionStatus.h" @@ -16,9 +17,6 @@ #include "cmSystemTools.h" #include "cmTarget.h" -static bool cmAddCustomCommandCommandCheckOutputs( - const std::vector& outputs, cmExecutionStatus& status); - bool cmAddCustomCommandCommand(std::vector const& args, cmExecutionStatus& status) { @@ -307,9 +305,9 @@ bool cmAddCustomCommandCommand(std::vector const& args, } // Make sure the output names and locations are safe. - if (!cmAddCustomCommandCommandCheckOutputs(output, status) || - !cmAddCustomCommandCommandCheckOutputs(outputs, status) || - !cmAddCustomCommandCommandCheckOutputs(byproducts, status)) { + if (!cmCheckCustomOutputs(output, "OUTPUT", status) || + !cmCheckCustomOutputs(outputs, "OUTPUTS", status) || + !cmCheckCustomOutputs(byproducts, "BYPRODUCTS", status)) { return false; } @@ -387,29 +385,3 @@ bool cmAddCustomCommandCommand(std::vector const& args, return true; } - -bool cmAddCustomCommandCommandCheckOutputs( - const std::vector& outputs, cmExecutionStatus& status) -{ - cmMakefile& mf = status.GetMakefile(); - for (std::string const& o : outputs) { - // Make sure the file will not be generated into the source - // directory during an out of source build. - if (!mf.CanIWriteThisFile(o)) { - std::string e = "attempted to have a file\n\"" + o + - "\"\nin a source directory as an output of custom command."; - status.SetError(e); - cmSystemTools::SetFatalErrorOccured(); - return false; - } - - // Make sure the output file name has no invalid characters. - std::string::size_type pos = o.find_first_of("#<>"); - if (pos != std::string::npos) { - status.SetError(cmStrCat("called with OUTPUT containing a \"", o[pos], - "\". This character is not allowed.")); - return false; - } - } - return true; -} diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx index 9fd1234..b580c43 100644 --- a/Source/cmAddCustomTargetCommand.cxx +++ b/Source/cmAddCustomTargetCommand.cxx @@ -4,6 +4,7 @@ #include +#include "cmCheckCustomOutputs.h" #include "cmCustomCommandLines.h" #include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" @@ -205,6 +206,11 @@ bool cmAddCustomTargetCommand(std::vector const& args, return false; } + // Make sure the byproduct names and locations are safe. + if (!cmCheckCustomOutputs(byproducts, "BYPRODUCTS", status)) { + return false; + } + // Add the utility target to the makefile. bool escapeOldStyle = !verbatim; cmTarget* target = mf.AddUtilityCommand( diff --git a/Source/cmCheckCustomOutputs.cxx b/Source/cmCheckCustomOutputs.cxx new file mode 100644 index 0000000..a401738 --- /dev/null +++ b/Source/cmCheckCustomOutputs.cxx @@ -0,0 +1,36 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmCheckCustomOutputs.h" + +#include "cmExecutionStatus.h" +#include "cmMakefile.h" +#include "cmStringAlgorithms.h" +#include "cmSystemTools.h" + +bool cmCheckCustomOutputs(const std::vector& outputs, + cm::string_view keyword, cmExecutionStatus& status) +{ + cmMakefile& mf = status.GetMakefile(); + + for (std::string const& o : outputs) { + // Make sure the file will not be generated into the source + // directory during an out of source build. + if (!mf.CanIWriteThisFile(o)) { + status.SetError( + cmStrCat("attempted to have a file\n\"", o, + "\"\nin a source directory as an output of custom command.")); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + + // Make sure the output file name has no invalid characters. + std::string::size_type pos = o.find_first_of("#<>"); + if (pos != std::string::npos) { + status.SetError(cmStrCat("called with ", keyword, " containing a \"", + o[pos], "\". This character is not allowed.")); + return false; + } + } + + return true; +} diff --git a/Source/cmCheckCustomOutputs.h b/Source/cmCheckCustomOutputs.h new file mode 100644 index 0000000..7c4b3fe --- /dev/null +++ b/Source/cmCheckCustomOutputs.h @@ -0,0 +1,18 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cmCheckCustomOutputs_h +#define cmCheckCustomOutputs_h + +#include "cmConfigure.h" // IWYU pragma: keep + +#include + +#include +#include + +class cmExecutionStatus; + +bool cmCheckCustomOutputs(const std::vector& outputs, + cm::string_view keyword, cmExecutionStatus& status); + +#endif diff --git a/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt b/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt index 6315c8b..97b9cca 100644 --- a/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt +++ b/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt @@ -1,27 +1,27 @@ CMake Error at BadByproduct.cmake:2 \(add_custom_command\): - add_custom_command called with OUTPUT containing a "#". This character is - not allowed. + add_custom_command called with BYPRODUCTS containing a "#". This character + is not allowed. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) CMake Error at BadByproduct.cmake:3 \(add_custom_command\): - add_custom_command called with OUTPUT containing a "<". This character is - not allowed. + add_custom_command called with BYPRODUCTS containing a "<". This character + is not allowed. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) CMake Error at BadByproduct.cmake:4 \(add_custom_command\): - add_custom_command called with OUTPUT containing a ">". This character is - not allowed. + add_custom_command called with BYPRODUCTS containing a ">". This character + is not allowed. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) CMake Error at BadByproduct.cmake:5 \(add_custom_command\): - add_custom_command called with OUTPUT containing a "<". This character is - not allowed. + add_custom_command called with BYPRODUCTS containing a "<". This character + is not allowed. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/add_custom_target/BadByproduct-result.txt b/Tests/RunCMake/add_custom_target/BadByproduct-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/add_custom_target/BadByproduct-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_custom_target/BadByproduct-stderr.txt b/Tests/RunCMake/add_custom_target/BadByproduct-stderr.txt new file mode 100644 index 0000000..7390e6a --- /dev/null +++ b/Tests/RunCMake/add_custom_target/BadByproduct-stderr.txt @@ -0,0 +1,36 @@ +CMake Error at BadByproduct.cmake:2 \(add_custom_target\): + add_custom_target called with BYPRODUCTS containing a "#". This character + is not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at BadByproduct.cmake:3 \(add_custom_target\): + add_custom_target called with BYPRODUCTS containing a "<". This character + is not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at BadByproduct.cmake:4 \(add_custom_target\): + add_custom_target called with BYPRODUCTS containing a ">". This character + is not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at BadByproduct.cmake:5 \(add_custom_target\): + add_custom_target called with BYPRODUCTS containing a "<". This character + is not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at BadByproduct.cmake:6 \(add_custom_target\): + add_custom_target attempted to have a file + + .*/j".* + + in a source directory as an output of custom command. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/add_custom_target/BadByproduct.cmake b/Tests/RunCMake/add_custom_target/BadByproduct.cmake new file mode 100644 index 0000000..963d641 --- /dev/null +++ b/Tests/RunCMake/add_custom_target/BadByproduct.cmake @@ -0,0 +1,6 @@ +set(CMAKE_DISABLE_SOURCE_CHANGES ON) +add_custom_target(a BYPRODUCTS "a#" COMMAND b) +add_custom_target(c BYPRODUCTS "a<" COMMAND d) +add_custom_target(e BYPRODUCTS "a>" COMMAND f) +add_custom_target(g BYPRODUCTS "$/#" COMMAND h) +add_custom_target(i BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/j COMMAND k) diff --git a/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake index 49c7d3e..f5d5dd2 100644 --- a/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake @@ -1,11 +1,12 @@ include(RunCMake) -run_cmake(CommandExpandsEmpty) -run_cmake(GeneratedProperty) -run_cmake(NoArguments) +run_cmake(BadByproduct) run_cmake(BadTargetName) run_cmake(ByproductsNoCommand) +run_cmake(CommandExpandsEmpty) +run_cmake(GeneratedProperty) run_cmake(LiteralQuotes) +run_cmake(NoArguments) run_cmake(UsesTerminalNoCommand) function(run_TargetOrder) diff --git a/bootstrap b/bootstrap index 0923dd4..42f869b 100755 --- a/bootstrap +++ b/bootstrap @@ -278,6 +278,7 @@ CMAKE_CXX_SOURCES="\ cmCMakePolicyCommand \ cmCPackPropertiesGenerator \ cmCacheManager \ + cmCheckCustomOutputs \ cmCommand \ cmCommandArgumentParserHelper \ cmCommands \ https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cbb861ade85e3b7e550bb1f150513b237efc1f02 commit cbb861ade85e3b7e550bb1f150513b237efc1f02 Author: Daniel Eiband AuthorDate: Sat Sep 21 15:16:36 2019 +0200 Commit: Daniel Eiband CommitDate: Mon Sep 23 22:15:31 2019 +0200 add_custom_command: Add tests for custom command output checks diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index 35db6a4..defefaf 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -396,8 +396,8 @@ bool cmAddCustomCommandCommandCheckOutputs( // Make sure the file will not be generated into the source // directory during an out of source build. if (!mf.CanIWriteThisFile(o)) { - std::string e = "attempted to have a file \"" + o + - "\" in a source directory as an output of custom command."; + std::string e = "attempted to have a file\n\"" + o + + "\"\nin a source directory as an output of custom command."; status.SetError(e); cmSystemTools::SetFatalErrorOccured(); return false; diff --git a/Tests/RunCMake/add_custom_command/BadByproduct-result.txt b/Tests/RunCMake/add_custom_command/BadByproduct-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/add_custom_command/BadByproduct-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt b/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt new file mode 100644 index 0000000..6315c8b --- /dev/null +++ b/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt @@ -0,0 +1,36 @@ +CMake Error at BadByproduct.cmake:2 \(add_custom_command\): + add_custom_command called with OUTPUT containing a "#". This character is + not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at BadByproduct.cmake:3 \(add_custom_command\): + add_custom_command called with OUTPUT containing a "<". This character is + not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at BadByproduct.cmake:4 \(add_custom_command\): + add_custom_command called with OUTPUT containing a ">". This character is + not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at BadByproduct.cmake:5 \(add_custom_command\): + add_custom_command called with OUTPUT containing a "<". This character is + not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at BadByproduct.cmake:6 \(add_custom_command\): + add_custom_command attempted to have a file + + .*/f".* + + in a source directory as an output of custom command. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/add_custom_command/BadByproduct.cmake b/Tests/RunCMake/add_custom_command/BadByproduct.cmake new file mode 100644 index 0000000..91bca52 --- /dev/null +++ b/Tests/RunCMake/add_custom_command/BadByproduct.cmake @@ -0,0 +1,6 @@ +set(CMAKE_DISABLE_SOURCE_CHANGES ON) +add_custom_command(OUTPUT a BYPRODUCTS "a#") +add_custom_command(OUTPUT b BYPRODUCTS "a<") +add_custom_command(OUTPUT c BYPRODUCTS "a>") +add_custom_command(OUTPUT d BYPRODUCTS "$/#") +add_custom_command(OUTPUT e BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/f) diff --git a/Tests/RunCMake/add_custom_command/BadOutput-result.txt b/Tests/RunCMake/add_custom_command/BadOutput-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/add_custom_command/BadOutput-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_custom_command/BadOutput-stderr.txt b/Tests/RunCMake/add_custom_command/BadOutput-stderr.txt new file mode 100644 index 0000000..584aa88 --- /dev/null +++ b/Tests/RunCMake/add_custom_command/BadOutput-stderr.txt @@ -0,0 +1,36 @@ +CMake Error at BadOutput.cmake:2 \(add_custom_command\): + add_custom_command called with OUTPUT containing a "#". This character is + not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at BadOutput.cmake:3 \(add_custom_command\): + add_custom_command called with OUTPUT containing a "<". This character is + not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at BadOutput.cmake:4 \(add_custom_command\): + add_custom_command called with OUTPUT containing a ">". This character is + not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at BadOutput.cmake:5 \(add_custom_command\): + add_custom_command called with OUTPUT containing a "<". This character is + not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) + + +CMake Error at BadOutput.cmake:6 \(add_custom_command\): + add_custom_command attempted to have a file + + .*/e".* + + in a source directory as an output of custom command. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/add_custom_command/BadOutput.cmake b/Tests/RunCMake/add_custom_command/BadOutput.cmake new file mode 100644 index 0000000..6875fe9 --- /dev/null +++ b/Tests/RunCMake/add_custom_command/BadOutput.cmake @@ -0,0 +1,6 @@ +set(CMAKE_DISABLE_SOURCE_CHANGES ON) +add_custom_command(OUTPUT "a#" COMMAND a) +add_custom_command(OUTPUT "a<" COMMAND b) +add_custom_command(OUTPUT "a>" COMMAND c) +add_custom_command(OUTPUT "$/#" COMMAND d) +add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/e COMMAND f) diff --git a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake index 270df2f..96642fa 100644 --- a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake @@ -4,6 +4,8 @@ run_cmake(AppendLiteralQuotes) run_cmake(AppendNoOutput) run_cmake(AppendNotOutput) run_cmake(BadArgument) +run_cmake(BadByproduct) +run_cmake(BadOutput) run_cmake(GeneratedProperty) run_cmake(LiteralQuotes) run_cmake(NoArguments) ----------------------------------------------------------------------- Summary of changes: Source/CMakeLists.txt | 2 ++ Source/cmAddCustomCommandCommand.cxx | 40 ++++------------------ Source/cmAddCustomTargetCommand.cxx | 6 ++++ Source/cmCheckCustomOutputs.cxx | 36 +++++++++++++++++++ ...DefinitionsCommand.h => cmCheckCustomOutputs.h} | 10 +++--- Source/cmGlobalVisualStudio7Generator.cxx | 17 ++++++--- Source/cmGlobalVisualStudioGenerator.cxx | 16 ++------- Source/cmGlobalVisualStudioGenerator.h | 2 +- Source/cmake.cxx | 2 +- Tests/RunCMake/CMakeLists.txt | 2 +- .../RerunCMake-build3-result.txt} | 0 .../Configure/RerunCMake-build3-stdout.txt | 1 + .../RerunCMake-build4-result.txt} | 0 .../Configure/RerunCMake-build4-stdout.txt | 1 + Tests/RunCMake/Configure/RerunCMake.cmake | 6 ++++ Tests/RunCMake/Configure/RunCMakeTest.cmake | 17 +++++++++ .../add_custom_command/AppendNotOutput-stderr.txt | 2 +- .../BadByproduct-result.txt} | 0 .../add_custom_command/BadByproduct-stderr.txt | 36 +++++++++++++++++++ .../RunCMake/add_custom_command/BadByproduct.cmake | 6 ++++ .../BadOutput-result.txt} | 0 .../add_custom_command/BadOutput-stderr.txt | 36 +++++++++++++++++++ Tests/RunCMake/add_custom_command/BadOutput.cmake | 6 ++++ .../RunCMake/add_custom_command/RunCMakeTest.cmake | 2 ++ .../BadByproduct-result.txt} | 0 .../add_custom_target/BadByproduct-stderr.txt | 36 +++++++++++++++++++ .../RunCMake/add_custom_target/BadByproduct.cmake | 6 ++++ .../RunCMake/add_custom_target/RunCMakeTest.cmake | 7 ++-- bootstrap | 1 + 29 files changed, 234 insertions(+), 62 deletions(-) create mode 100644 Source/cmCheckCustomOutputs.cxx copy Source/{cmAddDefinitionsCommand.h => cmCheckCustomOutputs.h} (53%) copy Tests/RunCMake/{GoogleTest/GoogleTest-test-missing-result.txt => Configure/RerunCMake-build3-result.txt} (100%) create mode 100644 Tests/RunCMake/Configure/RerunCMake-build3-stdout.txt copy Tests/RunCMake/{GoogleTest/GoogleTest-test-missing-result.txt => Configure/RerunCMake-build4-result.txt} (100%) create mode 100644 Tests/RunCMake/Configure/RerunCMake-build4-stdout.txt copy Tests/RunCMake/{while/MissingArgument-result.txt => add_custom_command/BadByproduct-result.txt} (100%) create mode 100644 Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt create mode 100644 Tests/RunCMake/add_custom_command/BadByproduct.cmake copy Tests/RunCMake/{while/MissingArgument-result.txt => add_custom_command/BadOutput-result.txt} (100%) create mode 100644 Tests/RunCMake/add_custom_command/BadOutput-stderr.txt create mode 100644 Tests/RunCMake/add_custom_command/BadOutput.cmake copy Tests/RunCMake/{while/MissingArgument-result.txt => add_custom_target/BadByproduct-result.txt} (100%) create mode 100644 Tests/RunCMake/add_custom_target/BadByproduct-stderr.txt create mode 100644 Tests/RunCMake/add_custom_target/BadByproduct.cmake hooks/post-receive -- CMake From kwrobot at kitware.com Thu Sep 26 09:53:19 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 26 Sep 2019 09:53:19 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1205-g3cb1289 Message-ID: <20190926135319.B1202113491@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 3cb12895f3d99614ac30bd2f7703f721154b7068 (commit) via c54448e1855432de95844d4d0546bbe6d7f47c84 (commit) from a29b8d285e176b40c9c5f1ce506dd97ed38f9c97 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3cb12895f3d99614ac30bd2f7703f721154b7068 commit 3cb12895f3d99614ac30bd2f7703f721154b7068 Merge: a29b8d2 c54448e Author: Brad King AuthorDate: Thu Sep 26 13:51:41 2019 +0000 Commit: Kitware Robot CommitDate: Thu Sep 26 09:51:55 2019 -0400 Merge topic 'pch-export' c54448e185 PCH: Propagate INTERFACE_PRECOMPILE_HEADERS in install(EXPORT) Acked-by: Kitware Robot Acked-by: Cristian Adam Merge-request: !3862 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c54448e1855432de95844d4d0546bbe6d7f47c84 commit c54448e1855432de95844d4d0546bbe6d7f47c84 Author: Brad King AuthorDate: Mon Sep 23 13:51:07 2019 -0400 Commit: Brad King CommitDate: Wed Sep 25 12:06:28 2019 -0400 PCH: Propagate INTERFACE_PRECOMPILE_HEADERS in install(EXPORT) This was accidentally left out of commit 0467a2f91b (PCH: add PRECOMPILE_HEADERS to special properties, 2015-03-12). Also add a test case for `install(EXPORT)` and `export()` propagation of precompiled headers. Fixes: #19741 diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 0009b3a..1e843b6 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -94,6 +94,9 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", gt, cmGeneratorExpression::InstallInterface, properties, missingTargets); + this->PopulateInterfaceProperty("INTERFACE_PRECOMPILE_HEADERS", gt, + cmGeneratorExpression::InstallInterface, + properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", gt, cmGeneratorExpression::InstallInterface, properties, missingTargets); diff --git a/Tests/ExportImport/Export/Interface/CMakeLists.txt b/Tests/ExportImport/Export/Interface/CMakeLists.txt index 22a4ef6..43b7217 100644 --- a/Tests/ExportImport/Export/Interface/CMakeLists.txt +++ b/Tests/ExportImport/Export/Interface/CMakeLists.txt @@ -6,6 +6,12 @@ set_property(TARGET headeronly PROPERTY INTERFACE_INCLUDE_DIRECTORIES ) set_property(TARGET headeronly PROPERTY INTERFACE_COMPILE_DEFINITIONS "HEADERONLY_DEFINE") +add_library(pch_iface INTERFACE) +target_precompile_headers(pch_iface INTERFACE + "$" + "$/include/pch/pch.h>" + ) + include(GenerateExportHeader) add_library(sharedlib SHARED sharedlib.cpp) generate_export_header(sharedlib) @@ -45,7 +51,7 @@ set_property(TARGET cmakeonly PROPERTY custom_property CustomPropertyValue) set_property(TARGET cmakeonly PROPERTY EXPORT_PROPERTIES custom_property) install(TARGETS headeronly sharediface use_auto_type use_c_restrict source_target - cmakeonly + pch_iface cmakeonly EXPORT expInterface ) install(TARGETS sharedlib @@ -61,6 +67,10 @@ install(FILES DESTINATION include/headeronly ) install(FILES + pch/pch.h + DESTINATION include/pch +) +install(FILES sharedlib/sharedlib.h "${CMAKE_CURRENT_BINARY_DIR}/sharedlib_export.h" DESTINATION include/sharedlib diff --git a/Tests/ExportImport/Export/Interface/pch/pch.h b/Tests/ExportImport/Export/Interface/pch/pch.h new file mode 100644 index 0000000..bc50727 --- /dev/null +++ b/Tests/ExportImport/Export/Interface/pch/pch.h @@ -0,0 +1 @@ +#define PCH_PCH_H_INCLUDED diff --git a/Tests/ExportImport/Import/Interface/CMakeLists.txt b/Tests/ExportImport/Import/Interface/CMakeLists.txt index a07a5b3..ef666b1 100644 --- a/Tests/ExportImport/Import/Interface/CMakeLists.txt +++ b/Tests/ExportImport/Import/Interface/CMakeLists.txt @@ -98,6 +98,17 @@ set_property(TARGET exp::sharediface APPEND PROPERTY INTERFACE_LINK_LIBRARIES de add_executable(interfacetest_exp interfacetest.cpp) target_link_libraries(interfacetest_exp exp::sharediface) +if(NOT CMAKE_OSX_ARCHITECTURES MATCHES "[;$]" OR CMAKE_GENERATOR STREQUAL "Xcode") + add_executable(pch_iface_test_bld pch_iface_test.cpp) + target_link_libraries(pch_iface_test_bld bld::pch_iface) + add_executable(pch_iface_test_exp pch_iface_test.cpp) + target_link_libraries(pch_iface_test_exp exp::pch_iface) + if(CMAKE_CXX_COMPILE_OPTIONS_USE_PCH) + target_compile_definitions(pch_iface_test_bld PRIVATE EXPECT_PCH) + target_compile_definitions(pch_iface_test_exp PRIVATE EXPECT_PCH) + endif() +endif() + do_try_compile(exp) foreach(ns exp bld) diff --git a/Tests/ExportImport/Import/Interface/pch_iface_test.cpp b/Tests/ExportImport/Import/Interface/pch_iface_test.cpp new file mode 100644 index 0000000..a460d0d --- /dev/null +++ b/Tests/ExportImport/Import/Interface/pch_iface_test.cpp @@ -0,0 +1,16 @@ +#ifdef EXPECT_PCH +// Verify that pch/pch.h was included via '-include ...' or equivalent. +# ifndef PCH_PCH_H_INCLUDED +# error "Expected PCH_PCH_H_INCLUDED." +# endif +#elif defined(__PGIC__) || defined(__ibmxl__) +// No PCH expected but these compilers define macros below. +#elif defined(__GNUC__) || defined(__clang__) || defined(_INTEL_COMPILER) || \ + defined(_MSC_VER) +# error "Expected EXPECT_PCH for this compiler." +#endif + +int main() +{ + return 0; +} ----------------------------------------------------------------------- Summary of changes: Source/cmExportInstallFileGenerator.cxx | 3 +++ Tests/ExportImport/Export/Interface/CMakeLists.txt | 12 +++++++++++- Tests/ExportImport/Export/Interface/pch/pch.h | 1 + Tests/ExportImport/Import/Interface/CMakeLists.txt | 11 +++++++++++ Tests/ExportImport/Import/Interface/pch_iface_test.cpp | 16 ++++++++++++++++ 5 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 Tests/ExportImport/Export/Interface/pch/pch.h create mode 100644 Tests/ExportImport/Import/Interface/pch_iface_test.cpp hooks/post-receive -- CMake From kwrobot at kitware.com Thu Sep 26 10:00:22 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 26 Sep 2019 10:00:22 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1211-g28a2613 Message-ID: <20190926140022.0F5E9113D65@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 28a2613dd291c641f17940e3f996bd4cc9b9888d (commit) via d867e058924d348ee5ec5bba867965e8f1f276e2 (commit) via 881e3cfbf96c7b4f48304d3dfc07899c2e6703de (commit) via fc36f4410bcdb76ef23a07e5172cb57b41ff5ce3 (commit) via 1f0d23546d5721fdd92883da4c4368dad3931393 (commit) via 6a05bd3fa6a3f4ecf45c4cc32abc616883998ff9 (commit) from 3cb12895f3d99614ac30bd2f7703f721154b7068 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=28a2613dd291c641f17940e3f996bd4cc9b9888d commit 28a2613dd291c641f17940e3f996bd4cc9b9888d Merge: 3cb1289 d867e05 Author: Brad King AuthorDate: Thu Sep 26 13:56:57 2019 +0000 Commit: Kitware Robot CommitDate: Thu Sep 26 09:57:15 2019 -0400 Merge topic 'autogen_json' d867e05892 Autogen: Use JSON instead of CMake script for info files 881e3cfbf9 Autogen: Variable renames and cleanups fc36f4410b Autogen: Inline GetKnownQtVersions function 1f0d23546d Autogen: Return unsigned int from GetParallelCPUCount() 6a05bd3fa6 cm/algorithm: Provide function cm::clamp Acked-by: Kitware Robot Merge-request: !3859 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d867e058924d348ee5ec5bba867965e8f1f276e2 commit d867e058924d348ee5ec5bba867965e8f1f276e2 Author: Sebastian Holtermann AuthorDate: Fri Sep 20 22:39:13 2019 +0200 Commit: Brad King CommitDate: Wed Sep 25 10:07:09 2019 -0400 Autogen: Use JSON instead of CMake script for info files We used to store information for the _autogen target in a CMake script file AutogenInfo.cmake, which was imported by a temporary cmake instance in the _autogen target. This introduced the overhead of creating a temporary cmake instance and inherited the limitations of the CMake language which only supports lists. This patch introduces JSON files to pass information to AUTORCC and autogen_ targets. JSON files are more flexible for passing data, e.g. they support nested lists. The patch has the side effects that - AutogenInfo.cmake is renamed to AutogenInfo.json - AutogenOldSettings.txt is renamed to AutogenUsed.txt - RCCInfo.cmake is renamed to AutoRcc___Info.json - RCC.lock is renamed to AutoRcc___Lock.lock - RCCSettings.txt is renamed to AutoRcc___Used.txt diff --git a/Source/cmQtAutoGen.cxx b/Source/cmQtAutoGen.cxx index 57c8825..0f0e864 100644 --- a/Source/cmQtAutoGen.cxx +++ b/Source/cmQtAutoGen.cxx @@ -72,7 +72,6 @@ void MergeOptions(std::vector& baseOpts, // - Class definitions unsigned int const cmQtAutoGen::ParallelMax = 64; -std::string const cmQtAutoGen::ListSep = "<<>>"; cm::string_view cmQtAutoGen::GeneratorName(GenT genType) { @@ -162,6 +161,16 @@ std::string cmQtAutoGen::QuotedCommand(std::vector const& command) return res; } +std::string cmQtAutoGen::FileNameWithoutLastExtension(cm::string_view filename) +{ + auto slashPos = filename.rfind('/'); + if (slashPos != cm::string_view::npos) { + filename.remove_prefix(slashPos + 1); + } + auto dotPos = filename.rfind('.'); + return std::string(filename.substr(0, dotPos)); +} + std::string cmQtAutoGen::ParentDir(cm::string_view filename) { auto slashPos = filename.rfind('/'); diff --git a/Source/cmQtAutoGen.h b/Source/cmQtAutoGen.h index c8e4203..d070b79 100644 --- a/Source/cmQtAutoGen.h +++ b/Source/cmQtAutoGen.h @@ -62,8 +62,6 @@ public: RCC // AUTORCC }; - /// @brief Nested lists separator - static std::string const ListSep; /// @brief Maximum number of parallel threads/processes in a generator static unsigned int const ParallelMax; @@ -81,6 +79,9 @@ public: static std::string QuotedCommand(std::vector const& command); + /// @brief Returns the file name without path and extension (thread safe) + static std::string FileNameWithoutLastExtension(cm::string_view filename); + /// @brief Returns the parent directory of the file (thread safe) static std::string ParentDir(cm::string_view filename); diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 0329ac7..0d56fe1 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -8,7 +8,7 @@ #include "cmAlgorithms.h" #include "cmCustomCommand.h" #include "cmCustomCommandLines.h" -#include "cmFilePathChecksum.h" +#include "cmGeneratedFileStream.h" #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" @@ -17,7 +17,6 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmMessageType.h" -#include "cmOutputConverter.h" #include "cmPolicies.h" #include "cmSourceFile.h" #include "cmSourceFileLocationKind.h" @@ -27,6 +26,8 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTarget.h" +#include "cm_jsoncpp_value.h" +#include "cm_jsoncpp_writer.h" #include "cmake.h" #include "cmsys/SystemInformation.hxx" @@ -34,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -41,6 +43,7 @@ #include #include +#include #include namespace { @@ -157,99 +160,134 @@ std::vector SearchPathSanitizer::operator()( } return res; } -} // End of unnamed namespace -cmQtAutoGenInitializer::InfoWriter::InfoWriter(std::string const& filename) +/** @brief Writes a CMake info file. */ +class InfoWriter { - Ofs_.SetCopyIfDifferent(true); - Ofs_.Open(filename, false, true); -} +public: + // -- Single value + void Set(std::string const& key, std::string const& value) + { + Value_[key] = value; + } + void SetConfig(std::string const& key, + cmQtAutoGenInitializer::ConfigString const& cfgStr); + void SetBool(std::string const& key, bool value) { Value_[key] = value; } + void SetUInt(std::string const& key, unsigned int value) + { + Value_[key] = value; + } + + // -- Array utility + template + static bool MakeArray(Json::Value& jval, CONT const& container); + + template + static void MakeStringArray(Json::Value& jval, CONT const& container); + + // -- Array value + template + void SetArray(std::string const& key, CONT const& container); + template + void SetConfigArray( + std::string const& key, + cmQtAutoGenInitializer::ConfigStrings const& cfgStr); -template -std::string cmQtAutoGenInitializer::InfoWriter::ListJoin(IT it_begin, - IT it_end) + // -- Array of arrays + template + void SetArrayArray(std::string const& key, CONT const& container, FUNC func); + + // -- Save to json file + bool Save(std::string const& filename); + +private: + Json::Value Value_; +}; + +void InfoWriter::SetConfig(std::string const& key, + cmQtAutoGenInitializer::ConfigString const& cfgStr) { - std::string res; - for (IT it = it_begin; it != it_end; ++it) { - if (it != it_begin) { - res += ';'; - } - for (const char* c = it->c_str(); *c; ++c) { - if (*c == '"') { - // Escape the double quote to avoid ending the argument. - res += "\\\""; - } else if (*c == '$') { - // Escape the dollar to avoid expanding variables. - res += "\\$"; - } else if (*c == '\\') { - // Escape the backslash to avoid other escapes. - res += "\\\\"; - } else if (*c == ';') { - // Escape the semicolon to avoid list expansion. - res += "\\;"; - } else { - // Other characters will be parsed correctly. - res += *c; - } - } + Set(key, cfgStr.Default); + for (auto const& item : cfgStr.Config) { + Set(cmStrCat(key, '_', item.first), item.second); } - return res; } -inline std::string cmQtAutoGenInitializer::InfoWriter::ConfigKey( - cm::string_view key, std::string const& config) +template +bool InfoWriter::MakeArray(Json::Value& jval, CONT const& container) { - return cmStrCat(key, "_", config); + jval = Json::arrayValue; + std::size_t const listSize = cm::size(container); + if (listSize == 0) { + return false; + } + jval.resize(static_cast(listSize)); + return true; } -void cmQtAutoGenInitializer::InfoWriter::Write(cm::string_view key, - std::string const& value) +template +void InfoWriter::MakeStringArray(Json::Value& jval, CONT const& container) { - Ofs_ << "set(" << key << " " << cmOutputConverter::EscapeForCMake(value) - << ")\n"; -}; - -void cmQtAutoGenInitializer::InfoWriter::WriteUInt(cm::string_view key, - unsigned int value) -{ - Ofs_ << "set(" << key << " " << value << ")\n"; -}; + if (MakeArray(jval, container)) { + Json::ArrayIndex ii = 0; + for (std::string const& item : container) { + jval[ii++] = item; + } + } +} -template -void cmQtAutoGenInitializer::InfoWriter::WriteStrings(cm::string_view key, - C const& container) +template +void InfoWriter::SetArray(std::string const& key, CONT const& container) { - Ofs_ << "set(" << key << " \"" - << ListJoin(container.begin(), container.end()) << "\")\n"; + MakeStringArray(Value_[key], container); } -void cmQtAutoGenInitializer::InfoWriter::WriteConfig( - cm::string_view key, std::map const& map) +template +void InfoWriter::SetArrayArray(std::string const& key, CONT const& container, + FUNC func) { - for (auto const& item : map) { - Write(ConfigKey(key, item.first), item.second); + Json::Value& jval = Value_[key]; + if (MakeArray(jval, container)) { + Json::ArrayIndex ii = 0; + for (auto const& citem : container) { + Json::Value& aval = jval[ii++]; + aval = Json::arrayValue; + func(aval, citem); + } } -}; +} -template -void cmQtAutoGenInitializer::InfoWriter::WriteConfigStrings( - cm::string_view key, std::map const& map) +template +void InfoWriter::SetConfigArray( + std::string const& key, + cmQtAutoGenInitializer::ConfigStrings const& cfgStr) { - for (auto const& item : map) { - WriteStrings(ConfigKey(key, item.first), item.second); + SetArray(key, cfgStr.Default); + for (auto const& item : cfgStr.Config) { + SetArray(cmStrCat(key, '_', item.first), item.second); } } -void cmQtAutoGenInitializer::InfoWriter::WriteNestedLists( - cm::string_view key, std::vector> const& lists) +bool InfoWriter::Save(std::string const& filename) { - std::vector seplist; - seplist.reserve(lists.size()); - for (std::vector const& list : lists) { - seplist.push_back(cmStrCat("{", ListJoin(list.begin(), list.end()), "}")); + cmGeneratedFileStream fileStream; + fileStream.SetCopyIfDifferent(true); + fileStream.Open(filename, false, true); + if (!fileStream) { + return false; } - Write(key, cmJoin(seplist, cmQtAutoGen::ListSep)); -}; + + Json::StyledStreamWriter jsonWriter; + try { + jsonWriter.write(fileStream, Value_); + } catch (...) { + return false; + } + + return fileStream.Close(); +} + +} // End of unnamed namespace cmQtAutoGenInitializer::cmQtAutoGenInitializer( cmQtAutoGenGlobalInitializer* globalInitializer, @@ -261,6 +299,7 @@ cmQtAutoGenInitializer::cmQtAutoGenInitializer( , GlobalGen(genTarget->GetGlobalGenerator()) , LocalGen(genTarget->GetLocalGenerator()) , Makefile(genTarget->Makefile) + , PathCheckSum(genTarget->Makefile) , QtVersion(qtVersion) { AutogenTarget.GlobalTarget = globalAutogenTarget; @@ -280,12 +319,20 @@ bool cmQtAutoGenInitializer::InitCustomTargets() } // Verbosity - this->Verbosity = this->Makefile->GetSafeDefinition("CMAKE_AUTOGEN_VERBOSE"); - if (!this->Verbosity.empty()) { - unsigned long iVerb = 0; - if (!cmStrToULong(this->Verbosity, &iVerb)) { - // Non numeric verbosity - this->Verbosity = cmIsOn(this->Verbosity) ? "1" : "0"; + { + std::string def = + this->Makefile->GetSafeDefinition("CMAKE_AUTOGEN_VERBOSE"); + if (!def.empty()) { + unsigned long iVerb = 0; + if (cmStrToULong(def, &iVerb)) { + // Numeric verbosity + this->Verbosity = static_cast(iVerb); + } else { + // Non numeric verbosity + if (cmIsOn(def)) { + this->Verbosity = 1; + } + } } } @@ -352,15 +399,9 @@ bool cmQtAutoGenInitializer::InitCustomTargets() cmSystemTools::ConvertToUnixSlashes(this->Dir.Work); // Include directory - this->Dir.Include = cmStrCat(this->Dir.Build, "/include"); - // Per config include directories - if (this->MultiConfig) { - for (std::string const& cfg : this->ConfigsList) { - std::string& dir = this->Dir.ConfigInclude[cfg]; - dir = cmStrCat(this->Dir.Build, "/include_", cfg); - } - } - this->Dir.IncludeGenExp = this->Dir.Include; + ConfigFileNames(this->Dir.Include, cmStrCat(this->Dir.Build, "/include"), + ""); + this->Dir.IncludeGenExp = this->Dir.Include.Default; if (this->MultiConfig) { this->Dir.IncludeGenExp += "_$"; } @@ -383,36 +424,31 @@ bool cmQtAutoGenInitializer::InitCustomTargets() cmStrCat(this->GenTarget->GetName(), "_autogen"); // Autogen target parallel processing - this->AutogenTarget.Parallel = - this->GenTarget->GetSafeProperty("AUTOGEN_PARALLEL"); - if (this->AutogenTarget.Parallel.empty() || - (this->AutogenTarget.Parallel == "AUTO")) { - // Autodetect number of CPUs - this->AutogenTarget.Parallel = std::to_string(GetParallelCPUCount()); + { + std::string prop = this->GenTarget->GetSafeProperty("AUTOGEN_PARALLEL"); + if (prop.empty() || (prop == "AUTO")) { + // Autodetect number of CPUs + this->AutogenTarget.Parallel = GetParallelCPUCount(); + } else { + this->AutogenTarget.Parallel = 1; + } } // Autogen target info and settings files { + // Info file this->AutogenTarget.InfoFile = - cmStrCat(this->Dir.Info, "/AutogenInfo.cmake"); + cmStrCat(this->Dir.Info, "/AutogenInfo.json"); - this->AutogenTarget.SettingsFile = - cmStrCat(this->Dir.Info, "/AutogenOldSettings.txt"); - - if (this->MultiConfig) { - for (std::string const& cfg : this->ConfigsList) { - std::string& filename = this->AutogenTarget.ConfigSettingsFile[cfg]; - filename = - AppendFilenameSuffix(this->AutogenTarget.SettingsFile, "_" + cfg); - this->AddCleanFile(filename); - } - } else { - this->AddCleanFile(this->AutogenTarget.SettingsFile); - } + // Used settings file + ConfigFileNames(this->AutogenTarget.SettingsFile, + cmStrCat(this->Dir.Info, "/AutogenUsed"), ".txt"); + ConfigFileClean(this->AutogenTarget.SettingsFile); - this->AutogenTarget.ParseCacheFile = - cmStrCat(this->Dir.Info, "/ParseCache.txt"); - this->AddCleanFile(this->AutogenTarget.ParseCacheFile); + // Parse cache file + ConfigFileNames(this->AutogenTarget.ParseCacheFile, + cmStrCat(this->Dir.Info, "/ParseCache"), ".txt"); + ConfigFileClean(this->AutogenTarget.ParseCacheFile); } // Autogen target: Compute user defined dependencies @@ -435,9 +471,15 @@ bool cmQtAutoGenInitializer::InitCustomTargets() } } - // CMAKE_AUTOMOC_RELAXED_MODE deprecation warning if (this->Moc.Enabled) { + // Path prefix + if (cmIsOn(this->GenTarget->GetSafeProperty("AUTOMOC_PATH_PREFIX"))) { + this->Moc.PathPrefix = true; + } + + // CMAKE_AUTOMOC_RELAXED_MODE if (this->Makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE")) { + this->Moc.RelaxedMode = true; this->Makefile->IssueMessage( MessageType::AUTHOR_WARNING, cmStrCat("AUTOMOC: CMAKE_AUTOMOC_RELAXED_MODE is " @@ -445,6 +487,32 @@ bool cmQtAutoGenInitializer::InitCustomTargets() "disabling it and converting the target ", this->GenTarget->GetName(), " to regular mode.")); } + + // Options + cmExpandList(this->GenTarget->GetSafeProperty("AUTOMOC_MOC_OPTIONS"), + this->Moc.Options); + // Filters + cmExpandList(this->GenTarget->GetSafeProperty("AUTOMOC_MACRO_NAMES"), + this->Moc.MacroNames); + { + auto filterList = cmExpandedList( + this->GenTarget->GetSafeProperty("AUTOMOC_DEPEND_FILTERS")); + if ((filterList.size() % 2) != 0) { + cmSystemTools::Error( + cmStrCat("AutoMoc: AUTOMOC_DEPEND_FILTERS predefs size ", + filterList.size(), " is not a multiple of 2.")); + return false; + } + this->Moc.DependFilters.reserve(1 + (filterList.size() / 2)); + this->Moc.DependFilters.emplace_back( + "Q_PLUGIN_METADATA", + "[\n][ \t]*Q_PLUGIN_METADATA[ \t]*\\(" + "[^\\)]*FILE[ \t]*\"([^\"]+)\""); + for (std::size_t ii = 0; ii != filterList.size(); ii += 2) { + this->Moc.DependFilters.emplace_back(filterList[ii], + filterList[ii + 1]); + } + } } } @@ -479,20 +547,27 @@ bool cmQtAutoGenInitializer::InitCustomTargets() bool cmQtAutoGenInitializer::InitMoc() { // Mocs compilation file - this->Moc.MocsCompilation = + this->Moc.CompilationFile = cmStrCat(this->Dir.Build, "/mocs_compilation.cpp"); - // Moc predefs command + // Moc predefs if (this->GenTarget->GetPropertyAsBool("AUTOMOC_COMPILER_PREDEFINES") && (this->QtVersion >= IntegerVersion(5, 8))) { - this->Moc.PredefsCmd = this->Makefile->GetSafeDefinition( - "CMAKE_CXX_COMPILER_PREDEFINES_COMMAND"); + // Command + cmExpandList(this->Makefile->GetSafeDefinition( + "CMAKE_CXX_COMPILER_PREDEFINES_COMMAND"), + this->Moc.PredefsCmd); + // Header + if (!this->Moc.PredefsCmd.empty()) { + ConfigFileNames(this->Moc.PredefsFile, + cmStrCat(this->Dir.Build, "/moc_predefs"), ".h"); + } } // Moc includes { SearchPathSanitizer sanitizer(this->Makefile); - auto GetIncludeDirs = + auto getDirs = [this, &sanitizer](std::string const& cfg) -> std::vector { // Get the include dirs for this target, without stripping the implicit // include dirs off, see issue #13667. @@ -504,22 +579,22 @@ bool cmQtAutoGenInitializer::InitMoc() }; // Default configuration include directories - this->Moc.Includes = GetIncludeDirs(this->ConfigDefault); + this->Moc.Includes.Default = getDirs(this->ConfigDefault); // Other configuration settings if (this->MultiConfig) { for (std::string const& cfg : this->ConfigsList) { - std::vector dirs = GetIncludeDirs(cfg); - if (dirs != this->Moc.Includes) { - this->Moc.ConfigIncludes[cfg] = std::move(dirs); + std::vector dirs = getDirs(cfg); + if (dirs == this->Moc.Includes.Default) { + continue; } + this->Moc.Includes.Config[cfg] = std::move(dirs); } } } // Moc compile definitions { - auto GetCompileDefinitions = - [this](std::string const& cfg) -> std::set { + auto getDefs = [this](std::string const& cfg) -> std::set { std::set defines; this->LocalGen->GetTargetDefines(this->GenTarget, cfg, "CXX", defines); #ifdef _WIN32 @@ -532,14 +607,15 @@ bool cmQtAutoGenInitializer::InitMoc() }; // Default configuration defines - this->Moc.Defines = GetCompileDefinitions(this->ConfigDefault); + this->Moc.Defines.Default = getDefs(this->ConfigDefault); // Other configuration defines if (this->MultiConfig) { for (std::string const& cfg : this->ConfigsList) { - std::set defines = GetCompileDefinitions(cfg); - if (defines != this->Moc.Defines) { - this->Moc.ConfigDefines[cfg] = std::move(defines); + std::set defines = getDefs(cfg); + if (defines == this->Moc.Defines.Default) { + continue; } + this->Moc.Defines.Config[cfg] = std::move(defines); } } } @@ -572,23 +648,22 @@ bool cmQtAutoGenInitializer::InitUic() } // Uic target options { - auto UicGetOpts = - [this](std::string const& cfg) -> std::vector { + auto getOpts = [this](std::string const& cfg) -> std::vector { std::vector opts; this->GenTarget->GetAutoUicOptions(opts, cfg); return opts; }; - // Default settings - this->Uic.Options = UicGetOpts(this->ConfigDefault); - - // Configuration specific settings + // Default options + this->Uic.Options.Default = getOpts(this->ConfigDefault); + // Configuration specific options if (this->MultiConfig) { for (std::string const& cfg : this->ConfigsList) { - std::vector options = UicGetOpts(cfg); - if (options != this->Uic.Options) { - this->Uic.ConfigOptions[cfg] = std::move(options); + std::vector options = getOpts(cfg); + if (options == this->Uic.Options.Default) { + continue; } + this->Uic.Options.Config[cfg] = std::move(options); } } } @@ -822,8 +897,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() // Check if the .ui file has uic options std::string const uicOpts = sf->GetSafeProperty(kw.AUTOUIC_OPTIONS); if (!uicOpts.empty()) { - this->Uic.FileFiles.push_back(fullPath); - this->Uic.FileOptions.push_back(cmExpandedList(uicOpts)); + this->Uic.UiFiles.emplace_back(fullPath, cmExpandedList(uicOpts)); } } else { // Register skipped .ui file @@ -887,31 +961,17 @@ bool cmQtAutoGenInitializer::InitScanFiles() } } // Path checksum and file names - { - cmFilePathChecksum const fpathCheckSum(this->Makefile); - for (Qrc& qrc : this->Rcc.Qrcs) { - // Path checksum - qrc.QrcPathChecksum = fpathCheckSum.getPart(qrc.QrcFile); - // Output file name - qrc.OutputFile = cmStrCat(this->Dir.Build, '/', qrc.QrcPathChecksum, - "/qrc_", qrc.QrcName, ".cpp"); - { - cm::string_view const baseSuffix = qrc.Unique - ? cm::string_view() - : cm::string_view(qrc.QrcPathChecksum); - std::string const base = - cmStrCat(this->Dir.Info, "/RCC", qrc.QrcName, baseSuffix); - qrc.LockFile = cmStrCat(base, ".lock"); - qrc.InfoFile = cmStrCat(base, "Info.cmake"); - qrc.SettingsFile = cmStrCat(base, "Settings.txt"); - if (this->MultiConfig) { - for (std::string const& cfg : this->ConfigsList) { - qrc.ConfigSettingsFile[cfg] = - AppendFilenameSuffix(qrc.SettingsFile, "_" + cfg); - } - } - } - } + for (Qrc& qrc : this->Rcc.Qrcs) { + // Path checksum + qrc.QrcPathChecksum = this->PathCheckSum.getPart(qrc.QrcFile); + // Output file name + qrc.OutputFile = cmStrCat(this->Dir.Build, '/', qrc.QrcPathChecksum, + "/qrc_", qrc.QrcName, ".cpp"); + std::string const base = cmStrCat(this->Dir.Info, "/AutoRcc_", + qrc.QrcName, '_', qrc.QrcPathChecksum); + qrc.LockFile = cmStrCat(base, "_Lock.lock"); + qrc.InfoFile = cmStrCat(base, "_Info.json"); + ConfigFileNames(qrc.SettingsFile, cmStrCat(base, "_Used"), ".txt"); } // rcc options for (Qrc& qrc : this->Rcc.Qrcs) { @@ -959,8 +1019,8 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() // Files provided by the autogen target std::vector autogenProvides; if (this->Moc.Enabled) { - this->AddGeneratedSource(this->Moc.MocsCompilation, this->Moc, true); - autogenProvides.push_back(this->Moc.MocsCompilation); + this->AddGeneratedSource(this->Moc.CompilationFile, this->Moc, true); + autogenProvides.push_back(this->Moc.CompilationFile); } // Compose target comment @@ -1214,229 +1274,185 @@ bool cmQtAutoGenInitializer::SetupCustomTargets() bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() { - InfoWriter ofs(this->AutogenTarget.InfoFile); - if (ofs) { - // Utility lambdas - auto MfDef = [this](const char* key) { - return this->Makefile->GetSafeDefinition(key); - }; + // Utility lambdas + auto MfDef = [this](std::string const& key) { + return this->Makefile->GetSafeDefinition(key); + }; - // Write common settings - ofs.Write("# Meta\n"); - ofs.Write("AM_MULTI_CONFIG", this->MultiConfig ? "TRUE" : "FALSE"); - ofs.Write("AM_PARALLEL", this->AutogenTarget.Parallel); - ofs.Write("AM_VERBOSITY", this->Verbosity); - - ofs.Write("# Directories\n"); - ofs.Write("AM_CMAKE_SOURCE_DIR", MfDef("CMAKE_SOURCE_DIR")); - ofs.Write("AM_CMAKE_BINARY_DIR", MfDef("CMAKE_BINARY_DIR")); - ofs.Write("AM_CMAKE_CURRENT_SOURCE_DIR", - MfDef("CMAKE_CURRENT_SOURCE_DIR")); - ofs.Write("AM_CMAKE_CURRENT_BINARY_DIR", - MfDef("CMAKE_CURRENT_BINARY_DIR")); - ofs.Write("AM_BUILD_DIR", this->Dir.Build); - ofs.Write("AM_INCLUDE_DIR", this->Dir.Include); - ofs.WriteConfig("AM_INCLUDE_DIR", this->Dir.ConfigInclude); - - std::vector headers; - std::vector headersFlags; - std::vector headersBuildPaths; - std::vector sources; - std::vector sourcesFlags; - std::set moc_skip; - std::set uic_skip; - - // Filter headers - { - auto headerCount = this->AutogenTarget.Headers.size(); - headers.reserve(headerCount); - headersFlags.reserve(headerCount); + // Filtered headers and sources + std::set moc_skip; + std::set uic_skip; + std::vector headers; + std::vector sources; - std::vector sortedHeaders; - { - sortedHeaders.reserve(headerCount); - for (auto const& pair : this->AutogenTarget.Headers) { - sortedHeaders.emplace_back(pair.second.get()); - } - std::sort(sortedHeaders.begin(), sortedHeaders.end(), - [](MUFile const* a, MUFile const* b) { - return (a->FullPath < b->FullPath); - }); + // Filter headers + { + headers.reserve(this->AutogenTarget.Headers.size()); + for (auto const& pair : this->AutogenTarget.Headers) { + MUFile const* const muf = pair.second.get(); + if (muf->Generated && !this->CMP0071Accept) { + continue; } - - for (MUFile const* const muf : sortedHeaders) { - if (muf->Generated && !this->CMP0071Accept) { - continue; - } - if (muf->SkipMoc) { - moc_skip.insert(muf->FullPath); - } - if (muf->SkipUic) { - uic_skip.insert(muf->FullPath); - } - if (muf->MocIt || muf->UicIt) { - headers.emplace_back(muf->FullPath); - headersFlags.emplace_back( - cmStrCat(muf->MocIt ? 'M' : 'm', muf->UicIt ? 'U' : 'u')); - } + if (muf->SkipMoc) { + moc_skip.insert(muf->FullPath); } - } - // Header build paths - { - cmFilePathChecksum const fpathCheckSum(this->Makefile); - std::unordered_set emitted; - for (std::string const& hdr : headers) { - std::string const basePath = - cmStrCat(fpathCheckSum.getPart(hdr), "/moc_", - cmSystemTools::GetFilenameWithoutLastExtension(hdr)); - std::string suffix; - for (int ii = 0; ii != 1024; ++ii) { - std::string path = cmStrCat(basePath, suffix, ".cpp"); - if (emitted.emplace(path).second) { - headersBuildPaths.emplace_back(std::move(path)); - break; - } - suffix = cmStrCat('_', ii + 1); - } + if (muf->SkipUic) { + uic_skip.insert(muf->FullPath); + } + if (muf->MocIt || muf->UicIt) { + headers.emplace_back(muf); } } + std::sort(headers.begin(), headers.end(), + [](MUFile const* a, MUFile const* b) { + return (a->FullPath < b->FullPath); + }); + } - // Filter sources - { - auto sourcesCount = this->AutogenTarget.Sources.size(); - sources.reserve(sourcesCount); - sourcesFlags.reserve(sourcesCount); - - std::vector sorted; - sorted.reserve(sourcesCount); - for (auto const& pair : this->AutogenTarget.Sources) { - sorted.emplace_back(pair.second.get()); + // Filter sources + { + sources.reserve(this->AutogenTarget.Sources.size()); + for (auto const& pair : this->AutogenTarget.Sources) { + MUFile const* const muf = pair.second.get(); + if (muf->Generated && !this->CMP0071Accept) { + continue; } - std::sort(sorted.begin(), sorted.end(), - [](MUFile const* a, MUFile const* b) { - return (a->FullPath < b->FullPath); - }); - - for (MUFile const* const muf : sorted) { - if (muf->Generated && !this->CMP0071Accept) { - continue; - } - if (muf->SkipMoc) { - moc_skip.insert(muf->FullPath); - } - if (muf->SkipUic) { - uic_skip.insert(muf->FullPath); - } - if (muf->MocIt || muf->UicIt) { - sources.emplace_back(muf->FullPath); - sourcesFlags.emplace_back( - cmStrCat(muf->MocIt ? 'M' : 'm', muf->UicIt ? 'U' : 'u')); - } + if (muf->SkipMoc) { + moc_skip.insert(muf->FullPath); + } + if (muf->SkipUic) { + uic_skip.insert(muf->FullPath); + } + if (muf->MocIt || muf->UicIt) { + sources.emplace_back(muf); } } + std::sort(sources.begin(), sources.end(), + [](MUFile const* a, MUFile const* b) { + return (a->FullPath < b->FullPath); + }); + } - ofs.Write("# Qt\n"); - ofs.WriteUInt("AM_QT_VERSION_MAJOR", this->QtVersion.Major); - ofs.Write("AM_QT_MOC_EXECUTABLE", this->Moc.Executable); - ofs.Write("AM_QT_UIC_EXECUTABLE", this->Uic.Executable); - - ofs.Write("# Files\n"); - ofs.Write("AM_CMAKE_EXECUTABLE", cmSystemTools::GetCMakeCommand()); - ofs.Write("AM_SETTINGS_FILE", this->AutogenTarget.SettingsFile); - ofs.WriteConfig("AM_SETTINGS_FILE", - this->AutogenTarget.ConfigSettingsFile); - ofs.Write("AM_PARSE_CACHE_FILE", this->AutogenTarget.ParseCacheFile); - ofs.WriteStrings("AM_HEADERS", headers); - ofs.WriteStrings("AM_HEADERS_FLAGS", headersFlags); - ofs.WriteStrings("AM_HEADERS_BUILD_PATHS", headersBuildPaths); - ofs.WriteStrings("AM_SOURCES", sources); - ofs.WriteStrings("AM_SOURCES_FLAGS", sourcesFlags); - - // Write moc settings - if (this->Moc.Enabled) { - ofs.Write("# MOC settings\n"); - ofs.WriteStrings("AM_MOC_SKIP", moc_skip); - ofs.WriteStrings("AM_MOC_DEFINITIONS", this->Moc.Defines); - ofs.WriteConfigStrings("AM_MOC_DEFINITIONS", this->Moc.ConfigDefines); - ofs.WriteStrings("AM_MOC_INCLUDES", this->Moc.Includes); - ofs.WriteConfigStrings("AM_MOC_INCLUDES", this->Moc.ConfigIncludes); - ofs.Write("AM_MOC_OPTIONS", - this->GenTarget->GetSafeProperty("AUTOMOC_MOC_OPTIONS")); - ofs.Write("AM_MOC_RELAXED_MODE", MfDef("CMAKE_AUTOMOC_RELAXED_MODE")); - ofs.Write("AM_MOC_PATH_PREFIX", - this->GenTarget->GetSafeProperty("AUTOMOC_PATH_PREFIX")); - ofs.Write("AM_MOC_MACRO_NAMES", - this->GenTarget->GetSafeProperty("AUTOMOC_MACRO_NAMES")); - ofs.Write("AM_MOC_DEPEND_FILTERS", - this->GenTarget->GetSafeProperty("AUTOMOC_DEPEND_FILTERS")); - ofs.Write("AM_MOC_PREDEFS_CMD", this->Moc.PredefsCmd); - } - - // Write uic settings - if (this->Uic.Enabled) { - // Add skipped .ui files - uic_skip.insert(this->Uic.SkipUi.begin(), this->Uic.SkipUi.end()); + // Info writer + InfoWriter info; + + // General + info.SetBool("MULTI_CONFIG", this->MultiConfig); + info.SetUInt("PARALLEL", this->AutogenTarget.Parallel); + info.SetUInt("VERBOSITY", this->Verbosity); + + // Directories + info.Set("CMAKE_SOURCE_DIR", MfDef("CMAKE_SOURCE_DIR")); + info.Set("CMAKE_BINARY_DIR", MfDef("CMAKE_BINARY_DIR")); + info.Set("CMAKE_CURRENT_SOURCE_DIR", MfDef("CMAKE_CURRENT_SOURCE_DIR")); + info.Set("CMAKE_CURRENT_BINARY_DIR", MfDef("CMAKE_CURRENT_BINARY_DIR")); + info.Set("BUILD_DIR", this->Dir.Build); + info.SetConfig("INCLUDE_DIR", this->Dir.Include); + + info.SetUInt("QT_VERSION_MAJOR", this->QtVersion.Major); + info.Set("QT_MOC_EXECUTABLE", this->Moc.Executable); + info.Set("QT_UIC_EXECUTABLE", this->Uic.Executable); + + info.Set("CMAKE_EXECUTABLE", cmSystemTools::GetCMakeCommand()); + info.SetConfig("SETTINGS_FILE", this->AutogenTarget.SettingsFile); + info.SetConfig("PARSE_CACHE_FILE", this->AutogenTarget.ParseCacheFile); + info.SetArray("HEADER_EXTENSIONS", + this->Makefile->GetCMakeInstance()->GetHeaderExtensions()); + info.SetArrayArray( + "HEADERS", headers, [this](Json::Value& jval, MUFile const* muf) { + jval.resize(3u); + jval[0u] = muf->FullPath; + jval[1u] = cmStrCat(muf->MocIt ? 'M' : 'm', muf->UicIt ? 'U' : 'u'); + jval[2u] = this->GetMocBuildPath(*muf); + }); + info.SetArrayArray( + "SOURCES", sources, [](Json::Value& jval, MUFile const* muf) { + jval.resize(2u); + jval[0u] = muf->FullPath; + jval[1u] = cmStrCat(muf->MocIt ? 'M' : 'm', muf->UicIt ? 'U' : 'u'); + }); + + // Write moc settings + if (this->Moc.Enabled) { + info.SetArray("MOC_SKIP", moc_skip); + info.SetConfigArray("MOC_DEFINITIONS", this->Moc.Defines); + info.SetConfigArray("MOC_INCLUDES", this->Moc.Includes); + info.SetArray("MOC_OPTIONS", this->Moc.Options); + info.SetBool("MOC_RELAXED_MODE", this->Moc.RelaxedMode); + info.SetBool("MOC_PATH_PREFIX", this->Moc.PathPrefix); + info.SetArray("MOC_MACRO_NAMES", this->Moc.MacroNames); + info.SetArrayArray( + "MOC_DEPEND_FILTERS", this->Moc.DependFilters, + [](Json::Value& jval, std::pair const& pair) { + jval.resize(2u); + jval[0u] = pair.first; + jval[1u] = pair.second; + }); + info.Set("MOC_COMPILATION_FILE", this->Moc.CompilationFile); + info.SetArray("MOC_PREDEFS_CMD", this->Moc.PredefsCmd); + info.SetConfig("MOC_PREDEFS_FILE", this->Moc.PredefsFile); + } - ofs.Write("# UIC settings\n"); - ofs.WriteStrings("AM_UIC_SKIP", uic_skip); - ofs.WriteStrings("AM_UIC_TARGET_OPTIONS", this->Uic.Options); - ofs.WriteConfigStrings("AM_UIC_TARGET_OPTIONS", this->Uic.ConfigOptions); - ofs.WriteStrings("AM_UIC_OPTIONS_FILES", this->Uic.FileFiles); - ofs.WriteNestedLists("AM_UIC_OPTIONS_OPTIONS", this->Uic.FileOptions); - ofs.WriteStrings("AM_UIC_SEARCH_PATHS", this->Uic.SearchPaths); - } - } else { - cmSystemTools::Error(cmStrCat("AutoGen: Could not write file ", - this->AutogenTarget.InfoFile)); - return false; + // Write uic settings + if (this->Uic.Enabled) { + // Add skipped .ui files + uic_skip.insert(this->Uic.SkipUi.begin(), this->Uic.SkipUi.end()); + + info.SetArray("UIC_SKIP", uic_skip); + info.SetArrayArray("UIC_UI_FILES", this->Uic.UiFiles, + [](Json::Value& jval, UicT::UiFileT const& uiFile) { + jval.resize(2u); + jval[0u] = uiFile.first; + InfoWriter::MakeStringArray(jval[1u], uiFile.second); + }); + info.SetConfigArray("UIC_OPTIONS", this->Uic.Options); + info.SetArray("UIC_SEARCH_PATHS", this->Uic.SearchPaths); } + info.Save(this->AutogenTarget.InfoFile); + return true; } bool cmQtAutoGenInitializer::SetupWriteRccInfo() { for (Qrc const& qrc : this->Rcc.Qrcs) { - InfoWriter ofs(qrc.InfoFile); - if (ofs) { - // Utility lambdas - auto MfDef = [this](const char* key) { - return this->Makefile->GetSafeDefinition(key); - }; + // Utility lambdas + auto MfDef = [this](std::string const& key) { + return this->Makefile->GetSafeDefinition(key); + }; - // Write - ofs.Write("# Configurations\n"); - ofs.Write("ARCC_MULTI_CONFIG", this->MultiConfig ? "TRUE" : "FALSE"); - ofs.Write("ARCC_VERBOSITY", this->Verbosity); - ofs.Write("# Settings file\n"); - ofs.Write("ARCC_SETTINGS_FILE", qrc.SettingsFile); - ofs.WriteConfig("ARCC_SETTINGS_FILE", qrc.ConfigSettingsFile); - - ofs.Write("# Directories\n"); - ofs.Write("ARCC_CMAKE_SOURCE_DIR", MfDef("CMAKE_SOURCE_DIR")); - ofs.Write("ARCC_CMAKE_BINARY_DIR", MfDef("CMAKE_BINARY_DIR")); - ofs.Write("ARCC_BUILD_DIR", this->Dir.Build); - ofs.Write("ARCC_INCLUDE_DIR", this->Dir.Include); - ofs.WriteConfig("ARCC_INCLUDE_DIR", this->Dir.ConfigInclude); - - ofs.Write("# Rcc executable\n"); - ofs.Write("ARCC_RCC_EXECUTABLE", this->Rcc.Executable); - ofs.WriteStrings("ARCC_RCC_LIST_OPTIONS", - this->Rcc.ExecutableFeatures->ListOptions); - - ofs.Write("# Rcc job\n"); - ofs.Write("ARCC_LOCK_FILE", qrc.LockFile); - ofs.Write("ARCC_SOURCE", qrc.QrcFile); - ofs.Write("ARCC_OUTPUT_CHECKSUM", qrc.QrcPathChecksum); - ofs.Write("ARCC_OUTPUT_NAME", - cmSystemTools::GetFilenameName(qrc.OutputFile)); - ofs.WriteStrings("ARCC_OPTIONS", qrc.Options); - ofs.WriteStrings("ARCC_INPUTS", qrc.Resources); - } else { - cmSystemTools::Error( - cmStrCat("AutoRcc: Could not write file ", qrc.InfoFile)); - return false; - } + InfoWriter info; + + // General + info.SetBool("MULTI_CONFIG", this->MultiConfig); + info.SetUInt("VERBOSITY", this->Verbosity); + + // Files + info.Set("LOCK_FILE", qrc.LockFile); + info.SetConfig("SETTINGS_FILE", qrc.SettingsFile); + + // Directories + info.Set("CMAKE_SOURCE_DIR", MfDef("CMAKE_SOURCE_DIR")); + info.Set("CMAKE_BINARY_DIR", MfDef("CMAKE_BINARY_DIR")); + info.Set("CMAKE_CURRENT_SOURCE_DIR", MfDef("CMAKE_CURRENT_SOURCE_DIR")); + info.Set("CMAKE_CURRENT_BINARY_DIR", MfDef("CMAKE_CURRENT_BINARY_DIR")); + info.Set("BUILD_DIR", this->Dir.Build); + info.SetConfig("INCLUDE_DIR", this->Dir.Include); + + // rcc executable + info.Set("RCC_EXECUTABLE", this->Rcc.Executable); + info.SetArray("RCC_LIST_OPTIONS", + this->Rcc.ExecutableFeatures->ListOptions); + + // qrc file + info.Set("SOURCE", qrc.QrcFile); + info.Set("OUTPUT_CHECKSUM", qrc.QrcPathChecksum); + info.Set("OUTPUT_NAME", cmSystemTools::GetFilenameName(qrc.OutputFile)); + info.SetArray("OPTIONS", qrc.Options); + info.SetArray("INPUTS", qrc.Resources); + + info.Save(qrc.InfoFile); } return true; @@ -1509,6 +1525,28 @@ void cmQtAutoGenInitializer::AddCleanFile(std::string const& fileName) fileName.c_str(), false); } +void cmQtAutoGenInitializer::ConfigFileNames(ConfigString& configString, + cm::string_view prefix, + cm::string_view suffix) +{ + configString.Default = cmStrCat(prefix, suffix); + if (this->MultiConfig) { + for (auto const& cfg : this->ConfigsList) { + configString.Config[cfg] = cmStrCat(prefix, '_', cfg, suffix); + } + } +} + +void cmQtAutoGenInitializer::ConfigFileClean(ConfigString& configString) +{ + this->AddCleanFile(configString.Default); + if (this->MultiConfig) { + for (auto const& pair : configString.Config) { + this->AddCleanFile(pair.second); + } + } +} + std::pair cmQtAutoGenInitializer::GetQtVersion(cmGeneratorTarget const* target) { @@ -1581,6 +1619,30 @@ cmQtAutoGenInitializer::GetQtVersion(cmGeneratorTarget const* target) return res; } +std::string cmQtAutoGenInitializer::GetMocBuildPath(MUFile const& muf) +{ + std::string res; + if (!muf.MocIt) { + return res; + } + { + std::string const basePath = + cmStrCat(this->PathCheckSum.getPart(muf.FullPath), "/moc_", + FileNameWithoutLastExtension(muf.FullPath)); + std::string suffix; + constexpr std::size_t num_tries_max = 256; + for (std::size_t ii = 0; ii != num_tries_max; ++ii) { + res = cmStrCat(basePath, suffix, ".cpp"); + if (this->Moc.EmittedBuildPaths.emplace(res).second) { + break; + } + // Compute new suffix + suffix = cmStrCat('_', ii + 1); + } + } + return res; +} + bool cmQtAutoGenInitializer::GetQtExecutable(GenVarsT& genVars, const std::string& executable, bool ignoreMissingTarget) const diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h index 2411936..0580ddb 100644 --- a/Source/cmQtAutoGenInitializer.h +++ b/Source/cmQtAutoGenInitializer.h @@ -4,17 +4,16 @@ #define cmQtAutoGenInitializer_h #include "cmConfigure.h" // IWYU pragma: keep -#include "cmGeneratedFileStream.h" +#include "cmFilePathChecksum.h" #include "cmQtAutoGen.h" #include -#include #include -#include #include #include #include +#include #include #include @@ -32,6 +31,23 @@ class cmTarget; class cmQtAutoGenInitializer : public cmQtAutoGen { public: + /** String value with per configuration variants. */ + class ConfigString + { + public: + std::string Default; + std::unordered_map Config; + }; + + /** String values with per configuration variants. */ + template + class ConfigStrings + { + public: + C Default; + std::unordered_map Config; + }; + /** rcc job. */ class Qrc { @@ -41,8 +57,7 @@ public: std::string QrcName; std::string QrcPathChecksum; std::string InfoFile; - std::string SettingsFile; - std::map ConfigSettingsFile; + ConfigString SettingsFile; std::string OutputFile; bool Generated = false; bool Unique = false; @@ -63,7 +78,7 @@ public: }; using MUFileHandle = std::unique_ptr; - /** Abstract moc/uic/rcc generator variables base class */ + /** Abstract moc/uic/rcc generator variables base class. */ struct GenVarsT { bool Enabled = false; @@ -81,39 +96,6 @@ public: , GenNameUpper(cmQtAutoGen::GeneratorNameUpper(gen)){}; }; - /** Writes a CMake info file. */ - class InfoWriter - { - public: - /** Open the given file. */ - InfoWriter(std::string const& filename); - - /** @return True if the file is open. */ - explicit operator bool() const { return static_cast(Ofs_); } - - void Write(cm::string_view text) { Ofs_ << text; } - void Write(cm::string_view, std::string const& value); - void WriteUInt(cm::string_view, unsigned int value); - - template - void WriteStrings(cm::string_view, C const& container); - void WriteConfig(cm::string_view, - std::map const& map); - template - void WriteConfigStrings(cm::string_view, - std::map const& map); - void WriteNestedLists(cm::string_view, - std::vector> const& lists); - - private: - template - static std::string ListJoin(IT it_begin, IT it_end); - static std::string ConfigKey(cm::string_view, std::string const& config); - - private: - cmGeneratedFileStream Ofs_; - }; - public: /** @return The detected Qt version and the required Qt major version. */ static std::pair GetQtVersion( @@ -153,6 +135,12 @@ private: cm::string_view genNameUpper); void AddCleanFile(std::string const& fileName); + void ConfigFileNames(ConfigString& configString, cm::string_view prefix, + cm::string_view suffix); + void ConfigFileClean(ConfigString& configString); + + std::string GetMocBuildPath(MUFile const& muf); + bool GetQtExecutable(GenVarsT& genVars, const std::string& executable, bool ignoreMissingTarget) const; @@ -162,16 +150,17 @@ private: cmGlobalGenerator* GlobalGen = nullptr; cmLocalGenerator* LocalGen = nullptr; cmMakefile* Makefile = nullptr; + cmFilePathChecksum const PathCheckSum; // -- Configuration IntegerVersion QtVersion; + unsigned int Verbosity = 0; bool MultiConfig = false; + bool CMP0071Accept = false; + bool CMP0071Warn = false; std::string ConfigDefault; std::vector ConfigsList; - std::string Verbosity; std::string TargetsFolder; - bool CMP0071Accept = false; - bool CMP0071Warn = false; /** Common directories. */ struct @@ -179,8 +168,7 @@ private: std::string Info; std::string Build; std::string Work; - std::string Include; - std::map ConfigInclude; + ConfigString Include; std::string IncludeGenExp; } Dir; @@ -190,12 +178,11 @@ private: std::string Name; bool GlobalTarget = false; // Settings - std::string Parallel; + unsigned int Parallel = 1; // Configuration files std::string InfoFile; - std::string SettingsFile; - std::string ParseCacheFile; - std::map ConfigSettingsFile; + ConfigString SettingsFile; + ConfigString ParseCacheFile; // Dependencies bool DependOrigin = false; std::set DependFiles; @@ -212,26 +199,37 @@ private: MocT() : GenVarsT(GenT::MOC){}; - std::string PredefsCmd; - std::vector Includes; - std::map> ConfigIncludes; - std::set Defines; - std::map> ConfigDefines; - std::string MocsCompilation; + bool RelaxedMode = false; + bool PathPrefix = false; + std::string CompilationFile; + // Compiler implicit pre defines + std::vector PredefsCmd; + ConfigString PredefsFile; + // Defines + ConfigStrings> Defines; + // Includes + ConfigStrings> Includes; + // Options + std::vector Options; + // Filters + std::vector MacroNames; + std::vector> DependFilters; + // Utility + std::unordered_set EmittedBuildPaths; } Moc; /** uic variables. */ struct UicT : public GenVarsT { + using UiFileT = std::pair>; + UicT() : GenVarsT(GenT::UIC){}; std::set SkipUi; + std::vector UiFiles; + ConfigStrings> Options; std::vector SearchPaths; - std::vector Options; - std::map> ConfigOptions; - std::vector FileFiles; - std::vector> FileOptions; } Uic; /** rcc variables. */ diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx index eb829fa..a9d4fee 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -2,19 +2,11 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmQtAutoGenerator.h" -#include - -#include "cmsys/FStream.hxx" - -#include "cmGlobalGenerator.h" -#include "cmMakefile.h" #include "cmQtAutoGen.h" -#include "cmState.h" -#include "cmStateDirectory.h" -#include "cmStateSnapshot.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include "cmake.h" +#include "cm_jsoncpp_reader.h" +#include "cmsys/FStream.hxx" cmQtAutoGenerator::Logger::Logger() { @@ -44,13 +36,10 @@ cmQtAutoGenerator::Logger::Logger() cmQtAutoGenerator::Logger::~Logger() = default; -void cmQtAutoGenerator::Logger::RaiseVerbosity(std::string const& value) +void cmQtAutoGenerator::Logger::RaiseVerbosity(unsigned int value) { - unsigned long verbosity = 0; - if (cmStrToULong(value, &verbosity)) { - if (this->Verbosity_ < verbosity) { - this->Verbosity_ = static_cast(verbosity); - } + if (this->Verbosity_ < value) { + this->Verbosity_ = value; } } @@ -214,7 +203,10 @@ bool cmQtAutoGenerator::FileDiffers(std::string const& filename, return differs; } -cmQtAutoGenerator::cmQtAutoGenerator() = default; +cmQtAutoGenerator::cmQtAutoGenerator(GenT genType) + : GenType_(genType) +{ +} cmQtAutoGenerator::~cmQtAutoGenerator() = default; @@ -223,7 +215,7 @@ bool cmQtAutoGenerator::Run(std::string const& infoFile, { // Info settings InfoFile_ = infoFile; - cmSystemTools::ConvertToUnixSlashes(InfoFile_); + cmSystemTools::CollapseFullPath(InfoFile_); if (!InfoFileTime_.Load(InfoFile_)) { cmSystemTools::Stderr(cmStrCat("AutoGen: The info file ", Quoted(InfoFile_), " is not readable\n")); @@ -232,29 +224,221 @@ bool cmQtAutoGenerator::Run(std::string const& infoFile, InfoDir_ = cmSystemTools::GetFilenamePath(infoFile); InfoConfig_ = config; - bool success = false; + // Read info file { - cmake cm(cmake::RoleScript, cmState::Unknown); - cm.SetHomeOutputDirectory(InfoDir()); - cm.SetHomeDirectory(InfoDir()); - cm.GetCurrentSnapshot().SetDefaultDefinitions(); - cmGlobalGenerator gg(&cm); - - cmStateSnapshot snapshot = cm.GetCurrentSnapshot(); - snapshot.GetDirectory().SetCurrentBinary(InfoDir()); - snapshot.GetDirectory().SetCurrentSource(InfoDir()); - - auto makefile = cm::make_unique(&gg, snapshot); - // The OLD/WARN behavior for policy CMP0053 caused a speed regression. - // https://gitlab.kitware.com/cmake/cmake/issues/17570 - makefile->SetPolicyVersion("3.9", std::string()); - gg.SetCurrentMakefile(makefile.get()); - success = this->Init(makefile.get()); + cmsys::ifstream ifs(InfoFile_.c_str(), (std::ios::in | std::ios::binary)); + if (!ifs) { + Log().Error(GenType_, + cmStrCat("Could not to open info file ", Quoted(InfoFile_))); + return false; + } + try { + ifs >> Info_; + } catch (...) { + Log().Error(GenType_, + cmStrCat("Could not read info file ", Quoted(InfoFile_))); + return false; + } } - if (success) { - success = this->Process(); + // Info: setup logger + { + unsigned int value = 0; + if (!InfoUInt("VERBOSITY", value, false)) { + return false; + } + Logger_.RaiseVerbosity(value); } - return success; + // Info: setup project directories + if (!InfoString("CMAKE_SOURCE_DIR", ProjectDirs_.Source, true) || + !InfoString("CMAKE_BINARY_DIR", ProjectDirs_.Binary, true) || + !InfoString("CMAKE_CURRENT_SOURCE_DIR", ProjectDirs_.CurrentSource, + true) || + !InfoString("CMAKE_CURRENT_BINARY_DIR", ProjectDirs_.CurrentBinary, + true)) { + return false; + } + + if (!this->InitFromInfo()) { + return false; + } + // Clear info + Info_ = Json::nullValue; + + return this->Process(); +} + +bool cmQtAutoGenerator::LogInfoError(GenT genType, + cm::string_view message) const +{ + this->Log().Error( + genType, + cmStrCat("Info error in info file\n", Quoted(InfoFile()), ":\n", message)); + return false; +} + +bool cmQtAutoGenerator::LogInfoError(cm::string_view message) const +{ + return LogInfoError(GenType_, message); +} + +bool cmQtAutoGenerator::JsonGetArray(std::vector& list, + Json::Value const& jval) +{ + Json::ArrayIndex const arraySize = jval.size(); + if (arraySize == 0) { + return false; + } + + bool picked = false; + list.reserve(list.size() + arraySize); + for (Json::ArrayIndex ii = 0; ii != arraySize; ++ii) { + Json::Value const& ival = jval[ii]; + if (ival.isString()) { + list.emplace_back(ival.asString()); + picked = true; + } + } + return picked; +} + +bool cmQtAutoGenerator::JsonGetArray(std::unordered_set& list, + Json::Value const& jval) +{ + Json::ArrayIndex const arraySize = jval.size(); + if (arraySize == 0) { + return false; + } + + bool picked = false; + list.reserve(list.size() + arraySize); + for (Json::ArrayIndex ii = 0; ii != arraySize; ++ii) { + Json::Value const& ival = jval[ii]; + if (ival.isString()) { + list.emplace(ival.asString()); + picked = true; + } + } + return picked; +} + +std::string cmQtAutoGenerator::InfoConfigKey(std::string const& key) const +{ + return cmStrCat(key, '_', InfoConfig()); +} + +bool cmQtAutoGenerator::InfoString(std::string const& key, std::string& value, + bool required) const +{ + Json::Value const& jval = Info()[key]; + if (!jval.isString()) { + if (!jval.isNull() || required) { + return LogInfoError(cmStrCat(key, " is not a string.")); + } + } else { + value = jval.asString(); + if (value.empty() && required) { + return LogInfoError(cmStrCat(key, " is empty.")); + } + } + return true; +} + +bool cmQtAutoGenerator::InfoStringConfig(std::string const& key, + std::string& value, + + bool required) const +{ + { // Try config + std::string const configKey = InfoConfigKey(key); + Json::Value const& jval = Info_[configKey]; + if (!jval.isNull()) { + if (!jval.isString()) { + return LogInfoError(cmStrCat(configKey, " is not a string.")); + } + value = jval.asString(); + if (required && value.empty()) { + return LogInfoError(cmStrCat(configKey, " is empty.")); + } + return true; + } + } + // Try plain + return InfoString(key, value, required); +} + +bool cmQtAutoGenerator::InfoBool(std::string const& key, bool& value, + bool required) const +{ + Json::Value const& jval = Info()[key]; + if (jval.isBool()) { + value = jval.asBool(); + } else { + if (!jval.isNull() || required) { + return LogInfoError(cmStrCat(key, " is not a boolean.")); + } + } + return true; +} + +bool cmQtAutoGenerator::InfoUInt(std::string const& key, unsigned int& value, + bool required) const +{ + Json::Value const& jval = Info()[key]; + if (jval.isUInt()) { + value = jval.asUInt(); + } else { + if (!jval.isNull() || required) { + return LogInfoError(cmStrCat(key, " is not an unsigned integer.")); + } + } + return true; +} + +bool cmQtAutoGenerator::InfoArray(std::string const& key, + std::vector& list, + bool required) const +{ + Json::Value const& jval = Info()[key]; + if (!jval.isArray()) { + if (!jval.isNull() || required) { + return LogInfoError(cmStrCat(key, " is not an array.")); + } + } + return JsonGetArray(list, jval) || !required; +} + +bool cmQtAutoGenerator::InfoArray(std::string const& key, + std::unordered_set& list, + bool required) const +{ + Json::Value const& jval = Info()[key]; + if (!jval.isArray()) { + if (!jval.isNull() || required) { + return LogInfoError(cmStrCat(key, " is not an array.")); + } + } + return JsonGetArray(list, jval) || !required; +} + +bool cmQtAutoGenerator::InfoArrayConfig(std::string const& key, + std::vector& list, + bool required) const +{ + { // Try config + std::string const configKey = InfoConfigKey(key); + Json::Value const& jval = Info()[configKey]; + if (!jval.isNull()) { + if (!jval.isArray()) { + return LogInfoError(cmStrCat(configKey, " is not an array string.")); + } + if (!JsonGetArray(list, jval) && required) { + return LogInfoError(cmStrCat(configKey, " is empty.")); + } + return true; + } + } + // Try plain + return InfoArray(key, list, required); } std::string cmQtAutoGenerator::SettingsFind(std::string const& content, diff --git a/Source/cmQtAutoGenerator.h b/Source/cmQtAutoGenerator.h index f60acb0..7f83fc6 100644 --- a/Source/cmQtAutoGenerator.h +++ b/Source/cmQtAutoGenerator.h @@ -7,15 +7,15 @@ #include "cmFileTime.h" #include "cmQtAutoGen.h" +#include "cm_jsoncpp_value.h" #include #include #include +#include #include -class cmMakefile; - /** \class cmQtAutoGenerator * \brief Base class for QtAutoGen generators */ @@ -34,7 +34,7 @@ public: // -- Verbosity unsigned int Verbosity() const { return this->Verbosity_; } void SetVerbosity(unsigned int value) { this->Verbosity_ = value; } - void RaiseVerbosity(std::string const& value); + void RaiseVerbosity(unsigned int value); bool Verbose() const { return (this->Verbosity_ != 0); } void SetVerbose(bool value) { this->Verbosity_ = value ? 1 : 0; } // -- Color output @@ -80,7 +80,7 @@ public: public: // -- Constructors - cmQtAutoGenerator(); + cmQtAutoGenerator(GenT genType); virtual ~cmQtAutoGenerator(); cmQtAutoGenerator(cmQtAutoGenerator const&) = delete; @@ -91,10 +91,39 @@ public: // -- InfoFile std::string const& InfoFile() const { return InfoFile_; } + Json::Value const& Info() const { return Info_; } cmFileTime const& InfoFileTime() const { return InfoFileTime_; } std::string const& InfoDir() const { return InfoDir_; } std::string const& InfoConfig() const { return InfoConfig_; } + bool LogInfoError(GenT genType, cm::string_view message) const; + bool LogInfoError(cm::string_view message) const; + + /** Returns true if strings were appended to the list. */ + static bool JsonGetArray(std::vector& list, + Json::Value const& jval); + /** Returns true if strings were found in the JSON array. */ + static bool JsonGetArray(std::unordered_set& list, + Json::Value const& jval); + + std::string InfoConfigKey(std::string const& key) const; + + /** Returns false if the JSON value isn't a string. */ + bool InfoString(std::string const& key, std::string& value, + bool required) const; + bool InfoStringConfig(std::string const& key, std::string& value, + bool required) const; + bool InfoBool(std::string const& key, bool& value, bool required) const; + bool InfoUInt(std::string const& key, unsigned int& value, + bool required) const; + /** Returns false if the JSON value isn't an array. */ + bool InfoArray(std::string const& key, std::vector& list, + bool required) const; + bool InfoArray(std::string const& key, std::unordered_set& list, + bool required) const; + bool InfoArrayConfig(std::string const& key, std::vector& list, + bool required) const; + // -- Directories ProjectDirsT const& ProjectDirs() const { return ProjectDirs_; } @@ -104,16 +133,22 @@ public: protected: // -- Abstract processing interface - virtual bool Init(cmMakefile* makefile) = 0; + virtual bool InitFromInfo() = 0; virtual bool Process() = 0; - ProjectDirsT& ProjectDirsRef() { return ProjectDirs_; } + // - Utility classes + Logger const& Log() const { return Logger_; } private: - // -- Info settings + // -- Generator type + GenT GenType_; + // -- Logging + Logger Logger_; + // -- Info file std::string InfoFile_; cmFileTime InfoFileTime_; std::string InfoDir_; std::string InfoConfig_; + Json::Value Info_; // -- Directories ProjectDirsT ProjectDirs_; }; diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 5cd1ba1..5f3cd5f 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -11,19 +11,22 @@ #include "cmAlgorithms.h" #include "cmCryptoHash.h" #include "cmGeneratedFileStream.h" -#include "cmMakefile.h" #include "cmQtAutoGen.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include "cmake.h" +#include "cm_jsoncpp_value.h" #include "cmsys/FStream.hxx" #if defined(__APPLE__) # include #endif -static constexpr std::size_t MocUnderscoreLength = 4; // Length of "moc_" -static constexpr std::size_t UiUnderscoreLength = 3; // Length of "ui_" +namespace { + +constexpr std::size_t MocUnderscoreLength = 4; // Length of "moc_" +constexpr std::size_t UiUnderscoreLength = 3; // Length of "ui_" + +} // End of unnamed namespace cmQtAutoMocUic::IncludeKeyT::IncludeKeyT(std::string const& key, std::size_t basePrefixLength) @@ -1464,10 +1467,10 @@ void cmQtAutoMocUic::JobCompileUicT::Process() std::vector cmd; cmd.push_back(UicConst().Executable); { - std::vector allOpts = UicConst().TargetOptions; - auto optionIt = UicConst().Options.find(sourceFile); - if (optionIt != UicConst().Options.end()) { - UicMergeOptions(allOpts, optionIt->second, + std::vector allOpts = UicConst().Options; + auto optionIt = UicConst().UiFiles.find(sourceFile); + if (optionIt != UicConst().UiFiles.end()) { + UicMergeOptions(allOpts, optionIt->second.Options, (BaseConst().QtVersionMajor == 5)); } cmAppend(cmd, allOpts); @@ -1548,338 +1551,310 @@ void cmQtAutoMocUic::JobFinishT::Process() Gen()->AbortSuccess(); } -cmQtAutoMocUic::cmQtAutoMocUic() = default; +cmQtAutoMocUic::cmQtAutoMocUic() + : cmQtAutoGenerator(GenT::GEN) +{ +} cmQtAutoMocUic::~cmQtAutoMocUic() = default; -bool cmQtAutoMocUic::Init(cmMakefile* makefile) +bool cmQtAutoMocUic::InitFromInfo() { - // Utility lambdas - auto InfoGet = [makefile](cm::string_view key) { - return makefile->GetSafeDefinition(std::string(key)); - }; - auto InfoGetBool = [makefile](cm::string_view key) { - return makefile->IsOn(std::string(key)); - }; - auto InfoGetList = - [makefile](cm::string_view key) -> std::vector { - return cmExpandedList(makefile->GetSafeDefinition(std::string(key))); - }; - auto InfoGetLists = - [makefile](cm::string_view key) -> std::vector> { - std::vector> lists; - { - std::string const value = makefile->GetSafeDefinition(std::string(key)); - std::string::size_type pos = 0; - while (pos < value.size()) { - std::string::size_type next = value.find(ListSep, pos); - std::string::size_type length = - (next != std::string::npos) ? next - pos : value.size() - pos; - // Remove enclosing braces - if (length >= 2) { - std::string::const_iterator itBeg = value.begin() + (pos + 1); - std::string::const_iterator itEnd = itBeg + (length - 2); - lists.emplace_back(cmExpandedList(std::string(itBeg, itEnd))); - } - pos += length; - pos += ListSep.size(); - } - } - return lists; - }; - auto InfoGetConfig = [makefile, this](cm::string_view key) -> std::string { - if (const char* valueConf = - makefile->GetDefinition(cmStrCat(key, '_', InfoConfig()))) { - return std::string(valueConf); - } - return makefile->GetSafeDefinition(std::string(key)); - }; - auto InfoGetConfigList = - [&InfoGetConfig](cm::string_view key) -> std::vector { - return cmExpandedList(InfoGetConfig(key)); - }; - auto LogInfoError = [this](cm::string_view msg) -> bool { - this->Log().Error(GenT::GEN, - cmStrCat("In ", Quoted(this->InfoFile()), ":\n", msg)); + // -- Required settings + if (!InfoBool("MULTI_CONFIG", BaseConst_.MultiConfig, true) || + !InfoUInt("QT_VERSION_MAJOR", BaseConst_.QtVersionMajor, true) || + !InfoUInt("PARALLEL", BaseConst_.ThreadCount, false) || + !InfoString("BUILD_DIR", BaseConst_.AutogenBuildDir, true) || + !InfoStringConfig("INCLUDE_DIR", BaseConst_.AutogenIncludeDir, true) || + !InfoString("CMAKE_EXECUTABLE", BaseConst_.CMakeExecutable, true) || + !InfoStringConfig("PARSE_CACHE_FILE", BaseConst_.ParseCacheFile, true) || + !InfoStringConfig("SETTINGS_FILE", SettingsFile_, true) || + !InfoArray("HEADER_EXTENSIONS", BaseConst_.HeaderExtensions, true) || + !InfoString("QT_MOC_EXECUTABLE", MocConst_.Executable, false) || + !InfoString("QT_UIC_EXECUTABLE", UicConst_.Executable, false)) { return false; - }; - auto MatchSizes = [&LogInfoError](cm::string_view keyA, cm::string_view keyB, - std::size_t sizeA, - std::size_t sizeB) -> bool { - if (sizeA == sizeB) { - return true; - } - return LogInfoError(cmStrCat("Lists sizes mismatch ", keyA, '(', sizeA, - ") ", keyB, '(', sizeB, ')')); - }; - - // -- Read info file - if (!makefile->ReadListFile(InfoFile())) { - return LogInfoError("File processing failed"); - } - - // -- Meta - Logger_.RaiseVerbosity(InfoGet("AM_VERBOSITY")); - BaseConst_.MultiConfig = InfoGetBool("AM_MULTI_CONFIG"); - { - unsigned long num = 1; - if (cmStrToULong(InfoGet("AM_PARALLEL"), &num)) { - num = std::max(num, 1); - num = std::min(num, ParallelMax); - } - WorkerPool_.SetThreadCount(static_cast(num)); } - BaseConst_.HeaderExtensions = - makefile->GetCMakeInstance()->GetHeaderExtensions(); - // - Files and directories - ProjectDirsRef().Source = InfoGet("AM_CMAKE_SOURCE_DIR"); - ProjectDirsRef().Binary = InfoGet("AM_CMAKE_BINARY_DIR"); - ProjectDirsRef().CurrentSource = InfoGet("AM_CMAKE_CURRENT_SOURCE_DIR"); - ProjectDirsRef().CurrentBinary = InfoGet("AM_CMAKE_CURRENT_BINARY_DIR"); - BaseConst_.AutogenBuildDir = InfoGet("AM_BUILD_DIR"); - if (BaseConst_.AutogenBuildDir.empty()) { - return LogInfoError("Autogen build directory missing."); - } - BaseConst_.AutogenIncludeDir = InfoGetConfig("AM_INCLUDE_DIR"); - if (BaseConst_.AutogenIncludeDir.empty()) { - return LogInfoError("Autogen include directory missing."); - } - BaseConst_.CMakeExecutable = InfoGetConfig("AM_CMAKE_EXECUTABLE"); - if (BaseConst_.CMakeExecutable.empty()) { - return LogInfoError("CMake executable file name missing."); - } + // -- Checks if (!BaseConst_.CMakeExecutableTime.Load(BaseConst_.CMakeExecutable)) { return LogInfoError(cmStrCat("The CMake executable ", MessagePath(BaseConst_.CMakeExecutable), " does not exist.")); } - BaseConst_.ParseCacheFile = InfoGetConfig("AM_PARSE_CACHE_FILE"); - if (BaseConst_.ParseCacheFile.empty()) { - return LogInfoError("Parse cache file name missing."); - } - // - Settings file - SettingsFile_ = InfoGetConfig("AM_SETTINGS_FILE"); - if (SettingsFile_.empty()) { - return LogInfoError("Settings file name missing."); - } + // -- Evaluate values + BaseConst_.ThreadCount = std::min(BaseConst_.ThreadCount, ParallelMax); + WorkerPool_.SetThreadCount(BaseConst_.ThreadCount); - // - Qt environment - { - unsigned long qtv = BaseConst_.QtVersionMajor; - if (cmStrToULong(InfoGet("AM_QT_VERSION_MAJOR"), &qtv)) { - BaseConst_.QtVersionMajor = static_cast(qtv); - } - } - - // - Moc - MocConst_.Executable = InfoGet("AM_QT_MOC_EXECUTABLE"); - if (!MocConst().Executable.empty()) { + // -- Moc + if (!MocConst_.Executable.empty()) { + // -- Moc is enabled MocConst_.Enabled = true; - // Load the executable file time - if (!MocConst_.ExecutableTime.Load(MocConst_.Executable)) { - return LogInfoError(cmStrCat("The moc executable ", - MessagePath(MocConst_.Executable), - " does not exist.")); - } - for (std::string& sfl : InfoGetList("AM_MOC_SKIP")) { - MocConst_.SkipList.insert(std::move(sfl)); - } - MocConst_.Definitions = InfoGetConfigList("AM_MOC_DEFINITIONS"); - MocConst_.IncludePaths = InfoGetConfigList("AM_MOC_INCLUDES"); - MocConst_.OptionsExtra = InfoGetList("AM_MOC_OPTIONS"); - MocConst_.RelaxedMode = InfoGetBool("AM_MOC_RELAXED_MODE"); - MocConst_.PathPrefix = InfoGetBool("AM_MOC_PATH_PREFIX"); + // -- Temporary buffers + struct + { + std::vector MacroNames; + std::vector DependFilters; + } tmp; + + // -- Required settings + if (!InfoBool("MOC_RELAXED_MODE", MocConst_.RelaxedMode, false) || + !InfoBool("MOC_PATH_PREFIX", MocConst_.PathPrefix, true) || + !InfoArray("MOC_SKIP", MocConst_.SkipList, false) || + !InfoArrayConfig("MOC_DEFINITIONS", MocConst_.Definitions, false) || + !InfoArrayConfig("MOC_INCLUDES", MocConst_.IncludePaths, false) || + !InfoArray("MOC_OPTIONS", MocConst_.OptionsExtra, false) || + !InfoStringConfig("MOC_COMPILATION_FILE", MocConst_.CompFileAbs, + true) || + !InfoArray("MOC_PREDEFS_CMD", MocConst_.PredefsCmd, false) || + !InfoStringConfig("MOC_PREDEFS_FILE", MocConst_.PredefsFileAbs, + !MocConst_.PredefsCmd.empty()) || + !InfoArray("MOC_MACRO_NAMES", tmp.MacroNames, true) || + !InfoArray("MOC_DEPEND_FILTERS", tmp.DependFilters, false)) { + return false; + } - for (std::string const& item : InfoGetList("AM_MOC_MACRO_NAMES")) { + // -- Evaluate settings + for (std::string const& item : tmp.MacroNames) { MocConst_.MacroFilters.emplace_back( item, ("[\n][ \t]*{?[ \t]*" + item).append("[^a-zA-Z0-9_]")); } + // Dependency filters { - auto addFilter = [this, &LogInfoError](std::string const& key, - std::string const& exp) -> bool { - auto filterErr = [&LogInfoError, &key, - &exp](cm::string_view err) -> bool { - return LogInfoError(cmStrCat("AUTOMOC_DEPEND_FILTERS: ", err, '\n', - " Key: ", Quoted(key), '\n', - " Exp: ", Quoted(exp), '\n')); + Json::Value const& val = Info()["MOC_DEPEND_FILTERS"]; + if (!val.isArray()) { + return LogInfoError("MOC_DEPEND_FILTERS JSON value is not an array."); + } + Json::ArrayIndex const arraySize = val.size(); + for (Json::ArrayIndex ii = 0; ii != arraySize; ++ii) { + // Test entry closure + auto testEntry = [this, ii](bool test, + cm::string_view message) -> bool { + if (!test) { + this->LogInfoError( + cmStrCat("MOC_DEPEND_FILTERS filter ", ii, ": ", message)); + } + return !test; }; - if (key.empty()) { - return filterErr("Key is empty"); + + Json::Value const& pairVal = val[ii]; + + if (testEntry(pairVal.isArray(), "JSON value is not an array.") || + testEntry(pairVal.size() == 2, "JSON array size invalid.")) { + return false; } - if (exp.empty()) { - return filterErr("Regular expression is empty"); + + Json::Value const& keyVal = pairVal[0u]; + Json::Value const& expVal = pairVal[1u]; + if (testEntry(keyVal.isString(), + "JSON value for keyword is not a string.") || + testEntry(expVal.isString(), + "JSON value for regular expression is not a string.")) { + return false; } - this->MocConst_.DependFilters.emplace_back(key, exp); - if (!this->MocConst_.DependFilters.back().Exp.is_valid()) { - return filterErr("Regular expression compiling failed"); + + std::string const key = keyVal.asString(); + std::string const exp = expVal.asString(); + if (testEntry(!key.empty(), "Keyword is empty.") || + testEntry(!exp.empty(), "Regular expression is empty.")) { + return false; } - return true; - }; - // Insert default filter for Q_PLUGIN_METADATA - if (BaseConst().QtVersionMajor != 4) { - if (!addFilter("Q_PLUGIN_METADATA", - "[\n][ \t]*Q_PLUGIN_METADATA[ \t]*\\(" - "[^\\)]*FILE[ \t]*\"([^\"]+)\"")) { + this->MocConst_.DependFilters.emplace_back(key, exp); + if (testEntry( + this->MocConst_.DependFilters.back().Exp.is_valid(), + cmStrCat("Regular expression compilation failed.\nKeyword: ", + Quoted(key), "\nExpression: ", Quoted(exp)))) { return false; } } - // Insert user defined dependency filters - std::vector flts = InfoGetList("AM_MOC_DEPEND_FILTERS"); - if ((flts.size() % 2) != 0) { - return LogInfoError( - "AUTOMOC_DEPEND_FILTERS list size is not a multiple of 2"); + } + // Check if moc executable exists (by reading the file time) + if (!MocConst_.ExecutableTime.Load(MocConst_.Executable)) { + return LogInfoError(cmStrCat("The moc executable ", + MessagePath(MocConst_.Executable), + " does not exist.")); + } + } + + // -- Uic + if (!UicConst_.Executable.empty()) { + // Uic is enabled + UicConst_.Enabled = true; + + // -- Required settings + if (!InfoArray("UIC_SKIP", UicConst_.SkipList, false) || + !InfoArray("UIC_SEARCH_PATHS", UicConst_.SearchPaths, false) || + !InfoArrayConfig("UIC_OPTIONS", UicConst_.Options, false)) { + return false; + } + // .ui files + { + Json::Value const& val = Info()["UIC_UI_FILES"]; + if (!val.isArray()) { + return LogInfoError("UIC_UI_FILES JSON value is not an array."); } - for (auto itC = flts.begin(), itE = flts.end(); itC != itE; itC += 2) { - if (!addFilter(*itC, *(itC + 1))) { + Json::ArrayIndex const arraySize = val.size(); + for (Json::ArrayIndex ii = 0; ii != arraySize; ++ii) { + // Test entry closure + auto testEntry = [this, ii](bool test, + cm::string_view message) -> bool { + if (!test) { + this->LogInfoError( + cmStrCat("UIC_UI_FILES entry ", ii, ": ", message)); + } + return !test; + }; + + Json::Value const& entry = val[ii]; + if (testEntry(entry.isArray(), "JSON value is not an array.") || + testEntry(entry.size() == 2, "JSON array size invalid.")) { + return false; + } + + Json::Value const& entryName = entry[0u]; + Json::Value const& entryOptions = entry[1u]; + if (testEntry(entryName.isString(), + "JSON value for name is not a string.") || + testEntry(entryOptions.isArray(), + "JSON value for options is not an array.")) { return false; } + + auto& uiFile = UicConst_.UiFiles[entryName.asString()]; + JsonGetArray(uiFile.Options, entryOptions); } } - MocConst_.PredefsCmd = InfoGetList("AM_MOC_PREDEFS_CMD"); - } - // - Uic - UicConst_.Executable = InfoGet("AM_QT_UIC_EXECUTABLE"); - if (!UicConst().Executable.empty()) { - UicConst_.Enabled = true; - // Load the executable file time + // -- Evaluate settings + // Check if uic executable exists (by reading the file time) if (!UicConst_.ExecutableTime.Load(UicConst_.Executable)) { return LogInfoError(cmStrCat("The uic executable ", MessagePath(UicConst_.Executable), " does not exist.")); } - for (std::string& sfl : InfoGetList("AM_UIC_SKIP")) { - UicConst_.SkipList.insert(std::move(sfl)); - } - UicConst_.SearchPaths = InfoGetList("AM_UIC_SEARCH_PATHS"); - UicConst_.TargetOptions = InfoGetConfigList("AM_UIC_TARGET_OPTIONS"); - { - cm::string_view const keyFiles = "AM_UIC_OPTIONS_FILES"; - cm::string_view const keyOpts = "AM_UIC_OPTIONS_OPTIONS"; - auto sources = InfoGetList(keyFiles); - auto options = InfoGetLists(keyOpts); - if (!MatchSizes(keyFiles, keyOpts, sources.size(), options.size())) { - return false; - } - auto fitEnd = sources.cend(); - auto fit = sources.begin(); - auto oit = options.begin(); - while (fit != fitEnd) { - UicConst_.Options[*fit] = std::move(*oit); - ++fit; - ++oit; - } - } } - // Headers + // -- Headers { - // Get file lists - cm::string_view const keyFiles = "AM_HEADERS"; - cm::string_view const keyFlags = "AM_HEADERS_FLAGS"; - std::vector files = InfoGetList(keyFiles); - std::vector flags = InfoGetList(keyFlags); - std::vector builds; - if (!MatchSizes(keyFiles, keyFlags, files.size(), flags.size())) { - return false; - } - if (MocConst().Enabled) { - cm::string_view const keyPaths = "AM_HEADERS_BUILD_PATHS"; - builds = InfoGetList(keyPaths); - if (!MatchSizes(keyFiles, keyPaths, files.size(), builds.size())) { + Json::Value const& val = Info()["HEADERS"]; + if (!val.isArray()) { + return LogInfoError("HEADERS JSON value is not an array."); + } + Json::ArrayIndex const arraySize = val.size(); + for (Json::ArrayIndex ii = 0; ii != arraySize; ++ii) { + // Test entry closure + auto testEntry = [this, ii](bool test, cm::string_view message) -> bool { + if (!test) { + this->LogInfoError(cmStrCat("HEADERS entry ", ii, ": ", message)); + } + return !test; + }; + + Json::Value const& entry = val[ii]; + if (testEntry(entry.isArray(), "JSON value is not an array.") || + testEntry(entry.size() == 3, "JSON array size invalid.")) { + return false; + } + + Json::Value const& entryName = entry[0u]; + Json::Value const& entryFlags = entry[1u]; + Json::Value const& entryBuild = entry[2u]; + if (testEntry(entryName.isString(), + "JSON value for name is not a string.") || + testEntry(entryFlags.isString(), + "JSON value for flags is not a string.") || + testEntry(entryBuild.isString(), + "JSON value for build path is not a string.")) { return false; } - } - // Process file lists - for (std::size_t ii = 0; ii != files.size(); ++ii) { - std::string& fileName(files[ii]); - std::string const& fileFlags(flags[ii]); - if (fileFlags.size() != 2) { - LogInfoError(cmStrCat("Invalid flags string size ", fileFlags.size(), - "in ", keyFlags)); + std::string name = entryName.asString(); + std::string flags = entryFlags.asString(); + std::string build = entryBuild.asString(); + if (testEntry(flags.size() == 2, "Invalid flags string size")) { return false; } + cmFileTime fileTime; - if (!fileTime.Load(fileName)) { - LogInfoError(cmStrCat("The header file ", this->MessagePath(fileName), + if (!fileTime.Load(name)) { + LogInfoError(cmStrCat("The header file ", this->MessagePath(name), " does not exist.")); return false; } - SourceFileHandleT sourceHandle = std::make_shared(fileName); + SourceFileHandleT sourceHandle = std::make_shared(name); sourceHandle->FileTime = fileTime; sourceHandle->IsHeader = true; - sourceHandle->Moc = (fileFlags[0] == 'M'); - sourceHandle->Uic = (fileFlags[1] == 'U'); - + sourceHandle->Moc = (flags[0] == 'M'); + sourceHandle->Uic = (flags[1] == 'U'); if (sourceHandle->Moc && MocConst().Enabled) { - sourceHandle->BuildPath = std::move(builds[ii]); - if (sourceHandle->BuildPath.empty()) { - return LogInfoError("Header file build path is empty"); + if (build.empty()) { + return LogInfoError( + cmStrCat("Header file ", ii, " build path is empty")); } + sourceHandle->BuildPath = std::move(build); } - BaseEval().Headers.emplace(std::move(fileName), std::move(sourceHandle)); + BaseEval().Headers.emplace(std::move(name), std::move(sourceHandle)); } } - // Sources + // -- Sources { - cm::string_view const keyFiles = "AM_SOURCES"; - cm::string_view const keyFlags = "AM_SOURCES_FLAGS"; - std::vector files = InfoGetList(keyFiles); - std::vector flags = InfoGetList(keyFlags); - if (!MatchSizes(keyFiles, keyFlags, files.size(), flags.size())) { - return false; - } + Json::Value const& val = Info()["SOURCES"]; + if (!val.isArray()) { + return LogInfoError("SOURCES JSON value is not an array."); + } + Json::ArrayIndex const arraySize = val.size(); + for (Json::ArrayIndex ii = 0; ii != arraySize; ++ii) { + // Test entry closure + auto testEntry = [this, ii](bool test, cm::string_view message) -> bool { + if (!test) { + this->LogInfoError(cmStrCat("SOURCES entry ", ii, ": ", message)); + } + return !test; + }; + + Json::Value const& entry = val[ii]; + if (testEntry(entry.isArray(), "JSON value is not an array.") || + testEntry(entry.size() == 2, "JSON array size invalid.")) { + return false; + } + + Json::Value const& entryName = entry[0u]; + Json::Value const& entryFlags = entry[1u]; + if (testEntry(entryName.isString(), + "JSON value for name is not a string.") || + testEntry(entryFlags.isString(), + "JSON value for flags is not a string.")) { + return false; + } - // Process file lists - for (std::size_t ii = 0; ii != files.size(); ++ii) { - std::string& fileName(files[ii]); - std::string const& fileFlags(flags[ii]); - if (fileFlags.size() != 2) { - LogInfoError(cmStrCat("Invalid flags string size ", fileFlags.size(), - "in ", keyFlags)); + std::string name = entryName.asString(); + std::string flags = entryFlags.asString(); + if (testEntry(flags.size() == 2, "Invalid flags string size")) { return false; } + cmFileTime fileTime; - if (!fileTime.Load(fileName)) { - LogInfoError(cmStrCat("The source file ", this->MessagePath(fileName), + if (!fileTime.Load(name)) { + LogInfoError(cmStrCat("The source file ", this->MessagePath(name), " does not exist.")); return false; } - SourceFileHandleT sourceHandle = std::make_shared(fileName); + SourceFileHandleT sourceHandle = std::make_shared(name); sourceHandle->FileTime = fileTime; sourceHandle->IsHeader = false; - sourceHandle->Moc = (fileFlags[0] == 'M'); - sourceHandle->Uic = (fileFlags[1] == 'U'); - BaseEval().Sources.emplace(std::move(fileName), std::move(sourceHandle)); + sourceHandle->Moc = (flags[0] == 'M'); + sourceHandle->Uic = (flags[1] == 'U'); + BaseEval().Sources.emplace(std::move(name), std::move(sourceHandle)); } } - // Init derived information - // ------------------------ - + // -- Init derived information // Moc variables if (MocConst().Enabled) { - // Mocs compilation file - MocConst_.CompFileAbs = AbsoluteBuildPath("mocs_compilation.cpp"); - - // Moc predefs file - if (!MocConst_.PredefsCmd.empty()) { - std::string pathRel; - if (BaseConst_.MultiConfig) { - pathRel = cmStrCat("moc_predefs_", InfoConfig(), ".h"); - } else { - pathRel = "moc_predefs.h"; - } - MocConst_.PredefsFileAbs = AbsoluteBuildPath(pathRel); - } - // Compose moc includes list { // Compute framework paths @@ -2031,11 +2006,11 @@ void cmQtAutoMocUic::SettingsFileRead() if (UicConst().Enabled) { cryptoHash.Initialize(); cha(UicConst().Executable); - std::for_each(UicConst().TargetOptions.begin(), - UicConst().TargetOptions.end(), cha); - for (const auto& item : UicConst().Options) { + std::for_each(UicConst().Options.begin(), UicConst().Options.end(), cha); + for (const auto& item : UicConst().UiFiles) { cha(item.first); - std::for_each(item.second.begin(), item.second.end(), cha); + auto const& opts = item.second.Options; + std::for_each(opts.begin(), opts.end(), cha); } SettingsStringUic_ = cryptoHash.FinalizeHex(); } @@ -2080,7 +2055,7 @@ bool cmQtAutoMocUic::SettingsFileWrite() if (Log().Verbose()) { Log().Info( GenT::GEN, - cmStrCat("Writing settings file ", MessagePath(SettingsFile_))); + cmStrCat("Writing the settings file ", MessagePath(SettingsFile_))); } // Compose settings file content std::string content; diff --git a/Source/cmQtAutoMocUic.h b/Source/cmQtAutoMocUic.h index f37d923..7101b8f 100644 --- a/Source/cmQtAutoMocUic.h +++ b/Source/cmQtAutoMocUic.h @@ -25,8 +25,6 @@ #include #include -class cmMakefile; - /** \class cmQtAutoMocUic * \brief AUTOMOC and AUTOUIC generator */ @@ -42,17 +40,21 @@ public: public: // -- Types + /** Include string with sub parts. */ + struct IncludeKeyT + { + IncludeKeyT(std::string const& key, std::size_t basePrefixLength); + + std::string Key; // Full include string + std::string Dir; // Include directory + std::string Base; // Base part of the include file name + }; + /** Search key plus regular expression pair. */ struct KeyExpT { KeyExpT() = default; - KeyExpT(const char* key, const char* exp) - : Key(key) - , Exp(exp) - { - } - KeyExpT(std::string key, std::string const& exp) : Key(std::move(key)) , Exp(exp) @@ -63,16 +65,6 @@ public: cmsys::RegularExpression Exp; }; - /** Include string with sub parts. */ - struct IncludeKeyT - { - IncludeKeyT(std::string const& key, std::size_t basePrefixLength); - - std::string Key; // Full include string - std::string Dir; // Include directory - std::string Base; // Base part of the include file name - }; - /** Source file parsing cache. */ class ParseCacheT { @@ -169,6 +161,7 @@ public: // - Config bool MultiConfig = false; unsigned int QtVersionMajor = 4; + unsigned int ThreadCount = 0; // - Directories std::string AutogenBuildDir; std::string AutogenIncludeDir; @@ -252,6 +245,12 @@ public: class UicSettingsT { public: + struct UiFile + { + std::vector Options; + }; + + public: UicSettingsT(); ~UicSettingsT(); @@ -267,8 +266,8 @@ public: cmFileTime ExecutableTime; std::string Executable; std::unordered_set SkipList; - std::vector TargetOptions; - std::map> Options; + std::vector Options; + std::unordered_map UiFiles; std::vector SearchPaths; cmsys::RegularExpression RegExpInclude; }; @@ -523,10 +522,8 @@ public: std::string CollapseFullPathTS(std::string const& path) const; private: - // -- Utility accessors - Logger const& Log() const { return Logger_; } // -- Abstract processing interface - bool Init(cmMakefile* makefile) override; + bool InitFromInfo() override; void InitJobs(); bool Process() override; // -- Settings file @@ -541,8 +538,6 @@ private: bool CreateDirectories(); private: - // -- Utility - Logger Logger_; // -- Settings BaseSettingsT BaseConst_; BaseEvalT BaseEval_; diff --git a/Source/cmQtAutoRcc.cxx b/Source/cmQtAutoRcc.cxx index 1bf8ca4..b0b15d4 100644 --- a/Source/cmQtAutoRcc.cxx +++ b/Source/cmQtAutoRcc.cxx @@ -6,7 +6,6 @@ #include "cmCryptoHash.h" #include "cmDuration.h" #include "cmFileLockResult.h" -#include "cmMakefile.h" #include "cmProcessOutput.h" #include "cmQtAutoGen.h" #include "cmStringAlgorithms.h" @@ -16,112 +15,49 @@ #include -cmQtAutoRcc::cmQtAutoRcc() = default; +cmQtAutoRcc::cmQtAutoRcc() + : cmQtAutoGenerator(GenT::RCC) +{ +} cmQtAutoRcc::~cmQtAutoRcc() = default; -bool cmQtAutoRcc::Init(cmMakefile* makefile) +bool cmQtAutoRcc::InitFromInfo() { - // -- Utility lambdas - auto InfoGet = [makefile](cm::string_view key) { - return makefile->GetSafeDefinition(std::string(key)); - }; - auto InfoGetList = - [makefile](cm::string_view key) -> std::vector { - return cmExpandedList(makefile->GetSafeDefinition(std::string(key))); - }; - auto InfoGetConfig = [makefile, this](cm::string_view key) -> std::string { - if (const char* valueConf = - makefile->GetDefinition(cmStrCat(key, '_', InfoConfig()))) { - return std::string(valueConf); - } - return makefile->GetSafeDefinition(std::string(key)); - }; - auto InfoGetConfigList = - [&InfoGetConfig](cm::string_view key) -> std::vector { - return cmExpandedList(InfoGetConfig(key)); - }; - auto LogInfoError = [this](cm::string_view msg) -> bool { - this->Log().Error( - GenT::RCC, cmStrCat("In ", MessagePath(this->InfoFile()), ":\n", msg)); + // -- Required settings + if (!InfoBool("MULTI_CONFIG", MultiConfig_, true) || + !InfoString("BUILD_DIR", AutogenBuildDir_, true) || + !InfoStringConfig("INCLUDE_DIR", IncludeDir_, true) || + !InfoString("RCC_EXECUTABLE", RccExecutable_, true) || + !InfoArray("RCC_LIST_OPTIONS", RccListOptions_, false) || + !InfoString("LOCK_FILE", LockFile_, true) || + !InfoStringConfig("SETTINGS_FILE", SettingsFile_, true) || + !InfoString("SOURCE", QrcFile_, true) || + !InfoString("OUTPUT_CHECKSUM", RccPathChecksum_, true) || + !InfoString("OUTPUT_NAME", RccFileName_, true) || + !InfoArray("OPTIONS", Options_, false) || + !InfoArray("INPUTS", Inputs_, false)) { return false; - }; - - // -- Read info file - if (!makefile->ReadListFile(InfoFile())) { - return LogInfoError("File processing failed."); } - // - Configurations - Logger_.RaiseVerbosity(InfoGet("ARCC_VERBOSITY")); - MultiConfig_ = makefile->IsOn("ARCC_MULTI_CONFIG"); - - // - Directories - ProjectDirsRef().Source = InfoGet("ARCC_CMAKE_SOURCE_DIR"); - ProjectDirsRef().Binary = InfoGet("ARCC_CMAKE_BINARY_DIR"); - AutogenBuildDir_ = InfoGet("ARCC_BUILD_DIR"); - if (AutogenBuildDir_.empty()) { - return LogInfoError("Build directory empty."); - } - - IncludeDir_ = InfoGetConfig("ARCC_INCLUDE_DIR"); - if (IncludeDir_.empty()) { - return LogInfoError("Include directory empty."); - } - - // - Rcc executable - RccExecutable_ = InfoGet("ARCC_RCC_EXECUTABLE"); - if (!RccExecutableTime_.Load(RccExecutable_)) { - return LogInfoError(cmStrCat( - "The rcc executable ", MessagePath(RccExecutable_), " does not exist.")); - } - RccListOptions_ = InfoGetList("ARCC_RCC_LIST_OPTIONS"); - - // - Job - LockFile_ = InfoGet("ARCC_LOCK_FILE"); - QrcFile_ = InfoGet("ARCC_SOURCE"); + // -- Derive information QrcFileName_ = cmSystemTools::GetFilenameName(QrcFile_); QrcFileDir_ = cmSystemTools::GetFilenamePath(QrcFile_); - RccPathChecksum_ = InfoGet("ARCC_OUTPUT_CHECKSUM"); - RccFileName_ = InfoGet("ARCC_OUTPUT_NAME"); - Options_ = InfoGetConfigList("ARCC_OPTIONS"); - Inputs_ = InfoGetList("ARCC_INPUTS"); - - // - Settings file - SettingsFile_ = InfoGetConfig("ARCC_SETTINGS_FILE"); - - // - Validity checks - if (LockFile_.empty()) { - return LogInfoError("Lock file name missing."); - } - if (SettingsFile_.empty()) { - return LogInfoError("Settings file name missing."); - } - if (AutogenBuildDir_.empty()) { - return LogInfoError("Autogen build directory missing."); - } - if (RccExecutable_.empty()) { - return LogInfoError("rcc executable missing."); - } - if (QrcFile_.empty()) { - return LogInfoError("rcc input file missing."); - } - if (RccFileName_.empty()) { - return LogInfoError("rcc output file missing."); - } - - // Init derived information - // ------------------------ - RccFilePublic_ = cmStrCat(AutogenBuildDir_, '/', RccPathChecksum_, '/', RccFileName_); - // Compute rcc output file name + // rcc output file name if (IsMultiConfig()) { RccFileOutput_ = cmStrCat(IncludeDir_, '/', MultiConfigOutput()); } else { RccFileOutput_ = RccFilePublic_; } + // -- Checks + if (!RccExecutableTime_.Load(RccExecutable_)) { + return LogInfoError(cmStrCat( + "The rcc executable ", MessagePath(RccExecutable_), " does not exist.")); + } + return true; } diff --git a/Source/cmQtAutoRcc.h b/Source/cmQtAutoRcc.h index 5d3bd6a..945b68f 100644 --- a/Source/cmQtAutoRcc.h +++ b/Source/cmQtAutoRcc.h @@ -12,8 +12,6 @@ #include #include -class cmMakefile; - /** \class cmQtAutoRcc * \brief AUTORCC generator */ @@ -28,12 +26,11 @@ public: private: // -- Utility - Logger const& Log() const { return Logger_; } bool IsMultiConfig() const { return MultiConfig_; } std::string MultiConfigOutput() const; // -- Abstract processing interface - bool Init(cmMakefile* makefile) override; + bool InitFromInfo() override; bool Process() override; // -- Settings file bool SettingsFileRead(); @@ -47,8 +44,6 @@ private: bool GenerateWrapper(); private: - // -- Logging - Logger Logger_; // -- Config settings bool MultiConfig_ = false; // -- Directories https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=881e3cfbf96c7b4f48304d3dfc07899c2e6703de commit 881e3cfbf96c7b4f48304d3dfc07899c2e6703de Author: Sebastian Holtermann AuthorDate: Mon Sep 23 13:21:10 2019 +0200 Commit: Sebastian Holtermann CommitDate: Wed Sep 25 10:31:06 2019 +0200 Autogen: Variable renames and cleanups diff --git a/Source/cmQtAutoGen.h b/Source/cmQtAutoGen.h index 2a28c1e..c8e4203 100644 --- a/Source/cmQtAutoGen.h +++ b/Source/cmQtAutoGen.h @@ -17,7 +17,7 @@ class cmQtAutoGen { public: - /// @brief Integer version + /** Integer version. */ struct IntegerVersion { unsigned int Major = 0; @@ -43,6 +43,7 @@ public: } }; + /** Compiler features. */ class CompilerFeatures { public: @@ -52,7 +53,7 @@ public: }; using CompilerFeaturesHandle = std::shared_ptr; - /// @brief AutoGen generator type + /** AutoGen generator type. */ enum class GenT { GEN, // AUTOGEN diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 3aba19d..0329ac7 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -123,7 +123,7 @@ bool StaticLibraryCycle(cmGeneratorTarget const* targetOrigin, return cycle; } -/** Sanitizes file search paths */ +/** Sanitizes file search paths. */ class SearchPathSanitizer { public: @@ -353,9 +353,6 @@ bool cmQtAutoGenInitializer::InitCustomTargets() // Include directory this->Dir.Include = cmStrCat(this->Dir.Build, "/include"); - if (this->MultiConfig) { - this->Dir.Include += "_$"; - } // Per config include directories if (this->MultiConfig) { for (std::string const& cfg : this->ConfigsList) { @@ -363,6 +360,10 @@ bool cmQtAutoGenInitializer::InitCustomTargets() dir = cmStrCat(this->Dir.Build, "/include_", cfg); } } + this->Dir.IncludeGenExp = this->Dir.Include; + if (this->MultiConfig) { + this->Dir.IncludeGenExp += "_$"; + } } // Moc, Uic and _autogen target settings @@ -454,7 +455,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets() // Add autogen include directory to the origin target INCLUDE_DIRECTORIES if (this->MocOrUicEnabled() || (this->Rcc.Enabled && this->MultiConfig)) { - this->GenTarget->AddIncludeDirectory(this->Dir.Include, true); + this->GenTarget->AddIncludeDirectory(this->Dir.IncludeGenExp, true); } // Scan files @@ -889,13 +890,15 @@ bool cmQtAutoGenInitializer::InitScanFiles() { cmFilePathChecksum const fpathCheckSum(this->Makefile); for (Qrc& qrc : this->Rcc.Qrcs) { - qrc.PathChecksum = fpathCheckSum.getPart(qrc.QrcFile); - // RCC output file name - qrc.RccFile = cmStrCat(this->Dir.Build, '/', qrc.PathChecksum, "/qrc_", - qrc.QrcName, ".cpp"); + // Path checksum + qrc.QrcPathChecksum = fpathCheckSum.getPart(qrc.QrcFile); + // Output file name + qrc.OutputFile = cmStrCat(this->Dir.Build, '/', qrc.QrcPathChecksum, + "/qrc_", qrc.QrcName, ".cpp"); { - cm::string_view const baseSuffix = - qrc.Unique ? cm::string_view() : cm::string_view(qrc.PathChecksum); + cm::string_view const baseSuffix = qrc.Unique + ? cm::string_view() + : cm::string_view(qrc.QrcPathChecksum); std::string const base = cmStrCat(this->Dir.Info, "/RCC", qrc.QrcName, baseSuffix); qrc.LockFile = cmStrCat(base, ".lock"); @@ -910,7 +913,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() } } } - // RCC options + // rcc options for (Qrc& qrc : this->Rcc.Qrcs) { // Target options std::vector opts = optionsTarget; @@ -920,7 +923,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() // Replace '-' with '_'. The former is not valid for symbol names. std::replace(name.begin(), name.end(), '-', '_'); if (!qrc.Unique) { - name += cmStrCat('_', qrc.PathChecksum); + name += cmStrCat('_', qrc.QrcPathChecksum); } std::vector nameOpts; nameOpts.emplace_back("-name"); @@ -931,7 +934,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() RccMergeOptions(opts, qrc.Options, modernQt); qrc.Options = std::move(opts); } - // RCC resources + // rcc resources for (Qrc& qrc : this->Rcc.Qrcs) { if (!qrc.Generated) { std::string error; @@ -1099,10 +1102,10 @@ bool cmQtAutoGenInitializer::InitRccTargets() // Register info file as generated by CMake this->Makefile->AddCMakeOutputFile(qrc.InfoFile); // Register file at target - this->AddGeneratedSource(qrc.RccFile, this->Rcc); + this->AddGeneratedSource(qrc.OutputFile, this->Rcc); std::vector ccOutput; - ccOutput.push_back(qrc.RccFile); + ccOutput.push_back(qrc.OutputFile); std::vector ccDepends; // Add the .qrc and info file to the custom command dependencies @@ -1132,7 +1135,7 @@ bool cmQtAutoGenInitializer::InitRccTargets() { ccName = cmStrCat(this->GenTarget->GetName(), "_arcc_", qrc.QrcName); if (!qrc.Unique) { - ccName += cmStrCat('_', qrc.PathChecksum); + ccName += cmStrCat('_', qrc.QrcPathChecksum); } cmTarget* autoRccTarget = this->Makefile->AddUtilityCommand( @@ -1424,9 +1427,9 @@ bool cmQtAutoGenInitializer::SetupWriteRccInfo() ofs.Write("# Rcc job\n"); ofs.Write("ARCC_LOCK_FILE", qrc.LockFile); ofs.Write("ARCC_SOURCE", qrc.QrcFile); - ofs.Write("ARCC_OUTPUT_CHECKSUM", qrc.PathChecksum); + ofs.Write("ARCC_OUTPUT_CHECKSUM", qrc.QrcPathChecksum); ofs.Write("ARCC_OUTPUT_NAME", - cmSystemTools::GetFilenameName(qrc.RccFile)); + cmSystemTools::GetFilenameName(qrc.OutputFile)); ofs.WriteStrings("ARCC_OPTIONS", qrc.Options); ofs.WriteStrings("ARCC_INPUTS", qrc.Resources); } else { diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h index 7ce9fad..2411936 100644 --- a/Source/cmQtAutoGenInitializer.h +++ b/Source/cmQtAutoGenInitializer.h @@ -26,29 +26,31 @@ class cmQtAutoGenGlobalInitializer; class cmSourceFile; class cmTarget; -/// @brief Initializes the QtAutoGen generators +/** \class cmQtAutoGenerator + * \brief Initializes the QtAutoGen generators + */ class cmQtAutoGenInitializer : public cmQtAutoGen { public: - /// @brief Rcc job information + /** rcc job. */ class Qrc { public: std::string LockFile; std::string QrcFile; std::string QrcName; - std::string PathChecksum; + std::string QrcPathChecksum; std::string InfoFile; std::string SettingsFile; std::map ConfigSettingsFile; - std::string RccFile; + std::string OutputFile; bool Generated = false; bool Unique = false; std::vector Options; std::vector Resources; }; - /// @brief Moc/Uic file + /** moc and/or uic file. */ struct MUFile { std::string FullPath; @@ -61,7 +63,7 @@ public: }; using MUFileHandle = std::unique_ptr; - /// @brief Abstract moc/uic/rcc generator variables base class + /** Abstract moc/uic/rcc generator variables base class */ struct GenVarsT { bool Enabled = false; @@ -74,20 +76,19 @@ public: std::string Executable; CompilerFeaturesHandle ExecutableFeatures; - /// @brief Constructor GenVarsT(GenT gen) : Gen(gen) , GenNameUpper(cmQtAutoGen::GeneratorNameUpper(gen)){}; }; - /// @brief Writes a CMake info file + /** Writes a CMake info file. */ class InfoWriter { public: - /// @brief Open the given file + /** Open the given file. */ InfoWriter(std::string const& filename); - /// @return True if the file is open + /** @return True if the file is open. */ explicit operator bool() const { return static_cast(Ofs_); } void Write(cm::string_view text) { Ofs_ << text; } @@ -114,7 +115,7 @@ public: }; public: - /// @return The detected Qt version and the required Qt major version + /** @return The detected Qt version and the required Qt major version. */ static std::pair GetQtVersion( cmGeneratorTarget const* genTarget); @@ -128,7 +129,7 @@ public: bool SetupCustomTargets(); private: - /// @brief If moc or uic is enabled, the autogen target will be generated + /** If moc or uic is enabled, the autogen target will be generated. */ bool MocOrUicEnabled() const { return (this->Moc.Enabled || this->Uic.Enabled); @@ -162,7 +163,7 @@ private: cmLocalGenerator* LocalGen = nullptr; cmMakefile* Makefile = nullptr; - // Configuration + // -- Configuration IntegerVersion QtVersion; bool MultiConfig = false; std::string ConfigDefault; @@ -172,7 +173,7 @@ private: bool CMP0071Accept = false; bool CMP0071Warn = false; - /// @brief Common directories + /** Common directories. */ struct { std::string Info; @@ -180,9 +181,10 @@ private: std::string Work; std::string Include; std::map ConfigInclude; + std::string IncludeGenExp; } Dir; - /// @brief Autogen target variables + /** Autogen target variables. */ struct { std::string Name; @@ -204,45 +206,42 @@ private: std::vector FilesGenerated; } AutogenTarget; - /// @brief Moc only variables + /** moc variables. */ struct MocT : public GenVarsT { + MocT() + : GenVarsT(GenT::MOC){}; + std::string PredefsCmd; std::vector Includes; std::map> ConfigIncludes; std::set Defines; std::map> ConfigDefines; std::string MocsCompilation; - - /// @brief Constructor - MocT() - : GenVarsT(GenT::MOC){}; } Moc; - /// @brief Uic only variables + /** uic variables. */ struct UicT : public GenVarsT { + UicT() + : GenVarsT(GenT::UIC){}; + std::set SkipUi; std::vector SearchPaths; std::vector Options; std::map> ConfigOptions; std::vector FileFiles; std::vector> FileOptions; - - /// @brief Constructor - UicT() - : GenVarsT(GenT::UIC){}; } Uic; - /// @brief Rcc only variables + /** rcc variables. */ struct RccT : public GenVarsT { - bool GlobalTarget = false; - std::vector Qrcs; - - /// @brief Constructor RccT() : GenVarsT(GenT::RCC){}; + + bool GlobalTarget = false; + std::vector Qrcs; } Rcc; }; diff --git a/Source/cmQtAutoMocUic.h b/Source/cmQtAutoMocUic.h index 15b66ca..f37d923 100644 --- a/Source/cmQtAutoMocUic.h +++ b/Source/cmQtAutoMocUic.h @@ -78,9 +78,8 @@ public: { public: // -- Types - /** - * Entry of the file parsing cache - */ + + /** Entry of the file parsing cache. */ struct FileT { void Clear(); diff --git a/Source/cmQtAutoRcc.h b/Source/cmQtAutoRcc.h index 636a667..5d3bd6a 100644 --- a/Source/cmQtAutoRcc.h +++ b/Source/cmQtAutoRcc.h @@ -14,7 +14,9 @@ class cmMakefile; -// @brief AUTORCC generator +/** \class cmQtAutoRcc + * \brief AUTORCC generator + */ class cmQtAutoRcc : public cmQtAutoGenerator { public: diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 211fd4c..bf856d7 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -1058,18 +1058,18 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args) #ifndef CMAKE_BOOTSTRAP if ((args[1] == "cmake_autogen") && (args.size() >= 4)) { cmQtAutoMocUic autoGen; - std::string const& infoDir = args[2]; + std::string const& infoFile = args[2]; std::string const& config = args[3]; - return autoGen.Run(infoDir, config) ? 0 : 1; + return autoGen.Run(infoFile, config) ? 0 : 1; } if ((args[1] == "cmake_autorcc") && (args.size() >= 3)) { - cmQtAutoRcc autoGen; + cmQtAutoRcc autoRcc; std::string const& infoFile = args[2]; std::string config; if (args.size() > 3) { config = args[3]; } - return autoGen.Run(infoFile, config) ? 0 : 1; + return autoRcc.Run(infoFile, config) ? 0 : 1; } #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fc36f4410bcdb76ef23a07e5172cb57b41ff5ce3 commit fc36f4410bcdb76ef23a07e5172cb57b41ff5ce3 Author: Sebastian Holtermann AuthorDate: Mon Sep 23 11:52:21 2019 +0200 Commit: Sebastian Holtermann CommitDate: Wed Sep 25 10:31:06 2019 +0200 Autogen: Inline GetKnownQtVersions function diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index d595eec..3aba19d 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1506,64 +1506,60 @@ void cmQtAutoGenInitializer::AddCleanFile(std::string const& fileName) fileName.c_str(), false); } -static unsigned int CharPtrToUInt(const char* const input) -{ - unsigned long tmp = 0; - if (input != nullptr && cmStrToULong(input, &tmp)) { - return static_cast(tmp); - } - return 0; -} - -static std::vector GetKnownQtVersions( - cmGeneratorTarget const* genTarget) +std::pair +cmQtAutoGenInitializer::GetQtVersion(cmGeneratorTarget const* target) { - // Qt version variable prefixes - static std::initializer_list< - std::pair> const keys{ - { "Qt6Core_VERSION_MAJOR", "Qt6Core_VERSION_MINOR" }, - { "Qt5Core_VERSION_MAJOR", "Qt5Core_VERSION_MINOR" }, - { "QT_VERSION_MAJOR", "QT_VERSION_MINOR" }, - }; - - std::vector result; - result.reserve(keys.size() * 2); - - // Adds a version to the result (nullptr safe) - auto addVersion = [&result](const char* major, const char* minor) { - cmQtAutoGen::IntegerVersion ver(CharPtrToUInt(major), - CharPtrToUInt(minor)); - if (ver.Major != 0) { - result.emplace_back(ver); + // Converts a char ptr to an unsigned int value + auto toUInt = [](const char* const input) -> unsigned int { + unsigned long tmp = 0; + if (input != nullptr && cmStrToULong(input, &tmp)) { + return static_cast(tmp); } + return 0u; }; - cmMakefile* makefile = genTarget->Makefile; + // Initialize return value to a default + std::pair res( + IntegerVersion(), + toUInt(target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", + ""))); - // Read versions from variables - for (auto const& keyPair : keys) { - addVersion(makefile->GetDefinition(std::string(keyPair.first)), - makefile->GetDefinition(std::string(keyPair.second))); - } + // Acquire known Qt versions + std::vector knownQtVersions; + { + // Qt version variable prefixes + static std::initializer_list< + std::pair> const keys{ + { "Qt6Core_VERSION_MAJOR", "Qt6Core_VERSION_MINOR" }, + { "Qt5Core_VERSION_MAJOR", "Qt5Core_VERSION_MINOR" }, + { "QT_VERSION_MAJOR", "QT_VERSION_MINOR" }, + }; - // Read versions from directory properties - for (auto const& keyPair : keys) { - addVersion(makefile->GetProperty(std::string(keyPair.first)), - makefile->GetProperty(std::string(keyPair.second))); - } + knownQtVersions.reserve(keys.size() * 2); - return result; -} + // Adds a version to the result (nullptr safe) + auto addVersion = [&knownQtVersions, &toUInt](const char* major, + const char* minor) { + cmQtAutoGen::IntegerVersion ver(toUInt(major), toUInt(minor)); + if (ver.Major != 0) { + knownQtVersions.emplace_back(ver); + } + }; -std::pair -cmQtAutoGenInitializer::GetQtVersion(cmGeneratorTarget const* target) -{ - std::pair res( - IntegerVersion(), - CharPtrToUInt(target->GetLinkInterfaceDependentStringProperty( - "QT_MAJOR_VERSION", ""))); + // Read versions from variables + for (auto const& keyPair : keys) { + addVersion(target->Makefile->GetDefinition(std::string(keyPair.first)), + target->Makefile->GetDefinition(std::string(keyPair.second))); + } + + // Read versions from directory properties + for (auto const& keyPair : keys) { + addVersion(target->Makefile->GetProperty(std::string(keyPair.first)), + target->Makefile->GetProperty(std::string(keyPair.second))); + } + } - auto knownQtVersions = GetKnownQtVersions(target); + // Evaluate known Qt versions if (!knownQtVersions.empty()) { if (res.second == 0) { // No specific version was requested by the target: https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1f0d23546d5721fdd92883da4c4368dad3931393 commit 1f0d23546d5721fdd92883da4c4368dad3931393 Author: Sebastian Holtermann AuthorDate: Tue Sep 24 11:34:49 2019 +0200 Commit: Sebastian Holtermann CommitDate: Wed Sep 25 10:31:06 2019 +0200 Autogen: Return unsigned int from GetParallelCPUCount() diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 9045722..d595eec 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -30,7 +30,6 @@ #include "cmake.h" #include "cmsys/SystemInformation.hxx" -#include #include #include #include @@ -41,20 +40,20 @@ #include #include +#include #include namespace { -std::size_t GetParallelCPUCount() +unsigned int GetParallelCPUCount() { - static std::size_t count = 0; + static unsigned int count = 0; // Detect only on the first call if (count == 0) { cmsys::SystemInformation info; info.RunCPUCheck(); - count = info.GetNumberOfPhysicalCPU(); - count = std::max(count, 1); - count = std::min(count, cmQtAutoGen::ParallelMax); + count = + cm::clamp(info.GetNumberOfPhysicalCPU(), 1u, cmQtAutoGen::ParallelMax); } return count; } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6a05bd3fa6a3f4ecf45c4cc32abc616883998ff9 commit 6a05bd3fa6a3f4ecf45c4cc32abc616883998ff9 Author: Regina Pfeifer AuthorDate: Tue Sep 24 07:01:03 2019 +0000 Commit: Sebastian Holtermann CommitDate: Wed Sep 25 10:30:58 2019 +0200 cm/algorithm: Provide function cm::clamp diff --git a/Utilities/std/cm/algorithm b/Utilities/std/cm/algorithm new file mode 100644 index 0000000..8ade99c --- /dev/null +++ b/Utilities/std/cm/algorithm @@ -0,0 +1,38 @@ +// -*-c++-*- +// vim: set ft=cpp: + +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cm_algorithm +#define cm_algorithm + +#include // IWYU pragma: export +#include + +namespace cm { + +#if __cplusplus >= 201703L || defined(_MSVC_LANG) && _MSVC_LANG >= 201703L + +using std::clamp; + +#else + +template +T const& clamp(T const& v, T const& lo, T const& hi) +{ + assert(!(hi < lo)); + return (v < lo) ? lo : (hi < v) ? hi : v; +} + +template +T const& clamp(T const& v, T const& lo, T const& hi, Comp comp) +{ + assert(!comp(hi, lo)); + return comp(v, lo) ? lo : comp(hi, v) ? hi : v; +} + +#endif + +} // namespace cm + +#endif ----------------------------------------------------------------------- Summary of changes: Source/cmQtAutoGen.cxx | 11 +- Source/cmQtAutoGen.h | 10 +- Source/cmQtAutoGenInitializer.cxx | 902 ++++++++++++++++++++------------------ Source/cmQtAutoGenInitializer.h | 159 ++++--- Source/cmQtAutoGenerator.cxx | 260 +++++++++-- Source/cmQtAutoGenerator.h | 49 ++- Source/cmQtAutoMocUic.cxx | 513 +++++++++++----------- Source/cmQtAutoMocUic.h | 50 +-- Source/cmQtAutoRcc.cxx | 116 ++--- Source/cmQtAutoRcc.h | 11 +- Source/cmcmd.cxx | 8 +- Utilities/std/cm/algorithm | 38 ++ 12 files changed, 1177 insertions(+), 950 deletions(-) create mode 100644 Utilities/std/cm/algorithm hooks/post-receive -- CMake From kwrobot at kitware.com Thu Sep 26 10:50:24 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 26 Sep 2019 10:50:24 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1215-gb4087a2 Message-ID: <20190926145025.1EB2E113841@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via b4087a23538f87efebcc8e4ece248416c242167f (commit) via 4dc8c153ec40c48f88e74beb127949395dfbcf55 (commit) via 481070a78a90a7e6c0bfc433fec842c78d63d9de (commit) via acdb326610416ea3a559740fa79ad807a44838ee (commit) from 28a2613dd291c641f17940e3f996bd4cc9b9888d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b4087a23538f87efebcc8e4ece248416c242167f commit b4087a23538f87efebcc8e4ece248416c242167f Merge: 28a2613 4dc8c15 Author: Brad King AuthorDate: Thu Sep 26 14:43:16 2019 +0000 Commit: Kitware Robot CommitDate: Thu Sep 26 10:43:27 2019 -0400 Merge topic 'vs-ReferenceOutputAssembly-conditions' 4dc8c153ec Tests: Teach VSWinStorePhone to verify the content of generated xap 481070a78a Tests: Teach VSWinStorePhone to verify the content of generated appx/msix acdb326610 VS: Do not reference output assemblies of targets with no output Acked-by: Kitware Robot Merge-request: !3778 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4dc8c153ec40c48f88e74beb127949395dfbcf55 commit 4dc8c153ec40c48f88e74beb127949395dfbcf55 Author: Vedran Vujinovic AuthorDate: Wed Sep 25 20:57:47 2019 +0200 Commit: Vedran Vujinovic CommitDate: Wed Sep 25 20:57:47 2019 +0200 Tests: Teach VSWinStorePhone to verify the content of generated xap XAP format was used as app package format on Windows Phone 7 and 8. It was replaced by APPX format since Windows Phone 8.1. diff --git a/Tests/VSWinStorePhone/VerifyAppPackage.cmake b/Tests/VSWinStorePhone/VerifyAppPackage.cmake index f1cf030..f9440d7 100644 --- a/Tests/VSWinStorePhone/VerifyAppPackage.cmake +++ b/Tests/VSWinStorePhone/VerifyAppPackage.cmake @@ -8,8 +8,8 @@ set(EXPECTED_APP_PKG_CONTENT JusticeLeagueWinRT.dll ) -# Windows app package formats can be either appx or msix -file(GLOB_RECURSE ALL_APP_PKG_FILES ${APP_PACKAGE_DIR}/AppPackages ${APP_PKG_NAME}*.appx ${APP_PKG_NAME}*.msix) +# Windows app package formats can be either msix, appx or xap +file(GLOB_RECURSE ALL_APP_PKG_FILES ${APP_PACKAGE_DIR} ${APP_PKG_NAME}*.msix ${APP_PKG_NAME}*.appx ${APP_PKG_NAME}*.xap) # There can be only one generated app package list(LENGTH ALL_APP_PKG_FILES APP_PKG_COUNT) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=481070a78a90a7e6c0bfc433fec842c78d63d9de commit 481070a78a90a7e6c0bfc433fec842c78d63d9de Author: Vedran Vujinovic AuthorDate: Wed Sep 4 11:32:10 2019 +0200 Commit: Brad King CommitDate: Tue Sep 24 10:12:43 2019 -0400 Tests: Teach VSWinStorePhone to verify the content of generated appx/msix Add a test to verify the content of generated UWP app package - appx/msix. MSIX format was introduced Visual Studio 2017 version 15.9.0 and Windows SDK version 17763. diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 78ae7aa..c284603 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -2079,6 +2079,9 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH --build-config $ --build-options -DCMAKE_SYSTEM_NAME=${systemName} -DCMAKE_SYSTEM_VERSION=${systemVersion} + --test-command + ${CMAKE_CMAKE_COMMAND} -DAPP_PACKAGE_DIR="${CMake_BINARY_DIR}/Tests/VSWinStorePhone/${name}" + -P "${CMake_SOURCE_DIR}/Tests/VSWinStorePhone/VerifyAppPackage.cmake" ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSWinStorePhone/${name}") endmacro() diff --git a/Tests/VSWinStorePhone/CMakeLists.txt b/Tests/VSWinStorePhone/CMakeLists.txt index efc7760..b8e157d 100644 --- a/Tests/VSWinStorePhone/CMakeLists.txt +++ b/Tests/VSWinStorePhone/CMakeLists.txt @@ -9,6 +9,7 @@ elseif(MSVC_VERSION GREATER 1600) endif() add_subdirectory(WinRT) +add_subdirectory(CxxDLL) set (APP_MANIFEST_NAME Package.appxmanifest) if("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsPhone") @@ -151,4 +152,4 @@ if("${SHORT_VERSION}" STREQUAL "10.0") set_property(TARGET ${EXE_NAME} PROPERTY VS_SDK_REFERENCES "Microsoft.UniversalCRT.Debug, Version=${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}") endif() -target_link_libraries(${EXE_NAME} d3d11 JusticeLeagueWinRT) +target_link_libraries(${EXE_NAME} d3d11 JusticeLeagueWinRT CxxDll) diff --git a/Tests/VSWinStorePhone/CxxDLL/CMakeLists.txt b/Tests/VSWinStorePhone/CxxDLL/CMakeLists.txt new file mode 100644 index 0000000..6bd32a2 --- /dev/null +++ b/Tests/VSWinStorePhone/CxxDLL/CMakeLists.txt @@ -0,0 +1,3 @@ +project(CxxDll CXX) + +add_library(CxxDll SHARED cxxdll.cpp) diff --git a/Tests/VSWinStorePhone/CxxDLL/cxxdll.cpp b/Tests/VSWinStorePhone/CxxDLL/cxxdll.cpp new file mode 100644 index 0000000..d82a792 --- /dev/null +++ b/Tests/VSWinStorePhone/CxxDLL/cxxdll.cpp @@ -0,0 +1,7 @@ +#include "cxxdll.h" +#include + +void CxxDllClass::SomeMethod() +{ + std::cout << "CxxDllClass::SomeMethod\n"; +} diff --git a/Tests/VSWinStorePhone/CxxDLL/cxxdll.h b/Tests/VSWinStorePhone/CxxDLL/cxxdll.h new file mode 100644 index 0000000..86edceb --- /dev/null +++ b/Tests/VSWinStorePhone/CxxDLL/cxxdll.h @@ -0,0 +1,5 @@ +class __declspec(dllexport) CxxDllClass +{ +public: + static void SomeMethod(); +}; diff --git a/Tests/VSWinStorePhone/VerifyAppPackage.cmake b/Tests/VSWinStorePhone/VerifyAppPackage.cmake new file mode 100644 index 0000000..f1cf030 --- /dev/null +++ b/Tests/VSWinStorePhone/VerifyAppPackage.cmake @@ -0,0 +1,34 @@ +set(APP_PKG_NAME Direct3DApp1) + +# List of files that are expected to be present in the generated app package +set(EXPECTED_APP_PKG_CONTENT + ${APP_PKG_NAME}.exe + CxxDll.dll + JusticeLeagueWinRT.winmd + JusticeLeagueWinRT.dll +) + +# Windows app package formats can be either appx or msix +file(GLOB_RECURSE ALL_APP_PKG_FILES ${APP_PACKAGE_DIR}/AppPackages ${APP_PKG_NAME}*.appx ${APP_PKG_NAME}*.msix) + +# There can be only one generated app package +list(LENGTH ALL_APP_PKG_FILES APP_PKG_COUNT) +if(NOT APP_PKG_COUNT EQUAL 1) + message(FATAL_ERROR "Expected 1 generated app package, but detected ${APP_PKG_COUNT}: ${ALL_APP_PKG_FILES}") +endif() + +execute_process(COMMAND ${CMAKE_COMMAND} -E tar tf ${ALL_APP_PKG_FILES} + OUTPUT_VARIABLE APP_PKG_CONTENT_OUTPUT + ERROR_VARIABLE error + RESULT_VARIABLE result) + +if(NOT result EQUAL 0) + message(FATAL_ERROR "Listing app package content failed with: ${error}") +endif() + +foreach(app_pkg_item ${EXPECTED_APP_PKG_CONTENT}) + string(FIND ${APP_PKG_CONTENT_OUTPUT} ${app_pkg_item} _found) + if(_found EQUAL -1) + message(FATAL_ERROR "Generated app package is missing an expected item: ${app_pkg_item}") + endif() +endforeach() https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=acdb326610416ea3a559740fa79ad807a44838ee commit acdb326610416ea3a559740fa79ad807a44838ee Author: Vedran Vujinovic AuthorDate: Wed Sep 4 11:11:45 2019 +0200 Commit: Brad King CommitDate: Thu Sep 19 11:47:15 2019 -0400 VS: Do not reference output assemblies of targets with no output Our logic that sets `ReferenceOutputAssembly` in `ProjectReference` has accumulated a series of conditions for different cases in which the referenced target has no output. Simplify the condition to check `GetManagedType` directly for cases with no output. This will explicitly turn off `ReferenceOutputAssembly` in `ProjectReference` for utility (i.e. `add_custom_target`) and special targets (i.e. `ZERO_CHECK`, etc.), and allowing reference of target dependencies that produce some output. Fixes: #19665 diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ba72294..b1acccb 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -4092,32 +4092,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0) e2.Element("Name", name); this->WriteDotNetReferenceCustomTags(e2, name); - // If the dependency target is not managed (compiled with /clr or - // C# target) and not a WinRT component we cannot reference it and - // have to set 'ReferenceOutputAssembly' to false. - auto referenceNotManaged = - dt->GetManagedType("") < cmGeneratorTarget::ManagedType::Mixed; - // Workaround to check for manually set /clr flags. - if (referenceNotManaged) { - if (const auto* flags = dt->GetProperty("COMPILE_OPTIONS")) { - std::string flagsStr = flags; - if (flagsStr.find("clr") != std::string::npos) { - // There is a warning already issued when building the flags. - referenceNotManaged = false; - } - } - } - // Workaround for static library C# targets - if (referenceNotManaged && dt->GetType() == cmStateEnums::STATIC_LIBRARY) { - referenceNotManaged = !dt->IsCSharpOnly(); - } - - // Referencing WinRT components is okay. - if (referenceNotManaged) { - referenceNotManaged = !dt->GetPropertyAsBool("VS_WINRT_COMPONENT"); - } - - if (referenceNotManaged) { + // Don't reference targets that don't produce any output. + if (dt->GetManagedType("") == cmGeneratorTarget::ManagedType::Undefined) { e2.Element("ReferenceOutputAssembly", "false"); e2.Element("CopyToOutputDirectory", "Never"); } ----------------------------------------------------------------------- Summary of changes: Source/cmVisualStudio10TargetGenerator.cxx | 28 ++--------------------- Tests/CMakeLists.txt | 3 +++ Tests/VSWinStorePhone/CMakeLists.txt | 3 ++- Tests/VSWinStorePhone/CxxDLL/CMakeLists.txt | 3 +++ Tests/VSWinStorePhone/CxxDLL/cxxdll.cpp | 7 ++++++ Tests/VSWinStorePhone/CxxDLL/cxxdll.h | 5 ++++ Tests/VSWinStorePhone/VerifyAppPackage.cmake | 34 ++++++++++++++++++++++++++++ 7 files changed, 56 insertions(+), 27 deletions(-) create mode 100644 Tests/VSWinStorePhone/CxxDLL/CMakeLists.txt create mode 100644 Tests/VSWinStorePhone/CxxDLL/cxxdll.cpp create mode 100644 Tests/VSWinStorePhone/CxxDLL/cxxdll.h create mode 100644 Tests/VSWinStorePhone/VerifyAppPackage.cmake hooks/post-receive -- CMake From kwrobot at kitware.com Fri Sep 27 00:00:03 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 27 Sep 2019 00:00:03 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1216-g8c56872 Message-ID: <20190927040005.1A72A127AAB@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 8c568722d79f9de0c03550981cbcb9453733a8bb (commit) from b4087a23538f87efebcc8e4ece248416c242167f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8c568722d79f9de0c03550981cbcb9453733a8bb commit 8c568722d79f9de0c03550981cbcb9453733a8bb Author: Kitware Robot AuthorDate: Fri Sep 27 00:02:11 2019 -0400 Commit: Kitware Robot CommitDate: Fri Sep 27 00:02:11 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index d24c2c0..d9ca09b 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 15) -set(CMake_VERSION_PATCH 20190925) +set(CMake_VERSION_PATCH 20190927) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Fri Sep 27 14:39:42 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 27 Sep 2019 14:39:42 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1219-gd608b2c Message-ID: <20190927183942.B0B52517A@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via d608b2c6200afd9d732c30c862bda923139a8d08 (commit) via 8b84c046faa9d6e52b99855a955bd7b6f48e9a8b (commit) via c71ac889ba6565c2a2aa31a403e3ab999abb5570 (commit) from 8c568722d79f9de0c03550981cbcb9453733a8bb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d608b2c6200afd9d732c30c862bda923139a8d08 commit d608b2c6200afd9d732c30c862bda923139a8d08 Merge: 8c56872 8b84c04 Author: Brad King AuthorDate: Fri Sep 27 18:38:02 2019 +0000 Commit: Kitware Robot CommitDate: Fri Sep 27 14:38:30 2019 -0400 Merge topic 'fileapiSourcePropertyBacktraces' 8b84c046fa fileapi: add some source property backtraces c71ac889ba cmSourceFile: Add backtraces for a few source properties Acked-by: Kitware Robot Merge-request: !3861 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8b84c046faa9d6e52b99855a955bd7b6f48e9a8b commit 8b84c046faa9d6e52b99855a955bd7b6f48e9a8b Author: Justin Goshi AuthorDate: Tue Sep 24 12:19:49 2019 -0700 Commit: Brad King CommitDate: Thu Sep 26 10:56:52 2019 -0400 fileapi: add some source property backtraces Support backtraces for COMPILE_DEFINITIONS, COMPILE_OPTIONS, and INCLUDE_DIRECTORIES source properties. diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 96ea071..fbdb975 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -858,47 +858,69 @@ CompileData Target::BuildCompileData(cmSourceFile* sf) fd.Flags.emplace_back(std::move(flags), JBTIndex()); } const std::string COMPILE_OPTIONS("COMPILE_OPTIONS"); - if (const char* coptions = sf->GetProperty(COMPILE_OPTIONS)) { - std::string flags; - lg->AppendCompileOptions( - flags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS)); - fd.Flags.emplace_back(std::move(flags), JBTIndex()); + for (BT tmpOpt : sf->GetCompileOptions()) { + tmpOpt.Value = genexInterpreter.Evaluate(tmpOpt.Value, COMPILE_OPTIONS); + // After generator evaluation we need to use the AppendCompileOptions + // method so we handle situations where backtrace entries have lists + // and properly escape flags. + std::string tmp; + lg->AppendCompileOptions(tmp, tmpOpt.Value); + BT opt(tmp, tmpOpt.Backtrace); + fd.Flags.emplace_back(this->ToJBT(opt)); } // Add include directories from source file properties. { - std::vector includes; const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES"); - if (const char* cincludes = sf->GetProperty(INCLUDE_DIRECTORIES)) { - const std::string& evaluatedIncludes = - genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES); - lg->AppendIncludeDirectories(includes, evaluatedIncludes, *sf); - - for (std::string const& include : includes) { - bool const isSystemInclude = this->GT->IsSystemIncludeDirectory( - include, this->Config, fd.Language); - fd.Includes.emplace_back(include, isSystemInclude); + for (BT tmpInclude : sf->GetIncludeDirectories()) { + tmpInclude.Value = + genexInterpreter.Evaluate(tmpInclude.Value, INCLUDE_DIRECTORIES); + + // After generator evaluation we need to use the AppendIncludeDirectories + // method so we handle situations where backtrace entries have lists. + std::vector tmp; + lg->AppendIncludeDirectories(tmp, tmpInclude.Value, *sf); + for (std::string& i : tmp) { + bool const isSystemInclude = + this->GT->IsSystemIncludeDirectory(i, this->Config, fd.Language); + BT include(i, tmpInclude.Backtrace); + fd.Includes.emplace_back(this->ToJBT(include), isSystemInclude); } } } const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS"); - std::set fileDefines; - if (const char* defs = sf->GetProperty(COMPILE_DEFINITIONS)) { - lg->AppendDefines(fileDefines, - genexInterpreter.Evaluate(defs, COMPILE_DEFINITIONS)); + std::set> fileDefines; + for (BT tmpDef : sf->GetCompileDefinitions()) { + tmpDef.Value = + genexInterpreter.Evaluate(tmpDef.Value, COMPILE_DEFINITIONS); + + // After generator evaluation we need to use the AppendDefines method + // so we handle situations where backtrace entries have lists. + std::set tmp; + lg->AppendDefines(tmp, tmpDef.Value); + for (const std::string& i : tmp) { + BT def(i, tmpDef.Backtrace); + fileDefines.insert(def); + } } + std::set configFileDefines; const std::string defPropName = "COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(this->Config); if (const char* config_defs = sf->GetProperty(defPropName)) { lg->AppendDefines( - fileDefines, + configFileDefines, genexInterpreter.Evaluate(config_defs, COMPILE_DEFINITIONS)); } - fd.Defines.reserve(fileDefines.size()); - for (std::string const& d : fileDefines) { + fd.Defines.reserve(fileDefines.size() + configFileDefines.size()); + + for (BT const& def : fileDefines) { + fd.Defines.emplace_back(this->ToJBT(def)); + } + + for (std::string const& d : configFileDefines) { fd.Defines.emplace_back(d, JBTIndex()); } diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py index 52934f2..66c559d 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py +++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py @@ -4838,7 +4838,20 @@ def gen_check_targets(c, g, inSource): { "path": "^.*/Tests/RunCMake/FileAPI/FileAPIExternalBuild$", "isSystem": None, - "backtrace": None, + "backtrace": [ + { + "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$", + "line": 10, + "command": "set_property", + "hasParent": True, + }, + { + "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$", + "line": None, + "command": None, + "hasParent": False, + }, + ], }, { "path": "^.*/Tests/RunCMake/FileAPIExternalSource$", @@ -4862,11 +4875,37 @@ def gen_check_targets(c, g, inSource): "defines": [ { "define": "EMPTY_C=1", - "backtrace": None, + "backtrace": [ + { + "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$", + "line": 9, + "command": "set_property", + "hasParent": True, + }, + { + "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$", + "line": None, + "command": None, + "hasParent": False, + }, + ], }, { "define": "SRC_DUMMY", - "backtrace": None, + "backtrace": [ + { + "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$", + "line": 9, + "command": "set_property", + "hasParent": True, + }, + { + "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$", + "line": None, + "command": None, + "hasParent": False, + }, + ], }, { "define": "GENERATED_EXE=1", @@ -4903,7 +4942,25 @@ def gen_check_targets(c, g, inSource): ], }, ], - "compileCommandFragments": None, + "compileCommandFragments": [ + { + "fragment" : "SRC_COMPILE_OPTIONS_DUMMY", + "backtrace": [ + { + "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$", + "line": 13, + "command": "set_source_files_properties", + "hasParent": True, + }, + { + "file" : "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$", + "line": None, + "command": None, + "hasParent": False, + }, + ], + } + ], }, { "language": "CXX", diff --git a/Tests/RunCMake/FileAPIExternalSource/CMakeLists.txt b/Tests/RunCMake/FileAPIExternalSource/CMakeLists.txt index f5670a7..b3ca660 100644 --- a/Tests/RunCMake/FileAPIExternalSource/CMakeLists.txt +++ b/Tests/RunCMake/FileAPIExternalSource/CMakeLists.txt @@ -10,3 +10,4 @@ set_property(SOURCE empty.c PROPERTY COMPILE_DEFINITIONS EMPTY_C=1 SRC_DUMMY) set_property(SOURCE empty.c PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}") target_include_directories(generated_exe SYSTEM PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") target_compile_definitions(generated_exe PRIVATE GENERATED_EXE=1 -DTGT_DUMMY) +set_source_files_properties(empty.c PROPERTIES COMPILE_OPTIONS SRC_COMPILE_OPTIONS_DUMMY) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c71ac889ba6565c2a2aa31a403e3ab999abb5570 commit c71ac889ba6565c2a2aa31a403e3ab999abb5570 Author: Justin Goshi AuthorDate: Mon Sep 23 11:21:07 2019 -0700 Commit: Brad King CommitDate: Thu Sep 26 10:56:52 2019 -0400 cmSourceFile: Add backtraces for a few source properties Adding backtrace support for INCLUDE_DIRECTORIES, COMPILE_OPTIONS, and COMPILE_DEFINITIONS. diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index bd68d04..2a345eb 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -6,6 +6,7 @@ #include #include "cmGlobalGenerator.h" +#include "cmListFileCache.h" #include "cmMakefile.h" #include "cmMessageType.h" #include "cmProperty.h" @@ -28,6 +29,11 @@ std::string const& cmSourceFile::GetExtension() const const std::string cmSourceFile::propLANGUAGE = "LANGUAGE"; const std::string cmSourceFile::propLOCATION = "LOCATION"; const std::string cmSourceFile::propGENERATED = "GENERATED"; +const std::string cmSourceFile::propCOMPILE_DEFINITIONS = + "COMPILE_DEFINITIONS"; +const std::string cmSourceFile::propCOMPILE_OPTIONS = "COMPILE_OPTIONS"; +const std::string cmSourceFile::propINCLUDE_DIRECTORIES = + "INCLUDE_DIRECTORIES"; void cmSourceFile::SetObjectLibrary(std::string const& objlib) { @@ -226,7 +232,27 @@ bool cmSourceFile::Matches(cmSourceFileLocation const& loc) void cmSourceFile::SetProperty(const std::string& prop, const char* value) { - this->Properties.SetProperty(prop, value); + if (prop == propINCLUDE_DIRECTORIES) { + this->IncludeDirectories.clear(); + if (value) { + cmListFileBacktrace lfbt = this->Location.GetMakefile()->GetBacktrace(); + this->IncludeDirectories.emplace_back(value, lfbt); + } + } else if (prop == propCOMPILE_OPTIONS) { + this->CompileOptions.clear(); + if (value) { + cmListFileBacktrace lfbt = this->Location.GetMakefile()->GetBacktrace(); + this->CompileOptions.emplace_back(value, lfbt); + } + } else if (prop == propCOMPILE_DEFINITIONS) { + this->CompileDefinitions.clear(); + if (value) { + cmListFileBacktrace lfbt = this->Location.GetMakefile()->GetBacktrace(); + this->CompileDefinitions.emplace_back(value, lfbt); + } + } else { + this->Properties.SetProperty(prop, value); + } // Update IsGenerated flag if (prop == propGENERATED) { @@ -237,7 +263,24 @@ void cmSourceFile::SetProperty(const std::string& prop, const char* value) void cmSourceFile::AppendProperty(const std::string& prop, const char* value, bool asString) { - this->Properties.AppendProperty(prop, value, asString); + if (prop == propINCLUDE_DIRECTORIES) { + if (value && *value) { + cmListFileBacktrace lfbt = this->Location.GetMakefile()->GetBacktrace(); + this->IncludeDirectories.emplace_back(value, lfbt); + } + } else if (prop == propCOMPILE_OPTIONS) { + if (value && *value) { + cmListFileBacktrace lfbt = this->Location.GetMakefile()->GetBacktrace(); + this->CompileOptions.emplace_back(value, lfbt); + } + } else if (prop == propCOMPILE_DEFINITIONS) { + if (value && *value) { + cmListFileBacktrace lfbt = this->Location.GetMakefile()->GetBacktrace(); + this->CompileDefinitions.emplace_back(value, lfbt); + } + } else { + this->Properties.AppendProperty(prop, value, asString); + } // Update IsGenerated flag if (prop == propGENERATED) { @@ -287,6 +330,37 @@ const char* cmSourceFile::GetProperty(const std::string& prop) const return this->FullPath.c_str(); } + // Check for the properties with backtraces. + if (prop == propINCLUDE_DIRECTORIES) { + if (this->IncludeDirectories.empty()) { + return nullptr; + } + + static std::string output; + output = cmJoin(this->IncludeDirectories, ";"); + return output.c_str(); + } + + if (prop == propCOMPILE_OPTIONS) { + if (this->CompileOptions.empty()) { + return nullptr; + } + + static std::string output; + output = cmJoin(this->CompileOptions, ";"); + return output.c_str(); + } + + if (prop == propCOMPILE_DEFINITIONS) { + if (this->CompileDefinitions.empty()) { + return nullptr; + } + + static std::string output; + output = cmJoin(this->CompileDefinitions, ";"); + return output.c_str(); + } + const char* retVal = this->Properties.GetPropertyValue(prop); if (!retVal) { cmMakefile const* mf = this->Location.GetMakefile(); diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index 3b18fdb..6ef4167 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -6,6 +6,7 @@ #include "cmConfigure.h" // IWYU pragma: keep #include "cmCustomCommand.h" +#include "cmListFileCache.h" #include "cmPropertyMap.h" #include "cmSourceFileLocation.h" #include "cmSourceFileLocationKind.h" @@ -57,6 +58,21 @@ public: /// @return Equivalent to GetPropertyAsBool("GENERATED") bool GetIsGenerated() const { return this->IsGenerated; } + const std::vector>& GetCompileOptions() const + { + return this->CompileOptions; + } + + const std::vector>& GetCompileDefinitions() const + { + return this->CompileDefinitions; + } + + const std::vector>& GetIncludeDirectories() const + { + return this->IncludeDirectories; + } + /** * Resolves the full path to the file. Attempts to locate the file on disk * and finalizes its location. @@ -116,6 +132,9 @@ private: std::string FullPath; std::string ObjectLibrary; std::vector Depends; + std::vector> CompileOptions; + std::vector> CompileDefinitions; + std::vector> IncludeDirectories; bool FindFullPathFailed = false; bool IsGenerated = false; @@ -126,6 +145,9 @@ private: static const std::string propLANGUAGE; static const std::string propLOCATION; static const std::string propGENERATED; + static const std::string propCOMPILE_DEFINITIONS; + static const std::string propCOMPILE_OPTIONS; + static const std::string propINCLUDE_DIRECTORIES; }; // TODO: Factor out into platform information modules. ----------------------------------------------------------------------- Summary of changes: Source/cmFileAPICodemodel.cxx | 66 ++++++++++++------ Source/cmSourceFile.cxx | 78 +++++++++++++++++++++- Source/cmSourceFile.h | 22 ++++++ Tests/RunCMake/FileAPI/codemodel-v2-check.py | 65 ++++++++++++++++-- .../RunCMake/FileAPIExternalSource/CMakeLists.txt | 1 + 5 files changed, 204 insertions(+), 28 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Fri Sep 27 14:59:43 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 27 Sep 2019 14:59:43 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1229-gc88cf48 Message-ID: <20190927185943.4E2D41256E0@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via c88cf48bbe775c45c36c23b990c89d85b7b9a220 (commit) via f30f1625c25afb44861eff1f69ca4fa966077c73 (commit) via 0672647e123670342d68827354610c747fe98004 (commit) via b2fd479df595394734ed1a830848cba2f57729f2 (commit) via 9d1a1bc495be41b035f61f9b707df8006da54160 (commit) via 587ccffe74638676090005ac6b7f799f15a0112c (commit) via 5a06efda05feda02511592c76134ee8ed3e8b650 (commit) via ea1bed34b2ba16f3971b90996dc345834f0d9699 (commit) via 91abf9f3c4a80f5a8417401d5277b3b66bc7d008 (commit) via f151a5770597dbe341fc6329a711f40e9195c773 (commit) from d608b2c6200afd9d732c30c862bda923139a8d08 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c88cf48bbe775c45c36c23b990c89d85b7b9a220 commit c88cf48bbe775c45c36c23b990c89d85b7b9a220 Merge: f30f162 b2fd479 Author: Brad King AuthorDate: Fri Sep 27 18:56:32 2019 +0000 Commit: Kitware Robot CommitDate: Fri Sep 27 14:56:53 2019 -0400 Merge topic 'FindBinUtils-ask-compiler' b2fd479df5 FindBinUtils: Use the compiler to get the path to compiler tools 587ccffe74 Tests: Add symbols to FortranModules static libraries Acked-by: Kitware Robot Acked-by: Alex Turbov Merge-request: !3854 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f30f1625c25afb44861eff1f69ca4fa966077c73 commit f30f1625c25afb44861eff1f69ca4fa966077c73 Merge: 0672647 5a06efd Author: Brad King AuthorDate: Fri Sep 27 18:54:39 2019 +0000 Commit: Kitware Robot CommitDate: Fri Sep 27 14:54:58 2019 -0400 Merge topic 'decompose-custom-command-creation' 5a06efda05 cmMakefile: Remove AddUtilityCommand overload without byproducts ea1bed34b2 cmMakefile: Extract utilities used for creation of custom commands 91abf9f3c4 cmCustomCommand: Move custom commands f151a57705 cmMakefile: Move enumerations into new header Acked-by: Kitware Robot Merge-request: !3846 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0672647e123670342d68827354610c747fe98004 commit 0672647e123670342d68827354610c747fe98004 Merge: d608b2c 9d1a1bc Author: Brad King AuthorDate: Fri Sep 27 18:51:46 2019 +0000 Commit: Kitware Robot CommitDate: Fri Sep 27 14:52:01 2019 -0400 Merge topic 'free-target-commands' 9d1a1bc495 cmTarget*: Port away from cmCommand Acked-by: Kitware Robot Merge-request: !3799 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b2fd479df595394734ed1a830848cba2f57729f2 commit b2fd479df595394734ed1a830848cba2f57729f2 Author: Isuru Fernando AuthorDate: Sun Sep 22 12:50:44 2019 -0500 Commit: Isuru Fernando CommitDate: Thu Sep 26 19:11:00 2019 -0500 FindBinUtils: Use the compiler to get the path to compiler tools Fixes: #19728 diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 781b48c..3887b2d 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -57,6 +57,44 @@ endfunction() __resolve_tool_path(CMAKE_LINKER "${_CMAKE_TOOLCHAIN_LOCATION}" "Default Linker") __resolve_tool_path(CMAKE_MT "${_CMAKE_TOOLCHAIN_LOCATION}" "Default Manifest Tool") +function(__get_compiler_component CMAKE_TOOL NAME) + get_property(_CMAKE_TOOL_CACHED CACHE ${CMAKE_TOOL} PROPERTY TYPE) + # If CMAKE_TOOL is present in the CMake Cache, return + if(_CMAKE_TOOL_CACHED) + return() + endif() + + cmake_parse_arguments(_COMPILER_COMP_ARGS "" "DOC" "HINTS;NAMES" ${ARGN}) + + set(_LOCATION_FROM_COMPILER ) + set(_NAME_FROM_COMPILER ) + + if (NOT DEFINED ${CMAKE_TOOL}) + if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xGNU" OR + "x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xClang") + execute_process( + COMMAND ${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER} -print-prog-name=${NAME} + RESULT_VARIABLE _CMAKE_TOOL_PROG_NAME_RESULT + OUTPUT_VARIABLE _CMAKE_TOOL_PROG_NAME_OUTPUT + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if (_CMAKE_TOOL_PROG_NAME_RESULT STREQUAL "0" AND IS_ABSOLUTE "${_CMAKE_TOOL_PROG_NAME_OUTPUT}") + get_filename_component(_LOCATION_FROM_COMPILER "${_CMAKE_TOOL_PROG_NAME_OUTPUT}" DIRECTORY) + get_filename_component(_NAME_FROM_COMPILER "${_CMAKE_TOOL_PROG_NAME_OUTPUT}" NAME) + endif() + endif() + endif() + + if (NOT _COMPILER_COMP_ARGS_DOC) + set(_COMPILER_COMP_ARGS_DOC "Path to ${NAME} program") + endif() + find_program(${CMAKE_TOOL} + NAMES ${_NAME_FROM_COMPILER} ${_COMPILER_COMP_ARGS_NAMES} + HINTS ${_LOCATION_FROM_COMPILER} ${_COMPILER_COMP_ARGS_HINTS} + DOC "${_COMPILER_COMP_ARGS_DOC}" + ) +endfunction() + set(_CMAKE_TOOL_VARS "") # if it's the MS C/CXX compiler, search for link @@ -101,22 +139,32 @@ else() set(_CMAKE_ADDITIONAL_ADDR2LINE_NAMES "llvm-addr2line") endif() - find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} ${_CMAKE_ADDITIONAL_AR_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + __get_compiler_component(CMAKE_AR ar NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} ${_CMAKE_ADDITIONAL_AR_NAMES} + HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib ${_CMAKE_ADDITIONAL_RANLIB_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + __get_compiler_component(CMAKE_RANLIB ranlib NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib ${_CMAKE_ADDITIONAL_RANLIB_NAMES} + HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) if(NOT CMAKE_RANLIB) set(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib") endif() - find_program(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip${_CMAKE_TOOLCHAIN_SUFFIX} ${_CMAKE_ADDITIONAL_STRIP_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld ${_CMAKE_ADDITIONAL_LINKER_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm ${_CMAKE_ADDITIONAL_NM_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump ${_CMAKE_ADDITIONAL_OBJDUMP_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_OBJCOPY NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy ${_CMAKE_ADDITIONAL_OBJCOPY_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_READELF NAMES ${_CMAKE_TOOLCHAIN_PREFIX}readelf ${_CMAKE_ADDITIONAL_READELF_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_DLLTOOL NAMES ${_CMAKE_TOOLCHAIN_PREFIX}dlltool ${_CMAKE_ADDITIONAL_DLLTOOL_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_ADDR2LINE NAMES ${_CMAKE_TOOLCHAIN_PREFIX}addr2line ${_CMAKE_ADDITIONAL_ADDR2LINE_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + __get_compiler_component(CMAKE_STRIP strip NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip${_CMAKE_TOOLCHAIN_SUFFIX} ${_CMAKE_ADDITIONAL_STRIP_NAMES} + HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + __get_compiler_component(CMAKE_LINKER ld NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld ${_CMAKE_ADDITIONAL_LINKER_NAMES} + HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + __get_compiler_component(CMAKE_NM nm NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm ${_CMAKE_ADDITIONAL_NM_NAMES} + HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + __get_compiler_component(CMAKE_OBJDUMP objdump NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump ${_CMAKE_ADDITIONAL_OBJDUMP_NAMES} + HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + __get_compiler_component(CMAKE_OBJCOPY objcopy NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy ${_CMAKE_ADDITIONAL_OBJCOPY_NAMES} + HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + __get_compiler_component(CMAKE_READELF readelf NAMES ${_CMAKE_TOOLCHAIN_PREFIX}readelf ${_CMAKE_ADDITIONAL_READELF_NAMES} + HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + __get_compiler_component(CMAKE_DLLTOOL dlltool NAMES ${_CMAKE_TOOLCHAIN_PREFIX}dlltool ${_CMAKE_ADDITIONAL_DLLTOOL_NAMES} + HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + __get_compiler_component(CMAKE_ADDR2LINE addr2line NAMES ${_CMAKE_TOOLCHAIN_PREFIX}addr2line ${_CMAKE_ADDITIONAL_ADDR2LINE_NAMES} + HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) list(APPEND _CMAKE_TOOL_VARS AR RANLIB STRIP LINKER NM OBJDUMP OBJCOPY READELF DLLTOOL ADDR2LINE) @@ -134,7 +182,7 @@ else() endif() if(CMAKE_PLATFORM_HAS_INSTALLNAME) - find_program(CMAKE_INSTALL_NAME_TOOL NAMES ${_CMAKE_TOOLCHAIN_PREFIX}install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + __get_compiler_component(CMAKE_INSTALL_NAME_TOOL install_name_tool NAMES ${_CMAKE_TOOLCHAIN_PREFIX}install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) if(NOT CMAKE_INSTALL_NAME_TOOL) message(FATAL_ERROR "Could not find install_name_tool, please check your installation.") diff --git a/Modules/Compiler/GNU-FindBinUtils.cmake b/Modules/Compiler/GNU-FindBinUtils.cmake index 097fbf3..a47b7ad 100644 --- a/Modules/Compiler/GNU-FindBinUtils.cmake +++ b/Modules/Compiler/GNU-FindBinUtils.cmake @@ -15,21 +15,27 @@ string(REGEX MATCH "^([0-9]+\\.[0-9]+)" __version_x_y get_filename_component(__gcc_hints "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" DIRECTORY) # http://manpages.ubuntu.com/manpages/wily/en/man1/gcc-ar.1.html -find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR NAMES - "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar-${__version_x_y}" - "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar-${__version_x}" - "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar${_CMAKE_COMPILER_SUFFIX}" - HINTS ${__gcc_hints} +__get_compiler_component( + CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR gcc-ar + HINTS + ${__gcc_hints} + NAMES + "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar-${__version_x_y}" + "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar-${__version_x}" + "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar" DOC "A wrapper around 'ar' adding the appropriate '--plugin' option for the GCC compiler" ) mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR) # http://manpages.ubuntu.com/manpages/wily/en/man1/gcc-ranlib.1.html -find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB NAMES - "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib-${__version_x_y}" - "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib-${__version_x}" - "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib${_CMAKE_COMPILER_SUFFIX}" - HINTS ${__gcc_hints} +__get_compiler_component( + CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB gcc-ranlib + HINTS + ${__gcc_hints} + NAMES + "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib-${__version_x_y}" + "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib-${__version_x}" + "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib" DOC "A wrapper around 'ranlib' adding the appropriate '--plugin' option for the GCC compiler" ) mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9d1a1bc495be41b035f61f9b707df8006da54160 commit 9d1a1bc495be41b035f61f9b707df8006da54160 Author: Regina Pfeifer AuthorDate: Tue Sep 10 21:41:44 2019 +0200 Commit: Brad King CommitDate: Thu Sep 26 13:27:55 2019 -0400 cmTarget*: Port away from cmCommand diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 88d17f1..b1f7db7 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -246,26 +246,22 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("set_tests_properties", cmSetTestsPropertiesCommand); state->AddBuiltinCommand("subdirs", cmSubdirCommand); - state->AddBuiltinCommand( - "target_compile_definitions", - cm::make_unique()); + state->AddBuiltinCommand("target_compile_definitions", + cmTargetCompileDefinitionsCommand); state->AddBuiltinCommand("target_compile_features", - cm::make_unique()); + cmTargetCompileFeaturesCommand); state->AddBuiltinCommand("target_compile_options", - cm::make_unique()); - state->AddBuiltinCommand( - "target_include_directories", - cm::make_unique()); + cmTargetCompileOptionsCommand); + state->AddBuiltinCommand("target_include_directories", + cmTargetIncludeDirectoriesCommand); state->AddBuiltinCommand("target_link_libraries", cmTargetLinkLibrariesCommand); - state->AddBuiltinCommand("target_sources", - cm::make_unique()); + state->AddBuiltinCommand("target_sources", cmTargetSourcesCommand); state->AddBuiltinCommand("try_compile", cm::make_unique()); state->AddBuiltinCommand("try_run", cm::make_unique()); - state->AddBuiltinCommand( - "target_precompile_headers", - cm::make_unique()); + state->AddBuiltinCommand("target_precompile_headers", + cmTargetPrecompileHeadersCommand); #if !defined(CMAKE_BOOTSTRAP) state->AddBuiltinCommand("add_compile_definitions", @@ -280,10 +276,9 @@ void GetProjectCommands(cmState* state) state->AddBuiltinCommand("install_programs", cmInstallProgramsCommand); state->AddBuiltinCommand("add_link_options", cmAddLinkOptionsCommand); state->AddBuiltinCommand("link_libraries", cmLinkLibrariesCommand); - state->AddBuiltinCommand("target_link_options", - cm::make_unique()); + state->AddBuiltinCommand("target_link_options", cmTargetLinkOptionsCommand); state->AddBuiltinCommand("target_link_directories", - cm::make_unique()); + cmTargetLinkDirectoriesCommand); state->AddBuiltinCommand("load_cache", cmLoadCacheCommand); state->AddBuiltinCommand("qt_wrap_cpp", cmQTWrapCPPCommand); state->AddBuiltinCommand("qt_wrap_ui", cmQTWrapUICommand); diff --git a/Source/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx index 94e249f..edee167 100644 --- a/Source/cmTargetCompileDefinitionsCommand.cxx +++ b/Source/cmTargetCompileDefinitionsCommand.cxx @@ -6,43 +6,53 @@ #include "cmMessageType.h" #include "cmStringAlgorithms.h" #include "cmTarget.h" +#include "cmTargetPropCommandBase.h" -class cmExecutionStatus; +namespace { -bool cmTargetCompileDefinitionsCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +class TargetCompileDefinitionsImpl : public cmTargetPropCommandBase { - return this->HandleArguments(args, "COMPILE_DEFINITIONS"); -} +public: + using cmTargetPropCommandBase::cmTargetPropCommandBase; -void cmTargetCompileDefinitionsCommand::HandleMissingTarget( - const std::string& name) -{ - this->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat("Cannot specify compile definitions for target \"", name, - "\" which is not built by this project.")); -} +private: + void HandleMissingTarget(const std::string& name) override + { + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Cannot specify compile definitions for target \"", name, + "\" which is not built by this project.")); + } -std::string cmTargetCompileDefinitionsCommand::Join( - const std::vector& content) -{ - std::string defs; - std::string sep; - for (std::string const& it : content) { - if (cmHasLiteralPrefix(it, "-D")) { - defs += sep + it.substr(2); - } else { - defs += sep + it; + bool HandleDirectContent(cmTarget* tgt, + const std::vector& content, + bool /*prepend*/, bool /*system*/) override + { + tgt->AppendProperty("COMPILE_DEFINITIONS", this->Join(content).c_str()); + return true; // Successfully handled. + } + + std::string Join(const std::vector& content) override + { + std::string defs; + std::string sep; + for (std::string const& it : content) { + if (cmHasLiteralPrefix(it, "-D")) { + defs += sep + it.substr(2); + } else { + defs += sep + it; + } + sep = ";"; } - sep = ";"; + return defs; } - return defs; -} +}; + +} // namespace -bool cmTargetCompileDefinitionsCommand::HandleDirectContent( - cmTarget* tgt, const std::vector& content, bool, bool) +bool cmTargetCompileDefinitionsCommand(std::vector const& args, + cmExecutionStatus& status) { - tgt->AppendProperty("COMPILE_DEFINITIONS", this->Join(content).c_str()); - return true; // Successfully handled. + return TargetCompileDefinitionsImpl(status).HandleArguments( + args, "COMPILE_DEFINITIONS"); } diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h index f85dc0a..05ff092 100644 --- a/Source/cmTargetCompileDefinitionsCommand.h +++ b/Source/cmTargetCompileDefinitionsCommand.h @@ -8,39 +8,9 @@ #include #include -#include - -#include "cmCommand.h" -#include "cmTargetPropCommandBase.h" - class cmExecutionStatus; -class cmTarget; - -class cmTargetCompileDefinitionsCommand : public cmTargetPropCommandBase -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - -private: - void HandleMissingTarget(const std::string& name) override; - bool HandleDirectContent(cmTarget* tgt, - const std::vector& content, - bool prepend, bool system) override; - std::string Join(const std::vector& content) override; -}; +bool cmTargetCompileDefinitionsCommand(std::vector const& args, + cmExecutionStatus& status); #endif diff --git a/Source/cmTargetCompileFeaturesCommand.cxx b/Source/cmTargetCompileFeaturesCommand.cxx index a22b94b..06be4f0 100644 --- a/Source/cmTargetCompileFeaturesCommand.cxx +++ b/Source/cmTargetCompileFeaturesCommand.cxx @@ -5,40 +5,51 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmStringAlgorithms.h" +#include "cmTargetPropCommandBase.h" -class cmExecutionStatus; class cmTarget; -bool cmTargetCompileFeaturesCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) -{ - return this->HandleArguments(args, "COMPILE_FEATURES", NO_FLAGS); -} +namespace { -void cmTargetCompileFeaturesCommand::HandleMissingTarget( - const std::string& name) +class TargetCompileFeaturesImpl : public cmTargetPropCommandBase { - this->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat("Cannot specify compile features for target \"", name, - "\" which is not built by this project.")); -} +public: + using cmTargetPropCommandBase::cmTargetPropCommandBase; -std::string cmTargetCompileFeaturesCommand::Join( - const std::vector& content) -{ - return cmJoin(content, ";"); -} +private: + void HandleMissingTarget(const std::string& name) override + { + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Cannot specify compile features for target \"", name, + "\" which is not built by this project.")); + } -bool cmTargetCompileFeaturesCommand::HandleDirectContent( - cmTarget* tgt, const std::vector& content, bool, bool) -{ - for (std::string const& it : content) { - std::string error; - if (!this->Makefile->AddRequiredTargetFeature(tgt, it, &error)) { - this->SetError(error); - return false; // Not (successfully) handled. + bool HandleDirectContent(cmTarget* tgt, + const std::vector& content, + bool /*prepend*/, bool /*system*/) override + { + for (std::string const& it : content) { + std::string error; + if (!this->Makefile->AddRequiredTargetFeature(tgt, it, &error)) { + this->SetError(error); + return false; // Not (successfully) handled. + } } + return true; // Successfully handled. + } + + std::string Join(const std::vector& content) override + { + return cmJoin(content, ";"); } - return true; // Successfully handled. +}; + +} // namespace + +bool cmTargetCompileFeaturesCommand(std::vector const& args, + cmExecutionStatus& status) +{ + return TargetCompileFeaturesImpl(status).HandleArguments(args, + "COMPILE_FEATURES"); } diff --git a/Source/cmTargetCompileFeaturesCommand.h b/Source/cmTargetCompileFeaturesCommand.h index 39597ca..db0c04b 100644 --- a/Source/cmTargetCompileFeaturesCommand.h +++ b/Source/cmTargetCompileFeaturesCommand.h @@ -8,31 +8,9 @@ #include #include -#include - -#include "cmCommand.h" -#include "cmTargetPropCommandBase.h" - class cmExecutionStatus; -class cmTarget; - -class cmTargetCompileFeaturesCommand : public cmTargetPropCommandBase -{ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - -private: - void HandleMissingTarget(const std::string& name) override; - bool HandleDirectContent(cmTarget* tgt, - const std::vector& content, - bool prepend, bool system) override; - std::string Join(const std::vector& content) override; -}; +bool cmTargetCompileFeaturesCommand(std::vector const& args, + cmExecutionStatus& status); #endif diff --git a/Source/cmTargetCompileOptionsCommand.cxx b/Source/cmTargetCompileOptionsCommand.cxx index ccc215a..e39b726 100644 --- a/Source/cmTargetCompileOptionsCommand.cxx +++ b/Source/cmTargetCompileOptionsCommand.cxx @@ -7,34 +7,44 @@ #include "cmMessageType.h" #include "cmStringAlgorithms.h" #include "cmTarget.h" +#include "cmTargetPropCommandBase.h" -class cmExecutionStatus; +namespace { -bool cmTargetCompileOptionsCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +class TargetCompileOptionsImpl : public cmTargetPropCommandBase { - return this->HandleArguments(args, "COMPILE_OPTIONS", PROCESS_BEFORE); -} +public: + using cmTargetPropCommandBase::cmTargetPropCommandBase; -void cmTargetCompileOptionsCommand::HandleMissingTarget( - const std::string& name) -{ - this->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat("Cannot specify compile options for target \"", name, - "\" which is not built by this project.")); -} +private: + void HandleMissingTarget(const std::string& name) override + { + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Cannot specify compile options for target \"", name, + "\" which is not built by this project.")); + } -std::string cmTargetCompileOptionsCommand::Join( - const std::vector& content) -{ - return cmJoin(content, ";"); -} + bool HandleDirectContent(cmTarget* tgt, + const std::vector& content, + bool /*prepend*/, bool /*system*/) override + { + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + tgt->InsertCompileOption(this->Join(content), lfbt); + return true; // Successfully handled. + } + + std::string Join(const std::vector& content) override + { + return cmJoin(content, ";"); + } +}; + +} // namespace -bool cmTargetCompileOptionsCommand::HandleDirectContent( - cmTarget* tgt, const std::vector& content, bool, bool) +bool cmTargetCompileOptionsCommand(std::vector const& args, + cmExecutionStatus& status) { - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - tgt->InsertCompileOption(this->Join(content), lfbt); - return true; // Successfully handled. + return TargetCompileOptionsImpl(status).HandleArguments( + args, "COMPILE_OPTIONS", TargetCompileOptionsImpl::PROCESS_BEFORE); } diff --git a/Source/cmTargetCompileOptionsCommand.h b/Source/cmTargetCompileOptionsCommand.h index b328ba2..3ab1a89 100644 --- a/Source/cmTargetCompileOptionsCommand.h +++ b/Source/cmTargetCompileOptionsCommand.h @@ -8,39 +8,9 @@ #include #include -#include - -#include "cmCommand.h" -#include "cmTargetPropCommandBase.h" - class cmExecutionStatus; -class cmTarget; - -class cmTargetCompileOptionsCommand : public cmTargetPropCommandBase -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - -private: - void HandleMissingTarget(const std::string& name) override; - bool HandleDirectContent(cmTarget* tgt, - const std::vector& content, - bool prepend, bool system) override; - std::string Join(const std::vector& content) override; -}; +bool cmTargetCompileOptionsCommand(std::vector const& args, + cmExecutionStatus& status); #endif diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index 7801ee8..95b69f3 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -11,26 +11,36 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTarget.h" +#include "cmTargetPropCommandBase.h" -class cmExecutionStatus; +namespace { -bool cmTargetIncludeDirectoriesCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +class TargetIncludeDirectoriesImpl : public cmTargetPropCommandBase { - return this->HandleArguments(args, "INCLUDE_DIRECTORIES", - ArgumentFlags(PROCESS_BEFORE | PROCESS_SYSTEM)); -} +public: + using cmTargetPropCommandBase::cmTargetPropCommandBase; -void cmTargetIncludeDirectoriesCommand::HandleMissingTarget( - const std::string& name) -{ - this->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat("Cannot specify include directories for target \"", name, - "\" which is not built by this project.")); -} +private: + void HandleMissingTarget(const std::string& name) override + { + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Cannot specify include directories for target \"", name, + "\" which is not built by this project.")); + } + + bool HandleDirectContent(cmTarget* tgt, + const std::vector& content, + bool prepend, bool system) override; + + void HandleInterfaceContent(cmTarget* tgt, + const std::vector& content, + bool prepend, bool system) override; -std::string cmTargetIncludeDirectoriesCommand::Join( + std::string Join(const std::vector& content) override; +}; + +std::string TargetIncludeDirectoriesImpl::Join( const std::vector& content) { std::string dirs; @@ -48,7 +58,7 @@ std::string cmTargetIncludeDirectoriesCommand::Join( return dirs; } -bool cmTargetIncludeDirectoriesCommand::HandleDirectContent( +bool TargetIncludeDirectoriesImpl::HandleDirectContent( cmTarget* tgt, const std::vector& content, bool prepend, bool system) { @@ -70,16 +80,27 @@ bool cmTargetIncludeDirectoriesCommand::HandleDirectContent( return true; // Successfully handled. } -void cmTargetIncludeDirectoriesCommand::HandleInterfaceContent( +void TargetIncludeDirectoriesImpl::HandleInterfaceContent( cmTarget* tgt, const std::vector& content, bool prepend, bool system) { cmTargetPropCommandBase::HandleInterfaceContent(tgt, content, prepend, system); - if (system) { std::string joined = this->Join(content); tgt->AppendProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", joined.c_str()); } } + +} // namespace + +bool cmTargetIncludeDirectoriesCommand(std::vector const& args, + cmExecutionStatus& status) +{ + return TargetIncludeDirectoriesImpl(status).HandleArguments( + args, "INCLUDE_DIRECTORIES", + TargetIncludeDirectoriesImpl::ArgumentFlags( + TargetIncludeDirectoriesImpl::PROCESS_BEFORE | + TargetIncludeDirectoriesImpl::PROCESS_SYSTEM)); +} diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h index f6481db..9958f41 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.h +++ b/Source/cmTargetIncludeDirectoriesCommand.h @@ -8,43 +8,9 @@ #include #include -#include - -#include "cmCommand.h" -#include "cmTargetPropCommandBase.h" - class cmExecutionStatus; -class cmTarget; - -class cmTargetIncludeDirectoriesCommand : public cmTargetPropCommandBase -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - -private: - void HandleMissingTarget(const std::string& name) override; - - bool HandleDirectContent(cmTarget* tgt, - const std::vector& content, - bool prepend, bool system) override; - void HandleInterfaceContent(cmTarget* tgt, - const std::vector& content, - bool prepend, bool system) override; - std::string Join(const std::vector& content) override; -}; +bool cmTargetIncludeDirectoriesCommand(std::vector const& args, + cmExecutionStatus& status); #endif diff --git a/Source/cmTargetLinkDirectoriesCommand.cxx b/Source/cmTargetLinkDirectoriesCommand.cxx index c2ef6c1..0c68d60 100644 --- a/Source/cmTargetLinkDirectoriesCommand.cxx +++ b/Source/cmTargetLinkDirectoriesCommand.cxx @@ -9,25 +9,37 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTarget.h" +#include "cmTargetPropCommandBase.h" -class cmExecutionStatus; +namespace { -bool cmTargetLinkDirectoriesCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +class TargetLinkDirectoriesImpl : public cmTargetPropCommandBase { - return this->HandleArguments(args, "LINK_DIRECTORIES", PROCESS_BEFORE); -} +public: + using cmTargetPropCommandBase::cmTargetPropCommandBase; -void cmTargetLinkDirectoriesCommand::HandleMissingTarget( - const std::string& name) -{ - this->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat("Cannot specify link directories for target \"", name, - "\" which is not built by this project.")); -} +private: + void HandleMissingTarget(const std::string& name) override + { + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Cannot specify link directories for target \"", name, + "\" which is not built by this project.")); + } + + std::string Join(const std::vector& content) override; -std::string cmTargetLinkDirectoriesCommand::Join( + bool HandleDirectContent(cmTarget* tgt, + const std::vector& content, + bool prepend, bool /*system*/) override + { + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + tgt->InsertLinkDirectory(this->Join(content), lfbt, prepend); + return true; // Successfully handled. + } +}; + +std::string TargetLinkDirectoriesImpl::Join( const std::vector& content) { std::vector directories; @@ -48,12 +60,11 @@ std::string cmTargetLinkDirectoriesCommand::Join( return cmJoin(directories, ";"); } -bool cmTargetLinkDirectoriesCommand::HandleDirectContent( - cmTarget* tgt, const std::vector& content, bool prepend, bool) -{ - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); +} // namespace - tgt->InsertLinkDirectory(this->Join(content), lfbt, prepend); - - return true; // Successfully handled. +bool cmTargetLinkDirectoriesCommand(std::vector const& args, + cmExecutionStatus& status) +{ + return TargetLinkDirectoriesImpl(status).HandleArguments( + args, "LINK_DIRECTORIES", TargetLinkDirectoriesImpl::PROCESS_BEFORE); } diff --git a/Source/cmTargetLinkDirectoriesCommand.h b/Source/cmTargetLinkDirectoriesCommand.h index a651d73..3724d6c 100644 --- a/Source/cmTargetLinkDirectoriesCommand.h +++ b/Source/cmTargetLinkDirectoriesCommand.h @@ -8,39 +8,9 @@ #include #include -#include - -#include "cmCommand.h" -#include "cmTargetPropCommandBase.h" - class cmExecutionStatus; -class cmTarget; - -class cmTargetLinkDirectoriesCommand : public cmTargetPropCommandBase -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - -private: - void HandleMissingTarget(const std::string& name) override; - std::string Join(const std::vector& content) override; - bool HandleDirectContent(cmTarget* tgt, - const std::vector& content, - bool prepend, bool system) override; -}; +bool cmTargetLinkDirectoriesCommand(std::vector const& args, + cmExecutionStatus& status); #endif diff --git a/Source/cmTargetLinkOptionsCommand.cxx b/Source/cmTargetLinkOptionsCommand.cxx index dbd7bfe..df9416f 100644 --- a/Source/cmTargetLinkOptionsCommand.cxx +++ b/Source/cmTargetLinkOptionsCommand.cxx @@ -7,33 +7,44 @@ #include "cmMessageType.h" #include "cmStringAlgorithms.h" #include "cmTarget.h" +#include "cmTargetPropCommandBase.h" -class cmExecutionStatus; +namespace { -bool cmTargetLinkOptionsCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +class TargetLinkOptionsImpl : public cmTargetPropCommandBase { - return this->HandleArguments(args, "LINK_OPTIONS", PROCESS_BEFORE); -} +public: + using cmTargetPropCommandBase::cmTargetPropCommandBase; -void cmTargetLinkOptionsCommand::HandleMissingTarget(const std::string& name) -{ - this->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat("Cannot specify link options for target \"", name, - "\" which is not built by this project.")); -} +private: + void HandleMissingTarget(const std::string& name) override + { + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Cannot specify link options for target \"", name, + "\" which is not built by this project.")); + } -std::string cmTargetLinkOptionsCommand::Join( - const std::vector& content) -{ - return cmJoin(content, ";"); -} + bool HandleDirectContent(cmTarget* tgt, + const std::vector& content, + bool prepend, bool /*system*/) override + { + cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + tgt->InsertLinkOption(this->Join(content), lfbt, prepend); + return true; // Successfully handled. + } + + std::string Join(const std::vector& content) override + { + return cmJoin(content, ";"); + } +}; + +} // namespace -bool cmTargetLinkOptionsCommand::HandleDirectContent( - cmTarget* tgt, const std::vector& content, bool prepend, bool) +bool cmTargetLinkOptionsCommand(std::vector const& args, + cmExecutionStatus& status) { - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - tgt->InsertLinkOption(this->Join(content), lfbt, prepend); - return true; // Successfully handled. + return TargetLinkOptionsImpl(status).HandleArguments( + args, "LINK_OPTIONS", TargetLinkOptionsImpl::PROCESS_BEFORE); } diff --git a/Source/cmTargetLinkOptionsCommand.h b/Source/cmTargetLinkOptionsCommand.h index 918a8d7..13fb40c 100644 --- a/Source/cmTargetLinkOptionsCommand.h +++ b/Source/cmTargetLinkOptionsCommand.h @@ -8,39 +8,9 @@ #include #include -#include - -#include "cmCommand.h" -#include "cmTargetPropCommandBase.h" - class cmExecutionStatus; -class cmTarget; - -class cmTargetLinkOptionsCommand : public cmTargetPropCommandBase -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - -private: - void HandleMissingTarget(const std::string& name) override; - bool HandleDirectContent(cmTarget* tgt, - const std::vector& content, - bool prepend, bool system) override; - std::string Join(const std::vector& content) override; -}; +bool cmTargetLinkOptionsCommand(std::vector const& args, + cmExecutionStatus& status); #endif diff --git a/Source/cmTargetPrecompileHeadersCommand.cxx b/Source/cmTargetPrecompileHeadersCommand.cxx index 5751fff..887d973 100644 --- a/Source/cmTargetPrecompileHeadersCommand.cxx +++ b/Source/cmTargetPrecompileHeadersCommand.cxx @@ -8,51 +8,14 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTarget.h" +#include "cmTargetPropCommandBase.h" #include -bool cmTargetPrecompileHeadersCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) -{ - return this->HandleArguments(args, "PRECOMPILE_HEADERS", PROCESS_REUSE_FROM); -} - -void cmTargetPrecompileHeadersCommand::HandleInterfaceContent( - cmTarget* tgt, const std::vector& content, bool prepend, - bool system) -{ - cmTargetPropCommandBase::HandleInterfaceContent( - tgt, ConvertToAbsoluteContent(tgt, content, true), prepend, system); -} - -void cmTargetPrecompileHeadersCommand::HandleMissingTarget( - const std::string& name) -{ - const std::string e = - cmStrCat("Cannot specify precompile headers for target \"", name, - "\" which is not built by this project."); - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e); -} - -std::string cmTargetPrecompileHeadersCommand::Join( - const std::vector& content) -{ - return cmJoin(content, ";"); -} - -bool cmTargetPrecompileHeadersCommand::HandleDirectContent( - cmTarget* tgt, const std::vector& content, bool, bool) -{ - tgt->AppendProperty( - "PRECOMPILE_HEADERS", - this->Join(ConvertToAbsoluteContent(tgt, content, false)).c_str()); - return true; -} +namespace { -std::vector -cmTargetPrecompileHeadersCommand::ConvertToAbsoluteContent( - cmTarget* /*tgt*/, const std::vector& content, - bool /*isInterfaceContent*/) +std::vector ConvertToAbsoluteContent( + const std::vector& content, std::string const& baseDir) { std::vector absoluteContent; absoluteContent.reserve(content.size()); @@ -66,10 +29,59 @@ cmTargetPrecompileHeadersCommand::ConvertToAbsoluteContent( cmGeneratorExpression::Find(src) == 0) { absoluteSrc = src; } else { - absoluteSrc = - cmStrCat(this->Makefile->GetCurrentSourceDirectory(), '/', src); + absoluteSrc = cmStrCat(baseDir, '/', src); } absoluteContent.emplace_back(std::move(absoluteSrc)); } return absoluteContent; } + +class TargetPrecompileHeadersImpl : public cmTargetPropCommandBase +{ +public: + using cmTargetPropCommandBase::cmTargetPropCommandBase; + +private: + bool HandleDirectContent(cmTarget* tgt, + const std::vector& content, + bool /*prepend*/, bool /*system*/) override + { + std::string const& base = this->Makefile->GetCurrentSourceDirectory(); + tgt->AppendProperty( + "PRECOMPILE_HEADERS", + this->Join(ConvertToAbsoluteContent(content, base)).c_str()); + return true; + } + + void HandleInterfaceContent(cmTarget* tgt, + const std::vector& content, + bool prepend, bool system) override + { + std::string const& base = this->Makefile->GetCurrentSourceDirectory(); + cmTargetPropCommandBase::HandleInterfaceContent( + tgt, ConvertToAbsoluteContent(content, base), prepend, system); + } + + void HandleMissingTarget(const std::string& name) override + { + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Cannot specify precompile headers for target \"", name, + "\" which is not built by this project.")); + } + + std::string Join(const std::vector& content) override + { + return cmJoin(content, ";"); + } +}; + +} // namespace + +bool cmTargetPrecompileHeadersCommand(std::vector const& args, + cmExecutionStatus& status) +{ + return TargetPrecompileHeadersImpl(status).HandleArguments( + args, "PRECOMPILE_HEADERS", + TargetPrecompileHeadersImpl::PROCESS_REUSE_FROM); +} diff --git a/Source/cmTargetPrecompileHeadersCommand.h b/Source/cmTargetPrecompileHeadersCommand.h index 00dc928..8b0ac97 100644 --- a/Source/cmTargetPrecompileHeadersCommand.h +++ b/Source/cmTargetPrecompileHeadersCommand.h @@ -8,43 +8,9 @@ #include #include -#include - -#include "cmCommand.h" - -#include "cmTargetPropCommandBase.h" - class cmExecutionStatus; -class cmTarget; - -class cmTargetPrecompileHeadersCommand : public cmTargetPropCommandBase -{ -public: - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - -protected: - void HandleInterfaceContent(cmTarget* tgt, - const std::vector& content, - bool prepend, bool system) override; - -private: - void HandleMissingTarget(const std::string& name) override; - - bool HandleDirectContent(cmTarget* tgt, - const std::vector& content, - bool prepend, bool system) override; - - std::string Join(const std::vector& content) override; - std::vector ConvertToAbsoluteContent( - cmTarget* tgt, const std::vector& content, - bool isInterfaceContent); -}; +bool cmTargetPrecompileHeadersCommand(std::vector const& args, + cmExecutionStatus& status); #endif diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index 4bc3125..bbc1e16 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -2,12 +2,24 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmTargetPropCommandBase.h" +#include "cmExecutionStatus.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmStateTypes.h" #include "cmTarget.h" #include "cmake.h" +cmTargetPropCommandBase::cmTargetPropCommandBase(cmExecutionStatus& status) + : Makefile(&status.GetMakefile()) + , Status(status) +{ +} + +void cmTargetPropCommandBase::SetError(std::string const& e) +{ + this->Status.SetError(e); +} + bool cmTargetPropCommandBase::HandleArguments( std::vector const& args, const std::string& prop, ArgumentFlags flags) diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h index b244417..601ad01 100644 --- a/Source/cmTargetPropCommandBase.h +++ b/Source/cmTargetPropCommandBase.h @@ -8,13 +8,18 @@ #include #include -#include "cmCommand.h" - +class cmExecutionStatus; +class cmMakefile; class cmTarget; -class cmTargetPropCommandBase : public cmCommand +class cmTargetPropCommandBase { public: + cmTargetPropCommandBase(cmExecutionStatus& status); + virtual ~cmTargetPropCommandBase() = default; + + void SetError(std::string const& e); + enum ArgumentFlags { NO_FLAGS = 0x0, @@ -30,6 +35,7 @@ public: protected: std::string Property; cmTarget* Target = nullptr; + cmMakefile* Makefile; virtual void HandleInterfaceContent(cmTarget* tgt, const std::vector& content, @@ -49,6 +55,8 @@ private: bool PopulateTargetProperies(const std::string& scope, const std::vector& content, bool prepend, bool system); + + cmExecutionStatus& Status; }; #endif diff --git a/Source/cmTargetSourcesCommand.cxx b/Source/cmTargetSourcesCommand.cxx index 7c9d03c..c2e0b28 100644 --- a/Source/cmTargetSourcesCommand.cxx +++ b/Source/cmTargetSourcesCommand.cxx @@ -11,47 +11,54 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTarget.h" +#include "cmTargetPropCommandBase.h" -class cmExecutionStatus; +namespace { -bool cmTargetSourcesCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +class TargetSourcesImpl : public cmTargetPropCommandBase { - return this->HandleArguments(args, "SOURCES"); -} +public: + using cmTargetPropCommandBase::cmTargetPropCommandBase; -void cmTargetSourcesCommand::HandleInterfaceContent( - cmTarget* tgt, const std::vector& content, bool prepend, - bool system) -{ - cmTargetPropCommandBase::HandleInterfaceContent( - tgt, ConvertToAbsoluteContent(tgt, content, true), prepend, system); -} +protected: + void HandleInterfaceContent(cmTarget* tgt, + const std::vector& content, + bool prepend, bool system) override + { + cmTargetPropCommandBase::HandleInterfaceContent( + tgt, ConvertToAbsoluteContent(tgt, content, true), prepend, system); + } -void cmTargetSourcesCommand::HandleMissingTarget(const std::string& name) -{ - this->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat("Cannot specify sources for target \"", name, - "\" which is not built by this project.")); -} +private: + void HandleMissingTarget(const std::string& name) override + { + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Cannot specify sources for target \"", name, + "\" which is not built by this project.")); + } -std::string cmTargetSourcesCommand::Join( - const std::vector& content) -{ - return cmJoin(content, ";"); -} + bool HandleDirectContent(cmTarget* tgt, + const std::vector& content, + bool /*prepend*/, bool /*system*/) override + { + tgt->AppendProperty( + "SOURCES", + this->Join(ConvertToAbsoluteContent(tgt, content, false)).c_str()); + return true; // Successfully handled. + } -bool cmTargetSourcesCommand::HandleDirectContent( - cmTarget* tgt, const std::vector& content, bool, bool) -{ - tgt->AppendProperty( - "SOURCES", - this->Join(ConvertToAbsoluteContent(tgt, content, false)).c_str()); - return true; // Successfully handled. -} + std::string Join(const std::vector& content) override + { + return cmJoin(content, ";"); + } + + std::vector ConvertToAbsoluteContent( + cmTarget* tgt, const std::vector& content, + bool isInterfaceContent); +}; -std::vector cmTargetSourcesCommand::ConvertToAbsoluteContent( +std::vector TargetSourcesImpl::ConvertToAbsoluteContent( cmTarget* tgt, const std::vector& content, bool isInterfaceContent) { @@ -120,3 +127,11 @@ std::vector cmTargetSourcesCommand::ConvertToAbsoluteContent( return useAbsoluteContent ? absoluteContent : content; } + +} // namespace + +bool cmTargetSourcesCommand(std::vector const& args, + cmExecutionStatus& status) +{ + return TargetSourcesImpl(status).HandleArguments(args, "SOURCES"); +} diff --git a/Source/cmTargetSourcesCommand.h b/Source/cmTargetSourcesCommand.h index 1cff8c3..5eecf34 100644 --- a/Source/cmTargetSourcesCommand.h +++ b/Source/cmTargetSourcesCommand.h @@ -8,49 +8,9 @@ #include #include -#include - -#include "cmCommand.h" -#include "cmTargetPropCommandBase.h" - class cmExecutionStatus; -class cmTarget; - -class cmTargetSourcesCommand : public cmTargetPropCommandBase -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - -protected: - void HandleInterfaceContent(cmTarget* tgt, - const std::vector& content, - bool prepend, bool system) override; - -private: - void HandleMissingTarget(const std::string& name) override; - - bool HandleDirectContent(cmTarget* tgt, - const std::vector& content, - bool prepend, bool system) override; - - std::string Join(const std::vector& content) override; - std::vector ConvertToAbsoluteContent( - cmTarget* tgt, const std::vector& content, - bool isInterfaceContent); -}; +bool cmTargetSourcesCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=587ccffe74638676090005ac6b7f799f15a0112c commit 587ccffe74638676090005ac6b7f799f15a0112c Author: Brad King AuthorDate: Thu Sep 26 10:27:55 2019 -0400 Commit: Brad King CommitDate: Thu Sep 26 10:31:44 2019 -0400 Tests: Add symbols to FortranModules static libraries When GNU `ar` creates an archive with no symbols it has only an empty header but no string table. On Solaris the OS-provided `ld` fails in this case: ld: elf error: file libfoo.a: elf_getarsym Update our test to actually provide symbols from its archives. diff --git a/Tests/FortranModules/Library/a.f90 b/Tests/FortranModules/Library/a.f90 index 3031c07..c180cc0 100644 --- a/Tests/FortranModules/Library/a.f90 +++ b/Tests/FortranModules/Library/a.f90 @@ -1,3 +1,6 @@ MODULE libraryModuleA USE libraryModuleB +CONTAINS + SUBROUTINE libA + END SUBROUTINE END MODULE diff --git a/Tests/FortranModules/Library/b.f90 b/Tests/FortranModules/Library/b.f90 index ae1edcb..f550996 100644 --- a/Tests/FortranModules/Library/b.f90 +++ b/Tests/FortranModules/Library/b.f90 @@ -1,2 +1,5 @@ MODULE libraryModuleB +CONTAINS + SUBROUTINE libB + END SUBROUTINE END MODULE diff --git a/Tests/FortranModules/Subdir/subdir.f90 b/Tests/FortranModules/Subdir/subdir.f90 index 68955f6..5288b06 100644 --- a/Tests/FortranModules/Subdir/subdir.f90 +++ b/Tests/FortranModules/Subdir/subdir.f90 @@ -1,2 +1,5 @@ MODULE subdirModuleA +CONTAINS + SUBROUTINE subdirLibA + END SUBROUTINE END MODULE https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5a06efda05feda02511592c76134ee8ed3e8b650 commit 5a06efda05feda02511592c76134ee8ed3e8b650 Author: Daniel Eiband AuthorDate: Sat Sep 21 01:17:15 2019 +0200 Commit: Brad King CommitDate: Thu Sep 26 10:04:03 2019 -0400 cmMakefile: Remove AddUtilityCommand overload without byproducts diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 29d2495..78a232e 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -220,8 +220,10 @@ void CCONV cmAddUtilityCommand(void* arg, const char* utilityName, } // Pass the call to the makefile instance. + std::vector no_byproducts; mf->AddUtilityCommand(utilityName, cmCommandOrigin::Project, - (all ? false : true), nullptr, depends2, commandLines); + (all ? false : true), nullptr, no_byproducts, depends2, + commandLines); } void CCONV cmAddCustomCommand(void* arg, const char* source, const char* command, int numArgs, diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 808bebd..8e6125b 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -96,17 +96,18 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() return false; } - const char* no_working_directory = nullptr; - std::vector no_depends; std::vector const& generators = this->LocalGenerators; cmLocalVisualStudio7Generator* lg = static_cast(generators[0]); cmMakefile* mf = lg->GetMakefile(); - cmCustomCommandLines noCommandLines; + const char* no_working_directory = nullptr; + std::vector no_byproducts; + std::vector no_depends; + cmCustomCommandLines no_commands; cmTarget* tgt = mf->AddUtilityCommand( CMAKE_CHECK_BUILD_SYSTEM_TARGET, cmCommandOrigin::Generator, false, - no_working_directory, no_depends, noCommandLines); + no_working_directory, no_byproducts, no_depends, no_commands); cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg); lg->AddGeneratorTarget(gt); @@ -182,7 +183,6 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() // file as the main dependency because it would get // overwritten by the CreateVCProjBuildRule. // (this could be avoided with per-target source files) - std::vector no_byproducts; std::string no_main_dependency; cmImplicitDependsList no_implicit_depends; if (cmSourceFile* file = mf->AddCustomCommandToOutput( diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 82219bd..0bc08a5 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -183,7 +183,8 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets() { // Add a special target that depends on ALL projects for easy build // of one configuration only. - const char* no_working_dir = 0; + const char* no_working_dir = nullptr; + std::vector no_byproducts; std::vector no_depends; cmCustomCommandLines no_commands; for (auto const& it : this->ProjectMap) { @@ -194,7 +195,7 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets() // considered always out of date. cmTarget* allBuild = gen[0]->GetMakefile()->AddUtilityCommand( "ALL_BUILD", cmCommandOrigin::Generator, true, no_working_dir, - no_depends, no_commands, false, "Build all projects"); + no_byproducts, no_depends, no_commands, false, "Build all projects"); cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]); gen[0]->AddGeneratorTarget(gt); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index e4dff78..4202175 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -497,12 +497,15 @@ void cmGlobalXCodeGenerator::AddExtraTargets( { cmMakefile* mf = root->GetMakefile(); - // Add ALL_BUILD const char* no_working_directory = nullptr; + std::vector no_byproducts; std::vector no_depends; + + // Add ALL_BUILD cmTarget* allbuild = mf->AddUtilityCommand( "ALL_BUILD", cmCommandOrigin::Generator, true, no_working_directory, - no_depends, cmMakeSingleCommandLine({ "echo", "Build all projects" })); + no_byproducts, no_depends, + cmMakeSingleCommandLine({ "echo", "Build all projects" })); cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root); root->AddGeneratorTarget(allBuildGt); @@ -526,7 +529,7 @@ void cmGlobalXCodeGenerator::AddExtraTargets( cmSystemTools::ReplaceString(file, "\\ ", " "); cmTarget* check = mf->AddUtilityCommand( CMAKE_CHECK_BUILD_SYSTEM_TARGET, cmCommandOrigin::Generator, true, - no_working_directory, no_depends, + no_working_directory, no_byproducts, no_depends, cmMakeSingleCommandLine({ "make", "-f", file })); cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root); @@ -541,9 +544,8 @@ void cmGlobalXCodeGenerator::AddExtraTargets( continue; } - std::string targetName = target->GetName(); - - if (regenerate && (targetName != CMAKE_CHECK_BUILD_SYSTEM_TARGET)) { + if (regenerate && + (target->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET)) { target->Target->AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET); } @@ -554,7 +556,6 @@ void cmGlobalXCodeGenerator::AddExtraTargets( if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) { commandLines.front().back() = // fill placeholder this->PostBuildMakeTarget(target->GetName(), "$(CONFIGURATION)"); - std::vector no_byproducts; gen->GetMakefile()->AddCustomCommandToTarget( target->GetName(), no_byproducts, no_depends, commandLines, cmCustomCommandType::POST_BUILD, "Depend check for xcode", diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2e1c821..a528fc6 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1213,20 +1213,6 @@ cmUtilityOutput cmMakefile::GetUtilityOutput(cmTarget* target) cmTarget* cmMakefile::AddUtilityCommand( const std::string& utilityName, cmCommandOrigin origin, bool excludeFromAll, - const char* workingDirectory, const std::vector& depends, - const cmCustomCommandLines& commandLines, bool escapeOldStyle, - const char* comment, bool uses_terminal, bool command_expand_lists, - const std::string& job_pool) -{ - std::vector no_byproducts; - return this->AddUtilityCommand( - utilityName, origin, excludeFromAll, workingDirectory, no_byproducts, - depends, commandLines, escapeOldStyle, comment, uses_terminal, - command_expand_lists, job_pool); -} - -cmTarget* cmMakefile::AddUtilityCommand( - const std::string& utilityName, cmCommandOrigin origin, bool excludeFromAll, const char* workingDirectory, const std::vector& byproducts, const std::vector& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle, @@ -1237,8 +1223,8 @@ cmTarget* cmMakefile::AddUtilityCommand( this->AddNewUtilityTarget(utilityName, origin, excludeFromAll); // Validate custom commands. - if (!this->ValidateCustomCommand(commandLines) || - (commandLines.empty() && depends.empty())) { + if ((commandLines.empty() && depends.empty()) || + !this->ValidateCustomCommand(commandLines)) { return target; } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 5ea2cce..bb88bed 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -264,13 +264,6 @@ public: cmTarget* AddUtilityCommand( const std::string& utilityName, cmCommandOrigin origin, bool excludeFromAll, const char* workingDirectory, - const std::vector& depends, - const cmCustomCommandLines& commandLines, bool escapeOldStyle = true, - const char* comment = nullptr, bool uses_terminal = false, - bool command_expand_lists = false, const std::string& job_pool = ""); - cmTarget* AddUtilityCommand( - const std::string& utilityName, cmCommandOrigin origin, - bool excludeFromAll, const char* workingDirectory, const std::vector& byproducts, const std::vector& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle = true, https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ea1bed34b2ba16f3971b90996dc345834f0d9699 commit ea1bed34b2ba16f3971b90996dc345834f0d9699 Author: Daniel Eiband AuthorDate: Sat Sep 21 00:55:34 2019 +0200 Commit: Brad King CommitDate: Thu Sep 26 10:03:48 2019 -0400 cmMakefile: Extract utilities used for creation of custom commands Decompose creation of custom commands further into logical steps. diff --git a/Source/cmCustomCommandTypes.h b/Source/cmCustomCommandTypes.h index f3ecd6e..d4bf1f9 100644 --- a/Source/cmCustomCommandTypes.h +++ b/Source/cmCustomCommandTypes.h @@ -5,6 +5,8 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include + /** Target custom command type */ enum class cmCustomCommandType { @@ -27,4 +29,11 @@ enum class cmObjectLibraryCommands Accept }; +/** Utility target output source file name. */ +struct cmUtilityOutput +{ + std::string Name; + std::string NameCMP0049; +}; + #endif diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index d1235b2..2e1c821 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -838,13 +838,8 @@ bool cmMakefile::ValidateCustomCommand( return true; } -cmTarget* cmMakefile::AddCustomCommandToTarget( - const std::string& target, const std::vector& byproducts, - const std::vector& depends, - const cmCustomCommandLines& commandLines, cmCustomCommandType type, - const char* comment, const char* workingDir, bool escapeOldStyle, - bool uses_terminal, const std::string& depfile, const std::string& job_pool, - bool command_expand_lists, cmObjectLibraryCommands objLibCommands) +cmTarget* cmMakefile::GetCustomCommandTarget( + const std::string& target, cmObjectLibraryCommands objLibCommands) const { // Find the target to which to add the custom command. auto ti = this->Targets.find(target); @@ -903,8 +898,21 @@ cmTarget* cmMakefile::AddCustomCommandToTarget( return nullptr; } + return t; +} + +cmTarget* cmMakefile::AddCustomCommandToTarget( + const std::string& target, const std::vector& byproducts, + const std::vector& depends, + const cmCustomCommandLines& commandLines, cmCustomCommandType type, + const char* comment, const char* workingDir, bool escapeOldStyle, + bool uses_terminal, const std::string& depfile, const std::string& job_pool, + bool command_expand_lists, cmObjectLibraryCommands objLibCommands) +{ + cmTarget* t = this->GetCustomCommandTarget(target, objLibCommands); + // Validate custom commands. - if (!this->ValidateCustomCommand(commandLines)) { + if (!t || !this->ValidateCustomCommand(commandLines)) { return t; } @@ -947,37 +955,8 @@ void cmMakefile::CommitCustomCommandToTarget( target->AddPostBuildCommand(std::move(cc)); break; } - this->UpdateOutputToSourceMap(byproducts, target); -} -void cmMakefile::UpdateOutputToSourceMap( - std::vector const& byproducts, cmTarget* target) -{ - for (std::string const& o : byproducts) { - this->UpdateOutputToSourceMap(o, target); - } -} - -void cmMakefile::UpdateOutputToSourceMap(std::string const& byproduct, - cmTarget* target) -{ - SourceEntry entry; - entry.Sources.Target = target; - - auto pr = this->OutputToSource.emplace(byproduct, entry); - if (!pr.second) { - SourceEntry& current = pr.first->second; - // Has the target already been set? - if (!current.Sources.Target) { - current.Sources.Target = target; - } else { - // Multiple custom commands/targets produce the same output (source file - // or target). See also comment in other UpdateOutputToSourceMap - // overload. - // - // TODO: Warn the user about this case. - } - } + this->AddTargetByproducts(target, byproducts); } cmSourceFile* cmMakefile::AddCustomCommandToOutput( @@ -1103,47 +1082,10 @@ cmSourceFile* cmMakefile::CommitCustomCommandToOutput( cc->SetDepfile(depfile); cc->SetJobPool(job_pool); file->SetCustomCommand(std::move(cc)); - this->UpdateOutputToSourceMap(outputs, file, false); - this->UpdateOutputToSourceMap(byproducts, file, true); - } - return file; -} -void cmMakefile::UpdateOutputToSourceMap( - std::vector const& outputs, cmSourceFile* source, - bool byproduct) -{ - for (std::string const& o : outputs) { - this->UpdateOutputToSourceMap(o, source, byproduct); - } -} - -void cmMakefile::UpdateOutputToSourceMap(std::string const& output, - cmSourceFile* source, bool byproduct) -{ - SourceEntry entry; - entry.Sources.Source = source; - entry.Sources.SourceIsByproduct = byproduct; - - auto pr = this->OutputToSource.emplace(output, entry); - if (!pr.second) { - SourceEntry& current = pr.first->second; - // Outputs take precedence over byproducts - if (!current.Sources.Source || - (current.Sources.SourceIsByproduct && !byproduct)) { - current.Sources.Source = source; - current.Sources.SourceIsByproduct = false; - } else { - // Multiple custom commands produce the same output but may - // be attached to a different source file (MAIN_DEPENDENCY). - // LinearGetSourceFileWithOutput would return the first one, - // so keep the mapping for the first one. - // - // TODO: Warn the user about this case. However, the VS 8 generator - // triggers it for separate generate.stamp rules in ZERO_CHECK and - // individual targets. - } + this->AddSourceOutputs(file, outputs, byproducts); } + return file; } void cmMakefile::AddCustomCommandOldStyle( @@ -1248,6 +1190,27 @@ void cmMakefile::CommitAppendCustomCommandToOutput( } } +cmUtilityOutput cmMakefile::GetUtilityOutput(cmTarget* target) +{ + std::string force = cmStrCat(this->GetCurrentBinaryDirectory(), + "/CMakeFiles/", target->GetName()); + std::string forceCMP0049 = target->GetSourceCMP0049(force); + { + cmSourceFile* sf = nullptr; + if (!forceCMP0049.empty()) { + sf = this->GetOrCreateSource(forceCMP0049, false, + cmSourceFileLocationKind::Known); + } + // The output is not actually created so mark it symbolic. + if (sf) { + sf->SetProperty("SYMBOLIC", "1"); + } else { + cmSystemTools::Error("Could not get source file entry for " + force); + } + } + return { std::move(force), std::move(forceCMP0049) }; +} + cmTarget* cmMakefile::AddUtilityCommand( const std::string& utilityName, cmCommandOrigin origin, bool excludeFromAll, const char* workingDirectory, const std::vector& depends, @@ -1270,12 +1233,8 @@ cmTarget* cmMakefile::AddUtilityCommand( const char* comment, bool uses_terminal, bool command_expand_lists, const std::string& job_pool) { - // Create a target instance for this utility. - cmTarget* target = this->AddNewTarget(cmStateEnums::UTILITY, utilityName); - target->SetIsGeneratorProvided(origin == cmCommandOrigin::Generator); - if (excludeFromAll || this->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { - target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); - } + cmTarget* target = + this->AddNewUtilityTarget(utilityName, origin, excludeFromAll); // Validate custom commands. if (!this->ValidateCustomCommand(commandLines) || @@ -1283,50 +1242,35 @@ cmTarget* cmMakefile::AddUtilityCommand( return target; } + // Get the output name of the utility target and mark it generated. + cmUtilityOutput force = this->GetUtilityOutput(target); + this->GetOrCreateGeneratedSource(force.Name); + // Always create the byproduct sources and mark them generated. this->CreateGeneratedSources(byproducts); - std::string force = - cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles/", utilityName); - this->CreateGeneratedSource(force); - std::string forceCMP0049 = target->GetSourceCMP0049(force); - { - cmSourceFile* sf = nullptr; - if (!forceCMP0049.empty()) { - sf = this->GetOrCreateSource(forceCMP0049, false, - cmSourceFileLocationKind::Known); - } - // The output is not actually created so mark it symbolic. - if (sf) { - sf->SetProperty("SYMBOLIC", "1"); - } else { - cmSystemTools::Error("Could not get source file entry for " + force); - } - } - if (!comment) { // Use an empty comment to avoid generation of default comment. comment = ""; } - this->CommitUtilityCommand(target, force, forceCMP0049, workingDirectory, - byproducts, depends, commandLines, escapeOldStyle, - comment, uses_terminal, command_expand_lists, - job_pool); + this->CommitUtilityCommand(target, force, workingDirectory, byproducts, + depends, commandLines, escapeOldStyle, comment, + uses_terminal, command_expand_lists, job_pool); return target; } void cmMakefile::CommitUtilityCommand( - cmTarget* target, const std::string& force, const std::string& forceCMP0049, - const char* workingDirectory, const std::vector& byproducts, + cmTarget* target, const cmUtilityOutput& force, const char* workingDirectory, + const std::vector& byproducts, const std::vector& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle, const char* comment, bool uses_terminal, bool command_expand_lists, const std::string& job_pool) { std::vector forced; - forced.push_back(force); + forced.push_back(force.Name); std::string no_main_dependency; cmImplicitDependsList no_implicit_depends; bool no_replace = false; @@ -1334,11 +1278,11 @@ void cmMakefile::CommitUtilityCommand( forced, byproducts, depends, no_main_dependency, no_implicit_depends, commandLines, comment, workingDirectory, no_replace, escapeOldStyle, uses_terminal, command_expand_lists, /*depfile=*/"", job_pool); - if (!forceCMP0049.empty()) { - target->AddSource(forceCMP0049); + if (!force.NameCMP0049.empty()) { + target->AddSource(force.NameCMP0049); } if (sf) { - this->UpdateOutputToSourceMap(byproducts, target); + this->AddTargetByproducts(target, byproducts); } } @@ -2157,6 +2101,18 @@ cmTarget* cmMakefile::AddNewTarget(cmStateEnums::TargetType type, return &it->second; } +cmTarget* cmMakefile::AddNewUtilityTarget(const std::string& utilityName, + cmCommandOrigin origin, + bool excludeFromAll) +{ + cmTarget* target = this->AddNewTarget(cmStateEnums::UTILITY, utilityName); + target->SetIsGeneratorProvided(origin == cmCommandOrigin::Generator); + if (excludeFromAll || this->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { + target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); + } + return target; +} + namespace { bool AnyOutputMatches(const std::string& name, const std::vector& outputs) @@ -2287,6 +2243,76 @@ bool cmMakefile::MightHaveCustomCommand(const std::string& name) const return false; } +void cmMakefile::AddTargetByproducts( + cmTarget* target, const std::vector& byproducts) +{ + for (std::string const& o : byproducts) { + this->UpdateOutputToSourceMap(o, target); + } +} + +void cmMakefile::AddSourceOutputs(cmSourceFile* source, + const std::vector& outputs, + const std::vector& byproducts) +{ + for (std::string const& o : outputs) { + this->UpdateOutputToSourceMap(o, source, false); + } + for (std::string const& o : byproducts) { + this->UpdateOutputToSourceMap(o, source, true); + } +} + +void cmMakefile::UpdateOutputToSourceMap(std::string const& byproduct, + cmTarget* target) +{ + SourceEntry entry; + entry.Sources.Target = target; + + auto pr = this->OutputToSource.emplace(byproduct, entry); + if (!pr.second) { + SourceEntry& current = pr.first->second; + // Has the target already been set? + if (!current.Sources.Target) { + current.Sources.Target = target; + } else { + // Multiple custom commands/targets produce the same output (source file + // or target). See also comment in other UpdateOutputToSourceMap + // overload. + // + // TODO: Warn the user about this case. + } + } +} + +void cmMakefile::UpdateOutputToSourceMap(std::string const& output, + cmSourceFile* source, bool byproduct) +{ + SourceEntry entry; + entry.Sources.Source = source; + entry.Sources.SourceIsByproduct = byproduct; + + auto pr = this->OutputToSource.emplace(output, entry); + if (!pr.second) { + SourceEntry& current = pr.first->second; + // Outputs take precedence over byproducts + if (!current.Sources.Source || + (current.Sources.SourceIsByproduct && !byproduct)) { + current.Sources.Source = source; + current.Sources.SourceIsByproduct = false; + } else { + // Multiple custom commands produce the same output but may + // be attached to a different source file (MAIN_DEPENDENCY). + // LinearGetSourceFileWithOutput would return the first one, + // so keep the mapping for the first one. + // + // TODO: Warn the user about this case. However, the VS 8 generator + // triggers it for separate generate.stamp rules in ZERO_CHECK and + // individual targets. + } + } +} + #if !defined(CMAKE_BOOTSTRAP) cmSourceGroup* cmMakefile::GetSourceGroup( const std::vector& name) const @@ -3531,19 +3557,20 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName, return this->CreateSource(sourceName, generated, kind); } -void cmMakefile::CreateGeneratedSource(const std::string& output) +cmSourceFile* cmMakefile::GetOrCreateGeneratedSource( + const std::string& sourceName) { - if (cmSourceFile* out = this->GetOrCreateSource( - output, true, cmSourceFileLocationKind::Known)) { - out->SetProperty("GENERATED", "1"); - } + cmSourceFile* sf = + this->GetOrCreateSource(sourceName, true, cmSourceFileLocationKind::Known); + sf->SetProperty("GENERATED", "1"); + return sf; } void cmMakefile::CreateGeneratedSources( const std::vector& outputs) { for (std::string const& output : outputs) { - this->CreateGeneratedSource(output); + this->GetOrCreateGeneratedSource(output); } } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 6bac47c..5ea2cce 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -168,6 +168,12 @@ public: */ void FinalPass(); + /** + * Get the target for PRE_BUILD, PRE_LINK, or POST_BUILD commands. + */ + cmTarget* GetCustomCommandTarget( + const std::string& target, cmObjectLibraryCommands objLibCommands) const; + /** Add a custom command to the build. */ cmTarget* AddCustomCommandToTarget( const std::string& target, const std::vector& byproducts, @@ -206,6 +212,19 @@ public: const cmCustomCommandLines& commandLines); /** + * Add target byproducts. + */ + void AddTargetByproducts(cmTarget* target, + const std::vector& byproducts); + + /** + * Add source file outputs. + */ + void AddSourceOutputs(cmSourceFile* source, + const std::vector& outputs, + const std::vector& byproducts); + + /** * Add a define flag to the build. */ void AddDefineFlag(std::string const& definition); @@ -222,6 +241,10 @@ public: cmTarget* AddNewTarget(cmStateEnums::TargetType type, const std::string& name); + /** Create a target instance for the utility. */ + cmTarget* AddNewUtilityTarget(const std::string& utilityName, + cmCommandOrigin origin, bool excludeFromAll); + /** * Add an executable to the build. */ @@ -230,6 +253,11 @@ public: bool excludeFromAll = false); /** + * Return the utility target output source file name and the CMP0049 name. + */ + cmUtilityOutput GetUtilityOutput(cmTarget* target); + + /** * Add a utility to the build. A utility target is a command that * is run every time the target is built. */ @@ -447,6 +475,12 @@ public: const std::string& sourceName, bool generated = false, cmSourceFileLocationKind kind = cmSourceFileLocationKind::Ambiguous); + /** Get a cmSourceFile pointer for a given source name and always mark the + * file as generated, if the name is not found, then create the source file + * and return it. + */ + cmSourceFile* GetOrCreateGeneratedSource(const std::string& sourceName); + void AddTargetObject(std::string const& tgtName, std::string const& objFile); /** @@ -1028,13 +1062,12 @@ private: friend bool cmCMakePolicyCommand(std::vector const& args, cmExecutionStatus& status); class IncludeScope; - friend class IncludeScope; - class ListFileScope; + class ListFileScope; friend class ListFileScope; - class BuildsystemFileScope; + class BuildsystemFileScope; friend class BuildsystemFileScope; // CMP0053 == old @@ -1053,6 +1086,8 @@ private: bool ValidateCustomCommand(const cmCustomCommandLines& commandLines) const; + void CreateGeneratedSources(const std::vector& outputs); + void CommitCustomCommandToTarget( cmTarget* target, const std::vector& byproducts, const std::vector& depends, @@ -1075,8 +1110,7 @@ private: const cmImplicitDependsList& implicit_depends, const cmCustomCommandLines& commandLines); - void CommitUtilityCommand(cmTarget* target, const std::string& force, - const std::string& forceCMP0049, + void CommitUtilityCommand(cmTarget* target, const cmUtilityOutput& force, const char* workingDirectory, const std::vector& byproducts, const std::vector& depends, @@ -1085,9 +1119,6 @@ private: bool uses_terminal, bool command_expand_lists, const std::string& job_pool); - void CreateGeneratedSource(const std::string& output); - void CreateGeneratedSources(const std::vector& outputs); - /** * See LinearGetSourceFileWithOutput for background information */ @@ -1112,12 +1143,7 @@ private: using OutputToSourceMap = std::unordered_map; OutputToSourceMap OutputToSource; - void UpdateOutputToSourceMap(std::vector const& byproducts, - cmTarget* target); void UpdateOutputToSourceMap(std::string const& byproduct, cmTarget* target); - - void UpdateOutputToSourceMap(std::vector const& outputs, - cmSourceFile* source, bool byproduct); void UpdateOutputToSourceMap(std::string const& output, cmSourceFile* source, bool byproduct); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=91abf9f3c4a80f5a8417401d5277b3b66bc7d008 commit 91abf9f3c4a80f5a8417401d5277b3b66bc7d008 Author: Daniel Eiband AuthorDate: Fri Sep 20 22:47:50 2019 +0200 Commit: Brad King CommitDate: Thu Sep 26 10:02:08 2019 -0400 cmCustomCommand: Move custom commands diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 2273c50..c4974f3 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2582,7 +2582,7 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(GlobalTargetInfo const& gti, cmCustomCommand cc(nullptr, no_outputs, no_byproducts, no_depends, gti.CommandLines, nullptr, gti.WorkingDir.c_str()); cc.SetUsesTerminal(gti.UsesTerminal); - target.AddPostBuildCommand(cc); + target.AddPostBuildCommand(std::move(cc)); if (!gti.Message.empty()) { target.SetProperty("EchoString", gti.Message.c_str()); } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index e53851d..d1235b2 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -938,13 +938,13 @@ void cmMakefile::CommitCustomCommandToTarget( cc.SetJobPool(job_pool); switch (type) { case cmCustomCommandType::PRE_BUILD: - target->AddPreBuildCommand(cc); + target->AddPreBuildCommand(std::move(cc)); break; case cmCustomCommandType::PRE_LINK: - target->AddPreLinkCommand(cc); + target->AddPreLinkCommand(std::move(cc)); break; case cmCustomCommandType::POST_BUILD: - target->AddPostBuildCommand(cc); + target->AddPostBuildCommand(std::move(cc)); break; } this->UpdateOutputToSourceMap(byproducts, target); diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 9dbd612..d7b9fa2 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1086,7 +1086,7 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() this->Dir.Work.c_str()); cc.SetEscapeOldStyle(false); cc.SetEscapeAllowMakeVars(true); - this->GenTarget->Target->AddPreBuildCommand(cc); + this->GenTarget->Target->AddPreBuildCommand(std::move(cc)); } else { // Add link library target dependencies to the autogen target diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1b88db6..ae77d9e 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -604,6 +604,11 @@ void cmTarget::AddPreBuildCommand(cmCustomCommand const& cmd) impl->PreBuildCommands.push_back(cmd); } +void cmTarget::AddPreBuildCommand(cmCustomCommand&& cmd) +{ + impl->PreBuildCommands.push_back(std::move(cmd)); +} + std::vector const& cmTarget::GetPreLinkCommands() const { return impl->PreLinkCommands; @@ -614,6 +619,11 @@ void cmTarget::AddPreLinkCommand(cmCustomCommand const& cmd) impl->PreLinkCommands.push_back(cmd); } +void cmTarget::AddPreLinkCommand(cmCustomCommand&& cmd) +{ + impl->PreLinkCommands.push_back(std::move(cmd)); +} + std::vector const& cmTarget::GetPostBuildCommands() const { return impl->PostBuildCommands; @@ -624,6 +634,11 @@ void cmTarget::AddPostBuildCommand(cmCustomCommand const& cmd) impl->PostBuildCommands.push_back(cmd); } +void cmTarget::AddPostBuildCommand(cmCustomCommand&& cmd) +{ + impl->PostBuildCommands.push_back(std::move(cmd)); +} + void cmTarget::AddTracedSources(std::vector const& srcs) { if (!srcs.empty()) { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1b4f23a..65a1ce3 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -84,14 +84,17 @@ public: //! Get the list of the PRE_BUILD custom commands for this target std::vector const& GetPreBuildCommands() const; void AddPreBuildCommand(cmCustomCommand const& cmd); + void AddPreBuildCommand(cmCustomCommand&& cmd); //! Get the list of the PRE_LINK custom commands for this target std::vector const& GetPreLinkCommands() const; void AddPreLinkCommand(cmCustomCommand const& cmd); + void AddPreLinkCommand(cmCustomCommand&& cmd); //! Get the list of the POST_BUILD custom commands for this target std::vector const& GetPostBuildCommands() const; void AddPostBuildCommand(cmCustomCommand const& cmd); + void AddPostBuildCommand(cmCustomCommand&& cmd); //! Add sources to the target. void AddSources(std::vector const& srcs); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f151a5770597dbe341fc6329a711f40e9195c773 commit f151a5770597dbe341fc6329a711f40e9195c773 Author: Daniel Eiband AuthorDate: Fri Sep 20 22:44:14 2019 +0200 Commit: Brad King CommitDate: Thu Sep 26 10:02:06 2019 -0400 cmMakefile: Move enumerations into new header The enumerations will also be used in cmLocalGenerator. diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 71a7dbd..0c1f3b1 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -195,6 +195,7 @@ set(SRCS cmCustomCommandGenerator.h cmCustomCommandLines.cxx cmCustomCommandLines.h + cmCustomCommandTypes.h cmDefinitions.cxx cmDefinitions.h cmDepends.cxx diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index 94de851..6e04ce5 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -8,6 +8,7 @@ #include "cmCheckCustomOutputs.h" #include "cmCustomCommand.h" #include "cmCustomCommandLines.h" +#include "cmCustomCommandTypes.h" #include "cmExecutionStatus.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" @@ -15,7 +16,6 @@ #include "cmPolicies.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include "cmTarget.h" bool cmAddCustomCommandCommand(std::vector const& args, cmExecutionStatus& status) @@ -55,7 +55,7 @@ bool cmAddCustomCommandCommand(std::vector const& args, // Save all command lines. cmCustomCommandLines commandLines; - cmTarget::CustomCommandType cctype = cmTarget::POST_BUILD; + cmCustomCommandType cctype = cmCustomCommandType::POST_BUILD; enum tdoing { @@ -139,11 +139,11 @@ bool cmAddCustomCommandCommand(std::vector const& args, currentLine.clear(); } } else if (copy == keyPRE_BUILD) { - cctype = cmTarget::PRE_BUILD; + cctype = cmCustomCommandType::PRE_BUILD; } else if (copy == keyPRE_LINK) { - cctype = cmTarget::PRE_LINK; + cctype = cmCustomCommandType::PRE_LINK; } else if (copy == keyPOST_BUILD) { - cctype = cmTarget::POST_BUILD; + cctype = cmCustomCommandType::POST_BUILD; } else if (copy == keyVERBATIM) { verbatim = true; } else if (copy == keyAPPEND) { diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx index b580c43..e27b126 100644 --- a/Source/cmAddCustomTargetCommand.cxx +++ b/Source/cmAddCustomTargetCommand.cxx @@ -6,6 +6,7 @@ #include "cmCheckCustomOutputs.h" #include "cmCustomCommandLines.h" +#include "cmCustomCommandTypes.h" #include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" #include "cmGlobalGenerator.h" @@ -214,7 +215,7 @@ bool cmAddCustomTargetCommand(std::vector const& args, // Add the utility target to the makefile. bool escapeOldStyle = !verbatim; cmTarget* target = mf.AddUtilityCommand( - targetName, cmMakefile::TargetOrigin::Project, excludeFromAll, + targetName, cmCommandOrigin::Project, excludeFromAll, working_directory.c_str(), byproducts, depends, commandLines, escapeOldStyle, comment, uses_terminal, command_expand_lists, job_pool); diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 1eaf48b..29d2495 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -220,7 +220,7 @@ void CCONV cmAddUtilityCommand(void* arg, const char* utilityName, } // Pass the call to the makefile instance. - mf->AddUtilityCommand(utilityName, cmMakefile::TargetOrigin::Project, + mf->AddUtilityCommand(utilityName, cmCommandOrigin::Project, (all ? false : true), nullptr, depends2, commandLines); } void CCONV cmAddCustomCommand(void* arg, const char* source, @@ -319,16 +319,16 @@ void CCONV cmAddCustomCommandToTarget(void* arg, const char* target, commandLines.push_back(commandLine); // Select the command type. - cmTarget::CustomCommandType cctype = cmTarget::POST_BUILD; + cmCustomCommandType cctype = cmCustomCommandType::POST_BUILD; switch (commandType) { case CM_PRE_BUILD: - cctype = cmTarget::PRE_BUILD; + cctype = cmCustomCommandType::PRE_BUILD; break; case CM_PRE_LINK: - cctype = cmTarget::PRE_LINK; + cctype = cmCustomCommandType::PRE_LINK; break; case CM_POST_BUILD: - cctype = cmTarget::POST_BUILD; + cctype = cmCustomCommandType::POST_BUILD; break; } diff --git a/Source/cmCustomCommandTypes.h b/Source/cmCustomCommandTypes.h new file mode 100644 index 0000000..f3ecd6e --- /dev/null +++ b/Source/cmCustomCommandTypes.h @@ -0,0 +1,30 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cmCustomCommandTypes_h +#define cmCustomCommandTypes_h + +#include "cmConfigure.h" // IWYU pragma: keep + +/** Target custom command type */ +enum class cmCustomCommandType +{ + PRE_BUILD, + PRE_LINK, + POST_BUILD +}; + +/** Where the command originated from. */ +enum class cmCommandOrigin +{ + Project, + Generator +}; + +/** How to handle custom commands for object libraries */ +enum class cmObjectLibraryCommands +{ + Reject, + Accept +}; + +#endif diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index f25d2e2..808bebd 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -105,8 +105,8 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() cmCustomCommandLines noCommandLines; cmTarget* tgt = mf->AddUtilityCommand( - CMAKE_CHECK_BUILD_SYSTEM_TARGET, cmMakefile::TargetOrigin::Generator, - false, no_working_directory, no_depends, noCommandLines); + CMAKE_CHECK_BUILD_SYSTEM_TARGET, cmCommandOrigin::Generator, false, + no_working_directory, no_depends, noCommandLines); cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg); lg->AddGeneratorTarget(gt); @@ -152,10 +152,10 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() std::vector byproducts; byproducts.push_back(cm->GetGlobVerifyStamp()); - mf->AddCustomCommandToTarget(CMAKE_CHECK_BUILD_SYSTEM_TARGET, byproducts, - no_depends, verifyCommandLines, - cmTarget::PRE_BUILD, "Checking File Globs", - no_working_directory, false); + mf->AddCustomCommandToTarget( + CMAKE_CHECK_BUILD_SYSTEM_TARGET, byproducts, no_depends, + verifyCommandLines, cmCustomCommandType::PRE_BUILD, + "Checking File Globs", no_working_directory, false); // Ensure ZERO_CHECK always runs in Visual Studio using MSBuild, // otherwise the prebuild command will not be run. diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 7a564ed..82219bd 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -193,7 +193,7 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets() // Use no actual command lines so that the target itself is not // considered always out of date. cmTarget* allBuild = gen[0]->GetMakefile()->AddUtilityCommand( - "ALL_BUILD", cmMakefile::TargetOrigin::Generator, true, no_working_dir, + "ALL_BUILD", cmCommandOrigin::Generator, true, no_working_dir, no_depends, no_commands, false, "Build all projects"); cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 2c3d3ad..e4dff78 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -501,9 +501,8 @@ void cmGlobalXCodeGenerator::AddExtraTargets( const char* no_working_directory = nullptr; std::vector no_depends; cmTarget* allbuild = mf->AddUtilityCommand( - "ALL_BUILD", cmMakefile::TargetOrigin::Generator, true, - no_working_directory, no_depends, - cmMakeSingleCommandLine({ "echo", "Build all projects" })); + "ALL_BUILD", cmCommandOrigin::Generator, true, no_working_directory, + no_depends, cmMakeSingleCommandLine({ "echo", "Build all projects" })); cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root); root->AddGeneratorTarget(allBuildGt); @@ -526,8 +525,8 @@ void cmGlobalXCodeGenerator::AddExtraTargets( this->ConvertToRelativeForMake(this->CurrentReRunCMakeMakefile); cmSystemTools::ReplaceString(file, "\\ ", " "); cmTarget* check = mf->AddUtilityCommand( - CMAKE_CHECK_BUILD_SYSTEM_TARGET, cmMakefile::TargetOrigin::Generator, - true, no_working_directory, no_depends, + CMAKE_CHECK_BUILD_SYSTEM_TARGET, cmCommandOrigin::Generator, true, + no_working_directory, no_depends, cmMakeSingleCommandLine({ "make", "-f", file })); cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root); @@ -558,8 +557,9 @@ void cmGlobalXCodeGenerator::AddExtraTargets( std::vector no_byproducts; gen->GetMakefile()->AddCustomCommandToTarget( target->GetName(), no_byproducts, no_depends, commandLines, - cmTarget::POST_BUILD, "Depend check for xcode", dir.c_str(), true, - false, "", "", false, cmMakefile::AcceptObjectLibraryCommands); + cmCustomCommandType::POST_BUILD, "Depend check for xcode", + dir.c_str(), true, false, "", "", false, + cmObjectLibraryCommands::Accept); } if (!this->IsExcluded(target)) { diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 93e074d..7af3da5 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -7,6 +7,7 @@ #include "cmCustomCommand.h" #include "cmCustomCommandGenerator.h" #include "cmCustomCommandLines.h" +#include "cmCustomCommandTypes.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorExpression.h" #include "cmGeneratorExpressionEvaluationFile.h" @@ -2356,7 +2357,7 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target, if (this->GetGlobalGenerator()->IsMultiConfig()) { this->Makefile->AddCustomCommandToTarget( target->GetName(), outputs, no_deps, commandLines, - cmTarget::PRE_BUILD, no_message, no_current_dir); + cmCustomCommandType::PRE_BUILD, no_message, no_current_dir); } else { cmImplicitDependsList no_implicit_depends; cmSourceFile* copy_rule = this->Makefile->AddCustomCommandToOutput( diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 34081ed..e53851d 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -39,6 +39,7 @@ #include "cmStateDirectory.h" #include "cmStateTypes.h" #include "cmSystemTools.h" +#include "cmTarget.h" #include "cmTargetLinkLibraryType.h" #include "cmTest.h" #include "cmTestGenerator.h" // IWYU pragma: keep @@ -840,10 +841,10 @@ bool cmMakefile::ValidateCustomCommand( cmTarget* cmMakefile::AddCustomCommandToTarget( const std::string& target, const std::vector& byproducts, const std::vector& depends, - const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type, + const cmCustomCommandLines& commandLines, cmCustomCommandType type, const char* comment, const char* workingDir, bool escapeOldStyle, bool uses_terminal, const std::string& depfile, const std::string& job_pool, - bool command_expand_lists, ObjectLibraryCommands objLibraryCommands) + bool command_expand_lists, cmObjectLibraryCommands objLibCommands) { // Find the target to which to add the custom command. auto ti = this->Targets.find(target); @@ -884,7 +885,7 @@ cmTarget* cmMakefile::AddCustomCommandToTarget( } cmTarget* t = &ti->second; - if (objLibraryCommands == RejectObjectLibraryCommands && + if (objLibCommands == cmObjectLibraryCommands::Reject && t->GetType() == cmStateEnums::OBJECT_LIBRARY) { std::ostringstream e; e << "Target \"" << target @@ -920,7 +921,7 @@ cmTarget* cmMakefile::AddCustomCommandToTarget( void cmMakefile::CommitCustomCommandToTarget( cmTarget* target, const std::vector& byproducts, const std::vector& depends, - const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type, + const cmCustomCommandLines& commandLines, cmCustomCommandType type, const char* comment, const char* workingDir, bool escapeOldStyle, bool uses_terminal, const std::string& depfile, const std::string& job_pool, bool command_expand_lists) @@ -936,13 +937,13 @@ void cmMakefile::CommitCustomCommandToTarget( cc.SetDepfile(depfile); cc.SetJobPool(job_pool); switch (type) { - case cmTarget::PRE_BUILD: + case cmCustomCommandType::PRE_BUILD: target->AddPreBuildCommand(cc); break; - case cmTarget::PRE_LINK: + case cmCustomCommandType::PRE_LINK: target->AddPreLinkCommand(cc); break; - case cmTarget::POST_BUILD: + case cmCustomCommandType::POST_BUILD: target->AddPostBuildCommand(cc); break; } @@ -1157,9 +1158,9 @@ void cmMakefile::AddCustomCommandOldStyle( // same then it added a post-build rule to the target. Preserve // this behavior. std::vector no_byproducts; - this->AddCustomCommandToTarget(target, no_byproducts, depends, - commandLines, cmTarget::POST_BUILD, comment, - nullptr); + this->AddCustomCommandToTarget( + target, no_byproducts, depends, commandLines, + cmCustomCommandType::POST_BUILD, comment, nullptr); return; } @@ -1248,7 +1249,7 @@ void cmMakefile::CommitAppendCustomCommandToOutput( } cmTarget* cmMakefile::AddUtilityCommand( - const std::string& utilityName, TargetOrigin origin, bool excludeFromAll, + const std::string& utilityName, cmCommandOrigin origin, bool excludeFromAll, const char* workingDirectory, const std::vector& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle, const char* comment, bool uses_terminal, bool command_expand_lists, @@ -1262,7 +1263,7 @@ cmTarget* cmMakefile::AddUtilityCommand( } cmTarget* cmMakefile::AddUtilityCommand( - const std::string& utilityName, TargetOrigin origin, bool excludeFromAll, + const std::string& utilityName, cmCommandOrigin origin, bool excludeFromAll, const char* workingDirectory, const std::vector& byproducts, const std::vector& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle, @@ -1271,7 +1272,7 @@ cmTarget* cmMakefile::AddUtilityCommand( { // Create a target instance for this utility. cmTarget* target = this->AddNewTarget(cmStateEnums::UTILITY, utilityName); - target->SetIsGeneratorProvided(origin == TargetOrigin::Generator); + target->SetIsGeneratorProvided(origin == cmCommandOrigin::Generator); if (excludeFromAll || this->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index db37477..6bac47c 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -20,6 +20,7 @@ #include #include "cmAlgorithms.h" +#include "cmCustomCommandTypes.h" #include "cmListFileCache.h" #include "cmMessageType.h" #include "cmNewLineStyle.h" @@ -28,7 +29,10 @@ #include "cmStateSnapshot.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" -#include "cmTarget.h" + +// IWYU does not see that 'std::unordered_map' +// will not compile without the complete type. +#include "cmTarget.h" // IWYU pragma: keep #if !defined(CMAKE_BOOTSTRAP) # include "cmSourceGroup.h" @@ -164,22 +168,15 @@ public: */ void FinalPass(); - /** How to handle custom commands for object libraries */ - enum ObjectLibraryCommands - { - RejectObjectLibraryCommands, - AcceptObjectLibraryCommands - }; - /** Add a custom command to the build. */ cmTarget* AddCustomCommandToTarget( const std::string& target, const std::vector& byproducts, const std::vector& depends, - const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type, + const cmCustomCommandLines& commandLines, cmCustomCommandType type, const char* comment, const char* workingDir, bool escapeOldStyle = true, bool uses_terminal = false, const std::string& depfile = "", const std::string& job_pool = "", bool command_expand_lists = false, - ObjectLibraryCommands objLibraryCommands = RejectObjectLibraryCommands); + cmObjectLibraryCommands objLibCommands = cmObjectLibraryCommands::Reject); cmSourceFile* AddCustomCommandToOutput( const std::string& output, const std::vector& depends, const std::string& main_dependency, @@ -232,26 +229,21 @@ public: const std::vector& srcs, bool excludeFromAll = false); - /** Where the target originated from. */ - enum class TargetOrigin - { - Project, - Generator - }; - /** * Add a utility to the build. A utility target is a command that * is run every time the target is built. */ cmTarget* AddUtilityCommand( - const std::string& utilityName, TargetOrigin origin, bool excludeFromAll, - const char* workingDirectory, const std::vector& depends, + const std::string& utilityName, cmCommandOrigin origin, + bool excludeFromAll, const char* workingDirectory, + const std::vector& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle = true, const char* comment = nullptr, bool uses_terminal = false, bool command_expand_lists = false, const std::string& job_pool = ""); cmTarget* AddUtilityCommand( - const std::string& utilityName, TargetOrigin origin, bool excludeFromAll, - const char* workingDirectory, const std::vector& byproducts, + const std::string& utilityName, cmCommandOrigin origin, + bool excludeFromAll, const char* workingDirectory, + const std::vector& byproducts, const std::vector& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle = true, const char* comment = nullptr, bool uses_terminal = false, @@ -1064,7 +1056,7 @@ private: void CommitCustomCommandToTarget( cmTarget* target, const std::vector& byproducts, const std::vector& depends, - const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type, + const cmCustomCommandLines& commandLines, cmCustomCommandType type, const char* comment, const char* workingDir, bool escapeOldStyle, bool uses_terminal, const std::string& depfile, const std::string& job_pool, bool command_expand_lists); diff --git a/Source/cmQtAutoGenGlobalInitializer.cxx b/Source/cmQtAutoGenGlobalInitializer.cxx index 576a034..751ad50 100644 --- a/Source/cmQtAutoGenGlobalInitializer.cxx +++ b/Source/cmQtAutoGenGlobalInitializer.cxx @@ -3,6 +3,7 @@ #include "cmQtAutoGenGlobalInitializer.h" #include "cmCustomCommandLines.h" +#include "cmCustomCommandTypes.h" #include "cmDuration.h" #include "cmGeneratorTarget.h" #include "cmLocalGenerator.h" @@ -154,7 +155,7 @@ void cmQtAutoGenGlobalInitializer::GetOrCreateGlobalTarget( // Create utility target cmTarget* target = makefile->AddUtilityCommand( - name, cmMakefile::TargetOrigin::Generator, true, + name, cmCommandOrigin::Generator, true, makefile->GetHomeOutputDirectory().c_str() /*work dir*/, std::vector() /*output*/, std::vector() /*depends*/, cmCustomCommandLines(), false, diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 0d56fe1..9dbd612 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -8,6 +8,7 @@ #include "cmAlgorithms.h" #include "cmCustomCommand.h" #include "cmCustomCommandLines.h" +#include "cmCustomCommandTypes.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" @@ -1117,7 +1118,7 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() // Create autogen target cmTarget* autogenTarget = this->Makefile->AddUtilityCommand( - this->AutogenTarget.Name, cmMakefile::TargetOrigin::Generator, true, + this->AutogenTarget.Name, cmCommandOrigin::Generator, true, this->Dir.Work.c_str(), /*byproducts=*/autogenProvides, std::vector(this->AutogenTarget.DependFiles.begin(), this->AutogenTarget.DependFiles.end()), @@ -1199,9 +1200,8 @@ bool cmQtAutoGenInitializer::InitRccTargets() } cmTarget* autoRccTarget = this->Makefile->AddUtilityCommand( - ccName, cmMakefile::TargetOrigin::Generator, true, - this->Dir.Work.c_str(), ccOutput, ccDepends, commandLines, false, - ccComment.c_str()); + ccName, cmCommandOrigin::Generator, true, this->Dir.Work.c_str(), + ccOutput, ccDepends, commandLines, false, ccComment.c_str()); // Create autogen generator target this->LocalGen->AddGeneratorTarget( diff --git a/Source/cmTarget.h b/Source/cmTarget.h index f4726d3..1b4f23a 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -43,13 +43,6 @@ public: VisibilityImportedGlobally }; - enum CustomCommandType - { - PRE_BUILD, - PRE_LINK, - POST_BUILD - }; - cmTarget(std::string const& name, cmStateEnums::TargetType type, Visibility vis, cmMakefile* mf); ----------------------------------------------------------------------- Summary of changes: Modules/CMakeFindBinUtils.cmake | 70 ++++++- Modules/Compiler/GNU-FindBinUtils.cmake | 26 ++- Source/CMakeLists.txt | 1 + Source/cmAddCustomCommandCommand.cxx | 10 +- Source/cmAddCustomTargetCommand.cxx | 3 +- Source/cmCPluginAPI.cxx | 14 +- Source/cmCommands.cxx | 27 +-- Source/cmCustomCommandTypes.h | 39 ++++ Source/cmGlobalGenerator.cxx | 2 +- Source/cmGlobalVisualStudio8Generator.cxx | 20 +- Source/cmGlobalVisualStudioGenerator.cxx | 7 +- Source/cmGlobalXCodeGenerator.cxx | 23 ++- Source/cmLocalGenerator.cxx | 3 +- Source/cmMakefile.cxx | 298 ++++++++++++++------------- Source/cmMakefile.h | 85 ++++---- Source/cmQtAutoGenGlobalInitializer.cxx | 3 +- Source/cmQtAutoGenInitializer.cxx | 10 +- Source/cmTarget.cxx | 15 ++ Source/cmTarget.h | 10 +- Source/cmTargetCompileDefinitionsCommand.cxx | 70 ++++--- Source/cmTargetCompileDefinitionsCommand.h | 34 +-- Source/cmTargetCompileFeaturesCommand.cxx | 65 +++--- Source/cmTargetCompileFeaturesCommand.h | 26 +-- Source/cmTargetCompileOptionsCommand.cxx | 56 ++--- Source/cmTargetCompileOptionsCommand.h | 34 +-- Source/cmTargetIncludeDirectoriesCommand.cxx | 57 +++-- Source/cmTargetIncludeDirectoriesCommand.h | 38 +--- Source/cmTargetLinkDirectoriesCommand.cxx | 53 +++-- Source/cmTargetLinkDirectoriesCommand.h | 34 +-- Source/cmTargetLinkOptionsCommand.cxx | 55 +++-- Source/cmTargetLinkOptionsCommand.h | 34 +-- Source/cmTargetPrecompileHeadersCommand.cxx | 98 +++++---- Source/cmTargetPrecompileHeadersCommand.h | 38 +--- Source/cmTargetPropCommandBase.cxx | 12 ++ Source/cmTargetPropCommandBase.h | 14 +- Source/cmTargetSourcesCommand.cxx | 81 +++++--- Source/cmTargetSourcesCommand.h | 44 +--- Tests/FortranModules/Library/a.f90 | 3 + Tests/FortranModules/Library/b.f90 | 3 + Tests/FortranModules/Subdir/subdir.f90 | 3 + 40 files changed, 765 insertions(+), 753 deletions(-) create mode 100644 Source/cmCustomCommandTypes.h hooks/post-receive -- CMake From kwrobot at kitware.com Fri Sep 27 23:59:30 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 27 Sep 2019 23:59:30 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1230-g9cd47ff Message-ID: <20190928035930.21142E5C1C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 9cd47ff3c8e9e5b2706075445b4eba5c332dc1d8 (commit) from c88cf48bbe775c45c36c23b990c89d85b7b9a220 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9cd47ff3c8e9e5b2706075445b4eba5c332dc1d8 commit 9cd47ff3c8e9e5b2706075445b4eba5c332dc1d8 Author: Kitware Robot AuthorDate: Sat Sep 28 00:01:06 2019 -0400 Commit: Kitware Robot CommitDate: Sat Sep 28 00:01:06 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index d9ca09b..775dc49 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 15) -set(CMake_VERSION_PATCH 20190927) +set(CMake_VERSION_PATCH 20190928) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Sat Sep 28 23:58:54 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Sat, 28 Sep 2019 23:58:54 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1231-gc174e60 Message-ID: <20190929035854.19C24F9A16@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via c174e603be444be737fd332cfc45ae1e3fc812be (commit) from 9cd47ff3c8e9e5b2706075445b4eba5c332dc1d8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c174e603be444be737fd332cfc45ae1e3fc812be commit c174e603be444be737fd332cfc45ae1e3fc812be Author: Kitware Robot AuthorDate: Sun Sep 29 00:01:05 2019 -0400 Commit: Kitware Robot CommitDate: Sun Sep 29 00:01:05 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 775dc49..91050d5 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 15) -set(CMake_VERSION_PATCH 20190928) +set(CMake_VERSION_PATCH 20190929) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Sun Sep 29 23:58:21 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Sun, 29 Sep 2019 23:58:21 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1232-g3f7829f Message-ID: <20190930035821.DAF254B63@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 3f7829fc4f2e30105f6d37c9509b7bfe77ae3c67 (commit) from c174e603be444be737fd332cfc45ae1e3fc812be (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3f7829fc4f2e30105f6d37c9509b7bfe77ae3c67 commit 3f7829fc4f2e30105f6d37c9509b7bfe77ae3c67 Author: Kitware Robot AuthorDate: Mon Sep 30 00:01:05 2019 -0400 Commit: Kitware Robot CommitDate: Mon Sep 30 00:01:05 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 91050d5..2196243 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 15) -set(CMake_VERSION_PATCH 20190929) +set(CMake_VERSION_PATCH 20190930) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Sep 30 10:28:08 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 30 Sep 2019 10:28:08 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1261-g8aa5f6b Message-ID: <20190930142808.2B320F8C9A@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 8aa5f6ba446dd8ff817e54979f466b8a247f967a (commit) via 9b03baee308d78db119554def6e34fd9db9683ac (commit) via b24e501bc289956867b6104aac9d07afb75c906e (commit) via c2d1ea58bfbee75fe509e0c9745a66cb1e924b77 (commit) via 45507eeb6aa9e9caf01cc4852a6fcb06b73cc207 (commit) via dce58afd30b781bd99a1af5c6860583577d58a1f (commit) via 013d7dd48420b7040355066724ede9eb7050c94a (commit) via 61103c0bac4e9ef264d87fe9b23087ed8f5291c4 (commit) via 1fe450159278fd30138ef5133daf26f931537de4 (commit) via 05d7ca14e99ee8ad36da01ddb314d0b90ab41874 (commit) via 62d45d91e83f537b19d9bfc7b1e8d909a0c5c322 (commit) via b3b1c7bf3afc8f33fa69b79f47f778cb781ac3c7 (commit) via 6bd40ccf8424a6e8c3a77857d48600ed7c624a07 (commit) via e0e9be3d575a255add19169d174c869fdebebbeb (commit) via 820962edc9dd7481c440068dd894c1026abf671d (commit) via dd0f304613b1661754d9cccf5829087a8bb19a12 (commit) via b515af782bccf147e8bd62444c9f1808668f12ac (commit) via 9e66397c28110f015e5b044dfe9782cd5f11c8c3 (commit) via 80f120a85fb0992e3f06ad69ebdad881bea9af8c (commit) via 156b56480a786db4d967bde5eb6d5edee56a27d0 (commit) via 60473cc660cc37c922b0ff93112deeb34d51f2ca (commit) via 7d6e08b438a187e89735ae6aad749a14137f34be (commit) via 0833486d62e8ed3ae9f0219f9924c4e78d74f781 (commit) via cf01d3d2bd649ab1157641b3212a360b06db747f (commit) via 21442d72a44c2bd732f2ff19ed89ce488854d25d (commit) via bc71b253cb372cc6c0ae50406a11b81fe4259559 (commit) via 36875ff419240a5a60b1b13ff190a5824a8363a5 (commit) via 2b1607114985e56a7847eb6081d5656f73c230d0 (commit) via 0cfbd85e7b0d61affda6450b1cc081860b5543a6 (commit) from 3f7829fc4f2e30105f6d37c9509b7bfe77ae3c67 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8aa5f6ba446dd8ff817e54979f466b8a247f967a commit 8aa5f6ba446dd8ff817e54979f466b8a247f967a Merge: 9b03bae dce58af Author: Brad King AuthorDate: Mon Sep 30 14:26:37 2019 +0000 Commit: Kitware Robot CommitDate: Mon Sep 30 10:27:15 2019 -0400 Merge topic 'fix-EXCLUDE_FROM_ALL-subdir-all' dce58afd30 Merge branch 'backport-3.15-fix-EXCLUDE_FROM_ALL-subdir-all' 013d7dd484 Help: Mention 3.14.7 EXCLUDE_FROM_ALL fix in 3.15.4 release note 61103c0bac Merge branch 'backport-3.14-fix-EXCLUDE_FROM_ALL-subdir-all' 1fe4501592 Help: Add release note for EXCLUDE_FROM_ALL fix in 3.15.4 05d7ca14e9 Merge branch 'backport-3.14-fix-EXCLUDE_FROM_ALL-subdir-all' 62d45d91e8 Help: Add release note for EXCLUDE_FROM_ALL fix in 3.14.7 b3b1c7bf3a Restore "all" target in subdirectories marked EXCLUDE_FROM_ALL 156b56480a Makefiles: Revert "Make build root targets ... recursive" ... Acked-by: Kitware Robot Merge-request: !3863 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9b03baee308d78db119554def6e34fd9db9683ac commit 9b03baee308d78db119554def6e34fd9db9683ac Merge: b24e501 dd0f304 Author: Brad King AuthorDate: Mon Sep 30 14:24:55 2019 +0000 Commit: Kitware Robot CommitDate: Mon Sep 30 10:25:19 2019 -0400 Merge topic 'objective-c-cxx' dd0f304613 Objective C/C++: Add compiler standard detection b515af782b Help: Add release note for Objective-C/C++ language support 9e66397c28 Languages: Add support for Objective-C++ 80f120a85f Languages: Add support for Objective-C Acked-by: Kitware Robot Merge-request: !3811 diff --cc Source/cmMakefile.cxx index a528fc6,85ba38c..264a73a --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@@ -38,8 -38,8 +38,9 @@@ #include "cmState.h" #include "cmStateDirectory.h" #include "cmStateTypes.h" + #include "cmStringAlgorithms.h" #include "cmSystemTools.h" +#include "cmTarget.h" #include "cmTargetLinkLibraryType.h" #include "cmTest.h" #include "cmTestGenerator.h" // IWYU pragma: keep https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b24e501bc289956867b6104aac9d07afb75c906e commit b24e501bc289956867b6104aac9d07afb75c906e Merge: c2d1ea5 6bd40cc Author: Brad King AuthorDate: Mon Sep 30 14:23:27 2019 +0000 Commit: Kitware Robot CommitDate: Mon Sep 30 10:23:42 2019 -0400 Merge topic 'autogen_free_functions' 6bd40ccf84 Autogen: Make cmQtAutoMocUic a free function e0e9be3d57 Autogen: Make cmQtAutoRcc a free function 820962edc9 Autogen: Refactor json info file reading interface Acked-by: Kitware Robot Merge-request: !3867 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c2d1ea58bfbee75fe509e0c9745a66cb1e924b77 commit c2d1ea58bfbee75fe509e0c9745a66cb1e924b77 Merge: 45507ee 60473cc Author: Brad King AuthorDate: Mon Sep 30 14:22:13 2019 +0000 Commit: Kitware Robot CommitDate: Mon Sep 30 10:22:35 2019 -0400 Merge topic 'FPHSA-reason-failure-message' 60473cc660 FPHSA: add capability to specify message explaining reason of failure Acked-by: Kitware Robot Merge-request: !3866 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=45507eeb6aa9e9caf01cc4852a6fcb06b73cc207 commit 45507eeb6aa9e9caf01cc4852a6fcb06b73cc207 Merge: 3f7829f 7d6e08b Author: Brad King AuthorDate: Mon Sep 30 14:21:27 2019 +0000 Commit: Kitware Robot CommitDate: Mon Sep 30 10:21:38 2019 -0400 Merge topic 'smart_ptr/cmCurses' 7d6e08b438 cmCursesMainForm: change Entries to object vector 0833486d62 cmCursesStringWidget: remove manual delete bc71b253cb cmCursesCacheEntryComposite: default destructor 36875ff419 cmCursesMainForm: cleanup manual allocation 2b16071149 CursesDialog: modernize CMake usage Acked-by: Kitware Robot Merge-request: !3849 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dce58afd30b781bd99a1af5c6860583577d58a1f commit dce58afd30b781bd99a1af5c6860583577d58a1f Merge: c88cf48 013d7dd Author: Brad King AuthorDate: Mon Sep 30 09:34:57 2019 -0400 Commit: Brad King CommitDate: Mon Sep 30 09:34:57 2019 -0400 Merge branch 'backport-3.15-fix-EXCLUDE_FROM_ALL-subdir-all' Resolve conflicts with changes since the 3.15 series: * Convert `cmSystemTools::IsOn` => `cmIsOn`. * Move one "EXCLUDE_FROM_ALL" target property logic fix to its new location in `cmMakefile::AddNewUtilityTarget`. diff --cc Source/cmGlobalGenerator.cxx index c4974f3,ea898e1..a75e2ed --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@@ -2037,10 -2088,18 +2037,18 @@@ bool cmGlobalGenerator::IsExcluded(cmLo return this->IsExcluded(rootSnp, snp); } - bool cmGlobalGenerator::IsExcluded(cmGeneratorTarget* target) const + bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, + cmGeneratorTarget* target) const { - return target->GetType() == cmStateEnums::INTERFACE_LIBRARY || - target->GetPropertyAsBool("EXCLUDE_FROM_ALL"); + if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + return true; + } + if (const char* exclude = target->GetProperty("EXCLUDE_FROM_ALL")) { - return cmSystemTools::IsOn(exclude); ++ return cmIsOn(exclude); + } + // This target is included in its directory. Check whether the + // directory is excluded. + return this->IsExcluded(root, target->GetLocalGenerator()); } void cmGlobalGenerator::GetEnabledLanguages( diff --cc Source/cmGlobalXCodeGenerator.cxx index 4202175,9d72528..f42218b --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@@ -554,16 -560,18 +554,16 @@@ void cmGlobalXCodeGenerator::AddExtraTa // this will make sure that when the next target is built // things are up-to-date if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) { - makeHelper.back() = // fill placeholder + commandLines.front().back() = // fill placeholder this->PostBuildMakeTarget(target->GetName(), "$(CONFIGURATION)"); - cmCustomCommandLines commandLines; - commandLines.push_back(makeHelper); - std::vector no_byproducts; gen->GetMakefile()->AddCustomCommandToTarget( target->GetName(), no_byproducts, no_depends, commandLines, - cmTarget::POST_BUILD, "Depend check for xcode", dir.c_str(), true, - false, "", "", false, cmMakefile::AcceptObjectLibraryCommands); + cmCustomCommandType::POST_BUILD, "Depend check for xcode", + dir.c_str(), true, false, "", "", false, + cmObjectLibraryCommands::Accept); } - if (!this->IsExcluded(target)) { + if (!this->IsExcluded(gens[0], target)) { allbuild->AddUtility(target->GetName()); } } diff --cc Source/cmMakefile.cxx index a528fc6,3f8bd4e..640f823 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@@ -2087,85 -2043,26 +2085,85 @@@ cmTarget* cmMakefile::AddNewTarget(cmSt return &it->second; } +cmTarget* cmMakefile::AddNewUtilityTarget(const std::string& utilityName, + cmCommandOrigin origin, + bool excludeFromAll) +{ + cmTarget* target = this->AddNewTarget(cmStateEnums::UTILITY, utilityName); + target->SetIsGeneratorProvided(origin == cmCommandOrigin::Generator); - if (excludeFromAll || this->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { ++ if (excludeFromAll) { + target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); + } + return target; +} + +namespace { +bool AnyOutputMatches(const std::string& name, + const std::vector& outputs) +{ + for (std::string const& output : outputs) { + std::string::size_type pos = output.rfind(name); + // If the output matches exactly + if (pos != std::string::npos && pos == output.size() - name.size() && + (pos == 0 || output[pos - 1] == '/')) { + return true; + } + } + return false; +} + +bool AnyTargetCommandOutputMatches( + const std::string& name, const std::vector& commands) +{ + for (cmCustomCommand const& command : commands) { + if (AnyOutputMatches(name, command.GetByproducts())) { + return true; + } + } + return false; +} +} + +cmTarget* cmMakefile::LinearGetTargetWithOutput(const std::string& name) const +{ + // We go through the ordered vector of targets to get reproducible results + // should multiple names match. + for (cmTarget* t : this->OrderedTargets) { + // Does the output of any command match the source file name? + if (AnyTargetCommandOutputMatches(name, t->GetPreBuildCommands())) { + return t; + } + if (AnyTargetCommandOutputMatches(name, t->GetPreLinkCommands())) { + return t; + } + if (AnyTargetCommandOutputMatches(name, t->GetPostBuildCommands())) { + return t; + } + } + return nullptr; +} + cmSourceFile* cmMakefile::LinearGetSourceFileWithOutput( - const std::string& name) const + const std::string& name, cmSourceOutputKind kind, bool& byproduct) const { - std::string out; + // Outputs take precedence over byproducts. + byproduct = false; + cmSourceFile* fallback = nullptr; - // look through all the source files that have custom commands - // and see if the custom command has the passed source file as an output + // Look through all the source files that have custom commands and see if the + // custom command has the passed source file as an output. for (cmSourceFile* src : this->SourceFiles) { - // does this source file have a custom command? + // Does this source file have a custom command? if (src->GetCustomCommand()) { // Does the output of the custom command match the source file name? - const std::vector& outputs = - src->GetCustomCommand()->GetOutputs(); - for (std::string const& output : outputs) { - out = output; - std::string::size_type pos = out.rfind(name); - // If the output matches exactly - if (pos != std::string::npos && pos == out.size() - name.size() && - (pos == 0 || out[pos - 1] == '/')) { - return src; + if (AnyOutputMatches(name, src->GetCustomCommand()->GetOutputs())) { + // Return the first matching output. + return src; + } + if (kind == cmSourceOutputKind::OutputOrByproduct) { + if (AnyOutputMatches(name, src->GetCustomCommand()->GetByproducts())) { + // Do not return the source yet as there might be a matching output. + fallback = src; } } } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=013d7dd48420b7040355066724ede9eb7050c94a commit 013d7dd48420b7040355066724ede9eb7050c94a Author: Brad King AuthorDate: Tue Sep 24 14:31:23 2019 -0400 Commit: Brad King CommitDate: Mon Sep 30 09:20:55 2019 -0400 Help: Mention 3.14.7 EXCLUDE_FROM_ALL fix in 3.15.4 release note diff --git a/Help/release/3.15.rst b/Help/release/3.15.rst index 148c2d2..957e6e9 100644 --- a/Help/release/3.15.rst +++ b/Help/release/3.15.rst @@ -384,3 +384,4 @@ Changes made since CMake 3.15.0 include the following. directory property was regressed from pre-3.14 behavior and caused targets within the directory to be excluded even from its own "all". This has been fixed. + The bug also existed in 3.14.0 through 3.14.6 and is fixed in 3.14.7. https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=61103c0bac4e9ef264d87fe9b23087ed8f5291c4 commit 61103c0bac4e9ef264d87fe9b23087ed8f5291c4 Merge: 1fe4501 62d45d9 Author: Brad King AuthorDate: Mon Sep 30 09:20:40 2019 -0400 Commit: Brad King CommitDate: Mon Sep 30 09:20:40 2019 -0400 Merge branch 'backport-3.14-fix-EXCLUDE_FROM_ALL-subdir-all' https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1fe450159278fd30138ef5133daf26f931537de4 commit 1fe450159278fd30138ef5133daf26f931537de4 Author: Brad King AuthorDate: Tue Sep 24 14:31:00 2019 -0400 Commit: Brad King CommitDate: Mon Sep 30 09:20:35 2019 -0400 Help: Add release note for EXCLUDE_FROM_ALL fix in 3.15.4 diff --git a/Help/release/3.15.rst b/Help/release/3.15.rst index 48f3aa4..148c2d2 100644 --- a/Help/release/3.15.rst +++ b/Help/release/3.15.rst @@ -376,3 +376,11 @@ Changes made since CMake 3.15.0 include the following. * ``CrayPrgEnv`` compiler wrapper support has been updated for the 19.06 release of the Cray Programming Environment for which the default linking mode on XC Cray systems is now dynamic instead of static. + +3.15.4 +------ + +* In CMake 3.15.0 through 3.15.3, the :prop_dir:`EXCLUDE_FROM_ALL` + directory property was regressed from pre-3.14 behavior and caused + targets within the directory to be excluded even from its own "all". + This has been fixed. https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=05d7ca14e99ee8ad36da01ddb314d0b90ab41874 commit 05d7ca14e99ee8ad36da01ddb314d0b90ab41874 Merge: 156b564 b3b1c7b Author: Brad King AuthorDate: Mon Sep 30 09:19:21 2019 -0400 Commit: Brad King CommitDate: Mon Sep 30 09:19:21 2019 -0400 Merge branch 'backport-3.14-fix-EXCLUDE_FROM_ALL-subdir-all' diff --cc Source/cmGlobalXCodeGenerator.cxx index 7c2bcd3,dc63ce6..9d72528 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@@ -568,10 -564,10 +568,10 @@@ void cmGlobalXCodeGenerator::AddExtraTa gen->GetMakefile()->AddCustomCommandToTarget( target->GetName(), no_byproducts, no_depends, commandLines, cmTarget::POST_BUILD, "Depend check for xcode", dir.c_str(), true, - false, "", false, cmMakefile::AcceptObjectLibraryCommands); + false, "", "", false, cmMakefile::AcceptObjectLibraryCommands); } - if (!this->IsExcluded(target)) { + if (!this->IsExcluded(gens[0], target)) { allbuild->AddUtility(target->GetName()); } } diff --cc Source/cmLocalNinjaGenerator.cxx index 81cafa3,69656a2..90666fc --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@@ -88,9 -88,12 +88,11 @@@ void cmLocalNinjaGenerator::Generate( if (tg) { tg->Generate(); // Add the target to "all" if required. - if (!this->GetGlobalNinjaGenerator()->IsExcluded(target)) { + if (!this->GetGlobalNinjaGenerator()->IsExcluded( + this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], + target)) { this->GetGlobalNinjaGenerator()->AddDependencyToAll(target); } - delete tg; } } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=62d45d91e83f537b19d9bfc7b1e8d909a0c5c322 commit 62d45d91e83f537b19d9bfc7b1e8d909a0c5c322 Author: Brad King AuthorDate: Tue Sep 24 14:24:55 2019 -0400 Commit: Brad King CommitDate: Mon Sep 30 09:18:20 2019 -0400 Help: Add release note for EXCLUDE_FROM_ALL fix in 3.14.7 diff --git a/Help/release/3.14.rst b/Help/release/3.14.rst index 229d8dc..8a9738c 100644 --- a/Help/release/3.14.rst +++ b/Help/release/3.14.rst @@ -428,3 +428,11 @@ Changes made since CMake 3.14.0 include the following. policy :policy:`CMP0088` ``NEW`` behavior accidentally interpreted a relative path to the ``.y`` input as relative to the build tree directory instead of the source tree directory. This has been fixed. + +3.14.7 +------ + +* In CMake 3.14.0 through 3.14.6, the :prop_dir:`EXCLUDE_FROM_ALL` + directory property was regressed from pre-3.14 behavior and caused + targets within the directory to be excluded even from its own "all". + This has been fixed. https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b3b1c7bf3afc8f33fa69b79f47f778cb781ac3c7 commit b3b1c7bf3afc8f33fa69b79f47f778cb781ac3c7 Author: Brad King AuthorDate: Tue Sep 24 11:50:18 2019 -0400 Commit: Brad King CommitDate: Mon Sep 30 09:18:20 2019 -0400 Restore "all" target in subdirectories marked EXCLUDE_FROM_ALL The "all" target in each directory is supposed to have targets from that directory even if the directory itself is marked `EXCLUDE_FROM_ALL` in its parent. This was broken by commit dc6888573d (Pass EXCLUDE_FROM_ALL from directory to targets, 2019-01-15, v3.14.0-rc1~83^2) which made the participation of a target in "all" independent of context. Revert much of the logic change from that commit to restore the old behavior. Then re-implement the behavior intended by the commit to keep its test working. Extend the test to cover the old behavior too. Fixes: #19753 diff --git a/Help/prop_dir/EXCLUDE_FROM_ALL.rst b/Help/prop_dir/EXCLUDE_FROM_ALL.rst index 9d3192c..8e3cca0 100644 --- a/Help/prop_dir/EXCLUDE_FROM_ALL.rst +++ b/Help/prop_dir/EXCLUDE_FROM_ALL.rst @@ -1,15 +1,13 @@ EXCLUDE_FROM_ALL ---------------- -Exclude the directory from the all target of its parent. +Set this directory property to a true value on a subdirectory to exclude +its targets from the "all" target of its ancestors. If excluded, running +e.g. ``make`` in the parent directory will not build targets the +subdirectory by default. This does not affect the "all" target of the +subdirectory itself. Running e.g. ``make`` inside the subdirectory will +still build its targets. -A property on a directory that indicates if its targets are excluded -from the default build target. If it is not, then with a Makefile for -example typing make will cause the targets to be built. The same -concept applies to the default build of other generators. - -Targets inherit the :prop_tgt:`EXCLUDE_FROM_ALL` property from the directory -that they are created in. When a directory is excluded, all of its targets will -have :prop_tgt:`EXCLUDE_FROM_ALL` set to ``TRUE``. After creating such a target -you can change its :prop_tgt:`EXCLUDE_FROM_ALL` property to ``FALSE``. This -will cause the target to be included in the default build target. +If the :prop_tgt:`EXCLUDE_FROM_ALL` target property is set on a target +then its value determines whether the target is included in the "all" +target of this directory and its ancestors. diff --git a/Help/prop_tgt/EXCLUDE_FROM_ALL.rst b/Help/prop_tgt/EXCLUDE_FROM_ALL.rst index 0eee297..3aa296d 100644 --- a/Help/prop_tgt/EXCLUDE_FROM_ALL.rst +++ b/Help/prop_tgt/EXCLUDE_FROM_ALL.rst @@ -1,12 +1,15 @@ EXCLUDE_FROM_ALL ---------------- -Exclude the target from the all target. +Set this target property to a true (or false) value to exclude (or include) +the target from the "all" target of the containing directory and its +ancestors. If excluded, running e.g. ``make`` in the containing directory +or its ancestors will not build the target by default. -A property on a target that indicates if the target is excluded from -the default build target. If it is not, then with a Makefile for -example typing make will cause this target to be built. The same -concept applies to the default build of other generators. +If this target property is not set then the target will be included in +the "all" target of the containing directory. Furthermore, it will be +included in the "all" target of its ancestor directories unless the +:prop_dir:`EXCLUDE_FROM_ALL` directory property is set. With ``EXCLUDE_FROM_ALL`` set to false or not set at all, the target will be brought up to date as part of doing a ``make install`` or its @@ -16,6 +19,3 @@ target has undefined behavior. Note that such a target can still safely be listed in an :command:`install(TARGETS)` command as long as the install components the target belongs to are not part of the set of components that anything tries to install. - -This property is enabled by default for targets that are created in -directories that have :prop_dir:`EXCLUDE_FROM_ALL` set to ``TRUE``. diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 386a3f7..8a3720f 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2029,10 +2029,18 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, return this->IsExcluded(rootSnp, snp); } -bool cmGlobalGenerator::IsExcluded(cmGeneratorTarget* target) const +bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, + cmGeneratorTarget* target) const { - return target->GetType() == cmStateEnums::INTERFACE_LIBRARY || - target->GetPropertyAsBool("EXCLUDE_FROM_ALL"); + if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { + return true; + } + if (const char* exclude = target->GetProperty("EXCLUDE_FROM_ALL")) { + return cmSystemTools::IsOn(exclude); + } + // This target is included in its directory. Check whether the + // directory is excluded. + return this->IsExcluded(root, target->GetLocalGenerator()); } void cmGlobalGenerator::GetEnabledLanguages( diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index ac01326..0e40610 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -522,7 +522,7 @@ protected: bool IsExcluded(cmStateSnapshot const& root, cmStateSnapshot const& snp) const; bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; - bool IsExcluded(cmGeneratorTarget* target) const; + bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; virtual void InitializeProgressMarks() {} struct GlobalTargetInfo diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index c619e67..226b73d 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -329,9 +329,9 @@ public: return LocalGenerators; } - bool IsExcluded(cmGeneratorTarget* target) + bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) { - return cmGlobalGenerator::IsExcluded(target); + return cmGlobalGenerator::IsExcluded(root, target); } int GetRuleCmdLength(const std::string& name) { return RuleCmdLength[name]; } diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index dac6ea6..f1a128a 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -713,7 +713,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( localName, depends, commands, true); // add the all/all dependency - if (!this->IsExcluded(gtarget)) { + if (!this->IsExcluded(this->LocalGenerators[0], gtarget)) { depends.clear(); depends.push_back(localName); commands.clear(); @@ -777,7 +777,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( "Pre-install relink rule for target.", localName, depends, commands, true); - if (!this->IsExcluded(gtarget)) { + if (!this->IsExcluded(this->LocalGenerators[0], gtarget)) { depends.clear(); depends.push_back(localName); commands.clear(); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index f3ed76b..cc5a880 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -209,7 +209,7 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets() tgt->IsImported()) { continue; } - if (!this->IsExcluded(tgt)) { + if (!this->IsExcluded(gen[0], tgt)) { allBuild->AddUtility(tgt->GetName()); } } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 57de60e..dc63ce6 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -567,7 +567,7 @@ void cmGlobalXCodeGenerator::AddExtraTargets( false, "", false, cmMakefile::AcceptObjectLibraryCommands); } - if (!this->IsExcluded(target)) { + if (!this->IsExcluded(gens[0], target)) { allbuild->AddUtility(target->GetName()); } } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index c0afc25..69656a2 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -88,7 +88,9 @@ void cmLocalNinjaGenerator::Generate() if (tg) { tg->Generate(); // Add the target to "all" if required. - if (!this->GetGlobalNinjaGenerator()->IsExcluded(target)) { + if (!this->GetGlobalNinjaGenerator()->IsExcluded( + this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], + target)) { this->GetGlobalNinjaGenerator()->AddDependencyToAll(target); } delete tg; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7e33bda..2735122 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1151,7 +1151,7 @@ cmTarget* cmMakefile::AddUtilityCommand( // Create a target instance for this utility. cmTarget* target = this->AddNewTarget(cmStateEnums::UTILITY, utilityName); target->SetIsGeneratorProvided(origin == TargetOrigin::Generator); - if (excludeFromAll || this->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { + if (excludeFromAll) { target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } if (!comment) { @@ -1689,7 +1689,7 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot); this->GetGlobalGenerator()->AddMakefile(subMf); - if (excludeFromAll || this->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { + if (excludeFromAll) { subMf->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } @@ -1985,9 +1985,7 @@ cmTarget* cmMakefile::AddLibrary(const std::string& lname, // over changes in CMakeLists.txt, making the information stale and // hence useless. target->ClearDependencyInformation(*this); - if (excludeFromAll || - (type != cmStateEnums::INTERFACE_LIBRARY && - this->GetPropertyAsBool("EXCLUDE_FROM_ALL"))) { + if (excludeFromAll) { target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } target->AddSources(srcs); @@ -2000,7 +1998,7 @@ cmTarget* cmMakefile::AddExecutable(const std::string& exeName, bool excludeFromAll) { cmTarget* target = this->AddNewTarget(cmStateEnums::EXECUTABLE, exeName); - if (excludeFromAll || this->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { + if (excludeFromAll) { target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } target->AddSources(srcs); diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll-build-sub-stderr.txt b/Tests/RunCMake/add_subdirectory/ExcludeFromAll-build-sub-stderr.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll-build-sub-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake b/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake index 16f39d9..ff676a6 100644 --- a/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake @@ -9,5 +9,6 @@ file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$>.c set(main_exe \"$\") set(foo_lib \"$\") set(bar_lib \"$\") +set(zot_lib \"$\") set(subinc_lib \"$\") ") diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt index 9d7922f..790da54 100644 --- a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt @@ -1,4 +1,8 @@ -add_library(bar STATIC bar.cpp) +project(ExcludeFromAllSub NONE) + +add_library(bar STATIC EXCLUDE_FROM_ALL bar.cpp) + +add_library(zot STATIC zot.cpp) add_library(foo STATIC foo.cpp) target_include_directories(foo PUBLIC .) diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check-sub.cmake similarity index 97% copy from Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake copy to Tests/RunCMake/add_subdirectory/ExcludeFromAll/check-sub.cmake index 56a8abd..297ad1e 100644 --- a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check-sub.cmake @@ -7,7 +7,7 @@ if(EXISTS ${RunCMake_TEST_BINARY_DIR}/check-debug.cmake) foreach(file "${foo_lib}" "${subinc_lib}" - "${main_exe}" + "${zot_lib}" ) if(NOT EXISTS "${file}") set(RunCMake_TEST_FAILED @@ -16,6 +16,7 @@ if(EXISTS ${RunCMake_TEST_BINARY_DIR}/check-debug.cmake) endif() endforeach() foreach(file + "${main_exe}" "${bar_lib}" ) if(EXISTS "${file}") diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake index 56a8abd..433c032 100644 --- a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake @@ -9,13 +9,17 @@ if(EXISTS ${RunCMake_TEST_BINARY_DIR}/check-debug.cmake) "${subinc_lib}" "${main_exe}" ) - if(NOT EXISTS "${file}") + if(EXISTS "${file}") + # Remove for next step of test. + file(REMOVE "${file}") + else() set(RunCMake_TEST_FAILED "Artifact should exist but is missing:\n ${file}") return() endif() endforeach() foreach(file + "${zot_lib}" "${bar_lib}" ) if(EXISTS "${file}") diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/zot.cpp b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/zot.cpp new file mode 100644 index 0000000..ba7e966 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/zot.cpp @@ -0,0 +1,4 @@ +int zot() +{ + return 0; +} diff --git a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake index e9ba92f..951e03c 100644 --- a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake @@ -34,6 +34,26 @@ run_cmake(ExcludeFromAll) set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake-check-file ExcludeFromAll/check.cmake) run_cmake_command(ExcludeFromAll-build ${CMAKE_COMMAND} --build . --config Debug) +if(RunCMake_GENERATOR STREQUAL "Ninja") + if(WIN32) + set(slash [[\]]) + else() + set(slash [[/]]) + endif() + set(RunCMake-check-file ExcludeFromAll/check-sub.cmake) + run_cmake_command(ExcludeFromAll-build-sub ${CMAKE_COMMAND} --build . --target "ExcludeFromAll${slash}all") +elseif(RunCMake_GENERATOR MATCHES "Make") + set(RunCMake-check-file ExcludeFromAll/check-sub.cmake) + set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY ${RunCMake_BINARY_DIR}/ExcludeFromAll-build/ExcludeFromAll) + run_cmake_command(ExcludeFromAll-build-sub "${RunCMake_MAKE_PROGRAM}") +elseif(RunCMake_GENERATOR MATCHES "^Visual Studio [1-9][0-9]") + set(RunCMake-check-file ExcludeFromAll/check-sub.cmake) + run_cmake_command(ExcludeFromAll-build-sub ${CMAKE_COMMAND} --build ExcludeFromAll --config Debug) +elseif(RunCMake_GENERATOR STREQUAL "Xcode") + set(RunCMake-check-file ExcludeFromAll/check-sub.cmake) + set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY ${RunCMake_BINARY_DIR}/ExcludeFromAll-build/ExcludeFromAll) + run_cmake_command(ExcludeFromAll-build-sub xcodebuild -configuration Debug) +endif() unset(RunCMake-check-file) unset(RunCMake_TEST_NO_CLEAN) unset(RunCMake_TEST_OPTIONS) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6bd40ccf8424a6e8c3a77857d48600ed7c624a07 commit 6bd40ccf8424a6e8c3a77857d48600ed7c624a07 Author: Sebastian Holtermann AuthorDate: Fri Sep 27 15:57:29 2019 +0200 Commit: Sebastian Holtermann CommitDate: Sun Sep 29 00:07:32 2019 +0200 Autogen: Make cmQtAutoMocUic a free function diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index ab91af4..3b0f717 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -2,20 +2,33 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmQtAutoMocUic.h" -#include -#include -#include - -#include - #include "cmAlgorithms.h" #include "cmCryptoHash.h" +#include "cmFileTime.h" #include "cmGeneratedFileStream.h" #include "cmQtAutoGen.h" +#include "cmQtAutoGenerator.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" +#include "cmWorkerPool.h" #include "cm_jsoncpp_value.h" #include "cmsys/FStream.hxx" +#include "cmsys/RegularExpression.hxx" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #if defined(__APPLE__) # include @@ -26,10 +39,533 @@ namespace { constexpr std::size_t MocUnderscoreLength = 4; // Length of "moc_" constexpr std::size_t UiUnderscoreLength = 3; // Length of "ui_" -} // End of unnamed namespace +/** \class cmQtAutoMocUicT + * \brief AUTOMOC and AUTOUIC generator + */ +class cmQtAutoMocUicT : public cmQtAutoGenerator +{ +public: + cmQtAutoMocUicT(); + ~cmQtAutoMocUicT() override; + + cmQtAutoMocUicT(cmQtAutoMocUicT const&) = delete; + cmQtAutoMocUicT& operator=(cmQtAutoMocUicT const&) = delete; + +public: + // -- Types + + /** Include string with sub parts. */ + struct IncludeKeyT + { + IncludeKeyT(std::string const& key, std::size_t basePrefixLength); + + std::string Key; // Full include string + std::string Dir; // Include directory + std::string Base; // Base part of the include file name + }; + + /** Search key plus regular expression pair. */ + struct KeyExpT + { + KeyExpT(std::string key, std::string const& exp) + : Key(std::move(key)) + , Exp(exp) + { + } + + std::string Key; + cmsys::RegularExpression Exp; + }; + + /** Source file parsing cache. */ + class ParseCacheT + { + public: + // -- Types + + /** Entry of the file parsing cache. */ + struct FileT + { + void Clear(); + + struct MocT + { + std::string Macro; + struct IncludeT + { + std::vector Underscore; + std::vector Dot; + } Include; + std::vector Depends; + } Moc; + + struct UicT + { + std::vector Include; + std::vector Depends; + } Uic; + }; + using FileHandleT = std::shared_ptr; + using GetOrInsertT = std::pair; + + public: + ParseCacheT(); + ~ParseCacheT(); + + bool ReadFromFile(std::string const& fileName); + bool WriteToFile(std::string const& fileName); + + //! Always returns a valid handle + GetOrInsertT GetOrInsert(std::string const& fileName); + + private: + std::unordered_map Map_; + }; + + /** Source file data. */ + class SourceFileT + { + public: + SourceFileT(std::string fileName) + : FileName(std::move(fileName)) + { + } + + public: + std::string FileName; + cmFileTime FileTime; + ParseCacheT::FileHandleT ParseData; + std::string BuildPath; + bool IsHeader = false; + bool Moc = false; + bool Uic = false; + }; + using SourceFileHandleT = std::shared_ptr; + using SourceFileMapT = std::map; + + /** Meta compiler file mapping information. */ + struct MappingT + { + SourceFileHandleT SourceFile; + std::string OutputFile; + std::string IncludeString; + std::vector IncluderFiles; + }; + using MappingHandleT = std::shared_ptr; + using MappingMapT = std::map; + + /** Common settings. */ + class BaseSettingsT + { + public: + // -- Constructors + BaseSettingsT(); + ~BaseSettingsT(); + + BaseSettingsT(BaseSettingsT const&) = delete; + BaseSettingsT& operator=(BaseSettingsT const&) = delete; + + // -- Attributes + // - Config + bool MultiConfig = false; + unsigned int QtVersionMajor = 4; + unsigned int ThreadCount = 0; + // - Directories + std::string AutogenBuildDir; + std::string AutogenIncludeDir; + // - Files + std::string CMakeExecutable; + cmFileTime CMakeExecutableTime; + std::string ParseCacheFile; + std::vector HeaderExtensions; + }; + + /** Shared common variables. */ + class BaseEvalT + { + public: + // -- Parse Cache + bool ParseCacheChanged = false; + cmFileTime ParseCacheTime; + ParseCacheT ParseCache; + + // -- Sources + SourceFileMapT Headers; + SourceFileMapT Sources; + }; + + /** Moc settings. */ + class MocSettingsT + { + public: + // -- Constructors + MocSettingsT(); + ~MocSettingsT(); + + MocSettingsT(MocSettingsT const&) = delete; + MocSettingsT& operator=(MocSettingsT const&) = delete; + + // -- Const methods + bool skipped(std::string const& fileName) const; + std::string MacrosString() const; + + // -- Attributes + bool Enabled = false; + bool SettingsChanged = false; + bool RelaxedMode = false; + bool PathPrefix = false; + cmFileTime ExecutableTime; + std::string Executable; + std::string CompFileAbs; + std::string PredefsFileAbs; + std::unordered_set SkipList; + std::vector IncludePaths; + std::vector Definitions; + std::vector OptionsIncludes; + std::vector OptionsDefinitions; + std::vector OptionsExtra; + std::vector PredefsCmd; + std::vector DependFilters; + std::vector MacroFilters; + cmsys::RegularExpression RegExpInclude; + }; + + /** Moc shared variables. */ + class MocEvalT + { + public: + // -- predefines file + cmFileTime PredefsTime; + // -- Mappings + MappingMapT HeaderMappings; + MappingMapT SourceMappings; + MappingMapT Includes; + // -- Discovered files + SourceFileMapT HeadersDiscovered; + // -- Output directories + std::unordered_set OutputDirs; + // -- Mocs compilation + bool CompUpdated = false; + std::vector CompFiles; + }; + + /** Uic settings. */ + class UicSettingsT + { + public: + struct UiFile + { + std::vector Options; + }; + + public: + UicSettingsT(); + ~UicSettingsT(); + + UicSettingsT(UicSettingsT const&) = delete; + UicSettingsT& operator=(UicSettingsT const&) = delete; + + // -- Const methods + bool skipped(std::string const& fileName) const; + + // -- Attributes + bool Enabled = false; + bool SettingsChanged = false; + cmFileTime ExecutableTime; + std::string Executable; + std::unordered_set SkipList; + std::vector Options; + std::unordered_map UiFiles; + std::vector SearchPaths; + cmsys::RegularExpression RegExpInclude; + }; + + /** Uic shared variables. */ + class UicEvalT + { + public: + // -- Discovered files + SourceFileMapT UiFiles; + // -- Mappings + MappingMapT Includes; + // -- Output directories + std::unordered_set OutputDirs; + }; + + /** Abstract job class for concurrent job processing. */ + class JobT : public cmWorkerPool::JobT + { + protected: + /** Protected default constructor. */ + JobT(bool fence = false) + : cmWorkerPool::JobT(fence) + { + } + + //! Get the generator. Only valid during Process() call! + cmQtAutoMocUicT* Gen() const + { + return static_cast(UserData()); + }; + + // -- Accessors. Only valid during Process() call! + Logger const& Log() const { return Gen()->Log(); } + BaseSettingsT const& BaseConst() const { return Gen()->BaseConst(); } + BaseEvalT& BaseEval() const { return Gen()->BaseEval(); } + MocSettingsT const& MocConst() const { return Gen()->MocConst(); } + MocEvalT& MocEval() const { return Gen()->MocEval(); } + UicSettingsT const& UicConst() const { return Gen()->UicConst(); } + UicEvalT& UicEval() const { return Gen()->UicEval(); } + + // -- Logging + std::string MessagePath(cm::string_view path) const + { + return Gen()->MessagePath(path); + } + // - Error logging with automatic abort + void LogError(GenT genType, cm::string_view message) const; + void LogCommandError(GenT genType, cm::string_view message, + std::vector const& command, + std::string const& output) const; + + /** @brief Run an external process. Use only during Process() call! */ + bool RunProcess(GenT genType, cmWorkerPool::ProcessResultT& result, + std::vector const& command, + std::string* infoMessage = nullptr); + }; + + /** Fence job utility class. */ + class JobFenceT : public JobT + { + public: + JobFenceT() + : JobT(true) + { + } + void Process() override{}; + }; + + /** Generate moc_predefs.h. */ + class JobMocPredefsT : public JobFenceT + { + void Process() override; + bool Update(std::string* reason) const; + }; + + /** File parse job base class. */ + class JobParseT : public JobT + { + public: + JobParseT(SourceFileHandleT fileHandle) + : FileHandle(std::move(fileHandle)) + { + } + + protected: + bool ReadFile(); + void CreateKeys(std::vector& container, + std::set const& source, + std::size_t basePrefixLength); + void MocMacro(); + void MocDependecies(); + void MocIncludes(); + void UicIncludes(); + + protected: + SourceFileHandleT FileHandle; + std::string Content; + }; + + /** Header file parse job. */ + class JobParseHeaderT : public JobParseT + { + public: + using JobParseT::JobParseT; + void Process() override; + }; -cmQtAutoMocUic::IncludeKeyT::IncludeKeyT(std::string const& key, - std::size_t basePrefixLength) + /** Source file parse job. */ + class JobParseSourceT : public JobParseT + { + public: + using JobParseT::JobParseT; + void Process() override; + }; + + /** Evaluate cached file parse data - moc. */ + class JobEvalCacheT : public JobT + { + protected: + std::string MessageSearchLocations() const; + std::vector SearchLocations; + }; + + /** Evaluate cached file parse data - moc. */ + class JobEvalCacheMocT : public JobEvalCacheT + { + void Process() override; + bool EvalHeader(SourceFileHandleT source); + bool EvalSource(SourceFileHandleT const& source); + bool FindIncludedHeader(SourceFileHandleT& headerHandle, + cm::string_view includerDir, + cm::string_view includeBase); + bool RegisterIncluded(std::string const& includeString, + SourceFileHandleT includerFileHandle, + SourceFileHandleT sourceFileHandle) const; + void RegisterMapping(MappingHandleT mappingHandle) const; + std::string MessageHeader(cm::string_view headerBase) const; + }; + + /** Evaluate cached file parse data - uic. */ + class JobEvalCacheUicT : public JobEvalCacheT + { + void Process() override; + bool EvalFile(SourceFileHandleT const& sourceFileHandle); + bool FindIncludedUi(cm::string_view sourceDirPrefix, + cm::string_view includePrefix); + bool RegisterMapping(std::string const& includeString, + SourceFileHandleT includerFileHandle); + + std::string UiName; + SourceFileHandleT UiFileHandle; + }; + + /** Evaluate cached file parse data - finish */ + class JobEvalCacheFinishT : public JobFenceT + { + void Process() override; + }; + + /** Dependency probing base job. */ + class JobProbeDepsT : public JobT + { + }; + + /** Probes file dependencies and generates moc compile jobs. */ + class JobProbeDepsMocT : public JobProbeDepsT + { + void Process() override; + bool Generate(MappingHandleT const& mapping, bool compFile) const; + bool Probe(MappingT const& mapping, std::string* reason) const; + std::pair FindDependency( + std::string const& sourceDir, std::string const& includeString) const; + }; + + /** Probes file dependencies and generates uic compile jobs. */ + class JobProbeDepsUicT : public JobProbeDepsT + { + void Process() override; + bool Probe(MappingT const& mapping, std::string* reason) const; + }; + + /** Dependency probing finish job. */ + class JobProbeDepsFinishT : public JobFenceT + { + void Process() override; + }; + + /** Meta compiler base job. */ + class JobCompileT : public JobT + { + public: + JobCompileT(MappingHandleT uicMapping, std::unique_ptr reason) + : Mapping(std::move(uicMapping)) + , Reason(std::move(reason)) + { + } + + protected: + MappingHandleT Mapping; + std::unique_ptr Reason; + }; + + /** moc compiles a file. */ + class JobCompileMocT : public JobCompileT + { + public: + using JobCompileT::JobCompileT; + void Process() override; + }; + + /** uic compiles a file. */ + class JobCompileUicT : public JobCompileT + { + public: + using JobCompileT::JobCompileT; + void Process() override; + }; + + /** Generate mocs_compilation.cpp. */ + class JobMocsCompilationT : public JobFenceT + { + private: + void Process() override; + }; + + /** @brief The last job. */ + class JobFinishT : public JobFenceT + { + private: + void Process() override; + }; + + // -- Const settings interface + BaseSettingsT const& BaseConst() const { return this->BaseConst_; } + BaseEvalT& BaseEval() { return this->BaseEval_; } + MocSettingsT const& MocConst() const { return this->MocConst_; } + MocEvalT& MocEval() { return this->MocEval_; } + UicSettingsT const& UicConst() const { return this->UicConst_; } + UicEvalT& UicEval() { return this->UicEval_; } + + // -- Parallel job processing interface + cmWorkerPool& WorkerPool() { return WorkerPool_; } + void AbortError() { Abort(true); } + void AbortSuccess() { Abort(false); } + + // -- Utility + std::string AbsoluteBuildPath(cm::string_view relativePath) const; + std::string AbsoluteIncludePath(cm::string_view relativePath) const; + template + void CreateParseJobs(SourceFileMapT const& sourceMap); + std::string CollapseFullPathTS(std::string const& path) const; + +private: + // -- Abstract processing interface + bool InitFromInfo(InfoT const& info) override; + void InitJobs(); + bool Process() override; + // -- Settings file + void SettingsFileRead(); + bool SettingsFileWrite(); + // -- Parse cache + void ParseCacheRead(); + bool ParseCacheWrite(); + // -- Thread processing + void Abort(bool error); + // -- Generation + bool CreateDirectories(); + +private: + // -- Settings + BaseSettingsT BaseConst_; + BaseEvalT BaseEval_; + MocSettingsT MocConst_; + MocEvalT MocEval_; + UicSettingsT UicConst_; + UicEvalT UicEval_; + // -- Settings file + std::string SettingsFile_; + std::string SettingsStringMoc_; + std::string SettingsStringUic_; + // -- Worker thread pool + std::atomic JobError_ = ATOMIC_VAR_INIT(false); + cmWorkerPool WorkerPool_; + // -- Concurrent processing + mutable std::mutex CMakeLibMutex_; +}; + +cmQtAutoMocUicT::IncludeKeyT::IncludeKeyT(std::string const& key, + std::size_t basePrefixLength) : Key(key) , Dir(SubDirPrefix(key)) , Base(cmSystemTools::GetFilenameWithoutLastExtension(key)) @@ -39,7 +575,7 @@ cmQtAutoMocUic::IncludeKeyT::IncludeKeyT(std::string const& key, } } -void cmQtAutoMocUic::ParseCacheT::FileT::Clear() +void cmQtAutoMocUicT::ParseCacheT::FileT::Clear() { Moc.Macro.clear(); Moc.Include.Underscore.clear(); @@ -50,18 +586,8 @@ void cmQtAutoMocUic::ParseCacheT::FileT::Clear() Uic.Depends.clear(); } -cmQtAutoMocUic::ParseCacheT::FileHandleT cmQtAutoMocUic::ParseCacheT::Get( - std::string const& fileName) const -{ - auto it = Map_.find(fileName); - if (it != Map_.end()) { - return it->second; - } - return FileHandleT(); -} - -cmQtAutoMocUic::ParseCacheT::GetOrInsertT -cmQtAutoMocUic::ParseCacheT::GetOrInsert(std::string const& fileName) +cmQtAutoMocUicT::ParseCacheT::GetOrInsertT +cmQtAutoMocUicT::ParseCacheT::GetOrInsert(std::string const& fileName) { // Find existing entry { @@ -77,15 +603,10 @@ cmQtAutoMocUic::ParseCacheT::GetOrInsert(std::string const& fileName) }; } -cmQtAutoMocUic::ParseCacheT::ParseCacheT() = default; -cmQtAutoMocUic::ParseCacheT::~ParseCacheT() = default; +cmQtAutoMocUicT::ParseCacheT::ParseCacheT() = default; +cmQtAutoMocUicT::ParseCacheT::~ParseCacheT() = default; -void cmQtAutoMocUic::ParseCacheT::Clear() -{ - Map_.clear(); -} - -bool cmQtAutoMocUic::ParseCacheT::ReadFromFile(std::string const& fileName) +bool cmQtAutoMocUicT::ParseCacheT::ReadFromFile(std::string const& fileName) { cmsys::ifstream fin(fileName.c_str()); if (!fin) { @@ -148,7 +669,7 @@ bool cmQtAutoMocUic::ParseCacheT::ReadFromFile(std::string const& fileName) return true; } -bool cmQtAutoMocUic::ParseCacheT::WriteToFile(std::string const& fileName) +bool cmQtAutoMocUicT::ParseCacheT::WriteToFile(std::string const& fileName) { cmGeneratedFileStream ofs(fileName); if (!ofs) { @@ -180,24 +701,24 @@ bool cmQtAutoMocUic::ParseCacheT::WriteToFile(std::string const& fileName) return ofs.Close(); } -cmQtAutoMocUic::BaseSettingsT::BaseSettingsT() = default; -cmQtAutoMocUic::BaseSettingsT::~BaseSettingsT() = default; +cmQtAutoMocUicT::BaseSettingsT::BaseSettingsT() = default; +cmQtAutoMocUicT::BaseSettingsT::~BaseSettingsT() = default; -cmQtAutoMocUic::MocSettingsT::MocSettingsT() +cmQtAutoMocUicT::MocSettingsT::MocSettingsT() { RegExpInclude.compile( "(^|\n)[ \t]*#[ \t]*include[ \t]+" "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]"); } -cmQtAutoMocUic::MocSettingsT::~MocSettingsT() = default; +cmQtAutoMocUicT::MocSettingsT::~MocSettingsT() = default; -bool cmQtAutoMocUic::MocSettingsT::skipped(std::string const& fileName) const +bool cmQtAutoMocUicT::MocSettingsT::skipped(std::string const& fileName) const { return (!Enabled || (SkipList.find(fileName) != SkipList.end())); } -std::string cmQtAutoMocUic::MocSettingsT::MacrosString() const +std::string cmQtAutoMocUicT::MocSettingsT::MacrosString() const { std::string res; const auto itB = MacroFilters.cbegin(); @@ -219,27 +740,27 @@ std::string cmQtAutoMocUic::MocSettingsT::MacrosString() const return res; } -cmQtAutoMocUic::UicSettingsT::UicSettingsT() +cmQtAutoMocUicT::UicSettingsT::UicSettingsT() { RegExpInclude.compile("(^|\n)[ \t]*#[ \t]*include[ \t]+" "[\"<](([^ \">]+/)?ui_[^ \">/]+\\.h)[\">]"); } -cmQtAutoMocUic::UicSettingsT::~UicSettingsT() = default; +cmQtAutoMocUicT::UicSettingsT::~UicSettingsT() = default; -bool cmQtAutoMocUic::UicSettingsT::skipped(std::string const& fileName) const +bool cmQtAutoMocUicT::UicSettingsT::skipped(std::string const& fileName) const { return (!Enabled || (SkipList.find(fileName) != SkipList.end())); } -void cmQtAutoMocUic::JobT::LogError(GenT genType, - cm::string_view message) const +void cmQtAutoMocUicT::JobT::LogError(GenT genType, + cm::string_view message) const { Gen()->AbortError(); Gen()->Log().Error(genType, message); } -void cmQtAutoMocUic::JobT::LogCommandError( +void cmQtAutoMocUicT::JobT::LogCommandError( GenT genType, cm::string_view message, std::vector const& command, std::string const& output) const { @@ -247,10 +768,10 @@ void cmQtAutoMocUic::JobT::LogCommandError( Gen()->Log().ErrorCommand(genType, message, command, output); } -bool cmQtAutoMocUic::JobT::RunProcess(GenT genType, - cmWorkerPool::ProcessResultT& result, - std::vector const& command, - std::string* infoMessage) +bool cmQtAutoMocUicT::JobT::RunProcess(GenT genType, + cmWorkerPool::ProcessResultT& result, + std::vector const& command, + std::string* infoMessage) { // Log command if (Log().Verbose()) { @@ -268,7 +789,7 @@ bool cmQtAutoMocUic::JobT::RunProcess(GenT genType, BaseConst().AutogenBuildDir); } -void cmQtAutoMocUic::JobMocPredefsT::Process() +void cmQtAutoMocUicT::JobMocPredefsT::Process() { // (Re)generate moc_predefs.h on demand std::unique_ptr reason; @@ -330,7 +851,7 @@ void cmQtAutoMocUic::JobMocPredefsT::Process() } } -bool cmQtAutoMocUic::JobMocPredefsT::Update(std::string* reason) const +bool cmQtAutoMocUicT::JobMocPredefsT::Update(std::string* reason) const { // Test if the file exists if (!MocEval().PredefsTime.Load(MocConst().PredefsFileAbs)) { @@ -369,7 +890,7 @@ bool cmQtAutoMocUic::JobMocPredefsT::Update(std::string* reason) const return false; } -bool cmQtAutoMocUic::JobParseT::ReadFile() +bool cmQtAutoMocUicT::JobParseT::ReadFile() { // Clear old parse information FileHandle->ParseData->Clear(); @@ -396,9 +917,9 @@ bool cmQtAutoMocUic::JobParseT::ReadFile() return true; } -void cmQtAutoMocUic::JobParseT::CreateKeys(std::vector& container, - std::set const& source, - std::size_t basePrefixLength) +void cmQtAutoMocUicT::JobParseT::CreateKeys( + std::vector& container, std::set const& source, + std::size_t basePrefixLength) { if (source.empty()) { return; @@ -409,7 +930,7 @@ void cmQtAutoMocUic::JobParseT::CreateKeys(std::vector& container, } } -void cmQtAutoMocUic::JobParseT::MocMacro() +void cmQtAutoMocUicT::JobParseT::MocMacro() { for (KeyExpT const& filter : MocConst().MacroFilters) { // Run a simple find string check @@ -426,7 +947,7 @@ void cmQtAutoMocUic::JobParseT::MocMacro() } } -void cmQtAutoMocUic::JobParseT::MocDependecies() +void cmQtAutoMocUicT::JobParseT::MocDependecies() { if (MocConst().DependFilters.empty()) { return; @@ -467,7 +988,7 @@ void cmQtAutoMocUic::JobParseT::MocDependecies() } } -void cmQtAutoMocUic::JobParseT::MocIncludes() +void cmQtAutoMocUicT::JobParseT::MocIncludes() { if (Content.find("moc") == std::string::npos) { return; @@ -500,7 +1021,7 @@ void cmQtAutoMocUic::JobParseT::MocIncludes() CreateKeys(Include.Dot, dot, 0); } -void cmQtAutoMocUic::JobParseT::UicIncludes() +void cmQtAutoMocUicT::JobParseT::UicIncludes() { if (Content.find("ui_") == std::string::npos) { return; @@ -520,7 +1041,7 @@ void cmQtAutoMocUic::JobParseT::UicIncludes() CreateKeys(FileHandle->ParseData->Uic.Include, includes, UiUnderscoreLength); } -void cmQtAutoMocUic::JobParseHeaderT::Process() +void cmQtAutoMocUicT::JobParseHeaderT::Process() { if (!ReadFile()) { return; @@ -536,7 +1057,7 @@ void cmQtAutoMocUic::JobParseHeaderT::Process() } } -void cmQtAutoMocUic::JobParseSourceT::Process() +void cmQtAutoMocUicT::JobParseSourceT::Process() { if (!ReadFile()) { return; @@ -553,7 +1074,7 @@ void cmQtAutoMocUic::JobParseSourceT::Process() } } -std::string cmQtAutoMocUic::JobEvalCacheT::MessageSearchLocations() const +std::string cmQtAutoMocUicT::JobEvalCacheT::MessageSearchLocations() const { std::string res; res.reserve(512); @@ -565,7 +1086,7 @@ std::string cmQtAutoMocUic::JobEvalCacheT::MessageSearchLocations() const return res; } -void cmQtAutoMocUic::JobEvalCacheMocT::Process() +void cmQtAutoMocUicT::JobEvalCacheMocT::Process() { // Evaluate headers for (auto const& pair : BaseEval().Headers) { @@ -581,7 +1102,7 @@ void cmQtAutoMocUic::JobEvalCacheMocT::Process() } } -bool cmQtAutoMocUic::JobEvalCacheMocT::EvalHeader(SourceFileHandleT source) +bool cmQtAutoMocUicT::JobEvalCacheMocT::EvalHeader(SourceFileHandleT source) { SourceFileT const& sourceFile = *source; auto const& parseData = sourceFile.ParseData->Moc; @@ -608,7 +1129,7 @@ bool cmQtAutoMocUic::JobEvalCacheMocT::EvalHeader(SourceFileHandleT source) return true; } -bool cmQtAutoMocUic::JobEvalCacheMocT::EvalSource( +bool cmQtAutoMocUicT::JobEvalCacheMocT::EvalSource( SourceFileHandleT const& source) { SourceFileT const& sourceFile = *source; @@ -809,7 +1330,7 @@ bool cmQtAutoMocUic::JobEvalCacheMocT::EvalSource( return true; } -bool cmQtAutoMocUic::JobEvalCacheMocT::FindIncludedHeader( +bool cmQtAutoMocUicT::JobEvalCacheMocT::FindIncludedHeader( SourceFileHandleT& headerHandle, cm::string_view includerDir, cm::string_view includeBase) { @@ -874,7 +1395,7 @@ bool cmQtAutoMocUic::JobEvalCacheMocT::FindIncludedHeader( return false; } -bool cmQtAutoMocUic::JobEvalCacheMocT::RegisterIncluded( +bool cmQtAutoMocUicT::JobEvalCacheMocT::RegisterIncluded( std::string const& includeString, SourceFileHandleT includerFileHandle, SourceFileHandleT sourceFileHandle) const { @@ -922,7 +1443,7 @@ bool cmQtAutoMocUic::JobEvalCacheMocT::RegisterIncluded( return true; } -void cmQtAutoMocUic::JobEvalCacheMocT::RegisterMapping( +void cmQtAutoMocUicT::JobEvalCacheMocT::RegisterMapping( MappingHandleT mappingHandle) const { auto& regMap = mappingHandle->SourceFile->IsHeader @@ -941,14 +1462,14 @@ void cmQtAutoMocUic::JobEvalCacheMocT::RegisterMapping( } } -std::string cmQtAutoMocUic::JobEvalCacheMocT::MessageHeader( +std::string cmQtAutoMocUicT::JobEvalCacheMocT::MessageHeader( cm::string_view headerBase) const { return MessagePath(cmStrCat( headerBase, ".{", cmJoin(this->BaseConst().HeaderExtensions, ","), '}')); } -void cmQtAutoMocUic::JobEvalCacheUicT::Process() +void cmQtAutoMocUicT::JobEvalCacheUicT::Process() { // Prepare buffers SearchLocations.reserve((UicConst().SearchPaths.size() + 1) * 2); @@ -967,7 +1488,7 @@ void cmQtAutoMocUic::JobEvalCacheUicT::Process() } } -bool cmQtAutoMocUic::JobEvalCacheUicT::EvalFile( +bool cmQtAutoMocUicT::JobEvalCacheUicT::EvalFile( SourceFileHandleT const& sourceFileHandle) { SourceFileT const& sourceFile = *sourceFileHandle; @@ -1002,7 +1523,7 @@ bool cmQtAutoMocUic::JobEvalCacheUicT::EvalFile( return true; } -bool cmQtAutoMocUic::JobEvalCacheUicT::FindIncludedUi( +bool cmQtAutoMocUicT::JobEvalCacheUicT::FindIncludedUi( cm::string_view sourceDirPrefix, cm::string_view includePrefix) { // Clear locations buffer @@ -1056,7 +1577,7 @@ bool cmQtAutoMocUic::JobEvalCacheUicT::FindIncludedUi( return false; } -bool cmQtAutoMocUic::JobEvalCacheUicT::RegisterMapping( +bool cmQtAutoMocUicT::JobEvalCacheUicT::RegisterMapping( std::string const& includeString, SourceFileHandleT includerFileHandle) { auto& Includes = Gen()->UicEval().Includes; @@ -1101,7 +1622,7 @@ bool cmQtAutoMocUic::JobEvalCacheUicT::RegisterMapping( return true; } -void cmQtAutoMocUic::JobEvalCacheFinishT::Process() +void cmQtAutoMocUicT::JobEvalCacheFinishT::Process() { // Add discovered header parse jobs Gen()->CreateParseJobs(MocEval().HeadersDiscovered); @@ -1121,7 +1642,7 @@ void cmQtAutoMocUic::JobEvalCacheFinishT::Process() } } -void cmQtAutoMocUic::JobProbeDepsMocT::Process() +void cmQtAutoMocUicT::JobProbeDepsMocT::Process() { // Create moc header jobs for (auto const& pair : MocEval().HeaderMappings) { @@ -1143,8 +1664,8 @@ void cmQtAutoMocUic::JobProbeDepsMocT::Process() } } -bool cmQtAutoMocUic::JobProbeDepsMocT::Generate(MappingHandleT const& mapping, - bool compFile) const +bool cmQtAutoMocUicT::JobProbeDepsMocT::Generate(MappingHandleT const& mapping, + bool compFile) const { std::unique_ptr reason; if (Log().Verbose()) { @@ -1163,8 +1684,8 @@ bool cmQtAutoMocUic::JobProbeDepsMocT::Generate(MappingHandleT const& mapping, return true; } -bool cmQtAutoMocUic::JobProbeDepsMocT::Probe(MappingT const& mapping, - std::string* reason) const +bool cmQtAutoMocUicT::JobProbeDepsMocT::Probe(MappingT const& mapping, + std::string* reason) const { std::string const& sourceFile = mapping.SourceFile->FileName; std::string const& outputFile = mapping.OutputFile; @@ -1254,7 +1775,7 @@ bool cmQtAutoMocUic::JobProbeDepsMocT::Probe(MappingT const& mapping, } std::pair -cmQtAutoMocUic::JobProbeDepsMocT::FindDependency( +cmQtAutoMocUicT::JobProbeDepsMocT::FindDependency( std::string const& sourceDir, std::string const& includeString) const { using ResPair = std::pair; @@ -1276,7 +1797,7 @@ cmQtAutoMocUic::JobProbeDepsMocT::FindDependency( return ResPair(); } -void cmQtAutoMocUic::JobProbeDepsUicT::Process() +void cmQtAutoMocUicT::JobProbeDepsUicT::Process() { for (auto const& pair : Gen()->UicEval().Includes) { MappingHandleT const& mapping = pair.second; @@ -1295,8 +1816,8 @@ void cmQtAutoMocUic::JobProbeDepsUicT::Process() } } -bool cmQtAutoMocUic::JobProbeDepsUicT::Probe(MappingT const& mapping, - std::string* reason) const +bool cmQtAutoMocUicT::JobProbeDepsUicT::Probe(MappingT const& mapping, + std::string* reason) const { std::string const& sourceFile = mapping.SourceFile->FileName; std::string const& outputFile = mapping.OutputFile; @@ -1345,7 +1866,7 @@ bool cmQtAutoMocUic::JobProbeDepsUicT::Probe(MappingT const& mapping, return false; } -void cmQtAutoMocUic::JobProbeDepsFinishT::Process() +void cmQtAutoMocUicT::JobProbeDepsFinishT::Process() { // Create output directories { @@ -1381,7 +1902,7 @@ void cmQtAutoMocUic::JobProbeDepsFinishT::Process() Gen()->WorkerPool().EmplaceJob(); } -void cmQtAutoMocUic::JobCompileMocT::Process() +void cmQtAutoMocUicT::JobCompileMocT::Process() { std::string const& sourceFile = Mapping->SourceFile->FileName; std::string const& outputFile = Mapping->OutputFile; @@ -1458,7 +1979,7 @@ void cmQtAutoMocUic::JobCompileMocT::Process() } } -void cmQtAutoMocUic::JobCompileUicT::Process() +void cmQtAutoMocUicT::JobCompileUicT::Process() { std::string const& sourceFile = Mapping->SourceFile->FileName; std::string const& outputFile = Mapping->OutputFile; @@ -1501,7 +2022,7 @@ void cmQtAutoMocUic::JobCompileUicT::Process() } } -void cmQtAutoMocUic::JobMocsCompilationT::Process() +void cmQtAutoMocUicT::JobMocsCompilationT::Process() { // Compose mocs compilation file content std::string content = @@ -1546,18 +2067,18 @@ void cmQtAutoMocUic::JobMocsCompilationT::Process() } } -void cmQtAutoMocUic::JobFinishT::Process() +void cmQtAutoMocUicT::JobFinishT::Process() { Gen()->AbortSuccess(); } -cmQtAutoMocUic::cmQtAutoMocUic() +cmQtAutoMocUicT::cmQtAutoMocUicT() : cmQtAutoGenerator(GenT::GEN) { } -cmQtAutoMocUic::~cmQtAutoMocUic() = default; +cmQtAutoMocUicT::~cmQtAutoMocUicT() = default; -bool cmQtAutoMocUic::InitFromInfo(InfoT const& info) +bool cmQtAutoMocUicT::InitFromInfo(InfoT const& info) { // -- Required settings if (!info.GetBool("MULTI_CONFIG", BaseConst_.MultiConfig, true) || @@ -1894,7 +2415,7 @@ bool cmQtAutoMocUic::InitFromInfo(InfoT const& info) } template -void cmQtAutoMocUic::CreateParseJobs(SourceFileMapT const& sourceMap) +void cmQtAutoMocUicT::CreateParseJobs(SourceFileMapT const& sourceMap) { cmFileTime const parseCacheTime = BaseEval().ParseCacheTime; ParseCacheT& parseCache = BaseEval().ParseCache; @@ -1911,13 +2432,13 @@ void cmQtAutoMocUic::CreateParseJobs(SourceFileMapT const& sourceMap) } /** Concurrently callable implementation of cmSystemTools::CollapseFullPath */ -std::string cmQtAutoMocUic::CollapseFullPathTS(std::string const& path) const +std::string cmQtAutoMocUicT::CollapseFullPathTS(std::string const& path) const { std::lock_guard guard(CMakeLibMutex_); return cmSystemTools::CollapseFullPath(path, ProjectDirs().CurrentSource); } -void cmQtAutoMocUic::InitJobs() +void cmQtAutoMocUicT::InitJobs() { // Add moc_predefs.h job if (MocConst().Enabled && !MocConst().PredefsCmd.empty()) { @@ -1944,7 +2465,7 @@ void cmQtAutoMocUic::InitJobs() } } -bool cmQtAutoMocUic::Process() +bool cmQtAutoMocUicT::Process() { SettingsFileRead(); ParseCacheRead(); @@ -1967,7 +2488,7 @@ bool cmQtAutoMocUic::Process() return true; } -void cmQtAutoMocUic::SettingsFileRead() +void cmQtAutoMocUicT::SettingsFileRead() { // Compose current settings strings { @@ -2046,7 +2567,7 @@ void cmQtAutoMocUic::SettingsFileRead() } } -bool cmQtAutoMocUic::SettingsFileWrite() +bool cmQtAutoMocUicT::SettingsFileWrite() { // Only write if any setting changed if (MocConst().SettingsChanged || UicConst().SettingsChanged) { @@ -2081,7 +2602,7 @@ bool cmQtAutoMocUic::SettingsFileWrite() return true; } -void cmQtAutoMocUic::ParseCacheRead() +void cmQtAutoMocUicT::ParseCacheRead() { cm::string_view reason; // Don't read the cache if it is invalid @@ -2107,7 +2628,7 @@ void cmQtAutoMocUic::ParseCacheRead() } } -bool cmQtAutoMocUic::ParseCacheWrite() +bool cmQtAutoMocUicT::ParseCacheWrite() { if (BaseEval().ParseCacheChanged) { if (Log().Verbose()) { @@ -2126,7 +2647,7 @@ bool cmQtAutoMocUic::ParseCacheWrite() return true; } -bool cmQtAutoMocUic::CreateDirectories() +bool cmQtAutoMocUicT::CreateDirectories() { // Create AUTOGEN include directory if (!cmSystemTools::MakeDirectory(BaseConst().AutogenIncludeDir)) { @@ -2139,7 +2660,7 @@ bool cmQtAutoMocUic::CreateDirectories() return true; } -void cmQtAutoMocUic::Abort(bool error) +void cmQtAutoMocUicT::Abort(bool error) { if (error) { JobError_.store(true); @@ -2147,14 +2668,21 @@ void cmQtAutoMocUic::Abort(bool error) WorkerPool_.Abort(); } -std::string cmQtAutoMocUic::AbsoluteBuildPath( +std::string cmQtAutoMocUicT::AbsoluteBuildPath( cm::string_view relativePath) const { return cmStrCat(BaseConst().AutogenBuildDir, '/', relativePath); } -std::string cmQtAutoMocUic::AbsoluteIncludePath( +std::string cmQtAutoMocUicT::AbsoluteIncludePath( cm::string_view relativePath) const { return cmStrCat(BaseConst().AutogenIncludeDir, '/', relativePath); } + +} // End of unnamed namespace + +bool cmQtAutoMocUic(cm::string_view infoFile, cm::string_view config) +{ + return cmQtAutoMocUicT().Run(infoFile, config); +} diff --git a/Source/cmQtAutoMocUic.h b/Source/cmQtAutoMocUic.h index 53946ef..ffcc2db 100644 --- a/Source/cmQtAutoMocUic.h +++ b/Source/cmQtAutoMocUic.h @@ -5,555 +5,12 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include "cmFileTime.h" -#include "cmQtAutoGen.h" -#include "cmQtAutoGenerator.h" -#include "cmWorkerPool.h" -#include "cmsys/RegularExpression.hxx" - #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/** \class cmQtAutoMocUic - * \brief AUTOMOC and AUTOUIC generator +/** + * Process AUTOMOC and AUTOUIC + * @return true on success */ -class cmQtAutoMocUic : public cmQtAutoGenerator -{ -public: - cmQtAutoMocUic(); - ~cmQtAutoMocUic() override; - - cmQtAutoMocUic(cmQtAutoMocUic const&) = delete; - cmQtAutoMocUic& operator=(cmQtAutoMocUic const&) = delete; - -public: - // -- Types - - /** Include string with sub parts. */ - struct IncludeKeyT - { - IncludeKeyT(std::string const& key, std::size_t basePrefixLength); - - std::string Key; // Full include string - std::string Dir; // Include directory - std::string Base; // Base part of the include file name - }; - - /** Search key plus regular expression pair. */ - struct KeyExpT - { - KeyExpT() = default; - - KeyExpT(std::string key, std::string const& exp) - : Key(std::move(key)) - , Exp(exp) - { - } - - std::string Key; - cmsys::RegularExpression Exp; - }; - - /** Source file parsing cache. */ - class ParseCacheT - { - public: - // -- Types - - /** Entry of the file parsing cache. */ - struct FileT - { - void Clear(); - - struct MocT - { - std::string Macro; - struct IncludeT - { - std::vector Underscore; - std::vector Dot; - } Include; - std::vector Depends; - } Moc; - - struct UicT - { - std::vector Include; - std::vector Depends; - } Uic; - }; - using FileHandleT = std::shared_ptr; - using GetOrInsertT = std::pair; - - public: - ParseCacheT(); - ~ParseCacheT(); - - void Clear(); - - bool ReadFromFile(std::string const& fileName); - bool WriteToFile(std::string const& fileName); - - //! Might return an invalid handle - FileHandleT Get(std::string const& fileName) const; - //! Always returns a valid handle - GetOrInsertT GetOrInsert(std::string const& fileName); - - private: - std::unordered_map Map_; - }; - - /** Source file data. */ - class SourceFileT - { - public: - SourceFileT(std::string fileName) - : FileName(std::move(fileName)) - { - } - - public: - std::string FileName; - cmFileTime FileTime; - ParseCacheT::FileHandleT ParseData; - std::string BuildPath; - bool IsHeader = false; - bool Moc = false; - bool Uic = false; - }; - using SourceFileHandleT = std::shared_ptr; - using SourceFileMapT = std::map; - - /** Meta compiler file mapping information. */ - struct MappingT - { - SourceFileHandleT SourceFile; - std::string OutputFile; - std::string IncludeString; - std::vector IncluderFiles; - }; - using MappingHandleT = std::shared_ptr; - using MappingMapT = std::map; - - /** Common settings. */ - class BaseSettingsT - { - public: - // -- Constructors - BaseSettingsT(); - ~BaseSettingsT(); - - BaseSettingsT(BaseSettingsT const&) = delete; - BaseSettingsT& operator=(BaseSettingsT const&) = delete; - - // -- Attributes - // - Config - bool MultiConfig = false; - unsigned int QtVersionMajor = 4; - unsigned int ThreadCount = 0; - // - Directories - std::string AutogenBuildDir; - std::string AutogenIncludeDir; - // - Files - std::string CMakeExecutable; - cmFileTime CMakeExecutableTime; - std::string ParseCacheFile; - std::vector HeaderExtensions; - }; - - /** Shared common variables. */ - class BaseEvalT - { - public: - // -- Parse Cache - bool ParseCacheChanged = false; - cmFileTime ParseCacheTime; - ParseCacheT ParseCache; - - // -- Sources - SourceFileMapT Headers; - SourceFileMapT Sources; - }; - - /** Moc settings. */ - class MocSettingsT - { - public: - // -- Constructors - MocSettingsT(); - ~MocSettingsT(); - - MocSettingsT(MocSettingsT const&) = delete; - MocSettingsT& operator=(MocSettingsT const&) = delete; - - // -- Const methods - bool skipped(std::string const& fileName) const; - std::string MacrosString() const; - - // -- Attributes - bool Enabled = false; - bool SettingsChanged = false; - bool RelaxedMode = false; - bool PathPrefix = false; - cmFileTime ExecutableTime; - std::string Executable; - std::string CompFileAbs; - std::string PredefsFileAbs; - std::unordered_set SkipList; - std::vector IncludePaths; - std::vector Definitions; - std::vector OptionsIncludes; - std::vector OptionsDefinitions; - std::vector OptionsExtra; - std::vector PredefsCmd; - std::vector DependFilters; - std::vector MacroFilters; - cmsys::RegularExpression RegExpInclude; - }; - - /** Moc shared variables. */ - class MocEvalT - { - public: - // -- predefines file - cmFileTime PredefsTime; - // -- Mappings - MappingMapT HeaderMappings; - MappingMapT SourceMappings; - MappingMapT Includes; - // -- Discovered files - SourceFileMapT HeadersDiscovered; - // -- Output directories - std::unordered_set OutputDirs; - // -- Mocs compilation - bool CompUpdated = false; - std::vector CompFiles; - }; - - /** Uic settings. */ - class UicSettingsT - { - public: - struct UiFile - { - std::vector Options; - }; - - public: - UicSettingsT(); - ~UicSettingsT(); - - UicSettingsT(UicSettingsT const&) = delete; - UicSettingsT& operator=(UicSettingsT const&) = delete; - - // -- Const methods - bool skipped(std::string const& fileName) const; - - // -- Attributes - bool Enabled = false; - bool SettingsChanged = false; - cmFileTime ExecutableTime; - std::string Executable; - std::unordered_set SkipList; - std::vector Options; - std::unordered_map UiFiles; - std::vector SearchPaths; - cmsys::RegularExpression RegExpInclude; - }; - - /** Uic shared variables. */ - class UicEvalT - { - public: - // -- Discovered files - SourceFileMapT UiFiles; - // -- Mappings - MappingMapT Includes; - // -- Output directories - std::unordered_set OutputDirs; - }; - - /** Abstract job class for concurrent job processing. */ - class JobT : public cmWorkerPool::JobT - { - protected: - /** Protected default constructor. */ - JobT(bool fence = false) - : cmWorkerPool::JobT(fence) - { - } - - //! Get the generator. Only valid during Process() call! - cmQtAutoMocUic* Gen() const - { - return static_cast(UserData()); - }; - - // -- Accessors. Only valid during Process() call! - Logger const& Log() const { return Gen()->Log(); } - BaseSettingsT const& BaseConst() const { return Gen()->BaseConst(); } - BaseEvalT& BaseEval() const { return Gen()->BaseEval(); } - MocSettingsT const& MocConst() const { return Gen()->MocConst(); } - MocEvalT& MocEval() const { return Gen()->MocEval(); } - UicSettingsT const& UicConst() const { return Gen()->UicConst(); } - UicEvalT& UicEval() const { return Gen()->UicEval(); } - - // -- Logging - std::string MessagePath(cm::string_view path) const - { - return Gen()->MessagePath(path); - } - // - Error logging with automatic abort - void LogError(GenT genType, cm::string_view message) const; - void LogCommandError(GenT genType, cm::string_view message, - std::vector const& command, - std::string const& output) const; - - /** @brief Run an external process. Use only during Process() call! */ - bool RunProcess(GenT genType, cmWorkerPool::ProcessResultT& result, - std::vector const& command, - std::string* infoMessage = nullptr); - }; - - /** Fence job utility class. */ - class JobFenceT : public JobT - { - public: - JobFenceT() - : JobT(true) - { - } - void Process() override{}; - }; - - /** Generate moc_predefs.h. */ - class JobMocPredefsT : public JobFenceT - { - void Process() override; - bool Update(std::string* reason) const; - }; - - /** File parse job base class. */ - class JobParseT : public JobT - { - public: - JobParseT(SourceFileHandleT fileHandle) - : FileHandle(std::move(fileHandle)) - { - } - - protected: - bool ReadFile(); - void CreateKeys(std::vector& container, - std::set const& source, - std::size_t basePrefixLength); - void MocMacro(); - void MocDependecies(); - void MocIncludes(); - void UicIncludes(); - - protected: - SourceFileHandleT FileHandle; - std::string Content; - }; - - /** Header file parse job. */ - class JobParseHeaderT : public JobParseT - { - public: - using JobParseT::JobParseT; - void Process() override; - }; - - /** Source file parse job. */ - class JobParseSourceT : public JobParseT - { - public: - using JobParseT::JobParseT; - void Process() override; - }; - - /** Evaluate cached file parse data - moc. */ - class JobEvalCacheT : public JobT - { - protected: - std::string MessageSearchLocations() const; - std::vector SearchLocations; - }; - - /** Evaluate cached file parse data - moc. */ - class JobEvalCacheMocT : public JobEvalCacheT - { - void Process() override; - bool EvalHeader(SourceFileHandleT source); - bool EvalSource(SourceFileHandleT const& source); - bool FindIncludedHeader(SourceFileHandleT& headerHandle, - cm::string_view includerDir, - cm::string_view includeBase); - bool RegisterIncluded(std::string const& includeString, - SourceFileHandleT includerFileHandle, - SourceFileHandleT sourceFileHandle) const; - void RegisterMapping(MappingHandleT mappingHandle) const; - std::string MessageHeader(cm::string_view headerBase) const; - }; - - /** Evaluate cached file parse data - uic. */ - class JobEvalCacheUicT : public JobEvalCacheT - { - void Process() override; - bool EvalFile(SourceFileHandleT const& sourceFileHandle); - bool FindIncludedUi(cm::string_view sourceDirPrefix, - cm::string_view includePrefix); - bool RegisterMapping(std::string const& includeString, - SourceFileHandleT includerFileHandle); - - std::string UiName; - SourceFileHandleT UiFileHandle; - }; - - /** Evaluate cached file parse data - finish */ - class JobEvalCacheFinishT : public JobFenceT - { - void Process() override; - }; - - /** Dependency probing base job. */ - class JobProbeDepsT : public JobT - { - }; - - /** Probes file dependencies and generates moc compile jobs. */ - class JobProbeDepsMocT : public JobProbeDepsT - { - void Process() override; - bool Generate(MappingHandleT const& mapping, bool compFile) const; - bool Probe(MappingT const& mapping, std::string* reason) const; - std::pair FindDependency( - std::string const& sourceDir, std::string const& includeString) const; - }; - - /** Probes file dependencies and generates uic compile jobs. */ - class JobProbeDepsUicT : public JobProbeDepsT - { - void Process() override; - bool Probe(MappingT const& mapping, std::string* reason) const; - }; - - /** Dependency probing finish job. */ - class JobProbeDepsFinishT : public JobFenceT - { - void Process() override; - }; - - /** Meta compiler base job. */ - class JobCompileT : public JobT - { - public: - JobCompileT(MappingHandleT uicMapping, std::unique_ptr reason) - : Mapping(std::move(uicMapping)) - , Reason(std::move(reason)) - { - } - - protected: - MappingHandleT Mapping; - std::unique_ptr Reason; - }; - - /** moc compiles a file. */ - class JobCompileMocT : public JobCompileT - { - public: - using JobCompileT::JobCompileT; - void Process() override; - }; - - /** uic compiles a file. */ - class JobCompileUicT : public JobCompileT - { - public: - using JobCompileT::JobCompileT; - void Process() override; - }; - - /** Generate mocs_compilation.cpp. */ - class JobMocsCompilationT : public JobFenceT - { - private: - void Process() override; - }; - - /** @brief The last job. */ - class JobFinishT : public JobFenceT - { - private: - void Process() override; - }; - - // -- Const settings interface - BaseSettingsT const& BaseConst() const { return this->BaseConst_; } - BaseEvalT& BaseEval() { return this->BaseEval_; } - MocSettingsT const& MocConst() const { return this->MocConst_; } - MocEvalT& MocEval() { return this->MocEval_; } - UicSettingsT const& UicConst() const { return this->UicConst_; } - UicEvalT& UicEval() { return this->UicEval_; } - - // -- Parallel job processing interface - cmWorkerPool& WorkerPool() { return WorkerPool_; } - void AbortError() { Abort(true); } - void AbortSuccess() { Abort(false); } - - // -- Utility - std::string AbsoluteBuildPath(cm::string_view relativePath) const; - std::string AbsoluteIncludePath(cm::string_view relativePath) const; - template - void CreateParseJobs(SourceFileMapT const& sourceMap); - std::string CollapseFullPathTS(std::string const& path) const; - -private: - // -- Abstract processing interface - bool InitFromInfo(InfoT const& info) override; - void InitJobs(); - bool Process() override; - // -- Settings file - void SettingsFileRead(); - bool SettingsFileWrite(); - // -- Parse cache - void ParseCacheRead(); - bool ParseCacheWrite(); - // -- Thread processing - void Abort(bool error); - // -- Generation - bool CreateDirectories(); - -private: - // -- Settings - BaseSettingsT BaseConst_; - BaseEvalT BaseEval_; - MocSettingsT MocConst_; - MocEvalT MocEval_; - UicSettingsT UicConst_; - UicEvalT UicEval_; - // -- Settings file - std::string SettingsFile_; - std::string SettingsStringMoc_; - std::string SettingsStringUic_; - // -- Worker thread pool - std::atomic JobError_ = ATOMIC_VAR_INIT(false); - cmWorkerPool WorkerPool_; - // -- Concurrent processing - mutable std::mutex CMakeLibMutex_; -}; +bool cmQtAutoMocUic(cm::string_view infoFile, cm::string_view config); #endif diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index f075e21..7bb3dce 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -27,6 +27,7 @@ #if !defined(CMAKE_BOOTSTRAP) && defined(_WIN32) # include "bindexplib.h" +# include "cmFileTime.h" # include "cmsys/ConsoleBuf.hxx" #endif @@ -1059,10 +1060,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args) #ifndef CMAKE_BOOTSTRAP if ((args[1] == "cmake_autogen") && (args.size() >= 4)) { - cmQtAutoMocUic autoGen; cm::string_view const infoFile = args[2]; cm::string_view const config = args[3]; - return autoGen.Run(infoFile, config) ? 0 : 1; + return cmQtAutoMocUic(infoFile, config) ? 0 : 1; } if ((args[1] == "cmake_autorcc") && (args.size() >= 3)) { cm::string_view const infoFile = args[2]; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e0e9be3d575a255add19169d174c869fdebebbeb commit e0e9be3d575a255add19169d174c869fdebebbeb Author: Sebastian Holtermann AuthorDate: Fri Sep 27 15:49:13 2019 +0200 Commit: Sebastian Holtermann CommitDate: Sun Sep 29 00:07:32 2019 +0200 Autogen: Make cmQtAutoRcc a free function diff --git a/Source/cmQtAutoRcc.cxx b/Source/cmQtAutoRcc.cxx index 579cda7..4a3ecfa 100644 --- a/Source/cmQtAutoRcc.cxx +++ b/Source/cmQtAutoRcc.cxx @@ -5,23 +5,91 @@ #include "cmAlgorithms.h" #include "cmCryptoHash.h" #include "cmDuration.h" +#include "cmFileLock.h" #include "cmFileLockResult.h" +#include "cmFileTime.h" #include "cmProcessOutput.h" #include "cmQtAutoGen.h" +#include "cmQtAutoGenerator.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include - #include +#include +#include + +namespace { -cmQtAutoRcc::cmQtAutoRcc() +/** \class cmQtAutoRccT + * \brief AUTORCC generator + */ +class cmQtAutoRccT : public cmQtAutoGenerator +{ +public: + cmQtAutoRccT(); + ~cmQtAutoRccT() override; + + cmQtAutoRccT(cmQtAutoRccT const&) = delete; + cmQtAutoRccT& operator=(cmQtAutoRccT const&) = delete; + +private: + // -- Utility + bool IsMultiConfig() const { return MultiConfig_; } + std::string MultiConfigOutput() const; + + // -- Abstract processing interface + bool InitFromInfo(InfoT const& info) override; + bool Process() override; + // -- Settings file + bool SettingsFileRead(); + bool SettingsFileWrite(); + // -- Tests + bool TestQrcRccFiles(bool& generate); + bool TestResources(bool& generate); + bool TestInfoFile(); + // -- Generation + bool GenerateRcc(); + bool GenerateWrapper(); + +private: + // -- Config settings + bool MultiConfig_ = false; + // -- Directories + std::string AutogenBuildDir_; + std::string IncludeDir_; + // -- Qt environment + std::string RccExecutable_; + cmFileTime RccExecutableTime_; + std::vector RccListOptions_; + // -- Job + std::string LockFile_; + cmFileLock LockFileLock_; + std::string QrcFile_; + std::string QrcFileName_; + std::string QrcFileDir_; + cmFileTime QrcFileTime_; + std::string RccPathChecksum_; + std::string RccFileName_; + std::string RccFileOutput_; + std::string RccFilePublic_; + cmFileTime RccFileTime_; + std::string Reason; + std::vector Options_; + std::vector Inputs_; + // -- Settings file + std::string SettingsFile_; + std::string SettingsString_; + bool SettingsChanged_ = false; + bool BuildFileChanged_ = false; +}; + +cmQtAutoRccT::cmQtAutoRccT() : cmQtAutoGenerator(GenT::RCC) { } -cmQtAutoRcc::~cmQtAutoRcc() = default; +cmQtAutoRccT::~cmQtAutoRccT() = default; -bool cmQtAutoRcc::InitFromInfo(InfoT const& info) +bool cmQtAutoRccT::InitFromInfo(InfoT const& info) { // -- Required settings if (!info.GetBool("MULTI_CONFIG", MultiConfig_, true) || @@ -61,7 +129,7 @@ bool cmQtAutoRcc::InitFromInfo(InfoT const& info) return true; } -bool cmQtAutoRcc::Process() +bool cmQtAutoRccT::Process() { if (!SettingsFileRead()) { return false; @@ -94,13 +162,13 @@ bool cmQtAutoRcc::Process() return SettingsFileWrite(); } -std::string cmQtAutoRcc::MultiConfigOutput() const +std::string cmQtAutoRccT::MultiConfigOutput() const { return cmStrCat(RccPathChecksum_, '/', AppendFilenameSuffix(RccFileName_, "_CMAKE_")); } -bool cmQtAutoRcc::SettingsFileRead() +bool cmQtAutoRccT::SettingsFileRead() { // Compose current settings strings { @@ -178,7 +246,7 @@ bool cmQtAutoRcc::SettingsFileRead() return true; } -bool cmQtAutoRcc::SettingsFileWrite() +bool cmQtAutoRccT::SettingsFileWrite() { // Only write if any setting changed if (SettingsChanged_) { @@ -205,7 +273,7 @@ bool cmQtAutoRcc::SettingsFileWrite() } /// Do basic checks if rcc generation is required -bool cmQtAutoRcc::TestQrcRccFiles(bool& generate) +bool cmQtAutoRccT::TestQrcRccFiles(bool& generate) { // Test if the rcc input file exists if (!QrcFileTime_.Load(QrcFile_)) { @@ -262,7 +330,7 @@ bool cmQtAutoRcc::TestQrcRccFiles(bool& generate) return true; } -bool cmQtAutoRcc::TestResources(bool& generate) +bool cmQtAutoRccT::TestResources(bool& generate) { // Read resource files list if (Inputs_.empty()) { @@ -301,7 +369,7 @@ bool cmQtAutoRcc::TestResources(bool& generate) return true; } -bool cmQtAutoRcc::TestInfoFile() +bool cmQtAutoRccT::TestInfoFile() { // Test if the rcc output file is older than the info file if (RccFileTime_.Older(InfoFileTime())) { @@ -324,7 +392,7 @@ bool cmQtAutoRcc::TestInfoFile() return true; } -bool cmQtAutoRcc::GenerateRcc() +bool cmQtAutoRccT::GenerateRcc() { // Make parent directory if (!MakeParentDirectory(RccFileOutput_)) { @@ -376,7 +444,7 @@ bool cmQtAutoRcc::GenerateRcc() return true; } -bool cmQtAutoRcc::GenerateWrapper() +bool cmQtAutoRccT::GenerateWrapper() { // Generate a wrapper source file on demand if (IsMultiConfig()) { @@ -426,3 +494,10 @@ bool cmQtAutoRcc::GenerateWrapper() } return true; } + +} // End of unnamed namespace + +bool cmQtAutoRcc(cm::string_view infoFile, cm::string_view config) +{ + return cmQtAutoRccT().Run(infoFile, config); +} diff --git a/Source/cmQtAutoRcc.h b/Source/cmQtAutoRcc.h index 33c7960..a74b33a 100644 --- a/Source/cmQtAutoRcc.h +++ b/Source/cmQtAutoRcc.h @@ -5,74 +5,12 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include "cmFileLock.h" -#include "cmFileTime.h" -#include "cmQtAutoGenerator.h" +#include -#include -#include - -/** \class cmQtAutoRcc - * \brief AUTORCC generator +/** + * Process AUTORCC + * @return true on success */ -class cmQtAutoRcc : public cmQtAutoGenerator -{ -public: - cmQtAutoRcc(); - ~cmQtAutoRcc() override; - - cmQtAutoRcc(cmQtAutoRcc const&) = delete; - cmQtAutoRcc& operator=(cmQtAutoRcc const&) = delete; - -private: - // -- Utility - bool IsMultiConfig() const { return MultiConfig_; } - std::string MultiConfigOutput() const; - - // -- Abstract processing interface - bool InitFromInfo(InfoT const& info) override; - bool Process() override; - // -- Settings file - bool SettingsFileRead(); - bool SettingsFileWrite(); - // -- Tests - bool TestQrcRccFiles(bool& generate); - bool TestResources(bool& generate); - bool TestInfoFile(); - // -- Generation - bool GenerateRcc(); - bool GenerateWrapper(); - -private: - // -- Config settings - bool MultiConfig_ = false; - // -- Directories - std::string AutogenBuildDir_; - std::string IncludeDir_; - // -- Qt environment - std::string RccExecutable_; - cmFileTime RccExecutableTime_; - std::vector RccListOptions_; - // -- Job - std::string LockFile_; - cmFileLock LockFileLock_; - std::string QrcFile_; - std::string QrcFileName_; - std::string QrcFileDir_; - cmFileTime QrcFileTime_; - std::string RccPathChecksum_; - std::string RccFileName_; - std::string RccFileOutput_; - std::string RccFilePublic_; - cmFileTime RccFileTime_; - std::string Reason; - std::vector Options_; - std::vector Inputs_; - // -- Settings file - std::string SettingsFile_; - std::string SettingsString_; - bool SettingsChanged_ = false; - bool BuildFileChanged_ = false; -}; +bool cmQtAutoRcc(cm::string_view infoFile, cm::string_view config); #endif diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index b6076db..f075e21 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -1065,11 +1065,10 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args) return autoGen.Run(infoFile, config) ? 0 : 1; } if ((args[1] == "cmake_autorcc") && (args.size() >= 3)) { - cmQtAutoRcc autoRcc; cm::string_view const infoFile = args[2]; cm::string_view const config = (args.size() > 3) ? cm::string_view(args[3]) : cm::string_view(); - return autoRcc.Run(infoFile, config) ? 0 : 1; + return cmQtAutoRcc(infoFile, config) ? 0 : 1; } #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=820962edc9dd7481c440068dd894c1026abf671d commit 820962edc9dd7481c440068dd894c1026abf671d Author: Sebastian Holtermann AuthorDate: Fri Sep 27 14:47:05 2019 +0200 Commit: Sebastian Holtermann CommitDate: Sun Sep 29 00:07:32 2019 +0200 Autogen: Refactor json info file reading interface diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx index a9d4fee..1320b07 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -210,79 +210,18 @@ cmQtAutoGenerator::cmQtAutoGenerator(GenT genType) cmQtAutoGenerator::~cmQtAutoGenerator() = default; -bool cmQtAutoGenerator::Run(std::string const& infoFile, - std::string const& config) +bool cmQtAutoGenerator::InfoT::Read(std::istream& istr) { - // Info settings - InfoFile_ = infoFile; - cmSystemTools::CollapseFullPath(InfoFile_); - if (!InfoFileTime_.Load(InfoFile_)) { - cmSystemTools::Stderr(cmStrCat("AutoGen: The info file ", - Quoted(InfoFile_), " is not readable\n")); - return false; - } - InfoDir_ = cmSystemTools::GetFilenamePath(infoFile); - InfoConfig_ = config; - - // Read info file - { - cmsys::ifstream ifs(InfoFile_.c_str(), (std::ios::in | std::ios::binary)); - if (!ifs) { - Log().Error(GenType_, - cmStrCat("Could not to open info file ", Quoted(InfoFile_))); - return false; - } - try { - ifs >> Info_; - } catch (...) { - Log().Error(GenType_, - cmStrCat("Could not read info file ", Quoted(InfoFile_))); - return false; - } - } - // Info: setup logger - { - unsigned int value = 0; - if (!InfoUInt("VERBOSITY", value, false)) { - return false; - } - Logger_.RaiseVerbosity(value); - } - // Info: setup project directories - if (!InfoString("CMAKE_SOURCE_DIR", ProjectDirs_.Source, true) || - !InfoString("CMAKE_BINARY_DIR", ProjectDirs_.Binary, true) || - !InfoString("CMAKE_CURRENT_SOURCE_DIR", ProjectDirs_.CurrentSource, - true) || - !InfoString("CMAKE_CURRENT_BINARY_DIR", ProjectDirs_.CurrentBinary, - true)) { - return false; - } - - if (!this->InitFromInfo()) { + try { + istr >> Json_; + } catch (...) { return false; } - // Clear info - Info_ = Json::nullValue; - - return this->Process(); -} - -bool cmQtAutoGenerator::LogInfoError(GenT genType, - cm::string_view message) const -{ - this->Log().Error( - genType, - cmStrCat("Info error in info file\n", Quoted(InfoFile()), ":\n", message)); - return false; -} - -bool cmQtAutoGenerator::LogInfoError(cm::string_view message) const -{ - return LogInfoError(GenType_, message); + return true; } -bool cmQtAutoGenerator::JsonGetArray(std::vector& list, - Json::Value const& jval) +bool cmQtAutoGenerator::InfoT::GetJsonArray(std::vector& list, + Json::Value const& jval) { Json::ArrayIndex const arraySize = jval.size(); if (arraySize == 0) { @@ -301,8 +240,8 @@ bool cmQtAutoGenerator::JsonGetArray(std::vector& list, return picked; } -bool cmQtAutoGenerator::JsonGetArray(std::unordered_set& list, - Json::Value const& jval) +bool cmQtAutoGenerator::InfoT::GetJsonArray( + std::unordered_set& list, Json::Value const& jval) { Json::ArrayIndex const arraySize = jval.size(); if (arraySize == 0) { @@ -321,141 +260,157 @@ bool cmQtAutoGenerator::JsonGetArray(std::unordered_set& list, return picked; } -std::string cmQtAutoGenerator::InfoConfigKey(std::string const& key) const +std::string cmQtAutoGenerator::InfoT::ConfigKey(cm::string_view key) const { - return cmStrCat(key, '_', InfoConfig()); + return cmStrCat(key, '_', Gen_.InfoConfig()); } -bool cmQtAutoGenerator::InfoString(std::string const& key, std::string& value, - bool required) const +bool cmQtAutoGenerator::InfoT::GetString(std::string const& key, + std::string& value, + bool required) const { - Json::Value const& jval = Info()[key]; + Json::Value const& jval = Json_[key]; if (!jval.isString()) { if (!jval.isNull() || required) { - return LogInfoError(cmStrCat(key, " is not a string.")); + return LogError(cmStrCat(key, " is not a string.")); } } else { value = jval.asString(); if (value.empty() && required) { - return LogInfoError(cmStrCat(key, " is empty.")); + return LogError(cmStrCat(key, " is empty.")); } } return true; } -bool cmQtAutoGenerator::InfoStringConfig(std::string const& key, - std::string& value, - - bool required) const +bool cmQtAutoGenerator::InfoT::GetStringConfig(std::string const& key, + std::string& value, + bool required) const { { // Try config - std::string const configKey = InfoConfigKey(key); - Json::Value const& jval = Info_[configKey]; + std::string const configKey = ConfigKey(key); + Json::Value const& jval = Json_[configKey]; if (!jval.isNull()) { if (!jval.isString()) { - return LogInfoError(cmStrCat(configKey, " is not a string.")); + return LogError(cmStrCat(configKey, " is not a string.")); } value = jval.asString(); if (required && value.empty()) { - return LogInfoError(cmStrCat(configKey, " is empty.")); + return LogError(cmStrCat(configKey, " is empty.")); } return true; } } // Try plain - return InfoString(key, value, required); + return GetString(key, value, required); } -bool cmQtAutoGenerator::InfoBool(std::string const& key, bool& value, - bool required) const +bool cmQtAutoGenerator::InfoT::GetBool(std::string const& key, bool& value, + bool required) const { - Json::Value const& jval = Info()[key]; + Json::Value const& jval = Json_[key]; if (jval.isBool()) { value = jval.asBool(); } else { if (!jval.isNull() || required) { - return LogInfoError(cmStrCat(key, " is not a boolean.")); + return LogError(cmStrCat(key, " is not a boolean.")); } } return true; } -bool cmQtAutoGenerator::InfoUInt(std::string const& key, unsigned int& value, - bool required) const +bool cmQtAutoGenerator::InfoT::GetUInt(std::string const& key, + unsigned int& value, + bool required) const { - Json::Value const& jval = Info()[key]; + Json::Value const& jval = Json_[key]; if (jval.isUInt()) { value = jval.asUInt(); } else { if (!jval.isNull() || required) { - return LogInfoError(cmStrCat(key, " is not an unsigned integer.")); + return LogError(cmStrCat(key, " is not an unsigned integer.")); } } return true; } -bool cmQtAutoGenerator::InfoArray(std::string const& key, - std::vector& list, - bool required) const +bool cmQtAutoGenerator::InfoT::GetArray(std::string const& key, + std::vector& list, + bool required) const { - Json::Value const& jval = Info()[key]; + Json::Value const& jval = Json_[key]; if (!jval.isArray()) { if (!jval.isNull() || required) { - return LogInfoError(cmStrCat(key, " is not an array.")); + return LogError(cmStrCat(key, " is not an array.")); } } - return JsonGetArray(list, jval) || !required; + return GetJsonArray(list, jval) || !required; } -bool cmQtAutoGenerator::InfoArray(std::string const& key, - std::unordered_set& list, - bool required) const +bool cmQtAutoGenerator::InfoT::GetArray(std::string const& key, + std::unordered_set& list, + bool required) const { - Json::Value const& jval = Info()[key]; + Json::Value const& jval = Json_[key]; if (!jval.isArray()) { if (!jval.isNull() || required) { - return LogInfoError(cmStrCat(key, " is not an array.")); + return LogError(cmStrCat(key, " is not an array.")); } } - return JsonGetArray(list, jval) || !required; + return GetJsonArray(list, jval) || !required; } -bool cmQtAutoGenerator::InfoArrayConfig(std::string const& key, - std::vector& list, - bool required) const +bool cmQtAutoGenerator::InfoT::GetArrayConfig(std::string const& key, + std::vector& list, + bool required) const { { // Try config - std::string const configKey = InfoConfigKey(key); - Json::Value const& jval = Info()[configKey]; + std::string const configKey = ConfigKey(key); + Json::Value const& jval = Json_[configKey]; if (!jval.isNull()) { if (!jval.isArray()) { - return LogInfoError(cmStrCat(configKey, " is not an array string.")); + return LogError(cmStrCat(configKey, " is not an array string.")); } - if (!JsonGetArray(list, jval) && required) { - return LogInfoError(cmStrCat(configKey, " is empty.")); + if (!GetJsonArray(list, jval) && required) { + return LogError(cmStrCat(configKey, " is empty.")); } return true; } } // Try plain - return InfoArray(key, list, required); + return GetArray(key, list, required); +} + +bool cmQtAutoGenerator::InfoT::LogError(GenT genType, + cm::string_view message) const +{ + Gen_.Log().Error(genType, + cmStrCat("Info error in info file\n", + Quoted(Gen_.InfoFile()), ":\n", message)); + return false; } -std::string cmQtAutoGenerator::SettingsFind(std::string const& content, - const char* key) +bool cmQtAutoGenerator::InfoT::LogError(cm::string_view message) const { - std::string prefix = cmStrCat(key, ':'); - std::string::size_type pos = content.find(prefix); - if (pos != std::string::npos) { + return LogError(Gen_.GenType_, message); +} + +std::string cmQtAutoGenerator::SettingsFind(cm::string_view content, + cm::string_view key) +{ + cm::string_view res; + std::string const prefix = cmStrCat(key, ':'); + cm::string_view::size_type pos = content.find(prefix); + if (pos != cm::string_view::npos) { pos += prefix.size(); if (pos < content.size()) { - std::string::size_type posE = content.find('\n', pos); - if ((posE != std::string::npos) && (posE != pos)) { - return content.substr(pos, posE - pos); + cm::string_view::size_type posE = content.find('\n', pos); + if ((posE != cm::string_view::npos) && (posE != pos)) { + res = content.substr(pos, posE - pos); } } } - return std::string(); + return std::string(res); } std::string cmQtAutoGenerator::MessagePath(cm::string_view path) const @@ -470,3 +425,66 @@ std::string cmQtAutoGenerator::MessagePath(cm::string_view path) const } return cmQtAutoGen::Quoted(res); } + +bool cmQtAutoGenerator::Run(cm::string_view infoFile, cm::string_view config) +{ + // Info config + InfoConfig_ = std::string(config); + + // Info file + InfoFile_ = std::string(infoFile); + cmSystemTools::CollapseFullPath(InfoFile_); + InfoDir_ = cmSystemTools::GetFilenamePath(InfoFile_); + + // Load info file time + if (!InfoFileTime_.Load(InfoFile_)) { + cmSystemTools::Stderr(cmStrCat("AutoGen: The info file ", + Quoted(InfoFile_), " is not readable\n")); + return false; + } + + { + InfoT info(*this); + + // Read info file + { + cmsys::ifstream ifs(InfoFile_.c_str(), + (std::ios::in | std::ios::binary)); + if (!ifs) { + Log().Error( + GenType_, + cmStrCat("Could not to open info file ", Quoted(InfoFile_))); + return false; + } + if (!info.Read(ifs)) { + Log().Error(GenType_, + cmStrCat("Could not read info file ", Quoted(InfoFile_))); + return false; + } + } + + // -- Read common info settings + { + unsigned int verbosity = 0; + // Info: setup project directories + if (!info.GetUInt("VERBOSITY", verbosity, false) || + !info.GetString("CMAKE_SOURCE_DIR", ProjectDirs_.Source, true) || + !info.GetString("CMAKE_BINARY_DIR", ProjectDirs_.Binary, true) || + !info.GetString("CMAKE_CURRENT_SOURCE_DIR", + ProjectDirs_.CurrentSource, true) || + !info.GetString("CMAKE_CURRENT_BINARY_DIR", + ProjectDirs_.CurrentBinary, true)) { + return false; + } + Logger_.RaiseVerbosity(verbosity); + } + + // -- Call virtual init from info method. + if (!this->InitFromInfo(info)) { + return false; + } + } + + // Call virtual process method. + return this->Process(); +} diff --git a/Source/cmQtAutoGenerator.h b/Source/cmQtAutoGenerator.h index 7f83fc6..71ee9ce 100644 --- a/Source/cmQtAutoGenerator.h +++ b/Source/cmQtAutoGenerator.h @@ -11,6 +11,7 @@ #include +#include #include #include #include @@ -86,54 +87,78 @@ public: cmQtAutoGenerator(cmQtAutoGenerator const&) = delete; cmQtAutoGenerator& operator=(cmQtAutoGenerator const&) = delete; - // -- Run - bool Run(std::string const& infoFile, std::string const& config); - - // -- InfoFile + // -- Info options std::string const& InfoFile() const { return InfoFile_; } - Json::Value const& Info() const { return Info_; } - cmFileTime const& InfoFileTime() const { return InfoFileTime_; } std::string const& InfoDir() const { return InfoDir_; } + cmFileTime const& InfoFileTime() const { return InfoFileTime_; } std::string const& InfoConfig() const { return InfoConfig_; } - bool LogInfoError(GenT genType, cm::string_view message) const; - bool LogInfoError(cm::string_view message) const; + // -- Info file parsing + /** Info file reader class. */ + class InfoT + { + public: + InfoT(cmQtAutoGenerator& gen) + : Gen_(gen) + { + } + + /** Read json data from a stream. */ + bool Read(std::istream& istr); + + /** Returns false if the JSON value isn't a string. */ + bool GetString(std::string const& key, std::string& value, + bool required) const; + bool GetStringConfig(std::string const& key, std::string& value, + bool required) const; + bool GetBool(std::string const& key, bool& value, bool required) const; + bool GetUInt(std::string const& key, unsigned int& value, + bool required) const; + /** Returns false if the JSON value isn't an array. */ + bool GetArray(std::string const& key, std::vector& list, + bool required) const; + bool GetArray(std::string const& key, + std::unordered_set& list, bool required) const; + bool GetArrayConfig(std::string const& key, std::vector& list, + bool required) const; - /** Returns true if strings were appended to the list. */ - static bool JsonGetArray(std::vector& list, - Json::Value const& jval); - /** Returns true if strings were found in the JSON array. */ - static bool JsonGetArray(std::unordered_set& list, - Json::Value const& jval); + Json::Value const& GetValue(std::string const& key) const + { + return Json_[key]; + } - std::string InfoConfigKey(std::string const& key) const; + /** Returns true if strings were appended to the list. */ + static bool GetJsonArray(std::vector& list, + Json::Value const& jval); + /** Returns true if strings were found in the JSON array. */ + static bool GetJsonArray(std::unordered_set& list, + Json::Value const& jval); - /** Returns false if the JSON value isn't a string. */ - bool InfoString(std::string const& key, std::string& value, - bool required) const; - bool InfoStringConfig(std::string const& key, std::string& value, - bool required) const; - bool InfoBool(std::string const& key, bool& value, bool required) const; - bool InfoUInt(std::string const& key, unsigned int& value, - bool required) const; - /** Returns false if the JSON value isn't an array. */ - bool InfoArray(std::string const& key, std::vector& list, - bool required) const; - bool InfoArray(std::string const& key, std::unordered_set& list, - bool required) const; - bool InfoArrayConfig(std::string const& key, std::vector& list, - bool required) const; + bool LogError(GenT genType, cm::string_view message) const; + bool LogError(cm::string_view message) const; + + private: + std::string ConfigKey(cm::string_view key) const; + + private: + Json::Value Json_; + cmQtAutoGenerator& Gen_; + }; + + // -- Settings file + static std::string SettingsFind(cm::string_view content, + cm::string_view key); // -- Directories ProjectDirsT const& ProjectDirs() const { return ProjectDirs_; } - - // -- Utility - static std::string SettingsFind(std::string const& content, const char* key); std::string MessagePath(cm::string_view path) const; + // -- Run + bool Run(cm::string_view infoFile, cm::string_view config); + protected: // -- Abstract processing interface - virtual bool InitFromInfo() = 0; + virtual bool InitFromInfo(InfoT const& info) = 0; virtual bool Process() = 0; // - Utility classes Logger const& Log() const { return Logger_; } @@ -145,10 +170,9 @@ private: Logger Logger_; // -- Info file std::string InfoFile_; - cmFileTime InfoFileTime_; std::string InfoDir_; + cmFileTime InfoFileTime_; std::string InfoConfig_; - Json::Value Info_; // -- Directories ProjectDirsT ProjectDirs_; }; diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 5f3cd5f..ab91af4 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -1557,28 +1557,30 @@ cmQtAutoMocUic::cmQtAutoMocUic() } cmQtAutoMocUic::~cmQtAutoMocUic() = default; -bool cmQtAutoMocUic::InitFromInfo() +bool cmQtAutoMocUic::InitFromInfo(InfoT const& info) { // -- Required settings - if (!InfoBool("MULTI_CONFIG", BaseConst_.MultiConfig, true) || - !InfoUInt("QT_VERSION_MAJOR", BaseConst_.QtVersionMajor, true) || - !InfoUInt("PARALLEL", BaseConst_.ThreadCount, false) || - !InfoString("BUILD_DIR", BaseConst_.AutogenBuildDir, true) || - !InfoStringConfig("INCLUDE_DIR", BaseConst_.AutogenIncludeDir, true) || - !InfoString("CMAKE_EXECUTABLE", BaseConst_.CMakeExecutable, true) || - !InfoStringConfig("PARSE_CACHE_FILE", BaseConst_.ParseCacheFile, true) || - !InfoStringConfig("SETTINGS_FILE", SettingsFile_, true) || - !InfoArray("HEADER_EXTENSIONS", BaseConst_.HeaderExtensions, true) || - !InfoString("QT_MOC_EXECUTABLE", MocConst_.Executable, false) || - !InfoString("QT_UIC_EXECUTABLE", UicConst_.Executable, false)) { + if (!info.GetBool("MULTI_CONFIG", BaseConst_.MultiConfig, true) || + !info.GetUInt("QT_VERSION_MAJOR", BaseConst_.QtVersionMajor, true) || + !info.GetUInt("PARALLEL", BaseConst_.ThreadCount, false) || + !info.GetString("BUILD_DIR", BaseConst_.AutogenBuildDir, true) || + !info.GetStringConfig("INCLUDE_DIR", BaseConst_.AutogenIncludeDir, + true) || + !info.GetString("CMAKE_EXECUTABLE", BaseConst_.CMakeExecutable, true) || + !info.GetStringConfig("PARSE_CACHE_FILE", BaseConst_.ParseCacheFile, + true) || + !info.GetStringConfig("SETTINGS_FILE", SettingsFile_, true) || + !info.GetArray("HEADER_EXTENSIONS", BaseConst_.HeaderExtensions, true) || + !info.GetString("QT_MOC_EXECUTABLE", MocConst_.Executable, false) || + !info.GetString("QT_UIC_EXECUTABLE", UicConst_.Executable, false)) { return false; } // -- Checks if (!BaseConst_.CMakeExecutableTime.Load(BaseConst_.CMakeExecutable)) { - return LogInfoError(cmStrCat("The CMake executable ", - MessagePath(BaseConst_.CMakeExecutable), - " does not exist.")); + return info.LogError(cmStrCat("The CMake executable ", + MessagePath(BaseConst_.CMakeExecutable), + " does not exist.")); } // -- Evaluate values @@ -1598,19 +1600,20 @@ bool cmQtAutoMocUic::InitFromInfo() } tmp; // -- Required settings - if (!InfoBool("MOC_RELAXED_MODE", MocConst_.RelaxedMode, false) || - !InfoBool("MOC_PATH_PREFIX", MocConst_.PathPrefix, true) || - !InfoArray("MOC_SKIP", MocConst_.SkipList, false) || - !InfoArrayConfig("MOC_DEFINITIONS", MocConst_.Definitions, false) || - !InfoArrayConfig("MOC_INCLUDES", MocConst_.IncludePaths, false) || - !InfoArray("MOC_OPTIONS", MocConst_.OptionsExtra, false) || - !InfoStringConfig("MOC_COMPILATION_FILE", MocConst_.CompFileAbs, - true) || - !InfoArray("MOC_PREDEFS_CMD", MocConst_.PredefsCmd, false) || - !InfoStringConfig("MOC_PREDEFS_FILE", MocConst_.PredefsFileAbs, - !MocConst_.PredefsCmd.empty()) || - !InfoArray("MOC_MACRO_NAMES", tmp.MacroNames, true) || - !InfoArray("MOC_DEPEND_FILTERS", tmp.DependFilters, false)) { + if (!info.GetBool("MOC_RELAXED_MODE", MocConst_.RelaxedMode, false) || + !info.GetBool("MOC_PATH_PREFIX", MocConst_.PathPrefix, true) || + !info.GetArray("MOC_SKIP", MocConst_.SkipList, false) || + !info.GetArrayConfig("MOC_DEFINITIONS", MocConst_.Definitions, + false) || + !info.GetArrayConfig("MOC_INCLUDES", MocConst_.IncludePaths, false) || + !info.GetArray("MOC_OPTIONS", MocConst_.OptionsExtra, false) || + !info.GetStringConfig("MOC_COMPILATION_FILE", MocConst_.CompFileAbs, + true) || + !info.GetArray("MOC_PREDEFS_CMD", MocConst_.PredefsCmd, false) || + !info.GetStringConfig("MOC_PREDEFS_FILE", MocConst_.PredefsFileAbs, + !MocConst_.PredefsCmd.empty()) || + !info.GetArray("MOC_MACRO_NAMES", tmp.MacroNames, true) || + !info.GetArray("MOC_DEPEND_FILTERS", tmp.DependFilters, false)) { return false; } @@ -1621,18 +1624,17 @@ bool cmQtAutoMocUic::InitFromInfo() } // Dependency filters { - Json::Value const& val = Info()["MOC_DEPEND_FILTERS"]; + Json::Value const& val = info.GetValue("MOC_DEPEND_FILTERS"); if (!val.isArray()) { - return LogInfoError("MOC_DEPEND_FILTERS JSON value is not an array."); + return info.LogError("MOC_DEPEND_FILTERS JSON value is not an array."); } Json::ArrayIndex const arraySize = val.size(); for (Json::ArrayIndex ii = 0; ii != arraySize; ++ii) { // Test entry closure - auto testEntry = [this, ii](bool test, - cm::string_view message) -> bool { + auto testEntry = [&info, ii](bool test, cm::string_view msg) -> bool { if (!test) { - this->LogInfoError( - cmStrCat("MOC_DEPEND_FILTERS filter ", ii, ": ", message)); + info.LogError( + cmStrCat("MOC_DEPEND_FILTERS filter ", ii, ": ", msg)); } return !test; }; @@ -1671,9 +1673,9 @@ bool cmQtAutoMocUic::InitFromInfo() } // Check if moc executable exists (by reading the file time) if (!MocConst_.ExecutableTime.Load(MocConst_.Executable)) { - return LogInfoError(cmStrCat("The moc executable ", - MessagePath(MocConst_.Executable), - " does not exist.")); + return info.LogError(cmStrCat("The moc executable ", + MessagePath(MocConst_.Executable), + " does not exist.")); } } @@ -1683,25 +1685,23 @@ bool cmQtAutoMocUic::InitFromInfo() UicConst_.Enabled = true; // -- Required settings - if (!InfoArray("UIC_SKIP", UicConst_.SkipList, false) || - !InfoArray("UIC_SEARCH_PATHS", UicConst_.SearchPaths, false) || - !InfoArrayConfig("UIC_OPTIONS", UicConst_.Options, false)) { + if (!info.GetArray("UIC_SKIP", UicConst_.SkipList, false) || + !info.GetArray("UIC_SEARCH_PATHS", UicConst_.SearchPaths, false) || + !info.GetArrayConfig("UIC_OPTIONS", UicConst_.Options, false)) { return false; } // .ui files { - Json::Value const& val = Info()["UIC_UI_FILES"]; + Json::Value const& val = info.GetValue("UIC_UI_FILES"); if (!val.isArray()) { - return LogInfoError("UIC_UI_FILES JSON value is not an array."); + return info.LogError("UIC_UI_FILES JSON value is not an array."); } Json::ArrayIndex const arraySize = val.size(); for (Json::ArrayIndex ii = 0; ii != arraySize; ++ii) { // Test entry closure - auto testEntry = [this, ii](bool test, - cm::string_view message) -> bool { + auto testEntry = [&info, ii](bool test, cm::string_view msg) -> bool { if (!test) { - this->LogInfoError( - cmStrCat("UIC_UI_FILES entry ", ii, ": ", message)); + info.LogError(cmStrCat("UIC_UI_FILES entry ", ii, ": ", msg)); } return !test; }; @@ -1722,31 +1722,31 @@ bool cmQtAutoMocUic::InitFromInfo() } auto& uiFile = UicConst_.UiFiles[entryName.asString()]; - JsonGetArray(uiFile.Options, entryOptions); + InfoT::GetJsonArray(uiFile.Options, entryOptions); } } // -- Evaluate settings // Check if uic executable exists (by reading the file time) if (!UicConst_.ExecutableTime.Load(UicConst_.Executable)) { - return LogInfoError(cmStrCat("The uic executable ", - MessagePath(UicConst_.Executable), - " does not exist.")); + return info.LogError(cmStrCat("The uic executable ", + MessagePath(UicConst_.Executable), + " does not exist.")); } } // -- Headers { - Json::Value const& val = Info()["HEADERS"]; + Json::Value const& val = info.GetValue("HEADERS"); if (!val.isArray()) { - return LogInfoError("HEADERS JSON value is not an array."); + return info.LogError("HEADERS JSON value is not an array."); } Json::ArrayIndex const arraySize = val.size(); for (Json::ArrayIndex ii = 0; ii != arraySize; ++ii) { // Test entry closure - auto testEntry = [this, ii](bool test, cm::string_view message) -> bool { + auto testEntry = [&info, ii](bool test, cm::string_view msg) -> bool { if (!test) { - this->LogInfoError(cmStrCat("HEADERS entry ", ii, ": ", message)); + info.LogError(cmStrCat("HEADERS entry ", ii, ": ", msg)); } return !test; }; @@ -1778,9 +1778,8 @@ bool cmQtAutoMocUic::InitFromInfo() cmFileTime fileTime; if (!fileTime.Load(name)) { - LogInfoError(cmStrCat("The header file ", this->MessagePath(name), - " does not exist.")); - return false; + return info.LogError(cmStrCat( + "The header file ", this->MessagePath(name), " does not exist.")); } SourceFileHandleT sourceHandle = std::make_shared(name); @@ -1790,7 +1789,7 @@ bool cmQtAutoMocUic::InitFromInfo() sourceHandle->Uic = (flags[1] == 'U'); if (sourceHandle->Moc && MocConst().Enabled) { if (build.empty()) { - return LogInfoError( + return info.LogError( cmStrCat("Header file ", ii, " build path is empty")); } sourceHandle->BuildPath = std::move(build); @@ -1801,16 +1800,16 @@ bool cmQtAutoMocUic::InitFromInfo() // -- Sources { - Json::Value const& val = Info()["SOURCES"]; + Json::Value const& val = info.GetValue("SOURCES"); if (!val.isArray()) { - return LogInfoError("SOURCES JSON value is not an array."); + return info.LogError("SOURCES JSON value is not an array."); } Json::ArrayIndex const arraySize = val.size(); for (Json::ArrayIndex ii = 0; ii != arraySize; ++ii) { // Test entry closure - auto testEntry = [this, ii](bool test, cm::string_view message) -> bool { + auto testEntry = [&info, ii](bool test, cm::string_view msg) -> bool { if (!test) { - this->LogInfoError(cmStrCat("SOURCES entry ", ii, ": ", message)); + info.LogError(cmStrCat("SOURCES entry ", ii, ": ", msg)); } return !test; }; @@ -1838,9 +1837,8 @@ bool cmQtAutoMocUic::InitFromInfo() cmFileTime fileTime; if (!fileTime.Load(name)) { - LogInfoError(cmStrCat("The source file ", this->MessagePath(name), - " does not exist.")); - return false; + return info.LogError(cmStrCat( + "The source file ", this->MessagePath(name), " does not exist.")); } SourceFileHandleT sourceHandle = std::make_shared(name); diff --git a/Source/cmQtAutoMocUic.h b/Source/cmQtAutoMocUic.h index 7101b8f..53946ef 100644 --- a/Source/cmQtAutoMocUic.h +++ b/Source/cmQtAutoMocUic.h @@ -523,7 +523,7 @@ public: private: // -- Abstract processing interface - bool InitFromInfo() override; + bool InitFromInfo(InfoT const& info) override; void InitJobs(); bool Process() override; // -- Settings file diff --git a/Source/cmQtAutoRcc.cxx b/Source/cmQtAutoRcc.cxx index b0b15d4..579cda7 100644 --- a/Source/cmQtAutoRcc.cxx +++ b/Source/cmQtAutoRcc.cxx @@ -21,21 +21,21 @@ cmQtAutoRcc::cmQtAutoRcc() } cmQtAutoRcc::~cmQtAutoRcc() = default; -bool cmQtAutoRcc::InitFromInfo() +bool cmQtAutoRcc::InitFromInfo(InfoT const& info) { // -- Required settings - if (!InfoBool("MULTI_CONFIG", MultiConfig_, true) || - !InfoString("BUILD_DIR", AutogenBuildDir_, true) || - !InfoStringConfig("INCLUDE_DIR", IncludeDir_, true) || - !InfoString("RCC_EXECUTABLE", RccExecutable_, true) || - !InfoArray("RCC_LIST_OPTIONS", RccListOptions_, false) || - !InfoString("LOCK_FILE", LockFile_, true) || - !InfoStringConfig("SETTINGS_FILE", SettingsFile_, true) || - !InfoString("SOURCE", QrcFile_, true) || - !InfoString("OUTPUT_CHECKSUM", RccPathChecksum_, true) || - !InfoString("OUTPUT_NAME", RccFileName_, true) || - !InfoArray("OPTIONS", Options_, false) || - !InfoArray("INPUTS", Inputs_, false)) { + if (!info.GetBool("MULTI_CONFIG", MultiConfig_, true) || + !info.GetString("BUILD_DIR", AutogenBuildDir_, true) || + !info.GetStringConfig("INCLUDE_DIR", IncludeDir_, true) || + !info.GetString("RCC_EXECUTABLE", RccExecutable_, true) || + !info.GetArray("RCC_LIST_OPTIONS", RccListOptions_, false) || + !info.GetString("LOCK_FILE", LockFile_, true) || + !info.GetStringConfig("SETTINGS_FILE", SettingsFile_, true) || + !info.GetString("SOURCE", QrcFile_, true) || + !info.GetString("OUTPUT_CHECKSUM", RccPathChecksum_, true) || + !info.GetString("OUTPUT_NAME", RccFileName_, true) || + !info.GetArray("OPTIONS", Options_, false) || + !info.GetArray("INPUTS", Inputs_, false)) { return false; } @@ -54,7 +54,7 @@ bool cmQtAutoRcc::InitFromInfo() // -- Checks if (!RccExecutableTime_.Load(RccExecutable_)) { - return LogInfoError(cmStrCat( + return info.LogError(cmStrCat( "The rcc executable ", MessagePath(RccExecutable_), " does not exist.")); } diff --git a/Source/cmQtAutoRcc.h b/Source/cmQtAutoRcc.h index 945b68f..33c7960 100644 --- a/Source/cmQtAutoRcc.h +++ b/Source/cmQtAutoRcc.h @@ -30,7 +30,7 @@ private: std::string MultiConfigOutput() const; // -- Abstract processing interface - bool InitFromInfo() override; + bool InitFromInfo(InfoT const& info) override; bool Process() override; // -- Settings file bool SettingsFileRead(); diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index bf856d7..b6076db 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -48,6 +48,8 @@ #include #include +#include + class cmConnection; int cmcmd_cmake_ninja_depends(std::vector::const_iterator argBeg, @@ -1058,17 +1060,15 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args) #ifndef CMAKE_BOOTSTRAP if ((args[1] == "cmake_autogen") && (args.size() >= 4)) { cmQtAutoMocUic autoGen; - std::string const& infoFile = args[2]; - std::string const& config = args[3]; + cm::string_view const infoFile = args[2]; + cm::string_view const config = args[3]; return autoGen.Run(infoFile, config) ? 0 : 1; } if ((args[1] == "cmake_autorcc") && (args.size() >= 3)) { cmQtAutoRcc autoRcc; - std::string const& infoFile = args[2]; - std::string config; - if (args.size() > 3) { - config = args[3]; - } + cm::string_view const infoFile = args[2]; + cm::string_view const config = + (args.size() > 3) ? cm::string_view(args[3]) : cm::string_view(); return autoRcc.Run(infoFile, config) ? 0 : 1; } #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dd0f304613b1661754d9cccf5829087a8bb19a12 commit dd0f304613b1661754d9cccf5829087a8bb19a12 Author: Cristian Adam AuthorDate: Tue Sep 17 19:21:09 2019 +0200 Commit: Cristian Adam CommitDate: Sat Sep 28 15:56:53 2019 +0200 Objective C/C++: Add compiler standard detection diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3583dc9..303a484 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1941,10 +1941,20 @@ void cmLocalGenerator::AddCompilerRequirementFlag( langStdMap["CXX"].emplace_back("11"); langStdMap["CXX"].emplace_back("98"); + langStdMap["OBJCXX"].emplace_back("20"); + langStdMap["OBJCXX"].emplace_back("17"); + langStdMap["OBJCXX"].emplace_back("14"); + langStdMap["OBJCXX"].emplace_back("11"); + langStdMap["OBJCXX"].emplace_back("98"); + langStdMap["C"].emplace_back("11"); langStdMap["C"].emplace_back("99"); langStdMap["C"].emplace_back("90"); + langStdMap["OBJC"].emplace_back("11"); + langStdMap["OBJC"].emplace_back("99"); + langStdMap["OBJC"].emplace_back("90"); + langStdMap["CUDA"].emplace_back("14"); langStdMap["CUDA"].emplace_back("11"); langStdMap["CUDA"].emplace_back("98"); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 34081ed..85ba38c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -38,6 +38,7 @@ #include "cmState.h" #include "cmStateDirectory.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTargetLinkLibraryType.h" #include "cmTest.h" @@ -4615,9 +4616,9 @@ bool cmMakefile::AddRequiredTargetFeature(cmTarget* target, target->AppendProperty("COMPILE_FEATURES", feature.c_str()); - return lang == "C" - ? this->AddRequiredTargetCFeature(target, feature, error) - : this->AddRequiredTargetCxxFeature(target, feature, error); + return lang == "C" || lang == "OBJC" + ? this->AddRequiredTargetCFeature(target, feature, lang, error) + : this->AddRequiredTargetCxxFeature(target, feature, lang, error); } bool cmMakefile::CompileFeatureKnown(cmTarget const* target, @@ -4709,30 +4710,33 @@ bool cmMakefile::HaveStandardAvailable(cmTarget const* target, std::string const& lang, const std::string& feature) const { - return lang == "C" ? this->HaveCStandardAvailable(target, feature) - : this->HaveCxxStandardAvailable(target, feature); + return lang == "C" || lang == "OBJC" + ? this->HaveCStandardAvailable(target, feature, lang) + : this->HaveCxxStandardAvailable(target, feature, lang); } bool cmMakefile::HaveCStandardAvailable(cmTarget const* target, - const std::string& feature) const + const std::string& feature, + std::string const& lang) const { const char* defaultCStandard = - this->GetDefinition("CMAKE_C_STANDARD_DEFAULT"); + this->GetDefinition(cmStrCat("CMAKE_", lang, "_STANDARD_DEFAULT")); if (!defaultCStandard) { this->IssueMessage( MessageType::INTERNAL_ERROR, - "CMAKE_C_STANDARD_DEFAULT is not set. COMPILE_FEATURES support " - "not fully configured for this compiler."); + cmStrCat("CMAKE_", lang, + "_STANDARD_DEFAULT is not set. COMPILE_FEATURES support " + "not fully configured for this compiler.")); // Return true so the caller does not try to lookup the default standard. return true; } if (std::find_if(cm::cbegin(C_STANDARDS), cm::cend(C_STANDARDS), cmStrCmp(defaultCStandard)) == cm::cend(C_STANDARDS)) { - std::ostringstream e; - e << "The CMAKE_C_STANDARD_DEFAULT variable contains an " - "invalid value: \"" - << defaultCStandard << "\"."; - this->IssueMessage(MessageType::INTERNAL_ERROR, e.str()); + const std::string e = cmStrCat("The CMAKE_", lang, + "_STANDARD_DEFAULT variable contains an " + "invalid value: \"", + defaultCStandard, "\"."); + this->IssueMessage(MessageType::INTERNAL_ERROR, e); return false; } @@ -4740,19 +4744,20 @@ bool cmMakefile::HaveCStandardAvailable(cmTarget const* target, bool needC99 = false; bool needC11 = false; - this->CheckNeededCLanguage(feature, needC90, needC99, needC11); + this->CheckNeededCLanguage(feature, lang, needC90, needC99, needC11); - const char* existingCStandard = target->GetProperty("C_STANDARD"); + const char* existingCStandard = + target->GetProperty(cmStrCat(lang, "_STANDARD")); if (!existingCStandard) { existingCStandard = defaultCStandard; } if (std::find_if(cm::cbegin(C_STANDARDS), cm::cend(C_STANDARDS), cmStrCmp(existingCStandard)) == cm::cend(C_STANDARDS)) { - std::ostringstream e; - e << "The C_STANDARD property on target \"" << target->GetName() - << "\" contained an invalid value: \"" << existingCStandard << "\"."; - this->IssueMessage(MessageType::FATAL_ERROR, e.str()); + const std::string e = cmStrCat( + "The ", lang, "_STANDARD property on target \"", target->GetName(), + "\" contained an invalid value: \"", existingCStandard, "\"."); + this->IssueMessage(MessageType::FATAL_ERROR, e); return false; } @@ -4783,7 +4788,7 @@ bool cmMakefile::IsLaterStandard(std::string const& lang, std::string const& lhs, std::string const& rhs) { - if (lang == "C") { + if (lang == "C" || lang == "OBJC") { const char* const* rhsIt = std::find_if( cm::cbegin(C_STANDARDS), cm::cend(C_STANDARDS), cmStrCmp(rhs)); @@ -4798,25 +4803,26 @@ bool cmMakefile::IsLaterStandard(std::string const& lang, } bool cmMakefile::HaveCxxStandardAvailable(cmTarget const* target, - const std::string& feature) const + const std::string& feature, + std::string const& lang) const { const char* defaultCxxStandard = - this->GetDefinition("CMAKE_CXX_STANDARD_DEFAULT"); + this->GetDefinition(cmStrCat("CMAKE_", lang, "_STANDARD_DEFAULT")); if (!defaultCxxStandard) { this->IssueMessage( MessageType::INTERNAL_ERROR, - "CMAKE_CXX_STANDARD_DEFAULT is not set. COMPILE_FEATURES support " - "not fully configured for this compiler."); + cmStrCat("CMAKE_", lang, + "_STANDARD_DEFAULT is not set. COMPILE_FEATURES support " + "not fully configured for this compiler.")); // Return true so the caller does not try to lookup the default standard. return true; } if (std::find_if(cm::cbegin(CXX_STANDARDS), cm::cend(CXX_STANDARDS), cmStrCmp(defaultCxxStandard)) == cm::cend(CXX_STANDARDS)) { - std::ostringstream e; - e << "The CMAKE_CXX_STANDARD_DEFAULT variable contains an " - "invalid value: \"" - << defaultCxxStandard << "\"."; - this->IssueMessage(MessageType::INTERNAL_ERROR, e.str()); + const std::string e = + cmStrCat("The CMAKE_", lang, "_STANDARD_DEFAULT variable contains an ", + "invalid value: \"", defaultCxxStandard, "\"."); + this->IssueMessage(MessageType::INTERNAL_ERROR, e); return false; } @@ -4825,10 +4831,11 @@ bool cmMakefile::HaveCxxStandardAvailable(cmTarget const* target, bool needCxx14 = false; bool needCxx17 = false; bool needCxx20 = false; - this->CheckNeededCxxLanguage(feature, needCxx98, needCxx11, needCxx14, + this->CheckNeededCxxLanguage(feature, lang, needCxx98, needCxx11, needCxx14, needCxx17, needCxx20); - const char* existingCxxStandard = target->GetProperty("CXX_STANDARD"); + const char* existingCxxStandard = + target->GetProperty(cmStrCat(lang, "_STANDARD")); if (!existingCxxStandard) { existingCxxStandard = defaultCxxStandard; } @@ -4837,10 +4844,10 @@ bool cmMakefile::HaveCxxStandardAvailable(cmTarget const* target, std::find_if(cm::cbegin(CXX_STANDARDS), cm::cend(CXX_STANDARDS), cmStrCmp(existingCxxStandard)); if (existingCxxLevel == cm::cend(CXX_STANDARDS)) { - std::ostringstream e; - e << "The CXX_STANDARD property on target \"" << target->GetName() - << "\" contained an invalid value: \"" << existingCxxStandard << "\"."; - this->IssueMessage(MessageType::FATAL_ERROR, e.str()); + const std::string e = cmStrCat( + "The ", lang, "_STANDARD property on target \"", target->GetName(), + "\" contained an invalid value: \"", existingCxxStandard, "\"."); + this->IssueMessage(MessageType::FATAL_ERROR, e); return false; } @@ -4858,32 +4865,33 @@ bool cmMakefile::HaveCxxStandardAvailable(cmTarget const* target, } void cmMakefile::CheckNeededCxxLanguage(const std::string& feature, + std::string const& lang, bool& needCxx98, bool& needCxx11, bool& needCxx14, bool& needCxx17, bool& needCxx20) const { if (const char* propCxx98 = - this->GetDefinition("CMAKE_CXX98_COMPILE_FEATURES")) { + this->GetDefinition(cmStrCat("CMAKE_", lang, "98_COMPILE_FEATURES"))) { std::vector props = cmExpandedList(propCxx98); needCxx98 = cmContains(props, feature); } if (const char* propCxx11 = - this->GetDefinition("CMAKE_CXX11_COMPILE_FEATURES")) { + this->GetDefinition(cmStrCat("CMAKE_", lang, "11_COMPILE_FEATURES"))) { std::vector props = cmExpandedList(propCxx11); needCxx11 = cmContains(props, feature); } if (const char* propCxx14 = - this->GetDefinition("CMAKE_CXX14_COMPILE_FEATURES")) { + this->GetDefinition(cmStrCat("CMAKE_", lang, "14_COMPILE_FEATURES"))) { std::vector props = cmExpandedList(propCxx14); needCxx14 = cmContains(props, feature); } if (const char* propCxx17 = - this->GetDefinition("CMAKE_CXX17_COMPILE_FEATURES")) { + this->GetDefinition(cmStrCat("CMAKE_", lang, "17_COMPILE_FEATURES"))) { std::vector props = cmExpandedList(propCxx17); needCxx17 = cmContains(props, feature); } if (const char* propCxx20 = - this->GetDefinition("CMAKE_CXX20_COMPILE_FEATURES")) { + this->GetDefinition(cmStrCat("CMAKE_", lang, "20_COMPILE_FEATURES"))) { std::vector props = cmExpandedList(propCxx20); needCxx20 = cmContains(props, feature); } @@ -4891,6 +4899,7 @@ void cmMakefile::CheckNeededCxxLanguage(const std::string& feature, bool cmMakefile::AddRequiredTargetCxxFeature(cmTarget* target, const std::string& feature, + std::string const& lang, std::string* error) const { bool needCxx98 = false; @@ -4899,13 +4908,14 @@ bool cmMakefile::AddRequiredTargetCxxFeature(cmTarget* target, bool needCxx17 = false; bool needCxx20 = false; - this->CheckNeededCxxLanguage(feature, needCxx98, needCxx11, needCxx14, + this->CheckNeededCxxLanguage(feature, lang, needCxx98, needCxx11, needCxx14, needCxx17, needCxx20); - const char* existingCxxStandard = target->GetProperty("CXX_STANDARD"); + const char* existingCxxStandard = + target->GetProperty(cmStrCat(lang, "_STANDARD")); if (existingCxxStandard == nullptr) { const char* defaultCxxStandard = - this->GetDefinition("CMAKE_CXX_STANDARD_DEFAULT"); + this->GetDefinition(cmStrCat("CMAKE_", lang, "_STANDARD_DEFAULT")); if (defaultCxxStandard && *defaultCxxStandard) { existingCxxStandard = defaultCxxStandard; } @@ -4916,14 +4926,14 @@ bool cmMakefile::AddRequiredTargetCxxFeature(cmTarget* target, std::find_if(cm::cbegin(CXX_STANDARDS), cm::cend(CXX_STANDARDS), cmStrCmp(existingCxxStandard)); if (existingCxxLevel == cm::cend(CXX_STANDARDS)) { - std::ostringstream e; - e << "The CXX_STANDARD property on target \"" << target->GetName() - << "\" contained an invalid value: \"" << existingCxxStandard << "\"."; + const std::string e = cmStrCat( + "The ", lang, "_STANDARD property on target \"", target->GetName(), + "\" contained an invalid value: \"", existingCxxStandard, "\"."); if (error) { - *error = e.str(); + *error = e; } else { - this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, - e.str(), this->Backtrace); + this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, e, + this->Backtrace); } return false; } @@ -4964,7 +4974,7 @@ bool cmMakefile::AddRequiredTargetCxxFeature(cmTarget* target, // Ensure the C++ language level is high enough to support // the needed C++ features. if (!existingCxxLevel || existingCxxLevel < needCxxLevel) { - target->SetProperty("CXX_STANDARD", *needCxxLevel); + target->SetProperty(cmStrCat(lang, "_STANDARD"), *needCxxLevel); } // Ensure the CUDA language level is high enough to support @@ -4978,21 +4988,21 @@ bool cmMakefile::AddRequiredTargetCxxFeature(cmTarget* target, } void cmMakefile::CheckNeededCLanguage(const std::string& feature, - bool& needC90, bool& needC99, - bool& needC11) const + std::string const& lang, bool& needC90, + bool& needC99, bool& needC11) const { if (const char* propC90 = - this->GetDefinition("CMAKE_C90_COMPILE_FEATURES")) { + this->GetDefinition(cmStrCat("CMAKE_", lang, "90_COMPILE_FEATURES"))) { std::vector props = cmExpandedList(propC90); needC90 = cmContains(props, feature); } if (const char* propC99 = - this->GetDefinition("CMAKE_C99_COMPILE_FEATURES")) { + this->GetDefinition(cmStrCat("CMAKE_", lang, "99_COMPILE_FEATURES"))) { std::vector props = cmExpandedList(propC99); needC99 = cmContains(props, feature); } if (const char* propC11 = - this->GetDefinition("CMAKE_C11_COMPILE_FEATURES")) { + this->GetDefinition(cmStrCat("CMAKE_", lang, "11_COMPILE_FEATURES"))) { std::vector props = cmExpandedList(propC11); needC11 = cmContains(props, feature); } @@ -5000,18 +5010,20 @@ void cmMakefile::CheckNeededCLanguage(const std::string& feature, bool cmMakefile::AddRequiredTargetCFeature(cmTarget* target, const std::string& feature, + std::string const& lang, std::string* error) const { bool needC90 = false; bool needC99 = false; bool needC11 = false; - this->CheckNeededCLanguage(feature, needC90, needC99, needC11); + this->CheckNeededCLanguage(feature, lang, needC90, needC99, needC11); - const char* existingCStandard = target->GetProperty("C_STANDARD"); + const char* existingCStandard = + target->GetProperty(cmStrCat(lang, "_STANDARD")); if (existingCStandard == nullptr) { const char* defaultCStandard = - this->GetDefinition("CMAKE_C_STANDARD_DEFAULT"); + this->GetDefinition(cmStrCat("CMAKE_", lang, "_STANDARD_DEFAULT")); if (defaultCStandard && *defaultCStandard) { existingCStandard = defaultCStandard; } @@ -5019,14 +5031,14 @@ bool cmMakefile::AddRequiredTargetCFeature(cmTarget* target, if (existingCStandard) { if (std::find_if(cm::cbegin(C_STANDARDS), cm::cend(C_STANDARDS), cmStrCmp(existingCStandard)) == cm::cend(C_STANDARDS)) { - std::ostringstream e; - e << "The C_STANDARD property on target \"" << target->GetName() - << "\" contained an invalid value: \"" << existingCStandard << "\"."; + const std::string e = cmStrCat( + "The ", lang, "_STANDARD property on target \"", target->GetName(), + "\" contained an invalid value: \"", existingCStandard, "\"."); if (error) { - *error = e.str(); + *error = e; } else { - this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, - e.str(), this->Backtrace); + this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, e, + this->Backtrace); } return false; } @@ -5057,11 +5069,11 @@ bool cmMakefile::AddRequiredTargetCFeature(cmTarget* target, } if (setC11) { - target->SetProperty("C_STANDARD", "11"); + target->SetProperty(cmStrCat(lang, "_STANDARD"), "11"); } else if (setC99) { - target->SetProperty("C_STANDARD", "99"); + target->SetProperty(cmStrCat(lang, "_STANDARD"), "99"); } else if (setC90) { - target->SetProperty("C_STANDARD", "90"); + target->SetProperty(cmStrCat(lang, "_STANDARD"), "90"); } return true; } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index db37477..1dc83b4 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -1135,22 +1135,28 @@ private: bool MightHaveCustomCommand(const std::string& name) const; bool AddRequiredTargetCFeature(cmTarget* target, const std::string& feature, + std::string const& lang, std::string* error = nullptr) const; bool AddRequiredTargetCxxFeature(cmTarget* target, const std::string& feature, + std::string const& lang, std::string* error = nullptr) const; - void CheckNeededCLanguage(const std::string& feature, bool& needC90, + void CheckNeededCLanguage(const std::string& feature, + std::string const& lang, bool& needC90, bool& needC99, bool& needC11) const; - void CheckNeededCxxLanguage(const std::string& feature, bool& needCxx98, + void CheckNeededCxxLanguage(const std::string& feature, + std::string const& lang, bool& needCxx98, bool& needCxx11, bool& needCxx14, bool& needCxx17, bool& needCxx20) const; bool HaveCStandardAvailable(cmTarget const* target, - const std::string& feature) const; + const std::string& feature, + std::string const& lang) const; bool HaveCxxStandardAvailable(cmTarget const* target, - const std::string& feature) const; + const std::string& feature, + std::string const& lang) const; void CheckForUnusedVariables() const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1b88db6..f65a018 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -332,6 +332,9 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, initProp("C_STANDARD"); initProp("C_STANDARD_REQUIRED"); initProp("C_EXTENSIONS"); + initProp("OBJC_STANDARD"); + initProp("OBJC_STANDARD_REQUIRED"); + initProp("OBJC_EXTENSIONS"); initProp("CXX_CLANG_TIDY"); initProp("CXX_COMPILER_LAUNCHER"); initProp("CXX_CPPLINT"); @@ -340,6 +343,9 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, initProp("CXX_STANDARD"); initProp("CXX_STANDARD_REQUIRED"); initProp("CXX_EXTENSIONS"); + initProp("OBJCXX_STANDARD"); + initProp("OBJCXX_STANDARD_REQUIRED"); + initProp("OBJCXX_EXTENSIONS"); initProp("CUDA_STANDARD"); initProp("CUDA_STANDARD_REQUIRED"); initProp("CUDA_EXTENSIONS"); @@ -452,6 +458,8 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, this->GetType() != cmStateEnums::UTILITY) { initProp("C_VISIBILITY_PRESET"); initProp("CXX_VISIBILITY_PRESET"); + initProp("OBJC_VISIBILITY_PRESET"); + initProp("OBJCXX_VISIBILITY_PRESET"); initProp("CUDA_VISIBILITY_PRESET"); initProp("VISIBILITY_INLINES_HIDDEN"); } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b515af782bccf147e8bd62444c9f1808668f12ac commit b515af782bccf147e8bd62444c9f1808668f12ac Author: Cristian Adam AuthorDate: Fri Sep 13 20:21:23 2019 +0200 Commit: Cristian Adam CommitDate: Sat Sep 28 15:56:53 2019 +0200 Help: Add release note for Objective-C/C++ language support diff --git a/Help/release/dev/objective-c-cxx.rst b/Help/release/dev/objective-c-cxx.rst new file mode 100644 index 0000000..218af4e --- /dev/null +++ b/Help/release/dev/objective-c-cxx.rst @@ -0,0 +1,9 @@ +Objective C/C++ +--------------- + +* CMake learned to support the Objective C (``OBJC``) and Objective C++ + (``OBJCXX``) languages. They may be enabled via the :command:`project` + and :command:`enable_language` commands. When ``OBJC`` or ``OBJCXX`` + is enabled, source files with the ``.m`` or ``.mm``, respectively, + will be compiled as Objective C or C++. Otherwise they will be treated + as plain C++ sources as they were before. https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9e66397c28110f015e5b044dfe9782cd5f11c8c3 commit 9e66397c28110f015e5b044dfe9782cd5f11c8c3 Author: Steve Wilson AuthorDate: Fri Sep 13 18:12:15 2019 +0100 Commit: Cristian Adam CommitDate: Sat Sep 28 15:56:53 2019 +0200 Languages: Add support for Objective-C++ Add entries in Modules and Modules/Platform to support Objective-C++ compiler determination and identification. Add Modules to check Objective-C++ compiler flags, source compilations, program checks, etc... Use OBJCXX as the designator of the language, eg: project(foo OBJCXX) Add various tests for Objective-C++ language features. Add tests to preserve C++ handling of .M and .mm files when Objective-C++ is not a configured language. Co-authored-by: Cristian Adam diff --git a/Help/command/enable_language.rst b/Help/command/enable_language.rst index 44beb54..fdc44f2 100644 --- a/Help/command/enable_language.rst +++ b/Help/command/enable_language.rst @@ -1,7 +1,6 @@ enable_language --------------- - -Enable a language (CXX/C/OBJC/Fortran/etc) +Enable a language (CXX/C/OBJC/OBJCXX/Fortran/etc) .. code-block:: cmake @@ -10,7 +9,7 @@ Enable a language (CXX/C/OBJC/Fortran/etc) Enables support for the named language in CMake. This is the same as the :command:`project` command but does not create any of the extra variables that are created by the project command. Example languages -are ``CXX``, ``C``, ``CUDA``, ``OBJC``, ``Fortran``, and ``ASM``. +are ``CXX``, ``C``, ``CUDA``, ``OBJC``, ``OBJCXX``, ``Fortran``, and ``ASM``. If enabling ``ASM``, enable it last so that CMake can check whether compilers for other languages like ``C`` work for assembly too. diff --git a/Help/command/project.rst b/Help/command/project.rst index 2bbb3f4..3951456 100644 --- a/Help/command/project.rst +++ b/Help/command/project.rst @@ -87,8 +87,8 @@ The options are: Can also be specified without ``LANGUAGES`` keyword per the first, short signature. Selects which programming languages are needed to build the project. - Supported languages include ``C``, ``CXX`` (i.e. C++), ``CUDA``, ``OBJC`` (i.e. Objective-C), - ``Fortran``, and ``ASM``. + Supported languages include ``C``, ``CXX`` (i.e. C++), ``CUDA``, + ``OBJC`` (i.e. Objective-C), ``OBJCXX``, ``Fortran``, and ``ASM``. By default ``C`` and ``CXX`` are enabled if no language options are given. Specify language ``NONE``, or use the ``LANGUAGES`` keyword and list no languages, to skip enabling any languages. diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index 8890433..6e7f9b5 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -135,6 +135,11 @@ Variable Queries ``1`` if the CMake's compiler id of the Objective-C compiler matches any one of the entries in ``compiler_ids``, otherwise ``0``. See also the :variable:`CMAKE__COMPILER_ID` variable. +``$`` + where ``compiler_ids`` is a comma-separated list. + ``1`` if the CMake's compiler id of the Objective-C++ compiler matches any one + of the entries in ``compiler_ids``, otherwise ``0``. + See also the :variable:`CMAKE__COMPILER_ID` variable. ``$`` where ``compiler_ids`` is a comma-separated list. ``1`` if the CMake's compiler id of the Fortran compiler matches any one @@ -149,6 +154,12 @@ Variable Queries ``$`` ``1`` if the version of the CXX compiler matches ``version``, otherwise ``0``. See also the :variable:`CMAKE__COMPILER_VERSION` variable. +``$`` + ``1`` if the version of the OBJC compiler matches ``version``, otherwise ``0``. + See also the :variable:`CMAKE__COMPILER_VERSION` variable. +``$`` + ``1`` if the version of the OBJCXX compiler matches ``version``, otherwise ``0``. + See also the :variable:`CMAKE__COMPILER_VERSION` variable. ``$`` ``1`` if the version of the Fortran compiler matches ``version``, otherwise ``0``. See also the :variable:`CMAKE__COMPILER_VERSION` variable. @@ -406,6 +417,12 @@ Variable Queries ``$`` The CMake's compiler id of the CUDA compiler used. See also the :variable:`CMAKE__COMPILER_ID` variable. +``$`` + The CMake's compiler id of the OBJC compiler used. + See also the :variable:`CMAKE__COMPILER_ID` variable. +``$`` + The CMake's compiler id of the OBJCXX compiler used. + See also the :variable:`CMAKE__COMPILER_ID` variable. ``$`` The CMake's compiler id of the Fortran compiler used. See also the :variable:`CMAKE__COMPILER_ID` variable. @@ -421,6 +438,9 @@ Variable Queries ``$`` The version of the OBJC compiler used. See also the :variable:`CMAKE__COMPILER_VERSION` variable. +``$`` + The version of the OBJCXX compiler used. + See also the :variable:`CMAKE__COMPILER_VERSION` variable. ``$`` The version of the Fortran compiler used. See also the :variable:`CMAKE__COMPILER_VERSION` variable. diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst index 78881e6..c60dc40 100644 --- a/Help/manual/cmake-modules.7.rst +++ b/Help/manual/cmake-modules.7.rst @@ -39,6 +39,9 @@ These modules are loaded using the :command:`include` command. /module/CheckOBJCCompilerFlag /module/CheckOBJCSourceCompiles /module/CheckOBJCSourceRuns + /module/CheckOBJCXXCompilerFlag + /module/CheckOBJCXXSourceCompiles + /module/CheckOBJCXXSourceRuns /module/CheckPIESupported /module/CheckPrototypeDefinition /module/CheckStructHasMember diff --git a/Help/module/CheckOBJCXXCompilerFlag.rst b/Help/module/CheckOBJCXXCompilerFlag.rst new file mode 100644 index 0000000..1518a48 --- /dev/null +++ b/Help/module/CheckOBJCXXCompilerFlag.rst @@ -0,0 +1 @@ +.. cmake-module:: ../../Modules/CheckOBJCXXCompilerFlag.cmake diff --git a/Help/module/CheckOBJCXXSourceCompiles.rst b/Help/module/CheckOBJCXXSourceCompiles.rst new file mode 100644 index 0000000..a1c8ae9 --- /dev/null +++ b/Help/module/CheckOBJCXXSourceCompiles.rst @@ -0,0 +1 @@ +.. cmake-module:: ../../Modules/CheckOBJCXXSourceCompiles.cmake diff --git a/Help/module/CheckOBJCXXSourceRuns.rst b/Help/module/CheckOBJCXXSourceRuns.rst new file mode 100644 index 0000000..5198e1b --- /dev/null +++ b/Help/module/CheckOBJCXXSourceRuns.rst @@ -0,0 +1 @@ +.. cmake-module:: ../../Modules/CheckOBJCXXSourceRuns.cmake diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index 6936cd4..ef65021 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -45,7 +45,7 @@ set(CMAKE_CXX_COMPILER_ID_RUN 1) set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm;CPP) set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC) -foreach (lang OBJC) +foreach (lang OBJC OBJCXX) if (CMAKE_${lang}_COMPILER_ID_RUN) foreach(extension IN LISTS CMAKE_${lang}_SOURCE_FILE_EXTENSIONS) list(REMOVE_ITEM CMAKE_CXX_SOURCE_FILE_EXTENSIONS ${extension}) diff --git a/Modules/CMakeDetermineOBJCXXCompiler.cmake b/Modules/CMakeDetermineOBJCXXCompiler.cmake new file mode 100644 index 0000000..60fcbb3 --- /dev/null +++ b/Modules/CMakeDetermineOBJCXXCompiler.cmake @@ -0,0 +1,197 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + + +# determine the compiler to use for Objective-C++ programs +# NOTE, a generator may set CMAKE_OBJCXX_COMPILER before +# loading this file to force a compiler. +# use environment variable OBJCXX first if defined by user, next use +# the cmake variable CMAKE_GENERATOR_OBJCXX which can be defined by a generator +# as a default compiler +# If the internal cmake variable _CMAKE_TOOLCHAIN_PREFIX is set, this is used +# as prefix for the tools (e.g. arm-elf-g++, arm-elf-ar etc.) +# +# Sets the following variables: +# CMAKE_OBJCXX_COMPILER +# CMAKE_COMPILER_IS_GNUOBJCXX +# CMAKE_COMPILER_IS_CLANGOBJCXX +# CMAKE_AR +# CMAKE_RANLIB +# +# If not already set before, it also sets +# _CMAKE_TOOLCHAIN_PREFIX + +include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake) + +# Load system-specific compiler preferences for this language. +include(Platform/${CMAKE_SYSTEM_NAME}-Determine-OBJCXX OPTIONAL) +include(Platform/${CMAKE_SYSTEM_NAME}-OBJCXX OPTIONAL) +if(NOT CMAKE_OBJCXX_COMPILER_NAMES) + set(CMAKE_OBJCXX_COMPILER_NAMES clang++) +endif() + +if("${CMAKE_GENERATOR}" MATCHES "Xcode") + set(CMAKE_OBJCXX_COMPILER_XCODE_TYPE sourcecode.cpp.objcpp) +else() + if(NOT CMAKE_OBJCXX_COMPILER) + set(CMAKE_OBJCXX_COMPILER_INIT NOTFOUND) + + # prefer the environment variable OBJCXX + if($ENV{OBJCXX} MATCHES ".+") + get_filename_component(CMAKE_OBJCXX_COMPILER_INIT $ENV{OBJCXX} PROGRAM PROGRAM_ARGS CMAKE_OBJCXX_FLAGS_ENV_INIT) + if(CMAKE_OBJCXX_FLAGS_ENV_INIT) + set(CMAKE_OBJCXX_COMPILER_ARG1 "${CMAKE_OBJCXX_FLAGS_ENV_INIT}" CACHE STRING "First argument to Objective-C++ compiler") + endif() + if(NOT EXISTS ${CMAKE_OBJCXX_COMPILER_INIT}) + message(FATAL_ERROR "Could not find compiler set in environment variable OBJCXX:\n$ENV{OBJCXX}.\n${CMAKE_OBJCXX_COMPILER_INIT}") + endif() + endif() + + # next prefer the generator specified compiler + if(CMAKE_GENERATOR_OBJCXX) + if(NOT CMAKE_OBJCXX_COMPILER_INIT) + set(CMAKE_OBJCXX_COMPILER_INIT ${CMAKE_GENERATOR_OBJCXX}) + endif() + endif() + + # finally list compilers to try + if(NOT CMAKE_OBJCXX_COMPILER_INIT) + set(CMAKE_OBJCXX_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}c++ ${_CMAKE_TOOLCHAIN_PREFIX}g++ clang++) + endif() + + _cmake_find_compiler(OBJCXX) + + else() + # we only get here if CMAKE_OBJCXX_COMPILER was specified using -D or a pre-made CMakeCache.txt + # (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE + # if CMAKE_OBJCXX_COMPILER is a list of length 2, use the first item as + # CMAKE_OBJCXX_COMPILER and the 2nd one as CMAKE_OBJCXX_COMPILER_ARG1 + + list(LENGTH CMAKE_OBJCXX_COMPILER _CMAKE_OBJCXX_COMPILER_LIST_LENGTH) + if("${_CMAKE_OBJCXX_COMPILER_LIST_LENGTH}" EQUAL 2) + list(GET CMAKE_OBJCXX_COMPILER 1 CMAKE_OBJCXX_COMPILER_ARG1) + list(GET CMAKE_OBJCXX_COMPILER 0 CMAKE_OBJCXX_COMPILER) + endif() + + # if a compiler was specified by the user but without path, + # now try to find it with the full path + # if it is found, force it into the cache, + # if not, don't overwrite the setting (which was given by the user) with "NOTFOUND" + # if the C compiler already had a path, reuse it for searching the CXX compiler + get_filename_component(_CMAKE_USER_OBJCXX_COMPILER_PATH "${CMAKE_OBJCXX_COMPILER}" PATH) + if(NOT _CMAKE_USER_OBJCXX_COMPILER_PATH) + find_program(CMAKE_OBJCXX_COMPILER_WITH_PATH NAMES ${CMAKE_OBJCXX_COMPILER}) + if(CMAKE_OBJCXX_COMPILER_WITH_PATH) + set(CMAKE_OBJCXX_COMPILER ${CMAKE_OBJCXX_COMPILER_WITH_PATH} CACHE STRING "Objective-C++ compiler" FORCE) + endif() + unset(CMAKE_OBJCXX_COMPILER_WITH_PATH CACHE) + endif() + + endif() + mark_as_advanced(CMAKE_OBJCXX_COMPILER) + + # Each entry in this list is a set of extra flags to try + # adding to the compile line to see if it helps produce + # a valid identification file. + set(CMAKE_OBJCXX_COMPILER_ID_TEST_FLAGS_FIRST) + set(CMAKE_OBJCXX_COMPILER_ID_TEST_FLAGS + # Try compiling to an object file only. + "-c" + + # ARMClang need target options + "--target=arm-arm-none-eabi -mcpu=cortex-m3" + ) +endif() + +# Build a small source file to identify the compiler. +if(NOT CMAKE_OBJCXX_COMPILER_ID_RUN) + set(CMAKE_OBJCXX_COMPILER_ID_RUN 1) + + # Try to identify the compiler. + set(CMAKE_OBJCXX_COMPILER_ID) + file(READ ${CMAKE_ROOT}/Modules/CMakePlatformId.h.in + CMAKE_OBJCXX_COMPILER_ID_PLATFORM_CONTENT) + + # Match the link line from xcodebuild output of the form + # Ld ... + # ... + # /path/to/cc ...CompilerIdOBJCXX/... + # to extract the compiler front-end for the language. + set(CMAKE_OBJCXX_COMPILER_ID_TOOL_MATCH_REGEX "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerIdOBJCXX/(\\./)?(CompilerIdOBJCXX.(framework|xctest)/)?CompilerIdOBJCXX[ \t\n\\\"]") + set(CMAKE_OBJCXX_COMPILER_ID_TOOL_MATCH_INDEX 2) + + include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) + CMAKE_DETERMINE_COMPILER_ID(OBJCXX OBJCXXFLAGS CMakeOBJCXXCompilerId.mm) + + # Set old compiler and platform id variables. + if(CMAKE_OBJCXX_COMPILER_ID MATCHES "GNU") + set(CMAKE_COMPILER_IS_GNUOBJCXX 1) + endif() + if(CMAKE_OBJCXX_COMPILER_ID MATCHES "Clang") + set(CMAKE_COMPILER_IS_CLANGOBJCXX 1) + endif() +endif() + +if (NOT _CMAKE_TOOLCHAIN_LOCATION) + get_filename_component(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_OBJCXX_COMPILER}" PATH) +endif () + +# if we have a g++ cross compiler, they have usually some prefix, like +# e.g. powerpc-linux-g++, arm-elf-g++ or i586-mingw32msvc-g++ , optionally +# with a 3-component version number at the end (e.g. arm-eabi-gcc-4.5.2). +# The other tools of the toolchain usually have the same prefix +# NAME_WE cannot be used since then this test will fail for names like +# "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be +# "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" + + +if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) + + if("${CMAKE_OBJCXX_COMPILER_ID}" MATCHES "GNU|Clang|QCC") + get_filename_component(COMPILER_BASENAME "${CMAKE_OBJCXX_COMPILER}" NAME) + if (COMPILER_BASENAME MATCHES "^(.+-)(clan)?[gc]\\+\\+(-[0-9]+(\\.[0-9]+)*)?(-[^.]+)?(\\.exe)?$") + set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + set(_CMAKE_COMPILER_SUFFIX ${CMAKE_MATCH_5}) + elseif("${CMAKE_OBJCXX_COMPILER_ID}" MATCHES "Clang") + if(CMAKE_OBJCXX_COMPILER_TARGET) + set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_OBJCXX_COMPILER_TARGET}-) + endif() + elseif(COMPILER_BASENAME MATCHES "QCC(\\.exe)?$") + if(CMAKE_OBJCXX_COMPILER_TARGET MATCHES "gcc_nto([a-z0-9]+_[0-9]+|[^_le]+)(le)") + set(_CMAKE_TOOLCHAIN_PREFIX nto${CMAKE_MATCH_1}-) + endif() + endif () + + # if "llvm-" is part of the prefix, remove it, since llvm doesn't have its own binutils + # but uses the regular ar, objcopy, etc. (instead of llvm-objcopy etc.) + if ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") + set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + endif () + endif() + +endif () + +set(_CMAKE_PROCESSING_LANGUAGE "OBJCXX") +include(CMakeFindBinUtils) +include(Compiler/${CMAKE_OBJCXX_COMPILER_ID}-FindBinUtils OPTIONAL) +unset(_CMAKE_PROCESSING_LANGUAGE) + +if(CMAKE_OBJCXX_COMPILER_ARCHITECTURE_ID) + set(_SET_CMAKE_OBJCXX_COMPILER_ARCHITECTURE_ID + "set(CMAKE_OBJCXX_COMPILER_ARCHITECTURE_ID ${CMAKE_OBJCXX_COMPILER_ARCHITECTURE_ID})") +else() + set(_SET_CMAKE_OBJCXX_COMPILER_ARCHITECTURE_ID "") +endif() + +if(CMAKE_OBJCXX_XCODE_ARCHS) + set(SET_CMAKE_XCODE_ARCHS + "set(CMAKE_XCODE_ARCHS \"${CMAKE_OBJCXX_XCODE_ARCHS}\")") +endif() + +# configure all variables set in this file +configure_file(${CMAKE_ROOT}/Modules/CMakeOBJCXXCompiler.cmake.in + ${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCXXCompiler.cmake + @ONLY + ) + +set(CMAKE_OBJCXX_COMPILER_ENV_VAR "OBJCXX") diff --git a/Modules/CMakeOBJCXXCompiler.cmake.in b/Modules/CMakeOBJCXXCompiler.cmake.in new file mode 100644 index 0000000..b6452c4 --- /dev/null +++ b/Modules/CMakeOBJCXXCompiler.cmake.in @@ -0,0 +1,79 @@ +set(CMAKE_OBJCXX_COMPILER "@CMAKE_OBJCXX_COMPILER@") +set(CMAKE_OBJCXX_COMPILER_ARG1 "@CMAKE_OBJCXX_COMPILER_ARG1@") +set(CMAKE_OBJCXX_COMPILER_ID "@CMAKE_OBJCXX_COMPILER_ID@") +set(CMAKE_OBJCXX_COMPILER_VERSION "@CMAKE_OBJCXX_COMPILER_VERSION@") +set(CMAKE_OBJCXX_COMPILER_VERSION_INTERNAL "@CMAKE_OBJCXX_COMPILER_VERSION_INTERNAL@") +set(CMAKE_OBJCXX_COMPILER_WRAPPER "@CMAKE_OBJCXX_COMPILER_WRAPPER@") +set(CMAKE_OBJCXX_STANDARD_COMPUTED_DEFAULT "@CMAKE_OBJCXX_STANDARD_COMPUTED_DEFAULT@") +set(CMAKE_OBJCXX_COMPILE_FEATURES "@CMAKE_OBJCXX_COMPILE_FEATURES@") +set(CMAKE_OBJCXX98_COMPILE_FEATURES "@CMAKE_OBJCXX98_COMPILE_FEATURES@") +set(CMAKE_OBJCXX11_COMPILE_FEATURES "@CMAKE_OBJCXX11_COMPILE_FEATURES@") +set(CMAKE_OBJCXX14_COMPILE_FEATURES "@CMAKE_OBJCXX14_COMPILE_FEATURES@") +set(CMAKE_OBJCXX17_COMPILE_FEATURES "@CMAKE_OBJCXX17_COMPILE_FEATURES@") +set(CMAKE_OBJCXX20_COMPILE_FEATURES "@CMAKE_OBJCXX20_COMPILE_FEATURES@") + +set(CMAKE_OBJCXX_PLATFORM_ID "@CMAKE_OBJCXX_PLATFORM_ID@") +set(CMAKE_OBJCXX_SIMULATE_ID "@CMAKE_OBJCXX_SIMULATE_ID@") +set(CMAKE_OBJCXX_COMPILER_FRONTEND_VARIANT "@CMAKE_OBJCXX_COMPILER_FRONTEND_VARIANT@") +set(CMAKE_OBJCXX_SIMULATE_VERSION "@CMAKE_OBJCXX_SIMULATE_VERSION@") + at _SET_CMAKE_OBJCXX_COMPILER_ARCHITECTURE_ID@ + at SET_CMAKE_XCODE_ARCHS@ +set(CMAKE_AR "@CMAKE_AR@") +set(CMAKE_OBJCXX_COMPILER_AR "@CMAKE_OBJCXX_COMPILER_AR@") +set(CMAKE_RANLIB "@CMAKE_RANLIB@") +set(CMAKE_OBJCXX_COMPILER_RANLIB "@CMAKE_OBJCXX_COMPILER_RANLIB@") +set(CMAKE_LINKER "@CMAKE_LINKER@") +set(CMAKE_MT "@CMAKE_MT@") +set(CMAKE_COMPILER_IS_GNUOBJCXX @CMAKE_COMPILER_IS_GNUOBJCXX@) +set(CMAKE_OBJCXX_COMPILER_LOADED 1) +set(CMAKE_OBJCXX_COMPILER_WORKS @CMAKE_OBJCXX_COMPILER_WORKS@) +set(CMAKE_OBJCXX_ABI_COMPILED @CMAKE_OBJCXX_ABI_COMPILED@) + +set(CMAKE_OBJCXX_COMPILER_ENV_VAR "OBJCXX") + +set(CMAKE_OBJCXX_COMPILER_ID_RUN 1) +set(CMAKE_OBJCXX_SOURCE_FILE_EXTENSIONS M;m;mm) +set(CMAKE_OBJCXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O) + +if (CMAKE_OBJC_COMPILER_ID_RUN) + foreach(extension IN LISTS CMAKE_OBJC_SOURCE_FILE_EXTENSIONS) + list(REMOVE_ITEM CMAKE_OBJCXX_SOURCE_FILE_EXTENSIONS ${extension}) + endforeach() +endif() + +foreach (lang C CXX OBJC) + foreach(extension IN LISTS CMAKE_OBJCXX_SOURCE_FILE_EXTENSIONS) + if (CMAKE_${lang}_COMPILER_ID_RUN) + list(REMOVE_ITEM CMAKE_${lang}_SOURCE_FILE_EXTENSIONS ${extension}) + endif() + endforeach() +endforeach() + +set(CMAKE_OBJCXX_LINKER_PREFERENCE 25) +set(CMAKE_OBJCXX_LINKER_PREFERENCE_PROPAGATES 1) + +# Save compiler ABI information. +set(CMAKE_OBJCXX_SIZEOF_DATA_PTR "@CMAKE_OBJCXX_SIZEOF_DATA_PTR@") +set(CMAKE_OBJCXX_COMPILER_ABI "@CMAKE_OBJCXX_COMPILER_ABI@") +set(CMAKE_OBJCXX_LIBRARY_ARCHITECTURE "@CMAKE_OBJCXX_LIBRARY_ARCHITECTURE@") + +if(CMAKE_OBJCXX_SIZEOF_DATA_PTR) + set(CMAKE_SIZEOF_VOID_P "${CMAKE_OBJCXX_SIZEOF_DATA_PTR}") +endif() + +if(CMAKE_OBJCXX_COMPILER_ABI) + set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_OBJCXX_COMPILER_ABI}") +endif() + +if(CMAKE_OBJCXX_LIBRARY_ARCHITECTURE) + set(CMAKE_LIBRARY_ARCHITECTURE "@CMAKE_OBJCXX_LIBRARY_ARCHITECTURE@") +endif() + + at CMAKE_OBJCXX_COMPILER_CUSTOM_CODE@ + at CMAKE_OBJCXX_SYSROOT_FLAG_CODE@ + at CMAKE_OBJCXX_OSX_DEPLOYMENT_TARGET_FLAG_CODE@ + +set(CMAKE_OBJCXX_IMPLICIT_INCLUDE_DIRECTORIES "@CMAKE_OBJCXX_IMPLICIT_INCLUDE_DIRECTORIES@") +set(CMAKE_OBJCXX_IMPLICIT_LINK_LIBRARIES "@CMAKE_OBJCXX_IMPLICIT_LINK_LIBRARIES@") +set(CMAKE_OBJCXX_IMPLICIT_LINK_DIRECTORIES "@CMAKE_OBJCXX_IMPLICIT_LINK_DIRECTORIES@") +set(CMAKE_OBJCXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_OBJCXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@") diff --git a/Modules/CMakeOBJCXXCompilerABI.mm b/Modules/CMakeOBJCXXCompilerABI.mm new file mode 100644 index 0000000..288a58c --- /dev/null +++ b/Modules/CMakeOBJCXXCompilerABI.mm @@ -0,0 +1,20 @@ +#ifndef __cplusplus +# error "A C compiler has been selected for Objective-C++." +#endif + +/*--------------------------------------------------------------------------*/ + +#include "CMakeCompilerABI.h" + +/*--------------------------------------------------------------------------*/ + +int main(int argc, char *argv[]) +{ + int require = 0; + require += info_sizeof_dptr[argc]; +#if defined(ABI_ID) + require += info_abi[argc]; +#endif + (void)argv; + return require; +} diff --git a/Modules/CMakeOBJCXXCompilerId.mm.in b/Modules/CMakeOBJCXXCompilerId.mm.in new file mode 100644 index 0000000..fe04de1 --- /dev/null +++ b/Modules/CMakeOBJCXXCompilerId.mm.in @@ -0,0 +1,68 @@ +/* This source file must have a .cpp extension so that all C++ compilers + recognize the extension without flags. Borland does not know .cxx for + example. */ +#ifndef __cplusplus +# error "An Objective-C compiler has been selected for Objective-C++." +#endif + + at CMAKE_OBJCXX_COMPILER_ID_CONTENT@ + +/* Construct the string literal in pieces to prevent the source from + getting matched. Store it in a pointer rather than an array + because some compilers will just produce instructions to fill the + array rather than assigning a pointer to a static array. */ +char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; +#ifdef SIMULATE_ID +char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; +#endif + +#ifdef __QNXNTO__ +char const* qnxnto = "INFO" ":" "qnxnto[]"; +#endif + + at CMAKE_OBJCXX_COMPILER_ID_PLATFORM_CONTENT@ + at CMAKE_OBJCXX_COMPILER_ID_ERROR_FOR_TEST@ + +#if defined(_MSC_VER) && defined(_MSVC_LANG) +#define CXX_STD _MSVC_LANG +#else +#define CXX_STD __cplusplus +#endif + +const char* info_language_dialect_default = "INFO" ":" "dialect_default[" +#if CXX_STD > 201703L + "20" +#elif CXX_STD >= 201703L + "17" +#elif CXX_STD >= 201402L + "14" +#elif CXX_STD >= 201103L + "11" +#else + "98" +#endif +"]"; + +/*--------------------------------------------------------------------------*/ + +int main(int argc, char* argv[]) +{ + int require = 0; + require += info_compiler[argc]; + require += info_platform[argc]; +#ifdef COMPILER_VERSION_MAJOR + require += info_version[argc]; +#endif +#ifdef COMPILER_VERSION_INTERNAL + require += info_version_internal[argc]; +#endif +#ifdef SIMULATE_ID + require += info_simulate[argc]; +#endif +#ifdef SIMULATE_VERSION_MAJOR + require += info_simulate_version[argc]; +#endif + require += info_language_dialect_default[argc]; + (void)argv; + return require; +} diff --git a/Modules/CMakeOBJCXXInformation.cmake b/Modules/CMakeOBJCXXInformation.cmake new file mode 100644 index 0000000..3f55b01 --- /dev/null +++ b/Modules/CMakeOBJCXXInformation.cmake @@ -0,0 +1,273 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + + +# This file sets the basic flags for the Objective-C++ language in CMake. +# It also loads the available platform file for the system-compiler +# if it exists. +# It also loads a system - compiler - processor (or target hardware) +# specific file, which is mainly useful for crosscompiling and embedded systems. + +include(CMakeLanguageInformation) + +# some compilers use different extensions (e.g. sdcc uses .rel) +# so set the extension here first so it can be overridden by the compiler specific file +set(CMAKE_OBJCXX_OUTPUT_EXTENSION .o) + +set(_INCLUDED_FILE 0) + +# Load compiler-specific information. +if(CMAKE_OBJCXX_COMPILER_ID) + include(Compiler/${CMAKE_OBJCXX_COMPILER_ID}-OBJCXX OPTIONAL) +endif() + +set(CMAKE_BASE_NAME) +get_filename_component(CMAKE_BASE_NAME "${CMAKE_OBJCXX_COMPILER}" NAME_WE) +# since the gnu compiler has several names force g++ +if(CMAKE_COMPILER_IS_GNUOBJCXX) + set(CMAKE_BASE_NAME g++) +endif() + + +# load a hardware specific file, mostly useful for embedded compilers +if(CMAKE_SYSTEM_PROCESSOR) + if(CMAKE_OBJCXX_COMPILER_ID) + include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_OBJCXX_COMPILER_ID}-OBJCXX-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE) + endif() + if (NOT _INCLUDED_FILE) + include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL) + endif () +endif() + +# load the system- and compiler specific files +if(CMAKE_OBJCXX_COMPILER_ID) + include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_OBJCXX_COMPILER_ID}-OBJCXX OPTIONAL RESULT_VARIABLE _INCLUDED_FILE) +endif() +if (NOT _INCLUDED_FILE) + include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL + RESULT_VARIABLE _INCLUDED_FILE) +endif () + +# load any compiler-wrapper specific information +if (CMAKE_OBJCXX_COMPILER_WRAPPER) + __cmake_include_compiler_wrapper(OBJCXX) +endif () + +# We specify the compiler information in the system file for some +# platforms, but this language may not have been enabled when the file +# was first included. Include it again to get the language info. +# Remove this when all compiler info is removed from system files. +if (NOT _INCLUDED_FILE) + include(Platform/${CMAKE_SYSTEM_NAME} OPTIONAL) +endif () + +if(CMAKE_OBJCXX_SIZEOF_DATA_PTR) + foreach(f ${CMAKE_OBJCXX_ABI_FILES}) + include(${f}) + endforeach() + unset(CMAKE_OBJCXX_ABI_FILES) +endif() + +# This should be included before the _INIT variables are +# used to initialize the cache. Since the rule variables +# have if blocks on them, users can still define them here. +# But, it should still be after the platform file so changes can +# be made to those values. + +if(CMAKE_USER_MAKE_RULES_OVERRIDE) + # Save the full path of the file so try_compile can use it. + include(${CMAKE_USER_MAKE_RULES_OVERRIDE} RESULT_VARIABLE _override) + set(CMAKE_USER_MAKE_RULES_OVERRIDE "${_override}") +endif() + +if(CMAKE_USER_MAKE_RULES_OVERRIDE_OBJCXX) + # Save the full path of the file so try_compile can use it. + include(${CMAKE_USER_MAKE_RULES_OVERRIDE_OBJCXX} RESULT_VARIABLE _override) + set(CMAKE_USER_MAKE_RULES_OVERRIDE_OBJCXX "${_override}") +endif() + + +# Create a set of shared library variable specific to Objective-C++ +# For 90% of the systems, these are the same flags as the Objective-C versions +# so if these are not set just copy the flags from the Objective-C version +if(NOT CMAKE_SHARED_LIBRARY_CREATE_OBJCXX_FLAGS) + set(CMAKE_SHARED_LIBRARY_CREATE_OBJCXX_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_OBJC_FLAGS}) +endif() + +if(NOT CMAKE_OBJCXX_COMPILE_OPTIONS_PIC) + set(CMAKE_OBJCXX_COMPILE_OPTIONS_PIC ${CMAKE_OBJC_COMPILE_OPTIONS_PIC}) +endif() + +if(NOT CMAKE_OBJCXX_COMPILE_OPTIONS_PIE) + set(CMAKE_OBJCXX_COMPILE_OPTIONS_PIE ${CMAKE_OBJC_COMPILE_OPTIONS_PIE}) +endif() +if(NOT CMAKE_OBJCXX_LINK_OPTIONS_PIE) + set(CMAKE_OBJCXX_LINK_OPTIONS_PIE ${CMAKE_OBJC_LINK_OPTIONS_PIE}) +endif() +if(NOT CMAKE_OBJCXX_LINK_OPTIONS_NO_PIE) + set(CMAKE_OBJCXX_LINK_OPTIONS_NO_PIE ${CMAKE_OBJC_LINK_OPTIONS_NO_PIE}) +endif() + +if(NOT CMAKE_OBJCXX_COMPILE_OPTIONS_DLL) + set(CMAKE_OBJCXX_COMPILE_OPTIONS_DLL ${CMAKE_OBJC_COMPILE_OPTIONS_DLL}) +endif() + +if(NOT CMAKE_SHARED_LIBRARY_OBJCXX_FLAGS) + set(CMAKE_SHARED_LIBRARY_OBJCXX_FLAGS ${CMAKE_SHARED_LIBRARY_OBJC_FLAGS}) +endif() + +if(NOT DEFINED CMAKE_SHARED_LIBRARY_LINK_OBJCXX_FLAGS) + set(CMAKE_SHARED_LIBRARY_LINK_OBJCXX_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_OBJC_FLAGS}) +endif() + +if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_OBJCXX_FLAG) + set(CMAKE_SHARED_LIBRARY_RUNTIME_OBJCXX_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_OBJC_FLAG}) +endif() + +if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_OBJCXX_FLAG_SEP) + set(CMAKE_SHARED_LIBRARY_RUNTIME_OBJCXX_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_OBJC_FLAG_SEP}) +endif() + +if(NOT CMAKE_SHARED_LIBRARY_RPATH_LINK_OBJCXX_FLAG) + set(CMAKE_SHARED_LIBRARY_RPATH_LINK_OBJCXX_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_OBJC_FLAG}) +endif() + +if(NOT DEFINED CMAKE_EXE_EXPORTS_OBJCXX_FLAG) + set(CMAKE_EXE_EXPORTS_OBJCXX_FLAG ${CMAKE_EXE_EXPORTS_OBJC_FLAG}) +endif() + +if(NOT DEFINED CMAKE_SHARED_LIBRARY_SONAME_OBJCXX_FLAG) + set(CMAKE_SHARED_LIBRARY_SONAME_OBJCXX_FLAG ${CMAKE_SHARED_LIBRARY_SONAME_OBJC_FLAG}) +endif() + +if(NOT CMAKE_EXECUTABLE_RUNTIME_OBJCXX_FLAG) + set(CMAKE_EXECUTABLE_RUNTIME_OBJCXX_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_OBJCXX_FLAG}) +endif() + +if(NOT CMAKE_EXECUTABLE_RUNTIME_OBJCXX_FLAG_SEP) + set(CMAKE_EXECUTABLE_RUNTIME_OBJCXX_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_OBJCXX_FLAG_SEP}) +endif() + +if(NOT CMAKE_EXECUTABLE_RPATH_LINK_OBJCXX_FLAG) + set(CMAKE_EXECUTABLE_RPATH_LINK_OBJCXX_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_OBJCXX_FLAG}) +endif() + +if(NOT DEFINED CMAKE_SHARED_LIBRARY_LINK_OBJCXX_WITH_RUNTIME_PATH) + set(CMAKE_SHARED_LIBRARY_LINK_OBJCXX_WITH_RUNTIME_PATH ${CMAKE_SHARED_LIBRARY_LINK_OBJC_WITH_RUNTIME_PATH}) +endif() + +if(NOT CMAKE_INCLUDE_FLAG_OBJCXX) + set(CMAKE_INCLUDE_FLAG_OBJCXX ${CMAKE_INCLUDE_FLAG_C}) +endif() + +# for most systems a module is the same as a shared library +# so unless the variable CMAKE_MODULE_EXISTS is set just +# copy the values from the LIBRARY variables +if(NOT CMAKE_MODULE_EXISTS) + set(CMAKE_SHARED_MODULE_OBJCXX_FLAGS ${CMAKE_SHARED_LIBRARY_OBJCXX_FLAGS}) + set(CMAKE_SHARED_MODULE_CREATE_OBJCXX_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_OBJCXX_FLAGS}) +endif() + +# repeat for modules +if(NOT CMAKE_SHARED_MODULE_CREATE_OBJCXX_FLAGS) + set(CMAKE_SHARED_MODULE_CREATE_OBJCXX_FLAGS ${CMAKE_SHARED_MODULE_CREATE_OBJC_FLAGS}) +endif() + +if(NOT CMAKE_SHARED_MODULE_OBJCXX_FLAGS) + set(CMAKE_SHARED_MODULE_OBJCXX_FLAGS ${CMAKE_SHARED_MODULE_OBJC_FLAGS}) +endif() + +# Initialize OBJCXX link type selection flags from OBJC versions. +foreach(type SHARED_LIBRARY SHARED_MODULE EXE) + if(NOT CMAKE_${type}_LINK_STATIC_OBJCXX_FLAGS) + set(CMAKE_${type}_LINK_STATIC_OBJCXX_FLAGS + ${CMAKE_${type}_LINK_STATIC_OBJC_FLAGS}) + endif() + if(NOT CMAKE_${type}_LINK_DYNAMIC_OBJCXX_FLAGS) + set(CMAKE_${type}_LINK_DYNAMIC_OBJCXX_FLAGS + ${CMAKE_${type}_LINK_DYNAMIC_OBJC_FLAGS}) + endif() +endforeach() + +# add the flags to the cache based +# on the initial values computed in the platform/*.cmake files +# use _INIT variables so that this only happens the first time +# and you can set these flags in the cmake cache +set(CMAKE_OBJCXX_FLAGS_INIT "$ENV{OBJCXXFLAGS} ${CMAKE_OBJCXX_FLAGS_INIT}") + +cmake_initialize_per_config_variable(CMAKE_OBJCXX_FLAGS "Flags used by the Objective-C++ compiler") + +if(CMAKE_OBJCXX_STANDARD_LIBRARIES_INIT) + set(CMAKE_OBJCXX_STANDARD_LIBRARIES "${CMAKE_OBJCXX_STANDARD_LIBRARIES_INIT}" + CACHE STRING "Libraries linked by default with all Objective-C++ applications.") + mark_as_advanced(CMAKE_OBJCXX_STANDARD_LIBRARIES) +endif() + +include(CMakeCommonLanguageInclude) + +# now define the following rules: +# CMAKE_OBJCXX_CREATE_SHARED_LIBRARY +# CMAKE_OBJCXX_CREATE_SHARED_MODULE +# CMAKE_OBJCXX_COMPILE_OBJECT +# CMAKE_OBJCXX_LINK_EXECUTABLE + +# variables supplied by the generator at use time +# +# the target without the suffix +# +# +# +# +# + +# Objective-C++ compiler information +# +# +# +# + +# Static library tools +# +# + + +# create a shared Objective-C++ library +if(NOT CMAKE_OBJCXX_CREATE_SHARED_LIBRARY) + set(CMAKE_OBJCXX_CREATE_SHARED_LIBRARY + " -o ") +endif() + +# create an Objective-C++ shared module copy the shared library rule by default +if(NOT CMAKE_OBJCXX_CREATE_SHARED_MODULE) + set(CMAKE_OBJCXX_CREATE_SHARED_MODULE ${CMAKE_OBJCXX_CREATE_SHARED_LIBRARY}) +endif() + + +# Create a static archive incrementally for large object file counts. +# If CMAKE_OBJCXX_CREATE_STATIC_LIBRARY is set it will override these. +if(NOT DEFINED CMAKE_OBJCXX_ARCHIVE_CREATE) + set(CMAKE_OBJCXX_ARCHIVE_CREATE " qc ") +endif() +if(NOT DEFINED CMAKE_OBJCXX_ARCHIVE_APPEND) + set(CMAKE_OBJCXX_ARCHIVE_APPEND " q ") +endif() +if(NOT DEFINED CMAKE_OBJCXX_ARCHIVE_FINISH) + set(CMAKE_OBJCXX_ARCHIVE_FINISH " ") +endif() + +# compile an Objective-C++ file into an object file +if(NOT CMAKE_OBJCXX_COMPILE_OBJECT) + set(CMAKE_OBJCXX_COMPILE_OBJECT + " -o -c ") +endif() + +if(NOT CMAKE_OBJCXX_LINK_EXECUTABLE) + set(CMAKE_OBJCXX_LINK_EXECUTABLE + " -o ") +endif() + +mark_as_advanced( +CMAKE_VERBOSE_MAKEFILE +) + +set(CMAKE_OBJCXX_INFORMATION_LOADED 1) diff --git a/Modules/CMakeTestOBJCXXCompiler.cmake b/Modules/CMakeTestOBJCXXCompiler.cmake new file mode 100644 index 0000000..bcce2f1 --- /dev/null +++ b/Modules/CMakeTestOBJCXXCompiler.cmake @@ -0,0 +1,93 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + + +if(CMAKE_OBJCXX_COMPILER_FORCED) + # The compiler configuration was forced by the user. + # Assume the user has configured all compiler information. + set(CMAKE_OBJCXX_COMPILER_WORKS TRUE) + return() +endif() + +include(CMakeTestCompilerCommon) + +# work around enforced code signing and / or missing exectuable target type +set(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE}) +if(_CMAKE_FEATURE_DETECTION_TARGET_TYPE) + set(CMAKE_TRY_COMPILE_TARGET_TYPE ${_CMAKE_FEATURE_DETECTION_TARGET_TYPE}) +endif() + +# Remove any cached result from an older CMake version. +# We now store this in CMakeOBJCXXCompiler.cmake. +unset(CMAKE_OBJCXX_COMPILER_WORKS CACHE) + +# This file is used by EnableLanguage in cmGlobalGenerator to +# determine that the selected Objective-C++ compiler can actually compile +# and link the most basic of programs. If not, a fatal error +# is set and cmake stops processing commands and will not generate +# any makefiles or projects. +if(NOT CMAKE_OBJCXX_COMPILER_WORKS) + PrintTestCompilerStatus("OBJCXX" "") + __TestCompiler_setTryCompileTargetType() + file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCXXCompiler.mm + "#ifndef __cplusplus\n" + "# error \"The CMAKE_OBJCXX_COMPILER is set to a C compiler\"\n" + "#endif\n" + "#ifndef __OBJC__\n" + "# error \"The CMAKE_OBJCXX_COMPILER is not an Objective-C++ compiler\"\n" + "#endif\n" + "int main(){return 0;}\n") + try_compile(CMAKE_OBJCXX_COMPILER_WORKS ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCXXCompiler.mm + OUTPUT_VARIABLE __CMAKE_OBJCXX_COMPILER_OUTPUT) + # Move result from cache to normal variable. + set(CMAKE_OBJCXX_COMPILER_WORKS ${CMAKE_OBJCXX_COMPILER_WORKS}) + unset(CMAKE_OBJCXX_COMPILER_WORKS CACHE) + set(OBJCXX_TEST_WAS_RUN 1) + __TestCompiler_restoreTryCompileTargetType() +endif() + +if(NOT CMAKE_OBJCXX_COMPILER_WORKS) + PrintTestCompilerStatus("OBJCXX" " -- broken") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the Objective-C++ compiler works failed with " + "the following output:\n${__CMAKE_OBJCXX_COMPILER_OUTPUT}\n\n") + string(REPLACE "\n" "\n " _output "${__CMAKE_OBJCXX_COMPILER_OUTPUT}") + message(FATAL_ERROR "The Objective-C++ compiler\n \"${CMAKE_OBJCXX_COMPILER}\"\n" + "is not able to compile a simple test program.\nIt fails " + "with the following output:\n ${_output}\n\n" + "CMake will not be able to correctly generate this project.") +else() + if(OBJCXX_TEST_WAS_RUN) + PrintTestCompilerStatus("OBJCXX" " -- works") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the Objective-C++ compiler works passed with " + "the following output:\n${__CMAKE_OBJCXX_COMPILER_OUTPUT}\n\n") + endif() + + # Try to identify the ABI and configure it into CMakeOBJCXXCompiler.cmake + include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) + CMAKE_DETERMINE_COMPILER_ABI(OBJCXX ${CMAKE_ROOT}/Modules/CMakeOBJCXXCompilerABI.mm) + # Try to identify the compiler features + include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake) + CMAKE_DETERMINE_COMPILE_FEATURES(OBJCXX) + + # Re-configure to save learned information. + configure_file( + ${CMAKE_ROOT}/Modules/CMakeOBJCXXCompiler.cmake.in + ${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCXXCompiler.cmake + @ONLY + ) + include(${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCXXCompiler.cmake) + + if(CMAKE_OBJCXX_SIZEOF_DATA_PTR) + foreach(f ${CMAKE_OBJCXX_ABI_FILES}) + include(${f}) + endforeach() + unset(CMAKE_OBJCXX_ABI_FILES) + endif() +endif() + +set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE}) +unset(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE) +unset(__CMAKE_OBJCXX_COMPILER_OUTPUT) diff --git a/Modules/CheckOBJCXXCompilerFlag.cmake b/Modules/CheckOBJCXXCompilerFlag.cmake new file mode 100644 index 0000000..c32741b --- /dev/null +++ b/Modules/CheckOBJCXXCompilerFlag.cmake @@ -0,0 +1,64 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +CheckOBJCXXCompilerFlag +----------------------- + +Check whether the Objective-C++ compiler supports a given flag. + +.. command:: check_objcxx_compiler_flag + + .. code-block:: cmake + + check_objcxx_compiler_flag( ) + + Check that the ```` is accepted by the compiler without + a diagnostic. Stores the result in an internal cache entry + named ````. + +This command temporarily sets the ``CMAKE_REQUIRED_DEFINITIONS`` variable +and calls the ``check_objcxx_source_compiles`` macro from the +:module:`CheckOBJCXXSourceCompiles` module. See documentation of that +module for a listing of variables that can otherwise modify the build. + +A positive result from this check indicates only that the compiler did not +issue a diagnostic message when given the flag. Whether the flag has any +effect or even a specific one is beyond the scope of this module. + +.. note:: + Since the :command:`try_compile` command forwards flags from variables + like :variable:`CMAKE_OBJCXX_FLAGS _FLAGS>`, unknown flags + in such variables may cause a false negative for this check. +#]=======================================================================] + +include_guard(GLOBAL) +include(CheckOBJCXXSourceCompiles) +include(CMakeCheckCompilerFlagCommonPatterns) + +macro (CHECK_OBJCXX_COMPILER_FLAG _FLAG _RESULT) + set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}") + set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}") + + # Normalize locale during test compilation. + set(_CheckOBJCXXCompilerFlag_LOCALE_VARS LC_ALL LC_MESSAGES LANG) + foreach(v ${_CheckOBJCXXCompilerFlag_LOCALE_VARS}) + set(_CheckOBJCXXCompilerFlag_SAVED_${v} "$ENV{${v}}") + set(ENV{${v}} OBJCXX) + endforeach() + CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckOBJCXXCompilerFlag_COMMON_PATTERNS) + CHECK_OBJCXX_SOURCE_COMPILES("#ifndef __OBJC__\n# error \"Not an Objective-C++ compiler\"\n#endif\nint main(void) { return 0; }" ${_RESULT} + # Some compilers do not fail with a bad flag + FAIL_REGEX "command line option .* is valid for .* but not for Objective-C\\\\+\\\\+" # GNU + FAIL_REGEX "argument unused during compilation: .*" # Clang + ${_CheckOBJCXXCompilerFlag_COMMON_PATTERNS} + ) + foreach(v ${_CheckOBJCXXCompilerFlag_LOCALE_VARS}) + set(ENV{${v}} ${_CheckOBJCXXCompilerFlag_SAVED_${v}}) + unset(_CheckOBJCXXCompilerFlag_SAVED_${v}) + endforeach() + unset(_CheckOBJCXXCompilerFlag_LOCALE_VARS) + unset(_CheckOBJCXXCompilerFlag_COMMON_PATTERNS) + + set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}") +endmacro () diff --git a/Modules/CheckOBJCXXSourceCompiles.cmake b/Modules/CheckOBJCXXSourceCompiles.cmake new file mode 100644 index 0000000..4c0fdd0 --- /dev/null +++ b/Modules/CheckOBJCXXSourceCompiles.cmake @@ -0,0 +1,146 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +CheckOBJCXXSourceCompiles +------------------------- + +Check if given Objective-C++ source compiles and links into an executable. + +.. command:: check_objcxx_source_compiles + + .. code-block:: cmake + + check_objcxx_source_compiles( + [FAIL_REGEX [...]]) + + Check that the source supplied in ```` can be compiled as a Objective-C++ source + file and linked as an executable (so it must contain at least a ``main()`` + function). The result will be stored in the internal cache variable specified + by ````, with a boolean true value for success and boolean false + for failure. If ``FAIL_REGEX`` is provided, then failure is determined by + checking if anything in the output matches any of the specified regular + expressions. + + The underlying check is performed by the :command:`try_compile` command. The + compile and link commands can be influenced by setting any of the following + variables prior to calling ``check_objcxx_source_compiles()``: + + ``CMAKE_REQUIRED_FLAGS`` + Additional flags to pass to the compiler. Note that the contents of + :variable:`CMAKE_OBJCXX_FLAGS _FLAGS>` and its associated + configuration-specific variable are automatically added to the compiler + command before the contents of ``CMAKE_REQUIRED_FLAGS``. + + ``CMAKE_REQUIRED_DEFINITIONS`` + A :ref:`;-list ` of compiler definitions of the form + ``-DFOO`` or ``-DFOO=bar``. A definition for the name specified by + ```` will also be added automatically. + + ``CMAKE_REQUIRED_INCLUDES`` + A :ref:`;-list ` of header search paths to pass to + the compiler. These will be the only header search paths used by + ``try_compile()``, i.e. the contents of the :prop_dir:`INCLUDE_DIRECTORIES` + directory property will be ignored. + + ``CMAKE_REQUIRED_LINK_OPTIONS`` + A :ref:`;-list ` of options to add to the link + command (see :command:`try_compile` for further details). + + ``CMAKE_REQUIRED_LIBRARIES`` + A :ref:`;-list ` of libraries to add to the link + command. These can be the name of system libraries or they can be + :ref:`Imported Targets ` (see :command:`try_compile` for + further details). + + ``CMAKE_REQUIRED_QUIET`` + If this variable evaluates to a boolean true value, all status messages + associated with the check will be suppressed. + + The check is only performed once, with the result cached in the variable + named by ````. Every subsequent CMake run will re-use this cached + value rather than performing the check again, even if the ```` changes. + In order to force the check to be re-evaluated, the variable named by + ```` must be manually removed from the cache. + +#]=======================================================================] + +include_guard(GLOBAL) + +macro(CHECK_OBJCXX_SOURCE_COMPILES SOURCE VAR) + if(NOT DEFINED "${VAR}") + set(_FAIL_REGEX) + set(_key) + foreach(arg ${ARGN}) + if("${arg}" MATCHES "^(FAIL_REGEX)$") + set(_key "${arg}") + elseif(_key) + list(APPEND _${_key} "${arg}") + else() + message(FATAL_ERROR "Unknown argument:\n ${arg}\n") + endif() + endforeach() + + set(MACRO_CHECK_FUNCTION_DEFINITIONS + "-D${VAR} ${CMAKE_REQUIRED_FLAGS}") + if(CMAKE_REQUIRED_LINK_OPTIONS) + set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_LINK_OPTIONS + LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS}) + else() + set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_LINK_OPTIONS) + endif() + if(CMAKE_REQUIRED_LIBRARIES) + set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_LIBRARIES + LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) + else() + set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_LIBRARIES) + endif() + if(CMAKE_REQUIRED_INCLUDES) + set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_INCLUDES + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") + else() + set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_INCLUDES) + endif() + file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.mm" + "${SOURCE}\n") + + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR}") + endif() + try_compile(${VAR} + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.mm + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + ${CHECK_OBJCXX_SOURCE_COMPILES_ADD_LINK_OPTIONS} + ${CHECK_OBJCXX_SOURCE_COMPILES_ADD_LIBRARIES} + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} + "${CHECK_OBJCXX_SOURCE_COMPILES_ADD_INCLUDES}" + OUTPUT_VARIABLE OUTPUT) + + foreach(_regex ${_FAIL_REGEX}) + if("${OUTPUT}" MATCHES "${_regex}") + set(${VAR} 0) + endif() + endforeach() + + if(${VAR}) + set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Success") + endif() + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Performing Objective-C++ SOURCE FILE Test ${VAR} succeeded with the following output:\n" + "${OUTPUT}\n" + "Source file was:\n${SOURCE}\n") + else() + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Failed") + endif() + set(${VAR} "" CACHE INTERNAL "Test ${VAR}") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Performing Objective-C++ SOURCE FILE Test ${VAR} failed with the following output:\n" + "${OUTPUT}\n" + "Source file was:\n${SOURCE}\n") + endif() + endif() +endmacro() diff --git a/Modules/CheckOBJCXXSourceRuns.cmake b/Modules/CheckOBJCXXSourceRuns.cmake new file mode 100644 index 0000000..a3d5923 --- /dev/null +++ b/Modules/CheckOBJCXXSourceRuns.cmake @@ -0,0 +1,145 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +CheckOBJCXXSourceRuns +--------------------- + +Check if given Objective-C++ source compiles and links into an executable and can +subsequently be run. + +.. command:: check_objcxx_source_runs + + .. code-block:: cmake + + check_objcxx_source_runs( ) + + Check that the source supplied in ```` can be compiled as a Objective-C++ source + file, linked as an executable and then run. The ```` must contain at + least a ``main()`` function. If the ```` could be built and run + successfully, the internal cache variable specified by ```` will + be set to 1, otherwise it will be set to an value that evaluates to boolean + false (e.g. an empty string or an error message). + + The underlying check is performed by the :command:`try_run` command. The + compile and link commands can be influenced by setting any of the following + variables prior to calling ``check_objcxx_source_runs()``: + + ``CMAKE_REQUIRED_FLAGS`` + Additional flags to pass to the compiler. Note that the contents of + :variable:`CMAKE_OBJCXX_FLAGS _FLAGS>` and its associated + configuration-specific variable are automatically added to the compiler + command before the contents of ``CMAKE_REQUIRED_FLAGS``. + + ``CMAKE_REQUIRED_DEFINITIONS`` + A :ref:`;-list ` of compiler definitions of the form + ``-DFOO`` or ``-DFOO=bar``. A definition for the name specified by + ```` will also be added automatically. + + ``CMAKE_REQUIRED_INCLUDES`` + A :ref:`;-list ` of header search paths to pass to + the compiler. These will be the only header search paths used by + ``try_run()``, i.e. the contents of the :prop_dir:`INCLUDE_DIRECTORIES` + directory property will be ignored. + + ``CMAKE_REQUIRED_LINK_OPTIONS`` + A :ref:`;-list ` of options to add to the link + command (see :command:`try_run` for further details). + + ``CMAKE_REQUIRED_LIBRARIES`` + A :ref:`;-list ` of libraries to add to the link + command. These can be the name of system libraries or they can be + :ref:`Imported Targets ` (see :command:`try_run` for + further details). + + ``CMAKE_REQUIRED_QUIET`` + If this variable evaluates to a boolean true value, all status messages + associated with the check will be suppressed. + + The check is only performed once, with the result cached in the variable + named by ````. Every subsequent CMake run will re-use this cached + value rather than performing the check again, even if the ```` changes. + In order to force the check to be re-evaluated, the variable named by + ```` must be manually removed from the cache. + +#]=======================================================================] + +include_guard(GLOBAL) + +macro(CHECK_OBJCXX_SOURCE_RUNS SOURCE VAR) + if(NOT DEFINED "${VAR}") + set(MACRO_CHECK_FUNCTION_DEFINITIONS + "-D${VAR} ${CMAKE_REQUIRED_FLAGS}") + if(CMAKE_REQUIRED_LINK_OPTIONS) + set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_LINK_OPTIONS + LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS}) + else() + set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_LINK_OPTIONS) + endif() + if(CMAKE_REQUIRED_LIBRARIES) + set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_LIBRARIES + LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) + else() + set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_LIBRARIES) + endif() + if(CMAKE_REQUIRED_INCLUDES) + set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_INCLUDES + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") + else() + set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_INCLUDES) + endif() + file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.mm" + "${SOURCE}\n") + + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR}") + endif() + try_run(${VAR}_EXITCODE ${VAR}_COMPILED + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.mm + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + ${CHECK_OBJCXX_SOURCE_COMPILES_ADD_LINK_OPTIONS} + ${CHECK_OBJCXX_SOURCE_COMPILES_ADD_LIBRARIES} + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} + -DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH} + "${CHECK_OBJCXX_SOURCE_COMPILES_ADD_INCLUDES}" + COMPILE_OUTPUT_VARIABLE OUTPUT + RUN_OUTPUT_VARIABLE RUN_OUTPUT) + + # if it did not compile make the return value fail code of 1 + if(NOT ${VAR}_COMPILED) + set(${VAR}_EXITCODE 1) + endif() + # if the return value was 0 then it worked + if("${${VAR}_EXITCODE}" EQUAL 0) + set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Success") + endif() + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Performing Objective-C++ SOURCE FILE Test ${VAR} succeeded with the following output:\n" + "${OUTPUT}\n" + "...and run output:\n" + "${RUN_OUTPUT}\n" + "Return value: ${${VAR}}\n" + "Source file was:\n${SOURCE}\n") + else() + if(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES "FAILED_TO_RUN") + set(${VAR} "${${VAR}_EXITCODE}") + else() + set(${VAR} "" CACHE INTERNAL "Test ${VAR}") + endif() + + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Failed") + endif() + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Performing Objective-C++ SOURCE FILE Test ${VAR} failed with the following output:\n" + "${OUTPUT}\n" + "...and run output:\n" + "${RUN_OUTPUT}\n" + "Return value: ${${VAR}_EXITCODE}\n" + "Source file was:\n${SOURCE}\n") + endif() + endif() +endmacro() diff --git a/Modules/Compiler/AppleClang-OBJCXX.cmake b/Modules/Compiler/AppleClang-OBJCXX.cmake new file mode 100644 index 0000000..7c6f763 --- /dev/null +++ b/Modules/Compiler/AppleClang-OBJCXX.cmake @@ -0,0 +1,37 @@ +include(Compiler/Clang-OBJCXX) + +if(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 4.0) + set(CMAKE_OBJCXX98_STANDARD_COMPILE_OPTION "-std=c++98") + set(CMAKE_OBJCXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") + set(CMAKE_OBJCXX98_STANDARD__HAS_FULL_SUPPORT ON) + + set(CMAKE_OBJCXX11_STANDARD_COMPILE_OPTION "-std=c++11") + set(CMAKE_OBJCXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") +endif() + +if(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 6.1) + set(CMAKE_OBJCXX14_STANDARD_COMPILE_OPTION "-std=c++14") + set(CMAKE_OBJCXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14") + set(CMAKE_OBJCXX14_STANDARD__HAS_FULL_SUPPORT ON) +elseif(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 5.1) + # AppleClang 5.0 knows this flag, but does not set a __cplusplus macro greater than 201103L + set(CMAKE_OBJCXX14_STANDARD_COMPILE_OPTION "-std=c++1y") + set(CMAKE_OBJCXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y") + set(CMAKE_OBJCXX14_STANDARD__HAS_FULL_SUPPORT ON) +endif() + +if (NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 6.1) + set(CMAKE_OBJCXX17_STANDARD_COMPILE_OPTION "-std=c++1z") + set(CMAKE_OBJCXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z") +endif() + +if (NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 8.0) + set(CMAKE_OBJCXX11_STANDARD__HAS_FULL_SUPPORT ON) +endif() + +if (NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 10.0) + set(CMAKE_OBJCXX20_STANDARD_COMPILE_OPTION "-std=c++2a") + set(CMAKE_OBJCXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a") +endif() + +__compiler_check_default_language_standard(OBJCXX 4.0 98) diff --git a/Modules/Compiler/Clang-OBJCXX.cmake b/Modules/Compiler/Clang-OBJCXX.cmake new file mode 100644 index 0000000..b01ce64 --- /dev/null +++ b/Modules/Compiler/Clang-OBJCXX.cmake @@ -0,0 +1,70 @@ +include(Compiler/Clang) +__compiler_clang(OBJCXX) + +if("x${CMAKE_OBJCXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU") + if(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 2.1) + set(CMAKE_OBJCXX98_STANDARD_COMPILE_OPTION "-std=c++98") + set(CMAKE_OBJCXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") + endif() + + if(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 3.1) + set(CMAKE_OBJCXX98_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_OBJCXX11_STANDARD_COMPILE_OPTION "-std=c++11") + set(CMAKE_OBJCXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") + set(CMAKE_OBJCXX11_STANDARD__HAS_FULL_SUPPORT ON) + elseif(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 2.1) + set(CMAKE_OBJCXX11_STANDARD_COMPILE_OPTION "-std=c++0x") + set(CMAKE_OBJCXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x") + endif() + + if(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 3.5) + set(CMAKE_OBJCXX14_STANDARD_COMPILE_OPTION "-std=c++14") + set(CMAKE_OBJCXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14") + set(CMAKE_OBJCXX14_STANDARD__HAS_FULL_SUPPORT ON) + elseif(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 3.4) + set(CMAKE_OBJCXX14_STANDARD_COMPILE_OPTION "-std=c++1y") + set(CMAKE_OBJCXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y") + set(CMAKE_OBJCXX14_STANDARD__HAS_FULL_SUPPORT ON) + endif() + + set(_clang_version_std17 5.0) + + if (NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS "${_clang_version_std17}") + set(CMAKE_OBJCXX17_STANDARD_COMPILE_OPTION "-std=c++17") + set(CMAKE_OBJCXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17") + elseif (NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 3.5) + set(CMAKE_OBJCXX17_STANDARD_COMPILE_OPTION "-std=c++1z") + set(CMAKE_OBJCXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z") + endif() + + if (NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS "${_clang_version_std17}") + set(CMAKE_OBJCXX20_STANDARD_COMPILE_OPTION "-std=c++2a") + set(CMAKE_OBJCXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a") + endif() + + unset(_clang_version_std17) + + __compiler_check_default_language_standard(OBJCXX 2.1 98) +elseif(CMAKE_OBJCXX_COMPILER_VERSION VERSION_GREATER_EQUAL 3.9 + AND CMAKE_OBJCXX_SIMULATE_VERSION VERSION_GREATER_EQUAL 19.0) + # This version of clang-cl and the MSVC version it simulates have + # support for -std: flags. + set(CMAKE_OBJCXX98_STANDARD_COMPILE_OPTION "") + set(CMAKE_OBJCXX98_EXTENSION_COMPILE_OPTION "") + set(CMAKE_OBJCXX98_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_OBJCXX11_STANDARD_COMPILE_OPTION "") + set(CMAKE_OBJCXX11_EXTENSION_COMPILE_OPTION "") + set(CMAKE_OBJCXX14_STANDARD_COMPILE_OPTION "-std:c++14") + set(CMAKE_OBJCXX14_EXTENSION_COMPILE_OPTION "-std:c++14") + if (CMAKE_OBJCXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0) + set(CMAKE_OBJCXX17_STANDARD_COMPILE_OPTION "-std:c++17") + set(CMAKE_OBJCXX17_EXTENSION_COMPILE_OPTION "-std:c++17") + set(CMAKE_OBJCXX20_STANDARD_COMPILE_OPTION "-std:c++latest") + set(CMAKE_OBJCXX20_EXTENSION_COMPILE_OPTION "-std:c++latest") + else() + set(CMAKE_OBJCXX17_STANDARD_COMPILE_OPTION "-std:c++latest") + set(CMAKE_OBJCXX17_EXTENSION_COMPILE_OPTION "-std:c++latest") + endif() + + __compiler_check_default_language_standard(OBJCXX 3.9 14) +endif() diff --git a/Modules/Compiler/GNU-OBJCXX.cmake b/Modules/Compiler/GNU-OBJCXX.cmake new file mode 100644 index 0000000..66a547e --- /dev/null +++ b/Modules/Compiler/GNU-OBJCXX.cmake @@ -0,0 +1,10 @@ +include(Compiler/GNU) +__compiler_gnu(OBJC) + +if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.2) + set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") +endif() + +if(NOT CMAKE_OBJCXX_LINK_FLAGS) + set(CMAKE_OBCXX_LINK_FLAGS "-lstdc++") +endif() diff --git a/Modules/Platform/Apple-AppleClang-OBJCXX.cmake b/Modules/Platform/Apple-AppleClang-OBJCXX.cmake new file mode 100644 index 0000000..ed172f1 --- /dev/null +++ b/Modules/Platform/Apple-AppleClang-OBJCXX.cmake @@ -0,0 +1,6 @@ +include(Platform/Apple-Clang-OBJCXX) +if(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 4.2) + set(CMAKE_OBJCXX_SYSTEM_FRAMEWORK_SEARCH_FLAG "-iframework ") +else() + unset(CMAKE_OBJCXX_SYSTEM_FRAMEWORK_SEARCH_FLAG) +endif() diff --git a/Modules/Platform/Apple-Clang-OBJCXX.cmake b/Modules/Platform/Apple-Clang-OBJCXX.cmake new file mode 100644 index 0000000..28fc352 --- /dev/null +++ b/Modules/Platform/Apple-Clang-OBJCXX.cmake @@ -0,0 +1,2 @@ +include(Platform/Apple-Clang) +__apple_compiler_clang(OBJCXX) diff --git a/Modules/Platform/Apple-GNU-OBJCXX.cmake b/Modules/Platform/Apple-GNU-OBJCXX.cmake new file mode 100644 index 0000000..919e11d --- /dev/null +++ b/Modules/Platform/Apple-GNU-OBJCXX.cmake @@ -0,0 +1,4 @@ +include(Platform/Apple-GNU) +__apple_compiler_gnu(OBJCXX) +cmake_gnu_set_sysroot_flag(OBJCXX) +cmake_gnu_set_osx_deployment_target_flag(OBJCXX) diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index dcda7c5..d0bb359 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -120,14 +120,17 @@ set(CMAKE_CXX_CREATE_MACOSX_FRAMEWORK " -o ") set(CMAKE_OBJC_CREATE_MACOSX_FRAMEWORK - " -o -dynamiclib -install_name " -) + " -o ") + +set(CMAKE_OBJCXX_CREATE_MACOSX_FRAMEWORK + " -o ") # Set default framework search path flag for languages known to use a # preprocessor that may find headers in frameworks. set(CMAKE_C_FRAMEWORK_SEARCH_FLAG -F) set(CMAKE_CXX_FRAMEWORK_SEARCH_FLAG -F) set(CMAKE_OBJC_FRAMEWORK_SEARCH_FLAG -F) +set(CMAKE_OBJCXX_FRAMEWORK_SEARCH_FLAG -F) set(CMAKE_Fortran_FRAMEWORK_SEARCH_FLAG -F) # default to searching for frameworks first @@ -227,7 +230,7 @@ unset(_apps_paths) include(Platform/UnixPaths) if(_CMAKE_OSX_SYSROOT_PATH AND EXISTS ${_CMAKE_OSX_SYSROOT_PATH}/usr/include) list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${_CMAKE_OSX_SYSROOT_PATH}/usr) - foreach(lang C CXX OBJC) + foreach(lang C CXX OBJC OBJCXX) list(APPEND _CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES_INIT ${_CMAKE_OSX_SYSROOT_PATH}/usr/include) endforeach() endif() diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 641cbaf..5a35007 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -707,7 +707,8 @@ struct CompilerIdNode : public cmGeneratorExpressionNode }; static const CompilerIdNode cCompilerIdNode("C"), cxxCompilerIdNode("CXX"), - cudaCompilerIdNode("CUDA"), fortranCompilerIdNode("Fortran"); + cudaCompilerIdNode("CUDA"), objcCompilerIdNode("OBJC"), + objcxxCompilerIdNode("OBJCXX"), fortranCompilerIdNode("Fortran"); struct CompilerVersionNode : public cmGeneratorExpressionNode { @@ -771,6 +772,7 @@ struct CompilerVersionNode : public cmGeneratorExpressionNode static const CompilerVersionNode cCompilerVersionNode("C"), cxxCompilerVersionNode("CXX"), cudaCompilerVersionNode("CUDA"), + objcCompilerVersionNode("OBJC"), objcxxCompilerVersionNode("OBJCXX"), fortranCompilerVersionNode("Fortran"); struct PlatformIdNode : public cmGeneratorExpressionNode @@ -2243,6 +2245,8 @@ const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode( { "NOT", ¬Node }, { "C_COMPILER_ID", &cCompilerIdNode }, { "CXX_COMPILER_ID", &cxxCompilerIdNode }, + { "OBJC_COMPILER_ID", &objcCompilerIdNode }, + { "OBJCXX_COMPILER_ID", &objcxxCompilerIdNode }, { "CUDA_COMPILER_ID", &cudaCompilerIdNode }, { "Fortran_COMPILER_ID", &fortranCompilerIdNode }, { "VERSION_GREATER", &versionGreaterNode }, @@ -2253,6 +2257,8 @@ const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode( { "C_COMPILER_VERSION", &cCompilerVersionNode }, { "CXX_COMPILER_VERSION", &cxxCompilerVersionNode }, { "CUDA_COMPILER_VERSION", &cudaCompilerVersionNode }, + { "OBJC_COMPILER_VERSION", &objcCompilerVersionNode }, + { "OBJCXX_COMPILER_VERSION", &objcxxCompilerVersionNode }, { "Fortran_COMPILER_VERSION", &fortranCompilerVersionNode }, { "PLATFORM_ID", &platformIdNode }, { "COMPILE_FEATURES", &compileFeaturesNode }, diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 2e17e59..789fc0e 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -2365,6 +2365,42 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH ) list(APPEND TEST_BUILD_DIRS "${CMAKE_BINARY_DIR}/Tests/Objective-C/objc-file-extension-test") + add_test(Objective-CXX.simple-build-test ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Objective-C++/simple-build-test" + "${CMake_BINARY_DIR}/Tests/Objective-C++/simple-build-test" + --build-two-config + ${build_generator_args} + --build-project simple-build-test + --build-options ${build_options} + --test-command simple-build-test + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Objective-C++/simple-build-test") + + add_test(Objective-CXX.cxx-file-extension-test ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Objective-C++/cxx-file-extension-test" + "${CMake_BINARY_DIR}/Tests/Objective-C++/cxx-file-extension-test" + --build-two-config + ${build_generator_args} + --build-project cxx-file-extension-test + --build-options ${build_options} + --test-command cxx-file-extension-test + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Objective-C++/cxx-file-extension-test") + + add_test(Objective-CXX.objcxx-file-extension-test ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Objective-C++/objcxx-file-extension-test" + "${CMake_BINARY_DIR}/Tests/Objective-C++/objcxx-file-extension-test" + --build-two-config + ${build_generator_args} + --build-project objcxx-file-extension-test + --build-options ${build_options} + --test-command objcxx-file-extension-test + ) + list(APPEND TEST_BUILD_DIRS "${CMAKE_BINARY_DIR}/Tests/Objective-C++/objcxx-file-extension-test") + endif () endif () diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt index 1a25469..03babd2 100644 --- a/Tests/CMakeOnly/CMakeLists.txt +++ b/Tests/CMakeOnly/CMakeLists.txt @@ -36,6 +36,11 @@ if(CMAKE_OBJC_COMPILER) add_CMakeOnly_test(CheckOBJCCompilerFlag) endif() +if(CMAKE_OBJCXX_COMPILER) + add_CMakeOnly_test(CompilerIdOBJCXX) + add_CMakeOnly_test(CheckOBJCXXCompilerFlag) +endif() + if(CMAKE_Fortran_COMPILER) add_CMakeOnly_test(CompilerIdFortran) endif() diff --git a/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt b/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt index e9bdf6a..90aa921 100644 --- a/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt +++ b/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt @@ -5,16 +5,17 @@ include(CheckLanguage) set(langs ) set(expect_C 1) set(expect_CXX 1) + if(APPLE) set(expect_OBJC 1) + set(expect_OBJCXX 1) endif() unset(expect_Fortran) set(expect_NoSuchLanguage 0) set(LANGUAGES C CXX Fortran CUDA NoSuchLanguage) - if(APPLE) - list(APPEND LANGUAGES OBJC) + list(APPEND LANGUAGES OBJC OBJCXX) endif() foreach(lang ${LANGUAGES}) diff --git a/Tests/CMakeOnly/CheckOBJCXXCompilerFlag/CMakeLists.txt b/Tests/CMakeOnly/CheckOBJCXXCompilerFlag/CMakeLists.txt new file mode 100644 index 0000000..f83b738 --- /dev/null +++ b/Tests/CMakeOnly/CheckOBJCXXCompilerFlag/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 2.8.12) + +project(CheckOBJCXXCompilerFlag) + +include(CheckOBJCXXCompilerFlag) + +if(CMAKE_COMPILER_IS_GNUOBJCXX) + set(COMPILER_FLAG -fobjc-direct-dispatch) +else() + set(COMPILER_FLAG -fobjc-gc) +endif() + +CHECK_OBJCXX_COMPILER_FLAGS(${COMPILER_FLAG} HAS_COMPILER_FLAG) + +if(NOT HAS_COMPILER_FLAG) + message(SEND_ERROR "Test fail: HAS_COMPILER_FLAG: ${COMPILER_FLAG}") +endif() diff --git a/Tests/CMakeOnly/CompilerIdOBJCXX/CMakeLists.txt b/Tests/CMakeOnly/CompilerIdOBJCXX/CMakeLists.txt new file mode 100644 index 0000000..8f41db0 --- /dev/null +++ b/Tests/CMakeOnly/CompilerIdOBJCXX/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 2.8.12) +project(CompilerIdOBJCXX OBJCXX) + +foreach(v + CMAKE_OBJCXX_COMPILER + CMAKE_OBJCXX_COMPILER_ID + CMAKE_OBJCXX_COMPILER_VERSION + ) + if(${v}) + message(STATUS "${v}=[${${v}}]") + else() + message(SEND_ERROR "${v} not set!") + endif() +endforeach() diff --git a/Tests/Objective-C++/cxx-file-extension-test/CMakeLists.txt b/Tests/Objective-C++/cxx-file-extension-test/CMakeLists.txt new file mode 100644 index 0000000..0b33875 --- /dev/null +++ b/Tests/Objective-C++/cxx-file-extension-test/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.15) + +project(cxx-file-extension-test CXX) + +add_executable(cxx-file-extension-test main.mm) diff --git a/Tests/Objective-C++/cxx-file-extension-test/main.mm b/Tests/Objective-C++/cxx-file-extension-test/main.mm new file mode 100644 index 0000000..1c159a9 --- /dev/null +++ b/Tests/Objective-C++/cxx-file-extension-test/main.mm @@ -0,0 +1,8 @@ +#ifndef __OBJC__ +# error "Compiler cannot compile Objective-C" +#endif + +int main() +{ + return 0; +} diff --git a/Tests/Objective-C++/objcxx-file-extension-test/CMakeLists.txt b/Tests/Objective-C++/objcxx-file-extension-test/CMakeLists.txt new file mode 100644 index 0000000..eda7bba --- /dev/null +++ b/Tests/Objective-C++/objcxx-file-extension-test/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.15) + +project(objcxx-file-extension-test OBJCXX CXX) + +add_executable(objcxx-file-extension-test main.mm) +target_link_libraries(objcxx-file-extension-test "-framework Foundation") diff --git a/Tests/Objective-C++/objcxx-file-extension-test/main.mm b/Tests/Objective-C++/objcxx-file-extension-test/main.mm new file mode 100644 index 0000000..d4aa1bb --- /dev/null +++ b/Tests/Objective-C++/objcxx-file-extension-test/main.mm @@ -0,0 +1,14 @@ +#ifndef __OBJC__ +# error "Compiler is not an Objective-C compiler." +#endif + +#import +#include + +int main() +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + std::cout << "Hello World" << std::endl; + [pool release]; + return 0; +} diff --git a/Tests/Objective-C++/simple-build-test/CMakeLists.txt b/Tests/Objective-C++/simple-build-test/CMakeLists.txt new file mode 100644 index 0000000..cf27683 --- /dev/null +++ b/Tests/Objective-C++/simple-build-test/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.15) + +set(CMAKE_MACOSX_RPATH OFF) + +project(simple-build-test OBJCXX) + +add_library(foo SHARED foo.mm) +target_link_libraries(foo "-framework Foundation") + +add_executable(simple-build-test main.mm) +target_link_libraries(simple-build-test "-framework Foundation" foo) diff --git a/Tests/Objective-C++/simple-build-test/foo.h b/Tests/Objective-C++/simple-build-test/foo.h new file mode 100644 index 0000000..b3fb084 --- /dev/null +++ b/Tests/Objective-C++/simple-build-test/foo.h @@ -0,0 +1,9 @@ +#import + + at interface Foo : NSObject { + NSNumber* age; +} + + at property (nonatomic, retain) NSNumber* age; + + at end diff --git a/Tests/Objective-C++/simple-build-test/foo.mm b/Tests/Objective-C++/simple-build-test/foo.mm new file mode 100644 index 0000000..2d452a8 --- /dev/null +++ b/Tests/Objective-C++/simple-build-test/foo.mm @@ -0,0 +1,7 @@ +#import "foo.h" + + at implementation Foo + + at synthesize age; + + at end diff --git a/Tests/Objective-C++/simple-build-test/main.mm b/Tests/Objective-C++/simple-build-test/main.mm new file mode 100644 index 0000000..7c85551 --- /dev/null +++ b/Tests/Objective-C++/simple-build-test/main.mm @@ -0,0 +1,14 @@ +#import +#import "foo.h" +#include + +int main(int argc, char **argv) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + Foo *theFoo = [[Foo alloc] init]; + theFoo.age = [NSNumber numberWithInt:argc]; + NSLog(@"%d\n",[theFoo.age intValue]); + std::cout << [theFoo.age intValue] << std::endl; + [pool release]; + return 0; +} diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index 8fd8090..498e556 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required (VERSION 2.6) -project(TryCompile OBJC C CXX) +project(TryCompile) macro(TEST_ASSERT value msg) if (NOT ${value}) @@ -315,31 +315,57 @@ endif() ######################################################################### # -# Test that the CHECK_OBJCC_SOURCE_COMPILES, CHECK_OBJC_SOURCE_RUNS -# macros work. +# Test that the CHECK_OBJCC_SOURCE_COMPILES, CHECK_OBJCXX_SOURCE_COMPILES +# CHECK_OBJC_SOURCE_RUNS and CHECK_OBJCXX_SOURCE_RUNS macros work -include(CheckOBJCSourceCompiles) -include(CheckOBJCSourceRuns) +if (APPLE) + enable_language(OBJC) + enable_language(OBJCXX) -CHECK_OBJC_SOURCE_COMPILES("I don't build in Objective-C" OBJC_BUILD_SHOULD_FAIL) -CHECK_OBJC_SOURCE_COMPILES("int main() { return 0; }" SIMPLE_OBJC_BUILD_SHOULD_WORK) + include(CheckOBJCSourceCompiles) + include(CheckOBJCXXSourceCompiles) + include(CheckOBJCSourceRuns) + include(CheckOBJCXXSourceRuns) -TEST_FAIL(OBJC_BUILD_SHOULD_FAIL "CHECK_OBJC_SOURCE_COMPILES() succeeded, but should have failed") -TEST_ASSERT(SIMPLE_OBJC_BUILD_SHOULD_WORK "CHECK_OBJC_SOURCE_COMPILES() failed, but should have succeeded") + CHECK_OBJC_SOURCE_COMPILES("I don't build in Objective-C" OBJC_BUILD_SHOULD_FAIL) + CHECK_OBJC_SOURCE_COMPILES("int main() { return 0; }" SIMPLE_OBJC_BUILD_SHOULD_WORK) -set(CMAKE_REQUIRED_LIBRARIES "-framework Foundation") + TEST_FAIL(OBJC_BUILD_SHOULD_FAIL "CHECK_OBJC_SOURCE_COMPILES() succeeded, but should have failed") + TEST_ASSERT(SIMPLE_OBJC_BUILD_SHOULD_WORK "CHECK_OBJC_SOURCE_COMPILES() failed, but should have succeeded") -CHECK_OBJC_SOURCE_COMPILES("#import \nint main()\n{\nNSObject *foo;\nreturn 0;\n}\n" OBJC_BUILD_SHOULD_WORK) -CHECK_OBJC_SOURCE_RUNS("int main() { return 2; }" SIMPLE_OBJC_RUN_SHOULD_FAIL) -CHECK_OBJC_SOURCE_RUNS("int main() { return 0; }" SIMPLE_OBJC_RUN_SHOULD_WORK) -CHECK_OBJC_SOURCE_RUNS("#import \nint main()\n{\nNSObject *foo;\nreturn 2;\n}\n" OBJC_RUN_SHOULD_FAIL) -CHECK_OBJC_SOURCE_RUNS("#import \nint main()\n{\nNSObject *foo;\nreturn 0;\n}\n" OBJC_RUN_SHOULD_WORK) + set(CMAKE_REQUIRED_LIBRARIES "-framework Foundation") -TEST_ASSERT(OBJC_BUILD_SHOULD_WORK "CHECK_OBJC_SOURCE_COMPILES() failed, but should have succeeded") -TEST_FAIL(SIMPLE_OBJC_RUN_SHOULD_FAIL "CHECK_OBJC_SOURC_RUNS() succeeds, but should have failed") -TEST_ASSERT(SIMPLE_OBJC_RUN_SHOULD_WORK "CHECK_OBJC_SOURCE_RUNS() failed, but should have succeeded") -TEST_FAIL(OBJC_RUN_SHOULD_FAIL "CHECK_OBJC_SOURCE_RUNS() succeeds, but should have failed") -TEST_ASSERT(OBJC_RUN_SHOULD_WORK "CHECK_OBJC_SOURCE_RUNS() failed, but should have succeeded") + CHECK_OBJC_SOURCE_COMPILES("#import \nint main()\n{\nNSObject *foo;\nreturn 0;\n}\n" OBJC_BUILD_SHOULD_WORK) + CHECK_OBJC_SOURCE_RUNS("int main() { return 2; }" SIMPLE_OBJC_RUN_SHOULD_FAIL) + CHECK_OBJC_SOURCE_RUNS("int main() { return 0; }" SIMPLE_OBJC_RUN_SHOULD_WORK) + CHECK_OBJC_SOURCE_RUNS("#import \nint main()\n{\nNSObject *foo;\nreturn 2;\n}\n" OBJC_RUN_SHOULD_FAIL) + CHECK_OBJC_SOURCE_RUNS("#import \nint main()\n{\nNSObject *foo;\nreturn 0;\n}\n" OBJC_RUN_SHOULD_WORK) + + TEST_ASSERT(OBJC_BUILD_SHOULD_WORK "CHECK_OBJC_SOURCE_COMPILES() failed, but should have succeeded") + TEST_FAIL(SIMPLE_OBJC_RUN_SHOULD_FAIL "CHECK_OBJC_SOURC_RUNS() succeeds, but should have failed") + TEST_ASSERT(SIMPLE_OBJC_RUN_SHOULD_WORK "CHECK_OBJC_SOURCE_RUNS() failed, but should have succeeded") + TEST_FAIL(OBJC_RUN_SHOULD_FAIL "CHECK_OBJC_SOURCE_RUNS() succeeds, but should have failed") + TEST_ASSERT(OBJC_RUN_SHOULD_WORK "CHECK_OBJC_SOURCE_RUNS() failed, but should have succeeded") + + + CHECK_OBJCXX_SOURCE_COMPILES("I don't build in Objective-C++" OBJCXX_BUILD_SHOULD_FAIL) + CHECK_OBJCXX_SOURCE_COMPILES("int main() { return 0; }" SIMPLE_OBJCXX_BUILD_SHOULD_WORK) + + TEST_FAIL(OBJCXX_BUILD_SHOULD_FAIL "CHECK_OBJCXX_SOURCE_COMPILES() succeeded, but should have failed") + TEST_ASSERT(SIMPLE_OBJCXX_BUILD_SHOULD_WORK "CHECK_OBJCXX_SOURCE_COMPILES() failed, but should have succeeded") + + CHECK_OBJCXX_SOURCE_COMPILES("#import \n#include \nint main()\n{\nNSObject *foo;\nstd::cout << \"Hello\" << std::endl;\nreturn 0;\n}\n" OBJCXX_BUILD_SHOULD_WORK) + CHECK_OBJCXX_SOURCE_RUNS("int main() { return 2; }" SIMPLE_OBJCXX_RUN_SHOULD_FAIL) + CHECK_OBJCXX_SOURCE_RUNS("int main() { return 0; }" SIMPLE_OBJCXX_RUN_SHOULD_WORK) + CHECK_OBJCXX_SOURCE_RUNS("#import \n#include \nint main()\n{\nNSObject *foo;\nstd::vector bar;\nreturn 2;\n}\n" OBJCXX_RUN_SHOULD_FAIL) + CHECK_OBJCXX_SOURCE_RUNS("#import \n#include \nint main()\n{\nNSObject *foo;\nstd::vector bar;\nreturn 0;\n}\n" OBJCXX_RUN_SHOULD_WORK) + + TEST_ASSERT(OBJCXX_BUILD_SHOULD_WORK "CHECK_OBJCXX_SOURCE_COMPILES() failed, but should have succeeded") + TEST_FAIL(SIMPLE_OBJCXX_RUN_SHOULD_FAIL "CHECK_OBJCXX_SOURC_RUNS() succeeds, but should have failed") + TEST_ASSERT(SIMPLE_OBJCXX_RUN_SHOULD_WORK "CHECK_OBJCXX_SOURCE_RUNS() failed, but should have succeeded") + TEST_FAIL(OBJCXX_RUN_SHOULD_FAIL "CHECK_OBJCXX_SOURCE_RUNS() succeeds, but should have failed") + TEST_ASSERT(OBJCXX_RUN_SHOULD_WORK "CHECK_OBJCXX_SOURCE_RUNS() failed, but should have succeeded") +endif() ####################################################################### # https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=80f120a85fb0992e3f06ad69ebdad881bea9af8c commit 80f120a85fb0992e3f06ad69ebdad881bea9af8c Author: Steve Wilson AuthorDate: Fri Sep 13 18:11:15 2019 +0100 Commit: Cristian Adam CommitDate: Sat Sep 28 15:56:46 2019 +0200 Languages: Add support for Objective-C Add entries in Modules and Modules/Platform to support Objective-C compiler determination and identification. Add Modules to check Objective-C compiler flags, source compilations, program checks, etc... Use OBJC as the designator of the language, eg: project(foo OBJC) Add various tests for Objective-C language features. Add tests to preserve C++ handling of .m and .mm files when OBJC is not a configured language. Co-Authored-By: Cristian Adam diff --git a/Help/command/enable_language.rst b/Help/command/enable_language.rst index fb49b44..44beb54 100644 --- a/Help/command/enable_language.rst +++ b/Help/command/enable_language.rst @@ -1,7 +1,7 @@ enable_language --------------- -Enable a language (CXX/C/Fortran/etc) +Enable a language (CXX/C/OBJC/Fortran/etc) .. code-block:: cmake @@ -10,7 +10,7 @@ Enable a language (CXX/C/Fortran/etc) Enables support for the named language in CMake. This is the same as the :command:`project` command but does not create any of the extra variables that are created by the project command. Example languages -are ``CXX``, ``C``, ``CUDA``, ``Fortran``, and ``ASM``. +are ``CXX``, ``C``, ``CUDA``, ``OBJC``, ``Fortran``, and ``ASM``. If enabling ``ASM``, enable it last so that CMake can check whether compilers for other languages like ``C`` work for assembly too. diff --git a/Help/command/project.rst b/Help/command/project.rst index baf18be..2bbb3f4 100644 --- a/Help/command/project.rst +++ b/Help/command/project.rst @@ -87,7 +87,8 @@ The options are: Can also be specified without ``LANGUAGES`` keyword per the first, short signature. Selects which programming languages are needed to build the project. - Supported languages include ``C``, ``CXX`` (i.e. C++), ``CUDA``, ``Fortran``, and ``ASM``. + Supported languages include ``C``, ``CXX`` (i.e. C++), ``CUDA``, ``OBJC`` (i.e. Objective-C), + ``Fortran``, and ``ASM``. By default ``C`` and ``CXX`` are enabled if no language options are given. Specify language ``NONE``, or use the ``LANGUAGES`` keyword and list no languages, to skip enabling any languages. diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index c0449fb..8890433 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -130,6 +130,11 @@ Variable Queries ``1`` if the CMake's compiler id of the CUDA compiler matches any one of the entries in ``compiler_ids``, otherwise ``0``. See also the :variable:`CMAKE__COMPILER_ID` variable. +``$`` + where ``compiler_ids`` is a comma-separated list. + ``1`` if the CMake's compiler id of the Objective-C compiler matches any one + of the entries in ``compiler_ids``, otherwise ``0``. + See also the :variable:`CMAKE__COMPILER_ID` variable. ``$`` where ``compiler_ids`` is a comma-separated list. ``1`` if the CMake's compiler id of the Fortran compiler matches any one @@ -413,6 +418,9 @@ Variable Queries ``$`` The version of the CUDA compiler used. See also the :variable:`CMAKE__COMPILER_VERSION` variable. +``$`` + The version of the OBJC compiler used. + See also the :variable:`CMAKE__COMPILER_VERSION` variable. ``$`` The version of the Fortran compiler used. See also the :variable:`CMAKE__COMPILER_VERSION` variable. diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst index fc4bfdc..78881e6 100644 --- a/Help/manual/cmake-modules.7.rst +++ b/Help/manual/cmake-modules.7.rst @@ -36,6 +36,9 @@ These modules are loaded using the :command:`include` command. /module/CheckIncludeFiles /module/CheckLanguage /module/CheckLibraryExists + /module/CheckOBJCCompilerFlag + /module/CheckOBJCSourceCompiles + /module/CheckOBJCSourceRuns /module/CheckPIESupported /module/CheckPrototypeDefinition /module/CheckStructHasMember diff --git a/Help/module/CheckOBJCCompilerFlag.rst b/Help/module/CheckOBJCCompilerFlag.rst new file mode 100644 index 0000000..e4bd6fd --- /dev/null +++ b/Help/module/CheckOBJCCompilerFlag.rst @@ -0,0 +1 @@ +.. cmake-module:: ../../Modules/CheckOBJCCompilerFlag.cmake diff --git a/Help/module/CheckOBJCSourceCompiles.rst b/Help/module/CheckOBJCSourceCompiles.rst new file mode 100644 index 0000000..d4a1484 --- /dev/null +++ b/Help/module/CheckOBJCSourceCompiles.rst @@ -0,0 +1 @@ +.. cmake-module:: ../../Modules/CheckOBJCSourceCompiles.cmake diff --git a/Help/module/CheckOBJCSourceRuns.rst b/Help/module/CheckOBJCSourceRuns.rst new file mode 100644 index 0000000..c72f0db --- /dev/null +++ b/Help/module/CheckOBJCSourceRuns.rst @@ -0,0 +1 @@ +.. cmake-module:: ../../Modules/CheckOBJCSourceRuns.cmake diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index e7f0e70..6936cd4 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -42,8 +42,17 @@ if(CMAKE_COMPILER_IS_MINGW) set(MINGW 1) endif() set(CMAKE_CXX_COMPILER_ID_RUN 1) +set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm;CPP) set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC) -set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;mm;CPP) + +foreach (lang OBJC) + if (CMAKE_${lang}_COMPILER_ID_RUN) + foreach(extension IN LISTS CMAKE_${lang}_SOURCE_FILE_EXTENSIONS) + list(REMOVE_ITEM CMAKE_CXX_SOURCE_FILE_EXTENSIONS ${extension}) + endforeach() + endif() +endforeach() + set(CMAKE_CXX_LINKER_PREFERENCE 30) set(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1) diff --git a/Modules/CMakeDetermineOBJCCompiler.cmake b/Modules/CMakeDetermineOBJCCompiler.cmake new file mode 100644 index 0000000..ad13eab --- /dev/null +++ b/Modules/CMakeDetermineOBJCCompiler.cmake @@ -0,0 +1,189 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + + +# determine the compiler to use for Objective-C programs +# NOTE, a generator may set CMAKE_OBJC_COMPILER before +# loading this file to force a compiler. +# use environment variable OBJC first if defined by user, next use +# the cmake variable CMAKE_GENERATOR_OBJC which can be defined by a generator +# as a default compiler +# +# Sets the following variables: +# CMAKE_OBJC_COMPILER +# CMAKE_AR +# CMAKE_RANLIB +# CMAKE_COMPILER_IS_GNUOBJC +# CMAKE_COMPILER_IS_CLANGOBJC +# +# If not already set before, it also sets +# _CMAKE_TOOLCHAIN_PREFIX + +include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake) + +# Load system-specific compiler preferences for this language. +include(Platform/${CMAKE_SYSTEM_NAME}-Determine-OBJC OPTIONAL) +include(Platform/${CMAKE_SYSTEM_NAME}-OBJC OPTIONAL) +if(NOT CMAKE_OBJC_COMPILER_NAMES) + set(CMAKE_OBJC_COMPILER_NAMES clang) +endif() + +if("${CMAKE_GENERATOR}" MATCHES "Xcode") + set(CMAKE_OBJC_COMPILER_XCODE_TYPE sourcecode.c.objc) +else() + if(NOT CMAKE_OBJC_COMPILER) + set(CMAKE_OBJC_COMPILER_INIT NOTFOUND) + + # prefer the environment variable OBJC + if($ENV{OBJC} MATCHES ".+") + get_filename_component(CMAKE_OBJC_COMPILER_INIT $ENV{OBJC} PROGRAM PROGRAM_ARGS CMAKE_OBJC_FLAGS_ENV_INIT) + if(CMAKE_OBJC_FLAGS_ENV_INIT) + set(CMAKE_OBJC_COMPILER_ARG1 "${CMAKE_OBJC_FLAGS_ENV_INIT}" CACHE STRING "First argument to Objective-C compiler") + endif() + if(NOT EXISTS ${CMAKE_OBJC_COMPILER_INIT}) + message(FATAL_ERROR "Could not find compiler set in environment variable OBJC:\n$ENV{OBJC}.") + endif() + endif() + + # next try prefer the compiler specified by the generator + if(CMAKE_GENERATOR_OBJC) + if(NOT CMAKE_OBJC_COMPILER_INIT) + set(CMAKE_OBJC_COMPILER_INIT ${CMAKE_GENERATOR_OBJC}) + endif() + endif() + + # finally list compilers to try + if(NOT CMAKE_OBJC_COMPILER_INIT) + set(CMAKE_OBJC_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}cc ${_CMAKE_TOOLCHAIN_PREFIX}gcc clang) + endif() + + _cmake_find_compiler(OBJC) + + else() + # we only get here if CMAKE_OBJC_COMPILER was specified using -D or a pre-made CMakeCache.txt + # (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE + # if CMAKE_OBJC_COMPILER is a list of length 2, use the first item as + # CMAKE_OBJC_COMPILER and the 2nd one as CMAKE_OBJC_COMPILER_ARG1 + + list(LENGTH CMAKE_OBJC_COMPILER _CMAKE_OBJC_COMPILER_LIST_LENGTH) + if("${_CMAKE_OBJC_COMPILER_LIST_LENGTH}" EQUAL 2) + list(GET CMAKE_OBJC_COMPILER 1 CMAKE_OBJC_COMPILER_ARG1) + list(GET CMAKE_OBJC_COMPILER 0 CMAKE_OBJC_COMPILER) + endif() + + # if a compiler was specified by the user but without path, + # now try to find it with the full path + # if it is found, force it into the cache, + # if not, don't overwrite the setting (which was given by the user) with "NOTFOUND" + # if the C compiler already had a path, reuse it for searching the CXX compiler + get_filename_component(_CMAKE_USER_OBJC_COMPILER_PATH "${CMAKE_OBJC_COMPILER}" PATH) + if(NOT _CMAKE_USER_OBJC_COMPILER_PATH) + find_program(CMAKE_OBJC_COMPILER_WITH_PATH NAMES ${CMAKE_OBJC_COMPILER}) + if(CMAKE_OBJC_COMPILER_WITH_PATH) + set(CMAKE_OBJC_COMPILER ${CMAKE_OBJC_COMPILER_WITH_PATH} CACHE STRING "Objective-C compiler" FORCE) + endif() + unset(CMAKE_OBJC_COMPILER_WITH_PATH CACHE) + endif() + endif() + mark_as_advanced(CMAKE_OBJC_COMPILER) + + # Each entry in this list is a set of extra flags to try + # adding to the compile line to see if it helps produce + # a valid identification file. + set(CMAKE_OBJC_COMPILER_ID_TEST_FLAGS_FIRST) + set(CMAKE_OBJC_COMPILER_ID_TEST_FLAGS + # Try compiling to an object file only. + "-c" + + ) +endif() + +# Build a small source file to identify the compiler. +if(NOT CMAKE_OBJC_COMPILER_ID_RUN) + set(CMAKE_OBJC_COMPILER_ID_RUN 1) + + # Try to identify the compiler. + set(CMAKE_OBJC_COMPILER_ID) + file(READ ${CMAKE_ROOT}/Modules/CMakePlatformId.h.in + CMAKE_OBJC_COMPILER_ID_PLATFORM_CONTENT) + + # Match the link line from xcodebuild output of the form + # Ld ... + # ... + # /path/to/cc ...CompilerIdOBJC/... + # to extract the compiler front-end for the language. + set(CMAKE_OBJC_COMPILER_ID_TOOL_MATCH_REGEX "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerIdOBJC/(\\./)?(CompilerIdOBJC.(framework|xctest)/)?CompilerIdOBJC[ \t\n\\\"]") + set(CMAKE_OBJC_COMPILER_ID_TOOL_MATCH_INDEX 2) + + include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) + CMAKE_DETERMINE_COMPILER_ID(OBJC OBJCCFLAGS CMakeOBJCCompilerId.m) + + # Set old compiler and platform id variables. + if(CMAKE_OBJC_COMPILER_ID STREQUAL "GNU") + set(CMAKE_COMPILER_IS_GNUOBJC 1) + endif() + if(CMAKE_OBJC_COMPILER_ID STREQUAL "Clang") + set(CMAKE_COMPILER_IS_CLANGOBJC 1) + endif() +endif() + +if (NOT _CMAKE_TOOLCHAIN_LOCATION) + get_filename_component(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_OBJC_COMPILER}" PATH) +endif () + +# If we have a gcc cross compiler, they have usually some prefix, like +# e.g. powerpc-linux-gcc, arm-elf-gcc or i586-mingw32msvc-gcc, optionally +# with a 3-component version number at the end (e.g. arm-eabi-gcc-4.5.2). +# The other tools of the toolchain usually have the same prefix +# NAME_WE cannot be used since then this test will fail for names like +# "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be +# "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" +if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) + + if(CMAKE_OBJC_COMPILER_ID MATCHES "GNU|Clang|QCC") + get_filename_component(COMPILER_BASENAME "${CMAKE_OBJC_COMPILER}" NAME) + if (COMPILER_BASENAME MATCHES "^(.+-)(clang|g?cc)(-[0-9]+(\\.[0-9]+)*)?(-[^.]+)?(\\.exe)?$") + set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + set(_CMAKE_COMPILER_SUFFIX ${CMAKE_MATCH_5}) + elseif(CMAKE_OBJC_COMPILER_ID MATCHES "Clang") + if(CMAKE_OBJC_COMPILER_TARGET) + set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_OBJC_COMPILER_TARGET}-) + endif() + elseif(COMPILER_BASENAME MATCHES "qcc(\\.exe)?$") + if(CMAKE_OBJC_COMPILER_TARGET MATCHES "gcc_nto([a-z0-9]+_[0-9]+|[^_le]+)(le)?") + set(_CMAKE_TOOLCHAIN_PREFIX nto${CMAKE_MATCH_1}-) + endif() + endif () + + # if "llvm-" is part of the prefix, remove it, since llvm doesn't have its own binutils + # but uses the regular ar, objcopy, etc. (instead of llvm-objcopy etc.) + if ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") + set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + endif () + endif() + +endif () + +set(_CMAKE_PROCESSING_LANGUAGE "OBJC") +include(CMakeFindBinUtils) +include(Compiler/${CMAKE_OBJC_COMPILER_ID}-FindBinUtils OPTIONAL) +unset(_CMAKE_PROCESSING_LANGUAGE) + +if(CMAKE_OBJC_COMPILER_ARCHITECTURE_ID) + set(_SET_CMAKE_OBJC_COMPILER_ARCHITECTURE_ID + "set(CMAKE_OBJC_COMPILER_ARCHITECTURE_ID ${CMAKE_OBJC_COMPILER_ARCHITECTURE_ID})") +else() + set(_SET_CMAKE_OBJC_COMPILER_ARCHITECTURE_ID "") +endif() + +if(CMAKE_OBJC_XCODE_ARCHS) + set(SET_CMAKE_XCODE_ARCHS + "set(CMAKE_XCODE_ARCHS \"${CMAKE_OBJC_XCODE_ARCHS}\")") +endif() + +# configure variables set in this file for fast reload later on +configure_file(${CMAKE_ROOT}/Modules/CMakeOBJCCompiler.cmake.in + ${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCCompiler.cmake + @ONLY + ) +set(CMAKE_OBJC_COMPILER_ENV_VAR "OBJC") diff --git a/Modules/CMakeOBJCCompiler.cmake.in b/Modules/CMakeOBJCCompiler.cmake.in new file mode 100644 index 0000000..1555517 --- /dev/null +++ b/Modules/CMakeOBJCCompiler.cmake.in @@ -0,0 +1,69 @@ +set(CMAKE_OBJC_COMPILER "@CMAKE_OBJC_COMPILER@") +set(CMAKE_OBJC_COMPILER_ARG1 "@CMAKE_OBJC_COMPILER_ARG1@") +set(CMAKE_OBJC_COMPILER_ID "@CMAKE_OBJC_COMPILER_ID@") +set(CMAKE_OBJC_COMPILER_VERSION "@CMAKE_OBJC_COMPILER_VERSION@") +set(CMAKE_OBJC_COMPILER_VERSION_INTERNAL "@CMAKE_OBJC_COMPILER_VERSION_INTERNAL@") +set(CMAKE_OBJC_COMPILER_WRAPPER "@CMAKE_OBJC_COMPILER_WRAPPER@") +set(CMAKE_OBJC_STANDARD_COMPUTED_DEFAULT "@CMAKE_OBJC_STANDARD_COMPUTED_DEFAULT@") +set(CMAKE_OBJC_COMPILE_FEATURES "@CMAKE_OBJC_COMPILE_FEATURES@") +set(CMAKE_OBJC90_COMPILE_FEATURES "@CMAKE_OBJC90_COMPILE_FEATURES@") +set(CMAKE_OBJC99_COMPILE_FEATURES "@CMAKE_OBJC99_COMPILE_FEATURES@") +set(CMAKE_OBJC11_COMPILE_FEATURES "@CMAKE_OBJC11_COMPILE_FEATURES@") + +set(CMAKE_OBJC_PLATFORM_ID "@CMAKE_OBJC_PLATFORM_ID@") +set(CMAKE_OBJC_SIMULATE_ID "@CMAKE_OBJC_SIMULATE_ID@") +set(CMAKE_OBJC_COMPILER_FRONTEND_VARIANT "@CMAKE_OBJC_COMPILER_FRONTEND_VARIANT@") +set(CMAKE_OBJC_SIMULATE_VERSION "@CMAKE_OBJC_SIMULATE_VERSION@") + at _SET_CMAKE_OBJC_COMPILER_ARCHITECTURE_ID@ + at SET_CMAKE_XCODE_ARCHS@ +set(CMAKE_AR "@CMAKE_AR@") +set(CMAKE_OBJC_COMPILER_AR "@CMAKE_OBJC_COMPILER_AR@") +set(CMAKE_RANLIB "@CMAKE_RANLIB@") +set(CMAKE_OBJC_COMPILER_RANLIB "@CMAKE_OBJC_COMPILER_RANLIB@") +set(CMAKE_LINKER "@CMAKE_LINKER@") +set(CMAKE_MT "@CMAKE_MT@") +set(CMAKE_COMPILER_IS_GNUOBJC @CMAKE_COMPILER_IS_GNUOBJC@) +set(CMAKE_OBJC_COMPILER_LOADED 1) +set(CMAKE_OBJC_COMPILER_WORKS @CMAKE_OBJC_COMPILER_WORKS@) +set(CMAKE_OBJC_ABI_COMPILED @CMAKE_OBJC_ABI_COMPILED@) + +set(CMAKE_OBJC_COMPILER_ENV_VAR "OBJC") + +set(CMAKE_OBJC_COMPILER_ID_RUN 1) +set(CMAKE_OBJC_SOURCE_FILE_EXTENSIONS m) +set(CMAKE_OBJC_IGNORE_EXTENSIONS h;H;o;O) +set(CMAKE_OBJC_LINKER_PREFERENCE 5) + +foreach (lang C CXX OBJCXX) + foreach(extension IN LISTS CMAKE_OBJC_SOURCE_FILE_EXTENSIONS) + if (CMAKE_${lang}_COMPILER_ID_RUN) + list(REMOVE_ITEM CMAKE_${lang}_SOURCE_FILE_EXTENSIONS ${extension}) + endif() + endforeach() +endforeach() + +# Save compiler ABI information. +set(CMAKE_OBJC_SIZEOF_DATA_PTR "@CMAKE_OBJC_SIZEOF_DATA_PTR@") +set(CMAKE_OBJC_COMPILER_ABI "@CMAKE_OBJC_COMPILER_ABI@") +set(CMAKE_OBJC_LIBRARY_ARCHITECTURE "@CMAKE_OBJC_LIBRARY_ARCHITECTURE@") + +if(CMAKE_OBJC_SIZEOF_DATA_PTR) + set(CMAKE_SIZEOF_VOID_P "${CMAKE_OBJC_SIZEOF_DATA_PTR}") +endif() + +if(CMAKE_OBJC_COMPILER_ABI) + set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_OBJC_COMPILER_ABI}") +endif() + +if(CMAKE_OBJC_LIBRARY_ARCHITECTURE) + set(CMAKE_LIBRARY_ARCHITECTURE "@CMAKE_OBJC_LIBRARY_ARCHITECTURE@") +endif() + + at CMAKE_OBJC_COMPILER_CUSTOM_CODE@ + at CMAKE_OBJC_SYSROOT_FLAG_CODE@ + at CMAKE_OBJC_OSX_DEPLOYMENT_TARGET_FLAG_CODE@ + +set(CMAKE_OBJC_IMPLICIT_INCLUDE_DIRECTORIES "@CMAKE_OBJC_IMPLICIT_INCLUDE_DIRECTORIES@") +set(CMAKE_OBJC_IMPLICIT_LINK_LIBRARIES "@CMAKE_OBJC_IMPLICIT_LINK_LIBRARIES@") +set(CMAKE_OBJC_IMPLICIT_LINK_DIRECTORIES "@CMAKE_OBJC_IMPLICIT_LINK_DIRECTORIES@") +set(CMAKE_OBJC_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_OBJC_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@") diff --git a/Modules/CMakeOBJCCompilerABI.m b/Modules/CMakeOBJCCompilerABI.m new file mode 100644 index 0000000..8fa8511 --- /dev/null +++ b/Modules/CMakeOBJCCompilerABI.m @@ -0,0 +1,20 @@ +#ifdef __cplusplus +# error "A C++ compiler has been selected for Objective-C." +#endif + +/*--------------------------------------------------------------------------*/ + +#include "CMakeCompilerABI.h" + +/*--------------------------------------------------------------------------*/ + +int main(int argc, char *argv[]) +{ + int require = 0; + require += info_sizeof_dptr[argc]; +#if defined(ABI_ID) + require += info_abi[argc]; +#endif + (void)argv; + return require; +} diff --git a/Modules/CMakeOBJCCompilerId.m.in b/Modules/CMakeOBJCCompilerId.m.in new file mode 100644 index 0000000..2b8aa30 --- /dev/null +++ b/Modules/CMakeOBJCCompilerId.m.in @@ -0,0 +1,63 @@ +#ifdef __cplusplus +# error "An Objective-C++ compiler has been selected for Objective-C." +#endif + + at CMAKE_OBJC_COMPILER_ID_CONTENT@ + +/* Construct the string literal in pieces to prevent the source from + getting matched. Store it in a pointer rather than an array + because some compilers will just produce instructions to fill the + array rather than assigning a pointer to a static array. */ +char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; +#ifdef SIMULATE_ID +char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; +#endif + +#ifdef __QNXNTO__ +char const* qnxnto = "INFO" ":" "qnxnto[]"; +#endif + + at CMAKE_OBJC_COMPILER_ID_PLATFORM_CONTENT@ + at CMAKE_OBJC_COMPILER_ID_ERROR_FOR_TEST@ + +#if !defined(__STDC__) +# if (defined(_MSC_VER) && !defined(__clang__)) \ + || (defined(__ibmxl__) || defined(__IBMC__)) +# define C_DIALECT "90" +# else +# define C_DIALECT +# endif +#elif __STDC_VERSION__ >= 201000L +# define C_DIALECT "11" +#elif __STDC_VERSION__ >= 199901L +# define C_DIALECT "99" +#else +# define C_DIALECT "90" +#endif +const char* info_language_dialect_default = + "INFO" ":" "dialect_default[" C_DIALECT "]"; + +/*--------------------------------------------------------------------------*/ + +int main(int argc, char* argv[]) +{ + int require = 0; + require += info_compiler[argc]; + require += info_platform[argc]; + require += info_arch[argc]; +#ifdef COMPILER_VERSION_MAJOR + require += info_version[argc]; +#endif +#ifdef COMPILER_VERSION_INTERNAL + require += info_version_internal[argc]; +#endif +#ifdef SIMULATE_ID + require += info_simulate[argc]; +#endif +#ifdef SIMULATE_VERSION_MAJOR + require += info_simulate_version[argc]; +#endif + require += info_language_dialect_default[argc]; + (void)argv; + return require; +} diff --git a/Modules/CMakeOBJCInformation.cmake b/Modules/CMakeOBJCInformation.cmake new file mode 100644 index 0000000..2baad4a --- /dev/null +++ b/Modules/CMakeOBJCInformation.cmake @@ -0,0 +1,188 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + + +# This file sets the basic flags for the Objective-C language in CMake. +# It also loads the available platform file for the system-compiler +# if it exists. +# It also loads a system - compiler - processor (or target hardware) +# specific file, which is mainly useful for crosscompiling and embedded systems. + +include(CMakeLanguageInformation) + +# some compilers use different extensions (e.g. sdcc uses .rel) +# so set the extension here first so it can be overridden by the compiler specific file +set(CMAKE_OBJC_OUTPUT_EXTENSION .o) + +if(NOT CMAKE_INCLUDE_FLAG_OBJC) + set(CMAKE_INCLUDE_FLAG_OBJC ${CMAKE_INCLUDE_FLAG_C}) +endif() + +set(_INCLUDED_FILE 0) + +# Load compiler-specific information. +if(CMAKE_OBJC_COMPILER_ID) + include(Compiler/${CMAKE_OBJC_COMPILER_ID}-OBJC OPTIONAL) +endif() + +set(CMAKE_BASE_NAME) +get_filename_component(CMAKE_BASE_NAME "${CMAKE_OBJC_COMPILER}" NAME_WE) +if(CMAKE_COMPILER_IS_GNUOBJC) + set(CMAKE_BASE_NAME gcc) +endif() + + +# load a hardware specific file, mostly useful for embedded compilers +if(CMAKE_SYSTEM_PROCESSOR) + if(CMAKE_OBJC_COMPILER_ID) + include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_OBJC_COMPILER_ID}-OBJC-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE) + endif() + if (NOT _INCLUDED_FILE) + include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL) + endif () +endif() + + +# load the system- and compiler specific files +if(CMAKE_OBJC_COMPILER_ID) + include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_OBJC_COMPILER_ID}-OBJC + OPTIONAL RESULT_VARIABLE _INCLUDED_FILE) +endif() +if (NOT _INCLUDED_FILE) + include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_BASE_NAME} + OPTIONAL RESULT_VARIABLE _INCLUDED_FILE) +endif () + +# load any compiler-wrapper specific information +if (CMAKE_OBJC_COMPILER_WRAPPER) + __cmake_include_compiler_wrapper(OBJC) +endif () + +# We specify the compiler information in the system file for some +# platforms, but this language may not have been enabled when the file +# was first included. Include it again to get the language info. +# Remove this when all compiler info is removed from system files. +if (NOT _INCLUDED_FILE) + include(Platform/${CMAKE_SYSTEM_NAME} OPTIONAL) +endif () + +if(CMAKE_OBJC_SIZEOF_DATA_PTR) + foreach(f ${CMAKE_OBJC_ABI_FILES}) + include(${f}) + endforeach() + unset(CMAKE_OBJC_ABI_FILES) +endif() + +# This should be included before the _INIT variables are +# used to initialize the cache. Since the rule variables +# have if blocks on them, users can still define them here. +# But, it should still be after the platform file so changes can +# be made to those values. + +if(CMAKE_USER_MAKE_RULES_OVERRIDE) + # Save the full path of the file so try_compile can use it. + include(${CMAKE_USER_MAKE_RULES_OVERRIDE} RESULT_VARIABLE _override) + set(CMAKE_USER_MAKE_RULES_OVERRIDE "${_override}") +endif() + +if(CMAKE_USER_MAKE_RULES_OVERRIDE_OBJC) + # Save the full path of the file so try_compile can use it. + include(${CMAKE_USER_MAKE_RULES_OVERRIDE_OBJC} RESULT_VARIABLE _override) + set(CMAKE_USER_MAKE_RULES_OVERRIDE_OBJC "${_override}") +endif() + + +# for most systems a module is the same as a shared library +# so unless the variable CMAKE_MODULE_EXISTS is set just +# copy the values from the LIBRARY variables +if(NOT CMAKE_MODULE_EXISTS) + set(CMAKE_SHARED_MODULE_OBJC_FLAGS ${CMAKE_SHARED_LIBRARY_OBJC_FLAGS}) + set(CMAKE_SHARED_MODULE_CREATE_OBJC_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_OBJC_FLAGS}) +endif() + +set(CMAKE_OBJC_FLAGS_INIT "$ENV{OBJCFLAGS} ${CMAKE_OBJC_FLAGS_INIT}") + +cmake_initialize_per_config_variable(CMAKE_OBJC_FLAGS "Flags used by the Objective-C compiler") + +if(CMAKE_OBJC_STANDARD_LIBRARIES_INIT) + set(CMAKE_OBJC_STANDARD_LIBRARIES "${CMAKE_OBJC_STANDARD_LIBRARIES_INIT}" + CACHE STRING "Libraries linked by default with all Objective-C applications.") + mark_as_advanced(CMAKE_OBJC_STANDARD_LIBRARIES) +endif() + +include(CMakeCommonLanguageInclude) + +# now define the following rule variables + +# CMAKE_OBJC_CREATE_SHARED_LIBRARY +# CMAKE_OBJC_CREATE_SHARED_MODULE +# CMAKE_OBJC_COMPILE_OBJECT +# CMAKE_OBJC_LINK_EXECUTABLE + +# variables supplied by the generator at use time +# +# the target without the suffix +# +# +# +# +# + +# Objective-C compiler information +# +# +# +# + +# Static library tools +# +# + + +# create an Objective-C shared library +if(NOT CMAKE_OBJC_CREATE_SHARED_LIBRARY) + set(CMAKE_OBJC_CREATE_SHARED_LIBRARY + " -o ") +endif() + +# create an Objective-C shared module just copy the shared library rule +if(NOT CMAKE_OBJC_CREATE_SHARED_MODULE) + set(CMAKE_OBJC_CREATE_SHARED_MODULE ${CMAKE_OBJC_CREATE_SHARED_LIBRARY}) +endif() + +# Create an static archive incrementally for large object file counts. +# If CMAKE_OBJC_CREATE_STATIC_LIBRARY is set it will override these. +if(NOT DEFINED CMAKE_OBJC_ARCHIVE_CREATE) + set(CMAKE_OBJC_ARCHIVE_CREATE " qc ") +endif() +if(NOT DEFINED CMAKE_OBJC_ARCHIVE_APPEND) + set(CMAKE_OBJC_ARCHIVE_APPEND " q ") +endif() +if(NOT DEFINED CMAKE_OBJC_ARCHIVE_FINISH) + set(CMAKE_OBJC_ARCHIVE_FINISH " ") +endif() + +# compile an Objective-C file into an object file +if(NOT CMAKE_OBJC_COMPILE_OBJECT) + set(CMAKE_OBJC_COMPILE_OBJECT + " -o -c ") +endif() + +if(NOT CMAKE_OBJC_LINK_EXECUTABLE) + set(CMAKE_OBJC_LINK_EXECUTABLE + " -o ") +endif() + +if(NOT CMAKE_EXECUTABLE_RUNTIME_OBJC_FLAG) + set(CMAKE_EXECUTABLE_RUNTIME_OBJC_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_OBJC_FLAG}) +endif() + +if(NOT CMAKE_EXECUTABLE_RUNTIME_OBJC_FLAG_SEP) + set(CMAKE_EXECUTABLE_RUNTIME_OBJC_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_OBJC_FLAG_SEP}) +endif() + +if(NOT CMAKE_EXECUTABLE_RPATH_LINK_OBJC_FLAG) + set(CMAKE_EXECUTABLE_RPATH_LINK_OBJC_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_OBJC_FLAG}) +endif() + +set(CMAKE_OBJC_INFORMATION_LOADED 1) diff --git a/Modules/CMakeTestOBJCCompiler.cmake b/Modules/CMakeTestOBJCCompiler.cmake new file mode 100644 index 0000000..0030683 --- /dev/null +++ b/Modules/CMakeTestOBJCCompiler.cmake @@ -0,0 +1,94 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + + +if(CMAKE_OBJC_COMPILER_FORCED) + # The compiler configuration was forced by the user. + # Assume the user has configured all compiler information. + set(CMAKE_OBJC_COMPILER_WORKS TRUE) + return() +endif() + +include(CMakeTestCompilerCommon) + +# work around enforced code signing and / or missing exectuable target type +set(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE}) +if(_CMAKE_FEATURE_DETECTION_TARGET_TYPE) + set(CMAKE_TRY_COMPILE_TARGET_TYPE ${_CMAKE_FEATURE_DETECTION_TARGET_TYPE}) +endif() + +# Remove any cached result from an older CMake version. +# We now store this in CMakeCCompiler.cmake. +unset(CMAKE_OBJC_COMPILER_WORKS CACHE) + +# This file is used by EnableLanguage in cmGlobalGenerator to +# determine that that selected Objective-C compiler can actually compile +# and link the most basic of programs. If not, a fatal error +# is set and cmake stops processing commands and will not generate +# any makefiles or projects. +if(NOT CMAKE_OBJC_COMPILER_WORKS) + PrintTestCompilerStatus("OBJC" "") + __TestCompiler_setTryCompileTargetType() + file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCCompiler.m + "#ifdef __cplusplus\n" + "# error \"The CMAKE_OBJC_COMPILER is set to a C++ compiler\"\n" + "#endif\n" + "#ifndef __OBJC__\n" + "# error \"The CMAKE_OBJC_COMPILER is not an Objective-C compiler\"\n" + "#endif\n" + "int main(int argc, char* argv[])\n" + "{ (void)argv; return argc-1;}\n") + try_compile(CMAKE_OBJC_COMPILER_WORKS ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCCompiler.m + OUTPUT_VARIABLE __CMAKE_OBJC_COMPILER_OUTPUT) + # Move result from cache to normal variable. + set(CMAKE_OBJC_COMPILER_WORKS ${CMAKE_OBJC_COMPILER_WORKS}) + unset(CMAKE_OBJC_COMPILER_WORKS CACHE) + set(OBJC_TEST_WAS_RUN 1) + __TestCompiler_restoreTryCompileTargetType() +endif() + +if(NOT CMAKE_OBJC_COMPILER_WORKS) + PrintTestCompilerStatus("OBJC" " -- broken") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the Objective-C compiler works failed with " + "the following output:\n${__CMAKE_OBJC_COMPILER_OUTPUT}\n\n") + string(REPLACE "\n" "\n " _output "${__CMAKE_OBJC_COMPILER_OUTPUT}") + message(FATAL_ERROR "The Objective-C compiler\n \"${CMAKE_OBJC_COMPILER}\"\n" + "is not able to compile a simple test program.\nIt fails " + "with the following output:\n ${_output}\n\n" + "CMake will not be able to correctly generate this project.") +else() + if(OBJC_TEST_WAS_RUN) + PrintTestCompilerStatus("OBJC" " -- works") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the Objective-C compiler works passed with " + "the following output:\n${__CMAKE_OBJC_COMPILER_OUTPUT}\n\n") + endif() + + # Try to identify the ABI and configure it into CMakeOBJCCompiler.cmake + include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) + CMAKE_DETERMINE_COMPILER_ABI(OBJC ${CMAKE_ROOT}/Modules/CMakeOBJCCompilerABI.m) + # Try to identify the compiler features + include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake) + CMAKE_DETERMINE_COMPILE_FEATURES(OBJC) + + # Re-configure to save learned information. + configure_file( + ${CMAKE_ROOT}/Modules/CMakeOBJCCompiler.cmake.in + ${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCCompiler.cmake + @ONLY + ) + include(${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCCompiler.cmake) + + if(CMAKE_OBJC_SIZEOF_DATA_PTR) + foreach(f ${CMAKE_OBJC_ABI_FILES}) + include(${f}) + endforeach() + unset(CMAKE_OBJC_ABI_FILES) + endif() +endif() + +set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE}) +unset(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE) +unset(__CMAKE_OBJC_COMPILER_OUTPUT) diff --git a/Modules/CheckOBJCCompilerFlag.cmake b/Modules/CheckOBJCCompilerFlag.cmake new file mode 100644 index 0000000..1d975da --- /dev/null +++ b/Modules/CheckOBJCCompilerFlag.cmake @@ -0,0 +1,64 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +CheckOBJCCompilerFlag +--------------------- + +Check whether the Objective-C compiler supports a given flag. + +.. command:: check_objc_compiler_flag + + .. code-block:: cmake + + check_objc_compiler_flag( ) + + Check that the ```` is accepted by the compiler without + a diagnostic. Stores the result in an internal cache entry + named ````. + +This command temporarily sets the ``CMAKE_REQUIRED_DEFINITIONS`` variable +and calls the ``check_objc_source_compiles`` macro from the +:module:`CheckOBJCSourceCompiles` module. See documentation of that +module for a listing of variables that can otherwise modify the build. + +A positive result from this check indicates only that the compiler did not +issue a diagnostic message when given the flag. Whether the flag has any +effect or even a specific one is beyond the scope of this module. + +.. note:: + Since the :command:`try_compile` command forwards flags from variables + like :variable:`CMAKE_OBJC_FLAGS _FLAGS>`, unknown flags + in such variables may cause a false negative for this check. +#]=======================================================================] + +include_guard(GLOBAL) +include(CheckOBJCSourceCompiles) +include(CMakeCheckCompilerFlagCommonPatterns) + +macro (CHECK_OBJC_COMPILER_FLAG _FLAG _RESULT) + set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}") + set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}") + + # Normalize locale during test compilation. + set(_CheckOBJCCompilerFlag_LOCALE_VARS LC_ALL LC_MESSAGES LANG) + foreach(v ${_CheckOBJCCompilerFlag_LOCALE_VARS}) + set(_CheckOBJCCompilerFlag_SAVED_${v} "$ENV{${v}}") + set(ENV{${v}} OBJC) + endforeach() + CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckOBJCCompilerFlag_COMMON_PATTERNS) + CHECK_OBJC_SOURCE_COMPILES("#ifndef __OBJC__\n# error \"Not an Objective-C compiler\"\n#endif\nint main(void) { return 0; }" ${_RESULT} + # Some compilers do not fail with a bad flag + FAIL_REGEX "command line option .* is valid for .* but not for Objective-C" # GNU + FAIL_REGEX "argument unused during compilation: .*" # Clang + ${_CheckOBJCCompilerFlag_COMMON_PATTERNS} + ) + foreach(v ${_CheckOBJCCompilerFlag_LOCALE_VARS}) + set(ENV{${v}} ${_CheckOBJCCompilerFlag_SAVED_${v}}) + unset(_CheckOBJCCompilerFlag_SAVED_${v}) + endforeach() + unset(_CheckOBJCCompilerFlag_LOCALE_VARS) + unset(_CheckOBJCCompilerFlag_COMMON_PATTERNS) + + set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}") +endmacro () diff --git a/Modules/CheckOBJCSourceCompiles.cmake b/Modules/CheckOBJCSourceCompiles.cmake new file mode 100644 index 0000000..a4676ad --- /dev/null +++ b/Modules/CheckOBJCSourceCompiles.cmake @@ -0,0 +1,145 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +CheckOBJCSourceCompiles +----------------------- + +Check if given Objective-C source compiles and links into an executable. + +.. command:: check_objc_source_compiles + + .. code-block:: cmake + + check_objc_source_compiles( + [FAIL_REGEX [...]]) + + Check that the source supplied in ```` can be compiled as a Objectie-C source + file and linked as an executable (so it must contain at least a ``main()`` + function). The result will be stored in the internal cache variable specified + by ````, with a boolean true value for success and boolean false + for failure. If ``FAIL_REGEX`` is provided, then failure is determined by + checking if anything in the output matches any of the specified regular + expressions. + + The underlying check is performed by the :command:`try_compile` command. The + compile and link commands can be influenced by setting any of the following + variables prior to calling ``check_objc_source_compiles()``: + + ``CMAKE_REQUIRED_FLAGS`` + Additional flags to pass to the compiler. Note that the contents of + :variable:`CMAKE_OBJC_FLAGS _FLAGS>` and its associated + configuration-specific variable are automatically added to the compiler + command before the contents of ``CMAKE_REQUIRED_FLAGS``. + + ``CMAKE_REQUIRED_DEFINITIONS`` + A :ref:`;-list ` of compiler definitions of the form + ``-DFOO`` or ``-DFOO=bar``. A definition for the name specified by + ```` will also be added automatically. + + ``CMAKE_REQUIRED_INCLUDES`` + A :ref:`;-list ` of header search paths to pass to + the compiler. These will be the only header search paths used by + ``try_compile()``, i.e. the contents of the :prop_dir:`INCLUDE_DIRECTORIES` + directory property will be ignored. + + ``CMAKE_REQUIRED_LINK_OPTIONS`` + A :ref:`;-list ` of options to add to the link + command (see :command:`try_compile` for further details). + + ``CMAKE_REQUIRED_LIBRARIES`` + A :ref:`;-list ` of libraries to add to the link + command. These can be the name of system libraries or they can be + :ref:`Imported Targets ` (see :command:`try_compile` for + further details). + + ``CMAKE_REQUIRED_QUIET`` + If this variable evaluates to a boolean true value, all status messages + associated with the check will be suppressed. + + The check is only performed once, with the result cached in the variable + named by ````. Every subsequent CMake run will re-use this cached + value rather than performing the check again, even if the ```` changes. + In order to force the check to be re-evaluated, the variable named by + ```` must be manually removed from the cache. + +#]=======================================================================] + +include_guard(GLOBAL) + +macro(CHECK_OBJC_SOURCE_COMPILES SOURCE VAR) + if(NOT DEFINED "${VAR}") + set(_FAIL_REGEX) + set(_key) + foreach(arg ${ARGN}) + if("${arg}" MATCHES "^(FAIL_REGEX)$") + set(_key "${arg}") + elseif(_key) + list(APPEND _${_key} "${arg}") + else() + message(FATAL_ERROR "Unknown argument:\n ${arg}\n") + endif() + endforeach() + set(MACRO_CHECK_FUNCTION_DEFINITIONS + "-D${VAR} ${CMAKE_REQUIRED_FLAGS}") + if(CMAKE_REQUIRED_LINK_OPTIONS) + set(CHECK_OBJC_SOURCE_COMPILES_ADD_LINK_OPTIONS + LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS}) + else() + set(CHECK_OBJC_SOURCE_COMPILES_ADD_LINK_OPTIONS) + endif() + if(CMAKE_REQUIRED_LIBRARIES) + set(CHECK_OBJC_SOURCE_COMPILES_ADD_LIBRARIES + LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) + else() + set(CHECK_OBJC_SOURCE_COMPILES_ADD_LIBRARIES) + endif() + if(CMAKE_REQUIRED_INCLUDES) + set(CHECK_OBJC_SOURCE_COMPILES_ADD_INCLUDES + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") + else() + set(CHECK_OBJC_SOURCE_COMPILES_ADD_INCLUDES) + endif() + file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.m" + "${SOURCE}\n") + + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR}") + endif() + try_compile(${VAR} + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.m + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + ${CHECK_OBJC_SOURCE_COMPILES_ADD_LINK_OPTIONS} + ${CHECK_OBJC_SOURCE_COMPILES_ADD_LIBRARIES} + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} + "${CHECK_OBJC_SOURCE_COMPILES_ADD_INCLUDES}" + OUTPUT_VARIABLE OUTPUT) + + foreach(_regex ${_FAIL_REGEX}) + if("${OUTPUT}" MATCHES "${_regex}") + set(${VAR} 0) + endif() + endforeach() + + if(${VAR}) + set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Success") + endif() + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Performing Objective-C SOURCE FILE Test ${VAR} succeeded with the following output:\n" + "${OUTPUT}\n" + "Source file was:\n${SOURCE}\n") + else() + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Failed") + endif() + set(${VAR} "" CACHE INTERNAL "Test ${VAR}") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Performing Objective-C SOURCE FILE Test ${VAR} failed with the following output:\n" + "${OUTPUT}\n" + "Source file was:\n${SOURCE}\n") + endif() + endif() +endmacro() diff --git a/Modules/CheckOBJCSourceRuns.cmake b/Modules/CheckOBJCSourceRuns.cmake new file mode 100644 index 0000000..00a1ebd --- /dev/null +++ b/Modules/CheckOBJCSourceRuns.cmake @@ -0,0 +1,145 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +CheckOBJCSourceRuns +------------------- + +Check if given Objective-C source compiles and links into an executable and can +subsequently be run. + +.. command:: check_objc_source_runs + + .. code-block:: cmake + + check_objc_source_runs( ) + + Check that the source supplied in ```` can be compiled as a Objective-C source + file, linked as an executable and then run. The ```` must contain at + least a ``main()`` function. If the ```` could be built and run + successfully, the internal cache variable specified by ```` will + be set to 1, otherwise it will be set to an value that evaluates to boolean + false (e.g. an empty string or an error message). + + The underlying check is performed by the :command:`try_run` command. The + compile and link commands can be influenced by setting any of the following + variables prior to calling ``check_objc_source_runs()``: + + ``CMAKE_REQUIRED_FLAGS`` + Additional flags to pass to the compiler. Note that the contents of + :variable:`CMAKE_OBJC_FLAGS _FLAGS>` and its associated + configuration-specific variable are automatically added to the compiler + command before the contents of ``CMAKE_REQUIRED_FLAGS``. + + ``CMAKE_REQUIRED_DEFINITIONS`` + A :ref:`;-list ` of compiler definitions of the form + ``-DFOO`` or ``-DFOO=bar``. A definition for the name specified by + ```` will also be added automatically. + + ``CMAKE_REQUIRED_INCLUDES`` + A :ref:`;-list ` of header search paths to pass to + the compiler. These will be the only header search paths used by + ``try_run()``, i.e. the contents of the :prop_dir:`INCLUDE_DIRECTORIES` + directory property will be ignored. + + ``CMAKE_REQUIRED_LINK_OPTIONS`` + A :ref:`;-list ` of options to add to the link + command (see :command:`try_run` for further details). + + ``CMAKE_REQUIRED_LIBRARIES`` + A :ref:`;-list ` of libraries to add to the link + command. These can be the name of system libraries or they can be + :ref:`Imported Targets ` (see :command:`try_run` for + further details). + + ``CMAKE_REQUIRED_QUIET`` + If this variable evaluates to a boolean true value, all status messages + associated with the check will be suppressed. + + The check is only performed once, with the result cached in the variable + named by ````. Every subsequent CMake run will re-use this cached + value rather than performing the check again, even if the ```` changes. + In order to force the check to be re-evaluated, the variable named by + ```` must be manually removed from the cache. + +#]=======================================================================] + +include_guard(GLOBAL) + +macro(CHECK_OBJC_SOURCE_RUNS SOURCE VAR) + if(NOT DEFINED "${VAR}") + set(MACRO_CHECK_FUNCTION_DEFINITIONS + "-D${VAR} ${CMAKE_REQUIRED_FLAGS}") + if(CMAKE_REQUIRED_LINK_OPTIONS) + set(CHECK_OBJC_SOURCE_COMPILES_ADD_LINK_OPTIONS + LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS}) + else() + set(CHECK_OBJC_SOURCE_COMPILES_ADD_LINK_OPTIONS) + endif() + if(CMAKE_REQUIRED_LIBRARIES) + set(CHECK_OBJC_SOURCE_COMPILES_ADD_LIBRARIES + LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) + else() + set(CHECK_OBJC_SOURCE_COMPILES_ADD_LIBRARIES) + endif() + if(CMAKE_REQUIRED_INCLUDES) + set(CHECK_OBJC_SOURCE_COMPILES_ADD_INCLUDES + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") + else() + set(CHECK_OBJC_SOURCE_COMPILES_ADD_INCLUDES) + endif() + file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.m" + "${SOURCE}\n") + + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR}") + endif() + try_run(${VAR}_EXITCODE ${VAR}_COMPILED + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.m + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + ${CHECK_OBJC_SOURCE_COMPILES_ADD_LINK_OPTIONS} + ${CHECK_OBJC_SOURCE_COMPILES_ADD_LIBRARIES} + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} + -DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH} + "${CHECK_OBJC_SOURCE_COMPILES_ADD_INCLUDES}" + COMPILE_OUTPUT_VARIABLE OUTPUT + RUN_OUTPUT_VARIABLE RUN_OUTPUT) + # if it did not compile make the return value fail code of 1 + if(NOT ${VAR}_COMPILED) + set(${VAR}_EXITCODE 1) + endif() + # if the return value was 0 then it worked + if("${${VAR}_EXITCODE}" EQUAL 0) + set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Success") + endif() + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Performing Objective-C SOURCE FILE Test ${VAR} succeeded with the following compile output:\n" + "${OUTPUT}\n" + "...and run output:\n" + "${RUN_OUTPUT}\n" + "Return value: ${${VAR}}\n" + "Source file was:\n${SOURCE}\n") + else() + if(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES "FAILED_TO_RUN") + set(${VAR} "${${VAR}_EXITCODE}") + else() + set(${VAR} "" CACHE INTERNAL "Test ${VAR}") + endif() + + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Performing Test ${VAR} - Failed") + endif() + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Performing Objective-C SOURCE FILE Test ${VAR} failed with the following compile output:\n" + "${OUTPUT}\n" + "...and run output:\n" + "${RUN_OUTPUT}\n" + "Return value: ${${VAR}_EXITCODE}\n" + "Source file was:\n${SOURCE}\n") + + endif() + endif() +endmacro() diff --git a/Modules/Compiler/AppleClang-OBJC.cmake b/Modules/Compiler/AppleClang-OBJC.cmake new file mode 100644 index 0000000..d1f3706 --- /dev/null +++ b/Modules/Compiler/AppleClang-OBJC.cmake @@ -0,0 +1,17 @@ +include(Compiler/Clang-OBJC) + +if(NOT CMAKE_OBJC_COMPILER_VERSION VERSION_LESS 4.0) + set(CMAKE_OBJC90_STANDARD_COMPILE_OPTION "-std=c90") + set(CMAKE_OBJC90_EXTENSION_COMPILE_OPTION "-std=gnu90") + set(CMAKE_OBJC90_STANDARD__HAS_FULL_SUPPORT ON) + + set(CMAKE_OBJC99_STANDARD_COMPILE_OPTION "-std=c99") + set(CMAKE_OBJC99_EXTENSION_COMPILE_OPTION "-std=gnu99") + set(CMAKE_OBJC99_STANDARD__HAS_FULL_SUPPORT ON) + + set(CMAKE_OBJC11_STANDARD_COMPILE_OPTION "-std=c11") + set(CMAKE_OBJC11_EXTENSION_COMPILE_OPTION "-std=gnu11") + set(CMAKE_OBJC11_STANDARD__HAS_FULL_SUPPORT ON) +endif() + +__compiler_check_default_language_standard(OBJC 4.0 99) diff --git a/Modules/Compiler/Clang-OBJC.cmake b/Modules/Compiler/Clang-OBJC.cmake new file mode 100644 index 0000000..c61c497 --- /dev/null +++ b/Modules/Compiler/Clang-OBJC.cmake @@ -0,0 +1,18 @@ +include(Compiler/Clang) +__compiler_clang(OBJC) + +if(NOT CMAKE_OBJC_COMPILER_VERSION VERSION_LESS 3.4) + set(CMAKE_OBJC90_STANDARD_COMPILE_OPTION "-std=c90") + set(CMAKE_OBJC90_EXTENSION_COMPILE_OPTION "-std=gnu90") + set(CMAKE_OBJC90_STANDARD__HAS_FULL_SUPPORT ON) + + set(CMAKE_OBJC99_STANDARD_COMPILE_OPTION "-std=c99") + set(CMAKE_OBJC99_EXTENSION_COMPILE_OPTION "-std=gnu99") + set(CMAKE_OBJC99_STANDARD__HAS_FULL_SUPPORT ON) + + set(CMAKE_OBJC11_STANDARD_COMPILE_OPTION "-std=c11") + set(CMAKE_OBJC11_EXTENSION_COMPILE_OPTION "-std=gnu11") + set(CMAKE_OBJC11_STANDARD__HAS_FULL_SUPPORT ON) +endif() + +__compiler_check_default_language_standard(OBJC 3.4 99 3.6 11) diff --git a/Modules/Compiler/GNU-OBJC.cmake b/Modules/Compiler/GNU-OBJC.cmake new file mode 100644 index 0000000..5fba801 --- /dev/null +++ b/Modules/Compiler/GNU-OBJC.cmake @@ -0,0 +1,6 @@ +include(Compiler/GNU) +__compiler_gnu(OBJC) + +if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.2) + set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") +endif() diff --git a/Modules/Platform/Apple-AppleClang-OBJC.cmake b/Modules/Platform/Apple-AppleClang-OBJC.cmake new file mode 100644 index 0000000..b78edb1 --- /dev/null +++ b/Modules/Platform/Apple-AppleClang-OBJC.cmake @@ -0,0 +1,6 @@ +include(Platform/Apple-Clang-OBJC) +if(NOT CMAKE_OBJC_COMPILER_VERSION VERSION_LESS 4.2) + set(CMAKE_OBJC_SYSTEM_FRAMEWORK_SEARCH_FLAG "-iframework ") +else() + unset(CMAKE_OBJC_SYSTEM_FRAMEWORK_SEARCH_FLAG) +endif() diff --git a/Modules/Platform/Apple-Clang-OBJC.cmake b/Modules/Platform/Apple-Clang-OBJC.cmake new file mode 100644 index 0000000..63cd846 --- /dev/null +++ b/Modules/Platform/Apple-Clang-OBJC.cmake @@ -0,0 +1,2 @@ +include(Platform/Apple-Clang) +__apple_compiler_clang(OBJC) diff --git a/Modules/Platform/Apple-GNU-OBJC.cmake b/Modules/Platform/Apple-GNU-OBJC.cmake new file mode 100644 index 0000000..aa8b33f --- /dev/null +++ b/Modules/Platform/Apple-GNU-OBJC.cmake @@ -0,0 +1,4 @@ +include(Platform/Apple-GNU) +__apple_compiler_gnu(OBJC) +cmake_gnu_set_sysroot_flag(OBJC) +cmake_gnu_set_osx_deployment_target_flag(OBJC) diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index 7e02814..dcda7c5 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -119,10 +119,15 @@ set(CMAKE_C_CREATE_MACOSX_FRAMEWORK set(CMAKE_CXX_CREATE_MACOSX_FRAMEWORK " -o ") +set(CMAKE_OBJC_CREATE_MACOSX_FRAMEWORK + " -o -dynamiclib -install_name " +) + # Set default framework search path flag for languages known to use a # preprocessor that may find headers in frameworks. set(CMAKE_C_FRAMEWORK_SEARCH_FLAG -F) set(CMAKE_CXX_FRAMEWORK_SEARCH_FLAG -F) +set(CMAKE_OBJC_FRAMEWORK_SEARCH_FLAG -F) set(CMAKE_Fortran_FRAMEWORK_SEARCH_FLAG -F) # default to searching for frameworks first @@ -222,7 +227,7 @@ unset(_apps_paths) include(Platform/UnixPaths) if(_CMAKE_OSX_SYSROOT_PATH AND EXISTS ${_CMAKE_OSX_SYSROOT_PATH}/usr/include) list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${_CMAKE_OSX_SYSROOT_PATH}/usr) - foreach(lang C CXX) + foreach(lang C CXX OBJC) list(APPEND _CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES_INIT ${_CMAKE_OSX_SYSROOT_PATH}/usr/include) endforeach() endif() diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 93e074d..3583dc9 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1654,7 +1654,7 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, const char* deploymentTargetFlag = this->Makefile->GetDefinition(deploymentTargetFlagVar); if (!archs.empty() && !lang.empty() && - (lang[0] == 'C' || lang[0] == 'F')) { + (lang[0] == 'C' || lang[0] == 'F' || lang[0] == 'O')) { for (std::string const& arch : archs) { flags += " -arch "; flags += arch; diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index c284603..2e17e59 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -2328,6 +2328,43 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CFBundleTest") ADD_TEST_MACRO(ObjC++ ObjC++) + + add_test(Objective-C.simple-build-test ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Objective-C/simple-build-test" + "${CMake_BINARY_DIR}/Tests/Objective-C/simple-build-test" + --build-two-config + ${build_generator_args} + --build-project simple-build-test + --build-options ${build_options} + --test-command simple-build-test + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Objective-C/simple-build-test") + + add_test(Objective-C.c-file-extension-test ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Objective-C/c-file-extension-test" + "${CMake_BINARY_DIR}/Tests/Objective-C/c-file-extension-test" + --build-two-config + ${build_generator_args} + --build-project c-file-extension-test + --build-options ${build_options} + --test-command c-file-extension-test + ) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Objective-C/c-file-extension-test") + + add_test(Objective-C.objc-file-extension-test ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Objective-C/objc-file-extension-test" + "${CMake_BINARY_DIR}/Tests/Objective-C/objc-file-extension-test" + --build-two-config + ${build_generator_args} + --build-project objc-file-extension-test + --build-options ${build_options} + --test-command objc-file-extension-test + ) + list(APPEND TEST_BUILD_DIRS "${CMAKE_BINARY_DIR}/Tests/Objective-C/objc-file-extension-test") + endif () endif () diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt index 19f3f79..1a25469 100644 --- a/Tests/CMakeOnly/CMakeLists.txt +++ b/Tests/CMakeOnly/CMakeLists.txt @@ -30,6 +30,12 @@ add_CMakeOnly_test(CheckStructHasMember) add_CMakeOnly_test(CompilerIdC) add_CMakeOnly_test(CompilerIdCXX) + +if(CMAKE_OBJC_COMPILER) + add_CMakeOnly_test(CompilerIdOBJC) + add_CMakeOnly_test(CheckOBJCCompilerFlag) +endif() + if(CMAKE_Fortran_COMPILER) add_CMakeOnly_test(CompilerIdFortran) endif() diff --git a/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt b/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt index ca4becb..e9bdf6a 100644 --- a/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt +++ b/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt @@ -5,10 +5,19 @@ include(CheckLanguage) set(langs ) set(expect_C 1) set(expect_CXX 1) +if(APPLE) + set(expect_OBJC 1) +endif() unset(expect_Fortran) set(expect_NoSuchLanguage 0) -foreach(lang C CXX Fortran CUDA NoSuchLanguage) +set(LANGUAGES C CXX Fortran CUDA NoSuchLanguage) + +if(APPLE) + list(APPEND LANGUAGES OBJC) +endif() + +foreach(lang ${LANGUAGES}) check_language(${lang}) if(NOT DEFINED CMAKE_${lang}_COMPILER) message(FATAL_ERROR "check_language(${lang}) did not set result") diff --git a/Tests/CMakeOnly/CheckOBJCCompilerFlag/CMakeLists.txt b/Tests/CMakeOnly/CheckOBJCCompilerFlag/CMakeLists.txt new file mode 100644 index 0000000..a9a96ee --- /dev/null +++ b/Tests/CMakeOnly/CheckOBJCCompilerFlag/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 2.8.12) + +project(CheckOBJCCompilerFlag) + +include(CheckOBJCCompilerFlag) + +if(CMAKE_COMPILER_IS_GNUOBJC) + set(COMPILER_FLAG -fobjc-direct-dispatch) +else() + set(COMPILER_FLAG -fobjc-gc) +endif() + +CHECK_OBJC_COMPILER_FLAGS(${COMPILER_FLAG} HAS_COMPILER_FLAG) + +if(NOT HAS_COMPILER_FLAG) + message(SEND_ERROR "Test fail: HAS_COMPILER_FLAG: ${COMPILER_FLAG}") +endif diff --git a/Tests/CMakeOnly/CompilerIdOBJC/CMakeLists.txt b/Tests/CMakeOnly/CompilerIdOBJC/CMakeLists.txt new file mode 100644 index 0000000..8f13787 --- /dev/null +++ b/Tests/CMakeOnly/CompilerIdOBJC/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 2.8.12) +project(CompilerIdOBJC OBJC) + +foreach(v + CMAKE_OBJC_COMPILER + CMAKE_OBJC_COMPILER_ID + CMAKE_OBJC_COMPILER_VERSION + ) + if(${v}) + message(STATUS "${v}=[${${v}}]") + else() + message(SEND_ERROR "${v} not set!") + endif() +endforeach() diff --git a/Tests/Objective-C/c-file-extension-test/CMakeLists.txt b/Tests/Objective-C/c-file-extension-test/CMakeLists.txt new file mode 100644 index 0000000..e091448 --- /dev/null +++ b/Tests/Objective-C/c-file-extension-test/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.15) + +project(c-file-extension-test C) + +add_executable(c-file-extension-test main.m) diff --git a/Tests/Objective-C/c-file-extension-test/main.m b/Tests/Objective-C/c-file-extension-test/main.m new file mode 100644 index 0000000..1c159a9 --- /dev/null +++ b/Tests/Objective-C/c-file-extension-test/main.m @@ -0,0 +1,8 @@ +#ifndef __OBJC__ +# error "Compiler cannot compile Objective-C" +#endif + +int main() +{ + return 0; +} diff --git a/Tests/Objective-C/objc-file-extension-test/CMakeLists.txt b/Tests/Objective-C/objc-file-extension-test/CMakeLists.txt new file mode 100644 index 0000000..27e88be --- /dev/null +++ b/Tests/Objective-C/objc-file-extension-test/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.15) + +project(objc-file-extension-test OBJC CXX) + +add_executable(objc-file-extension-test main.m) +target_link_libraries(objc-file-extension-test "-framework Foundation") diff --git a/Tests/Objective-C/objc-file-extension-test/main.m b/Tests/Objective-C/objc-file-extension-test/main.m new file mode 100644 index 0000000..2ec3917 --- /dev/null +++ b/Tests/Objective-C/objc-file-extension-test/main.m @@ -0,0 +1,12 @@ +#ifndef __OBJC__ +# error "Compiler is not an Objective-C compiler." +#endif + +#import + +int main() +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + [pool release]; + return 0; +} diff --git a/Tests/Objective-C/simple-build-test/CMakeLists.txt b/Tests/Objective-C/simple-build-test/CMakeLists.txt new file mode 100644 index 0000000..5ab46ac --- /dev/null +++ b/Tests/Objective-C/simple-build-test/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.15) + +set(CMAKE_MACOSX_RPATH OFF) + +project(simple-build-test OBJC) + +add_library(foo SHARED foo.m) +target_link_libraries(foo "-framework Foundation") + +add_executable(simple-build-test main.m) +target_link_libraries(simple-build-test "-framework Foundation" foo) diff --git a/Tests/Objective-C/simple-build-test/foo.h b/Tests/Objective-C/simple-build-test/foo.h new file mode 100644 index 0000000..b3fb084 --- /dev/null +++ b/Tests/Objective-C/simple-build-test/foo.h @@ -0,0 +1,9 @@ +#import + + at interface Foo : NSObject { + NSNumber* age; +} + + at property (nonatomic, retain) NSNumber* age; + + at end diff --git a/Tests/Objective-C/simple-build-test/foo.m b/Tests/Objective-C/simple-build-test/foo.m new file mode 100644 index 0000000..2d452a8 --- /dev/null +++ b/Tests/Objective-C/simple-build-test/foo.m @@ -0,0 +1,7 @@ +#import "foo.h" + + at implementation Foo + + at synthesize age; + + at end diff --git a/Tests/Objective-C/simple-build-test/main.m b/Tests/Objective-C/simple-build-test/main.m new file mode 100644 index 0000000..970d554 --- /dev/null +++ b/Tests/Objective-C/simple-build-test/main.m @@ -0,0 +1,12 @@ +#import +#import "foo.h" + +int main(int argc, char **argv) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + Foo *theFoo = [[Foo alloc] init]; + theFoo.age = [NSNumber numberWithInt:argc]; + NSLog(@"%d\n",[theFoo.age intValue]); + [pool release]; + return 0; +} diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index 54e96a2..8fd8090 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required (VERSION 2.6) -project(TryCompile) +project(TryCompile OBJC C CXX) macro(TEST_ASSERT value msg) if (NOT ${value}) @@ -313,6 +313,34 @@ if(CMAKE_C_COMPILER_ID STREQUAL "GNU") TEST_ASSERT(C_STRICT_PROTOTYPES "CHECK_C_COMPILER_FLAG failed -Werror -Wstrict-prototypes") endif() +######################################################################### +# +# Test that the CHECK_OBJCC_SOURCE_COMPILES, CHECK_OBJC_SOURCE_RUNS +# macros work. + +include(CheckOBJCSourceCompiles) +include(CheckOBJCSourceRuns) + +CHECK_OBJC_SOURCE_COMPILES("I don't build in Objective-C" OBJC_BUILD_SHOULD_FAIL) +CHECK_OBJC_SOURCE_COMPILES("int main() { return 0; }" SIMPLE_OBJC_BUILD_SHOULD_WORK) + +TEST_FAIL(OBJC_BUILD_SHOULD_FAIL "CHECK_OBJC_SOURCE_COMPILES() succeeded, but should have failed") +TEST_ASSERT(SIMPLE_OBJC_BUILD_SHOULD_WORK "CHECK_OBJC_SOURCE_COMPILES() failed, but should have succeeded") + +set(CMAKE_REQUIRED_LIBRARIES "-framework Foundation") + +CHECK_OBJC_SOURCE_COMPILES("#import \nint main()\n{\nNSObject *foo;\nreturn 0;\n}\n" OBJC_BUILD_SHOULD_WORK) +CHECK_OBJC_SOURCE_RUNS("int main() { return 2; }" SIMPLE_OBJC_RUN_SHOULD_FAIL) +CHECK_OBJC_SOURCE_RUNS("int main() { return 0; }" SIMPLE_OBJC_RUN_SHOULD_WORK) +CHECK_OBJC_SOURCE_RUNS("#import \nint main()\n{\nNSObject *foo;\nreturn 2;\n}\n" OBJC_RUN_SHOULD_FAIL) +CHECK_OBJC_SOURCE_RUNS("#import \nint main()\n{\nNSObject *foo;\nreturn 0;\n}\n" OBJC_RUN_SHOULD_WORK) + +TEST_ASSERT(OBJC_BUILD_SHOULD_WORK "CHECK_OBJC_SOURCE_COMPILES() failed, but should have succeeded") +TEST_FAIL(SIMPLE_OBJC_RUN_SHOULD_FAIL "CHECK_OBJC_SOURC_RUNS() succeeds, but should have failed") +TEST_ASSERT(SIMPLE_OBJC_RUN_SHOULD_WORK "CHECK_OBJC_SOURCE_RUNS() failed, but should have succeeded") +TEST_FAIL(OBJC_RUN_SHOULD_FAIL "CHECK_OBJC_SOURCE_RUNS() succeeds, but should have failed") +TEST_ASSERT(OBJC_RUN_SHOULD_WORK "CHECK_OBJC_SOURCE_RUNS() failed, but should have succeeded") + ####################################################################### # # also test that the check_prototype_definition macro works https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=156b56480a786db4d967bde5eb6d5edee56a27d0 commit 156b56480a786db4d967bde5eb6d5edee56a27d0 Author: Brad King AuthorDate: Fri Sep 27 13:06:56 2019 -0400 Commit: Brad King CommitDate: Fri Sep 27 14:15:00 2019 -0400 Makefiles: Revert "Make build root targets ... recursive" Revert the main logic change from commit 827da1119e (Makefiles: Make build root targets "all", "clean" and "preinstall" recursive, 2019-05-17, v3.15.0-rc1~96^2~2) for the "all" and "preinstall" targets. The commit cleaned up the Makefile generator to use the same logic for the "all" target in the top-level directory as for subdirectories. It exposed a long-existing bug that caused the "all" target in a subdirectory to include the "all" targets from sub-subdirectories even if they are marked `EXCLUDE_FROM_ALL`. The `Tests/SubDir` test should fail but the problem is currently covered up by another bug introduced by commit dc6888573d (Pass EXCLUDE_FROM_ALL from directory to targets, 2019-01-15, v3.14.0-rc1~83^2) that causes the "all" targets in `EXCLUDE_FROM_ALL` subdirectories to be empty. Revert the top-level "all" and "preinstall" targets to the old approach to prepare to fix the latter bug without exposing the long-existing bug at the top-level. Leave the "clean" target in the new approach because it does not honor `EXCLUDE_FROM_ALL` anyway. Issue: #19753 diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index aa584ad..c636334 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -232,6 +232,14 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2() depends.push_back(this->EmptyRuleHackDepends); } + // Write and empty all: + lg->WriteMakeRule(makefileStream, "The main recursive all target", "all", + depends, no_commands, true); + + // Write an empty preinstall: + lg->WriteMakeRule(makefileStream, "The main recursive preinstall target", + "preinstall", depends, no_commands, true); + // Write out the "special" stuff lg->WriteSpecialTargetsTop(makefileStream); @@ -473,8 +481,13 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRules2( ruleFileStream << "\n\n"; } - // Write directory-level rules for "all". - this->WriteDirectoryRule2(ruleFileStream, lg, "all", true, false); + if (!lg->IsRootMakefile()) { + // Write directory-level rules for "all". + this->WriteDirectoryRule2(ruleFileStream, lg, "all", true, false); + + // Write directory-level rules for "preinstall". + this->WriteDirectoryRule2(ruleFileStream, lg, "preinstall", true, true); + } // Write directory-level rules for "clean". { @@ -482,9 +495,6 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRules2( lg->AppendDirectoryCleanCommand(cmds); this->WriteDirectoryRule2(ruleFileStream, lg, "clean", false, false, cmds); } - - // Write directory-level rules for "preinstall". - this->WriteDirectoryRule2(ruleFileStream, lg, "preinstall", true, true); } std::vector @@ -707,6 +717,15 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( lg->WriteMakeRule(ruleFileStream, "All Build rule for target.", localName, depends, commands, true); + // add the all/all dependency + if (!this->IsExcluded(gtarget)) { + depends.clear(); + depends.push_back(localName); + commands.clear(); + lg->WriteMakeRule(ruleFileStream, "Include target in all.", "all", + depends, commands, true); + } + // Write the rule. commands.clear(); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=60473cc660cc37c922b0ff93112deeb34d51f2ca commit 60473cc660cc37c922b0ff93112deeb34d51f2ca Author: Marc Chevrier AuthorDate: Fri Sep 27 12:20:15 2019 +0200 Commit: Marc Chevrier CommitDate: Fri Sep 27 16:04:54 2019 +0200 FPHSA: add capability to specify message explaining reason of failure Fixes: #19660 diff --git a/Help/release/dev/FPHSA-reason-failure-message.rst b/Help/release/dev/FPHSA-reason-failure-message.rst new file mode 100644 index 0000000..419c3ba --- /dev/null +++ b/Help/release/dev/FPHSA-reason-failure-message.rst @@ -0,0 +1,5 @@ +FPHSA-reason-failure-message +---------------------------- + +* Modules :module:`FindPackageHandleStandardArgs` gains the capability to + specify a message giving the reason for the failure. diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index a2999fc..d824ee8 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -27,6 +27,7 @@ valid filepaths. [VERSION_VAR ] [HANDLE_COMPONENTS] [CONFIG_MODE] + [REASON_FAILURE_MESSAGE ] [FAIL_MESSAGE ] ) @@ -81,6 +82,10 @@ valid filepaths. will automatically check whether the package configuration file was found. + ``REASON_FAILURE_MESSAGE `` + Specify a custom message of the reason for the failure which will be + appended to the default generated message. + ``FAIL_MESSAGE `` Specify a custom failure message instead of using the default generated message. Not recommended. @@ -133,11 +138,15 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake) # internal helper macro macro(_FPHSA_FAILURE_MESSAGE _msg) + set (__msg "${_msg}") + if (FPHSA_REASON_FAILURE_MESSAGE) + string(APPEND __msg "\n Reason given by package: ${FPHSA_REASON_FAILURE_MESSAGE}\n") + endif() if (${_NAME}_FIND_REQUIRED) - message(FATAL_ERROR "${_msg}") + message(FATAL_ERROR "${__msg}") else () if (NOT ${_NAME}_FIND_QUIETLY) - message(STATUS "${_msg}") + message(STATUS "${__msg}") endif () endif () endmacro() @@ -158,12 +167,18 @@ macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) foreach(currentConfigIndex RANGE ${configsCount}) list(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename) list(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version) - string(APPEND configsText " ${filename} (version ${version})\n") + string(APPEND configsText "\n ${filename} (version ${version})") endforeach() if (${_NAME}_NOT_FOUND_MESSAGE) - string(APPEND configsText " Reason given by package: ${${_NAME}_NOT_FOUND_MESSAGE}\n") + if (FPHSA_REASON_FAILURE_MESSAGE) + string(PREPEND FPHSA_REASON_FAILURE_MESSAGE "${${_NAME}_NOT_FOUND_MESSAGE}\n ") + else() + set(FPHSA_REASON_FAILURE_MESSAGE "${${_NAME}_NOT_FOUND_MESSAGE}") + endif() + else() + string(APPEND configsText "\n") endif() - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}") + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:${configsText}") else() # Simple case: No Config-file was found at all: @@ -177,7 +192,7 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) # Set up the arguments for `cmake_parse_arguments`. set(options CONFIG_MODE HANDLE_COMPONENTS) - set(oneValueArgs FAIL_MESSAGE VERSION_VAR FOUND_VAR) + set(oneValueArgs FAIL_MESSAGE REASON_FAILURE_MESSAGE VERSION_VAR FOUND_VAR) set(multiValueArgs REQUIRED_VARS) # Check whether we are in 'simple' or 'extended' mode: diff --git a/Tests/RunCMake/FPHSA/CustomMessageConfig.cmake b/Tests/RunCMake/FPHSA/CustomMessageConfig.cmake new file mode 100644 index 0000000..e25db1a --- /dev/null +++ b/Tests/RunCMake/FPHSA/CustomMessageConfig.cmake @@ -0,0 +1 @@ +# pseudo config module diff --git a/Tests/RunCMake/FPHSA/CustomMessageConfigVersion.cmake b/Tests/RunCMake/FPHSA/CustomMessageConfigVersion.cmake new file mode 100644 index 0000000..b7c9e18 --- /dev/null +++ b/Tests/RunCMake/FPHSA/CustomMessageConfigVersion.cmake @@ -0,0 +1,4 @@ +# pseudo find_module + +set (PACKAGE_VERSION 2) +set (PACKAGE_VERSION_UNSUITABLE TRUE) diff --git a/Tests/RunCMake/FPHSA/FindCustomMessage.cmake b/Tests/RunCMake/FPHSA/FindCustomMessage.cmake new file mode 100644 index 0000000..4d67db8 --- /dev/null +++ b/Tests/RunCMake/FPHSA/FindCustomMessage.cmake @@ -0,0 +1,17 @@ +# pseudo find_module + +if (REASON_FAILURE_MESSAGE) + list (PREPEND REASON_FAILURE_MESSAGE "REASON_FAILURE_MESSAGE") +endif() + +include(FindPackageHandleStandardArgs) + +if (CONFIG_MODE) + find_package (CustomMessage QUIET CONFIG HINTS "${CMAKE_MODULE_PATH}") + find_package_handle_standard_args(CustomMessage CONFIG_MODE + ${REASON_FAILURE_MESSAGE}) +else() + find_package_handle_standard_args(CustomMessage REQUIRED_VARS FOOBAR + VERSION_VAR CustomMessage_VERSION + ${REASON_FAILURE_MESSAGE}) +endif() diff --git a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake index dd73cd4..f3e6c3e 100644 --- a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake +++ b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake @@ -39,3 +39,10 @@ unset(RunCMake_DEFAULT_stderr) # check if searching for a version 0 works list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudo_VERSION=0") run_cmake(exact_0_matching) + +# check custom error message +set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DCustomMessage_VERSION=1.2.3.4") +run_cmake(custom_message_1) +set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DCONFIG_MODE=TRUE") +run_cmake(custom_message_2) +run_cmake(custom_message_3) diff --git a/Tests/RunCMake/FPHSA/custom_message_1-result.txt b/Tests/RunCMake/FPHSA/custom_message_1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FPHSA/custom_message_1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FPHSA/custom_message_1-stderr.txt b/Tests/RunCMake/FPHSA/custom_message_1-stderr.txt new file mode 100644 index 0000000..992fe39 --- /dev/null +++ b/Tests/RunCMake/FPHSA/custom_message_1-stderr.txt @@ -0,0 +1,7 @@ +^CMake Error at .+/Modules/FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\): + Could NOT find CustomMessage \(missing: FOOBAR\) \(found suitable version + "1\.2\.3\.4", minimum required is "1\.2"\) + + Reason given by package: Reason Failure + +Call Stack \(most recent call first\): diff --git a/Tests/RunCMake/FPHSA/custom_message_1.cmake b/Tests/RunCMake/FPHSA/custom_message_1.cmake new file mode 100644 index 0000000..330de50 --- /dev/null +++ b/Tests/RunCMake/FPHSA/custom_message_1.cmake @@ -0,0 +1,4 @@ + +set (REASON_FAILURE_MESSAGE "Reason Failure") + +find_package(CustomMessage 1.2 REQUIRED) diff --git a/Tests/RunCMake/FPHSA/custom_message_2-result.txt b/Tests/RunCMake/FPHSA/custom_message_2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FPHSA/custom_message_2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FPHSA/custom_message_2-stderr.txt b/Tests/RunCMake/FPHSA/custom_message_2-stderr.txt new file mode 100644 index 0000000..4940752 --- /dev/null +++ b/Tests/RunCMake/FPHSA/custom_message_2-stderr.txt @@ -0,0 +1,8 @@ +^CMake Error at .+/Modules/FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\): + Could NOT find CustomMessage \(Required is at least version "1\.2"\), checked + the following files: + + .+/Tests/RunCMake/FPHSA/CustomMessageConfig.cmake \(version 2\) + Reason given by package: Not Found Message + +Call Stack \(most recent call first\): diff --git a/Tests/RunCMake/FPHSA/custom_message_2.cmake b/Tests/RunCMake/FPHSA/custom_message_2.cmake new file mode 100644 index 0000000..a3f2d96 --- /dev/null +++ b/Tests/RunCMake/FPHSA/custom_message_2.cmake @@ -0,0 +1,5 @@ + +unset (REASON_FAILURE_MESSAGE) +set (CustomMessage_NOT_FOUND_MESSAGE "Not Found Message") + +find_package(CustomMessage 1.2 REQUIRED) diff --git a/Tests/RunCMake/FPHSA/custom_message_3-result.txt b/Tests/RunCMake/FPHSA/custom_message_3-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FPHSA/custom_message_3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FPHSA/custom_message_3-stderr.txt b/Tests/RunCMake/FPHSA/custom_message_3-stderr.txt new file mode 100644 index 0000000..dc55843 --- /dev/null +++ b/Tests/RunCMake/FPHSA/custom_message_3-stderr.txt @@ -0,0 +1,9 @@ +^CMake Error at .+/Modules/FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\): + Could NOT find CustomMessage \(Required is at least version "1\.2"\), checked + the following files: + + .+/Tests/RunCMake/FPHSA/CustomMessageConfig.cmake \(version 2\) + Reason given by package: Not Found Message + Reason Failure + +Call Stack \(most recent call first\): diff --git a/Tests/RunCMake/FPHSA/custom_message_3.cmake b/Tests/RunCMake/FPHSA/custom_message_3.cmake new file mode 100644 index 0000000..203e012 --- /dev/null +++ b/Tests/RunCMake/FPHSA/custom_message_3.cmake @@ -0,0 +1,5 @@ + +set (REASON_FAILURE_MESSAGE "Reason Failure") +set (CustomMessage_NOT_FOUND_MESSAGE "Not Found Message") + +find_package(CustomMessage 1.2 REQUIRED) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7d6e08b438a187e89735ae6aad749a14137f34be commit 7d6e08b438a187e89735ae6aad749a14137f34be Author: Tushar Maheshwari AuthorDate: Sun Sep 22 07:24:57 2019 +0530 Commit: Tushar Maheshwari CommitDate: Fri Sep 27 17:18:16 2019 +0530 cmCursesMainForm: change Entries to object vector - Add move constructor and move assignment operator for `cmCursesCacheEntryComposite`. - Transfer ownership of Entries objects to std::vector. diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.h b/Source/CursesDialog/cmCursesCacheEntryComposite.h index 1ed60c8..a711363 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.h +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.h @@ -25,6 +25,10 @@ public: cmCursesCacheEntryComposite& operator=(cmCursesCacheEntryComposite const&) = delete; + cmCursesCacheEntryComposite(cmCursesCacheEntryComposite&&) = default; + cmCursesCacheEntryComposite& operator=(cmCursesCacheEntryComposite&&) = + default; + const char* GetValue(); friend class cmCursesMainForm; diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 15ccc91..219771b 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -67,11 +67,10 @@ cmCursesMainForm::~cmCursesMainForm() // See if a cache entry is in the list of entries in the ui. bool cmCursesMainForm::LookForCacheEntry(const std::string& key) { - return std::any_of( - this->Entries.begin(), this->Entries.end(), - [&key](std::unique_ptr const& entry) { - return key == entry->Key; - }); + return std::any_of(this->Entries.begin(), this->Entries.end(), + [&key](cmCursesCacheEntryComposite const& entry) { + return key == entry.Key; + }); } // Create new cmCursesCacheEntryComposite entries from the cache @@ -79,7 +78,7 @@ void cmCursesMainForm::InitializeUI() { // Create a vector of cmCursesCacheEntryComposite's // which contain labels, entries and new entry markers - std::vector> newEntries; + std::vector newEntries; std::vector cacheKeys = this->CMakeInstance->GetState()->GetCacheEntryKeys(); newEntries.reserve(cacheKeys.size()); @@ -101,9 +100,8 @@ void cmCursesMainForm::InitializeUI() if (count == 0) { // If cache is empty, display a label saying so and a // dummy entry widget (does not respond to input) - std::unique_ptr comp = - cm::make_unique("EMPTY CACHE", 30, 30); - comp->Entry = cm::make_unique(1, 1, 1, 1); + cmCursesCacheEntryComposite comp("EMPTY CACHE", 30, 30); + comp.Entry = cm::make_unique(1, 1, 1, 1); newEntries.emplace_back(std::move(comp)); } else { // Create the composites. @@ -118,8 +116,8 @@ void cmCursesMainForm::InitializeUI() } if (!this->LookForCacheEntry(key)) { - newEntries.emplace_back(cm::make_unique( - key, this->CMakeInstance->GetState(), true, 30, entrywidth)); + newEntries.emplace_back(key, this->CMakeInstance->GetState(), true, 30, + entrywidth); this->OkToGenerate = false; } } @@ -134,8 +132,8 @@ void cmCursesMainForm::InitializeUI() } if (this->LookForCacheEntry(key)) { - newEntries.emplace_back(cm::make_unique( - key, this->CMakeInstance->GetState(), false, 30, entrywidth)); + newEntries.emplace_back(key, this->CMakeInstance->GetState(), false, + 30, entrywidth); } } } @@ -161,12 +159,12 @@ void cmCursesMainForm::RePost() } else { // If normal mode, count only non-advanced entries this->NumberOfVisibleEntries = 0; - for (std::unique_ptr& entry : this->Entries) { + for (cmCursesCacheEntryComposite& entry : this->Entries) { const char* existingValue = - this->CMakeInstance->GetState()->GetCacheEntryValue(entry->GetValue()); + this->CMakeInstance->GetState()->GetCacheEntryValue(entry.GetValue()); bool advanced = this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool( - entry->GetValue(), "ADVANCED"); + entry.GetValue(), "ADVANCED"); if (!existingValue || (!this->AdvancedMode && advanced)) { continue; } @@ -182,22 +180,22 @@ void cmCursesMainForm::RePost() this->Fields.reserve(3 * this->NumberOfVisibleEntries + 1); // Assign fields - for (std::unique_ptr& entry : this->Entries) { + for (cmCursesCacheEntryComposite& entry : this->Entries) { const char* existingValue = - this->CMakeInstance->GetState()->GetCacheEntryValue(entry->GetValue()); + this->CMakeInstance->GetState()->GetCacheEntryValue(entry.GetValue()); bool advanced = this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool( - entry->GetValue(), "ADVANCED"); + entry.GetValue(), "ADVANCED"); if (!existingValue || (!this->AdvancedMode && advanced)) { continue; } - this->Fields.push_back(entry->Label->Field); - this->Fields.push_back(entry->IsNewLabel->Field); - this->Fields.push_back(entry->Entry->Field); + this->Fields.push_back(entry.Label->Field); + this->Fields.push_back(entry.IsNewLabel->Field); + this->Fields.push_back(entry.Entry->Field); } // if no cache entries there should still be one dummy field if (this->Fields.empty()) { - const auto& front = *this->Entries.front(); + const auto& front = this->Entries.front(); this->Fields.push_back(front.Label->Field); this->Fields.push_back(front.IsNewLabel->Field); this->Fields.push_back(front.Entry->Field); @@ -241,12 +239,12 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) } else { // If normal, display only non-advanced entries this->NumberOfVisibleEntries = 0; - for (std::unique_ptr& entry : this->Entries) { + for (cmCursesCacheEntryComposite& entry : this->Entries) { const char* existingValue = - this->CMakeInstance->GetState()->GetCacheEntryValue(entry->GetValue()); + this->CMakeInstance->GetState()->GetCacheEntryValue(entry.GetValue()); bool advanced = this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool( - entry->GetValue(), "ADVANCED"); + entry.GetValue(), "ADVANCED"); if (!existingValue || (!this->AdvancedMode && advanced)) { continue; } @@ -259,12 +257,12 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) if (height > 0) { bool isNewPage; int i = 0; - for (std::unique_ptr& entry : this->Entries) { + for (cmCursesCacheEntryComposite& entry : this->Entries) { const char* existingValue = - this->CMakeInstance->GetState()->GetCacheEntryValue(entry->GetValue()); + this->CMakeInstance->GetState()->GetCacheEntryValue(entry.GetValue()); bool advanced = this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool( - entry->GetValue(), "ADVANCED"); + entry.GetValue(), "ADVANCED"); if (!existingValue || (!this->AdvancedMode && advanced)) { continue; } @@ -275,10 +273,10 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) if (isNewPage) { this->NumberOfPages++; } - entry->Label->Move(left, top + row - 1, isNewPage); - entry->IsNewLabel->Move(left + 32, top + row - 1, false); - entry->Entry->Move(left + 33, top + row - 1, false); - entry->Entry->SetPage(this->NumberOfPages); + entry.Label->Move(left, top + row - 1, isNewPage); + entry.IsNewLabel->Move(left + 32, top + row - 1, false); + entry.Entry->Move(left + 33, top + row - 1, false); + entry.Entry->SetPage(this->NumberOfPages); i++; } } @@ -630,12 +628,12 @@ void cmCursesMainForm::RemoveEntry(const char* value) return; } - auto removeIt = std::find_if( - this->Entries.begin(), this->Entries.end(), - [value](std::unique_ptr& entry) -> bool { - const char* val = entry->GetValue(); - return val != nullptr && !strcmp(value, val); - }); + auto removeIt = + std::find_if(this->Entries.begin(), this->Entries.end(), + [value](cmCursesCacheEntryComposite& entry) -> bool { + const char* val = entry.GetValue(); + return val != nullptr && !strcmp(value, val); + }); if (removeIt != this->Entries.end()) { this->CMakeInstance->UnwatchUnusedCli(value); @@ -646,13 +644,13 @@ void cmCursesMainForm::RemoveEntry(const char* value) // copy from the list box to the cache manager void cmCursesMainForm::FillCacheManagerFromUI() { - for (std::unique_ptr& entry : this->Entries) { - const std::string& cacheKey = entry->Key; + for (cmCursesCacheEntryComposite& entry : this->Entries) { + const std::string& cacheKey = entry.Key; const char* existingValue = this->CMakeInstance->GetState()->GetCacheEntryValue(cacheKey); if (existingValue) { std::string oldValue = existingValue; - std::string newValue = entry->Entry->GetValue(); + std::string newValue = entry.Entry->GetValue(); std::string fixedOldValue; std::string fixedNewValue; cmStateEnums::CacheEntryType t = @@ -943,12 +941,12 @@ void cmCursesMainForm::HandleInput() // make the next or prev. current field after deletion auto nextEntryIt = std::find_if( this->Entries.begin(), this->Entries.end(), - [&nextVal](std::unique_ptr& entry) { - return nextVal == entry->Key; + [&nextVal](cmCursesCacheEntryComposite const& entry) { + return nextVal == entry.Key; }); if (nextEntryIt != this->Entries.end()) { - set_current_field(this->Form, (*nextEntryIt)->Entry->Field); + set_current_field(this->Form, nextEntryIt->Entry->Field); } } } diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h index 9a83c30..48d1791 100644 --- a/Source/CursesDialog/cmCursesMainForm.h +++ b/Source/CursesDialog/cmCursesMainForm.h @@ -5,6 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include "cmCursesCacheEntryComposite.h" #include "cmCursesForm.h" #include "cmCursesStandardIncludes.h" #include "cmStateTypes.h" @@ -14,7 +15,6 @@ #include #include -class cmCursesCacheEntryComposite; class cmake; /** \class cmCursesMainForm @@ -123,7 +123,7 @@ protected: void JumpToCacheEntry(const char* str); // Copies of cache entries stored in the user interface - std::vector> Entries; + std::vector Entries; // Errors produced during last run of cmake std::vector Errors; // Command line arguments to be passed to cmake each time https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0833486d62e8ed3ae9f0219f9924c4e78d74f781 commit 0833486d62e8ed3ae9f0219f9924c4e78d74f781 Author: Tushar Maheshwari AuthorDate: Sat Sep 21 19:47:23 2019 +0530 Commit: Tushar Maheshwari CommitDate: Fri Sep 27 17:18:16 2019 +0530 cmCursesStringWidget: remove manual delete - Relpace `char*` operations with `std::string` diff --git a/Source/CursesDialog/cmCursesStringWidget.cxx b/Source/CursesDialog/cmCursesStringWidget.cxx index 3fc1858..d3a05e8 100644 --- a/Source/CursesDialog/cmCursesStringWidget.cxx +++ b/Source/CursesDialog/cmCursesStringWidget.cxx @@ -9,7 +9,6 @@ #include "cmStateTypes.h" #include -#include inline int ctrl(int z) { @@ -35,13 +34,13 @@ void cmCursesStringWidget::OnTab(cmCursesMainForm* /*unused*/, void cmCursesStringWidget::OnReturn(cmCursesMainForm* fm, WINDOW* /*unused*/) { - FORM* form = fm->GetForm(); if (this->InEdit) { cmCursesForm::LogMessage("String widget leaving edit."); this->InEdit = false; fm->PrintKeys(); - delete[] this->OriginalString; + this->OriginalString.clear(); // trick to force forms to update the field buffer + FORM* form = fm->GetForm(); form_driver(form, REQ_NEXT_FIELD); form_driver(form, REQ_PREV_FIELD); this->Done = true; @@ -49,9 +48,7 @@ void cmCursesStringWidget::OnReturn(cmCursesMainForm* fm, WINDOW* /*unused*/) cmCursesForm::LogMessage("String widget entering edit."); this->InEdit = true; fm->PrintKeys(); - char* buf = field_buffer(this->Field, 0); - this->OriginalString = new char[strlen(buf) + 1]; - strcpy(this->OriginalString, buf); + this->OriginalString = field_buffer(this->Field, 0); } } @@ -75,7 +72,7 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm, return false; } - this->OriginalString = nullptr; + this->OriginalString.clear(); this->Done = false; char debugMessage[128]; @@ -113,7 +110,7 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm, key == ctrl('p') || key == KEY_NPAGE || key == ctrl('d') || key == KEY_PPAGE || key == ctrl('u')) { this->InEdit = false; - delete[] this->OriginalString; + this->OriginalString.clear(); // trick to force forms to update the field buffer form_driver(form, REQ_NEXT_FIELD); form_driver(form, REQ_PREV_FIELD); @@ -125,7 +122,7 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm, this->InEdit = false; fm->PrintKeys(); this->SetString(this->OriginalString); - delete[] this->OriginalString; + this->OriginalString.clear(); touchwin(w); wrefresh(w); return true; @@ -188,23 +185,18 @@ bool cmCursesStringWidget::PrintKeys() } if (this->InEdit) { char fmt_s[] = "%s"; - char firstLine[512]; // Clean the toolbar - memset(firstLine, ' ', sizeof(firstLine)); - firstLine[511] = '\0'; curses_move(y - 4, 0); - printw(fmt_s, firstLine); - curses_move(y - 3, 0); - printw(fmt_s, firstLine); - curses_move(y - 2, 0); - printw(fmt_s, firstLine); - curses_move(y - 1, 0); - printw(fmt_s, firstLine); - + clrtoeol(); curses_move(y - 3, 0); printw(fmt_s, "Editing option, press [enter] to confirm"); + clrtoeol(); curses_move(y - 2, 0); printw(fmt_s, " press [esc] to cancel"); + clrtoeol(); + curses_move(y - 1, 0); + clrtoeol(); + return true; } return false; diff --git a/Source/CursesDialog/cmCursesStringWidget.h b/Source/CursesDialog/cmCursesStringWidget.h index 021515b..a41f0e8 100644 --- a/Source/CursesDialog/cmCursesStringWidget.h +++ b/Source/CursesDialog/cmCursesStringWidget.h @@ -23,9 +23,6 @@ class cmCursesStringWidget : public cmCursesWidget public: cmCursesStringWidget(int width, int height, int left, int top); - cmCursesStringWidget(cmCursesStringWidget const&) = delete; - cmCursesStringWidget& operator=(cmCursesStringWidget const&) = delete; - /** * Handle user input. Called by the container of this widget * when this widget has focus. Returns true if the input was @@ -65,7 +62,7 @@ public: protected: // true if the widget is in edit mode bool InEdit; - char* OriginalString; + std::string OriginalString; bool Done; }; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cf01d3d2bd649ab1157641b3212a360b06db747f commit cf01d3d2bd649ab1157641b3212a360b06db747f Author: Brad King AuthorDate: Thu Sep 26 14:47:53 2019 -0400 Commit: Brad King CommitDate: Thu Sep 26 14:58:26 2019 -0400 Tests: Clarify target names in RunCMake.add_subdirectory ExcludeFromAll Rename the `baz` target to `subinc` to clarify that its role is to be included even though it is in an otherwise excluded subdirectory. diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake b/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake index cc31428..16f39d9 100644 --- a/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake @@ -9,5 +9,5 @@ file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$>.c set(main_exe \"$\") set(foo_lib \"$\") set(bar_lib \"$\") -set(baz_lib \"$\") +set(subinc_lib \"$\") ") diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt index 99add23..9d7922f 100644 --- a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt @@ -1,8 +1,7 @@ add_library(bar STATIC bar.cpp) add_library(foo STATIC foo.cpp) - -add_library(baz STATIC foo.cpp) -set_target_properties(baz PROPERTIES EXCLUDE_FROM_ALL OFF) - target_include_directories(foo PUBLIC .) + +add_library(subinc STATIC subinc.cpp) +set_target_properties(subinc PROPERTIES EXCLUDE_FROM_ALL OFF) diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake index 2a0179e..56a8abd 100644 --- a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake @@ -6,7 +6,7 @@ if(EXISTS ${RunCMake_TEST_BINARY_DIR}/check-debug.cmake) foreach(file "${foo_lib}" - "${baz_lib}" + "${subinc_lib}" "${main_exe}" ) if(NOT EXISTS "${file}") diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/subinc.cpp b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/subinc.cpp new file mode 100644 index 0000000..e9faacd --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/subinc.cpp @@ -0,0 +1,4 @@ +int subinc() +{ + return 0; +} https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=21442d72a44c2bd732f2ff19ed89ce488854d25d commit 21442d72a44c2bd732f2ff19ed89ce488854d25d Author: Brad King AuthorDate: Tue Sep 24 12:39:33 2019 -0400 Commit: Brad King CommitDate: Thu Sep 26 14:57:40 2019 -0400 Tests: Revise RunCMake.add_subdirectory ExcludeFromAll to avoid globbing Also simplify the clean step. diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake b/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake index f686005..cc31428 100644 --- a/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake @@ -4,3 +4,10 @@ add_subdirectory(ExcludeFromAll EXCLUDE_FROM_ALL) add_executable(main main.cpp) target_link_libraries(main PRIVATE foo) + +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$>.cmake CONTENT " +set(main_exe \"$\") +set(foo_lib \"$\") +set(bar_lib \"$\") +set(baz_lib \"$\") +") diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt index 9e6462b..99add23 100644 --- a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt @@ -5,16 +5,4 @@ add_library(foo STATIC foo.cpp) add_library(baz STATIC foo.cpp) set_target_properties(baz PROPERTIES EXCLUDE_FROM_ALL OFF) -file(GENERATE - OUTPUT "${CMAKE_BINARY_DIR}/main.txt" - CONTENT "$") - -file(GENERATE - OUTPUT "${CMAKE_BINARY_DIR}/bar.txt" - CONTENT "$") - -file(GENERATE - OUTPUT "${CMAKE_BINARY_DIR}/baz.txt" - CONTENT "$") - target_include_directories(foo PUBLIC .) diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake index 14ec482..2a0179e 100644 --- a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake +++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake @@ -1,44 +1,31 @@ -# Use globbing to check if exes / libs were built because determining -# exactly where these files will live inside a CMake -P script is -# pretty challenging. - -file(READ "${RunCMake_TEST_BINARY_DIR}/main.txt" main_exe) -file(READ "${RunCMake_TEST_BINARY_DIR}/bar.txt" bar_lib) -file(READ "${RunCMake_TEST_BINARY_DIR}/baz.txt" baz_lib) - -set(found_main FALSE) -file(GLOB_RECURSE files - LIST_DIRECTORIES FALSE - RELATIVE "${RunCMake_TEST_BINARY_DIR}" - "${RunCMake_TEST_BINARY_DIR}/*") -foreach (file IN LISTS files) - if (file MATCHES "${main_exe}") - set(found_main TRUE) +if(EXISTS ${RunCMake_TEST_BINARY_DIR}/check-debug.cmake) + include(${RunCMake_TEST_BINARY_DIR}/check-debug.cmake) + if(RunCMake_TEST_FAILED) + return() endif() -endforeach() -if (NOT found_main) - set(RunCMake_TEST_FAILED "'main' missing from ${RunCMake_TEST_BINARY_DIR}") -endif() -set(found_bar FALSE) -set(found_baz FALSE) -file(GLOB_RECURSE files - LIST_DIRECTORIES FALSE - RELATIVE "${RunCMake_TEST_BINARY_DIR}/ExcludeFromAll" - "${RunCMake_TEST_BINARY_DIR}/ExcludeFromAll/*") -foreach (file IN LISTS files) - if (file MATCHES "${bar_lib}") - set(found_bar TRUE) - endif() - if (file MATCHES "${baz_lib}") - set(found_baz TRUE) - endif() -endforeach() -if (found_bar) - set(RunCMake_TEST_FAILED - "'bar' was not excluded from ${RunCMake_TEST_BINARY_DIR}/ExcludeFromAll") -endif() -if (NOT found_baz) - set(RunCMake_TEST_FAILED - "'baz' missing from ${RunCMake_TEST_BINARY_DIR}/ExcludeFromAll") + foreach(file + "${foo_lib}" + "${baz_lib}" + "${main_exe}" + ) + if(NOT EXISTS "${file}") + set(RunCMake_TEST_FAILED + "Artifact should exist but is missing:\n ${file}") + return() + endif() + endforeach() + foreach(file + "${bar_lib}" + ) + if(EXISTS "${file}") + set(RunCMake_TEST_FAILED + "Artifact should be missing but exists:\n ${file}") + return() + endif() + endforeach() +else() + set(RunCMake_TEST_FAILED " + '${RunCMake_TEST_BINARY_DIR}/check-debug.cmake' missing +") endif() diff --git a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake index 781e483..e9ba92f 100644 --- a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake @@ -27,14 +27,14 @@ run_cmake_install(CMP0082-OLD -DCMP0082_VALUE=OLD) run_cmake_install(CMP0082-NEW -DCMP0082_VALUE=NEW) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ExcludeFromAll-build) -set(RunCMake_TEST_NO_CLEAN 1) - -file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") -file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") - +if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) +endif() run_cmake(ExcludeFromAll) +set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake-check-file ExcludeFromAll/check.cmake) -run_cmake_command(ExcludeFromAll-build ${CMAKE_COMMAND} --build .) - -unset(RunCMake_TEST_BINARY_DIR) +run_cmake_command(ExcludeFromAll-build ${CMAKE_COMMAND} --build . --config Debug) +unset(RunCMake-check-file) unset(RunCMake_TEST_NO_CLEAN) +unset(RunCMake_TEST_OPTIONS) +unset(RunCMake_TEST_BINARY_DIR) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bc71b253cb372cc6c0ae50406a11b81fe4259559 commit bc71b253cb372cc6c0ae50406a11b81fe4259559 Author: Tushar Maheshwari AuthorDate: Sat Sep 14 17:27:00 2019 +0530 Commit: Brad King CommitDate: Thu Sep 26 11:10:22 2019 -0400 cmCursesCacheEntryComposite: default destructor diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx index 8b160a4..561784c 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx @@ -14,7 +14,10 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" +#include + #include +#include #include cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( @@ -23,9 +26,11 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( , LabelWidth(labelwidth) , EntryWidth(entrywidth) { - this->Label = new cmCursesLabelWidget(this->LabelWidth, 1, 1, 1, key); - this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, " "); - this->Entry = new cmCursesStringWidget(this->EntryWidth, 1, 1, 1); + this->Label = + cm::make_unique(this->LabelWidth, 1, 1, 1, key); + this->IsNewLabel = cm::make_unique(1, 1, 1, 1, " "); + this->Entry = + cm::make_unique(this->EntryWidth, 1, 1, 1); } cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( @@ -35,47 +40,51 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( , LabelWidth(labelwidth) , EntryWidth(entrywidth) { - this->Label = new cmCursesLabelWidget(this->LabelWidth, 1, 1, 1, key); + this->Label = + cm::make_unique(this->LabelWidth, 1, 1, 1, key); if (isNew) { - this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, "*"); + this->IsNewLabel = cm::make_unique(1, 1, 1, 1, "*"); } else { - this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, " "); + this->IsNewLabel = cm::make_unique(1, 1, 1, 1, " "); } - this->Entry = nullptr; const char* value = state->GetCacheEntryValue(key); assert(value); switch (state->GetCacheEntryType(key)) { - case cmStateEnums::BOOL: - this->Entry = new cmCursesBoolWidget(this->EntryWidth, 1, 1, 1); - if (cmIsOn(value)) { - static_cast(this->Entry)->SetValueAsBool(true); - } else { - static_cast(this->Entry)->SetValueAsBool(false); - } + case cmStateEnums::BOOL: { + auto bw = cm::make_unique(this->EntryWidth, 1, 1, 1); + bw->SetValueAsBool(cmIsOn(value)); + this->Entry = std::move(bw); break; - case cmStateEnums::PATH: - this->Entry = new cmCursesPathWidget(this->EntryWidth, 1, 1, 1); - static_cast(this->Entry)->SetString(value); + } + case cmStateEnums::PATH: { + auto pw = cm::make_unique(this->EntryWidth, 1, 1, 1); + pw->SetString(value); + this->Entry = std::move(pw); break; - case cmStateEnums::FILEPATH: - this->Entry = new cmCursesFilePathWidget(this->EntryWidth, 1, 1, 1); - static_cast(this->Entry)->SetString(value); + } + case cmStateEnums::FILEPATH: { + auto fpw = + cm::make_unique(this->EntryWidth, 1, 1, 1); + fpw->SetString(value); + this->Entry = std::move(fpw); break; + } case cmStateEnums::STRING: { const char* stringsProp = state->GetCacheEntryProperty(key, "STRINGS"); if (stringsProp) { - cmCursesOptionsWidget* ow = - new cmCursesOptionsWidget(this->EntryWidth, 1, 1, 1); - this->Entry = ow; - std::vector options = cmExpandedList(stringsProp); - for (auto const& opt : options) { + auto ow = + cm::make_unique(this->EntryWidth, 1, 1, 1); + for (std::string const& opt : cmExpandedList(stringsProp)) { ow->AddOption(opt); } ow->SetOption(value); + this->Entry = std::move(ow); } else { - this->Entry = new cmCursesStringWidget(this->EntryWidth, 1, 1, 1); - static_cast(this->Entry)->SetString(value); + auto sw = + cm::make_unique(this->EntryWidth, 1, 1, 1); + sw->SetString(value); + this->Entry = std::move(sw); } break; } @@ -88,12 +97,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( } } -cmCursesCacheEntryComposite::~cmCursesCacheEntryComposite() -{ - delete this->Label; - delete this->IsNewLabel; - delete this->Entry; -} +cmCursesCacheEntryComposite::~cmCursesCacheEntryComposite() = default; const char* cmCursesCacheEntryComposite::GetValue() { diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.h b/Source/CursesDialog/cmCursesCacheEntryComposite.h index b18f076..1ed60c8 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.h +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.h @@ -5,6 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include #include class cmCursesLabelWidget; @@ -29,9 +30,9 @@ public: friend class cmCursesMainForm; protected: - cmCursesLabelWidget* Label; - cmCursesLabelWidget* IsNewLabel; - cmCursesWidget* Entry; + std::unique_ptr Label; + std::unique_ptr IsNewLabel; + std::unique_ptr Entry; std::string Key; int LabelWidth; int EntryWidth; diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index e754196..15ccc91 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -103,7 +103,7 @@ void cmCursesMainForm::InitializeUI() // dummy entry widget (does not respond to input) std::unique_ptr comp = cm::make_unique("EMPTY CACHE", 30, 30); - comp->Entry = new cmCursesDummyWidget(1, 1, 1, 1); + comp->Entry = cm::make_unique(1, 1, 1, 1); newEntries.emplace_back(std::move(comp)); } else { // Create the composites. https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=36875ff419240a5a60b1b13ff190a5824a8363a5 commit 36875ff419240a5a60b1b13ff190a5824a8363a5 Author: Tushar Maheshwari AuthorDate: Sun Sep 8 11:22:38 2019 +0530 Commit: Brad King CommitDate: Thu Sep 26 11:10:20 2019 -0400 cmCursesMainForm: cleanup manual allocation diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx index 47fe84c..8b160a4 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx @@ -13,7 +13,6 @@ #include "cmStateTypes.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include "cmake.h" #include #include @@ -26,12 +25,11 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( { this->Label = new cmCursesLabelWidget(this->LabelWidth, 1, 1, 1, key); this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, " "); - this->Entry = nullptr; this->Entry = new cmCursesStringWidget(this->EntryWidth, 1, 1, 1); } cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( - const std::string& key, cmake* cm, bool isNew, int labelwidth, + const std::string& key, cmState* state, bool isNew, int labelwidth, int entrywidth) : Key(key) , LabelWidth(labelwidth) @@ -45,9 +43,9 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( } this->Entry = nullptr; - const char* value = cm->GetState()->GetCacheEntryValue(key); + const char* value = state->GetCacheEntryValue(key); assert(value); - switch (cm->GetState()->GetCacheEntryType(key)) { + switch (state->GetCacheEntryType(key)) { case cmStateEnums::BOOL: this->Entry = new cmCursesBoolWidget(this->EntryWidth, 1, 1, 1); if (cmIsOn(value)) { @@ -65,8 +63,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( static_cast(this->Entry)->SetString(value); break; case cmStateEnums::STRING: { - const char* stringsProp = - cm->GetState()->GetCacheEntryProperty(key, "STRINGS"); + const char* stringsProp = state->GetCacheEntryProperty(key, "STRINGS"); if (stringsProp) { cmCursesOptionsWidget* ow = new cmCursesOptionsWidget(this->EntryWidth, 1, 1, 1); diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.h b/Source/CursesDialog/cmCursesCacheEntryComposite.h index 0a69d3a..b18f076 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.h +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.h @@ -9,15 +9,15 @@ class cmCursesLabelWidget; class cmCursesWidget; -class cmake; +class cmState; class cmCursesCacheEntryComposite { public: cmCursesCacheEntryComposite(const std::string& key, int labelwidth, int entrywidth); - cmCursesCacheEntryComposite(const std::string& key, cmake* cm, bool isNew, - int labelwidth, int entrywidth); + cmCursesCacheEntryComposite(const std::string& key, cmState* state, + bool isNew, int labelwidth, int entrywidth); ~cmCursesCacheEntryComposite(); cmCursesCacheEntryComposite(cmCursesCacheEntryComposite const&) = delete; diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 5f8a19e..e754196 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCursesMainForm.h" -#include "cmAlgorithms.h" #include "cmCursesCacheEntryComposite.h" #include "cmCursesDummyWidget.h" #include "cmCursesForm.h" @@ -18,6 +17,8 @@ #include "cmVersion.h" #include "cmake.h" +#include + #include #include #include @@ -34,8 +35,6 @@ cmCursesMainForm::cmCursesMainForm(std::vector args, , InitialWidth(initWidth) { this->NumberOfPages = 0; - this->Fields = nullptr; - this->Entries = nullptr; this->AdvancedMode = false; this->NumberOfVisibleEntries = 0; this->OkToGenerate = false; @@ -43,7 +42,8 @@ cmCursesMainForm::cmCursesMainForm(std::vector args, "Welcome to ccmake, curses based user interface for CMake."); this->HelpMessage.emplace_back(); this->HelpMessage.emplace_back(s_ConstHelpMessage); - this->CMakeInstance = new cmake(cmake::RoleProject, cmState::Project); + this->CMakeInstance = + cm::make_unique(cmake::RoleProject, cmState::Project); this->CMakeInstance->SetCMakeEditCommand( cmSystemTools::GetCMakeCursesCommand()); @@ -52,8 +52,6 @@ cmCursesMainForm::cmCursesMainForm(std::vector args, cmStrCat(cmSystemTools::GetProgramPath(this->Args[0]), "/cmake"); this->Args[0] = whereCMake; this->CMakeInstance->SetArgs(this->Args); - this->SearchString = ""; - this->OldSearchString = ""; this->SearchMode = false; } @@ -64,27 +62,16 @@ cmCursesMainForm::~cmCursesMainForm() free_form(this->Form); this->Form = nullptr; } - delete[] this->Fields; - - // Clean-up composites - if (this->Entries) { - cmDeleteAll(*this->Entries); - } - delete this->Entries; - if (this->CMakeInstance) { - delete this->CMakeInstance; - this->CMakeInstance = nullptr; - } } // See if a cache entry is in the list of entries in the ui. bool cmCursesMainForm::LookForCacheEntry(const std::string& key) { - return this->Entries && - std::any_of(this->Entries->begin(), this->Entries->end(), - [&key](cmCursesCacheEntryComposite* entry) { - return key == entry->Key; - }); + return std::any_of( + this->Entries.begin(), this->Entries.end(), + [&key](std::unique_ptr const& entry) { + return key == entry->Key; + }); } // Create new cmCursesCacheEntryComposite entries from the cache @@ -92,11 +79,10 @@ void cmCursesMainForm::InitializeUI() { // Create a vector of cmCursesCacheEntryComposite's // which contain labels, entries and new entry markers - std::vector* newEntries = - new std::vector; + std::vector> newEntries; std::vector cacheKeys = this->CMakeInstance->GetState()->GetCacheEntryKeys(); - newEntries->reserve(cacheKeys.size()); + newEntries.reserve(cacheKeys.size()); // Count non-internal and non-static entries int count = 0; @@ -112,13 +98,13 @@ void cmCursesMainForm::InitializeUI() int entrywidth = this->InitialWidth - 35; - cmCursesCacheEntryComposite* comp; if (count == 0) { // If cache is empty, display a label saying so and a // dummy entry widget (does not respond to input) - comp = new cmCursesCacheEntryComposite("EMPTY CACHE", 30, 30); + std::unique_ptr comp = + cm::make_unique("EMPTY CACHE", 30, 30); comp->Entry = new cmCursesDummyWidget(1, 1, 1, 1); - newEntries->push_back(comp); + newEntries.emplace_back(std::move(comp)); } else { // Create the composites. @@ -132,8 +118,8 @@ void cmCursesMainForm::InitializeUI() } if (!this->LookForCacheEntry(key)) { - newEntries->push_back(new cmCursesCacheEntryComposite( - key, this->CMakeInstance, true, 30, entrywidth)); + newEntries.emplace_back(cm::make_unique( + key, this->CMakeInstance->GetState(), true, 30, entrywidth)); this->OkToGenerate = false; } } @@ -148,18 +134,14 @@ void cmCursesMainForm::InitializeUI() } if (this->LookForCacheEntry(key)) { - newEntries->push_back(new cmCursesCacheEntryComposite( - key, this->CMakeInstance, false, 30, entrywidth)); + newEntries.emplace_back(cm::make_unique( + key, this->CMakeInstance->GetState(), false, 30, entrywidth)); } } } - // Clean old entries - if (this->Entries) { - cmDeleteAll(*this->Entries); - } - delete this->Entries; - this->Entries = newEntries; + // Replace old entries + this->Entries = std::move(newEntries); // Compute fields from composites this->RePost(); @@ -173,13 +155,13 @@ void cmCursesMainForm::RePost() free_form(this->Form); this->Form = nullptr; } - delete[] this->Fields; + this->Fields.clear(); if (this->AdvancedMode) { - this->NumberOfVisibleEntries = this->Entries->size(); + this->NumberOfVisibleEntries = this->Entries.size(); } else { // If normal mode, count only non-advanced entries this->NumberOfVisibleEntries = 0; - for (cmCursesCacheEntryComposite* entry : *this->Entries) { + for (std::unique_ptr& entry : this->Entries) { const char* existingValue = this->CMakeInstance->GetState()->GetCacheEntryValue(entry->GetValue()); bool advanced = @@ -197,15 +179,10 @@ void cmCursesMainForm::RePost() } // Assign the fields: 3 for each entry: label, new entry marker // ('*' or ' ') and entry widget - this->Fields = new FIELD*[3 * this->NumberOfVisibleEntries + 1]; - size_t cc; - for (cc = 0; cc < 3 * this->NumberOfVisibleEntries + 1; cc++) { - this->Fields[cc] = nullptr; - } + this->Fields.reserve(3 * this->NumberOfVisibleEntries + 1); // Assign fields - int j = 0; - for (cmCursesCacheEntryComposite* entry : *this->Entries) { + for (std::unique_ptr& entry : this->Entries) { const char* existingValue = this->CMakeInstance->GetState()->GetCacheEntryValue(entry->GetValue()); bool advanced = @@ -214,21 +191,20 @@ void cmCursesMainForm::RePost() if (!existingValue || (!this->AdvancedMode && advanced)) { continue; } - this->Fields[3 * j] = entry->Label->Field; - this->Fields[3 * j + 1] = entry->IsNewLabel->Field; - this->Fields[3 * j + 2] = entry->Entry->Field; - j++; + this->Fields.push_back(entry->Label->Field); + this->Fields.push_back(entry->IsNewLabel->Field); + this->Fields.push_back(entry->Entry->Field); } // if no cache entries there should still be one dummy field - if (j == 0) { - const auto& front = *this->Entries->front(); - this->Fields[0] = front.Label->Field; - this->Fields[1] = front.IsNewLabel->Field; - this->Fields[2] = front.Entry->Field; + if (this->Fields.empty()) { + const auto& front = *this->Entries.front(); + this->Fields.push_back(front.Label->Field); + this->Fields.push_back(front.IsNewLabel->Field); + this->Fields.push_back(front.Entry->Field); this->NumberOfVisibleEntries = 1; } // Has to be null terminated. - this->Fields[3 * this->NumberOfVisibleEntries] = nullptr; + this->Fields.push_back(nullptr); } void cmCursesMainForm::Render(int left, int top, int width, int height) @@ -261,11 +237,11 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) height -= 7; if (this->AdvancedMode) { - this->NumberOfVisibleEntries = this->Entries->size(); + this->NumberOfVisibleEntries = this->Entries.size(); } else { // If normal, display only non-advanced entries this->NumberOfVisibleEntries = 0; - for (cmCursesCacheEntryComposite* entry : *this->Entries) { + for (std::unique_ptr& entry : this->Entries) { const char* existingValue = this->CMakeInstance->GetState()->GetCacheEntryValue(entry->GetValue()); bool advanced = @@ -283,7 +259,7 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) if (height > 0) { bool isNewPage; int i = 0; - for (cmCursesCacheEntryComposite* entry : *this->Entries) { + for (std::unique_ptr& entry : this->Entries) { const char* existingValue = this->CMakeInstance->GetState()->GetCacheEntryValue(entry->GetValue()); bool advanced = @@ -308,7 +284,7 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) } // Post the form - this->Form = new_form(this->Fields); + this->Form = new_form(this->Fields.data()); post_form(this->Form); // Update toolbar this->UpdateStatusBar(); @@ -654,23 +630,23 @@ void cmCursesMainForm::RemoveEntry(const char* value) return; } - auto removeIt = - std::find_if(this->Entries->begin(), this->Entries->end(), - [value](cmCursesCacheEntryComposite* entry) -> bool { - const char* val = entry->GetValue(); - return val != nullptr && !strcmp(value, val); - }); + auto removeIt = std::find_if( + this->Entries.begin(), this->Entries.end(), + [value](std::unique_ptr& entry) -> bool { + const char* val = entry->GetValue(); + return val != nullptr && !strcmp(value, val); + }); - if (removeIt != this->Entries->end()) { + if (removeIt != this->Entries.end()) { this->CMakeInstance->UnwatchUnusedCli(value); - this->Entries->erase(removeIt); + this->Entries.erase(removeIt); } } // copy from the list box to the cache manager void cmCursesMainForm::FillCacheManagerFromUI() { - for (cmCursesCacheEntryComposite* entry : *this->Entries) { + for (std::unique_ptr& entry : this->Entries) { const std::string& cacheKey = entry->Key; const char* existingValue = this->CMakeInstance->GetState()->GetCacheEntryValue(cacheKey); @@ -762,7 +738,7 @@ void cmCursesMainForm::HandleInput() this->JumpToCacheEntry(this->SearchString.c_str()); this->OldSearchString = this->SearchString; } - this->SearchString = ""; + this->SearchString.clear(); } /* else if ( key == KEY_ESCAPE ) @@ -778,7 +754,7 @@ void cmCursesMainForm::HandleInput() } } else if (key == ctrl('h') || key == KEY_BACKSPACE || key == KEY_DC) { if (!this->SearchString.empty()) { - this->SearchString.resize(this->SearchString.size() - 1); + this->SearchString.pop_back(); } } } else if (currentWidget && !this->SearchMode) { @@ -867,17 +843,9 @@ void cmCursesMainForm::HandleInput() curField, "HELPSTRING"); } if (helpString) { - char* message = new char - [strlen(curField) + strlen(helpString) + - strlen( - "Current option is: \n Help string for this option is: \n") + - 10]; - sprintf( - message, - "Current option is: %s\nHelp string for this option is: %s\n", - curField, helpString); - this->HelpMessage[1] = message; - delete[] message; + this->HelpMessage[1] = + cmStrCat("Current option is: ", curField, '\n', + "Help string for this option is: ", helpString, '\n'); } else { this->HelpMessage[1] = ""; } @@ -973,13 +941,13 @@ void cmCursesMainForm::HandleInput() if (nextCur) { // make the next or prev. current field after deletion - auto nextEntryIt = - std::find_if(this->Entries->begin(), this->Entries->end(), - [&nextVal](cmCursesCacheEntryComposite* entry) { - return nextVal == entry->Key; - }); + auto nextEntryIt = std::find_if( + this->Entries.begin(), this->Entries.end(), + [&nextVal](std::unique_ptr& entry) { + return nextVal == entry->Key; + }); - if (nextEntryIt != this->Entries->end()) { + if (nextEntryIt != this->Entries.end()) { set_current_field(this->Form, (*nextEntryIt)->Entry->Field); } } diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h index f3194ab..9a83c30 100644 --- a/Source/CursesDialog/cmCursesMainForm.h +++ b/Source/CursesDialog/cmCursesMainForm.h @@ -10,6 +10,7 @@ #include "cmStateTypes.h" #include +#include #include #include @@ -122,7 +123,7 @@ protected: void JumpToCacheEntry(const char* str); // Copies of cache entries stored in the user interface - std::vector* Entries; + std::vector> Entries; // Errors produced during last run of cmake std::vector Errors; // Command line arguments to be passed to cmake each time @@ -136,11 +137,7 @@ protected: static const char* s_ConstHelpMessage; // Fields displayed. Includes labels, new entry markers, entries - FIELD** Fields; - // Where is source of current project - std::string WhereSource; - // Where is cmake executable - std::string WhereCMake; + std::vector Fields; // Number of entries shown (depends on mode -normal or advanced-) size_t NumberOfVisibleEntries; bool AdvancedMode; @@ -150,7 +147,7 @@ protected: int NumberOfPages; int InitialWidth; - cmake* CMakeInstance; + std::unique_ptr CMakeInstance; std::string SearchString; std::string OldSearchString; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2b1607114985e56a7847eb6081d5656f73c230d0 commit 2b1607114985e56a7847eb6081d5656f73c230d0 Author: Tushar Maheshwari AuthorDate: Thu Sep 26 08:36:24 2019 +0530 Commit: Tushar Maheshwari CommitDate: Thu Sep 26 13:50:58 2019 +0530 CursesDialog: modernize CMake usage diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 8ed7b2f..fe048cb 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -1142,7 +1142,7 @@ target_link_libraries(cpack CPackLib) # Curses GUI if(BUILD_CursesDialog) - include(${CMake_SOURCE_DIR}/Source/CursesDialog/CMakeLists.txt) + add_subdirectory(CursesDialog) endif() # Qt GUI diff --git a/Source/CursesDialog/CMakeLists.txt b/Source/CursesDialog/CMakeLists.txt index 270b07e..7009717 100644 --- a/Source/CursesDialog/CMakeLists.txt +++ b/Source/CursesDialog/CMakeLists.txt @@ -1,26 +1,22 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -set( CURSES_SRCS - CursesDialog/cmCursesOptionsWidget.cxx - CursesDialog/cmCursesBoolWidget.cxx - CursesDialog/cmCursesCacheEntryComposite.cxx - CursesDialog/cmCursesDummyWidget.cxx - CursesDialog/cmCursesFilePathWidget.cxx - CursesDialog/cmCursesForm.cxx - CursesDialog/cmCursesLabelWidget.cxx - CursesDialog/cmCursesLongMessageForm.cxx - CursesDialog/cmCursesMainForm.cxx - CursesDialog/cmCursesPathWidget.cxx - CursesDialog/cmCursesStringWidget.cxx - CursesDialog/cmCursesWidget.cxx - CursesDialog/ccmake.cxx - ) - -include_directories(${CURSES_INCLUDE_PATH}) - - -add_executable(ccmake ${CURSES_SRCS} ) +add_executable(ccmake + ccmake.cxx + cmCursesBoolWidget.cxx + cmCursesCacheEntryComposite.cxx + cmCursesDummyWidget.cxx + cmCursesFilePathWidget.cxx + cmCursesForm.cxx + cmCursesLabelWidget.cxx + cmCursesLongMessageForm.cxx + cmCursesMainForm.cxx + cmCursesOptionsWidget.cxx + cmCursesPathWidget.cxx + cmCursesStringWidget.cxx + cmCursesWidget.cxx + ) +target_include_directories(ccmake PRIVATE ${CURSES_INCLUDE_PATH}) target_link_libraries(ccmake CMakeLib) if(CMAKE_USE_SYSTEM_FORM) find_path(CURSES_FORM_INCLUDE_DIR NAMES form.h HINTS ${CURSES_INCLUDE_PATH} ${CURSES_INCLUDE_PATH}/ncurses) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0cfbd85e7b0d61affda6450b1cc081860b5543a6 commit 0cfbd85e7b0d61affda6450b1cc081860b5543a6 Author: Brad King AuthorDate: Tue Sep 24 13:07:14 2019 -0400 Commit: Brad King CommitDate: Tue Sep 24 14:10:34 2019 -0400 Tests: Teach RunCMake to support a custom working directory diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index ce71677..644da60 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -82,9 +82,12 @@ function(run_cmake test) set(maybe_input_file "") endif() if(RunCMake_TEST_COMMAND) + if(NOT RunCMake_TEST_COMMAND_WORKING_DIRECTORY) + set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + endif() execute_process( COMMAND ${RunCMake_TEST_COMMAND} - WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}" + WORKING_DIRECTORY "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}" OUTPUT_VARIABLE actual_stdout ERROR_VARIABLE ${actual_stderr_var} RESULT_VARIABLE actual_result ----------------------------------------------------------------------- Summary of changes: Help/command/enable_language.rst | 5 +- Help/command/project.rst | 3 +- Help/manual/cmake-generator-expressions.7.rst | 28 + Help/manual/cmake-modules.7.rst | 6 + Help/module/CheckOBJCCompilerFlag.rst | 1 + Help/module/CheckOBJCSourceCompiles.rst | 1 + Help/module/CheckOBJCSourceRuns.rst | 1 + Help/module/CheckOBJCXXCompilerFlag.rst | 1 + Help/module/CheckOBJCXXSourceCompiles.rst | 1 + Help/module/CheckOBJCXXSourceRuns.rst | 1 + Help/prop_dir/EXCLUDE_FROM_ALL.rst | 20 +- Help/prop_tgt/EXCLUDE_FROM_ALL.rst | 16 +- Help/release/3.14.rst | 8 + Help/release/3.15.rst | 9 + Help/release/dev/FPHSA-reason-failure-message.rst | 5 + Help/release/dev/objective-c-cxx.rst | 9 + Modules/CMakeCXXCompiler.cmake.in | 11 +- Modules/CMakeDetermineOBJCCompiler.cmake | 189 +++++ Modules/CMakeDetermineOBJCXXCompiler.cmake | 197 +++++ Modules/CMakeOBJCCompiler.cmake.in | 69 ++ Modules/CMakeOBJCCompilerABI.m | 20 + Modules/CMakeOBJCCompilerId.m.in | 63 ++ Modules/CMakeOBJCInformation.cmake | 188 +++++ Modules/CMakeOBJCXXCompiler.cmake.in | 79 ++ Modules/CMakeOBJCXXCompilerABI.mm | 20 + Modules/CMakeOBJCXXCompilerId.mm.in | 68 ++ Modules/CMakeOBJCXXInformation.cmake | 273 +++++++ Modules/CMakeTestOBJCCompiler.cmake | 94 +++ Modules/CMakeTestOBJCXXCompiler.cmake | 93 +++ Modules/CheckOBJCCompilerFlag.cmake | 64 ++ Modules/CheckOBJCSourceCompiles.cmake | 145 ++++ Modules/CheckOBJCSourceRuns.cmake | 145 ++++ Modules/CheckOBJCXXCompilerFlag.cmake | 64 ++ Modules/CheckOBJCXXSourceCompiles.cmake | 146 ++++ Modules/CheckOBJCXXSourceRuns.cmake | 145 ++++ Modules/Compiler/AppleClang-OBJC.cmake | 17 + Modules/Compiler/AppleClang-OBJCXX.cmake | 37 + Modules/Compiler/Clang-OBJC.cmake | 18 + Modules/Compiler/Clang-OBJCXX.cmake | 70 ++ Modules/Compiler/GNU-OBJC.cmake | 6 + Modules/Compiler/GNU-OBJCXX.cmake | 10 + Modules/FindPackageHandleStandardArgs.cmake | 27 +- Modules/Platform/Apple-AppleClang-OBJC.cmake | 6 + Modules/Platform/Apple-AppleClang-OBJCXX.cmake | 6 + Modules/Platform/Apple-Clang-OBJC.cmake | 2 + Modules/Platform/Apple-Clang-OBJCXX.cmake | 2 + Modules/Platform/Apple-GNU-OBJC.cmake | 4 + Modules/Platform/Apple-GNU-OBJCXX.cmake | 4 + Modules/Platform/Darwin.cmake | 10 +- Source/CMakeLists.txt | 2 +- Source/CursesDialog/CMakeLists.txt | 36 +- .../CursesDialog/cmCursesCacheEntryComposite.cxx | 81 +- Source/CursesDialog/cmCursesCacheEntryComposite.h | 17 +- Source/CursesDialog/cmCursesMainForm.cxx | 174 ++--- Source/CursesDialog/cmCursesMainForm.h | 13 +- Source/CursesDialog/cmCursesStringWidget.cxx | 32 +- Source/CursesDialog/cmCursesStringWidget.h | 5 +- Source/cmGeneratorExpressionNode.cxx | 8 +- Source/cmGlobalGenerator.cxx | 14 +- Source/cmGlobalGenerator.h | 2 +- Source/cmGlobalNinjaGenerator.h | 4 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 31 +- Source/cmGlobalVisualStudioGenerator.cxx | 2 +- Source/cmGlobalXCodeGenerator.cxx | 2 +- Source/cmLocalGenerator.cxx | 12 +- Source/cmLocalNinjaGenerator.cxx | 4 +- Source/cmMakefile.cxx | 158 ++-- Source/cmMakefile.h | 14 +- Source/cmQtAutoGenerator.cxx | 266 ++++--- Source/cmQtAutoGenerator.h | 96 ++- Source/cmQtAutoMocUic.cxx | 856 +++++++++++++++++---- Source/cmQtAutoMocUic.h | 551 +------------ Source/cmQtAutoRcc.cxx | 129 +++- Source/cmQtAutoRcc.h | 72 +- Source/cmTarget.cxx | 8 + Source/cmcmd.cxx | 21 +- Tests/CMakeLists.txt | 73 ++ Tests/CMakeOnly/CMakeLists.txt | 11 + Tests/CMakeOnly/CheckLanguage/CMakeLists.txt | 12 +- .../CMakeOnly/CheckOBJCCompilerFlag/CMakeLists.txt | 17 + .../CheckOBJCXXCompilerFlag/CMakeLists.txt | 17 + Tests/CMakeOnly/CompilerIdOBJC/CMakeLists.txt | 14 + Tests/CMakeOnly/CompilerIdOBJCXX/CMakeLists.txt | 14 + .../cxx-file-extension-test/CMakeLists.txt | 5 + .../Objective-C++/cxx-file-extension-test/main.mm | 8 + .../objcxx-file-extension-test/CMakeLists.txt | 6 + .../objcxx-file-extension-test/main.mm | 14 + .../Objective-C++/simple-build-test/CMakeLists.txt | 11 + Tests/Objective-C++/simple-build-test/foo.h | 9 + Tests/Objective-C++/simple-build-test/foo.mm | 7 + Tests/Objective-C++/simple-build-test/main.mm | 14 + .../c-file-extension-test/CMakeLists.txt | 5 + Tests/Objective-C/c-file-extension-test/main.m | 8 + .../objc-file-extension-test/CMakeLists.txt | 6 + Tests/Objective-C/objc-file-extension-test/main.m | 12 + Tests/Objective-C/simple-build-test/CMakeLists.txt | 11 + Tests/Objective-C/simple-build-test/foo.h | 9 + Tests/Objective-C/simple-build-test/foo.m | 7 + Tests/Objective-C/simple-build-test/main.m | 12 + Tests/RunCMake/FPHSA/CustomMessageConfig.cmake | 1 + .../FPHSA/CustomMessageConfigVersion.cmake | 4 + Tests/RunCMake/FPHSA/FindCustomMessage.cmake | 17 + Tests/RunCMake/FPHSA/RunCMakeTest.cmake | 7 + .../custom_message_1-result.txt} | 0 Tests/RunCMake/FPHSA/custom_message_1-stderr.txt | 7 + Tests/RunCMake/FPHSA/custom_message_1.cmake | 4 + .../custom_message_2-result.txt} | 0 Tests/RunCMake/FPHSA/custom_message_2-stderr.txt | 8 + Tests/RunCMake/FPHSA/custom_message_2.cmake | 5 + .../custom_message_3-result.txt} | 0 Tests/RunCMake/FPHSA/custom_message_3-stderr.txt | 9 + Tests/RunCMake/FPHSA/custom_message_3.cmake | 5 + Tests/RunCMake/RunCMake.cmake | 5 +- .../ExcludeFromAll-build-sub-stderr.txt} | 0 .../RunCMake/add_subdirectory/ExcludeFromAll.cmake | 8 + .../add_subdirectory/ExcludeFromAll/CMakeLists.txt | 23 +- .../ExcludeFromAll/check-sub.cmake | 32 + .../add_subdirectory/ExcludeFromAll/check.cmake | 73 +- .../add_subdirectory/ExcludeFromAll/subinc.cpp | 4 + .../add_subdirectory/ExcludeFromAll/zot.cpp | 4 + Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake | 36 +- Tests/TryCompile/CMakeLists.txt | 54 ++ 122 files changed, 4252 insertions(+), 1373 deletions(-) create mode 100644 Help/module/CheckOBJCCompilerFlag.rst create mode 100644 Help/module/CheckOBJCSourceCompiles.rst create mode 100644 Help/module/CheckOBJCSourceRuns.rst create mode 100644 Help/module/CheckOBJCXXCompilerFlag.rst create mode 100644 Help/module/CheckOBJCXXSourceCompiles.rst create mode 100644 Help/module/CheckOBJCXXSourceRuns.rst create mode 100644 Help/release/dev/FPHSA-reason-failure-message.rst create mode 100644 Help/release/dev/objective-c-cxx.rst create mode 100644 Modules/CMakeDetermineOBJCCompiler.cmake create mode 100644 Modules/CMakeDetermineOBJCXXCompiler.cmake create mode 100644 Modules/CMakeOBJCCompiler.cmake.in create mode 100644 Modules/CMakeOBJCCompilerABI.m create mode 100644 Modules/CMakeOBJCCompilerId.m.in create mode 100644 Modules/CMakeOBJCInformation.cmake create mode 100644 Modules/CMakeOBJCXXCompiler.cmake.in create mode 100644 Modules/CMakeOBJCXXCompilerABI.mm create mode 100644 Modules/CMakeOBJCXXCompilerId.mm.in create mode 100644 Modules/CMakeOBJCXXInformation.cmake create mode 100644 Modules/CMakeTestOBJCCompiler.cmake create mode 100644 Modules/CMakeTestOBJCXXCompiler.cmake create mode 100644 Modules/CheckOBJCCompilerFlag.cmake create mode 100644 Modules/CheckOBJCSourceCompiles.cmake create mode 100644 Modules/CheckOBJCSourceRuns.cmake create mode 100644 Modules/CheckOBJCXXCompilerFlag.cmake create mode 100644 Modules/CheckOBJCXXSourceCompiles.cmake create mode 100644 Modules/CheckOBJCXXSourceRuns.cmake create mode 100644 Modules/Compiler/AppleClang-OBJC.cmake create mode 100644 Modules/Compiler/AppleClang-OBJCXX.cmake create mode 100644 Modules/Compiler/Clang-OBJC.cmake create mode 100644 Modules/Compiler/Clang-OBJCXX.cmake create mode 100644 Modules/Compiler/GNU-OBJC.cmake create mode 100644 Modules/Compiler/GNU-OBJCXX.cmake create mode 100644 Modules/Platform/Apple-AppleClang-OBJC.cmake create mode 100644 Modules/Platform/Apple-AppleClang-OBJCXX.cmake create mode 100644 Modules/Platform/Apple-Clang-OBJC.cmake create mode 100644 Modules/Platform/Apple-Clang-OBJCXX.cmake create mode 100644 Modules/Platform/Apple-GNU-OBJC.cmake create mode 100644 Modules/Platform/Apple-GNU-OBJCXX.cmake create mode 100644 Tests/CMakeOnly/CheckOBJCCompilerFlag/CMakeLists.txt create mode 100644 Tests/CMakeOnly/CheckOBJCXXCompilerFlag/CMakeLists.txt create mode 100644 Tests/CMakeOnly/CompilerIdOBJC/CMakeLists.txt create mode 100644 Tests/CMakeOnly/CompilerIdOBJCXX/CMakeLists.txt create mode 100644 Tests/Objective-C++/cxx-file-extension-test/CMakeLists.txt create mode 100644 Tests/Objective-C++/cxx-file-extension-test/main.mm create mode 100644 Tests/Objective-C++/objcxx-file-extension-test/CMakeLists.txt create mode 100644 Tests/Objective-C++/objcxx-file-extension-test/main.mm create mode 100644 Tests/Objective-C++/simple-build-test/CMakeLists.txt create mode 100644 Tests/Objective-C++/simple-build-test/foo.h create mode 100644 Tests/Objective-C++/simple-build-test/foo.mm create mode 100644 Tests/Objective-C++/simple-build-test/main.mm create mode 100644 Tests/Objective-C/c-file-extension-test/CMakeLists.txt create mode 100644 Tests/Objective-C/c-file-extension-test/main.m create mode 100644 Tests/Objective-C/objc-file-extension-test/CMakeLists.txt create mode 100644 Tests/Objective-C/objc-file-extension-test/main.m create mode 100644 Tests/Objective-C/simple-build-test/CMakeLists.txt create mode 100644 Tests/Objective-C/simple-build-test/foo.h create mode 100644 Tests/Objective-C/simple-build-test/foo.m create mode 100644 Tests/Objective-C/simple-build-test/main.m create mode 100644 Tests/RunCMake/FPHSA/CustomMessageConfig.cmake create mode 100644 Tests/RunCMake/FPHSA/CustomMessageConfigVersion.cmake create mode 100644 Tests/RunCMake/FPHSA/FindCustomMessage.cmake copy Tests/RunCMake/{while/MissingArgument-result.txt => FPHSA/custom_message_1-result.txt} (100%) create mode 100644 Tests/RunCMake/FPHSA/custom_message_1-stderr.txt create mode 100644 Tests/RunCMake/FPHSA/custom_message_1.cmake copy Tests/RunCMake/{while/MissingArgument-result.txt => FPHSA/custom_message_2-result.txt} (100%) create mode 100644 Tests/RunCMake/FPHSA/custom_message_2-stderr.txt create mode 100644 Tests/RunCMake/FPHSA/custom_message_2.cmake copy Tests/RunCMake/{while/MissingArgument-result.txt => FPHSA/custom_message_3-result.txt} (100%) create mode 100644 Tests/RunCMake/FPHSA/custom_message_3-stderr.txt create mode 100644 Tests/RunCMake/FPHSA/custom_message_3.cmake copy Tests/RunCMake/{target_link_options/LINK_OPTIONS-shared-result.txt => add_subdirectory/ExcludeFromAll-build-sub-stderr.txt} (100%) create mode 100644 Tests/RunCMake/add_subdirectory/ExcludeFromAll/check-sub.cmake create mode 100644 Tests/RunCMake/add_subdirectory/ExcludeFromAll/subinc.cpp create mode 100644 Tests/RunCMake/add_subdirectory/ExcludeFromAll/zot.cpp hooks/post-receive -- CMake From kwrobot at kitware.com Mon Sep 30 10:48:05 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 30 Sep 2019 10:48:05 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1265-gacbe5ae Message-ID: <20190930144805.B2D02C0484@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via acbe5ae049f5918e3653cb250196f27f02a773d2 (commit) via fcd7b53d9594a5c3a1f2daf4e29bc7ab2f2e9e08 (commit) via e7637a3d1ad48f675050483199cb98565983d622 (commit) via 73dad4708f8c5f9bd7001d15dbbada91e4c0c4b3 (commit) from 8aa5f6ba446dd8ff817e54979f466b8a247f967a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=acbe5ae049f5918e3653cb250196f27f02a773d2 commit acbe5ae049f5918e3653cb250196f27f02a773d2 Merge: fcd7b53 e7637a3 Author: Brad King AuthorDate: Mon Sep 30 10:43:47 2019 -0400 Commit: Brad King CommitDate: Mon Sep 30 10:43:47 2019 -0400 Merge branch 'release-3.15' https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fcd7b53d9594a5c3a1f2daf4e29bc7ab2f2e9e08 commit fcd7b53d9594a5c3a1f2daf4e29bc7ab2f2e9e08 Merge: 8aa5f6b 73dad47 Author: Brad King AuthorDate: Mon Sep 30 10:43:37 2019 -0400 Commit: Brad King CommitDate: Mon Sep 30 10:43:37 2019 -0400 Merge branch 'release-3.14' https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=73dad4708f8c5f9bd7001d15dbbada91e4c0c4b3 commit 73dad4708f8c5f9bd7001d15dbbada91e4c0c4b3 Merge: 9654191 62d45d9 Author: Brad King AuthorDate: Mon Sep 30 10:28:20 2019 -0400 Commit: Brad King CommitDate: Mon Sep 30 10:28:20 2019 -0400 Merge branch 'backport-3.14-fix-EXCLUDE_FROM_ALL-subdir-all' into release-3.14 Merge-request: !3863 ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From kwrobot at kitware.com Mon Sep 30 10:48:06 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 30 Sep 2019 10:48:06 -0400 (EDT) Subject: [Cmake-commits] CMake branch, release, updated. v3.15.3-19-ge7637a3 Message-ID: <20190930144806.2C30FF8C9A@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, release has been updated via e7637a3d1ad48f675050483199cb98565983d622 (commit) via 013d7dd48420b7040355066724ede9eb7050c94a (commit) via 61103c0bac4e9ef264d87fe9b23087ed8f5291c4 (commit) via 1fe450159278fd30138ef5133daf26f931537de4 (commit) via 05d7ca14e99ee8ad36da01ddb314d0b90ab41874 (commit) via 62d45d91e83f537b19d9bfc7b1e8d909a0c5c322 (commit) via b3b1c7bf3afc8f33fa69b79f47f778cb781ac3c7 (commit) via 156b56480a786db4d967bde5eb6d5edee56a27d0 (commit) via cf01d3d2bd649ab1157641b3212a360b06db747f (commit) via 21442d72a44c2bd732f2ff19ed89ce488854d25d (commit) via 0cfbd85e7b0d61affda6450b1cc081860b5543a6 (commit) via 96541918c88c9a1647b44fbe07ca7d50e821a98a (commit) via 3af48083a24676025590e1e3a8db2cfef0317901 (commit) via 366746bbef613f9d258e66a32f8fbacd407acfba (commit) via c54fc8213bfbd33b9584188b90cd494e2bf515db (commit) from 5a35a9c70d1dc92ec70a6ff454bc9441fa410968 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: Help/prop_dir/EXCLUDE_FROM_ALL.rst | 20 +++--- Help/prop_tgt/EXCLUDE_FROM_ALL.rst | 16 ++--- Help/release/3.14.rst | 8 +++ Help/release/3.15.rst | 9 +++ Source/cmGlobalGenerator.cxx | 14 ++++- Source/cmGlobalGenerator.h | 2 +- Source/cmGlobalNinjaGenerator.h | 4 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 31 +++++++-- Source/cmGlobalVisualStudioGenerator.cxx | 2 +- Source/cmGlobalXCodeGenerator.cxx | 2 +- Source/cmLocalNinjaGenerator.cxx | 4 +- Source/cmMakefile.cxx | 10 ++- Tests/RunCMake/RunCMake.cmake | 5 +- .../ExcludeFromAll-build-sub-stderr.txt} | 0 .../RunCMake/add_subdirectory/ExcludeFromAll.cmake | 8 +++ .../add_subdirectory/ExcludeFromAll/CMakeLists.txt | 23 +++---- .../ExcludeFromAll/check-sub.cmake | 32 ++++++++++ .../add_subdirectory/ExcludeFromAll/check.cmake | 73 ++++++++++------------ .../add_subdirectory/ExcludeFromAll/subinc.cpp} | 2 +- .../add_subdirectory/ExcludeFromAll/zot.cpp} | 2 +- Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake | 36 ++++++++--- 21 files changed, 195 insertions(+), 108 deletions(-) copy Tests/RunCMake/{target_link_options/LINK_OPTIONS-shared-result.txt => add_subdirectory/ExcludeFromAll-build-sub-stderr.txt} (100%) create mode 100644 Tests/RunCMake/add_subdirectory/ExcludeFromAll/check-sub.cmake copy Tests/{BuildDepends/Project/linkdep.cxx => RunCMake/add_subdirectory/ExcludeFromAll/subinc.cpp} (55%) copy Tests/{CompatibleInterface/foo.cpp => RunCMake/add_subdirectory/ExcludeFromAll/zot.cpp} (61%) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Sep 30 15:07:59 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 30 Sep 2019 15:07:59 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1267-g6fa2bae Message-ID: <20190930190759.DD12DFEBC9@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 6fa2baef61dd8344c68dc25e4814113fb40aaffb (commit) via 6d01a8e004c5faf2d0b2c3b7c0645ce3726181b6 (commit) from acbe5ae049f5918e3653cb250196f27f02a773d2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6fa2baef61dd8344c68dc25e4814113fb40aaffb commit 6fa2baef61dd8344c68dc25e4814113fb40aaffb Merge: acbe5ae 6d01a8e Author: Brad King AuthorDate: Mon Sep 30 15:05:41 2019 -0400 Commit: Brad King CommitDate: Mon Sep 30 15:05:41 2019 -0400 Merge branch 'release-3.14' https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6d01a8e004c5faf2d0b2c3b7c0645ce3726181b6 commit 6d01a8e004c5faf2d0b2c3b7c0645ce3726181b6 Author: Brad King AuthorDate: Mon Sep 30 14:01:30 2019 -0400 Commit: Brad King CommitDate: Mon Sep 30 14:01:30 2019 -0400 CMake 3.14.7 diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index a1ff9fa..01dedde 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 14) -set(CMake_VERSION_PATCH 6) +set(CMake_VERSION_PATCH 7) #set(CMake_VERSION_RC 0) ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From kwrobot at kitware.com Mon Sep 30 15:27:56 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 30 Sep 2019 15:27:56 -0400 (EDT) Subject: [Cmake-commits] CMake annotated tag, v3.14.7, created. v3.14.7 Message-ID: <20190930192756.4B3D5FD032@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The annotated tag, v3.14.7 has been created at d2b29eddb8997bda6973a7d46cf6fed3e1900b02 (tag) tagging 6d01a8e004c5faf2d0b2c3b7c0645ce3726181b6 (commit) replaces v3.14.6 tagged by Brad King on Mon Sep 30 15:05:15 2019 -0400 - Log ----------------------------------------------------------------- CMake 3.14.7 -----BEGIN PGP SIGNATURE----- iQJKBAABCgA0FiEExsJlMku+vcNQtRPQLSzvEDSSFoQFAl2SUesWHGJyYWQua2lu Z0BraXR3YXJlLmNvbQAKCRAtLO8QNJIWhBgTD/9fJXqziq8KVmB1GfSJsF97HQca pJg6hsblm3vNlsVfUZmmEJgw9E+yU04qLxLA6fv67Q52nIbvofEYMcXkzQcNARfG 0t9YgVjimEv+psBW85TVhHloDo3OCNVrrA25hU3wc8XDwuZ2o3l/GBeayJ8/O/sc FM9FiY+L/hzTDk0/2mm4kFADTxiusFpnNsnwk85i7RYm7P+eyrGKw01loYxMn/Jb bQybwtaTNJNPjtE5emmVd8vnsK9sSdJ8w1FfP2TUSADyZbc63N59DX3uF6GZOz6r umFR11xANbxuWTHSEIFA7NGddAIWyyNidnr9qnIYZeXGTvJg0PjwpgwGdUDnV7/6 pphMNnv2fnfZS5xRaUjyl35BYr7TpAhEYlJunpy2aALBtfTwWIRfLKCEYZw0zIN8 VyLSqfSpVBUEi9AvkR/LMKFIrvRzsdltTH3LyxsU8d3YD8NW+CoYAPelCWvpkHl7 GP/wUliqlewD723JlcvQY5lg+jXaq455P0dc4mCH2TYrqntda3IX5k24TuoIUlJs 05gd/LXEjmvk2og6v6vN/vDilPCERTijFbx4NxCQ3Jwa5+8sYzxQ4OcztOozyzur 52/9fzN8hDx0guXJ8VlsEehakfWxXuB0snstrBk/tPpSaj1WR+Pc23pJ/5J4xHUS PKx9XfNkAId2ouDplw== =/zhW -----END PGP SIGNATURE----- Brad King (7): Tests: Teach RunCMake to support a custom working directory Tests: Revise RunCMake.add_subdirectory ExcludeFromAll to avoid globbing Tests: Clarify target names in RunCMake.add_subdirectory ExcludeFromAll Restore "all" target in subdirectories marked EXCLUDE_FROM_ALL Help: Add release note for EXCLUDE_FROM_ALL fix in 3.14.7 Merge branch 'backport-3.14-fix-EXCLUDE_FROM_ALL-subdir-all' into release-3.14 CMake 3.14.7 ----------------------------------------------------------------------- hooks/post-receive -- CMake From kwrobot at kitware.com Mon Sep 30 16:47:58 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 30 Sep 2019 16:47:58 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.3-1269-gd5efd8e Message-ID: <20190930204759.6C34B17B4@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via d5efd8ed72c4417aee9266a45bd203a98901d1b8 (commit) via 6fb747a01c27a2226fe4cbf77bc19e6d21286f81 (commit) from 6fa2baef61dd8344c68dc25e4814113fb40aaffb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d5efd8ed72c4417aee9266a45bd203a98901d1b8 commit d5efd8ed72c4417aee9266a45bd203a98901d1b8 Merge: 6fa2bae 6fb747a Author: Brad King AuthorDate: Mon Sep 30 16:37:39 2019 -0400 Commit: Brad King CommitDate: Mon Sep 30 16:37:39 2019 -0400 Merge branch 'release-3.15' ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From kwrobot at kitware.com Mon Sep 30 16:47:59 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 30 Sep 2019 16:47:59 -0400 (EDT) Subject: [Cmake-commits] CMake branch, release, updated. v3.15.3-20-g6fb747a Message-ID: <20190930204800.1357014C3@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, release has been updated via 6fb747a01c27a2226fe4cbf77bc19e6d21286f81 (commit) from e7637a3d1ad48f675050483199cb98565983d622 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Sep 30 16:57:56 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 30 Sep 2019 16:57:56 -0400 (EDT) Subject: [Cmake-commits] CMake annotated tag, v3.15.4, created. v3.15.4 Message-ID: <20190930205756.C65D8B01C5@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The annotated tag, v3.15.4 has been created at 32fdee68ca1bb2672516932a813b0da8e3952bd6 (tag) tagging 6fb747a01c27a2226fe4cbf77bc19e6d21286f81 (commit) replaces v3.15.3 tagged by Brad King on Mon Sep 30 15:52:25 2019 -0400 - Log ----------------------------------------------------------------- CMake 3.15.4 -----BEGIN PGP SIGNATURE----- iQJKBAABCgA0FiEExsJlMku+vcNQtRPQLSzvEDSSFoQFAl2SXPkWHGJyYWQua2lu Z0BraXR3YXJlLmNvbQAKCRAtLO8QNJIWhLh8EACAxAD63mIf1aqswtBgzWsq+0tY 9n7bkROYMe5LxwZuYkTpLlXog4d4V8iCf0JKz6TDVd/SehzDSJN2qHszFTsV5Uk3 +AyTmprN1GcO7YFrOe9A56Vj7RENrHtSMvV8sPhjgrGmEgJQGeIFum06KhGIgHEs yoqrF6SmEbi8gxKeapXxUBuIzokc69xrmPTpSf/1hPj8Gccm/Mc9XWUbHMswBahb OuFOvmAV70Up70OBnquYoUydWx0Xiwhpo4PYuz3panFEyEyevsVgscT7qHl//lFn ckttdh82pYq57rx4RLUEhEfCA0Lo//OHbW8t2XukxKDOSAVkH7EUznUVqu+tQzsA 3w5tiuc2JuVMT4uI5aWo6Ag6uVboyd+v0C6rKXQbj/CjzeXGqCI/dnb08gsBRrW5 /wdJh079l+TgMpE4Ud/9WFeD9zT+xhb1X8cTSOlbqMCDL2F1/DEA2WsD1c2ZE9py 9CuqGHJzrFxaIVt862GqI4cKVZYV+30IaU5U0sNEQI3WWxOyERsTW/5dWenjEEdo 79fjHdYETEXDbcrpF51/zk7buSZ/rmptnnJKU3Ka8EhNtHYkYwErj8dDWR60xhka UPWmm/LcUyQrrnQ9wN+HitYWVuteLNToQB4MJydRcaK6PzD/vcwRAtrMvzrpII6a WPwVqAzvboiVbhzpEQ== =PRXt -----END PGP SIGNATURE----- Brad King (19): Merge branch 'android-pie-cmp0083' into release-3.14 Merge branch 'backport-implicit-includes-cray-hlist' into release-3.14 Merge branch 'FindBISON-CMP0088-SourcePath' into release-3.14 CMake 3.14.6 Merge branch 'doc-vs-2019-toolset' into release-3.15 VS: Tell VS 16.4 not to verify SYMBOLIC custom command outputs Merge branch 'vs-16.4-custom-commands' into release-3.15 Tests: Teach RunCMake to support a custom working directory Tests: Revise RunCMake.add_subdirectory ExcludeFromAll to avoid globbing Tests: Clarify target names in RunCMake.add_subdirectory ExcludeFromAll Makefiles: Revert "Make build root targets ... recursive" Restore "all" target in subdirectories marked EXCLUDE_FROM_ALL Help: Add release note for EXCLUDE_FROM_ALL fix in 3.14.7 Merge branch 'backport-3.14-fix-EXCLUDE_FROM_ALL-subdir-all' Help: Add release note for EXCLUDE_FROM_ALL fix in 3.15.4 Merge branch 'backport-3.14-fix-EXCLUDE_FROM_ALL-subdir-all' Help: Mention 3.14.7 EXCLUDE_FROM_ALL fix in 3.15.4 release note Merge branch 'backport-3.15-fix-EXCLUDE_FROM_ALL-subdir-all' into release-3.15 CMake 3.15.4 LE GARREC Vincent (1): Help: Document VS 2019 toolset in MSVC_TOOLSET_VERSION ----------------------------------------------------------------------- hooks/post-receive -- CMake