diff options
-rw-r--r-- | Help/manual/cmake-properties.7.rst | 1 | ||||
-rw-r--r-- | Help/prop_tgt/CUDA_SEPARABLE_COMPILATION.rst | 13 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 21 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 18 |
4 files changed, 44 insertions, 9 deletions
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 82d5588..5da00ed 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -143,6 +143,7 @@ Properties on Targets /prop_tgt/CONFIG_OUTPUT_NAME /prop_tgt/CONFIG_POSTFIX /prop_tgt/CROSSCOMPILING_EMULATOR + /prop_tgt/CUDA_SEPARABLE_COMPILATION /prop_tgt/CXX_EXTENSIONS /prop_tgt/CXX_STANDARD /prop_tgt/CXX_STANDARD_REQUIRED diff --git a/Help/prop_tgt/CUDA_SEPARABLE_COMPILATION.rst b/Help/prop_tgt/CUDA_SEPARABLE_COMPILATION.rst new file mode 100644 index 0000000..1c7dd80 --- /dev/null +++ b/Help/prop_tgt/CUDA_SEPARABLE_COMPILATION.rst @@ -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) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 7dfb70f..2e5173d 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -596,13 +596,22 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( // 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; - 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") && lang_can_export_cmds && compileCommands.size() == 1) { diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index a220cd8..e47de97 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -583,10 +583,22 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang) } // 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; - 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. if (!compileCmds.empty() && (lang == "C" || lang == "CXX")) { |