From 8217c26813d1a1f6a81c2fe15f20ee1795d428e5 Mon Sep 17 00:00:00 2001 From: Peter Kuemmel Date: Fri, 6 Apr 2012 17:40:22 +0200 Subject: [PATCH 1/7] Ninja: ensure output directories exist --- Source/cmNinjaNormalTargetGenerator.cxx | 28 +++++++++++++++++++------ Source/cmNinjaNormalTargetGenerator.h | 3 +++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 2bad32c5d4..2bfe814d85 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -47,8 +47,7 @@ cmNinjaNormalTargetGenerator(cmTarget* target) { // on Windows the output dir is already needed at compile time // ensure the directory exists (OutDir test) - std::string outpath = target->GetDirectory(this->GetConfigName()); - cmSystemTools::MakeDirectory(outpath.c_str()); + EnsureDirectoryExists(target->GetDirectory(this->GetConfigName())); } } @@ -56,6 +55,18 @@ cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator() { } +void cmNinjaNormalTargetGenerator::EnsureDirectoryExists(const std::string& dir) +{ + cmSystemTools::MakeDirectory(dir.c_str()); +} + +void cmNinjaNormalTargetGenerator::EnsureParentDirectoryExists(const std::string& path) +{ + EnsureDirectoryExists(cmSystemTools::GetParentDirectory(path.c_str())); +} + + + void cmNinjaNormalTargetGenerator::Generate() { if (!this->TargetLinkLanguage) { @@ -380,13 +391,18 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } } + std::string path; if (!this->TargetNameImport.empty()) { - vars["TARGET_IMPLIB"] = this->GetLocalGenerator()->ConvertToOutputFormat( - targetOutputImplib.c_str(), cmLocalGenerator::SHELL); + path = this->GetLocalGenerator()->ConvertToOutputFormat( + targetOutputImplib.c_str(), cmLocalGenerator::SHELL); + vars["TARGET_IMPLIB"] = path; + EnsureParentDirectoryExists(path); } - vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat( - this->GetTargetPDB().c_str(), cmLocalGenerator::SHELL); + path = this->GetLocalGenerator()->ConvertToOutputFormat( + this->GetTargetPDB().c_str(), cmLocalGenerator::SHELL); + vars["TARGET_PDB"] = path; + EnsureParentDirectoryExists(path); std::vector *cmdLists[3] = { &this->GetTarget()->GetPreBuildCommands(), diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h index 1702cafe85..7acbe8f6f7 100644 --- a/Source/cmNinjaNormalTargetGenerator.h +++ b/Source/cmNinjaNormalTargetGenerator.h @@ -35,6 +35,9 @@ private: void WriteObjectLibStatement(); std::vector ComputeLinkCmd(); + void EnsureDirectoryExists(const std::string& dir); + void EnsureParentDirectoryExists(const std::string& path); + private: // Target name info. std::string TargetNameOut; From 73426ac774ab7f74ed6ef3339f075bcebb5336eb Mon Sep 17 00:00:00 2001 From: Peter Kuemmel Date: Fri, 6 Apr 2012 21:07:32 +0200 Subject: [PATCH 2/7] Ninja: no 16:9 screens for the cmake team ;) --- Source/cmNinjaNormalTargetGenerator.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 2bfe814d85..25d742b7c5 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -55,18 +55,21 @@ cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator() { } -void cmNinjaNormalTargetGenerator::EnsureDirectoryExists(const std::string& dir) +void +cmNinjaNormalTargetGenerator +::EnsureDirectoryExists(const std::string& dir) { cmSystemTools::MakeDirectory(dir.c_str()); } -void cmNinjaNormalTargetGenerator::EnsureParentDirectoryExists(const std::string& path) +void +cmNinjaNormalTargetGenerator +::EnsureParentDirectoryExists(const std::string& path) { EnsureDirectoryExists(cmSystemTools::GetParentDirectory(path.c_str())); } - void cmNinjaNormalTargetGenerator::Generate() { if (!this->TargetLinkLanguage) { From f93e81858b5e1243714ed7f26aadfc791a7b0ff0 Mon Sep 17 00:00:00 2001 From: Peter Kuemmel Date: Fri, 6 Apr 2012 23:25:09 +0200 Subject: [PATCH 3/7] Ninja: add option to enable ninja where it is not enabled by default --- Source/CMakeLists.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index f9d1c03594..a27ec75731 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -355,15 +355,17 @@ IF (WIN32) ENDIF(NOT UNIX) ENDIF (WIN32) -# turn on Ninja by default +# Turn on Ninja by default, but disable it +# on platforms where it does not pass all tests. +# Enforce Ninja support with ENABLE_NINJA set(_CMAKE_DEFAULT_NINJA_VALUE TRUE) -# turn it off for platforms where it does not pass all the -# tests if(WIN32 OR APPLE) - SET(_CMAKE_DEFAULT_NINJA_VALUE FALSE) + if(NOT ENABLE_NINJA) + SET(_CMAKE_DEFAULT_NINJA_VALUE FALSE) + endif() endif() SET(CMAKE_ENABLE_NINJA ${_CMAKE_DEFAULT_NINJA_VALUE} CACHE BOOL - "Enable the ninja generator for CMake. currently not fully working for Windows or OSX") + "Enable the ninja generator for CMake. On Windows and OSX broken" FORCE) MARK_AS_ADVANCED(CMAKE_ENABLE_NINJA) IF(CMAKE_ENABLE_NINJA) MESSAGE(STATUS "Enable ninja generator.") @@ -382,7 +384,7 @@ IF(CMAKE_ENABLE_NINJA) ) ADD_DEFINITIONS(-DCMAKE_USE_NINJA) ELSE() - MESSAGE(STATUS "Disable ninja generator.") + MESSAGE(STATUS "Ninja generator disabled, enforce with -DENABLE_NINJA=ON") ENDIF() # create a library used by the command line and the GUI From 11bd9b5588a9ea4922591772e633db5f4ac0862c Mon Sep 17 00:00:00 2001 From: Peter Kuemmel Date: Sat, 7 Apr 2012 21:41:05 +0200 Subject: [PATCH 4/7] Ninja: remove GCC -Wshadow warning --- Source/cmNinjaNormalTargetGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 25d742b7c5..cf2b4271e9 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -432,7 +432,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() // If we have any PRE_LINK commands, we need to go back to HOME_OUTPUT for // the link commands. if (!preLinkCmdLines.empty()) { - std::string path = this->GetLocalGenerator()->ConvertToOutputFormat( + path = this->GetLocalGenerator()->ConvertToOutputFormat( this->GetMakefile()->GetHomeOutputDirectory(), cmLocalGenerator::SHELL); preLinkCmdLines.push_back("cd " + path); From b8c3e8c1f1083ef9f8ece6b1cdb0cbe6dc50c79a Mon Sep 17 00:00:00 2001 From: Peter Kuemmel Date: Sat, 7 Apr 2012 21:40:17 +0200 Subject: [PATCH 5/7] Ninja: enable Ninja for CodeBlocks --- Source/cmExtraCodeBlocksGenerator.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index ccb17f0992..084c904e09 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -59,6 +59,9 @@ cmExtraCodeBlocksGenerator::cmExtraCodeBlocksGenerator() this->SupportedGlobalGenerators.push_back("NMake Makefiles"); // disable until somebody actually tests it: // this->SupportedGlobalGenerators.push_back("MSYS Makefiles"); +#endif +#ifdef CMAKE_USE_NINJA + this->SupportedGlobalGenerators.push_back("Ninja"); #endif this->SupportedGlobalGenerators.push_back("Unix Makefiles"); } From 2a081a2b3a3064530fe173a2930828e2232e844b Mon Sep 17 00:00:00 2001 From: Peter Kuemmel Date: Sun, 8 Apr 2012 11:15:17 +0200 Subject: [PATCH 6/7] Ninja: no additional variable needed to enable ninja --- Source/CMakeLists.txt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index a27ec75731..b7c15c9ab1 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -357,18 +357,16 @@ ENDIF (WIN32) # Turn on Ninja by default, but disable it # on platforms where it does not pass all tests. -# Enforce Ninja support with ENABLE_NINJA +# Enforce Ninja support by setting CMAKE_USE_NINJA set(_CMAKE_DEFAULT_NINJA_VALUE TRUE) if(WIN32 OR APPLE) - if(NOT ENABLE_NINJA) - SET(_CMAKE_DEFAULT_NINJA_VALUE FALSE) - endif() + SET(_CMAKE_DEFAULT_NINJA_VALUE FALSE) endif() SET(CMAKE_ENABLE_NINJA ${_CMAKE_DEFAULT_NINJA_VALUE} CACHE BOOL - "Enable the ninja generator for CMake. On Windows and OSX broken" FORCE) + "Enable the ninja generator for CMake. On Windows and OSX broken") MARK_AS_ADVANCED(CMAKE_ENABLE_NINJA) IF(CMAKE_ENABLE_NINJA) - MESSAGE(STATUS "Enable ninja generator.") + MESSAGE(STATUS "Ninja generator enabled.") SET(SRCS ${SRCS} cmGlobalNinjaGenerator.cxx cmGlobalNinjaGenerator.h @@ -384,7 +382,7 @@ IF(CMAKE_ENABLE_NINJA) ) ADD_DEFINITIONS(-DCMAKE_USE_NINJA) ELSE() - MESSAGE(STATUS "Ninja generator disabled, enforce with -DENABLE_NINJA=ON") + MESSAGE(STATUS "Ninja generator disabled, enforce with -DCMAKE_USE_NINJA=ON") ENDIF() # create a library used by the command line and the GUI From c9747f34ce3f9b00adb2d3048b845e8efe270f97 Mon Sep 17 00:00:00 2001 From: Peter Kuemmel Date: Sun, 8 Apr 2012 14:45:05 +0200 Subject: [PATCH 7/7] Ninja: CMAKE_USE_NINJA is the name of the macro --- Source/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index b7c15c9ab1..c01c490f6f 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -382,7 +382,7 @@ IF(CMAKE_ENABLE_NINJA) ) ADD_DEFINITIONS(-DCMAKE_USE_NINJA) ELSE() - MESSAGE(STATUS "Ninja generator disabled, enforce with -DCMAKE_USE_NINJA=ON") + MESSAGE(STATUS "Ninja generator disabled, enforce with -DCMAKE_ENABLE_NINJA=ON") ENDIF() # create a library used by the command line and the GUI