CUDA: Add support for the CUDA_SEPARABLE_COMPILATION target property
This commit is contained in:
parent
ae05fcc63f
commit
4b31609710
@ -143,6 +143,7 @@ Properties on Targets
|
|||||||
/prop_tgt/CONFIG_OUTPUT_NAME
|
/prop_tgt/CONFIG_OUTPUT_NAME
|
||||||
/prop_tgt/CONFIG_POSTFIX
|
/prop_tgt/CONFIG_POSTFIX
|
||||||
/prop_tgt/CROSSCOMPILING_EMULATOR
|
/prop_tgt/CROSSCOMPILING_EMULATOR
|
||||||
|
/prop_tgt/CUDA_SEPARABLE_COMPILATION
|
||||||
/prop_tgt/CXX_EXTENSIONS
|
/prop_tgt/CXX_EXTENSIONS
|
||||||
/prop_tgt/CXX_STANDARD
|
/prop_tgt/CXX_STANDARD
|
||||||
/prop_tgt/CXX_STANDARD_REQUIRED
|
/prop_tgt/CXX_STANDARD_REQUIRED
|
||||||
|
13
Help/prop_tgt/CUDA_SEPARABLE_COMPILATION.rst
Normal file
13
Help/prop_tgt/CUDA_SEPARABLE_COMPILATION.rst
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
CUDA_SEPARABLE_COMPILATION
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
CUDA only: Enables separate compilation of device code
|
||||||
|
|
||||||
|
If set this will enable separable compilation for all CUDA files for
|
||||||
|
the given target.
|
||||||
|
|
||||||
|
For instance:
|
||||||
|
|
||||||
|
.. code-block:: cmake
|
||||||
|
|
||||||
|
set_property(TARGET myexe PROPERTY CUDA_SEPARABLE_COMPILATION ON)
|
@ -596,13 +596,22 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
|
|||||||
|
|
||||||
// Construct the compile rules.
|
// Construct the compile rules.
|
||||||
{
|
{
|
||||||
std::string compileRuleVar = "CMAKE_";
|
|
||||||
compileRuleVar += lang;
|
|
||||||
compileRuleVar += "_COMPILE_OBJECT";
|
|
||||||
std::string compileRule =
|
|
||||||
this->Makefile->GetRequiredDefinition(compileRuleVar);
|
|
||||||
std::vector<std::string> compileCommands;
|
std::vector<std::string> compileCommands;
|
||||||
cmSystemTools::ExpandListArgument(compileRule, compileCommands);
|
if (lang == "CUDA") {
|
||||||
|
std::string cmdVar;
|
||||||
|
if (this->GeneratorTarget->GetProperty("CUDA_SEPARABLE_COMPILATION")) {
|
||||||
|
cmdVar = std::string("CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION");
|
||||||
|
} else {
|
||||||
|
cmdVar = std::string("CMAKE_CUDA_COMPILE_WHOLE_COMPILATION");
|
||||||
|
}
|
||||||
|
std::string compileRule = this->Makefile->GetRequiredDefinition(cmdVar);
|
||||||
|
cmSystemTools::ExpandListArgument(compileRule, compileCommands);
|
||||||
|
} else {
|
||||||
|
const std::string cmdVar =
|
||||||
|
std::string("CMAKE_") + lang + "_COMPILE_OBJECT";
|
||||||
|
std::string compileRule = this->Makefile->GetRequiredDefinition(cmdVar);
|
||||||
|
cmSystemTools::ExpandListArgument(compileRule, compileCommands);
|
||||||
|
}
|
||||||
|
|
||||||
if (this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS") &&
|
if (this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS") &&
|
||||||
lang_can_export_cmds && compileCommands.size() == 1) {
|
lang_can_export_cmds && compileCommands.size() == 1) {
|
||||||
|
@ -583,10 +583,22 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Rule for compiling object file.
|
// Rule for compiling object file.
|
||||||
const std::string cmdVar = std::string("CMAKE_") + lang + "_COMPILE_OBJECT";
|
|
||||||
std::string compileCmd = mf->GetRequiredDefinition(cmdVar);
|
|
||||||
std::vector<std::string> compileCmds;
|
std::vector<std::string> compileCmds;
|
||||||
cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
|
if (lang == "CUDA") {
|
||||||
|
std::string cmdVar;
|
||||||
|
if (this->GeneratorTarget->GetProperty("CUDA_SEPARABLE_COMPILATION")) {
|
||||||
|
cmdVar = std::string("CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION");
|
||||||
|
} else {
|
||||||
|
cmdVar = std::string("CMAKE_CUDA_COMPILE_WHOLE_COMPILATION");
|
||||||
|
}
|
||||||
|
std::string compileCmd = mf->GetRequiredDefinition(cmdVar);
|
||||||
|
cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
|
||||||
|
} else {
|
||||||
|
const std::string cmdVar =
|
||||||
|
std::string("CMAKE_") + lang + "_COMPILE_OBJECT";
|
||||||
|
std::string compileCmd = mf->GetRequiredDefinition(cmdVar);
|
||||||
|
cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
|
||||||
|
}
|
||||||
|
|
||||||
// Maybe insert an include-what-you-use runner.
|
// Maybe insert an include-what-you-use runner.
|
||||||
if (!compileCmds.empty() && (lang == "C" || lang == "CXX")) {
|
if (!compileCmds.empty() && (lang == "C" || lang == "CXX")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user