diff options
author | Brad King <brad.king@kitware.com> | 2022-03-31 12:47:17 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-03-31 12:47:24 (GMT) |
commit | e5cda4c7725d39c0d083778e9708daf967f7824d (patch) | |
tree | bb7e73119ea56312b3ad54404ddba4af6f014c6e | |
parent | cc75519e5d71398190037d78eef989ddd99cfb24 (diff) | |
parent | f7c6b9833c55257d2b83e2cb5678139ba52df3dc (diff) | |
download | CMake-e5cda4c7725d39c0d083778e9708daf967f7824d.zip CMake-e5cda4c7725d39c0d083778e9708daf967f7824d.tar.gz CMake-e5cda4c7725d39c0d083778e9708daf967f7824d.tar.bz2 |
Merge topic 'ninja_compile_database_understand_new_cuda_lang_variables' into release-3.23
f7c6b9833c CUDA: Ninja generator generates valid compile database
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7129
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 34 | ||||
-rw-r--r-- | Tests/CudaOnly/WithDefs/CMakeLists.txt | 2 |
2 files changed, 21 insertions, 15 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index dd7d244..e61b4b6 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1678,28 +1678,32 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand( compileObjectVars.Includes = includes.c_str(); // Rule for compiling object file. - std::vector<std::string> compileCmds; + std::string cudaCompileMode; if (language == "CUDA") { - std::string cmdVar; if (this->GeneratorTarget->GetPropertyAsBool( "CUDA_SEPARABLE_COMPILATION")) { - cmdVar = "CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION"; - } else if (this->GeneratorTarget->GetPropertyAsBool( - "CUDA_PTX_COMPILATION")) { - cmdVar = "CMAKE_CUDA_COMPILE_PTX_COMPILATION"; + const std::string& rdcFlag = + this->Makefile->GetRequiredDefinition("_CMAKE_CUDA_RDC_FLAG"); + cudaCompileMode = cmStrCat(cudaCompileMode, rdcFlag, " "); + } + if (this->GeneratorTarget->GetPropertyAsBool("CUDA_PTX_COMPILATION")) { + const std::string& ptxFlag = + this->Makefile->GetRequiredDefinition("_CMAKE_CUDA_PTX_FLAG"); + cudaCompileMode = cmStrCat(cudaCompileMode, ptxFlag); } else { - cmdVar = "CMAKE_CUDA_COMPILE_WHOLE_COMPILATION"; + const std::string& wholeFlag = + this->Makefile->GetRequiredDefinition("_CMAKE_CUDA_WHOLE_FLAG"); + cudaCompileMode = cmStrCat(cudaCompileMode, wholeFlag); } - const std::string& compileCmd = - this->GetMakefile()->GetRequiredDefinition(cmdVar); - cmExpandList(compileCmd, compileCmds); - } else { - const std::string cmdVar = cmStrCat("CMAKE_", language, "_COMPILE_OBJECT"); - const std::string& compileCmd = - this->GetMakefile()->GetRequiredDefinition(cmdVar); - cmExpandList(compileCmd, compileCmds); + 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( this->GetLocalGenerator()->CreateRulePlaceholderExpander()); diff --git a/Tests/CudaOnly/WithDefs/CMakeLists.txt b/Tests/CudaOnly/WithDefs/CMakeLists.txt index 02f043f..39bcd91 100644 --- a/Tests/CudaOnly/WithDefs/CMakeLists.txt +++ b/Tests/CudaOnly/WithDefs/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.18) project(WithDefs CUDA) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + set(release_compile_defs DEFREL) #Goal for this example: |