Generate new-style cmake code during export.

Use empty end*() commands and lowercase commands.
This commit is contained in:
Stephen Kelly 2013-01-20 18:02:13 +01:00
parent 35fbe4e4bc
commit 02d4e53f48
2 changed files with 72 additions and 72 deletions

View File

@ -81,16 +81,16 @@ bool cmExportFileGenerator::GenerateImportFile()
// Protect that file against use with older CMake versions. // Protect that file against use with older CMake versions.
os << "# Generated by CMake " << cmVersion::GetCMakeVersion() << "\n\n"; os << "# Generated by CMake " << cmVersion::GetCMakeVersion() << "\n\n";
os << "IF(\"${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}\" LESS 2.5)\n" os << "if(\"${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}\" LESS 2.5)\n"
<< " MESSAGE(FATAL_ERROR \"CMake >= 2.6.0 required\")\n" << " message(FATAL_ERROR \"CMake >= 2.6.0 required\")\n"
<< "ENDIF(\"${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}\" LESS 2.5)\n"; << "endif()\n";
// Isolate the file policy level. // Isolate the file policy level.
// We use 2.6 here instead of the current version because newer // We use 2.6 here instead of the current version because newer
// versions of CMake should be able to export files imported by 2.6 // versions of CMake should be able to export files imported by 2.6
// until the import format changes. // until the import format changes.
os << "CMAKE_POLICY(PUSH)\n" os << "cmake_policy(PUSH)\n"
<< "CMAKE_POLICY(VERSION 2.6)\n"; << "cmake_policy(VERSION 2.6)\n";
// Start with the import file header. // Start with the import file header.
this->GenerateImportHeaderCode(os); this->GenerateImportHeaderCode(os);
@ -100,7 +100,7 @@ bool cmExportFileGenerator::GenerateImportFile()
// End with the import file footer. // End with the import file footer.
this->GenerateImportFooterCode(os); this->GenerateImportFooterCode(os);
os << "CMAKE_POLICY(POP)\n"; os << "cmake_policy(POP)\n";
return result; return result;
} }
@ -186,7 +186,7 @@ void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget *target,
{ {
std::string targetName = this->Namespace; std::string targetName = this->Namespace;
targetName += target->GetName(); targetName += target->GetName();
os << "SET_TARGET_PROPERTIES(" << targetName << " PROPERTIES\n"; os << "set_target_properties(" << targetName << " PROPERTIES\n";
for(ImportPropertyMap::const_iterator pi = properties.begin(); for(ImportPropertyMap::const_iterator pi = properties.begin();
pi != properties.end(); ++pi) pi != properties.end(); ++pi)
{ {
@ -536,7 +536,7 @@ void cmExportFileGenerator::GenerateImportHeaderCode(std::ostream& os,
void cmExportFileGenerator::GenerateImportFooterCode(std::ostream& os) void cmExportFileGenerator::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";
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -545,7 +545,7 @@ void cmExportFileGenerator::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.
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" << "set(CMAKE_IMPORT_FILE_VERSION 1)\n"
<< "\n"; << "\n";
} }
@ -553,31 +553,31 @@ void cmExportFileGenerator::GenerateImportVersionCode(std::ostream& os)
void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os, void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os,
const std::string &expectedTargets) const std::string &expectedTargets)
{ {
os << "SET(_targetsDefined)\n" os << "set(_targetsDefined)\n"
"SET(_targetsNotDefined)\n" "set(_targetsNotDefined)\n"
"SET(_expectedTargets)\n" "set(_expectedTargets)\n"
"FOREACH(_expectedTarget " << expectedTargets << ")\n" "foreach(_expectedTarget " << expectedTargets << ")\n"
" LIST(APPEND _expectedTargets ${_expectedTarget})\n" " list(APPEND _expectedTargets ${_expectedTarget})\n"
" IF(NOT TARGET ${_expectedTarget})\n" " if(NOT TARGET ${_expectedTarget})\n"
" LIST(APPEND _targetsNotDefined ${_expectedTarget})\n" " list(APPEND _targetsNotDefined ${_expectedTarget})\n"
" ENDIF(NOT TARGET ${_expectedTarget})\n" " endif()\n"
" IF(TARGET ${_expectedTarget})\n" " if(TARGET ${_expectedTarget})\n"
" LIST(APPEND _targetsDefined ${_expectedTarget})\n" " list(APPEND _targetsDefined ${_expectedTarget})\n"
" ENDIF(TARGET ${_expectedTarget})\n" " endif()\n"
"ENDFOREACH(_expectedTarget)\n" "endforeach()\n"
"IF(\"${_targetsDefined}\" STREQUAL \"${_expectedTargets}\")\n" "if(\"${_targetsDefined}\" STREQUAL \"${_expectedTargets}\")\n"
" SET(CMAKE_IMPORT_FILE_VERSION)\n" " set(CMAKE_IMPORT_FILE_VERSION)\n"
" CMAKE_POLICY(POP)\n" " cmake_policy(POP)\n"
" RETURN()\n" " return()\n"
"ENDIF(\"${_targetsDefined}\" STREQUAL \"${_expectedTargets}\")\n" "endif()\n"
"IF(NOT \"${_targetsDefined}\" STREQUAL \"\")\n" "if(NOT \"${_targetsDefined}\" STREQUAL \"\")\n"
" MESSAGE(FATAL_ERROR \"Some (but not all) targets in this export " " message(FATAL_ERROR \"Some (but not all) targets in this export "
"set were already defined.\\nTargets Defined: ${_targetsDefined}\\n" "set were already defined.\\nTargets Defined: ${_targetsDefined}\\n"
"Targets not yet defined: ${_targetsNotDefined}\\n\")\n" "Targets not yet defined: ${_targetsNotDefined}\\n\")\n"
"ENDIF(NOT \"${_targetsDefined}\" STREQUAL \"\")\n" "endif()\n"
"UNSET(_targetsDefined)\n" "unset(_targetsDefined)\n"
"UNSET(_targetsNotDefined)\n" "unset(_targetsNotDefined)\n"
"UNSET(_expectedTargets)\n" "unset(_expectedTargets)\n"
"\n\n"; "\n\n";
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -594,16 +594,16 @@ cmExportFileGenerator
switch(target->GetType()) switch(target->GetType())
{ {
case cmTarget::EXECUTABLE: case cmTarget::EXECUTABLE:
os << "ADD_EXECUTABLE(" << targetName << " IMPORTED)\n"; os << "add_executable(" << targetName << " IMPORTED)\n";
break; break;
case cmTarget::STATIC_LIBRARY: case cmTarget::STATIC_LIBRARY:
os << "ADD_LIBRARY(" << targetName << " STATIC IMPORTED)\n"; os << "add_library(" << targetName << " STATIC IMPORTED)\n";
break; break;
case cmTarget::SHARED_LIBRARY: case cmTarget::SHARED_LIBRARY:
os << "ADD_LIBRARY(" << targetName << " SHARED IMPORTED)\n"; os << "add_library(" << targetName << " SHARED IMPORTED)\n";
break; break;
case cmTarget::MODULE_LIBRARY: case cmTarget::MODULE_LIBRARY:
os << "ADD_LIBRARY(" << targetName << " MODULE IMPORTED)\n"; os << "add_library(" << targetName << " MODULE IMPORTED)\n";
break; break;
default: // should never happen default: // should never happen
break; break;
@ -612,27 +612,27 @@ cmExportFileGenerator
// Mark the imported executable if it has exports. // Mark the imported executable if it has exports.
if(target->IsExecutableWithExports()) if(target->IsExecutableWithExports())
{ {
os << "SET_PROPERTY(TARGET " << targetName os << "set_property(TARGET " << targetName
<< " PROPERTY ENABLE_EXPORTS 1)\n"; << " PROPERTY ENABLE_EXPORTS 1)\n";
} }
// Mark the imported library if it is a framework. // Mark the imported library if it is a framework.
if(target->IsFrameworkOnApple()) if(target->IsFrameworkOnApple())
{ {
os << "SET_PROPERTY(TARGET " << targetName os << "set_property(TARGET " << targetName
<< " PROPERTY FRAMEWORK 1)\n"; << " PROPERTY FRAMEWORK 1)\n";
} }
// Mark the imported executable if it is an application bundle. // Mark the imported executable if it is an application bundle.
if(target->IsAppBundleOnApple()) if(target->IsAppBundleOnApple())
{ {
os << "SET_PROPERTY(TARGET " << targetName os << "set_property(TARGET " << targetName
<< " PROPERTY MACOSX_BUNDLE 1)\n"; << " PROPERTY MACOSX_BUNDLE 1)\n";
} }
if (target->IsCFBundleOnApple()) if (target->IsCFBundleOnApple())
{ {
os << "SET_PROPERTY(TARGET " << targetName os << "set_property(TARGET " << targetName
<< " PROPERTY BUNDLE 1)\n"; << " PROPERTY BUNDLE 1)\n";
} }
os << "\n"; os << "\n";
@ -652,7 +652,7 @@ cmExportFileGenerator
// Set the import properties. // Set the import properties.
os << "# Import target \"" << targetName << "\" for configuration \"" os << "# Import target \"" << targetName << "\" for configuration \""
<< config << "\"\n"; << config << "\"\n";
os << "SET_PROPERTY(TARGET " << targetName os << "set_property(TARGET " << targetName
<< " APPEND PROPERTY IMPORTED_CONFIGURATIONS "; << " APPEND PROPERTY IMPORTED_CONFIGURATIONS ";
if(config && *config) if(config && *config)
{ {
@ -663,7 +663,7 @@ cmExportFileGenerator
os << "NOCONFIG"; os << "NOCONFIG";
} }
os << ")\n"; os << ")\n";
os << "SET_TARGET_PROPERTIES(" << targetName << " PROPERTIES\n"; os << "set_target_properties(" << targetName << " PROPERTIES\n";
for(ImportPropertyMap::const_iterator pi = properties.begin(); for(ImportPropertyMap::const_iterator pi = properties.begin();
pi != properties.end(); ++pi) pi != properties.end(); ++pi)
{ {
@ -689,17 +689,17 @@ void cmExportFileGenerator::GenerateMissingTargetsCheckCode(std::ostream& os,
{ {
if (emitted.insert(missingTargets[i]).second) if (emitted.insert(missingTargets[i]).second)
{ {
os << "IF(NOT TARGET \"" << missingTargets[i] << "\" )\n" os << "if(NOT TARGET \"" << missingTargets[i] << "\" )\n"
<< " IF(CMAKE_FIND_PACKAGE_NAME)\n" << " if(CMAKE_FIND_PACKAGE_NAME)\n"
<< " SET( ${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)\n" << " set( ${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)\n"
<< " SET( ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE " << " set( ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "
<< "\"Required imported target \\\"" << missingTargets[i] << "\"Required imported target \\\"" << missingTargets[i]
<< "\\\" not found ! \")\n" << "\\\" not found ! \")\n"
<< " ELSE()\n" << " else()\n"
<< " MESSAGE(FATAL_ERROR \"Required imported target \\\"" << " message(FATAL_ERROR \"Required imported target \\\""
<< missingTargets[i] << "\\\" not found ! \")\n" << missingTargets[i] << "\\\" not found ! \")\n"
<< " ENDIF()\n" << " endif()\n"
<< "ENDIF()\n"; << "endif()\n";
} }
} }
os << "\n"; os << "\n";
@ -718,10 +718,10 @@ cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os)
// 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.).
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(target ${_IMPORT_CHECK_TARGETS} )\n" "foreach(target ${_IMPORT_CHECK_TARGETS} )\n"
" FOREACH(file ${_IMPORT_CHECK_FILES_FOR_${target}} )\n" " foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )\n"
" IF(NOT EXISTS \"${file}\" )\n" " if(NOT EXISTS \"${file}\" )\n"
" MESSAGE(FATAL_ERROR \"The imported target \\\"${target}\\\"" " message(FATAL_ERROR \"The imported target \\\"${target}\\\""
" references the file\n" " references the file\n"
" \\\"${file}\\\"\n" " \\\"${file}\\\"\n"
"but this file does not exist. Possible reasons include:\n" "but this file does not exist. Possible reasons include:\n"
@ -731,11 +731,11 @@ cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os)
" \\\"${CMAKE_CURRENT_LIST_FILE}\\\"\n" " \\\"${CMAKE_CURRENT_LIST_FILE}\\\"\n"
"but not all the files it references.\n" "but not all the files it references.\n"
"\")\n" "\")\n"
" ENDIF()\n" " endif()\n"
" ENDFOREACH()\n" " endforeach()\n"
" UNSET(_IMPORT_CHECK_FILES_FOR_${target})\n" " unset(_IMPORT_CHECK_FILES_FOR_${target})\n"
"ENDFOREACH()\n" "endforeach()\n"
"UNSET(_IMPORT_CHECK_TARGETS)\n" "unset(_IMPORT_CHECK_TARGETS)\n"
"\n"; "\n";
} }
@ -751,8 +751,8 @@ cmExportFileGenerator
std::string targetName = this->Namespace; std::string targetName = this->Namespace;
targetName += target->GetName(); targetName += target->GetName();
os << "LIST(APPEND _IMPORT_CHECK_TARGETS " << targetName << " )\n" os << "list(APPEND _IMPORT_CHECK_TARGETS " << targetName << " )\n"
"LIST(APPEND _IMPORT_CHECK_FILES_FOR_" << targetName << " "; "list(APPEND _IMPORT_CHECK_FILES_FOR_" << targetName << " ";
for(std::set<std::string>::const_iterator li = importedLocations.begin(); for(std::set<std::string>::const_iterator li = importedLocations.begin();
li != importedLocations.end(); li != importedLocations.end();

View File

@ -57,7 +57,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
else else
{ {
cmOStringStream e; cmOStringStream e;
e << "INSTALL(EXPORT \"" e << "install(EXPORT \""
<< this->IEGen->GetExportSet()->GetName() << this->IEGen->GetExportSet()->GetName()
<< "\" ...) " << "includes target \"" << te->Target->GetName() << "\" ...) " << "includes target \"" << te->Target->GetName()
<< "\" more than once in the export set."; << "\" more than once in the export set.";
@ -98,12 +98,12 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
// Now load per-configuration properties for them. // Now load per-configuration properties for them.
os << "# Load information for each installed configuration.\n" os << "# Load information for each installed configuration.\n"
<< "GET_FILENAME_COMPONENT(_DIR \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n" << "get_filename_component(_DIR \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"
<< "FILE(GLOB CONFIG_FILES \"${_DIR}/" << "file(GLOB CONFIG_FILES \"${_DIR}/"
<< this->GetConfigImportFileGlob() << "\")\n" << this->GetConfigImportFileGlob() << "\")\n"
<< "FOREACH(f ${CONFIG_FILES})\n" << "foreach(f ${CONFIG_FILES})\n"
<< " INCLUDE(${f})\n" << " include(${f})\n"
<< "ENDFOREACH(f)\n" << "endforeach()\n"
<< "\n"; << "\n";
this->GenerateImportedFileCheckLoop(os); this->GenerateImportedFileCheckLoop(os);
@ -193,12 +193,12 @@ cmExportInstallFileGenerator
{ {
std::string dest = installDest; std::string dest = installDest;
os << "# Compute the installation prefix relative to this file.\n" os << "# Compute the installation prefix relative to this file.\n"
<< "GET_FILENAME_COMPONENT(_IMPORT_PREFIX " << "get_filename_component(_IMPORT_PREFIX "
<< "\"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"; << "\"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n";
while(!dest.empty()) while(!dest.empty())
{ {
os << os <<
"GET_FILENAME_COMPONENT(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n"; "get_filename_component(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n";
dest = cmSystemTools::GetFilenamePath(dest); dest = cmSystemTools::GetFilenamePath(dest);
} }
os << "\n"; os << "\n";
@ -257,7 +257,7 @@ cmExportInstallFileGenerator
if(!this->ImportPrefix.empty()) if(!this->ImportPrefix.empty())
{ {
os << "# Cleanup temporary variables.\n" os << "# Cleanup temporary variables.\n"
<< "SET(_IMPORT_PREFIX)\n" << "set(_IMPORT_PREFIX)\n"
<< "\n"; << "\n";
} }
} }
@ -427,7 +427,7 @@ cmExportInstallFileGenerator
{ {
const char* installDest = this->IEGen->GetDestination(); const char* installDest = this->IEGen->GetDestination();
cmOStringStream e; cmOStringStream e;
e << "INSTALL(EXPORT \"" e << "install(EXPORT \""
<< this->IEGen->GetExportSet()->GetName() << this->IEGen->GetExportSet()->GetName()
<< "\") given absolute " << "\") given absolute "
<< "DESTINATION \"" << installDest << "\" but the export " << "DESTINATION \"" << installDest << "\" but the export "
@ -445,7 +445,7 @@ cmExportInstallFileGenerator
int occurrences) int occurrences)
{ {
cmOStringStream e; cmOStringStream e;
e << "INSTALL(EXPORT \"" e << "install(EXPORT \""
<< this->IEGen->GetExportSet()->GetName() << this->IEGen->GetExportSet()->GetName()
<< "\" ...) " << "\" ...) "
<< "includes target \"" << depender->GetName() << "includes target \"" << depender->GetName()