mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-22 14:23:10 -05:00
CUDA: Ninja generator generates valid compile database
The ninja generator has been updated to poperly write the compile database when the CUDA language has been enabled. Fixes #23368
This commit is contained in:
@@ -1678,28 +1678,32 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand(
|
|||||||
compileObjectVars.Includes = includes.c_str();
|
compileObjectVars.Includes = includes.c_str();
|
||||||
|
|
||||||
// Rule for compiling object file.
|
// Rule for compiling object file.
|
||||||
std::vector<std::string> compileCmds;
|
std::string cudaCompileMode;
|
||||||
if (language == "CUDA") {
|
if (language == "CUDA") {
|
||||||
std::string cmdVar;
|
|
||||||
if (this->GeneratorTarget->GetPropertyAsBool(
|
if (this->GeneratorTarget->GetPropertyAsBool(
|
||||||
"CUDA_SEPARABLE_COMPILATION")) {
|
"CUDA_SEPARABLE_COMPILATION")) {
|
||||||
cmdVar = "CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION";
|
const std::string& rdcFlag =
|
||||||
} else if (this->GeneratorTarget->GetPropertyAsBool(
|
this->Makefile->GetRequiredDefinition("_CMAKE_CUDA_RDC_FLAG");
|
||||||
"CUDA_PTX_COMPILATION")) {
|
cudaCompileMode = cmStrCat(cudaCompileMode, rdcFlag, " ");
|
||||||
cmdVar = "CMAKE_CUDA_COMPILE_PTX_COMPILATION";
|
|
||||||
} else {
|
|
||||||
cmdVar = "CMAKE_CUDA_COMPILE_WHOLE_COMPILATION";
|
|
||||||
}
|
}
|
||||||
const std::string& compileCmd =
|
if (this->GeneratorTarget->GetPropertyAsBool("CUDA_PTX_COMPILATION")) {
|
||||||
this->GetMakefile()->GetRequiredDefinition(cmdVar);
|
const std::string& ptxFlag =
|
||||||
cmExpandList(compileCmd, compileCmds);
|
this->Makefile->GetRequiredDefinition("_CMAKE_CUDA_PTX_FLAG");
|
||||||
} else {
|
cudaCompileMode = cmStrCat(cudaCompileMode, ptxFlag);
|
||||||
const std::string cmdVar = cmStrCat("CMAKE_", language, "_COMPILE_OBJECT");
|
} else {
|
||||||
const std::string& compileCmd =
|
const std::string& wholeFlag =
|
||||||
this->GetMakefile()->GetRequiredDefinition(cmdVar);
|
this->Makefile->GetRequiredDefinition("_CMAKE_CUDA_WHOLE_FLAG");
|
||||||
cmExpandList(compileCmd, compileCmds);
|
cudaCompileMode = cmStrCat(cudaCompileMode, wholeFlag);
|
||||||
|
}
|
||||||
|
compileObjectVars.CudaCompileMode = cudaCompileMode.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> compileCmds;
|
||||||
|
const std::string cmdVar = cmStrCat("CMAKE_", language, "_COMPILE_OBJECT");
|
||||||
|
const std::string& compileCmd =
|
||||||
|
this->Makefile->GetRequiredDefinition(cmdVar);
|
||||||
|
cmExpandList(compileCmd, compileCmds);
|
||||||
|
|
||||||
std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
|
std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
|
||||||
this->GetLocalGenerator()->CreateRulePlaceholderExpander());
|
this->GetLocalGenerator()->CreateRulePlaceholderExpander());
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
cmake_minimum_required(VERSION 3.18)
|
cmake_minimum_required(VERSION 3.18)
|
||||||
project(WithDefs CUDA)
|
project(WithDefs CUDA)
|
||||||
|
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
set(release_compile_defs DEFREL)
|
set(release_compile_defs DEFREL)
|
||||||
|
|
||||||
#Goal for this example:
|
#Goal for this example:
|
||||||
|
|||||||
Reference in New Issue
Block a user