Commit 02d4e53f authored by Stephen Kelly's avatar Stephen Kelly
Browse files

Generate new-style cmake code during export.

Use empty end*() commands and lowercase commands.
parent 35fbe4e4
......@@ -81,16 +81,16 @@ bool cmExportFileGenerator::GenerateImportFile()
// Protect that file against use with older CMake versions.
os << "# Generated by CMake " << cmVersion::GetCMakeVersion() << "\n\n";
os << "IF(\"${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}\" LESS 2.5)\n"
<< " MESSAGE(FATAL_ERROR \"CMake >= 2.6.0 required\")\n"
<< "ENDIF(\"${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"
<< "endif()\n";
// Isolate the file policy level.
// 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
// until the import format changes.
os << "CMAKE_POLICY(PUSH)\n"
<< "CMAKE_POLICY(VERSION 2.6)\n";
os << "cmake_policy(PUSH)\n"
<< "cmake_policy(VERSION 2.6)\n";
// Start with the import file header.
this->GenerateImportHeaderCode(os);
......@@ -100,7 +100,7 @@ bool cmExportFileGenerator::GenerateImportFile()
// End with the import file footer.
this->GenerateImportFooterCode(os);
os << "CMAKE_POLICY(POP)\n";
os << "cmake_policy(POP)\n";
return result;
}
......@@ -186,7 +186,7 @@ void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget *target,
{
std::string targetName = this->Namespace;
targetName += target->GetName();
os << "SET_TARGET_PROPERTIES(" << targetName << " PROPERTIES\n";
os << "set_target_properties(" << targetName << " PROPERTIES\n";
for(ImportPropertyMap::const_iterator pi = properties.begin();
pi != properties.end(); ++pi)
{
......@@ -536,7 +536,7 @@ void cmExportFileGenerator::GenerateImportHeaderCode(std::ostream& os,
void cmExportFileGenerator::GenerateImportFooterCode(std::ostream& os)
{
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
// format later while still allowing old import files to work.
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";
}
......@@ -553,31 +553,31 @@ void cmExportFileGenerator::GenerateImportVersionCode(std::ostream& os)
void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os,
const std::string &expectedTargets)
{
os << "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"
" ENDIF(NOT TARGET ${_expectedTarget})\n"
" IF(TARGET ${_expectedTarget})\n"
" LIST(APPEND _targetsDefined ${_expectedTarget})\n"
" ENDIF(TARGET ${_expectedTarget})\n"
"ENDFOREACH(_expectedTarget)\n"
"IF(\"${_targetsDefined}\" STREQUAL \"${_expectedTargets}\")\n"
" SET(CMAKE_IMPORT_FILE_VERSION)\n"
" CMAKE_POLICY(POP)\n"
" RETURN()\n"
"ENDIF(\"${_targetsDefined}\" STREQUAL \"${_expectedTargets}\")\n"
"IF(NOT \"${_targetsDefined}\" STREQUAL \"\")\n"
" MESSAGE(FATAL_ERROR \"Some (but not all) targets in this export "
os << "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"
" endif()\n"
" if(TARGET ${_expectedTarget})\n"
" list(APPEND _targetsDefined ${_expectedTarget})\n"
" endif()\n"
"endforeach()\n"
"if(\"${_targetsDefined}\" STREQUAL \"${_expectedTargets}\")\n"
" set(CMAKE_IMPORT_FILE_VERSION)\n"
" cmake_policy(POP)\n"
" return()\n"
"endif()\n"
"if(NOT \"${_targetsDefined}\" 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"
"ENDIF(NOT \"${_targetsDefined}\" STREQUAL \"\")\n"
"UNSET(_targetsDefined)\n"
"UNSET(_targetsNotDefined)\n"
"UNSET(_expectedTargets)\n"
"endif()\n"
"unset(_targetsDefined)\n"
"unset(_targetsNotDefined)\n"
"unset(_expectedTargets)\n"
"\n\n";
}
//----------------------------------------------------------------------------
......@@ -594,16 +594,16 @@ cmExportFileGenerator
switch(target->GetType())
{
case cmTarget::EXECUTABLE:
os << "ADD_EXECUTABLE(" << targetName << " IMPORTED)\n";
os << "add_executable(" << targetName << " IMPORTED)\n";
break;
case cmTarget::STATIC_LIBRARY:
os << "ADD_LIBRARY(" << targetName << " STATIC IMPORTED)\n";
os << "add_library(" << targetName << " STATIC IMPORTED)\n";
break;
case cmTarget::SHARED_LIBRARY:
os << "ADD_LIBRARY(" << targetName << " SHARED IMPORTED)\n";
os << "add_library(" << targetName << " SHARED IMPORTED)\n";
break;
case cmTarget::MODULE_LIBRARY:
os << "ADD_LIBRARY(" << targetName << " MODULE IMPORTED)\n";
os << "add_library(" << targetName << " MODULE IMPORTED)\n";
break;
default: // should never happen
break;
......@@ -612,27 +612,27 @@ cmExportFileGenerator
// Mark the imported executable if it has exports.
if(target->IsExecutableWithExports())
{
os << "SET_PROPERTY(TARGET " << targetName
os << "set_property(TARGET " << targetName
<< " PROPERTY ENABLE_EXPORTS 1)\n";
}
// Mark the imported library if it is a framework.
if(target->IsFrameworkOnApple())
{
os << "SET_PROPERTY(TARGET " << targetName
os << "set_property(TARGET " << targetName
<< " PROPERTY FRAMEWORK 1)\n";
}
// Mark the imported executable if it is an application bundle.
if(target->IsAppBundleOnApple())
{
os << "SET_PROPERTY(TARGET " << targetName
os << "set_property(TARGET " << targetName
<< " PROPERTY MACOSX_BUNDLE 1)\n";
}
if (target->IsCFBundleOnApple())
{
os << "SET_PROPERTY(TARGET " << targetName
os << "set_property(TARGET " << targetName
<< " PROPERTY BUNDLE 1)\n";
}
os << "\n";
......@@ -652,7 +652,7 @@ cmExportFileGenerator
// Set the import properties.
os << "# Import target \"" << targetName << "\" for configuration \""
<< config << "\"\n";
os << "SET_PROPERTY(TARGET " << targetName
os << "set_property(TARGET " << targetName
<< " APPEND PROPERTY IMPORTED_CONFIGURATIONS ";
if(config && *config)
{
......@@ -663,7 +663,7 @@ cmExportFileGenerator
os << "NOCONFIG";
}
os << ")\n";
os << "SET_TARGET_PROPERTIES(" << targetName << " PROPERTIES\n";
os << "set_target_properties(" << targetName << " PROPERTIES\n";
for(ImportPropertyMap::const_iterator pi = properties.begin();
pi != properties.end(); ++pi)
{
......@@ -689,17 +689,17 @@ void cmExportFileGenerator::GenerateMissingTargetsCheckCode(std::ostream& os,
{
if (emitted.insert(missingTargets[i]).second)
{
os << "IF(NOT TARGET \"" << missingTargets[i] << "\" )\n"
<< " IF(CMAKE_FIND_PACKAGE_NAME)\n"
<< " SET( ${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)\n"
<< " SET( ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "
os << "if(NOT TARGET \"" << missingTargets[i] << "\" )\n"
<< " if(CMAKE_FIND_PACKAGE_NAME)\n"
<< " set( ${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)\n"
<< " set( ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "
<< "\"Required imported target \\\"" << missingTargets[i]
<< "\\\" not found ! \")\n"
<< " ELSE()\n"
<< " MESSAGE(FATAL_ERROR \"Required imported target \\\""
<< " else()\n"
<< " message(FATAL_ERROR \"Required imported target \\\""
<< missingTargets[i] << "\\\" not found ! \")\n"
<< " ENDIF()\n"
<< "ENDIF()\n";
<< " endif()\n"
<< "endif()\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,
// but the development package was not installed.).
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(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}\\\""
" references the file\n"
" \\\"${file}\\\"\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"
"but not all the files it references.\n"
"\")\n"
" ENDIF()\n"
" ENDFOREACH()\n"
" UNSET(_IMPORT_CHECK_FILES_FOR_${target})\n"
"ENDFOREACH()\n"
"UNSET(_IMPORT_CHECK_TARGETS)\n"
" endif()\n"
" endforeach()\n"
" unset(_IMPORT_CHECK_FILES_FOR_${target})\n"
"endforeach()\n"
"unset(_IMPORT_CHECK_TARGETS)\n"
"\n";
}
......@@ -751,8 +751,8 @@ cmExportFileGenerator
std::string targetName = this->Namespace;
targetName += target->GetName();
os << "LIST(APPEND _IMPORT_CHECK_TARGETS " << targetName << " )\n"
"LIST(APPEND _IMPORT_CHECK_FILES_FOR_" << targetName << " ";
os << "list(APPEND _IMPORT_CHECK_TARGETS " << targetName << " )\n"
"list(APPEND _IMPORT_CHECK_FILES_FOR_" << targetName << " ";
for(std::set<std::string>::const_iterator li = importedLocations.begin();
li != importedLocations.end();
......
......@@ -57,7 +57,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
else
{
cmOStringStream e;
e << "INSTALL(EXPORT \""
e << "install(EXPORT \""
<< this->IEGen->GetExportSet()->GetName()
<< "\" ...) " << "includes target \"" << te->Target->GetName()
<< "\" more than once in the export set.";
......@@ -98,12 +98,12 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
// Now load per-configuration properties for them.
os << "# Load information for each installed configuration.\n"
<< "GET_FILENAME_COMPONENT(_DIR \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"
<< "FILE(GLOB CONFIG_FILES \"${_DIR}/"
<< "get_filename_component(_DIR \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"
<< "file(GLOB CONFIG_FILES \"${_DIR}/"
<< this->GetConfigImportFileGlob() << "\")\n"
<< "FOREACH(f ${CONFIG_FILES})\n"
<< " INCLUDE(${f})\n"
<< "ENDFOREACH(f)\n"
<< "foreach(f ${CONFIG_FILES})\n"
<< " include(${f})\n"
<< "endforeach()\n"
<< "\n";
this->GenerateImportedFileCheckLoop(os);
......@@ -193,12 +193,12 @@ cmExportInstallFileGenerator
{
std::string dest = installDest;
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";
while(!dest.empty())
{
os <<
"GET_FILENAME_COMPONENT(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n";
"get_filename_component(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n";
dest = cmSystemTools::GetFilenamePath(dest);
}
os << "\n";
......@@ -257,7 +257,7 @@ cmExportInstallFileGenerator
if(!this->ImportPrefix.empty())
{
os << "# Cleanup temporary variables.\n"
<< "SET(_IMPORT_PREFIX)\n"
<< "set(_IMPORT_PREFIX)\n"
<< "\n";
}
}
......@@ -427,7 +427,7 @@ cmExportInstallFileGenerator
{
const char* installDest = this->IEGen->GetDestination();
cmOStringStream e;
e << "INSTALL(EXPORT \""
e << "install(EXPORT \""
<< this->IEGen->GetExportSet()->GetName()
<< "\") given absolute "
<< "DESTINATION \"" << installDest << "\" but the export "
......@@ -445,7 +445,7 @@ cmExportInstallFileGenerator
int occurrences)
{
cmOStringStream e;
e << "INSTALL(EXPORT \""
e << "install(EXPORT \""
<< this->IEGen->GetExportSet()->GetName()
<< "\" ...) "
<< "includes target \"" << depender->GetName()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment