summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2012-04-25 18:00:59 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2012-04-25 18:00:59 (GMT)
commit04f5dd8ad49086f22cf866713482b5ea8c19f9fb (patch)
tree30366a271969e8000840f8fc88adf38d36d2e5f4 /Source
parent14be8dd264e2b8bc5a0c7c883bae4338d3c960e7 (diff)
parentc9747f34ce3f9b00adb2d3048b845e8efe270f97 (diff)
downloadCMake-04f5dd8ad49086f22cf866713482b5ea8c19f9fb.zip
CMake-04f5dd8ad49086f22cf866713482b5ea8c19f9fb.tar.gz
CMake-04f5dd8ad49086f22cf866713482b5ea8c19f9fb.tar.bz2
Merge topic 'ninja-patches'
c9747f3 Ninja: CMAKE_USE_NINJA is the name of the macro 2a081a2 Ninja: no additional variable needed to enable ninja b8c3e8c Ninja: enable Ninja for CodeBlocks 11bd9b5 Ninja: remove GCC -Wshadow warning f93e818 Ninja: add option to enable ninja where it is not enabled by default 73426ac Ninja: no 16:9 screens for the cmake team ;) 8217c26 Ninja: ensure output directories exist
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeLists.txt12
-rw-r--r--Source/cmExtraCodeBlocksGenerator.cxx3
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx33
-rw-r--r--Source/cmNinjaNormalTargetGenerator.h3
4 files changed, 38 insertions, 13 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index f9d1c03..c01c490 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -355,18 +355,18 @@ 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 by setting CMAKE_USE_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)
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")
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
@@ -382,7 +382,7 @@ IF(CMAKE_ENABLE_NINJA)
)
ADD_DEFINITIONS(-DCMAKE_USE_NINJA)
ELSE()
- MESSAGE(STATUS "Disable ninja generator.")
+ MESSAGE(STATUS "Ninja generator disabled, enforce with -DCMAKE_ENABLE_NINJA=ON")
ENDIF()
# create a library used by the command line and the GUI
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx
index ccb17f0..084c904 100644
--- a/Source/cmExtraCodeBlocksGenerator.cxx
+++ b/Source/cmExtraCodeBlocksGenerator.cxx
@@ -60,6 +60,9 @@ cmExtraCodeBlocksGenerator::cmExtraCodeBlocksGenerator()
// 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");
}
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 2bad32c..cf2b427 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,21 @@ 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 +394,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<cmCustomCommand> *cmdLists[3] = {
&this->GetTarget()->GetPreBuildCommands(),
@@ -413,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);
diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h
index 1702caf..7acbe8f 100644
--- a/Source/cmNinjaNormalTargetGenerator.h
+++ b/Source/cmNinjaNormalTargetGenerator.h
@@ -35,6 +35,9 @@ private:
void WriteObjectLibStatement();
std::vector<std::string> ComputeLinkCmd();
+ void EnsureDirectoryExists(const std::string& dir);
+ void EnsureParentDirectoryExists(const std::string& path);
+
private:
// Target name info.
std::string TargetNameOut;