| 980 | } |
| 981 | |
| 982 | void cmNinjaTargetGenerator::WriteObjectBuildStatements( |
| 983 | std::string const& config, std::string const& fileConfig, |
| 984 | bool firstForConfig) |
| 985 | { |
| 986 | this->GeneratorTarget->CheckCxxModuleStatus(config); |
| 987 | |
| 988 | // Write comments. |
| 989 | cmGlobalNinjaGenerator::WriteDivider(this->GetImplFileStream(fileConfig)); |
| 990 | this->GetImplFileStream(fileConfig) |
| 991 | << "# Object build statements for " |
| 992 | << cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType()) |
| 993 | << " target " << this->GetTargetName() << "\n\n"; |
| 994 | |
| 995 | std::vector<cmCustomCommand const*> customCommands; |
| 996 | { |
| 997 | std::vector<cmSourceFile const*> customCommandSources; |
| 998 | this->GeneratorTarget->GetCustomCommands(customCommandSources, config); |
| 999 | for (cmSourceFile const* sf : customCommandSources) { |
| 1000 | cmCustomCommand const* cc = sf->GetCustomCommand(); |
| 1001 | this->GetLocalGenerator()->AddCustomCommandTarget( |
| 1002 | cc, this->GetGeneratorTarget()); |
| 1003 | customCommands.push_back(cc); |
| 1004 | } |
| 1005 | } |
| 1006 | { |
| 1007 | std::vector<cmSourceFile const*> headerSources; |
| 1008 | this->GeneratorTarget->GetHeaderSources(headerSources, config); |
| 1009 | this->OSXBundleGenerator->GenerateMacOSXContentStatements( |
| 1010 | headerSources, this->Configs[fileConfig].MacOSXContentGenerator.get(), |
| 1011 | config); |
| 1012 | } |
| 1013 | { |
| 1014 | std::vector<cmSourceFile const*> extraSources; |
| 1015 | this->GeneratorTarget->GetExtraSources(extraSources, config); |
| 1016 | this->OSXBundleGenerator->GenerateMacOSXContentStatements( |
| 1017 | extraSources, this->Configs[fileConfig].MacOSXContentGenerator.get(), |
| 1018 | config); |
| 1019 | } |
| 1020 | if (firstForConfig) { |
| 1021 | cmValue pchExtension = |
| 1022 | this->GetMakefile()->GetDefinition("CMAKE_PCH_EXTENSION"); |
| 1023 | |
| 1024 | std::vector<cmSourceFile const*> externalObjects; |
| 1025 | this->GeneratorTarget->GetExternalObjects(externalObjects, config); |
| 1026 | for (cmSourceFile const* sf : externalObjects) { |
| 1027 | auto objectFileName = this->GetGlobalGenerator()->ExpandCFGIntDir( |
| 1028 | this->ConvertToNinjaPath(sf->GetFullPath()), config); |
| 1029 | if (!cmHasSuffix(objectFileName, pchExtension)) { |
| 1030 | this->Configs[config].Objects.push_back(objectFileName); |
| 1031 | } |
| 1032 | } |
| 1033 | } |
| 1034 | |
| 1035 | if (!this->GetGlobalGenerator()->SupportsCWDDepend()) { |
| 1036 | // Ensure that the object directory exists. If there are no objects in the |
| 1037 | // target (e.g., an empty `OBJECT` library), the directory is still listed |
| 1038 | // as an order-only depends in the build files. Alternate `ninja` |
| 1039 | // implementations may not allow this (such as `samu`). See #25526. |
no test coverage detected