Skip to content

Commit

Permalink
generated-cmake: use _cmake_ prefixes for local variables
Browse files Browse the repository at this point in the history
This avoids stomping on any user variables.
  • Loading branch information
mathstuf committed Apr 20, 2022
1 parent a2cb175 commit 59cc920
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
56 changes: 28 additions & 28 deletions Source/cmExportFileGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -985,34 +985,34 @@ void cmExportFileGenerator::GenerateExpectedTargetsCode(
/* clang-format off */
os << "# Protect against multiple inclusion, which would fail when already "
"imported targets are added once more.\n"
"set(_targetsDefined)\n"
"set(_targetsNotDefined)\n"
"set(_expectedTargets)\n"
"foreach(_expectedTarget " << expectedTargets << ")\n"
" list(APPEND _expectedTargets ${_expectedTarget})\n"
" if(NOT TARGET ${_expectedTarget})\n"
" list(APPEND _targetsNotDefined ${_expectedTarget})\n"
"set(_cmake_targets_defined)\n"
"set(_cmake_targets_not_defined)\n"
"set(_cmake_expected_targets)\n"
"foreach(_cmake_expected_target " << expectedTargets << ")\n"
" list(APPEND _cmake_expected_targets ${_cmake_expected_target})\n"
" if(NOT TARGET ${_cmake_expected_target})\n"
" list(APPEND _cmake_targets_not_defined ${_cmake_expected_target})\n"
" endif()\n"
" if(TARGET ${_expectedTarget})\n"
" list(APPEND _targetsDefined ${_expectedTarget})\n"
" if(TARGET ${_cmake_expected_target})\n"
" list(APPEND _cmake_targets_defined ${_cmake_expected_target})\n"
" endif()\n"
"endforeach()\n"
"if(\"${_targetsDefined}\" STREQUAL \"${_expectedTargets}\")\n"
" unset(_targetsDefined)\n"
" unset(_targetsNotDefined)\n"
" unset(_expectedTargets)\n"
"if(\"${_cmake_targets_defined}\" STREQUAL \"${_cmake_expected_targets}\")\n"
" unset(_cmake_targets_defined)\n"
" unset(_cmake_targets_not_defined)\n"
" unset(_cmake_expected_targets)\n"
" set(CMAKE_IMPORT_FILE_VERSION)\n"
" cmake_policy(POP)\n"
" return()\n"
"endif()\n"
"if(NOT \"${_targetsDefined}\" STREQUAL \"\")\n"
"if(NOT \"${_cmake_targets_defined}\" STREQUAL \"\")\n"
" message(FATAL_ERROR \"Some (but not all) targets in this export "
"set were already defined.\\nTargets Defined: ${_targetsDefined}\\n"
"Targets not yet defined: ${_targetsNotDefined}\\n\")\n"
"set were already defined.\\nTargets Defined: ${_cmake_targets_defined}\\n"
"Targets not yet defined: ${_cmake_targets_not_defined}\\n\")\n"
"endif()\n"
"unset(_targetsDefined)\n"
"unset(_targetsNotDefined)\n"
"unset(_expectedTargets)\n"
"unset(_cmake_targets_defined)\n"
"unset(_cmake_targets_not_defined)\n"
"unset(_cmake_expected_targets)\n"
"\n\n";
/* clang-format on */
}
Expand Down Expand Up @@ -1178,12 +1178,12 @@ void cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os)
// but the development package was not installed.).
/* clang-format off */
os << "# Loop over all imported files and verify that they actually exist\n"
"foreach(target ${_IMPORT_CHECK_TARGETS} )\n"
" foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )\n"
" if(NOT EXISTS \"${file}\" )\n"
" message(FATAL_ERROR \"The imported target \\\"${target}\\\""
"foreach(_cmake_target IN LISTS _cmake_import_check_targets)\n"
" foreach(_cmake_file IN LISTS \"_cmake_import_check_files_for_${_cmake_target}\")\n"
" if(NOT EXISTS \"${_cmake_file}\")\n"
" message(FATAL_ERROR \"The imported target \\\"${_cmake_target}\\\""
" references the file\n"
" \\\"${file}\\\"\n"
" \\\"${_cmake_file}\\\"\n"
"but this file does not exist. Possible reasons include:\n"
"* The file was deleted, renamed, or moved to another location.\n"
"* An install or uninstall procedure did not complete successfully.\n"
Expand All @@ -1193,9 +1193,9 @@ void cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os)
"\")\n"
" endif()\n"
" endforeach()\n"
" unset(_IMPORT_CHECK_FILES_FOR_${target})\n"
" unset(\"_cmake_import_check_files_for_${_cmake_target}\")\n"
"endforeach()\n"
"unset(_IMPORT_CHECK_TARGETS)\n"
"unset(_cmake_import_check_targets)\n"
"\n";
/* clang-format on */
}
Expand All @@ -1208,9 +1208,9 @@ void cmExportFileGenerator::GenerateImportedFileChecksCode(
// Construct the imported target name.
std::string targetName = cmStrCat(this->Namespace, target->GetExportName());

os << "list(APPEND _IMPORT_CHECK_TARGETS " << targetName
os << "list(APPEND _cmake_import_check_targets " << targetName
<< " )\n"
"list(APPEND _IMPORT_CHECK_FILES_FOR_"
"list(APPEND _cmake_import_check_files_for_"
<< targetName << " ";

for (std::string const& li : importedLocations) {
Expand Down
6 changes: 3 additions & 3 deletions Source/cmExportInstallFileGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@ void cmExportInstallFileGenerator::LoadConfigFiles(std::ostream& os)
/* clang-format off */
os << "# Load information for each installed configuration.\n"
<< "get_filename_component(_DIR \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"
<< "file(GLOB CONFIG_FILES \"${_DIR}/"
<< "file(GLOB _cmake_config_files \"${_DIR}/"
<< this->GetConfigImportFileGlob() << "\")\n"
<< "foreach(f ${CONFIG_FILES})\n"
<< " include(${f})\n"
<< "foreach(_cmake_config_file ${_cmake_config_files})\n"
<< " include(${_cmake_config_file})\n"
<< "endforeach()\n"
<< "\n";
/* clang-format on */
Expand Down
12 changes: 6 additions & 6 deletions Source/cmInstallExportGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,16 @@ void cmInstallExportGenerator::GenerateScriptActions(std::ostream& os,
Indent indentNN = indentN.Next();
Indent indentNNN = indentNN.Next();
/* clang-format off */
os << indentN << "file(DIFFERENT EXPORT_FILE_CHANGED FILES\n"
os << indentN << "file(DIFFERENT _cmake_export_file_changed FILES\n"
<< indentN << " \"" << installedFile << "\"\n"
<< indentN << " \"" << this->MainImportFile << "\")\n";
os << indentN << "if(EXPORT_FILE_CHANGED)\n";
os << indentNN << "file(GLOB OLD_CONFIG_FILES \"" << installedDir
os << indentN << "if(_cmake_export_file_changed)\n";
os << indentNN << "file(GLOB _cmake_old_config_files \"" << installedDir
<< this->EFGen->GetConfigImportFileGlob() << "\")\n";
os << indentNN << "if(OLD_CONFIG_FILES)\n";
os << indentNN << "if(_cmake_old_config_files)\n";
os << indentNNN << R"(message(STATUS "Old export file \")" << installedFile
<< "\\\" will be replaced. Removing files [${OLD_CONFIG_FILES}].\")\n";
os << indentNNN << "file(REMOVE ${OLD_CONFIG_FILES})\n";
<< "\\\" will be replaced. Removing files [${_cmake_old_config_files}].\")\n";
os << indentNNN << "file(REMOVE ${_cmake_old_config_files})\n";
os << indentNN << "endif()\n";
os << indentN << "endif()\n";
os << indent << "endif()\n";
Expand Down

0 comments on commit 59cc920

Please sign in to comment.