| 2599 | } |
| 2600 | |
| 2601 | void cmGeneratorTarget::AddCUDAArchitectureFlagsImpl(cmBuildStep compileOrLink, |
| 2602 | std::string const& config, |
| 2603 | std::string const& lang, |
| 2604 | std::string arch, |
| 2605 | std::string& flags) const |
| 2606 | { |
| 2607 | std::string const& compiler = this->Makefile->GetSafeDefinition( |
| 2608 | cmStrCat("CMAKE_", lang, "_COMPILER_ID")); |
| 2609 | bool const ipoEnabled = this->IsIPOEnabled(lang, config); |
| 2610 | |
| 2611 | // Check for special modes: `all`, `all-major`. |
| 2612 | if (arch == "all" || arch == "all-major") { |
| 2613 | if (compiler == "NVIDIA" && |
| 2614 | cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER_EQUAL, |
| 2615 | this->Makefile->GetDefinition(cmStrCat( |
| 2616 | "CMAKE_", lang, "_COMPILER_VERSION")), |
| 2617 | "11.5")) { |
| 2618 | flags = cmStrCat(flags, " -arch=", arch); |
| 2619 | return; |
| 2620 | } |
| 2621 | if (arch == "all") { |
| 2622 | arch = *this->Makefile->GetDefinition( |
| 2623 | cmStrCat("CMAKE_", lang, "_ARCHITECTURES_ALL")); |
| 2624 | } else if (arch == "all-major") { |
| 2625 | arch = *this->Makefile->GetDefinition( |
| 2626 | cmStrCat("CMAKE_", lang, "_ARCHITECTURES_ALL_MAJOR")); |
| 2627 | } |
| 2628 | } else if (arch == "native") { |
| 2629 | cmValue native = this->Makefile->GetDefinition( |
| 2630 | cmStrCat("CMAKE_", lang, "_ARCHITECTURES_NATIVE")); |
| 2631 | if (native.IsEmpty()) { |
| 2632 | this->Makefile->IssueMessage( |
| 2633 | MessageType::FATAL_ERROR, |
| 2634 | cmStrCat(lang, |
| 2635 | "_ARCHITECTURES is set to \"native\", but no NVIDIA GPU was " |
| 2636 | "detected.")); |
| 2637 | } |
| 2638 | if (compiler == "NVIDIA" && |
| 2639 | cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER_EQUAL, |
| 2640 | this->Makefile->GetDefinition(cmStrCat( |
| 2641 | "CMAKE_", lang, "_COMPILER_VERSION")), |
| 2642 | "11.6")) { |
| 2643 | flags = cmStrCat(flags, " -arch=", arch); |
| 2644 | return; |
| 2645 | } |
| 2646 | arch = *native; |
| 2647 | } |
| 2648 | |
| 2649 | struct CudaArchitecture |
| 2650 | { |
| 2651 | std::string name; |
| 2652 | bool real{ true }; |
| 2653 | bool virtual_{ true }; |
| 2654 | }; |
| 2655 | std::vector<CudaArchitecture> architectures; |
| 2656 | |
| 2657 | { |
| 2658 | cmList options(arch); |
no test coverage detected