|
@@ -93,8 +93,8 @@ void cmExportCMakeConfigGenerator::GenerateInterfaceProperties(
|
|
|
cmStrCat(this->Namespace, target->GetExportName());
|
|
cmStrCat(this->Namespace, target->GetExportName());
|
|
|
os << "set_target_properties(" << targetName << " PROPERTIES\n";
|
|
os << "set_target_properties(" << targetName << " PROPERTIES\n";
|
|
|
for (auto const& property : properties) {
|
|
for (auto const& property : properties) {
|
|
|
- os << " " << property.first << " "
|
|
|
|
|
- << cmExportFileGeneratorEscape(property.second) << "\n";
|
|
|
|
|
|
|
+ os << " " << property.first << ' '
|
|
|
|
|
+ << cmExportFileGeneratorEscape(property.second) << '\n';
|
|
|
}
|
|
}
|
|
|
os << ")\n\n";
|
|
os << ")\n\n";
|
|
|
}
|
|
}
|
|
@@ -164,22 +164,22 @@ void cmExportCMakeConfigGenerator::GeneratePolicyHeaderCode(std::ostream& os)
|
|
|
{
|
|
{
|
|
|
// Protect that file against use with older CMake versions.
|
|
// Protect that file against use with older CMake versions.
|
|
|
/* clang-format off */
|
|
/* clang-format off */
|
|
|
- os << "# Generated by CMake\n\n";
|
|
|
|
|
- os << "if(\"${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}\" LESS 2.8)\n"
|
|
|
|
|
- << " message(FATAL_ERROR \"CMake >= "
|
|
|
|
|
|
|
+ os << "# Generated by CMake\n\n"
|
|
|
|
|
+ "if(\"${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}\" LESS 2.8)\n"
|
|
|
|
|
+ " message(FATAL_ERROR \"CMake >= "
|
|
|
<< this->RequiredCMakeVersionMajor << '.'
|
|
<< this->RequiredCMakeVersionMajor << '.'
|
|
|
<< this->RequiredCMakeVersionMinor << '.'
|
|
<< this->RequiredCMakeVersionMinor << '.'
|
|
|
<< this->RequiredCMakeVersionPatch << " required\")\n"
|
|
<< this->RequiredCMakeVersionPatch << " required\")\n"
|
|
|
- << "endif()\n"
|
|
|
|
|
- << "if(CMAKE_VERSION VERSION_LESS \""
|
|
|
|
|
|
|
+ "endif()\n"
|
|
|
|
|
+ "if(CMAKE_VERSION VERSION_LESS \""
|
|
|
<< this->RequiredCMakeVersionMajor << '.'
|
|
<< this->RequiredCMakeVersionMajor << '.'
|
|
|
<< this->RequiredCMakeVersionMinor << '.'
|
|
<< this->RequiredCMakeVersionMinor << '.'
|
|
|
<< this->RequiredCMakeVersionPatch << "\")\n"
|
|
<< this->RequiredCMakeVersionPatch << "\")\n"
|
|
|
- << " message(FATAL_ERROR \"CMake >= "
|
|
|
|
|
|
|
+ " message(FATAL_ERROR \"CMake >= "
|
|
|
<< this->RequiredCMakeVersionMajor << '.'
|
|
<< this->RequiredCMakeVersionMajor << '.'
|
|
|
<< this->RequiredCMakeVersionMinor << '.'
|
|
<< this->RequiredCMakeVersionMinor << '.'
|
|
|
<< this->RequiredCMakeVersionPatch << " required\")\n"
|
|
<< this->RequiredCMakeVersionPatch << " required\")\n"
|
|
|
- << "endif()\n";
|
|
|
|
|
|
|
+ "endif()\n";
|
|
|
/* clang-format on */
|
|
/* clang-format on */
|
|
|
|
|
|
|
|
// Isolate the file policy level.
|
|
// Isolate the file policy level.
|
|
@@ -191,7 +191,7 @@ void cmExportCMakeConfigGenerator::GeneratePolicyHeaderCode(std::ostream& os)
|
|
|
// versions.
|
|
// versions.
|
|
|
/* clang-format off */
|
|
/* clang-format off */
|
|
|
os << "cmake_policy(PUSH)\n"
|
|
os << "cmake_policy(PUSH)\n"
|
|
|
- << "cmake_policy(VERSION "
|
|
|
|
|
|
|
+ "cmake_policy(VERSION "
|
|
|
<< this->RequiredCMakeVersionMajor << '.'
|
|
<< this->RequiredCMakeVersionMajor << '.'
|
|
|
<< this->RequiredCMakeVersionMinor << '.'
|
|
<< this->RequiredCMakeVersionMinor << '.'
|
|
|
<< this->RequiredCMakeVersionPatch << "...3.30)\n";
|
|
<< this->RequiredCMakeVersionPatch << "...3.30)\n";
|
|
@@ -207,32 +207,30 @@ void cmExportCMakeConfigGenerator::GenerateImportHeaderCode(
|
|
|
std::ostream& os, std::string const& config)
|
|
std::ostream& os, std::string const& config)
|
|
|
{
|
|
{
|
|
|
os << "#----------------------------------------------------------------\n"
|
|
os << "#----------------------------------------------------------------\n"
|
|
|
- << "# Generated CMake target import file";
|
|
|
|
|
|
|
+ "# Generated CMake target import file";
|
|
|
if (!config.empty()) {
|
|
if (!config.empty()) {
|
|
|
os << " for configuration \"" << config << "\".\n";
|
|
os << " for configuration \"" << config << "\".\n";
|
|
|
} else {
|
|
} else {
|
|
|
os << ".\n";
|
|
os << ".\n";
|
|
|
}
|
|
}
|
|
|
os << "#----------------------------------------------------------------\n"
|
|
os << "#----------------------------------------------------------------\n"
|
|
|
- << "\n";
|
|
|
|
|
|
|
+ "\n";
|
|
|
this->GenerateImportVersionCode(os);
|
|
this->GenerateImportVersionCode(os);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void cmExportCMakeConfigGenerator::GenerateImportFooterCode(std::ostream& os)
|
|
void cmExportCMakeConfigGenerator::GenerateImportFooterCode(std::ostream& os)
|
|
|
{
|
|
{
|
|
|
os << "# Commands beyond this point should not need to know the version.\n"
|
|
os << "# Commands beyond this point should not need to know the version.\n"
|
|
|
- << "set(CMAKE_IMPORT_FILE_VERSION)\n";
|
|
|
|
|
|
|
+ "set(CMAKE_IMPORT_FILE_VERSION)\n";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void cmExportCMakeConfigGenerator::GenerateImportVersionCode(std::ostream& os)
|
|
void cmExportCMakeConfigGenerator::GenerateImportVersionCode(std::ostream& os)
|
|
|
{
|
|
{
|
|
|
// Store an import file format version. This will let us change the
|
|
// Store an import file format version. This will let us change the
|
|
|
// format later while still allowing old import files to work.
|
|
// format later while still allowing old import files to work.
|
|
|
- /* clang-format off */
|
|
|
|
|
os << "# Commands may need to know the format version.\n"
|
|
os << "# Commands may need to know the format version.\n"
|
|
|
- << "set(CMAKE_IMPORT_FILE_VERSION 1)\n"
|
|
|
|
|
- << "\n";
|
|
|
|
|
- /* clang-format on */
|
|
|
|
|
|
|
+ "set(CMAKE_IMPORT_FILE_VERSION 1)\n"
|
|
|
|
|
+ "\n";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void cmExportCMakeConfigGenerator::GenerateExpectedTargetsCode(
|
|
void cmExportCMakeConfigGenerator::GenerateExpectedTargetsCode(
|
|
@@ -355,7 +353,7 @@ void cmExportCMakeConfigGenerator::GenerateImportTargetCode(
|
|
|
os << "set_property(TARGET " << targetName << " PROPERTY SYSTEM 0)\n";
|
|
os << "set_property(TARGET " << targetName << " PROPERTY SYSTEM 0)\n";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- os << "\n";
|
|
|
|
|
|
|
+ os << '\n';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void cmExportCMakeConfigGenerator::GenerateImportPropertyCode(
|
|
void cmExportCMakeConfigGenerator::GenerateImportPropertyCode(
|
|
@@ -370,22 +368,24 @@ void cmExportCMakeConfigGenerator::GenerateImportPropertyCode(
|
|
|
|
|
|
|
|
// Set the import properties.
|
|
// Set the import properties.
|
|
|
os << "# Import target \"" << targetName << "\" for configuration \""
|
|
os << "# Import target \"" << targetName << "\" for configuration \""
|
|
|
- << config << "\"\n";
|
|
|
|
|
- os << "set_property(TARGET " << targetName
|
|
|
|
|
- << " APPEND PROPERTY IMPORTED_CONFIGURATIONS ";
|
|
|
|
|
|
|
+ << config
|
|
|
|
|
+ << "\"\n"
|
|
|
|
|
+ "set_property(TARGET "
|
|
|
|
|
+ << targetName << " APPEND PROPERTY IMPORTED_CONFIGURATIONS ";
|
|
|
if (!config.empty()) {
|
|
if (!config.empty()) {
|
|
|
os << cmSystemTools::UpperCase(config);
|
|
os << cmSystemTools::UpperCase(config);
|
|
|
} else {
|
|
} else {
|
|
|
os << "NOCONFIG";
|
|
os << "NOCONFIG";
|
|
|
}
|
|
}
|
|
|
- os << ")\n";
|
|
|
|
|
- os << "set_target_properties(" << targetName << " PROPERTIES\n";
|
|
|
|
|
|
|
+ os << ")\n"
|
|
|
|
|
+ "set_target_properties("
|
|
|
|
|
+ << targetName << " PROPERTIES\n";
|
|
|
std::string importedLocationProp = cmStrCat("IMPORTED_LOCATION", suffix);
|
|
std::string importedLocationProp = cmStrCat("IMPORTED_LOCATION", suffix);
|
|
|
for (auto const& property : properties) {
|
|
for (auto const& property : properties) {
|
|
|
if (importedXcFrameworkLocation.empty() ||
|
|
if (importedXcFrameworkLocation.empty() ||
|
|
|
property.first != importedLocationProp) {
|
|
property.first != importedLocationProp) {
|
|
|
- os << " " << property.first << " "
|
|
|
|
|
- << cmExportFileGeneratorEscape(property.second) << "\n";
|
|
|
|
|
|
|
+ os << " " << property.first << ' '
|
|
|
|
|
+ << cmExportFileGeneratorEscape(property.second) << '\n';
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
os << " )\n";
|
|
os << " )\n";
|
|
@@ -396,15 +396,15 @@ void cmExportCMakeConfigGenerator::GenerateImportPropertyCode(
|
|
|
<< cmExportFileGeneratorEscape(importedXcFrameworkLocation)
|
|
<< cmExportFileGeneratorEscape(importedXcFrameworkLocation)
|
|
|
<< ")\n"
|
|
<< ")\n"
|
|
|
" set_property(TARGET "
|
|
" set_property(TARGET "
|
|
|
- << targetName << " PROPERTY " << importedLocationProp << " "
|
|
|
|
|
|
|
+ << targetName << " PROPERTY " << importedLocationProp << ' '
|
|
|
<< cmExportFileGeneratorEscape(importedXcFrameworkLocation)
|
|
<< cmExportFileGeneratorEscape(importedXcFrameworkLocation)
|
|
|
<< ")\nelse()\n set_property(TARGET " << targetName << " PROPERTY "
|
|
<< ")\nelse()\n set_property(TARGET " << targetName << " PROPERTY "
|
|
|
- << importedLocationProp << " "
|
|
|
|
|
|
|
+ << importedLocationProp << ' '
|
|
|
<< cmExportFileGeneratorEscape(importedLocationIt->second)
|
|
<< cmExportFileGeneratorEscape(importedLocationIt->second)
|
|
|
<< ")\nendif()\n";
|
|
<< ")\nendif()\n";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- os << "\n";
|
|
|
|
|
|
|
+ os << '\n';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void cmExportCMakeConfigGenerator::GenerateFindDependencyCalls(
|
|
void cmExportCMakeConfigGenerator::GenerateFindDependencyCalls(
|
|
@@ -467,7 +467,7 @@ void cmExportCMakeConfigGenerator::GenerateFindDependencyCalls(
|
|
|
if (it.second.Enabled == cmExportSet::PackageDependencyExportEnabled::On) {
|
|
if (it.second.Enabled == cmExportSet::PackageDependencyExportEnabled::On) {
|
|
|
os << "find_dependency(" << it.first;
|
|
os << "find_dependency(" << it.first;
|
|
|
for (auto const& arg : it.second.ExtraArguments) {
|
|
for (auto const& arg : it.second.ExtraArguments) {
|
|
|
- os << " " << cmOutputConverter::EscapeForCMake(arg);
|
|
|
|
|
|
|
+ os << ' ' << cmOutputConverter::EscapeForCMake(arg);
|
|
|
}
|
|
}
|
|
|
os << ")\n";
|
|
os << ")\n";
|
|
|
}
|
|
}
|
|
@@ -479,26 +479,21 @@ void cmExportCMakeConfigGenerator::GenerateMissingTargetsCheckCode(
|
|
|
std::ostream& os)
|
|
std::ostream& os)
|
|
|
{
|
|
{
|
|
|
if (this->MissingTargets.empty()) {
|
|
if (this->MissingTargets.empty()) {
|
|
|
- /* clang-format off */
|
|
|
|
|
os << "# This file does not depend on other imported targets which have\n"
|
|
os << "# This file does not depend on other imported targets which have\n"
|
|
|
"# been exported from the same project but in a separate "
|
|
"# been exported from the same project but in a separate "
|
|
|
- "export set.\n\n";
|
|
|
|
|
- /* clang-format on */
|
|
|
|
|
|
|
+ "export set.\n\n";
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- /* clang-format off */
|
|
|
|
|
os << "# Make sure the targets which have been exported in some other\n"
|
|
os << "# Make sure the targets which have been exported in some other\n"
|
|
|
"# export set exist.\n"
|
|
"# export set exist.\n"
|
|
|
"unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)\n"
|
|
"unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)\n"
|
|
|
"foreach(_target ";
|
|
"foreach(_target ";
|
|
|
- /* clang-format on */
|
|
|
|
|
std::set<std::string> emitted;
|
|
std::set<std::string> emitted;
|
|
|
for (std::string const& missingTarget : this->MissingTargets) {
|
|
for (std::string const& missingTarget : this->MissingTargets) {
|
|
|
if (emitted.insert(missingTarget).second) {
|
|
if (emitted.insert(missingTarget).second) {
|
|
|
- os << "\"" << missingTarget << "\" ";
|
|
|
|
|
|
|
+ os << '"' << missingTarget << "\" ";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- /* clang-format off */
|
|
|
|
|
os << ")\n"
|
|
os << ")\n"
|
|
|
" if(NOT TARGET \"${_target}\" )\n"
|
|
" if(NOT TARGET \"${_target}\" )\n"
|
|
|
" set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets \""
|
|
" set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets \""
|
|
@@ -513,16 +508,15 @@ void cmExportCMakeConfigGenerator::GenerateMissingTargetsCheckCode(
|
|
|
" set( ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "
|
|
" set( ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "
|
|
|
"\"The following imported targets are "
|
|
"\"The following imported targets are "
|
|
|
"referenced, but are missing: "
|
|
"referenced, but are missing: "
|
|
|
- "${${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets}\")\n"
|
|
|
|
|
|
|
+ "${${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets}\")\n"
|
|
|
" else()\n"
|
|
" else()\n"
|
|
|
" message(FATAL_ERROR \"The following imported targets are "
|
|
" message(FATAL_ERROR \"The following imported targets are "
|
|
|
"referenced, but are missing: "
|
|
"referenced, but are missing: "
|
|
|
- "${${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets}\")\n"
|
|
|
|
|
|
|
+ "${${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets}\")\n"
|
|
|
" endif()\n"
|
|
" endif()\n"
|
|
|
"endif()\n"
|
|
"endif()\n"
|
|
|
"unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)\n"
|
|
"unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE_targets)\n"
|
|
|
"\n";
|
|
"\n";
|
|
|
- /* clang-format on */
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void cmExportCMakeConfigGenerator::GenerateImportedFileCheckLoop(
|
|
void cmExportCMakeConfigGenerator::GenerateImportedFileCheckLoop(
|
|
@@ -535,7 +529,6 @@ void cmExportCMakeConfigGenerator::GenerateImportedFileCheckLoop(
|
|
|
// the non-development package, something similar happened to me without
|
|
// the non-development package, something similar happened to me without
|
|
|
// on SUSE with a mysql pkg-config file, which claimed everything is fine,
|
|
// on SUSE with a mysql pkg-config file, which claimed everything is fine,
|
|
|
// but the development package was not installed.).
|
|
// but the development package was not installed.).
|
|
|
- /* clang-format off */
|
|
|
|
|
os << "# Loop over all imported files and verify that they actually exist\n"
|
|
os << "# Loop over all imported files and verify that they actually exist\n"
|
|
|
"foreach(_cmake_target IN LISTS _cmake_import_check_targets)\n"
|
|
"foreach(_cmake_target IN LISTS _cmake_import_check_targets)\n"
|
|
|
" if(CMAKE_VERSION VERSION_LESS \"3.28\"\n"
|
|
" if(CMAKE_VERSION VERSION_LESS \"3.28\"\n"
|
|
@@ -565,7 +558,6 @@ void cmExportCMakeConfigGenerator::GenerateImportedFileCheckLoop(
|
|
|
"unset(_cmake_target)\n"
|
|
"unset(_cmake_target)\n"
|
|
|
"unset(_cmake_import_check_targets)\n"
|
|
"unset(_cmake_import_check_targets)\n"
|
|
|
"\n";
|
|
"\n";
|
|
|
- /* clang-format on */
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void cmExportCMakeConfigGenerator::GenerateImportedFileChecksCode(
|
|
void cmExportCMakeConfigGenerator::GenerateImportedFileChecksCode(
|
|
@@ -582,12 +574,12 @@ void cmExportCMakeConfigGenerator::GenerateImportedFileChecksCode(
|
|
|
os << "set(_cmake_import_check_xcframework_for_" << targetName << ' '
|
|
os << "set(_cmake_import_check_xcframework_for_" << targetName << ' '
|
|
|
<< cmExportFileGeneratorEscape(importedXcFrameworkLocation) << ")\n";
|
|
<< cmExportFileGeneratorEscape(importedXcFrameworkLocation) << ")\n";
|
|
|
}
|
|
}
|
|
|
- os << "list(APPEND _cmake_import_check_files_for_" << targetName << " ";
|
|
|
|
|
|
|
+ os << "list(APPEND _cmake_import_check_files_for_" << targetName << ' ';
|
|
|
|
|
|
|
|
for (std::string const& li : importedLocations) {
|
|
for (std::string const& li : importedLocations) {
|
|
|
auto pi = properties.find(li);
|
|
auto pi = properties.find(li);
|
|
|
if (pi != properties.end()) {
|
|
if (pi != properties.end()) {
|
|
|
- os << cmExportFileGeneratorEscape(pi->second) << " ";
|
|
|
|
|
|
|
+ os << cmExportFileGeneratorEscape(pi->second) << ' ';
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -602,7 +594,7 @@ void cmExportCMakeConfigGenerator::GenerateTargetFileSets(
|
|
|
std::string targetName = cmStrCat(this->Namespace, gte->GetExportName());
|
|
std::string targetName = cmStrCat(this->Namespace, gte->GetExportName());
|
|
|
os << "if(NOT CMAKE_VERSION VERSION_LESS \"3.23.0\")\n"
|
|
os << "if(NOT CMAKE_VERSION VERSION_LESS \"3.23.0\")\n"
|
|
|
" target_sources("
|
|
" target_sources("
|
|
|
- << targetName << "\n";
|
|
|
|
|
|
|
+ << targetName << '\n';
|
|
|
|
|
|
|
|
for (auto const& name : interfaceFileSets) {
|
|
for (auto const& name : interfaceFileSets) {
|
|
|
auto* fileSet = gte->Target->GetFileSet(name);
|
|
auto* fileSet = gte->Target->GetFileSet(name);
|
|
@@ -621,7 +613,7 @@ void cmExportCMakeConfigGenerator::GenerateTargetFileSets(
|
|
|
<< cmOutputConverter::EscapeForCMake(fileSet->GetType())
|
|
<< cmOutputConverter::EscapeForCMake(fileSet->GetType())
|
|
|
<< "\n BASE_DIRS "
|
|
<< "\n BASE_DIRS "
|
|
|
<< this->GetFileSetDirectories(gte, fileSet, te) << "\n FILES "
|
|
<< this->GetFileSetDirectories(gte, fileSet, te) << "\n FILES "
|
|
|
- << this->GetFileSetFiles(gte, fileSet, te) << "\n";
|
|
|
|
|
|
|
+ << this->GetFileSetFiles(gte, fileSet, te) << '\n';
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
os << " )\nelse()\n set_property(TARGET " << targetName
|
|
os << " )\nelse()\n set_property(TARGET " << targetName
|
|
@@ -667,8 +659,8 @@ void cmExportCMakeConfigGenerator::GenerateCxxModuleInformation(
|
|
|
|
|
|
|
|
// Write the include.
|
|
// Write the include.
|
|
|
os << "# Include C++ module properties\n"
|
|
os << "# Include C++ module properties\n"
|
|
|
- << "include(\"${CMAKE_CURRENT_LIST_DIR}/" << cxx_module_dirname
|
|
|
|
|
- << "/cxx-modules-" << name << ".cmake\")\n\n";
|
|
|
|
|
|
|
+ "include(\"${CMAKE_CURRENT_LIST_DIR}/"
|
|
|
|
|
+ << cxx_module_dirname << "/cxx-modules-" << name << ".cmake\")\n\n";
|
|
|
|
|
|
|
|
// Include all configuration-specific include files.
|
|
// Include all configuration-specific include files.
|
|
|
cmGeneratedFileStream ap(this->GetCxxModuleFile(name), true);
|
|
cmGeneratedFileStream ap(this->GetCxxModuleFile(name), true);
|