Ninja: allow spaces in source path
And make /showIncude prefix visible for all build rules
This commit is contained in:
parent
033a687acd
commit
941afa571c
|
@ -48,3 +48,8 @@ SET(CMAKE_C_HAS_ISYSROOT "@CMAKE_C_HAS_ISYSROOT@")
|
||||||
|
|
||||||
SET(CMAKE_C_IMPLICIT_LINK_LIBRARIES "@CMAKE_C_IMPLICIT_LINK_LIBRARIES@")
|
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@")
|
||||||
|
|
||||||
|
IF(MSVC_CXX_ARCHITECTURE_ID)
|
||||||
|
SET(CMAKE_CMCLDEPS_EXECUTABLE "@CMAKE_CMCLDEPS_EXECUTABLE@")
|
||||||
|
SET(CMAKE_CL_SHOWINCLUDE_PREFIX "@CMAKE_CL_SHOWINCLUDE_PREFIX@")
|
||||||
|
ENDIF()
|
||||||
|
|
|
@ -49,3 +49,8 @@ SET(CMAKE_CXX_HAS_ISYSROOT "@CMAKE_CXX_HAS_ISYSROOT@")
|
||||||
|
|
||||||
SET(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "@CMAKE_CXX_IMPLICIT_LINK_LIBRARIES@")
|
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@")
|
||||||
|
|
||||||
|
IF(MSVC_CXX_ARCHITECTURE_ID)
|
||||||
|
SET(CMAKE_CMCLDEPS_EXECUTABLE "@CMAKE_CMCLDEPS_EXECUTABLE@")
|
||||||
|
SET(CMAKE_CL_SHOWINCLUDE_PREFIX "@CMAKE_CL_SHOWINCLUDE_PREFIX@")
|
||||||
|
ENDIF()
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
IF(MSVC_C_ARCHITECTURE_ID AND CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_C_COMPILER)
|
||||||
|
FIND_PROGRAM(CMAKE_CMCLDEPS_EXECUTABLE NAMES cmcldeps.exe)
|
||||||
|
SET(showdir ${CMAKE_BINARY_DIR}/CMakeFiles/ShowIncludes)
|
||||||
|
FILE(WRITE ${showdir}/foo.h "\n")
|
||||||
|
FILE(WRITE ${showdir}/main.c "#include \"foo.h\" \nint main(){}\n")
|
||||||
|
EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} /nologo /showIncludes ${showdir}/main.c
|
||||||
|
WORKING_DIRECTORY ${showdir} OUTPUT_VARIABLE showOut)
|
||||||
|
STRING(REPLACE main.c "" showOut1 ${showOut})
|
||||||
|
STRING(REPLACE "/" "\\" header1 ${showdir}/foo.h)
|
||||||
|
STRING(TOLOWER ${header1} header2)
|
||||||
|
STRING(REPLACE ${header2} "" showOut2 ${showOut1})
|
||||||
|
STRING(REPLACE "\n" "" showOut3 ${showOut2})
|
||||||
|
SET(CMAKE_CL_SHOWINCLUDE_PREFIX ${showOut3} CACHE STRING "cl.exe's /showInclides prefix" FORCE)
|
||||||
|
ENDIF()
|
|
@ -165,9 +165,7 @@ ENDIF (CMAKE_CROSSCOMPILING
|
||||||
AND "${CMAKE_C_COMPILER_ID}" MATCHES "GNU"
|
AND "${CMAKE_C_COMPILER_ID}" MATCHES "GNU"
|
||||||
AND NOT _CMAKE_TOOLCHAIN_PREFIX)
|
AND NOT _CMAKE_TOOLCHAIN_PREFIX)
|
||||||
|
|
||||||
|
INCLUDE(${CMAKE_ROOT}/Modules/CMakeClDeps.cmake)
|
||||||
|
|
||||||
|
|
||||||
INCLUDE(CMakeFindBinUtils)
|
INCLUDE(CMakeFindBinUtils)
|
||||||
IF(MSVC_C_ARCHITECTURE_ID)
|
IF(MSVC_C_ARCHITECTURE_ID)
|
||||||
SET(SET_MSVC_C_ARCHITECTURE_ID
|
SET(SET_MSVC_C_ARCHITECTURE_ID
|
||||||
|
|
|
@ -173,6 +173,7 @@ ENDIF (CMAKE_CROSSCOMPILING
|
||||||
AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU"
|
AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU"
|
||||||
AND NOT _CMAKE_TOOLCHAIN_PREFIX)
|
AND NOT _CMAKE_TOOLCHAIN_PREFIX)
|
||||||
|
|
||||||
|
INCLUDE(${CMAKE_ROOT}/Modules/CMakeClDeps.cmake)
|
||||||
INCLUDE(CMakeFindBinUtils)
|
INCLUDE(CMakeFindBinUtils)
|
||||||
IF(MSVC_CXX_ARCHITECTURE_ID)
|
IF(MSVC_CXX_ARCHITECTURE_ID)
|
||||||
SET(SET_MSVC_CXX_ARCHITECTURE_ID
|
SET(SET_MSVC_CXX_ARCHITECTURE_ID
|
||||||
|
|
|
@ -251,21 +251,3 @@ IF(NOT EXISTS "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCXXPlatform.cmake")
|
||||||
CONFIGURE_FILE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake.in
|
CONFIGURE_FILE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake.in
|
||||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCXXPlatform.cmake IMMEDIATE)
|
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCXXPlatform.cmake IMMEDIATE)
|
||||||
ENDIF(NOT EXISTS "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCXXPlatform.cmake")
|
ENDIF(NOT EXISTS "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCXXPlatform.cmake")
|
||||||
|
|
||||||
|
|
||||||
IF(CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_C_COMPILER)
|
|
||||||
# TODO try_compile doesn't need cmcldeps, find a better solution
|
|
||||||
if(NOT EXISTS ${CMAKE_TRY_COMPILE_SOURCE_DIR}/../ShowIncludes)
|
|
||||||
SET(showdir ${CMAKE_BINARY_DIR}/CMakeFiles/ShowIncludes)
|
|
||||||
FILE(WRITE ${showdir}/foo.h "\n")
|
|
||||||
FILE(WRITE ${showdir}/main.c "#include \"foo.h\" \nint main(){}\n")
|
|
||||||
EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} /nologo /showIncludes ${showdir}/main.c
|
|
||||||
WORKING_DIRECTORY ${showdir} OUTPUT_VARIABLE showOut)
|
|
||||||
STRING(REPLACE main.c "" showOut1 ${showOut})
|
|
||||||
STRING(REPLACE "/" "\\" header1 ${showdir}/foo.h)
|
|
||||||
STRING(TOLOWER ${header1} header2)
|
|
||||||
STRING(REPLACE ${header2} "" showOut2 ${showOut1})
|
|
||||||
STRING(REPLACE "\n" "" showOut3 ${showOut2})
|
|
||||||
SET(CMAKE_CL_SHOWINCLUDE_PREFIX ${showOut3})
|
|
||||||
ENDIF()
|
|
||||||
ENDIF()
|
|
||||||
|
|
|
@ -458,8 +458,7 @@ void cmGlobalNinjaGenerator
|
||||||
else if(*l == "RC")
|
else if(*l == "RC")
|
||||||
{
|
{
|
||||||
// check if mingw is used
|
// check if mingw is used
|
||||||
const char* cc = mf->GetDefinition("CMAKE_C_COMPILER");
|
if(mf->IsOn("CMAKE_COMPILER_IS_MINGW"))
|
||||||
if(cc && std::string(cc).find("gcc.exe") != std::string::npos)
|
|
||||||
{
|
{
|
||||||
UsingMinGW = true;
|
UsingMinGW = true;
|
||||||
std::string rc = cmSystemTools::FindProgram("windres");
|
std::string rc = cmSystemTools::FindProgram("windres");
|
||||||
|
@ -467,17 +466,6 @@ void cmGlobalNinjaGenerator
|
||||||
rc = "windres.exe";;
|
rc = "windres.exe";;
|
||||||
mf->AddDefinition("CMAKE_RC_COMPILER", rc.c_str());
|
mf->AddDefinition("CMAKE_RC_COMPILER", rc.c_str());
|
||||||
}
|
}
|
||||||
else if (cc && std::string(cc).find("cl.exe") != std::string::npos)
|
|
||||||
{
|
|
||||||
const char* cmake = mf->GetDefinition("CMAKE_COMMAND");
|
|
||||||
std::string bindir = cmake ? cmake : "";
|
|
||||||
cmSystemTools::ReplaceString(bindir, "cmake.exe", "");
|
|
||||||
std::vector<std::string> locations;
|
|
||||||
locations.push_back(bindir);
|
|
||||||
std::string cldeps = cmSystemTools::FindProgram("cmcldeps", locations);
|
|
||||||
if(!cldeps.empty())
|
|
||||||
mf->AddDefinition("CMAKE_CMCLDEPS_EXECUTABLE", cldeps.c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this->cmGlobalGenerator::EnableLanguage(language, mf, optional);
|
this->cmGlobalGenerator::EnableLanguage(language, mf, optional);
|
||||||
this->ResolveLanguageCompiler(*l, mf, optional);
|
this->ResolveLanguageCompiler(*l, mf, optional);
|
||||||
|
|
|
@ -330,20 +330,14 @@ cmNinjaTargetGenerator
|
||||||
vars.Defines = "$DEFINES";
|
vars.Defines = "$DEFINES";
|
||||||
vars.TargetPDB = "$TARGET_PDB";
|
vars.TargetPDB = "$TARGET_PDB";
|
||||||
|
|
||||||
const char* cldeps = 0;
|
cmMakefile* mf = this->GetMakefile();
|
||||||
const char* showIncludePrefix = 0;
|
const char* clDepsBinary = mf->GetDefinition("CMAKE_CMCLDEPS_EXECUTABLE");
|
||||||
const char* cc = this->GetMakefile()->GetDefinition("CMAKE_C_COMPILER");
|
const char* clShowPrefix = mf->GetDefinition("CMAKE_CL_SHOWINCLUDE_PREFIX");
|
||||||
if(cc && std::string(cc).find("cl.exe") != std::string::npos)
|
|
||||||
{
|
|
||||||
cldeps = this->GetMakefile()->GetDefinition("CMAKE_CMCLDEPS_EXECUTABLE");
|
|
||||||
showIncludePrefix = this->GetMakefile()->GetDefinition("CMAKE_CL_SHOWINCLUDE_PREFIX");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string depfile;
|
std::string depfile;
|
||||||
std::string depfileFlagsName = "CMAKE_DEPFILE_FLAGS_" + language;
|
std::string depfileFlagsName = "CMAKE_DEPFILE_FLAGS_" + language;
|
||||||
const char *depfileFlags =
|
const char *depfileFlags = mf->GetDefinition(depfileFlagsName.c_str());
|
||||||
this->GetMakefile()->GetDefinition(depfileFlagsName.c_str());
|
if (depfileFlags || (clDepsBinary && clShowPrefix)) {
|
||||||
if (depfileFlags || (cldeps && showIncludePrefix)) {
|
|
||||||
std::string depfileFlagsStr = depfileFlags ? depfileFlags : "";
|
std::string depfileFlagsStr = depfileFlags ? depfileFlags : "";
|
||||||
depfile = "$out.d";
|
depfile = "$out.d";
|
||||||
cmSystemTools::ReplaceString(depfileFlagsStr, "<DEPFILE>",
|
cmSystemTools::ReplaceString(depfileFlagsStr, "<DEPFILE>",
|
||||||
|
@ -351,7 +345,7 @@ cmNinjaTargetGenerator
|
||||||
cmSystemTools::ReplaceString(depfileFlagsStr, "<OBJECT>",
|
cmSystemTools::ReplaceString(depfileFlagsStr, "<OBJECT>",
|
||||||
"$out");
|
"$out");
|
||||||
cmSystemTools::ReplaceString(depfileFlagsStr, "<CMAKE_C_COMPILER>",
|
cmSystemTools::ReplaceString(depfileFlagsStr, "<CMAKE_C_COMPILER>",
|
||||||
this->GetMakefile()->GetDefinition("CMAKE_C_COMPILER"));
|
mf->GetDefinition("CMAKE_C_COMPILER"));
|
||||||
flags += " " + depfileFlagsStr;
|
flags += " " + depfileFlagsStr;
|
||||||
}
|
}
|
||||||
vars.Flags = flags.c_str();
|
vars.Flags = flags.c_str();
|
||||||
|
@ -361,8 +355,7 @@ cmNinjaTargetGenerator
|
||||||
std::string compileCmdVar = "CMAKE_";
|
std::string compileCmdVar = "CMAKE_";
|
||||||
compileCmdVar += language;
|
compileCmdVar += language;
|
||||||
compileCmdVar += "_COMPILE_OBJECT";
|
compileCmdVar += "_COMPILE_OBJECT";
|
||||||
std::string compileCmd =
|
std::string compileCmd = mf->GetRequiredDefinition(compileCmdVar.c_str());
|
||||||
this->GetMakefile()->GetRequiredDefinition(compileCmdVar.c_str());
|
|
||||||
std::vector<std::string> compileCmds;
|
std::vector<std::string> compileCmds;
|
||||||
cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
|
cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
|
||||||
|
|
||||||
|
@ -373,10 +366,10 @@ cmNinjaTargetGenerator
|
||||||
std::string cmdLine =
|
std::string cmdLine =
|
||||||
this->GetLocalGenerator()->BuildCommandLine(compileCmds);
|
this->GetLocalGenerator()->BuildCommandLine(compileCmds);
|
||||||
|
|
||||||
if(cldeps && showIncludePrefix)
|
if(clDepsBinary && clShowPrefix)
|
||||||
{
|
{
|
||||||
std::string prefix = showIncludePrefix;
|
std::string prefix = clShowPrefix;
|
||||||
cmdLine = std::string(cldeps) + " $in $out.d $out " + "\"" + prefix + "\" " + cmdLine;
|
cmdLine = "\"" + std::string(clDepsBinary) + "\" $in $out.d $out \"" + prefix + "\" " + cmdLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the rule for compiling file of the given language.
|
// Write the rule for compiling file of the given language.
|
||||||
|
|
Loading…
Reference in New Issue