Ninja: Refactor lookup of cmcldeps location

This executable comes with CMake so just compute its location in
cmSystemTools instead of storing it in compiler information modules.
This commit is contained in:
Brad King 2015-09-18 08:47:27 -04:00
parent c73fbda66b
commit 828c05b9f5
6 changed files with 16 additions and 5 deletions

View File

@ -60,5 +60,4 @@ set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "@CMAKE_C_IMPLICIT_LINK_LIBRARIES@")
set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "@CMAKE_C_IMPLICIT_LINK_DIRECTORIES@") set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "@CMAKE_C_IMPLICIT_LINK_DIRECTORIES@")
set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@") set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@")
@SET_CMAKE_CMCLDEPS_EXECUTABLE@
@SET_CMAKE_CL_SHOWINCLUDES_PREFIX@ @SET_CMAKE_CL_SHOWINCLUDES_PREFIX@

View File

@ -61,5 +61,4 @@ set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "@CMAKE_CXX_IMPLICIT_LINK_LIBRARIES@")
set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "@CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES@") set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "@CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES@")
set(CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@") set(CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@")
@SET_CMAKE_CMCLDEPS_EXECUTABLE@
@SET_CMAKE_CL_SHOWINCLUDES_PREFIX@ @SET_CMAKE_CL_SHOWINCLUDES_PREFIX@

View File

@ -21,7 +21,6 @@
# #
if(CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_C_COMPILER AND CMAKE_COMMAND) if(CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_C_COMPILER AND CMAKE_COMMAND)
string(REPLACE "cmake.exe" "cmcldeps.exe" CMAKE_CMCLDEPS_EXECUTABLE ${CMAKE_COMMAND})
set(showdir ${CMAKE_BINARY_DIR}/CMakeFiles/ShowIncludes) set(showdir ${CMAKE_BINARY_DIR}/CMakeFiles/ShowIncludes)
file(WRITE ${showdir}/foo.h "\n") file(WRITE ${showdir}/foo.h "\n")
file(WRITE ${showdir}/main.c "#include \"foo.h\" \nint main(){}\n") file(WRITE ${showdir}/main.c "#include \"foo.h\" \nint main(){}\n")
@ -29,6 +28,5 @@ if(CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_C_COMPILER AND CMAKE_COMMAND)
WORKING_DIRECTORY ${showdir} OUTPUT_VARIABLE outLine) WORKING_DIRECTORY ${showdir} OUTPUT_VARIABLE outLine)
string(REGEX MATCH "\n([^:]*:[^:]*:[ \t]*)" tmp "${outLine}") string(REGEX MATCH "\n([^:]*:[^:]*:[ \t]*)" tmp "${outLine}")
set(localizedPrefix "${CMAKE_MATCH_1}") set(localizedPrefix "${CMAKE_MATCH_1}")
set(SET_CMAKE_CMCLDEPS_EXECUTABLE "set(CMAKE_CMCLDEPS_EXECUTABLE \"${CMAKE_CMCLDEPS_EXECUTABLE}\")")
set(SET_CMAKE_CL_SHOWINCLUDES_PREFIX "set(CMAKE_CL_SHOWINCLUDES_PREFIX \"${localizedPrefix}\")") set(SET_CMAKE_CL_SHOWINCLUDES_PREFIX "set(CMAKE_CL_SHOWINCLUDES_PREFIX \"${localizedPrefix}\")")
endif() endif()

View File

@ -371,7 +371,7 @@ cmNinjaTargetGenerator
mf->GetSafeDefinition("CMAKE_C_COMPILER") : mf->GetSafeDefinition("CMAKE_C_COMPILER") :
mf->GetSafeDefinition("CMAKE_CXX_COMPILER"); mf->GetSafeDefinition("CMAKE_CXX_COMPILER");
cldeps = "\""; cldeps = "\"";
cldeps += mf->GetSafeDefinition("CMAKE_CMCLDEPS_EXECUTABLE"); cldeps += cmSystemTools::GetCMClDepsCommand();
cldeps += "\" " + lang + " $in \"$DEP_FILE\" $out \""; cldeps += "\" " + lang + " $in \"$DEP_FILE\" $out \"";
cldeps += mf->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX"); cldeps += mf->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX");
cldeps += "\" \"" + cl + "\" "; cldeps += "\" \"" + cl + "\" ";

View File

@ -2216,6 +2216,7 @@ static std::string cmSystemToolsCTestCommand;
static std::string cmSystemToolsCPackCommand; static std::string cmSystemToolsCPackCommand;
static std::string cmSystemToolsCMakeCursesCommand; static std::string cmSystemToolsCMakeCursesCommand;
static std::string cmSystemToolsCMakeGUICommand; static std::string cmSystemToolsCMakeGUICommand;
static std::string cmSystemToolsCMClDepsCommand;
static std::string cmSystemToolsCMakeRoot; static std::string cmSystemToolsCMakeRoot;
void cmSystemTools::FindCMakeResources(const char* argv0) void cmSystemTools::FindCMakeResources(const char* argv0)
{ {
@ -2308,6 +2309,13 @@ void cmSystemTools::FindCMakeResources(const char* argv0)
{ {
cmSystemToolsCMakeCursesCommand = ""; cmSystemToolsCMakeCursesCommand = "";
} }
cmSystemToolsCMClDepsCommand = exe_dir;
cmSystemToolsCMClDepsCommand += "/cmcldeps";
cmSystemToolsCMClDepsCommand += cmSystemTools::GetExecutableExtension();
if(!cmSystemTools::FileExists(cmSystemToolsCMClDepsCommand.c_str()))
{
cmSystemToolsCMClDepsCommand = "";
}
#ifdef CMAKE_BUILD_WITH_CMAKE #ifdef CMAKE_BUILD_WITH_CMAKE
// Install tree has "<prefix>/bin/cmake" and "<prefix><CMAKE_DATA_DIR>". // Install tree has "<prefix>/bin/cmake" and "<prefix><CMAKE_DATA_DIR>".
@ -2374,6 +2382,12 @@ std::string const& cmSystemTools::GetCMakeGUICommand()
return cmSystemToolsCMakeGUICommand; return cmSystemToolsCMakeGUICommand;
} }
//----------------------------------------------------------------------------
std::string const& cmSystemTools::GetCMClDepsCommand()
{
return cmSystemToolsCMClDepsCommand;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string const& cmSystemTools::GetCMakeRoot() std::string const& cmSystemTools::GetCMakeRoot()
{ {

View File

@ -426,6 +426,7 @@ public:
static std::string const& GetCMakeCommand(); static std::string const& GetCMakeCommand();
static std::string const& GetCMakeGUICommand(); static std::string const& GetCMakeGUICommand();
static std::string const& GetCMakeCursesCommand(); static std::string const& GetCMakeCursesCommand();
static std::string const& GetCMClDepsCommand();
static std::string const& GetCMakeRoot(); static std::string const& GetCMakeRoot();
/** Echo a message in color using KWSys's Terminal cprintf. */ /** Echo a message in color using KWSys's Terminal cprintf. */