From 493f88ce553ec7e39db83bd1bdf5c0896420c52d Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 16 Mar 2009 16:55:58 -0400 Subject: [PATCH] ENH: Allow projects to disable per-rule echo lines This creates global property RULE_MESSAGES which can be set to disbale per-rule progress and action reporting. On Windows, these reports may cause a noticable delay due to the cost of starting extra processes. This feature will allow scripted builds to avoid the cost since they do not need detailed information anyway. This replaces the RULE_PROGRESS property created earlier as it is more complete. See issue #8726. --- Modules/CMakeGenericSystem.cmake | 6 +-- .../cmMakefileExecutableTargetGenerator.cxx | 17 ++++---- Source/cmMakefileLibraryTargetGenerator.cxx | 41 ++++++++++--------- Source/cmMakefileTargetGenerator.cxx | 34 ++++++++------- Source/cmMakefileTargetGenerator.h | 2 +- Source/cmake.cxx | 14 +++---- Tests/Complex/CMakeLists.txt | 4 +- Tests/ComplexOneConfig/CMakeLists.txt | 4 +- Tests/ComplexRelativePaths/CMakeLists.txt | 4 +- 9 files changed, 69 insertions(+), 57 deletions(-) diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake index 72711148f..25dbb9eb3 100644 --- a/Modules/CMakeGenericSystem.cmake +++ b/Modules/CMakeGenericSystem.cmake @@ -33,9 +33,9 @@ IF(CMAKE_GENERATOR MATCHES "Makefiles") "Enable/Disable color output during build." ) MARK_AS_ADVANCED(CMAKE_COLOR_MAKEFILE) - IF(DEFINED CMAKE_RULE_PROGRESS) - SET_PROPERTY(GLOBAL PROPERTY RULE_PROGRESS ${CMAKE_RULE_PROGRESS}) - ENDIF(DEFINED CMAKE_RULE_PROGRESS) + IF(DEFINED CMAKE_RULE_MESSAGES) + SET_PROPERTY(GLOBAL PROPERTY RULE_MESSAGES ${CMAKE_RULE_MESSAGES}) + ENDIF(DEFINED CMAKE_RULE_MESSAGES) ENDIF(CMAKE_GENERATOR MATCHES "Makefiles") # Set a variable to indicate whether the value of CMAKE_INSTALL_PREFIX diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index a96d2970b..acffb8aa1 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -189,13 +189,16 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) return; } - // Add the link message. - std::string buildEcho = "Linking "; - buildEcho += linkLanguage; - buildEcho += " executable "; - buildEcho += targetOutPath; - this->LocalGenerator->AppendEcho(commands, buildEcho.c_str(), - cmLocalUnixMakefileGenerator3::EchoLink); + if(!this->NoRuleMessages) + { + // Add the link message. + std::string buildEcho = "Linking "; + buildEcho += linkLanguage; + buildEcho += " executable "; + buildEcho += targetOutPath; + this->LocalGenerator->AppendEcho(commands, buildEcho.c_str(), + cmLocalUnixMakefileGenerator3::EchoLink); + } // Build a list of compiler flags and linker flags. std::string flags; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index e38a19621..0e71d50b3 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -448,27 +448,30 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules this->Convert(targetFullPathImport.c_str(),cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); - // Add the link message. - std::string buildEcho = "Linking "; - buildEcho += linkLanguage; - switch(this->Target->GetType()) + if(!this->NoRuleMessages) { - case cmTarget::STATIC_LIBRARY: - buildEcho += " static library "; - break; - case cmTarget::SHARED_LIBRARY: - buildEcho += " shared library "; - break; - case cmTarget::MODULE_LIBRARY: - buildEcho += " shared module "; - break; - default: - buildEcho += " library "; - break; + // Add the link message. + std::string buildEcho = "Linking "; + buildEcho += linkLanguage; + switch(this->Target->GetType()) + { + case cmTarget::STATIC_LIBRARY: + buildEcho += " static library "; + break; + case cmTarget::SHARED_LIBRARY: + buildEcho += " shared library "; + break; + case cmTarget::MODULE_LIBRARY: + buildEcho += " shared module "; + break; + default: + buildEcho += " library "; + break; + } + buildEcho += targetOutPath.c_str(); + this->LocalGenerator->AppendEcho(commands, buildEcho.c_str(), + cmLocalUnixMakefileGenerator3::EchoLink); } - buildEcho += targetOutPath.c_str(); - this->LocalGenerator->AppendEcho(commands, buildEcho.c_str(), - cmLocalUnixMakefileGenerator3::EchoLink); const char* forbiddenFlagVar = 0; switch(this->Target->GetType()) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index b88abed39..4b9c7240d 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -47,10 +47,10 @@ cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmTarget* target) static_cast( this->LocalGenerator->GetGlobalGenerator()); cmake* cm = this->GlobalGenerator->GetCMakeInstance(); - this->NoRuleProgress = false; - if(const char* ruleProgress = cm->GetProperty("RULE_PROGRESS")) + this->NoRuleMessages = false; + if(const char* ruleStatus = cm->GetProperty("RULE_MESSAGES")) { - this->NoRuleProgress = cmSystemTools::IsOff(ruleProgress); + this->NoRuleMessages = cmSystemTools::IsOff(ruleStatus); } } @@ -202,7 +202,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() cmLocalGenerator::MAKEFILE) << "\n\n"; - if(!this->NoRuleProgress) + if(!this->NoRuleMessages) { // Include the progress variables for the target. *this->BuildFileStream @@ -591,12 +591,15 @@ cmMakefileTargetGenerator // add in a progress call if needed this->AppendProgress(commands); - std::string buildEcho = "Building "; - buildEcho += lang; - buildEcho += " object "; - buildEcho += relativeObj; - this->LocalGenerator->AppendEcho(commands, buildEcho.c_str(), - cmLocalUnixMakefileGenerator3::EchoBuild); + if(!this->NoRuleMessages) + { + std::string buildEcho = "Building "; + buildEcho += lang; + buildEcho += " object "; + buildEcho += relativeObj; + this->LocalGenerator->AppendEcho + (commands, buildEcho.c_str(), cmLocalUnixMakefileGenerator3::EchoBuild); + } std::string targetOutPathPDB; { @@ -1106,9 +1109,12 @@ void cmMakefileTargetGenerator { // add in a progress call if needed this->AppendProgress(commands); - this->LocalGenerator - ->AppendEcho(commands, comment.c_str(), - cmLocalUnixMakefileGenerator3::EchoGenerate); + if(!this->NoRuleMessages) + { + this->LocalGenerator + ->AppendEcho(commands, comment.c_str(), + cmLocalUnixMakefileGenerator3::EchoGenerate); + } } // Now append the actual user-specified commands. @@ -1209,7 +1215,7 @@ void cmMakefileTargetGenerator::AppendProgress(std::vector& commands) { this->NumberOfProgressActions++; - if(this->NoRuleProgress) + if(this->NoRuleMessages) { return; } diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 629d1922a..0c0d21d54 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -170,7 +170,7 @@ protected: std::string ProgressFileName; std::string ProgressFileNameFull; unsigned long NumberOfProgressActions; - bool NoRuleProgress; + bool NoRuleMessages; // the path to the directory the build file is in std::string TargetBuildDirectory; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 33265a3d9..df528e2a9 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -3455,16 +3455,16 @@ void cmake::DefineProperties(cmake *cm) "Non-Makefile generators currently ignore this property."); cm->DefineProperty - ("RULE_PROGRESS", cmProperty::GLOBAL, - "Specify whether to report progress for each make rule.", - "Makefile generators add commands to report progress. " - "This property specifies whether to report progress on every rule. " + ("RULE_MESSAGES", cmProperty::GLOBAL, + "Specify whether to report a message for each make rule.", + "This property specifies whether Makefile generators should add a " + "progress message describing what each build rule does. " "If the property is not set the default is ON. " - "Set the property to OFF to disable granular progress and report only " + "Set the property to OFF to disable granular messages and report only " "as each target completes. " "This is intended to allow scripted builds to avoid the build time " - "cost of detailed progress reports. " - "If a CMAKE_RULE_PROGRESS cache entry exists its value initializes " + "cost of detailed reports. " + "If a CMAKE_RULE_MESSAGES cache entry exists its value initializes " "the value of this property. " "Non-Makefile generators currently ignore this property."); diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt index 569ca30b3..5f9b18c3e 100644 --- a/Tests/Complex/CMakeLists.txt +++ b/Tests/Complex/CMakeLists.txt @@ -14,8 +14,8 @@ IF(POLICY CMP0003) ENDIF(NOT "${P3}" STREQUAL "NEW") ENDIF(POLICY CMP0003) -# Test building without per-rule progress in Makefiles. -SET_PROPERTY(GLOBAL PROPERTY RULE_PROGRESS OFF) +# Test building without per-rule echo lines in Makefiles. +SET_PROPERTY(GLOBAL PROPERTY RULE_MESSAGES OFF) # Choose whether to test CMakeLib. SET(COMPLEX_TEST_CMAKELIB 1) diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt index 569ca30b3..5f9b18c3e 100644 --- a/Tests/ComplexOneConfig/CMakeLists.txt +++ b/Tests/ComplexOneConfig/CMakeLists.txt @@ -14,8 +14,8 @@ IF(POLICY CMP0003) ENDIF(NOT "${P3}" STREQUAL "NEW") ENDIF(POLICY CMP0003) -# Test building without per-rule progress in Makefiles. -SET_PROPERTY(GLOBAL PROPERTY RULE_PROGRESS OFF) +# Test building without per-rule echo lines in Makefiles. +SET_PROPERTY(GLOBAL PROPERTY RULE_MESSAGES OFF) # Choose whether to test CMakeLib. SET(COMPLEX_TEST_CMAKELIB 1) diff --git a/Tests/ComplexRelativePaths/CMakeLists.txt b/Tests/ComplexRelativePaths/CMakeLists.txt index 569ca30b3..5f9b18c3e 100644 --- a/Tests/ComplexRelativePaths/CMakeLists.txt +++ b/Tests/ComplexRelativePaths/CMakeLists.txt @@ -14,8 +14,8 @@ IF(POLICY CMP0003) ENDIF(NOT "${P3}" STREQUAL "NEW") ENDIF(POLICY CMP0003) -# Test building without per-rule progress in Makefiles. -SET_PROPERTY(GLOBAL PROPERTY RULE_PROGRESS OFF) +# Test building without per-rule echo lines in Makefiles. +SET_PROPERTY(GLOBAL PROPERTY RULE_MESSAGES OFF) # Choose whether to test CMakeLib. SET(COMPLEX_TEST_CMAKELIB 1)