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 <brad.k...@kitware.com> AuthorDate: Fri Sep 13 13:56:02 2019 +0000 Commit: Kitware Robot <kwro...@kitware.com> 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 <kwro...@kitware.com> Merge-request: !3806 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0b8c0b26ce076952bfdc0392d2c93c3597974c9f commit 0b8c0b26ce076952bfdc0392d2c93c3597974c9f Merge: bacb50a d694570 Author: Brad King <brad.k...@kitware.com> AuthorDate: Fri Sep 13 13:53:16 2019 +0000 Commit: Kitware Robot <kwro...@kitware.com> 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 <kwro...@kitware.com> Merge-request: !3802 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bacb50afa9ed7806a8900ab7524f2f4a4cd7d669 commit bacb50afa9ed7806a8900ab7524f2f4a4cd7d669 Merge: 729c928 a81e9a0 Author: Brad King <brad.k...@kitware.com> AuthorDate: Fri Sep 13 13:52:23 2019 +0000 Commit: Kitware Robot <kwro...@kitware.com> 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 <kwro...@kitware.com> Merge-request: !3807 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a81e9a0ced25490d1384316834dff36a55d4e864 commit a81e9a0ced25490d1384316834dff36a55d4e864 Author: Regina Pfeifer <reg...@mailbox.org> AuthorDate: Thu Sep 12 16:29:52 2019 +0200 Commit: Regina Pfeifer <reg...@mailbox.org> 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<cmSetTargetPropertiesCommand>()); state->AddBuiltinCommand("set_tests_properties", cmSetTestsPropertiesCommand); - state->AddBuiltinCommand("subdirs", cm::make_unique<cmSubdirCommand>()); + state->AddBuiltinCommand("subdirs", cmSubdirCommand); state->AddBuiltinCommand( "target_compile_definitions", cm::make_unique<cmTargetCompileDefinitionsCommand>()); 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<std::string> const& args, - cmExecutionStatus&) +bool cmSubdirCommand(std::vector<std::string> 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<std::string> 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 <string> #include <vector> -#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<cmCommand> Clone() override - { - return cm::make_unique<cmSubdirCommand>(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector<std::string> const& args, - cmExecutionStatus& status) override; -}; +bool cmSubdirCommand(std::vector<std::string> const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=573cd4e4b43d8d3b75f6e7c420b5f833cdd2120e commit 573cd4e4b43d8d3b75f6e7c420b5f833cdd2120e Author: Regina Pfeifer <reg...@mailbox.org> AuthorDate: Thu Sep 12 16:28:59 2019 +0200 Commit: Regina Pfeifer <reg...@mailbox.org> 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<cmSetTargetPropertiesCommand>()); state->AddBuiltinCommand("set_tests_properties", - cm::make_unique<cmSetTestsPropertiesCommand>()); + cmSetTestsPropertiesCommand); state->AddBuiltinCommand("subdirs", cm::make_unique<cmSubdirCommand>()); 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 <iterator> #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<std::string>& propertyPairs, cmMakefile* mf, + std::string& errors); -// cmSetTestsPropertiesCommand -bool cmSetTestsPropertiesCommand::InitialPass( - std::vector<std::string> const& args, cmExecutionStatus&) +bool cmSetTestsPropertiesCommand(std::vector<std::string> 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<std::string> 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<std::string>& propertyPairs, - cmMakefile* mf, std::string& errors) +static bool SetOneTest(const std::string& tname, + std::vector<std::string>& 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 <string> #include <vector> -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -class cmMakefile; - -class cmSetTestsPropertiesCommand : public cmCommand -{ -public: - std::unique_ptr<cmCommand> Clone() override - { - return cm::make_unique<cmSetTestsPropertiesCommand>(); - } - - /** - * This is called when the command is first encountered in - * the input file. - */ - bool InitialPass(std::vector<std::string> const& args, - cmExecutionStatus& status) override; - static bool SetOneTest(const std::string& tname, - std::vector<std::string>& propertyPairs, - cmMakefile* mf, std::string& errors); -}; +bool cmSetTestsPropertiesCommand(std::vector<std::string> const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=95f23ea5d5a07da503f8e2ab9c52c82086cdcae4 commit 95f23ea5d5a07da503f8e2ab9c52c82086cdcae4 Author: Regina Pfeifer <reg...@mailbox.org> AuthorDate: Thu Sep 12 16:28:00 2019 +0200 Commit: Regina Pfeifer <reg...@mailbox.org> 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<cmLinkDirectoriesCommand>()); state->AddBuiltinCommand("project", cm::make_unique<cmProjectCommand>()); - state->AddBuiltinCommand( - "set_source_files_properties", - cm::make_unique<cmSetSourceFilesPropertiesCommand>()); + state->AddBuiltinCommand("set_source_files_properties", + cmSetSourceFilesPropertiesCommand); state->AddBuiltinCommand("set_target_properties", cm::make_unique<cmSetTargetPropertiesCommand>()); 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<std::string>::const_iterator filebeg, + std::vector<std::string>::const_iterator fileend, + std::vector<std::string>::const_iterator propbeg, + std::vector<std::string>::const_iterator propend, + std::string& errors); -// cmSetSourceFilesPropertiesCommand -bool cmSetSourceFilesPropertiesCommand::InitialPass( - std::vector<std::string> const& args, cmExecutionStatus&) +bool cmSetSourceFilesPropertiesCommand(std::vector<std::string> 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<std::string>::const_iterator filebeg, - std::vector<std::string>::const_iterator fileend, - std::vector<std::string>::const_iterator propbeg, - std::vector<std::string>::const_iterator propend, std::string& errors) +static bool RunCommand(cmMakefile* mf, + std::vector<std::string>::const_iterator filebeg, + std::vector<std::string>::const_iterator fileend, + std::vector<std::string>::const_iterator propbeg, + std::vector<std::string>::const_iterator propend, + std::string& errors) { std::vector<std::string> 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 <string> #include <vector> -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -class cmMakefile; - -class cmSetSourceFilesPropertiesCommand : public cmCommand -{ -public: - std::unique_ptr<cmCommand> Clone() override - { - return cm::make_unique<cmSetSourceFilesPropertiesCommand>(); - } - - /** - * This is called when the command is first encountered in - * the input file. - */ - bool InitialPass(std::vector<std::string> const& args, - cmExecutionStatus& status) override; - static bool RunCommand(cmMakefile* mf, - std::vector<std::string>::const_iterator filebeg, - std::vector<std::string>::const_iterator fileend, - std::vector<std::string>::const_iterator propbeg, - std::vector<std::string>::const_iterator propend, - std::string& errors); -}; +bool cmSetSourceFilesPropertiesCommand(std::vector<std::string> const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=706400d417e6435a442af2626a8430016e24aa9d commit 706400d417e6435a442af2626a8430016e24aa9d Author: Regina Pfeifer <reg...@mailbox.org> AuthorDate: Thu Sep 12 10:24:55 2019 +0200 Commit: Regina Pfeifer <reg...@mailbox.org> 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<cmLoadCacheCommand>()); state->AddBuiltinCommand("qt_wrap_cpp", cmQTWrapCPPCommand); state->AddBuiltinCommand("qt_wrap_ui", cmQTWrapUICommand); - state->AddBuiltinCommand("remove_definitions", - cm::make_unique<cmRemoveDefinitionsCommand>()); + state->AddBuiltinCommand("remove_definitions", cmRemoveDefinitionsCommand); state->AddBuiltinCommand("source_group", cm::make_unique<cmSourceGroupCommand>()); 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<std::string> const& args, cmExecutionStatus&) +bool cmRemoveDefinitionsCommand(std::vector<std::string> 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 <string> #include <vector> -#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<cmCommand> Clone() override - { - return cm::make_unique<cmRemoveDefinitionsCommand>(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector<std::string> const& args, - cmExecutionStatus& status) override; -}; +bool cmRemoveDefinitionsCommand(std::vector<std::string> const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7f8699026211c6a3055e767125021a91da4b1393 commit 7f8699026211c6a3055e767125021a91da4b1393 Author: Regina Pfeifer <reg...@mailbox.org> AuthorDate: Thu Sep 12 10:23:36 2019 +0200 Commit: Regina Pfeifer <reg...@mailbox.org> 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<cmLoadCacheCommand>()); state->AddBuiltinCommand("qt_wrap_cpp", cmQTWrapCPPCommand); - state->AddBuiltinCommand("qt_wrap_ui", cm::make_unique<cmQTWrapUICommand>()); + state->AddBuiltinCommand("qt_wrap_ui", cmQTWrapUICommand); state->AddBuiltinCommand("remove_definitions", cm::make_unique<cmRemoveDefinitionsCommand>()); 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 <utility> + #include "cmCustomCommandLines.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmRange.h" #include "cmSourceFile.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include <utility> - -class cmExecutionStatus; - -// cmQTWrapUICommand -bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& args, - cmExecutionStatus&) +bool cmQTWrapUICommand(std::vector<std::string> 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<std::string> 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<std::string> 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 <string> #include <vector> -#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<cmCommand> Clone() override - { - return cm::make_unique<cmQTWrapUICommand>(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector<std::string> const& args, - cmExecutionStatus& status) override; -}; +bool cmQTWrapUICommand(std::vector<std::string> const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=56bfb8de5d1ddc3a499b03be8ae75c9832b6f878 commit 56bfb8de5d1ddc3a499b03be8ae75c9832b6f878 Author: Regina Pfeifer <reg...@mailbox.org> AuthorDate: Thu Sep 12 10:22:50 2019 +0200 Commit: Regina Pfeifer <reg...@mailbox.org> 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<cmTargetLinkDirectoriesCommand>()); state->AddBuiltinCommand("load_cache", cm::make_unique<cmLoadCacheCommand>()); - state->AddBuiltinCommand("qt_wrap_cpp", - cm::make_unique<cmQTWrapCPPCommand>()); + state->AddBuiltinCommand("qt_wrap_cpp", cmQTWrapCPPCommand); state->AddBuiltinCommand("qt_wrap_ui", cm::make_unique<cmQTWrapUICommand>()); state->AddBuiltinCommand("remove_definitions", cm::make_unique<cmRemoveDefinitionsCommand>()); 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 <utility> + #include "cmCustomCommandLines.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmRange.h" #include "cmSourceFile.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include <utility> - -class cmExecutionStatus; - -// cmQTWrapCPPCommand -bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& args, - cmExecutionStatus&) +bool cmQTWrapCPPCommand(std::vector<std::string> 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<std::string> 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<std::string> 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 <string> #include <vector> -#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<cmCommand> Clone() override - { - return cm::make_unique<cmQTWrapCPPCommand>(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector<std::string> const& args, - cmExecutionStatus& status) override; -}; +bool cmQTWrapCPPCommand(std::vector<std::string> const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=83b3f76a3b13ffe2d8bdf3f67c20e36e22a6955f commit 83b3f76a3b13ffe2d8bdf3f67c20e36e22a6955f Author: Regina Pfeifer <reg...@mailbox.org> AuthorDate: Thu Sep 12 10:21:36 2019 +0200 Commit: Regina Pfeifer <reg...@mailbox.org> 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<cmLinkLibrariesCommand>()); + state->AddBuiltinCommand("link_libraries", cmLinkLibrariesCommand); state->AddBuiltinCommand("target_link_options", cm::make_unique<cmTargetLinkOptionsCommand>()); 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<std::string> const& args, - cmExecutionStatus&) +bool cmLinkLibrariesCommand(std::vector<std::string> 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 <string> #include <vector> -#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<cmCommand> Clone() override - { - return cm::make_unique<cmLinkLibrariesCommand>(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector<std::string> const& args, - cmExecutionStatus& status) override; -}; +bool cmLinkLibrariesCommand(std::vector<std::string> const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b85407ae76951649907e8e5675fe17d65dfd5457 commit b85407ae76951649907e8e5675fe17d65dfd5457 Author: Regina Pfeifer <reg...@mailbox.org> AuthorDate: Thu Sep 12 10:20:35 2019 +0200 Commit: Regina Pfeifer <reg...@mailbox.org> 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<cmInstallCommand>()); state->AddBuiltinCommand("install_files", cmInstallFilesCommand); - state->AddBuiltinCommand("install_targets", - cm::make_unique<cmInstallTargetsCommand>()); + state->AddBuiltinCommand("install_targets", cmInstallTargetsCommand); state->AddBuiltinCommand("link_directories", cm::make_unique<cmLinkDirectoriesCommand>()); state->AddBuiltinCommand("project", cm::make_unique<cmProjectCommand>()); 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 <unordered_map> #include <utility> +#include "cmExecutionStatus.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmTarget.h" -class cmExecutionStatus; - -// cmExecutableCommand -bool cmInstallTargetsCommand::InitialPass(std::vector<std::string> const& args, - cmExecutionStatus&) +bool cmInstallTargetsCommand(std::vector<std::string> 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<std::string> 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<std::string> 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 <string> #include <vector> -#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<cmCommand> Clone() override - { - return cm::make_unique<cmInstallTargetsCommand>(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector<std::string> const& args, - cmExecutionStatus& status) override; -}; +bool cmInstallTargetsCommand(std::vector<std::string> const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d55319c01d5482ff31166750717252e1b49f1e69 commit d55319c01d5482ff31166750717252e1b49f1e69 Author: Regina Pfeifer <reg...@mailbox.org> AuthorDate: Thu Sep 12 10:19:23 2019 +0200 Commit: Regina Pfeifer <reg...@mailbox.org> 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<cmInstallProgramsCommand>()); + state->AddBuiltinCommand("install_programs", cmInstallProgramsCommand); state->AddBuiltinCommand("add_link_options", cmAddLinkOptionsCommand); state->AddBuiltinCommand("link_libraries", cm::make_unique<cmLinkLibrariesCommand>()); 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<std::string> const& args); static std::string FindInstallSource(cmMakefile& makefile, const char* name); -// cmExecutableCommand -bool cmInstallProgramsCommand::InitialPass( - std::vector<std::string> const& args, cmExecutionStatus&) +bool cmInstallProgramsCommand(std::vector<std::string> 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<std::string> 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 <string> #include <vector> -#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<cmCommand> Clone() override - { - return cm::make_unique<cmInstallProgramsCommand>(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector<std::string> const& args, - cmExecutionStatus& status) override; -}; +bool cmInstallProgramsCommand(std::vector<std::string> const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fb5affe0859ae1bc07d059fc11cee3daca4d8780 commit fb5affe0859ae1bc07d059fc11cee3daca4d8780 Author: Regina Pfeifer <reg...@mailbox.org> AuthorDate: Thu Sep 12 10:18:01 2019 +0200 Commit: Regina Pfeifer <reg...@mailbox.org> 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<cmInstallCommand>()); - state->AddBuiltinCommand("install_files", - cm::make_unique<cmInstallFilesCommand>()); + state->AddBuiltinCommand("install_files", cmInstallFilesCommand); state->AddBuiltinCommand("install_targets", cm::make_unique<cmInstallTargetsCommand>()); 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<std::string> const& args); -bool cmInstallFilesCommand::InitialPass(std::vector<std::string> const& args, - cmExecutionStatus&) +bool cmInstallFilesCommand(std::vector<std::string> 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<std::string> const& args, std::vector<std::string> 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<std::string> 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 <string> #include <vector> -#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<cmCommand> Clone() override - { - return cm::make_unique<cmInstallFilesCommand>(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector<std::string> const& args, - cmExecutionStatus& status) override; -}; +bool cmInstallFilesCommand(std::vector<std::string> const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=242d876d7b919fe6efb3a347dfa35a66e3ef58df commit 242d876d7b919fe6efb3a347dfa35a66e3ef58df Author: Regina Pfeifer <reg...@mailbox.org> AuthorDate: Thu Sep 12 10:16:43 2019 +0200 Commit: Regina Pfeifer <reg...@mailbox.org> 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<cmIncludeDirectoryCommand>()); - state->AddBuiltinCommand( - "include_regular_expression", - cm::make_unique<cmIncludeRegularExpressionCommand>()); + state->AddBuiltinCommand("include_regular_expression", + cmIncludeRegularExpressionCommand); state->AddBuiltinCommand("install", cm::make_unique<cmInstallCommand>()); state->AddBuiltinCommand("install_files", cm::make_unique<cmInstallFilesCommand>()); 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<std::string> const& args, cmExecutionStatus&) +bool cmIncludeRegularExpressionCommand(std::vector<std::string> 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 <string> #include <vector> -#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<cmCommand> Clone() override - { - return cm::make_unique<cmIncludeRegularExpressionCommand>(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector<std::string> const& args, - cmExecutionStatus& status) override; -}; +bool cmIncludeRegularExpressionCommand(std::vector<std::string> const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=06a2e764f0f088a212e20b85e364b5621ef639fe commit 06a2e764f0f088a212e20b85e364b5621ef639fe Author: Regina Pfeifer <reg...@mailbox.org> AuthorDate: Thu Sep 12 10:15:29 2019 +0200 Commit: Regina Pfeifer <reg...@mailbox.org> 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<cmExportCommand>()); state->AddBuiltinCommand("fltk_wrap_ui", cmFLTKWrapUICommand); - state->AddBuiltinCommand( - "include_external_msproject", - cm::make_unique<cmIncludeExternalMSProjectCommand>()); + state->AddBuiltinCommand("include_external_msproject", + cmIncludeExternalMSProjectCommand); state->AddBuiltinCommand("install_programs", cm::make_unique<cmInstallProgramsCommand>()); 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<std::string> const& args, cmExecutionStatus&) +bool cmIncludeExternalMSProjectCommand(std::vector<std::string> 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 <string> #include <vector> -#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<cmCommand> Clone() override - { - return cm::make_unique<cmIncludeExternalMSProjectCommand>(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector<std::string> const& args, - cmExecutionStatus& status) override; -}; +bool cmIncludeExternalMSProjectCommand(std::vector<std::string> const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b46970cfe9e0c96a9794acb49fc580565bcd6e91 commit b46970cfe9e0c96a9794acb49fc580565bcd6e91 Author: Regina Pfeifer <reg...@mailbox.org> AuthorDate: Thu Sep 12 10:14:27 2019 +0200 Commit: Regina Pfeifer <reg...@mailbox.org> 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<cmGetTestPropertyCommand>()); + state->AddBuiltinCommand("get_test_property", cmGetTestPropertyCommand); state->AddBuiltinCommand("include_directories", cm::make_unique<cmIncludeDirectoryCommand>()); 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<std::string> const& args, cmExecutionStatus&) +bool cmGetTestPropertyCommand(std::vector<std::string> 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 <string> #include <vector> -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -class cmGetTestPropertyCommand : public cmCommand -{ -public: - std::unique_ptr<cmCommand> Clone() override - { - return cm::make_unique<cmGetTestPropertyCommand>(); - } - - /** - * This is called when the command is first encountered in - * the input file. - */ - bool InitialPass(std::vector<std::string> const& args, - cmExecutionStatus& status) override; -}; +bool cmGetTestPropertyCommand(std::vector<std::string> const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0b95c64e43e5f60ee9c60570f359a40e4e882096 commit 0b95c64e43e5f60ee9c60570f359a40e4e882096 Author: Regina Pfeifer <reg...@mailbox.org> AuthorDate: Thu Sep 12 10:13:17 2019 +0200 Commit: Regina Pfeifer <reg...@mailbox.org> 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<cmGetTargetPropertyCommand>()); + state->AddBuiltinCommand("get_target_property", cmGetTargetPropertyCommand); state->AddBuiltinCommand("get_test_property", cm::make_unique<cmGetTestPropertyCommand>()); 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 <sstream> +#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<std::string> const& args, cmExecutionStatus&) +bool cmGetTargetPropertyCommand(std::vector<std::string> 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 <string> #include <vector> -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -class cmGetTargetPropertyCommand : public cmCommand -{ -public: - std::unique_ptr<cmCommand> Clone() override - { - return cm::make_unique<cmGetTargetPropertyCommand>(); - } - - /** - * This is called when the command is first encountered in - * the input file. - */ - bool InitialPass(std::vector<std::string> const& args, - cmExecutionStatus& status) override; -}; +bool cmGetTargetPropertyCommand(std::vector<std::string> const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e4c67981aca4fd736fd7503d9d105a0a6fb43828 commit e4c67981aca4fd736fd7503d9d105a0a6fb43828 Author: Regina Pfeifer <reg...@mailbox.org> AuthorDate: Thu Sep 12 10:12:09 2019 +0200 Commit: Regina Pfeifer <reg...@mailbox.org> 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>()); + cmGetSourceFilePropertyCommand); state->AddBuiltinCommand("get_target_property", cm::make_unique<cmGetTargetPropertyCommand>()); 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<std::string> const& args, cmExecutionStatus&) +bool cmGetSourceFilePropertyCommand(std::vector<std::string> 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 <string> #include <vector> -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -class cmGetSourceFilePropertyCommand : public cmCommand -{ -public: - std::unique_ptr<cmCommand> Clone() override - { - return cm::make_unique<cmGetSourceFilePropertyCommand>(); - } - - /** - * This is called when the command is first encountered in - * the input file. - */ - bool InitialPass(std::vector<std::string> const& args, - cmExecutionStatus& status) override; -}; +bool cmGetSourceFilePropertyCommand(std::vector<std::string> const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=36b939db682a9405790bee76f95673eeaeb445b8 commit 36b939db682a9405790bee76f95673eeaeb445b8 Author: Regina Pfeifer <reg...@mailbox.org> AuthorDate: Thu Sep 12 10:10:28 2019 +0200 Commit: Regina Pfeifer <reg...@mailbox.org> 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<cmExportCommand>()); - state->AddBuiltinCommand("fltk_wrap_ui", - cm::make_unique<cmFLTKWrapUICommand>()); + state->AddBuiltinCommand("fltk_wrap_ui", cmFLTKWrapUICommand); state->AddBuiltinCommand( "include_external_msproject", cm::make_unique<cmIncludeExternalMSProjectCommand>()); 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 <stddef.h> #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<std::string> const& args, - cmExecutionStatus&) +bool cmFLTKWrapUICommand(std::vector<std::string> 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<std::string> outputDirectories; outputDirectories.push_back(outputDirectory); - this->Makefile->AddIncludeDirectories(outputDirectories); + mf.AddIncludeDirectories(outputDirectories); } // List of produced files. std::vector<cmSourceFile*> 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<std::string> 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<std::string> 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 <string> #include <vector> -#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<cmCommand> Clone() override - { - return cm::make_unique<cmFLTKWrapUICommand>(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector<std::string> const& args, - cmExecutionStatus& status) override; -}; +bool cmFLTKWrapUICommand(std::vector<std::string> const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=28cf1271ed6051af46ff68f52a8c9c0435ca1234 commit 28cf1271ed6051af46ff68f52a8c9c0435ca1234 Author: Regina Pfeifer <reg...@mailbox.org> AuthorDate: Thu Sep 12 10:09:06 2019 +0200 Commit: Regina Pfeifer <reg...@mailbox.org> 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<cmEnableLanguageCommand>()); + state->AddBuiltinCommand("enable_language", cmEnableLanguageCommand); state->AddBuiltinCommand("enable_testing", cmEnableTestingCommand); state->AddBuiltinCommand("get_source_file_property", cm::make_unique<cmGetSourceFilePropertyCommand>()); 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<std::string> const& args, - cmExecutionStatus&) +bool cmEnableLanguageCommand(std::vector<std::string> const& args, + cmExecutionStatus& status) { - bool optional = false; - std::vector<std::string> 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<std::string> languages; for (std::string const& it : args) { if (it == "OPTIONAL") { optional = true; @@ -24,6 +23,6 @@ bool cmEnableLanguageCommand::InitialPass(std::vector<std::string> 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 <string> #include <vector> -#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<cmCommand> Clone() override - { - return cm::make_unique<cmEnableLanguageCommand>(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector<std::string> const& args, - cmExecutionStatus& status) override; -}; +bool cmEnableLanguageCommand(std::vector<std::string> const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=41b0d60f48c3d8d882ec25b56d638b392121fcc8 commit 41b0d60f48c3d8d882ec25b56d638b392121fcc8 Author: Regina Pfeifer <reg...@mailbox.org> AuthorDate: Thu Sep 12 10:08:01 2019 +0200 Commit: Regina Pfeifer <reg...@mailbox.org> 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<cmDefinePropertyCommand>()); + state->AddBuiltinCommand("define_property", cmDefinePropertyCommand); state->AddBuiltinCommand("enable_language", cm::make_unique<cmEnableLanguageCommand>()); 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 <sstream> - +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmProperty.h" #include "cmState.h" +#include "cmStringAlgorithms.h" -class cmExecutionStatus; - -bool cmDefinePropertyCommand::InitialPass(std::vector<std::string> const& args, - cmExecutionStatus&) +bool cmDefinePropertyCommand(std::vector<std::string> 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<std::string> 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<std::string> 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 <name> argument."); + if (PropertyName.empty()) { + status.SetError("not given a PROPERTY <name> argument."); return false; } // Make sure documentation was given. - if (this->BriefDocs.empty()) { - this->SetError("not given a BRIEF_DOCS <brief-doc> argument."); + if (BriefDocs.empty()) { + status.SetError("not given a BRIEF_DOCS <brief-doc> argument."); return false; } - if (this->FullDocs.empty()) { - this->SetError("not given a FULL_DOCS <full-doc> argument."); + if (FullDocs.empty()) { + status.SetError("not given a FULL_DOCS <full-doc> 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 <string> #include <vector> -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -class cmDefinePropertyCommand : public cmCommand -{ -public: - std::unique_ptr<cmCommand> Clone() override - { - return cm::make_unique<cmDefinePropertyCommand>(); - } - - /** - * This is called when the command is first encountered in - * the input file. - */ - bool InitialPass(std::vector<std::string> const& args, - cmExecutionStatus& status) override; - -private: - std::string PropertyName; - std::string BriefDocs; - std::string FullDocs; -}; +bool cmDefinePropertyCommand(std::vector<std::string> const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f717e1fccf2968ffeba36dc84e428abd4f8db5c0 commit f717e1fccf2968ffeba36dc84e428abd4f8db5c0 Author: Regina Pfeifer <reg...@mailbox.org> AuthorDate: Thu Sep 12 10:06:03 2019 +0200 Commit: Regina Pfeifer <reg...@mailbox.org> 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<cmCreateTestSourceList>()); + state->AddBuiltinCommand("create_test_sourcelist", cmCreateTestSourceList); state->AddBuiltinCommand("define_property", cm::make_unique<cmDefinePropertyCommand>()); 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 <algorithm> +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmSourceFile.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -class cmExecutionStatus; - -// cmCreateTestSourceList -bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args, - cmExecutionStatus&) +bool cmCreateTestSourceList(std::vector<std::string> 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<std::string> 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<std::string> 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<std::string> 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 <string> #include <vector> -#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<cmCommand> Clone() override - { - return cm::make_unique<cmCreateTestSourceList>(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector<std::string> const& args, - cmExecutionStatus& status) override; -}; +bool cmCreateTestSourceList(std::vector<std::string> const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f0ecb123981c6b383a55f7d75e023cf4310f2074 commit f0ecb123981c6b383a55f7d75e023cf4310f2074 Author: Regina Pfeifer <reg...@mailbox.org> AuthorDate: Thu Sep 12 10:04:07 2019 +0200 Commit: Regina Pfeifer <reg...@mailbox.org> 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 <sstream> - +#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<std::string> 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<std::string> const& args) +bool MainSignature(std::vector<std::string> 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<std::string> 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<std::string> 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<std::string> const& args) +bool TwoArgsSignature(std::vector<std::string> 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<std::string> 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<std::string> 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 <string> #include <vector> -#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<cmCommand> Clone() override - { - return cm::make_unique<cmBuildCommand>(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector<std::string> const& args, - cmExecutionStatus& status) override; - - /** - * The primary command signature with optional, KEYWORD-based args. - */ - virtual bool MainSignature(std::vector<std::string> const& args); - - /** - * Legacy "exactly 2 args required" signature. - */ - virtual bool TwoArgsSignature(std::vector<std::string> const& args); - -private: - bool IgnoreErrors() const; -}; +bool cmBuildCommand(std::vector<std::string> 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<cmBuildCommand>()); + state->AddBuiltinCommand("build_command", cmBuildCommand); state->AddBuiltinCommand("create_test_sourcelist", cm::make_unique<cmCreateTestSourceList>()); state->AddBuiltinCommand("define_property", https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=482d858500a42a63c97d3dc11ae74d81a10bab3f commit 482d858500a42a63c97d3dc11ae74d81a10bab3f Author: Daniel Eiband <daniel.eib...@brainlab.com> AuthorDate: Wed Sep 11 15:06:01 2019 +0200 Commit: Daniel Eiband <daniel.eib...@brainlab.com> 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 <daniel.eib...@brainlab.com> AuthorDate: Wed Sep 11 12:45:50 2019 +0200 Commit: Daniel Eiband <daniel.eib...@brainlab.com> 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<cmSourceFile*> SourceQueue; std::set<cmSourceFile*> SourcesQueued; - using NameMapType = std::map<std::string, cmSourceFile*>; + using NameMapType = std::map<std::string, cmSourcesWithOutput>; NameMapType NameMap; std::vector<std::string> 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 <daniel.eib...@brainlab.com> AuthorDate: Wed Sep 11 12:19:43 2019 +0200 Commit: Daniel Eiband <daniel.eib...@brainlab.com> 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<std::string> 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<std::string> const& outputs, cmSourceFile* source) + std::vector<std::string> 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<cmCustomCommand>& 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<std::string, std::string> AliasTargets; + using TargetsVec = std::vector<cmTarget*>; + TargetsVec OrderedTargets; + using SourceFileVec = std::vector<cmSourceFile*>; 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<std::string, cmSourceFile*>; + using OutputToSourceMap = std::unordered_map<std::string, SourceEntry>; OutputToSourceMap OutputToSource; + void UpdateOutputToSourceMap(std::vector<std::string> const& byproducts, + cmTarget* target); + void UpdateOutputToSourceMap(std::string const& byproduct, cmTarget* target); + void UpdateOutputToSourceMap(std::vector<std::string> 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 <daniel.eib...@brainlab.com> AuthorDate: Wed Sep 11 11:32:23 2019 +0200 Commit: Daniel Eiband <daniel.eib...@brainlab.com> 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<std::string>& 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<std::string>& 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 <alexe...@xiphos.de> AuthorDate: Wed Sep 11 15:22:47 2019 +0200 Commit: Alexej Harm <alexe...@xiphos.de> 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 _______________________________________________ Cmake-commits mailing list Cmake-commits@cmake.org https://cmake.org/mailman/listinfo/cmake-commits