diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2020-01-14 20:11:25 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-01-14 20:11:35 (GMT) |
commit | 93526fd91319d952e60760c735a9bb191bc4ede3 (patch) | |
tree | b898aa01d49af34cc2bbaa3bf3d22e67cc27f772 /Source | |
parent | 710371ca2f5032462e8dc352da869834bb421261 (diff) | |
parent | c7ac13e8ed471497e672578816570535440e5815 (diff) | |
download | CMake-93526fd91319d952e60760c735a9bb191bc4ede3.zip CMake-93526fd91319d952e60760c735a9bb191bc4ede3.tar.gz CMake-93526fd91319d952e60760c735a9bb191bc4ede3.tar.bz2 |
Merge topic 'ninja_multi_config_support_cuda'
c7ac13e8ed CUDA: Mult-Config Ninja generator now supports CUDA
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4187
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 45 | ||||
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.h | 4 |
2 files changed, 41 insertions, 8 deletions
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 517241e..f853ac5 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -83,15 +83,15 @@ void cmNinjaNormalTargetGenerator::Generate(const std::string& config) if (this->GetGeneratorTarget()->GetType() == cmStateEnums::OBJECT_LIBRARY) { this->WriteObjectLibStatement(config); } else { - // If this target has cuda language link inputs, and we need to do - // device linking - this->WriteDeviceLinkStatement(config); firstForConfig = true; for (auto const& fileConfig : this->GetConfigNames()) { if (fileConfig != config && !this->GetGlobalGenerator()->EnableCrossConfigBuild()) { continue; } + // If this target has cuda language link inputs, and we need to do + // device linking + this->WriteDeviceLinkStatement(config, fileConfig, firstForConfig); this->WriteLinkStatement(config, fileConfig, firstForConfig); firstForConfig = false; } @@ -561,7 +561,8 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd( } void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement( - const std::string& config) + const std::string& config, const std::string& fileConfig, + bool firstForConfig) { cmGlobalNinjaGenerator* globalGen = this->GetGlobalGenerator(); if (!globalGen->GetLanguageEnabled("CUDA")) { @@ -584,12 +585,42 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement( std::string const& objExt = this->Makefile->GetSafeDefinition("CMAKE_CUDA_OUTPUT_EXTENSION"); - std::string const targetOutputReal = ConvertToNinjaPath( - genTarget->ObjectDirectory + "cmake_device_link" + objExt); + std::string targetOutputDir = + cmStrCat(this->GetLocalGenerator()->GetTargetDirectory(genTarget), + globalGen->ConfigDirectory(config), "/"); + targetOutputDir = globalGen->ExpandCFGIntDir(targetOutputDir, config); - std::string const targetOutputImplib = ConvertToNinjaPath( + std::string targetOutputReal = + ConvertToNinjaPath(targetOutputDir + "cmake_device_link" + objExt); + + std::string targetOutputImplib = ConvertToNinjaPath( genTarget->GetFullPath(config, cmStateEnums::ImportLibraryArtifact)); + if (config != fileConfig) { + std::string targetOutputFileConfigDir = + cmStrCat(this->GetLocalGenerator()->GetTargetDirectory(genTarget), + globalGen->ConfigDirectory(fileConfig), "/"); + targetOutputFileConfigDir = + globalGen->ExpandCFGIntDir(targetOutputDir, fileConfig); + if (targetOutputDir == targetOutputFileConfigDir) { + return; + } + + if (!genTarget->GetFullName(config, cmStateEnums::ImportLibraryArtifact) + .empty() && + !genTarget + ->GetFullName(fileConfig, cmStateEnums::ImportLibraryArtifact) + .empty() && + targetOutputImplib == + ConvertToNinjaPath(genTarget->GetFullPath( + fileConfig, cmStateEnums::ImportLibraryArtifact))) { + return; + } + } + + if (firstForConfig) { + globalGen->GetByproductsForCleanTarget(config).push_back(targetOutputReal); + } this->DeviceLinkObject = targetOutputReal; // Write comments. diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h index cda76d8..9de99b9 100644 --- a/Source/cmNinjaNormalTargetGenerator.h +++ b/Source/cmNinjaNormalTargetGenerator.h @@ -31,7 +31,9 @@ private: void WriteLinkStatement(const std::string& config, const std::string& fileConfig, bool firstForConfig); - void WriteDeviceLinkStatement(const std::string& config); + void WriteDeviceLinkStatement(const std::string& config, + const std::string& fileConfig, + bool firstForConfig); void WriteObjectLibStatement(const std::string& config); |