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
This commit is contained in:
David Cole 2012-04-25 14:00:59 -04:00 committed by CMake Topic Stage
commit 04f5dd8ad4
4 changed files with 38 additions and 13 deletions

View File

@ -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

View File

@ -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");
}

View File

@ -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);

View File

@ -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;