diff options
Diffstat (limited to 'Source')
451 files changed, 17624 insertions, 22779 deletions
diff --git a/Source/CMakeInstallDestinations.cmake b/Source/CMakeInstallDestinations.cmake new file mode 100644 index 0000000..3e93d41 --- /dev/null +++ b/Source/CMakeInstallDestinations.cmake @@ -0,0 +1,38 @@ +# Keep formatting here consistent with bootstrap script expectations. +if(BEOS) + set(CMAKE_DATA_DIR_DEFAULT "share/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}") # HAIKU + set(CMAKE_MAN_DIR_DEFAULT "documentation/man") # HAIKU + set(CMAKE_DOC_DIR_DEFAULT "documentation/doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}") # HAIKU +elseif(CYGWIN) + set(CMAKE_DATA_DIR_DEFAULT "share/cmake-${CMake_VERSION}") # CYGWIN + set(CMAKE_DOC_DIR_DEFAULT "share/doc/cmake-${CMake_VERSION}") # CYGWIN + set(CMAKE_MAN_DIR_DEFAULT "share/man") # CYGWIN +else() + set(CMAKE_DATA_DIR_DEFAULT "share/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}") # OTHER + set(CMAKE_DOC_DIR_DEFAULT "doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}") # OTHER + set(CMAKE_MAN_DIR_DEFAULT "man") # OTHER +endif() + +set(CMAKE_DATA_DIR_DESC "data") +set(CMAKE_DOC_DIR_DESC "docs") +set(CMAKE_MAN_DIR_DESC "man pages") + +foreach(v + CMAKE_DATA_DIR + CMAKE_DOC_DIR + CMAKE_MAN_DIR + ) + # Populate the cache with empty values so we know when the user sets them. + set(${v} "" CACHE STRING "") + set_property(CACHE ${v} PROPERTY HELPSTRING + "Location under install prefix for ${${v}_DESC} (default \"${${v}_DEFAULT}\")" + ) + set_property(CACHE ${v} PROPERTY ADVANCED 1) + + # Use the default when the user did not set this variable. + if(NOT ${v}) + set(${v} "${${v}_DEFAULT}") + endif() + # Remove leading slash to treat as relative to install prefix. + string(REGEX REPLACE "^/" "" ${v} "${${v}}") +endforeach() diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 8412e3e..dbb922d 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -38,6 +38,12 @@ configure_file( "${CMake_BINARY_DIR}/Source/CPack/cmCPackConfigure.h" ) +# Tell CMake executable in the build tree where to find the source tree. +configure_file( + "${CMake_SOURCE_DIR}/Source/CMakeSourceDir.txt.in" + "${CMake_BINARY_DIR}/CMakeFiles/CMakeSourceDir.txt" @ONLY + ) + # add the include path to find the .h include_directories( "${CMake_BINARY_DIR}/Source" @@ -159,16 +165,7 @@ set(SRCS cmDependsJavaParserHelper.h cmDocumentation.cxx cmDocumentationFormatter.cxx - cmDocumentationFormatterHTML.cxx - cmDocumentationFormatterDocbook.cxx - cmDocumentationFormatterMan.cxx - cmDocumentationFormatterText.cxx - cmDocumentationFormatterUsage.cxx cmDocumentationSection.cxx - cmDocumentCompileDefinitions.h - cmDocumentGeneratorExpressions.h - cmDocumentLocationUndefined.h - cmDocumentVariables.cxx cmDynamicLoader.cxx cmDynamicLoader.h ${ELF_SRCS} @@ -189,8 +186,12 @@ set(SRCS cmExportSetMap.cxx cmExtraCodeBlocksGenerator.cxx cmExtraCodeBlocksGenerator.h + cmExtraCodeLiteGenerator.cxx + cmExtraCodeLiteGenerator.h cmExtraEclipseCDT4Generator.cxx cmExtraEclipseCDT4Generator.h + cmExtraKateGenerator.cxx + cmExtraKateGenerator.h cmExtraSublimeTextGenerator.cxx cmExtraSublimeTextGenerator.h cmFileTimeComparison.cxx @@ -259,8 +260,10 @@ set(SRCS cmPropertyDefinitionMap.h cmPropertyMap.cxx cmPropertyMap.h - cmQtAutomoc.cxx - cmQtAutomoc.h + cmQtAutoGenerators.cxx + cmQtAutoGenerators.h + cmRST.cxx + cmRST.h cmScriptGenerator.h cmScriptGenerator.cxx cmSourceFile.cxx @@ -288,8 +291,6 @@ set(SRCS cmXMLSafe.h cmake.cxx cmake.h - cmakewizard.cxx - cmakewizard.h cm_sha2.h cm_sha2.c @@ -370,8 +371,6 @@ if (WIN32) cmVisualStudioSlnParser.cxx cmVisualStudioWCEPlatformParser.h cmVisualStudioWCEPlatformParser.cxx - cmWin32ProcessExecution.cxx - cmWin32ProcessExecution.h ) endif() endif () @@ -439,6 +438,7 @@ set(CTEST_SRCS cmCTest.cxx CTest/cmParseCacheCoverage.cxx CTest/cmParseGTMCoverage.cxx CTest/cmParsePHPCoverage.cxx + CTest/cmParsePythonCoverage.cxx CTest/cmCTestEmptyBinaryDirectoryCommand.cxx CTest/cmCTestGenericHandler.cxx CTest/cmCTestHandlerCommand.cxx @@ -475,6 +475,8 @@ set(CTEST_SRCS cmCTest.cxx CTest/cmCTestGIT.h CTest/cmCTestHG.cxx CTest/cmCTestHG.h + CTest/cmCTestP4.cxx + CTest/cmCTestP4.h ) # Build CTestLib @@ -496,8 +498,6 @@ set(CPACK_SRCS CPack/cmCPackTarBZip2Generator.cxx CPack/cmCPackTarCompressGenerator.cxx CPack/cmCPackZIPGenerator.cxx - CPack/cmCPackDocumentVariables.cxx - CPack/cmCPackDocumentMacros.cxx ) if(CYGWIN) @@ -519,6 +519,7 @@ if(WIN32) CPack/WiX/cmCPackWIXGenerator.cxx CPack/WiX/cmWIXSourceWriter.cxx CPack/WiX/cmWIXRichTextFormatWriter.cxx + CPack/WiX/cmWIXPatchParser.cxx ) endif() @@ -545,19 +546,9 @@ if(APPLE) endif() # Build CMake executable -add_executable(cmake cmakemain.cxx) +add_executable(cmake cmakemain.cxx cmcmd.cxx cmcmd.h) target_link_libraries(cmake CMakeLib) -# Build special executable for running programs on Windows 98. -# Included on any Windows (unconditional packaging required!). -if(WIN32) - if(NOT UNIX) - add_executable(cmw9xcom cmw9xcom.cxx) - target_link_libraries(cmw9xcom CMakeLib) - install(TARGETS cmw9xcom DESTINATION bin) - endif() -endif() - # Build CTest executable add_executable(ctest ctest.cxx) target_link_libraries(ctest CTestLib) diff --git a/Source/CMakeSourceDir.txt.in b/Source/CMakeSourceDir.txt.in new file mode 100644 index 0000000..5e6a988 --- /dev/null +++ b/Source/CMakeSourceDir.txt.in @@ -0,0 +1 @@ +@CMake_SOURCE_DIR@ diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index bd1c38a..14b0789 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,6 +1,6 @@ # CMake version number components. set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) -set(CMake_VERSION_PATCH 11) -set(CMake_VERSION_TWEAK 20131007) +set(CMake_VERSION_PATCH 12) +set(CMake_VERSION_TWEAK 20140116) #set(CMake_VERSION_RC 1) diff --git a/Source/CMakeVersionCompute.cmake b/Source/CMakeVersionCompute.cmake new file mode 100644 index 0000000..a166334 --- /dev/null +++ b/Source/CMakeVersionCompute.cmake @@ -0,0 +1,23 @@ +# Load version number components. +include(${CMake_SOURCE_DIR}/Source/CMakeVersion.cmake) + +# Releases define a small tweak level. +if("${CMake_VERSION_TWEAK}" VERSION_LESS 20000000) + set(CMake_VERSION_IS_RELEASE 1) + set(CMake_VERSION_SOURCE "") +else() + set(CMake_VERSION_IS_RELEASE 0) + include(${CMake_SOURCE_DIR}/Source/CMakeVersionSource.cmake) +endif() + +# Compute the full version string. +set(CMake_VERSION ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}) +if(${CMake_VERSION_TWEAK} GREATER 0) + set(CMake_VERSION ${CMake_VERSION}.${CMake_VERSION_TWEAK}) +endif() +if(CMake_VERSION_RC) + set(CMake_VERSION ${CMake_VERSION}-rc${CMake_VERSION_RC}) +endif() +if(CMake_VERSION_SOURCE) + set(CMake_VERSION ${CMake_VERSION}-${CMake_VERSION_SOURCE}) +endif() diff --git a/Source/CPack/OSXScriptLauncher.cxx b/Source/CPack/OSXScriptLauncher.cxx index a9842c1..d9d6236 100644 --- a/Source/CPack/OSXScriptLauncher.cxx +++ b/Source/CPack/OSXScriptLauncher.cxx @@ -11,8 +11,8 @@ ============================================================================*/ #include <cmsys/SystemTools.hxx> #include <cmsys/Process.h> -#include <cmsys/ios/fstream> #include <cmsys/ios/iostream> +#include <cmsys/FStream.hxx> #include <CoreFoundation/CoreFoundation.h> @@ -27,7 +27,7 @@ int main(int argc, char* argv[]) { //if ( cmsys::SystemTools::FileExists( cmsys_stl::string cwd = cmsys::SystemTools::GetCurrentWorkingDirectory(); - cmsys_ios::ofstream ofs("/tmp/output.txt"); + cmsys::ofstream ofs("/tmp/output.txt"); CFStringRef fileName; CFBundleRef appBundle; diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index cc9dec7..998b5f1 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -1,6 +1,6 @@ /*============================================================================ CMake - Cross Platform Makefile Generator - Copyright 2000-2012 Kitware, Inc., Insight Software Consortium + Copyright 2000-2013 Kitware, Inc., Insight Software Consortium Distributed under the OSI-approved BSD License (the "License"); see accompanying file Copyright.txt for details. @@ -14,6 +14,7 @@ #include <cmSystemTools.h> #include <cmGeneratedFileStream.h> +#include <cmCryptoHash.h> #include <CPack/cmCPackLog.h> #include <CPack/cmCPackComponentGroup.h> @@ -22,9 +23,14 @@ #include <cmsys/SystemTools.hxx> #include <cmsys/Directory.hxx> +#include <cmsys/Encoding.hxx> +#include <cmsys/FStream.hxx> #include <rpc.h> // for GUID generation +#include <sys/types.h> +#include <sys/stat.h> + int cmCPackWIXGenerator::InitializeInternal() { componentPackageMethod = ONE_PACKAGE; @@ -51,7 +57,7 @@ bool cmCPackWIXGenerator::RunWiXCommand(const std::string& command) bool status = cmSystemTools::RunSingleCommand(command.c_str(), &output, &returnValue, 0, cmSystemTools::OUTPUT_NONE); - std::ofstream logFile(logFileName.c_str(), std::ios::app); + cmsys::ofstream logFile(logFileName.c_str(), std::ios::app); logFile << command << std::endl; logFile << output; logFile.close(); @@ -82,6 +88,15 @@ bool cmCPackWIXGenerator::RunCandleCommand( command << " -nologo"; command << " -arch " << GetArchitecture(); command << " -out " << QuotePath(objectFile); + + for(extension_set_t::const_iterator i = CandleExtensions.begin(); + i != CandleExtensions.end(); ++i) + { + command << " -ext " << QuotePath(*i); + } + + AddCustomFlags("CPACK_WIX_CANDLE_EXTRA_FLAGS", command); + command << " " << QuotePath(sourceFile); return RunWiXCommand(command.str()); @@ -99,12 +114,21 @@ bool cmCPackWIXGenerator::RunLightCommand(const std::string& objectFiles) command << QuotePath(executable); command << " -nologo"; command << " -out " << QuotePath(packageFileNames.at(0)); - command << " -ext WixUIExtension"; + + for(extension_set_t::const_iterator i = LightExtensions.begin(); + i != LightExtensions.end(); ++i) + { + command << " -ext " << QuotePath(*i); + } + const char* const cultures = GetOption("CPACK_WIX_CULTURES"); if(cultures) { command << " -cultures:" << cultures; } + + AddCustomFlags("CPACK_WIX_LIGHT_EXTRA_FLAGS", command); + command << " " << objectFiles; return RunWiXCommand(command.str()); @@ -169,6 +193,41 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration() } } + if(GetOption("CPACK_PACKAGE_VENDOR") == 0) + { + std::string defaultVendor = "Humanity"; + SetOption("CPACK_PACKAGE_VENDOR", defaultVendor.c_str()); + + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "CPACK_PACKAGE_VENDOR implicitly set to " << defaultVendor << " . " + << std::endl); + } + + if(GetOption("CPACK_WIX_UI_REF") == 0) + { + std::string defaultRef = "WixUI_InstallDir"; + + if(Components.size()) + { + defaultRef = "WixUI_FeatureTree"; + } + + SetOption("CPACK_WIX_UI_REF", defaultRef.c_str()); + } + + CollectExtensions("CPACK_WIX_EXTENSIONS", CandleExtensions); + CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", CandleExtensions); + + LightExtensions.insert("WixUIExtension"); + CollectExtensions("CPACK_WIX_EXTENSIONS", LightExtensions); + CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", LightExtensions); + + const char* patchFilePath = GetOption("CPACK_WIX_PATCH_FILE"); + if(patchFilePath) + { + LoadPatchFragments(patchFilePath); + } + return true; } @@ -189,10 +248,12 @@ bool cmCPackWIXGenerator::PackageFilesImpl() return false; } + AppendUserSuppliedExtraSources(); + std::stringstream objectFiles; - for(size_t i = 0; i < wixSources.size(); ++i) + for(size_t i = 0; i < WixSources.size(); ++i) { - const std::string& sourceFilename = wixSources[i]; + const std::string& sourceFilename = WixSources[i]; std::string objectFilename = cmSystemTools::GetFilenameWithoutExtension(sourceFilename) + ".wixobj"; @@ -205,9 +266,35 @@ bool cmCPackWIXGenerator::PackageFilesImpl() objectFiles << " " << QuotePath(objectFilename); } + AppendUserSuppliedExtraObjects(objectFiles); + return RunLightCommand(objectFiles.str()); } +void cmCPackWIXGenerator::AppendUserSuppliedExtraSources() +{ + const char *cpackWixExtraSources = GetOption("CPACK_WIX_EXTRA_SOURCES"); + if(!cpackWixExtraSources) return; + + cmSystemTools::ExpandListArgument(cpackWixExtraSources, WixSources); +} + +void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream) +{ + const char *cpackWixExtraObjects = GetOption("CPACK_WIX_EXTRA_OBJECTS"); + if(!cpackWixExtraObjects) return; + + std::vector<std::string> expandedExtraObjects; + + cmSystemTools::ExpandListArgument( + cpackWixExtraObjects, expandedExtraObjects); + + for(size_t i = 0; i < expandedExtraObjects.size(); ++i) + { + stream << " " << QuotePath(expandedExtraObjects[i]); + } +} + bool cmCPackWIXGenerator::CreateWiXVariablesIncludeFile() { std::string cpackTopLevel; @@ -232,6 +319,7 @@ bool cmCPackWIXGenerator::CreateWiXVariablesIncludeFile() SetOptionIfNotSet("CPACK_WIX_PROGRAM_MENU_FOLDER", GetOption("CPACK_PACKAGE_NAME")); CopyDefinition(includeFile, "CPACK_WIX_PROGRAM_MENU_FOLDER"); + CopyDefinition(includeFile, "CPACK_WIX_UI_REF"); return true; } @@ -267,7 +355,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() std::string directoryDefinitionsFilename = cpackTopLevel + "/directories.wxs"; - wixSources.push_back(directoryDefinitionsFilename); + WixSources.push_back(directoryDefinitionsFilename); cmWIXSourceWriter directoryDefinitions(Logger, directoryDefinitionsFilename); directoryDefinitions.BeginElement("Fragment"); @@ -319,13 +407,10 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() directoryDefinitions.AddAttribute("Name", install_root[i]); } - size_t directoryCounter = 0; - size_t fileCounter = 0; - std::string fileDefinitionsFilename = cpackTopLevel + "/files.wxs"; - wixSources.push_back(fileDefinitionsFilename); + WixSources.push_back(fileDefinitionsFilename); cmWIXSourceWriter fileDefinitions(Logger, fileDefinitionsFilename); fileDefinitions.BeginElement("Fragment"); @@ -333,122 +418,109 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() std::string featureDefinitionsFilename = cpackTopLevel +"/features.wxs"; - wixSources.push_back(featureDefinitionsFilename); + WixSources.push_back(featureDefinitionsFilename); cmWIXSourceWriter featureDefinitions(Logger, featureDefinitionsFilename); featureDefinitions.BeginElement("Fragment"); featureDefinitions.BeginElement("Feature"); featureDefinitions.AddAttribute("Id", "ProductFeature"); - featureDefinitions.AddAttribute("Title", Name); + featureDefinitions.AddAttribute("Display", "expand"); + featureDefinitions.AddAttribute("ConfigurableDirectory", "INSTALL_ROOT"); + + std::string cpackPackageName; + if(!RequireOption("CPACK_PACKAGE_NAME", cpackPackageName)) + { + return false; + } + featureDefinitions.AddAttribute("Title", cpackPackageName); + featureDefinitions.AddAttribute("Level", "1"); - featureDefinitions.EndElement(); - featureDefinitions.BeginElement("FeatureRef"); - featureDefinitions.AddAttribute("Id", "ProductFeature"); + if(!CreateCMakePackageRegistryEntry(featureDefinitions)) + { + return false; + } - const char *cpackPackageExecutables = GetOption("CPACK_PACKAGE_EXECUTABLES"); - std::vector<std::string> cpackPkgExecutables; - std::string regKey; - if ( cpackPackageExecutables ) + if(!CreateFeatureHierarchy(featureDefinitions)) { - cmSystemTools::ExpandListArgument(cpackPackageExecutables, - cpackPkgExecutables); - if ( cpackPkgExecutables.size() % 2 != 0 ) - { - cmCPackLogger(cmCPackLog::LOG_ERROR, - "CPACK_PACKAGE_EXECUTABLES should contain pairs of <executable> and " - "<icon name>." << std::endl); - cpackPkgExecutables.clear(); - } + return false; + } - const char *cpackVendor = GetOption("CPACK_PACKAGE_VENDOR"); - const char *cpackPkgName = GetOption("CPACK_PACKAGE_NAME"); - if (!cpackVendor || !cpackPkgName) + featureDefinitions.EndElement("Feature"); + + bool hasShortcuts = false; + + shortcut_map_t globalShortcuts; + if(Components.empty()) + { + AddComponentsToFeature(toplevel, "ProductFeature", + directoryDefinitions, fileDefinitions, featureDefinitions, + globalShortcuts); + if(globalShortcuts.size()) { - cmCPackLogger(cmCPackLog::LOG_WARNING, "CPACK_PACKAGE_VENDOR and " - "CPACK_PACKAGE_NAME must be defined for shortcut creation" << std::endl); - cpackPkgExecutables.clear(); + hasShortcuts = true; } - else + } + else + { + for(std::map<std::string, cmCPackComponent>::const_iterator + i = Components.begin(); i != Components.end(); ++i) { - regKey = std::string("Software/") + cpackVendor + "/" + cpackPkgName; + cmCPackComponent const& component = i->second; + + std::string componentPath = toplevel; + componentPath += "/"; + componentPath += component.Name; + + std::string componentFeatureId = "CM_C_" + component.Name; + + shortcut_map_t featureShortcuts; + AddComponentsToFeature(componentPath, componentFeatureId, + directoryDefinitions, fileDefinitions, + featureDefinitions, featureShortcuts); + if(featureShortcuts.size()) + { + hasShortcuts = true; + } + + if(featureShortcuts.size()) + { + if(!CreateStartMenuShortcuts(component.Name, componentFeatureId, + featureShortcuts, fileDefinitions, featureDefinitions)) + { + return false; + } + } } } - std::vector<std::string> dirIdExecutables; - AddDirectoryAndFileDefinitons( - toplevel, "INSTALL_ROOT", - directoryDefinitions, fileDefinitions, featureDefinitions, - directoryCounter, fileCounter, cpackPkgExecutables, dirIdExecutables); + if(hasShortcuts) + { + if(!CreateStartMenuShortcuts(std::string(), "ProductFeature", + globalShortcuts, fileDefinitions, featureDefinitions)) + { + return false; + } + } - directoryDefinitions.EndElement(); - directoryDefinitions.EndElement(); + featureDefinitions.EndElement("Fragment"); + fileDefinitions.EndElement("Fragment"); - if (dirIdExecutables.size() > 0 && dirIdExecutables.size() % 3 == 0) + for(size_t i = 1; i < install_root.size(); ++i) { - fileDefinitions.BeginElement("DirectoryRef"); - fileDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER"); - fileDefinitions.BeginElement("Component"); - fileDefinitions.AddAttribute("Id", "SHORTCUT"); - fileDefinitions.AddAttribute("Guid", "*"); + directoryDefinitions.EndElement("Directory"); + } - std::vector<std::string>::iterator it; - for ( it = dirIdExecutables.begin() ; - it != dirIdExecutables.end(); - ++it) - { - std::string fileName = *it++; - std::string iconName = *it++; - std::string directoryId = *it; - - fileDefinitions.BeginElement("Shortcut"); - std::string shortcutName = fileName; // the iconName is mor likely to contain blanks early on - std::string::size_type const dotPos = shortcutName.find('.'); - if(std::string::npos == dotPos) - { shortcutName = shortcutName.substr(0, dotPos); } - fileDefinitions.AddAttribute("Id", "SHORTCUT_" + shortcutName); - fileDefinitions.AddAttribute("Name", iconName); - std::string target = "[" + directoryId + "]" + fileName; - fileDefinitions.AddAttribute("Target", target); - fileDefinitions.AddAttribute("WorkingDirectory", directoryId); - fileDefinitions.EndElement(); - } - fileDefinitions.BeginElement("Shortcut"); - fileDefinitions.AddAttribute("Id", "UNINSTALL"); - std::string pkgName = GetOption("CPACK_PACKAGE_NAME"); - fileDefinitions.AddAttribute("Name", "Uninstall " + pkgName); - fileDefinitions.AddAttribute("Description", "Uninstalls " + pkgName); - fileDefinitions.AddAttribute("Target", "[SystemFolder]msiexec.exe"); - fileDefinitions.AddAttribute("Arguments", "/x [ProductCode]"); - fileDefinitions.EndElement(); - fileDefinitions.BeginElement("RemoveFolder"); - fileDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER"); - fileDefinitions.AddAttribute("On", "uninstall"); - fileDefinitions.EndElement(); - fileDefinitions.BeginElement("RegistryValue"); - fileDefinitions.AddAttribute("Root", "HKCU"); - fileDefinitions.AddAttribute("Key", regKey); - fileDefinitions.AddAttribute("Name", "installed"); - fileDefinitions.AddAttribute("Type", "integer"); - fileDefinitions.AddAttribute("Value", "1"); - fileDefinitions.AddAttribute("KeyPath", "yes"); - - featureDefinitions.BeginElement("ComponentRef"); - featureDefinitions.AddAttribute("Id", "SHORTCUT"); - featureDefinitions.EndElement(); - directoryDefinitions.BeginElement("Directory"); - directoryDefinitions.AddAttribute("Id", "ProgramMenuFolder"); - directoryDefinitions.BeginElement("Directory"); - directoryDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER"); - const char *startMenuFolder = GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER"); - directoryDefinitions.AddAttribute("Name", startMenuFolder); - } + directoryDefinitions.EndElement("Directory"); - featureDefinitions.EndElement(); - featureDefinitions.EndElement(); - fileDefinitions.EndElement(); - directoryDefinitions.EndElement(); + if(hasShortcuts) + { + CreateStartMenuFolder(directoryDefinitions); + } + + directoryDefinitions.EndElement("Directory"); + directoryDefinitions.EndElement("Fragment"); std::string wixTemplate = FindTemplate("WIX.template.in"); if(GetOption("CPACK_WIX_TEMPLATE") != 0) @@ -473,11 +545,315 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() return false; } - wixSources.push_back(mainSourceFilePath); + WixSources.push_back(mainSourceFilePath); + + std::string fragmentList; + for(cmWIXPatchParser::fragment_map_t::const_iterator + i = Fragments.begin(); i != Fragments.end(); ++i) + { + if(!fragmentList.empty()) + { + fragmentList += ", "; + } + + fragmentList += "'"; + fragmentList += i->first; + fragmentList += "'"; + } + + if(fragmentList.size()) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Some XML patch fragments did not have matching IDs: " << + fragmentList << std::endl); + return false; + } + + return true; +} + +bool cmCPackWIXGenerator::CreateCMakePackageRegistryEntry( + cmWIXSourceWriter& featureDefinitions) +{ + const char* package = GetOption("CPACK_WIX_CMAKE_PACKAGE_REGISTRY"); + if(!package) + { + return true; + } + + featureDefinitions.BeginElement("Component"); + featureDefinitions.AddAttribute("Id", "CM_PACKAGE_REGISTRY"); + featureDefinitions.AddAttribute("Directory", "TARGETDIR"); + featureDefinitions.AddAttribute("Guid", "*"); + + std::string registryKey = + std::string("Software\\Kitware\\CMake\\Packages\\") + package; + + std::string upgradeGuid = GetOption("CPACK_WIX_UPGRADE_GUID"); + + featureDefinitions.BeginElement("RegistryValue"); + featureDefinitions.AddAttribute("Root", "HKLM"); + featureDefinitions.AddAttribute("Key", registryKey); + featureDefinitions.AddAttribute("Name", upgradeGuid); + featureDefinitions.AddAttribute("Type", "string"); + featureDefinitions.AddAttribute("Value", "[INSTALL_ROOT]"); + featureDefinitions.AddAttribute("KeyPath", "yes"); + featureDefinitions.EndElement("RegistryValue"); + + featureDefinitions.EndElement("Component"); + + return true; +} + +bool cmCPackWIXGenerator::CreateFeatureHierarchy( + cmWIXSourceWriter& featureDefinitions) +{ + for(std::map<std::string, cmCPackComponentGroup>::const_iterator + i = ComponentGroups.begin(); i != ComponentGroups.end(); ++i) + { + cmCPackComponentGroup const& group = i->second; + if(group.ParentGroup == 0) + { + if(!EmitFeatureForComponentGroup(featureDefinitions, group)) + { + return false; + } + } + } + + for(std::map<std::string, cmCPackComponent>::const_iterator + i = Components.begin(); i != Components.end(); ++i) + { + cmCPackComponent const& component = i->second; + + if(!component.Group) + { + if(!EmitFeatureForComponent(featureDefinitions, component)) + { + return false; + } + } + } + + return true; +} + +bool cmCPackWIXGenerator::EmitFeatureForComponentGroup( + cmWIXSourceWriter& featureDefinitions, + cmCPackComponentGroup const& group) +{ + featureDefinitions.BeginElement("Feature"); + featureDefinitions.AddAttribute("Id", "CM_G_" + group.Name); + + if(group.IsExpandedByDefault) + { + featureDefinitions.AddAttribute("Display", "expand"); + } + + featureDefinitions.AddAttributeUnlessEmpty( + "Title", group.DisplayName); + + featureDefinitions.AddAttributeUnlessEmpty( + "Description", group.Description); + + for(std::vector<cmCPackComponentGroup*>::const_iterator + i = group.Subgroups.begin(); i != group.Subgroups.end(); ++i) + { + if(!EmitFeatureForComponentGroup(featureDefinitions, **i)) + { + return false; + } + } + + for(std::vector<cmCPackComponent*>::const_iterator + i = group.Components.begin(); i != group.Components.end(); ++i) + { + if(!EmitFeatureForComponent(featureDefinitions, **i)) + { + return false; + } + } + + featureDefinitions.EndElement("Feature"); + + return true; +} + +bool cmCPackWIXGenerator::EmitFeatureForComponent( + cmWIXSourceWriter& featureDefinitions, + cmCPackComponent const& component) +{ + featureDefinitions.BeginElement("Feature"); + featureDefinitions.AddAttribute("Id", "CM_C_" + component.Name); + + featureDefinitions.AddAttributeUnlessEmpty( + "Title", component.DisplayName); + + featureDefinitions.AddAttributeUnlessEmpty( + "Description", component.Description); + + if(component.IsRequired) + { + featureDefinitions.AddAttribute("Absent", "disallow"); + } + + if(component.IsHidden) + { + featureDefinitions.AddAttribute("Display", "hidden"); + } + + featureDefinitions.EndElement("Feature"); + + return true; +} + +bool cmCPackWIXGenerator::AddComponentsToFeature( + std::string const& rootPath, + std::string const& featureId, + cmWIXSourceWriter& directoryDefinitions, + cmWIXSourceWriter& fileDefinitions, + cmWIXSourceWriter& featureDefinitions, + shortcut_map_t& shortcutMap) +{ + featureDefinitions.BeginElement("FeatureRef"); + featureDefinitions.AddAttribute("Id", featureId); + + std::vector<std::string> cpackPackageExecutablesList; + const char *cpackPackageExecutables = GetOption("CPACK_PACKAGE_EXECUTABLES"); + if(cpackPackageExecutables) + { + cmSystemTools::ExpandListArgument(cpackPackageExecutables, + cpackPackageExecutablesList); + if(cpackPackageExecutablesList.size() % 2 != 0 ) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "CPACK_PACKAGE_EXECUTABLES should contain pairs of <executable> and " + "<text label>." << std::endl); + return false; + } + } + + AddDirectoryAndFileDefinitons( + rootPath, "INSTALL_ROOT", + directoryDefinitions, fileDefinitions, featureDefinitions, + cpackPackageExecutablesList, shortcutMap); + + featureDefinitions.EndElement("FeatureRef"); + + return true; +} + +bool cmCPackWIXGenerator::CreateStartMenuShortcuts( + std::string const& cpackComponentName, + std::string const& featureId, + shortcut_map_t& shortcutMap, + cmWIXSourceWriter& fileDefinitions, + cmWIXSourceWriter& featureDefinitions) +{ + featureDefinitions.BeginElement("FeatureRef"); + featureDefinitions.AddAttribute("Id", featureId); + + std::string cpackVendor; + if(!RequireOption("CPACK_PACKAGE_VENDOR", cpackVendor)) + { + return false; + } + + std::string cpackPackageName; + if(!RequireOption("CPACK_PACKAGE_NAME", cpackPackageName)) + { + return false; + } + + std::string idSuffix; + if(!cpackComponentName.empty()) + { + idSuffix += "_"; + idSuffix += cpackComponentName; + } + + std::string componentId = "CM_SHORTCUT" + idSuffix; + + fileDefinitions.BeginElement("DirectoryRef"); + fileDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER"); + fileDefinitions.BeginElement("Component"); + fileDefinitions.AddAttribute("Id", componentId); + fileDefinitions.AddAttribute("Guid", "*"); + + for(shortcut_map_t::const_iterator + i = shortcutMap.begin(); i != shortcutMap.end(); ++i) + { + std::string const& id = i->first; + cmWIXShortcut const& shortcut = i->second; + + std::string shortcutId = std::string("CM_S") + id; + std::string fileId = std::string("CM_F") + id; + + fileDefinitions.BeginElement("Shortcut"); + fileDefinitions.AddAttribute("Id", shortcutId); + fileDefinitions.AddAttribute("Name", shortcut.textLabel); + std::string target = "[#" + fileId + "]"; + fileDefinitions.AddAttribute("Target", target); + fileDefinitions.AddAttribute("WorkingDirectory", + shortcut.workingDirectoryId); + fileDefinitions.EndElement("Shortcut"); + } + + if(cpackComponentName.empty()) + { + CreateUninstallShortcut(cpackPackageName, fileDefinitions); + } + + fileDefinitions.BeginElement("RemoveFolder"); + fileDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER" + idSuffix); + fileDefinitions.AddAttribute("On", "uninstall"); + fileDefinitions.EndElement("RemoveFolder"); + + std::string registryKey = + std::string("Software\\") + cpackVendor + "\\" + cpackPackageName; + + fileDefinitions.BeginElement("RegistryValue"); + fileDefinitions.AddAttribute("Root", "HKCU"); + fileDefinitions.AddAttribute("Key", registryKey); + + std::string valueName; + if(!cpackComponentName.empty()) + { + valueName = cpackComponentName + "_"; + } + valueName += "installed"; + + fileDefinitions.AddAttribute("Name", valueName); + fileDefinitions.AddAttribute("Type", "integer"); + fileDefinitions.AddAttribute("Value", "1"); + fileDefinitions.AddAttribute("KeyPath", "yes"); + fileDefinitions.EndElement("RegistryValue"); + + fileDefinitions.EndElement("Component"); + fileDefinitions.EndElement("DirectoryRef"); + + featureDefinitions.BeginElement("ComponentRef"); + featureDefinitions.AddAttribute("Id", componentId); + featureDefinitions.EndElement("ComponentRef"); + + featureDefinitions.EndElement("FeatureRef"); return true; } +void cmCPackWIXGenerator::CreateUninstallShortcut( + std::string const& packageName, + cmWIXSourceWriter& fileDefinitions) +{ + fileDefinitions.BeginElement("Shortcut"); + fileDefinitions.AddAttribute("Id", "UNINSTALL"); + fileDefinitions.AddAttribute("Name", "Uninstall " + packageName); + fileDefinitions.AddAttribute("Description", "Uninstalls " + packageName); + fileDefinitions.AddAttribute("Target", "[SystemFolder]msiexec.exe"); + fileDefinitions.AddAttribute("Arguments", "/x [ProductCode]"); + fileDefinitions.EndElement("Shortcut"); +} + bool cmCPackWIXGenerator::CreateLicenseFile() { std::string licenseSourceFilename; @@ -504,7 +880,7 @@ bool cmCPackWIXGenerator::CreateLicenseFile() { cmWIXRichTextFormatWriter rtfWriter(licenseDestinationFilename); - std::ifstream licenseSource(licenseSourceFilename.c_str()); + cmsys::ifstream licenseSource(licenseSourceFilename.c_str()); std::string line; while(std::getline(licenseSource, line)) @@ -531,10 +907,8 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( cmWIXSourceWriter& directoryDefinitions, cmWIXSourceWriter& fileDefinitions, cmWIXSourceWriter& featureDefinitions, - size_t& directoryCounter, - size_t& fileCounter, - const std::vector<std::string>& pkgExecutables, - std::vector<std::string>& dirIdExecutables) + const std::vector<std::string>& packageExecutables, + shortcut_map_t& shortcutMap) { cmsys::Directory dir; dir.Load(topdir.c_str()); @@ -550,11 +924,14 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( std::string fullPath = topdir + "/" + fileName; + std::string relativePath = cmSystemTools::RelativePath( + toplevel.c_str(), fullPath.c_str()); + + std::string id = PathToId(relativePath); + if(cmSystemTools::FileIsDirectory(fullPath.c_str())) { - std::stringstream tmp; - tmp << "DIR_ID_" << ++directoryCounter; - std::string subDirectoryId = tmp.str(); + std::string subDirectoryId = std::string("CM_D") + id; directoryDefinitions.BeginElement("Directory"); directoryDefinitions.AddAttribute("Id", subDirectoryId); @@ -565,20 +942,16 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( directoryDefinitions, fileDefinitions, featureDefinitions, - directoryCounter, - fileCounter, - pkgExecutables, - dirIdExecutables); - directoryDefinitions.EndElement(); + packageExecutables, + shortcutMap); + + ApplyPatchFragment(subDirectoryId, directoryDefinitions); + directoryDefinitions.EndElement("Directory"); } else { - std::stringstream tmp; - tmp << "_ID_" << ++fileCounter; - std::string idSuffix = tmp.str(); - - std::string componentId = std::string("CMP") + idSuffix; - std::string fileId = std::string("FILE") + idSuffix; + std::string componentId = std::string("CM_C") + id; + std::string fileId = std::string("CM_F") + id; fileDefinitions.BeginElement("DirectoryRef"); fileDefinitions.AddAttribute("Id", directoryId); @@ -592,28 +965,36 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( fileDefinitions.AddAttribute("Source", fullPath); fileDefinitions.AddAttribute("KeyPath", "yes"); - fileDefinitions.EndElement(); - fileDefinitions.EndElement(); - fileDefinitions.EndElement(); + mode_t fileMode = 0; + cmSystemTools::GetPermissions(fullPath.c_str(), fileMode); + + if(!(fileMode & S_IWRITE)) + { + fileDefinitions.AddAttribute("ReadOnly", "yes"); + } + + ApplyPatchFragment(fileId, fileDefinitions); + fileDefinitions.EndElement("File"); + + ApplyPatchFragment(componentId, fileDefinitions); + fileDefinitions.EndElement("Component"); + fileDefinitions.EndElement("DirectoryRef"); featureDefinitions.BeginElement("ComponentRef"); featureDefinitions.AddAttribute("Id", componentId); - featureDefinitions.EndElement(); + featureDefinitions.EndElement("ComponentRef"); - std::vector<std::string>::const_iterator it; - for (it = pkgExecutables.begin() ; - it != pkgExecutables.end() ; - ++it) + for(size_t j = 0; j < packageExecutables.size(); ++j) { - std::string execName = *it++; - std::string iconName = *it; + std::string const& executableName = packageExecutables[j++]; + std::string const& textLabel = packageExecutables[j]; - if (cmSystemTools::LowerCase(fileName) == - cmSystemTools::LowerCase(execName) + ".exe") + if(cmSystemTools::LowerCase(fileName) == + cmSystemTools::LowerCase(executableName) + ".exe") { - dirIdExecutables.push_back(fileName); - dirIdExecutables.push_back(iconName); - dirIdExecutables.push_back(directoryId); + cmWIXShortcut &shortcut = shortcutMap[id]; + shortcut.textLabel= textLabel; + shortcut.workingDirectoryId = directoryId; } } } @@ -659,11 +1040,12 @@ std::string cmCPackWIXGenerator::GenerateGUID() UUID guid; UuidCreate(&guid); - unsigned char *tmp = 0; - UuidToString(&guid, &tmp); + unsigned short *tmp = 0; + UuidToStringW(&guid, &tmp); - std::string result(reinterpret_cast<char*>(tmp)); - RpcStringFree(&tmp); + std::string result = + cmsys::Encoding::ToNarrow(reinterpret_cast<wchar_t*>(tmp)); + RpcStringFreeW(&tmp); return cmSystemTools::UpperCase(result); } @@ -686,3 +1068,208 @@ std::string cmCPackWIXGenerator::GetRightmostExtension( return cmSystemTools::LowerCase(extension); } + +std::string cmCPackWIXGenerator::PathToId(const std::string& path) +{ + id_map_t::const_iterator i = PathToIdMap.find(path); + if(i != PathToIdMap.end()) return i->second; + + std::string id = CreateNewIdForPath(path); + return id; +} + +std::string cmCPackWIXGenerator::CreateNewIdForPath(const std::string& path) +{ + std::vector<std::string> components; + cmSystemTools::SplitPath(path.c_str(), components, false); + + size_t replacementCount = 0; + + std::string identifier; + std::string currentComponent; + + for(size_t i = 1; i < components.size(); ++i) + { + if(i != 1) identifier += '.'; + + currentComponent = NormalizeComponentForId( + components[i], replacementCount); + + identifier += currentComponent; + } + + std::string idPrefix = "P"; + size_t replacementPercent = replacementCount * 100 / identifier.size(); + if(replacementPercent > 33 || identifier.size() > 60) + { + identifier = CreateHashedId(path, currentComponent); + idPrefix = "H"; + } + + std::stringstream result; + result << idPrefix << "_" << identifier; + + size_t ambiguityCount = ++IdAmbiguityCounter[identifier]; + + if(ambiguityCount > 999) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error while trying to generate a unique Id for '" << + path << "'" << std::endl); + + return std::string(); + } + else if(ambiguityCount > 1) + { + result << "_" << ambiguityCount; + } + + std::string resultString = result.str(); + + PathToIdMap[path] = resultString; + + return resultString; +} + +std::string cmCPackWIXGenerator::CreateHashedId( + const std::string& path, const std::string& normalizedFilename) +{ + cmsys::auto_ptr<cmCryptoHash> sha1 = cmCryptoHash::New("SHA1"); + std::string hash = sha1->HashString(path.c_str()); + + std::string identifier; + identifier += hash.substr(0, 7) + "_"; + + const size_t maxFileNameLength = 52; + if(normalizedFilename.length() > maxFileNameLength) + { + identifier += normalizedFilename.substr(0, maxFileNameLength - 3); + identifier += "..."; + } + else + { + identifier += normalizedFilename; + } + + return identifier; +} + +std::string cmCPackWIXGenerator::NormalizeComponentForId( + const std::string& component, size_t& replacementCount) +{ + std::string result; + result.resize(component.size()); + + for(size_t i = 0; i < component.size(); ++i) + { + char c = component[i]; + if(IsLegalIdCharacter(c)) + { + result[i] = c; + } + else + { + result[i] = '_'; + ++ replacementCount; + } + } + + return result; +} + +bool cmCPackWIXGenerator::IsLegalIdCharacter(char c) +{ + return (c >= '0' && c <= '9') || + (c >= 'a' && c <= 'z') || + (c >= 'A' && c <= 'Z') || + c == '_' || c == '.'; +} + +void cmCPackWIXGenerator::CollectExtensions( + const std::string& variableName, extension_set_t& extensions) +{ + const char *variableContent = GetOption(variableName.c_str()); + if(!variableContent) return; + + std::vector<std::string> list; + cmSystemTools::ExpandListArgument(variableContent, list); + + for(std::vector<std::string>::const_iterator i = list.begin(); + i != list.end(); ++i) + { + extensions.insert(*i); + } +} + +void cmCPackWIXGenerator::AddCustomFlags( + const std::string& variableName, std::ostream& stream) +{ + const char *variableContent = GetOption(variableName.c_str()); + if(!variableContent) return; + + std::vector<std::string> list; + cmSystemTools::ExpandListArgument(variableContent, list); + + for(std::vector<std::string>::const_iterator i = list.begin(); + i != list.end(); ++i) + { + stream << " " << QuotePath(*i); + } +} + +void cmCPackWIXGenerator::CreateStartMenuFolder( + cmWIXSourceWriter& directoryDefinitions) +{ + directoryDefinitions.BeginElement("Directory"); + directoryDefinitions.AddAttribute("Id", "ProgramMenuFolder"); + + directoryDefinitions.BeginElement("Directory"); + directoryDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER"); + const char *startMenuFolder = GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER"); + directoryDefinitions.AddAttribute("Name", startMenuFolder); + directoryDefinitions.EndElement("Directory"); + + directoryDefinitions.EndElement("Directory"); +} + +void cmCPackWIXGenerator::LoadPatchFragments(const std::string& patchFilePath) +{ + cmWIXPatchParser parser(Fragments, Logger); + parser.ParseFile(patchFilePath.c_str()); +} + +void cmCPackWIXGenerator::ApplyPatchFragment( + const std::string& id, cmWIXSourceWriter& writer) +{ + cmWIXPatchParser::fragment_map_t::iterator i = Fragments.find(id); + if(i == Fragments.end()) return; + + const cmWIXPatchElement& fragment = i->second; + for(cmWIXPatchElement::child_list_t::const_iterator + j = fragment.children.begin(); j != fragment.children.end(); ++j) + { + ApplyPatchElement(**j, writer); + } + + Fragments.erase(i); +} + +void cmCPackWIXGenerator::ApplyPatchElement( + const cmWIXPatchElement& element, cmWIXSourceWriter& writer) +{ + writer.BeginElement(element.name); + + for(cmWIXPatchElement::attributes_t::const_iterator + i = element.attributes.begin(); i != element.attributes.end(); ++i) + { + writer.AddAttribute(i->first, i->second); + } + + for(cmWIXPatchElement::child_list_t::const_iterator + i = element.children.begin(); i != element.children.end(); ++i) + { + ApplyPatchElement(**i, writer); + } + + writer.EndElement(element.name); +} diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h index aaccf9d..1f4facf 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.h +++ b/Source/CPack/WiX/cmCPackWIXGenerator.h @@ -13,11 +13,19 @@ #ifndef cmCPackWIXGenerator_h #define cmCPackWIXGenerator_h +#include "cmWIXPatchParser.h" + #include <CPack/cmCPackGenerator.h> #include <string> #include <map> +struct cmWIXShortcut +{ + std::string textLabel; + std::string workingDirectoryId; +}; + class cmWIXSourceWriter; /** \class cmCPackWIXGenerator @@ -50,10 +58,15 @@ protected: virtual bool SupportsComponentInstallation() const { - return false; + return true; } private: + typedef std::map<std::string, std::string> id_map_t; + typedef std::map<std::string, size_t> ambiguity_map_t; + typedef std::map<std::string, cmWIXShortcut> shortcut_map_t; + typedef std::set<std::string> extension_set_t; + bool InitializeWiXConfiguration(); bool PackageFilesImpl(); @@ -68,6 +81,43 @@ private: bool CreateWiXSourceFiles(); + bool CreateCMakePackageRegistryEntry( + cmWIXSourceWriter& featureDefinitions); + + bool CreateFeatureHierarchy( + cmWIXSourceWriter& featureDefinitions); + + bool EmitFeatureForComponentGroup( + cmWIXSourceWriter& featureDefinitions, + cmCPackComponentGroup const& group); + + bool EmitFeatureForComponent( + cmWIXSourceWriter& featureDefinitions, + cmCPackComponent const& component); + + bool AddComponentsToFeature( + std::string const& rootPath, + std::string const& featureId, + cmWIXSourceWriter& directoryDefinitions, + cmWIXSourceWriter& fileDefinitions, + cmWIXSourceWriter& featureDefinitions, + shortcut_map_t& shortcutMap); + + bool CreateStartMenuShortcuts( + std::string const& cpackComponentName, + std::string const& featureId, + shortcut_map_t& shortcutMap, + cmWIXSourceWriter& fileDefinitions, + cmWIXSourceWriter& featureDefinitions); + + void CreateUninstallShortcut( + std::string const& packageName, + cmWIXSourceWriter& fileDefinitions); + + void AppendUserSuppliedExtraSources(); + + void AppendUserSuppliedExtraObjects(std::ostream& stream); + bool CreateLicenseFile(); bool RunWiXCommand(const std::string& command); @@ -82,12 +132,8 @@ private: cmWIXSourceWriter& directoryDefinitions, cmWIXSourceWriter& fileDefinitions, cmWIXSourceWriter& featureDefinitions, - size_t& directoryCounter, - size_t& fileCounter, const std::vector<std::string>& pkgExecutables, - std::vector<std::string>& dirIdExecutables - ); - + shortcut_map_t& shortcutMap); bool RequireOption(const std::string& name, std::string& value) const; @@ -99,7 +145,41 @@ private: static std::string GetRightmostExtension(const std::string& filename); - std::vector<std::string> wixSources; + std::string PathToId(const std::string& path); + + std::string CreateNewIdForPath(const std::string& path); + + static std::string CreateHashedId( + const std::string& path, const std::string& normalizedFilename); + + std::string NormalizeComponentForId( + const std::string& component, size_t& replacementCount); + + static bool IsLegalIdCharacter(char c); + + void CollectExtensions( + const std::string& variableName, extension_set_t& extensions); + + void AddCustomFlags( + const std::string& variableName, std::ostream& stream); + + void CreateStartMenuFolder(cmWIXSourceWriter& directoryDefinitions); + + void LoadPatchFragments(const std::string& patchFilePath); + + void ApplyPatchFragment(const std::string& id, cmWIXSourceWriter& writer); + + void ApplyPatchElement(const cmWIXPatchElement& element, + cmWIXSourceWriter& writer); + + std::vector<std::string> WixSources; + id_map_t PathToIdMap; + ambiguity_map_t IdAmbiguityCounter; + + extension_set_t CandleExtensions; + extension_set_t LightExtensions; + + cmWIXPatchParser::fragment_map_t Fragments; }; #endif diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx new file mode 100644 index 0000000..7ceaf1f --- /dev/null +++ b/Source/CPack/WiX/cmWIXPatchParser.cxx @@ -0,0 +1,145 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2013 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#include "cmWIXPatchParser.h" + +#include <CPack/cmCPackGenerator.h> + +#include <cm_expat.h> + +cmWIXPatchElement::~cmWIXPatchElement() +{ + for(child_list_t::iterator i = children.begin(); i != children.end(); ++i) + { + delete *i; + } +} + +cmWIXPatchParser::cmWIXPatchParser( + fragment_map_t& fragments, cmCPackLog* logger): + Logger(logger), + State(BEGIN_DOCUMENT), + Valid(true), + Fragments(fragments) +{ + +} + +void cmWIXPatchParser::StartElement(const char *name, const char **atts) +{ + std::string name_str = name; + if(State == BEGIN_DOCUMENT) + { + if(name_str == "CPackWiXPatch") + { + State = BEGIN_FRAGMENTS; + } + else + { + ReportValidationError("Expected root element 'CPackWiXPatch'"); + } + } + else if(State == BEGIN_FRAGMENTS) + { + if(name_str == "CPackWiXFragment") + { + State = INSIDE_FRAGMENT; + StartFragment(atts); + } + else + { + ReportValidationError("Expected 'CPackWixFragment' element"); + } + } + else if(State == INSIDE_FRAGMENT) + { + cmWIXPatchElement &parent = *ElementStack.back(); + + parent.children.resize(parent.children.size() + 1); + cmWIXPatchElement*& currentElement = parent.children.back(); + currentElement = new cmWIXPatchElement; + currentElement->name = name; + + for(size_t i = 0; atts[i]; i += 2) + { + std::string key = atts[i]; + std::string value = atts[i+1]; + + currentElement->attributes[key] = value; + } + + ElementStack.push_back(currentElement); + } +} + +void cmWIXPatchParser::StartFragment(const char **attributes) +{ + for(size_t i = 0; attributes[i]; i += 2) + { + std::string key = attributes[i]; + std::string value = attributes[i+1]; + + if(key == "Id") + { + if(Fragments.find(value) != Fragments.end()) + { + std::stringstream tmp; + tmp << "Invalid reuse of 'CPackWixFragment' 'Id': " << value; + ReportValidationError(tmp.str()); + } + + ElementStack.push_back(&Fragments[value]); + } + else + { + ReportValidationError( + "The only allowed 'CPackWixFragment' attribute is 'Id'"); + } + } +} + +void cmWIXPatchParser::EndElement(const char *name) +{ + std::string name_str = name; + if(State == INSIDE_FRAGMENT) + { + if(name_str == "CPackWiXFragment") + { + State = BEGIN_FRAGMENTS; + ElementStack.clear(); + } + else + { + ElementStack.pop_back(); + } + } +} + +void cmWIXPatchParser::ReportError(int line, int column, const char* msg) +{ + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error while processing XML patch file at " << line << ":" << column << + ": "<< msg << std::endl); + Valid = false; +} + +void cmWIXPatchParser::ReportValidationError(const std::string& message) +{ + ReportError(XML_GetCurrentLineNumber(Parser), + XML_GetCurrentColumnNumber(Parser), + message.c_str()); +} + +bool cmWIXPatchParser::IsValid() const +{ + return Valid; +} diff --git a/Source/CPack/WiX/cmWIXPatchParser.h b/Source/CPack/WiX/cmWIXPatchParser.h new file mode 100644 index 0000000..91b3b66 --- /dev/null +++ b/Source/CPack/WiX/cmWIXPatchParser.h @@ -0,0 +1,75 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2013 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmCPackWIXPatchParser_h +#define cmCPackWIXPatchParser_h + +#include <cmXMLParser.h> + +#include <CPack/cmCPackLog.h> + +#include <map> +#include <list> + +struct cmWIXPatchElement +{ + ~cmWIXPatchElement(); + + typedef std::list<cmWIXPatchElement*> child_list_t; + typedef std::map<std::string, std::string> attributes_t; + + std::string name; + child_list_t children; + attributes_t attributes; +}; + +/** \class cmWIXPatchParser + * \brief Helper class that parses XML patch files (CPACK_WIX_PATCH_FILE) + */ +class cmWIXPatchParser : public cmXMLParser +{ +public: + typedef std::map<std::string, cmWIXPatchElement> fragment_map_t; + + cmWIXPatchParser(fragment_map_t& Fragments, cmCPackLog* logger); + +private: + virtual void StartElement(const char *name, const char **atts); + + void StartFragment(const char **attributes); + + virtual void EndElement(const char *name); + virtual void ReportError(int line, int column, const char* msg); + + void ReportValidationError(const std::string& message); + + bool IsValid() const; + + cmCPackLog* Logger; + + enum ParserState + { + BEGIN_DOCUMENT, + BEGIN_FRAGMENTS, + INSIDE_FRAGMENT + }; + + ParserState State; + + bool Valid; + + fragment_map_t& Fragments; + + std::list<cmWIXPatchElement*> ElementStack; +}; + +#endif diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx index 774c22c..ddc1d71 100644 --- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx +++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx @@ -16,7 +16,7 @@ cmWIXRichTextFormatWriter::cmWIXRichTextFormatWriter( const std::string& filename): - file(filename.c_str(), std::ios::binary) + File(filename.c_str(), std::ios::binary) { StartGroup(); WriteHeader(); @@ -29,8 +29,8 @@ cmWIXRichTextFormatWriter::~cmWIXRichTextFormatWriter() /* I haven't seen this in the RTF spec but * wordpad terminates its RTF like this */ - file << "\r\n"; - file.put(0); + File << "\r\n"; + File.put(0); } void cmWIXRichTextFormatWriter::AddText(const std::string& text) @@ -44,16 +44,16 @@ void cmWIXRichTextFormatWriter::AddText(const std::string& text) switch(c) { case '\\': - file << "\\\\"; + File << "\\\\"; break; case '{': - file << "\\{"; + File << "\\{"; break; case '}': - file << "\\}"; + File << "\\}"; break; case '\n': - file << "\\par\r\n"; + File << "\\par\r\n"; break; case '\r': continue; @@ -61,11 +61,45 @@ void cmWIXRichTextFormatWriter::AddText(const std::string& text) { if(c <= 0x7F) { - file << c; + File << c; } else { - file << "[NON-ASCII-" << int(c) << "]"; + if(c <= 0xC0) + { + EmitInvalidCodepoint(c); + } + else if(c < 0xE0 && i+1 < text.size()) + { + EmitUnicodeCodepoint( + (text[i+1] & 0x3F) | + ((c & 0x1F) << 6) + ); + i+= 1; + } + else if(c < 0xF0 && i+2 < text.size()) + { + EmitUnicodeCodepoint( + (text[i+2] & 0x3F) | + ((text[i+1] & 0x3F) << 6) | + ((c & 0xF) << 12) + ); + i += 2; + } + else if(c < 0xF8 && i+3 < text.size()) + { + EmitUnicodeCodepoint( + (text[i+3] & 0x3F) | + ((text[i+2] & 0x3F) << 6) | + ((text[i+1] & 0x3F) << 12) | + ((c & 0x7) << 18) + ); + i += 3; + } + else + { + EmitInvalidCodepoint(c); + } } } break; @@ -82,6 +116,7 @@ void cmWIXRichTextFormatWriter::WriteHeader() ControlWord("deflang1031"); WriteFontTable(); + WriteColorTable(); WriteGenerator(); } @@ -99,11 +134,27 @@ void cmWIXRichTextFormatWriter::WriteFontTable() EndGroup(); } +void cmWIXRichTextFormatWriter::WriteColorTable() +{ + StartGroup(); + ControlWord("colortbl ;"); + ControlWord("red255"); + ControlWord("green0"); + ControlWord("blue0;"); + ControlWord("red0"); + ControlWord("green255"); + ControlWord("blue0;"); + ControlWord("red0"); + ControlWord("green0"); + ControlWord("blue255;"); + EndGroup(); +} + void cmWIXRichTextFormatWriter::WriteGenerator() { StartGroup(); NewControlWord("generator"); - file << " CPack WiX Generator (" << cmVersion::GetCMakeVersion() << ");"; + File << " CPack WiX Generator (" << cmVersion::GetCMakeVersion() << ");"; EndGroup(); } @@ -118,20 +169,60 @@ void cmWIXRichTextFormatWriter::WriteDocumentPrefix() void cmWIXRichTextFormatWriter::ControlWord(const std::string& keyword) { - file << "\\" << keyword; + File << "\\" << keyword; } void cmWIXRichTextFormatWriter::NewControlWord(const std::string& keyword) { - file << "\\*\\" << keyword; + File << "\\*\\" << keyword; } void cmWIXRichTextFormatWriter::StartGroup() { - file.put('{'); + File.put('{'); } void cmWIXRichTextFormatWriter::EndGroup() { - file.put('}'); + File.put('}'); +} + +void cmWIXRichTextFormatWriter::EmitUnicodeCodepoint(int c) +{ + // Do not emit byte order mark (BOM) + if(c == 0xFEFF) + { + return; + } + else if(c <= 0xFFFF) + { + EmitUnicodeSurrogate(c); + } + else + { + c -= 0x10000; + EmitUnicodeSurrogate(((c >> 10) & 0x3FF) + 0xD800); + EmitUnicodeSurrogate((c & 0x3FF) + 0xDC00); + } +} + +void cmWIXRichTextFormatWriter::EmitUnicodeSurrogate(int c) +{ + ControlWord("u"); + if(c <= 32767) + { + File << c; + } + else + { + File << (c - 65536); + } + File << "?"; +} + +void cmWIXRichTextFormatWriter::EmitInvalidCodepoint(int c) +{ + ControlWord("cf1 "); + File << "[INVALID-BYTE-" << int(c) << "]"; + ControlWord("cf0 "); } diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h index 10b67c3..2b665d4 100644 --- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h +++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h @@ -13,7 +13,7 @@ #ifndef cmWIXRichTextFormatWriter_h #define cmWIXRichTextFormatWriter_h -#include <fstream> +#include <cmsys/FStream.hxx> /** \class cmWIXRichtTextFormatWriter * \brief Helper class to generate Rich Text Format (RTF) documents @@ -30,6 +30,7 @@ public: private: void WriteHeader(); void WriteFontTable(); + void WriteColorTable(); void WriteGenerator(); void WriteDocumentPrefix(); @@ -40,7 +41,12 @@ private: void StartGroup(); void EndGroup(); - std::ofstream file; + void EmitUnicodeCodepoint(int c); + void EmitUnicodeSurrogate(int c); + + void EmitInvalidCodepoint(int c); + + cmsys::ofstream File; }; #endif diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx index af7ba80..e83c226 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx @@ -20,8 +20,9 @@ cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger, const std::string& filename, bool isIncludeFile): Logger(logger), - file(filename.c_str()), - state(DEFAULT) + File(filename.c_str()), + State(DEFAULT), + SourceFilename(filename) { WriteXMLDeclaration(); @@ -39,64 +40,79 @@ cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger, cmWIXSourceWriter::~cmWIXSourceWriter() { - while(elements.size()) + if(Elements.size() > 1) { - EndElement(); + cmCPackLogger(cmCPackLog::LOG_ERROR, + Elements.size() - 1 << " WiX elements were still open when closing '" << + SourceFilename << "'" << std::endl); + return; } + + EndElement(Elements.back()); } void cmWIXSourceWriter::BeginElement(const std::string& name) { - if(state == BEGIN) + if(State == BEGIN) { - file << ">"; + File << ">"; } - file << "\n"; - Indent(elements.size()); - file << "<" << name; + File << "\n"; + Indent(Elements.size()); + File << "<" << name; - elements.push_back(name); - state = BEGIN; + Elements.push_back(name); + State = BEGIN; } -void cmWIXSourceWriter::EndElement() +void cmWIXSourceWriter::EndElement(std::string const& name) { - if(elements.empty()) + if(Elements.empty()) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "can not end WiX element with no open elements in '" << + SourceFilename << "'" << std::endl); + return; + } + + if(Elements.back() != name) { cmCPackLogger(cmCPackLog::LOG_ERROR, - "can not end WiX element with no open elements" << std::endl); + "WiX element <" << Elements.back() << + "> can not be closed by </" << name << "> in '" << + SourceFilename << "'" << std::endl); return; } - if(state == DEFAULT) + if(State == DEFAULT) { - file << "\n"; - Indent(elements.size()-1); - file << "</" << elements.back() << ">"; + File << "\n"; + Indent(Elements.size()-1); + File << "</" << Elements.back() << ">"; } else { - file << "/>"; + File << "/>"; } - elements.pop_back(); - state = DEFAULT; + Elements.pop_back(); + State = DEFAULT; } void cmWIXSourceWriter::AddProcessingInstruction( const std::string& target, const std::string& content) { - if(state == BEGIN) + if(State == BEGIN) { - file << ">"; + File << ">"; } - file << "\n"; - Indent(elements.size()); - file << "<?" << target << " " << content << "?>"; + File << "\n"; + Indent(Elements.size()); + File << "<?" << target << " " << content << "?>"; - state = DEFAULT; + State = DEFAULT; } void cmWIXSourceWriter::AddAttribute( @@ -104,7 +120,16 @@ void cmWIXSourceWriter::AddAttribute( { std::string utf8 = WindowsCodepageToUtf8(value); - file << " " << key << "=\"" << EscapeAttributeValue(utf8) << '"'; + File << " " << key << "=\"" << EscapeAttributeValue(utf8) << '"'; +} + +void cmWIXSourceWriter::AddAttributeUnlessEmpty( + const std::string& key, const std::string& value) +{ + if(value.size()) + { + AddAttribute(key, value); + } } std::string cmWIXSourceWriter::WindowsCodepageToUtf8(const std::string& value) @@ -147,14 +172,14 @@ std::string cmWIXSourceWriter::WindowsCodepageToUtf8(const std::string& value) void cmWIXSourceWriter::WriteXMLDeclaration() { - file << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl; + File << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl; } void cmWIXSourceWriter::Indent(size_t count) { for(size_t i = 0; i < count; ++i) { - file << " "; + File << " "; } } @@ -173,6 +198,9 @@ std::string cmWIXSourceWriter::EscapeAttributeValue( case '<': result += "<"; break; + case '>': + result += ">"; + break; case '&': result +="&"; break; diff --git a/Source/CPack/WiX/cmWIXSourceWriter.h b/Source/CPack/WiX/cmWIXSourceWriter.h index 1dafc1f..894ad78 100644 --- a/Source/CPack/WiX/cmWIXSourceWriter.h +++ b/Source/CPack/WiX/cmWIXSourceWriter.h @@ -15,7 +15,7 @@ #include <vector> #include <string> -#include <fstream> +#include <cmsys/FStream.hxx> #include <CPack/cmCPackLog.h> @@ -32,7 +32,7 @@ public: void BeginElement(const std::string& name); - void EndElement(); + void EndElement(const std::string& name); void AddProcessingInstruction( const std::string& target, const std::string& content); @@ -40,6 +40,9 @@ public: void AddAttribute( const std::string& key, const std::string& value); + void AddAttributeUnlessEmpty( + const std::string& key, const std::string& value); + static std::string WindowsCodepageToUtf8(const std::string& value); private: @@ -57,11 +60,13 @@ private: cmCPackLog* Logger; - std::ofstream file; + cmsys::ofstream File; + + State State; - State state; + std::vector<std::string> Elements; - std::vector<std::string> elements; + std::string SourceFilename; }; #endif diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 4494e8a..0162d55 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -803,7 +803,7 @@ static int put_arobj(CF *cfp, struct stat *sb) static int ar_append(const char* archive,const std::vector<std::string>& files) { int eval = 0; - FILE* aFile = fopen(archive, "wb+"); + FILE* aFile = cmSystemTools::Fopen(archive, "wb+"); if (aFile!=NULL) { fwrite(ARMAG, SARMAG, 1, aFile); if (fseek(aFile, 0, SEEK_END) != -1) { @@ -814,7 +814,7 @@ static int ar_append(const char* archive,const std::vector<std::string>& files) for(std::vector<std::string>::const_iterator fileIt = files.begin(); fileIt!=files.end(); ++fileIt) { const char* filename = fileIt->c_str(); - FILE* file = fopen(filename, "rb"); + FILE* file = cmSystemTools::Fopen(filename, "rb"); if (file == NULL) { eval = -1; continue; diff --git a/Source/CPack/cmCPackDocumentMacros.cxx b/Source/CPack/cmCPackDocumentMacros.cxx deleted file mode 100644 index ddc75a4..0000000 --- a/Source/CPack/cmCPackDocumentMacros.cxx +++ /dev/null @@ -1,16 +0,0 @@ -#include "cmCPackDocumentMacros.h" - -void cmCPackDocumentMacros::GetMacrosDocumentation( - std::vector<cmDocumentationEntry>& ) -{ - // Commented-out example of use - // - // cmDocumentationEntry e("cpack_<macro>", - // "Brief Description" - // "which may be on several lines.", - // "Long description in pre-formatted format" - // " blah\n" - // " blah\n" - //); - //v.push_back(e); -} diff --git a/Source/CPack/cmCPackDocumentMacros.h b/Source/CPack/cmCPackDocumentMacros.h deleted file mode 100644 index 544f74f..0000000 --- a/Source/CPack/cmCPackDocumentMacros.h +++ /dev/null @@ -1,21 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#ifndef cmCPackDocumentMacros_h -#define cmCPackDocumentMacros_h -#include "cmStandardIncludes.h" -class cmCPackDocumentMacros -{ -public: - static void GetMacrosDocumentation(std::vector<cmDocumentationEntry>& v); -}; - -#endif diff --git a/Source/CPack/cmCPackDocumentVariables.cxx b/Source/CPack/cmCPackDocumentVariables.cxx deleted file mode 100644 index 8b16ae9..0000000 --- a/Source/CPack/cmCPackDocumentVariables.cxx +++ /dev/null @@ -1,122 +0,0 @@ -#include "cmCPackDocumentVariables.h" -#include "cmake.h" - -void cmCPackDocumentVariables::DefineVariables(cmake* cm) -{ - // Subsection: variables defined/used by cpack, - // which are common to all CPack generators - - cm->DefineProperty - ("CPACK_PACKAGING_INSTALL_PREFIX", cmProperty::VARIABLE, - "The prefix used in the built package.", - "Each CPack generator has a default value (like /usr)." - " This default value may" - " be overwritten from the CMakeLists.txt or the cpack command line" - " by setting an alternative value.\n" - "e.g. " - " set(CPACK_PACKAGING_INSTALL_PREFIX \"/opt\")\n" - "This is not the same purpose as CMAKE_INSTALL_PREFIX which" - " is used when installing from the build tree without building" - " a package." - "", false, - "Variables common to all CPack generators"); - - cm->DefineProperty - ("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", cmProperty::VARIABLE, - "Boolean toggle to include/exclude top level directory.", - "When preparing a package CPack installs the item under" - " the so-called top level directory. The purpose of" - " is to include (set to 1 or ON or TRUE) the top level directory" - " in the package or not (set to 0 or OFF or FALSE).\n" - "Each CPack generator has a built-in default value for this" - " variable. E.g. Archive generators (ZIP, TGZ, ...) includes" - " the top level whereas RPM or DEB don't. The user may override" - " the default value by setting this variable.\n" - "There is a similar variable " - "CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY " - "which may be used to override the behavior for the component" - " packaging case which may have different default value for" - " historical (now backward compatibility) reason.", false, - "Variables common to all CPack generators"); - - cm->DefineProperty - ("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY", cmProperty::VARIABLE, - "Boolean toggle to include/exclude top level directory " - "(component case).", - "Similar usage as CPACK_INCLUDE_TOPLEVEL_DIRECTORY" - " but for the component case. " - "See CPACK_INCLUDE_TOPLEVEL_DIRECTORY documentation for" - " the detail.", false, - "Variables common to all CPack generators"); - - cm->DefineProperty - ("CPACK_SET_DESTDIR", cmProperty::VARIABLE, - "Boolean toggle to make CPack use DESTDIR mechanism when" - " packaging.", "DESTDIR means DESTination DIRectory." - " It is commonly used by makefile " - "users in order to install software at non-default location. It " - "is a basic relocation mechanism that should not be used on" - " Windows (see CMAKE_INSTALL_PREFIX documentation). " - "It is usually invoked like this:\n" - " make DESTDIR=/home/john install\n" - "which will install the concerned software using the" - " installation prefix, e.g. \"/usr/local\" prepended with " - "the DESTDIR value which finally gives \"/home/john/usr/local\"." - " When preparing a package, CPack first installs the items to be " - "packaged in a local (to the build tree) directory by using the " - "same DESTDIR mechanism. Nevertheless, if " - "CPACK_SET_DESTDIR is set then CPack will set DESTDIR before" - " doing the local install. The most noticeable difference is" - " that without CPACK_SET_DESTDIR, CPack uses " - "CPACK_PACKAGING_INSTALL_PREFIX as a prefix whereas with " - "CPACK_SET_DESTDIR set, CPack will use CMAKE_INSTALL_PREFIX as" - " a prefix.\n" - "Manually setting CPACK_SET_DESTDIR may help (or simply be" - " necessary) if some install rules uses absolute " - "DESTINATION (see CMake INSTALL command)." - " However, starting with" - " CPack/CMake 2.8.3 RPM and DEB installers tries to handle DESTDIR" - " automatically so that it is seldom necessary for the user to set" - " it.", false, - "Variables common to all CPack generators"); - - cm->DefineProperty - ("CPACK_INSTALL_SCRIPT", cmProperty::VARIABLE, - "Extra CMake script provided by the user.", - "If set this CMake script will be executed by CPack " - "during its local [CPack-private] installation " - "which is done right before packaging the files." - " The script is not called by e.g.: make install.", false, - "Variables common to all CPack generators"); - - cm->DefineProperty - ("CPACK_ABSOLUTE_DESTINATION_FILES", cmProperty::VARIABLE, - "List of files which have been installed using " - " an ABSOLUTE DESTINATION path.", - "This variable is a Read-Only variable which is set internally" - " by CPack during installation and before packaging using" - " CMAKE_ABSOLUTE_DESTINATION_FILES defined in cmake_install.cmake " - "scripts. The value can be used within CPack project configuration" - " file and/or CPack<GEN>.cmake file of <GEN> generator.", false, - "Variables common to all CPack generators"); - - cm->DefineProperty - ("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION", cmProperty::VARIABLE, - "Ask CPack to warn each time a file with absolute INSTALL" - " DESTINATION is encountered.", - "This variable triggers the definition of " - "CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION when CPack runs" - " cmake_install.cmake scripts.", false, - "Variables common to all CPack generators"); - - cm->DefineProperty - ("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION", cmProperty::VARIABLE, - "Ask CPack to error out as soon as a file with absolute INSTALL" - " DESTINATION is encountered.", - "The fatal error is emitted before the installation of " - "the offending file takes place. Some CPack generators, like NSIS," - "enforce this internally. " - "This variable triggers the definition of" - "CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION when CPack runs" - "Variables common to all CPack generators"); -} diff --git a/Source/CPack/cmCPackDocumentVariables.h b/Source/CPack/cmCPackDocumentVariables.h deleted file mode 100644 index e7971be..0000000 --- a/Source/CPack/cmCPackDocumentVariables.h +++ /dev/null @@ -1,21 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#ifndef cmCPackDocumentVariables_h -#define cmCPackDocumentVariables_h -class cmake; -class cmCPackDocumentVariables -{ -public: - static void DefineVariables(cmake* cm); -}; - -#endif diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index d973c01..9f0a77e 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -16,6 +16,7 @@ #include "cmGeneratedFileStream.h" #include <cmsys/RegularExpression.hxx> +#include <cmsys/FStream.hxx> static const char* SLAHeader = "data 'LPic' (5000) {\n" @@ -422,7 +423,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, std::string sla_r = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); sla_r += "/sla.r"; - std::ifstream ifs; + cmsys::ifstream ifs; ifs.open(cpack_license_file.c_str()); if(ifs.is_open()) { @@ -474,7 +475,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, udco_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); udco_image_command << " convert \"" << temp_image << "\""; udco_image_command << " -format UDCO"; - udco_image_command << " -o \"" << temp_udco << "\""; + udco_image_command << " -ov -o \"" << temp_udco << "\""; std::string error; if(!this->RunCommand(udco_image_command, &error)) @@ -504,6 +505,11 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, // Rez the SLA cmOStringStream embed_sla_command; embed_sla_command << this->GetOption("CPACK_COMMAND_REZ"); + const char* sysroot = this->GetOption("CPACK_OSX_SYSROOT"); + if(sysroot && sysroot[0] != '\0') + { + embed_sla_command << " -isysroot \"" << sysroot << "\""; + } embed_sla_command << " \"" << sla_r << "\""; embed_sla_command << " -a -o "; embed_sla_command << "\"" << temp_udco << "\""; diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 3c685bd..96491aa 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -23,10 +23,12 @@ #include <cmsys/SystemTools.hxx> #include <cmsys/Glob.hxx> +#include <cmsys/FStream.hxx> #include <algorithm> #if defined(__HAIKU__) -#include <StorageKit.h> +#include <FindDirectory.h> +#include <StorageDefs.h> #endif //---------------------------------------------------------------------- @@ -151,7 +153,7 @@ int cmCPackGenerator::PrepareNames() << descFileName << "]" << std::endl); return 0; } - std::ifstream ifs(descFileName); + cmsys::ifstream ifs(descFileName); if ( !ifs ) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -579,7 +581,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( * (this works at CPack time too) */ if (this->SupportsComponentInstallation() & - !(this->IsSet("CPACK_MONOLITHIC_INSTALL"))) + !(this->IsOn("CPACK_MONOLITHIC_INSTALL"))) { // Determine the installation types for this project (if provided). std::string installTypesVar = "CPACK_" @@ -636,19 +638,21 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( globalGenerator->FindMakeProgram(this->MakefileMap); const char* cmakeMakeProgram = this->MakefileMap->GetDefinition("CMAKE_MAKE_PROGRAM"); - std::string buildCommand - = globalGenerator->GenerateBuildCommand(cmakeMakeProgram, - installProjectName.c_str(), 0, 0, + std::vector<std::string> buildCommand; + globalGenerator->GenerateBuildCommand(buildCommand, cmakeMakeProgram, + installProjectName.c_str(), installDirectory.c_str(), globalGenerator->GetPreinstallTargetName(), - buildConfig, false, false); + buildConfig, false); + std::string buildCommandStr = + cmSystemTools::PrintSingleCommand(buildCommand); cmCPackLogger(cmCPackLog::LOG_DEBUG, - "- Install command: " << buildCommand << std::endl); + "- Install command: " << buildCommandStr << std::endl); cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Run preinstall target for: " << installProjectName << std::endl); std::string output; int retVal = 1; bool resB = - cmSystemTools::RunSingleCommand(buildCommand.c_str(), + cmSystemTools::RunSingleCommand(buildCommand, &output, &retVal, installDirectory.c_str(), @@ -658,12 +662,12 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/PreinstallOutput.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << buildCommand.c_str() << std::endl + ofs << "# Run command: " << buildCommandStr.c_str() << std::endl << "# Directory: " << installDirectory.c_str() << std::endl << "# Output:" << std::endl << output.c_str() << std::endl; cmCPackLogger(cmCPackLog::LOG_ERROR, - "Problem running install command: " << buildCommand.c_str() + "Problem running install command: " << buildCommandStr.c_str() << std::endl << "Please check " << tmpFile.c_str() << " for errors" << std::endl); @@ -1142,12 +1146,6 @@ int cmCPackGenerator::Initialize(const char* name, cmMakefile* mf) { this->MakefileMap = mf; this->Name = name; - if ( !this->SetCMakeRoot() ) - { - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Cannot initialize the generator" << std::endl); - return 0; - } // set the running generator name this->SetOption("CPACK_GENERATOR", this->Name.c_str()); // Load the project specific config file @@ -1204,32 +1202,6 @@ const char* cmCPackGenerator::GetOption(const char* op) const } //---------------------------------------------------------------------- -int cmCPackGenerator::SetCMakeRoot() -{ - // use the CMAKE_ROOT from cmake which should have been - // found by now - const char* root= - this->MakefileMap->GetDefinition("CMAKE_ROOT"); - - if(root) - { - this->CMakeRoot = root; - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " - << this->CMakeRoot.c_str() << std::endl); - this->SetOption("CMAKE_ROOT", this->CMakeRoot.c_str()); - return 1; - } - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Could not find CMAKE_ROOT !!!" - << std::endl - << "CMake has most likely not been installed correctly." - << std::endl - <<"Modules directory not found in" - << std::endl); - return 0; -} - -//---------------------------------------------------------------------- int cmCPackGenerator::PackageFiles() { return 0; @@ -1263,14 +1235,14 @@ const char* cmCPackGenerator::GetInstallPath() this->InstallPath += "-"; this->InstallPath += this->GetOption("CPACK_PACKAGE_VERSION"); #elif defined(__HAIKU__) - BPath dir; - if (find_directory(B_COMMON_DIRECTORY, &dir) == B_OK) + char dir[B_PATH_NAME_LENGTH]; + if (find_directory(B_SYSTEM_DIRECTORY, -1, false, dir, sizeof(dir)) == B_OK) { - this->InstallPath = dir.Path(); + this->InstallPath = dir; } else { - this->InstallPath = "/boot/common"; + this->InstallPath = "/boot/system"; } #else this->InstallPath = "/usr/local/"; @@ -1561,13 +1533,13 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name) component->DisplayName = component->Name; } component->IsHidden - = this->IsSet((macroPrefix + "_HIDDEN").c_str()); + = this->IsOn((macroPrefix + "_HIDDEN").c_str()); component->IsRequired - = this->IsSet((macroPrefix + "_REQUIRED").c_str()); + = this->IsOn((macroPrefix + "_REQUIRED").c_str()); component->IsDisabledByDefault - = this->IsSet((macroPrefix + "_DISABLED").c_str()); + = this->IsOn((macroPrefix + "_DISABLED").c_str()); component->IsDownloaded - = this->IsSet((macroPrefix + "_DOWNLOADED").c_str()) + = this->IsOn((macroPrefix + "_DOWNLOADED").c_str()) || cmSystemTools::IsOn(this->GetOption("CPACK_DOWNLOAD_ALL")); const char* archiveFile = this->GetOption((macroPrefix + @@ -1664,9 +1636,9 @@ cmCPackGenerator::GetComponentGroup(const char *projectName, const char *name) group->Description = description; } group->IsBold - = this->IsSet((macroPrefix + "_BOLD_TITLE").c_str()); + = this->IsOn((macroPrefix + "_BOLD_TITLE").c_str()); group->IsExpandedByDefault - = this->IsSet((macroPrefix + "_EXPANDED").c_str()); + = this->IsOn((macroPrefix + "_EXPANDED").c_str()); const char* parentGroupName = this->GetOption((macroPrefix + "_PARENT_GROUP").c_str()); if (parentGroupName && *parentGroupName) diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index 8fafef9..bb33aa0 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -105,9 +105,6 @@ public: bool IsSet(const char* name) const; bool IsOn(const char* name) const; - //! Set all the variables - int SetCMakeRoot(); - //! Set the logger void SetLogger(cmCPackLog* log) { this->Logger = log; } @@ -160,9 +157,10 @@ protected: * CPack specific generator may mangle CPACK_PACKAGE_FILE_NAME * with CPACK_COMPONENT_xxxx_<NAME>_DISPLAY_NAME if * CPACK_<GEN>_USE_DISPLAY_NAME_IN_FILENAME is ON. - * @param[in] initialPackageFileName - * @param[in] groupOrComponentName - * @param[in] isGroupName + * @param[in] initialPackageFileName the initial package name to be mangled + * @param[in] groupOrComponentName the name of the group/component + * @param[in] isGroupName true if previous name refers to a group, + * false otherwise */ virtual std::string GetComponentPackageFileName( const std::string& initialPackageFileName, @@ -172,7 +170,7 @@ protected: /** * Package the list of files and/or components which * has been prepared by the beginning of DoPackage. - * @pre @ref toplevel has been filled-in + * @pre the @ref toplevel has been filled-in * @pre the list of file @ref files has been populated * @pre packageFileNames contains at least 1 entry * @post packageFileNames may have been updated and contains @@ -284,10 +282,6 @@ protected: */ std::vector<std::string> files; - std::string CPackSelf; - std::string CMakeSelf; - std::string CMakeRoot; - std::map<std::string, cmCPackInstallationType> InstallationTypes; /** * The set of components. diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index c617a3e..c5b9c6f 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -22,6 +22,7 @@ #include <cmsys/SystemTools.hxx> #include <cmsys/Glob.hxx> +#include <cmsys/FStream.hxx> //---------------------------------------------------------------------- cmCPackPackageMakerGenerator::cmCPackPackageMakerGenerator() @@ -467,7 +468,7 @@ int cmCPackPackageMakerGenerator::InitializeInternal() return 0; } - std::ifstream ifs(versionFile.c_str()); + cmsys::ifstream ifs(versionFile.c_str()); if ( !ifs ) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -716,7 +717,7 @@ GenerateComponentPackage(const char *packageFile, // X packages, which work on Mac OS X 10.3 and newer. std::string descriptionFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); descriptionFile += '/' + component.Name + "-Description.plist"; - std::ofstream out(descriptionFile.c_str()); + cmsys::ofstream out(descriptionFile.c_str()); out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl << "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\"" << "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" << std::endl diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index 9b6cf14..8342fee 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -20,6 +20,7 @@ #include "cmCPackLog.h" #include <cmsys/ios/sstream> +#include <cmsys/FStream.hxx> #include <sys/types.h> #include <sys/stat.h> @@ -91,7 +92,7 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os) std::string inLicFile = this->GetOption("CPACK_RESOURCE_FILE_LICENSE"); std::string line; - std::ifstream ilfs(inLicFile.c_str()); + cmsys::ifstream ilfs(inLicFile.c_str()); std::string licenseText; while ( cmSystemTools::GetLineFromStream(ilfs, line) ) { @@ -104,7 +105,7 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os) // Create the header std::string inFile = this->GetOption("CPACK_STGZ_HEADER_FILE"); - std::ifstream ifs(inFile.c_str()); + cmsys::ifstream ifs(inFile.c_str()); std::string packageHeaderText; while ( cmSystemTools::GetLineFromStream(ifs, line) ) { diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index b188918..a19b778 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -14,8 +14,6 @@ // Need these for documentation support. #include "cmake.h" #include "cmDocumentation.h" -#include "cmCPackDocumentVariables.h" -#include "cmCPackDocumentMacros.h" #include "cmCPackGeneratorFactory.h" #include "cmCPackGenerator.h" #include "cmake.h" @@ -27,114 +25,38 @@ #include <cmsys/CommandLineArguments.hxx> #include <cmsys/SystemTools.hxx> +#include <cmsys/Encoding.hxx> //---------------------------------------------------------------------------- -static const char * cmDocumentationName[][3] = +static const char * cmDocumentationName[][2] = { {0, - " cpack - Packaging driver provided by CMake.", 0}, - {0,0,0} + " cpack - Packaging driver provided by CMake."}, + {0,0} }; //---------------------------------------------------------------------------- -static const char * cmDocumentationUsage[][3] = +static const char * cmDocumentationUsage[][2] = { {0, - " cpack -G <generator> [options]", - 0}, - {0,0,0} + " cpack -G <generator> [options]"}, + {0,0} }; //---------------------------------------------------------------------------- -static const char * cmDocumentationDescription[][3] = +static const char * cmDocumentationOptions[][2] = { - {0, - "The \"cpack\" executable is the CMake packaging program. " - "CMake-generated build trees created for projects that use " - "the INSTALL_* commands have packaging support. " - "This program will generate the package.", 0}, - CMAKE_STANDARD_INTRODUCTION, - {0,0,0} -}; - -//---------------------------------------------------------------------------- -static const char * cmDocumentationOptions[][3] = -{ - {"-G <generator>", "Use the specified generator to generate package.", - "CPack may support multiple native packaging systems on certain " - "platforms. A generator is responsible for generating input files for " - "particular system and invoking that systems. Possible generator names " - "are specified in the Generators section." }, - {"-C <Configuration>", "Specify the project configuration", - "This option specifies the configuration that the project was build " - "with, for example 'Debug', 'Release'." }, - {"-D <var>=<value>", "Set a CPack variable.", \ - "Set a variable that can be used by the generator."}, \ - {"--config <config file>", "Specify the config file.", - "Specify the config file to use to create the package. By default " - "CPackConfig.cmake in the current directory will be used." }, - {"--verbose,-V","enable verbose output","Run cpack with verbose output."}, - {"--debug","enable debug output (for CPack developers)", - "Run cpack with debug output (for CPack developers)."}, - {"-P <package name>","override/define CPACK_PACKAGE_NAME", - "If the package name is not specified on cpack commmand line then" - "CPack.cmake defines it as CMAKE_PROJECT_NAME"}, - {"-R <package version>","override/define CPACK_PACKAGE_VERSION", - "If version is not specified on cpack command line then" - "CPack.cmake defines it from CPACK_PACKAGE_VERSION_[MAJOR|MINOR|PATCH]" - "look into CPack.cmake for detail"}, - {"-B <package directory>","override/define CPACK_PACKAGE_DIRECTORY", - "The directory where CPack will be doing its packaging work." - "The resulting package will be found there. Inside this directory" - "CPack creates '_CPack_Packages' sub-directory which is the" - "CPack temporary directory."}, - {"--vendor <vendor name>","override/define CPACK_PACKAGE_VENDOR", - "If vendor is not specified on cpack command line " - "(or inside CMakeLists.txt) then" - "CPack.cmake defines it with a default value"}, - {"--help-command cmd [file]", "Print help for a single command and exit.", - "Full documentation specific to the given command is displayed. " - "If a file is specified, the documentation is written into and the output " - "format is determined depending on the filename suffix. Supported are man " - "page, HTML, DocBook and plain text."}, - {"--help-command-list [file]", "List available commands and exit.", - "The list contains all commands for which help may be obtained by using " - "the --help-command argument followed by a command name. " - "If a file is specified, the documentation is written into and the output " - "format is determined depending on the filename suffix. Supported are man " - "page, HTML, DocBook and plain text."}, - {"--help-commands [file]", "Print help for all commands and exit.", - "Full documentation specific for all current command is displayed." - "If a file is specified, the documentation is written into and the output " - "format is determined depending on the filename suffix. Supported are man " - "page, HTML, DocBook and plain text."}, - {"--help-variable var [file]", - "Print help for a single variable and exit.", - "Full documentation specific to the given variable is displayed." - "If a file is specified, the documentation is written into and the output " - "format is determined depending on the filename suffix. Supported are man " - "page, HTML, DocBook and plain text."}, - {"--help-variable-list [file]", "List documented variables and exit.", - "The list contains all variables for which help may be obtained by using " - "the --help-variable argument followed by a variable name. If a file is " - "specified, the help is written into it." - "If a file is specified, the documentation is written into and the output " - "format is determined depending on the filename suffix. Supported are man " - "page, HTML, DocBook and plain text."}, - {"--help-variables [file]", "Print help for all variables and exit.", - "Full documentation for all variables is displayed." - "If a file is specified, the documentation is written into and the output " - "format is determined depending on the filename suffix. Supported are man " - "page, HTML, DocBook and plain text."}, - {0,0,0} -}; - -//---------------------------------------------------------------------------- -static const char * cmDocumentationSeeAlso[][3] = -{ - {0, "cmake", 0}, - {0, "ccmake", 0}, - {0, 0, 0} + {"-G <generator>", "Use the specified generator to generate package."}, + {"-C <Configuration>", "Specify the project configuration"}, + {"-D <var>=<value>", "Set a CPack variable."}, + {"--config <config file>", "Specify the config file."}, + {"--verbose,-V","enable verbose output"}, + {"--debug","enable debug output (for CPack developers)"}, + {"-P <package name>","override/define CPACK_PACKAGE_NAME"}, + {"-R <package version>","override/define CPACK_PACKAGE_VERSION"}, + {"-B <package directory>","override/define CPACK_PACKAGE_DIRECTORY"}, + {"--vendor <vendor name>","override/define CPACK_PACKAGE_VENDOR"}, + {0,0} }; //---------------------------------------------------------------------------- @@ -176,9 +98,14 @@ int cpackDefinitionArgument(const char* argument, const char* cValue, //---------------------------------------------------------------------------- // this is CPack. -int main (int argc, char *argv[]) +int main (int argc, char const* const* argv) { - cmSystemTools::FindExecutableDirectory(argv[0]); + cmsys::Encoding::CommandLineArguments args = + cmsys::Encoding::CommandLineArguments::Main(argc, argv); + argc = args.argc(); + argv = args.argv(); + + cmSystemTools::FindCMakeResources(argv[0]); cmCPackLog log; log.SetErrorPrefix("CPack Error: "); @@ -481,11 +408,6 @@ int main (int argc, char *argv[]) } if ( parsed ) { -#ifdef _WIN32 - std::string comspec = "cmw9xcom.exe"; - cmSystemTools::SetWindows9xComspecSubstitute(comspec.c_str()); -#endif - const char* projName = mf->GetDefinition("CPACK_PACKAGE_NAME"); cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: " << cpackGenerator->GetNameOfClass() << std::endl); @@ -533,43 +455,8 @@ int main (int argc, char *argv[]) doc.SetName("cpack"); doc.SetSection("Name",cmDocumentationName); doc.SetSection("Usage",cmDocumentationUsage); - doc.SetSection("Description",cmDocumentationDescription); doc.PrependSection("Options",cmDocumentationOptions); - // statically (in C++ code) defined variables - cmCPackDocumentVariables::DefineVariables(&cminst); - - std::vector<cmDocumentationEntry> commands; - - std::string docedFile; - std::string docPath; - cmDocumentation::documentedModulesList_t docedModList; - - docedFile = globalMF->GetModulesFile("CPack.cmake"); - if (docedFile.length()!=0) - { - docPath = cmSystemTools::GetFilenamePath(docedFile.c_str()); - doc.getDocumentedModulesListInDir(docPath,"CPack*.cmake",docedModList); - } - - // parse the files for documentation. - cmDocumentation::documentedModulesList_t::iterator docedIt; - for (docedIt = docedModList.begin(); - docedIt!= docedModList.end(); ++docedIt) - { - doc.GetStructuredDocFromFile( - (docedIt->first).c_str(), - commands,&cminst); - } - - std::map<std::string,cmDocumentationSection *> propDocs; - cminst.GetPropertiesDocumentation(propDocs); - doc.SetSections(propDocs); - cminst.GetCommandDocumentation(commands,true,false); - // statically (in C++ code) defined macros/commands - cmCPackDocumentMacros::GetMacrosDocumentation(commands); - doc.SetSection("Commands",commands); - std::vector<cmDocumentationEntry> v; cmCPackGeneratorFactory::DescriptionsMap::const_iterator generatorIt; for( generatorIt = generators.GetGeneratorsList().begin(); @@ -579,12 +466,10 @@ int main (int argc, char *argv[]) cmDocumentationEntry e; e.Name = generatorIt->first.c_str(); e.Brief = generatorIt->second.c_str(); - e.Full = ""; v.push_back(e); } doc.SetSection("Generators",v); - doc.SetSeeAlsoList(cmDocumentationSeeAlso); #undef cout return doc.PrintRequestedDocumentation(std::cout)? 0:1; #define cout no_cout_use_cmCPack_Log diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index 4fa3c53..0fac136 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -18,6 +18,7 @@ #include "cmGlobalGenerator.h" #include <cmsys/Process.h> #include "cmCTestTestHandler.h" +#include "cmCacheManager.h" //---------------------------------------------------------------------- cmCTestBuildAndTestHandler::cmCTestBuildAndTestHandler() @@ -59,7 +60,7 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, { unsigned int k; std::vector<std::string> args; - args.push_back(this->CTest->GetCMakeExecutable()); + args.push_back(cmSystemTools::GetCMakeCommand()); args.push_back(this->SourceDir); if(this->BuildGenerator.size()) { @@ -184,14 +185,14 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) cmOStringStream out; // if the generator and make program are not specified then it is an error - if (!this->BuildGenerator.size() || !this->BuildMakeProgram.size()) + if (!this->BuildGenerator.size()) { if(outstring) { *outstring = - "--build-and-test requires that both the generator and makeprogram " - "be provided using the --build-generator and --build-makeprogram " - "command line options. "; + "--build-and-test requires that the generator " + "be provided using the --build-generator " + "command line option. "; } return 1; } @@ -238,9 +239,13 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) if(this->BuildNoCMake) { + // Make the generator available for the Build call below. cm.SetGlobalGenerator(cm.CreateGlobalGenerator( this->BuildGenerator.c_str())); cm.SetGeneratorToolset(this->BuildGeneratorToolset); + + // Load the cache to make CMAKE_MAKE_PROGRAM available. + cm.GetCacheManager()->LoadCache(this->BinaryDir.c_str()); } else { @@ -508,23 +513,14 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments( { this->BuildNoClean = true; } - if(currentArg.find("--build-options",0) == 0 && idx < allArgs.size() - 1) + if(currentArg.find("--build-options",0) == 0) { - ++idx; - bool done = false; - while(idx < allArgs.size() && !done) + while(idx+1 < allArgs.size() && + allArgs[idx+1] != "--build-target" && + allArgs[idx+1] != "--test-command") { + ++idx; this->BuildOptions.push_back(allArgs[idx]); - if(idx+1 < allArgs.size() - && (allArgs[idx+1] == "--build-target" || - allArgs[idx+1] == "--test-command")) - { - done = true; - } - else - { - ++idx; - } } } if(currentArg.find("--test-command",0) == 0 && idx < allArgs.size() - 1) diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index 1f63185..12ff718 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -114,9 +114,6 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() this->Makefile->GetCMakeInstance()->CreateGlobalGenerator( cmakeGeneratorName); } - this->GlobalGenerator->FindMakeProgram(this->Makefile); - const char* cmakeMakeProgram - = this->Makefile->GetDefinition("CMAKE_MAKE_PROGRAM"); if(strlen(cmakeBuildConfiguration) == 0) { const char* config = 0; @@ -133,10 +130,8 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory"); std::string buildCommand = this->GlobalGenerator-> - GenerateBuildCommand(cmakeMakeProgram, - cmakeProjectName, dir.c_str(), - cmakeBuildAdditionalFlags, cmakeBuildTarget, - cmakeBuildConfiguration, true, false); + GenerateCMakeBuildCommand(cmakeBuildTarget, cmakeBuildConfiguration, + cmakeBuildAdditionalFlags, true); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "SetMakeCommand:" << buildCommand.c_str() << "\n"); diff --git a/Source/CTest/cmCTestBuildCommand.h b/Source/CTest/cmCTestBuildCommand.h index cabc39b..08887fe 100644 --- a/Source/CTest/cmCTestBuildCommand.h +++ b/Source/CTest/cmCTestBuildCommand.h @@ -45,34 +45,8 @@ public: */ virtual const char* GetName() const { return "ctest_build";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Build the project."; - } virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " ctest_build([BUILD build_dir] [TARGET target] [RETURN_VALUE res]\n" - " [APPEND][NUMBER_ERRORS val] [NUMBER_WARNINGS val])\n" - "Builds the given build directory and stores results in Build.xml. " - "If no BUILD is given, the CTEST_BINARY_DIRECTORY variable is used.\n" - "The TARGET variable can be used to specify a build target. If none " - "is specified, the \"all\" target will be built.\n" - "The RETURN_VALUE option specifies a variable in which to store the " - "return value of the native build tool. " - "The NUMBER_ERRORS and NUMBER_WARNINGS options specify variables in " - "which to store the number of build errors and warnings detected." - "\n" - CTEST_COMMAND_APPEND_OPTION_DOCS; - } cmTypeMacro(cmCTestBuildCommand, cmCTestHandlerCommand); diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 39eeb70..c5deb96 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -24,6 +24,7 @@ //#include <cmsys/RegularExpression.hxx> #include <cmsys/Process.h> #include <cmsys/Directory.hxx> +#include <cmsys/FStream.hxx> // used for sleep #ifdef _WIN32 @@ -751,7 +752,7 @@ void cmCTestBuildHandler::GenerateXMLFooter(std::ostream& os, void cmCTestBuildHandler::GenerateXMLLaunchedFragment(std::ostream& os, const char* fname) { - std::ifstream fin(fname, std::ios::in | std::ios::binary); + cmsys::ifstream fin(fname, std::ios::in | std::ios::binary); std::string line; while(cmSystemTools::GetLineFromStream(fin, line)) { @@ -763,7 +764,7 @@ void cmCTestBuildHandler::GenerateXMLLaunchedFragment(std::ostream& os, bool cmCTestBuildHandler::IsLaunchedErrorFile(const char* fname) { // error-{hash}.xml - return (strncmp(fname, "error-", 6) == 0 && + return (cmHasLiteralPrefix(fname, "error-") && strcmp(fname+strlen(fname)-4, ".xml") == 0); } @@ -771,7 +772,7 @@ bool cmCTestBuildHandler::IsLaunchedErrorFile(const char* fname) bool cmCTestBuildHandler::IsLaunchedWarningFile(const char* fname) { // warning-{hash}.xml - return (strncmp(fname, "warning-", 8) == 0 && + return (cmHasLiteralPrefix(fname, "warning-") && strcmp(fname+strlen(fname)-4, ".xml") == 0); } @@ -885,7 +886,7 @@ cmCTestBuildHandler::LaunchHelper //---------------------------------------------------------------------- int cmCTestBuildHandler::RunMakeCommand(const char* command, - int* retVal, const char* dir, int timeout, std::ofstream& ofs) + int* retVal, const char* dir, int timeout, std::ostream& ofs) { // First generate the command and arguments std::vector<cmStdString> args = cmSystemTools::ParseArguments(command); @@ -1049,7 +1050,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, //---------------------------------------------------------------------- void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, - size_t& tick, size_t tick_len, std::ofstream& ofs, + size_t& tick, size_t tick_len, std::ostream& ofs, t_BuildProcessingQueueType* queue) { const std::string::size_type tick_line_len = 50; diff --git a/Source/CTest/cmCTestBuildHandler.h b/Source/CTest/cmCTestBuildHandler.h index 439efd6..ff7cfd6 100644 --- a/Source/CTest/cmCTestBuildHandler.h +++ b/Source/CTest/cmCTestBuildHandler.h @@ -54,7 +54,7 @@ private: // and retVal is return value or exception. int RunMakeCommand(const char* command, int* retVal, const char* dir, int timeout, - std::ofstream& ofs); + std::ostream& ofs); enum { b_REGULAR_LINE, @@ -113,7 +113,7 @@ private: typedef std::deque<char> t_BuildProcessingQueueType; void ProcessBuffer(const char* data, int length, size_t& tick, - size_t tick_len, std::ofstream& ofs, t_BuildProcessingQueueType* queue); + size_t tick_len, std::ostream& ofs, t_BuildProcessingQueueType* queue); int ProcessSingleLine(const char* data); t_BuildProcessingQueueType BuildProcessingQueue; diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx index 7269507..17dbb55 100644 --- a/Source/CTest/cmCTestCVS.cxx +++ b/Source/CTest/cmCTestCVS.cxx @@ -16,6 +16,7 @@ #include "cmXMLSafe.h" #include <cmsys/RegularExpression.hxx> +#include <cmsys/FStream.hxx> //---------------------------------------------------------------------------- cmCTestCVS::cmCTestCVS(cmCTest* ct, std::ostream& log): cmCTestVC(ct, log) @@ -231,7 +232,7 @@ std::string cmCTestCVS::ComputeBranchFlag(std::string const& dir) // Lookup the branch in the tag file, if any. std::string tagLine; - std::ifstream tagStream(tagFile.c_str()); + cmsys::ifstream tagStream(tagFile.c_str()); if(tagStream && cmSystemTools::GetLineFromStream(tagStream, tagLine) && tagLine.size() > 1 && tagLine[0] == 'T') { diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index db33cb6..5eed409 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -86,7 +86,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() } std::string cmakeConfigureCommand = "\""; - cmakeConfigureCommand += this->CTest->GetCMakeExecutable(); + cmakeConfigureCommand += cmSystemTools::GetCMakeCommand(); cmakeConfigureCommand += "\""; std::vector<std::string>::const_iterator it; diff --git a/Source/CTest/cmCTestConfigureCommand.h b/Source/CTest/cmCTestConfigureCommand.h index b343fc1..b592c5a 100644 --- a/Source/CTest/cmCTestConfigureCommand.h +++ b/Source/CTest/cmCTestConfigureCommand.h @@ -40,34 +40,6 @@ public: */ virtual const char* GetName() const { return "ctest_configure";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Configure the project build tree."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " ctest_configure([BUILD build_dir] [SOURCE source_dir] [APPEND]\n" - " [OPTIONS options] [RETURN_VALUE res])\n" - "Configures the given build directory and stores results in " - "Configure.xml. " - "If no BUILD is given, the CTEST_BINARY_DIRECTORY variable is used. " - "If no SOURCE is given, the CTEST_SOURCE_DIRECTORY variable is used. " - "The OPTIONS argument specifies command line arguments to pass to " - "the configuration tool. " - "The RETURN_VALUE option specifies a variable in which to store the " - "return value of the native build tool." - "\n" - CTEST_COMMAND_APPEND_OPTION_DOCS; - } - cmTypeMacro(cmCTestConfigureCommand, cmCTestHandlerCommand); protected: diff --git a/Source/CTest/cmCTestCoverageCommand.h b/Source/CTest/cmCTestCoverageCommand.h index 2fe762c..11bb411 100644 --- a/Source/CTest/cmCTestCoverageCommand.h +++ b/Source/CTest/cmCTestCoverageCommand.h @@ -41,32 +41,6 @@ public: */ virtual const char* GetName() const { return "ctest_coverage";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Collect coverage tool results."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " ctest_coverage([BUILD build_dir] [RETURN_VALUE res] [APPEND]\n" - " [LABELS label1 [label2 [...]]])\n" - "Perform the coverage of the given build directory and stores results " - "in Coverage.xml. The second argument is a variable that will hold " - "value." - "\n" - "The LABELS option filters the coverage report to include only " - "source files labeled with at least one of the labels specified." - "\n" - CTEST_COMMAND_APPEND_OPTION_DOCS; - } - cmTypeMacro(cmCTestCoverageCommand, cmCTestHandlerCommand); protected: diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 20aded2..3c65c55 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -11,6 +11,7 @@ ============================================================================*/ #include "cmCTestCoverageHandler.h" #include "cmParsePHPCoverage.h" +#include "cmParsePythonCoverage.h" #include "cmParseGTMCoverage.h" #include "cmParseCacheCoverage.h" #include "cmCTest.h" @@ -25,6 +26,7 @@ #include <cmsys/Glob.hxx> #include <cmsys/stl/iterator> #include <cmsys/stl/algorithm> +#include <cmsys/FStream.hxx> #include <stdlib.h> #include <math.h> @@ -141,6 +143,7 @@ void cmCTestCoverageHandler::Initialize() this->Superclass::Initialize(); this->CustomCoverageExclude.clear(); this->SourceLabels.clear(); + this->TargetDirs.clear(); this->LabelIdMap.clear(); this->Labels.clear(); this->LabelFilter.clear(); @@ -392,6 +395,13 @@ int cmCTestCoverageHandler::ProcessHandler() { return error; } + file_count += this->HandlePythonCoverage(&cont); + error = cont.Error; + if ( file_count < 0 ) + { + return error; + } + file_count += this->HandleMumpsCoverage(&cont); error = cont.Error; if ( file_count < 0 ) @@ -502,7 +512,7 @@ int cmCTestCoverageHandler::ProcessHandler() << "\" FullPath=\"" << cmXMLSafe(shortFileName) << "\">\n" << "\t\t<Report>" << std::endl; - std::ifstream ifs(fullFileName.c_str()); + cmsys::ifstream ifs(fullFileName.c_str()); if ( !ifs) { cmOStringStream ostr; @@ -591,7 +601,7 @@ int cmCTestCoverageHandler::ProcessHandler() << "\" FullPath=\"" << cmXMLSafe(*i) << "\">\n" << "\t\t<Report>" << std::endl; - std::ifstream ifs(fullPath.c_str()); + cmsys::ifstream ifs(fullPath.c_str()); if (!ifs) { cmOStringStream ostr; @@ -761,6 +771,32 @@ int cmCTestCoverageHandler::HandlePHPCoverage( } return static_cast<int>(cont->TotalCoverage.size()); } + +//---------------------------------------------------------------------- +int cmCTestCoverageHandler::HandlePythonCoverage( + cmCTestCoverageHandlerContainer* cont) +{ + cmParsePythonCoverage cov(*cont, this->CTest); + + // Assume the coverage.xml is in the source directory + std::string coverageXMLFile = this->CTest->GetBinaryDir() + "/coverage.xml"; + + if(cmSystemTools::FileExists(coverageXMLFile.c_str())) + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Parsing coverage.py XML file: " << coverageXMLFile + << std::endl); + cov.ReadCoverageXML(coverageXMLFile.c_str()); + } + else + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Cannot find coverage.py XML file: " << coverageXMLFile + << std::endl); + } + return static_cast<int>(cont->TotalCoverage.size()); +} + //---------------------------------------------------------------------- int cmCTestCoverageHandler::HandleMumpsCoverage( cmCTestCoverageHandlerContainer* cont) @@ -1123,7 +1159,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " in gcovFile: " << gcovFile << std::endl); - std::ifstream ifile(gcovFile.c_str()); + cmsys::ifstream ifile(gcovFile.c_str()); if ( ! ifile ) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: " @@ -1335,7 +1371,7 @@ int cmCTestCoverageHandler::HandleTracePyCoverage( = &cont->TotalCoverage[actualSourceFile]; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " in file: " << fileIt->c_str() << std::endl); - std::ifstream ifile(fileIt->c_str()); + cmsys::ifstream ifile(fileIt->c_str()); if ( ! ifile ) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: " @@ -1495,7 +1531,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch( "covbr output in " << outputFile << std::endl); // open the output file - std::ifstream fin(outputFile.c_str()); + cmsys::ifstream fin(outputFile.c_str()); if(!fin) { cmCTestLog(this->CTest, ERROR_MESSAGE, @@ -1708,7 +1744,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary( std::vector<std::string> coveredFiles; std::vector<std::string> coveredFilesFullPath; // Read and parse the summary output file - std::ifstream fin(outputFile.c_str()); + cmsys::ifstream fin(outputFile.c_str()); if(!fin) { cmCTestLog(this->CTest, ERROR_MESSAGE, @@ -1977,7 +2013,7 @@ void cmCTestCoverageHandler::LoadLabels() fileList += "/TargetDirectories.txt"; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " target directory list [" << fileList << "]\n"); - std::ifstream finList(fileList.c_str()); + cmsys::ifstream finList(fileList.c_str()); std::string line; while(cmSystemTools::GetLineFromStream(finList, line)) { @@ -1991,7 +2027,7 @@ void cmCTestCoverageHandler::LoadLabels(const char* dir) LabelSet& dirLabels = this->TargetDirs[dir]; std::string fname = dir; fname += "/Labels.txt"; - std::ifstream fin(fname.c_str()); + cmsys::ifstream fin(fname.c_str()); if(!fin) { return; @@ -2045,7 +2081,7 @@ void cmCTestCoverageHandler::LoadLabels(const char* dir) } //---------------------------------------------------------------------- -void cmCTestCoverageHandler::WriteXMLLabels(std::ofstream& os, +void cmCTestCoverageHandler::WriteXMLLabels(std::ostream& os, std::string const& source) { LabelMapType::const_iterator li = this->SourceLabels.find(source); diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h index 92b0b22..660f501 100644 --- a/Source/CTest/cmCTestCoverageHandler.h +++ b/Source/CTest/cmCTestCoverageHandler.h @@ -70,6 +70,10 @@ private: //! Handle coverage using xdebug php coverage int HandlePHPCoverage(cmCTestCoverageHandlerContainer* cont); + + //! Handle coverage for Python with coverage.py + int HandlePythonCoverage(cmCTestCoverageHandlerContainer* cont); + //! Handle coverage for mumps int HandleMumpsCoverage(cmCTestCoverageHandlerContainer* cont); @@ -128,7 +132,7 @@ private: // Label reading and writing methods. void LoadLabels(); void LoadLabels(const char* dir); - void WriteXMLLabels(std::ofstream& os, std::string const& source); + void WriteXMLLabels(std::ostream& os, std::string const& source); // Label-based filtering. std::set<int> LabelFilter; diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h index a763fe9..07e59a4 100644 --- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h +++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h @@ -50,26 +50,6 @@ public: */ virtual const char* GetName() const { return "ctest_empty_binary_directory";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "empties the binary directory"; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " ctest_empty_binary_directory( directory )\n" - "Removes a binary directory. This command will perform some checks " - "prior to deleting the directory in an attempt to avoid malicious " - "or accidental directory deletion."; - } - cmTypeMacro(cmCTestEmptyBinaryDirectoryCommand, cmCTestCommand); }; diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 5b34491..0e0e797 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -18,6 +18,7 @@ #include <cmsys/RegularExpression.hxx> #include <cmsys/ios/sstream> #include <cmsys/Process.h> +#include <cmsys/FStream.hxx> #include <sys/types.h> #include <time.h> @@ -200,7 +201,7 @@ bool cmCTestGIT::UpdateByFetchAndReset() std::string sha1; { std::string fetch_head = this->FindGitDir() + "/FETCH_HEAD"; - std::ifstream fin(fetch_head.c_str(), std::ios::in | std::ios::binary); + cmsys::ifstream fin(fetch_head.c_str(), std::ios::in | std::ios::binary); if(!fin) { this->Log << "Unable to open " << fetch_head << "\n"; @@ -536,11 +537,11 @@ private: void DoHeaderLine() { // Look for header fields that we need. - if(strncmp(this->Line.c_str(), "commit ", 7) == 0) + if(cmHasLiteralPrefix(this->Line.c_str(), "commit ")) { this->Rev.Rev = this->Line.c_str()+7; } - else if(strncmp(this->Line.c_str(), "author ", 7) == 0) + else if(cmHasLiteralPrefix(this->Line.c_str(), "author ")) { Person author; this->ParsePerson(this->Line.c_str()+7, author); @@ -548,7 +549,7 @@ private: this->Rev.EMail = author.EMail; this->Rev.Date = this->FormatDateTime(author); } - else if(strncmp(this->Line.c_str(), "committer ", 10) == 0) + else if(cmHasLiteralPrefix(this->Line.c_str(), "committer ")) { Person committer; this->ParsePerson(this->Line.c_str()+10, committer); diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index 9831d02..7d9c034 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -19,6 +19,7 @@ #include <cmsys/MD5.h> #include <cmsys/Process.h> #include <cmsys/RegularExpression.hxx> +#include <cmsys/FStream.hxx> //---------------------------------------------------------------------------- cmCTestLaunch::cmCTestLaunch(int argc, const char* const* argv) @@ -64,7 +65,8 @@ bool cmCTestLaunch::ParseArguments(int argc, const char* const* argv) DoingTargetName, DoingTargetType, DoingBuildDir, - DoingCount }; + DoingCount, + DoingFilterPrefix }; Doing doing = DoingNone; int arg0 = 0; for(int i=1; !arg0 && i < argc; ++i) @@ -98,6 +100,10 @@ bool cmCTestLaunch::ParseArguments(int argc, const char* const* argv) { doing = DoingBuildDir; } + else if(strcmp(arg, "--filter-prefix") == 0) + { + doing = DoingFilterPrefix; + } else if(doing == DoingOutput) { this->OptionOutput = arg; @@ -132,6 +138,11 @@ bool cmCTestLaunch::ParseArguments(int argc, const char* const* argv) this->OptionBuildDir = arg; doing = DoingNone; } + else if(doing == DoingFilterPrefix) + { + this->OptionFilterPrefix = arg; + doing = DoingNone; + } } // Extract the real command line. @@ -161,7 +172,7 @@ void cmCTestLaunch::HandleRealArg(const char* arg) // Expand response file arguments. if(arg[0] == '@' && cmSystemTools::FileExists(arg+1)) { - std::ifstream fin(arg+1); + cmsys::ifstream fin(arg+1); std::string line; while(cmSystemTools::GetLineFromStream(fin, line)) { @@ -231,8 +242,8 @@ void cmCTestLaunch::RunChild() cmsysProcess* cp = this->Process; cmsysProcess_SetCommand(cp, this->RealArgV); - std::ofstream fout; - std::ofstream ferr; + cmsys::ofstream fout; + cmsys::ofstream ferr; if(this->Passthru) { // In passthru mode we just share the output pipes. @@ -320,7 +331,7 @@ void cmCTestLaunch::LoadLabels() cmSystemTools::ConvertToUnixSlashes(source); // Load the labels file. - std::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary); + cmsys::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary); if(!fin) { return; } bool inTarget = true; bool inSource = false; @@ -569,12 +580,19 @@ void cmCTestLaunch::WriteXMLLabels(std::ostream& fxml) void cmCTestLaunch::DumpFileToXML(std::ostream& fxml, std::string const& fname) { - std::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary); + cmsys::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary); std::string line; const char* sep = ""; + while(cmSystemTools::GetLineFromStream(fin, line)) { + if(OptionFilterPrefix.size() && cmSystemTools::StringStartsWith( + line.c_str(), OptionFilterPrefix.c_str())) + { + continue; + } + fxml << sep << cmXMLSafe(line).Quotes(false); sep = "\n"; } @@ -635,7 +653,7 @@ cmCTestLaunch fname += "Custom"; fname += purpose; fname += ".txt"; - std::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary); + cmsys::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary); std::string line; cmsys::RegularExpression rex; while(cmSystemTools::GetLineFromStream(fin, line)) @@ -654,7 +672,7 @@ bool cmCTestLaunch::ScrapeLog(std::string const& fname) // Look for log file lines matching warning expressions but not // suppression expressions. - std::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary); + cmsys::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary); std::string line; while(cmSystemTools::GetLineFromStream(fin, line)) { diff --git a/Source/CTest/cmCTestLaunch.h b/Source/CTest/cmCTestLaunch.h index 7457e83..a86a9df 100644 --- a/Source/CTest/cmCTestLaunch.h +++ b/Source/CTest/cmCTestLaunch.h @@ -45,6 +45,7 @@ private: std::string OptionTargetName; std::string OptionTargetType; std::string OptionBuildDir; + std::string OptionFilterPrefix; bool ParseArguments(int argc, const char* const* argv); // The real command line appearing after launcher arguments. diff --git a/Source/CTest/cmCTestMemCheckCommand.h b/Source/CTest/cmCTestMemCheckCommand.h index 6db47ae..b50170d 100644 --- a/Source/CTest/cmCTestMemCheckCommand.h +++ b/Source/CTest/cmCTestMemCheckCommand.h @@ -43,40 +43,6 @@ public: */ virtual const char* GetName() const { return "ctest_memcheck";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Run tests with a dynamic analysis tool."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " ctest_memcheck([BUILD build_dir] [RETURN_VALUE res] [APPEND]\n" - " [START start number] [END end number]\n" - " [STRIDE stride number] [EXCLUDE exclude regex ]\n" - " [INCLUDE include regex] \n" - " [EXCLUDE_LABEL exclude regex] \n" - " [INCLUDE_LABEL label regex] \n" - " [PARALLEL_LEVEL level] )\n" - "Tests the given build directory and stores results in MemCheck.xml. " - "The second argument is a variable that will hold value. Optionally, " - "you can specify the starting test number START, the ending test number " - "END, the number of tests to skip between each test STRIDE, a regular " - "expression for tests to run INCLUDE, or a regular expression for tests " - "not to run EXCLUDE. EXCLUDE_LABEL and INCLUDE_LABEL are regular " - "expressions for tests to be included or excluded by the test " - "property LABEL. PARALLEL_LEVEL should be set to a positive number " - "representing the number of tests to be run in parallel." - "\n" - CTEST_COMMAND_APPEND_OPTION_DOCS; - } - cmTypeMacro(cmCTestMemCheckCommand, cmCTestTestCommand); protected: diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 3ae2ac6..fdce04d 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -18,6 +18,7 @@ #include <cmsys/Process.h> #include <cmsys/RegularExpression.hxx> #include <cmsys/Base64.h> +#include <cmsys/FStream.hxx> #include "cmMakefile.h" #include "cmXMLSafe.h" @@ -929,7 +930,7 @@ cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res, } // put a scope around this to close ifs so the file can be removed { - std::ifstream ifs(ofile.c_str()); + cmsys::ifstream ifs(ofile.c_str()); if ( !ifs ) { std::string log = "Cannot read memory tester output file: " + ofile; @@ -984,7 +985,7 @@ cmCTestMemCheckHandler::appendMemTesterOutput(cmCTestTestResult& res, { return; } - std::ifstream ifs(ofile.c_str()); + cmsys::ifstream ifs(ofile.c_str()); if ( !ifs ) { std::string log = "Cannot read memory tester output file: " + ofile; diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 76ddeea..ddd1707 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -17,6 +17,7 @@ #include <stdlib.h> #include <stack> #include <float.h> +#include <cmsys/FStream.hxx> class TestComparator { @@ -41,6 +42,7 @@ cmCTestMultiProcessHandler::cmCTestMultiProcessHandler() this->Completed = 0; this->RunningCount = 0; this->StopTimePassed = false; + this->HasCycles = false; } cmCTestMultiProcessHandler::~cmCTestMultiProcessHandler() @@ -65,6 +67,11 @@ cmCTestMultiProcessHandler::SetTests(TestMap& tests, if(!this->CTest->GetShowOnly()) { this->ReadCostData(); + this->HasCycles = !this->CheckCycles(); + if(this->HasCycles) + { + return; + } this->CreateTestCostList(); } } @@ -79,7 +86,7 @@ void cmCTestMultiProcessHandler::SetParallelLevel(size_t level) void cmCTestMultiProcessHandler::RunTests() { this->CheckResume(); - if(!this->CheckCycles()) + if(this->HasCycles) { return; } @@ -133,6 +140,13 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test) } else { + + for(TestMap::iterator j = this->Tests.begin(); + j != this->Tests.end(); ++j) + { + j->second.erase(test); + } + this->UnlockResources(test); this->Completed++; this->TestFinishMap[test] = true; @@ -205,37 +219,8 @@ bool cmCTestMultiProcessHandler::StartTest(int test) } } - // copy the depend tests locally because when - // a test is finished it will be removed from the depend list - // and we don't want to be iterating a list while removing from it - TestSet depends = this->Tests[test]; - size_t totalDepends = depends.size(); - if(totalDepends) - { - for(TestSet::const_iterator i = depends.begin(); - i != depends.end(); ++i) - { - // if the test is not already running then start it - if(!this->TestRunningMap[*i]) - { - // this test might be finished, but since - // this is a copy of the depend map we might - // still have it - if(!this->TestFinishMap[*i]) - { - // only start one test in this function - return this->StartTest(*i); - } - else - { - // the depend has been and finished - totalDepends--; - } - } - } - } // if there are no depends left then run this test - if(totalDepends == 0) + if(this->Tests[test].empty()) { this->StartTestProcess(test); return true; @@ -262,25 +247,17 @@ void cmCTestMultiProcessHandler::StartNextTests() TestList copy = this->SortedTests; for(TestList::iterator test = copy.begin(); test != copy.end(); ++test) { - //in case this test has already been started due to dependency - if(this->TestRunningMap[*test] || this->TestFinishMap[*test]) - { - continue; - } size_t processors = GetProcessorsUsed(*test); - if(processors > numToStart) - { - return; - } - if(this->StartTest(*test)) + + if(processors <= numToStart && this->StartTest(*test)) { - if(this->StopTimePassed) - { - return; - } - numToStart -= processors; + if(this->StopTimePassed) + { + return; + } + numToStart -= processors; } - if(numToStart == 0) + else if(numToStart == 0) { return; } @@ -349,7 +326,7 @@ void cmCTestMultiProcessHandler::UpdateCostData() if(cmSystemTools::FileExists(fname.c_str())) { - std::ifstream fin; + cmsys::ifstream fin; fin.open(fname.c_str()); std::string line; @@ -408,7 +385,7 @@ void cmCTestMultiProcessHandler::ReadCostData() if(cmSystemTools::FileExists(fname.c_str(), true)) { - std::ifstream fin; + cmsys::ifstream fin; fin.open(fname.c_str()); std::string line; while(std::getline(fin, line)) @@ -472,24 +449,160 @@ int cmCTestMultiProcessHandler::SearchByName(std::string name) //--------------------------------------------------------- void cmCTestMultiProcessHandler::CreateTestCostList() { - for(TestMap::iterator i = this->Tests.begin(); - i != this->Tests.end(); ++i) + if(this->ParallelLevel > 1) { - SortedTests.push_back(i->first); + CreateParallelTestCostList(); + } + else + { + CreateSerialTestCostList(); + } +} - //If the test failed last time, it should be run first, so max the cost. - //Only do this for parallel runs; in non-parallel runs, avoid clobbering - //the test's explicitly set cost. - if(this->ParallelLevel > 1 && - std::find(this->LastTestsFailed.begin(), this->LastTestsFailed.end(), +//--------------------------------------------------------- +void cmCTestMultiProcessHandler::CreateParallelTestCostList() +{ + TestSet alreadySortedTests; + + std::list<TestSet> priorityStack; + priorityStack.push_back(TestSet()); + TestSet &topLevel = priorityStack.back(); + + // In parallel test runs add previously failed tests to the front + // of the cost list and queue other tests for further sorting + for(TestMap::const_iterator i = this->Tests.begin(); + i != this->Tests.end(); ++i) + { + if(std::find(this->LastTestsFailed.begin(), this->LastTestsFailed.end(), this->Properties[i->first]->Name) != this->LastTestsFailed.end()) { - this->Properties[i->first]->Cost = FLT_MAX; + //If the test failed last time, it should be run first. + this->SortedTests.push_back(i->first); + alreadySortedTests.insert(i->first); + } + else + { + topLevel.insert(i->first); } } + // In parallel test runs repeatedly move dependencies of the tests on + // the current dependency level to the next level until no + // further dependencies exist. + while(priorityStack.back().size()) + { + TestSet &previousSet = priorityStack.back(); + priorityStack.push_back(TestSet()); + TestSet ¤tSet = priorityStack.back(); + + for(TestSet::const_iterator i = previousSet.begin(); + i != previousSet.end(); ++i) + { + TestSet const& dependencies = this->Tests[*i]; + for(TestSet::const_iterator j = dependencies.begin(); + j != dependencies.end(); ++j) + { + currentSet.insert(*j); + } + } + + for(TestSet::const_iterator i = currentSet.begin(); + i != currentSet.end(); ++i) + { + previousSet.erase(*i); + } + } + + // Remove the empty dependency level + priorityStack.pop_back(); + + // Reverse iterate over the different dependency levels (deepest first). + // Sort tests within each level by COST and append them to the cost list. + for(std::list<TestSet>::reverse_iterator i = priorityStack.rbegin(); + i != priorityStack.rend(); ++i) + { + TestSet const& currentSet = *i; + TestComparator comp(this); + + TestList sortedCopy; + + for(TestSet::const_iterator j = currentSet.begin(); + j != currentSet.end(); ++j) + { + sortedCopy.push_back(*j); + } + + std::stable_sort(sortedCopy.begin(), sortedCopy.end(), comp); + + for(TestList::const_iterator j = sortedCopy.begin(); + j != sortedCopy.end(); ++j) + { + if(alreadySortedTests.find(*j) == alreadySortedTests.end()) + { + this->SortedTests.push_back(*j); + alreadySortedTests.insert(*j); + } + } + } +} + +//--------------------------------------------------------- +void cmCTestMultiProcessHandler::GetAllTestDependencies( + int test, TestList& dependencies) +{ + TestSet const& dependencySet = this->Tests[test]; + for(TestSet::const_iterator i = dependencySet.begin(); + i != dependencySet.end(); ++i) + { + GetAllTestDependencies(*i, dependencies); + dependencies.push_back(*i); + } +} + +//--------------------------------------------------------- +void cmCTestMultiProcessHandler::CreateSerialTestCostList() +{ + TestList presortedList; + + for(TestMap::iterator i = this->Tests.begin(); + i != this->Tests.end(); ++i) + { + presortedList.push_back(i->first); + } + TestComparator comp(this); - std::stable_sort(SortedTests.begin(), SortedTests.end(), comp); + std::stable_sort(presortedList.begin(), presortedList.end(), comp); + + TestSet alreadySortedTests; + + for(TestList::const_iterator i = presortedList.begin(); + i != presortedList.end(); ++i) + { + int test = *i; + + if(alreadySortedTests.find(test) != alreadySortedTests.end()) + { + continue; + } + + TestList dependencies; + GetAllTestDependencies(test, dependencies); + + for(TestList::const_iterator j = dependencies.begin(); + j != dependencies.end(); ++j) + { + int testDependency = *j; + + if(alreadySortedTests.find(testDependency) == alreadySortedTests.end()) + { + alreadySortedTests.insert(testDependency); + this->SortedTests.push_back(testDependency); + } + } + + alreadySortedTests.insert(test); + this->SortedTests.push_back(test); + } } //--------------------------------------------------------- @@ -609,7 +722,7 @@ void cmCTestMultiProcessHandler::CheckResume() << "----------------------------------------------------------" << std::endl; - std::ifstream fin; + cmsys::ifstream fin; fin.open(fname.c_str()); std::string line; while(std::getline(fin, line)) diff --git a/Source/CTest/cmCTestMultiProcessHandler.h b/Source/CTest/cmCTestMultiProcessHandler.h index cd21d91..1b53ec7 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.h +++ b/Source/CTest/cmCTestMultiProcessHandler.h @@ -72,6 +72,12 @@ protected: int SearchByName(std::string name); void CreateTestCostList(); + + void GetAllTestDependencies(int test, TestList& dependencies); + void CreateSerialTestCostList(); + + void CreateParallelTestCostList(); + // Removes the checkpoint file void MarkFinished(); void EraseTest(int index); @@ -111,6 +117,7 @@ protected: std::set<cmCTestRunTest*> RunningTests; // current running tests cmCTestTestHandler * TestHandler; cmCTest* CTest; + bool HasCycles; }; #endif diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx new file mode 100644 index 0000000..0058721 --- /dev/null +++ b/Source/CTest/cmCTestP4.cxx @@ -0,0 +1,559 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2013 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmCTestP4.h" + +#include "cmCTest.h" +#include "cmSystemTools.h" +#include "cmXMLSafe.h" + +#include <cmsys/RegularExpression.hxx> +#include <cmsys/ios/sstream> +#include <cmsys/Process.h> + +#include <sys/types.h> +#include <time.h> +#include <ctype.h> + +//---------------------------------------------------------------------------- +cmCTestP4::cmCTestP4(cmCTest* ct, std::ostream& log): + cmCTestGlobalVC(ct, log) +{ + this->PriorRev = this->Unknown; +} + +//---------------------------------------------------------------------------- +cmCTestP4::~cmCTestP4() +{ +} + +//---------------------------------------------------------------------------- +class cmCTestP4::IdentifyParser: public cmCTestVC::LineParser +{ +public: + IdentifyParser(cmCTestP4* p4, const char* prefix, + std::string& rev): Rev(rev) + { + this->SetLog(&p4->Log, prefix); + this->RegexIdentify.compile("^Change ([0-9]+) on"); + } +private: + std::string& Rev; + cmsys::RegularExpression RegexIdentify; + + bool ProcessLine() + { + if(this->RegexIdentify.find(this->Line)) + { + this->Rev = this->RegexIdentify.match(1); + return false; + } + return true; + } +}; + +//---------------------------------------------------------------------------- +class cmCTestP4::ChangesParser: public cmCTestVC::LineParser +{ +public: + ChangesParser(cmCTestP4* p4, const char* prefix) : P4(p4) + { + this->SetLog(&P4->Log, prefix); + this->RegexIdentify.compile("^Change ([0-9]+) on"); + } +private: + cmsys::RegularExpression RegexIdentify; + cmCTestP4* P4; + + bool ProcessLine() + { + if(this->RegexIdentify.find(this->Line)) + { + P4->ChangeLists.push_back(this->RegexIdentify.match(1)); + } + return true; + } +}; + +//---------------------------------------------------------------------------- +class cmCTestP4::UserParser: public cmCTestVC::LineParser +{ +public: + UserParser(cmCTestP4* p4, const char* prefix) : P4(p4) + { + this->SetLog(&P4->Log, prefix); + this->RegexUser.compile("^(.+) <(.*)> \\((.*)\\) accessed (.*)$"); + } +private: + cmsys::RegularExpression RegexUser; + cmCTestP4* P4; + + bool ProcessLine() + { + if(this->RegexUser.find(this->Line)) + { + User NewUser; + + NewUser.UserName = this->RegexUser.match(1); + NewUser.EMail = this->RegexUser.match(2); + NewUser.Name = this->RegexUser.match(3); + NewUser.AccessTime = this->RegexUser.match(4); + P4->Users[this->RegexUser.match(1)] = NewUser; + + return false; + } + return true; + } +}; + +//---------------------------------------------------------------------------- +/* Diff format: +==== //depot/file#rev - /absolute/path/to/file ==== +(diff data) +==== //depot/file2#rev - /absolute/path/to/file2 ==== +(diff data) +==== //depot/file3#rev - /absolute/path/to/file3 ==== +==== //depot/file4#rev - /absolute/path/to/file4 ==== +(diff data) +*/ +class cmCTestP4::DiffParser: public cmCTestVC::LineParser +{ +public: + DiffParser(cmCTestP4* p4, const char* prefix) + : P4(p4), AlreadyNotified(false) + { + this->SetLog(&P4->Log, prefix); + this->RegexDiff.compile("^==== (.*)#[0-9]+ - (.*)"); + } +private: + cmCTestP4* P4; + bool AlreadyNotified; + std::string CurrentPath; + cmsys::RegularExpression RegexDiff; + + bool ProcessLine() + { + if(!this->Line.empty() && this->Line[0] == '=' + && this->RegexDiff.find(this->Line)) + { + CurrentPath = this->RegexDiff.match(1); + AlreadyNotified = false; + } + else + { + if(!AlreadyNotified) + { + P4->DoModification(PathModified, CurrentPath); + AlreadyNotified = true; + } + } + return true; + } +}; + +//---------------------------------------------------------------------------- +cmCTestP4::User cmCTestP4::GetUserData(const std::string& username) +{ + std::map<std::string, cmCTestP4::User>::const_iterator it = + Users.find(username); + + if(it == Users.end()) + { + std::vector<char const*> p4_users; + SetP4Options(p4_users); + p4_users.push_back("users"); + p4_users.push_back("-m"); + p4_users.push_back("1"); + p4_users.push_back(username.c_str()); + p4_users.push_back(0); + + UserParser out(this, "users-out> "); + OutputLogger err(this->Log, "users-err> "); + RunChild(&p4_users[0], &out, &err); + + // The user should now be added to the map. Search again. + it = Users.find(username); + if(it == Users.end()) + { + return cmCTestP4::User(); + } + } + + return it->second; +} + +//---------------------------------------------------------------------------- +/* Commit format: + +Change 1111111 by user@client on 2013/09/26 11:50:36 + + text + text + +Affected files ... + +... //path/to/file#rev edit +... //path/to/file#rev add +... //path/to/file#rev delete +... //path/to/file#rev integrate +*/ +class cmCTestP4::DescribeParser: public cmCTestVC::LineParser +{ +public: + DescribeParser(cmCTestP4* p4, const char* prefix): + LineParser('\n', false), P4(p4), Section(SectionHeader) + { + this->SetLog(&P4->Log, prefix); + this->RegexHeader.compile("^Change ([0-9]+) by (.+)@(.+) on (.*)$"); + this->RegexDiff.compile("^\\.\\.\\. (.*)#[0-9]+ ([^ ]+)$"); + } +private: + cmsys::RegularExpression RegexHeader; + cmsys::RegularExpression RegexDiff; + cmCTestP4* P4; + + typedef cmCTestP4::Revision Revision; + typedef cmCTestP4::Change Change; + std::vector<Change> Changes; + enum SectionType { SectionHeader, SectionBody, SectionDiffHeader, + SectionDiff, SectionCount }; + SectionType Section; + Revision Rev; + + virtual bool ProcessLine() + { + if(this->Line.empty()) + { + this->NextSection(); + } + else + { + switch(this->Section) + { + case SectionHeader: this->DoHeaderLine(); break; + case SectionBody: this->DoBodyLine(); break; + case SectionDiffHeader: break; // nothing to do + case SectionDiff: this->DoDiffLine(); break; + case SectionCount: break; // never happens + } + } + return true; + } + + void NextSection() + { + if(this->Section == SectionDiff) + { + this->P4->DoRevision(this->Rev, this->Changes); + this->Rev = Revision(); + } + + this->Section = SectionType((this->Section+1) % SectionCount); + } + + void DoHeaderLine() + { + if(this->RegexHeader.find(this->Line)) + { + this->Rev.Rev = this->RegexHeader.match(1); + this->Rev.Date = this->RegexHeader.match(4); + + cmCTestP4::User user = P4->GetUserData(this->RegexHeader.match(2)); + this->Rev.Author = user.Name; + this->Rev.EMail = user.EMail; + + this->Rev.Committer = this->Rev.Author; + this->Rev.CommitterEMail = this->Rev.EMail; + this->Rev.CommitDate = this->Rev.Date; + } + } + + void DoBodyLine() + { + if(this->Line[0] == '\t') + { + this->Rev.Log += this->Line.substr(1); + } + this->Rev.Log += "\n"; + } + + void DoDiffLine() + { + if(this->RegexDiff.find(this->Line)) + { + Change change; + std::string Path = this->RegexDiff.match(1); + if(Path.length() > 2 && Path[0] == '/' && Path[1] == '/') + { + size_t found = Path.find('/', 2); + if(found != std::string::npos) + { + Path = Path.substr(found + 1); + } + } + + change.Path = Path; + std::string action = this->RegexDiff.match(2); + + if(action == "add") + { + change.Action = 'A'; + } + else if(action == "delete") + { + change.Action = 'D'; + } + else if(action == "edit" || action == "integrate") + { + change.Action = 'M'; + } + + Changes.push_back(change); + } + } +}; + +//---------------------------------------------------------------------------- +void cmCTestP4::SetP4Options(std::vector<char const*> &CommandOptions) +{ + if(P4Options.size() == 0) + { + const char* p4 = this->CommandLineTool.c_str(); + P4Options.push_back(p4); + + //The CTEST_P4_CLIENT variable sets the P4 client used when issuing + //Perforce commands, if it's different from the default one. + std::string client = this->CTest->GetCTestConfiguration("P4Client"); + if(!client.empty()) + { + P4Options.push_back("-c"); + P4Options.push_back(client); + } + + //Set the message language to be English, in case the P4 admin + //has localized them + P4Options.push_back("-L"); + P4Options.push_back("en"); + + //The CTEST_P4_OPTIONS variable adds additional Perforce command line + //options before the main command + std::string opts = this->CTest->GetCTestConfiguration("P4Options"); + std::vector<cmStdString> args = + cmSystemTools::ParseArguments(opts.c_str()); + + for(std::vector<cmStdString>::const_iterator ai = args.begin(); + ai != args.end(); ++ai) + { + P4Options.push_back(ai->c_str()); + } + } + + CommandOptions.clear(); + for(std::vector<std::string>::iterator i = P4Options.begin(); + i != P4Options.end(); ++i) + { + CommandOptions.push_back(i->c_str()); + } +} + +//---------------------------------------------------------------------------- +std::string cmCTestP4::GetWorkingRevision() +{ + std::vector<char const*> p4_identify; + SetP4Options(p4_identify); + + p4_identify.push_back("changes"); + p4_identify.push_back("-m"); + p4_identify.push_back("1"); + p4_identify.push_back("-t"); + + std::string source = this->SourceDirectory + "/...#have"; + p4_identify.push_back(source.c_str()); + p4_identify.push_back(0); + + std::string rev; + IdentifyParser out(this, "rev-out> ", rev); + OutputLogger err(this->Log, "rev-err> "); + + RunChild(&p4_identify[0], &out, &err); + + if(rev.empty()) + { + return "0"; + } + else + { + return rev; + } +} + +//---------------------------------------------------------------------------- +void cmCTestP4::NoteOldRevision() +{ + this->OldRevision = this->GetWorkingRevision(); + + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Old revision of repository is: " + << this->OldRevision << "\n"); + this->PriorRev.Rev = this->OldRevision; +} + +//---------------------------------------------------------------------------- +void cmCTestP4::NoteNewRevision() +{ + this->NewRevision = this->GetWorkingRevision(); + + cmCTestLog(this->CTest, HANDLER_OUTPUT, " New revision of repository is: " + << this->NewRevision << "\n"); +} + +//---------------------------------------------------------------------------- +void cmCTestP4::LoadRevisions() +{ + std::vector<char const*> p4_changes; + SetP4Options(p4_changes); + + // Use 'p4 changes ...@old,new' to get a list of changelists + std::string range = this->SourceDirectory + "/..."; + + if(this->OldRevision != "0") + { + range.append("@").append(this->OldRevision); + } + + if(this->NewRevision != "0") + { + if(this->OldRevision != "0") + { + range.append(",").append(this->NewRevision); + } + else + { + range.append("@").append(this->NewRevision); + } + } + + p4_changes.push_back("changes"); + p4_changes.push_back(range.c_str()); + p4_changes.push_back(0); + + ChangesParser out(this, "changes-out> "); + OutputLogger err(this->Log, "changes-err> "); + + ChangeLists.clear(); + this->RunChild(&p4_changes[0], &out, &err); + + if(ChangeLists.size() == 0) + return; + + //p4 describe -s ...@1111111,2222222 + std::vector<char const*> p4_describe; + for(std::vector<std::string>::reverse_iterator i = ChangeLists.rbegin(); + i != ChangeLists.rend(); ++i) + { + SetP4Options(p4_describe); + p4_describe.push_back("describe"); + p4_describe.push_back("-s"); + p4_describe.push_back(i->c_str()); + p4_describe.push_back(0); + + DescribeParser outDescribe(this, "describe-out> "); + OutputLogger errDescribe(this->Log, "describe-err> "); + this->RunChild(&p4_describe[0], &outDescribe, &errDescribe); + } +} + +//---------------------------------------------------------------------------- +void cmCTestP4::LoadModifications() +{ + std::vector<char const*> p4_diff; + SetP4Options(p4_diff); + + p4_diff.push_back("diff"); + + //Ideally we would use -Od but not all clients support it + p4_diff.push_back("-dn"); + std::string source = this->SourceDirectory + "/..."; + p4_diff.push_back(source.c_str()); + p4_diff.push_back(0); + + DiffParser out(this, "diff-out> "); + OutputLogger err(this->Log, "diff-err> "); + this->RunChild(&p4_diff[0], &out, &err); +} + +//---------------------------------------------------------------------------- +bool cmCTestP4::UpdateCustom(const std::string& custom) +{ + std::vector<std::string> p4_custom_command; + cmSystemTools::ExpandListArgument(custom, p4_custom_command, true); + + std::vector<char const*> p4_custom; + for(std::vector<std::string>::const_iterator + i = p4_custom_command.begin(); i != p4_custom_command.end(); ++i) + { + p4_custom.push_back(i->c_str()); + } + p4_custom.push_back(0); + + OutputLogger custom_out(this->Log, "custom-out> "); + OutputLogger custom_err(this->Log, "custom-err> "); + + return this->RunUpdateCommand(&p4_custom[0], &custom_out, &custom_err); +} + +//---------------------------------------------------------------------------- +bool cmCTestP4::UpdateImpl() +{ + std::string custom = this->CTest->GetCTestConfiguration("P4UpdateCustom"); + if(!custom.empty()) + { + return this->UpdateCustom(custom); + } + + std::vector<char const*> p4_sync; + SetP4Options(p4_sync); + + p4_sync.push_back("sync"); + + // Get user-specified update options. + std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions"); + if(opts.empty()) + { + opts = this->CTest->GetCTestConfiguration("P4UpdateOptions"); + } + std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str()); + for(std::vector<cmStdString>::const_iterator ai = args.begin(); + ai != args.end(); ++ai) + { + p4_sync.push_back(ai->c_str()); + } + + std::string source = this->SourceDirectory + "/..."; + + // Specify the start time for nightly testing. + if(this->CTest->GetTestModel() == cmCTest::NIGHTLY) + { + std::string date = this->GetNightlyTime(); + //CTest reports the date as YYYY-MM-DD, Perforce needs it as YYYY/MM/DD + std::replace(date.begin(), date.end(), '-', '/'); + + //Revision specification: /...@"YYYY/MM/DD HH:MM:SS" + source.append("@\"").append(date).append("\""); + } + + p4_sync.push_back(source.c_str()); + p4_sync.push_back(0); + + OutputLogger out(this->Log, "sync-out> "); + OutputLogger err(this->Log, "sync-err> "); + + return this->RunUpdateCommand(&p4_sync[0], &out, &err); +} diff --git a/Source/CTest/cmCTestP4.h b/Source/CTest/cmCTestP4.h new file mode 100644 index 0000000..7a53475 --- /dev/null +++ b/Source/CTest/cmCTestP4.h @@ -0,0 +1,71 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2013 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmCTestP4_h +#define cmCTestP4_h + +#include "cmCTestGlobalVC.h" +#include <vector> +#include <map> + +/** \class cmCTestP4 + * \brief Interaction with the Perforce command-line tool + * + */ +class cmCTestP4: public cmCTestGlobalVC +{ +public: + /** Construct with a CTest instance and update log stream. */ + cmCTestP4(cmCTest* ctest, std::ostream& log); + + virtual ~cmCTestP4(); + +private: + std::vector<std::string> ChangeLists; + + struct User + { + std::string UserName; + std::string Name; + std::string EMail; + std::string AccessTime; + + User(): UserName(), Name(), EMail(), AccessTime() {} + }; + std::map<std::string, User> Users; + std::vector<std::string> P4Options; + + User GetUserData(const std::string& username); + void SetP4Options(std::vector<char const*> &options); + + std::string GetWorkingRevision(); + virtual void NoteOldRevision(); + virtual void NoteNewRevision(); + virtual bool UpdateImpl(); + bool UpdateCustom(const std::string& custom); + + void LoadRevisions(); + void LoadModifications(); + + // Parsing helper classes. + class IdentifyParser; + class ChangesParser; + class UserParser; + class DescribeParser; + class DiffParser; + friend class IdentifyParser; + friend class ChangesParser; + friend class UserParser; + friend class DescribeParser; + friend class DiffParser; +}; + +#endif diff --git a/Source/CTest/cmCTestReadCustomFilesCommand.h b/Source/CTest/cmCTestReadCustomFilesCommand.h index b984c84..9c0af81 100644 --- a/Source/CTest/cmCTestReadCustomFilesCommand.h +++ b/Source/CTest/cmCTestReadCustomFilesCommand.h @@ -48,25 +48,6 @@ public: */ virtual const char* GetName() const { return "ctest_read_custom_files";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "read CTestCustom files."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " ctest_read_custom_files( directory ... )\n" - "Read all the CTestCustom.ctest or CTestCustom.cmake files from " - "the given directory."; - } - cmTypeMacro(cmCTestReadCustomFilesCommand, cmCTestCommand); }; diff --git a/Source/CTest/cmCTestRunScriptCommand.h b/Source/CTest/cmCTestRunScriptCommand.h index 05e7899..f34bd13 100644 --- a/Source/CTest/cmCTestRunScriptCommand.h +++ b/Source/CTest/cmCTestRunScriptCommand.h @@ -49,30 +49,6 @@ public: */ virtual const char* GetName() const { return "ctest_run_script";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "runs a ctest -S script"; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " ctest_run_script([NEW_PROCESS] script_file_name script_file_name1 \n" - " script_file_name2 ... [RETURN_VALUE var])\n" - "Runs a script or scripts much like if it was run from ctest -S. " - "If no argument is provided then the current script is run using " - "the current settings of the variables. If NEW_PROCESS is specified " - "then each script will be run in a separate process." - "If RETURN_VALUE is specified the return value of the last script " - "run will be put into var."; - } - cmTypeMacro(cmCTestRunScriptCommand, cmCTestCommand); }; diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 0e2fa41..cdf90b9 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -206,7 +206,13 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) bool success = !forceFail && (retVal == 0 || this->TestProperties->RequiredRegularExpressions.size()); - if((success && !this->TestProperties->WillFail) + if(this->TestProperties->SkipReturnCode >= 0 + && this->TestProperties->SkipReturnCode == retVal) + { + this->TestResult.Status = cmCTestTestHandler::NOT_RUN; + cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Skipped "); + } + else if((success && !this->TestProperties->WillFail) || (!success && this->TestProperties->WillFail)) { this->TestResult.Status = cmCTestTestHandler::COMPLETED; diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 8643cb3..00a0a09 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -22,6 +22,7 @@ //#include <cmsys/RegularExpression.hxx> #include <cmsys/Process.h> +#include <cmsys/Directory.hxx> // used for sleep #ifdef _WIN32 @@ -221,13 +222,13 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg) // execute the script passing in the arguments to the script as well as the // arguments from this invocation of cmake std::vector<const char*> argv; - argv.push_back(this->CTest->GetCTestExecutable()); + argv.push_back(cmSystemTools::GetCTestCommand().c_str()); argv.push_back("-SR"); argv.push_back(total_script_arg.c_str()); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Executable for CTest is: " << - this->CTest->GetCTestExecutable() << "\n"); + cmSystemTools::GetCTestCommand() << "\n"); // now pass through all the other arguments std::vector<cmStdString> &initArgs = @@ -361,12 +362,6 @@ void cmCTestScriptHandler::CreateCMake() this->AddCTestCommand(new cmCTestUploadCommand); } -void cmCTestScriptHandler::GetCommandDocumentation( - std::vector<cmDocumentationEntry>& v) const -{ - this->CMake->GetCommandDocumentation(v); -} - //---------------------------------------------------------------------- // this sets up some variables for the script to use, creates the required // cmake instance and generators, and then reads in the script @@ -402,9 +397,9 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) this->Makefile->AddDefinition("CTEST_SCRIPT_NAME", cmSystemTools::GetFilenameName(script).c_str()); this->Makefile->AddDefinition("CTEST_EXECUTABLE_NAME", - this->CTest->GetCTestExecutable()); + cmSystemTools::GetCTestCommand().c_str()); this->Makefile->AddDefinition("CMAKE_EXECUTABLE_NAME", - this->CTest->GetCMakeExecutable()); + cmSystemTools::GetCMakeCommand().c_str()); this->Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", true); this->UpdateElapsedTime(); @@ -1062,15 +1057,71 @@ bool cmCTestScriptHandler::EmptyBinaryDirectory(const char *sname) return false; } + // consider non existing target directory a success + if(!cmSystemTools::FileExists(sname)) + { + return true; + } + // try to avoid deleting directories that we shouldn't std::string check = sname; check += "/CMakeCache.txt"; - if(cmSystemTools::FileExists(check.c_str()) && - !cmSystemTools::RemoveADirectory(sname)) + + if(!cmSystemTools::FileExists(check.c_str())) { return false; } - return true; + + for(int i = 0; i < 5; ++i) + { + if(TryToRemoveBinaryDirectoryOnce(sname)) + { + return true; + } + cmSystemTools::Delay(100); + } + + return false; +} + +//------------------------------------------------------------------------- +bool cmCTestScriptHandler::TryToRemoveBinaryDirectoryOnce( + const std::string& directoryPath) +{ + cmsys::Directory directory; + directory.Load(directoryPath.c_str()); + + for(unsigned long i = 0; i < directory.GetNumberOfFiles(); ++i) + { + std::string path = directory.GetFile(i); + + if(path == "." || path == ".." || path == "CMakeCache.txt") + { + continue; + } + + std::string fullPath = directoryPath + std::string("/") + path; + + bool isDirectory = cmSystemTools::FileIsDirectory(fullPath.c_str()) && + !cmSystemTools::FileIsSymlink(fullPath.c_str()); + + if(isDirectory) + { + if(!cmSystemTools::RemoveADirectory(fullPath.c_str())) + { + return false; + } + } + else + { + if(!cmSystemTools::RemoveFile(fullPath.c_str())) + { + return false; + } + } + } + + return cmSystemTools::RemoveADirectory(directoryPath.c_str()); } //------------------------------------------------------------------------- diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h index 9d852ca..44e9dd0 100644 --- a/Source/CTest/cmCTestScriptHandler.h +++ b/Source/CTest/cmCTestScriptHandler.h @@ -110,7 +110,6 @@ public: void Initialize(); void CreateCMake(); - void GetCommandDocumentation(std::vector<cmDocumentationEntry>& v) const; cmake* GetCMake() { return this->CMake;} private: // reads in a script @@ -136,6 +135,9 @@ private: // Add ctest command void AddCTestCommand(cmCTestCommand* command); + // Try to remove the binary directory once + static bool TryToRemoveBinaryDirectoryOnce(const std::string& directoryPath); + std::vector<cmStdString> ConfigurationScripts; std::vector<bool> ScriptProcessScope; diff --git a/Source/CTest/cmCTestSleepCommand.h b/Source/CTest/cmCTestSleepCommand.h index 0f51ddf..c6baf1c 100644 --- a/Source/CTest/cmCTestSleepCommand.h +++ b/Source/CTest/cmCTestSleepCommand.h @@ -49,26 +49,6 @@ public: */ virtual const char* GetName() const { return "ctest_sleep";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "sleeps for some amount of time"; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " ctest_sleep(<seconds>)\n" - "Sleep for given number of seconds.\n" - " ctest_sleep(<time1> <duration> <time2>)\n" - "Sleep for t=(time1 + duration - time2) seconds if t > 0."; - } - cmTypeMacro(cmCTestSleepCommand, cmCTestCommand); }; diff --git a/Source/CTest/cmCTestStartCommand.h b/Source/CTest/cmCTestStartCommand.h index 6be4770..e5535c1 100644 --- a/Source/CTest/cmCTestStartCommand.h +++ b/Source/CTest/cmCTestStartCommand.h @@ -57,30 +57,6 @@ public: */ virtual const char* GetName() const { return "ctest_start";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Starts the testing for a given model"; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " ctest_start(Model [TRACK <track>] [APPEND] [source [binary]])\n" - "Starts the testing for a given model. The command should be called " - "after the binary directory is initialized. If the 'source' and " - "'binary' directory are not specified, it reads the " - "CTEST_SOURCE_DIRECTORY and CTEST_BINARY_DIRECTORY. If the track is " - "specified, the submissions will go to the specified track. " - "If APPEND is used, the existing TAG is used rather than " - "creating a new one based on the current time stamp."; - } - cmTypeMacro(cmCTestStartCommand, cmCTestCommand); private: diff --git a/Source/CTest/cmCTestSubmitCommand.h b/Source/CTest/cmCTestSubmitCommand.h index 53ee875..64c6cae 100644 --- a/Source/CTest/cmCTestSubmitCommand.h +++ b/Source/CTest/cmCTestSubmitCommand.h @@ -50,44 +50,6 @@ public: */ virtual const char* GetName() const { return "ctest_submit";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Submit results to a dashboard server."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " ctest_submit([PARTS ...] [FILES ...] [RETRY_COUNT count] " - " [RETRY_DELAY delay][RETURN_VALUE res])\n" - "By default all available parts are submitted if no PARTS or FILES " - "are specified. " - "The PARTS option lists a subset of parts to be submitted. " - "Valid part names are:\n" - " Start = nothing\n" - " Update = ctest_update results, in Update.xml\n" - " Configure = ctest_configure results, in Configure.xml\n" - " Build = ctest_build results, in Build.xml\n" - " Test = ctest_test results, in Test.xml\n" - " Coverage = ctest_coverage results, in Coverage.xml\n" - " MemCheck = ctest_memcheck results, in DynamicAnalysis.xml\n" - " Notes = Files listed by CTEST_NOTES_FILES, in Notes.xml\n" - " ExtraFiles = Files listed by CTEST_EXTRA_SUBMIT_FILES\n" - " Submit = nothing\n" - "The FILES option explicitly lists specific files to be submitted. " - "Each individual file must exist at the time of the call.\n" - "The RETRY_DELAY option specifies how long in seconds to wait after " - "a timed-out submission before attempting to re-submit.\n" - "The RETRY_COUNT option specifies how many times to retry a timed-out " - "submission.\n"; - } - cmTypeMacro(cmCTestSubmitCommand, cmCTestHandlerCommand); protected: diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 941d348..139f515 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -235,7 +235,7 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, return false; } - ftpfile = ::fopen(local_file.c_str(), "rb"); + ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb"); *this->LogFile << "\tUpload file: " << local_file.c_str() << " to " << upload_as.c_str() << std::endl; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " @@ -476,7 +476,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, return false; } - ftpfile = ::fopen(local_file.c_str(), "rb"); + ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb"); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " << local_file.c_str() << " to " << upload_as.c_str() << " Size: " << st.st_size << std::endl); @@ -566,7 +566,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, << count << std::endl); ::fclose(ftpfile); - ftpfile = ::fopen(local_file.c_str(), "rb"); + ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb"); ::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile); chunk.clear(); @@ -998,7 +998,7 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix, return false; } size_t fileSize = static_cast<size_t>(st.st_size); - FILE* fp = fopen(local_file.c_str(), "rb"); + FILE* fp = cmsys::SystemTools::Fopen(local_file.c_str(), "rb"); if ( !fp ) { cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot open file: " diff --git a/Source/CTest/cmCTestTestCommand.h b/Source/CTest/cmCTestTestCommand.h index 130cb69..451ac99 100644 --- a/Source/CTest/cmCTestTestCommand.h +++ b/Source/CTest/cmCTestTestCommand.h @@ -41,45 +41,6 @@ public: */ virtual const char* GetName() const { return "ctest_test";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Run tests in the project build tree."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " ctest_test([BUILD build_dir] [APPEND]\n" - " [START start number] [END end number]\n" - " [STRIDE stride number] [EXCLUDE exclude regex ]\n" - " [INCLUDE include regex] [RETURN_VALUE res] \n" - " [EXCLUDE_LABEL exclude regex] \n" - " [INCLUDE_LABEL label regex] \n" - " [PARALLEL_LEVEL level] \n" - " [SCHEDULE_RANDOM on] \n" - " [STOP_TIME time of day]) \n" - "Tests the given build directory and stores results in Test.xml. The " - "second argument is a variable that will hold value. Optionally, " - "you can specify the starting test number START, the ending test number " - "END, the number of tests to skip between each test STRIDE, a regular " - "expression for tests to run INCLUDE, or a regular expression for tests " - "to not run EXCLUDE. EXCLUDE_LABEL and INCLUDE_LABEL are regular " - "expression for test to be included or excluded by the test " - "property LABEL. PARALLEL_LEVEL should be set to a positive number " - "representing the number of tests to be run in parallel. " - "SCHEDULE_RANDOM will launch tests in a random order, and is " - "typically used to detect implicit test dependencies. STOP_TIME is the " - "time of day at which the tests should all stop running." - "\n" - CTEST_COMMAND_APPEND_OPTION_DOCS; - } - cmTypeMacro(cmCTestTestCommand, cmCTestHandlerCommand); protected: diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 497774d..3a04b33 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -20,6 +20,8 @@ #include <cmsys/Process.h> #include <cmsys/RegularExpression.hxx> #include <cmsys/Base64.h> +#include <cmsys/Directory.hxx> +#include <cmsys/FStream.hxx> #include "cmMakefile.h" #include "cmGlobalGenerator.h" #include "cmLocalGenerator.h" @@ -60,10 +62,6 @@ public: */ virtual const char* GetName() const { return "subdirs";} - // Unused methods - virtual const char* GetTerseDocumentation() const { return ""; } - virtual const char* GetFullDocumentation() const { return ""; } - cmTypeMacro(cmCTestSubdirCommand, cmCommand); cmCTestTestHandler* TestHandler; @@ -161,10 +159,6 @@ public: */ virtual const char* GetName() const { return "add_subdirectory";} - // Unused methods - virtual const char* GetTerseDocumentation() const { return ""; } - virtual const char* GetFullDocumentation() const { return ""; } - cmTypeMacro(cmCTestAddSubdirectoryCommand, cmCommand); cmCTestTestHandler* TestHandler; @@ -249,11 +243,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "ADD_TEST";} - - // Unused methods - virtual const char* GetTerseDocumentation() const { return ""; } - virtual const char* GetFullDocumentation() const { return ""; } + virtual const char* GetName() const { return "add_test";} cmTypeMacro(cmCTestAddTestCommand, cmCommand); @@ -297,11 +287,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() const { return "SET_TESTS_PROPERTIES";} - - // Unused methods - virtual const char* GetTerseDocumentation() const { return ""; } - virtual const char* GetFullDocumentation() const { return ""; } + virtual const char* GetName() const { return "set_tests_properties";} cmTypeMacro(cmCTestSetTestsPropertiesCommand, cmCommand); @@ -537,6 +523,7 @@ int cmCTestTestHandler::ProcessHandler() this->UseExcludeRegExp(); this->SetExcludeRegExp(val); } + this->SetRerunFailed(cmSystemTools::IsOn(this->GetOption("RerunFailed"))); this->TestResults.clear(); @@ -819,6 +806,13 @@ void cmCTestTestHandler::ComputeTestList() { this->TestList.clear(); // clear list of test this->GetListOfTests(); + + if (this->RerunFailed) + { + this->ComputeTestListForRerunFailed(); + return; + } + cmCTestTestHandler::ListOfTests::size_type tmsize = this->TestList.size(); // how many tests are in based on RegExp? int inREcnt = 0; @@ -881,9 +875,47 @@ void cmCTestTestHandler::ComputeTestList() this->TotalNumberOfTests = this->TestList.size(); // Set the TestList to the final list of all test this->TestList = finalList; + + this->UpdateMaxTestNameWidth(); +} + +void cmCTestTestHandler::ComputeTestListForRerunFailed() +{ + this->ExpandTestsToRunInformationForRerunFailed(); + + cmCTestTestHandler::ListOfTests::iterator it; + ListOfTests finalList; + int cnt = 0; + for ( it = this->TestList.begin(); it != this->TestList.end(); it ++ ) + { + cnt ++; + + // if this test is not in our list of tests to run, then skip it. + if ((this->TestsToRun.size() && + std::find(this->TestsToRun.begin(), this->TestsToRun.end(), cnt) + == this->TestsToRun.end())) + { + continue; + } + + it->Index = cnt; + finalList.push_back(*it); + } + + // Save the total number of tests before exclusions + this->TotalNumberOfTests = this->TestList.size(); + + // Set the TestList to the list of failed tests to rerun + this->TestList = finalList; + + this->UpdateMaxTestNameWidth(); +} + +void cmCTestTestHandler::UpdateMaxTestNameWidth() +{ std::string::size_type max = this->CTest->GetMaxTestNameWidth(); - for (it = this->TestList.begin(); - it != this->TestList.end(); it ++ ) + for ( cmCTestTestHandler::ListOfTests::iterator it = this->TestList.begin(); + it != this->TestList.end(); it ++ ) { cmCTestTestProperties& p = *it; if(max < p.Name.size()) @@ -900,7 +932,7 @@ void cmCTestTestHandler::ComputeTestList() bool cmCTestTestHandler::GetValue(const char* tag, int& value, - std::ifstream& fin) + std::istream& fin) { std::string line; bool ret = true; @@ -922,7 +954,7 @@ bool cmCTestTestHandler::GetValue(const char* tag, bool cmCTestTestHandler::GetValue(const char* tag, double& value, - std::ifstream& fin) + std::istream& fin) { std::string line; cmSystemTools::GetLineFromStream(fin, line); @@ -944,7 +976,7 @@ bool cmCTestTestHandler::GetValue(const char* tag, bool cmCTestTestHandler::GetValue(const char* tag, bool& value, - std::ifstream& fin) + std::istream& fin) { std::string line; cmSystemTools::GetLineFromStream(fin, line); @@ -976,7 +1008,7 @@ bool cmCTestTestHandler::GetValue(const char* tag, bool cmCTestTestHandler::GetValue(const char* tag, size_t& value, - std::ifstream& fin) + std::istream& fin) { std::string line; cmSystemTools::GetLineFromStream(fin, line); @@ -998,7 +1030,7 @@ bool cmCTestTestHandler::GetValue(const char* tag, bool cmCTestTestHandler::GetValue(const char* tag, std::string& value, - std::ifstream& fin) + std::istream& fin) { std::string line; cmSystemTools::GetLineFromStream(fin, line); @@ -1708,6 +1740,91 @@ void cmCTestTestHandler::ExpandTestsToRunInformation(size_t numTests) this->TestsToRun.erase(new_end, this->TestsToRun.end()); } +void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed() +{ + + std::string dirName = this->CTest->GetBinaryDir() + "/Testing/Temporary"; + + cmsys::Directory directory; + if (directory.Load(dirName.c_str()) == 0) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to read the contents of " + << dirName << std::endl); + return; + } + + int numFiles = static_cast<int> + (cmsys::Directory::GetNumberOfFilesInDirectory(dirName.c_str())); + std::string pattern = "LastTestsFailed"; + std::string logName = ""; + + for (int i = 0; i < numFiles; ++i) + { + std::string fileName = directory.GetFile(i); + // bcc crashes if we attempt a normal substring comparison, + // hence the following workaround + std::string fileNameSubstring = fileName.substr(0, pattern.length()); + if (fileNameSubstring.compare(pattern) != 0) + { + continue; + } + if (logName == "") + { + logName = fileName; + } + else + { + // if multiple matching logs were found we use the most recently + // modified one. + int res; + cmSystemTools::FileTimeCompare(logName.c_str(), fileName.c_str(), &res); + if (res == -1) + { + logName = fileName; + } + } + } + + std::string lastTestsFailedLog = this->CTest->GetBinaryDir() + + "/Testing/Temporary/" + logName; + + if ( !cmSystemTools::FileExists(lastTestsFailedLog.c_str()) ) + { + if ( !this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels() ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, lastTestsFailedLog + << " does not exist!" << std::endl); + } + return; + } + + // parse the list of tests to rerun from LastTestsFailed.log + cmsys::ifstream ifs(lastTestsFailedLog.c_str()); + if ( ifs ) + { + std::string line; + std::string::size_type pos; + while ( cmSystemTools::GetLineFromStream(ifs, line) ) + { + pos = line.find(':', 0); + if (pos == line.npos) + { + continue; + } + + int val = atoi(line.substr(0, pos).c_str()); + this->TestsToRun.push_back(val); + } + ifs.close(); + } + else if ( !this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels() ) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem reading file: " + << lastTestsFailedLog.c_str() << + " while generating list of previously failed tests." << std::endl); + } +} + //---------------------------------------------------------------------- // Just for convenience #define SPACE_REGEX "[ \t\r\n]" @@ -1848,7 +1965,7 @@ std::string cmCTestTestHandler::GenerateRegressionImages( } else { - std::ifstream ifs(filename.c_str(), std::ios::in + cmsys::ifstream ifs(filename.c_str(), std::ios::in #ifdef _WIN32 | std::ios::binary #endif @@ -1938,7 +2055,7 @@ void cmCTestTestHandler::SetTestsToRunInformation(const char* in) // string if(cmSystemTools::FileExists(in)) { - std::ifstream fin(in); + cmsys::ifstream fin(in); unsigned long filelen = cmSystemTools::FileLength(in); char* buff = new char[filelen+1]; fin.getline(buff, filelen); @@ -2112,6 +2229,14 @@ bool cmCTestTestHandler::SetTestsProperties( rtit->Processors = 1; } } + if ( key == "SKIP_RETURN_CODE" ) + { + rtit->SkipReturnCode = atoi(val.c_str()); + if(rtit->SkipReturnCode < 0 || rtit->SkipReturnCode > 255) + { + rtit->SkipReturnCode = -1; + } + } if ( key == "DEPENDS" ) { std::vector<std::string> lval; @@ -2247,6 +2372,7 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args) test.ExplicitTimeout = false; test.Cost = 0; test.Processors = 1; + test.SkipReturnCode = -1; test.PreviousRuns = 0; if (this->UseIncludeRegExpFlag && !this->IncludeTestsRegularExpression.find(testname.c_str())) diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 93b793b..63f9c93 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -44,6 +44,12 @@ public: void SetUseUnion(bool val) { this->UseUnion = val; } /** + * Set whether or not CTest should only execute the tests that failed + * on the previous run. By default this is false. + */ + void SetRerunFailed(bool val) { this->RerunFailed = val; } + + /** * This method is called when reading CTest custom file */ void PopulateCustomVectors(cmMakefile *mf); @@ -103,6 +109,8 @@ public: int Index; //Requested number of process slots int Processors; + // return code of test which will mark test as "not run" + int SkipReturnCode; std::vector<std::string> Environment; std::vector<std::string> Labels; std::set<std::string> LockedResources; @@ -213,21 +221,27 @@ private: // based on union regex and -I stuff void ComputeTestList(); + // compute the lists of tests that will actually run + // based on LastTestFailed.log + void ComputeTestListForRerunFailed(); + + void UpdateMaxTestNameWidth(); + bool GetValue(const char* tag, std::string& value, - std::ifstream& fin); + std::istream& fin); bool GetValue(const char* tag, int& value, - std::ifstream& fin); + std::istream& fin); bool GetValue(const char* tag, size_t& value, - std::ifstream& fin); + std::istream& fin); bool GetValue(const char* tag, bool& value, - std::ifstream& fin); + std::istream& fin); bool GetValue(const char* tag, double& value, - std::ifstream& fin); + std::istream& fin); /** * Find the executable for a test */ @@ -235,6 +249,7 @@ private: const char* GetTestStatus(int status); void ExpandTestsToRunInformation(size_t numPossibleTests); + void ExpandTestsToRunInformationForRerunFailed(); std::vector<cmStdString> CustomPreTest; std::vector<cmStdString> CustomPostTest; @@ -268,6 +283,8 @@ private: cmsys::RegularExpression DartStuff; std::ostream* LogFile; + + bool RerunFailed; }; #endif diff --git a/Source/CTest/cmCTestUpdateCommand.cxx b/Source/CTest/cmCTestUpdateCommand.cxx index 2ca9f6c..5408a8a 100644 --- a/Source/CTest/cmCTestUpdateCommand.cxx +++ b/Source/CTest/cmCTestUpdateCommand.cxx @@ -59,6 +59,14 @@ cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler() "HGCommand", "CTEST_HG_COMMAND"); this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, "HGUpdateOptions", "CTEST_HG_UPDATE_OPTIONS"); + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, + "P4Command", "CTEST_P4_COMMAND"); + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, + "P4UpdateOptions", "CTEST_P4_UPDATE_OPTIONS"); + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, + "P4Client", "CTEST_P4_CLIENT"); + this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, + "P4Options", "CTEST_P4_OPTIONS"); cmCTestGenericHandler* handler = this->CTest->GetInitializedHandler("update"); diff --git a/Source/CTest/cmCTestUpdateCommand.h b/Source/CTest/cmCTestUpdateCommand.h index c578fff..a785bd8 100644 --- a/Source/CTest/cmCTestUpdateCommand.h +++ b/Source/CTest/cmCTestUpdateCommand.h @@ -41,28 +41,6 @@ public: */ virtual const char* GetName() const { return "ctest_update";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Update the work tree from version control."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " ctest_update([SOURCE source] [RETURN_VALUE res])\n" - "Updates the given source directory and stores results in Update.xml. " - "If no SOURCE is given, the CTEST_SOURCE_DIRECTORY variable is used. " - "The RETURN_VALUE option specifies a variable in which to store the " - "result, which is the number of files updated or -1 on error." - ; - } - cmTypeMacro(cmCTestUpdateCommand, cmCTestHandlerCommand); protected: diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx index 9eae3f3..11474ec 100644 --- a/Source/CTest/cmCTestUpdateHandler.cxx +++ b/Source/CTest/cmCTestUpdateHandler.cxx @@ -28,6 +28,7 @@ #include "cmCTestBZR.h" #include "cmCTestGIT.h" #include "cmCTestHG.h" +#include "cmCTestP4.h" #include <cmsys/auto_ptr.hxx> @@ -51,7 +52,8 @@ static const char* cmCTestUpdateHandlerUpdateStrings[] = "SVN", "BZR", "GIT", - "HG" + "HG", + "P4" }; static const char* cmCTestUpdateHandlerUpdateToString(int type) @@ -146,6 +148,10 @@ int cmCTestUpdateHandler::DetermineType(const char* cmd, const char* type) { return cmCTestUpdateHandler::e_HG; } + if ( stype.find("p4") != std::string::npos ) + { + return cmCTestUpdateHandler::e_P4; + } } else { @@ -172,6 +178,10 @@ int cmCTestUpdateHandler::DetermineType(const char* cmd, const char* type) { return cmCTestUpdateHandler::e_HG; } + if ( stype.find("p4") != std::string::npos ) + { + return cmCTestUpdateHandler::e_P4; + } } return cmCTestUpdateHandler::e_UNKNOWN; } @@ -223,6 +233,7 @@ int cmCTestUpdateHandler::ProcessHandler() case e_BZR: vc.reset(new cmCTestBZR(this->CTest, ofs)); break; case e_GIT: vc.reset(new cmCTestGIT(this->CTest, ofs)); break; case e_HG: vc.reset(new cmCTestHG(this->CTest, ofs)); break; + case e_P4: vc.reset(new cmCTestP4(this->CTest, ofs)); break; default: vc.reset(new cmCTestVC(this->CTest, ofs)); break; } vc->SetCommandLineTool(this->UpdateCommand); @@ -350,6 +361,18 @@ int cmCTestUpdateHandler::DetectVCS(const char* dir) { return cmCTestUpdateHandler::e_HG; } + sourceDirectory = dir; + sourceDirectory += "/.p4"; + if ( cmSystemTools::FileExists(sourceDirectory.c_str()) ) + { + return cmCTestUpdateHandler::e_P4; + } + sourceDirectory = dir; + sourceDirectory += "/.p4config"; + if ( cmSystemTools::FileExists(sourceDirectory.c_str()) ) + { + return cmCTestUpdateHandler::e_P4; + } return cmCTestUpdateHandler::e_UNKNOWN; } @@ -380,6 +403,7 @@ bool cmCTestUpdateHandler::SelectVCS() case e_BZR: key = "BZRCommand"; break; case e_GIT: key = "GITCommand"; break; case e_HG: key = "HGCommand"; break; + case e_P4: key = "P4Command"; break; default: break; } if (key) diff --git a/Source/CTest/cmCTestUpdateHandler.h b/Source/CTest/cmCTestUpdateHandler.h index 55ec974..954c024 100644 --- a/Source/CTest/cmCTestUpdateHandler.h +++ b/Source/CTest/cmCTestUpdateHandler.h @@ -44,6 +44,7 @@ public: e_BZR, e_GIT, e_HG, + e_P4, e_LAST }; diff --git a/Source/CTest/cmCTestUploadCommand.h b/Source/CTest/cmCTestUploadCommand.h index 62f379f..e867fb6 100644 --- a/Source/CTest/cmCTestUploadCommand.h +++ b/Source/CTest/cmCTestUploadCommand.h @@ -45,25 +45,6 @@ public: */ virtual const char* GetName() const { return "ctest_upload";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Upload files to a dashboard server."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " ctest_upload(FILES ...)\n" - "Pass a list of files to be sent along with the build results to " - "the dashboard server.\n"; - } - cmTypeMacro(cmCTestUploadCommand, cmCTestHandlerCommand); protected: diff --git a/Source/CTest/cmParseCacheCoverage.cxx b/Source/CTest/cmParseCacheCoverage.cxx index 137f344..85e07ae 100644 --- a/Source/CTest/cmParseCacheCoverage.cxx +++ b/Source/CTest/cmParseCacheCoverage.cxx @@ -5,6 +5,7 @@ #include "cmParseCacheCoverage.h" #include <cmsys/Directory.hxx> #include <cmsys/Glob.hxx> +#include <cmsys/FStream.hxx> cmParseCacheCoverage::cmParseCacheCoverage( @@ -106,7 +107,7 @@ bool cmParseCacheCoverage::SplitString(std::vector<std::string>& args, bool cmParseCacheCoverage::ReadCMCovFile(const char* file) { - std::ifstream in(file); + cmsys::ifstream in(file); if(!in) { cmCTestLog(this->CTest, ERROR_MESSAGE, diff --git a/Source/CTest/cmParseGTMCoverage.cxx b/Source/CTest/cmParseGTMCoverage.cxx index 6b4adb4..528d0db 100644 --- a/Source/CTest/cmParseGTMCoverage.cxx +++ b/Source/CTest/cmParseGTMCoverage.cxx @@ -5,6 +5,7 @@ #include "cmParseGTMCoverage.h" #include <cmsys/Directory.hxx> #include <cmsys/Glob.hxx> +#include <cmsys/FStream.hxx> cmParseGTMCoverage::cmParseGTMCoverage(cmCTestCoverageHandlerContainer& cont, @@ -48,7 +49,7 @@ bool cmParseGTMCoverage::LoadCoverageData(const char* d) bool cmParseGTMCoverage::ReadMCovFile(const char* file) { - std::ifstream in(file); + cmsys::ifstream in(file); if(!in) { return false; @@ -127,7 +128,7 @@ bool cmParseGTMCoverage::FindFunctionInMumpsFile(std::string const& filepath, std::string const& function, int& lineoffset) { - std::ifstream in(filepath.c_str()); + cmsys::ifstream in(filepath.c_str()); if(!in) { return false; diff --git a/Source/CTest/cmParseMumpsCoverage.cxx b/Source/CTest/cmParseMumpsCoverage.cxx index 37e8bd0..6226feb 100644 --- a/Source/CTest/cmParseMumpsCoverage.cxx +++ b/Source/CTest/cmParseMumpsCoverage.cxx @@ -5,6 +5,7 @@ #include "cmParseGTMCoverage.h" #include <cmsys/Directory.hxx> #include <cmsys/Glob.hxx> +#include <cmsys/FStream.hxx> cmParseMumpsCoverage::cmParseMumpsCoverage( @@ -23,7 +24,7 @@ bool cmParseMumpsCoverage::ReadCoverageFile(const char* file) // Read the gtm_coverage.mcov file, that has two lines of data: // packages:/full/path/to/Vista/Packages // coverage_dir:/full/path/to/dir/with/*.mcov - std::ifstream in(file); + cmsys::ifstream in(file); if(!in) { return false; @@ -61,7 +62,7 @@ bool cmParseMumpsCoverage::ReadCoverageFile(const char* file) void cmParseMumpsCoverage::InitializeMumpsFile(std::string& file) { // initialize the coverage information for a given mumps file - std::ifstream in(file.c_str()); + cmsys::ifstream in(file.c_str()); if(!in) { return; diff --git a/Source/CTest/cmParsePHPCoverage.cxx b/Source/CTest/cmParsePHPCoverage.cxx index 593b2d1..1c26c1c 100644 --- a/Source/CTest/cmParsePHPCoverage.cxx +++ b/Source/CTest/cmParsePHPCoverage.cxx @@ -2,6 +2,7 @@ #include "cmSystemTools.h" #include "cmParsePHPCoverage.h" #include <cmsys/Directory.hxx> +#include <cmsys/FStream.hxx> /* To setup coverage for php. @@ -20,7 +21,7 @@ cmParsePHPCoverage::cmParsePHPCoverage(cmCTestCoverageHandlerContainer& cont, { } -bool cmParsePHPCoverage::ReadUntil(std::ifstream& in, char until) +bool cmParsePHPCoverage::ReadUntil(std::istream& in, char until) { char c = 0; while(in.get(c) && c != until) @@ -32,7 +33,7 @@ bool cmParsePHPCoverage::ReadUntil(std::ifstream& in, char until) } return true; } -bool cmParsePHPCoverage::ReadCoverageArray(std::ifstream& in, +bool cmParsePHPCoverage::ReadCoverageArray(std::istream& in, cmStdString const& fileName) { cmCTestCoverageHandlerContainer::SingleFileCoverageVector& coverageVector @@ -109,7 +110,7 @@ bool cmParsePHPCoverage::ReadCoverageArray(std::ifstream& in, return true; } -bool cmParsePHPCoverage::ReadInt(std::ifstream& in, int& v) +bool cmParsePHPCoverage::ReadInt(std::istream& in, int& v) { std::string s; char c = 0; @@ -121,7 +122,7 @@ bool cmParsePHPCoverage::ReadInt(std::ifstream& in, int& v) return true; } -bool cmParsePHPCoverage::ReadArraySize(std::ifstream& in, int& size) +bool cmParsePHPCoverage::ReadArraySize(std::istream& in, int& size) { char c = 0; in.get(c); @@ -139,7 +140,7 @@ bool cmParsePHPCoverage::ReadArraySize(std::ifstream& in, int& size) return false; } -bool cmParsePHPCoverage::ReadFileInformation(std::ifstream& in) +bool cmParsePHPCoverage::ReadFileInformation(std::istream& in) { char buf[4]; in.read(buf, 2); @@ -190,7 +191,7 @@ bool cmParsePHPCoverage::ReadFileInformation(std::ifstream& in) bool cmParsePHPCoverage::ReadPHPData(const char* file) { - std::ifstream in(file); + cmsys::ifstream in(file); if(!in) { return false; diff --git a/Source/CTest/cmParsePHPCoverage.h b/Source/CTest/cmParsePHPCoverage.h index d50a83c..035a093 100644 --- a/Source/CTest/cmParsePHPCoverage.h +++ b/Source/CTest/cmParsePHPCoverage.h @@ -32,11 +32,11 @@ public: void PrintCoverage(); private: bool ReadPHPData(const char* file); - bool ReadArraySize(std::ifstream& in, int& size); - bool ReadFileInformation(std::ifstream& in); - bool ReadInt(std::ifstream& in, int& v); - bool ReadCoverageArray(std::ifstream& in, cmStdString const&); - bool ReadUntil(std::ifstream& in, char until); + bool ReadArraySize(std::istream& in, int& size); + bool ReadFileInformation(std::istream& in); + bool ReadInt(std::istream& in, int& v); + bool ReadCoverageArray(std::istream& in, cmStdString const&); + bool ReadUntil(std::istream& in, char until); cmCTestCoverageHandlerContainer& Coverage; cmCTest* CTest; }; diff --git a/Source/CTest/cmParsePythonCoverage.cxx b/Source/CTest/cmParsePythonCoverage.cxx new file mode 100644 index 0000000..38a770a --- /dev/null +++ b/Source/CTest/cmParsePythonCoverage.cxx @@ -0,0 +1,113 @@ +#include "cmStandardIncludes.h" +#include "cmSystemTools.h" +#include "cmXMLParser.h" +#include "cmParsePythonCoverage.h" +#include <cmsys/Directory.hxx> +#include <cmsys/FStream.hxx> + +//---------------------------------------------------------------------------- +class cmParsePythonCoverage::XMLParser: public cmXMLParser +{ +public: + XMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont) + : CTest(ctest), Coverage(cont) + { + } + + virtual ~XMLParser() + { + } + +protected: + + virtual void StartElement(const char* name, const char** atts) + { + if(strcmp(name, "class") == 0) + { + int tagCount = 0; + while(true) + { + if(strcmp(atts[tagCount], "filename") == 0) + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Reading file: " + << atts[tagCount+1] << std::endl); + this->CurFileName = this->Coverage.SourceDir + "/" + + atts[tagCount+1]; + FileLinesType& curFileLines = + this->Coverage.TotalCoverage[this->CurFileName]; + cmsys::ifstream fin(this->CurFileName.c_str()); + if(!fin) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Python Coverage: Error opening " << this->CurFileName + << std::endl); + this->Coverage.Error++; + break; + } + + std::string line; + curFileLines.push_back(-1); + while(cmSystemTools::GetLineFromStream(fin, line)) + { + curFileLines.push_back(-1); + } + + break; + } + ++tagCount; + } + } + else if(strcmp(name, "line") == 0) + { + int tagCount = 0; + int curNumber = -1; + int curHits = -1; + while(true) + { + if(strcmp(atts[tagCount], "hits") == 0) + { + curHits = atoi(atts[tagCount+1]); + } + else if(strcmp(atts[tagCount], "number") == 0) + { + curNumber = atoi(atts[tagCount+1]); + } + + if(curHits > -1 && curNumber > -1) + { + FileLinesType& curFileLines = + this->Coverage.TotalCoverage[this->CurFileName]; + curFileLines[curNumber] = curHits; + break; + } + ++tagCount; + } + } + } + + virtual void EndElement(const char*) {} + +private: + + typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector + FileLinesType; + cmCTest* CTest; + cmCTestCoverageHandlerContainer& Coverage; + std::string CurFileName; + +}; + + +cmParsePythonCoverage::cmParsePythonCoverage( + cmCTestCoverageHandlerContainer& cont, + cmCTest* ctest) + :Coverage(cont), CTest(ctest) +{ +} + +bool cmParsePythonCoverage::ReadCoverageXML(const char* xmlFile) +{ + cmParsePythonCoverage::XMLParser parser(this->CTest, this->Coverage); + parser.ParseFile(xmlFile); + return true; +} diff --git a/Source/CTest/cmParsePythonCoverage.h b/Source/CTest/cmParsePythonCoverage.h new file mode 100644 index 0000000..668c7f9 --- /dev/null +++ b/Source/CTest/cmParsePythonCoverage.h @@ -0,0 +1,48 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmParsePythonCoverage_h +#define cmParsePythonCoverage_h + +#include "cmStandardIncludes.h" +#include "cmCTestCoverageHandler.h" + +/** \class cmParsePythonCoverage + * \brief Parse coverage.py Python coverage information + * + * This class is used to parse the output of the coverage.py tool that + * is currently maintained by Ned Batchelder. That tool has a command + * that produces xml output in the format typically output by the common + * Java-based Cobertura coverage application. This helper class parses + * that XML file to fill the coverage-handler container. + */ +class cmParsePythonCoverage +{ +public: + + //! Create the coverage parser by passing in the coverage handler + //! container and the cmCTest object + cmParsePythonCoverage(cmCTestCoverageHandlerContainer& cont, + cmCTest* ctest); + + //! Read the XML produced by running `coverage xml` + bool ReadCoverageXML(const char* xmlFile); + +private: + + class XMLParser; + cmCTestCoverageHandlerContainer& Coverage; + cmCTest* CTest; + std::string CurFileName; +}; + +#endif diff --git a/Source/CursesDialog/CMakeLists.txt b/Source/CursesDialog/CMakeLists.txt index 5efc2fb..548f5a5 100644 --- a/Source/CursesDialog/CMakeLists.txt +++ b/Source/CursesDialog/CMakeLists.txt @@ -11,6 +11,7 @@ #============================================================================= set( CURSES_SRCS + CursesDialog/cmCursesOptionsWidget CursesDialog/cmCursesBoolWidget CursesDialog/cmCursesCacheEntryComposite CursesDialog/cmCursesDummyWidget diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index 623d7d3..2d1ef5c 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -19,51 +19,32 @@ #include "cmCursesMainForm.h" #include "cmCursesStandardIncludes.h" +#include <cmsys/Encoding.hxx> #include <form.h> //---------------------------------------------------------------------------- -static const char * cmDocumentationName[][3] = +static const char * cmDocumentationName[][2] = { {0, - " ccmake - Curses Interface for CMake.", 0}, - {0,0,0} + " ccmake - Curses Interface for CMake."}, + {0,0} }; //---------------------------------------------------------------------------- -static const char * cmDocumentationUsage[][3] = +static const char * cmDocumentationUsage[][2] = { {0, " ccmake <path-to-source>\n" - " ccmake <path-to-existing-build>", 0}, - {0,0,0} + " ccmake <path-to-existing-build>"}, + {0,0} }; //---------------------------------------------------------------------------- -static const char * cmDocumentationDescription[][3] = -{ - {0, - "The \"ccmake\" executable is the CMake curses interface. Project " - "configuration settings may be specified interactively through " - "this GUI. Brief instructions are provided at the bottom of the " - "terminal when the program is running.", 0}, - CMAKE_STANDARD_INTRODUCTION, - {0,0,0} -}; - -//---------------------------------------------------------------------------- -static const char * cmDocumentationOptions[][3] = +static const char * cmDocumentationOptions[][2] = { CMAKE_STANDARD_OPTIONS_TABLE, - {0,0,0} -}; - -//---------------------------------------------------------------------------- -static const char * cmDocumentationSeeAlso[][3] = -{ - {0, "cmake", 0}, - {0, "ctest", 0}, - {0, 0, 0} + {0,0} }; cmCursesForm* cmCursesForm::CurrentForm=0; @@ -98,29 +79,27 @@ void CMakeErrorHandler(const char* message, const char* title, bool&, void* clie self->AddError(message, title); } -int main(int argc, char** argv) +int main(int argc, char const* const* argv) { - cmSystemTools::FindExecutableDirectory(argv[0]); + cmsys::Encoding::CommandLineArguments encoding_args = + cmsys::Encoding::CommandLineArguments::Main(argc, argv); + argc = encoding_args.argc(); + argv = encoding_args.argv(); + + cmSystemTools::FindCMakeResources(argv[0]); cmDocumentation doc; doc.addCMakeStandardDocSections(); if(doc.CheckOptions(argc, argv)) { cmake hcm; - std::vector<cmDocumentationEntry> commands; - std::vector<cmDocumentationEntry> compatCommands; + hcm.AddCMakePaths(); std::vector<cmDocumentationEntry> generators; - hcm.GetCommandDocumentation(commands, true, false); - hcm.GetCommandDocumentation(compatCommands, false, true); hcm.GetGeneratorDocumentation(generators); doc.SetName("ccmake"); doc.SetSection("Name",cmDocumentationName); doc.SetSection("Usage",cmDocumentationUsage); - doc.SetSection("Description",cmDocumentationDescription); doc.SetSection("Generators",generators); doc.PrependSection("Options",cmDocumentationOptions); - doc.SetSection("Command",commands); - doc.SetSection("Compatibility Commands",compatCommands); - doc.SetSeeAlsoList(cmDocumentationSeeAlso); return doc.PrintRequestedDocumentation(std::cout)? 0:1; } diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx index c58d037..249137f 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx @@ -10,6 +10,7 @@ See the License for more information. ============================================================================*/ #include "cmCursesCacheEntryComposite.h" +#include "cmCursesOptionsWidget.h" #include "cmCursesStringWidget.h" #include "cmCursesLabelWidget.h" #include "cmCursesBoolWidget.h" @@ -69,9 +70,27 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( it.GetValue()); break; case cmCacheManager::STRING: - this->Entry = new cmCursesStringWidget(this->EntryWidth, 1, 1, 1); - static_cast<cmCursesStringWidget*>(this->Entry)->SetString( - it.GetValue()); + if(it.PropertyExists("STRINGS")) + { + cmCursesOptionsWidget* ow = + new cmCursesOptionsWidget(this->EntryWidth, 1, 1, 1); + this->Entry = ow; + std::vector<std::string> options; + cmSystemTools::ExpandListArgument( + std::string(it.GetProperty("STRINGS")), options); + for(std::vector<std::string>::iterator + si = options.begin(); si != options.end(); ++si) + { + ow->AddOption(*si); + } + ow->SetOption(it.GetValue()); + } + else + { + this->Entry = new cmCursesStringWidget(this->EntryWidth, 1, 1, 1); + static_cast<cmCursesStringWidget*>(this->Entry)->SetString( + it.GetValue()); + } break; case cmCacheManager::UNINITIALIZED: cmSystemTools::Error("Found an undefined variable: ", it.GetName()); diff --git a/Source/CursesDialog/cmCursesForm.cxx b/Source/CursesDialog/cmCursesForm.cxx index 72ae5ee..d1b470c 100644 --- a/Source/CursesDialog/cmCursesForm.cxx +++ b/Source/CursesDialog/cmCursesForm.cxx @@ -11,7 +11,7 @@ ============================================================================*/ #include "cmCursesForm.h" -std::ofstream cmCursesForm::DebugFile; +cmsys::ofstream cmCursesForm::DebugFile; bool cmCursesForm::Debug = false; cmCursesForm::cmCursesForm() diff --git a/Source/CursesDialog/cmCursesForm.h b/Source/CursesDialog/cmCursesForm.h index 3cba856..f9317b9 100644 --- a/Source/CursesDialog/cmCursesForm.h +++ b/Source/CursesDialog/cmCursesForm.h @@ -14,6 +14,7 @@ #include "../cmStandardIncludes.h" #include "cmCursesStandardIncludes.h" +#include <cmsys/FStream.hxx> class cmCursesForm { @@ -63,7 +64,7 @@ public: protected: - static std::ofstream DebugFile; + static cmsys::ofstream DebugFile; static bool Debug; cmCursesForm(const cmCursesForm& form); diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 4fee0bb..d94cd37 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -43,14 +43,14 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> const& args, this->HelpMessage.push_back(""); this->HelpMessage.push_back(s_ConstHelpMessage); this->CMakeInstance = new cmake; - this->CMakeInstance->SetCMakeEditCommand("ccmake"); + this->CMakeInstance->SetCMakeEditCommand( + cmSystemTools::GetCMakeCursesCommand()); // create the arguments for the cmake object std::string whereCMake = cmSystemTools::GetProgramPath(this->Args[0].c_str()); whereCMake += "/cmake"; this->Args[0] = whereCMake; this->CMakeInstance->SetArgs(this->Args); - this->CMakeInstance->SetCMakeCommand(whereCMake.c_str()); this->SearchString = ""; this->OldSearchString = ""; this->SearchMode = false; diff --git a/Source/CursesDialog/cmCursesOptionsWidget.cxx b/Source/CursesDialog/cmCursesOptionsWidget.cxx new file mode 100644 index 0000000..652b2df --- /dev/null +++ b/Source/CursesDialog/cmCursesOptionsWidget.cxx @@ -0,0 +1,106 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmCursesOptionsWidget.h" +#include "cmCursesMainForm.h" + +inline int ctrl(int z) +{ + return (z&037); +} + +cmCursesOptionsWidget::cmCursesOptionsWidget(int width, int height, + int left, int top) : + cmCursesWidget(width, height, left, top) +{ + this->Type = cmCacheManager::BOOL; // this is a bit of a hack + // there is no option type, and string type causes ccmake to cast + // the widget into a string widget at some point. BOOL is safe for + // now. + set_field_fore(this->Field, A_NORMAL); + set_field_back(this->Field, A_STANDOUT); + field_opts_off(this->Field, O_STATIC); +} + +bool cmCursesOptionsWidget::HandleInput(int& key, cmCursesMainForm*, WINDOW* w) +{ + + // 10 == enter + if (key == 10 || key == KEY_ENTER) + { + this->NextOption(); + touchwin(w); + wrefresh(w); + return true; + } + else if (key == KEY_LEFT || key == ctrl('b')) + { + touchwin(w); + wrefresh(w); + this->PreviousOption(); + return true; + } + else if (key == KEY_RIGHT || key == ctrl('f')) + { + this->NextOption(); + touchwin(w); + wrefresh(w); + return true; + } + else + { + return false; + } + return false; +} + +void cmCursesOptionsWidget::AddOption(std::string const & option ) +{ + this->Options.push_back(option); +} + +void cmCursesOptionsWidget::NextOption() +{ + this->CurrentOption++; + if(this->CurrentOption > this->Options.size()-1) + { + this->CurrentOption = 0; + } + this->SetValue(this->Options[this->CurrentOption].c_str()); +} +void cmCursesOptionsWidget::PreviousOption() +{ + if(this->CurrentOption == 0) + { + this->CurrentOption = this->Options.size()-1; + } + else + { + this->CurrentOption--; + } + this->SetValue(this->Options[this->CurrentOption].c_str()); +} + +void cmCursesOptionsWidget::SetOption(const char* value) +{ + this->CurrentOption = 0; // default to 0 index + this->SetValue(value); + int index = 0; + for(std::vector<std::string>::iterator i = this->Options.begin(); + i != this->Options.end(); ++i) + { + if(*i == value) + { + this->CurrentOption = index; + } + index++; + } +} diff --git a/Source/CursesDialog/cmCursesOptionsWidget.h b/Source/CursesDialog/cmCursesOptionsWidget.h new file mode 100644 index 0000000..b52ac9d --- /dev/null +++ b/Source/CursesDialog/cmCursesOptionsWidget.h @@ -0,0 +1,39 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef __cmCursesOptionsWidget_h +#define __cmCursesOptionsWidget_h + +#include "cmCursesWidget.h" +class cmCursesMainForm; + +class cmCursesOptionsWidget : public cmCursesWidget +{ +public: + cmCursesOptionsWidget(int width, int height, int left, int top); + + // Description: + // Handle user input. Called by the container of this widget + // when this widget has focus. Returns true if the input was + // handled. + virtual bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w); + void SetOption(const char*); + void AddOption(std::string const &); + void NextOption(); + void PreviousOption(); +protected: + cmCursesOptionsWidget(const cmCursesOptionsWidget& from); + void operator=(const cmCursesOptionsWidget&); + std::vector<std::string> Options; + std::vector<std::string>::size_type CurrentOption; +}; + +#endif // __cmCursesOptionsWidget_h diff --git a/Source/QtDialog/AddCacheEntry.cxx b/Source/QtDialog/AddCacheEntry.cxx index e7fedc5..3881045 100644 --- a/Source/QtDialog/AddCacheEntry.cxx +++ b/Source/QtDialog/AddCacheEntry.cxx @@ -15,14 +15,16 @@ #include <QCompleter> static const int NumTypes = 4; +static const int DefaultTypeIndex = 0; static const QByteArray TypeStrings[NumTypes] = { "BOOL", "PATH", "FILEPATH", "STRING" }; static const QCMakeProperty::PropertyType Types[NumTypes] = { QCMakeProperty::BOOL, QCMakeProperty::PATH, QCMakeProperty::FILEPATH, QCMakeProperty::STRING}; -AddCacheEntry::AddCacheEntry(QWidget* p, const QStringList& completions) - : QWidget(p) +AddCacheEntry::AddCacheEntry(QWidget* p, const QStringList& varNames, + const QStringList& varTypes) + : QWidget(p), VarNames(varNames), VarTypes(varTypes) { this->setupUi(this); for(int i=0; i<NumTypes; i++) @@ -43,7 +45,10 @@ AddCacheEntry::AddCacheEntry(QWidget* p, const QStringList& completions) this->setTabOrder(path, filepath); this->setTabOrder(filepath, string); this->setTabOrder(string, this->Description); - this->Name->setCompleter(new QCompleter(completions, this)); + QCompleter *completer = new QCompleter(this->VarNames, this); + this->Name->setCompleter(completer); + connect(completer, SIGNAL(activated(const QString&)), + this, SLOT(onCompletionActivated(const QString&))); } QString AddCacheEntry::name() const @@ -77,7 +82,32 @@ QCMakeProperty::PropertyType AddCacheEntry::type() const { return Types[idx]; } - return QCMakeProperty::BOOL; + return Types[DefaultTypeIndex]; } +QString AddCacheEntry::typeString() const +{ + int idx = this->Type->currentIndex(); + if(idx >= 0 && idx < NumTypes) + { + return TypeStrings[idx]; + } + return TypeStrings[DefaultTypeIndex]; +} +void AddCacheEntry::onCompletionActivated(const QString &text) +{ + int idx = this->VarNames.indexOf(text); + if (idx != -1) + { + QString vartype = this->VarTypes[idx]; + for (int i = 0; i < NumTypes; i++) + { + if (TypeStrings[i] == vartype) + { + this->Type->setCurrentIndex(i); + break; + } + } + } +} diff --git a/Source/QtDialog/AddCacheEntry.h b/Source/QtDialog/AddCacheEntry.h index e219d4e..38c3a74 100644 --- a/Source/QtDialog/AddCacheEntry.h +++ b/Source/QtDialog/AddCacheEntry.h @@ -24,12 +24,21 @@ class AddCacheEntry : public QWidget, public Ui::AddCacheEntry { Q_OBJECT public: - AddCacheEntry(QWidget* p, const QStringList& completions); + AddCacheEntry(QWidget* p, const QStringList& varNames, + const QStringList& varTypes); QString name() const; QVariant value() const; QString description() const; QCMakeProperty::PropertyType type() const; + QString typeString() const; + +private slots: + void onCompletionActivated(const QString &text); + +private: + const QStringList& VarNames; + const QStringList& VarTypes; }; #endif diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index ef25294..4308a4d 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -102,6 +102,13 @@ if(APPLE) MACOSX_PACKAGE_LOCATION Resources) endif() +if(CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL) + install(FILES ${CMake_SOURCE_DIR}/Licenses/LGPLv2.1.txt + DESTINATION ${CMAKE_DATA_DIR}/Licenses) + set_property(SOURCE CMakeSetupDialog.cxx + PROPERTY COMPILE_DEFINITIONS CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL) +endif() + set(CMAKE_INCLUDE_CURRENT_DIR ON) add_executable(cmake-gui WIN32 MACOSX_BUNDLE ${SRCS}) @@ -111,8 +118,23 @@ if(Qt_BIN_DIR) endif() if(APPLE) + file(STRINGS "${CMake_SOURCE_DIR}/Copyright.txt" copyright_line + LIMIT_COUNT 1 REGEX "^Copyright 2000-20[0-9][0-9] Kitware") + set_target_properties(cmake-gui PROPERTIES - OUTPUT_NAME ${CMAKE_BUNDLE_NAME}) + OUTPUT_NAME CMake + MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in" + MACOSX_BUNDLE_SHORT_VERSION_STRING "${CMAKE_BUNDLE_VERSION}" + # TBD: MACOSX_BUNDLE_BUNDLE_VERSION "${CMAKE_BUNDLE_VERSION}" + MACOSX_BUNDLE_COPYRIGHT "${copyright_line}" + ) + + # Create a symlink in the build tree to provide a "cmake-gui" next + # to the "cmake" executable that refers to the application bundle. + add_custom_command(TARGET cmake-gui POST_BUILD + COMMAND ln -sf CMake.app/Contents/MacOS/CMake + $<TARGET_FILE_DIR:cmake>/cmake-gui + ) endif() set(CMAKE_INSTALL_DESTINATION_ARGS BUNDLE DESTINATION "${CMAKE_BUNDLE_LOCATION}") @@ -136,7 +158,7 @@ if(APPLE) "${CMake_BINARY_DIR}/Source/QtDialog/postflight.sh") configure_file("${CMake_SOURCE_DIR}/Source/QtDialog/postupgrade.sh.in" "${CMake_BINARY_DIR}/Source/QtDialog/postupgrade.sh") - install(CODE "execute_process(COMMAND ln -s \"../MacOS/${CMAKE_BUNDLE_NAME}\" cmake-gui + install(CODE "execute_process(COMMAND ln -s \"../MacOS/CMake\" cmake-gui WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin)") endif() @@ -145,7 +167,7 @@ if(APPLE OR WIN32) # if a system Qt is used (e.g. installed in /usr/lib/), it will not be included in the installation set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin/cmake-gui${CMAKE_EXECUTABLE_SUFFIX}") if(APPLE) - set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/MacOS/${CMAKE_BUNDLE_NAME}") + set(fixup_exe "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/MacOS/CMake") endif() install(CODE " include(\"${CMake_SOURCE_DIR}/Modules/BundleUtilities.cmake\") diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index 01893f5..821121e 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -21,79 +21,57 @@ #include "cmVersion.h" #include <cmsys/CommandLineArguments.hxx> #include <cmsys/SystemTools.hxx> +#include <cmsys/Encoding.hxx> //---------------------------------------------------------------------------- -static const char * cmDocumentationName[][3] = +static const char * cmDocumentationName[][2] = { {0, - " cmake-gui - CMake GUI.", 0}, - {0,0,0} + " cmake-gui - CMake GUI."}, + {0,0} }; //---------------------------------------------------------------------------- -static const char * cmDocumentationUsage[][3] = +static const char * cmDocumentationUsage[][2] = { {0, " cmake-gui [options]\n" " cmake-gui [options] <path-to-source>\n" - " cmake-gui [options] <path-to-existing-build>", 0}, - {0,0,0} + " cmake-gui [options] <path-to-existing-build>"}, + {0,0} }; //---------------------------------------------------------------------------- -static const char * cmDocumentationDescription[][3] = +static const char * cmDocumentationOptions[][2] = { - {0, - "The \"cmake-gui\" executable is the CMake GUI. Project " - "configuration settings may be specified interactively. " - "Brief instructions are provided at the bottom of the " - "window when the program is running.", 0}, - CMAKE_STANDARD_INTRODUCTION, - {0,0,0} -}; - -//---------------------------------------------------------------------------- -static const char * cmDocumentationOptions[][3] = -{ - {0,0,0} + {0,0} }; int main(int argc, char** argv) { - cmSystemTools::FindExecutableDirectory(argv[0]); + cmsys::Encoding::CommandLineArguments encoding_args = + cmsys::Encoding::CommandLineArguments::Main(argc, argv); + int argc2 = encoding_args.argc(); + char const* const* argv2 = encoding_args.argv(); + + cmSystemTools::FindCMakeResources(argv2[0]); // check docs first so that X is not need to get docs // do docs, if args were given cmDocumentation doc; doc.addCMakeStandardDocSections(); - if(argc >1 && doc.CheckOptions(argc, argv)) + if(argc2 >1 && doc.CheckOptions(argc2, argv2)) { // Construct and print requested documentation. cmake hcm; hcm.AddCMakePaths(); - // just incase the install is bad avoid a seg fault - const char* root = hcm.GetCacheDefinition("CMAKE_ROOT"); - if(root) - { - doc.SetCMakeRoot(root); - } - std::vector<cmDocumentationEntry> commands; - std::vector<cmDocumentationEntry> compatCommands; - std::map<std::string,cmDocumentationSection *> propDocs; std::vector<cmDocumentationEntry> generators; - hcm.GetCommandDocumentation(commands, true, false); - hcm.GetCommandDocumentation(compatCommands, false, true); hcm.GetGeneratorDocumentation(generators); - hcm.GetPropertiesDocumentation(propDocs); doc.SetName("cmake"); doc.SetSection("Name",cmDocumentationName); doc.SetSection("Usage",cmDocumentationUsage); - doc.SetSection("Description",cmDocumentationDescription); doc.AppendSection("Generators",generators); doc.PrependSection("Options",cmDocumentationOptions); - doc.SetSection("Commands",commands); - doc.SetSection("Compatilbility Commands", compatCommands); - doc.SetSections(propDocs); return (doc.PrintRequestedDocumentation(std::cout)? 0:1); } @@ -108,9 +86,9 @@ int main(int argc, char** argv) } // if arg for install - for(int i =0; i < argc; i++) + for(int i =0; i < argc2; i++) { - if(strcmp(argv[i], "--mac-install") == 0) + if(strcmp(argv2[i], "--mac-install") == 0) { QMacInstallDialog setupdialog(0); setupdialog.exec(); @@ -144,7 +122,7 @@ int main(int argc, char** argv) dialog.show(); cmsys::CommandLineArguments arg; - arg.Initialize(argc, argv); + arg.Initialize(argc2, argv2); std::string binaryDirectory; std::string sourceDirectory; typedef cmsys::CommandLineArguments argT; diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 4d62f72..f62afd6 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -34,6 +34,7 @@ #include "QCMakeCacheView.h" #include "AddCacheEntry.h" #include "FirstConfigure.h" +#include "cmSystemTools.h" #include "cmVersion.h" QCMakeThread::QCMakeThread(QObject* p) @@ -66,12 +67,13 @@ CMakeSetupDialog::CMakeSetupDialog() // create the GUI QSettings settings; settings.beginGroup("Settings/StartPath"); - int h = settings.value("Height", 500).toInt(); - int w = settings.value("Width", 700).toInt(); - this->resize(w, h); + restoreGeometry(settings.value("geometry").toByteArray()); + restoreState(settings.value("windowState").toByteArray()); - this->AddVariableCompletions = settings.value("AddVariableCompletionEntries", + this->AddVariableNames = settings.value("AddVariableNames", QStringList("CMAKE_INSTALL_PREFIX")).toStringList(); + this->AddVariableTypes = settings.value("AddVariableTypes", + QStringList("PATH")).toStringList(); QWidget* cont = new QWidget(this); this->setupUi(cont); @@ -299,8 +301,8 @@ CMakeSetupDialog::~CMakeSetupDialog() { QSettings settings; settings.beginGroup("Settings/StartPath"); - settings.setValue("Height", this->height()); - settings.setValue("Width", this->width()); + settings.setValue("windowState", QVariant(saveState())); + settings.setValue("geometry", QVariant(saveGeometry())); settings.setValue("SplitterSizes", this->Splitter->saveState()); // wait for thread to stop @@ -808,12 +810,26 @@ void CMakeSetupDialog::doDeleteCache() void CMakeSetupDialog::doAbout() { - QString msg = tr("CMake %1\n" - "Using Qt %2\n" - "www.cmake.org"); - + QString msg = tr( + "CMake %1 (cmake.org).\n" + "CMake suite maintained by Kitware, Inc. (kitware.com).\n" + "Distributed under terms of the BSD 3-Clause License.\n" + "\n" + "CMake GUI maintained by csimsoft,\n" + "built using Qt %2 (qt-project.org).\n" +#ifdef CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL + "\n" + "The Qt Toolkit is Copyright (C) Digia Plc and/or its subsidiary(-ies).\n" + "Qt is licensed under terms of the GNU LGPLv2.1, available at:\n" + " \"%3\"" +#endif + ); msg = msg.arg(cmVersion::GetCMakeVersion()); msg = msg.arg(qVersion()); +#ifdef CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL + std::string lgpl = cmSystemTools::GetCMakeRoot()+"/Licenses/LGPLv2.1.txt"; + msg = msg.arg(lgpl.c_str()); +#endif QDialog dialog; dialog.setWindowTitle(tr("About")); @@ -947,6 +963,7 @@ void CMakeSetupDialog::saveBuildPaths(const QStringList& paths) void CMakeSetupDialog::setCacheModified() { this->CacheModified = true; + this->ConfigureNeeded = true; this->enterState(ReadyConfigure); } @@ -1034,7 +1051,8 @@ void CMakeSetupDialog::addCacheEntry() dialog.resize(400, 200); dialog.setWindowTitle(tr("Add Cache Entry")); QVBoxLayout* l = new QVBoxLayout(&dialog); - AddCacheEntry* w = new AddCacheEntry(&dialog, this->AddVariableCompletions); + AddCacheEntry* w = new AddCacheEntry(&dialog, this->AddVariableNames, + this->AddVariableTypes); QDialogButtonBox* btns = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dialog); @@ -1049,23 +1067,26 @@ void CMakeSetupDialog::addCacheEntry() m->insertProperty(w->type(), w->name(), w->description(), w->value(), false); // only add variable names to the completion which are new - if (!this->AddVariableCompletions.contains(w->name())) + if (!this->AddVariableNames.contains(w->name())) { - this->AddVariableCompletions << w->name(); + this->AddVariableNames << w->name(); + this->AddVariableTypes << w->typeString(); // limit to at most 100 completion items - if (this->AddVariableCompletions.size() > 100) + if (this->AddVariableNames.size() > 100) { - this->AddVariableCompletions.removeFirst(); + this->AddVariableNames.removeFirst(); + this->AddVariableTypes.removeFirst(); } // make sure CMAKE_INSTALL_PREFIX is always there - if (!this->AddVariableCompletions.contains("CMAKE_INSTALL_PREFIX")) + if (!this->AddVariableNames.contains("CMAKE_INSTALL_PREFIX")) { - this->AddVariableCompletions << QString("CMAKE_INSTALL_PREFIX"); + this->AddVariableNames << "CMAKE_INSTALL_PREFIX"; + this->AddVariableTypes << "PATH"; } QSettings settings; settings.beginGroup("Settings/StartPath"); - settings.setValue("AddVariableCompletionEntries", - this->AddVariableCompletions); + settings.setValue("AddVariableNames", this->AddVariableNames); + settings.setValue("AddVariableTypes", this->AddVariableTypes); } } } @@ -1231,7 +1252,7 @@ void CMakeSetupDialog::doOutputFindNext(bool directionForward) QString search = this->FindHistory.front(); - QTextCursor cursor = this->Output->textCursor(); + QTextCursor textCursor = this->Output->textCursor(); QTextDocument* document = this->Output->document(); QTextDocument::FindFlags flags; if (!directionForward) @@ -1239,67 +1260,67 @@ void CMakeSetupDialog::doOutputFindNext(bool directionForward) flags |= QTextDocument::FindBackward; } - cursor = document->find(search, cursor, flags); + textCursor = document->find(search, textCursor, flags); - if (cursor.isNull()) + if (textCursor.isNull()) { // first search found nothing, wrap around and search again - cursor = this->Output->textCursor(); - cursor.movePosition(directionForward ? QTextCursor::Start - : QTextCursor::End); - cursor = document->find(search, cursor, flags); + textCursor = this->Output->textCursor(); + textCursor.movePosition(directionForward ? QTextCursor::Start + : QTextCursor::End); + textCursor = document->find(search, textCursor, flags); } - if (cursor.hasSelection()) + if (textCursor.hasSelection()) { - this->Output->setTextCursor(cursor); + this->Output->setTextCursor(textCursor); } } void CMakeSetupDialog::doOutputErrorNext() { - QTextCursor cursor = this->Output->textCursor(); + QTextCursor textCursor = this->Output->textCursor(); bool atEnd = false; // move cursor out of current error-block - if (cursor.blockCharFormat() == this->ErrorFormat) + if (textCursor.blockCharFormat() == this->ErrorFormat) { - atEnd = !cursor.movePosition(QTextCursor::NextBlock); + atEnd = !textCursor.movePosition(QTextCursor::NextBlock); } // move cursor to next error-block - while (cursor.blockCharFormat() != this->ErrorFormat && !atEnd) + while (textCursor.blockCharFormat() != this->ErrorFormat && !atEnd) { - atEnd = !cursor.movePosition(QTextCursor::NextBlock); + atEnd = !textCursor.movePosition(QTextCursor::NextBlock); } if (atEnd) { // first search found nothing, wrap around and search again - atEnd = !cursor.movePosition(QTextCursor::Start); + atEnd = !textCursor.movePosition(QTextCursor::Start); // move cursor to next error-block - while (cursor.blockCharFormat() != this->ErrorFormat && !atEnd) + while (textCursor.blockCharFormat() != this->ErrorFormat && !atEnd) { - atEnd = !cursor.movePosition(QTextCursor::NextBlock); + atEnd = !textCursor.movePosition(QTextCursor::NextBlock); } } if (!atEnd) { - cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); + textCursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); QTextCharFormat selectionFormat; selectionFormat.setBackground(Qt::yellow); - QTextEdit::ExtraSelection extraSelection = {cursor, selectionFormat}; + QTextEdit::ExtraSelection extraSelection = {textCursor, selectionFormat}; this->Output->setExtraSelections(QList<QTextEdit::ExtraSelection>() << extraSelection); // make the whole error-block visible - this->Output->setTextCursor(cursor); + this->Output->setTextCursor(textCursor); // remove the selection to see the extraSelection - cursor.setPosition(cursor.anchor()); - this->Output->setTextCursor(cursor); + textCursor.setPosition(textCursor.anchor()); + this->Output->setTextCursor(textCursor); } } diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h index 963c7d1..1b26c64 100644 --- a/Source/QtDialog/CMakeSetupDialog.h +++ b/Source/QtDialog/CMakeSetupDialog.h @@ -110,7 +110,8 @@ protected: QTextCharFormat ErrorFormat; QTextCharFormat MessageFormat; - QStringList AddVariableCompletions; + QStringList AddVariableNames; + QStringList AddVariableTypes; QStringList FindHistory; QEventLoop LocalLoop; diff --git a/Source/QtDialog/Info.plist.in b/Source/QtDialog/Info.plist.in new file mode 100644 index 0000000..b9c4af5 --- /dev/null +++ b/Source/QtDialog/Info.plist.in @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleExecutable</key> + <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string> + <key>CFBundleIconFile</key> + <string>${MACOSX_BUNDLE_ICON_FILE}</string> + <key>CFBundleIdentifier</key> + <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleShortVersionString</key> + <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string> + <key>CSResourcesFileMapped</key> + <true/> + <key>LSApplicationCategoryType</key> + <string>public.app-category.developer-tools</string> + <key>NSHumanReadableCopyright</key> + <string>${MACOSX_BUNDLE_COPYRIGHT}</string> +</dict> +</plist> diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 0d01181..0fe5f8c 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -33,34 +33,13 @@ QCMake::QCMake(QObject* p) qRegisterMetaType<QCMakeProperty>(); qRegisterMetaType<QCMakePropertyList>(); - QDir execDir(QCoreApplication::applicationDirPath()); - -#if defined(Q_OS_MAC) - if(execDir.exists("../bin/cmake")) - { - execDir.cd("../bin"); - } - else - { - execDir.cd("../../../"); // path to cmake in build directory (need to fix for deployment) - } -#endif - - QString cmakeCommand = QString("cmake")+QString::fromLocal8Bit(cmSystemTools::GetExecutableExtension()); - cmakeCommand = execDir.filePath(cmakeCommand); - cmSystemTools::DisableRunCommandOutput(); cmSystemTools::SetRunCommandHideConsole(true); cmSystemTools::SetErrorCallback(QCMake::errorCallback, this); - cmSystemTools::FindExecutableDirectory(cmakeCommand.toLocal8Bit().data()); this->CMakeInstance = new cmake; - this->CMakeInstance->SetCMakeCommand(cmakeCommand.toLocal8Bit().data()); -#if defined(Q_OS_MAC) - this->CMakeInstance->SetCMakeEditCommand("cmake-gui.app/Contents/MacOS/cmake-gui"); -#else - this->CMakeInstance->SetCMakeEditCommand("cmake-gui"); -#endif + this->CMakeInstance->SetCMakeEditCommand( + cmSystemTools::GetCMakeGUICommand()); this->CMakeInstance->SetProgressCallback(QCMake::progressCallback, this); cmSystemTools::SetInterruptCallback(QCMake::interruptCallback, this); diff --git a/Source/QtDialog/postflight.sh.in b/Source/QtDialog/postflight.sh.in index 33be352..0b96889 100755 --- a/Source/QtDialog/postflight.sh.in +++ b/Source/QtDialog/postflight.sh.in @@ -1,3 +1,3 @@ #!/bin/bash -"$2@CMAKE_INSTALL_SUBDIR@/@CMAKE_BUNDLE_NAME@.app/Contents/MacOS/@CMAKE_BUNDLE_NAME@" --mac-install +"$2@CMAKE_INSTALL_SUBDIR@/CMake.app/Contents/MacOS/CMake" --mac-install exit 0 diff --git a/Source/cmAddCompileOptionsCommand.h b/Source/cmAddCompileOptionsCommand.h index e9bbf28..38ed208 100644 --- a/Source/cmAddCompileOptionsCommand.h +++ b/Source/cmAddCompileOptionsCommand.h @@ -13,7 +13,6 @@ #define cmAddCompileOptionsCommand_h #include "cmCommand.h" -#include "cmDocumentGeneratorExpressions.h" class cmAddCompileOptionsCommand : public cmCommand { @@ -38,33 +37,6 @@ public: */ virtual const char* GetName() const {return "add_compile_options";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Adds options to the compilation of source files."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " add_compile_options(<option> ...)\n" - "Adds options to the compiler command line for sources in the " - "current directory and below. This command can be used to add any " - "options, but alternative commands exist to add preprocessor " - "definitions or include directories. " - "See documentation of the directory and target COMPILE_OPTIONS " - "properties for details. " - "Arguments to add_compile_options may use \"generator " - "expressions\" with the syntax \"$<...>\". " - CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS - ; - } - cmTypeMacro(cmAddCompileOptionsCommand, cmCommand); }; diff --git a/Source/cmAddCustomCommandCommand.h b/Source/cmAddCustomCommandCommand.h index 1cc1e3a..114957f 100644 --- a/Source/cmAddCustomCommandCommand.h +++ b/Source/cmAddCustomCommandCommand.h @@ -13,12 +13,9 @@ #define cmAddCustomCommandCommand_h #include "cmCommand.h" -#include "cmDocumentGeneratorExpressions.h" /** \class cmAddCustomCommandCommand - * \brief - * - * cmAddCustomCommandCommand defines a new command (rule) that can + * \brief cmAddCustomCommandCommand defines a new command (rule) that can * be executed within the build process * */ @@ -46,141 +43,6 @@ public: */ virtual const char* GetName() const {return "add_custom_command";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Add a custom build rule to the generated build system."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - "There are two main signatures for add_custom_command " - "The first signature is for adding a custom command " - "to produce an output.\n" - " add_custom_command(OUTPUT output1 [output2 ...]\n" - " COMMAND command1 [ARGS] [args1...]\n" - " [COMMAND command2 [ARGS] [args2...] ...]\n" - " [MAIN_DEPENDENCY depend]\n" - " [DEPENDS [depends...]]\n" - " [IMPLICIT_DEPENDS <lang1> depend1\n" - " [<lang2> depend2] ...]\n" - " [WORKING_DIRECTORY dir]\n" - " [COMMENT comment] [VERBATIM] [APPEND])\n" - "This defines a command to generate specified OUTPUT file(s). " - "A target created in the same directory (CMakeLists.txt file) that " - "specifies any output of the custom command as a source file is given " - "a rule to generate the file using the command at build time. " - "Do not list the output in more than one independent target that may " - "build in parallel or the two instances of the rule may conflict " - "(instead use add_custom_target to drive the command and make the " - "other targets depend on that one). " - "If an output name is a relative path it will be interpreted " - "relative to the build tree directory corresponding to the current " - "source directory. " - "Note that MAIN_DEPENDENCY is completely optional and is " - "used as a suggestion to visual studio about where to hang the " - "custom command. In makefile terms this creates a new target in the " - "following form:\n" - " OUTPUT: MAIN_DEPENDENCY DEPENDS\n" - " COMMAND\n" - "If more than one command is specified they will be executed in order. " - "The optional ARGS argument is for backward compatibility and will be " - "ignored.\n" - "The second signature adds a custom command to a target " - "such as a library or executable. This is useful for " - "performing an operation before or after building the target. " - "The command becomes part of the target and will only execute " - "when the target itself is built. If the target is already built," - " the command will not execute.\n" - " add_custom_command(TARGET target\n" - " PRE_BUILD | PRE_LINK | POST_BUILD\n" - " COMMAND command1 [ARGS] [args1...]\n" - " [COMMAND command2 [ARGS] [args2...] ...]\n" - " [WORKING_DIRECTORY dir]\n" - " [COMMENT comment] [VERBATIM])\n" - "This defines a new command that will be associated with " - "building the specified target. When the command will " - "happen is determined by which of the following is specified:\n" - " PRE_BUILD - run before all other dependencies\n" - " PRE_LINK - run after other dependencies\n" - " POST_BUILD - run after the target has been built\n" - "Note that the PRE_BUILD option is only supported on Visual " - "Studio 7 or later. For all other generators PRE_BUILD " - "will be treated as PRE_LINK.\n" - "If WORKING_DIRECTORY is specified the command will be executed " - "in the directory given. " - "If it is a relative path it will be interpreted relative to the " - "build tree directory corresponding to the current source directory. " - "If COMMENT is set, the value will be displayed as a " - "message before the commands are executed at build time. " - "If APPEND is specified the COMMAND and DEPENDS option values " - "are appended to the custom command for the first output specified. " - "There must have already been a previous call to this command with " - "the same output. The COMMENT, WORKING_DIRECTORY, and MAIN_DEPENDENCY " - "options are currently ignored when APPEND is given, " - "but may be used in the future." - "\n" - "If VERBATIM is given then all arguments to the commands will be " - "escaped properly for the build tool so that the invoked command " - "receives each argument unchanged. " - "Note that one level of escapes is still used by the CMake language " - "processor before add_custom_command even sees the arguments. " - "Use of VERBATIM is recommended as it enables correct behavior. " - "When VERBATIM is not given the behavior is platform specific because " - "there is no protection of tool-specific special characters." - "\n" - "If the output of the custom command is not actually " - "created as a file on disk it should be marked as SYMBOLIC with " - "SET_SOURCE_FILES_PROPERTIES.\n" - - "The IMPLICIT_DEPENDS option requests scanning of implicit " - "dependencies of an input file. The language given specifies the " - "programming language whose corresponding dependency scanner should " - "be used. Currently only C and CXX language scanners are supported. " - "The language has to be specified for every file in the " - "IMPLICIT_DEPENDS list. " - "Dependencies discovered from the scanning are added to those of " - "the custom command at build time. Note that the IMPLICIT_DEPENDS " - "option is currently supported only for Makefile generators and " - "will be ignored by other generators." - "\n" - "If COMMAND specifies an executable target (created by " - "ADD_EXECUTABLE) it will automatically be replaced by the location " - "of the executable created at build time. Additionally a " - "target-level dependency will be added so that the executable target " - "will be built before any target using this custom command. However " - "this does NOT add a file-level dependency that would cause the " - "custom command to re-run whenever the executable is recompiled." - "\n" - "Arguments to COMMAND may use \"generator expressions\" with the " - "syntax \"$<...>\". " - CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS - "References to target names in generator expressions imply " - "target-level dependencies, but NOT file-level dependencies. " - "List target names with the DEPENDS option to add file dependencies." - "\n" - "The DEPENDS option specifies files on which the command depends. " - "If any dependency is an OUTPUT of another custom command in the " - "same directory (CMakeLists.txt file) CMake automatically brings the " - "other custom command into the target in which this command is built. " - "If DEPENDS is not specified the command will run whenever the OUTPUT " - "is missing; if the command does not actually create the OUTPUT then " - "the rule will always run. " - "If DEPENDS specifies any target (created by an ADD_* command) " - "a target-level dependency is created to make sure the target is " - "built before any target using this custom command. Additionally, " - "if the target is an executable or library a file-level dependency " - "is created to cause the custom command to re-run whenever the target " - "is recompiled.\n" - ; - } - cmTypeMacro(cmAddCustomCommandCommand, cmCommand); protected: bool CheckOutputs(const std::vector<std::string>& outputs); diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx index 4eba886..ef62523 100644 --- a/Source/cmAddCustomTargetCommand.cxx +++ b/Source/cmAddCustomTargetCommand.cxx @@ -11,6 +11,9 @@ ============================================================================*/ #include "cmAddCustomTargetCommand.h" +#include "cmGeneratorExpression.h" +#include "cmGlobalGenerator.h" + // cmAddCustomTargetCommand bool cmAddCustomTargetCommand ::InitialPass(std::vector<std::string> const& args, @@ -22,20 +25,17 @@ bool cmAddCustomTargetCommand return false; } + std::string targetName = args[0]; + // Check the target name. - if(args[0].find_first_of("/\\") != args[0].npos) + if(targetName.find_first_of("/\\") != targetName.npos) { - if(!this->Makefile->NeedBackwardsCompatibility(2,2)) - { - cmOStringStream e; - e << "called with invalid target name \"" << args[0] - << "\". Target names may not contain a slash. " - << "Use ADD_CUSTOM_COMMAND to generate files. " - << "Set CMAKE_BACKWARDS_COMPATIBILITY to 2.2 " - << "or lower to skip this check."; - this->SetError(e.str().c_str()); - return false; - } + cmOStringStream e; + e << "called with invalid target name \"" << targetName + << "\". Target names may not contain a slash. " + << "Use ADD_CUSTOM_COMMAND to generate files."; + this->SetError(e.str().c_str()); + return false; } // Accumulate one command line at a time. @@ -143,16 +143,59 @@ bool cmAddCustomTargetCommand } } - std::string::size_type pos = args[0].find_first_of("#<>"); - if(pos != args[0].npos) + std::string::size_type pos = targetName.find_first_of("#<>"); + if(pos != targetName.npos) { cmOStringStream msg; - msg << "called with target name containing a \"" << args[0][pos] + msg << "called with target name containing a \"" << targetName[pos] << "\". This character is not allowed."; this->SetError(msg.str().c_str()); return false; } + // Some requirements on custom target names already exist + // and have been checked at this point. + // The following restrictions overlap but depend on policy CMP0037. + bool nameOk = cmGeneratorExpression::IsValidTargetName(targetName) && + !cmGlobalGenerator::IsReservedTarget(targetName); + if (nameOk) + { + nameOk = targetName.find(":") == std::string::npos; + } + if (!nameOk) + { + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + bool issueMessage = false; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) + { + case cmPolicies::WARN: + issueMessage = true; + case cmPolicies::OLD: + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + issueMessage = true; + messageType = cmake::FATAL_ERROR; + } + if (issueMessage) + { + cmOStringStream e; + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0037)) << "\n"; + e << "The target name \"" << targetName << + "\" is reserved or not valid for certain " + "CMake features, such as generator expressions, and may result " + "in undefined behavior."; + this->Makefile->IssueMessage(messageType, e.str().c_str()); + + if (messageType == cmake::FATAL_ERROR) + { + return false; + } + } + } + // Store the last command line finished. if(!currentLine.empty()) { @@ -163,7 +206,7 @@ bool cmAddCustomTargetCommand // Enforce name uniqueness. { std::string msg; - if(!this->Makefile->EnforceUniqueName(args[0], msg, true)) + if(!this->Makefile->EnforceUniqueName(targetName, msg, true)) { this->SetError(msg.c_str()); return false; @@ -181,7 +224,7 @@ bool cmAddCustomTargetCommand // Add the utility target to the makefile. bool escapeOldStyle = !verbatim; cmTarget* target = - this->Makefile->AddUtilityCommand(args[0].c_str(), excludeFromAll, + this->Makefile->AddUtilityCommand(targetName.c_str(), excludeFromAll, working_directory.c_str(), depends, commandLines, escapeOldStyle, comment); diff --git a/Source/cmAddCustomTargetCommand.h b/Source/cmAddCustomTargetCommand.h index d4ed450..d0fcdad 100644 --- a/Source/cmAddCustomTargetCommand.h +++ b/Source/cmAddCustomTargetCommand.h @@ -45,63 +45,6 @@ public: virtual const char* GetName() const {return "add_custom_target";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Add a target with no output so it will always be built."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " add_custom_target(Name [ALL] [command1 [args1...]]\n" - " [COMMAND command2 [args2...] ...]\n" - " [DEPENDS depend depend depend ... ]\n" - " [WORKING_DIRECTORY dir]\n" - " [COMMENT comment] [VERBATIM]\n" - " [SOURCES src1 [src2...]])\n" - "Adds a target with the given name that executes the given commands. " - "The target has no output file and is ALWAYS CONSIDERED OUT OF DATE " - "even if the commands try to create a file with the name of the " - "target. Use ADD_CUSTOM_COMMAND to generate a file with dependencies. " - "By default nothing depends on the custom target. Use " - "ADD_DEPENDENCIES to add dependencies to or from other targets. " - "If the ALL option is specified " - "it indicates that this target should be added to the default build " - "target so that it will be run every time " - "(the command cannot be called ALL). " - "The command and arguments are optional and if not specified an " - "empty target will be created. " - "If WORKING_DIRECTORY is set, then the command will be run in that " - "directory. " - "If it is a relative path it will be interpreted relative to the " - "build tree directory corresponding to the current source directory. " - "If COMMENT is set, the value will be displayed as a " - "message before the commands are executed at build time. " - "Dependencies listed with the DEPENDS argument may reference files " - "and outputs of custom commands created with add_custom_command() in " - "the same directory (CMakeLists.txt file).\n" - "If VERBATIM is given then all arguments to the commands will be " - "escaped properly for the build tool so that the invoked command " - "receives each argument unchanged. " - "Note that one level of escapes is still used by the CMake language " - "processor before add_custom_target even sees the arguments. " - "Use of VERBATIM is recommended as it enables correct behavior. " - "When VERBATIM is not given the behavior is platform specific because " - "there is no protection of tool-specific special characters." - "\n" - "The SOURCES option specifies additional source files to be included " - "in the custom target. " - "Specified source files will be added to IDE project files for " - "convenience in editing even if they have not build rules." - ; - } - cmTypeMacro(cmAddCustomTargetCommand, cmCommand); }; diff --git a/Source/cmAddDefinitionsCommand.h b/Source/cmAddDefinitionsCommand.h index ff2c4a0..d05f187 100644 --- a/Source/cmAddDefinitionsCommand.h +++ b/Source/cmAddDefinitionsCommand.h @@ -43,35 +43,6 @@ public: */ virtual const char* GetName() const {return "add_definitions";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Adds -D define flags to the compilation of source files."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " add_definitions(-DFOO -DBAR ...)\n" - "Adds flags to the compiler command line for sources in the current " - "directory and below. This command can be used to add any flags, " - "but it was originally intended to add preprocessor definitions. " - "Flags beginning in -D or /D that look like preprocessor definitions " - "are automatically added to the COMPILE_DEFINITIONS property for " - "the current directory. Definitions with non-trivial values may be " - "left in the set of flags instead of being converted for reasons of " - "backwards compatibility. See documentation of the directory, " - "target, and source file COMPILE_DEFINITIONS properties for details " - "on adding preprocessor definitions to specific scopes and " - "configurations." - ; - } - cmTypeMacro(cmAddDefinitionsCommand, cmCommand); }; diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx index e4d7f7f..a7ffded 100644 --- a/Source/cmAddDependenciesCommand.cxx +++ b/Source/cmAddDependenciesCommand.cxx @@ -33,11 +33,20 @@ bool cmAddDependenciesCommand } if(cmTarget* target = this->Makefile->FindTargetToUse(target_name.c_str())) { + if (target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + cmOStringStream e; + e << "Cannot add target-level dependencies to INTERFACE library " + "target \"" << target_name << "\".\n"; + this->SetError(e.str().c_str()); + return false; + } + std::vector<std::string>::const_iterator s = args.begin(); ++s; // skip over target_name for (; s != args.end(); ++s) { - target->AddUtility(s->c_str()); + target->AddUtility(s->c_str(), this->Makefile); } } else diff --git a/Source/cmAddDependenciesCommand.h b/Source/cmAddDependenciesCommand.h index ed80067..247cc54 100644 --- a/Source/cmAddDependenciesCommand.h +++ b/Source/cmAddDependenciesCommand.h @@ -42,35 +42,6 @@ public: */ virtual const char* GetName() const { return "add_dependencies";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Add a dependency between top-level targets."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " add_dependencies(target-name depend-target1\n" - " depend-target2 ...)\n" - "Make a top-level target depend on other top-level targets. A " - "top-level target is one created by ADD_EXECUTABLE, ADD_LIBRARY, " - "or ADD_CUSTOM_TARGET. Adding dependencies with this command " - "can be used to make sure one target is built before another target. " - "Dependencies added to an IMPORTED target are followed transitively " - "in its place since the target itself does not build. " - "See the DEPENDS option of ADD_CUSTOM_TARGET " - "and ADD_CUSTOM_COMMAND for adding file-level dependencies in custom " - "rules. See the OBJECT_DEPENDS option in " - "SET_SOURCE_FILES_PROPERTIES to add file-level dependencies to object " - "files."; - } - cmTypeMacro(cmAddDependenciesCommand, cmCommand); }; diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index 5785259..a352be0 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -69,6 +69,47 @@ bool cmAddExecutableCommand } } + bool nameOk = cmGeneratorExpression::IsValidTargetName(exename) && + !cmGlobalGenerator::IsReservedTarget(exename); + + if (nameOk && !importTarget && !isAlias) + { + nameOk = exename.find(":") == std::string::npos; + } + if (!nameOk) + { + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + bool issueMessage = false; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) + { + case cmPolicies::WARN: + issueMessage = true; + case cmPolicies::OLD: + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + issueMessage = true; + messageType = cmake::FATAL_ERROR; + } + if (issueMessage) + { + cmOStringStream e; + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0037)) << "\n"; + e << "The target name \"" << exename << + "\" is reserved or not valid for certain " + "CMake features, such as generator expressions, and may result " + "in undefined behavior."; + this->Makefile->IssueMessage(messageType, e.str().c_str()); + + if (messageType == cmake::FATAL_ERROR) + { + return false; + } + } + } + // Special modifiers are not allowed with IMPORTED signature. if(importTarget && (use_win32 || use_macbundle || excludeFromAll)) diff --git a/Source/cmAddExecutableCommand.h b/Source/cmAddExecutableCommand.h index 2774ce8..30ecce3 100644 --- a/Source/cmAddExecutableCommand.h +++ b/Source/cmAddExecutableCommand.h @@ -43,86 +43,6 @@ public: */ virtual const char* GetName() const { return "add_executable";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return - "Add an executable to the project using the specified source files."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " add_executable(<name> [WIN32] [MACOSX_BUNDLE]\n" - " [EXCLUDE_FROM_ALL]\n" - " source1 source2 ... sourceN)\n" - "Adds an executable target called <name> to be built from the " - "source files listed in the command invocation. " - "The <name> corresponds to the logical target name and must be " - "globally unique within a project. " - "The actual file name of the executable built is constructed based on " - "conventions of the native platform " - "(such as <name>.exe or just <name>). " - "\n" - "By default the executable file will be created in the build tree " - "directory corresponding to the source tree directory in which " - "the command was invoked. " - "See documentation of the RUNTIME_OUTPUT_DIRECTORY " - "target property to change this location. " - "See documentation of the OUTPUT_NAME target property to change " - "the <name> part of the final file name. " - "\n" - "If WIN32 is given the property WIN32_EXECUTABLE will be set on the " - "target created. " - "See documentation of that target property for details." - "\n" - "If MACOSX_BUNDLE is given the corresponding property will be " - "set on the created target. " - "See documentation of the MACOSX_BUNDLE target property for details." - "\n" - "If EXCLUDE_FROM_ALL is given the corresponding property will be " - "set on the created target. " - "See documentation of the EXCLUDE_FROM_ALL target property for " - "details." - "\n" - "The add_executable command can also create IMPORTED executable " - "targets using this signature:\n" - " add_executable(<name> IMPORTED [GLOBAL])\n" - "An IMPORTED executable target references an executable file located " - "outside the project. " - "No rules are generated to build it. " - "The target name has scope in the directory in which it is created " - "and below, but the GLOBAL option extends visibility. " - "It may be referenced like any target built within the project. " - "IMPORTED executables are useful for convenient reference from " - "commands like add_custom_command. " - "Details about the imported executable are specified by setting " - "properties whose names begin in \"IMPORTED_\". " - "The most important such property is IMPORTED_LOCATION " - "(and its per-configuration version IMPORTED_LOCATION_<CONFIG>) " - "which specifies the location of the main executable file on disk. " - "See documentation of the IMPORTED_* properties for more information." - "\n" - "The signature\n" - " add_executable(<name> ALIAS <target>)\n" - "creates an alias, such that <name> can be used to refer to <target> " - "in subsequent commands. The <name> does not appear in the generated " - "buildsystem as a make target. The <target> may not be an IMPORTED " - "target or an ALIAS. Alias targets can be used as linkable targets, " - "targets to read properties from, executables for custom commands and " - "custom targets. They can also be tested for existance with the " - "regular if(TARGET) subcommand. The <name> may not be used to modify " - "properties of <target>, that is, it may not be used as the operand of " - "set_property, set_target_properties, target_link_libraries etc. An " - "ALIAS target may not be installed of exported." - ; - } - cmTypeMacro(cmAddExecutableCommand, cmCommand); }; diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index cbc6ed1..2627445 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -49,41 +49,117 @@ bool cmAddLibraryCommand std::string libType = *s; if(libType == "STATIC") { + if (type == cmTarget::INTERFACE_LIBRARY) + { + cmOStringStream e; + e << "INTERFACE library specified with conflicting STATIC type."; + this->SetError(e.str().c_str()); + return false; + } ++s; type = cmTarget::STATIC_LIBRARY; haveSpecifiedType = true; } else if(libType == "SHARED") { + if (type == cmTarget::INTERFACE_LIBRARY) + { + cmOStringStream e; + e << "INTERFACE library specified with conflicting SHARED type."; + this->SetError(e.str().c_str()); + return false; + } ++s; type = cmTarget::SHARED_LIBRARY; haveSpecifiedType = true; } else if(libType == "MODULE") { + if (type == cmTarget::INTERFACE_LIBRARY) + { + cmOStringStream e; + e << "INTERFACE library specified with conflicting MODULE type."; + this->SetError(e.str().c_str()); + return false; + } ++s; type = cmTarget::MODULE_LIBRARY; haveSpecifiedType = true; } else if(libType == "OBJECT") { + if (type == cmTarget::INTERFACE_LIBRARY) + { + cmOStringStream e; + e << "INTERFACE library specified with conflicting OBJECT type."; + this->SetError(e.str().c_str()); + return false; + } ++s; type = cmTarget::OBJECT_LIBRARY; haveSpecifiedType = true; } else if(libType == "UNKNOWN") { + if (type == cmTarget::INTERFACE_LIBRARY) + { + cmOStringStream e; + e << "INTERFACE library specified with conflicting UNKNOWN type."; + this->SetError(e.str().c_str()); + return false; + } ++s; type = cmTarget::UNKNOWN_LIBRARY; haveSpecifiedType = true; } else if(libType == "ALIAS") { + if (type == cmTarget::INTERFACE_LIBRARY) + { + cmOStringStream e; + e << "INTERFACE library specified with conflicting ALIAS type."; + this->SetError(e.str().c_str()); + return false; + } ++s; isAlias = true; } + else if(libType == "INTERFACE") + { + if (haveSpecifiedType) + { + cmOStringStream e; + e << "INTERFACE library specified with conflicting/multiple types."; + this->SetError(e.str().c_str()); + return false; + } + if (isAlias) + { + cmOStringStream e; + e << "INTERFACE library specified with conflicting ALIAS type."; + this->SetError(e.str().c_str()); + return false; + } + if (excludeFromAll) + { + cmOStringStream e; + e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL."; + this->SetError(e.str().c_str()); + return false; + } + ++s; + type = cmTarget::INTERFACE_LIBRARY; + haveSpecifiedType = true; + } else if(*s == "EXCLUDE_FROM_ALL") { + if (type == cmTarget::INTERFACE_LIBRARY) + { + cmOStringStream e; + e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL."; + this->SetError(e.str().c_str()); + return false; + } ++s; excludeFromAll = true; } @@ -102,6 +178,66 @@ bool cmAddLibraryCommand break; } } + + if (type == cmTarget::INTERFACE_LIBRARY) + { + if (s != args.end()) + { + cmOStringStream e; + e << "INTERFACE library requires no source arguments."; + this->SetError(e.str().c_str()); + return false; + } + if (importGlobal && !importTarget) + { + cmOStringStream e; + e << "INTERFACE library specified as GLOBAL, but not as IMPORTED."; + this->SetError(e.str().c_str()); + return false; + } + } + + bool nameOk = cmGeneratorExpression::IsValidTargetName(libName) && + !cmGlobalGenerator::IsReservedTarget(libName); + + if (nameOk && !importTarget && !isAlias) + { + nameOk = libName.find(":") == std::string::npos; + } + if (!nameOk) + { + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + bool issueMessage = false; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) + { + case cmPolicies::WARN: + issueMessage = type != cmTarget::INTERFACE_LIBRARY; + case cmPolicies::OLD: + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + issueMessage = true; + messageType = cmake::FATAL_ERROR; + } + if (issueMessage) + { + cmOStringStream e; + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0037)) << "\n"; + e << "The target name \"" << libName << + "\" is reserved or not valid for certain " + "CMake features, such as generator expressions, and may result " + "in undefined behavior."; + this->Makefile->IssueMessage(messageType, e.str().c_str()); + + if (messageType == cmake::FATAL_ERROR) + { + return false; + } + } + } + if (isAlias) { if(!cmGeneratorExpression::IsValidTargetName(libName.c_str())) @@ -151,7 +287,8 @@ bool cmAddLibraryCommand if(aliasedType != cmTarget::SHARED_LIBRARY && aliasedType != cmTarget::STATIC_LIBRARY && aliasedType != cmTarget::MODULE_LIBRARY - && aliasedType != cmTarget::OBJECT_LIBRARY) + && aliasedType != cmTarget::OBJECT_LIBRARY + && aliasedType != cmTarget::INTERFACE_LIBRARY) { cmOStringStream e; e << "cannot create ALIAS target \"" << libName @@ -183,6 +320,7 @@ bool cmAddLibraryCommand yet its linker language. */ if ((type != cmTarget::STATIC_LIBRARY) && (type != cmTarget::OBJECT_LIBRARY) && + (type != cmTarget::INTERFACE_LIBRARY) && (this->Makefile->GetCMakeInstance()->GetPropertyAsBool( "TARGET_SUPPORTS_SHARED_LIBS") == false)) { @@ -213,6 +351,16 @@ bool cmAddLibraryCommand ); return true; } + if(type == cmTarget::INTERFACE_LIBRARY) + { + if (!cmGeneratorExpression::IsValidTargetName(libName)) + { + cmOStringStream e; + e << "Invalid name for IMPORTED INTERFACE library target: " << libName; + this->SetError(e.str().c_str()); + return false; + } + } // Make sure the target does not already exist. if(this->Makefile->FindTargetToUse(libName.c_str())) @@ -249,6 +397,26 @@ bool cmAddLibraryCommand } } + std::vector<std::string> srclists; + + if(type == cmTarget::INTERFACE_LIBRARY) + { + if (!cmGeneratorExpression::IsValidTargetName(libName) + || libName.find("::") != std::string::npos) + { + cmOStringStream e; + e << "Invalid name for INTERFACE library target: " << libName; + this->SetError(e.str().c_str()); + return false; + } + + this->Makefile->AddLibrary(libName.c_str(), + type, + srclists, + excludeFromAll); + return true; + } + if (s == args.end()) { std::string msg = "You have called ADD_LIBRARY for library "; @@ -258,7 +426,6 @@ bool cmAddLibraryCommand cmSystemTools::Message(msg.c_str() ,"Warning"); } - std::vector<std::string> srclists; while (s != args.end()) { srclists.push_back(*s); diff --git a/Source/cmAddLibraryCommand.h b/Source/cmAddLibraryCommand.h index 59354b0..1001043 100644 --- a/Source/cmAddLibraryCommand.h +++ b/Source/cmAddLibraryCommand.h @@ -43,117 +43,6 @@ public: */ virtual const char* GetName() const { return "add_library";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Add a library to the project using the specified source files."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " add_library(<name> [STATIC | SHARED | MODULE]\n" - " [EXCLUDE_FROM_ALL]\n" - " source1 source2 ... sourceN)\n" - "Adds a library target called <name> to be built from the " - "source files listed in the command invocation. " - "The <name> corresponds to the logical target name and must be " - "globally unique within a project. " - "The actual file name of the library built is constructed based on " - "conventions of the native platform " - "(such as lib<name>.a or <name>.lib)." - "\n" - "STATIC, SHARED, or MODULE may be given to specify the type of library " - "to be created. " - "STATIC libraries are archives of object files for use when linking " - "other targets. " - "SHARED libraries are linked dynamically and loaded at runtime. " - "MODULE libraries are plugins that are not linked into other targets " - "but may be loaded dynamically at runtime using dlopen-like " - "functionality. " - "If no type is given explicitly the type is STATIC or SHARED based " - "on whether the current value of the variable BUILD_SHARED_LIBS is " - "true. " - "For SHARED and MODULE libraries the POSITION_INDEPENDENT_CODE " - "target property is set to TRUE automatically." - "\n" - "By default the library file will be created in the build tree " - "directory corresponding to the source tree directory in which " - "the command was invoked. " - "See documentation of the ARCHIVE_OUTPUT_DIRECTORY, " - "LIBRARY_OUTPUT_DIRECTORY, and RUNTIME_OUTPUT_DIRECTORY " - "target properties to change this location. " - "See documentation of the OUTPUT_NAME target property to change " - "the <name> part of the final file name. " - "\n" - "If EXCLUDE_FROM_ALL is given the corresponding property will be " - "set on the created target. " - "See documentation of the EXCLUDE_FROM_ALL target property for " - "details." - "\n" - "The add_library command can also create IMPORTED library " - "targets using this signature:\n" - " add_library(<name> <SHARED|STATIC|MODULE|UNKNOWN> IMPORTED\n" - " [GLOBAL])\n" - "An IMPORTED library target references a library file located " - "outside the project. " - "No rules are generated to build it. " - "The target name has scope in the directory in which it is created " - "and below, but the GLOBAL option extends visibility. " - "It may be referenced like any target built within the project. " - "IMPORTED libraries are useful for convenient reference from " - "commands like target_link_libraries. " - "Details about the imported library are specified by setting " - "properties whose names begin in \"IMPORTED_\". " - "The most important such property is IMPORTED_LOCATION " - "(and its per-configuration version IMPORTED_LOCATION_<CONFIG>) " - "which specifies the location of the main library file on disk. " - "See documentation of the IMPORTED_* properties for more information." - "\n" - "The signature\n" - " add_library(<name> OBJECT <src>...)\n" - "creates a special \"object library\" target. " - "An object library compiles source files but does not archive or link " - "their object files into a library. " - "Instead other targets created by add_library or add_executable may " - "reference the objects using an expression of the form " - "$<TARGET_OBJECTS:objlib> as a source, where \"objlib\" is the " - "object library name. " - "For example:\n" - " add_library(... $<TARGET_OBJECTS:objlib> ...)\n" - " add_executable(... $<TARGET_OBJECTS:objlib> ...)\n" - "will include objlib's object files in a library and an executable " - "along with those compiled from their own sources. " - "Object libraries may contain only sources (and headers) that compile " - "to object files. " - "They may contain custom commands generating such sources, but not " - "PRE_BUILD, PRE_LINK, or POST_BUILD commands. " - "Object libraries cannot be imported, exported, installed, or linked." - " " - "Some native build systems may not like targets that have only " - "object files, so consider adding at least one real source file " - "to any target that references $<TARGET_OBJECTS:objlib>." - "\n" - "The signature\n" - " add_library(<name> ALIAS <target>)\n" - "creates an alias, such that <name> can be used to refer to <target> " - "in subsequent commands. The <name> does not appear in the generated " - "buildsystem as a make target. The <target> may not be an IMPORTED " - "target or an ALIAS. Alias targets can be used as linkable targets, " - "targets to read properties from. They can also be tested for " - "existance with the " - "regular if(TARGET) subcommand. The <name> may not be used to modify " - "properties of <target>, that is, it may not be used as the operand of " - "set_property, set_target_properties, target_link_libraries etc. An " - "ALIAS target may not be installed of exported." - ; - } - cmTypeMacro(cmAddLibraryCommand, cmCommand); }; diff --git a/Source/cmAddSubDirectoryCommand.h b/Source/cmAddSubDirectoryCommand.h index e7f907c..1e5b1ab 100644 --- a/Source/cmAddSubDirectoryCommand.h +++ b/Source/cmAddSubDirectoryCommand.h @@ -44,53 +44,6 @@ public: */ virtual const char* GetName() const { return "add_subdirectory";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Add a subdirectory to the build."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " add_subdirectory(source_dir [binary_dir] \n" - " [EXCLUDE_FROM_ALL])\n" - "Add a subdirectory to the build. The source_dir specifies the " - "directory in which the source CMakeLists.txt and code files are " - "located. If it is a relative " - "path it will be evaluated with respect to the current " - "directory (the typical usage), but it may also be an absolute path. " - "The binary_dir specifies the directory in which to place the output " - "files. If it is a relative path it will be evaluated with respect " - "to the current output directory, but it may also be an absolute " - "path. If binary_dir is not specified, the value of source_dir, " - "before expanding any relative path, will be used (the typical usage). " - "The CMakeLists.txt file in the specified source directory will " - "be processed immediately by CMake before processing in the current " - "input file continues beyond this command.\n" - - "If the EXCLUDE_FROM_ALL argument is provided then targets in the " - "subdirectory will not be included in the ALL target of the parent " - "directory by default, and will be excluded from IDE project files. " - "Users must explicitly build targets in the subdirectory. " - "This is meant for use when the subdirectory contains a separate part " - "of the project that is useful but not necessary, such as a set of " - "examples. " - "Typically the subdirectory should contain its own project() command " - "invocation so that a full build system will be generated in the " - "subdirectory (such as a VS IDE solution file). " - "Note that inter-target dependencies supercede this exclusion. " - "If a target built by the parent project depends on a target in the " - "subdirectory, the dependee target will be included in the parent " - "project build system to satisfy the dependency." - ; - } - cmTypeMacro(cmAddSubDirectoryCommand, cmCommand); }; diff --git a/Source/cmAddTestCommand.h b/Source/cmAddTestCommand.h index ec7fda3..9173454 100644 --- a/Source/cmAddTestCommand.h +++ b/Source/cmAddTestCommand.h @@ -13,7 +13,6 @@ #define cmAddTestCommand_h #include "cmCommand.h" -#include "cmDocumentGeneratorExpressions.h" /** \class cmAddTestCommand * \brief Add a test to the lists of tests to run. @@ -43,58 +42,6 @@ public: */ virtual const char* GetName() const { return "add_test";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Add a test to the project with the specified arguments."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " add_test(testname Exename arg1 arg2 ... )\n" - "If the ENABLE_TESTING command has been run, this command adds a " - "test target to the current directory. If ENABLE_TESTING has not " - "been run, this command does nothing. " - "The tests are run by the testing subsystem by executing Exename " - "with the specified arguments. Exename can be either an executable " - "built by this project or an arbitrary executable on the " - "system (like tclsh). The test will be run with the current working " - "directory set to the CMakeList.txt files corresponding directory " - "in the binary tree.\n" - "\n" - " add_test(NAME <name> [CONFIGURATIONS [Debug|Release|...]]\n" - " [WORKING_DIRECTORY dir]\n" - " COMMAND <command> [arg1 [arg2 ...]])\n" - "Add a test called <name>. " - "The test name may not contain spaces, quotes, or other characters " - "special in CMake syntax. " - "If COMMAND specifies an executable target (created by " - "add_executable) it will automatically be replaced by the location " - "of the executable created at build time. " - "If a CONFIGURATIONS option is given then the test will be executed " - "only when testing under one of the named configurations. " - "If a WORKING_DIRECTORY option is given then the test will be executed " - "in the given directory." - "\n" - "Arguments after COMMAND may use \"generator expressions\" with the " - "syntax \"$<...>\". " - CM_DOCUMENT_ADD_TEST_GENERATOR_EXPRESSIONS - "Example usage:\n" - " add_test(NAME mytest\n" - " COMMAND testDriver --config $<CONFIGURATION>\n" - " --exe $<TARGET_FILE:myexe>)\n" - "This creates a test \"mytest\" whose command runs a testDriver " - "tool passing the configuration name and the full path to the " - "executable file produced by target \"myexe\"." - ; - } - cmTypeMacro(cmAddTestCommand, cmCommand); private: bool HandleNameMode(std::vector<std::string> const& args); diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index b410e44..d5dcd6a 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -14,6 +14,7 @@ #include "cmSystemTools.h" #include <cmsys/ios/iostream> #include <cmsys/Directory.hxx> +#include <cmsys/FStream.hxx> #include <cm_libarchive.h> //---------------------------------------------------------------------------- @@ -263,7 +264,7 @@ bool cmArchiveWrite::AddFile(const char* file, //---------------------------------------------------------------------------- bool cmArchiveWrite::AddData(const char* file, size_t size) { - std::ifstream fin(file, std::ios::in | cmsys_ios_binary); + cmsys::ifstream fin(file, std::ios::in | cmsys_ios_binary); if(!fin) { this->Error = "Error opening \""; diff --git a/Source/cmAuxSourceDirectoryCommand.h b/Source/cmAuxSourceDirectoryCommand.h index 8a70f19..8b5fa8a 100644 --- a/Source/cmAuxSourceDirectoryCommand.h +++ b/Source/cmAuxSourceDirectoryCommand.h @@ -46,38 +46,6 @@ public: */ virtual const char* GetName() const { return "aux_source_directory";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Find all source files in a directory."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " aux_source_directory(<dir> <variable>)\n" - "Collects the names of all the source files in the specified " - "directory and stores the list in the <variable> provided. This " - "command is intended to be used by projects that use explicit " - "template instantiation. Template instantiation files can be " - "stored in a \"Templates\" subdirectory and collected automatically " - "using this command to avoid manually listing all instantiations.\n" - "It is tempting to use this command to avoid writing the list of " - "source files for a library or executable target. While this seems " - "to work, there is no way for CMake to generate a build system that " - "knows when a new source file has been added. Normally the " - "generated build system knows when it needs to rerun CMake because " - "the CMakeLists.txt file is modified to add a new source. When the " - "source is just added to the directory without modifying this file, " - "one would have to manually rerun CMake to generate a build system " - "incorporating the new file."; - } - cmTypeMacro(cmAuxSourceDirectoryCommand, cmCommand); }; diff --git a/Source/cmBreakCommand.h b/Source/cmBreakCommand.h index 17f57cf..52f0e9c 100644 --- a/Source/cmBreakCommand.h +++ b/Source/cmBreakCommand.h @@ -47,24 +47,6 @@ public: */ virtual const char* GetName() const {return "break";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Break from an enclosing foreach or while loop."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " break()\n" - "Breaks from an enclosing foreach loop or while loop"; - } - cmTypeMacro(cmBreakCommand, cmCommand); }; diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx index b6e2569..c06b8ad 100644 --- a/Source/cmBuildCommand.cxx +++ b/Source/cmBuildCommand.cxx @@ -85,18 +85,7 @@ bool cmBuildCommand } } - const char* makeprogram - = this->Makefile->GetDefinition("CMAKE_MAKE_PROGRAM"); - if(!makeprogram) - { - this->Makefile->IssueMessage( - cmake::FATAL_ERROR, - "build_command() requires CMAKE_MAKE_PROGRAM to be defined. " - "Call project() or enable_language() first."); - return true; - } - - // If null/empty CONFIGURATION argument, GenerateBuildCommand uses 'Debug' + // If null/empty CONFIGURATION argument, cmake --build uses 'Debug' // in the currently implemented multi-configuration global generators... // so we put this code here to end up with the same default configuration // as the original 2-arg build_command signature: @@ -110,19 +99,15 @@ bool cmBuildCommand configuration = "Release"; } - // If null/empty PROJECT_NAME argument, use the Makefile's project name: - // - if(!project_name || !*project_name) + if(project_name && *project_name) { - project_name = this->Makefile->GetProjectName(); + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, + "Ignoring PROJECT_NAME option because it has no effect."); } - // If null/empty TARGET argument, GenerateBuildCommand omits any mention - // of a target name on the build command line... - // std::string makecommand = this->Makefile->GetLocalGenerator() - ->GetGlobalGenerator()->GenerateBuildCommand - (makeprogram, project_name, 0, 0, target, configuration, true, false); + ->GetGlobalGenerator()->GenerateCMakeBuildCommand(target, configuration, + 0, true); this->Makefile->AddDefinition(variable, makecommand.c_str()); @@ -142,7 +127,6 @@ bool cmBuildCommand const char* define = args[0].c_str(); const char* cacheValue = this->Makefile->GetDefinition(define); - std::string makeprogram = args[1]; std::string configType = "Release"; const char* cfg = getenv("CMAKE_CONFIG_TYPE"); @@ -152,9 +136,8 @@ bool cmBuildCommand } std::string makecommand = this->Makefile->GetLocalGenerator() - ->GetGlobalGenerator()->GenerateBuildCommand - (makeprogram.c_str(), this->Makefile->GetProjectName(), 0, 0, - 0, configType.c_str(), true, false); + ->GetGlobalGenerator()->GenerateCMakeBuildCommand(0, configType.c_str(), + 0, true); if(cacheValue) { diff --git a/Source/cmBuildCommand.h b/Source/cmBuildCommand.h index 1bab453..2160655 100644 --- a/Source/cmBuildCommand.h +++ b/Source/cmBuildCommand.h @@ -52,45 +52,6 @@ public: */ virtual const char* GetName() const {return "build_command";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Get the command line to build this project."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " build_command(<variable>\n" - " [CONFIGURATION <config>]\n" - " [PROJECT_NAME <projname>]\n" - " [TARGET <target>])\n" - "Sets the given <variable> to a string containing the command line " - "for building one configuration of a target in a project using the " - "build tool appropriate for the current CMAKE_GENERATOR.\n" - "If CONFIGURATION is omitted, CMake chooses a reasonable default " - "value for multi-configuration generators. CONFIGURATION is " - "ignored for single-configuration generators.\n" - "If PROJECT_NAME is omitted, the resulting command line will build " - "the top level PROJECT in the current build tree.\n" - "If TARGET is omitted, the resulting command line will build " - "everything, effectively using build target 'all' or 'ALL_BUILD'.\n" - " build_command(<cachevariable> <makecommand>)\n" - "This second signature is deprecated, but still available for " - "backwards compatibility. Use the first signature instead.\n" - "Sets the given <cachevariable> to a string containing the command " - "to build this project from the root of the build tree using " - "the build tool given by <makecommand>. <makecommand> should be " - "the full path to msdev, devenv, nmake, make or one of the end " - "user build tools." - ; - } - cmTypeMacro(cmBuildCommand, cmCommand); }; diff --git a/Source/cmBuildNameCommand.cxx b/Source/cmBuildNameCommand.cxx index f95a79e..e3528e1 100644 --- a/Source/cmBuildNameCommand.cxx +++ b/Source/cmBuildNameCommand.cxx @@ -17,6 +17,9 @@ bool cmBuildNameCommand ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) { + if(this->Disallowed(cmPolicies::CMP0036, + "The build_name command should not be called; see CMP0036.")) + { return true; } if(args.size() < 1 ) { this->SetError("called with incorrect number of arguments"); diff --git a/Source/cmBuildNameCommand.h b/Source/cmBuildNameCommand.h index 26505a2..2f7acde 100644 --- a/Source/cmBuildNameCommand.h +++ b/Source/cmBuildNameCommand.h @@ -14,67 +14,16 @@ #include "cmCommand.h" -/** \class cmBuildNameCommand - * \brief build_name command - * - * cmBuildNameCommand implements the build_name CMake command - */ class cmBuildNameCommand : public cmCommand { public: - /** - * This is a virtual constructor for the command. - */ - virtual cmCommand* Clone() - { - return new cmBuildNameCommand; - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ + cmTypeMacro(cmBuildNameCommand, cmCommand); + virtual cmCommand* Clone() { return new cmBuildNameCommand; } virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); - - /** - * This determines if the command is invoked when in script mode. - */ - virtual bool IsScriptable() const { return true; } - - /** - * The name of the command as specified in CMakeList.txt. - */ virtual const char* GetName() const {return "build_name";} - - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return - "Deprecated. Use ${CMAKE_SYSTEM} and ${CMAKE_CXX_COMPILER} instead."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " build_name(variable)\n" - "Sets the specified variable to a string representing the platform " - "and compiler settings. These values are now available through the " - "CMAKE_SYSTEM and CMAKE_CXX_COMPILER variables."; - } - - /** This command is kept for compatibility with older CMake versions. */ - virtual bool IsDiscouraged() const - { - return true; - } - - cmTypeMacro(cmBuildNameCommand, cmCommand); + virtual bool IsScriptable() const { return true; } + virtual bool IsDiscouraged() const { return true; } }; diff --git a/Source/cmCMakeHostSystemInformationCommand.h b/Source/cmCMakeHostSystemInformationCommand.h index d1b8700..27ba638 100644 --- a/Source/cmCMakeHostSystemInformationCommand.h +++ b/Source/cmCMakeHostSystemInformationCommand.h @@ -53,41 +53,6 @@ public: return "cmake_host_system_information"; } - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Query host system specific information."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " cmake_host_system_information(RESULT <variable> QUERY <key> ...)\n" - "Queries system information of the host system on which cmake runs. " - "One or more <key> can be provided to " - "select the information to be queried. " - "The list of queried values is stored in <variable>.\n" - "<key> can be one of the following values:\n" - " NUMBER_OF_LOGICAL_CORES = Number of logical cores.\n" - " NUMBER_OF_PHYSICAL_CORES = Number of physical cores.\n" - " HOSTNAME = Hostname.\n" - " FQDN = Fully qualified domain name.\n" - " TOTAL_VIRTUAL_MEMORY = " - "Total virtual memory in megabytes.\n" - " AVAILABLE_VIRTUAL_MEMORY = " - "Available virtual memory in megabytes.\n" - " TOTAL_PHYSICAL_MEMORY = " - "Total physical memory in megabytes.\n" - " AVAILABLE_PHYSICAL_MEMORY = " - "Available physical memory in megabytes.\n" - ; - } - cmTypeMacro(cmCMakeHostSystemInformationCommand, cmCommand); private: diff --git a/Source/cmCMakeMinimumRequired.cxx b/Source/cmCMakeMinimumRequired.cxx index 49c585f..6e2ca64 100644 --- a/Source/cmCMakeMinimumRequired.cxx +++ b/Source/cmCMakeMinimumRequired.cxx @@ -114,6 +114,9 @@ bool cmCMakeMinimumRequired if (required_major < 2 || (required_major == 2 && required_minor < 4)) { + this->Makefile->IssueMessage( + cmake::AUTHOR_WARNING, + "Compatibility with CMake < 2.4 is not supported by CMake >= 3.0."); this->Makefile->SetPolicyVersion("2.4"); } else diff --git a/Source/cmCMakeMinimumRequired.h b/Source/cmCMakeMinimumRequired.h index acf2829..0cdd4c5 100644 --- a/Source/cmCMakeMinimumRequired.h +++ b/Source/cmCMakeMinimumRequired.h @@ -47,37 +47,6 @@ public: */ virtual const char* GetName() const {return "cmake_minimum_required";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Set the minimum required version of cmake for a project."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " cmake_minimum_required(VERSION major[.minor[.patch[.tweak]]]\n" - " [FATAL_ERROR])\n" - "If the current version of CMake is lower than that required " - "it will stop processing the project and report an error. " - "When a version higher than 2.4 is specified the command implicitly " - "invokes\n" - " cmake_policy(VERSION major[.minor[.patch[.tweak]]])\n" - "which sets the cmake policy version level to the version specified. " - "When version 2.4 or lower is given the command implicitly invokes\n" - " cmake_policy(VERSION 2.4)\n" - "which enables compatibility features for CMake 2.4 and lower.\n" - "The FATAL_ERROR option is accepted but ignored by CMake 2.6 " - "and higher. " - "It should be specified so CMake versions 2.4 and lower fail with an " - "error instead of just a warning."; - } - cmTypeMacro(cmCMakeMinimumRequired, cmCommand); private: diff --git a/Source/cmCMakePolicyCommand.h b/Source/cmCMakePolicyCommand.h index 4f9faa1..7e3f4e6 100644 --- a/Source/cmCMakePolicyCommand.h +++ b/Source/cmCMakePolicyCommand.h @@ -48,88 +48,6 @@ public: */ virtual const char* GetName() const {return "cmake_policy";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Manage CMake Policy settings."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - "As CMake evolves it is sometimes necessary to change existing " - "behavior in order to fix bugs or improve implementations of " - "existing features. " - "The CMake Policy mechanism is designed to help keep existing projects " - "building as new versions of CMake introduce changes in behavior. " - "Each new policy (behavioral change) is given an identifier of " - "the form \"CMP<NNNN>\" where \"<NNNN>\" is an integer index. " - "Documentation associated with each policy describes the OLD and NEW " - "behavior and the reason the policy was introduced. " - "Projects may set each policy to select the desired behavior. " - "When CMake needs to know which behavior to use it checks for " - "a setting specified by the project. " - "If no setting is available the OLD behavior is assumed and a warning " - "is produced requesting that the policy be set.\n" - "The cmake_policy command is used to set policies to OLD or NEW " - "behavior. " - "While setting policies individually is supported, we encourage " - "projects to set policies based on CMake versions.\n" - " cmake_policy(VERSION major.minor[.patch[.tweak]])\n" - "Specify that the current CMake list file is written for the " - "given version of CMake. " - "All policies introduced in the specified version or earlier " - "will be set to use NEW behavior. " - "All policies introduced after the specified version will be unset " - "(unless variable CMAKE_POLICY_DEFAULT_CMP<NNNN> sets a default). " - "This effectively requests behavior preferred as of a given CMake " - "version and tells newer CMake versions to warn about their new " - "policies. " - "The policy version specified must be at least 2.4 or the command " - "will report an error. " - "In order to get compatibility features supporting versions earlier " - "than 2.4 see documentation of policy CMP0001." - "\n" - " cmake_policy(SET CMP<NNNN> NEW)\n" - " cmake_policy(SET CMP<NNNN> OLD)\n" - "Tell CMake to use the OLD or NEW behavior for a given policy. " - "Projects depending on the old behavior of a given policy may " - "silence a policy warning by setting the policy state to OLD. " - "Alternatively one may fix the project to work with the new behavior " - "and set the policy state to NEW." - "\n" - " cmake_policy(GET CMP<NNNN> <variable>)\n" - "Check whether a given policy is set to OLD or NEW behavior. " - "The output variable value will be \"OLD\" or \"NEW\" if the " - "policy is set, and empty otherwise." - "\n" - "CMake keeps policy settings on a stack, so changes made by the " - "cmake_policy command affect only the top of the stack. " - "A new entry on the policy stack is managed automatically for each " - "subdirectory to protect its parents and siblings. " - "CMake also manages a new entry for scripts loaded by include() and " - "find_package() commands except when invoked with the NO_POLICY_SCOPE " - "option (see also policy CMP0011). " - "The cmake_policy command provides an interface to manage custom " - "entries on the policy stack:\n" - " cmake_policy(PUSH)\n" - " cmake_policy(POP)\n" - "Each PUSH must have a matching POP to erase any changes. " - "This is useful to make temporary changes to policy settings." - "\n" - "Functions and macros record policy settings when they are created " - "and use the pre-record policies when they are invoked. " - "If the function or macro implementation sets policies, the changes " - "automatically propagate up through callers until they reach the " - "closest nested policy stack entry." - ; - } - cmTypeMacro(cmCMakePolicyCommand, cmCommand); private: bool HandleSetMode(std::vector<std::string> const& args); diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 14e1f50..acedc1a 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -19,6 +19,7 @@ #include <cmsys/Base64.h> #include <cmsys/Directory.hxx> #include <cmsys/SystemInformation.hxx> +#include <cmsys/FStream.hxx> #include "cmDynamicLoader.h" #include "cmGeneratedFileStream.h" #include "cmXMLSafe.h" @@ -53,14 +54,10 @@ #include <cm_zlib.h> #include <cmsys/Base64.h> -#if defined(__BEOS__) +#if defined(__BEOS__) || defined(__HAIKU__) #include <be/kernel/OS.h> /* disable_debugger() API. */ #endif -#if defined(__HAIKU__) -#include <os/kernel/OS.h> /* disable_debugger() API. */ -#endif - #define DEBUGOUT std::cout << __LINE__ << " "; std::cout #define DEBUGERR std::cerr << __LINE__ << " "; std::cerr @@ -211,7 +208,7 @@ int cmCTest::HTTPRequest(std::string url, HTTPMethod method, return -1; } ::curl_easy_setopt(curl, CURLOPT_PUT, 1); - file = ::fopen(putFile.c_str(), "rb"); + file = cmsys::SystemTools::Fopen(putFile.c_str(), "rb"); ::curl_easy_setopt(curl, CURLOPT_INFILE, file); //fall through to append GET fields case cmCTest::HTTP_GET: @@ -553,7 +550,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) } std::string tagfile = testingDir + "/TAG"; - std::ifstream tfin(tagfile.c_str()); + cmsys::ifstream tfin(tagfile.c_str()); std::string tag; if (createNewTag) @@ -608,7 +605,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) lctime->tm_hour, lctime->tm_min); tag = datestring; - std::ofstream ofs(tagfile.c_str()); + cmsys::ofstream ofs(tagfile.c_str()); if ( ofs ) { ofs << tag << std::endl; @@ -767,7 +764,7 @@ bool cmCTest::UpdateCTestConfiguration() cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Parse Config file:" << fileName.c_str() << "\n"); // parse the dart test file - std::ifstream fin(fileName.c_str()); + cmsys::ifstream fin(fileName.c_str()); if(!fin) { @@ -1135,11 +1132,11 @@ int cmCTest::GetTestModelFromString(const char* str) return cmCTest::EXPERIMENTAL; } std::string rstr = cmSystemTools::LowerCase(str); - if ( strncmp(rstr.c_str(), "cont", 4) == 0 ) + if ( cmHasLiteralPrefix(rstr.c_str(), "cont") ) { return cmCTest::CONTINUOUS; } - if ( strncmp(rstr.c_str(), "nigh", 4) == 0 ) + if ( cmHasLiteralPrefix(rstr.c_str(), "nigh") ) { return cmCTest::NIGHTLY; } @@ -1153,7 +1150,7 @@ int cmCTest::GetTestModelFromString(const char* str) //---------------------------------------------------------------------- int cmCTest::RunMakeCommand(const char* command, std::string* output, - int* retVal, const char* dir, int timeout, std::ofstream& ofs) + int* retVal, const char* dir, int timeout, std::ostream& ofs) { // First generate the command and arguments std::vector<cmStdString> args = cmSystemTools::ParseArguments(command); @@ -1302,7 +1299,8 @@ int cmCTest::RunTest(std::vector<const char*> argv, } cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Test timeout computed to be: " << timeout << "\n"); - if(cmSystemTools::SameFile(argv[0], this->CTestSelf.c_str()) && + if(cmSystemTools::SameFile( + argv[0], cmSystemTools::GetCTestCommand().c_str()) && !this->ForceNewCTestProcess) { cmCTest inst; @@ -1614,7 +1612,7 @@ int cmCTest::GenerateCTestNotesOutput(std::ostream& os, << "<Time>" << cmSystemTools::GetTime() << "</Time>\n" << "<DateTime>" << note_time << "</DateTime>\n" << "<Text>" << std::endl; - std::ifstream ifs(it->c_str()); + cmsys::ifstream ifs(it->c_str()); if ( ifs ) { std::string line; @@ -1695,7 +1693,7 @@ std::string cmCTest::Base64GzipEncodeFile(std::string file) std::string cmCTest::Base64EncodeFile(std::string file) { long len = cmSystemTools::FileLength(file.c_str()); - std::ifstream ifs(file.c_str(), std::ios::in + cmsys::ifstream ifs(file.c_str(), std::ios::in #ifdef _WIN32 | std::ios::binary #endif @@ -2187,6 +2185,12 @@ void cmCTest::HandleCommandLineArguments(size_t &i, this->GetHandler("memcheck")-> SetPersistentOption("ExcludeRegularExpression", args[i].c_str()); } + + if(this->CheckArgument(arg, "--rerun-failed")) + { + this->GetHandler("test")->SetPersistentOption("RerunFailed", "true"); + this->GetHandler("memcheck")->SetPersistentOption("RerunFailed", "true"); + } } //---------------------------------------------------------------------- @@ -2255,7 +2259,6 @@ bool cmCTest::AddVariableDefinition(const std::string &arg) // the main entry point of ctest, called from main int cmCTest::Run(std::vector<std::string> &args, std::string* output) { - this->FindRunningCMake(); const char* ctestExec = "ctest"; bool cmakeAndTest = false; bool executeTests = true; @@ -2496,29 +2499,6 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output) } //---------------------------------------------------------------------- -void cmCTest::FindRunningCMake() -{ - // Find our own executable. - this->CTestSelf = cmSystemTools::GetExecutableDirectory(); - this->CTestSelf += "/ctest"; - this->CTestSelf += cmSystemTools::GetExecutableExtension(); - if(!cmSystemTools::FileExists(this->CTestSelf.c_str())) - { - cmSystemTools::Error("CTest executable cannot be found at ", - this->CTestSelf.c_str()); - } - - this->CMakeSelf = cmSystemTools::GetExecutableDirectory(); - this->CMakeSelf += "/cmake"; - this->CMakeSelf += cmSystemTools::GetExecutableExtension(); - if(!cmSystemTools::FileExists(this->CMakeSelf.c_str())) - { - cmSystemTools::Error("CMake executable cannot be found at ", - this->CMakeSelf.c_str()); - } -} - -//---------------------------------------------------------------------- void cmCTest::SetNotesFiles(const char* notes) { if ( !notes ) diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 5dd35ce..becb0f5 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -273,7 +273,7 @@ public: // and retVal is return value or exception. int RunMakeCommand(const char* command, std::string* output, int* retVal, const char* dir, int timeout, - std::ofstream& ofs); + std::ostream& ofs); /* * return the current tag @@ -287,10 +287,6 @@ public: //source directory, it will become /.../relative/path/to/file std::string GetShortPathToFile(const char* fname); - //! Get the path to CTest - const char* GetCTestExecutable() { return this->CTestSelf.c_str(); } - const char* GetCMakeExecutable() { return this->CMakeSelf.c_str(); } - enum { EXPERIMENTAL, NIGHTLY, @@ -490,8 +486,6 @@ private: int CompatibilityMode; // information for the --build-and-test options - std::string CMakeSelf; - std::string CTestSelf; std::string BinaryDir; std::string NotesFiles; @@ -546,9 +540,6 @@ private: int GenerateCTestNotesOutput(std::ostream& os, const VectorOfStrings& files); - ///! Find the running cmake - void FindRunningCMake(); - //! Check if the argument is the one specified bool CheckArgument(const std::string& arg, const char* varg1, const char* varg2 = 0); diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index ed09545..d3d8f3f 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -20,7 +20,7 @@ #include <cmsys/Directory.hxx> #include <cmsys/Glob.hxx> - +#include <cmsys/FStream.hxx> #include <cmsys/RegularExpression.hxx> const char* cmCacheManagerTypes[] = @@ -211,7 +211,7 @@ bool cmCacheManager::LoadCache(const char* path, return false; } - std::ifstream fin(cacheFile.c_str()); + cmsys::ifstream fin(cacheFile.c_str()); if(!fin) { return false; @@ -566,7 +566,7 @@ bool cmCacheManager::SaveCache(const char* path) checkCacheFile += cmake::GetCMakeFilesDirectory(); cmSystemTools::MakeDirectory(checkCacheFile.c_str()); checkCacheFile += "/cmake.check_cache"; - std::ofstream checkCache(checkCacheFile.c_str()); + cmsys::ofstream checkCache(checkCacheFile.c_str()); if(!checkCache) { cmSystemTools::Error("Unable to open check cache file for write. ", @@ -935,65 +935,3 @@ bool cmCacheManager::NeedCacheCompatibility(int major, int minor) return (actual_compat && actual_compat <= CMake_VERSION_ENCODE(major, minor, 0)); } - -//---------------------------------------------------------------------------- -void cmCacheManager::DefineProperties(cmake *cm) -{ - cm->DefineProperty - ("ADVANCED", cmProperty::CACHE, - "True if entry should be hidden by default in GUIs.", - "This is a boolean value indicating whether the entry is considered " - "interesting only for advanced configuration. " - "The mark_as_advanced() command modifies this property." - ); - - cm->DefineProperty - ("HELPSTRING", cmProperty::CACHE, - "Help associated with entry in GUIs.", - "This string summarizes the purpose of an entry to help users set it " - "through a CMake GUI." - ); - - cm->DefineProperty - ("TYPE", cmProperty::CACHE, - "Widget type for entry in GUIs.", - "Cache entry values are always strings, but CMake GUIs present widgets " - "to help users set values. " - "The GUIs use this property as a hint to determine the widget type. " - "Valid TYPE values are:\n" - " BOOL = Boolean ON/OFF value.\n" - " PATH = Path to a directory.\n" - " FILEPATH = Path to a file.\n" - " STRING = Generic string value.\n" - " INTERNAL = Do not present in GUI at all.\n" - " STATIC = Value managed by CMake, do not change.\n" - " UNINITIALIZED = Type not yet specified.\n" - "Generally the TYPE of a cache entry should be set by the command " - "which creates it (set, option, find_library, etc.)." - ); - - cm->DefineProperty - ("MODIFIED", cmProperty::CACHE, - "Internal management property. Do not set or get.", - "This is an internal cache entry property managed by CMake to " - "track interactive user modification of entries. Ignore it." - ); - - cm->DefineProperty - ("STRINGS", cmProperty::CACHE, - "Enumerate possible STRING entry values for GUI selection.", - "For cache entries with type STRING, this enumerates a set of values. " - "CMake GUIs may use this to provide a selection widget instead of a " - "generic string entry field. " - "This is for convenience only. " - "CMake does not enforce that the value matches one of those listed." - ); - - cm->DefineProperty - ("VALUE", cmProperty::CACHE, - "Value of a cache entry.", - "This property maps to the actual value of a cache entry. " - "Setting this property always sets the value without checking, so " - "use with care." - ); -} diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index a5e5eee..4b8c07d 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -149,9 +149,6 @@ public: unsigned int GetCacheMinorVersion() { return this->CacheMinorVersion; } bool NeedCacheCompatibility(int major, int minor); - /** Define and document CACHE entry properties. */ - static void DefineProperties(cmake *cm); - protected: ///! Add an entry into the cache void AddCacheEntry(const char* key, const char* value, @@ -182,7 +179,6 @@ private: // the commands should never use the cmCacheManager directly friend class cmMakefile; // allow access to add cache values friend class cmake; // allow access to add cache values - friend class cmakewizard; // allow access to add cache values friend class cmMarkAsAdvancedCommand; // allow access to add cache values }; diff --git a/Source/cmCommand.h b/Source/cmCommand.h index 49f451b..e148857 100644 --- a/Source/cmCommand.h +++ b/Source/cmCommand.h @@ -127,16 +127,6 @@ public: virtual const char* GetName() const = 0; /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const = 0; - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const = 0; - - /** * Enable the command. */ void EnabledOn() @@ -183,6 +173,25 @@ public: this->Error += e; } + /** Check if the command is disallowed by a policy. */ + bool Disallowed(cmPolicies::PolicyID pol, const char* e) + { + switch(this->Makefile->GetPolicyStatus(pol)) + { + case cmPolicies::WARN: + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, + this->Makefile->GetPolicies()->GetPolicyWarning(pol)); + case cmPolicies::OLD: + return false; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e); + break; + } + return true; + } + protected: cmMakefile* Makefile; cmCommandArgumentsHelper Helper; diff --git a/Source/cmCommandArgumentLexer.cxx b/Source/cmCommandArgumentLexer.cxx index e68f6b5..e62e53e 100644 --- a/Source/cmCommandArgumentLexer.cxx +++ b/Source/cmCommandArgumentLexer.cxx @@ -1820,7 +1820,7 @@ void cmCommandArgument_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yysca } /** Set the current line number. - * @param line_number + * @param line_number The line number to set. * @param yyscanner The scanner object. */ void cmCommandArgument_yyset_lineno (int line_number , yyscan_t yyscanner) @@ -1835,7 +1835,7 @@ void cmCommandArgument_yyset_lineno (int line_number , yyscan_t yyscanner) } /** Set the current column. - * @param column_no + * @param column_no The column number to set. * @param yyscanner The scanner object. */ void cmCommandArgument_yyset_column (int column_no , yyscan_t yyscanner) diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index dec2b54..1be5980 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -172,7 +172,8 @@ satisfy dependencies. //---------------------------------------------------------------------------- cmComputeLinkDepends -::cmComputeLinkDepends(cmTarget* target, const char* config, cmTarget* head) +::cmComputeLinkDepends(cmTarget const* target, const char* config, + cmTarget const* head) { // Store context information. this->Target = target; @@ -355,9 +356,16 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) if(cmTarget::LinkInterface const* iface = entry.Target->GetLinkInterface(this->Config, this->HeadTarget)) { + const bool isIface = + entry.Target->GetType() == cmTarget::INTERFACE_LIBRARY; // This target provides its own link interface information. this->AddLinkEntries(depender_index, iface->Libraries); + if (isIface) + { + return; + } + // Handle dependent shared libraries. this->FollowSharedDeps(depender_index, iface); @@ -611,19 +619,19 @@ cmComputeLinkDepends::AddLinkEntries(int depender_index, } //---------------------------------------------------------------------------- -cmTarget* cmComputeLinkDepends::FindTargetToLink(int depender_index, +cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index, const char* name) { // Look for a target in the scope of the depender. cmMakefile* mf = this->Makefile; if(depender_index >= 0) { - if(cmTarget* depender = this->EntryList[depender_index].Target) + if(cmTarget const* depender = this->EntryList[depender_index].Target) { mf = depender->GetMakefile(); } } - cmTarget* tgt = mf->FindTargetToUse(name); + cmTarget const* tgt = mf->FindTargetToUse(name); // Skip targets that will not really be linked. This is probably a // name conflict between an external library and an executable @@ -942,7 +950,7 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) int count = 2; for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { - if(cmTarget* target = this->EntryList[*ni].Target) + if(cmTarget const* target = this->EntryList[*ni].Target) { if(cmTarget::LinkInterface const* iface = target->GetLinkInterface(this->Config, this->HeadTarget)) @@ -989,7 +997,8 @@ void cmComputeLinkDepends::CheckWrongConfigItem(int depender_index, // For CMake 2.4 bug-compatibility we need to consider the output // directories of targets linked in another configuration as link // directories. - if(cmTarget* tgt = this->FindTargetToLink(depender_index, item.c_str())) + if(cmTarget const* tgt + = this->FindTargetToLink(depender_index, item.c_str())) { if(!tgt->IsImported()) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 1d5d1b9..9776f55 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -32,14 +32,15 @@ class cmake; class cmComputeLinkDepends { public: - cmComputeLinkDepends(cmTarget* target, const char* config, cmTarget *head); + cmComputeLinkDepends(cmTarget const* target, const char* config, + cmTarget const* head); ~cmComputeLinkDepends(); // Basic information about each link item. struct LinkEntry { std::string Item; - cmTarget* Target; + cmTarget const* Target; bool IsSharedDep; bool IsFlag; LinkEntry(): Item(), Target(0), IsSharedDep(false), IsFlag(false) {} @@ -52,17 +53,17 @@ public: EntryVector const& Compute(); void SetOldLinkDirMode(bool b); - std::set<cmTarget*> const& GetOldWrongConfigItems() const + std::set<cmTarget const*> const& GetOldWrongConfigItems() const { return this->OldWrongConfigItems; } private: // Context information. - cmTarget* Target; - cmTarget* HeadTarget; + cmTarget const* Target; + cmTarget const* HeadTarget; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; - cmGlobalGenerator* GlobalGenerator; + cmGlobalGenerator const* GlobalGenerator; cmake* CMakeInstance; bool DebugMode; @@ -82,7 +83,7 @@ private: void AddDirectLinkEntries(); void AddLinkEntries(int depender_index, std::vector<std::string> const& libs); - cmTarget* FindTargetToLink(int depender_index, const char* name); + cmTarget const* FindTargetToLink(int depender_index, const char* name); // One entry for each unique item. std::vector<LinkEntry> EntryList; @@ -163,7 +164,7 @@ private: // Compatibility help. bool OldLinkDirMode; void CheckWrongConfigItem(int depender_index, std::string const& item); - std::set<cmTarget*> OldWrongConfigItems; + std::set<cmTarget const*> OldWrongConfigItems; }; #endif diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index fb7b5b6..6986965 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -239,8 +239,8 @@ because this need be done only for shared libraries without soname-s. //---------------------------------------------------------------------------- cmComputeLinkInformation -::cmComputeLinkInformation(cmTarget* target, const char* config, - cmTarget *headTarget) +::cmComputeLinkInformation(cmTarget const* target, const char* config, + cmTarget const* headTarget) { // Store context information. this->Target = target; @@ -477,7 +477,7 @@ std::vector<std::string> const& cmComputeLinkInformation::GetFrameworkPaths() } //---------------------------------------------------------------------------- -std::set<cmTarget*> const& +std::set<cmTarget const*> const& cmComputeLinkInformation::GetSharedLibrariesLinked() { return this->SharedLibrariesLinked; @@ -542,11 +542,11 @@ bool cmComputeLinkInformation::Compute() // For CMake 2.4 bug-compatibility we need to consider the output // directories of targets linked in another configuration as link // directories. - std::set<cmTarget*> const& wrongItems = cld.GetOldWrongConfigItems(); - for(std::set<cmTarget*>::const_iterator i = wrongItems.begin(); + std::set<cmTarget const*> const& wrongItems = cld.GetOldWrongConfigItems(); + for(std::set<cmTarget const*>::const_iterator i = wrongItems.begin(); i != wrongItems.end(); ++i) { - cmTarget* tgt = *i; + cmTarget const* tgt = *i; bool implib = (this->UseImportLibrary && (tgt->GetType() == cmTarget::SHARED_LIBRARY)); @@ -620,7 +620,8 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang) } //---------------------------------------------------------------------------- -void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt) +void cmComputeLinkInformation::AddItem(std::string const& item, + cmTarget const* tgt) { // Compute the proper name to use to link this library. const char* config = this->Config; @@ -655,6 +656,11 @@ void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt) (this->UseImportLibrary && (impexe || tgt->GetType() == cmTarget::SHARED_LIBRARY)); + if(tgt->GetType() == cmTarget::INTERFACE_LIBRARY) + { + this->Items.push_back(Item(std::string(), true, tgt)); + return; + } // Pass the full path to the target file. std::string lib = tgt->GetFullPath(config, implib, true); if(!this->LinkDependsNoShared || @@ -695,7 +701,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt) //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, - cmTarget* tgt) + cmTarget const* tgt) { // If dropping shared library dependencies, ignore them. if(this->SharedDependencyMode == SharedDepModeNone) @@ -1057,7 +1063,7 @@ void cmComputeLinkInformation::SetCurrentLinkType(LinkType lt) //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddTargetItem(std::string const& item, - cmTarget* target) + cmTarget const* target) { // This is called to handle a link item that is a full path to a target. // If the target is not a static library make sure the link type is @@ -1739,14 +1745,14 @@ cmComputeLinkInformation::GetRuntimeSearchPath() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, - cmTarget* target) + cmTarget const* target) { // Ignore targets on Apple where install_name is not @rpath. // The dependenty library can be found with other means such as // @loader_path or full paths. if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { - if(!target->HasMacOSXRpath(this->Config)) + if(!target->HasMacOSXRpathInstallNameDir(this->Config)) { return; } @@ -1896,6 +1902,12 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, } if(use_build_rpath || use_link_rpath) { + std::string rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT"); + const char *stagePath + = this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX"); + const char *installPrefix + = this->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX"); + cmSystemTools::ConvertToUnixSlashes(rootPath); std::vector<std::string> const& rdirs = this->GetRuntimeSearchPath(); for(std::vector<std::string>::const_iterator ri = rdirs.begin(); ri != rdirs.end(); ++ri) @@ -1904,9 +1916,22 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, // support or if using the link path as an rpath. if(use_build_rpath) { - if(emitted.insert(*ri).second) + std::string d = *ri; + if (!rootPath.empty() && d.find(rootPath) == 0) + { + d = d.substr(rootPath.size()); + } + else if (stagePath && *stagePath && d.find(stagePath) == 0) + { + std::string suffix = d.substr(strlen(stagePath)); + d = installPrefix; + d += "/"; + d += suffix; + cmSystemTools::ConvertToUnixSlashes(d); + } + if(emitted.insert(d).second) { - runtimeDirs.push_back(*ri); + runtimeDirs.push_back(d); } } else if(use_link_rpath) @@ -1919,9 +1944,22 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, !cmSystemTools::IsSubDirectory(ri->c_str(), topSourceDir) && !cmSystemTools::IsSubDirectory(ri->c_str(), topBinaryDir)) { - if(emitted.insert(*ri).second) + std::string d = *ri; + if (!rootPath.empty() && d.find(rootPath) == 0) + { + d = d.substr(rootPath.size()); + } + else if (stagePath && *stagePath && d.find(stagePath) == 0) + { + std::string suffix = d.substr(strlen(stagePath)); + d = installPrefix; + d += "/"; + d += suffix; + cmSystemTools::ConvertToUnixSlashes(d); + } + if(emitted.insert(d).second) { - runtimeDirs.push_back(*ri); + runtimeDirs.push_back(d); } } } diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index e6ee871..356e6ed 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -29,8 +29,8 @@ class cmOrderDirectories; class cmComputeLinkInformation { public: - cmComputeLinkInformation(cmTarget* target, const char* config, - cmTarget* headTarget); + cmComputeLinkInformation(cmTarget const* target, const char* config, + cmTarget const* headTarget); ~cmComputeLinkInformation(); bool Compute(); @@ -39,11 +39,11 @@ public: Item(): Value(), IsPath(true), Target(0) {} Item(Item const& item): Value(item.Value), IsPath(item.IsPath), Target(item.Target) {} - Item(std::string const& v, bool p, cmTarget* target = 0): + Item(std::string const& v, bool p, cmTarget const* target = 0): Value(v), IsPath(p), Target(target) {} std::string Value; bool IsPath; - cmTarget* Target; + cmTarget const* Target; }; typedef std::vector<Item> ItemVector; ItemVector const& GetItems(); @@ -57,13 +57,13 @@ public: void GetRPath(std::vector<std::string>& runtimeDirs, bool for_install); std::string GetRPathString(bool for_install); std::string GetChrpathString(); - std::set<cmTarget*> const& GetSharedLibrariesLinked(); + std::set<cmTarget const*> const& GetSharedLibrariesLinked(); std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; } std::string GetRPathLinkString(); private: - void AddItem(std::string const& item, cmTarget* tgt); - void AddSharedDepItem(std::string const& item, cmTarget* tgt); + void AddItem(std::string const& item, cmTarget const* tgt); + void AddSharedDepItem(std::string const& item, cmTarget const* tgt); // Output information. ItemVector Items; @@ -71,11 +71,11 @@ private: std::vector<std::string> Depends; std::vector<std::string> FrameworkPaths; std::vector<std::string> RuntimeSearchPath; - std::set<cmTarget*> SharedLibrariesLinked; + std::set<cmTarget const*> SharedLibrariesLinked; // Context information. - cmTarget* Target; - cmTarget* HeadTarget; + cmTarget const* Target; + cmTarget const* HeadTarget; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; cmGlobalGenerator* GlobalGenerator; @@ -139,7 +139,7 @@ private: std::string NoCaseExpression(const char* str); // Handling of link items. - void AddTargetItem(std::string const& item, cmTarget* target); + void AddTargetItem(std::string const& item, cmTarget const* target); void AddFullItem(std::string const& item); bool CheckImplicitDirItem(std::string const& item); void AddUserItem(std::string const& item, bool pathNotKnown); @@ -179,7 +179,8 @@ private: // Runtime path computation. cmOrderDirectories* OrderRuntimeSearchPath; - void AddLibraryRuntimeInfo(std::string const& fullPath, cmTarget* target); + void AddLibraryRuntimeInfo(std::string const& fullPath, + cmTarget const* target); void AddLibraryRuntimeInfo(std::string const& fullPath); // Dependent library path computation. diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 0829add..a848e4f 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -143,12 +143,13 @@ bool cmComputeTargetDepends::Compute() //---------------------------------------------------------------------------- void -cmComputeTargetDepends::GetTargetDirectDepends(cmTarget* t, +cmComputeTargetDepends::GetTargetDirectDepends(cmTarget const* t, cmTargetDependSet& deps) { // Lookup the index for this target. All targets should be known by // this point. - std::map<cmTarget*, int>::const_iterator tii = this->TargetIndex.find(t); + std::map<cmTarget const*, int>::const_iterator tii + = this->TargetIndex.find(t); assert(tii != this->TargetIndex.end()); int i = tii->second; @@ -156,7 +157,7 @@ cmComputeTargetDepends::GetTargetDirectDepends(cmTarget* t, EdgeList const& nl = this->FinalGraph[i]; for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { - cmTarget* dep = this->Targets[*ni]; + cmTarget const* dep = this->Targets[*ni]; cmTargetDependSet::iterator di = deps.insert(dep).first; di->SetType(ni->IsStrong()); } @@ -170,10 +171,11 @@ void cmComputeTargetDepends::CollectTargets() this->GlobalGenerator->GetLocalGenerators(); for(unsigned int i = 0; i < lgens.size(); ++i) { - cmTargets& targets = lgens[i]->GetMakefile()->GetTargets(); - for(cmTargets::iterator ti = targets.begin(); ti != targets.end(); ++ti) + const cmTargets& targets = lgens[i]->GetMakefile()->GetTargets(); + for(cmTargets::const_iterator ti = targets.begin(); + ti != targets.end(); ++ti) { - cmTarget* target = &ti->second; + cmTarget const* target = &ti->second; int index = static_cast<int>(this->Targets.size()); this->TargetIndex[target] = index; this->Targets.push_back(target); @@ -198,7 +200,11 @@ void cmComputeTargetDepends::CollectDepends() void cmComputeTargetDepends::CollectTargetDepends(int depender_index) { // Get the depender. - cmTarget* depender = this->Targets[depender_index]; + cmTarget const* depender = this->Targets[depender_index]; + if (depender->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return; + } // Loop over all targets linked directly in all configs. // We need to make targets depend on the union of all config-specific @@ -230,6 +236,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) { std::vector<std::string> tlibs; depender->GetDirectLinkLibraries(it->c_str(), tlibs, depender); + // A target should not depend on itself. emitted.insert(depender->GetName()); for(std::vector<std::string>::const_iterator lib = tlibs.begin(); @@ -266,11 +273,11 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) //---------------------------------------------------------------------------- void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, - cmTarget* dependee, + cmTarget const* dependee, const char *config, std::set<cmStdString> &emitted) { - cmTarget* depender = this->Targets[depender_index]; + cmTarget const* depender = this->Targets[depender_index]; if(cmTarget::LinkInterface const* iface = dependee->GetLinkInterface(config, depender)) { @@ -295,8 +302,8 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, bool linking, std::set<cmStdString> &emitted) { - cmTarget* depender = this->Targets[depender_index]; - cmTarget* dependee = + cmTarget const* depender = this->Targets[depender_index]; + cmTarget const* dependee = depender->GetMakefile()->FindTargetToUse(dependee_name); // Skip targets that will not really be linked. This is probably a // name conflict between an external library and an executable @@ -330,12 +337,51 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, bool linking) { // Get the depender. - cmTarget* depender = this->Targets[depender_index]; + cmTarget const* depender = this->Targets[depender_index]; // Check the target's makefile first. - cmTarget* dependee = + cmTarget const* dependee = depender->GetMakefile()->FindTargetToUse(dependee_name); + if(!dependee && !linking && + (depender->GetType() != cmTarget::GLOBAL_TARGET)) + { + cmMakefile *makefile = depender->GetMakefile(); + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + bool issueMessage = false; + switch(makefile->GetPolicyStatus(cmPolicies::CMP0046)) + { + case cmPolicies::WARN: + issueMessage = true; + case cmPolicies::OLD: + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + issueMessage = true; + messageType = cmake::FATAL_ERROR; + } + if(issueMessage) + { + cmake* cm = this->GlobalGenerator->GetCMakeInstance(); + cmOStringStream e; + e << (makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0046)) << "\n"; + e << "The dependency target \"" << dependee_name + << "\" of target \"" << depender->GetName() << "\" does not exist."; + + cmListFileBacktrace nullBacktrace; + cmListFileBacktrace const* backtrace = + depender->GetUtilityBacktrace(dependee_name); + if(!backtrace) + { + backtrace = &nullBacktrace; + } + + cm->IssueMessage(messageType, e.str(), *backtrace); + } + } + // Skip targets that will not really be linked. This is probably a // name conflict between an external library and an executable // within the project. @@ -354,7 +400,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, //---------------------------------------------------------------------------- void cmComputeTargetDepends::AddTargetDepend(int depender_index, - cmTarget* dependee, + cmTarget const* dependee, bool linking) { if(dependee->IsImported()) @@ -364,7 +410,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, for(std::set<cmStdString>::const_iterator i = utils.begin(); i != utils.end(); ++i) { - if(cmTarget* transitive_dependee = + if(cmTarget const* transitive_dependee = dependee->GetMakefile()->FindTargetToUse(i->c_str())) { this->AddTargetDepend(depender_index, transitive_dependee, false); @@ -375,7 +421,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, { // Lookup the index for this target. All targets should be known by // this point. - std::map<cmTarget*, int>::const_iterator tii = + std::map<cmTarget const*, int>::const_iterator tii = this->TargetIndex.find(dependee); assert(tii != this->TargetIndex.end()); int dependee_index = tii->second; @@ -395,13 +441,13 @@ cmComputeTargetDepends::DisplayGraph(Graph const& graph, const char* name) for(int depender_index = 0; depender_index < n; ++depender_index) { EdgeList const& nl = graph[depender_index]; - cmTarget* depender = this->Targets[depender_index]; + cmTarget const* depender = this->Targets[depender_index]; fprintf(stderr, "target %d is [%s]\n", depender_index, depender->GetName()); for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { int dependee_index = *ni; - cmTarget* dependee = this->Targets[dependee_index]; + cmTarget const* dependee = this->Targets[dependee_index]; fprintf(stderr, " depends on target %d [%s] (%s)\n", dependee_index, dependee->GetName(), ni->IsStrong()? "strong" : "weak"); } @@ -488,7 +534,7 @@ cmComputeTargetDepends { // Get the depender. int i = *ci; - cmTarget* depender = this->Targets[i]; + cmTarget const* depender = this->Targets[i]; // Describe the depender. e << " \"" << depender->GetName() << "\" of type " @@ -501,7 +547,7 @@ cmComputeTargetDepends int j = *ni; if(cmap[j] == c) { - cmTarget* dependee = this->Targets[j]; + cmTarget const* dependee = this->Targets[j]; e << " depends on \"" << dependee->GetName() << "\"" << " (" << (ni->IsStrong()? "strong" : "weak") << ")\n"; } diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h index d6131cf..6cd6da0 100644 --- a/Source/cmComputeTargetDepends.h +++ b/Source/cmComputeTargetDepends.h @@ -38,19 +38,21 @@ public: bool Compute(); - std::vector<cmTarget*> const& GetTargets() const { return this->Targets; } - void GetTargetDirectDepends(cmTarget* t, cmTargetDependSet& deps); + std::vector<cmTarget const*> const& + GetTargets() const { return this->Targets; } + void GetTargetDirectDepends(cmTarget const* t, cmTargetDependSet& deps); private: void CollectTargets(); void CollectDepends(); void CollectTargetDepends(int depender_index); void AddTargetDepend(int depender_index, const char* dependee_name, bool linking); - void AddTargetDepend(int depender_index, cmTarget* dependee, bool linking); + void AddTargetDepend(int depender_index, cmTarget const* dependee, + bool linking); bool ComputeFinalDepends(cmComputeComponentGraph const& ccg); void AddInterfaceDepends(int depender_index, const char* dependee_name, bool linking, std::set<cmStdString> &emitted); - void AddInterfaceDepends(int depender_index, cmTarget* dependee, + void AddInterfaceDepends(int depender_index, cmTarget const* dependee, const char *config, std::set<cmStdString> &emitted); cmGlobalGenerator* GlobalGenerator; @@ -58,8 +60,8 @@ private: bool NoCycles; // Collect all targets. - std::vector<cmTarget*> Targets; - std::map<cmTarget*, int> TargetIndex; + std::vector<cmTarget const*> Targets; + std::map<cmTarget const*, int> TargetIndex; // Represent the target dependency graph. The entry at each // top-level index corresponds to a depender whose dependencies are diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index ab53b1d..c5e95d0 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -16,7 +16,4 @@ #cmakedefine HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE #cmakedefine HAVE_UNSETENV #cmakedefine CMAKE_USE_ELF_PARSER -#cmakedefine CMAKE_STRICT -#define CMAKE_ROOT_DIR "${CMake_SOURCE_DIR}" -#define CMAKE_BUILD_DIR "${CMake_BINARY_DIR}" #define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@" diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx index e52ddef..f8ec642 100644 --- a/Source/cmConfigureFileCommand.cxx +++ b/Source/cmConfigureFileCommand.cxx @@ -74,10 +74,6 @@ bool cmConfigureFileCommand this->CopyOnly = false; this->EscapeQuotes = false; - // for CMake 2.0 and earlier CONFIGURE_FILE defaults to the FinalPass, - // after 2.0 it only does InitialPass - this->Immediate = !this->Makefile->NeedBackwardsCompatibility(2,0); - this->AtOnly = false; for(unsigned int i=2;i < args.size();++i) { @@ -101,32 +97,19 @@ bool cmConfigureFileCommand } else if(args[i] == "IMMEDIATE") { - this->Immediate = true; + /* Ignore legacy option. */ } } - // If we were told to copy the file immediately, then do it on the - // first pass (now). - if(this->Immediate) + if ( !this->ConfigureFile() ) { - if ( !this->ConfigureFile() ) - { - this->SetError("Problem configuring file"); - return false; - } + this->SetError("Problem configuring file"); + return false; } return true; } -void cmConfigureFileCommand::FinalPass() -{ - if(!this->Immediate) - { - this->ConfigureFile(); - } -} - int cmConfigureFileCommand::ConfigureFile() { return this->Makefile->ConfigureFile( diff --git a/Source/cmConfigureFileCommand.h b/Source/cmConfigureFileCommand.h index 0393ecf..86de92c 100644 --- a/Source/cmConfigureFileCommand.h +++ b/Source/cmConfigureFileCommand.h @@ -41,64 +41,6 @@ public: */ virtual bool IsScriptable() const { return true; } - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Copy a file to another location and modify its contents."; - } - - /** - * Longer documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " configure_file(<input> <output>\n" - " [COPYONLY] [ESCAPE_QUOTES] [@ONLY] \n" - " [NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ])\n" - "Copies a file <input> to file <output> and substitutes variable " - "values referenced in the file content. " - "If <input> is a relative path it is evaluated with respect to " - "the current source directory. " - "The <input> must be a file, not a directory. " - "If <output> is a relative path it is evaluated with respect to " - "the current binary directory. " - "If <output> names an existing directory the input file is placed " - "in that directory with its original name. " - "\n" - "If the <input> file is modified the build system will re-run CMake " - "to re-configure the file and generate the build system again." - "\n" - "This command replaces any variables in the input file referenced as " - "${VAR} or @VAR@ with their values as determined by CMake. If a " - "variable is not defined, it will be replaced with nothing. " - "If COPYONLY is specified, then no variable expansion will take " - "place. If ESCAPE_QUOTES is specified then any substituted quotes " - "will be C-style escaped. " - "The file will be configured with the current values of CMake " - "variables. If @ONLY is specified, only variables " - "of the form @VAR@ will be replaced and ${VAR} will be ignored. " - "This is useful for configuring scripts that use ${VAR}." - "\n" - "Input file lines of the form \"#cmakedefine VAR ...\" " - "will be replaced with either \"#define VAR ...\" or " - "\"/* #undef VAR */\" depending on whether VAR is set in CMake to " - "any value not considered a false constant by the if() command. " - "(Content of \"...\", if any, is processed as above.) " - "Input file lines of the form \"#cmakedefine01 VAR\" " - "will be replaced with either \"#define VAR 1\" or " - "\"#define VAR 0\" similarly." - "\n" - "With NEWLINE_STYLE the line ending could be adjusted: \n" - " 'UNIX' or 'LF' for \\n, 'DOS', 'WIN32' or 'CRLF' for \\r\\n.\n" - "COPYONLY must not be used with NEWLINE_STYLE.\n"; - } - - virtual void FinalPass(); - virtual bool HasFinalPass() const { return !this->Immediate; } - private: int ConfigureFile(); @@ -108,7 +50,6 @@ private: std::string OutputFile; bool CopyOnly; bool EscapeQuotes; - bool Immediate; bool AtOnly; }; diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 086f27a..78bb9a6 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -34,7 +34,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) std::string outputVariable; std::string copyFile; std::string copyFileError; - std::vector<cmTarget*> targets; + std::vector<cmTarget const*> targets; std::string libsToLink = " "; bool useOldLinkLibs = true; char targetNameBuf[64]; @@ -99,6 +99,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) { case cmTarget::SHARED_LIBRARY: case cmTarget::STATIC_LIBRARY: + case cmTarget::INTERFACE_LIBRARY: case cmTarget::UNKNOWN_LIBRARY: break; case cmTarget::EXECUTABLE: @@ -277,7 +278,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) sourceDirectory = this->BinaryDirectory.c_str(); // now create a CMakeLists.txt file in that directory - FILE *fout = fopen(outFileName.c_str(),"w"); + FILE *fout = cmsys::SystemTools::Fopen(outFileName.c_str(),"w"); if (!fout) { cmOStringStream e; @@ -294,7 +295,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) cmVersion::GetPatchVersion(), cmVersion::GetTweakVersion()); if(def) { - fprintf(fout, "SET(CMAKE_MODULE_PATH %s)\n", def); + fprintf(fout, "set(CMAKE_MODULE_PATH %s)\n", def); } std::string projectLangs; @@ -307,35 +308,35 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) if(const char* rulesOverridePath = this->Makefile->GetDefinition(rulesOverrideLang.c_str())) { - fprintf(fout, "SET(%s \"%s\")\n", + fprintf(fout, "set(%s \"%s\")\n", rulesOverrideLang.c_str(), rulesOverridePath); } else if(const char* rulesOverridePath2 = this->Makefile->GetDefinition(rulesOverrideBase.c_str())) { - fprintf(fout, "SET(%s \"%s\")\n", + fprintf(fout, "set(%s \"%s\")\n", rulesOverrideBase.c_str(), rulesOverridePath2); } } - fprintf(fout, "PROJECT(CMAKE_TRY_COMPILE%s)\n", projectLangs.c_str()); - fprintf(fout, "SET(CMAKE_VERBOSE_MAKEFILE 1)\n"); + fprintf(fout, "project(CMAKE_TRY_COMPILE%s)\n", projectLangs.c_str()); + fprintf(fout, "set(CMAKE_VERBOSE_MAKEFILE 1)\n"); for(std::set<std::string>::iterator li = testLangs.begin(); li != testLangs.end(); ++li) { std::string langFlags = "CMAKE_" + *li + "_FLAGS"; const char* flags = this->Makefile->GetDefinition(langFlags.c_str()); - fprintf(fout, "SET(CMAKE_%s_FLAGS %s)\n", li->c_str(), + fprintf(fout, "set(CMAKE_%s_FLAGS %s)\n", li->c_str(), lg->EscapeForCMake(flags?flags:"").c_str()); - fprintf(fout, "SET(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}" + fprintf(fout, "set(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}" " ${COMPILE_DEFINITIONS}\")\n", li->c_str(), li->c_str()); } - fprintf(fout, "INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES})\n"); - fprintf(fout, "SET(CMAKE_SUPPRESS_REGENERATION 1)\n"); - fprintf(fout, "LINK_DIRECTORIES(${LINK_DIRECTORIES})\n"); + fprintf(fout, "include_directories(${INCLUDE_DIRECTORIES})\n"); + fprintf(fout, "set(CMAKE_SUPPRESS_REGENERATION 1)\n"); + fprintf(fout, "link_directories(${LINK_DIRECTORIES})\n"); // handle any compile flags we need to pass on if (compileDefs.size()) { - fprintf(fout, "ADD_DEFINITIONS( "); + fprintf(fout, "add_definitions( "); for (size_t i = 0; i < compileDefs.size(); ++i) { fprintf(fout,"%s ",compileDefs[i].c_str()); @@ -371,8 +372,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) } /* for the TRY_COMPILEs we want to be able to specify the architecture. - So the user can set CMAKE_OSX_ARCHITECTURE to i386;ppc and then set - CMAKE_TRY_COMPILE_OSX_ARCHITECTURE first to i386 and then to ppc to + So the user can set CMAKE_OSX_ARCHITECTURES to i386;ppc and then set + CMAKE_TRY_COMPILE_OSX_ARCHITECTURES first to i386 and then to ppc to have the tests run for each specific architecture. Since cmLocalGenerator doesn't allow building for "the other" architecture only via CMAKE_OSX_ARCHITECTURES. @@ -404,16 +405,51 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) flag += this->Makefile->GetSafeDefinition("CMAKE_OSX_DEPLOYMENT_TARGET"); cmakeFlags.push_back(flag); } + if (const char *cxxDef + = this->Makefile->GetDefinition("CMAKE_CXX_COMPILER_TARGET")) + { + std::string flag="-DCMAKE_CXX_COMPILER_TARGET="; + flag += cxxDef; + cmakeFlags.push_back(flag); + } + if (const char *cDef + = this->Makefile->GetDefinition("CMAKE_C_COMPILER_TARGET")) + { + std::string flag="-DCMAKE_C_COMPILER_TARGET="; + flag += cDef; + cmakeFlags.push_back(flag); + } + if (const char *tcxxDef = this->Makefile->GetDefinition( + "CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN")) + { + std::string flag="-DCMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN="; + flag += tcxxDef; + cmakeFlags.push_back(flag); + } + if (const char *tcDef = this->Makefile->GetDefinition( + "CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN")) + { + std::string flag="-DCMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN="; + flag += tcDef; + cmakeFlags.push_back(flag); + } + if (const char *rootDef + = this->Makefile->GetDefinition("CMAKE_SYSROOT")) + { + std::string flag="-DCMAKE_SYSROOT="; + flag += rootDef; + cmakeFlags.push_back(flag); + } if(this->Makefile->GetDefinition("CMAKE_POSITION_INDEPENDENT_CODE")!=0) { - fprintf(fout, "SET(CMAKE_POSITION_INDEPENDENT_CODE \"ON\")\n"); + fprintf(fout, "set(CMAKE_POSITION_INDEPENDENT_CODE \"ON\")\n"); } /* Put the executable at a known location (for COPY_FILE). */ - fprintf(fout, "SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n", + fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n", this->BinaryDirectory.c_str()); /* Create the actual executable. */ - fprintf(fout, "ADD_EXECUTABLE(%s", targetName); + fprintf(fout, "add_executable(%s", targetName); for(std::vector<std::string>::iterator si = sources.begin(); si != sources.end(); ++si) { @@ -429,11 +465,11 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) if (useOldLinkLibs) { fprintf(fout, - "TARGET_LINK_LIBRARIES(%s ${LINK_LIBRARIES})\n",targetName); + "target_link_libraries(%s ${LINK_LIBRARIES})\n",targetName); } else { - fprintf(fout, "TARGET_LINK_LIBRARIES(%s %s)\n", + fprintf(fout, "target_link_libraries(%s %s)\n", targetName, libsToLink.c_str()); } diff --git a/Source/cmCreateTestSourceList.h b/Source/cmCreateTestSourceList.h index 3aa0a79..8b1e4de 100644 --- a/Source/cmCreateTestSourceList.h +++ b/Source/cmCreateTestSourceList.h @@ -15,7 +15,7 @@ #include "cmCommand.h" /** \class cmCreateTestSourceList - * \brief + * \brief Test driver generation command * */ @@ -42,46 +42,6 @@ public: */ virtual const char* GetName() const {return "create_test_sourcelist";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Create a test driver and source list for building test programs."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " create_test_sourcelist(sourceListName driverName\n" - " test1 test2 test3\n" - " EXTRA_INCLUDE include.h\n" - " FUNCTION function)\n" - "A test driver is a program that links together many small tests into " - "a single executable. This is useful when building static executables " - "with large libraries to shrink the total required size. " - "The list of source files " - "needed to build the test driver will be in sourceListName. " - "DriverName is the name of the test driver program. The rest of " - "the arguments consist of a list of test source files, can be " - "semicolon separated. Each test source file should have a function in " - "it that is the same name as the file with no extension (foo.cxx " - "should have int foo(int, char*[]);) DriverName will be able to " - "call each of the " - "tests by name on the command line. If EXTRA_INCLUDE is specified, " - "then the next argument is included into the generated file. If " - "FUNCTION is specified, then the next argument is taken as a function " - "name that is passed a pointer to ac and av. This can be used to add " - "extra command line processing to each test. The cmake variable " - "CMAKE_TESTDRIVER_BEFORE_TESTMAIN can be set to have code that will be " - "placed directly before calling the test main function. " - "CMAKE_TESTDRIVER_AFTER_TESTMAIN can be set to have code that will be " - "placed directly after the call to the test main function."; - } - cmTypeMacro(cmCreateTestSourceList, cmCommand); }; diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx index a4f6ac4..7f4b10f 100644 --- a/Source/cmCryptoHash.cxx +++ b/Source/cmCryptoHash.cxx @@ -12,6 +12,7 @@ #include "cmCryptoHash.h" #include <cmsys/MD5.h> +#include <cmsys/FStream.hxx> #include "cm_sha2.h" //---------------------------------------------------------------------------- @@ -45,7 +46,7 @@ std::string cmCryptoHash::HashString(const char* input) //---------------------------------------------------------------------------- std::string cmCryptoHash::HashFile(const char* file) { - std::ifstream fin(file, std::ios::in | cmsys_ios_binary); + cmsys::ifstream fin(file, std::ios::in | cmsys_ios_binary); if(!fin) { return ""; diff --git a/Source/cmDefinePropertyCommand.cxx b/Source/cmDefinePropertyCommand.cxx index 5816829..1ad98af 100644 --- a/Source/cmDefinePropertyCommand.cxx +++ b/Source/cmDefinePropertyCommand.cxx @@ -12,7 +12,6 @@ #include "cmDefinePropertyCommand.h" #include "cmake.h" -// cmDefinePropertiesCommand bool cmDefinePropertyCommand ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) { diff --git a/Source/cmDefinePropertyCommand.h b/Source/cmDefinePropertyCommand.h index b5175d5..8dc4d96 100644 --- a/Source/cmDefinePropertyCommand.h +++ b/Source/cmDefinePropertyCommand.h @@ -34,53 +34,6 @@ public: */ virtual const char* GetName() const { return "define_property";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Define and document custom properties."; - } - - /** - * Longer documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " define_property(<GLOBAL | DIRECTORY | TARGET | SOURCE |\n" - " TEST | VARIABLE | CACHED_VARIABLE>\n" - " PROPERTY <name> [INHERITED]\n" - " BRIEF_DOCS <brief-doc> [docs...]\n" - " FULL_DOCS <full-doc> [docs...])\n" - "Define one property in a scope for use with the " - "set_property and get_property commands. " - "This is primarily useful to associate documentation with property " - "names that may be retrieved with the get_property command. " - "The first argument determines the kind of scope in which the " - "property should be used. It must be one of the following:\n" - " GLOBAL = associated with the global namespace\n" - " DIRECTORY = associated with one directory\n" - " TARGET = associated with one target\n" - " SOURCE = associated with one source file\n" - " TEST = associated with a test named with add_test\n" - " VARIABLE = documents a CMake language variable\n" - " CACHED_VARIABLE = documents a CMake cache variable\n" - "Note that unlike set_property and get_property no actual scope " - "needs to be given; only the kind of scope is important.\n" - "The required PROPERTY option is immediately followed by the name " - "of the property being defined.\n" - "If the INHERITED option then the get_property command will chain " - "up to the next higher scope when the requested property is not " - "set in the scope given to the command. " - "DIRECTORY scope chains to GLOBAL. " - "TARGET, SOURCE, and TEST chain to DIRECTORY.\n" - "The BRIEF_DOCS and FULL_DOCS options are followed by strings to be " - "associated with the property as its brief and full documentation. " - "Corresponding options to the get_property command will retrieve the " - "documentation."; - } - cmTypeMacro(cmDefinePropertyCommand, cmCommand); private: std::string PropertyName; diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx index 74a0ccb..1a0e93f 100644 --- a/Source/cmDepends.cxx +++ b/Source/cmDepends.cxx @@ -17,6 +17,7 @@ #include "cmSystemTools.h" #include "cmFileTimeComparison.h" #include <string.h> +#include <cmsys/FStream.hxx> //---------------------------------------------------------------------------- cmDepends::cmDepends(cmLocalGenerator* lg, const char* targetDir): @@ -103,7 +104,7 @@ bool cmDepends::Check(const char *makeFile, const char *internalFile, // Check whether dependencies must be regenerated. bool okay = true; - std::ifstream fin(internalFile); + cmsys::ifstream fin(internalFile); if(!(fin && this->CheckDependencies(fin, internalFile, validDeps))) { // Clear all dependencies so they will be regenerated. diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index a252a1a..4fc5efb 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -15,6 +15,7 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmSystemTools.h" +#include <cmsys/FStream.hxx> #include <ctype.h> // isspace @@ -246,7 +247,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources, // Try to scan the file. Just leave it out if we cannot find // it. - std::ifstream fin(fullName.c_str()); + cmsys::ifstream fin(fullName.c_str()); if(fin) { // Add this file as a dependency. @@ -291,7 +292,7 @@ void cmDependsC::ReadCacheFile() { return; } - std::ifstream fin(this->CacheFileName.c_str()); + cmsys::ifstream fin(this->CacheFileName.c_str()); if(!fin) { return; @@ -380,7 +381,7 @@ void cmDependsC::WriteCacheFile() const { return; } - std::ofstream cacheOut(this->CacheFileName.c_str()); + cmsys::ofstream cacheOut(this->CacheFileName.c_str()); if(!cacheOut) { return; diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index e41e5ea..d5472a1 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -17,7 +17,7 @@ #include "cmGeneratedFileStream.h" #include "cmDependsFortranParser.h" /* Interface to parser object. */ - +#include <cmsys/FStream.hxx> #include <assert.h> #include <stack> @@ -356,7 +356,7 @@ void cmDependsFortran::LocateModules() { std::string targetDir = cmSystemTools::GetFilenamePath(*i); std::string fname = targetDir + "/fortran.internal"; - std::ifstream fin(fname.c_str()); + cmsys::ifstream fin(fname.c_str()); if(fin) { this->MatchRemoteModules(fin, targetDir.c_str()); @@ -700,7 +700,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args) // is later used for longer sequences it should be re-written using an // efficient string search algorithm such as Boyer-Moore. static -bool cmDependsFortranStreamContainsSequence(std::ifstream& ifs, +bool cmDependsFortranStreamContainsSequence(std::istream& ifs, const char* seq, int len) { assert(len > 0); @@ -733,8 +733,8 @@ bool cmDependsFortranStreamContainsSequence(std::ifstream& ifs, //---------------------------------------------------------------------------- // Helper function to compare the remaining content in two streams. -static bool cmDependsFortranStreamsDiffer(std::ifstream& ifs1, - std::ifstream& ifs2) +static bool cmDependsFortranStreamsDiffer(std::istream& ifs1, + std::istream& ifs2) { // Compare the remaining content. for(;;) @@ -799,11 +799,11 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile, } #if defined(_WIN32) || defined(__CYGWIN__) - std::ifstream finModFile(modFile, std::ios::in | std::ios::binary); - std::ifstream finStampFile(stampFile, std::ios::in | std::ios::binary); + cmsys::ifstream finModFile(modFile, std::ios::in | std::ios::binary); + cmsys::ifstream finStampFile(stampFile, std::ios::in | std::ios::binary); #else - std::ifstream finModFile(modFile, std::ios::in); - std::ifstream finStampFile(stampFile, std::ios::in); + cmsys::ifstream finModFile(modFile, std::ios::in); + cmsys::ifstream finStampFile(stampFile, std::ios::in); #endif if(!finModFile || !finStampFile) { @@ -944,7 +944,7 @@ bool cmDependsFortranParser_FilePush(cmDependsFortranParser* parser, { // Open the new file and push it onto the stack. Save the old // buffer with it on the stack. - if(FILE* file = fopen(fname, "rb")) + if(FILE* file = cmsys::SystemTools::Fopen(fname, "rb")) { YY_BUFFER_STATE current = cmDependsFortranLexer_GetCurrentBuffer(parser->Scanner); diff --git a/Source/cmDependsFortranLexer.cxx b/Source/cmDependsFortranLexer.cxx index 924d9d2..1eff1e4 100644 --- a/Source/cmDependsFortranLexer.cxx +++ b/Source/cmDependsFortranLexer.cxx @@ -2165,7 +2165,7 @@ void cmDependsFortran_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscan } /** Set the current line number. - * @param line_number + * @param line_number The line number to set. * @param yyscanner The scanner object. */ void cmDependsFortran_yyset_lineno (int line_number , yyscan_t yyscanner) @@ -2180,7 +2180,7 @@ void cmDependsFortran_yyset_lineno (int line_number , yyscan_t yyscanner) } /** Set the current column. - * @param line_number + * @param column_no The column number to set. * @param yyscanner The scanner object. */ void cmDependsFortran_yyset_column (int column_no , yyscan_t yyscanner) diff --git a/Source/cmDependsJavaLexer.cxx b/Source/cmDependsJavaLexer.cxx index 0af44b0..1e505a5 100644 --- a/Source/cmDependsJavaLexer.cxx +++ b/Source/cmDependsJavaLexer.cxx @@ -2330,7 +2330,7 @@ void cmDependsJava_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner } /** Set the current line number. - * @param line_number + * @param line_number The line number to set. * @param yyscanner The scanner object. */ void cmDependsJava_yyset_lineno (int line_number , yyscan_t yyscanner) @@ -2345,7 +2345,7 @@ void cmDependsJava_yyset_lineno (int line_number , yyscan_t yyscanner) } /** Set the current column. - * @param column_no + * @param column_no The column number to set. * @param yyscanner The scanner object. */ void cmDependsJava_yyset_column (int column_no , yyscan_t yyscanner) diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx index 6136baa..c30d4bd 100644 --- a/Source/cmDependsJavaParserHelper.cxx +++ b/Source/cmDependsJavaParserHelper.cxx @@ -13,6 +13,7 @@ #include "cmSystemTools.h" #include "cmDependsJavaLexer.h" +#include <cmsys/FStream.hxx> int cmDependsJava_yyparse( yyscan_t yyscanner ); @@ -412,7 +413,7 @@ int cmDependsJavaParserHelper::ParseFile(const char* file) { return 0; } - std::ifstream ifs(file); + cmsys::ifstream ifs(file); if ( !ifs ) { return 0; diff --git a/Source/cmDocumentCompileDefinitions.h b/Source/cmDocumentCompileDefinitions.h deleted file mode 100644 index d15bd6d..0000000 --- a/Source/cmDocumentCompileDefinitions.h +++ /dev/null @@ -1,34 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2011 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#ifndef cmDocumentCompileDefinitions_h -#define cmDocumentCompileDefinitions_h - -#define CM_DOCUMENT_COMPILE_DEFINITIONS_DISCLAIMER \ - "Disclaimer: Most native build tools have poor support for escaping " \ - "certain values. CMake has work-arounds for many cases but some " \ - "values may just not be possible to pass correctly. If a value " \ - "does not seem to be escaped correctly, do not attempt to " \ - "work-around the problem by adding escape sequences to the value. " \ - "Your work-around may break in a future version of CMake that " \ - "has improved escape support. Instead consider defining the macro " \ - "in a (configured) header file. Then report the limitation. " \ - "Known limitations include:\n" \ - " # - broken almost everywhere\n" \ - " ; - broken in VS IDE 7.0 and Borland Makefiles\n" \ - " , - broken in VS IDE\n" \ - " % - broken in some cases in NMake\n" \ - " & | - broken in some cases on MinGW\n" \ - " ^ < > \\\" - broken in most Make tools on Windows\n" \ - "CMake does not reject these values outright because they do work " \ - "in some cases. Use with caution. " - -#endif diff --git a/Source/cmDocumentGeneratorExpressions.h b/Source/cmDocumentGeneratorExpressions.h deleted file mode 100644 index 46cd77e..0000000 --- a/Source/cmDocumentGeneratorExpressions.h +++ /dev/null @@ -1,98 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2010 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#ifndef cmDocumentGeneratorExpressions_h -#define cmDocumentGeneratorExpressions_h - -#define CM_DOCUMENT_ADD_TEST_GENERATOR_EXPRESSIONS \ - "Generator expressions are evaluated during build system generation " \ - "to produce information specific to each build configuration. " \ - "Valid expressions are:\n" \ - " $<0:...> = empty string (ignores \"...\")\n" \ - " $<1:...> = content of \"...\"\n" \ - " $<CONFIG:cfg> = '1' if config is \"cfg\", else '0'\n" \ - " $<CONFIGURATION> = configuration name\n" \ - " $<BOOL:...> = '1' if the '...' is true, else '0'\n" \ - " $<STREQUAL:a,b> = '1' if a is STREQUAL b, else '0'\n" \ - " $<ANGLE-R> = A literal '>'. Used to compare " \ - "strings which contain a '>' for example.\n" \ - " $<COMMA> = A literal ','. Used to compare " \ - "strings which contain a ',' for example.\n" \ - " $<SEMICOLON> = A literal ';'. Used to prevent " \ - "list expansion on an argument with ';'.\n" \ - " $<JOIN:list,...> = joins the list with the content of " \ - "\"...\"\n" \ - " $<TARGET_NAME:...> = Marks ... as being the name of a " \ - "target. This is required if exporting targets to multiple " \ - "dependent export sets. The '...' must be a literal name of a " \ - "target- it may not contain generator expressions.\n" \ - " $<INSTALL_INTERFACE:...> = content of \"...\" when the property " \ - "is exported using install(EXPORT), and empty otherwise.\n" \ - " $<BUILD_INTERFACE:...> = content of \"...\" when the property " \ - "is exported using export(), or when the target is used by another " \ - "target in the same buildsystem. Expands to the empty string " \ - "otherwise.\n" \ - " $<C_COMPILER_ID> = The CMake-id of the C compiler " \ - "used.\n" \ - " $<C_COMPILER_ID:comp> = '1' if the CMake-id of the C " \ - "compiler matches comp, otherwise '0'.\n" \ - " $<CXX_COMPILER_ID> = The CMake-id of the CXX compiler " \ - "used.\n" \ - " $<CXX_COMPILER_ID:comp> = '1' if the CMake-id of the CXX " \ - "compiler matches comp, otherwise '0'.\n" \ - " $<VERSION_GREATER:v1,v2> = '1' if v1 is a version greater than " \ - "v2, else '0'.\n" \ - " $<VERSION_LESS:v1,v2> = '1' if v1 is a version less than v2, " \ - "else '0'.\n" \ - " $<VERSION_EQUAL:v1,v2> = '1' if v1 is the same version as v2, " \ - "else '0'.\n" \ - " $<C_COMPILER_VERSION> = The version of the C compiler used.\n" \ - " $<C_COMPILER_VERSION:ver> = '1' if the version of the C " \ - "compiler matches ver, otherwise '0'.\n" \ - " $<CXX_COMPILER_VERSION> = The version of the CXX compiler " \ - "used.\n" \ - " $<CXX_COMPILER_VERSION:ver> = '1' if the version of the CXX " \ - "compiler matches ver, otherwise '0'.\n" \ - " $<TARGET_FILE:tgt> = main file (.exe, .so.1.2, .a)\n" \ - " $<TARGET_LINKER_FILE:tgt> = file used to link (.a, .lib, .so)\n" \ - " $<TARGET_SONAME_FILE:tgt> = file with soname (.so.3)\n" \ - "where \"tgt\" is the name of a target. " \ - "Target file expressions produce a full path, but _DIR and _NAME " \ - "versions can produce the directory and file name components:\n" \ - " $<TARGET_FILE_DIR:tgt>/$<TARGET_FILE_NAME:tgt>\n" \ - " $<TARGET_LINKER_FILE_DIR:tgt>/$<TARGET_LINKER_FILE_NAME:tgt>\n" \ - " $<TARGET_SONAME_FILE_DIR:tgt>/$<TARGET_SONAME_FILE_NAME:tgt>\n" \ - "\n" \ - " $<TARGET_PROPERTY:tgt,prop> = The value of the property prop " \ - "on the target tgt.\n" \ - "Note that tgt is not added as a dependency of the target this " \ - "expression is evaluated on.\n" \ - " $<TARGET_POLICY:pol> = '1' if the policy was NEW when " \ - "the 'head' target was created, else '0'. If the policy was not " \ - "set, the warning message for the policy will be emitted. This " \ - "generator expression only works for a subset of policies.\n" \ - " $<INSTALL_PREFIX> = Content of the install prefix when " \ - "the target is exported via INSTALL(EXPORT) and empty otherwise.\n" \ - "Boolean expressions:\n" \ - " $<AND:?[,?]...> = '1' if all '?' are '1', else '0'\n" \ - " $<OR:?[,?]...> = '0' if all '?' are '0', else '1'\n" \ - " $<NOT:?> = '0' if '?' is '1', else '1'\n" \ - "where '?' is always either '0' or '1'.\n" \ - "" - -#define CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS \ - CM_DOCUMENT_ADD_TEST_GENERATOR_EXPRESSIONS \ - "Expressions with an implicit 'this' target:\n" \ - " $<TARGET_PROPERTY:prop> = The value of the property prop on " \ - "the target on which the generator expression is evaluated.\n" \ - "" - -#endif diff --git a/Source/cmDocumentLocationUndefined.h b/Source/cmDocumentLocationUndefined.h deleted file mode 100644 index 9aecf21..0000000 --- a/Source/cmDocumentLocationUndefined.h +++ /dev/null @@ -1,24 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2011 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#ifndef cmDocumentLocationUndefined_h -#define cmDocumentLocationUndefined_h - -#define CM_LOCATION_UNDEFINED_BEHAVIOR(action) \ - "\n" \ - "Do not set properties that affect the location of a target after " \ - action ". These include properties whose names match " \ - "\"(RUNTIME|LIBRARY|ARCHIVE)_OUTPUT_(NAME|DIRECTORY)(_<CONFIG>)?\", " \ - "\"(IMPLIB_)?(PREFIX|SUFFIX)\", or \"LINKER_LANGUAGE\". " \ - "Failure to follow this rule is not diagnosed and leaves the location " \ - "of the target undefined." - -#endif diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx deleted file mode 100644 index c4f6216..0000000 --- a/Source/cmDocumentVariables.cxx +++ /dev/null @@ -1,2030 +0,0 @@ -#include "cmDocumentVariables.h" -#include "cmake.h" - -#include <cmsys/ios/sstream> - -void cmDocumentVariables::DefineVariables(cmake* cm) -{ - // Subsection: variables defined by cmake, that give - // information about the project, and cmake - cm->DefineProperty - ("CMAKE_AR", cmProperty::VARIABLE, - "Name of archiving tool for static libraries.", - "This specifies the name of the program that creates archive " - "or static libraries.",false, - "Variables that Provide Information"); - - cm->DefineProperty - ("CMAKE_COMMAND", cmProperty::VARIABLE, - "The full path to the cmake executable.", - "This is the full path to the CMake executable cmake which is " - "useful from custom commands that want to use the cmake -E " - "option for portable system commands. " - "(e.g. /usr/local/bin/cmake", false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_BINARY_DIR", cmProperty::VARIABLE, - "The path to the top level of the build tree.", - "This is the full path to the top level of the current CMake " - "build tree. For an in-source build, this would be the same " - "as CMAKE_SOURCE_DIR.", false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_SOURCE_DIR", cmProperty::VARIABLE, - "The path to the top level of the source tree.", - "This is the full path to the top level of the current CMake " - "source tree. For an in-source build, this would be the same " - "as CMAKE_BINARY_DIR.", false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_CURRENT_BINARY_DIR", cmProperty::VARIABLE, - "The path to the binary directory currently being processed.", - "This the full path to the build directory that is currently " - "being processed by cmake. Each directory added by " - "add_subdirectory will create a binary directory in the build " - "tree, and as it is being processed this variable will be set. " - "For in-source builds this is the current source directory " - "being processed.", false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_CURRENT_SOURCE_DIR", cmProperty::VARIABLE, - "The path to the source directory currently being processed.", - "This the full path to the source directory that is currently " - "being processed by cmake. ", false, - "Variables that Provide Information"); - - cm->DefineProperty - ("CMAKE_CURRENT_LIST_FILE", cmProperty::VARIABLE, - "Full path to the listfile currently being processed.", - "As CMake processes the listfiles in your project this " - "variable will always be set to the one currently being " - "processed. " - "The value has dynamic scope. " - "When CMake starts processing commands in a source file " - "it sets this variable to the location of the file. " - "When CMake finishes processing commands from the file it " - "restores the previous value. " - "Therefore the value of the variable inside a macro or " - "function is the file invoking the bottom-most entry on " - "the call stack, not the file containing the macro or " - "function definition." - "\n" - "See also CMAKE_PARENT_LIST_FILE.",false, - "Variables that Provide Information"); - - cm->DefineProperty - ("CMAKE_CURRENT_LIST_LINE", cmProperty::VARIABLE, - "The line number of the current file being processed.", - "This is the line number of the file currently being" - " processed by cmake.", false, - "Variables that Provide Information"); - - cm->DefineProperty - ("CMAKE_CURRENT_LIST_DIR", cmProperty::VARIABLE, - "Full directory of the listfile currently being processed.", - "As CMake processes the listfiles in your project this " - "variable will always be set to the directory where the listfile which " - "is currently being processed (CMAKE_CURRENT_LIST_FILE) is located. " - "The value has dynamic scope. " - "When CMake starts processing commands in a source file " - "it sets this variable to the directory where this file is located. " - "When CMake finishes processing commands from the file it " - "restores the previous value. " - "Therefore the value of the variable inside a macro or " - "function is the directory of the file invoking the bottom-most entry on " - "the call stack, not the directory of the file containing the macro or " - "function definition." - "\n" - "See also CMAKE_CURRENT_LIST_FILE.",false, - "Variables that Provide Information"); - - cm->DefineProperty - ("CMAKE_SCRIPT_MODE_FILE", cmProperty::VARIABLE, - "Full path to the -P script file currently being processed.", - "When run in -P script mode, CMake sets this variable to the full " - "path of the script file. When run to configure a CMakeLists.txt " - "file, this variable is not set.", false, - "Variables that Provide Information"); - - cm->DefineProperty - ("CMAKE_ARGC", cmProperty::VARIABLE, - "Number of command line arguments passed to CMake in script mode.", - "When run in -P script mode, CMake sets this variable to the number " - "of command line arguments. See also CMAKE_ARGV0, 1, 2 ...", false, - "Variables that Provide Information"); - - cm->DefineProperty - ("CMAKE_ARGV0", cmProperty::VARIABLE, - "Command line argument passed to CMake in script mode.", - "When run in -P script mode, CMake sets this variable to " - "the first command line argument. It then also sets CMAKE_ARGV1, " - "CMAKE_ARGV2, ... and so on, up to the number of command line arguments " - "given. See also CMAKE_ARGC.", false, - "Variables that Provide Information"); - - cm->DefineProperty - ("CMAKE_BUILD_TOOL", cmProperty::VARIABLE, - "Tool used for the actual build process.", - "This variable is set to the program that will be" - " needed to build the output of CMake. If the " - "generator selected was Visual Studio 6, the " - "CMAKE_BUILD_TOOL will be set to msdev, for " - "Unix Makefiles it will be set to make or gmake, " - "and for Visual Studio 7 it set to devenv. For " - "NMake Makefiles the value is nmake. This can be " - "useful for adding special flags and commands based" - " on the final build environment.", false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_CROSSCOMPILING", cmProperty::VARIABLE, - "Is CMake currently cross compiling.", - "This variable will be set to true by CMake if CMake is cross " - "compiling. Specifically if the build platform is different " - "from the target platform.", false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_CACHEFILE_DIR", cmProperty::VARIABLE, - "The directory with the CMakeCache.txt file.", - "This is the full path to the directory that has the " - "CMakeCache.txt file in it. This is the same as " - "CMAKE_BINARY_DIR.", false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_CACHE_MAJOR_VERSION", cmProperty::VARIABLE, - "Major version of CMake used to create the CMakeCache.txt file", - "This stores the major version of CMake used to " - "write a CMake cache file. It is only different when " - "a different version of CMake is run on a previously " - "created cache file.", false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_CACHE_MINOR_VERSION", cmProperty::VARIABLE, - "Minor version of CMake used to create the CMakeCache.txt file", - "This stores the minor version of CMake used to " - "write a CMake cache file. It is only different when " - "a different version of CMake is run on a previously " - "created cache file.", false, - "Variables that Provide Information"); - - cm->DefineProperty - ("CMAKE_CACHE_PATCH_VERSION", cmProperty::VARIABLE, - "Patch version of CMake used to create the CMakeCache.txt file", - "This stores the patch version of CMake used to " - "write a CMake cache file. It is only different when " - "a different version of CMake is run on a previously " - "created cache file.", false, - "Variables that Provide Information"); - - cm->DefineProperty - ("CMAKE_CFG_INTDIR", cmProperty::VARIABLE, - "Build-time reference to per-configuration output subdirectory.", - "For native build systems supporting multiple configurations " - "in the build tree (such as Visual Studio and Xcode), " - "the value is a reference to a build-time variable specifying " - "the name of the per-configuration output subdirectory. " - "On Makefile generators this evaluates to \".\" because there " - "is only one configuration in a build tree. " - "Example values:\n" - " $(IntDir) = Visual Studio 6\n" - " $(OutDir) = Visual Studio 7, 8, 9\n" - " $(Configuration) = Visual Studio 10\n" - " $(CONFIGURATION) = Xcode\n" - " . = Make-based tools\n" - "Since these values are evaluated by the native build system, this " - "variable is suitable only for use in command lines that will be " - "evaluated at build time. " - "Example of intended usage:\n" - " add_executable(mytool mytool.c)\n" - " add_custom_command(\n" - " OUTPUT out.txt\n" - " COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/mytool\n" - " ${CMAKE_CURRENT_SOURCE_DIR}/in.txt out.txt\n" - " DEPENDS mytool in.txt\n" - " )\n" - " add_custom_target(drive ALL DEPENDS out.txt)\n" - "Note that CMAKE_CFG_INTDIR is no longer necessary for this purpose " - "but has been left for compatibility with existing projects. " - "Instead add_custom_command() recognizes executable target names in " - "its COMMAND option, so " - "\"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/mytool\" can be " - "replaced by just \"mytool\"." - "\n" - "This variable is read-only. Setting it is undefined behavior. " - "In multi-configuration build systems the value of this variable " - "is passed as the value of preprocessor symbol \"CMAKE_INTDIR\" to " - "the compilation of all source files.",false, - "Variables that Provide Information"); - - cm->DefineProperty - ("CMAKE_CTEST_COMMAND", cmProperty::VARIABLE, - "Full path to ctest command installed with cmake.", - "This is the full path to the CTest executable ctest " - "which is useful from custom commands that want " - "to use the cmake -E option for portable system " - "commands.",false, - "Variables that Provide Information"); - - cm->DefineProperty - ("CMAKE_DL_LIBS", cmProperty::VARIABLE, - "Name of library containing dlopen and dlcose.", - "The name of the library that has dlopen and " - "dlclose in it, usually -ldl on most UNIX machines.",false, - "Variables that Provide Information"); - - cm->DefineProperty - ("CMAKE_EDIT_COMMAND", cmProperty::VARIABLE, - "Full path to cmake-gui or ccmake.", - "This is the full path to the CMake executable " - "that can graphically edit the cache. For example," - " cmake-gui, ccmake, or cmake -i.",false, - "Variables that Provide Information"); - - cm->DefineProperty - ("CMAKE_GENERATOR", cmProperty::VARIABLE, - "The generator used to build the project.", - "The name of the generator that is being used to generate the " - "build files. (e.g. \"Unix Makefiles\", " - "\"Visual Studio 6\", etc.)",false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_EXTRA_GENERATOR", cmProperty::VARIABLE, - "The extra generator used to build the project.", - "When using the Eclipse, CodeBlocks or KDevelop generators, CMake " - "generates Makefiles (CMAKE_GENERATOR) and additionally project files " - "for the respective IDE. This IDE project file generator is stored in " - "CMAKE_EXTRA_GENERATOR (e.g. \"Eclipse CDT4\").",false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_GENERATOR_TOOLSET", cmProperty::VARIABLE, - "Native build system toolset name specified by user.", - "Some CMake generators support a toolset name to be given to the " - "native build system to choose a compiler. " - "If the user specifies a toolset name (e.g. via the cmake -T option) " - "the value will be available in this variable.",false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_HOME_DIRECTORY", cmProperty::VARIABLE, - "Path to top of source tree.", - "This is the path to the top level of the source tree.",false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_LINK_LIBRARY_SUFFIX", cmProperty::VARIABLE, - "The suffix for libraries that you link to.", - "The suffix to use for the end of a library filename, .lib on Windows." - ,false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_EXECUTABLE_SUFFIX", cmProperty::VARIABLE, - "The suffix for executables on this platform.", - "The suffix to use for the end of an executable filename if any, " - ".exe on Windows." - "\n" - "CMAKE_EXECUTABLE_SUFFIX_<LANG> overrides this for language <LANG>." - ,false, "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_MAJOR_VERSION", cmProperty::VARIABLE, - "The Major version of cmake (i.e. the 2 in 2.X.X)", - "This specifies the major version of the CMake executable" - " being run.",false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_MAKE_PROGRAM", cmProperty::VARIABLE, - "See CMAKE_BUILD_TOOL.", - "This variable is around for backwards compatibility, " - "see CMAKE_BUILD_TOOL.",false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_VS_PLATFORM_TOOLSET", cmProperty::VARIABLE, - "Visual Studio Platform Toolset name.", - "VS 10 and above use MSBuild under the hood and support multiple " - "compiler toolchains. " - "CMake may specify a toolset explicitly, such as \"v110\" for " - "VS 11 or \"Windows7.1SDK\" for 64-bit support in VS 10 Express. " - "CMake provides the name of the chosen toolset in this variable." - ,false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_XCODE_PLATFORM_TOOLSET", cmProperty::VARIABLE, - "Xcode compiler selection.", - "Xcode supports selection of a compiler from one of the installed " - "toolsets. " - "CMake provides the name of the chosen toolset in this variable, " - "if any is explicitly selected (e.g. via the cmake -T option)." - ,false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_MINOR_VERSION", cmProperty::VARIABLE, - "The Minor version of cmake (i.e. the 4 in X.4.X).", - "This specifies the minor version of the CMake" - " executable being run.",false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_PATCH_VERSION", cmProperty::VARIABLE, - "The patch version of cmake (i.e. the 3 in X.X.3).", - "This specifies the patch version of the CMake" - " executable being run.",false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_TWEAK_VERSION", cmProperty::VARIABLE, - "The tweak version of cmake (i.e. the 1 in X.X.X.1).", - "This specifies the tweak version of the CMake executable being run. " - "Releases use tweak < 20000000 and development versions use the date " - "format CCYYMMDD for the tweak level." - ,false, "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_VERSION", cmProperty::VARIABLE, - "The full version of cmake in major.minor.patch[.tweak[-id]] format.", - "This specifies the full version of the CMake executable being run. " - "This variable is defined by versions 2.6.3 and higher. " - "See variables CMAKE_MAJOR_VERSION, CMAKE_MINOR_VERSION, " - "CMAKE_PATCH_VERSION, and CMAKE_TWEAK_VERSION " - "for individual version components. " - "The [-id] component appears in non-release versions " - "and may be arbitrary text.", false, - "Variables that Provide Information"); - - cm->DefineProperty - ("CMAKE_PARENT_LIST_FILE", cmProperty::VARIABLE, - "Full path to the CMake file that included the current one.", - "While processing a CMake file loaded by include() or find_package() " - "this variable contains the full path to the file including it. " - "The top of the include stack is always the CMakeLists.txt for the " - "current directory. " - "See also CMAKE_CURRENT_LIST_FILE.",false, - "Variables that Provide Information"); - - cm->DefineProperty - ("CMAKE_PROJECT_NAME", cmProperty::VARIABLE, - "The name of the current project.", - "This specifies name of the current project from" - " the closest inherited PROJECT command.",false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_RANLIB", cmProperty::VARIABLE, - "Name of randomizing tool for static libraries.", - "This specifies name of the program that randomizes " - "libraries on UNIX, not used on Windows, but may be present.",false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_ROOT", cmProperty::VARIABLE, - "Install directory for running cmake.", - "This is the install root for the running CMake and" - " the Modules directory can be found here. This is" - " commonly used in this format: ${CMAKE_ROOT}/Modules",false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_SIZEOF_VOID_P", cmProperty::VARIABLE, - "Size of a void pointer.", - "This is set to the size of a pointer on the machine, " - "and is determined by a try compile. If a 64 bit size " - "is found, then the library search path is modified to " - "look for 64 bit libraries first.",false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_SKIP_RPATH", cmProperty::VARIABLE, - "If true, do not add run time path information.", - "If this is set to TRUE, then the rpath information " - "is not added to compiled executables. The default " - "is to add rpath information if the platform supports it. " - "This allows for easy running from the build tree. To omit RPATH " - "in the install step, but not the build step, use " - "CMAKE_SKIP_INSTALL_RPATH instead.",false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_SOURCE_DIR", cmProperty::VARIABLE, - "Source directory for project.", - "This is the top level source directory for the project. " - "It corresponds to the source directory given to " - "cmake-gui or ccmake.",false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_STANDARD_LIBRARIES", cmProperty::VARIABLE, - "Libraries linked into every executable and shared library.", - "This is the list of libraries that are linked " - "into all executables and libraries.",false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_VERBOSE_MAKEFILE", cmProperty::VARIABLE, - "Create verbose makefiles if on.", - "This variable defaults to false. You can set " - "this variable to true to make CMake produce verbose " - "makefiles that show each command line as it is used.",false, - "Variables that Provide Information"); - cm->DefineProperty - ("PROJECT_BINARY_DIR", cmProperty::VARIABLE, - "Full path to build directory for project.", - "This is the binary directory of the most recent " - "PROJECT command.",false,"Variables that Provide Information"); - cm->DefineProperty - ("PROJECT_NAME", cmProperty::VARIABLE, - "Name of the project given to the project command.", - "This is the name given to the most " - "recent PROJECT command.",false, - "Variables that Provide Information"); - cm->DefineProperty - ("PROJECT_SOURCE_DIR", cmProperty::VARIABLE, - "Top level source directory for the current project.", - "This is the source directory of the most recent " - "PROJECT command.",false, - "Variables that Provide Information"); - cm->DefineProperty - ("[Project name]_BINARY_DIR", cmProperty::VARIABLE, - "Top level binary directory for the named project.", - "A variable is created with the name used in the PROJECT " - "command, and is the binary directory for the project. " - " This can be useful when SUBDIR is used to connect " - "several projects.",false, - "Variables that Provide Information"); - cm->DefineProperty - ("[Project name]_SOURCE_DIR", cmProperty::VARIABLE, - "Top level source directory for the named project.", - "A variable is created with the name used in the PROJECT " - "command, and is the source directory for the project." - " This can be useful when add_subdirectory " - "is used to connect several projects.",false, - "Variables that Provide Information"); - - cm->DefineProperty - ("CMAKE_IMPORT_LIBRARY_PREFIX", cmProperty::VARIABLE, - "The prefix for import libraries that you link to.", - "The prefix to use for the name of an import library if used " - "on this platform." - "\n" - "CMAKE_IMPORT_LIBRARY_PREFIX_<LANG> overrides this for language <LANG>." - ,false, "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_IMPORT_LIBRARY_SUFFIX", cmProperty::VARIABLE, - "The suffix for import libraries that you link to.", - "The suffix to use for the end of an import library filename if used " - "on this platform." - "\n" - "CMAKE_IMPORT_LIBRARY_SUFFIX_<LANG> overrides this for language <LANG>." - ,false, "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_SHARED_LIBRARY_PREFIX", cmProperty::VARIABLE, - "The prefix for shared libraries that you link to.", - "The prefix to use for the name of a shared library, lib on UNIX." - "\n" - "CMAKE_SHARED_LIBRARY_PREFIX_<LANG> overrides this for language <LANG>." - ,false, "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_SHARED_LIBRARY_SUFFIX", cmProperty::VARIABLE, - "The suffix for shared libraries that you link to.", - "The suffix to use for the end of a shared library filename, " - ".dll on Windows." - "\n" - "CMAKE_SHARED_LIBRARY_SUFFIX_<LANG> overrides this for language <LANG>." - ,false, "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_SHARED_MODULE_PREFIX", cmProperty::VARIABLE, - "The prefix for loadable modules that you link to.", - "The prefix to use for the name of a loadable module on this platform." - "\n" - "CMAKE_SHARED_MODULE_PREFIX_<LANG> overrides this for language <LANG>." - ,false, "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_SHARED_MODULE_SUFFIX", cmProperty::VARIABLE, - "The suffix for shared libraries that you link to.", - "The suffix to use for the end of a loadable module filename " - "on this platform" - "\n" - "CMAKE_SHARED_MODULE_SUFFIX_<LANG> overrides this for language <LANG>." - ,false, "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_STATIC_LIBRARY_PREFIX", cmProperty::VARIABLE, - "The prefix for static libraries that you link to.", - "The prefix to use for the name of a static library, lib on UNIX." - "\n" - "CMAKE_STATIC_LIBRARY_PREFIX_<LANG> overrides this for language <LANG>." - ,false, "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_STATIC_LIBRARY_SUFFIX", cmProperty::VARIABLE, - "The suffix for static libraries that you link to.", - "The suffix to use for the end of a static library filename, " - ".lib on Windows." - "\n" - "CMAKE_STATIC_LIBRARY_SUFFIX_<LANG> overrides this for language <LANG>." - ,false, "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES", cmProperty::VARIABLE, - "Additional suffixes for shared libraries.", - "Extensions for shared libraries other than that specified by " - "CMAKE_SHARED_LIBRARY_SUFFIX, if any. " - "CMake uses this to recognize external shared library files during " - "analysis of libraries linked by a target.", - false, - "Variables that Provide Information"); - cm->DefineProperty - ("CMAKE_MINIMUM_REQUIRED_VERSION", cmProperty::VARIABLE, - "Version specified to cmake_minimum_required command", - "Variable containing the VERSION component specified in the " - "cmake_minimum_required command.", - false, - "Variables that Provide Information"); - - - // Variables defined by cmake, that change the behavior - // of cmake - - cm->DefineProperty - ("CMAKE_POLICY_DEFAULT_CMP<NNNN>", cmProperty::VARIABLE, - "Default for CMake Policy CMP<NNNN> when it is otherwise left unset.", - "Commands cmake_minimum_required(VERSION) and cmake_policy(VERSION) " - "by default leave policies introduced after the given version unset. " - "Set CMAKE_POLICY_DEFAULT_CMP<NNNN> to OLD or NEW to specify the " - "default for policy CMP<NNNN>, where <NNNN> is the policy number." - "\n" - "This variable should not be set by a project in CMake code; " - "use cmake_policy(SET) instead. " - "Users running CMake may set this variable in the cache " - "(e.g. -DCMAKE_POLICY_DEFAULT_CMP<NNNN>=<OLD|NEW>) " - "to set a policy not otherwise set by the project. " - "Set to OLD to quiet a policy warning while using old behavior " - "or to NEW to try building the project with new behavior.", - false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_AUTOMOC_RELAXED_MODE", cmProperty::VARIABLE, - "Switch between strict and relaxed automoc mode.", - "By default, automoc behaves exactly as described in the documentation " - "of the AUTOMOC target property. " - "When set to TRUE, it accepts more input and tries to find the correct " - "input file for moc even if it differs from the documented behaviour. " - "In this mode it e.g. also checks whether a header file is intended to " - "be processed by moc when a \"foo.moc\" file has been included.\n" - "Relaxed mode has to be enabled for KDE4 compatibility.", - false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME", cmProperty::VARIABLE, - "Default component used in install() commands.", - "If an install() command is used without the COMPONENT argument, " - "these files will be grouped into a default component. The name of this " - "default install component will be taken from this variable. " - "It defaults to \"Unspecified\".", - false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_FIND_LIBRARY_PREFIXES", cmProperty::VARIABLE, - "Prefixes to prepend when looking for libraries.", - "This specifies what prefixes to add to library names when " - "the find_library command looks for libraries. On UNIX " - "systems this is typically lib, meaning that when trying " - "to find the foo library it will look for libfoo.", - false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_FIND_LIBRARY_SUFFIXES", cmProperty::VARIABLE, - "Suffixes to append when looking for libraries.", - "This specifies what suffixes to add to library names when " - "the find_library command looks for libraries. On Windows " - "systems this is typically .lib and .dll, meaning that when trying " - "to find the foo library it will look for foo.dll etc.", - false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_CONFIGURATION_TYPES", cmProperty::VARIABLE, - "Specifies the available build types on multi-config generators.", - "This specifies what build types (configurations) will be available " - "such as Debug, Release, RelWithDebInfo etc. " - "This has reasonable defaults on most platforms, " - "but can be extended to provide other build types. " - "See also CMAKE_BUILD_TYPE for details of managing configuration data, " - "and CMAKE_CFG_INTDIR." - ,false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_BUILD_TYPE", cmProperty::VARIABLE, - "Specifies the build type on single-configuration generators.", - "This statically specifies what build type (configuration) " - "will be built in this build tree. Possible values are " - "empty, Debug, Release, RelWithDebInfo and MinSizeRel. " - "This variable is only meaningful to single-configuration generators " - "(such as make and Ninja) i.e. " - "those which choose a single configuration " - "when CMake runs to generate a build tree as opposed to " - "multi-configuration generators which offer selection of the build " - "configuration within the generated build environment. " - "There are many per-config properties and variables " - "(usually following clean SOME_VAR_<CONFIG> order conventions), " - "such as CMAKE_C_FLAGS_<CONFIG>, specified as uppercase: " - "CMAKE_C_FLAGS_[DEBUG|RELEASE|RELWITHDEBINFO|MINSIZEREL]. " - "For example, in a build tree configured " - "to build type Debug, CMake will see to having " - "CMAKE_C_FLAGS_DEBUG settings get added to the CMAKE_C_FLAGS settings. " - "See also CMAKE_CONFIGURATION_TYPES." - ,false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_BACKWARDS_COMPATIBILITY", cmProperty::VARIABLE, - "Version of cmake required to build project", - "From the point of view of backwards compatibility, this " - "specifies what version of CMake should be supported. By " - "default this value is the version number of CMake that " - "you are running. You can set this to an older version of" - " CMake to support deprecated commands of CMake in projects" - " that were written to use older versions of CMake. This " - "can be set by the user or set at the beginning of a " - "CMakeLists file.",false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_INSTALL_PREFIX", cmProperty::VARIABLE, - "Install directory used by install.", - "If \"make install\" is invoked or INSTALL is built" - ", this directory is prepended onto all install " - "directories. This variable defaults to /usr/local" - " on UNIX and c:/Program Files on Windows.\n" - "On UNIX one can use the DESTDIR mechanism in order" - " to relocate the whole installation. " - "DESTDIR means DESTination DIRectory. It is " - "commonly used by makefile users " - "in order to install software at non-default location. " - "It is usually invoked like this:\n" - " make DESTDIR=/home/john install\n" - "which will install the concerned software using the" - " installation prefix, e.g. \"/usr/local\" prepended with " - "the DESTDIR value which finally gives \"/home/john/usr/local\".\n" - "WARNING: DESTDIR may not be used on Windows because installation" - " prefix usually contains a drive letter like in \"C:/Program Files\"" - " which cannot be prepended with some other prefix." - "\n" - "The installation prefix is also added to CMAKE_SYSTEM_PREFIX_PATH " - "so that find_package, find_program, find_library, find_path, and " - "find_file will search the prefix for other software." - ,false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY", cmProperty::VARIABLE, - "Don't make the install target depend on the all target.", - "By default, the \"install\" target depends on the \"all\" target. " - "This has the effect, that when \"make install\" is invoked or INSTALL " - "is built, first the \"all\" target is built, then the installation " - "starts. " - "If CMAKE_SKIP_INSTALL_ALL_DEPENDENCY is set to TRUE, this dependency " - "is not created, so the installation process will start immediately, " - "independent from whether the project has been completely built or not." - ,false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_MODULE_PATH", cmProperty::VARIABLE, - "List of directories to search for CMake modules.", - "Commands like include() and find_package() search for files in " - "directories listed by this variable before checking the default " - "modules that come with CMake.", - false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_WARN_DEPRECATED", cmProperty::VARIABLE, - "Whether to issue deprecation warnings for macros and functions.", - "If TRUE, this can be used by macros and functions to issue " - "deprecation warnings. This variable is FALSE by default.", - false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_ERROR_DEPRECATED", cmProperty::VARIABLE, - "Whether to issue deprecation errors for macros and functions.", - "If TRUE, this can be used by macros and functions to issue " - "fatal errors when deprecated macros or functions are used. This " - "variable is FALSE by default.", - false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_PREFIX_PATH", cmProperty::VARIABLE, - "Path used for searching by FIND_XXX(), with appropriate suffixes added.", - "Specifies a path which will be used by the FIND_XXX() commands. It " - "contains the \"base\" directories, the FIND_XXX() commands append " - "appropriate subdirectories to the base directories. So FIND_PROGRAM() " - "adds /bin to each of the directories in the path, FIND_LIBRARY() " - "appends /lib to each of the directories, and FIND_PATH() and " - "FIND_FILE() append /include . By default it is empty, it is intended " - "to be set by the project. See also CMAKE_SYSTEM_PREFIX_PATH, " - "CMAKE_INCLUDE_PATH, CMAKE_LIBRARY_PATH, CMAKE_PROGRAM_PATH.", false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_INCLUDE_PATH", cmProperty::VARIABLE, - "Path used for searching by FIND_FILE() and FIND_PATH().", - "Specifies a path which will be used both by FIND_FILE() and " - "FIND_PATH(). Both commands will check each of the contained directories " - "for the existence of the file which is currently searched. By default " - "it is empty, it is intended to be set by the project. See also " - "CMAKE_SYSTEM_INCLUDE_PATH, CMAKE_PREFIX_PATH.", false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_LIBRARY_PATH", cmProperty::VARIABLE, - "Path used for searching by FIND_LIBRARY().", - "Specifies a path which will be used by FIND_LIBRARY(). FIND_LIBRARY() " - "will check each of the contained directories for the existence of the " - "library which is currently searched. By default it is empty, it is " - "intended to be set by the project. See also CMAKE_SYSTEM_LIBRARY_PATH, " - "CMAKE_PREFIX_PATH.", false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_PROGRAM_PATH", cmProperty::VARIABLE, - "Path used for searching by FIND_PROGRAM().", - "Specifies a path which will be used by FIND_PROGRAM(). FIND_PROGRAM() " - "will check each of the contained directories for the existence of the " - "program which is currently searched. By default it is empty, it is " - "intended to be set by the project. See also CMAKE_SYSTEM_PROGRAM_PATH, " - " CMAKE_PREFIX_PATH.", false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_SYSTEM_PREFIX_PATH", cmProperty::VARIABLE, - "Path used for searching by FIND_XXX(), with appropriate suffixes added.", - "Specifies a path which will be used by the FIND_XXX() commands. It " - "contains the \"base\" directories, the FIND_XXX() commands append " - "appropriate subdirectories to the base directories. So FIND_PROGRAM() " - "adds /bin to each of the directories in the path, FIND_LIBRARY() " - "appends /lib to each of the directories, and FIND_PATH() and " - "FIND_FILE() append /include . By default this contains the standard " - "directories for the current system and the CMAKE_INSTALL_PREFIX. " - "It is NOT intended " - "to be modified by the project, use CMAKE_PREFIX_PATH for this. See also " - "CMAKE_SYSTEM_INCLUDE_PATH, CMAKE_SYSTEM_LIBRARY_PATH, " - "CMAKE_SYSTEM_PROGRAM_PATH, and CMAKE_SYSTEM_IGNORE_PATH.", false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_SYSTEM_IGNORE_PATH", cmProperty::VARIABLE, - "Path to be ignored by FIND_XXX() commands.", - "Specifies directories to be ignored by searches in FIND_XXX() " - "commands. " - "This is useful in cross-compiled environments where some system " - "directories contain incompatible but possibly linkable libraries. For " - "example, on cross-compiled cluster environments, this allows a user to " - "ignore directories containing libraries meant for the front-end " - "machine that modules like FindX11 (and others) would normally search. " - "By default this contains a list of directories containing incompatible " - "binaries for the host system. " - "See also CMAKE_SYSTEM_PREFIX_PATH, CMAKE_SYSTEM_LIBRARY_PATH, " - "CMAKE_SYSTEM_INCLUDE_PATH, and CMAKE_SYSTEM_PROGRAM_PATH.", false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_IGNORE_PATH", cmProperty::VARIABLE, - "Path to be ignored by FIND_XXX() commands.", - "Specifies directories to be ignored by searches in FIND_XXX() " - "commands. " - "This is useful in cross-compiled environments where some system " - "directories contain incompatible but possibly linkable libraries. For " - "example, on cross-compiled cluster environments, this allows a user to " - "ignore directories containing libraries meant for the front-end " - "machine that modules like FindX11 (and others) would normally search. " - "By default this is empty; it is intended to be set by the project. " - "Note that CMAKE_IGNORE_PATH takes a list of directory names, NOT a " - "list of prefixes. If you want to ignore paths under prefixes (bin, " - "include, lib, etc.), you'll need to specify them explicitly. " - "See also CMAKE_PREFIX_PATH, CMAKE_LIBRARY_PATH, CMAKE_INCLUDE_PATH, " - "CMAKE_PROGRAM_PATH.", false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_SYSTEM_INCLUDE_PATH", cmProperty::VARIABLE, - "Path used for searching by FIND_FILE() and FIND_PATH().", - "Specifies a path which will be used both by FIND_FILE() and " - "FIND_PATH(). Both commands will check each of the contained directories " - "for the existence of the file which is currently searched. By default " - "it contains the standard directories for the current system. It is " - "NOT intended to be modified by the project, use CMAKE_INCLUDE_PATH " - "for this. See also CMAKE_SYSTEM_PREFIX_PATH.", false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_SYSTEM_LIBRARY_PATH", cmProperty::VARIABLE, - "Path used for searching by FIND_LIBRARY().", - "Specifies a path which will be used by FIND_LIBRARY(). FIND_LIBRARY() " - "will check each of the contained directories for the existence of the " - "library which is currently searched. By default it contains the " - "standard directories for the current system. It is NOT intended to be " - "modified by the project, use CMAKE_LIBRARY_PATH for this. See " - "also CMAKE_SYSTEM_PREFIX_PATH.", false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_SYSTEM_PROGRAM_PATH", cmProperty::VARIABLE, - "Path used for searching by FIND_PROGRAM().", - "Specifies a path which will be used by FIND_PROGRAM(). FIND_PROGRAM() " - "will check each of the contained directories for the existence of the " - "program which is currently searched. By default it contains the " - "standard directories for the current system. It is NOT intended to be " - "modified by the project, use CMAKE_PROGRAM_PATH for this. See also " - "CMAKE_SYSTEM_PREFIX_PATH.", false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_DISABLE_FIND_PACKAGE_<PackageName>", cmProperty::VARIABLE, - "Variable for disabling find_package() calls.", - "Every non-REQUIRED find_package() call in a project can be disabled " - "by setting the variable CMAKE_DISABLE_FIND_PACKAGE_<PackageName> to " - "TRUE. This can be used to build a project without an optional package, " - "although that package is installed.\n" - "This switch should be used during the initial CMake run. Otherwise if " - "the package has already been found in a previous CMake run, the " - "variables which have been stored in the cache will still be there. " - "In that case it is recommended to remove the cache variables for " - "this package from the cache using the cache editor or cmake -U", false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_FIND_PACKAGE_WARN_NO_MODULE", cmProperty::VARIABLE, - "Tell find_package to warn if called without an explicit mode.", - "If find_package is called without an explicit mode option " - "(MODULE, CONFIG or NO_MODULE) and no Find<pkg>.cmake module is " - "in CMAKE_MODULE_PATH then CMake implicitly assumes that the " - "caller intends to search for a package configuration file. " - "If no package configuration file is found then the wording " - "of the failure message must account for both the case that the " - "package is really missing and the case that the project has a " - "bug and failed to provide the intended Find module. " - "If instead the caller specifies an explicit mode option then " - "the failure message can be more specific." - "\n" - "Set CMAKE_FIND_PACKAGE_WARN_NO_MODULE to TRUE to tell find_package " - "to warn when it implicitly assumes Config mode. " - "This helps developers enforce use of an explicit mode in all calls " - "to find_package within a project.", false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_USER_MAKE_RULES_OVERRIDE", cmProperty::VARIABLE, - "Specify a CMake file that overrides platform information.", - "CMake loads the specified file while enabling support for each " - "language from either the project() or enable_language() commands. " - "It is loaded after CMake's builtin compiler and platform information " - "modules have been loaded but before the information is used. " - "The file may set platform information variables to override CMake's " - "defaults." - "\n" - "This feature is intended for use only in overriding information " - "variables that must be set before CMake builds its first test " - "project to check that the compiler for a language works. " - "It should not be used to load a file in cases that a normal include() " - "will work. " - "Use it only as a last resort for behavior that cannot be achieved " - "any other way. " - "For example, one may set CMAKE_C_FLAGS_INIT to change the default " - "value used to initialize CMAKE_C_FLAGS before it is cached. " - "The override file should NOT be used to set anything that could " - "be set after languages are enabled, such as variables like " - "CMAKE_RUNTIME_OUTPUT_DIRECTORY that affect the placement of binaries. " - "Information set in the file will be used for try_compile and try_run " - "builds too." - ,false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("BUILD_SHARED_LIBS", cmProperty::VARIABLE, - "Global flag to cause add_library to create shared libraries if on.", - "If present and true, this will cause all libraries to be " - "built shared unless the library was explicitly added as a " - "static library. This variable is often added to projects " - "as an OPTION so that each user of a project can decide if " - "they want to build the project using shared or static " - "libraries.",false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_NOT_USING_CONFIG_FLAGS", cmProperty::VARIABLE, - "Skip _BUILD_TYPE flags if true.", - "This is an internal flag used by the generators in " - "CMake to tell CMake to skip the _BUILD_TYPE flags.",false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_MFC_FLAG", cmProperty::VARIABLE, - "Tell cmake to use MFC for an executable or dll.", - "This can be set in a CMakeLists.txt file and will " - "enable MFC in the application. It should be set " - "to 1 for the static MFC library, and 2 for " - "the shared MFC library. This is used in Visual " - "Studio 6 and 7 project files. The CMakeSetup " - "dialog used MFC and the CMakeLists.txt looks like this:\n" - " add_definitions(-D_AFXDLL)\n" - " set(CMAKE_MFC_FLAG 2)\n" - " add_executable(CMakeSetup WIN32 ${SRCS})\n",false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_COLOR_MAKEFILE", cmProperty::VARIABLE, - "Enables color output when using the Makefile generator.", - "When enabled, the generated Makefiles will produce colored output. " - "Default is ON.",false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_ABSOLUTE_DESTINATION_FILES", cmProperty::VARIABLE, - "List of files which have been installed using " - " an ABSOLUTE DESTINATION path.", - "This variable is defined by CMake-generated cmake_install.cmake " - "scripts." - " It can be used (read-only) by programs or scripts that source those" - " install scripts. This is used by some CPack generators (e.g. RPM).", - false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION", cmProperty::VARIABLE, - "Ask cmake_install.cmake script to warn each time a file with " - "absolute INSTALL DESTINATION is encountered.", - "This variable is used by CMake-generated cmake_install.cmake" - " scripts. If one sets this variable to ON while running the" - " script, it may get warning messages from the script.", false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION", cmProperty::VARIABLE, - "Ask cmake_install.cmake script to error out as soon as " - "a file with absolute INSTALL DESTINATION is encountered.", - "The fatal error is emitted before the installation of " - "the offending file takes place." - " This variable is used by CMake-generated cmake_install.cmake" - " scripts. If one sets this variable to ON while running the" - " script, it may get fatal error messages from the script.",false, - "Variables That Change Behavior"); - - cm->DefineProperty - ("CMAKE_DEBUG_TARGET_PROPERTIES", cmProperty::VARIABLE, - "Enables tracing output for target properties.", - "This variable can be populated with a list of properties to generate " - "debug output for when evaluating target properties. Currently it can " - "only be used when evaluating the INCLUDE_DIRECTORIES, " - "COMPILE_DEFINITIONS and COMPILE_OPTIONS target properties. " - "In that case, it outputs a backtrace for each entry in the target " - "property. Default is unset.", false, "Variables That Change Behavior"); - - // Variables defined by CMake that describe the system - - cm->DefineProperty - ("CMAKE_SYSTEM", cmProperty::VARIABLE, - "Name of system cmake is compiling for.", - "This variable is the composite of CMAKE_SYSTEM_NAME " - "and CMAKE_SYSTEM_VERSION, like this " - "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_VERSION}. " - "If CMAKE_SYSTEM_VERSION is not set, then " - "CMAKE_SYSTEM is the same as CMAKE_SYSTEM_NAME.",false, - "Variables That Describe the System"); - cm->DefineProperty - ("CMAKE_SYSTEM_NAME", cmProperty::VARIABLE, - "Name of the OS CMake is building for.", - "This is the name of the operating system on " - "which CMake is targeting. On systems that " - "have the uname command, this variable is set " - "to the output of uname -s. Linux, Windows, " - " and Darwin for Mac OS X are the values found " - " on the big three operating systems." ,false, - "Variables That Describe the System"); - cm->DefineProperty - ("CMAKE_SYSTEM_PROCESSOR", cmProperty::VARIABLE, - "The name of the CPU CMake is building for.", - "On systems that support uname, this variable is " - "set to the output of uname -p, on windows it is " - "set to the value of the environment variable " - "PROCESSOR_ARCHITECTURE",false, - "Variables That Describe the System"); - cm->DefineProperty - ("CMAKE_SYSTEM_VERSION", cmProperty::VARIABLE, - "OS version CMake is building for.", - "A numeric version string for the system, on " - "systems that support uname, this variable is " - "set to the output of uname -r. On other " - "systems this is set to major-minor version numbers.",false, - "Variables That Describe the System"); - cm->DefineProperty - ("CMAKE_LIBRARY_ARCHITECTURE", cmProperty::VARIABLE, - "Target architecture library directory name, if detected.", - "This is the value of CMAKE_<lang>_LIBRARY_ARCHITECTURE as " - "detected for one of the enabled languages.",false, - "Variables That Describe the System"); - cm->DefineProperty - ("CMAKE_LIBRARY_ARCHITECTURE_REGEX", cmProperty::VARIABLE, - "Regex matching possible target architecture library directory names.", - "This is used to detect CMAKE_<lang>_LIBRARY_ARCHITECTURE from the " - "implicit linker search path by matching the <arch> name.",false, - "Variables That Describe the System"); - - cm->DefineProperty - ("CMAKE_HOST_SYSTEM", cmProperty::VARIABLE, - "Name of system cmake is being run on.", - "The same as CMAKE_SYSTEM but for the host system instead " - "of the target system when cross compiling.",false, - "Variables That Describe the System"); - cm->DefineProperty - ("CMAKE_HOST_SYSTEM_NAME", cmProperty::VARIABLE, - "Name of the OS CMake is running on.", - "The same as CMAKE_SYSTEM_NAME but for the host system instead " - "of the target system when cross compiling.",false, - "Variables That Describe the System"); - cm->DefineProperty - ("CMAKE_HOST_SYSTEM_PROCESSOR", cmProperty::VARIABLE, - "The name of the CPU CMake is running on.", - "The same as CMAKE_SYSTEM_PROCESSOR but for the host system instead " - "of the target system when cross compiling.",false, - "Variables That Describe the System"); - cm->DefineProperty - ("CMAKE_HOST_SYSTEM_VERSION", cmProperty::VARIABLE, - "OS version CMake is running on.", - "The same as CMAKE_SYSTEM_VERSION but for the host system instead " - "of the target system when cross compiling.",false, - "Variables That Describe the System"); - - cm->DefineProperty - ("APPLE", cmProperty::VARIABLE, - "True if running on Mac OS X.", - "Set to true on Mac OS X." - ,false, - "Variables That Describe the System"); - - cm->DefineProperty - ("BORLAND", cmProperty::VARIABLE, - "True if the Borland compiler is being used.", - "This is set to true if the Borland compiler is being used.",false, - "Variables That Describe the System"); - - cm->DefineProperty - ("CYGWIN", cmProperty::VARIABLE, - "True for Cygwin.", - "Set to true when using Cygwin." - ,false, - "Variables That Describe the System"); - - cm->DefineProperty - ("MSVC", cmProperty::VARIABLE, - "True when using Microsoft Visual C", - "Set to true when the compiler is some version of Microsoft Visual C.", - false, - "Variables That Describe the System"); - - int msvc_versions[] = { 60, 70, 71, 80, 90, 100, 110, 120, 0 }; - for (int i = 0; msvc_versions[i] != 0; i ++) - { - const char minor = (char)('0' + (msvc_versions[i] % 10)); - cmStdString varName = "MSVC"; - cmsys_ios::ostringstream majorStr; - - majorStr << (msvc_versions[i] / 10); - varName += majorStr.str(); - if (msvc_versions[i] < 100) - { - varName += minor; - } - - cmStdString verString = majorStr.str() + "." + minor; - - cmStdString shortStr = "True when using Microsoft Visual C " + verString; - cmStdString fullStr = "Set to true when the compiler is version " + - verString + - " of Microsoft Visual C."; - cm->DefineProperty - (varName.c_str(), cmProperty::VARIABLE, - shortStr.c_str(), - fullStr.c_str(), - false, - "Variables That Describe the System"); - } - - cm->DefineProperty - ("MSVC_IDE", cmProperty::VARIABLE, - "True when using the Microsoft Visual C IDE", - "Set to true when the target platform is the Microsoft Visual C IDE, " - "as opposed to the command line compiler.", - false, - "Variables That Describe the System"); - - cm->DefineProperty - ("MSVC_VERSION", cmProperty::VARIABLE, - "The version of Microsoft Visual C/C++ being used if any.", - "Known version numbers are:\n" - " 1200 = VS 6.0\n" - " 1300 = VS 7.0\n" - " 1310 = VS 7.1\n" - " 1400 = VS 8.0\n" - " 1500 = VS 9.0\n" - " 1600 = VS 10.0\n" - " 1700 = VS 11.0\n" - " 1800 = VS 12.0\n" - "", - false, - "Variables That Describe the System"); - - cm->DefineProperty - ("CMAKE_CL_64", cmProperty::VARIABLE, - "Using the 64 bit compiler from Microsoft", - "Set to true when using the 64 bit cl compiler from Microsoft.", - false, - "Variables That Describe the System"); - - cm->DefineProperty - ("CMAKE_COMPILER_2005", cmProperty::VARIABLE, - "Using the Visual Studio 2005 compiler from Microsoft", - "Set to true when using the Visual Studio 2005 compiler " - "from Microsoft.", - false, - "Variables That Describe the System"); - - cm->DefineProperty - ("UNIX", cmProperty::VARIABLE, - "True for UNIX and UNIX like operating systems.", - "Set to true when the target system is UNIX or UNIX like " - "(i.e. APPLE and CYGWIN).",false, - "Variables That Describe the System"); - - cm->DefineProperty - ("WIN32", cmProperty::VARIABLE, - "True on windows systems, including win64.", - "Set to true when the target system is Windows.",false, - "Variables That Describe the System"); - - cm->DefineProperty - ("XCODE_VERSION", cmProperty::VARIABLE, - "Version of Xcode (Xcode generator only).", - "Under the Xcode generator, this is the version of Xcode as specified in " - "\"Xcode.app/Contents/version.plist\" (such as \"3.1.2\").",false, - "Variables That Describe the System"); - - cm->DefineProperty - ("CMAKE_HOST_APPLE", cmProperty::VARIABLE, - "True for Apple OS X operating systems.", - "Set to true when the host system is Apple OS X.", - false, - "Variables That Describe the System"); - - cm->DefineProperty - ("CMAKE_HOST_UNIX", cmProperty::VARIABLE, - "True for UNIX and UNIX like operating systems.", - "Set to true when the host system is UNIX or UNIX like " - "(i.e. APPLE and CYGWIN).",false, - "Variables That Describe the System"); - - cm->DefineProperty - ("CMAKE_HOST_WIN32", cmProperty::VARIABLE, - "True on windows systems, including win64.", - "Set to true when the host system is Windows and on Cygwin." - ,false, - "Variables That Describe the System"); - - cm->DefineProperty - ("CMAKE_OBJECT_PATH_MAX", cmProperty::VARIABLE, - "Maximum object file full-path length allowed by native build tools.", - "CMake computes for every source file an object file name that is " - "unique to the source file and deterministic with respect to the " - "full path to the source file. " - "This allows multiple source files in a target to share the same name " - "if they lie in different directories without rebuilding when one is " - "added or removed. " - "However, it can produce long full paths in a few cases, so CMake " - "shortens the path using a hashing scheme when the full path to an " - "object file exceeds a limit. " - "CMake has a built-in limit for each platform that is sufficient for " - "common tools, but some native tools may have a lower limit. " - "This variable may be set to specify the limit explicitly. " - "The value must be an integer no less than 128.",false, - "Variables That Describe the System"); - - cm->DefineProperty - ("ENV", cmProperty::VARIABLE, - "Access environment variables.", - "Use the syntax $ENV{VAR} to read environment variable VAR. " - "See also the set() command to set ENV{VAR}." - ,false, - "Variables That Describe the System"); - - // Variables that affect the building of object files and - // targets. - // - cm->DefineProperty - ("CMAKE_INCLUDE_CURRENT_DIR", cmProperty::VARIABLE, - "Automatically add the current source- and build directories " - "to the include path.", - "If this variable is enabled, CMake automatically adds in each " - "directory ${CMAKE_CURRENT_SOURCE_DIR} and ${CMAKE_CURRENT_BINARY_DIR} " - "to the include path for this directory. These additional include " - "directories do not propagate down to subdirectories. This is useful " - "mainly for out-of-source builds, where files generated into the " - "build tree are included by files located in the source tree.\n" - "By default CMAKE_INCLUDE_CURRENT_DIR is OFF.", - false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE", cmProperty::VARIABLE, - "Automatically add the current source- and build directories " - "to the INTERFACE_INCLUDE_DIRECTORIES.", - "If this variable is enabled, CMake automatically adds for each shared " - "library target, static library target, module target and executable " - "target, ${CMAKE_CURRENT_SOURCE_DIR} and ${CMAKE_CURRENT_BINARY_DIR} to " - "the INTERFACE_INCLUDE_DIRECTORIES." - "By default CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE is OFF.", - false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_INSTALL_RPATH", cmProperty::VARIABLE, - "The rpath to use for installed targets.", - "A semicolon-separated list specifying the rpath " - "to use in installed targets (for platforms that support it). " - "This is used to initialize the target property " - "INSTALL_RPATH for all targets.", - false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_INSTALL_RPATH_USE_LINK_PATH", cmProperty::VARIABLE, - "Add paths to linker search and installed rpath.", - "CMAKE_INSTALL_RPATH_USE_LINK_PATH is a boolean that if set to true " - "will append directories in the linker search path and outside the " - "project to the INSTALL_RPATH. " - "This is used to initialize the target property " - "INSTALL_RPATH_USE_LINK_PATH for all targets.", - false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_INSTALL_NAME_DIR", cmProperty::VARIABLE, - "Mac OS X directory name for installed targets.", - "CMAKE_INSTALL_NAME_DIR is used to initialize the " - "INSTALL_NAME_DIR property on all targets. See that target " - "property for more information.", - false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_Fortran_FORMAT", cmProperty::VARIABLE, - "Set to FIXED or FREE to indicate the Fortran source layout.", - "This variable is used to initialize the Fortran_FORMAT " - "property on all the targets. " - "See that target property for additional information.", - false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_Fortran_MODULE_DIRECTORY", cmProperty::VARIABLE, - "Fortran module output directory.", - "This variable is used to initialize the " - "Fortran_MODULE_DIRECTORY property on all the targets. " - "See that target property for additional information.", - false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_LIBRARY_OUTPUT_DIRECTORY", cmProperty::VARIABLE, - "Where to put all the LIBRARY targets when built.", - "This variable is used to initialize the " - "LIBRARY_OUTPUT_DIRECTORY property on all the targets. " - "See that target property for additional information.", - false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_ARCHIVE_OUTPUT_DIRECTORY", cmProperty::VARIABLE, - "Where to put all the ARCHIVE targets when built.", - "This variable is used to initialize the " - "ARCHIVE_OUTPUT_DIRECTORY property on all the targets. " - "See that target property for additional information.", - false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_RUNTIME_OUTPUT_DIRECTORY", cmProperty::VARIABLE, - "Where to put all the RUNTIME targets when built.", - "This variable is used to initialize the " - "RUNTIME_OUTPUT_DIRECTORY property on all the targets. " - "See that target property for additional information.", - false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_PDB_OUTPUT_DIRECTORY", cmProperty::VARIABLE, - "Where to put all the MS debug symbol files from linker.", - "This variable is used to initialize the " - "PDB_OUTPUT_DIRECTORY property on all the targets. " - "See that target property for additional information.", - false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_LINK_DEPENDS_NO_SHARED", cmProperty::VARIABLE, - "Whether to skip link dependencies on shared library files.", - "This variable initializes the LINK_DEPENDS_NO_SHARED " - "property on targets when they are created. " - "See that target property for additional information.", - false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_AUTOMOC", cmProperty::VARIABLE, - "Whether to handle moc automatically for Qt targets.", - "This variable is used to initialize the " - "AUTOMOC property on all the targets. " - "See that target property for additional information.", - false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_AUTOMOC_MOC_OPTIONS", cmProperty::VARIABLE, - "Additional options for moc when using automoc (see CMAKE_AUTOMOC).", - "This variable is used to initialize the " - "AUTOMOC_MOC_OPTIONS property on all the targets. " - "See that target property for additional information.", - false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_GNUtoMS", cmProperty::VARIABLE, - "Convert GNU import libraries (.dll.a) to MS format (.lib).", - "This variable is used to initialize the GNUtoMS property on targets " - "when they are created. " - "See that target property for additional information.", - false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_DEBUG_POSTFIX", cmProperty::VARIABLE, - "See variable CMAKE_<CONFIG>_POSTFIX.", - "This variable is a special case of the more-general " - "CMAKE_<CONFIG>_POSTFIX variable for the DEBUG configuration.", - false, - "Variables that Control the Build"); - cm->DefineProperty - ("CMAKE_<CONFIG>_POSTFIX", cmProperty::VARIABLE, - "Default filename postfix for libraries under configuration <CONFIG>.", - "When a non-executable target is created its <CONFIG>_POSTFIX " - "target property is initialized with the value of this variable " - "if it is set.", - false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_BUILD_WITH_INSTALL_RPATH", cmProperty::VARIABLE, - "Use the install path for the RPATH", - "Normally CMake uses the build tree for the RPATH when building " - "executables etc on systems that use RPATH. When the software " - "is installed the executables etc are relinked by CMake to have " - "the install RPATH. If this variable is set to true then the software " - "is always built with the install path for the RPATH and does not " - "need to be relinked when installed.",false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_NO_BUILTIN_CHRPATH", cmProperty::VARIABLE, - "Do not use the builtin ELF editor to fix RPATHs on installation.", - "When an ELF binary needs to have a different RPATH after installation " - "than it does in the build tree, CMake uses a builtin editor to change " - "the RPATH in the installed copy. " - "If this variable is set to true then CMake will relink the binary " - "before installation instead of using its builtin editor.",false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_SKIP_BUILD_RPATH", cmProperty::VARIABLE, - "Do not include RPATHs in the build tree.", - "Normally CMake uses the build tree for the RPATH when building " - "executables etc on systems that use RPATH. When the software " - "is installed the executables etc are relinked by CMake to have " - "the install RPATH. If this variable is set to true then the software " - "is always built with no RPATH.",false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_SKIP_INSTALL_RPATH", cmProperty::VARIABLE, - "Do not include RPATHs in the install tree.", - "Normally CMake uses the build tree for the RPATH when building " - "executables etc on systems that use RPATH. When the software " - "is installed the executables etc are relinked by CMake to have " - "the install RPATH. If this variable is set to true then the software " - "is always installed without RPATH, even if RPATH is enabled when " - "building. This can be useful for example to allow running tests from " - "the build directory with RPATH enabled before the installation step. " - "To omit RPATH in both the build and install steps, use " - "CMAKE_SKIP_RPATH instead.",false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_EXE_LINKER_FLAGS", cmProperty::VARIABLE, - "Linker flags to be used to create executables.", - "These flags will be used by the linker when creating an executable." - ,false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_EXE_LINKER_FLAGS_<CONFIG>", cmProperty::VARIABLE, - "Flags to be used when linking an executable.", - "Same as CMAKE_C_FLAGS_* but used by the linker " - "when creating executables.",false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_MODULE_LINKER_FLAGS", cmProperty::VARIABLE, - "Linker flags to be used to create modules.", - "These flags will be used by the linker when creating a module." - ,false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_MODULE_LINKER_FLAGS_<CONFIG>", cmProperty::VARIABLE, - "Flags to be used when linking a module.", - "Same as CMAKE_C_FLAGS_* but used by the linker " - "when creating modules.",false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_SHARED_LINKER_FLAGS", cmProperty::VARIABLE, - "Linker flags to be used to create shared libraries.", - "These flags will be used by the linker when creating a shared library." - ,false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_SHARED_LINKER_FLAGS_<CONFIG>", cmProperty::VARIABLE, - "Flags to be used when linking a shared library.", - "Same as CMAKE_C_FLAGS_* but used by the linker " - "when creating shared libraries.",false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_STATIC_LINKER_FLAGS", cmProperty::VARIABLE, - "Linker flags to be used to create static libraries.", - "These flags will be used by the linker when creating a static library." - ,false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_STATIC_LINKER_FLAGS_<CONFIG>", cmProperty::VARIABLE, - "Flags to be used when linking a static library.", - "Same as CMAKE_C_FLAGS_* but used by the linker " - "when creating static libraries.",false, - "Variables that Control the Build"); - - cm->DefineProperty - ("CMAKE_LIBRARY_PATH_FLAG", cmProperty::VARIABLE, - "The flag to be used to add a library search path to a compiler.", - "The flag will be used to specify a library directory to the compiler. " - "On most compilers this is \"-L\".",false, - "Variables that Control the Build"); - cm->DefineProperty - ("CMAKE_LINK_DEF_FILE_FLAG ", cmProperty::VARIABLE, - "Linker flag to be used to specify a .def file for dll creation.", - "The flag will be used to add a .def file when creating " - "a dll on Windows; this is only defined on Windows." - ,false, - "Variables that Control the Build"); - cm->DefineProperty - ("CMAKE_LINK_LIBRARY_FLAG", cmProperty::VARIABLE, - "Flag to be used to link a library into an executable.", - "The flag will be used to specify a library to link to an executable. " - "On most compilers this is \"-l\".",false, - "Variables that Control the Build"); - cm->DefineProperty - ("CMAKE_LINK_LIBRARY_FILE_FLAG", cmProperty::VARIABLE, - "Flag to be used to link a library specified by a path to its file.", - "The flag will be used before a library file path is given to the " - "linker. " - "This is needed only on very few platforms.", false, - "Variables that Control the Build"); - cm->DefineProperty - ("CMAKE_USE_RELATIVE_PATHS", cmProperty::VARIABLE, - "Use relative paths (May not work!).", - "If this is set to TRUE, then CMake will use " - "relative paths between the source and binary tree. " - "This option does not work for more complicated " - "projects, and relative paths are used when possible. " - "In general, it is not possible to move CMake generated" - " makefiles to a different location regardless " - "of the value of this variable.",false, - "Variables that Control the Build"); - cm->DefineProperty - ("EXECUTABLE_OUTPUT_PATH", cmProperty::VARIABLE, - "Old executable location variable.", - "The target property RUNTIME_OUTPUT_DIRECTORY supercedes " - "this variable for a target if it is set. " - "Executable targets are otherwise placed in this directory.",false, - "Variables that Control the Build"); - cm->DefineProperty - ("LIBRARY_OUTPUT_PATH", cmProperty::VARIABLE, - "Old library location variable.", - "The target properties ARCHIVE_OUTPUT_DIRECTORY, " - "LIBRARY_OUTPUT_DIRECTORY, and RUNTIME_OUTPUT_DIRECTORY supercede " - "this variable for a target if they are set. " - "Library targets are otherwise placed in this directory.",false, - "Variables that Control the Build"); - cm->DefineProperty - ("CMAKE_TRY_COMPILE_CONFIGURATION", cmProperty::VARIABLE, - "Build configuration used for try_compile and try_run projects.", - "Projects built by try_compile and try_run are built " - "synchronously during the CMake configuration step. " - "Therefore a specific build configuration must be chosen even " - "if the generated build system supports multiple configurations.",false, - "Variables that Control the Build"); - cm->DefineProperty - ("CMAKE_LINK_INTERFACE_LIBRARIES", cmProperty::VARIABLE, - "Default value for LINK_INTERFACE_LIBRARIES of targets.", - "This variable is used to initialize the " - "LINK_INTERFACE_LIBRARIES property on all the targets. " - "See that target property for additional information.", - false, - "Variables that Control the Build"); - cm->DefineProperty - ("CMAKE_WIN32_EXECUTABLE", cmProperty::VARIABLE, - "Default value for WIN32_EXECUTABLE of targets.", - "This variable is used to initialize the " - "WIN32_EXECUTABLE property on all the targets. " - "See that target property for additional information.", - false, - "Variables that Control the Build"); - cm->DefineProperty - ("CMAKE_MACOSX_BUNDLE", cmProperty::VARIABLE, - "Default value for MACOSX_BUNDLE of targets.", - "This variable is used to initialize the " - "MACOSX_BUNDLE property on all the targets. " - "See that target property for additional information.", - false, - "Variables that Control the Build"); - cm->DefineProperty - ("CMAKE_POSITION_INDEPENDENT_CODE", cmProperty::VARIABLE, - "Default value for POSITION_INDEPENDENT_CODE of targets.", - "This variable is used to initialize the " - "POSITION_INDEPENDENT_CODE property on all the targets. " - "See that target property for additional information.", - false, - "Variables that Control the Build"); - cm->DefineProperty - ("CMAKE_<LANG>_VISIBILITY_PRESET", cmProperty::VARIABLE, - "Default value for <LANG>_VISIBILITY_PRESET of targets.", - "This variable is used to initialize the " - "<LANG>_VISIBILITY_PRESET property on all the targets. " - "See that target property for additional information.", - false, - "Variables that Control the Build"); - cm->DefineProperty - ("CMAKE_VISIBILITY_INLINES_HIDDEN", cmProperty::VARIABLE, - "Default value for VISIBILITY_INLINES_HIDDEN of targets.", - "This variable is used to initialize the " - "VISIBILITY_INLINES_HIDDEN property on all the targets. " - "See that target property for additional information.", - false, - "Variables that Control the Build"); - -// Variables defined when the a language is enabled These variables will -// also be defined whenever CMake has loaded its support for compiling (LANG) -// programs. This support will be loaded whenever CMake is used to compile -// (LANG) files. C and CXX are examples of the most common values for (LANG). - - cm->DefineProperty - ("CMAKE_USER_MAKE_RULES_OVERRIDE_<LANG>", cmProperty::VARIABLE, - "Specify a CMake file that overrides platform information for <LANG>.", - "This is a language-specific version of " - "CMAKE_USER_MAKE_RULES_OVERRIDE loaded only when enabling " - "language <LANG>.",false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_COMPILER", cmProperty::VARIABLE, - "The full path to the compiler for LANG.", - "This is the command that will be used as the <LANG> compiler. " - "Once set, you can not change this variable.",false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_COMPILER_ID", cmProperty::VARIABLE, - "Compiler identification string.", - "A short string unique to the compiler vendor. " - "Possible values include:\n" - " Absoft = Absoft Fortran (absoft.com)\n" - " ADSP = Analog VisualDSP++ (analog.com)\n" - " Clang = LLVM Clang (clang.llvm.org)\n" - " Cray = Cray Compiler (cray.com)\n" - " Embarcadero, Borland = Embarcadero (embarcadero.com)\n" - " G95 = G95 Fortran (g95.org)\n" - " GNU = GNU Compiler Collection (gcc.gnu.org)\n" - " HP = Hewlett-Packard Compiler (hp.com)\n" - " Intel = Intel Compiler (intel.com)\n" - " MIPSpro = SGI MIPSpro (sgi.com)\n" - " MSVC = Microsoft Visual Studio (microsoft.com)\n" - " PGI = The Portland Group (pgroup.com)\n" - " PathScale = PathScale (pathscale.com)\n" - " SDCC = Small Device C Compiler (sdcc.sourceforge.net)\n" - " SunPro = Oracle Solaris Studio (oracle.com)\n" - " TI = Texas Instruments (ti.com)\n" - " TinyCC = Tiny C Compiler (tinycc.org)\n" - " Watcom = Open Watcom (openwatcom.org)\n" - " XL, VisualAge, zOS = IBM XL (ibm.com)\n" - "This variable is not guaranteed to be defined for all " - "compilers or languages.", - false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_PLATFORM_ID", cmProperty::VARIABLE, - "An internal variable subject to change.", - "This is used in determining the platform and is subject to change.", - false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_COMPILER_ABI", cmProperty::VARIABLE, - "An internal variable subject to change.", - "This is used in determining the compiler ABI and is subject to change.", - false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_COMPILER_VERSION", cmProperty::VARIABLE, - "Compiler version string.", - "Compiler version in major[.minor[.patch[.tweak]]] format. " - "This variable is not guaranteed to be defined for all " - "compilers or languages.", - false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_INTERNAL_PLATFORM_ABI", cmProperty::VARIABLE, - "An internal variable subject to change.", - "This is used in determining the compiler ABI and is subject to change.", - false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_SIZEOF_DATA_PTR", cmProperty::VARIABLE, - "Size of pointer-to-data types for language <LANG>.", - "This holds the size (in bytes) of pointer-to-data types in the target " - "platform ABI. " - "It is defined for languages C and CXX (C++).", - false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_COMPILER_IS_GNU<LANG>", cmProperty::VARIABLE, - "True if the compiler is GNU.", - "If the selected <LANG> compiler is the GNU " - "compiler then this is TRUE, if not it is FALSE. " - "Unlike the other per-language variables, this uses the GNU syntax for " - "identifying languages instead of the CMake syntax. Recognized values of " - "the <LANG> suffix are:\n" - " CC = C compiler\n" - " CXX = C++ compiler\n" - " G77 = Fortran compiler", - false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_FLAGS", cmProperty::VARIABLE, - "Flags for all build types.", - "<LANG> flags used regardless of the value of CMAKE_BUILD_TYPE.",false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_FLAGS_DEBUG", cmProperty::VARIABLE, - "Flags for Debug build type or configuration.", - "<LANG> flags used when CMAKE_BUILD_TYPE is Debug.",false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_FLAGS_MINSIZEREL", cmProperty::VARIABLE, - "Flags for MinSizeRel build type or configuration.", - "<LANG> flags used when CMAKE_BUILD_TYPE is MinSizeRel." - "Short for minimum size release.",false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_FLAGS_RELEASE", cmProperty::VARIABLE, - "Flags for Release build type or configuration.", - "<LANG> flags used when CMAKE_BUILD_TYPE is Release",false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_FLAGS_RELWITHDEBINFO", cmProperty::VARIABLE, - "Flags for RelWithDebInfo type or configuration.", - "<LANG> flags used when CMAKE_BUILD_TYPE is RelWithDebInfo. " - "Short for Release With Debug Information.",false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_COMPILE_OBJECT", cmProperty::VARIABLE, - "Rule variable to compile a single object file.", - "This is a rule variable that tells CMake how to " - "compile a single object file for the language <LANG>." - ,false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_CREATE_SHARED_LIBRARY", cmProperty::VARIABLE, - "Rule variable to create a shared library.", - "This is a rule variable that tells CMake how to " - "create a shared library for the language <LANG>.",false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_CREATE_SHARED_MODULE", cmProperty::VARIABLE, - "Rule variable to create a shared module.", - "This is a rule variable that tells CMake how to " - "create a shared library for the language <LANG>.",false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_CREATE_STATIC_LIBRARY", cmProperty::VARIABLE, - "Rule variable to create a static library.", - "This is a rule variable that tells CMake how " - "to create a static library for the language <LANG>.",false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_ARCHIVE_CREATE", cmProperty::VARIABLE, - "Rule variable to create a new static archive.", - "This is a rule variable that tells CMake how to create a static " - "archive. It is used in place of CMAKE_<LANG>_CREATE_STATIC_LIBRARY " - "on some platforms in order to support large object counts. " - "See also CMAKE_<LANG>_ARCHIVE_APPEND and CMAKE_<LANG>_ARCHIVE_FINISH.", - false, "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_ARCHIVE_APPEND", cmProperty::VARIABLE, - "Rule variable to append to a static archive.", - "This is a rule variable that tells CMake how to append to a static " - "archive. It is used in place of CMAKE_<LANG>_CREATE_STATIC_LIBRARY " - "on some platforms in order to support large object counts. " - "See also CMAKE_<LANG>_ARCHIVE_CREATE and CMAKE_<LANG>_ARCHIVE_FINISH.", - false, "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_ARCHIVE_FINISH", cmProperty::VARIABLE, - "Rule variable to finish an existing static archive.", - "This is a rule variable that tells CMake how to finish a static " - "archive. It is used in place of CMAKE_<LANG>_CREATE_STATIC_LIBRARY " - "on some platforms in order to support large object counts. " - "See also CMAKE_<LANG>_ARCHIVE_CREATE and CMAKE_<LANG>_ARCHIVE_APPEND.", - false, "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_IGNORE_EXTENSIONS", cmProperty::VARIABLE, - "File extensions that should be ignored by the build.", - "This is a list of file extensions that may be " - "part of a project for a given language but are not compiled.",false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES", cmProperty::VARIABLE, - "Directories implicitly searched by the compiler for header files.", - "CMake does not explicitly specify these directories on compiler " - "command lines for language <LANG>. " - "This prevents system include directories from being treated as user " - "include directories on some compilers.", false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_IMPLICIT_LINK_DIRECTORIES", cmProperty::VARIABLE, - "Implicit linker search path detected for language <LANG>.", - "Compilers typically pass directories containing language runtime " - "libraries and default library search paths when they invoke a linker. " - "These paths are implicit linker search directories for the compiler's " - "language. " - "CMake automatically detects these directories for each language and " - "reports the results in this variable." - "\n" - "When a library in one of these directories is given by full path to " - "target_link_libraries() CMake will generate the -l<name> form on " - "link lines to ensure the linker searches its implicit directories " - "for the library. " - "Note that some toolchains read implicit directories from an " - "environment variable such as LIBRARY_PATH so keep its value " - "consistent when operating in a given build tree.",false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES", cmProperty::VARIABLE, - "Implicit linker framework search path detected for language <LANG>.", - "These paths are implicit linker framework search directories for " - "the compiler's language. " - "CMake automatically detects these directories for each language and " - "reports the results in this variable.", false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_IMPLICIT_LINK_LIBRARIES", cmProperty::VARIABLE, - "Implicit link libraries and flags detected for language <LANG>.", - "Compilers typically pass language runtime library names and " - "other flags when they invoke a linker. " - "These flags are implicit link options for the compiler's language. " - "CMake automatically detects these libraries and flags for each " - "language and reports the results in this variable.", false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_LIBRARY_ARCHITECTURE", cmProperty::VARIABLE, - "Target architecture library directory name detected for <lang>.", - "If the <lang> compiler passes to the linker an architecture-specific " - "system library search directory such as <prefix>/lib/<arch> this " - "variable contains the <arch> name if/as detected by CMake.",false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_LINKER_PREFERENCE_PROPAGATES", cmProperty::VARIABLE, - "True if CMAKE_<LANG>_LINKER_PREFERENCE propagates across targets.", - "This is used when CMake selects a linker language for a target. " - "Languages compiled directly into the target are always considered. " - "A language compiled into static libraries linked by the target is " - "considered if this variable is true.", false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_LINKER_PREFERENCE", cmProperty::VARIABLE, - "Preference value for linker language selection.", - "The \"linker language\" for executable, shared library, and module " - "targets is the language whose compiler will invoke the linker. " - "The LINKER_LANGUAGE target property sets the language explicitly. " - "Otherwise, the linker language is that whose linker preference value " - "is highest among languages compiled and linked into the target. " - "See also the CMAKE_<LANG>_LINKER_PREFERENCE_PROPAGATES variable.", - false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_LINK_EXECUTABLE ", cmProperty::VARIABLE, - "Rule variable to link an executable.", - "Rule variable to link an executable for the given language." - ,false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_OUTPUT_EXTENSION", cmProperty::VARIABLE, - "Extension for the output of a compile for a single file.", - "This is the extension for an object file for " - "the given <LANG>. For example .obj for C on Windows.",false, - "Variables for Languages"); - - cm->DefineProperty - ("CMAKE_<LANG>_SOURCE_FILE_EXTENSIONS", cmProperty::VARIABLE, - "Extensions of source files for the given language.", - "This is the list of extensions for a " - "given language's source files." - ,false, - "Variables for Languages"); - - cm->DefineProperty( - "CMAKE_<LANG>_COMPILER_LOADED", cmProperty::VARIABLE, - "Defined to true if the language is enabled.", - "When language <LANG> is enabled by project() or enable_language() " - "this variable is defined to 1.", - false,"Variables for Languages"); - - cm->DefineProperty( - "CMAKE_Fortran_MODDIR_FLAG", cmProperty::VARIABLE, - "Fortran flag for module output directory.", - "This stores the flag needed to pass the value of the " - "Fortran_MODULE_DIRECTORY target property to the compiler.", - false,"Variables for Languages"); - - cm->DefineProperty( - "CMAKE_Fortran_MODDIR_DEFAULT", cmProperty::VARIABLE, - "Fortran default module output directory.", - "Most Fortran compilers write .mod files to the current working " - "directory. " - "For those that do not, this is set to \".\" and used when the " - "Fortran_MODULE_DIRECTORY target property is not set.", - false,"Variables for Languages"); - - cm->DefineProperty( - "CMAKE_Fortran_MODOUT_FLAG", cmProperty::VARIABLE, - "Fortran flag to enable module output.", - "Most Fortran compilers write .mod files out by default. " - "For others, this stores the flag needed to enable module output.", - false,"Variables for Languages"); - - // variables that are used by cmake but not to be documented - cm->DefineProperty("CMAKE_MATCH_0", cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_MATCH_1", cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_MATCH_2", cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_MATCH_3", cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_MATCH_4", cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_MATCH_5", cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_MATCH_6", cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_MATCH_7", cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_MATCH_8", cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_MATCH_9", cmProperty::VARIABLE,0,0); - - cm->DefineProperty("CMAKE_<LANG>_COMPILER_ARG1", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_<LANG>_COMPILER_ENV_VAR", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_<LANG>_COMPILER_ID_RUN", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_<LANG>_ABI_FILES", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_<LANG>_CREATE_ASSEMBLY_SOURCE", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_<LANG>_CREATE_PREPROCESSED_SOURCE", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_<LANG>_FLAGS_DEBUG_INIT", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_<LANG>_FLAGS_INIT", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_<LANG>_FLAGS_MINSIZEREL_INIT", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_<LANG>_FLAGS_RELEASE_INIT", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_<LANG>_FLAGS_RELWITHDEBINFO_INIT", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_<LANG>_INFORMATION_LOADED", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_<LANG>_LINK_EXECUTABLE", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_<LANG>_LINK_FLAGS", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_<LANG>_RESPONSE_FILE_LINK_FLAG", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_<LANG>_STANDARD_LIBRARIES", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_<LANG>_STANDARD_LIBRARIES_INIT", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_<LANG>_USE_RESPONSE_FILE_FOR_INCLUDES", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_<LANG>_USE_RESPONSE_FILE_FOR_OBJECTS", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_EXECUTABLE_SUFFIX_<LANG>", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_EXE_LINK_DYNAMIC_<LANG>_FLAGS", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_EXE_LINK_STATIC_<LANG>_FLAGS", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_GENERATOR_<LANG>", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_IMPORT_LIBRARY_PREFIX_<LANG>", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_IMPORT_LIBRARY_SUFFIX_<LANG>", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_INCLUDE_FLAG_<LANG>", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_INCLUDE_FLAG_SEP_<LANG>", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_INCLUDE_SYSTEM_FLAG_<LANG>", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_NEEDS_REQUIRES_STEP_<LANG>_FLAG", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_SHARED_LIBRARY_CREATE_<LANG>_FLAGS", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_SHARED_LIBRARY_<LANG>_FLAGS", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_SHARED_LIBRARY_LINK_<LANG>_FLAGS", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_<LANG>_FLAGS", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_SHARED_LIBRARY_LINK_STATIC_<LANG>_FLAGS", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_SHARED_LIBRARY_PREFIX_<LANG>", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_SHARED_LIBRARY_SUFFIX_<LANG>", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_SHARED_LIBRARY_RUNTIME_<LANG>_FLAG", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_SHARED_LIBRARY_RUNTIME_<LANG>_FLAG_SEP", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_SHARED_LIBRARY_RPATH_LINK_<LANG>_FLAG", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_EXECUTABLE_RUNTIME_<LANG>_FLAG", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_EXECUTABLE_RUNTIME_<LANG>_FLAG_SEP", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_EXECUTABLE_RPATH_LINK_<LANG>_FLAG", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH", - cmProperty::VARIABLE,0,0); - cm->DefineProperty( - "CMAKE_<LANG>_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_SHARED_MODULE_CREATE_<LANG>_FLAGS", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_SHARED_MODULE_<LANG>_FLAGS", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_SHARED_MODULE_LINK_DYNAMIC_<LANG>_FLAGS", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_SHARED_MODULE_LINK_STATIC_<LANG>_FLAGS", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_SHARED_MODULE_PREFIX_<LANG>", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_SHARED_MODULE_SUFFIX_<LANG>", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_STATIC_LIBRARY_PREFIX_<LANG>", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_STATIC_LIBRARY_SUFFIX_<LANG>", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_LINK_DEPENDENT_LIBRARY_FILES", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_LINK_DEPENDENT_LIBRARY_DIRS", - cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_MAKE_INCLUDE_FROM_ROOT", - cmProperty::VARIABLE,0,0); -} diff --git a/Source/cmDocumentVariables.h b/Source/cmDocumentVariables.h deleted file mode 100644 index 1d59b24..0000000 --- a/Source/cmDocumentVariables.h +++ /dev/null @@ -1,21 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#ifndef cmDocumentVariables_h -#define cmDocumentVariables_h -class cmake; -class cmDocumentVariables -{ -public: - static void DefineVariables(cmake* cm); -}; - -#endif diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 4edacbb..9c27fc1 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -13,208 +13,71 @@ #include "cmSystemTools.h" #include "cmVersion.h" +#include "cmRST.h" + #include <cmsys/Directory.hxx> #include <cmsys/Glob.hxx> +#include <cmsys/FStream.hxx> -#include <algorithm> - -//---------------------------------------------------------------------------- -static const char *cmDocumentationStandardOptions[][3] = -{ - {"--copyright [file]", "Print the CMake copyright and exit.", - "If a file is specified, the copyright is written into it."}, - {"--help,-help,-usage,-h,-H,/?", "Print usage information and exit.", - "Usage describes the basic command line interface and its options."}, - {"--help-full [file]", "Print full help and exit.", - "Full help displays most of the documentation provided by the UNIX " - "man page. It is provided for use on non-UNIX platforms, but is " - "also convenient if the man page is not installed. If a file is " - "specified, the help is written into it."}, - {"--help-html [file]", "Print full help in HTML format.", - "This option is used by CMake authors to help produce web pages. " - "If a file is specified, the help is written into it."}, - {"--help-man [file]", "Print full help as a UNIX man page and exit.", - "This option is used by the cmake build to generate the UNIX man page. " - "If a file is specified, the help is written into it."}, - {"--version,-version,/V [file]", - "Show program name/version banner and exit.", - "If a file is specified, the version is written into it."}, - {0,0,0} -}; - -//---------------------------------------------------------------------------- -static const char *cmModulesDocumentationDescription[][3] = -{ - {0, - " CMake Modules - Modules coming with CMake, the Cross-Platform Makefile " - "Generator.", 0}, -// CMAKE_DOCUMENTATION_OVERVIEW, - {0, - "This is the documentation for the modules and scripts coming with CMake. " - "Using these modules you can check the computer system for " - "installed software packages, features of the compiler and the " - "existence of headers to name just a few.", 0}, - {0,0,0} -}; - -//---------------------------------------------------------------------------- -static const char *cmCustomModulesDocumentationDescription[][3] = -{ - {0, - " Custom CMake Modules - Additional Modules for CMake.", 0}, -// CMAKE_DOCUMENTATION_OVERVIEW, - {0, - "This is the documentation for additional modules and scripts for CMake. " - "Using these modules you can check the computer system for " - "installed software packages, features of the compiler and the " - "existence of headers to name just a few.", 0}, - {0,0,0} -}; - -//---------------------------------------------------------------------------- -static const char *cmPropertiesDocumentationDescription[][3] = -{ - {0, - " CMake Properties - Properties supported by CMake, " - "the Cross-Platform Makefile Generator.", 0}, -// CMAKE_DOCUMENTATION_OVERVIEW, - {0, - "This is the documentation for the properties supported by CMake. " - "Properties can have different scopes. They can either be assigned to a " - "source file, a directory, a target or globally to CMake. By modifying the " - "values of properties the behaviour of the build system can be customized.", - 0}, - {0,0,0} -}; - -//---------------------------------------------------------------------------- -static const char *cmCompatCommandsDocumentationDescription[][3] = -{ - {0, - " CMake Compatibility Listfile Commands - " - "Obsolete commands supported by CMake for compatibility.", 0}, -// CMAKE_DOCUMENTATION_OVERVIEW, - {0, - "This is the documentation for now obsolete listfile commands from previous " - "CMake versions, which are still supported for compatibility reasons. You " - "should instead use the newer, faster and shinier new commands. ;-)", 0}, - {0,0,0} -}; - -//---------------------------------------------------------------------------- -static const char *cmDocumentationModulesHeader[][3] = -{ - {0, - "The following modules are provided with CMake. " - "They can be used with INCLUDE(ModuleName).", 0}, - {0,0,0} -}; - -//---------------------------------------------------------------------------- -static const char *cmDocumentationCustomModulesHeader[][3] = -{ - {0, - "The following modules are also available for CMake. " - "They can be used with INCLUDE(ModuleName).", 0}, - {0,0,0} -}; +#include <ctype.h> -//---------------------------------------------------------------------------- -static const char *cmDocumentationGeneratorsHeader[][3] = -{ - {0, - "The following generators are available on this platform:", 0}, - {0,0,0} -}; +#include <algorithm> //---------------------------------------------------------------------------- -static const char *cmDocumentationStandardSeeAlso[][3] = -{ - {0, - "The following resources are available to get help using CMake:", 0}, - {"Home Page", - "http://www.cmake.org", - "The primary starting point for learning about CMake."}, - {"Frequently Asked Questions", - "http://www.cmake.org/Wiki/CMake_FAQ", - "A Wiki is provided containing answers to frequently asked questions. "}, - {"Online Documentation", - "http://www.cmake.org/HTML/Documentation.html", - "Links to available documentation may be found on this web page."}, - {"Mailing List", - "http://www.cmake.org/HTML/MailingLists.html", - "For help and discussion about using cmake, a mailing list is provided at " - "cmake@cmake.org. " - "The list is member-post-only but one may sign up on the CMake web page. " - "Please first read the full documentation at " - "http://www.cmake.org before posting questions to the list."}, - {0,0,0} +static const char *cmDocumentationStandardOptions[][2] = +{ + {"--help,-help,-usage,-h,-H,/?", + "Print usage information and exit."}, + {"--version,-version,/V [<f>]", + "Print version number and exit."}, + {"--help-manual <man> [<f>]", + "Print one help manual and exit."}, + {"--help-manual-list [<f>]", + "List help manuals available and exit."}, + {"--help-command <cmd> [<f>]", + "Print help for one command and exit."}, + {"--help-command-list [<f>]", + "List commands with help available and exit."}, + {"--help-commands [<f>]", + "Print cmake-commands manual and exit."}, + {"--help-module <mod> [<f>]", + "Print help for one module and exit."}, + {"--help-module-list [<f>]", + "List modules with help available and exit."}, + {"--help-modules [<f>]", + "Print cmake-modules manual and exit."}, + {"--help-policy <cmp> [<f>]", + "Print help for one policy and exit."}, + {"--help-policy-list [<f>]", + "List policies with help available and exit."}, + {"--help-policies [<f>]", + "Print cmake-policies manual and exit."}, + {"--help-property <prop> [<f>]", + "Print help for one property and exit."}, + {"--help-property-list [<f>]", + "List properties with help available and exit."}, + {"--help-properties [<f>]", + "Print cmake-properties manual and exit."}, + {"--help-variable var [<f>]", + "Print help for one variable and exit."}, + {"--help-variable-list [<f>]", + "List variables with help available and exit."}, + {"--help-variables [<f>]", + "Print cmake-variables manual and exit."}, + {0,0} }; //---------------------------------------------------------------------------- -static const char *cmDocumentationCopyright[][3] = +static const char *cmDocumentationGeneratorsHeader[][2] = { {0, - "Copyright 2000-2012 Kitware, Inc., Insight Software Consortium. " - "All rights reserved.", 0}, - {0, - "Redistribution and use in source and binary forms, with or without " - "modification, are permitted provided that the following conditions are " - "met:", 0}, - {"", - "Redistributions of source code must retain the above copyright notice, " - "this list of conditions and the following disclaimer.", 0}, - {"", - "Redistributions in binary form must reproduce the above copyright " - "notice, this list of conditions and the following disclaimer in the " - "documentation and/or other materials provided with the distribution.", - 0}, - {"", - "Neither the names of Kitware, Inc., the Insight Software Consortium, " - "nor the names of their contributors may be used to endorse or promote " - "products derived from this software without specific prior written " - "permission.", 0}, - {0, - "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS " - "\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT " - "LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR " - "A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT " - "HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, " - "SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT " - "LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, " - "DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY " - "THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT " - "(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE " - "OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.", - 0}, - {0, 0, 0} + "The following generators are available on this platform:"}, + {0,0} }; //---------------------------------------------------------------------------- -#define DOCUMENT_INTRO(type, default_name, desc) \ - static char const *cmDocumentation##type##Intro[2] = { default_name, desc }; -#define GET_DOCUMENT_INTRO(type) cmDocumentation##type##Intro - -DOCUMENT_INTRO(Modules, "cmakemodules", - "Reference of available CMake modules."); -DOCUMENT_INTRO(CustomModules, "cmakecustommodules", - "Reference of available CMake custom modules."); -DOCUMENT_INTRO(Policies, "cmakepolicies", - "Reference of CMake policies."); -DOCUMENT_INTRO(Properties, "cmakeprops", - "Reference of CMake properties."); -DOCUMENT_INTRO(Variables, "cmakevars", - "Reference of CMake variables."); -DOCUMENT_INTRO(Commands, "cmakecommands", - "Reference of available CMake commands."); -DOCUMENT_INTRO(CompatCommands, "cmakecompat", - "Reference of CMake compatibility commands."); - -//---------------------------------------------------------------------------- cmDocumentation::cmDocumentation() -:CurrentFormatter(0) { - this->SetForm(TextForm, 0); this->addCommonStandardDocSections(); this->ShowGenerators = true; } @@ -222,11 +85,6 @@ cmDocumentation::cmDocumentation() //---------------------------------------------------------------------------- cmDocumentation::~cmDocumentation() { - for(std::vector< char* >::iterator i = this->ModuleStrings.begin(); - i != this->ModuleStrings.end(); ++i) - { - delete [] *i; - } for(std::map<std::string,cmDocumentationSection *>::iterator i = this->AllSections.begin(); i != this->AllSections.end(); ++i) @@ -236,349 +94,60 @@ cmDocumentation::~cmDocumentation() } //---------------------------------------------------------------------------- -bool cmDocumentation::PrintCopyright(std::ostream& os) -{ - cmDocumentationSection *sec = this->AllSections["Copyright"]; - const std::vector<cmDocumentationEntry> &entries = sec->GetEntries(); - for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin(); - op != entries.end(); ++op) - { - if(op->Name.size()) - { - os << " * "; - this->TextFormatter.SetIndent(" "); - this->TextFormatter.PrintColumn(os, op->Brief.c_str()); - } - else - { - this->TextFormatter.SetIndent(""); - this->TextFormatter.PrintColumn(os, op->Brief.c_str()); - } - os << "\n"; - } - return true; -} - -//---------------------------------------------------------------------------- bool cmDocumentation::PrintVersion(std::ostream& os) { - os << this->GetNameString() << " version " - << cmVersion::GetCMakeVersion() << "\n"; + os << + this->GetNameString() << + " version " << cmVersion::GetCMakeVersion() << "\n" + "\n" + "CMake suite maintained by Kitware, Inc. (kitware.com).\n" + ; return true; } //---------------------------------------------------------------------------- -void cmDocumentation::AddSectionToPrint(const char *section) -{ - if (this->AllSections.find(section) != this->AllSections.end()) - { - this->PrintSections.push_back(this->AllSections[section]); - } -} - -//---------------------------------------------------------------------------- -void cmDocumentation::ClearSections() -{ - this->PrintSections.erase(this->PrintSections.begin(), - this->PrintSections.end()); - this->ModulesFound.clear(); -} - -//---------------------------------------------------------------------------- -void cmDocumentation::AddDocumentIntroToPrint(const char* intro[2]) -{ - const char* docname = this->GetDocName(false); - if(intro && docname) - { - cmDocumentationSection* section; - std::string desc(""); - - desc += docname; - desc += " - "; - desc += intro[1]; - - section = new cmDocumentationSection("Introduction", "NAME"); - section->Append(0, desc.c_str(), 0); - this->PrintSections.push_back(section); - } -} - -//---------------------------------------------------------------------------- -bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os, - const char* docname) +bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os) { - if ((this->CurrentFormatter->GetForm() != HTMLForm) - && (this->CurrentFormatter->GetForm() != DocbookForm) - && (this->CurrentFormatter->GetForm() != ManForm)) - { - this->PrintVersion(os); - } - - // Handle Document Name. docname==0 disables intro. - this->SetDocName(""); - if (docname) - { - if (*docname) - this->SetDocName(docname); - else // empty string was given. select default if possible - this->SetDocName(this->GetDefaultDocName(ht)); - } - switch (ht) { case cmDocumentation::Usage: return this->PrintDocumentationUsage(os); - case cmDocumentation::Single: - return this->PrintDocumentationSingle(os); - case cmDocumentation::SingleModule: - return this->PrintDocumentationSingleModule(os); - case cmDocumentation::SinglePolicy: - return this->PrintDocumentationSinglePolicy(os); - case cmDocumentation::SingleProperty: - return this->PrintDocumentationSingleProperty(os); - case cmDocumentation::SingleVariable: - return this->PrintDocumentationSingleVariable(os); - case cmDocumentation::List: - this->PrintDocumentationList(os,"Commands"); - this->PrintDocumentationList(os,"Compatibility Commands"); - return true; - case cmDocumentation::ModuleList: - // find the modules first, print the custom module docs only if - // any custom modules have been found actually, Alex - this->CreateCustomModulesSection(); - this->CreateModulesSection(); - if (this->AllSections.find("Custom CMake Modules") - != this->AllSections.end()) - { - this->PrintDocumentationList(os,"Custom CMake Modules"); - } - this->PrintDocumentationList(os,"Modules"); - return true; - case cmDocumentation::PropertyList: - this->PrintDocumentationList(os,"Properties Description"); - for (std::vector<std::string>::iterator i = - this->PropertySections.begin(); - i != this->PropertySections.end(); ++i) - { - this->PrintDocumentationList(os,i->c_str()); - } - return true; - case cmDocumentation::VariableList: - for (std::vector<std::string>::iterator i = - this->VariableSections.begin(); - i != this->VariableSections.end(); ++i) - { - this->PrintDocumentationList(os,i->c_str()); - } - return true; - case cmDocumentation::Full: - return this->PrintDocumentationFull(os); - case cmDocumentation::Modules: - return this->PrintDocumentationModules(os); - case cmDocumentation::CustomModules: - return this->PrintDocumentationCustomModules(os); - case cmDocumentation::Policies: - return this->PrintDocumentationPolicies(os); - case cmDocumentation::Properties: - return this->PrintDocumentationProperties(os); - case cmDocumentation::Variables: - return this->PrintDocumentationVariables(os); - case cmDocumentation::Commands: - return this->PrintDocumentationCurrentCommands(os); - case cmDocumentation::CompatCommands: - return this->PrintDocumentationCompatCommands(os); - - case cmDocumentation::Copyright: - return this->PrintCopyright(os); + case cmDocumentation::OneManual: + return this->PrintHelpOneManual(os); + case cmDocumentation::OneCommand: + return this->PrintHelpOneCommand(os); + case cmDocumentation::OneModule: + return this->PrintHelpOneModule(os); + case cmDocumentation::OnePolicy: + return this->PrintHelpOnePolicy(os); + case cmDocumentation::OneProperty: + return this->PrintHelpOneProperty(os); + case cmDocumentation::OneVariable: + return this->PrintHelpOneVariable(os); + case cmDocumentation::ListManuals: + return this->PrintHelpListManuals(os); + case cmDocumentation::ListCommands: + return this->PrintHelpListCommands(os); + case cmDocumentation::ListModules: + return this->PrintHelpListModules(os); + case cmDocumentation::ListProperties: + return this->PrintHelpListProperties(os); + case cmDocumentation::ListVariables: + return this->PrintHelpListVariables(os); + case cmDocumentation::ListPolicies: + return this->PrintHelpListPolicies(os); case cmDocumentation::Version: - return true; + return this->PrintVersion(os); + case cmDocumentation::OldCustomModules: + return this->PrintOldCustomModules(os); default: return false; } } //---------------------------------------------------------------------------- -bool cmDocumentation::CreateModulesSection() -{ - cmDocumentationSection *sec = - new cmDocumentationSection("Standard CMake Modules", "MODULES"); - this->AllSections["Modules"] = sec; - std::string cmakeModules = this->CMakeRoot; - cmakeModules += "/Modules"; - cmsys::Directory dir; - dir.Load(cmakeModules.c_str()); - if (dir.GetNumberOfFiles() > 0) - { - sec->Append(cmDocumentationModulesHeader[0]); - sec->Append(cmModulesDocumentationDescription); - this->CreateModuleDocsForDir(dir, *this->AllSections["Modules"]); - } - return true; -} - -//---------------------------------------------------------------------------- -bool cmDocumentation::CreateCustomModulesSection() -{ - bool sectionHasHeader = false; - - std::vector<std::string> dirs; - cmSystemTools::ExpandListArgument(this->CMakeModulePath, dirs); - - for(std::vector<std::string>::const_iterator dirIt = dirs.begin(); - dirIt != dirs.end(); - ++dirIt) - { - cmsys::Directory dir; - dir.Load(dirIt->c_str()); - if (dir.GetNumberOfFiles() > 0) - { - if (!sectionHasHeader) - { - cmDocumentationSection *sec = - new cmDocumentationSection("Custom CMake Modules","CUSTOM MODULES"); - this->AllSections["Custom CMake Modules"] = sec; - sec->Append(cmDocumentationCustomModulesHeader[0]); - sec->Append(cmCustomModulesDocumentationDescription); - sectionHasHeader = true; - } - this->CreateModuleDocsForDir - (dir, *this->AllSections["Custom CMake Modules"]); - } - } - - return true; -} - -//---------------------------------------------------------------------------- -void cmDocumentation -::CreateModuleDocsForDir(cmsys::Directory& dir, - cmDocumentationSection &moduleSection) -{ - // sort the files alphabetically, so the docs for one module are easier - // to find than if they are in random order - std::vector<std::string> sortedFiles; - for(unsigned int i = 0; i < dir.GetNumberOfFiles(); ++i) - { - sortedFiles.push_back(dir.GetFile(i)); - } - std::sort(sortedFiles.begin(), sortedFiles.end()); - - for(std::vector<std::string>::const_iterator fname = sortedFiles.begin(); - fname!=sortedFiles.end(); ++fname) - { - if(fname->length() > 6) - { - if(fname->substr(fname->length()-6, 6) == ".cmake") - { - std::string moduleName = fname->substr(0, fname->length()-6); - // this check is to avoid creating documentation for the modules with - // the same name in multiple directories of CMAKE_MODULE_PATH - if (this->ModulesFound.find(moduleName) == this->ModulesFound.end()) - { - this->ModulesFound.insert(moduleName); - std::string path = dir.GetPath(); - path += "/"; - path += (*fname); - this->CreateSingleModule(path.c_str(), moduleName.c_str(), - moduleSection); - } - } - } - } -} - -//---------------------------------------------------------------------------- -bool cmDocumentation::CreateSingleModule(const char* fname, - const char* moduleName, - cmDocumentationSection &moduleSection) -{ - std::ifstream fin(fname); - if(!fin) - { - std::cerr << "Internal error: can not open module." << fname << std::endl; - return false; - } - std::string line; - std::string text; - std::string brief; - brief = " "; - bool newParagraph = true; - while ( fin && cmSystemTools::GetLineFromStream(fin, line) ) - { - if(line.size() && line[0] == '#') - { - /* line beginnings with ## are mark-up ignore them */ - if (line.size()>=2 && line[1] == '#') continue; - // blank line - if(line.size() <= 2) - { - text += "\n"; - newParagraph = true; - } - else if(line[2] == '-') - { - brief = line.c_str()+4; - } - else - { - // two spaces - if(line[1] == ' ' && line[2] == ' ') - { - if(!newParagraph) - { - text += "\n"; - newParagraph = true; - } - // Skip #, and leave space for preformatted - text += line.c_str()+1; - text += "\n"; - } - else if(line[1] == ' ') - { - if(!newParagraph) - { - text += " "; - } - newParagraph = false; - // skip # and space - text += line.c_str()+2; - } - else - { - if(!newParagraph) - { - text += " "; - } - newParagraph = false; - // skip # - text += line.c_str()+1; - } - } - } - else - { - break; - } - } - - if(text.length() < 2 && brief.length() == 1) - { - return false; - } - - char* pname = strcpy(new char[strlen(moduleName)+1], moduleName); - char* ptext = strcpy(new char[text.length()+1], text.c_str()); - this->ModuleStrings.push_back(pname); - this->ModuleStrings.push_back(ptext); - char* pbrief = strcpy(new char[brief.length()+1], brief.c_str()); - this->ModuleStrings.push_back(pbrief); - moduleSection.Append(pname, pbrief, ptext); - return true; -} - - -//---------------------------------------------------------------------------- bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os) { + int count = 0; bool result = true; // Loop over requested documentation types. @@ -587,16 +156,14 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os) i != this->RequestedHelpItems.end(); ++i) { - this->SetForm(i->HelpForm, i->ManSection); this->CurrentArgument = i->Argument; // If a file name was given, use it. Otherwise, default to the // given stream. - std::ofstream* fout = 0; + cmsys::ofstream* fout = 0; std::ostream* s = &os; - std::string docname(""); if(i->Filename.length() > 0) { - fout = new std::ofstream(i->Filename.c_str(), std::ios::out); + fout = new cmsys::ofstream(i->Filename.c_str(), std::ios::out); if(fout) { s = fout; @@ -605,14 +172,14 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os) { result = false; } - if(i->Filename != "-") - { - docname = cmSystemTools::GetFilenameWithoutLastExtension(i->Filename); - } + } + else if(++count > 1) + { + os << "\n\n"; } // Print this documentation type to the stream. - if(!this->PrintDocumentation(i->HelpType, *s, docname.c_str()) || !*s) + if(!this->PrintDocumentation(i->HelpType, *s) || !*s) { result = false; } @@ -634,33 +201,30 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os) }; -cmDocumentation::Form cmDocumentation::GetFormFromFilename( - const std::string& filename, - int* manSection) +void cmDocumentation::WarnFormFromFilename( + cmDocumentation::RequestedHelpItem& request, bool& result) { - std::string ext = cmSystemTools::GetFilenameLastExtension(filename); + std::string ext = cmSystemTools::GetFilenameLastExtension(request.Filename); ext = cmSystemTools::UpperCase(ext); if ((ext == ".HTM") || (ext == ".HTML")) { - return cmDocumentation::HTMLForm; + request.HelpType = cmDocumentation::None; + result = true; + cmSystemTools::Message("Warning: HTML help format no longer supported"); } - - if (ext == ".DOCBOOK") + else if (ext == ".DOCBOOK") { - return cmDocumentation::DocbookForm; + request.HelpType = cmDocumentation::None; + result = true; + cmSystemTools::Message("Warning: Docbook help format no longer supported"); } - // ".1" to ".9" should be manpages - if ((ext.length()==2) && (ext[1] >='1') && (ext[1]<='9')) + else if ((ext.length()==2) && (ext[1] >='1') && (ext[1]<='9')) { - if (manSection) - { - *manSection = ext[1] - '0'; - } - return cmDocumentation::ManForm; + request.HelpType = cmDocumentation::None; + result = true; + cmSystemTools::Message("Warning: Man help format no longer supported"); } - - return cmDocumentation::TextForm; } //---------------------------------------------------------------------------- @@ -668,29 +232,9 @@ void cmDocumentation::addCommonStandardDocSections() { cmDocumentationSection *sec; - sec = new cmDocumentationSection("Author","AUTHOR"); - sec->Append(cmDocumentationEntry - (0, - "This manual page was generated by the \"--help-man\" option.", - 0)); - this->AllSections["Author"] = sec; - - sec = new cmDocumentationSection("Copyright","COPYRIGHT"); - sec->Append(cmDocumentationCopyright); - this->AllSections["Copyright"] = sec; - - sec = new cmDocumentationSection("See Also","SEE ALSO"); - sec->Append(cmDocumentationStandardSeeAlso); - this->AllSections["Standard See Also"] = sec; - sec = new cmDocumentationSection("Options","OPTIONS"); sec->Append(cmDocumentationStandardOptions); this->AllSections["Options"] = sec; - - sec = new cmDocumentationSection("Compatibility Commands", - "COMPATIBILITY COMMANDS"); - sec->Append(cmCompatCommandsDocumentationDescription); - this->AllSections["Compatibility Commands"] = sec; } //---------------------------------------------------------------------------- @@ -698,27 +242,9 @@ void cmDocumentation::addCMakeStandardDocSections() { cmDocumentationSection *sec; - sec = new cmDocumentationSection("Properties","PROPERTIES"); - sec->Append(cmPropertiesDocumentationDescription); - this->AllSections["Properties Description"] = sec; - sec = new cmDocumentationSection("Generators","GENERATORS"); sec->Append(cmDocumentationGeneratorsHeader); this->AllSections["Generators"] = sec; - - this->PropertySections.push_back("Properties of Global Scope"); - this->PropertySections.push_back("Properties on Directories"); - this->PropertySections.push_back("Properties on Targets"); - this->PropertySections.push_back("Properties on Tests"); - this->PropertySections.push_back("Properties on Source Files"); - this->PropertySections.push_back("Properties on Cache Entries"); - - this->VariableSections.push_back("Variables that Provide Information"); - this->VariableSections.push_back("Variables That Change Behavior"); - this->VariableSections.push_back("Variables That Describe the System"); - this->VariableSections.push_back("Variables that Control the Build"); - this->VariableSections.push_back("Variables for Languages"); - } //---------------------------------------------------------------------------- @@ -737,347 +263,6 @@ void cmDocumentation::addCPackStandardDocSections() sec = new cmDocumentationSection("Generators","GENERATORS"); sec->Append(cmDocumentationGeneratorsHeader); this->AllSections["Generators"] = sec; - - this->VariableSections.push_back( - "Variables common to all CPack generators"); -} - -void cmDocumentation::addAutomaticVariableSections(const std::string& section) -{ - std::vector<std::string>::iterator it; - it = std::find(this->VariableSections.begin(), - this->VariableSections.end(), - section); - /* if the section does not exist then add it */ - if (it==this->VariableSections.end()) - { - this->VariableSections.push_back(section); - } -} -//---------------------------------------------------------------------------- -int cmDocumentation::getDocumentedModulesListInDir( - std::string path, - std::string globExpr, - documentedModulesList_t& docedModuleList) -{ - cmsys::Glob gl; - std::string findExpr; - std::vector<std::string> files; - std::string line; - documentedModuleSectionPair_t docPair; - int nbDocumentedModules = 0; - - findExpr = path + "/" + globExpr; - if (gl.FindFiles(findExpr)) - { - files = gl.GetFiles(); - for (std::vector<std::string>::iterator itf=files.begin(); - itf!=files.end();++itf) - { - std::ifstream fin((*itf).c_str()); - // file access trouble ignore it (ignore this kind of error) - if (!fin) continue; - /* read first line in order to get doc section */ - if (cmSystemTools::GetLineFromStream(fin, line)) - { - /* Doc section indicates that - * this file has structured doc in it. - */ - if (line.find("##section")!=std::string::npos) - { - // ok found one more documented module - ++nbDocumentedModules; - docPair.first = *itf; - // 10 is the size of '##section' + 1 - docPair.second = line.substr(10,std::string::npos); - docedModuleList.push_back(docPair); - } - // No else if no section is found (undocumented module) - } - // No else cannot read first line (ignore this kind of error) - line = ""; - } - } - if (nbDocumentedModules>0) - { - return 0; - } - else - { - return 1; - } -} - -//---------------------------------------------------------------------------- -static void trim(std::string& s) -{ - std::string::size_type pos = s.find_last_not_of(' '); - if(pos != std::string::npos) - { - s.erase(pos + 1); - pos = s.find_first_not_of(' '); - if(pos != std::string::npos) s.erase(0, pos); - } - else - { - s.erase(s.begin(), s.end()); - } -} - -int cmDocumentation::GetStructuredDocFromFile( - const char* fname, - std::vector<cmDocumentationEntry>& commands, - cmake* cm) -{ - typedef enum sdoce { - SDOC_NONE, SDOC_MODULE, SDOC_MACRO, SDOC_FUNCTION, SDOC_VARIABLE, - SDOC_SECTION, - SDOC_UNKNOWN} sdoc_t; - int nbDocItemFound = 0; - int docCtxIdx = 0; - std::vector<int> docContextStack(60); - docContextStack[docCtxIdx]=SDOC_NONE; - cmDocumentationEntry e; - std::ifstream fin(fname); - if(!fin) - { - return nbDocItemFound; - } - std::string section; - std::string name; - std::string full; - std::string brief; - std::string line; - bool newCtx = false; /* we've just entered ##<beginkey> context */ - bool inBrief = false; /* we are currently parsing brief desc. */ - bool inFullFirstParagraph = false; /* we are currently parsing full - desc. first paragraph */ - brief = ""; - full = ""; - bool newParagraph = true; - while ( fin && cmSystemTools::GetLineFromStream(fin, line) ) - { - if(line.size() && line[0] == '#') - { - /* handle structured doc context */ - if ((line.size()>=2) && line[1]=='#') - { - /* markup word is following '##' stopping at first space - * Some markup word like 'section' may have more characters - * following but we don't handle those here. - */ - std::string mkword = line.substr(2,line.find(' ',2)-2); - if (mkword=="macro") - { - docCtxIdx++; - docContextStack[docCtxIdx]=SDOC_MACRO; - newCtx = true; - } - else if (mkword=="variable") - { - docCtxIdx++; - docContextStack[docCtxIdx]=SDOC_VARIABLE; - newCtx = true; - } - else if (mkword=="function") - { - docCtxIdx++; - docContextStack[docCtxIdx]=SDOC_FUNCTION; - newCtx = true; - } - else if (mkword=="module") - { - docCtxIdx++; - docContextStack[docCtxIdx]=SDOC_MODULE; - newCtx = true; - } - else if (mkword=="section") - { - docCtxIdx++; - docContextStack[docCtxIdx]=SDOC_SECTION; - // 10 is the size of '##section' + 1 - section = line.substr(10,std::string::npos); - /* drop the rest of the line */ - line = ""; - newCtx = true; - } - else if (mkword.substr(0,3)=="end") - { - switch (docContextStack[docCtxIdx]) { - case SDOC_MACRO: - /* for now MACRO and FUNCTION are handled in the same way */ - case SDOC_FUNCTION: - commands.push_back(cmDocumentationEntry(name.c_str(), - brief.c_str(),full.c_str())); - break; - case SDOC_VARIABLE: - this->addAutomaticVariableSections(section); - cm->DefineProperty - (name.c_str(), cmProperty::VARIABLE, - brief.c_str(), - full.c_str(),false, - section.c_str()); - break; - case SDOC_MODULE: - /* not implemented */ - break; - case SDOC_SECTION: - /* not implemented */ - break; - default: - /* ignore other cases */ - break; - } - docCtxIdx--; - newCtx = false; - ++nbDocItemFound; - } - else - { - // error out unhandled context - return nbDocItemFound; - } - /* context is set go to next doc line */ - continue; - } - - // Now parse the text attached to the context - - // The first line after the context mark-up contains:: - // name - brief until. (brief is dot terminated or - // followed by a blank line) - if (newCtx) - { - // no brief (for easy variable definition) - if (line.find("-")==std::string::npos) - { - name = line.substr(1,std::string::npos); - trim(name); - brief = ""; - inBrief = false; - full = ""; - } - // here we have a name and brief beginning - else - { - name = line.substr(1,line.find("-")-1); - trim(name); - // we are parsing the brief context - brief = line.substr(line.find("-")+1,std::string::npos); - trim(brief); - // Brief may already be terminated on the first line - if (brief.find('.')!=std::string::npos) - { - inBrief = false; - full = brief.substr(brief.find('.')+1,std::string::npos); - trim(full); - inFullFirstParagraph = true; - brief = brief.substr(0,brief.find('.')); - } - // brief is continued on following lines - else - { - inBrief = true; - full = ""; - } - } - newCtx = false; - continue; - } - // blank line - if(line.size() <= 2) - { - if (inBrief) { - inBrief = false; - full = ""; - } else { - if (full.length()>0) - { - full += "\n"; - } - // the first paragraph of full has ended - inFullFirstParagraph = false; - } - newParagraph = true; - } - // brief is terminated by '.' - else if (inBrief && (line.find('.')!=std::string::npos)) - { - /* the brief just ended */ - inBrief = false; - std::string endBrief = line.substr(1,line.find('.')); - trim(endBrief); - trim(brief); - brief += " " + endBrief; - full += line.substr(line.find('.')+1,std::string::npos); - trim(full); - inFullFirstParagraph = true; - } - // we handle full text or multi-line brief. - else - { - std::string* text; - if (inBrief) - { - text = &brief; - } - else - { - text = &full; - } - // two spaces - if(line[1] == ' ' && line[2] == ' ') - { - // there is no "full first paragraph at all." - if (line[3] == ' ') - { - inFullFirstParagraph = false; - } - - if(!newParagraph && !inFullFirstParagraph) - { - *text += "\n"; - newParagraph = true; - } - // Skip #, and leave space for pre-formatted - if (inFullFirstParagraph) - { - std::string temp = line.c_str()+1; - trim(temp); - *text += " " + temp; - } - else - { - *text += line.c_str()+1; - *text += "\n"; - } - } - else if(line[1] == ' ') - { - if(!newParagraph) - { - *text += " "; - } - newParagraph = false; - // skip # and space - *text += line.c_str()+2; - } - else - { - if(!newParagraph) - { - *text += " "; - } - newParagraph = false; - // skip # - *text += line.c_str()+1; - } - } - } - /* next line is not the first context line */ - newCtx = false; - } - return nbDocItemFound; } //---------------------------------------------------------------------------- @@ -1089,7 +274,6 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv, { RequestedHelpItem help; help.HelpType = cmDocumentation::Usage; - help.HelpForm = cmDocumentation::UsageForm; this->RequestedHelpItems.push_back(help); return true; } @@ -1113,154 +297,167 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv, (strcmp(argv[i], "-H") == 0)) { help.HelpType = cmDocumentation::Usage; - help.HelpForm = cmDocumentation::UsageForm; GET_OPT_ARGUMENT(help.Argument); help.Argument = cmSystemTools::LowerCase(help.Argument); // special case for single command if (!help.Argument.empty()) { - help.HelpType = cmDocumentation::Single; + help.HelpType = cmDocumentation::OneCommand; } } else if(strcmp(argv[i], "--help-properties") == 0) { - help.HelpType = cmDocumentation::Properties; + help.HelpType = cmDocumentation::OneManual; + help.Argument = "cmake-properties.7"; GET_OPT_ARGUMENT(help.Filename); - help.HelpForm = this->GetFormFromFilename(help.Filename, - &help.ManSection); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-policies") == 0) { - help.HelpType = cmDocumentation::Policies; + help.HelpType = cmDocumentation::OneManual; + help.Argument = "cmake-policies.7"; GET_OPT_ARGUMENT(help.Filename); - help.HelpForm = this->GetFormFromFilename(help.Filename, - &help.ManSection); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-variables") == 0) { - help.HelpType = cmDocumentation::Variables; + help.HelpType = cmDocumentation::OneManual; + help.Argument = "cmake-variables.7"; GET_OPT_ARGUMENT(help.Filename); - help.HelpForm = this->GetFormFromFilename(help.Filename, - &help.ManSection); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-modules") == 0) { - help.HelpType = cmDocumentation::Modules; + help.HelpType = cmDocumentation::OneManual; + help.Argument = "cmake-modules.7"; GET_OPT_ARGUMENT(help.Filename); - help.HelpForm = this->GetFormFromFilename(help.Filename, - &help.ManSection); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-custom-modules") == 0) { - help.HelpType = cmDocumentation::CustomModules; GET_OPT_ARGUMENT(help.Filename); - help.HelpForm = this->GetFormFromFilename(help.Filename, - &help.ManSection); + cmSystemTools::Message( + "Warning: --help-custom-modules no longer supported"); + if(help.Filename.empty()) + { + return true; + } + // Avoid breaking old project builds completely by at least generating + // the output file. Abuse help.Argument to give the file name to + // PrintOldCustomModules without disrupting our internal API. + help.HelpType = cmDocumentation::OldCustomModules; + help.Argument = cmSystemTools::GetFilenameName(help.Filename); } else if(strcmp(argv[i], "--help-commands") == 0) { - help.HelpType = cmDocumentation::Commands; + help.HelpType = cmDocumentation::OneManual; + help.Argument = "cmake-commands.7"; GET_OPT_ARGUMENT(help.Filename); - help.HelpForm = this->GetFormFromFilename(help.Filename, - &help.ManSection); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-compatcommands") == 0) { - help.HelpType = cmDocumentation::CompatCommands; GET_OPT_ARGUMENT(help.Filename); - help.HelpForm = this->GetFormFromFilename(help.Filename, - &help.ManSection); + cmSystemTools::Message( + "Warning: --help-compatcommands no longer supported"); + return true; } else if(strcmp(argv[i], "--help-full") == 0) { - help.HelpType = cmDocumentation::Full; GET_OPT_ARGUMENT(help.Filename); - help.HelpForm = this->GetFormFromFilename(help.Filename, - &help.ManSection); + cmSystemTools::Message("Warning: --help-full no longer supported"); + return true; } else if(strcmp(argv[i], "--help-html") == 0) { - help.HelpType = cmDocumentation::Full; GET_OPT_ARGUMENT(help.Filename); - help.HelpForm = cmDocumentation::HTMLForm; + cmSystemTools::Message("Warning: --help-html no longer supported"); + return true; } else if(strcmp(argv[i], "--help-man") == 0) { - help.HelpType = cmDocumentation::Full; GET_OPT_ARGUMENT(help.Filename); - help.HelpForm = cmDocumentation::ManForm; - help.ManSection = 1; + cmSystemTools::Message("Warning: --help-man no longer supported"); + return true; } else if(strcmp(argv[i], "--help-command") == 0) { - help.HelpType = cmDocumentation::Single; + help.HelpType = cmDocumentation::OneCommand; GET_OPT_ARGUMENT(help.Argument); GET_OPT_ARGUMENT(help.Filename); help.Argument = cmSystemTools::LowerCase(help.Argument); - help.HelpForm = this->GetFormFromFilename(help.Filename, - &help.ManSection); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-module") == 0) { - help.HelpType = cmDocumentation::SingleModule; + help.HelpType = cmDocumentation::OneModule; GET_OPT_ARGUMENT(help.Argument); GET_OPT_ARGUMENT(help.Filename); - help.HelpForm = this->GetFormFromFilename(help.Filename, - &help.ManSection); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-property") == 0) { - help.HelpType = cmDocumentation::SingleProperty; + help.HelpType = cmDocumentation::OneProperty; GET_OPT_ARGUMENT(help.Argument); GET_OPT_ARGUMENT(help.Filename); - help.HelpForm = this->GetFormFromFilename(help.Filename, - &help.ManSection); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-policy") == 0) { - help.HelpType = cmDocumentation::SinglePolicy; + help.HelpType = cmDocumentation::OnePolicy; GET_OPT_ARGUMENT(help.Argument); GET_OPT_ARGUMENT(help.Filename); - help.HelpForm = this->GetFormFromFilename(help.Filename, - &help.ManSection); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-variable") == 0) { - help.HelpType = cmDocumentation::SingleVariable; + help.HelpType = cmDocumentation::OneVariable; + GET_OPT_ARGUMENT(help.Argument); + GET_OPT_ARGUMENT(help.Filename); + this->WarnFormFromFilename(help, result); + } + else if(strcmp(argv[i], "--help-manual") == 0) + { + help.HelpType = cmDocumentation::OneManual; GET_OPT_ARGUMENT(help.Argument); GET_OPT_ARGUMENT(help.Filename); - help.HelpForm = this->GetFormFromFilename(help.Filename, - &help.ManSection); + this->WarnFormFromFilename(help, result); } else if(strcmp(argv[i], "--help-command-list") == 0) { - help.HelpType = cmDocumentation::List; + help.HelpType = cmDocumentation::ListCommands; GET_OPT_ARGUMENT(help.Filename); - help.HelpForm = cmDocumentation::TextForm; } else if(strcmp(argv[i], "--help-module-list") == 0) { - help.HelpType = cmDocumentation::ModuleList; + help.HelpType = cmDocumentation::ListModules; GET_OPT_ARGUMENT(help.Filename); - help.HelpForm = cmDocumentation::TextForm; } else if(strcmp(argv[i], "--help-property-list") == 0) { - help.HelpType = cmDocumentation::PropertyList; + help.HelpType = cmDocumentation::ListProperties; GET_OPT_ARGUMENT(help.Filename); - help.HelpForm = cmDocumentation::TextForm; } else if(strcmp(argv[i], "--help-variable-list") == 0) { - help.HelpType = cmDocumentation::VariableList; + help.HelpType = cmDocumentation::ListVariables; + GET_OPT_ARGUMENT(help.Filename); + } + else if(strcmp(argv[i], "--help-policy-list") == 0) + { + help.HelpType = cmDocumentation::ListPolicies; + GET_OPT_ARGUMENT(help.Filename); + } + else if(strcmp(argv[i], "--help-manual-list") == 0) + { + help.HelpType = cmDocumentation::ListManuals; GET_OPT_ARGUMENT(help.Filename); - help.HelpForm = cmDocumentation::TextForm; } else if(strcmp(argv[i], "--copyright") == 0) { - help.HelpType = cmDocumentation::Copyright; GET_OPT_ARGUMENT(help.Filename); - help.HelpForm = cmDocumentation::UsageForm; + cmSystemTools::Message("Warning: --copyright no longer supported"); + return true; } else if((strcmp(argv[i], "--version") == 0) || (strcmp(argv[i], "-version") == 0) || @@ -1268,7 +465,6 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv, { help.HelpType = cmDocumentation::Version; GET_OPT_ARGUMENT(help.Filename); - help.HelpForm = cmDocumentation::UsageForm; } if(help.HelpType != None) { @@ -1281,40 +477,12 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv, } //---------------------------------------------------------------------------- -void cmDocumentation::Print(Form f, int manSection, std::ostream& os) -{ - this->SetForm(f, manSection); - this->Print(os); -} - -//---------------------------------------------------------------------------- -void cmDocumentation::Print(std::ostream& os) -{ - // if the formatter supports it, print a master index for - // all sections - this->CurrentFormatter->PrintIndex(os, this->PrintSections); - for(unsigned int i=0; i < this->PrintSections.size(); ++i) - { - std::string name = this->PrintSections[i]-> - GetName((this->CurrentFormatter->GetForm())); - this->CurrentFormatter->PrintSection(os,*this->PrintSections[i], - name.c_str()); - } -} - -//---------------------------------------------------------------------------- void cmDocumentation::SetName(const char* name) { this->NameString = name?name:""; } //---------------------------------------------------------------------------- -void cmDocumentation::SetDocName(const char *docname) -{ - this->DocName = docname?docname:""; -} - -//---------------------------------------------------------------------------- void cmDocumentation::SetSection(const char *name, cmDocumentationSection *section) { @@ -1338,7 +506,7 @@ void cmDocumentation::SetSection(const char *name, //---------------------------------------------------------------------------- void cmDocumentation::SetSection(const char *name, - const char *docs[][3]) + const char *docs[][2]) { cmDocumentationSection *sec = new cmDocumentationSection(name, @@ -1360,7 +528,7 @@ void cmDocumentation //---------------------------------------------------------------------------- void cmDocumentation::PrependSection(const char *name, - const char *docs[][3]) + const char *docs[][2]) { cmDocumentationSection *sec = 0; if (this->AllSections.find(name) == this->AllSections.end()) @@ -1396,7 +564,7 @@ void cmDocumentation::PrependSection(const char *name, //---------------------------------------------------------------------------- void cmDocumentation::AppendSection(const char *name, - const char *docs[][3]) + const char *docs[][2]) { cmDocumentationSection *sec = 0; if (this->AllSections.find(name) == this->AllSections.end()) @@ -1451,471 +619,243 @@ void cmDocumentation::PrependSection(const char *name, } //---------------------------------------------------------------------------- -void cmDocumentation::SetSeeAlsoList(const char *data[][3]) +void cmDocumentation::GlobHelp(std::vector<std::string>& files, + std::string const& pattern) { - cmDocumentationSection *sec = - new cmDocumentationSection("See Also", "SEE ALSO"); - this->AllSections["See Also"] = sec; - this->SeeAlsoString = ".B "; - int i = 0; - while(data[i][1]) + cmsys::Glob gl; + std::string findExpr = + cmSystemTools::GetCMakeRoot() + "/Help/" + pattern + ".rst"; + if(gl.FindFiles(findExpr)) { - this->SeeAlsoString += data[i][1]; - this->SeeAlsoString += data[i+1][1]? "(1), ":"(1)"; - ++i; + files = gl.GetFiles(); } - sec->Append(0,this->SeeAlsoString.c_str(),0); - sec->Append(cmDocumentationStandardSeeAlso); } //---------------------------------------------------------------------------- -bool cmDocumentation::PrintDocumentationGeneric(std::ostream& os, - const char *section) +void cmDocumentation::PrintNames(std::ostream& os, + std::string const& pattern) { - if(this->AllSections.find(section) == this->AllSections.end()) - { - os << "Internal error: " << section << " list is empty." << std::endl; - return false; - } - if(this->CurrentArgument.length() == 0) - { - os << "Required argument missing.\n"; - return false; - } - const std::vector<cmDocumentationEntry> &entries = - this->AllSections[section]->GetEntries(); - for(std::vector<cmDocumentationEntry>::const_iterator ei = - entries.begin(); - ei != entries.end(); ++ei) + std::vector<std::string> files; + this->GlobHelp(files, pattern); + std::vector<std::string> names; + for (std::vector<std::string>::const_iterator i = files.begin(); + i != files.end(); ++i) { - if(this->CurrentArgument == ei->Name) + std::string line; + cmsys::ifstream fin(i->c_str()); + while(fin && cmSystemTools::GetLineFromStream(fin, line)) { - this->PrintDocumentationCommand(os, *ei); - return true; + if(!line.empty() && (isalnum(line[0]) || line[0] == '<')) + { + names.push_back(line); + break; + } } } - return false; + std::sort(names.begin(), names.end()); + for (std::vector<std::string>::iterator i = names.begin(); + i != names.end(); ++i) + { + os << *i << "\n"; + } } //---------------------------------------------------------------------------- -bool cmDocumentation::PrintDocumentationSingle(std::ostream& os) +bool cmDocumentation::PrintFiles(std::ostream& os, + std::string const& pattern) { - if (this->PrintDocumentationGeneric(os,"Commands")) - { - return true; - } - if (this->PrintDocumentationGeneric(os,"Compatibility Commands")) + bool found = false; + std::vector<std::string> files; + this->GlobHelp(files, pattern); + std::sort(files.begin(), files.end()); + cmRST r(os, cmSystemTools::GetCMakeRoot() + "/Help"); + for (std::vector<std::string>::const_iterator i = files.begin(); + i != files.end(); ++i) { - return true; + found = r.ProcessFile(i->c_str()) || found; } - - // Argument was not a command. Complain. - os << "Argument \"" << this->CurrentArgument.c_str() - << "\" to --help-command is not a CMake command. " - << "Use --help-command-list to see all commands.\n"; - return false; + return found; } //---------------------------------------------------------------------------- -bool cmDocumentation::PrintDocumentationSingleModule(std::ostream& os) +bool cmDocumentation::PrintHelpOneManual(std::ostream& os) { - if(this->CurrentArgument.length() == 0) - { - os << "Argument --help-module needs a module name.\n"; - return false; - } - - std::string moduleName; - // find the module - std::vector<std::string> dirs; - cmSystemTools::ExpandListArgument(this->CMakeModulePath, dirs); - for(std::vector<std::string>::const_iterator dirIt = dirs.begin(); - dirIt != dirs.end(); - ++dirIt) - { - moduleName = *dirIt; - moduleName += "/"; - moduleName += this->CurrentArgument; - moduleName += ".cmake"; - if(cmSystemTools::FileExists(moduleName.c_str())) - { - break; - } - moduleName = ""; - } - - if (moduleName.empty()) + std::string mname = this->CurrentArgument; + std::string::size_type mlen = mname.length(); + if(mlen > 3 && mname[mlen-3] == '(' && + mname[mlen-1] == ')') { - moduleName = this->CMakeRoot; - moduleName += "/Modules/"; - moduleName += this->CurrentArgument; - moduleName += ".cmake"; - if(!cmSystemTools::FileExists(moduleName.c_str())) - { - moduleName = ""; - } + mname = mname.substr(0, mlen-3) + "." + mname[mlen-2]; } - - if(!moduleName.empty()) + if(this->PrintFiles(os, "manual/" + mname) || + this->PrintFiles(os, "manual/" + mname + ".[0-9]")) { - cmDocumentationSection *sec = - new cmDocumentationSection("Standard CMake Modules", "MODULES"); - this->AllSections["Modules"] = sec; - if (this->CreateSingleModule(moduleName.c_str(), - this->CurrentArgument.c_str(), - *this->AllSections["Modules"])) - { - if(this->AllSections["Modules"]->GetEntries().size()) - { - this->PrintDocumentationCommand - (os, this->AllSections["Modules"]->GetEntries()[0]); - os << "\n Defined in: "; - os << moduleName << "\n"; - return true; - } - else - { - return false; - } - } + return true; } - - // Argument was not a module. Complain. + // Argument was not a manual. Complain. os << "Argument \"" << this->CurrentArgument.c_str() - << "\" to --help-module is not a CMake module.\n"; + << "\" to --help-manual is not an available manual. " + << "Use --help-manual-list to see all available manuals.\n"; return false; } //---------------------------------------------------------------------------- -bool cmDocumentation::PrintDocumentationSingleProperty(std::ostream& os) +bool cmDocumentation::PrintHelpListManuals(std::ostream& os) { - bool done = false; - for (std::vector<std::string>::iterator i = - this->PropertySections.begin(); - !done && i != this->PropertySections.end(); ++i) - { - done = this->PrintDocumentationGeneric(os,i->c_str()); - } - - if (done) - { - return true; - } - - // Argument was not a command. Complain. - os << "Argument \"" << this->CurrentArgument.c_str() - << "\" to --help-property is not a CMake property. " - << "Use --help-property-list to see all properties.\n"; - return false; + this->PrintNames(os, "manual/*"); + return true; } //---------------------------------------------------------------------------- -bool cmDocumentation::PrintDocumentationSinglePolicy(std::ostream& os) +bool cmDocumentation::PrintHelpOneCommand(std::ostream& os) { - if (this->PrintDocumentationGeneric(os,"Policies")) + std::string cname = cmSystemTools::LowerCase(this->CurrentArgument); + if(this->PrintFiles(os, "command/" + cname)) { return true; } - // Argument was not a command. Complain. os << "Argument \"" << this->CurrentArgument.c_str() - << "\" to --help-policy is not a CMake policy.\n"; + << "\" to --help-command is not a CMake command. " + << "Use --help-command-list to see all commands.\n"; return false; } //---------------------------------------------------------------------------- -bool cmDocumentation::PrintDocumentationSingleVariable(std::ostream& os) +bool cmDocumentation::PrintHelpListCommands(std::ostream& os) { - bool done = false; - for (std::vector<std::string>::iterator i = - this->VariableSections.begin(); - !done && i != this->VariableSections.end(); ++i) - { - done = this->PrintDocumentationGeneric(os,i->c_str()); - } + this->PrintNames(os, "command/*"); + return true; +} - if (done) +//---------------------------------------------------------------------------- +bool cmDocumentation::PrintHelpOneModule(std::ostream& os) +{ + std::string mname = this->CurrentArgument; + if(this->PrintFiles(os, "module/" + mname)) { return true; } - - // Argument was not a command. Complain. + // Argument was not a module. Complain. os << "Argument \"" << this->CurrentArgument.c_str() - << "\" to --help-variable is not a defined variable. " - << "Use --help-variable-list to see all defined variables.\n"; + << "\" to --help-module is not a CMake module.\n"; return false; } //---------------------------------------------------------------------------- -bool cmDocumentation::PrintDocumentationList(std::ostream& os, - const char *section) +bool cmDocumentation::PrintHelpListModules(std::ostream& os) { - if(this->AllSections.find(section) == this->AllSections.end()) + std::vector<std::string> files; + this->GlobHelp(files, "module/*"); + std::vector<std::string> modules; + for (std::vector<std::string>::iterator fi = files.begin(); + fi != files.end(); ++fi) { - os << "Internal error: " << section << " list is empty." << std::endl; - return false; + std::string module = cmSystemTools::GetFilenameName(*fi); + modules.push_back(module.substr(0, module.size()-4)); } - - const std::vector<cmDocumentationEntry> &entries = - this->AllSections[section]->GetEntries(); - for(std::vector<cmDocumentationEntry>::const_iterator ei = - entries.begin(); - ei != entries.end(); ++ei) + std::sort(modules.begin(), modules.end()); + for (std::vector<std::string>::iterator i = modules.begin(); + i != modules.end(); ++i) { - if(ei->Name.size()) - { - os << ei->Name << std::endl; - } + os << *i << "\n"; } return true; } //---------------------------------------------------------------------------- -bool cmDocumentation::PrintDocumentationUsage(std::ostream& os) +bool cmDocumentation::PrintHelpOneProperty(std::ostream& os) { - this->ClearSections(); - this->AddSectionToPrint("Usage"); - this->AddSectionToPrint("Options"); - if(this->ShowGenerators) + std::string pname = cmSystemTools::HelpFileName(this->CurrentArgument); + if(this->PrintFiles(os, "prop_*/" + pname)) { - this->AddSectionToPrint("Generators"); + return true; } - this->Print(os); - return true; -} - -//---------------------------------------------------------------------------- -bool cmDocumentation::PrintDocumentationFull(std::ostream& os) -{ - this->CreateFullDocumentation(); - this->CurrentFormatter->PrintHeader(GetNameString(), GetNameString(), os); - this->Print(os); - this->CurrentFormatter->PrintFooter(os); - return true; -} - -//---------------------------------------------------------------------------- -bool cmDocumentation::PrintDocumentationModules(std::ostream& os) -{ - this->ClearSections(); - this->CreateModulesSection(); - this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(Modules)); - this->AddSectionToPrint("Description"); - this->AddSectionToPrint("Modules"); - this->AddSectionToPrint("Copyright"); - this->AddSectionToPrint("See Also"); - this->CurrentFormatter->PrintHeader(GetDocName(), GetNameString(), os); - this->Print(os); - this->CurrentFormatter->PrintFooter(os); - return true; + // Argument was not a property. Complain. + os << "Argument \"" << this->CurrentArgument.c_str() + << "\" to --help-property is not a CMake property. " + << "Use --help-property-list to see all properties.\n"; + return false; } //---------------------------------------------------------------------------- -bool cmDocumentation::PrintDocumentationCustomModules(std::ostream& os) +bool cmDocumentation::PrintHelpListProperties(std::ostream& os) { - this->ClearSections(); - this->CreateCustomModulesSection(); - this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(CustomModules)); - this->AddSectionToPrint("Description"); - this->AddSectionToPrint("Custom CMake Modules"); -// the custom modules are most probably not under Kitware's copyright, Alex -// this->AddSectionToPrint("Copyright"); - this->AddSectionToPrint("See Also"); - - this->CurrentFormatter->PrintHeader(GetDocName(), GetNameString(), os); - this->Print(os); - this->CurrentFormatter->PrintFooter(os); + this->PrintNames(os, "prop_*/*"); return true; } //---------------------------------------------------------------------------- -bool cmDocumentation::PrintDocumentationPolicies(std::ostream& os) +bool cmDocumentation::PrintHelpOnePolicy(std::ostream& os) { - this->ClearSections(); - this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(Policies)); - this->AddSectionToPrint("Description"); - this->AddSectionToPrint("Policies"); - this->AddSectionToPrint("Copyright"); - this->AddSectionToPrint("See Also"); + std::string pname = this->CurrentArgument; + std::vector<std::string> files; + if(this->PrintFiles(os, "policy/" + pname)) + { + return true; + } - this->CurrentFormatter->PrintHeader(GetDocName(), GetNameString(), os); - this->Print(os); - this->CurrentFormatter->PrintFooter(os); - return true; + // Argument was not a policy. Complain. + os << "Argument \"" << this->CurrentArgument.c_str() + << "\" to --help-policy is not a CMake policy.\n"; + return false; } //---------------------------------------------------------------------------- -bool cmDocumentation::PrintDocumentationProperties(std::ostream& os) +bool cmDocumentation::PrintHelpListPolicies(std::ostream& os) { - this->ClearSections(); - this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(Properties)); - this->AddSectionToPrint("Properties Description"); - for (std::vector<std::string>::iterator i = - this->PropertySections.begin(); - i != this->PropertySections.end(); ++i) - { - this->AddSectionToPrint(i->c_str()); - } - this->AddSectionToPrint("Copyright"); - this->AddSectionToPrint("Standard See Also"); - this->CurrentFormatter->PrintHeader(GetDocName(), GetNameString(), os); - this->Print(os); - this->CurrentFormatter->PrintFooter(os); + this->PrintNames(os, "policy/*"); return true; } //---------------------------------------------------------------------------- -bool cmDocumentation::PrintDocumentationVariables(std::ostream& os) +bool cmDocumentation::PrintHelpOneVariable(std::ostream& os) { - this->ClearSections(); - this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(Variables)); - for (std::vector<std::string>::iterator i = - this->VariableSections.begin(); - i != this->VariableSections.end(); ++i) + std::string vname = cmSystemTools::HelpFileName(this->CurrentArgument); + if(this->PrintFiles(os, "variable/" + vname)) { - this->AddSectionToPrint(i->c_str()); + return true; } - this->AddSectionToPrint("Copyright"); - this->AddSectionToPrint("Standard See Also"); - this->CurrentFormatter->PrintHeader(GetDocName(), GetNameString(), os); - this->Print(os); - this->CurrentFormatter->PrintFooter(os); - return true; -} - -//---------------------------------------------------------------------------- -bool cmDocumentation::PrintDocumentationCurrentCommands(std::ostream& os) -{ - this->ClearSections(); - this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(Commands)); - this->AddSectionToPrint("Commands"); - this->AddSectionToPrint("Copyright"); - this->AddSectionToPrint("Standard See Also"); - this->CurrentFormatter->PrintHeader(GetDocName(), GetNameString(), os); - this->Print(os); - this->CurrentFormatter->PrintFooter(os); - return true; + // Argument was not a variable. Complain. + os << "Argument \"" << this->CurrentArgument.c_str() + << "\" to --help-variable is not a defined variable. " + << "Use --help-variable-list to see all defined variables.\n"; + return false; } //---------------------------------------------------------------------------- -bool cmDocumentation::PrintDocumentationCompatCommands(std::ostream& os) +bool cmDocumentation::PrintHelpListVariables(std::ostream& os) { - this->ClearSections(); - this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(CompatCommands)); - this->AddSectionToPrint("Compatibility Commands Description"); - this->AddSectionToPrint("Compatibility Commands"); - this->AddSectionToPrint("Copyright"); - this->AddSectionToPrint("Standard See Also"); - this->CurrentFormatter->PrintHeader(GetDocName(), GetNameString(), os); - this->Print(os); - this->CurrentFormatter->PrintFooter(os); + this->PrintNames(os, "variable/*"); return true; } //---------------------------------------------------------------------------- -void cmDocumentation -::PrintDocumentationCommand(std::ostream& os, - const cmDocumentationEntry &entry) -{ - // the string "SingleItem" will be used in a few places to detect the case - // that only the documentation for a single item is printed - cmDocumentationSection *sec = new cmDocumentationSection("SingleItem",""); - sec->Append(entry); - this->AllSections["temp"] = sec; - this->ClearSections(); - this->AddSectionToPrint("temp"); - this->Print(os); - this->AllSections.erase("temp"); - delete sec; -} - -//---------------------------------------------------------------------------- -void cmDocumentation::CreateFullDocumentation() +bool cmDocumentation::PrintDocumentationUsage(std::ostream& os) { - this->ClearSections(); - this->CreateCustomModulesSection(); - this->CreateModulesSection(); - - std::set<std::string> emitted; - this->AddSectionToPrint("Name"); - emitted.insert("Name"); - this->AddSectionToPrint("Usage"); - emitted.insert("Usage"); - this->AddSectionToPrint("Description"); - emitted.insert("Description"); - this->AddSectionToPrint("Options"); - emitted.insert("Options"); - this->AddSectionToPrint("Generators"); - emitted.insert("Generators"); - this->AddSectionToPrint("Commands"); - emitted.insert("Commands"); - - - this->AddSectionToPrint("Properties Description"); - emitted.insert("Properties Description"); - for (std::vector<std::string>::iterator i = - this->PropertySections.begin(); - i != this->PropertySections.end(); ++i) + std::map<std::string,cmDocumentationSection*>::iterator si; + si = this->AllSections.find("Usage"); + if(si != this->AllSections.end()) { - this->AddSectionToPrint(i->c_str()); - emitted.insert(i->c_str()); + this->Formatter.PrintSection(os, *si->second); } - - emitted.insert("Copyright"); - emitted.insert("See Also"); - emitted.insert("Standard See Also"); - emitted.insert("Author"); - - // add any sections not yet written out, or to be written out - for (std::map<std::string, cmDocumentationSection*>::iterator i = - this->AllSections.begin(); - i != this->AllSections.end(); ++i) + si = this->AllSections.find("Options"); + if(si != this->AllSections.end()) { - if (emitted.find(i->first) == emitted.end()) - { - this->AddSectionToPrint(i->first.c_str()); - } + this->Formatter.PrintSection(os, *si->second); } - - this->AddSectionToPrint("Copyright"); - - if(this->CurrentFormatter->GetForm() == ManForm) - { - this->AddSectionToPrint("See Also"); - this->AddSectionToPrint("Author"); - } - else + if(this->ShowGenerators) { - this->AddSectionToPrint("Standard See Also"); + si = this->AllSections.find("Generators"); + if(si != this->AllSections.end()) + { + this->Formatter.PrintSection(os, *si->second); + } } + return true; } //---------------------------------------------------------------------------- -void cmDocumentation::SetForm(Form f, int manSection) -{ - switch(f) - { - case HTMLForm: - this->CurrentFormatter = &this->HTMLFormatter; - break; - case DocbookForm: - this->CurrentFormatter = &this->DocbookFormatter; - break; - case ManForm: - this->ManFormatter.SetManSection(manSection); - this->CurrentFormatter = &this->ManFormatter; - break; - case TextForm: - this->CurrentFormatter = &this->TextFormatter; - break; - case UsageForm: - this->CurrentFormatter = & this->UsageFormatter; - break; - } -} - - -//---------------------------------------------------------------------------- const char* cmDocumentation::GetNameString() const { if(this->NameString.length() > 0) @@ -1929,43 +869,53 @@ const char* cmDocumentation::GetNameString() const } //---------------------------------------------------------------------------- -const char* cmDocumentation::GetDocName(bool fallbackToNameString) const +bool cmDocumentation::IsOption(const char* arg) const { - if (this->DocName.length() > 0) - { - return this->DocName.c_str(); - } - else if (fallbackToNameString) - { - return this->GetNameString(); - } - else - return 0; + return ((arg[0] == '-') || (strcmp(arg, "/V") == 0) || + (strcmp(arg, "/?") == 0)); } //---------------------------------------------------------------------------- -#define CASE_DEFAULT_DOCNAME(doctype) \ - case cmDocumentation::doctype : \ - return GET_DOCUMENT_INTRO(doctype)[0]; -const char* cmDocumentation::GetDefaultDocName(Type ht) const -{ - switch (ht) +bool cmDocumentation::PrintOldCustomModules(std::ostream& os) +{ + // CheckOptions abuses the Argument field to give us the file name. + std::string filename = this->CurrentArgument; + std::string ext = cmSystemTools::UpperCase( + cmSystemTools::GetFilenameLastExtension(filename)); + std::string name = cmSystemTools::GetFilenameWithoutLastExtension(filename); + + const char* summary = "cmake --help-custom-modules no longer supported\n"; + const char* detail = + "CMake versions prior to 3.0 exposed their internal module help page\n" + "generation functionality through the --help-custom-modules option.\n" + "CMake versions 3.0 and above use other means to generate their module\n" + "help pages so this functionality is no longer available to be exposed.\n" + "\n" + "This file was generated as a placeholder to provide this information.\n" + ; + if((ext == ".HTM") || (ext == ".HTML")) + { + os << "<html><title>" << name << "</title><body>\n" + << summary << "<p/>\n" << detail << "</body></html>\n"; + } + else if((ext.length()==2) && (ext[1] >='1') && (ext[1]<='9')) + { + os << + ".TH " << name << " " << ext[1] << " \"" << + cmSystemTools::GetCurrentDateTime("%B %d, %Y") << + "\" \"cmake " << cmVersion::GetCMakeVersion() << "\"\n" + ".SH NAME\n" + ".PP\n" << + name << " \\- " << summary << + "\n" + ".SH DESCRIPTION\n" + ".PP\n" << + detail + ; + } + else { - CASE_DEFAULT_DOCNAME(Modules) - CASE_DEFAULT_DOCNAME(CustomModules) - CASE_DEFAULT_DOCNAME(Policies) - CASE_DEFAULT_DOCNAME(Properties) - CASE_DEFAULT_DOCNAME(Variables) - CASE_DEFAULT_DOCNAME(Commands) - CASE_DEFAULT_DOCNAME(CompatCommands) - default: break; + os << name << "\n\n" << summary << "\n" << detail; } - return 0; -} - -//---------------------------------------------------------------------------- -bool cmDocumentation::IsOption(const char* arg) const -{ - return ((arg[0] == '-') || (strcmp(arg, "/V") == 0) || - (strcmp(arg, "/?") == 0)); + return true; } diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h index e180f60..d5a7dd5 100644 --- a/Source/cmDocumentation.h +++ b/Source/cmDocumentation.h @@ -15,11 +15,6 @@ #include "cmStandardIncludes.h" #include "cmProperty.h" #include "cmDocumentationFormatter.h" -#include "cmDocumentationFormatterHTML.h" -#include "cmDocumentationFormatterDocbook.h" -#include "cmDocumentationFormatterMan.h" -#include "cmDocumentationFormatterText.h" -#include "cmDocumentationFormatterUsage.h" #include "cmDocumentationSection.h" #include "cmake.h" @@ -37,22 +32,6 @@ public: ~cmDocumentation(); /** - * An helper type pair for [structured] documented modules. - * The comment of those module contains structure markup - * which makes it possible to retrieve the documentation - * of variables, macros and functions defined in the module. - * - first is the filename of the module - * - second is the section of the doc the module belongs too - */ - typedef std::pair<std::string,std::string> documentedModuleSectionPair_t; - /** - * A list of documented module(s). - */ - typedef std::list<documentedModuleSectionPair_t> documentedModulesList_t; - - // High-level interface for standard documents: - - /** * Check command line arguments for documentation options. Returns * true if documentation options are found, and false otherwise. * When true is returned, PrintRequestedDocumentation should be @@ -72,7 +51,7 @@ public: bool PrintRequestedDocumentation(std::ostream& os); /** Print help of the given type. */ - bool PrintDocumentation(Type ht, std::ostream& os, const char* docname=0); + bool PrintDocumentation(Type ht, std::ostream& os); void SetShowGenerators(bool showGen) { this->ShowGenerators = showGen; } @@ -80,62 +59,30 @@ public: void SetName(const char* name); /** Set a section of the documentation. Typical sections include Name, - Usage, Description, Options, SeeAlso */ + Usage, Description, Options */ void SetSection(const char *sectionName, cmDocumentationSection *section); void SetSection(const char *sectionName, std::vector<cmDocumentationEntry> &docs); void SetSection(const char *sectionName, - const char *docs[][3]); + const char *docs[][2]); void SetSections(std::map<std::string,cmDocumentationSection *> §ions); /** Add the documentation to the beginning/end of the section */ void PrependSection(const char *sectionName, - const char *docs[][3]); + const char *docs[][2]); void PrependSection(const char *sectionName, std::vector<cmDocumentationEntry> &docs); void PrependSection(const char *sectionName, cmDocumentationEntry &docs); void AppendSection(const char *sectionName, - const char *docs[][3]); + const char *docs[][2]); void AppendSection(const char *sectionName, std::vector<cmDocumentationEntry> &docs); void AppendSection(const char *sectionName, cmDocumentationEntry &docs); - /** - * Print documentation in the given form. All previously added - * sections will be generated. - */ - void Print(Form f, int manSection, std::ostream& os); - - /** - * Print documentation in the current form. All previously added - * sections will be generated. - */ - void Print(std::ostream& os); - - /** - * Add a section of documentation. This can be used to generate custom help - * documents. - */ - void AddSectionToPrint(const char *section); - - void SetSeeAlsoList(const char *data[][3]); - - /** Clear all previously added sections of help. */ - void ClearSections(); - - /** Set cmake root so we can find installed files */ - void SetCMakeRoot(const char* root) { this->CMakeRoot = root;} - - /** Set CMAKE_MODULE_PATH so we can find additional cmake modules */ - void SetCMakeModulePath(const char* path) { this->CMakeModulePath = path;} - - static Form GetFormFromFilename(const std::string& filename, - int* ManSection); - /** Add common (to all tools) documentation section(s) */ void addCommonStandardDocSections(); @@ -148,124 +95,50 @@ public: /** Add the CPack standard documentation section(s) */ void addCPackStandardDocSections(); - /** Add automatic variables sections */ - void addAutomaticVariableSections(const std::string& section); - - /** - * Retrieve the list of documented module located in - * path which match the globing expression globExpr. - * @param[in] path, directory where to start the search - * we will recurse into it. - * @param[in] globExpr, the globing expression used to - * match the file in path. - * @param[out] the list of obtained pairs (may be empty) - * @return 0 on success 1 on error or empty list - */ - int getDocumentedModulesListInDir( - std::string path, - std::string globExpr, - documentedModulesList_t& docModuleList); - - /** - * Get the documentation of macros, functions and variable documented - * with CMake structured documentation in a CMake script. - * (in fact it may be in any file which follow the structured doc format) - * Structured documentation begin with - * ## (double sharp) in column 1 & 2 immediately followed - * by a markup. Those ## are ignored by the legacy module - * documentation parser @see CreateSingleModule. - * Current markup are ##section, ##module, - * ##macro, ##function, ##variable and ##end. - * ##end is closing either of the previous ones. - * @param[in] fname the script file name to be parsed for documentation - * @param[in,out] commands the vector of command/macros documentation - * entry found in the script file. - * @param[in,out] the cmake object instance to which variable documentation - * will be attached (using @see cmake::DefineProperty) - * @param[in] the documentation section in which the property will be - * inserted. - * @return the number of documented items (command and variable) - * found in the file. - */ - int GetStructuredDocFromFile(const char* fname, - std::vector<cmDocumentationEntry>& commands, - cmake* cm); private: - void SetForm(Form f, int manSection); - void SetDocName(const char* docname); - - bool CreateSingleModule(const char* fname, - const char* moduleName, - cmDocumentationSection &sec); - void CreateModuleDocsForDir(cmsys::Directory& dir, - cmDocumentationSection &moduleSection); - bool CreateModulesSection(); - bool CreateCustomModulesSection(); - void CreateFullDocumentation(); - void AddDocumentIntroToPrint(const char* intro[2]); + void GlobHelp(std::vector<std::string>& files, std::string const& pattern); + void PrintNames(std::ostream& os, std::string const& pattern); + bool PrintFiles(std::ostream& os, std::string const& pattern); - bool PrintCopyright(std::ostream& os); bool PrintVersion(std::ostream& os); - bool PrintDocumentationGeneric(std::ostream& os, const char *section); - bool PrintDocumentationList(std::ostream& os, const char *section); - bool PrintDocumentationSingle(std::ostream& os); - bool PrintDocumentationSingleModule(std::ostream& os); - bool PrintDocumentationSingleProperty(std::ostream& os); - bool PrintDocumentationSinglePolicy(std::ostream& os); - bool PrintDocumentationSingleVariable(std::ostream& os); + bool PrintHelpOneManual(std::ostream& os); + bool PrintHelpOneCommand(std::ostream& os); + bool PrintHelpOneModule(std::ostream& os); + bool PrintHelpOnePolicy(std::ostream& os); + bool PrintHelpOneProperty(std::ostream& os); + bool PrintHelpOneVariable(std::ostream& os); + bool PrintHelpListManuals(std::ostream& os); + bool PrintHelpListCommands(std::ostream& os); + bool PrintHelpListModules(std::ostream& os); + bool PrintHelpListProperties(std::ostream& os); + bool PrintHelpListVariables(std::ostream& os); + bool PrintHelpListPolicies(std::ostream& os); bool PrintDocumentationUsage(std::ostream& os); - bool PrintDocumentationFull(std::ostream& os); - bool PrintDocumentationModules(std::ostream& os); - bool PrintDocumentationCustomModules(std::ostream& os); - bool PrintDocumentationPolicies(std::ostream& os); - bool PrintDocumentationProperties(std::ostream& os); - bool PrintDocumentationVariables(std::ostream& os); - bool PrintDocumentationCurrentCommands(std::ostream& os); - bool PrintDocumentationCompatCommands(std::ostream& os); - void PrintDocumentationCommand(std::ostream& os, - const cmDocumentationEntry &entry); - + bool PrintOldCustomModules(std::ostream& os); const char* GetNameString() const; - const char* GetDocName(bool fallbackToNameString = true) const; - const char* GetDefaultDocName(Type ht) const; bool IsOption(const char* arg) const; bool ShowGenerators; std::string NameString; - std::string DocName; std::map<std::string,cmDocumentationSection*> AllSections; - std::string SeeAlsoString; - std::string CMakeRoot; - std::string CMakeModulePath; - std::set<std::string> ModulesFound; - std::vector< char* > ModuleStrings; - std::vector<const cmDocumentationSection *> PrintSections; std::string CurrentArgument; struct RequestedHelpItem { - RequestedHelpItem():HelpForm(TextForm), HelpType(None), ManSection(1) {} - cmDocumentationEnums::Form HelpForm; + RequestedHelpItem(): HelpType(None) {} cmDocumentationEnums::Type HelpType; std::string Filename; std::string Argument; - int ManSection; }; std::vector<RequestedHelpItem> RequestedHelpItems; - cmDocumentationFormatter* CurrentFormatter; - cmDocumentationFormatterHTML HTMLFormatter; - cmDocumentationFormatterDocbook DocbookFormatter; - cmDocumentationFormatterMan ManFormatter; - cmDocumentationFormatterText TextFormatter; - cmDocumentationFormatterUsage UsageFormatter; + cmDocumentationFormatter Formatter; - std::vector<std::string> PropertySections; - std::vector<std::string> VariableSections; + static void WarnFormFromFilename(RequestedHelpItem& request, bool& result); }; #endif diff --git a/Source/cmDocumentationFormatter.cxx b/Source/cmDocumentationFormatter.cxx index 9f01949..29c806d 100644 --- a/Source/cmDocumentationFormatter.cxx +++ b/Source/cmDocumentationFormatter.cxx @@ -11,7 +11,10 @@ ============================================================================*/ #include "cmDocumentationFormatter.h" -cmDocumentationFormatter::cmDocumentationFormatter() +#include "cmDocumentationSection.h" + +cmDocumentationFormatter::cmDocumentationFormatter(): + TextWidth(77), TextIndent("") { } @@ -66,91 +69,162 @@ void cmDocumentationFormatter::PrintFormatted(std::ostream& os, } } -//---------------------------------------------------------------------------- -std::string -cmDocumentationFormatter::ComputeSectionLinkPrefix(std::string const& name) +void cmDocumentationFormatter::PrintPreformatted(std::ostream& os, + const char* text) { - // Map from section name to a prefix for links pointing within the - // section. For example, the commands section should have HTML - // links to each command with names like #command:ADD_EXECUTABLE. - if(name.find("Command") != name.npos) - { - return "command"; - } - else if(name.find("Propert") != name.npos) + bool newline = true; + for(const char* ptr = text; *ptr; ++ptr) { - if(name.find("Global") != name.npos) - { - return "prop_global"; - } - else if(name.find("Direct") != name.npos) + if(newline && *ptr != '\n') { - return "prop_dir"; + os << this->TextIndent; + newline = false; } - else if(name.find("Target") != name.npos) + os << *ptr; + if(*ptr == '\n') { - return "prop_tgt"; + newline = true; } - else if(name.find("Test") != name.npos) + } + os << "\n"; +} + +void cmDocumentationFormatter::PrintParagraph(std::ostream& os, + const char* text) +{ + os << this->TextIndent; + this->PrintColumn(os, text); + os << "\n"; +} + +void cmDocumentationFormatter::SetIndent(const char* indent) +{ + this->TextIndent = indent; +} + +void cmDocumentationFormatter::PrintColumn(std::ostream& os, + const char* text) +{ + // Print text arranged in an indented column of fixed witdh. + const char* l = text; + long column = 0; + bool newSentence = false; + bool firstLine = true; + int width = this->TextWidth - static_cast<int>(strlen(this->TextIndent)); + + // Loop until the end of the text. + while(*l) + { + // Parse the next word. + const char* r = l; + while(*r && (*r != '\n') && (*r != ' ')) { ++r; } + + // Does it fit on this line? + if(r-l < (width-column-(newSentence?1:0))) { - return "prop_test"; + // Word fits on this line. + if(r > l) + { + if(column) + { + // Not first word on line. Separate from the previous word + // by a space, or two if this is a new sentence. + if(newSentence) + { + os << " "; + column += 2; + } + else + { + os << " "; + column += 1; + } + } + else + { + // First word on line. Print indentation unless this is the + // first line. + os << (firstLine?"":this->TextIndent); + } + + // Print the word. + os.write(l, static_cast<long>(r-l)); + newSentence = (*(r-1) == '.'); + } + + if(*r == '\n') + { + // Text provided a newline. Start a new line. + os << "\n"; + ++r; + column = 0; + firstLine = false; + } + else + { + // No provided newline. Continue this line. + column += static_cast<long>(r-l); + } } - else if(name.find("Source") != name.npos) + else { - return "prop_sf"; + // Word does not fit on this line. Start a new line. + os << "\n"; + firstLine = false; + if(r > l) + { + os << this->TextIndent; + os.write(l, static_cast<long>(r-l)); + column = static_cast<long>(r-l); + newSentence = (*(r-1) == '.'); + } + else + { + column = 0; + } } - return "property"; - } - else if(name.find("Variable") != name.npos) - { - return "variable"; - } - else if(name.find("Polic") != name.npos) - { - return "policy"; - } - else if(name.find("Module") != name.npos) - { - return "module"; - } - else if(name.find("Name") != name.npos || - name.find("Introduction") != name.npos) - { - return "name"; - } - else if(name.find("Usage") != name.npos) - { - return "usage"; - } - else if(name.find("Description") != name.npos) - { - return "desc"; - } - else if(name.find("Generators") != name.npos) - { - return "gen"; - } - else if(name.find("Options") != name.npos) - { - return "opt"; - } - else if(name.find("Copyright") != name.npos) - { - return "copy"; - } - else if(name.find("See Also") != name.npos) - { - return "see"; - } - else if(name.find("SingleItem") != name.npos) - { - return "single_item"; + + // Move to beginning of next word. Skip over whitespace. + l = r; + while(*l && (*l == ' ')) { ++l; } } - else +} + +void cmDocumentationFormatter +::PrintSection(std::ostream& os, + cmDocumentationSection const& section) +{ + os << section.GetName() << "\n"; + + const std::vector<cmDocumentationEntry> &entries = + section.GetEntries(); + for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin(); + op != entries.end(); ++op) { - std::cerr - << "WARNING: ComputeSectionLinkPrefix failed for \"" << name << "\"" - << std::endl; - return "other"; + if(op->Name.size()) + { + os << " " << op->Name; + this->TextIndent = " "; + int align = static_cast<int>(strlen(this->TextIndent))-4; + for(int i = static_cast<int>(op->Name.size()); i < align; ++i) + { + os << " "; + } + if (op->Name.size() > strlen(this->TextIndent)-4 ) + { + os << "\n"; + os.write(this->TextIndent, strlen(this->TextIndent)-2); + } + os << "= "; + this->PrintColumn(os, op->Brief.c_str()); + os << "\n"; + } + else + { + os << "\n"; + this->TextIndent = ""; + this->PrintFormatted(os, op->Brief.c_str()); + } } + os << "\n"; } diff --git a/Source/cmDocumentationFormatter.h b/Source/cmDocumentationFormatter.h index 665b9b6..118f03d 100644 --- a/Source/cmDocumentationFormatter.h +++ b/Source/cmDocumentationFormatter.h @@ -25,19 +25,17 @@ class cmDocumentationEnums public: /** Types of help provided. */ enum Type - { None, Usage, Single, SingleModule, SingleProperty, SingleVariable, - List, ModuleList, PropertyList, VariableList, - Full, Properties, Variables, Modules, CustomModules, Commands, - CompatCommands, Copyright, Version, Policies, SinglePolicy }; - - /** Forms of documentation output. */ - enum Form { TextForm, HTMLForm, ManForm, UsageForm, DocbookForm }; + { + None, Version, Usage, ListManuals, + ListCommands, ListModules, ListProperties, ListVariables, ListPolicies, + OneManual, OneCommand, OneModule, OneProperty, OneVariable, OnePolicy, + OldCustomModules + }; }; class cmDocumentationSection; -/** Base class for printing the documentation in the various supported - formats. */ +/** Print documentation in a simple text format. */ class cmDocumentationFormatter { public: @@ -45,23 +43,15 @@ public: virtual ~cmDocumentationFormatter(); void PrintFormatted(std::ostream& os, const char* text); - virtual cmDocumentationEnums::Form GetForm() const = 0; - - virtual void PrintHeader(const char* /*docname*/, - const char* /*appname*/, - std::ostream& /*os*/) {} - virtual void PrintFooter(std::ostream& /*os*/) {} virtual void PrintSection(std::ostream& os, - const cmDocumentationSection& section, - const char* name) = 0; - virtual void PrintPreformatted(std::ostream& os, const char* text) = 0; - virtual void PrintParagraph(std::ostream& os, const char* text) = 0; - virtual void PrintIndex(std::ostream& , - std::vector<const cmDocumentationSection *>&) - {} - - /** Compute a prefix for links into a section (#\<prefix\>_SOMETHING). */ - std::string ComputeSectionLinkPrefix(std::string const& name); + cmDocumentationSection const& section); + virtual void PrintPreformatted(std::ostream& os, const char* text); + virtual void PrintParagraph(std::ostream& os, const char* text); + void PrintColumn(std::ostream& os, const char* text); + void SetIndent(const char* indent); +private: + int TextWidth; + const char* TextIndent; }; #endif diff --git a/Source/cmDocumentationFormatterDocbook.cxx b/Source/cmDocumentationFormatterDocbook.cxx deleted file mode 100644 index 706ce0a..0000000 --- a/Source/cmDocumentationFormatterDocbook.cxx +++ /dev/null @@ -1,254 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#include "cmDocumentationFormatterDocbook.h" -#include "cmDocumentationSection.h" -#include <algorithm> -#include <ctype.h> // for isalnum - -static int cmIsAlnum(int c) -{ - return isalnum(c); -} - -//---------------------------------------------------------------------------- - -// this function is a copy of the one in the HTML formatter -// the three functions below are slightly modified copies -static bool cmDocumentationIsHyperlinkCharDocbook(char c) -{ - // This is not a complete list but works for CMake documentation. - return ((c >= 'A' && c <= 'Z') || - (c >= 'a' && c <= 'z') || - (c >= '0' && c <= '9') || - c == '-' || c == '.' || c == '/' || c == '~' || c == '@' || - c == ':' || c == '_' || c == '&' || c == '?' || c == '='); -} - -//---------------------------------------------------------------------------- -static void cmDocumentationPrintDocbookChar(std::ostream& os, char c) -{ - // Use an escape sequence if necessary. - switch(c) - { - case '<': - os << "<"; - break; - case '>': - os << ">"; - break; - case '&': - os << "&"; - break; - default: - os << c; - } -} - -//---------------------------------------------------------------------------- -const char* cmDocumentationPrintDocbookLink(std::ostream& os,const char* begin) -{ - // Look for the end of the link. - const char* end = begin; - while(cmDocumentationIsHyperlinkCharDocbook(*end)) - { - ++end; - } - - // Print the hyperlink itself. - os << "<ulink url=\""; - for(const char* c = begin; c != end; ++c) - { - cmDocumentationPrintDocbookChar(os, *c); - } - os << "\" />"; - - return end; -} - -//---------------------------------------------------------------------------- -void cmDocumentationPrintDocbookEscapes(std::ostream& os, const char* text) -{ - // Hyperlink prefixes. - static const char* hyperlinks[] = {"http://", "ftp://", "mailto:", 0}; - - // Print each character. - for(const char* p = text; *p;) - { - // Handle hyperlinks specially to make them active. - bool found_hyperlink = false; - for(const char** h = hyperlinks; !found_hyperlink && *h; ++h) - { - if(strncmp(p, *h, strlen(*h)) == 0) - { - p = cmDocumentationPrintDocbookLink(os, p); - found_hyperlink = true; - } - } - - // Print other characters normally. - if(!found_hyperlink) - { - cmDocumentationPrintDocbookChar(os, *p++); - } - } -} - -//---------------------------------------------------------------------------- -cmDocumentationFormatterDocbook::cmDocumentationFormatterDocbook() -:cmDocumentationFormatter() -{ -} - -//---------------------------------------------------------------------------- -void cmDocumentationFormatterDocbook -::PrintSection(std::ostream& os, - const cmDocumentationSection §ion, - const char* name) -{ - os << "<sect1 id=\""; - this->PrintId(os, 0, name); - os << "\">\n<title>" << name << "</title>\n"; - - std::string prefix = this->ComputeSectionLinkPrefix(name); - const std::vector<cmDocumentationEntry> &entries = section.GetEntries(); - - bool hasSubSections = false; - for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin(); - op != entries.end(); ++op) - { - if(op->Name.size()) - { - hasSubSections = true; - break; - } - } - - bool inAbstract = false; - for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin(); - op != entries.end(); ++op) - { - if(op->Name.size()) - { - if(inAbstract) - { - os << "</abstract>\n"; - inAbstract = false; - } - os << "<sect2 id=\""; - this->PrintId(os, prefix.c_str(), op->Name); - os << "\">\n<title>"; - cmDocumentationPrintDocbookEscapes(os, op->Name.c_str()); - os << "</title>\n"; - if(op->Full.size()) - { - os << "<abstract>\n<para>"; - cmDocumentationPrintDocbookEscapes(os, op->Brief.c_str()); - os << "</para>\n</abstract>\n"; - this->PrintFormatted(os, op->Full.c_str()); - } - else - { - this->PrintFormatted(os, op->Brief.c_str()); - } - os << "</sect2>\n"; - } - else - { - if(hasSubSections && op == entries.begin()) - { - os << "<abstract>\n"; - inAbstract = true; - } - this->PrintFormatted(os, op->Brief.c_str()); - } - } - - // empty sections are not allowed in docbook. - if(entries.empty()) - { - os << "<para/>\n"; - } - - os << "</sect1>\n"; -} - -//---------------------------------------------------------------------------- -void cmDocumentationFormatterDocbook -::PrintPreformatted(std::ostream& os, const char* text) -{ - os << "<para>\n<programlisting>"; - cmDocumentationPrintDocbookEscapes(os, text); - os << "</programlisting>\n</para>\n"; -} - -void cmDocumentationFormatterDocbook -::PrintParagraph(std::ostream& os, const char* text) -{ - os << "<para>"; - cmDocumentationPrintDocbookEscapes(os, text); - os << "</para>\n"; -} - -//---------------------------------------------------------------------------- -void cmDocumentationFormatterDocbook -::PrintHeader(const char* docname, const char* appname, std::ostream& os) -{ - this->Docname = docname; - - // this one is used to ensure that we don't create multiple link targets - // with the same name. We can clear it here since we are at the - // start of a document here. - this->EmittedLinkIds.clear(); - - os << "<?xml version=\"1.0\" ?>\n" - "<!DOCTYPE article PUBLIC \"-//OASIS//DTD DocBook V4.5//EN\" " - "\"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd\" [\n" - "<!ENTITY % addindex \"IGNORE\">\n" - "<!ENTITY % English \"INCLUDE\"> ]>\n" - "<article>\n" - "<articleinfo>\n" - "<title>" << docname << " - " << appname << "</title>\n" - "</articleinfo>\n"; -} - -//---------------------------------------------------------------------------- -void cmDocumentationFormatterDocbook::PrintFooter(std::ostream& os) -{ - os << "</article>\n"; -} - -//---------------------------------------------------------------------------- -void cmDocumentationFormatterDocbook -::PrintId(std::ostream& os, const char* prefix, std::string id) -{ - std::replace_if(id.begin(), id.end(), - std::not1(std::ptr_fun(cmIsAlnum)), '_'); - if(prefix) - { - id = std::string(prefix) + "." + id; - } - os << this->Docname << '.' << id; - - // make sure that each id exists only once. Since it seems - // not easily possible to determine which link refers to which id, - // we have at least to make sure that the duplicated id's get a - // different name (by appending an increasing number), Alex - if (this->EmittedLinkIds.find(id) == this->EmittedLinkIds.end()) - { - this->EmittedLinkIds.insert(id); - } - else - { - static unsigned int i=0; - os << i++; - } -} diff --git a/Source/cmDocumentationFormatterDocbook.h b/Source/cmDocumentationFormatterDocbook.h deleted file mode 100644 index 0352d34..0000000 --- a/Source/cmDocumentationFormatterDocbook.h +++ /dev/null @@ -1,43 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#ifndef _cmDocumentationFormatterDocbook_h -#define _cmDocumentationFormatterDocbook_h - -#include "cmStandardIncludes.h" - -#include "cmDocumentationFormatter.h" - -/** Class to print the documentation as Docbook. - http://www.oasis-open.org/docbook/xml/4.2/ */ -class cmDocumentationFormatterDocbook : public cmDocumentationFormatter -{ -public: - cmDocumentationFormatterDocbook(); - - virtual cmDocumentationEnums::Form GetForm() const - { return cmDocumentationEnums::DocbookForm;} - - virtual void PrintHeader(const char* docname, const char* appname, - std::ostream& os); - virtual void PrintFooter(std::ostream& os); - virtual void PrintSection(std::ostream& os, - const cmDocumentationSection& section, - const char* name); - virtual void PrintPreformatted(std::ostream& os, const char* text); - virtual void PrintParagraph(std::ostream& os, const char* text); -private: - void PrintId(std::ostream& os, const char* prefix, std::string id); - std::set<std::string> EmittedLinkIds; - std::string Docname; -}; - -#endif diff --git a/Source/cmDocumentationFormatterHTML.cxx b/Source/cmDocumentationFormatterHTML.cxx deleted file mode 100644 index 7213b43..0000000 --- a/Source/cmDocumentationFormatterHTML.cxx +++ /dev/null @@ -1,288 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#include "cmDocumentationFormatterHTML.h" -#include "cmDocumentationSection.h" -#include "cmVersion.h" -//---------------------------------------------------------------------------- -static bool cmDocumentationIsHyperlinkChar(char c) -{ - // This is not a complete list but works for CMake documentation. - return ((c >= 'A' && c <= 'Z') || - (c >= 'a' && c <= 'z') || - (c >= '0' && c <= '9') || - c == '-' || c == '.' || c == '/' || c == '~' || c == '@' || - c == ':' || c == '_' || c == '&' || c == '?' || c == '='); -} - -//---------------------------------------------------------------------------- -static void cmDocumentationPrintHTMLChar(std::ostream& os, char c) -{ - // Use an escape sequence if necessary. - switch (c) - { - case '<': - os << "<"; - break; - case '>': - os << ">"; - break; - case '&': - os << "&"; - break; - case '\n': - os << "<br />"; - break; - default: - os << c; - } -} - -//---------------------------------------------------------------------------- -bool cmDocumentationHTMLIsIdChar(char c) -{ - // From the HTML specification: - // ID and NAME tokens must begin with a letter ([A-Za-z]) and may - // be followed by any number of letters, digits ([0-9]), hyphens - // ("-"), underscores ("_"), colons (":"), and periods ("."). - return ((c >= 'A' && c <= 'Z') || - (c >= 'a' && c <= 'z') || - (c >= '0' && c <= '9') || - c == '-' || c == '_' || c == ':' || c == '.'); -} - -//---------------------------------------------------------------------------- -void cmDocumentationPrintHTMLId(std::ostream& os, const char* begin) -{ - for(const char* c = begin; *c; ++c) - { - if(cmDocumentationHTMLIsIdChar(*c)) - { - os << *c; - } - } -} - -//---------------------------------------------------------------------------- -const char* cmDocumentationPrintHTMLLink(std::ostream& os, const char* begin) -{ - // Look for the end of the link. - const char* end = begin; - while(cmDocumentationIsHyperlinkChar(*end)) - { - ++end; - } - - // Print the hyperlink itself. - os << "<a href=\""; - for(const char* c = begin; c != end; ++c) - { - cmDocumentationPrintHTMLChar(os, *c); - } - os << "\">"; - - // The name of the hyperlink is the text itself. - for(const char* c = begin; c != end; ++c) - { - cmDocumentationPrintHTMLChar(os, *c); - } - os << "</a>"; - - // Return the position at which to continue scanning the input - // string. - return end; -} - - -cmDocumentationFormatterHTML::cmDocumentationFormatterHTML() -:cmDocumentationFormatter() -{ -} - -void cmDocumentationFormatterHTML -::PrintSection(std::ostream& os, - const cmDocumentationSection §ion, - const char* name) -{ - std::string prefix = this->ComputeSectionLinkPrefix(name); - - const std::vector<cmDocumentationEntry> &entries = - section.GetEntries(); - - // skip the index if the help for only a single item (--help-command, - // --help-policy, --help-property, --help-module) is printed - bool isSingleItemHelp = ((name!=0) && (strcmp(name, "SingleItem")==0)); - - if (!isSingleItemHelp) - { - if (name) - { - os << "<h2><a name=\"section_"; - cmDocumentationPrintHTMLId(os, name); - os << "\"></a>" << name << "</h2>\n"; - } - - // Is a list needed? - for(std::vector<cmDocumentationEntry>::const_iterator op - = entries.begin(); op != entries.end(); ++ op ) - { - if (op->Name.size()) - { - os << "<ul>\n"; - for(;op != entries.end() && op->Name.size(); ++op) - { - if(op->Name.size()) - { - os << " <li><a href=\"#" << prefix << ":"; - cmDocumentationPrintHTMLId(os, op->Name.c_str()); - os << "\"><b><code>"; - this->PrintHTMLEscapes(os, op->Name.c_str()); - os << "</code></b></a></li>\n"; - } - } - os << "</ul>\n" ; - break; // Skip outer loop termination test - } - } - } - - for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin(); - op != entries.end();) - { - if(op->Name.size()) - { - os << "<ul>\n"; - for(;op != entries.end() && op->Name.size(); ++op) - { - os << " <li>\n"; - if(op->Name.size()) - { - os << " <a name=\"" << prefix << ":"; - cmDocumentationPrintHTMLId(os, op->Name.c_str()); - os << "\"></a><b><code>"; - this->PrintHTMLEscapes(os, op->Name.c_str()); - os << "</code></b>: "; - } - this->PrintHTMLEscapes(os, op->Brief.c_str()); - if(op->Full.size()) - { - os << "<br />\n "; - this->PrintFormatted(os, op->Full.c_str()); - } - os << "\n"; - os << " </li>\n"; - } - os << "</ul>\n"; - } - else - { - this->PrintFormatted(os, op->Brief.c_str()); - os << "\n"; - ++op; - } - } -} - -void cmDocumentationFormatterHTML::PrintPreformatted(std::ostream& os, - const char* text) -{ - os << "<pre>"; - this->PrintHTMLEscapes(os, text); - os << "</pre>\n "; -} - -void cmDocumentationFormatterHTML::PrintParagraph(std::ostream& os, - const char* text) -{ - os << "<p>"; - this->PrintHTMLEscapes(os, text); - os << "</p>\n"; -} - -//---------------------------------------------------------------------------- -void cmDocumentationFormatterHTML::PrintHeader(const char* docname, - const char* appname, - std::ostream& os) -{ - os << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"" - << " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"; - os << "<html xmlns=\"http://www.w3.org/1999/xhtml\"" - << " xml:lang=\"en\" lang=\"en\">\n"; - os << "<head><meta http-equiv=\"Content-Type\" " - << "content=\"text/html;charset=utf-8\" /><title>"; - os << docname << " - " << appname; - os << "</title></head><body>\n"; -} - -//---------------------------------------------------------------------------- -void cmDocumentationFormatterHTML::PrintFooter(std::ostream& os) -{ - os << "</body></html>\n"; -} - -//---------------------------------------------------------------------------- -void cmDocumentationFormatterHTML::PrintHTMLEscapes(std::ostream& os, - const char* text) -{ - // Hyperlink prefixes. - static const char* hyperlinks[] = {"http://", "ftp://", "mailto:", 0}; - - // Print each character. - for(const char* p = text; *p;) - { - // Handle hyperlinks specially to make them active. - bool found_hyperlink = false; - for(const char** h = hyperlinks; !found_hyperlink && *h; ++h) - { - if(strncmp(p, *h, strlen(*h)) == 0) - { - p = cmDocumentationPrintHTMLLink(os, p); - found_hyperlink = true; - } - } - - // Print other characters normally. - if(!found_hyperlink) - { - cmDocumentationPrintHTMLChar(os, *p++); - } - } -} - -void cmDocumentationFormatterHTML -::PrintIndex(std::ostream& os, - std::vector<const cmDocumentationSection *>& sections) -{ - // skip the index if only the help for a single item is printed - if ((sections.size() == 1) - && (sections[0]->GetName(this->GetForm()) != 0 ) - && (std::string(sections[0]->GetName(this->GetForm())) == "SingleItem")) - { - return; - } - - os << "<h2><a name=\"section_Index\"></a>Master Index " - << "CMake " << cmVersion::GetCMakeVersion() - << "</h2>\n"; - - if (!sections.empty()) - { - os << "<ul>\n"; - for(unsigned int i=0; i < sections.size(); ++i) - { - std::string name = sections[i]->GetName((this->GetForm())); - os << " <li><a href=\"#section_"; - cmDocumentationPrintHTMLId(os, name.c_str()); - os << "\"><b>" << name << "</b></a></li>\n"; - } - os << "</ul>\n"; - } -} diff --git a/Source/cmDocumentationFormatterHTML.h b/Source/cmDocumentationFormatterHTML.h deleted file mode 100644 index 44bf240..0000000 --- a/Source/cmDocumentationFormatterHTML.h +++ /dev/null @@ -1,42 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#ifndef _cmDocumentationFormatterHTML_h -#define _cmDocumentationFormatterHTML_h - -#include "cmStandardIncludes.h" - -#include "cmDocumentationFormatter.h" - -/** Class to print the documentation as HTML. */ -class cmDocumentationFormatterHTML : public cmDocumentationFormatter -{ -public: - cmDocumentationFormatterHTML(); - - virtual cmDocumentationEnums::Form GetForm() const - { return cmDocumentationEnums::HTMLForm;} - - virtual void PrintHeader(const char* docname, const char* appname, - std::ostream& os); - virtual void PrintFooter(std::ostream& os); - virtual void PrintSection(std::ostream& os, - const cmDocumentationSection& section, - const char* name); - virtual void PrintPreformatted(std::ostream& os, const char* text); - virtual void PrintParagraph(std::ostream& os, const char* text); - virtual void PrintIndex(std::ostream& , - std::vector<const cmDocumentationSection *>&); -private: - void PrintHTMLEscapes(std::ostream& os, const char* text); -}; - -#endif diff --git a/Source/cmDocumentationFormatterMan.cxx b/Source/cmDocumentationFormatterMan.cxx deleted file mode 100644 index 4123c85..0000000 --- a/Source/cmDocumentationFormatterMan.cxx +++ /dev/null @@ -1,102 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ - -#include "cmDocumentationFormatterMan.h" -#include "cmDocumentationSection.h" - -#include "cmSystemTools.h" -#include "cmVersion.h" - - -cmDocumentationFormatterMan::cmDocumentationFormatterMan() -:cmDocumentationFormatter() -,ManSection(1) -{ -} - -void cmDocumentationFormatterMan::SetManSection(int manSection) -{ - this->ManSection = manSection; -} - -void cmDocumentationFormatterMan -::PrintSection(std::ostream& os, - const cmDocumentationSection §ion, - const char* name) -{ - if(name) - { - os << ".SH " << name << "\n"; - } - - const std::vector<cmDocumentationEntry> &entries = - section.GetEntries(); - for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin(); - op != entries.end(); ++op) - { - if(op->Name.size()) - { - os << ".TP\n" - << ".B " << (op->Name.size()?op->Name.c_str():"*") << "\n"; - this->PrintFormatted(os, op->Brief.c_str()); - this->PrintFormatted(os, op->Full.c_str()); - } - else - { - os << ".PP\n"; - this->PrintFormatted(os, op->Brief.c_str()); - } - } -} - -void cmDocumentationFormatterMan::EscapeText(std::string& man_text) -{ - cmSystemTools::ReplaceString(man_text, "\\", "\\\\"); - cmSystemTools::ReplaceString(man_text, "-", "\\-"); -} - -void cmDocumentationFormatterMan::PrintPreformatted(std::ostream& os, - const char* text) -{ - std::string man_text = text; - this->EscapeText(man_text); - os << ".nf\n" << man_text; - if (*text && man_text.at(man_text.length()-1) != '\n') - os << "\n"; - os << ".fi\n\n"; -} - -void cmDocumentationFormatterMan::PrintParagraph(std::ostream& os, - const char* text) -{ - std::string man_text = text; - this->EscapeText(man_text); - os << man_text << "\n\n"; -} - - -//---------------------------------------------------------------------------- -void cmDocumentationFormatterMan::PrintHeader(const char* docname, - const char* appname, - std::ostream& os) -{ - std::string s_docname(docname), s_appname(appname); - - this->EscapeText(s_docname); - this->EscapeText(s_appname); - os << ".TH " << s_docname << " " << this->ManSection << " \"" - << cmSystemTools::GetCurrentDateTime("%B %d, %Y").c_str() - << "\" \"" << s_appname - << " " << cmVersion::GetCMakeVersion() - << "\"\n"; -} - diff --git a/Source/cmDocumentationFormatterMan.h b/Source/cmDocumentationFormatterMan.h deleted file mode 100644 index b3d069c..0000000 --- a/Source/cmDocumentationFormatterMan.h +++ /dev/null @@ -1,43 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#ifndef _cmDocumentationFormatterMan_h -#define _cmDocumentationFormatterMan_h - -#include "cmStandardIncludes.h" - -#include "cmDocumentationFormatter.h" - -/** Class to print the documentation as man page. */ -class cmDocumentationFormatterMan : public cmDocumentationFormatter -{ -public: - cmDocumentationFormatterMan(); - - void SetManSection(int manSection); - - virtual cmDocumentationEnums::Form GetForm() const - { return cmDocumentationEnums::ManForm;} - - virtual void PrintHeader(const char* docname, const char* appname, - std::ostream& os); - virtual void PrintSection(std::ostream& os, - const cmDocumentationSection& section, - const char* name); - virtual void PrintPreformatted(std::ostream& os, const char* text); - virtual void PrintParagraph(std::ostream& os, const char* text); - -private: - void EscapeText(std::string& man_text); - int ManSection; -}; - -#endif diff --git a/Source/cmDocumentationFormatterText.cxx b/Source/cmDocumentationFormatterText.cxx deleted file mode 100644 index 5def194..0000000 --- a/Source/cmDocumentationFormatterText.cxx +++ /dev/null @@ -1,180 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ - -#include "cmDocumentationFormatterText.h" -#include "cmDocumentationSection.h" - -cmDocumentationFormatterText::cmDocumentationFormatterText() -:cmDocumentationFormatter() -,TextWidth(77) -,TextIndent("") -{ -} - -void cmDocumentationFormatterText -::PrintSection(std::ostream& os, - const cmDocumentationSection §ion, - const char* name) -{ - if(name && (strcmp(name, "SingleItem")!=0)) - { - os << - "---------------------------------------" - "---------------------------------------\n"; - os << name << "\n\n"; - } - - const std::vector<cmDocumentationEntry> &entries = - section.GetEntries(); - for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin(); - op != entries.end(); ++op) - { - if(op->Name.size()) - { - os << " " << op->Name << "\n"; - this->TextIndent = " "; - this->PrintFormatted(os, op->Brief.c_str()); - if(op->Full.size()) - { - os << "\n"; - this->PrintFormatted(os, op->Full.c_str()); - } - } - else - { - this->TextIndent = ""; - this->PrintFormatted(os, op->Brief.c_str()); - } - os << "\n"; - } -} - -void cmDocumentationFormatterText::PrintPreformatted(std::ostream& os, - const char* text) -{ - bool newline = true; - for(const char* ptr = text; *ptr; ++ptr) - { - if(newline && *ptr != '\n') - { - os << this->TextIndent; - newline = false; - } - os << *ptr; - if(*ptr == '\n') - { - newline = true; - } - } - os << "\n"; -} - -void cmDocumentationFormatterText::PrintParagraph(std::ostream& os, - const char* text) -{ - os << this->TextIndent; - this->PrintColumn(os, text); - os << "\n"; -} - -void cmDocumentationFormatterText::SetIndent(const char* indent) -{ - this->TextIndent = indent; -} - -void cmDocumentationFormatterText::PrintColumn(std::ostream& os, - const char* text) -{ - // Print text arranged in an indented column of fixed witdh. - const char* l = text; - long column = 0; - bool newSentence = false; - bool firstLine = true; - int width = this->TextWidth - static_cast<int>(strlen(this->TextIndent)); - - // Loop until the end of the text. - while(*l) - { - // Parse the next word. - const char* r = l; - while(*r && (*r != '\n') && (*r != ' ')) { ++r; } - - // Does it fit on this line? - if(r-l < (width-column-(newSentence?1:0))) - { - // Word fits on this line. - if(r > l) - { - if(column) - { - // Not first word on line. Separate from the previous word - // by a space, or two if this is a new sentence. - if(newSentence) - { - os << " "; - column += 2; - } - else - { - os << " "; - column += 1; - } - } - else - { - // First word on line. Print indentation unless this is the - // first line. - os << (firstLine?"":this->TextIndent); - } - - // Print the word. - os.write(l, static_cast<long>(r-l)); - newSentence = (*(r-1) == '.'); - } - - if(*r == '\n') - { - // Text provided a newline. Start a new line. - os << "\n"; - ++r; - column = 0; - firstLine = false; - } - else - { - // No provided newline. Continue this line. - column += static_cast<long>(r-l); - } - } - else - { - // Word does not fit on this line. Start a new line. - os << "\n"; - firstLine = false; - if(r > l) - { - os << this->TextIndent; - os.write(l, static_cast<long>(r-l)); - column = static_cast<long>(r-l); - newSentence = (*(r-1) == '.'); - } - else - { - column = 0; - } - } - - // Move to beginning of next word. Skip over whitespace. - l = r; - while(*l && (*l == ' ')) { ++l; } - } -} diff --git a/Source/cmDocumentationFormatterText.h b/Source/cmDocumentationFormatterText.h deleted file mode 100644 index d9c2af2..0000000 --- a/Source/cmDocumentationFormatterText.h +++ /dev/null @@ -1,40 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#ifndef _cmDocumentationFormatterText_h -#define _cmDocumentationFormatterText_h - -#include "cmStandardIncludes.h" - -#include "cmDocumentationFormatter.h" - -/** Class to print the documentation as plain text. */ -class cmDocumentationFormatterText : public cmDocumentationFormatter -{ -public: - cmDocumentationFormatterText(); - - virtual cmDocumentationEnums::Form GetForm() const - { return cmDocumentationEnums::TextForm;} - - virtual void PrintSection(std::ostream& os, - const cmDocumentationSection& section, - const char* name); - virtual void PrintPreformatted(std::ostream& os, const char* text); - virtual void PrintParagraph(std::ostream& os, const char* text); - void PrintColumn(std::ostream& os, const char* text); - void SetIndent(const char* indent); -protected: - int TextWidth; - const char* TextIndent; -}; - -#endif diff --git a/Source/cmDocumentationFormatterUsage.cxx b/Source/cmDocumentationFormatterUsage.cxx deleted file mode 100644 index a068e56..0000000 --- a/Source/cmDocumentationFormatterUsage.cxx +++ /dev/null @@ -1,63 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ - -#include "cmDocumentationFormatterUsage.h" -#include "cmDocumentationSection.h" - -cmDocumentationFormatterUsage::cmDocumentationFormatterUsage() -:cmDocumentationFormatterText() -{ -} - -void cmDocumentationFormatterUsage -::PrintSection(std::ostream& os, - const cmDocumentationSection §ion, - const char* name) -{ - if(name) - { - os << name << "\n"; - } - - const std::vector<cmDocumentationEntry> &entries = - section.GetEntries(); - for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin(); - op != entries.end(); ++op) - { - if(op->Name.size()) - { - os << " " << op->Name; - this->TextIndent = " "; - int align = static_cast<int>(strlen(this->TextIndent))-4; - for(int i = static_cast<int>(op->Name.size()); i < align; ++i) - { - os << " "; - } - if (op->Name.size() > strlen(this->TextIndent)-4 ) - { - os << "\n"; - os.write(this->TextIndent, strlen(this->TextIndent)-2); - } - os << "= "; - this->PrintColumn(os, op->Brief.c_str()); - os << "\n"; - } - else - { - os << "\n"; - this->TextIndent = ""; - this->PrintFormatted(os, op->Brief.c_str()); - } - } - os << "\n"; -} - diff --git a/Source/cmDocumentationFormatterUsage.h b/Source/cmDocumentationFormatterUsage.h deleted file mode 100644 index 3ed3442..0000000 --- a/Source/cmDocumentationFormatterUsage.h +++ /dev/null @@ -1,31 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#ifndef _cmDocumentationFormatterUsage_h -#define _cmDocumentationFormatterUsage_h - -#include "cmDocumentationFormatterText.h" - -/** Class to print the documentation as usage on the command line. */ -class cmDocumentationFormatterUsage : public cmDocumentationFormatterText -{ -public: - cmDocumentationFormatterUsage(); - - virtual cmDocumentationEnums::Form GetForm() const - { return cmDocumentationEnums::UsageForm;} - - virtual void PrintSection(std::ostream& os, - const cmDocumentationSection& section, - const char* name); -}; - -#endif diff --git a/Source/cmDocumentationSection.cxx b/Source/cmDocumentationSection.cxx index a2dfe70..b0dd8ef 100644 --- a/Source/cmDocumentationSection.cxx +++ b/Source/cmDocumentationSection.cxx @@ -13,69 +13,33 @@ //---------------------------------------------------------------------------- -void cmDocumentationSection::Append(const char *data[][3]) +void cmDocumentationSection::Append(const char *data[][2]) { int i = 0; while(data[i][1]) { this->Entries.push_back(cmDocumentationEntry(data[i][0], - data[i][1], - data[i][2])); + data[i][1])); data += 1; } } //---------------------------------------------------------------------------- -void cmDocumentationSection::Prepend(const char *data[][3]) +void cmDocumentationSection::Prepend(const char *data[][2]) { std::vector<cmDocumentationEntry> tmp; int i = 0; while(data[i][1]) { tmp.push_back(cmDocumentationEntry(data[i][0], - data[i][1], - data[i][2])); + data[i][1])); data += 1; } this->Entries.insert(this->Entries.begin(),tmp.begin(),tmp.end()); } //---------------------------------------------------------------------------- -void cmDocumentationSection::Append(const char *n, const char *b, - const char *f) +void cmDocumentationSection::Append(const char *n, const char *b) { - this->Entries.push_back(cmDocumentationEntry(n,b,f)); + this->Entries.push_back(cmDocumentationEntry(n,b)); } - -#if 0 -//---------------------------------------------------------------------------- -void cmDocumentationSection::Set(const cmDocumentationEntry* header, - const cmDocumentationEntry* section, - const cmDocumentationEntry* footer) -{ - this->Entries.erase(this->Entries.begin(), this->Entries.end()); - if(header) - { - for(const cmDocumentationEntry* op = header; op->brief; ++op) - { - this->Entries.push_back(*op); - } - } - if(section) - { - for(const cmDocumentationEntry* op = section; op->brief; ++op) - { - this->Entries.push_back(*op); - } - } - if(footer) - { - for(const cmDocumentationEntry* op = footer; op->brief; ++op) - { - this->Entries.push_back(*op); - } - } - cmDocumentationEntry empty = {0,0,0}; - this->Entries.push_back(empty); -} -#endif diff --git a/Source/cmDocumentationSection.h b/Source/cmDocumentationSection.h index 4f8c10d..636860d 100644 --- a/Source/cmDocumentationSection.h +++ b/Source/cmDocumentationSection.h @@ -24,8 +24,8 @@ class cmDocumentationSection { public: /** Create a cmSection, with a special name for man-output mode. */ - cmDocumentationSection(const char* name, const char* manName) - :Name(name), ManName(manName) {} + cmDocumentationSection(const char* name, const char*) + :Name(name) {} /** Has any content been added to this section or is it empty ? */ bool IsEmpty() const { return this->Entries.empty(); } @@ -33,10 +33,9 @@ public: /** Clear contents. */ void Clear() { this->Entries.clear(); } - /** Return the name of this section for the given output form. */ - const char* GetName(cmDocumentationEnums::Form form) const - { return (form==cmDocumentationEnums::ManForm ? - this->ManName.c_str() : this->Name.c_str()); } + /** Return the name of this section. */ + const char* GetName() const + { return this->Name.c_str(); } /** Return a pointer to the first entry of this section. */ const std::vector<cmDocumentationEntry> &GetEntries() const @@ -49,11 +48,11 @@ public: { this->Entries.insert(this->Entries.end(),entries.begin(),entries.end()); } /** Append an entry to this section using NULL terminated chars */ - void Append(const char *[][3]); - void Append(const char *n, const char *b, const char *f); + void Append(const char *[][2]); + void Append(const char *n, const char *b); /** prepend some documentation to this section */ - void Prepend(const char *[][3]); + void Prepend(const char *[][2]); void Prepend(const std::vector<cmDocumentationEntry> &entries) { this->Entries.insert(this->Entries.begin(), entries.begin(),entries.end()); } @@ -61,7 +60,6 @@ public: private: std::string Name; - std::string ManName; std::vector<cmDocumentationEntry> Entries; }; diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index 30de9a8..353f2e9 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -13,6 +13,7 @@ #include "cmELF.h" #include <cmsys/auto_ptr.hxx> +#include <cmsys/FStream.hxx> // Need the native byte order of the running CPU. #define cmsys_CPU_UNKNOWN_OKAY // We can decide at runtime if not known. @@ -71,7 +72,7 @@ public: // Construct and take ownership of the file stream object. cmELFInternal(cmELF* external, - cmsys::auto_ptr<std::ifstream>& fin, + cmsys::auto_ptr<cmsys::ifstream>& fin, ByteOrderType order): External(external), Stream(*fin.release()), @@ -204,7 +205,7 @@ public: // Construct with a stream and byte swap indicator. cmELFInternalImpl(cmELF* external, - cmsys::auto_ptr<std::ifstream>& fin, + cmsys::auto_ptr<cmsys::ifstream>& fin, ByteOrderType order); // Return the number of sections as specified by the ELF header. @@ -462,7 +463,7 @@ private: template <class Types> cmELFInternalImpl<Types> ::cmELFInternalImpl(cmELF* external, - cmsys::auto_ptr<std::ifstream>& fin, + cmsys::auto_ptr<cmsys::ifstream>& fin, ByteOrderType order): cmELFInternal(external, fin, order) { @@ -707,7 +708,7 @@ cmELFInternalImpl<Types>::GetDynamicSectionString(int tag) cmELF::cmELF(const char* fname): Internal(0) { // Try to open the file. - cmsys::auto_ptr<std::ifstream> fin(new std::ifstream(fname)); + cmsys::auto_ptr<cmsys::ifstream> fin(new cmsys::ifstream(fname)); // Quit now if the file could not be opened. if(!fin.get() || !*fin) diff --git a/Source/cmElseCommand.h b/Source/cmElseCommand.h index f259919..d472e99 100644 --- a/Source/cmElseCommand.h +++ b/Source/cmElseCommand.h @@ -47,24 +47,6 @@ public: */ virtual const char* GetName() const { return "else";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Starts the else portion of an if block."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " else(expression)\n" - "See the if command."; - } - cmTypeMacro(cmElseCommand, cmCommand); }; diff --git a/Source/cmElseIfCommand.h b/Source/cmElseIfCommand.h index 46e2bd9..d811b35 100644 --- a/Source/cmElseIfCommand.h +++ b/Source/cmElseIfCommand.h @@ -47,24 +47,6 @@ public: */ virtual const char* GetName() const { return "elseif";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Starts the elseif portion of an if block."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " elseif(expression)\n" - "See the if command."; - } - cmTypeMacro(cmElseIfCommand, cmCommand); }; diff --git a/Source/cmEnableLanguageCommand.h b/Source/cmEnableLanguageCommand.h index 747448b..a248042 100644 --- a/Source/cmEnableLanguageCommand.h +++ b/Source/cmEnableLanguageCommand.h @@ -45,37 +45,6 @@ public: */ virtual const char* GetName() const {return "enable_language";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Enable a language (CXX/C/Fortran/etc)"; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " enable_language(<lang> [OPTIONAL] )\n" - "This command enables support for the named language in CMake. " - "This is the same as the project command but does not create " - "any of the extra variables that are created by the project command. " - "Example languages are CXX, C, Fortran. " - "\n" - "This command must be called in file scope, not in a function call. " - "Furthermore, it must be called in the highest directory common to " - "all targets using the named language directly for compiling sources " - "or indirectly through link dependencies. " - "It is simplest to enable all needed languages in the top-level " - "directory of a project." - "\n" - "The OPTIONAL keyword is a placeholder for future implementation " - "and does not currently work."; - } - cmTypeMacro(cmEnableLanguageCommand, cmCommand); }; diff --git a/Source/cmEnableTestingCommand.h b/Source/cmEnableTestingCommand.h index 9b9e985..e102f5e 100644 --- a/Source/cmEnableTestingCommand.h +++ b/Source/cmEnableTestingCommand.h @@ -50,27 +50,6 @@ public: */ virtual const char* GetName() const { return "enable_testing";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Enable testing for current directory and below."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " enable_testing()\n" - "Enables testing for this directory and below. " - "See also the add_test command. Note that ctest expects to find " - "a test file in the build directory root. Therefore, this command " - "should be in the source directory root."; - } - cmTypeMacro(cmEnableTestingCommand, cmCommand); }; diff --git a/Source/cmEndForEachCommand.h b/Source/cmEndForEachCommand.h index d5ee8a6..44d29b5 100644 --- a/Source/cmEndForEachCommand.h +++ b/Source/cmEndForEachCommand.h @@ -54,24 +54,6 @@ public: */ virtual const char* GetName() const { return "endforeach";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Ends a list of commands in a FOREACH block."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " endforeach(expression)\n" - "See the FOREACH command."; - } - cmTypeMacro(cmEndForEachCommand, cmCommand); }; diff --git a/Source/cmEndFunctionCommand.h b/Source/cmEndFunctionCommand.h index d7b74e9..4fdca6b 100644 --- a/Source/cmEndFunctionCommand.h +++ b/Source/cmEndFunctionCommand.h @@ -54,24 +54,6 @@ public: */ virtual const char* GetName() const { return "endfunction";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Ends a list of commands in a function block."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " endfunction(expression)\n" - "See the function command."; - } - cmTypeMacro(cmEndFunctionCommand, cmCommand); }; diff --git a/Source/cmEndIfCommand.h b/Source/cmEndIfCommand.h index 5c4b9e3..634da60 100644 --- a/Source/cmEndIfCommand.h +++ b/Source/cmEndIfCommand.h @@ -47,24 +47,6 @@ public: */ virtual const char* GetName() const { return "endif";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Ends a list of commands in an if block."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " endif(expression)\n" - "See the if command."; - } - cmTypeMacro(cmEndIfCommand, cmCommand); }; diff --git a/Source/cmEndMacroCommand.h b/Source/cmEndMacroCommand.h index 9d0e70f..db15f27 100644 --- a/Source/cmEndMacroCommand.h +++ b/Source/cmEndMacroCommand.h @@ -54,24 +54,6 @@ public: */ virtual const char* GetName() const { return "endmacro";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Ends a list of commands in a macro block."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " endmacro(expression)\n" - "See the macro command."; - } - cmTypeMacro(cmEndMacroCommand, cmCommand); }; diff --git a/Source/cmEndWhileCommand.h b/Source/cmEndWhileCommand.h index 18ba5ea..41138d1 100644 --- a/Source/cmEndWhileCommand.h +++ b/Source/cmEndWhileCommand.h @@ -54,24 +54,6 @@ public: */ virtual const char* GetName() const { return "endwhile";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Ends a list of commands in a while block."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " endwhile(expression)\n" - "See the while command."; - } - cmTypeMacro(cmEndWhileCommand, cmCommand); }; diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx index 9fdb1e8..6c11345 100644 --- a/Source/cmExecProgramCommand.cxx +++ b/Source/cmExecProgramCommand.cxx @@ -12,6 +12,8 @@ #include "cmExecProgramCommand.h" #include "cmSystemTools.h" +#include <cmsys/Process.h> + // cmExecProgramCommand bool cmExecProgramCommand ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) @@ -103,13 +105,13 @@ bool cmExecProgramCommand if(args.size() - count == 2) { cmSystemTools::MakeDirectory(args[1].c_str()); - result = cmSystemTools::RunCommand(command.c_str(), output, retVal, - args[1].c_str(), verbose); + result = cmExecProgramCommand::RunCommand(command.c_str(), output, retVal, + args[1].c_str(), verbose); } else { - result = cmSystemTools::RunCommand(command.c_str(), output, - retVal, 0, verbose); + result = cmExecProgramCommand::RunCommand(command.c_str(), output, + retVal, 0, verbose); } if(!result) { @@ -143,3 +145,189 @@ bool cmExecProgramCommand return true; } +bool cmExecProgramCommand::RunCommand(const char* command, + std::string& output, + int &retVal, + const char* dir, + bool verbose) +{ + if(cmSystemTools::GetRunCommandOutput()) + { + verbose = false; + } + +#if defined(WIN32) && !defined(__CYGWIN__) + // if the command does not start with a quote, then + // try to find the program, and if the program can not be + // found use system to run the command as it must be a built in + // shell command like echo or dir + int count = 0; + std::string shortCmd; + if(command[0] == '\"') + { + // count the number of quotes + for(const char* s = command; *s != 0; ++s) + { + if(*s == '\"') + { + count++; + if(count > 2) + { + break; + } + } + } + // if there are more than two double quotes use + // GetShortPathName, the cmd.exe program in windows which + // is used by system fails to execute if there are more than + // one set of quotes in the arguments + if(count > 2) + { + cmsys::RegularExpression quoted("^\"([^\"]*)\"[ \t](.*)"); + if(quoted.find(command)) + { + std::string cmd = quoted.match(1); + std::string args = quoted.match(2); + if(! cmSystemTools::FileExists(cmd.c_str()) ) + { + shortCmd = cmd; + } + else if(!cmSystemTools::GetShortPath(cmd.c_str(), shortCmd)) + { + cmSystemTools::Error("GetShortPath failed for " , cmd.c_str()); + return false; + } + shortCmd += " "; + shortCmd += args; + + command = shortCmd.c_str(); + } + else + { + cmSystemTools::Error("Could not parse command line with quotes ", + command); + } + } + } +#endif + + // Allocate a process instance. + cmsysProcess* cp = cmsysProcess_New(); + if(!cp) + { + cmSystemTools::Error("Error allocating process instance."); + return false; + } + +#if defined(WIN32) && !defined(__CYGWIN__) + if(dir) + { + cmsysProcess_SetWorkingDirectory(cp, dir); + } + if(cmSystemTools::GetRunCommandHideConsole()) + { + cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1); + } + cmsysProcess_SetOption(cp, cmsysProcess_Option_Verbatim, 1); + const char* cmd[] = {command, 0}; + cmsysProcess_SetCommand(cp, cmd); +#else + std::string commandInDir; + if(dir) + { + commandInDir = "cd \""; + commandInDir += dir; + commandInDir += "\" && "; + commandInDir += command; + } + else + { + commandInDir = command; + } +#ifndef __VMS + commandInDir += " 2>&1"; +#endif + command = commandInDir.c_str(); + if(verbose) + { + cmSystemTools::Stdout("running "); + cmSystemTools::Stdout(command); + cmSystemTools::Stdout("\n"); + } + fflush(stdout); + fflush(stderr); + const char* cmd[] = {"/bin/sh", "-c", command, 0}; + cmsysProcess_SetCommand(cp, cmd); +#endif + + cmsysProcess_Execute(cp); + + // Read the process output. + int length; + char* data; + int p; + while((p = cmsysProcess_WaitForData(cp, &data, &length, 0), p)) + { + if(p == cmsysProcess_Pipe_STDOUT || p == cmsysProcess_Pipe_STDERR) + { + if(verbose) + { + cmSystemTools::Stdout(data, length); + } + output.append(data, length); + } + } + + // All output has been read. Wait for the process to exit. + cmsysProcess_WaitForExit(cp, 0); + + // Check the result of running the process. + std::string msg; + switch(cmsysProcess_GetState(cp)) + { + case cmsysProcess_State_Exited: + retVal = cmsysProcess_GetExitValue(cp); + break; + case cmsysProcess_State_Exception: + retVal = -1; + msg += "\nProcess terminated due to: "; + msg += cmsysProcess_GetExceptionString(cp); + break; + case cmsysProcess_State_Error: + retVal = -1; + msg += "\nProcess failed because: "; + msg += cmsysProcess_GetErrorString(cp); + break; + case cmsysProcess_State_Expired: + retVal = -1; + msg += "\nProcess terminated due to timeout."; + break; + } + if(!msg.empty()) + { +#if defined(WIN32) && !defined(__CYGWIN__) + // Old Windows process execution printed this info. + msg += "\n\nfor command: "; + msg += command; + if(dir) + { + msg += "\nin dir: "; + msg += dir; + } + msg += "\n"; + if(verbose) + { + cmSystemTools::Stdout(msg.c_str()); + } + output += msg; +#else + // Old UNIX process execution only put message in output. + output += msg; +#endif + } + + // Delete the process instance. + cmsysProcess_Delete(cp); + + return true; +} diff --git a/Source/cmExecProgramCommand.h b/Source/cmExecProgramCommand.h index f752501..6d28cdc 100644 --- a/Source/cmExecProgramCommand.h +++ b/Source/cmExecProgramCommand.h @@ -50,39 +50,6 @@ public: */ virtual bool IsScriptable() const { return true; } - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return - "Deprecated. Use the execute_process() command instead."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - "Run an executable program during the processing of the CMakeList.txt" - " file.\n" - " exec_program(Executable [directory in which to run]\n" - " [ARGS <arguments to executable>]\n" - " [OUTPUT_VARIABLE <var>]\n" - " [RETURN_VALUE <var>])\n" - "The executable is run in the optionally specified directory. The " - "executable can include arguments if it is double quoted, but it is " - "better to use the optional ARGS argument to specify arguments to the " - "program. This is because cmake will then be able to escape spaces " - "in the executable path. An optional argument OUTPUT_VARIABLE " - "specifies a variable in which to store the output. " - "To capture the return value of the execution, provide a RETURN_VALUE. " - "If OUTPUT_VARIABLE is specified, then no output will go to the " - "stdout/stderr of the console running cmake.\n" - ; - } - /** This command is kept for compatibility with older CMake versions. */ virtual bool IsDiscouraged() const { @@ -90,6 +57,10 @@ public: } cmTypeMacro(cmExecProgramCommand, cmCommand); +private: + static bool RunCommand(const char* command, std::string& output, + int &retVal, const char* directory = 0, + bool verbose = true); }; #endif diff --git a/Source/cmExecuteProcessCommand.h b/Source/cmExecuteProcessCommand.h index 0e20a4b..bd0f783 100644 --- a/Source/cmExecuteProcessCommand.h +++ b/Source/cmExecuteProcessCommand.h @@ -49,64 +49,6 @@ public: */ virtual bool IsScriptable() const { return true; } - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Execute one or more child processes."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " execute_process(COMMAND <cmd1> [args1...]]\n" - " [COMMAND <cmd2> [args2...] [...]]\n" - " [WORKING_DIRECTORY <directory>]\n" - " [TIMEOUT <seconds>]\n" - " [RESULT_VARIABLE <variable>]\n" - " [OUTPUT_VARIABLE <variable>]\n" - " [ERROR_VARIABLE <variable>]\n" - " [INPUT_FILE <file>]\n" - " [OUTPUT_FILE <file>]\n" - " [ERROR_FILE <file>]\n" - " [OUTPUT_QUIET]\n" - " [ERROR_QUIET]\n" - " [OUTPUT_STRIP_TRAILING_WHITESPACE]\n" - " [ERROR_STRIP_TRAILING_WHITESPACE])\n" - "Runs the given sequence of one or more commands with the standard " - "output of each process piped to the standard input of the next. " - "A single standard error pipe is used for all processes. " - "If WORKING_DIRECTORY is given the named directory will be set as " - "the current working directory of the child processes. " - "If TIMEOUT is given the child processes will be terminated if they " - "do not finish in the specified number of seconds " - "(fractions are allowed). " - "If RESULT_VARIABLE is given the variable will be set to contain " - "the result of running the processes. This will be an integer return " - "code from the last child or a string describing an error condition. " - "If OUTPUT_VARIABLE or ERROR_VARIABLE are given the variable named " - "will be set with the contents of the standard output and standard " - "error pipes respectively. If the same variable is named for both " - "pipes their output will be merged in the order produced. " - "If INPUT_FILE, OUTPUT_FILE, or ERROR_FILE is given the file named " - "will be attached to the standard input of the first process, " - "standard output of the last process, or standard error of all " - "processes respectively. " - "If OUTPUT_QUIET or ERROR_QUIET is given then the standard output " - "or standard error results will be quietly ignored. " - "If more than one OUTPUT_* or ERROR_* option is given for the same " - "pipe the precedence is not specified. " - "If no OUTPUT_* or ERROR_* options are given the output will be shared " - "with the corresponding pipes of the CMake process itself.\n" - "The execute_process command is a newer more powerful version of " - "exec_program, but the old command has been kept for compatibility." - ; - } - cmTypeMacro(cmExecuteProcessCommand, cmCommand); }; diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index cdc3316..b669cd1 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -11,42 +11,49 @@ ============================================================================*/ #include "cmExportBuildFileGenerator.h" -#include "cmExportCommand.h" +#include "cmLocalGenerator.h" +#include "cmGlobalGenerator.h" +#include "cmExportSet.h" +#include "cmTargetExport.h" //---------------------------------------------------------------------------- cmExportBuildFileGenerator::cmExportBuildFileGenerator() { - this->ExportCommand = 0; + this->Makefile = 0; + this->ExportSet = 0; } //---------------------------------------------------------------------------- bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) { - std::vector<cmTarget*> allTargets; { std::string expectedTargets; std::string sep; - for(std::vector<cmTarget*>::const_iterator - tei = this->Exports->begin(); - tei != this->Exports->end(); ++tei) + std::vector<std::string> targets; + this->GetTargets(targets); + for(std::vector<std::string>::const_iterator + tei = targets.begin(); + tei != targets.end(); ++tei) { - expectedTargets += sep + this->Namespace + (*tei)->GetExportName(); + cmTarget *te = this->Makefile->FindTargetToUse(tei->c_str()); + expectedTargets += sep + this->Namespace + te->GetExportName(); sep = " "; - cmTarget* te = *tei; if(this->ExportedTargets.insert(te).second) { - allTargets.push_back(te); + this->Exports.push_back(te); } else { - if(this->ExportCommand && this->ExportCommand->ErrorMessage.empty()) - { - cmOStringStream e; - e << "given target \"" << te->GetName() << "\" more than once."; - this->ExportCommand->ErrorMessage = e.str(); - } + cmOStringStream e; + e << "given target \"" << te->GetName() << "\" more than once."; + this->Makefile->GetCMakeInstance() + ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(), this->Backtrace); return false; } + if (te->GetType() == cmTarget::INTERFACE_LIBRARY) + { + this->GenerateRequiredCMakeVersion(os, "2.8.12.20131007"); // 2.8.13 + } } this->GenerateExpectedTargetsCode(os, expectedTargets); @@ -56,8 +63,8 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) // Create all the imported targets. for(std::vector<cmTarget*>::const_iterator - tei = allTargets.begin(); - tei != allTargets.end(); ++tei) + tei = this->Exports.begin(); + tei != this->Exports.end(); ++tei) { cmTarget* te = *tei; this->GenerateImportTargetCode(os, te); @@ -75,6 +82,9 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", te, cmGeneratorExpression::BuildInterface, properties, missingTargets); + this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", te, + cmGeneratorExpression::BuildInterface, + properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", te, properties); const bool newCMP0022Behavior = @@ -112,22 +122,28 @@ cmExportBuildFileGenerator std::vector<std::string> &missingTargets) { for(std::vector<cmTarget*>::const_iterator - tei = this->Exports->begin(); - tei != this->Exports->end(); ++tei) + tei = this->Exports.begin(); + tei != this->Exports.end(); ++tei) { // Collect import properties for this target. cmTarget* target = *tei; ImportPropertyMap properties; - this->SetImportLocationProperty(config, suffix, target, properties); + + if (target->GetType() != cmTarget::INTERFACE_LIBRARY) + { + this->SetImportLocationProperty(config, suffix, target, properties); + } if(!properties.empty()) { // Get the rest of the target details. - this->SetImportDetailProperties(config, suffix, - target, properties, missingTargets); - this->SetImportLinkInterface(config, suffix, - cmGeneratorExpression::BuildInterface, - target, properties, missingTargets); - + if (target->GetType() != cmTarget::INTERFACE_LIBRARY) + { + this->SetImportDetailProperties(config, suffix, + target, properties, missingTargets); + this->SetImportLinkInterface(config, suffix, + cmGeneratorExpression::BuildInterface, + target, properties, missingTargets); + } // TOOD: PUBLIC_HEADER_LOCATION // This should wait until the build feature propagation stuff @@ -142,6 +158,12 @@ cmExportBuildFileGenerator } //---------------------------------------------------------------------------- +void cmExportBuildFileGenerator::SetExportSet(cmExportSet *exportSet) +{ + this->ExportSet = exportSet; +} + +//---------------------------------------------------------------------------- void cmExportBuildFileGenerator ::SetImportLocationProperty(const char* config, std::string const& suffix, @@ -188,15 +210,31 @@ cmExportBuildFileGenerator //---------------------------------------------------------------------------- void cmExportBuildFileGenerator::HandleMissingTarget( - std::string& link_libs, std::vector<std::string>&, - cmMakefile*, cmTarget* depender, cmTarget* dependee) + std::string& link_libs, std::vector<std::string>& missingTargets, + cmMakefile* mf, cmTarget* depender, cmTarget* dependee) { // The target is not in the export. if(!this->AppendMode) { - // We are not appending, so all exported targets should be - // known here. This is probably user-error. - this->ComplainAboutMissingTarget(depender, dependee); + const std::string name = dependee->GetName(); + std::vector<std::string> namespaces = this->FindNamespaces(mf, name); + + int targetOccurrences = (int)namespaces.size(); + if (targetOccurrences == 1) + { + std::string missingTarget = namespaces[0]; + + missingTarget += dependee->GetExportName(); + link_libs += missingTarget; + missingTargets.push_back(missingTarget); + return; + } + else + { + // We are not appending, so all exported targets should be + // known here. This is probably user-error. + this->ComplainAboutMissingTarget(depender, dependee, targetOccurrences); + } } // Assume the target will be exported by another command. // Append it with the export namespace. @@ -205,23 +243,77 @@ cmExportBuildFileGenerator::HandleMissingTarget( } //---------------------------------------------------------------------------- +void cmExportBuildFileGenerator +::GetTargets(std::vector<std::string> &targets) const +{ + if (this->ExportSet) + { + for(std::vector<cmTargetExport*>::const_iterator + tei = this->ExportSet->GetTargetExports()->begin(); + tei != this->ExportSet->GetTargetExports()->end(); ++tei) + { + targets.push_back((*tei)->Target->GetName()); + } + return; + } + targets = this->Targets; +} + +//---------------------------------------------------------------------------- +std::vector<std::string> +cmExportBuildFileGenerator +::FindNamespaces(cmMakefile* mf, const std::string& name) +{ + std::vector<std::string> namespaces; + cmGlobalGenerator* gg = mf->GetLocalGenerator()->GetGlobalGenerator(); + + std::map<std::string, cmExportBuildFileGenerator*>& exportSets + = gg->GetBuildExportSets(); + + for(std::map<std::string, cmExportBuildFileGenerator*>::const_iterator + expIt = exportSets.begin(); expIt != exportSets.end(); ++expIt) + { + const cmExportBuildFileGenerator* exportSet = expIt->second; + std::vector<std::string> targets; + exportSet->GetTargets(targets); + if (std::find(targets.begin(), targets.end(), name) != targets.end()) + { + namespaces.push_back(exportSet->GetNamespace()); + } + } + + return namespaces; +} + +//---------------------------------------------------------------------------- void cmExportBuildFileGenerator ::ComplainAboutMissingTarget(cmTarget* depender, - cmTarget* dependee) + cmTarget* dependee, + int occurrences) { - if(!this->ExportCommand || !this->ExportCommand->ErrorMessage.empty()) + if(cmSystemTools::GetErrorOccuredFlag()) { return; } cmOStringStream e; - e << "called with target \"" << depender->GetName() - << "\" which requires target \"" << dependee->GetName() - << "\" that is not in the export list.\n" - << "If the required target is not easy to reference in this call, " + e << "export called with target \"" << depender->GetName() + << "\" which requires target \"" << dependee->GetName() << "\" "; + if (occurrences == 0) + { + e << "that is not in the export set.\n"; + } + else + { + e << "that is not in this export set, but " << occurrences + << " times in others.\n"; + } + e << "If the required target is not easy to reference in this call, " << "consider using the APPEND option with multiple separate calls."; - this->ExportCommand->ErrorMessage = e.str(); + + this->Makefile->GetCMakeInstance() + ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(), this->Backtrace); } std::string diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h index 3ffdf8b..cea2099 100644 --- a/Source/cmExportBuildFileGenerator.h +++ b/Source/cmExportBuildFileGenerator.h @@ -13,8 +13,9 @@ #define cmExportBuildFileGenerator_h #include "cmExportFileGenerator.h" +#include "cmListFileCache.h" -class cmExportCommand; +class cmExportSet; /** \class cmExportBuildFileGenerator * \brief Generate a file exporting targets from a build tree. @@ -31,14 +32,22 @@ public: cmExportBuildFileGenerator(); /** Set the list of targets to export. */ - void SetExports(std::vector<cmTarget*> const* exports) - { this->Exports = exports; } + void SetTargets(std::vector<std::string> const& targets) + { this->Targets = targets; } + void GetTargets(std::vector<std::string> &targets) const; + void AppendTargets(std::vector<std::string> const& targets) + { this->Targets.insert(this->Targets.end(), + targets.begin(), targets.end()); } + void SetExportSet(cmExportSet*); /** Set whether to append generated code to the output file. */ void SetAppendMode(bool append) { this->AppendMode = append; } - /** Set the command instance through which errors should be reported. */ - void SetCommand(cmExportCommand* cmd) { this->ExportCommand = cmd; } + void SetMakefile(cmMakefile *mf) { + this->Makefile = mf; + this->Makefile->GetBacktrace(this->Backtrace); + } + protected: // Implement virtual methods from the superclass. virtual bool GenerateMainFile(std::ostream& os); @@ -53,7 +62,8 @@ protected: cmTarget* dependee); void ComplainAboutMissingTarget(cmTarget* depender, - cmTarget* dependee); + cmTarget* dependee, + int occurrences); /** Fill in properties indicating built file locations. */ void SetImportLocationProperty(const char* config, @@ -63,8 +73,14 @@ protected: std::string InstallNameDir(cmTarget* target, const std::string& config); - std::vector<cmTarget*> const* Exports; - cmExportCommand* ExportCommand; + std::vector<std::string> + FindNamespaces(cmMakefile* mf, const std::string& name); + + std::vector<std::string> Targets; + cmExportSet *ExportSet; + std::vector<cmTarget*> Exports; + cmMakefile* Makefile; + cmListFileBacktrace Backtrace; }; #endif diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index f059ceb..7c97d8d 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -16,11 +16,13 @@ #include "cmake.h" #include <cmsys/RegularExpression.hxx> +#include <cmsys/Encoding.hxx> #include "cmExportBuildFileGenerator.h" #if defined(__HAIKU__) -#include <StorageKit.h> +#include <FindDirectory.h> +#include <StorageDefs.h> #endif cmExportCommand::cmExportCommand() @@ -28,14 +30,12 @@ cmExportCommand::cmExportCommand() ,ArgumentGroup() ,Targets(&Helper, "TARGETS") ,Append(&Helper, "APPEND", &ArgumentGroup) +,ExportSetName(&Helper, "EXPORT", &ArgumentGroup) ,Namespace(&Helper, "NAMESPACE", &ArgumentGroup) ,Filename(&Helper, "FILE", &ArgumentGroup) ,ExportOld(&Helper, "EXPORT_LINK_INTERFACE_LIBRARIES", &ArgumentGroup) { - // at first TARGETS - this->Targets.Follows(0); - // and after that the other options in any order - this->ArgumentGroup.Follows(&this->Targets); + this->ExportSet = 0; } @@ -53,6 +53,16 @@ bool cmExportCommand { return this->HandlePackage(args); } + else if (args[0] == "EXPORT") + { + this->ExportSetName.Follows(0); + this->ArgumentGroup.Follows(&this->ExportSetName); + } + else + { + this->Targets.Follows(0); + this->ArgumentGroup.Follows(&this->Targets); + } std::vector<std::string> unknownArgs; this->Helper.Parse(&args, &unknownArgs); @@ -63,31 +73,32 @@ bool cmExportCommand return false; } - if (this->Targets.WasFound() == false) - { - this->SetError("TARGETS option missing."); - return false; - } - + std::string fname; if(!this->Filename.WasFound()) { - this->SetError("FILE <filename> option missing."); - return false; + if (args[0] != "EXPORT") + { + this->SetError("FILE <filename> option missing."); + return false; + } + fname = this->ExportSetName.GetString() + ".cmake"; } - - // Make sure the file has a .cmake extension. - if(cmSystemTools::GetFilenameLastExtension(this->Filename.GetCString()) - != ".cmake") + else { - cmOStringStream e; - e << "FILE option given filename \"" << this->Filename.GetString() - << "\" which does not have an extension of \".cmake\".\n"; - this->SetError(e.str().c_str()); - return false; + // Make sure the file has a .cmake extension. + if(cmSystemTools::GetFilenameLastExtension(this->Filename.GetCString()) + != ".cmake") + { + cmOStringStream e; + e << "FILE option given filename \"" << this->Filename.GetString() + << "\" which does not have an extension of \".cmake\".\n"; + this->SetError(e.str().c_str()); + return false; + } + fname = this->Filename.GetString(); } // Get the file to write. - std::string fname = this->Filename.GetString(); if(cmSystemTools::FileIsFullPath(fname.c_str())) { if(!this->Makefile->CanIWriteThisFile(fname.c_str())) @@ -102,73 +113,112 @@ bool cmExportCommand else { // Interpret relative paths with respect to the current build dir. - fname = this->Makefile->GetCurrentOutputDirectory(); - fname += "/"; - fname += this->Filename.GetString(); + std::string dir = this->Makefile->GetCurrentOutputDirectory(); + fname = dir + "/" + fname; } - // Collect the targets to be exported. - std::vector<cmTarget*> targets; - for(std::vector<std::string>::const_iterator - currentTarget = this->Targets.GetVector().begin(); - currentTarget != this->Targets.GetVector().end(); - ++currentTarget) + std::vector<std::string> targets; + + cmGlobalGenerator *gg = this->Makefile->GetLocalGenerator() + ->GetGlobalGenerator(); + + if(args[0] == "EXPORT") { - if (this->Makefile->IsAlias(currentTarget->c_str())) + if (this->Append.IsEnabled()) { cmOStringStream e; - e << "given ALIAS target \"" << *currentTarget - << "\" which may not be exported."; + e << "EXPORT signature does not recognise the APPEND option."; this->SetError(e.str().c_str()); return false; } - if(cmTarget* target = - this->Makefile->GetLocalGenerator()-> - GetGlobalGenerator()->FindTarget(0, currentTarget->c_str())) + if (this->ExportOld.IsEnabled()) { - if((target->GetType() == cmTarget::EXECUTABLE) || - (target->GetType() == cmTarget::STATIC_LIBRARY) || - (target->GetType() == cmTarget::SHARED_LIBRARY) || - (target->GetType() == cmTarget::MODULE_LIBRARY)) - { - targets.push_back(target); - } - else if(target->GetType() == cmTarget::OBJECT_LIBRARY) + cmOStringStream e; + e << "EXPORT signature does not recognise the " + "EXPORT_LINK_INTERFACE_LIBRARIES option."; + this->SetError(e.str().c_str()); + return false; + } + + cmExportSetMap &setMap = gg->GetExportSets(); + std::string setName = this->ExportSetName.GetString(); + if (setMap.find(setName) == setMap.end()) + { + cmOStringStream e; + e << "Export set \"" << setName << "\" not found."; + this->SetError(e.str().c_str()); + return false; + } + this->ExportSet = setMap[setName]; + } + else if (this->Targets.WasFound()) + { + for(std::vector<std::string>::const_iterator + currentTarget = this->Targets.GetVector().begin(); + currentTarget != this->Targets.GetVector().end(); + ++currentTarget) + { + if (this->Makefile->IsAlias(currentTarget->c_str())) { cmOStringStream e; - e << "given OBJECT library \"" << *currentTarget + e << "given ALIAS target \"" << *currentTarget << "\" which may not be exported."; this->SetError(e.str().c_str()); return false; } + + if(cmTarget* target = gg->FindTarget(0, currentTarget->c_str())) + { + if(target->GetType() == cmTarget::OBJECT_LIBRARY) + { + cmOStringStream e; + e << "given OBJECT library \"" << *currentTarget + << "\" which may not be exported."; + this->SetError(e.str().c_str()); + return false; + } + } else { cmOStringStream e; e << "given target \"" << *currentTarget - << "\" which is not an executable or library."; + << "\" which is not built by this project."; this->SetError(e.str().c_str()); return false; } + targets.push_back(*currentTarget); } - else + if (this->Append.IsEnabled()) { - cmOStringStream e; - e << "given target \"" << *currentTarget - << "\" which is not built by this project."; - this->SetError(e.str().c_str()); - return false; + if (cmExportBuildFileGenerator *ebfg = gg->GetExportedTargetsFile(fname)) + { + ebfg->AppendTargets(targets); + return true; + } } } + else + { + this->SetError("EXPORT or TARGETS specifier missing."); + return false; + } // Setup export file generation. - cmExportBuildFileGenerator ebfg; - ebfg.SetExportFile(fname.c_str()); - ebfg.SetNamespace(this->Namespace.GetCString()); - ebfg.SetAppendMode(this->Append.IsEnabled()); - ebfg.SetExports(&targets); - ebfg.SetCommand(this); - ebfg.SetExportOld(this->ExportOld.IsEnabled()); + cmExportBuildFileGenerator *ebfg = new cmExportBuildFileGenerator; + ebfg->SetExportFile(fname.c_str()); + ebfg->SetNamespace(this->Namespace.GetCString()); + ebfg->SetAppendMode(this->Append.IsEnabled()); + if (this->ExportSet) + { + ebfg->SetExportSet(this->ExportSet); + } + else + { + ebfg->SetTargets(targets); + } + ebfg->SetMakefile(this->Makefile); + ebfg->SetExportOld(this->ExportOld.IsEnabled()); // Compute the set of configurations exported. std::vector<std::string> configurationTypes; @@ -179,26 +229,20 @@ bool cmExportCommand ci = configurationTypes.begin(); ci != configurationTypes.end(); ++ci) { - ebfg.AddConfiguration(ci->c_str()); + ebfg->AddConfiguration(ci->c_str()); } } else { - ebfg.AddConfiguration(""); + ebfg->AddConfiguration(""); } - - // Generate the import file. - if(!ebfg.GenerateImportFile() && this->ErrorMessage.empty()) + if (this->ExportSet) { - this->SetError("could not write export file."); - return false; + gg->AddBuildExportExportSet(ebfg); } - - // Report generated error message if any. - if(!this->ErrorMessage.empty()) + else { - this->SetError(this->ErrorMessage.c_str()); - return false; + gg->AddBuildExportSet(ebfg); } return true; @@ -269,14 +313,14 @@ void cmExportCommand::ReportRegistryError(std::string const& msg, cmOStringStream e; e << msg << "\n" << " HKEY_CURRENT_USER\\" << key << "\n"; - char winmsg[1024]; - if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | + wchar_t winmsg[1024]; + if(FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), winmsg, 1024, 0) > 0) { e << "Windows reported:\n" - << " " << winmsg; + << " " << cmsys::Encoding::ToNarrow(winmsg); } this->Makefile->IssueMessage(cmake::WARNING, e.str()); } @@ -289,8 +333,9 @@ void cmExportCommand::StorePackageRegistryWin(std::string const& package, std::string key = "Software\\Kitware\\CMake\\Packages\\"; key += package; HKEY hKey; - LONG err = RegCreateKeyEx(HKEY_CURRENT_USER, - key.c_str(), 0, 0, REG_OPTION_NON_VOLATILE, + LONG err = RegCreateKeyExW(HKEY_CURRENT_USER, + cmsys::Encoding::ToWide(key).c_str(), + 0, 0, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, 0, &hKey, 0); if(err != ERROR_SUCCESS) { @@ -298,8 +343,11 @@ void cmExportCommand::StorePackageRegistryWin(std::string const& package, "Cannot create/open registry key", key, err); return; } - err = RegSetValueEx(hKey, hash, 0, REG_SZ, (BYTE const*)content, - static_cast<DWORD>(strlen(content)+1)); + + std::wstring wcontent = cmsys::Encoding::ToWide(content); + err = RegSetValueExW(hKey, cmsys::Encoding::ToWide(hash).c_str(), + 0, REG_SZ, (BYTE const*)wcontent.c_str(), + static_cast<DWORD>(wcontent.size()+1)*sizeof(wchar_t)); RegCloseKey(hKey); if(err != ERROR_SUCCESS) { @@ -316,14 +364,15 @@ void cmExportCommand::StorePackageRegistryDir(std::string const& package, const char* hash) { #if defined(__HAIKU__) - BPath dir; - if (find_directory(B_USER_SETTINGS_DIRECTORY, &dir) != B_OK) + char dir[B_PATH_NAME_LENGTH]; + if (find_directory(B_USER_SETTINGS_DIRECTORY, -1, false, dir, sizeof(dir)) != + B_OK) { return; } - dir.Append("cmake/packages"); - dir.Append(package.c_str()); - std::string fname = dir.Path(); + std::string fname = dir; + fname += "/cmake/packages/"; + fname += package; #else const char* home = cmSystemTools::GetEnv("HOME"); if(!home) diff --git a/Source/cmExportCommand.h b/Source/cmExportCommand.h index 87c3452..c0e445f 100644 --- a/Source/cmExportCommand.h +++ b/Source/cmExportCommand.h @@ -13,9 +13,9 @@ #define cmExportCommand_h #include "cmCommand.h" -#include "cmDocumentLocationUndefined.h" class cmExportBuildFileGenerator; +class cmExportSet; /** \class cmExportLibraryDependenciesCommand * \brief Add a test to the lists of tests to run. @@ -47,69 +47,19 @@ public: */ virtual const char* GetName() const { return "export";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return - "Export targets from the build tree for use by outside projects."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " export(TARGETS [target1 [target2 [...]]] [NAMESPACE <namespace>]\n" - " [APPEND] FILE <filename> [EXPORT_LINK_INTERFACE_LIBRARIES])\n" - "Create a file <filename> that may be included by outside projects to " - "import targets from the current project's build tree. " - "This is useful during cross-compiling to build utility executables " - "that can run on the host platform in one project and then import " - "them into another project being compiled for the target platform. " - "If the NAMESPACE option is given the <namespace> string will be " - "prepended to all target names written to the file. " - "If the APPEND option is given the generated code will be appended " - "to the file instead of overwriting it. " - "The EXPORT_LINK_INTERFACE_LIBRARIES keyword, if present, causes the " - "contents of the properties matching " - "(IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)? to be exported, when " - "policy CMP0022 is NEW. " - "If a library target is included in the export but " - "a target to which it links is not included the behavior is " - "unspecified." - "\n" - "The file created by this command is specific to the build tree and " - "should never be installed. " - "See the install(EXPORT) command to export targets from an " - "installation tree." - CM_LOCATION_UNDEFINED_BEHAVIOR("passing it to this command") - "\n" - " export(PACKAGE <name>)\n" - "Store the current build directory in the CMake user package registry " - "for package <name>. " - "The find_package command may consider the directory while searching " - "for package <name>. " - "This helps dependent projects find and use a package from the " - "current project's build tree without help from the user. " - "Note that the entry in the package registry that this command " - "creates works only in conjunction with a package configuration " - "file (<name>Config.cmake) that works with the build tree." - ; - } - cmTypeMacro(cmExportCommand, cmCommand); private: cmCommandArgumentGroup ArgumentGroup; cmCAStringVector Targets; cmCAEnabler Append; + cmCAString ExportSetName; cmCAString Namespace; cmCAString Filename; cmCAEnabler ExportOld; + cmExportSet *ExportSet; + friend class cmExportBuildFileGenerator; std::string ErrorMessage; diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index ef336ea..13bff19 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -24,6 +24,7 @@ #include "cmComputeLinkInformation.h" #include <cmsys/auto_ptr.hxx> +#include <cmsys/FStream.hxx> #include <assert.h> //---------------------------------------------------------------------------- @@ -52,15 +53,21 @@ void cmExportFileGenerator::SetExportFile(const char* mainFile) } //---------------------------------------------------------------------------- +const char* cmExportFileGenerator::GetMainExportFileName() const +{ + return this->MainImportFile.c_str(); +} + +//---------------------------------------------------------------------------- bool cmExportFileGenerator::GenerateImportFile() { // Open the output file to generate it. - cmsys::auto_ptr<std::ofstream> foutPtr; + cmsys::auto_ptr<cmsys::ofstream> foutPtr; if(this->AppendMode) { // Open for append. - cmsys::auto_ptr<std::ofstream> - ap(new std::ofstream(this->MainImportFile.c_str(), std::ios::app)); + cmsys::auto_ptr<cmsys::ofstream> + ap(new cmsys::ofstream(this->MainImportFile.c_str(), std::ios::app)); foutPtr = ap; } else @@ -185,6 +192,10 @@ bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty( ImportPropertyMap &properties, std::vector<std::string> &missingTargets) { + if(!target->IsLinkable()) + { + return false; + } const char *input = target->GetProperty("INTERFACE_LINK_LIBRARIES"); if (input) { @@ -223,26 +234,46 @@ static bool checkInterfaceDirs(const std::string &prepro, const bool inSourceBuild = strcmp(topSourceDir, topBinaryDir) == 0; + bool hadFatalError = false; + for(std::vector<std::string>::iterator li = parts.begin(); li != parts.end(); ++li) { - if (cmGeneratorExpression::Find(*li) != std::string::npos) + size_t genexPos = cmGeneratorExpression::Find(*li); + if (genexPos == 0) { continue; } - if (strncmp(li->c_str(), "${_IMPORT_PREFIX}", 17) == 0) + cmake::MessageType messageType = cmake::FATAL_ERROR; + cmOStringStream e; + if (genexPos != std::string::npos) + { + switch (target->GetPolicyStatusCMP0041()) + { + case cmPolicies::WARN: + messageType = cmake::WARNING; + e << target->GetMakefile()->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0041) << "\n"; + break; + case cmPolicies::OLD: + continue; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + hadFatalError = true; + break; // Issue fatal message. + } + } + if (cmHasLiteralPrefix(li->c_str(), "${_IMPORT_PREFIX}")) { continue; } if (!cmSystemTools::FileIsFullPath(li->c_str())) { - cmOStringStream e; e << "Target \"" << target->GetName() << "\" " "INTERFACE_INCLUDE_DIRECTORIES property contains relative path:\n" " \"" << *li << "\""; - target->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, - e.str().c_str()); - return false; + target->GetMakefile()->IssueMessage(messageType, e.str().c_str()); } if (isSubDirectory(li->c_str(), installDir)) { @@ -250,29 +281,44 @@ static bool checkInterfaceDirs(const std::string &prepro, } if (isSubDirectory(li->c_str(), topBinaryDir)) { - cmOStringStream e; e << "Target \"" << target->GetName() << "\" " "INTERFACE_INCLUDE_DIRECTORIES property contains path:\n" " \"" << *li << "\"\nwhich is prefixed in the build directory."; - target->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, - e.str().c_str()); - return false; + target->GetMakefile()->IssueMessage(messageType, e.str().c_str()); } if (!inSourceBuild) { if (isSubDirectory(li->c_str(), topSourceDir)) { - cmOStringStream e; e << "Target \"" << target->GetName() << "\" " "INTERFACE_INCLUDE_DIRECTORIES property contains path:\n" " \"" << *li << "\"\nwhich is prefixed in the source directory."; - target->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, - e.str().c_str()); - return false; + target->GetMakefile()->IssueMessage(messageType, e.str().c_str()); } } } - return true; + return !hadFatalError; +} + +//---------------------------------------------------------------------------- +static void prefixItems(std::string &exportDirs) +{ + std::vector<std::string> entries; + cmGeneratorExpression::Split(exportDirs, entries); + exportDirs = ""; + const char *sep = ""; + for(std::vector<std::string>::const_iterator ei = entries.begin(); + ei != entries.end(); ++ei) + { + exportDirs += sep; + sep = ";"; + if (!cmSystemTools::FileIsFullPath(ei->c_str()) + && ei->find("${_IMPORT_PREFIX}") == std::string::npos) + { + exportDirs += "${_IMPORT_PREFIX}/"; + } + exportDirs += *ei; + } } //---------------------------------------------------------------------------- @@ -291,7 +337,10 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( cmListFileBacktrace lfbt; cmGeneratorExpression ge(lfbt); - std::string dirs = tei->InterfaceIncludeDirectories; + std::string dirs = cmGeneratorExpression::Preprocess( + tei->InterfaceIncludeDirectories, + preprocessRule, + true); this->ReplaceInstallPrefix(dirs); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs); std::string exportDirs = cge->Evaluate(target->GetMakefile(), 0, @@ -320,6 +369,8 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( return; } + prefixItems(exportDirs); + std::string includes = (input?input:""); const char* sep = input ? ";" : ""; includes += sep + exportDirs; @@ -352,7 +403,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, //---------------------------------------------------------------------------- -void getPropertyContents(cmTarget *tgt, const char *prop, +void getPropertyContents(cmTarget const* tgt, const char *prop, std::set<std::string> &ifaceProperties) { const char *p = tgt->GetProperty(prop); @@ -381,7 +432,7 @@ void getCompatibleInterfaceProperties(cmTarget *target, cmMakefile* mf = target->GetMakefile(); cmOStringStream e; e << "Exporting the target \"" << target->GetName() << "\" is not " - "allowed since its linker language cannot be determined"; + "allowed since its linker language cannot be determined"; mf->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } @@ -402,6 +453,12 @@ void getCompatibleInterfaceProperties(cmTarget *target, getPropertyContents(li->Target, "COMPATIBLE_INTERFACE_STRING", ifaceProperties); + getPropertyContents(li->Target, + "COMPATIBLE_INTERFACE_NUMBER_MIN", + ifaceProperties); + getPropertyContents(li->Target, + "COMPATIBLE_INTERFACE_NUMBER_MAX", + ifaceProperties); } } @@ -414,21 +471,32 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( target, properties); this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING", target, properties); + this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MIN", + target, properties); + this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_NUMBER_MAX", + target, properties); std::set<std::string> ifaceProperties; getPropertyContents(target, "COMPATIBLE_INTERFACE_BOOL", ifaceProperties); getPropertyContents(target, "COMPATIBLE_INTERFACE_STRING", ifaceProperties); + getPropertyContents(target, "COMPATIBLE_INTERFACE_NUMBER_MIN", + ifaceProperties); + getPropertyContents(target, "COMPATIBLE_INTERFACE_NUMBER_MAX", + ifaceProperties); - getCompatibleInterfaceProperties(target, ifaceProperties, 0); + if (target->GetType() != cmTarget::INTERFACE_LIBRARY) + { + getCompatibleInterfaceProperties(target, ifaceProperties, 0); - std::vector<std::string> configNames; - target->GetMakefile()->GetConfigurations(configNames); + std::vector<std::string> configNames; + target->GetMakefile()->GetConfigurations(configNames); - for (std::vector<std::string>::const_iterator ci = configNames.begin(); - ci != configNames.end(); ++ci) - { - getCompatibleInterfaceProperties(target, ifaceProperties, ci->c_str()); + for (std::vector<std::string>::const_iterator ci = configNames.begin(); + ci != configNames.end(); ++ci) + { + getCompatibleInterfaceProperties(target, ifaceProperties, ci->c_str()); + } } for (std::set<std::string>::const_iterator it = ifaceProperties.begin(); @@ -440,7 +508,7 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( } //---------------------------------------------------------------------------- -void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget *target, +void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget const* target, std::ostream& os, const ImportPropertyMap &properties) { @@ -631,6 +699,7 @@ cmExportFileGenerator if (iface->ImplementationIsInterface) { + // Policy CMP0022 must not be NEW. this->SetImportLinkProperty(suffix, target, "IMPORTED_LINK_INTERFACE_LIBRARIES", iface->Libraries, properties, missingTargets); @@ -736,9 +805,10 @@ cmExportFileGenerator "IMPORTED_LINK_INTERFACE_LANGUAGES", iface->Languages, properties, missingTargets); + std::vector<std::string> dummy; this->SetImportLinkProperty(suffix, target, "IMPORTED_LINK_DEPENDENT_LIBRARIES", - iface->SharedDeps, properties, missingTargets); + iface->SharedDeps, properties, dummy); if(iface->Multiplicity > 0) { std::string prop = "IMPORTED_LINK_INTERFACE_MULTIPLICITY"; @@ -756,36 +826,36 @@ cmExportFileGenerator ::SetImportLinkProperty(std::string const& suffix, cmTarget* target, const char* propName, - std::vector<std::string> const& libs, + std::vector<std::string> const& entries, ImportPropertyMap& properties, std::vector<std::string>& missingTargets ) { - // Skip the property if there are no libraries. - if(libs.empty()) + // Skip the property if there are no entries. + if(entries.empty()) { return; } // Construct the property value. - std::string link_libs; + std::string link_entries; const char* sep = ""; - for(std::vector<std::string>::const_iterator li = libs.begin(); - li != libs.end(); ++li) + for(std::vector<std::string>::const_iterator li = entries.begin(); + li != entries.end(); ++li) { // Separate this from the previous entry. - link_libs += sep; + link_entries += sep; sep = ";"; std::string temp = *li; this->AddTargetNamespace(temp, target, missingTargets); - link_libs += temp; + link_entries += temp; } // Store the property. std::string prop = propName; prop += suffix; - properties[prop] = link_libs; + properties[prop] = link_entries; } @@ -861,7 +931,7 @@ void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os, //---------------------------------------------------------------------------- void cmExportFileGenerator -::GenerateImportTargetCode(std::ostream& os, cmTarget* target) +::GenerateImportTargetCode(std::ostream& os, cmTarget const* target) { // Construct the imported target name. std::string targetName = this->Namespace; @@ -887,6 +957,9 @@ cmExportFileGenerator case cmTarget::UNKNOWN_LIBRARY: os << "add_library(" << targetName << " UNKNOWN IMPORTED)\n"; break; + case cmTarget::INTERFACE_LIBRARY: + os << "add_library(" << targetName << " INTERFACE IMPORTED)\n"; + break; default: // should never happen break; } @@ -924,7 +997,7 @@ cmExportFileGenerator void cmExportFileGenerator ::GenerateImportPropertyCode(std::ostream& os, const char* config, - cmTarget* target, + cmTarget const* target, ImportPropertyMap const& properties) { // Construct the imported target name. diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 9628b96..1438f4d 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -33,9 +33,11 @@ public: /** Set the full path to the export file to generate. */ void SetExportFile(const char* mainFile); + const char *GetMainExportFileName() const; /** Set the namespace in which to place exported target names. */ void SetNamespace(const char* ns) { this->Namespace = ns; } + std::string GetNamespace() const { return this->Namespace; } void SetExportOld(bool exportOld) { this->ExportOld = exportOld; } @@ -58,9 +60,9 @@ protected: void GenerateImportHeaderCode(std::ostream& os, const char* config = 0); void GenerateImportFooterCode(std::ostream& os); void GenerateImportVersionCode(std::ostream& os); - void GenerateImportTargetCode(std::ostream& os, cmTarget* target); + void GenerateImportTargetCode(std::ostream& os, cmTarget const* target); void GenerateImportPropertyCode(std::ostream& os, const char* config, - cmTarget* target, + cmTarget const* target, ImportPropertyMap const& properties); void GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target, ImportPropertyMap const& properties, @@ -80,7 +82,7 @@ protected: std::vector<std::string>& missingTargets); void SetImportLinkProperty(std::string const& suffix, cmTarget* target, const char* propName, - std::vector<std::string> const& libs, + std::vector<std::string> const& entries, ImportPropertyMap& properties, std::vector<std::string>& missingTargets); @@ -113,7 +115,7 @@ protected: ImportPropertyMap &properties); void PopulateCompatibleInterfaceProperties(cmTarget *target, ImportPropertyMap &properties); - void GenerateInterfaceProperties(cmTarget *target, std::ostream& os, + void GenerateInterfaceProperties(cmTarget const* target, std::ostream& os, const ImportPropertyMap &properties); void PopulateIncludeDirectoriesInterface( cmTargetExport *target, diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index c97d4ff..73e9b31 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -81,10 +81,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) os << "# Compute the installation prefix relative to this file.\n" << "get_filename_component(_IMPORT_PREFIX" << " \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"; - if(strncmp(absDestS.c_str(), "/lib/", 5) == 0 || - strncmp(absDestS.c_str(), "/lib64/", 7) == 0 || - strncmp(absDestS.c_str(), "/usr/lib/", 9) == 0 || - strncmp(absDestS.c_str(), "/usr/lib64/", 11) == 0) + if(cmHasLiteralPrefix(absDestS.c_str(), "/lib/") || + cmHasLiteralPrefix(absDestS.c_str(), "/lib64/") || + cmHasLiteralPrefix(absDestS.c_str(), "/usr/lib/") || + cmHasLiteralPrefix(absDestS.c_str(), "/usr/lib64/")) { // Handle "/usr move" symlinks created by some Linux distros. os << @@ -114,12 +114,18 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) std::vector<std::string> missingTargets; bool require2_8_12 = false; + bool require3_0_0 = false; + bool requiresConfigFiles = false; // Create all the imported targets. for(std::vector<cmTargetExport*>::const_iterator tei = allTargets.begin(); tei != allTargets.end(); ++tei) { cmTarget* te = (*tei)->Target; + + requiresConfigFiles = requiresConfigFiles + || te->GetType() != cmTarget::INTERFACE_LIBRARY; + this->GenerateImportTargetCode(os, te); ImportPropertyMap properties; @@ -139,6 +145,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) te, cmGeneratorExpression::InstallInterface, properties, missingTargets); + this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", + te, + cmGeneratorExpression::InstallInterface, + properties, missingTargets); const bool newCMP0022Behavior = te->GetPolicyStatusCMP0022() != cmPolicies::WARN @@ -153,6 +163,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) require2_8_12 = true; } } + if (te->GetType() == cmTarget::INTERFACE_LIBRARY) + { + require3_0_0 = true; + } this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", te, properties); this->PopulateCompatibleInterfaceProperties(te, properties); @@ -160,9 +174,13 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) this->GenerateInterfaceProperties(te, os, properties); } - if (require2_8_12) + if (require3_0_0) + { + this->GenerateRequiredCMakeVersion(os, "2.8.12.20131007"); + } + else if (require2_8_12) { - this->GenerateRequiredCMakeVersion(os, "2.8.11.20130626"); + this->GenerateRequiredCMakeVersion(os, "2.8.12"); } // Now load per-configuration properties for them. @@ -184,15 +202,19 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) } this->GenerateImportedFileCheckLoop(os); - // Generate an import file for each configuration. bool result = true; - for(std::vector<std::string>::const_iterator - ci = this->Configurations.begin(); - ci != this->Configurations.end(); ++ci) + // Generate an import file for each configuration. + // Don't do this if we only export INTERFACE_LIBRARY targets. + if (requiresConfigFiles) { - if(!this->GenerateImportFileConfig(ci->c_str(), missingTargets)) + for(std::vector<std::string>::const_iterator + ci = this->Configurations.begin(); + ci != this->Configurations.end(); ++ci) { - result = false; + if(!this->GenerateImportFileConfig(ci->c_str(), missingTargets)) + { + result = false; + } } } @@ -284,8 +306,14 @@ cmExportInstallFileGenerator { // Collect import properties for this target. cmTargetExport const* te = *tei; + if (te->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } + ImportPropertyMap properties; std::set<std::string> importedLocations; + this->SetImportLocationProperty(config, suffix, te->ArchiveGenerator, properties, importedLocations); this->SetImportLocationProperty(config, suffix, te->LibraryGenerator, @@ -415,8 +443,8 @@ cmExportInstallFileGenerator::HandleMissingTarget( } else { - // We are not appending, so all exported targets should be - // known here. This is probably user-error. + // All exported targets should be known here and should be unique. + // This is probably user-error. this->ComplainAboutMissingTarget(depender, dependee, targetOccurrences); } } diff --git a/Source/cmExportLibraryDependencies.cxx b/Source/cmExportLibraryDependencies.cxx index f07b783..4624e92 100644 --- a/Source/cmExportLibraryDependencies.cxx +++ b/Source/cmExportLibraryDependencies.cxx @@ -21,6 +21,10 @@ bool cmExportLibraryDependenciesCommand ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) { + if(this->Disallowed(cmPolicies::CMP0033, + "The export_library_dependencies command should not be called; " + "see CMP0033.")) + { return true; } if(args.size() < 1 ) { this->SetError("called with incorrect number of arguments"); @@ -51,11 +55,11 @@ void cmExportLibraryDependenciesCommand::FinalPass() void cmExportLibraryDependenciesCommand::ConstFinalPass() const { // Use copy-if-different if not appending. - cmsys::auto_ptr<std::ofstream> foutPtr; + cmsys::auto_ptr<cmsys::ofstream> foutPtr; if(this->Append) { - cmsys::auto_ptr<std::ofstream> ap( - new std::ofstream(this->Filename.c_str(), std::ios::app)); + cmsys::auto_ptr<cmsys::ofstream> ap( + new cmsys::ofstream(this->Filename.c_str(), std::ios::app)); foutPtr = ap; } else @@ -169,7 +173,7 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const const char* vertest = "\"${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}\" GREATER 2.4"; fout << "# Generated by CMake " << cmVersion::GetCMakeVersion() << "\n\n"; - fout << "IF(" << vertest << ")\n"; + fout << "if(" << vertest << ")\n"; fout << " # Information for CMake 2.6 and above.\n"; for(std::map<cmStdString, cmStdString>::const_iterator i = libDepsNew.begin(); @@ -177,10 +181,10 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const { if(!i->second.empty()) { - fout << " SET(\"" << i->first << "\" \"" << i->second << "\")\n"; + fout << " set(\"" << i->first << "\" \"" << i->second << "\")\n"; } } - fout << "ELSE(" << vertest << ")\n"; + fout << "else()\n"; fout << " # Information for CMake 2.4 and lower.\n"; for(std::map<cmStdString, cmStdString>::const_iterator i = libDepsOld.begin(); @@ -188,7 +192,7 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const { if(!i->second.empty()) { - fout << " SET(\"" << i->first << "\" \"" << i->second << "\")\n"; + fout << " set(\"" << i->first << "\" \"" << i->second << "\")\n"; } } for(std::map<cmStdString, cmStdString>::const_iterator i = libTypes.begin(); @@ -196,9 +200,9 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const { if(i->second != "general") { - fout << " SET(\"" << i->first << "\" \"" << i->second << "\")\n"; + fout << " set(\"" << i->first << "\" \"" << i->second << "\")\n"; } } - fout << "ENDIF(" << vertest << ")\n"; + fout << "endif()\n"; return; } diff --git a/Source/cmExportLibraryDependencies.h b/Source/cmExportLibraryDependencies.h index d8b65cc..29b568f 100644 --- a/Source/cmExportLibraryDependencies.h +++ b/Source/cmExportLibraryDependencies.h @@ -14,82 +14,19 @@ #include "cmCommand.h" -/** \class cmExportLibraryDependenciesCommand - * \brief Add a test to the lists of tests to run. - * - * cmExportLibraryDependenciesCommand adds a test to the list of tests to run - * - */ class cmExportLibraryDependenciesCommand : public cmCommand { public: - /** - * This is a virtual constructor for the command. - */ - virtual cmCommand* Clone() - { - return new cmExportLibraryDependenciesCommand; - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ + cmTypeMacro(cmExportLibraryDependenciesCommand, cmCommand); + virtual cmCommand* Clone() { return new cmExportLibraryDependenciesCommand; } virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); + virtual const char* GetName() const { return "export_library_dependencies";} + virtual bool IsDiscouraged() const { return true; } - /** - * This is called at the end after all the information - * specified by the command is accumulated. - */ virtual void FinalPass(); virtual bool HasFinalPass() const { return true; } - /** - * The name of the command as specified in CMakeList.txt. - */ - virtual const char* GetName() const { return "export_library_dependencies";} - - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Deprecated. Use INSTALL(EXPORT) or EXPORT command."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - "This command generates an old-style library dependencies file. " - "Projects requiring CMake 2.6 or later should not use the command. " - "Use instead the install(EXPORT) command to help export targets " - "from an installation tree and the export() command to export targets " - "from a build tree.\n" - "The old-style library dependencies file does not take into account " - "per-configuration names of libraries or the LINK_INTERFACE_LIBRARIES " - "target property.\n" - " export_library_dependencies(<file> [APPEND])\n" - "Create a file named <file> that can be included into a CMake listfile " - "with the INCLUDE command. The file will contain a number of SET " - "commands that will set all the variables needed for library dependency " - "information. This should be the last command in the top level " - "CMakeLists.txt file of the project. If the APPEND option is " - "specified, the SET commands will be appended to the given file " - "instead of replacing it."; - } - - /** This command is kept for compatibility with older CMake versions. */ - virtual bool IsDiscouraged() const - { - return true; - } - - cmTypeMacro(cmExportLibraryDependenciesCommand, cmCommand); - private: std::string Filename; bool Append; diff --git a/Source/cmExportSetMap.cxx b/Source/cmExportSetMap.cxx index 96fdb3e..5174118 100644 --- a/Source/cmExportSetMap.cxx +++ b/Source/cmExportSetMap.cxx @@ -23,7 +23,7 @@ cmExportSet* cmExportSetMap::operator[](const std::string &name) return it->second; } -cmExportSetMap::~cmExportSetMap() +void cmExportSetMap::clear() { for(std::map<std::string, cmExportSet*>::iterator it = this->begin(); it != this->end(); @@ -31,4 +31,10 @@ cmExportSetMap::~cmExportSetMap() { delete it->second; } + this->derived::clear(); +} + +cmExportSetMap::~cmExportSetMap() +{ + this->clear(); } diff --git a/Source/cmExportSetMap.h b/Source/cmExportSetMap.h index 4663c55..965046c 100644 --- a/Source/cmExportSetMap.h +++ b/Source/cmExportSetMap.h @@ -18,6 +18,7 @@ class cmExportSet; /// A name -> cmExportSet map with overloaded operator[]. class cmExportSetMap : public std::map<std::string, cmExportSet*> { + typedef std::map<std::string, cmExportSet*> derived; public: /** \brief Overloaded operator[]. * @@ -26,6 +27,8 @@ public: */ cmExportSet* operator[](const std::string &name); + void clear(); + /// Overloaded destructor deletes all member export sets. ~cmExportSetMap(); }; diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 819ac37..8d37b62 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -18,11 +18,11 @@ //---------------------------------------------------------------------------- bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os) { - std::set<cmTarget*> emitted; - std::set<cmTarget*> emittedDeps; + std::set<cmTarget const*> emitted; + std::set<cmTarget const*> emittedDeps; while(!this->Exports.empty()) { - cmTarget* te = this->Exports.back(); + cmTarget const* te = this->Exports.back(); this->Exports.pop_back(); if (emitted.insert(te).second) { @@ -32,10 +32,12 @@ bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os) ImportPropertyMap properties; #define FIND_TARGETS(PROPERTY) \ - this->FindTargets(#PROPERTY, te, emittedDeps); + this->FindTargets("INTERFACE_" #PROPERTY, te, emittedDeps); CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(FIND_TARGETS) +#undef FIND_TARGETS + this->PopulateProperties(te, properties, emittedDeps); this->GenerateInterfaceProperties(te, os, properties); @@ -45,8 +47,8 @@ bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os) } std::string cmExportTryCompileFileGenerator::FindTargets(const char *propName, - cmTarget *tgt, - std::set<cmTarget*> &emitted) + cmTarget const* tgt, + std::set<cmTarget const*> &emitted) { const char *prop = tgt->GetProperty(propName); if(!prop) @@ -70,8 +72,8 @@ std::string cmExportTryCompileFileGenerator::FindTargets(const char *propName, std::string result = cge->Evaluate(tgt->GetMakefile(), this->Config, false, &dummyHead, tgt, &dagChecker); - const std::set<cmTarget*> &allTargets = cge->GetAllTargetsSeen(); - for(std::set<cmTarget*>::const_iterator li = allTargets.begin(); + const std::set<cmTarget const*> &allTargets = cge->GetAllTargetsSeen(); + for(std::set<cmTarget const*>::const_iterator li = allTargets.begin(); li != allTargets.end(); ++li) { if(emitted.insert(*li).second) @@ -84,9 +86,9 @@ std::string cmExportTryCompileFileGenerator::FindTargets(const char *propName, //---------------------------------------------------------------------------- void -cmExportTryCompileFileGenerator::PopulateProperties(cmTarget* target, +cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target, ImportPropertyMap& properties, - std::set<cmTarget*> &emitted) + std::set<cmTarget const*> &emitted) { cmPropertyMap props = target->GetProperties(); for(cmPropertyMap::const_iterator i = props.begin(); i != props.end(); ++i) diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h index 91b4a61..71ac0dd 100644 --- a/Source/cmExportTryCompileFileGenerator.h +++ b/Source/cmExportTryCompileFileGenerator.h @@ -21,7 +21,7 @@ class cmExportTryCompileFileGenerator: public cmExportFileGenerator { public: /** Set the list of targets to export. */ - void SetExports(const std::vector<cmTarget*> &exports) + void SetExports(const std::vector<cmTarget const*> &exports) { this->Exports = exports; } void SetConfig(const char *config) { this->Config = config; } protected: @@ -39,18 +39,18 @@ protected: cmTarget*, cmTarget*) {} - void PopulateProperties(cmTarget* target, + void PopulateProperties(cmTarget const* target, ImportPropertyMap& properties, - std::set<cmTarget*> &emitted); + std::set<cmTarget const*> &emitted); std::string InstallNameDir(cmTarget* target, const std::string& config); private: - std::string FindTargets(const char *prop, cmTarget *tgt, - std::set<cmTarget*> &emitted); + std::string FindTargets(const char *prop, cmTarget const* tgt, + std::set<cmTarget const*> &emitted); - std::vector<cmTarget*> Exports; + std::vector<cmTarget const*> Exports; const char *Config; }; diff --git a/Source/cmExprLexer.cxx b/Source/cmExprLexer.cxx index 9947c77..aa384cd 100644 --- a/Source/cmExprLexer.cxx +++ b/Source/cmExprLexer.cxx @@ -1716,7 +1716,7 @@ void cmExpr_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) } /** Set the current line number. - * @param line_number + * @param line_number The line number to set. * @param yyscanner The scanner object. */ void cmExpr_yyset_lineno (int line_number , yyscan_t yyscanner) @@ -1731,7 +1731,7 @@ void cmExpr_yyset_lineno (int line_number , yyscan_t yyscanner) } /** Set the current column. - * @param column_no + * @param column_no The column number to set. * @param yyscanner The scanner object. */ void cmExpr_yyset_column (int column_no , yyscan_t yyscanner) diff --git a/Source/cmExternalMakefileProjectGenerator.cxx b/Source/cmExternalMakefileProjectGenerator.cxx index 9c965cc..0d42c35 100644 --- a/Source/cmExternalMakefileProjectGenerator.cxx +++ b/Source/cmExternalMakefileProjectGenerator.cxx @@ -13,6 +13,12 @@ #include "cmExternalMakefileProjectGenerator.h" +void cmExternalMakefileProjectGenerator +::EnableLanguage(std::vector<std::string> const&, + cmMakefile *, bool) +{ +} + std::string cmExternalMakefileProjectGenerator::CreateFullGeneratorName( const char* globalGenerator, const char* extraGenerator) diff --git a/Source/cmExternalMakefileProjectGenerator.h b/Source/cmExternalMakefileProjectGenerator.h index 182c1a8..bce441d 100644 --- a/Source/cmExternalMakefileProjectGenerator.h +++ b/Source/cmExternalMakefileProjectGenerator.h @@ -41,6 +41,8 @@ public: /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry, const char* fullName) const = 0; + virtual void EnableLanguage(std::vector<std::string> const& languages, + cmMakefile *, bool optional); ///! set the global generator which will generate the makefiles virtual void SetGlobalGenerator(cmGlobalGenerator* generator) diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index dfbb1c0..548c88b 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -42,13 +42,6 @@ void cmExtraCodeBlocksGenerator { entry.Name = this->GetName(); entry.Brief = "Generates CodeBlocks project files."; - entry.Full = - "Project files for CodeBlocks will be created in the top directory " - "and in every subdirectory which features a CMakeLists.txt file " - "containing a PROJECT() call. " - "Additionally a hierarchy of makefiles is generated into the " - "build tree. The appropriate make program can build the project through " - "the default make target. A \"make install\" target is also provided."; } cmExtraCodeBlocksGenerator::cmExtraCodeBlocksGenerator() @@ -336,31 +329,11 @@ void cmExtraCodeBlocksGenerator { case cmTarget::GLOBAL_TARGET: { - bool insertTarget = false; // Only add the global targets from CMAKE_BINARY_DIR, // not from the subdirs if (strcmp(makefile->GetStartOutputDirectory(), makefile->GetHomeOutputDirectory())==0) { - insertTarget = true; - // only add the "edit_cache" target if it's not ccmake, because - // this will not work within the IDE - if (ti->first == "edit_cache") - { - const char* editCommand = makefile->GetDefinition - ("CMAKE_EDIT_COMMAND"); - if (editCommand == 0) - { - insertTarget = false; - } - else if (strstr(editCommand, "ccmake")!=NULL) - { - insertTarget = false; - } - } - } - if (insertTarget) - { this->AppendTarget(fout, ti->first.c_str(), 0, make.c_str(), makefile, compiler.c_str()); } @@ -425,7 +398,8 @@ void cmExtraCodeBlocksGenerator case cmTarget::OBJECT_LIBRARY: case cmTarget::UTILITY: // can have sources since 2.6.3 { - const std::vector<cmSourceFile*>&sources=ti->second.GetSourceFiles(); + std::vector<cmSourceFile*> sources; + ti->second.GetSourceFiles(sources); for (std::vector<cmSourceFile*>::const_iterator si=sources.begin(); si!=sources.end(); si++) { @@ -787,10 +761,12 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand( std::string command = make; if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0) { + // For Windows ConvertToOutputPath already adds quotes when required. + // These need to be escaped, see + // http://public.kitware.com/Bug/view.php?id=13952 std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile); - command += " /NOLOGO /f ""; - command += makefileName; - command += "" "; + command += " /NOLOGO /f "; + command += cmXMLSafe(makefileName).str(); command += " VERBOSE=1 "; command += target; } diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx new file mode 100644 index 0000000..b156691 --- /dev/null +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -0,0 +1,487 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2009 Kitware, Inc. + Copyright 2004 Alexander Neundorf (neundorf@kde.org) + Copyright 2013 Eran Ifrah (eran.ifrah@gmail.com) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmExtraCodeLiteGenerator.h" +#include "cmGlobalUnixMakefileGenerator3.h" +#include "cmLocalUnixMakefileGenerator3.h" +#include "cmMakefile.h" +#include "cmake.h" +#include "cmSourceFile.h" +#include "cmGeneratedFileStream.h" +#include "cmSystemTools.h" + +#include <cmsys/SystemTools.hxx> +#include <cmsys/SystemInformation.hxx> +#include <cmsys/Directory.hxx> +#include "cmXMLSafe.h" +#include <sstream> + +//---------------------------------------------------------------------------- +void cmExtraCodeLiteGenerator::GetDocumentation(cmDocumentationEntry& entry, + const char*) const +{ + entry.Name = this->GetName(); + entry.Brief = "Generates CodeLite project files."; +} + +cmExtraCodeLiteGenerator::cmExtraCodeLiteGenerator() + : cmExternalMakefileProjectGenerator() + , ConfigName("NoConfig") + , CpuCount(2) +{ +#if defined(_WIN32) + this->SupportedGlobalGenerators.push_back("MinGW Makefiles"); + this->SupportedGlobalGenerators.push_back("NMake Makefiles"); +#endif + this->SupportedGlobalGenerators.push_back("Ninja"); + this->SupportedGlobalGenerators.push_back("Unix Makefiles"); +} + +void cmExtraCodeLiteGenerator::Generate() +{ + // Hold root tree information for creating the workspace + std::string workspaceProjectName; + std::string workspaceOutputDir; + std::string workspaceFileName; + std::string workspaceSourcePath; + std::string lprjdebug; + + cmGeneratedFileStream fout; + + // loop projects and locate the root project. + // and extract the information for creating the worspace + for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator + it = this->GlobalGenerator->GetProjectMap().begin(); + it!= this->GlobalGenerator->GetProjectMap().end(); + ++it) + { + const cmMakefile* mf =it->second[0]->GetMakefile(); + this->ConfigName = GetConfigurationName( mf ); + + if (strcmp(mf->GetStartOutputDirectory(), + mf->GetHomeOutputDirectory()) == 0) + { + workspaceOutputDir = mf->GetStartOutputDirectory(); + workspaceProjectName = mf->GetProjectName(); + workspaceSourcePath = mf->GetHomeDirectory(); + workspaceFileName = workspaceOutputDir+"/"; + workspaceFileName += workspaceProjectName + ".workspace"; + this->WorkspacePath = mf->GetStartOutputDirectory();; + + fout.Open(workspaceFileName.c_str(), false, false); + fout << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<CodeLite_Workspace Name=\"" << workspaceProjectName << "\" >\n"; + } + } + + // for each sub project in the workspace create a codelite project + for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator + it = this->GlobalGenerator->GetProjectMap().begin(); + it!= this->GlobalGenerator->GetProjectMap().end(); + ++it) + { + // retrive project information + const cmMakefile* mf = it->second[0]->GetMakefile(); + std::string outputDir = mf->GetStartOutputDirectory(); + std::string projectName = mf->GetProjectName(); + std::string filename = outputDir + "/" + projectName + ".project"; + + // Make the project file relative to the workspace + filename = cmSystemTools::RelativePath(this->WorkspacePath.c_str(), + filename.c_str()); + + // create a project file + this->CreateProjectFile(it->second); + fout << " <Project Name=\"" << projectName << "\" Path=\"" + << filename << "\" Active=\"No\"/>\n"; + lprjdebug += "<Project Name=\"" + projectName + + "\" ConfigName=\"" + this->ConfigName + "\"/>\n"; + } + + fout << " <BuildMatrix>\n" + " <WorkspaceConfiguration Name=\"" + << this->ConfigName << "\" Selected=\"yes\">\n" + " " << lprjdebug << "" + " </WorkspaceConfiguration>\n" + " </BuildMatrix>\n" + "</CodeLite_Workspace>\n"; +} + +/* create the project file */ +void cmExtraCodeLiteGenerator::CreateProjectFile( + const std::vector<cmLocalGenerator*>& lgs) +{ + const cmMakefile* mf = lgs[0]->GetMakefile(); + std::string outputDir = mf->GetStartOutputDirectory(); + std::string projectName = mf->GetProjectName(); + std::string filename = outputDir + "/"; + + filename += projectName + ".project"; + this->CreateNewProjectFile(lgs, filename); +} + +void cmExtraCodeLiteGenerator +::CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs, + const std::string& filename) +{ + const cmMakefile* mf=lgs[0]->GetMakefile(); + cmGeneratedFileStream fout(filename.c_str()); + if(!fout) + { + return; + } + + // figure out the compiler + //std::string compiler = this->GetCBCompilerId(mf); + std::string workspaceSourcePath = mf->GetHomeDirectory(); + std::string workspaceOutputDir = mf->GetHomeOutputDirectory(); + std::vector<std::string> outputFiles = mf->GetOutputFiles(); + std::string projectName = mf->GetProjectName(); + std::string incDirs; + std::vector<cmValueWithOrigin> incDirsVec = + mf->GetIncludeDirectoriesEntries(); + std::vector<cmValueWithOrigin>::const_iterator iterInc = incDirsVec.begin(); + + //std::cout << "GetIncludeDirectories:" << std::endl; + for(; iterInc != incDirsVec.end(); ++iterInc ) + { + //std::cout << (*ItStrVec) << std::endl; + incDirs += iterInc->Value + " "; + } + + //////////////////////////////////// + fout << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<CodeLite_Project Name=\"" << mf->GetProjectName() + << "\" InternalType=\"\">\n"; + + // Collect all used source files in the project + // Sort them into two containers, one for C/C++ implementation files + // which may have an acompanying header, one for all other files + std::string projectType; + + std::map<std::string, cmSourceFile*> cFiles; + std::set<std::string> otherFiles; + for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin(); + lg!=lgs.end(); lg++) + { + cmMakefile* makefile=(*lg)->GetMakefile(); + cmTargets& targets=makefile->GetTargets(); + for (cmTargets::iterator ti = targets.begin(); + ti != targets.end(); ti++) + { + + switch(ti->second.GetType()) + { + case cmTarget::EXECUTABLE: + { + projectType = "Executable"; + } + break; + case cmTarget::STATIC_LIBRARY: + { + projectType = "Static Library"; + } + break; + case cmTarget::SHARED_LIBRARY: + { + projectType = "Dynamic Library"; + } + break; + case cmTarget::MODULE_LIBRARY: + { + projectType = "Dynamic Library"; + } + break; + default: // intended fallthrough + break; + } + + switch(ti->second.GetType()) + { + case cmTarget::EXECUTABLE: + case cmTarget::STATIC_LIBRARY: + case cmTarget::SHARED_LIBRARY: + case cmTarget::MODULE_LIBRARY: + { + std::vector<cmSourceFile*> sources; + ti->second.GetSourceFiles(sources); + for (std::vector<cmSourceFile*>::const_iterator si=sources.begin(); + si!=sources.end(); si++) + { + // check whether it is a C/C++ implementation file + bool isCFile = false; + if ((*si)->GetLanguage() && (*(*si)->GetLanguage() == 'C')) + { + for(std::vector<std::string>::const_iterator + ext = mf->GetSourceExtensions().begin(); + ext != mf->GetSourceExtensions().end(); + ++ext) + { + if ((*si)->GetExtension() == *ext) + { + isCFile = true; + break; + } + } + } + + // then put it accordingly into one of the two containers + if (isCFile) + { + cFiles[(*si)->GetFullPath()] = *si ; + } + else + { + otherFiles.insert((*si)->GetFullPath()); + } + } + } + default: // intended fallthrough + break; + } + } + } + + // The following loop tries to add header files matching to implementation + // files to the project. It does that by iterating over all source files, + // replacing the file name extension with ".h" and checks whether such a + // file exists. If it does, it is inserted into the map of files. + // A very similar version of that code exists also in the kdevelop + // project generator. + for (std::map<std::string, cmSourceFile*>::const_iterator + sit=cFiles.begin(); + sit!=cFiles.end(); + ++sit) + { + std::string headerBasename=cmSystemTools::GetFilenamePath(sit->first); + headerBasename+="/"; + headerBasename+=cmSystemTools::GetFilenameWithoutExtension(sit->first); + + // check if there's a matching header around + for(std::vector<std::string>::const_iterator + ext = mf->GetHeaderExtensions().begin(); + ext != mf->GetHeaderExtensions().end(); + ++ext) + { + std::string hname=headerBasename; + hname += "."; + hname += *ext; + // if it's already in the set, don't check if it exists on disk + std::set<std::string>::const_iterator headerIt=otherFiles.find(hname); + if (headerIt != otherFiles.end()) + { + break; + } + + if(cmSystemTools::FileExists(hname.c_str())) + { + otherFiles.insert(hname); + break; + } + } + } + + // Get the project path ( we need it later to convert files to + // their relative path) + std::string projectPath = cmSystemTools::GetFilenamePath(filename); + + // Create 2 virtual folders: src and include + // and place all the implementation files into the src + // folder, the rest goes to the include folder + fout<< " <VirtualDirectory Name=\"src\">\n"; + + // insert all source files in the codelite project + // first the C/C++ implementation files, then all others + for (std::map<std::string, cmSourceFile*>::const_iterator + sit=cFiles.begin(); + sit!=cFiles.end(); + ++sit) + { + std::string relativePath = + cmSystemTools::RelativePath(projectPath.c_str(), sit->first.c_str()); + fout<< " <File Name=\"" << relativePath.c_str() << "\"/>\n"; + } + fout<< " </VirtualDirectory>\n"; + fout<< " <VirtualDirectory Name=\"include\">\n"; + for (std::set<std::string>::const_iterator + sit=otherFiles.begin(); + sit!=otherFiles.end(); + ++sit) + { + std::string relativePath = + cmSystemTools::RelativePath(projectPath.c_str(), sit->c_str()); + fout << " <File Name=\"" << relativePath.c_str() << "\"/>\n"; + } + fout << " </VirtualDirectory>\n"; + + // Get the number of CPUs. We use this information for the make -jN + // command + cmsys::SystemInformation info; + info.RunCPUCheck(); + + this->CpuCount = info.GetNumberOfLogicalCPU() * + info.GetNumberOfPhysicalCPU(); + + std::string cleanCommand = GetCleanCommand(mf); + std::string buildCommand = GetBuildCommand(mf); + std::string rebuildCommand = GetRebuildCommand(mf); + std::string singleFileCommand = GetSingleFileBuildCommand(mf); + + std::string codeliteCompilerName = this->GetCodeLiteCompilerName(mf); + + fout << "\n" + " <Settings Type=\"" << projectType << "\">\n" + " <Configuration Name=\"" << this->ConfigName << "\" CompilerType=\"" + << codeliteCompilerName << "\" DebuggerType=\"GNU gdb debugger\" " + "Type=\"" + << projectType << "\" BuildCmpWithGlobalSettings=\"append\" " + "BuildLnkWithGlobalSettings=\"append\" " + "BuildResWithGlobalSettings=\"append\">\n" + " <Compiler Options=\"-g\" " + "Required=\"yes\" PreCompiledHeader=\"\">\n" + " <IncludePath Value=\".\"/>\n" + " </Compiler>\n" + " <Linker Options=\"\" Required=\"yes\"/>\n" + " <ResourceCompiler Options=\"\" Required=\"no\"/>\n" + " <General OutputFile=\"$(IntermediateDirectory)/$(ProjectName)\" " + "IntermediateDirectory=\"./\" Command=\"./$(ProjectName)\" " + "CommandArguments=\"\" WorkingDirectory=\"$(IntermediateDirectory)\" " + "PauseExecWhenProcTerminates=\"yes\"/>\n" + " <Debugger IsRemote=\"no\" RemoteHostName=\"\" " + "RemoteHostPort=\"\" DebuggerPath=\"\">\n" + " <PostConnectCommands/>\n" + " <StartupCommands/>\n" + " </Debugger>\n" + " <PreBuild/>\n" + " <PostBuild/>\n" + " <CustomBuild Enabled=\"yes\">\n" + " <RebuildCommand>" << rebuildCommand << "</RebuildCommand>\n" + " <CleanCommand>" << cleanCommand << "</CleanCommand>\n" + " <BuildCommand>" << buildCommand << "</BuildCommand>\n" + " <SingleFileCommand>" << singleFileCommand + << "</SingleFileCommand>\n" + " <PreprocessFileCommand/>\n" + " <WorkingDirectory>$(WorkspacePath)</WorkingDirectory>\n" + " </CustomBuild>\n" + " <AdditionalRules>\n" + " <CustomPostBuild/>\n" + " <CustomPreBuild/>\n" + " </AdditionalRules>\n" + " </Configuration>\n" + " <GlobalSettings>\n" + " <Compiler Options=\"\">\n" + " <IncludePath Value=\".\"/>\n" + " </Compiler>\n" + " <Linker Options=\"\">\n" + " <LibraryPath Value=\".\"/>\n" + " </Linker>\n" + " <ResourceCompiler Options=\"\"/>\n" + " </GlobalSettings>\n" + " </Settings>\n" + "</CodeLite_Project>\n"; +} + +std::string +cmExtraCodeLiteGenerator::GetCodeLiteCompilerName(const cmMakefile* mf) const +{ + // figure out which language to use + // for now care only for C and C++ + std::string compilerIdVar = "CMAKE_CXX_COMPILER_ID"; + if (this->GlobalGenerator->GetLanguageEnabled("CXX") == false) + { + compilerIdVar = "CMAKE_C_COMPILER_ID"; + } + + std::string compilerId = mf->GetSafeDefinition(compilerIdVar.c_str()); + std::string compiler = "gnu g++"; // default to g++ + + // Since we need the compiler for parsing purposes only + // it does not matter if we use clang or clang++, same as + // "gnu gcc" vs "gnu g++" + if (compilerId == "MSVC") + { + compiler = "VC++"; + } + else if (compilerId == "Clang") + { + compiler = "clang++"; + } + else if (compilerId == "GNU") + { + compiler = "gnu g++"; + } + return compiler; +} + +std::string +cmExtraCodeLiteGenerator::GetConfigurationName(const cmMakefile* mf) const +{ + std::string confName = mf->GetSafeDefinition("CMAKE_BUILD_TYPE"); + // Trim the configuration name from whitespaces (left and right) + confName.erase(0, confName.find_first_not_of(" \t\r\v\n")); + confName.erase(confName.find_last_not_of(" \t\r\v\n")+1); + if ( confName.empty() ) + { + confName = "NoConfig"; + } + return confName; +} + +std::string +cmExtraCodeLiteGenerator::GetBuildCommand(const cmMakefile* mf) const +{ + std::stringstream ss; + std::string generator = mf->GetSafeDefinition("CMAKE_GENERATOR"); + std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + std::string buildCommand = make; // Default + if ( generator == "NMake Makefiles" ) + { + buildCommand = make; + } + else if ( generator == "MinGW Makefiles" || + generator == "Unix Makefiles" || + generator == "Ninja" ) + { + ss << make; + buildCommand = ss.str(); + } + return buildCommand; +} + +std::string +cmExtraCodeLiteGenerator::GetCleanCommand(const cmMakefile* mf) const +{ + return GetBuildCommand(mf) + " clean"; +} + +std::string +cmExtraCodeLiteGenerator::GetRebuildCommand(const cmMakefile* mf) const +{ + return GetCleanCommand(mf) + cmXMLSafe(" && ").str() + GetBuildCommand(mf); +} + +std::string +cmExtraCodeLiteGenerator::GetSingleFileBuildCommand +(const cmMakefile* mf) const +{ + std::string buildCommand; + std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + std::string generator = mf->GetSafeDefinition("CMAKE_GENERATOR"); + if ( generator == "Unix Makefiles" || generator == "MinGW Makefiles" ) + { + std::stringstream ss; + ss << make << " -f$(ProjectPath)/Makefile $(CurrentFileName).cpp.o"; + buildCommand = ss.str(); + } + return buildCommand; +} diff --git a/Source/cmExtraCodeLiteGenerator.h b/Source/cmExtraCodeLiteGenerator.h new file mode 100644 index 0000000..984313e --- /dev/null +++ b/Source/cmExtraCodeLiteGenerator.h @@ -0,0 +1,54 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2009 Kitware, Inc. + Copyright 2004 Alexander Neundorf (neundorf@kde.org) + Copyright 2013 Eran Ifrah (eran.ifrah@gmail.com) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmGlobalCodeLiteGenerator_h +#define cmGlobalCodeLiteGenerator_h + +#include "cmExternalMakefileProjectGenerator.h" + +class cmLocalGenerator; + +class cmExtraCodeLiteGenerator : public cmExternalMakefileProjectGenerator +{ +protected: + std::string ConfigName; + std::string WorkspacePath; + unsigned int CpuCount; + +protected: + std::string GetCodeLiteCompilerName(const cmMakefile* mf) const; + std::string GetConfigurationName( const cmMakefile* mf ) const; + std::string GetBuildCommand(const cmMakefile* mf) const; + std::string GetCleanCommand(const cmMakefile* mf) const; + std::string GetRebuildCommand(const cmMakefile* mf) const; + std::string GetSingleFileBuildCommand(const cmMakefile* mf) const; +public: + cmExtraCodeLiteGenerator(); + + virtual const char* GetName() const + { return cmExtraCodeLiteGenerator::GetActualName();} + static const char* GetActualName() { return "CodeLite";} + static cmExternalMakefileProjectGenerator* New() + { return new cmExtraCodeLiteGenerator; } + /** Get the documentation entry for this generator. */ + virtual void GetDocumentation(cmDocumentationEntry& entry, + const char* fullName) const; + + virtual void Generate(); + void CreateProjectFile(const std::vector<cmLocalGenerator*>& lgs); + + void CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs, + const std::string& filename); +}; + +#endif diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index d80e775..3e9b786 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -40,6 +40,7 @@ cmExtraEclipseCDT4Generator this->SupportsVirtualFolders = true; this->GenerateLinkedResources = true; this->SupportsGmakeErrorParser = true; + this->SupportsMachO64Parser = true; } //---------------------------------------------------------------------------- @@ -48,13 +49,29 @@ void cmExtraEclipseCDT4Generator { entry.Name = this->GetName(); entry.Brief = "Generates Eclipse CDT 4.0 project files."; - entry.Full = - "Project files for Eclipse will be created in the top directory. " - "In out of source builds, a linked resource to the top level source " - "directory will be created. " - "Additionally a hierarchy of makefiles is generated into the " - "build tree. The appropriate make program can build the project through " - "the default make target. A \"make install\" target is also provided."; +} + +//---------------------------------------------------------------------------- +void cmExtraEclipseCDT4Generator +::EnableLanguage(std::vector<std::string> const& languages, + cmMakefile *, bool) +{ + for (std::vector<std::string>::const_iterator lit = languages.begin(); + lit != languages.end(); ++lit) + { + if (*lit == "CXX") + { + this->Natures.insert("org.eclipse.cdt.core.ccnature"); + } + else if (*lit == "C") + { + this->Natures.insert("org.eclipse.cdt.core.cnature"); + } + else if (*lit == "Java") + { + this->Natures.insert("org.eclipse.jdt.core.javanature"); + } + } } //---------------------------------------------------------------------------- @@ -77,6 +94,7 @@ void cmExtraEclipseCDT4Generator::Generate() if (version < 3006) // 3.6 is Helios { this->SupportsVirtualFolders = false; + this->SupportsMachO64Parser = false; } if (version < 3007) // 3.7 is Indigo { @@ -440,13 +458,28 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() // set natures for c/c++ projects fout << "\t<natures>\n" - // TODO: ccnature only if it is c++ ??? - "\t\t<nature>org.eclipse.cdt.core.ccnature</nature>\n" "\t\t<nature>org.eclipse.cdt.make.core.makeNature</nature>\n" - "\t\t<nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature>\n" - "\t\t<nature>org.eclipse.cdt.core.cnature</nature>\n" - "\t</natures>\n" - ; + "\t\t<nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature>\n"; + + for (std::set<std::string>::const_iterator nit=this->Natures.begin(); + nit != this->Natures.end(); ++nit) + { + fout << "\t\t<nature>" << *nit << "</nature>\n"; + } + + if (const char *extraNaturesProp = mf->GetCMakeInstance()-> + GetProperty("ECLIPSE_EXTRA_NATURES", cmProperty::GLOBAL)) + { + std::vector<std::string> extraNatures; + cmSystemTools::ExpandListArgument(extraNaturesProp, extraNatures); + for (std::vector<std::string>::const_iterator nit = extraNatures.begin(); + nit != extraNatures.end(); ++nit) + { + fout << "\t\t<nature>" << *nit << "</nature>\n"; + } + } + + fout << "\t</natures>\n"; fout << "\t<linkedResources>\n"; // create linked resources @@ -526,7 +559,8 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets( std::vector<cmSourceGroup> sourceGroups=makefile->GetSourceGroups(); // get the files from the source lists then add them to the groups cmTarget* tgt = const_cast<cmTarget*>(&ti->second); - std::vector<cmSourceFile*>const & files = tgt->GetSourceFiles(); + std::vector<cmSourceFile*> files; + tgt->GetSourceFiles(files); for(std::vector<cmSourceFile*>::const_iterator sfIt = files.begin(); sfIt != files.end(); sfIt++) @@ -723,7 +757,9 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const } else if (systemName == "Darwin") { - fout << "<extension id=\"org.eclipse.cdt.core.MachO\"" + fout << "<extension id=\"" << + (this->SupportsMachO64Parser ? "org.eclipse.cdt.core.MachO64" + : "org.eclipse.cdt.core.MachO") << "\"" " point=\"org.eclipse.cdt.core.BinaryParser\">\n" "<attribute key=\"c++filt\" value=\"c++filt\"/>\n" "</extension>\n" @@ -1002,30 +1038,10 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const { case cmTarget::GLOBAL_TARGET: { - bool insertTarget = false; // Only add the global targets from CMAKE_BINARY_DIR, // not from the subdirs if (subdir.empty()) { - insertTarget = true; - // only add the "edit_cache" target if it's not ccmake, because - // this will not work within the IDE - if (ti->first == "edit_cache") - { - const char* editCommand = makefile->GetDefinition - ("CMAKE_EDIT_COMMAND"); - if (editCommand == 0) - { - insertTarget = false; - } - else if (strstr(editCommand, "ccmake")!=NULL) - { - insertTarget = false; - } - } - } - if (insertTarget) - { this->AppendTarget(fout, ti->first, make, makeArgs, subdir, ": "); } } @@ -1139,7 +1155,7 @@ cmExtraEclipseCDT4Generator::GetEclipsePath(const std::string& path) #if defined(__CYGWIN__) std::string cmd = "cygpath -m " + path; std::string out; - if (!cmSystemTools::RunCommand(cmd.c_str(), out, 0, false)) + if (!cmSystemTools::RunSingleCommand(cmd.c_str(), &out)) { return path; } diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index b31cce7..d88b247 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -41,6 +41,8 @@ public: virtual void GetDocumentation(cmDocumentationEntry& entry, const char* fullName) const; + virtual void EnableLanguage(std::vector<std::string> const& languages, + cmMakefile *, bool optional); virtual void Generate(); @@ -105,6 +107,7 @@ private: void CreateLinksForTargets(cmGeneratedFileStream& fout); std::vector<std::string> SrcLinkedResources; + std::set<std::string> Natures; std::string HomeDirectory; std::string HomeOutputDirectory; bool IsOutOfSourceBuild; @@ -112,6 +115,7 @@ private: bool GenerateLinkedResources; bool SupportsVirtualFolders; bool SupportsGmakeErrorParser; + bool SupportsMachO64Parser; }; diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx new file mode 100644 index 0000000..0312488 --- /dev/null +++ b/Source/cmExtraKateGenerator.cxx @@ -0,0 +1,350 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2009 Kitware, Inc. + Copyright 2004 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmExtraKateGenerator.h" +#include "cmGlobalUnixMakefileGenerator3.h" +#include "cmLocalUnixMakefileGenerator3.h" +#include "cmMakefile.h" +#include "cmake.h" +#include "cmSourceFile.h" +#include "cmGeneratedFileStream.h" +#include "cmTarget.h" +#include "cmSystemTools.h" +#include "cmXMLSafe.h" + +#include <cmsys/SystemTools.hxx> + +//---------------------------------------------------------------------------- +void cmExtraKateGenerator +::GetDocumentation(cmDocumentationEntry& entry, const char*) const +{ + entry.Name = this->GetName(); + entry.Brief = "Generates Kate project files."; +} + +cmExtraKateGenerator::cmExtraKateGenerator() +:cmExternalMakefileProjectGenerator() +{ +#if defined(_WIN32) + this->SupportedGlobalGenerators.push_back("MinGW Makefiles"); + this->SupportedGlobalGenerators.push_back("NMake Makefiles"); +// disable until somebody actually tests it: +// this->SupportedGlobalGenerators.push_back("MSYS Makefiles"); +#endif + this->SupportedGlobalGenerators.push_back("Ninja"); + this->SupportedGlobalGenerators.push_back("Unix Makefiles"); +} + + +void cmExtraKateGenerator::Generate() +{ + const cmMakefile* mf + = this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile(); + this->ProjectName = this->GenerateProjectName(mf->GetProjectName(), + mf->GetSafeDefinition("CMAKE_BUILD_TYPE"), + this->GetPathBasename(mf->GetHomeOutputDirectory())); + this->UseNinja = (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0); + + this->CreateKateProjectFile(mf); + this->CreateDummyKateProjectFile(mf); +} + + +void cmExtraKateGenerator::CreateKateProjectFile(const cmMakefile* mf) const +{ + std::string filename = mf->GetHomeOutputDirectory(); + filename += "/.kateproject"; + cmGeneratedFileStream fout(filename.c_str()); + if (!fout) + { + return; + } + + std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + std::string args = mf->GetRequiredDefinition("CMAKE_KATE_MAKE_ARGUMENTS"); + + fout << + "{\n" + "\t\"name\": \"" << this->ProjectName << "\",\n" + "\t\"directory\": \"" << mf->GetHomeDirectory() << "\",\n" + "\t\"files\": [ { " << this->GenerateFilesString(mf) << "} ],\n"; + this->WriteTargets(mf, fout); + fout << "}\n"; +} + + +void +cmExtraKateGenerator::WriteTargets(const cmMakefile* mf, + cmGeneratedFileStream& fout) const +{ + const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + const std::string makeArgs = mf->GetSafeDefinition( + "CMAKE_KATE_MAKE_ARGUMENTS"); + const char* homeOutputDir = mf->GetHomeOutputDirectory(); + + fout << + "\t\"build\": {\n" + "\t\t\"directory\": \"" << mf->GetHomeOutputDirectory() << "\",\n" + "\t\t\"default_target\": \"all\",\n" + "\t\t\"clean_target\": \"clean\",\n"; + + // build, clean and quick are for the build plugin kate <= 4.12: + fout << "\t\t\"build\": \"" << make << " -C " << homeOutputDir + << " " << makeArgs << " " << "all\",\n"; + fout << "\t\t\"clean\": \"" << make << " -C " << homeOutputDir + << " " << makeArgs << " " << "clean\",\n"; + fout << "\t\t\"quick\": \"" << make << " -C " << homeOutputDir + << " " << makeArgs << " " << "install\",\n"; + + // this is for kate >= 4.13: + fout << + "\t\t\"targets\":[\n"; + + this->AppendTarget(fout, "all", make, makeArgs, + homeOutputDir, homeOutputDir); + this->AppendTarget(fout, "clean", make, makeArgs, + homeOutputDir, homeOutputDir); + + // add all executable and library targets and some of the GLOBAL + // and UTILITY targets + for (std::vector<cmLocalGenerator*>::const_iterator + it = this->GlobalGenerator->GetLocalGenerators().begin(); + it != this->GlobalGenerator->GetLocalGenerators().end(); + ++it) + { + const cmTargets& targets = (*it)->GetMakefile()->GetTargets(); + cmMakefile* makefile=(*it)->GetMakefile(); + std::string currentDir = makefile->GetCurrentOutputDirectory(); + bool topLevel = (currentDir == makefile->GetHomeOutputDirectory()); + + for(cmTargets::const_iterator ti=targets.begin(); ti!=targets.end(); ++ti) + { + switch(ti->second.GetType()) + { + case cmTarget::GLOBAL_TARGET: + { + bool insertTarget = false; + // Only add the global targets from CMAKE_BINARY_DIR, + // not from the subdirs + if (topLevel) + { + insertTarget = true; + // only add the "edit_cache" target if it's not ccmake, because + // this will not work within the IDE + if (ti->first == "edit_cache") + { + const char* editCommand = makefile->GetDefinition + ("CMAKE_EDIT_COMMAND"); + if (editCommand == 0) + { + insertTarget = false; + } + else if (strstr(editCommand, "ccmake")!=NULL) + { + insertTarget = false; + } + } + } + if (insertTarget) + { + this->AppendTarget(fout, ti->first, make, makeArgs, + currentDir, homeOutputDir); + } + } + break; + case cmTarget::UTILITY: + // Add all utility targets, except the Nightly/Continuous/ + // Experimental-"sub"targets as e.g. NightlyStart + if (((ti->first.find("Nightly")==0) &&(ti->first!="Nightly")) + || ((ti->first.find("Continuous")==0)&&(ti->first!="Continuous")) + || ((ti->first.find("Experimental")==0) + && (ti->first!="Experimental"))) + { + break; + } + + this->AppendTarget(fout, ti->first, make, makeArgs, + currentDir, homeOutputDir); + break; + case cmTarget::EXECUTABLE: + case cmTarget::STATIC_LIBRARY: + case cmTarget::SHARED_LIBRARY: + case cmTarget::MODULE_LIBRARY: + case cmTarget::OBJECT_LIBRARY: + { + this->AppendTarget(fout, ti->first, make, makeArgs, + currentDir, homeOutputDir); + std::string fastTarget = ti->first; + fastTarget += "/fast"; + this->AppendTarget(fout, fastTarget, make, makeArgs, + currentDir, homeOutputDir); + + } + break; + default: + break; + } + } + + //insert rules for compiling, preprocessing and assembling individual files + std::vector<std::string> objectFileTargets; + (*it)->GetIndividualFileTargets(objectFileTargets); + for(std::vector<std::string>::const_iterator fit=objectFileTargets.begin(); + fit != objectFileTargets.end(); + ++fit) + { + this->AppendTarget(fout, *fit, make, makeArgs, currentDir,homeOutputDir); + } + } + + fout << + "\t] }\n"; +} + + +void +cmExtraKateGenerator::AppendTarget(cmGeneratedFileStream& fout, + const std::string& target, + const std::string& make, + const std::string& makeArgs, + const std::string& path, + const char* homeOutputDir + ) const +{ + static char JsonSep = ' '; + + fout << + "\t\t\t" << JsonSep << "{\"name\":\"" << target << "\", " + "\"build_cmd\":\"" << make + << " -C " << (this->UseNinja ? homeOutputDir : path.c_str()) + << " " << makeArgs << " " + << target << "\"}\n"; + + JsonSep = ','; +} + + + +void +cmExtraKateGenerator::CreateDummyKateProjectFile(const cmMakefile* mf) const +{ + std::string filename = mf->GetHomeOutputDirectory(); + filename += "/"; + filename += this->ProjectName; + filename += ".kateproject"; + cmGeneratedFileStream fout(filename.c_str()); + if (!fout) + { + return; + } + + fout << "#Generated by " << mf->GetRequiredDefinition("CMAKE_COMMAND") + << ", do not edit.\n"; +} + + +std::string +cmExtraKateGenerator::GenerateFilesString(const cmMakefile* mf) const +{ + std::string s = mf->GetHomeDirectory(); + s += "/.git"; + if(cmSystemTools::FileExists(s.c_str())) + { + return std::string("\"git\": 1 "); + } + + s = mf->GetHomeDirectory(); + s += "/.svn"; + if(cmSystemTools::FileExists(s.c_str())) + { + return std::string("\"svn\": 1 "); + } + + s = mf->GetHomeDirectory(); + s += "/"; + + std::set<std::string> files; + std::string tmp; + const std::vector<cmLocalGenerator *>& lgs = + this->GlobalGenerator->GetLocalGenerators(); + + for (std::vector<cmLocalGenerator*>::const_iterator it=lgs.begin(); + it!=lgs.end(); it++) + { + cmMakefile* makefile=(*it)->GetMakefile(); + const std::vector<std::string>& listFiles=makefile->GetListFiles(); + for (std::vector<std::string>::const_iterator lt=listFiles.begin(); + lt!=listFiles.end(); lt++) + { + tmp=*lt; + { + files.insert(tmp); + } + } + + const std::vector<cmSourceFile*>& sources = makefile->GetSourceFiles(); + for (std::vector<cmSourceFile*>::const_iterator sfIt = sources.begin(); + sfIt != sources.end(); sfIt++) + { + cmSourceFile* sf = *sfIt; + if (sf->GetPropertyAsBool("GENERATED")) + { + continue; + } + + tmp = sf->GetFullPath(); + files.insert(tmp); + } + } + + const char* sep = ""; + tmp = "\"list\": ["; + for(std::set<std::string>::const_iterator it = files.begin(); + it != files.end(); ++it) + { + tmp += sep; + tmp += " \""; + tmp += *it; + tmp += "\""; + sep = ","; + } + tmp += "] "; + + return tmp; +} + + +std::string cmExtraKateGenerator::GenerateProjectName(const std::string& name, + const std::string& type, + const std::string& path) const +{ + return name + (type.empty() ? "" : "-") + type + "@" + path; +} + + +std::string cmExtraKateGenerator::GetPathBasename(const std::string& path)const +{ + std::string outputBasename = path; + while (outputBasename.size() > 0 && + (outputBasename[outputBasename.size() - 1] == '/' || + outputBasename[outputBasename.size() - 1] == '\\')) + { + outputBasename.resize(outputBasename.size() - 1); + } + std::string::size_type loc = outputBasename.find_last_of("/\\"); + if (loc != std::string::npos) + { + outputBasename = outputBasename.substr(loc + 1); + } + + return outputBasename; +} diff --git a/Source/cmExtraKateGenerator.h b/Source/cmExtraKateGenerator.h new file mode 100644 index 0000000..6ced5fe --- /dev/null +++ b/Source/cmExtraKateGenerator.h @@ -0,0 +1,62 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2009 Kitware, Inc. + Copyright 2013 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmExtraKateGenerator_h +#define cmExtraKateGenerator_h + +#include "cmExternalMakefileProjectGenerator.h" + +class cmLocalGenerator; +class cmMakefile; +class cmTarget; +class cmGeneratedFileStream; + +/** \class cmExtraKateGenerator + * \brief Write Kate project files for Makefile or ninja based projects + */ +class cmExtraKateGenerator : public cmExternalMakefileProjectGenerator +{ +public: + cmExtraKateGenerator(); + + virtual const char* GetName() const + { return cmExtraKateGenerator::GetActualName();} + static const char* GetActualName() { return "Kate";} + static cmExternalMakefileProjectGenerator* New() + { return new cmExtraKateGenerator; } + /** Get the documentation entry for this generator. */ + virtual void GetDocumentation(cmDocumentationEntry& entry, + const char* fullName) const; + + virtual void Generate(); +private: + void CreateKateProjectFile(const cmMakefile* mf) const; + void CreateDummyKateProjectFile(const cmMakefile* mf) const; + void WriteTargets(const cmMakefile* mf, cmGeneratedFileStream& fout) const; + void AppendTarget(cmGeneratedFileStream& fout, + const std::string& target, + const std::string& make, + const std::string& makeArgs, + const std::string& path, + const char* homeOutputDir) const; + + std::string GenerateFilesString(const cmMakefile* mf) const; + std::string GetPathBasename(const std::string& path) const; + std::string GenerateProjectName(const std::string& name, + const std::string& type, + const std::string& path) const; + + std::string ProjectName; + bool UseNinja; +}; + +#endif diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 523fca9..52411e8 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -45,13 +45,6 @@ void cmExtraSublimeTextGenerator { entry.Name = this->GetName(); entry.Brief = "Generates Sublime Text 2 project files."; - entry.Full = - "Project files for Sublime Text 2 will be created in the top directory " - "and in every subdirectory which features a CMakeLists.txt file " - "containing a PROJECT() call. " - "Additionally Makefiles (or build.ninja files) are generated into the " - "build tree. The appropriate make program can build the project through " - "the default make target. A \"make install\" target is also provided."; } cmExtraSublimeTextGenerator::cmExtraSublimeTextGenerator() @@ -179,31 +172,11 @@ void cmExtraSublimeTextGenerator:: { case cmTarget::GLOBAL_TARGET: { - bool insertTarget = false; // Only add the global targets from CMAKE_BINARY_DIR, // not from the subdirs if (strcmp(makefile->GetStartOutputDirectory(), makefile->GetHomeOutputDirectory())==0) { - insertTarget = true; - // only add the "edit_cache" target if it's not ccmake, because - // this will not work within the IDE - if (ti->first == "edit_cache") - { - const char* editCommand = makefile->GetDefinition - ("CMAKE_EDIT_COMMAND"); - if (editCommand == 0) - { - insertTarget = false; - } - else if (strstr(editCommand, "ccmake")!=NULL) - { - insertTarget = false; - } - } - } - if (insertTarget) - { this->AppendTarget(fout, ti->first.c_str(), *lg, 0, make.c_str(), makefile, compiler.c_str(), sourceFileFlags, false); @@ -264,7 +237,8 @@ void cmExtraSublimeTextGenerator:: { cmGeneratorTarget *gtgt = this->GlobalGenerator ->GetGeneratorTarget(target); - std::vector<cmSourceFile*> const& sourceFiles = target->GetSourceFiles(); + std::vector<cmSourceFile*> sourceFiles; + target->GetSourceFiles(sourceFiles); std::vector<cmSourceFile*>::const_iterator sourceFilesEnd = sourceFiles.end(); for (std::vector<cmSourceFile*>::const_iterator iter = diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index b08c335..4ce1ea5 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -132,8 +132,8 @@ void cmFLTKWrapUICommand::FinalPass() cmSystemTools::Message(msg.c_str(),"Warning"); return; } - std::vector<cmSourceFile*> const& srcs = - target->GetSourceFiles(); + std::vector<cmSourceFile*> srcs; + target->GetSourceFiles(srcs); bool found = false; for (unsigned int i = 0; i < srcs.size(); ++i) { diff --git a/Source/cmFLTKWrapUICommand.h b/Source/cmFLTKWrapUICommand.h index 530de2c..b94390c 100644 --- a/Source/cmFLTKWrapUICommand.h +++ b/Source/cmFLTKWrapUICommand.h @@ -54,28 +54,6 @@ public: */ virtual const char* GetName() const { return "fltk_wrap_ui";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Create FLTK user interfaces Wrappers."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " fltk_wrap_ui(resultingLibraryName source1\n" - " source2 ... sourceN )\n" - "Produce .h and .cxx files for all the .fl and .fld files listed. " - "The resulting .h and .cxx files will be added to a variable named " - "resultingLibraryName_FLTK_UI_SRCS which should be added to your " - "library."; - } - private: /** * List of produced files. diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 4446f72..311763b 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -32,6 +32,7 @@ #include <cmsys/Directory.hxx> #include <cmsys/Glob.hxx> #include <cmsys/RegularExpression.hxx> +#include <cmsys/FStream.hxx> // Table of permissions flags. #if defined(_WIN32) && !defined(__CYGWIN__) @@ -228,7 +229,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args, } // If GetPermissions fails, pretend like it is ok. File open will fail if // the file is not writable - std::ofstream file(fileName.c_str(), append?std::ios::app: std::ios::out); + cmsys::ofstream file(fileName.c_str(), append?std::ios::app: std::ios::out); if ( !file ) { std::string error = "Internal CMake error when trying to open file: "; @@ -283,10 +284,10 @@ bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args) // Open the specified file. #if defined(_WIN32) || defined(__CYGWIN__) - std::ifstream file(fileName.c_str(), std::ios::in | + cmsys::ifstream file(fileName.c_str(), std::ios::in | (hexOutputArg.IsEnabled() ? std::ios::binary : std::ios::in)); #else - std::ifstream file(fileName.c_str(), std::ios::in); + cmsys::ifstream file(fileName.c_str(), std::ios::in); #endif if ( !file ) @@ -577,9 +578,9 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) // Open the specified file. #if defined(_WIN32) || defined(__CYGWIN__) - std::ifstream fin(fileName.c_str(), std::ios::in | std::ios::binary); + cmsys::ifstream fin(fileName.c_str(), std::ios::in | std::ios::binary); #else - std::ifstream fin(fileName.c_str(), std::ios::in); + cmsys::ifstream fin(fileName.c_str(), std::ios::in); #endif if(!fin) { @@ -2490,7 +2491,7 @@ namespace { void *data) { int realsize = (int)(size * nmemb); - std::ofstream* fout = static_cast<std::ofstream*>(data); + cmsys::ofstream* fout = static_cast<cmsys::ofstream*>(data); const char* chPtr = static_cast<char*>(ptr); fout->write(chPtr, realsize); return realsize; @@ -2838,7 +2839,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) return false; } - std::ofstream fout(file.c_str(), std::ios::binary); + cmsys::ofstream fout(file.c_str(), std::ios::binary); if(!fout) { this->SetError("DOWNLOAD cannot open file for write."); @@ -3094,7 +3095,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args) // Open file for reading: // - FILE *fin = fopen(filename.c_str(), "rb"); + FILE *fin = cmsys::SystemTools::Fopen(filename.c_str(), "rb"); if(!fin) { std::string errStr = "UPLOAD cannot open file '"; diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h index aa755d1..ba45815 100644 --- a/Source/cmFileCommand.h +++ b/Source/cmFileCommand.h @@ -48,213 +48,6 @@ public: */ virtual const char* GetName() const { return "file";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "File manipulation command."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " file(WRITE filename \"message to write\"... )\n" - " file(APPEND filename \"message to write\"... )\n" - " file(READ filename variable [LIMIT numBytes] [OFFSET offset] [HEX])\n" - " file(<MD5|SHA1|SHA224|SHA256|SHA384|SHA512> filename variable)\n" - " file(STRINGS filename variable [LIMIT_COUNT num]\n" - " [LIMIT_INPUT numBytes] [LIMIT_OUTPUT numBytes]\n" - " [LENGTH_MINIMUM numBytes] [LENGTH_MAXIMUM numBytes]\n" - " [NEWLINE_CONSUME] [REGEX regex]\n" - " [NO_HEX_CONVERSION])\n" - " file(GLOB variable [RELATIVE path] [globbing expressions]...)\n" - " file(GLOB_RECURSE variable [RELATIVE path] \n" - " [FOLLOW_SYMLINKS] [globbing expressions]...)\n" - " file(RENAME <oldname> <newname>)\n" - " file(REMOVE [file1 ...])\n" - " file(REMOVE_RECURSE [file1 ...])\n" - " file(MAKE_DIRECTORY [directory1 directory2 ...])\n" - " file(RELATIVE_PATH variable directory file)\n" - " file(TO_CMAKE_PATH path result)\n" - " file(TO_NATIVE_PATH path result)\n" - " file(DOWNLOAD url file [INACTIVITY_TIMEOUT timeout]\n" - " [TIMEOUT timeout] [STATUS status] [LOG log] [SHOW_PROGRESS]\n" - " [EXPECTED_HASH ALGO=value] [EXPECTED_MD5 sum]\n" - " [TLS_VERIFY on|off] [TLS_CAINFO file])\n" - " file(UPLOAD filename url [INACTIVITY_TIMEOUT timeout]\n" - " [TIMEOUT timeout] [STATUS status] [LOG log] [SHOW_PROGRESS])\n" - " file(TIMESTAMP filename variable [<format string>] [UTC])\n" - " file(GENERATE OUTPUT output_file\n" - " <INPUT input_file|CONTENT input_content>\n" - " [CONDITION expression])\n" - "WRITE will write a message into a file called 'filename'. It " - "overwrites the file if it already exists, and creates the file " - "if it does not exist. (If the file is a build input, use " - "configure_file to update the file only when its content changes.)\n" - "APPEND will write a message into a file same as WRITE, except " - "it will append it to the end of the file\n" - "READ will read the content of a file and store it into the " - "variable. It will start at the given offset and read up to numBytes. " - "If the argument HEX is given, the binary data will be converted to " - "hexadecimal representation and this will be stored in the variable.\n" - "MD5, SHA1, SHA224, SHA256, SHA384, and SHA512 " - "will compute a cryptographic hash of the content of a file.\n" - "STRINGS will parse a list of ASCII strings from a file and " - "store it in a variable. Binary data in the file are ignored. Carriage " - "return (CR) characters are ignored. It works also for Intel Hex and " - "Motorola S-record files, which are automatically converted to binary " - "format when reading them. Disable this using NO_HEX_CONVERSION.\n" - "LIMIT_COUNT sets the maximum number of strings to return. " - "LIMIT_INPUT sets the maximum number of bytes to read from " - "the input file. " - "LIMIT_OUTPUT sets the maximum number of bytes to store in the " - "output variable. " - "LENGTH_MINIMUM sets the minimum length of a string to return. " - "Shorter strings are ignored. " - "LENGTH_MAXIMUM sets the maximum length of a string to return. Longer " - "strings are split into strings no longer than the maximum length. " - "NEWLINE_CONSUME allows newlines to be included in strings instead " - "of terminating them.\n" - "REGEX specifies a regular expression that a string must match to be " - "returned. Typical usage \n" - " file(STRINGS myfile.txt myfile)\n" - "stores a list in the variable \"myfile\" in which each item is " - "a line from the input file.\n" - "GLOB will generate a list of all files that match the globbing " - "expressions and store it into the variable. Globbing expressions " - "are similar to regular expressions, but much simpler. If RELATIVE " - "flag is specified for an expression, the results will be returned " - "as a relative path to the given path. " - "(We do not recommend using GLOB to collect a list of source files " - "from your source tree. If no CMakeLists.txt file changes when a " - "source is added or removed then the generated build system cannot " - "know when to ask CMake to regenerate.)" - "\n" - "Examples of globbing expressions include:\n" - " *.cxx - match all files with extension cxx\n" - " *.vt? - match all files with extension vta,...,vtz\n" - " f[3-5].txt - match files f3.txt, f4.txt, f5.txt\n" - "GLOB_RECURSE will generate a list similar to the regular GLOB, except " - "it will traverse all the subdirectories of the matched directory and " - "match the files. Subdirectories that are symlinks are only traversed " - "if FOLLOW_SYMLINKS is given or cmake policy CMP0009 is not set to NEW. " - "See cmake --help-policy CMP0009 for more information.\n" - "Examples of recursive globbing include:\n" - " /dir/*.py - match all python files in /dir and subdirectories\n" - "MAKE_DIRECTORY will create the given directories, also if their parent " - "directories don't exist yet\n" - "RENAME moves a file or directory within a filesystem, " - "replacing the destination atomically." - "\n" - "REMOVE will remove the given files, also in subdirectories\n" - "REMOVE_RECURSE will remove the given files and directories, also " - "non-empty directories\n" - "RELATIVE_PATH will determine relative path from directory to the given" - " file.\n" - "TO_CMAKE_PATH will convert path into a cmake style path with unix /. " - " The input can be a single path or a system path like \"$ENV{PATH}\". " - " Note the double quotes around the ENV call TO_CMAKE_PATH only takes " - " one argument. This command will also convert the native list" - " delimiters for a list of paths like the PATH environment variable.\n" - "TO_NATIVE_PATH works just like TO_CMAKE_PATH, but will convert from " - " a cmake style path into the native path style \\ for windows and / " - "for UNIX.\n" - "DOWNLOAD will download the given URL to the given file. " - "If LOG var is specified a log of the download will be put in var. " - "If STATUS var is specified the status of the operation will" - " be put in var. The status is returned in a list of length 2. " - "The first element is the numeric return value for the operation, " - "and the second element is a string value for the error. A 0 " - "numeric error means no error in the operation. " - "If TIMEOUT time is specified, the operation will " - "timeout after time seconds, time should be specified as an integer. " - "The INACTIVITY_TIMEOUT specifies an integer number of seconds of " - "inactivity after which the operation should terminate. " - "If EXPECTED_HASH ALGO=value is specified, the operation will verify " - "that the downloaded file's actual hash matches the expected value, " - "where ALGO is one of MD5, SHA1, SHA224, SHA256, SHA384, or SHA512. " - "If it does not match, the operation fails with an error. " - "(\"EXPECTED_MD5 sum\" is short-hand for \"EXPECTED_HASH MD5=sum\".) " - "If SHOW_PROGRESS is specified, progress information will be printed " - "as status messages until the operation is complete. " - "For https URLs CMake must be built with OpenSSL. " - "TLS/SSL certificates are not checked by default. " - "Set TLS_VERIFY to ON to check certificates and/or use " - "EXPECTED_HASH to verify downloaded content. " - "Set TLS_CAINFO to specify a custom Certificate Authority file. " - "If either TLS option is not given CMake will check variables " - "CMAKE_TLS_VERIFY and CMAKE_TLS_CAINFO, " - "respectively." - "\n" - "UPLOAD will upload the given file to the given URL. " - "If LOG var is specified a log of the upload will be put in var. " - "If STATUS var is specified the status of the operation will" - " be put in var. The status is returned in a list of length 2. " - "The first element is the numeric return value for the operation, " - "and the second element is a string value for the error. A 0 " - "numeric error means no error in the operation. " - "If TIMEOUT time is specified, the operation will " - "timeout after time seconds, time should be specified as an integer. " - "The INACTIVITY_TIMEOUT specifies an integer number of seconds of " - "inactivity after which the operation should terminate. " - "If SHOW_PROGRESS is specified, progress information will be printed " - "as status messages until the operation is complete." - "\n" - "TIMESTAMP will write a string representation of " - "the modification time of filename to variable.\n" - "Should the command be unable to obtain a timestamp " - "variable will be set to the empty string \"\".\n" - "See documentation of the string TIMESTAMP sub-command for more details." - "\n" - "The file() command also provides COPY and INSTALL signatures:\n" - " file(<COPY|INSTALL> files... DESTINATION <dir>\n" - " [FILE_PERMISSIONS permissions...]\n" - " [DIRECTORY_PERMISSIONS permissions...]\n" - " [NO_SOURCE_PERMISSIONS] [USE_SOURCE_PERMISSIONS]\n" - " [FILES_MATCHING]\n" - " [[PATTERN <pattern> | REGEX <regex>]\n" - " [EXCLUDE] [PERMISSIONS permissions...]] [...])\n" - "The COPY signature copies files, directories, and symlinks to a " - "destination folder. " - "Relative input paths are evaluated with respect to the current " - "source directory, and a relative destination is evaluated with " - "respect to the current build directory. " - "Copying preserves input file timestamps, and optimizes out a file " - "if it exists at the destination with the same timestamp. " - "Copying preserves input permissions unless explicit permissions or " - "NO_SOURCE_PERMISSIONS are given (default is USE_SOURCE_PERMISSIONS). " - "See the install(DIRECTORY) command for documentation of permissions, " - "PATTERN, REGEX, and EXCLUDE options. " - "\n" - "The INSTALL signature differs slightly from COPY: " - "it prints status messages, and NO_SOURCE_PERMISSIONS is default. " - "Installation scripts generated by the install() command use this " - "signature (with some undocumented options for internal use)." - "\n" - "GENERATE will write an <output_file> with content from an " - "<input_file>, or from <input_content>. The output is generated " - "conditionally based on the content of the <condition>. The file is " - "written at CMake generate-time and the input may contain generator " - "expressions. The <condition>, <output_file> and <input_file> may " - "also contain generator expressions. The <condition> must evaluate to " - "either '0' or '1'. The <output_file> must evaluate to a unique name " - "among all configurations and among all invocations of file(GENERATE)." - // Undocumented INSTALL options: - // - RENAME <name> - // - OPTIONAL - // - FILES keyword to re-enter files... list - // - PERMISSIONS before REGEX is alias for FILE_PERMISSIONS - // - DIR_PERMISSIONS is alias for DIRECTORY_PERMISSIONS - // - TYPE <FILE|DIRECTORY|EXECUTABLE|PROGRAM| - // STATIC_LIBRARY|SHARED_LIBRARY|MODULE> - // - COMPONENTS, CONFIGURATIONS, PROPERTIES (ignored for compat) - ; - } - cmTypeMacro(cmFileCommand, cmCommand); protected: diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx index 3167be4..02f10c0 100644 --- a/Source/cmFileTimeComparison.cxx +++ b/Source/cmFileTimeComparison.cxx @@ -16,6 +16,8 @@ # include <cmsys/hash_map.hxx> #endif +#include <cmsys/Encoding.hxx> + // Use a platform-specific API to get file times efficiently. #if !defined(_WIN32) || defined(__CYGWIN__) # define cmFileTimeComparison_Type struct stat @@ -86,7 +88,8 @@ bool cmFileTimeComparisonInternal::Stat(const char* fname, // Windows version. Get the modification time from extended file // attributes. WIN32_FILE_ATTRIBUTE_DATA fdata; - if(!GetFileAttributesEx(fname, GetFileExInfoStandard, &fdata)) + if(!GetFileAttributesExW(cmsys::Encoding::ToWide(fname).c_str(), + GetFileExInfoStandard, &fdata)) { return false; } diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index 7ce0032..ae15ee7 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -20,106 +20,6 @@ cmFindBase::cmFindBase() } //---------------------------------------------------------------------------- -void cmFindBase::GenerateDocumentation() -{ - this->cmFindCommon::GenerateDocumentation(); - cmSystemTools::ReplaceString(this->GenericDocumentationPathsOrder, - "FIND_ARGS_XXX", "<VAR> NAMES name"); - this->GenericDocumentation = - " FIND_XXX(<VAR> name1 [path1 path2 ...])\n" - "This is the short-hand signature for the command that " - "is sufficient in many cases. It is the same " - "as FIND_XXX(<VAR> name1 [PATHS path1 path2 ...])\n" - " FIND_XXX(\n" - " <VAR>\n" - " name | NAMES name1 [name2 ...]\n" - " [HINTS path1 [path2 ... ENV var]]\n" - " [PATHS path1 [path2 ... ENV var]]\n" - " [PATH_SUFFIXES suffix1 [suffix2 ...]]\n" - " [DOC \"cache documentation string\"]\n" - " [NO_DEFAULT_PATH]\n" - " [NO_CMAKE_ENVIRONMENT_PATH]\n" - " [NO_CMAKE_PATH]\n" - " [NO_SYSTEM_ENVIRONMENT_PATH]\n" - " [NO_CMAKE_SYSTEM_PATH]\n" - " [CMAKE_FIND_ROOT_PATH_BOTH |\n" - " ONLY_CMAKE_FIND_ROOT_PATH |\n" - " NO_CMAKE_FIND_ROOT_PATH]\n" - " )\n" - "" - "This command is used to find a SEARCH_XXX_DESC. " - "A cache entry named by <VAR> is created to store the result " - "of this command. " - "If the SEARCH_XXX is found the result is stored in the variable " - "and the search will not be repeated unless the variable is cleared. " - "If nothing is found, the result will be " - "<VAR>-NOTFOUND, and the search will be attempted again the " - "next time FIND_XXX is invoked with the same variable. " - "The name of the SEARCH_XXX that " - "is searched for is specified by the names listed " - "after the NAMES argument. Additional search locations " - "can be specified after the PATHS argument. If ENV var is " - "found in the HINTS or PATHS section the environment variable var " - "will be read and converted from a system environment variable to " - "a cmake style list of paths. For example ENV PATH would be a way " - "to list the system path variable. The argument " - "after DOC will be used for the documentation string in " - "the cache. " - "PATH_SUFFIXES specifies additional subdirectories to check below " - "each search path." - "\n" - "If NO_DEFAULT_PATH is specified, then no additional paths are " - "added to the search. " - "If NO_DEFAULT_PATH is not specified, the search process is as follows:\n" - "1. Search paths specified in cmake-specific cache variables. " - "These are intended to be used on the command line with a -DVAR=value. " - "This can be skipped if NO_CMAKE_PATH is passed.\n" - "XXX_EXTRA_PREFIX_ENTRY" - " <prefix>/XXX_SUBDIR for each <prefix> in CMAKE_PREFIX_PATH\n" - " CMAKE_XXX_PATH\n" - " CMAKE_XXX_MAC_PATH\n" - "2. Search paths specified in cmake-specific environment variables. " - "These are intended to be set in the user's shell configuration. " - "This can be skipped if NO_CMAKE_ENVIRONMENT_PATH is passed.\n" - "XXX_EXTRA_PREFIX_ENTRY" - " <prefix>/XXX_SUBDIR for each <prefix> in CMAKE_PREFIX_PATH\n" - " CMAKE_XXX_PATH\n" - " CMAKE_XXX_MAC_PATH\n" - "3. Search the paths specified by the HINTS option. " - "These should be paths computed by system introspection, such as a " - "hint provided by the location of another item already found. " - "Hard-coded guesses should be specified with the PATHS option.\n" - "4. Search the standard system environment variables. " - "This can be skipped if NO_SYSTEM_ENVIRONMENT_PATH is an argument.\n" - " PATH\n" - " XXX_SYSTEM\n" // replace with "", LIB, or INCLUDE - "5. Search cmake variables defined in the Platform files " - "for the current system. This can be skipped if NO_CMAKE_SYSTEM_PATH " - "is passed.\n" - "XXX_EXTRA_PREFIX_ENTRY" - " <prefix>/XXX_SUBDIR for each <prefix> in CMAKE_SYSTEM_PREFIX_PATH\n" - " CMAKE_SYSTEM_XXX_PATH\n" - " CMAKE_SYSTEM_XXX_MAC_PATH\n" - "6. Search the paths specified by the PATHS option " - "or in the short-hand version of the command. " - "These are typically hard-coded guesses.\n" - ; - this->GenericDocumentation += this->GenericDocumentationMacPolicy; - this->GenericDocumentation += this->GenericDocumentationRootPath; - this->GenericDocumentation += this->GenericDocumentationPathsOrder; -} - -//---------------------------------------------------------------------------- -const char* cmFindBase::GetFullDocumentation() const -{ - if(this->GenericDocumentation.empty()) - { - const_cast<cmFindBase *>(this)->GenerateDocumentation(); - } - return this->GenericDocumentation.c_str(); -} - -//---------------------------------------------------------------------------- bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) { if(argsIn.size() < 2 ) @@ -128,11 +28,6 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) return false; } - // CMake versions below 2.3 did not search all these extra - // locations. Preserve compatibility unless a modern argument is - // passed. - bool compatibility = this->Makefile->NeedBackwardsCompatibility(2,3); - // copy argsIn into args so it can be modified, // in the process extract the DOC "documentation" size_t size = argsIn.size(); @@ -212,7 +107,6 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) else if (args[j] == "PATH_SUFFIXES") { doing = DoingPathSuffixes; - compatibility = false; newStyle = true; } else if (args[j] == "NAMES_PER_DIR") @@ -236,7 +130,6 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) else if (this->CheckCommonArgument(args[j])) { doing = DoingNone; - compatibility = false; // Some common arguments were accidentally supported by CMake // 2.4 and 2.6.0 in the short-hand form of the command, so we // must support it even though it is not documented. @@ -259,17 +152,6 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) } } - // Now that arguments have been parsed check the compatibility - // setting. If we need to be compatible with CMake 2.2 and earlier - // do not add the CMake system paths. It is safe to add the CMake - // environment paths and system environment paths because that - // existed in 2.2. It is safe to add the CMake user variable paths - // because the user or project has explicitly set them. - if(compatibility) - { - this->NoCMakeSystemPath = true; - } - if(this->VariableDocumentation.size() == 0) { this->VariableDocumentation = "Where can "; diff --git a/Source/cmFindBase.h b/Source/cmFindBase.h index 84b0330..0562b1b 100644 --- a/Source/cmFindBase.h +++ b/Source/cmFindBase.h @@ -31,10 +31,7 @@ public: virtual bool ParseArguments(std::vector<std::string> const& args); cmTypeMacro(cmFindBase, cmFindCommon); - virtual const char* GetFullDocumentation() const; - protected: - virtual void GenerateDocumentation(); void PrintFindStuff(); void ExpandPaths(); void AddPathSuffixes(); @@ -44,7 +41,6 @@ protected: // if it has documentation in the cache bool CheckForVariableInCache(); - cmStdString GenericDocumentation; // use by command during find cmStdString VariableDocumentation; cmStdString VariableName; diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index b44864e..e8c8da3 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -37,55 +37,6 @@ cmFindCommon::cmFindCommon() } //---------------------------------------------------------------------------- -void cmFindCommon::GenerateDocumentation() -{ - // Documentation components. - this->GenericDocumentationMacPolicy = - "On Darwin or systems supporting OS X Frameworks, the cmake variable" - " CMAKE_FIND_FRAMEWORK can be set to empty or one of the following:\n" - " \"FIRST\" - Try to find frameworks before standard\n" - " libraries or headers. This is the default on Darwin.\n" - " \"LAST\" - Try to find frameworks after standard\n" - " libraries or headers.\n" - " \"ONLY\" - Only try to find frameworks.\n" - " \"NEVER\" - Never try to find frameworks.\n" - "On Darwin or systems supporting OS X Application Bundles, the cmake " - "variable CMAKE_FIND_APPBUNDLE can be set to empty or one of the " - "following:\n" - " \"FIRST\" - Try to find application bundles before standard\n" - " programs. This is the default on Darwin.\n" - " \"LAST\" - Try to find application bundles after standard\n" - " programs.\n" - " \"ONLY\" - Only try to find application bundles.\n" - " \"NEVER\" - Never try to find application bundles.\n"; - this->GenericDocumentationRootPath = - "The CMake variable CMAKE_FIND_ROOT_PATH specifies one or more " - "directories to be prepended to all other search directories. " - "This effectively \"re-roots\" the entire search under given locations. " - "By default it is empty. It is especially useful when " - "cross-compiling to point to the root directory of the " - "target environment and CMake will search there too. By default at first " - "the directories listed in CMAKE_FIND_ROOT_PATH and then the non-rooted " - "directories will be searched. " - "The default behavior can be adjusted by setting " - "CMAKE_FIND_ROOT_PATH_MODE_XXX. This behavior can be manually " - "overridden on a per-call basis. " - "By using CMAKE_FIND_ROOT_PATH_BOTH the search order will " - "be as described above. If NO_CMAKE_FIND_ROOT_PATH is used " - "then CMAKE_FIND_ROOT_PATH will not be used. If ONLY_CMAKE_FIND_ROOT_PATH " - "is used then only the re-rooted directories will be searched.\n"; - this->GenericDocumentationPathsOrder = - "The default search order is designed to be most-specific to " - "least-specific for common use cases. " - "Projects may override the order by simply calling the command " - "multiple times and using the NO_* options:\n" - " FIND_XXX(FIND_ARGS_XXX PATHS paths... NO_DEFAULT_PATH)\n" - " FIND_XXX(FIND_ARGS_XXX)\n" - "Once one of the calls succeeds the result variable will be set " - "and stored in the cache so that no call will search again."; -} - -//---------------------------------------------------------------------------- cmFindCommon::~cmFindCommon() { } @@ -187,22 +138,36 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) { return; } + const char* sysroot = + this->Makefile->GetDefinition("CMAKE_SYSROOT"); const char* rootPath = this->Makefile->GetDefinition("CMAKE_FIND_ROOT_PATH"); - if((rootPath == 0) || (strlen(rootPath) == 0)) + const bool noSysroot = !sysroot || !*sysroot; + const bool noRootPath = !rootPath || !*rootPath; + if(noSysroot && noRootPath) { return; } // Construct the list of path roots with no trailing slashes. std::vector<std::string> roots; - cmSystemTools::ExpandListArgument(rootPath, roots); + if (rootPath) + { + cmSystemTools::ExpandListArgument(rootPath, roots); + } + if (sysroot) + { + roots.push_back(sysroot); + } for(std::vector<std::string>::iterator ri = roots.begin(); ri != roots.end(); ++ri) { cmSystemTools::ConvertToUnixSlashes(*ri); } + const char* stagePrefix = + this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX"); + // Copy the original set of unrooted paths. std::vector<std::string> unrootedPaths = paths; paths.clear(); @@ -217,7 +182,9 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) // already inside. Skip the unrooted path if it is relative to // a user home directory or is empty. std::string rootedDir; - if(cmSystemTools::IsSubDirectory(ui->c_str(), ri->c_str())) + if(cmSystemTools::IsSubDirectory(ui->c_str(), ri->c_str()) + || (stagePrefix + && cmSystemTools::IsSubDirectory(ui->c_str(), stagePrefix))) { rootedDir = *ui; } diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h index 542805f..6109a9f 100644 --- a/Source/cmFindCommon.h +++ b/Source/cmFindCommon.h @@ -56,8 +56,6 @@ protected: /** Compute the current default bundle/framework search policy. */ void SelectDefaultMacMode(); - virtual void GenerateDocumentation(); - cmStdString CMakePathName; RootPathMode FindRootPathMode; @@ -85,10 +83,6 @@ protected: std::vector<std::string> SearchPaths; std::set<cmStdString> SearchPathsEmitted; - std::string GenericDocumentationMacPolicy; - std::string GenericDocumentationRootPath; - std::string GenericDocumentationPathsOrder; - bool SearchFrameworkFirst; bool SearchFrameworkOnly; bool SearchFrameworkLast; diff --git a/Source/cmFindFileCommand.cxx b/Source/cmFindFileCommand.cxx index fa66fa1..615e7c1 100644 --- a/Source/cmFindFileCommand.cxx +++ b/Source/cmFindFileCommand.cxx @@ -16,15 +16,3 @@ cmFindFileCommand::cmFindFileCommand() { this->IncludeFileInPath = true; } - -void cmFindFileCommand::GenerateDocumentation() -{ - this->cmFindPathCommand::GenerateDocumentation(); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "find_path", "find_file"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "directory containing the named file", - "full path to named file"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "file in a directory", "full path to a file"); -} diff --git a/Source/cmFindFileCommand.h b/Source/cmFindFileCommand.h index 1bfdcbd..3f0baa2 100644 --- a/Source/cmFindFileCommand.h +++ b/Source/cmFindFileCommand.h @@ -35,17 +35,7 @@ public: } virtual const char* GetName() const { return "find_file";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Find the full path to a file."; - } - cmTypeMacro(cmFindFileCommand, cmFindPathCommand); -protected: - virtual void GenerateDocumentation(); }; diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index 4af7e11..de52df7 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -20,62 +20,6 @@ cmFindLibraryCommand::cmFindLibraryCommand() this->NamesPerDirAllowed = true; } -//---------------------------------------------------------------------------- -void cmFindLibraryCommand::GenerateDocumentation() -{ - this->cmFindBase::GenerateDocumentation(); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "FIND_XXX", "find_library"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "CMAKE_XXX_PATH", "CMAKE_LIBRARY_PATH"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "CMAKE_XXX_MAC_PATH", - "CMAKE_FRAMEWORK_PATH"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "CMAKE_SYSTEM_XXX_MAC_PATH", - "CMAKE_SYSTEM_FRAMEWORK_PATH"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "XXX_SYSTEM", "LIB"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "CMAKE_SYSTEM_XXX_PATH", - "CMAKE_SYSTEM_LIBRARY_PATH"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "SEARCH_XXX_DESC", "library"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "SEARCH_XXX", "library"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "XXX_SUBDIR", "lib"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "NAMES name1 [name2 ...]", - "NAMES name1 [name2 ...] [NAMES_PER_DIR]"); - cmSystemTools::ReplaceString( - this->GenericDocumentation, - "XXX_EXTRA_PREFIX_ENTRY", - " <prefix>/lib/<arch> if CMAKE_LIBRARY_ARCHITECTURE is set, and\n"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "CMAKE_FIND_ROOT_PATH_MODE_XXX", - "CMAKE_FIND_ROOT_PATH_MODE_LIBRARY"); - this->GenericDocumentation += - "\n" - "When more than one value is given to the NAMES option this command " - "by default will consider one name at a time and search every directory " - "for it. " - "The NAMES_PER_DIR option tells this command to consider one directory " - "at a time and search for all names in it." - "\n" - "If the library found is a framework, then VAR will be set to " - "the full path to the framework <fullPath>/A.framework. " - "When a full path to a framework is used as a library, " - "CMake will use a -framework A, and a -F<fullPath> to " - "link the framework to the target." - "\n" - "If the global property FIND_LIBRARY_USE_LIB64_PATHS is set all search " - "paths will be tested as normal, with \"64/\" appended, and with all " - "matches of \"lib/\" replaced with \"lib64/\". This property is " - "automatically set for the platforms that are known to need it if at " - "least one of the languages supported by the PROJECT command is enabled."; -} - // cmFindLibraryCommand bool cmFindLibraryCommand ::InitialPass(std::vector<std::string> const& argsIn, cmExecutionStatus &) diff --git a/Source/cmFindLibraryCommand.h b/Source/cmFindLibraryCommand.h index cd0fce8..a9ec40e 100644 --- a/Source/cmFindLibraryCommand.h +++ b/Source/cmFindLibraryCommand.h @@ -51,13 +51,6 @@ public: */ virtual const char* GetName() const {return "find_library";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Find a library."; - } cmTypeMacro(cmFindLibraryCommand, cmFindBase); protected: @@ -67,7 +60,6 @@ protected: const char* suffix, bool fresh = true); std::string FindLibrary(); - virtual void GenerateDocumentation(); private: std::string FindNormalLibrary(); std::string FindNormalLibraryNamesPerDir(); diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index aa3a73d..c59aafd 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -13,41 +13,18 @@ #include <cmsys/Directory.hxx> #include <cmsys/RegularExpression.hxx> +#include <cmsys/Encoding.hxx> #ifdef CMAKE_BUILD_WITH_CMAKE #include "cmVariableWatch.h" #endif #if defined(__HAIKU__) -#include <StorageKit.h> +#include <string.h> +#include <FindDirectory.h> +#include <StorageDefs.h> #endif -void cmFindPackageNeedBackwardsCompatibility(const std::string& variable, - int access_type, void*, const char* newValue, - const cmMakefile*) -{ - (void)newValue; -#ifdef CMAKE_BUILD_WITH_CMAKE - if(access_type == cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS) - { - std::string message = "An attempt was made to access a variable: "; - message += variable; - message += - " that has not been defined. This variable is created by the " - "FIND_PACKAGE command. CMake version 1.6 always converted the " - "variable name to upper-case, but this behavior is no longer the " - "case. To fix this you might need to set the cache value of " - "CMAKE_BACKWARDS_COMPATIBILITY to 1.6 or less. If you are writing a " - "CMake listfile, you should change the variable reference to use " - "the case of the argument to FIND_PACKAGE."; - cmSystemTools::Error(message.c_str()); - } -#else - (void)variable; - (void)access_type; -#endif -} - //---------------------------------------------------------------------------- cmFindPackageCommand::cmFindPackageCommand() { @@ -77,322 +54,6 @@ cmFindPackageCommand::cmFindPackageCommand() } //---------------------------------------------------------------------------- -void cmFindPackageCommand::GenerateDocumentation() -{ - this->cmFindCommon::GenerateDocumentation(); - cmSystemTools::ReplaceString(this->GenericDocumentationRootPath, - "CMAKE_FIND_ROOT_PATH_MODE_XXX", - "CMAKE_FIND_ROOT_PATH_MODE_PACKAGE"); - cmSystemTools::ReplaceString(this->GenericDocumentationPathsOrder, - "FIND_ARGS_XXX", "<package>"); - cmSystemTools::ReplaceString(this->GenericDocumentationPathsOrder, - "FIND_XXX", "find_package"); - this->CommandDocumentation = - " find_package(<package> [version] [EXACT] [QUIET] [MODULE]\n" - " [REQUIRED] [[COMPONENTS] [components...]]\n" - " [OPTIONAL_COMPONENTS components...]\n" - " [NO_POLICY_SCOPE])\n" - "Finds and loads settings from an external project. " - "<package>_FOUND will be set to indicate whether the package was found. " - "When the package is found package-specific information is provided " - "through variables and imported targets documented by the package " - "itself. " - "The QUIET option disables messages if the package cannot be found. " - "The MODULE option disables the second signature documented below. " - "The REQUIRED option stops processing with an error message if the " - "package cannot be found." - "\n" - "A package-specific list of required components may be listed after the " - "COMPONENTS option (or after the REQUIRED option if present). " - "Additional optional components may be listed after OPTIONAL_COMPONENTS. " - "Available components and their influence on whether a package is " - "considered to be found are defined by the target package." - "\n" - "The [version] argument requests a version with which the package found " - "should be compatible (format is major[.minor[.patch[.tweak]]]). " - "The EXACT option requests that the version be matched exactly. " - "If no [version] and/or component list is given to a recursive " - "invocation inside a find-module, the corresponding arguments " - "are forwarded automatically from the outer call (including the " - "EXACT flag for [version]). " - "Version support is currently provided only on a package-by-package " - "basis (details below).\n" - "User code should generally look for packages using the above simple " - "signature. The remainder of this command documentation specifies the " - "full command signature and details of the search process. Project " - "maintainers wishing to provide a package to be found by this command " - "are encouraged to read on.\n" - "The command has two modes by which it searches for packages: " - "\"Module\" mode and \"Config\" mode. " - "Module mode is available when the command is invoked with the above " - "reduced signature. " - "CMake searches for a file called \"Find<package>.cmake\" in " - "the CMAKE_MODULE_PATH followed by the CMake installation. " - "If the file is found, it is read and processed by CMake. " - "It is responsible for finding the package, checking the version, " - "and producing any needed messages. " - "Many find-modules provide limited or no support for versioning; " - "check the module documentation. " - "If no module is found and the MODULE option is not given the command " - "proceeds to Config mode.\n" - "The complete Config mode command signature is:\n" - " find_package(<package> [version] [EXACT] [QUIET]\n" - " [REQUIRED] [[COMPONENTS] [components...]]\n" - " [CONFIG|NO_MODULE]\n" - " [NO_POLICY_SCOPE]\n" - " [NAMES name1 [name2 ...]]\n" - " [CONFIGS config1 [config2 ...]]\n" - " [HINTS path1 [path2 ... ]]\n" - " [PATHS path1 [path2 ... ]]\n" - " [PATH_SUFFIXES suffix1 [suffix2 ...]]\n" - " [NO_DEFAULT_PATH]\n" - " [NO_CMAKE_ENVIRONMENT_PATH]\n" - " [NO_CMAKE_PATH]\n" - " [NO_SYSTEM_ENVIRONMENT_PATH]\n" - " [NO_CMAKE_PACKAGE_REGISTRY]\n" - " [NO_CMAKE_BUILDS_PATH]\n" - " [NO_CMAKE_SYSTEM_PATH]\n" - " [NO_CMAKE_SYSTEM_PACKAGE_REGISTRY]\n" - " [CMAKE_FIND_ROOT_PATH_BOTH |\n" - " ONLY_CMAKE_FIND_ROOT_PATH |\n" - " NO_CMAKE_FIND_ROOT_PATH])\n" - "The CONFIG option may be used to skip Module mode explicitly and " - "switch to Config mode. It is synonymous to using NO_MODULE. " - "Config mode is also implied by use of options not specified in the " - "reduced signature. " - "\n" - "Config mode attempts to locate a configuration file provided by the " - "package to be found. A cache entry called <package>_DIR is created to " - "hold the directory containing the file. " - "By default the command searches for a package with the name <package>. " - "If the NAMES option is given the names following it are used instead " - "of <package>. " - "The command searches for a file called \"<name>Config.cmake\" or " - "\"<lower-case-name>-config.cmake\" for each name specified. " - "A replacement set of possible configuration file names may be given " - "using the CONFIGS option. " - "The search procedure is specified below. Once found, the configuration " - "file is read and processed by CMake. Since the file is provided by the " - "package it already knows the location of package contents. " - "The full path to the configuration file is stored in the cmake " - "variable <package>_CONFIG." - "\n" - "All configuration files which have been considered by CMake while " - "searching for an installation of the package with an appropriate " - "version are stored in the cmake variable <package>_CONSIDERED_CONFIGS, " - "the associated versions in <package>_CONSIDERED_VERSIONS. " - "\n" - "If the package configuration file cannot be found CMake " - "will generate an error describing the problem unless the QUIET " - "argument is specified. If REQUIRED is specified and the package " - "is not found a fatal error is generated and the configure step stops " - "executing. If <package>_DIR has been set to a directory not containing " - "a configuration file CMake will ignore it and search from scratch." - "\n" - "When the [version] argument is given Config mode will only find a " - "version of the package that claims compatibility with the requested " - "version (format is major[.minor[.patch[.tweak]]]). " - "If the EXACT option is given only a version of the package claiming " - "an exact match of the requested version may be found. " - "CMake does not establish any convention for the meaning of version " - "numbers. " - "Package version numbers are checked by \"version\" files provided by " - "the packages themselves. " - "For a candidate package configuration file \"<config-file>.cmake\" the " - "corresponding version file is located next to it and named either " - "\"<config-file>-version.cmake\" or \"<config-file>Version.cmake\". " - "If no such version file is available then the configuration file " - "is assumed to not be compatible with any requested version. " - "A basic version file containing generic version matching code can be " - "created using the macro write_basic_package_version_file(), see its " - "documentation for more details. " - "When a version file is found it is loaded to check the requested " - "version number. " - "The version file is loaded in a nested scope in which the following " - "variables have been defined:\n" - " PACKAGE_FIND_NAME = the <package> name\n" - " PACKAGE_FIND_VERSION = full requested version string\n" - " PACKAGE_FIND_VERSION_MAJOR = major version if requested, else 0\n" - " PACKAGE_FIND_VERSION_MINOR = minor version if requested, else 0\n" - " PACKAGE_FIND_VERSION_PATCH = patch version if requested, else 0\n" - " PACKAGE_FIND_VERSION_TWEAK = tweak version if requested, else 0\n" - " PACKAGE_FIND_VERSION_COUNT = number of version components, 0 to 4\n" - "The version file checks whether it satisfies the requested version " - "and sets these variables:\n" - " PACKAGE_VERSION = full provided version string\n" - " PACKAGE_VERSION_EXACT = true if version is exact match\n" - " PACKAGE_VERSION_COMPATIBLE = true if version is compatible\n" - " PACKAGE_VERSION_UNSUITABLE = true if unsuitable as any version\n" - "These variables are checked by the find_package command to determine " - "whether the configuration file provides an acceptable version. " - "They are not available after the find_package call returns. " - "If the version is acceptable the following variables are set:\n" - " <package>_VERSION = full provided version string\n" - " <package>_VERSION_MAJOR = major version if provided, else 0\n" - " <package>_VERSION_MINOR = minor version if provided, else 0\n" - " <package>_VERSION_PATCH = patch version if provided, else 0\n" - " <package>_VERSION_TWEAK = tweak version if provided, else 0\n" - " <package>_VERSION_COUNT = number of version components, 0 to 4\n" - "and the corresponding package configuration file is loaded. " - "When multiple package configuration files are available whose version " - "files claim compatibility with the version requested it is unspecified " - "which one is chosen. " - "No attempt is made to choose a highest or closest version number." - "\n" - "Config mode provides an elaborate interface and search procedure. " - "Much of the interface is provided for completeness and for use " - "internally by find-modules loaded by Module mode. " - "Most user code should simply call\n" - " find_package(<package> [major[.minor]] [EXACT] [REQUIRED|QUIET])\n" - "in order to find a package. Package maintainers providing CMake " - "package configuration files are encouraged to name and install " - "them such that the procedure outlined below will find them " - "without requiring use of additional options." - "\n" - "CMake constructs a set of possible installation prefixes for the " - "package. Under each prefix several directories are searched for a " - "configuration file. The tables below show the directories searched. " - "Each entry is meant for installation trees following Windows (W), " - "UNIX (U), or Apple (A) conventions.\n" - " <prefix>/ (W)\n" - " <prefix>/(cmake|CMake)/ (W)\n" - " <prefix>/<name>*/ (W)\n" - " <prefix>/<name>*/(cmake|CMake)/ (W)\n" - " <prefix>/(lib/<arch>|lib|share)/cmake/<name>*/ (U)\n" - " <prefix>/(lib/<arch>|lib|share)/<name>*/ (U)\n" - " <prefix>/(lib/<arch>|lib|share)/<name>*/(cmake|CMake)/ (U)\n" - "On systems supporting OS X Frameworks and Application Bundles " - "the following directories are searched for frameworks or bundles " - "containing a configuration file:\n" - " <prefix>/<name>.framework/Resources/ (A)\n" - " <prefix>/<name>.framework/Resources/CMake/ (A)\n" - " <prefix>/<name>.framework/Versions/*/Resources/ (A)\n" - " <prefix>/<name>.framework/Versions/*/Resources/CMake/ (A)\n" - " <prefix>/<name>.app/Contents/Resources/ (A)\n" - " <prefix>/<name>.app/Contents/Resources/CMake/ (A)\n" - "In all cases the <name> is treated as case-insensitive and corresponds " - "to any of the names specified (<package> or names given by NAMES). " - "Paths with lib/<arch> are enabled if CMAKE_LIBRARY_ARCHITECTURE is set. " - "If PATH_SUFFIXES is specified the suffixes are appended to each " - "(W) or (U) directory entry one-by-one.\n" - "This set of directories is intended to work in cooperation with " - "projects that provide configuration files in their installation trees. " - "Directories above marked with (W) are intended for installations on " - "Windows where the prefix may point at the top of an application's " - "installation directory. Those marked with (U) are intended for " - "installations on UNIX platforms where the prefix is shared by " - "multiple packages. This is merely a convention, so all (W) and (U) " - "directories are still searched on all platforms. " - "Directories marked with (A) are intended for installations on " - "Apple platforms. The cmake variables CMAKE_FIND_FRAMEWORK and " - "CMAKE_FIND_APPBUNDLE determine the order of preference " - "as specified below.\n" - "The set of installation prefixes is constructed using the following " - "steps. If NO_DEFAULT_PATH is specified all NO_* options are enabled.\n" - "1. Search paths specified in cmake-specific cache variables. " - "These are intended to be used on the command line with a -DVAR=value. " - "This can be skipped if NO_CMAKE_PATH is passed.\n" - " CMAKE_PREFIX_PATH\n" - " CMAKE_FRAMEWORK_PATH\n" - " CMAKE_APPBUNDLE_PATH\n" - "2. Search paths specified in cmake-specific environment variables. " - "These are intended to be set in the user's shell configuration. " - "This can be skipped if NO_CMAKE_ENVIRONMENT_PATH is passed.\n" - " <package>_DIR\n" - " CMAKE_PREFIX_PATH\n" - " CMAKE_FRAMEWORK_PATH\n" - " CMAKE_APPBUNDLE_PATH\n" - "3. Search paths specified by the HINTS option. " - "These should be paths computed by system introspection, such as a " - "hint provided by the location of another item already found. " - "Hard-coded guesses should be specified with the PATHS option.\n" - "4. Search the standard system environment variables. " - "This can be skipped if NO_SYSTEM_ENVIRONMENT_PATH is passed. " - "Path entries ending in \"/bin\" or \"/sbin\" are automatically " - "converted to their parent directories.\n" - " PATH\n" - "5. Search project build trees recently configured in a CMake GUI. " - "This can be skipped if NO_CMAKE_BUILDS_PATH is passed. " - "It is intended for the case when a user is building multiple " - "dependent projects one after another.\n" - "6. Search paths stored in the CMake user package registry. " - "This can be skipped if NO_CMAKE_PACKAGE_REGISTRY is passed. " - "On Windows a <package> may appear under registry key\n" - " HKEY_CURRENT_USER\\Software\\Kitware\\CMake\\Packages\\<package>\n" - "as a REG_SZ value, with arbitrary name, that specifies the directory " - "containing the package configuration file. " - "On UNIX platforms a <package> may appear under the directory\n" - " ~/.cmake/packages/<package>\n" - "as a file, with arbitrary name, whose content specifies the directory " - "containing the package configuration file. " - "See the export(PACKAGE) command to create user package registry entries " - "for project build trees." - "\n" - "7. Search cmake variables defined in the Platform files " - "for the current system. This can be skipped if NO_CMAKE_SYSTEM_PATH " - "is passed.\n" - " CMAKE_SYSTEM_PREFIX_PATH\n" - " CMAKE_SYSTEM_FRAMEWORK_PATH\n" - " CMAKE_SYSTEM_APPBUNDLE_PATH\n" - "8. Search paths stored in the CMake system package registry. " - "This can be skipped if NO_CMAKE_SYSTEM_PACKAGE_REGISTRY is passed. " - "On Windows a <package> may appear under registry key\n" - " HKEY_LOCAL_MACHINE\\Software\\Kitware\\CMake\\Packages\\<package>\n" - "as a REG_SZ value, with arbitrary name, that specifies the directory " - "containing the package configuration file. " - "There is no system package registry on non-Windows platforms." - "\n" - "9. Search paths specified by the PATHS option. " - "These are typically hard-coded guesses.\n" - ; - this->CommandDocumentation += this->GenericDocumentationMacPolicy; - this->CommandDocumentation += this->GenericDocumentationRootPath; - this->CommandDocumentation += this->GenericDocumentationPathsOrder; - this->CommandDocumentation += - "\n" - "Every non-REQUIRED find_package() call can be disabled by setting the " - "variable CMAKE_DISABLE_FIND_PACKAGE_<package> to TRUE. See the " - "documentation for the CMAKE_DISABLE_FIND_PACKAGE_<package> variable for " - "more information.\n" - "When loading a find module or package configuration file find_package " - "defines variables to provide information about the call arguments " - "(and restores their original state before returning):\n" - " <package>_FIND_REQUIRED = true if REQUIRED option was given\n" - " <package>_FIND_QUIETLY = true if QUIET option was given\n" - " <package>_FIND_VERSION = full requested version string\n" - " <package>_FIND_VERSION_MAJOR = major version if requested, else 0\n" - " <package>_FIND_VERSION_MINOR = minor version if requested, else 0\n" - " <package>_FIND_VERSION_PATCH = patch version if requested, else 0\n" - " <package>_FIND_VERSION_TWEAK = tweak version if requested, else 0\n" - " <package>_FIND_VERSION_COUNT = number of version components, 0 to 4\n" - " <package>_FIND_VERSION_EXACT = true if EXACT option was given\n" - " <package>_FIND_COMPONENTS = list of requested components\n" - " <package>_FIND_REQUIRED_<c> = true if component <c> is required\n" - " false if component <c> is optional\n" - "In Module mode the loaded find module is responsible to honor the " - "request detailed by these variables; see the find module for details. " - "In Config mode find_package handles REQUIRED, QUIET, and version " - "options automatically but leaves it to the package configuration file " - "to handle components in a way that makes sense for the package. " - "The package configuration file may set <package>_FOUND to false " - "to tell find_package that component requirements are not satisfied." - "\n" - "See the cmake_policy() command documentation for discussion of the " - "NO_POLICY_SCOPE option." - ; -} - -//---------------------------------------------------------------------------- -const char* cmFindPackageCommand::GetFullDocumentation() const -{ - if(this->CommandDocumentation.empty()) - { - const_cast<cmFindPackageCommand *>(this)->GenerateDocumentation(); - } - return this->CommandDocumentation.c_str(); -} - -//---------------------------------------------------------------------------- bool cmFindPackageCommand ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) { @@ -442,11 +103,6 @@ bool cmFindPackageCommand std::set<std::string> requiredComponents; std::set<std::string> optionalComponents; - // Check ancient compatibility. - this->Compatibility_1_6 = - this->Makefile->GetLocalGenerator() - ->NeedBackwardsCompatibility(1, 6); - // Always search directly in a generated path. this->SearchPathSuffixes.push_back(""); @@ -468,7 +124,6 @@ bool cmFindPackageCommand else if(args[i] == "EXACT") { this->VersionExact = true; - this->Compatibility_1_6 = false; doing = DoingNone; } else if(args[i] == "MODULE") @@ -493,75 +148,63 @@ bool cmFindPackageCommand } else if(args[i] == "COMPONENTS") { - this->Compatibility_1_6 = false; doing = DoingComponents; } else if(args[i] == "OPTIONAL_COMPONENTS") { - this->Compatibility_1_6 = false; doing = DoingOptionalComponents; } else if(args[i] == "NAMES") { configArgs.insert(i); - this->Compatibility_1_6 = false; doing = DoingNames; } else if(args[i] == "PATHS") { configArgs.insert(i); - this->Compatibility_1_6 = false; doing = DoingPaths; } else if(args[i] == "HINTS") { configArgs.insert(i); - this->Compatibility_1_6 = false; doing = DoingHints; } else if(args[i] == "PATH_SUFFIXES") { configArgs.insert(i); - this->Compatibility_1_6 = false; doing = DoingPathSuffixes; } else if(args[i] == "CONFIGS") { configArgs.insert(i); - this->Compatibility_1_6 = false; doing = DoingConfigs; } else if(args[i] == "NO_POLICY_SCOPE") { this->PolicyScope = false; - this->Compatibility_1_6 = false; doing = DoingNone; } else if(args[i] == "NO_CMAKE_PACKAGE_REGISTRY") { this->NoUserRegistry = true; configArgs.insert(i); - this->Compatibility_1_6 = false; doing = DoingNone; } else if(args[i] == "NO_CMAKE_SYSTEM_PACKAGE_REGISTRY") { this->NoSystemRegistry = true; configArgs.insert(i); - this->Compatibility_1_6 = false; doing = DoingNone; } else if(args[i] == "NO_CMAKE_BUILDS_PATH") { this->NoBuilds = true; configArgs.insert(i); - this->Compatibility_1_6 = false; doing = DoingNone; } else if(this->CheckCommonArgument(args[i])) { configArgs.insert(i); - this->Compatibility_1_6 = false; doing = DoingNone; } else if((doing == DoingComponents) || (doing == DoingOptionalComponents)) @@ -956,24 +599,9 @@ bool cmFindPackageCommand::HandlePackageMode() std::string upperFound = cmSystemTools::UpperCase(this->Name); upperDir += "_DIR"; upperFound += "_FOUND"; - if(upperDir == this->Variable) - { - this->Compatibility_1_6 = false; - } // Try to find the config file. const char* def = this->Makefile->GetDefinition(this->Variable.c_str()); - if(this->Compatibility_1_6 && cmSystemTools::IsOff(def)) - { - // Use the setting of the old name of the variable to provide the - // value of the new. - const char* oldDef = this->Makefile->GetDefinition(upperDir.c_str()); - if(!cmSystemTools::IsOff(oldDef)) - { - this->Makefile->AddDefinition(this->Variable.c_str(), oldDef); - def = this->Makefile->GetDefinition(this->Variable.c_str()); - } - } // Try to load the config file if the directory is known bool fileFound = false; @@ -1195,43 +823,6 @@ bool cmFindPackageCommand::HandlePackageMode() this->Makefile->RemoveDefinition(fileVar.c_str()); } - // Handle some ancient compatibility stuff. - if(this->Compatibility_1_6) - { - // Listfiles will be looking for the capitalized version of the - // name. Provide it. - this->Makefile->AddDefinition - (upperDir.c_str(), - this->Makefile->GetDefinition(this->Variable.c_str())); - this->Makefile->AddDefinition - (upperFound.c_str(), - this->Makefile->GetDefinition(foundVar.c_str())); - } - -#ifdef CMAKE_BUILD_WITH_CMAKE - if(!(upperDir == this->Variable)) - { - if(this->Compatibility_1_6) - { - // Listfiles may use the capitalized version of the name. - // Remove any previously added watch. - this->Makefile->GetVariableWatch()->RemoveWatch( - upperDir.c_str(), - cmFindPackageNeedBackwardsCompatibility - ); - } - else - { - // Listfiles should not be using the capitalized version of the - // name. Add a watch to warn the user. - this->Makefile->GetVariableWatch()->AddWatch( - upperDir.c_str(), - cmFindPackageNeedBackwardsCompatibility - ); - } - } -#endif - std::string consideredConfigsVar = this->Name; consideredConfigsVar += "_CONSIDERED_CONFIGS"; std::string consideredVersionsVar = this->Name; @@ -1560,8 +1151,8 @@ void cmFindPackageCommand::AddPrefixesSystemEnvironment() std::string const& d = *i; // If the path is a PREFIX/bin case then add its parent instead. - if((d.size() >= 4 && strcmp(d.c_str()+d.size()-4, "/bin") == 0) || - (d.size() >= 5 && strcmp(d.c_str()+d.size()-5, "/sbin") == 0)) + if((cmHasLiteralSuffix(d, "/bin")) || + (cmHasLiteralSuffix(d, "/sbin"))) { this->AddPathInternal(cmSystemTools::GetFilenamePath(d), EnvPath); } @@ -1584,12 +1175,14 @@ void cmFindPackageCommand::AddPrefixesUserRegistry() #if defined(_WIN32) && !defined(__CYGWIN__) this->LoadPackageRegistryWinUser(); #elif defined(__HAIKU__) - BPath dir; - if (find_directory(B_USER_SETTINGS_DIRECTORY, &dir) == B_OK) + char dir[B_PATH_NAME_LENGTH]; + if (find_directory(B_USER_SETTINGS_DIRECTORY, -1, false, dir, sizeof(dir)) == + B_OK) { - dir.Append("cmake/packages"); - dir.Append(this->Name.c_str()); - this->LoadPackageRegistryDir(dir.Path()); + std::string fname = dir; + fname += "/cmake/packages/"; + fname += Name; + this->LoadPackageRegistryDir(fname); } #else if(const char* home = cmSystemTools::GetEnv("HOME")) @@ -1653,23 +1246,23 @@ void cmFindPackageCommand::LoadPackageRegistryWinSystem() void cmFindPackageCommand::LoadPackageRegistryWin(bool user, unsigned int view) { - std::string key = "Software\\Kitware\\CMake\\Packages\\"; - key += this->Name; - std::set<cmStdString> bad; + std::wstring key = L"Software\\Kitware\\CMake\\Packages\\"; + key += cmsys::Encoding::ToWide(this->Name); + std::set<std::wstring> bad; HKEY hKey; - if(RegOpenKeyEx(user? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, key.c_str(), - 0, KEY_QUERY_VALUE|view, &hKey) == ERROR_SUCCESS) + if(RegOpenKeyExW(user? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, key.c_str(), + 0, KEY_QUERY_VALUE|view, &hKey) == ERROR_SUCCESS) { DWORD valueType = REG_NONE; - char name[16384]; - std::vector<char> data(512); + wchar_t name[16383]; // RegEnumValue docs limit name to 32767 _bytes_ + std::vector<wchar_t> data(512); bool done = false; DWORD index = 0; while(!done) { DWORD nameSize = static_cast<DWORD>(sizeof(name)); - DWORD dataSize = static_cast<DWORD>(data.size()-1); - switch(RegEnumValue(hKey, index, name, &nameSize, + DWORD dataSize = static_cast<DWORD>(data.size()*sizeof(data[0])); + switch(RegEnumValueW(hKey, index, name, &nameSize, 0, &valueType, (BYTE*)&data[0], &dataSize)) { case ERROR_SUCCESS: @@ -1677,7 +1270,7 @@ void cmFindPackageCommand::LoadPackageRegistryWin(bool user, if(valueType == REG_SZ) { data[dataSize] = 0; - cmsys_ios::stringstream ss(&data[0]); + cmsys_ios::stringstream ss(cmsys::Encoding::ToNarrow(&data[0])); if(!this->CheckPackageRegistryEntry(ss)) { // The entry is invalid. @@ -1686,7 +1279,7 @@ void cmFindPackageCommand::LoadPackageRegistryWin(bool user, } break; case ERROR_MORE_DATA: - data.resize(dataSize+1); + data.resize((dataSize+sizeof(data[0])-1)/sizeof(data[0])); break; case ERROR_NO_MORE_ITEMS: default: done = true; break; } @@ -1696,13 +1289,13 @@ void cmFindPackageCommand::LoadPackageRegistryWin(bool user, // Remove bad values if possible. if(user && !bad.empty() && - RegOpenKeyEx(HKEY_CURRENT_USER, key.c_str(), + RegOpenKeyExW(HKEY_CURRENT_USER, key.c_str(), 0, KEY_SET_VALUE|view, &hKey) == ERROR_SUCCESS) { - for(std::set<cmStdString>::const_iterator vi = bad.begin(); + for(std::set<std::wstring>::const_iterator vi = bad.begin(); vi != bad.end(); ++vi) { - RegDeleteValue(hKey, vi->c_str()); + RegDeleteValueW(hKey, vi->c_str()); } RegCloseKey(hKey); } @@ -1741,7 +1334,7 @@ void cmFindPackageCommand::LoadPackageRegistryDir(std::string const& dir) cmFindPackageCommandHoldFile holdFile(fname.c_str()); // Load the file. - std::ifstream fin(fname.c_str(), std::ios::in | cmsys_ios_binary); + cmsys::ifstream fin(fname.c_str(), std::ios::in | cmsys_ios_binary); if(fin && this->CheckPackageRegistryEntry(fin)) { // The file references an existing package, so release it. diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index c380122..7ceebb2 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -51,22 +51,7 @@ public: */ virtual const char* GetName() const { return "find_package";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Load settings for an external project."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const; - cmTypeMacro(cmFindPackageCommand, cmFindCommon); -protected: - virtual void GenerateDocumentation(); private: void AppendSuccessInformation(); void AppendToFoundProperty(bool found); @@ -113,7 +98,6 @@ private: struct OriginalDef { bool exists; std::string value; }; std::map<cmStdString, OriginalDef> OriginalDefs; - std::string CommandDocumentation; cmStdString Name; cmStdString Variable; cmStdString Version; @@ -133,7 +117,6 @@ private: unsigned int RequiredCMakeVersion; bool Quiet; bool Required; - bool Compatibility_1_6; bool UseConfigFiles; bool UseFindModules; bool NoUserRegistry; diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx index 6a43298..8459995 100644 --- a/Source/cmFindPathCommand.cxx +++ b/Source/cmFindPathCommand.cxx @@ -20,51 +20,6 @@ cmFindPathCommand::cmFindPathCommand() this->IncludeFileInPath = false; } -void cmFindPathCommand::GenerateDocumentation() -{ - this->cmFindBase::GenerateDocumentation(); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "FIND_XXX", "find_path"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "CMAKE_XXX_PATH", "CMAKE_INCLUDE_PATH"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "CMAKE_XXX_MAC_PATH", - "CMAKE_FRAMEWORK_PATH"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "CMAKE_SYSTEM_XXX_MAC_PATH", - "CMAKE_SYSTEM_FRAMEWORK_PATH"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "XXX_SYSTEM", "INCLUDE"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "CMAKE_SYSTEM_XXX_PATH", - "CMAKE_SYSTEM_INCLUDE_PATH"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "SEARCH_XXX_DESC", - "directory containing the named file"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "SEARCH_XXX", "file in a directory"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "XXX_SUBDIR", "include"); - cmSystemTools::ReplaceString( - this->GenericDocumentation, - "XXX_EXTRA_PREFIX_ENTRY", - " <prefix>/include/<arch> if CMAKE_LIBRARY_ARCHITECTURE is set, and\n"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "CMAKE_FIND_ROOT_PATH_MODE_XXX", - "CMAKE_FIND_ROOT_PATH_MODE_INCLUDE"); - if(!this->IncludeFileInPath) - { - this->GenericDocumentation += - "\n" - "When searching for frameworks, if the file is specified as " - "A/b.h, then the framework search will look for " - "A.framework/Headers/b.h. " - "If that is found the path will be set to the path to the framework. " - "CMake will convert this to the correct -F option to include the " - "file. "; - } -} - // cmFindPathCommand bool cmFindPathCommand ::InitialPass(std::vector<std::string> const& argsIn, cmExecutionStatus &) diff --git a/Source/cmFindPathCommand.h b/Source/cmFindPathCommand.h index 759567d..8df4540 100644 --- a/Source/cmFindPathCommand.h +++ b/Source/cmFindPathCommand.h @@ -51,18 +51,8 @@ public: */ virtual const char* GetName() const {return "find_path";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Find the directory containing a file."; - } - cmTypeMacro(cmFindPathCommand, cmFindBase); bool IncludeFileInPath; -protected: - virtual void GenerateDocumentation(); private: std::string FindHeaderInFramework(std::string const& file, std::string const& dir); diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx index 909b333..bb27753 100644 --- a/Source/cmFindProgramCommand.cxx +++ b/Source/cmFindProgramCommand.cxx @@ -17,37 +17,6 @@ #include <CoreFoundation/CoreFoundation.h> #endif -void cmFindProgramCommand::GenerateDocumentation() -{ - this->cmFindBase::GenerateDocumentation(); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "FIND_XXX", "find_program"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "CMAKE_XXX_PATH", "CMAKE_PROGRAM_PATH"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "CMAKE_XXX_MAC_PATH", - "CMAKE_APPBUNDLE_PATH"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "CMAKE_SYSTEM_XXX_MAC_PATH", - "CMAKE_SYSTEM_APPBUNDLE_PATH"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "XXX_SYSTEM", ""); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "CMAKE_SYSTEM_XXX_PATH", - "CMAKE_SYSTEM_PROGRAM_PATH"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "SEARCH_XXX_DESC", "program"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "SEARCH_XXX", "program"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "XXX_SUBDIR", "[s]bin"); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "XXX_EXTRA_PREFIX_ENTRY", ""); - cmSystemTools::ReplaceString(this->GenericDocumentation, - "CMAKE_FIND_ROOT_PATH_MODE_XXX", - "CMAKE_FIND_ROOT_PATH_MODE_PROGRAM"); -} - // cmFindProgramCommand bool cmFindProgramCommand ::InitialPass(std::vector<std::string> const& argsIn, cmExecutionStatus &) diff --git a/Source/cmFindProgramCommand.h b/Source/cmFindProgramCommand.h index 8350c9b..7f4811c 100644 --- a/Source/cmFindProgramCommand.h +++ b/Source/cmFindProgramCommand.h @@ -50,19 +50,10 @@ public: */ virtual const char* GetName() const { return "find_program";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Find an executable program."; - } - cmTypeMacro(cmFindProgramCommand, cmFindBase); protected: std::string FindProgram(std::vector<std::string> names); - virtual void GenerateDocumentation(); private: std::string FindAppBundle(std::vector<std::string> names); diff --git a/Source/cmForEachCommand.h b/Source/cmForEachCommand.h index dc47613..e548ba8 100644 --- a/Source/cmForEachCommand.h +++ b/Source/cmForEachCommand.h @@ -61,52 +61,6 @@ public: */ virtual const char* GetName() const { return "foreach";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Evaluate a group of commands for each value in a list."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " foreach(loop_var arg1 arg2 ...)\n" - " COMMAND1(ARGS ...)\n" - " COMMAND2(ARGS ...)\n" - " ...\n" - " endforeach(loop_var)\n" - "All commands between foreach and the matching endforeach are recorded " - "without being invoked. Once the endforeach is evaluated, the " - "recorded list of commands is invoked once for each argument listed " - "in the original foreach command. Before each iteration of the loop " - "\"${loop_var}\" will be set as a variable with " - "the current value in the list.\n" - " foreach(loop_var RANGE total)\n" - " foreach(loop_var RANGE start stop [step])\n" - "Foreach can also iterate over a generated range of numbers. " - "There are three types of this iteration:\n" - "* When specifying single number, the range will have elements " - "0 to \"total\".\n" - "* When specifying two numbers, the range will have elements from " - "the first number to the second number.\n" - "* The third optional number is the increment used to iterate from " - "the first number to the second number." - "\n" - " foreach(loop_var IN [LISTS [list1 [...]]]\n" - " [ITEMS [item1 [...]]])\n" - "Iterates over a precise list of items. " - "The LISTS option names list-valued variables to be traversed, " - "including empty elements (an empty string is a zero-length list). " - "The ITEMS option ends argument parsing and includes all arguments " - "following it in the iteration." - ; - } - cmTypeMacro(cmForEachCommand, cmCommand); private: bool HandleInMode(std::vector<std::string> const& args); diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index a126cd1..85b89d9 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -66,24 +66,6 @@ public: */ virtual const char* GetName() const { return this->Args[0].c_str(); } - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - std::string docs = "Function named: "; - docs += this->GetName(); - return docs.c_str(); - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return this->GetTerseDocumentation(); - } - cmTypeMacro(cmFunctionHelperCommand, cmCommand); std::vector<std::string> Args; diff --git a/Source/cmFunctionCommand.h b/Source/cmFunctionCommand.h index 0a029dc..a8bd3e7 100644 --- a/Source/cmFunctionCommand.h +++ b/Source/cmFunctionCommand.h @@ -59,46 +59,6 @@ public: */ virtual const char* GetName() const { return "function";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Start recording a function for later invocation as a command."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " function(<name> [arg1 [arg2 [arg3 ...]]])\n" - " COMMAND1(ARGS ...)\n" - " COMMAND2(ARGS ...)\n" - " ...\n" - " endfunction(<name>)\n" - "Define a function named <name> that takes arguments named " - "arg1 arg2 arg3 (...). Commands listed after function, but before " - "the matching endfunction, are not invoked until the function " - "is invoked. When it is invoked, the commands recorded in the " - "function are first modified by replacing formal parameters (${arg1}) " - "with the arguments passed, and then invoked as normal commands. In " - "addition to referencing the formal parameters you can reference " - "the variable ARGC which will be set to the number of arguments " - "passed into the function as well as ARGV0 ARGV1 ARGV2 ... which " - "will have the actual values of the arguments passed in. This " - "facilitates creating functions with optional arguments. Additionally " - "ARGV holds the list of all arguments given to the function and ARGN " - "holds the list of arguments past the last expected argument." - "\n" - "A function opens a new scope: see set(var PARENT_SCOPE) for details." - "\n" - "See the cmake_policy() command documentation for the behavior of " - "policies inside functions." - ; - } - cmTypeMacro(cmFunctionCommand, cmCommand); }; diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index 0af0753..34efc15 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -213,7 +213,7 @@ int cmGeneratedFileStreamBase::CompressFile(const char* oldname, { return 0; } - FILE* ifs = fopen(oldname, "r"); + FILE* ifs = cmsys::SystemTools::Fopen(oldname, "r"); if ( !ifs ) { return 0; diff --git a/Source/cmGeneratedFileStream.h b/Source/cmGeneratedFileStream.h index dac9c7b..99f3b47 100644 --- a/Source/cmGeneratedFileStream.h +++ b/Source/cmGeneratedFileStream.h @@ -13,6 +13,7 @@ #define cmGeneratedFileStream_h #include "cmStandardIncludes.h" +#include <cmsys/FStream.hxx> #if defined(__sgi) && !defined(__GNUC__) # pragma set woff 1375 /* base class destructor not virtual */ @@ -77,10 +78,10 @@ protected: * being updated. */ class cmGeneratedFileStream: private cmGeneratedFileStreamBase, - public std::ofstream + public cmsys::ofstream { public: - typedef std::ofstream Stream; + typedef cmsys::ofstream Stream; /** * This constructor prepares a default stream. The open method must diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index d73c72c..2e66d78 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -53,7 +53,7 @@ cmGeneratorExpression::~cmGeneratorExpression() //---------------------------------------------------------------------------- const char *cmCompiledGeneratorExpression::Evaluate( cmMakefile* mf, const char* config, bool quiet, - cmTarget *headTarget, + cmTarget const* headTarget, cmGeneratorExpressionDAGChecker *dagChecker) const { return this->Evaluate(mf, @@ -67,11 +67,11 @@ const char *cmCompiledGeneratorExpression::Evaluate( //---------------------------------------------------------------------------- const char *cmCompiledGeneratorExpression::Evaluate( cmMakefile* mf, const char* config, bool quiet, - cmTarget *headTarget, - cmTarget *currentTarget, + cmTarget const* headTarget, + cmTarget const* currentTarget, cmGeneratorExpressionDAGChecker *dagChecker) const { - if (!this->NeedsParsing) + if (!this->NeedsEvaluation) { return this->Input.c_str(); } @@ -129,9 +129,9 @@ cmCompiledGeneratorExpression::cmCompiledGeneratorExpression( cmGeneratorExpressionLexer l; std::vector<cmGeneratorExpressionToken> tokens = l.Tokenize(this->Input.c_str()); - this->NeedsParsing = l.GetSawGeneratorExpression(); + this->NeedsEvaluation = l.GetSawGeneratorExpression(); - if (this->NeedsParsing) + if (this->NeedsEvaluation) { cmGeneratorExpressionParser p(tokens); p.Parse(this->Evaluators); @@ -245,7 +245,7 @@ static void prefixItems(const std::string &content, std::string &result, result += sep; sep = ";"; if (!cmSystemTools::FileIsFullPath(ei->c_str()) - && cmGeneratorExpression::Find(*ei) == std::string::npos) + && cmGeneratorExpression::Find(*ei) != 0) { result += prefix; } diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index c20f130..4992e93 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -80,12 +80,12 @@ class cmCompiledGeneratorExpression public: const char* Evaluate(cmMakefile* mf, const char* config, bool quiet = false, - cmTarget *headTarget = 0, - cmTarget *currentTarget = 0, + cmTarget const* headTarget = 0, + cmTarget const* currentTarget = 0, cmGeneratorExpressionDAGChecker *dagChecker = 0) const; const char* Evaluate(cmMakefile* mf, const char* config, bool quiet, - cmTarget *headTarget, + cmTarget const* headTarget, cmGeneratorExpressionDAGChecker *dagChecker) const; /** Get set of targets found during evaluations. */ @@ -95,7 +95,7 @@ public: std::set<cmStdString> const& GetSeenTargetProperties() const { return this->SeenTargetProperties; } - std::set<cmTarget*> const& GetAllTargetsSeen() const + std::set<cmTarget const*> const& GetAllTargetsSeen() const { return this->AllTargetsSeen; } ~cmCompiledGeneratorExpression(); @@ -126,10 +126,10 @@ private: cmListFileBacktrace Backtrace; std::vector<cmGeneratorExpressionEvaluator*> Evaluators; const std::string Input; - bool NeedsParsing; + bool NeedsEvaluation; mutable std::set<cmTarget*> DependTargets; - mutable std::set<cmTarget*> AllTargetsSeen; + mutable std::set<cmTarget const*> AllTargetsSeen; mutable std::set<cmStdString> SeenTargetProperties; mutable std::string Output; mutable bool HadContextSensitiveCondition; diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 92dc054..e7e1d34 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -31,7 +31,7 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker( top = p; p = p->Parent; } - this->CheckResult = this->checkGraph(); + this->CheckResult = this->CheckGraph(); #define TEST_TRANSITIVE_PROPERTY_METHOD(METHOD) \ top->METHOD () || @@ -40,6 +40,7 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker( CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(TEST_TRANSITIVE_PROPERTY_METHOD) false) ) +#undef TEST_TRANSITIVE_PROPERTY_METHOD { std::map<cmStdString, std::set<cmStdString> >::const_iterator it = top->Seen.find(target); @@ -60,13 +61,13 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker( //---------------------------------------------------------------------------- cmGeneratorExpressionDAGChecker::Result -cmGeneratorExpressionDAGChecker::check() const +cmGeneratorExpressionDAGChecker::Check() const { return this->CheckResult; } //---------------------------------------------------------------------------- -void cmGeneratorExpressionDAGChecker::reportError( +void cmGeneratorExpressionDAGChecker::ReportError( cmGeneratorExpressionContext *context, const std::string &expr) { @@ -124,7 +125,7 @@ void cmGeneratorExpressionDAGChecker::reportError( //---------------------------------------------------------------------------- cmGeneratorExpressionDAGChecker::Result -cmGeneratorExpressionDAGChecker::checkGraph() const +cmGeneratorExpressionDAGChecker::CheckGraph() const { const cmGeneratorExpressionDAGChecker *parent = this->Parent; while (parent) @@ -173,40 +174,42 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(const char *tgt) return (strcmp(prop, "LINK_LIBRARIES") == 0 || strcmp(prop, "LINK_INTERFACE_LIBRARIES") == 0 || strcmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES") == 0 - || strncmp(prop, "LINK_INTERFACE_LIBRARIES_", 25) == 0 - || strncmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES_", 34) == 0) + || cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES_") + || cmHasLiteralPrefix(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES_")) || strcmp(prop, "INTERFACE_LINK_LIBRARIES") == 0; } -//---------------------------------------------------------------------------- -bool cmGeneratorExpressionDAGChecker::EvaluatingIncludeDirectories() const -{ - const char *prop = this->Property.c_str(); - return (strcmp(prop, "INCLUDE_DIRECTORIES") == 0 - || strcmp(prop, "INTERFACE_INCLUDE_DIRECTORIES") == 0 ); -} +enum TransitiveProperty { +#define DEFINE_ENUM_ENTRY(NAME) NAME, + CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(DEFINE_ENUM_ENTRY) +#undef DEFINE_ENUM_ENTRY + TransitivePropertyTerminal +}; -//---------------------------------------------------------------------------- -bool -cmGeneratorExpressionDAGChecker::EvaluatingSystemIncludeDirectories() const +template<TransitiveProperty> +bool additionalTest(const char* const) { - const char *prop = this->Property.c_str(); - return strcmp(prop, "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES") == 0; + return false; } -//---------------------------------------------------------------------------- -bool cmGeneratorExpressionDAGChecker::EvaluatingCompileDefinitions() const +template<> +bool additionalTest<COMPILE_DEFINITIONS>(const char* const prop) { - const char *prop = this->Property.c_str(); - return (strcmp(prop, "COMPILE_DEFINITIONS") == 0 - || strcmp(prop, "INTERFACE_COMPILE_DEFINITIONS") == 0 - || strncmp(prop, "COMPILE_DEFINITIONS_", 20) == 0); + return cmHasLiteralPrefix(prop, "COMPILE_DEFINITIONS_"); } -//---------------------------------------------------------------------------- -bool cmGeneratorExpressionDAGChecker::EvaluatingCompileOptions() const -{ - const char *prop = this->Property.c_str(); - return (strcmp(prop, "COMPILE_OPTIONS") == 0 - || strcmp(prop, "INTERFACE_COMPILE_OPTIONS") == 0 ); +#define DEFINE_TRANSITIVE_PROPERTY_METHOD(METHOD, PROPERTY) \ +bool cmGeneratorExpressionDAGChecker::METHOD() const \ +{ \ + const char* const prop = this->Property.c_str(); \ + if (strcmp(prop, #PROPERTY) == 0 \ + || strcmp(prop, "INTERFACE_" #PROPERTY) == 0) \ + { \ + return true; \ + } \ + return additionalTest<PROPERTY>(prop); \ } + +CM_FOR_EACH_TRANSITIVE_PROPERTY(DEFINE_TRANSITIVE_PROPERTY_METHOD) + +#undef DEFINE_TRANSITIVE_PROPERTY_METHOD diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index 0b7ef02..b6effa1 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -16,17 +16,25 @@ #include "cmGeneratorExpressionEvaluator.h" +#define CM_SELECT_BOTH(F, A1, A2) F(A1, A2) +#define CM_SELECT_FIRST(F, A1, A2) F(A1) +#define CM_SELECT_SECOND(F, A1, A2) F(A2) + +#define CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, SELECT) \ + SELECT(F, EvaluatingIncludeDirectories, INCLUDE_DIRECTORIES) \ + SELECT(F, EvaluatingSystemIncludeDirectories, SYSTEM_INCLUDE_DIRECTORIES) \ + SELECT(F, EvaluatingCompileDefinitions, COMPILE_DEFINITIONS) \ + SELECT(F, EvaluatingCompileOptions, COMPILE_OPTIONS) \ + SELECT(F, EvaluatingAutoUicOptions, AUTOUIC_OPTIONS) + +#define CM_FOR_EACH_TRANSITIVE_PROPERTY(F) \ + CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, CM_SELECT_BOTH) + #define CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(F) \ - F(EvaluatingIncludeDirectories) \ - F(EvaluatingSystemIncludeDirectories) \ - F(EvaluatingCompileDefinitions) \ - F(EvaluatingCompileOptions) + CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, CM_SELECT_FIRST) #define CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(F) \ - F(INTERFACE_INCLUDE_DIRECTORIES) \ - F(INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) \ - F(INTERFACE_COMPILE_DEFINITIONS) \ - F(INTERFACE_COMPILE_OPTIONS) + CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, CM_SELECT_SECOND) //---------------------------------------------------------------------------- struct cmGeneratorExpressionDAGChecker @@ -44,9 +52,9 @@ struct cmGeneratorExpressionDAGChecker ALREADY_SEEN }; - Result check() const; + Result Check() const; - void reportError(cmGeneratorExpressionContext *context, + void ReportError(cmGeneratorExpressionContext *context, const std::string &expr); bool EvaluatingLinkLibraries(const char *tgt = 0); @@ -54,14 +62,16 @@ struct cmGeneratorExpressionDAGChecker #define DECLARE_TRANSITIVE_PROPERTY_METHOD(METHOD) \ bool METHOD () const; -CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(DECLARE_TRANSITIVE_PROPERTY_METHOD) + CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(DECLARE_TRANSITIVE_PROPERTY_METHOD) + +#undef DECLARE_TRANSITIVE_PROPERTY_METHOD bool GetTransitivePropertiesOnly(); void SetTransitivePropertiesOnly() { this->TransitivePropertiesOnly = true; } private: - Result checkGraph() const; + Result CheckGraph() const; private: const cmGeneratorExpressionDAGChecker * const Parent; diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index cab99ed..bf85870 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -13,6 +13,7 @@ #include "cmGeneratorExpressionEvaluationFile.h" #include "cmMakefile.h" +#include <cmsys/FStream.hxx> #include <assert.h> @@ -78,7 +79,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(const char *config, this->Files.push_back(outputFileName); outputFiles[outputFileName] = outputContent; - std::ofstream fout(outputFileName.c_str()); + cmsys::ofstream fout(outputFileName.c_str()); if(!fout) { @@ -103,7 +104,7 @@ void cmGeneratorExpressionEvaluationFile::Generate() } else { - std::ifstream fin(this->Input.c_str()); + cmsys::ifstream fin(this->Input.c_str()); if(!fin) { cmOStringStream e; diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index abe4e70..1feb03a 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -19,6 +19,7 @@ #include <cmsys/String.h> #include <assert.h> +#include <errno.h> //---------------------------------------------------------------------------- #if !defined(__SUNPRO_CC) || __SUNPRO_CC > 0x510 @@ -48,7 +49,7 @@ struct cmGeneratorExpressionNode enum { DynamicParameters = 0, OneOrMoreParameters = -1, - ZeroOrMoreParameters = -2 + OneOrZeroParameters = -2 }; virtual ~cmGeneratorExpressionNode() {} @@ -82,7 +83,6 @@ static const struct ZeroNode : public cmGeneratorExpressionNode const GeneratorExpressionContent *, cmGeneratorExpressionDAGChecker *) const { - // Unreachable return std::string(); } } zeroNode; @@ -94,13 +94,12 @@ static const struct OneNode : public cmGeneratorExpressionNode virtual bool AcceptsArbitraryContentParameter() const { return true; } - std::string Evaluate(const std::vector<std::string> &, + std::string Evaluate(const std::vector<std::string> ¶meters, cmGeneratorExpressionContext *, const GeneratorExpressionContent *, cmGeneratorExpressionDAGChecker *) const { - // Unreachable - return std::string(); + return parameters.front(); } } oneNode; @@ -199,6 +198,140 @@ static const struct StrEqualNode : public cmGeneratorExpressionNode } strEqualNode; //---------------------------------------------------------------------------- +static const struct EqualNode : public cmGeneratorExpressionNode +{ + EqualNode() {} + + virtual int NumExpectedParameters() const { return 2; } + + std::string Evaluate(const std::vector<std::string> ¶meters, + cmGeneratorExpressionContext *context, + const GeneratorExpressionContent *content, + cmGeneratorExpressionDAGChecker *) const + { + char *pEnd; + + int base = 0; + bool flipSign = false; + + const char *lhs = parameters[0].c_str(); + if (cmHasLiteralPrefix(lhs, "0b") || cmHasLiteralPrefix(lhs, "0B")) + { + base = 2; + lhs += 2; + } + if (cmHasLiteralPrefix(lhs, "-0b") || cmHasLiteralPrefix(lhs, "-0B")) + { + base = 2; + lhs += 3; + flipSign = true; + } + if (cmHasLiteralPrefix(lhs, "+0b") || cmHasLiteralPrefix(lhs, "+0B")) + { + base = 2; + lhs += 3; + } + + long lnum = strtol(lhs, &pEnd, base); + if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) + { + reportError(context, content->GetOriginalExpression(), + "$<EQUAL> parameter " + parameters[0] + " is not a valid integer."); + return std::string(); + } + + if (flipSign) + { + lnum = -lnum; + } + + base = 0; + flipSign = false; + + const char *rhs = parameters[1].c_str(); + if (cmHasLiteralPrefix(rhs, "0b") || cmHasLiteralPrefix(rhs, "0B")) + { + base = 2; + rhs += 2; + } + if (cmHasLiteralPrefix(rhs, "-0b") || cmHasLiteralPrefix(rhs, "-0B")) + { + base = 2; + rhs += 3; + flipSign = true; + } + if (cmHasLiteralPrefix(rhs, "+0b") || cmHasLiteralPrefix(rhs, "+0B")) + { + base = 2; + rhs += 3; + } + + long rnum = strtol(rhs, &pEnd, base); + if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) + { + reportError(context, content->GetOriginalExpression(), + "$<EQUAL> parameter " + parameters[1] + " is not a valid integer."); + return std::string(); + } + + if (flipSign) + { + rnum = -rnum; + } + + return lnum == rnum ? "1" : "0"; + } +} equalNode; + +//---------------------------------------------------------------------------- +static const struct LowerCaseNode : public cmGeneratorExpressionNode +{ + LowerCaseNode() {} + + bool AcceptsArbitraryContentParameter() const { return true; } + + std::string Evaluate(const std::vector<std::string> ¶meters, + cmGeneratorExpressionContext *, + const GeneratorExpressionContent *, + cmGeneratorExpressionDAGChecker *) const + { + return cmSystemTools::LowerCase(parameters.front()); + } +} lowerCaseNode; + +//---------------------------------------------------------------------------- +static const struct UpperCaseNode : public cmGeneratorExpressionNode +{ + UpperCaseNode() {} + + bool AcceptsArbitraryContentParameter() const { return true; } + + std::string Evaluate(const std::vector<std::string> ¶meters, + cmGeneratorExpressionContext *, + const GeneratorExpressionContent *, + cmGeneratorExpressionDAGChecker *) const + { + return cmSystemTools::UpperCase(parameters.front()); + } +} upperCaseNode; + +//---------------------------------------------------------------------------- +static const struct MakeCIdentifierNode : public cmGeneratorExpressionNode +{ + MakeCIdentifierNode() {} + + bool AcceptsArbitraryContentParameter() const { return true; } + + std::string Evaluate(const std::vector<std::string> ¶meters, + cmGeneratorExpressionContext *, + const GeneratorExpressionContent *, + cmGeneratorExpressionDAGChecker *) const + { + return cmSystemTools::MakeCidentifier(parameters.front().c_str()); + } +} makeCIdentifierNode; + +//---------------------------------------------------------------------------- static const struct Angle_RNode : public cmGeneratorExpressionNode { Angle_RNode() {} @@ -251,7 +384,7 @@ struct CompilerIdNode : public cmGeneratorExpressionNode { CompilerIdNode() {} - virtual int NumExpectedParameters() const { return ZeroOrMoreParameters; } + virtual int NumExpectedParameters() const { return OneOrZeroParameters; } std::string EvaluateWithLanguage(const std::vector<std::string> ¶meters, cmGeneratorExpressionContext *context, @@ -279,10 +412,32 @@ struct CompilerIdNode : public cmGeneratorExpressionNode return parameters.front().empty() ? "1" : "0"; } - if (cmsysString_strcasecmp(parameters.begin()->c_str(), compilerId) == 0) + if (strcmp(parameters.begin()->c_str(), compilerId) == 0) { return "1"; } + + if (cmsysString_strcasecmp(parameters.begin()->c_str(), compilerId) == 0) + { + switch(context->Makefile->GetPolicyStatus(cmPolicies::CMP0044)) + { + case cmPolicies::WARN: + { + cmOStringStream e; + e << context->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0044); + context->Makefile->GetCMakeInstance() + ->IssueMessage(cmake::AUTHOR_WARNING, + e.str().c_str(), context->Backtrace); + } + case cmPolicies::OLD: + return "1"; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + break; + } + } return "0"; } }; @@ -297,17 +452,12 @@ static const struct CCompilerIdNode : public CompilerIdNode const GeneratorExpressionContent *content, cmGeneratorExpressionDAGChecker *dagChecker) const { - if (parameters.size() != 0 && parameters.size() != 1) - { - reportError(context, content->GetOriginalExpression(), - "$<C_COMPILER_ID> expression requires one or two parameters"); - return std::string(); - } if (!context->HeadTarget) { reportError(context, content->GetOriginalExpression(), "$<C_COMPILER_ID> may only be used with targets. It may not " "be used with add_custom_command."); + return std::string(); } return this->EvaluateWithLanguage(parameters, context, content, dagChecker, "C"); @@ -324,17 +474,12 @@ static const struct CXXCompilerIdNode : public CompilerIdNode const GeneratorExpressionContent *content, cmGeneratorExpressionDAGChecker *dagChecker) const { - if (parameters.size() != 0 && parameters.size() != 1) - { - reportError(context, content->GetOriginalExpression(), - "$<CXX_COMPILER_ID> expression requires one or two parameters"); - return std::string(); - } if (!context->HeadTarget) { reportError(context, content->GetOriginalExpression(), "$<CXX_COMPILER_ID> may only be used with targets. It may not " "be used with add_custom_command."); + return std::string(); } return this->EvaluateWithLanguage(parameters, context, content, dagChecker, "CXX"); @@ -346,7 +491,7 @@ struct CompilerVersionNode : public cmGeneratorExpressionNode { CompilerVersionNode() {} - virtual int NumExpectedParameters() const { return ZeroOrMoreParameters; } + virtual int NumExpectedParameters() const { return OneOrZeroParameters; } std::string EvaluateWithLanguage(const std::vector<std::string> ¶meters, cmGeneratorExpressionContext *context, @@ -391,17 +536,12 @@ static const struct CCompilerVersionNode : public CompilerVersionNode const GeneratorExpressionContent *content, cmGeneratorExpressionDAGChecker *dagChecker) const { - if (parameters.size() != 0 && parameters.size() != 1) - { - reportError(context, content->GetOriginalExpression(), - "$<C_COMPILER_VERSION> expression requires one or two parameters"); - return std::string(); - } if (!context->HeadTarget) { reportError(context, content->GetOriginalExpression(), "$<C_COMPILER_VERSION> may only be used with targets. It may not " "be used with add_custom_command."); + return std::string(); } return this->EvaluateWithLanguage(parameters, context, content, dagChecker, "C"); @@ -418,18 +558,12 @@ static const struct CxxCompilerVersionNode : public CompilerVersionNode const GeneratorExpressionContent *content, cmGeneratorExpressionDAGChecker *dagChecker) const { - if (parameters.size() != 0 && parameters.size() != 1) - { - reportError(context, content->GetOriginalExpression(), - "$<CXX_COMPILER_VERSION> expression requires one or two " - "parameters"); - return std::string(); - } if (!context->HeadTarget) { reportError(context, content->GetOriginalExpression(), "$<CXX_COMPILER_VERSION> may only be used with targets. It may " "not be used with add_custom_command."); + return std::string(); } return this->EvaluateWithLanguage(parameters, context, content, dagChecker, "CXX"); @@ -438,6 +572,39 @@ static const struct CxxCompilerVersionNode : public CompilerVersionNode //---------------------------------------------------------------------------- +struct PlatformIdNode : public cmGeneratorExpressionNode +{ + PlatformIdNode() {} + + virtual int NumExpectedParameters() const { return OneOrZeroParameters; } + + std::string Evaluate(const std::vector<std::string> ¶meters, + cmGeneratorExpressionContext *context, + const GeneratorExpressionContent *, + cmGeneratorExpressionDAGChecker *) const + { + const char *platformId = context->Makefile ? + context->Makefile->GetSafeDefinition( + "CMAKE_SYSTEM_NAME") : ""; + if (parameters.size() == 0) + { + return platformId ? platformId : ""; + } + + if (!platformId) + { + return parameters.front().empty() ? "1" : "0"; + } + + if (strcmp(parameters.begin()->c_str(), platformId) == 0) + { + return "1"; + } + return "0"; + } +} platformIdNode; + +//---------------------------------------------------------------------------- static const struct VersionGreaterNode : public cmGeneratorExpressionNode { VersionGreaterNode() {} @@ -531,13 +698,17 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode { ConfigurationTestNode() {} - virtual int NumExpectedParameters() const { return 1; } + virtual int NumExpectedParameters() const { return OneOrZeroParameters; } std::string Evaluate(const std::vector<std::string> ¶meters, cmGeneratorExpressionContext *context, const GeneratorExpressionContent *content, cmGeneratorExpressionDAGChecker *) const { + if (parameters.empty()) + { + return configurationNode.Evaluate(parameters, context, content, 0); + } cmsys::RegularExpression configValidator; configValidator.compile("^[A-Za-z0-9_]*$"); if (!configValidator.find(parameters.begin()->c_str())) @@ -619,7 +790,7 @@ static const struct JoinNode : public cmGeneratorExpressionNode } joinNode; #define TRANSITIVE_PROPERTY_NAME(PROPERTY) \ - , #PROPERTY + , "INTERFACE_" #PROPERTY //---------------------------------------------------------------------------- static const char* targetPropertyTransitiveWhitelist[] = { @@ -627,9 +798,11 @@ static const char* targetPropertyTransitiveWhitelist[] = { CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(TRANSITIVE_PROPERTY_NAME) }; +#undef TRANSITIVE_PROPERTY_NAME + std::string getLinkedTargetsContent(const std::vector<std::string> &libraries, - cmTarget *target, - cmTarget *headTarget, + cmTarget const* target, + cmTarget const* headTarget, cmGeneratorExpressionContext *context, cmGeneratorExpressionDAGChecker *dagChecker, const std::string &interfacePropertyName) @@ -671,17 +844,6 @@ std::string getLinkedTargetsContent(const std::vector<std::string> &libraries, } //---------------------------------------------------------------------------- -struct TransitiveWhitelistCompare -{ - explicit TransitiveWhitelistCompare(const std::string &needle) - : Needle(needle) {} - bool operator() (const char *item) - { return strcmp(item, this->Needle.c_str()) == 0; } -private: - std::string Needle; -}; - -//---------------------------------------------------------------------------- static const struct TargetPropertyNode : public cmGeneratorExpressionNode { TargetPropertyNode() {} @@ -704,7 +866,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode cmsys::RegularExpression propertyNameValidator; propertyNameValidator.compile("^[A-Za-z0-9_]+$"); - cmTarget* target = context->HeadTarget; + cmTarget const* target = context->HeadTarget; std::string propertyName = *parameters.begin(); if (!target && parameters.size() == 1) @@ -821,18 +983,17 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode content, dagCheckerParent); - switch (dagChecker.check()) + switch (dagChecker.Check()) { case cmGeneratorExpressionDAGChecker::SELF_REFERENCE: - dagChecker.reportError(context, content->GetOriginalExpression()); + dagChecker.ReportError(context, content->GetOriginalExpression()); return std::string(); case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE: // No error. We just skip cyclic references. return std::string(); case cmGeneratorExpressionDAGChecker::ALREADY_SEEN: for (size_t i = 1; - i < (sizeof(targetPropertyTransitiveWhitelist) / - sizeof(*targetPropertyTransitiveWhitelist)); + i < cmArraySize(targetPropertyTransitiveWhitelist); ++i) { if (targetPropertyTransitiveWhitelist[i] == propertyName) @@ -866,41 +1027,44 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode ASSERT_TRANSITIVE_PROPERTY_METHOD) false); } +#undef ASSERT_TRANSITIVE_PROPERTY_METHOD } std::string linkedTargetsContent; std::string interfacePropertyName; - if (propertyName == "INTERFACE_INCLUDE_DIRECTORIES" - || propertyName == "INCLUDE_DIRECTORIES") - { - interfacePropertyName = "INTERFACE_INCLUDE_DIRECTORIES"; - } - else if (propertyName == "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES") - { - interfacePropertyName = "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES"; - } - else if (propertyName == "INTERFACE_COMPILE_DEFINITIONS" - || propertyName == "COMPILE_DEFINITIONS" - || strncmp(propertyName.c_str(), "COMPILE_DEFINITIONS_", 20) == 0) - { - interfacePropertyName = "INTERFACE_COMPILE_DEFINITIONS"; - } - else if (propertyName == "INTERFACE_COMPILE_OPTIONS" - || propertyName == "COMPILE_OPTIONS") +#define POPULATE_INTERFACE_PROPERTY_NAME(prop) \ + if (propertyName == #prop || propertyName == "INTERFACE_" #prop) \ + { \ + interfacePropertyName = "INTERFACE_" #prop; \ + } \ + else + + CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(POPULATE_INTERFACE_PROPERTY_NAME) + // Note that the above macro terminates with an else + /* else */ if (cmHasLiteralPrefix(propertyName.c_str(), + "COMPILE_DEFINITIONS_")) { - interfacePropertyName = "INTERFACE_COMPILE_OPTIONS"; + cmPolicies::PolicyStatus polSt = + context->Makefile->GetPolicyStatus(cmPolicies::CMP0043); + if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD) + { + interfacePropertyName = "INTERFACE_COMPILE_DEFINITIONS"; + } } +#undef POPULATE_INTERFACE_PROPERTY_NAME + + cmTarget const* headTarget = context->HeadTarget + ? context->HeadTarget : target; - cmTarget *headTarget = context->HeadTarget ? context->HeadTarget : target; + const char * const *transBegin = + cmArrayBegin(targetPropertyTransitiveWhitelist) + 1; + const char * const *transEnd = + cmArrayEnd(targetPropertyTransitiveWhitelist); - const char **transBegin = targetPropertyTransitiveWhitelist + 1; - const char **transEnd = targetPropertyTransitiveWhitelist - + (sizeof(targetPropertyTransitiveWhitelist) / - sizeof(*targetPropertyTransitiveWhitelist)); if (std::find_if(transBegin, transEnd, - TransitiveWhitelistCompare(propertyName)) != transEnd) + cmStrCmp(propertyName)) != transEnd) { std::vector<std::string> libs; @@ -916,7 +1080,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } } else if (std::find_if(transBegin, transEnd, - TransitiveWhitelistCompare(interfacePropertyName)) != transEnd) + cmStrCmp(interfacePropertyName)) != transEnd) { const cmTarget::LinkImplementation *impl = target->GetLinkImplementation( context->Config, @@ -936,7 +1100,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if (!prop) { - if (target->IsImported()) + if (target->IsImported() + || target->GetType() == cmTarget::INTERFACE_LIBRARY) { return linkedTargetsContent; } @@ -958,13 +1123,56 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config); return propContent ? propContent : ""; } + if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName, + context->Config)) + { + context->HadContextSensitiveCondition = true; + const char *propContent = + target->GetLinkInterfaceDependentNumberMinProperty( + propertyName, + context->Config); + return propContent ? propContent : ""; + } + if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName, + context->Config)) + { + context->HadContextSensitiveCondition = true; + const char *propContent = + target->GetLinkInterfaceDependentNumberMaxProperty( + propertyName, + context->Config); + return propContent ? propContent : ""; + } return linkedTargetsContent; } + if (!target->IsImported() + && dagCheckerParent && !dagCheckerParent->EvaluatingLinkLibraries()) + { + if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName, + context->Config)) + { + context->HadContextSensitiveCondition = true; + const char *propContent = + target->GetLinkInterfaceDependentNumberMinProperty( + propertyName, + context->Config); + return propContent ? propContent : ""; + } + if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName, + context->Config)) + { + context->HadContextSensitiveCondition = true; + const char *propContent = + target->GetLinkInterfaceDependentNumberMaxProperty( + propertyName, + context->Config); + return propContent ? propContent : ""; + } + } for (size_t i = 1; - i < (sizeof(targetPropertyTransitiveWhitelist) / - sizeof(*targetPropertyTransitiveWhitelist)); + i < cmArraySize(targetPropertyTransitiveWhitelist); ++i) { if (targetPropertyTransitiveWhitelist[i] == interfacePropertyName) @@ -1026,7 +1234,8 @@ static const char* targetPolicyWhitelist[] = { #undef TARGET_POLICY_STRING }; -cmPolicies::PolicyStatus statusForTarget(cmTarget *tgt, const char *policy) +cmPolicies::PolicyStatus statusForTarget(cmTarget const* tgt, + const char *policy) { #define RETURN_POLICY(POLICY) \ if (strcmp(policy, #POLICY) == 0) \ @@ -1080,10 +1289,7 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode context->HadContextSensitiveCondition = true; - for (size_t i = 1; - i < (sizeof(targetPolicyWhitelist) / - sizeof(*targetPolicyWhitelist)); - ++i) + for (size_t i = 1; i < cmArraySize(targetPolicyWhitelist); ++i) { const char *policy = targetPolicyWhitelist[i]; if (parameters.front() == policy) @@ -1277,7 +1483,7 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode "No target \"" + name + "\""); return std::string(); } - if(target->GetType() >= cmTarget::UTILITY && + if(target->GetType() >= cmTarget::OBJECT_LIBRARY && target->GetType() != cmTarget::UNKNOWN_LIBRARY) { ::reportError(context, content->GetOriginalExpression(), @@ -1356,6 +1562,8 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier) return &cCompilerVersionNode; else if (identifier == "CXX_COMPILER_VERSION") return &cxxCompilerVersionNode; + else if (identifier == "PLATFORM_ID") + return &platformIdNode; else if (identifier == "CONFIGURATION") return &configurationNode; else if (identifier == "CONFIG") @@ -1380,6 +1588,14 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier) return &targetSoNameFileDirNode; else if (identifier == "STREQUAL") return &strEqualNode; + else if (identifier == "EQUAL") + return &equalNode; + else if (identifier == "LOWER_CASE") + return &lowerCaseNode; + else if (identifier == "UPPER_CASE") + return &upperCaseNode; + else if (identifier == "MAKE_C_IDENTIFIER") + return &makeCIdentifierNode; else if (identifier == "BOOL") return &boolNode; else if (identifier == "ANGLE-R") @@ -1411,7 +1627,7 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier) //---------------------------------------------------------------------------- GeneratorExpressionContent::GeneratorExpressionContent( const char *startContent, - unsigned int length) + size_t length) : StartContent(startContent), ContentLength(length) { @@ -1524,14 +1740,6 @@ std::string GeneratorExpressionContent::Evaluate( return std::string(); } - if (node->NumExpectedParameters() == 1 - && node->AcceptsArbitraryContentParameter()) - { - return this->ProcessArbitraryContent(node, identifier, context, - dagChecker, - this->ParamChildren.begin()); - } - std::vector<std::string> parameters; this->EvaluateParameters(node, identifier, context, dagChecker, parameters); if (context->HadError) @@ -1559,33 +1767,35 @@ std::string GeneratorExpressionContent::EvaluateParameters( pend = this->ParamChildren.end(); const bool acceptsArbitraryContent = node->AcceptsArbitraryContentParameter(); - for ( ; pit != pend; ++pit) + int counter = 1; + for ( ; pit != pend; ++pit, ++counter) { - std::string parameter; - std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it = - pit->begin(); - const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end = - pit->end(); - for ( ; it != end; ++it) - { - parameter += (*it)->Evaluate(context, dagChecker); - if (context->HadError) - { - return std::string(); - } - } - parameters.push_back(parameter); - if (acceptsArbitraryContent - && parameters.size() == (unsigned int)numExpected - 1) + if (acceptsArbitraryContent && counter == numExpected) { - assert(pit != pend); std::string lastParam = this->ProcessArbitraryContent(node, identifier, context, dagChecker, - pit + 1); + pit); parameters.push_back(lastParam); return std::string(); } + else + { + std::string parameter; + std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it = + pit->begin(); + const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end = + pit->end(); + for ( ; it != end; ++it) + { + parameter += (*it)->Evaluate(context, dagChecker); + if (context->HadError) + { + return std::string(); + } + } + parameters.push_back(parameter); + } } } @@ -1621,6 +1831,12 @@ std::string GeneratorExpressionContent::EvaluateParameters( reportError(context, this->GetOriginalExpression(), "$<" + identifier + "> expression requires at least one parameter."); } + if (numExpected == cmGeneratorExpressionNode::OneOrZeroParameters + && parameters.size() > 1) + { + reportError(context, this->GetOriginalExpression(), "$<" + identifier + + "> expression requires one or zero parameters."); + } return std::string(); } diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h index 218abf1..49e52df 100644 --- a/Source/cmGeneratorExpressionEvaluator.h +++ b/Source/cmGeneratorExpressionEvaluator.h @@ -24,13 +24,13 @@ struct cmGeneratorExpressionContext { cmListFileBacktrace Backtrace; std::set<cmTarget*> DependTargets; - std::set<cmTarget*> AllTargets; + std::set<cmTarget const*> AllTargets; std::set<cmStdString> SeenTargetProperties; cmMakefile *Makefile; const char *Config; - cmTarget *HeadTarget; // The target whose property is being evaluated. - cmTarget *CurrentTarget; // The dependent of HeadTarget which appears - // directly or indirectly in the property. + cmTarget const* HeadTarget; // The target whose property is being evaluated. + cmTarget const* CurrentTarget; // The dependent of HeadTarget which appears + // directly or indirectly in the property. bool Quiet; bool HadError; bool HadContextSensitiveCondition; @@ -63,7 +63,7 @@ private: struct TextContent : public cmGeneratorExpressionEvaluator { - TextContent(const char *start, unsigned int length) + TextContent(const char *start, size_t length) : Content(start), Length(length) { @@ -80,25 +80,25 @@ struct TextContent : public cmGeneratorExpressionEvaluator return cmGeneratorExpressionEvaluator::Text; } - void Extend(unsigned int length) + void Extend(size_t length) { this->Length += length; } - unsigned int GetLength() + size_t GetLength() { return this->Length; } private: const char *Content; - unsigned int Length; + size_t Length; }; //---------------------------------------------------------------------------- struct GeneratorExpressionContent : public cmGeneratorExpressionEvaluator { - GeneratorExpressionContent(const char *startContent, unsigned int length); + GeneratorExpressionContent(const char *startContent, size_t length); void SetIdentifier(std::vector<cmGeneratorExpressionEvaluator*> identifier) { this->IdentifierChildren = identifier; @@ -141,7 +141,7 @@ private: std::vector<cmGeneratorExpressionEvaluator*> IdentifierChildren; std::vector<std::vector<cmGeneratorExpressionEvaluator*> > ParamChildren; const char *StartContent; - unsigned int ContentLength; + size_t ContentLength; }; #endif diff --git a/Source/cmGeneratorExpressionLexer.h b/Source/cmGeneratorExpressionLexer.h index 5f16712..83d661d 100644 --- a/Source/cmGeneratorExpressionLexer.h +++ b/Source/cmGeneratorExpressionLexer.h @@ -19,7 +19,7 @@ //---------------------------------------------------------------------------- struct cmGeneratorExpressionToken { - cmGeneratorExpressionToken(unsigned type, const char *c, unsigned l) + cmGeneratorExpressionToken(unsigned type, const char *c, size_t l) : TokenType(type), Content(c), Length(l) { } @@ -32,7 +32,7 @@ struct cmGeneratorExpressionToken }; unsigned TokenType; const char *Content; - unsigned Length; + size_t Length; }; /** \class cmGeneratorExpressionLexer diff --git a/Source/cmGeneratorExpressionParser.cxx b/Source/cmGeneratorExpressionParser.cxx index e1fb8f1..a41a6e5 100644 --- a/Source/cmGeneratorExpressionParser.cxx +++ b/Source/cmGeneratorExpressionParser.cxx @@ -235,7 +235,7 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression( return; } - int contentLength = ((this->it - 1)->Content + size_t contentLength = ((this->it - 1)->Content - startToken->Content) + (this->it - 1)->Length; GeneratorExpressionContent *content = new GeneratorExpressionContent( diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 62ac263..0fcee3e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -18,6 +18,11 @@ #include "cmSourceFile.h" #include "cmGeneratorExpression.h" #include "cmGeneratorExpressionDAGChecker.h" +#include "cmComputeLinkInformation.h" + +#include <queue> + +#include "assert.h" //---------------------------------------------------------------------------- cmGeneratorTarget::cmGeneratorTarget(cmTarget* t): Target(t) @@ -25,8 +30,6 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t): Target(t) this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = this->Makefile->GetLocalGenerator(); this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator(); - this->ClassifySources(); - this->LookupObjectLibraries(); } //---------------------------------------------------------------------------- @@ -42,15 +45,146 @@ const char *cmGeneratorTarget::GetName() const } //---------------------------------------------------------------------------- -const char *cmGeneratorTarget::GetProperty(const char *prop) +const char *cmGeneratorTarget::GetProperty(const char *prop) const { return this->Target->GetProperty(prop); } //---------------------------------------------------------------------------- +std::vector<cmSourceFile*> const* +cmGeneratorTarget::GetSourceDepends(cmSourceFile* sf) const +{ + SourceEntriesType::const_iterator i = this->SourceEntries.find(sf); + if(i != this->SourceEntries.end()) + { + return &i->second.Depends; + } + return 0; +} + +static void handleSystemIncludesDep(cmMakefile *mf, const std::string &name, + const char *config, cmTarget *headTarget, + cmGeneratorExpressionDAGChecker *dagChecker, + std::vector<std::string>& result, + bool excludeImported) +{ + cmTarget* depTgt = mf->FindTargetToUse(name.c_str()); + + if (!depTgt) + { + return; + } + + cmListFileBacktrace lfbt; + + if (const char* dirs = + depTgt->GetProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")) + { + cmGeneratorExpression ge(lfbt); + cmSystemTools::ExpandListArgument(ge.Parse(dirs) + ->Evaluate(mf, + config, false, headTarget, + depTgt, dagChecker), result); + } + if (!depTgt->IsImported() || excludeImported) + { + return; + } + + if (const char* dirs = + depTgt->GetProperty("INTERFACE_INCLUDE_DIRECTORIES")) + { + cmGeneratorExpression ge(lfbt); + cmSystemTools::ExpandListArgument(ge.Parse(dirs) + ->Evaluate(mf, + config, false, headTarget, + depTgt, dagChecker), result); + } +} + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget::GetObjectSources(std::vector<cmSourceFile*> &objs) const +{ + objs = this->ObjectSources; +} + +//---------------------------------------------------------------------------- +const std::string& cmGeneratorTarget::GetObjectName(cmSourceFile const* file) +{ + return this->Objects[file]; +} + +void cmGeneratorTarget::AddObject(cmSourceFile *sf, std::string const&name) +{ + this->Objects[sf] = name; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile* sf) +{ + this->ExplicitObjectName.insert(sf); +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::HasExplicitObjectName(cmSourceFile const* file) const +{ + std::set<cmSourceFile const*>::const_iterator it + = this->ExplicitObjectName.find(file); + return it != this->ExplicitObjectName.end(); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetResxSources(std::vector<cmSourceFile*>& srcs) const +{ + srcs = this->ResxSources; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetIDLSources(std::vector<cmSourceFile*>& srcs) const +{ + srcs = this->IDLSources; +} + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget::GetHeaderSources(std::vector<cmSourceFile*>& srcs) const +{ + srcs = this->HeaderSources; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetExtraSources(std::vector<cmSourceFile*>& srcs) const +{ + srcs = this->ExtraSources; +} + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget::GetCustomCommands(std::vector<cmSourceFile*>& srcs) const +{ + srcs = this->CustomCommands; +} + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget::GetExpectedResxHeaders(std::set<std::string>& srcs) const +{ + srcs = this->ExpectedResxHeaders; +} + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget::GetExternalObjects(std::vector<cmSourceFile*>& srcs) const +{ + srcs = this->ExternalObjects; +} + +//---------------------------------------------------------------------------- bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, - const char *config) + const char *config) const { + assert(this->GetType() != cmTarget::INTERFACE_LIBRARY); std::string config_upper; if(config && *config) { @@ -58,65 +192,114 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, } typedef std::map<std::string, std::vector<std::string> > IncludeCacheType; - IncludeCacheType::iterator iter = + IncludeCacheType::const_iterator iter = this->SystemIncludesCache.find(config_upper); if (iter == this->SystemIncludesCache.end()) { + cmTarget::LinkImplementation const* impl + = this->Target->GetLinkImplementation(config, this->Target); + if(!impl) + { + return false; + } + + cmListFileBacktrace lfbt; + cmGeneratorExpressionDAGChecker dagChecker(lfbt, + this->GetName(), + "SYSTEM_INCLUDE_DIRECTORIES", 0, 0); + + bool excludeImported + = this->Target->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED"); + std::vector<std::string> result; for (std::set<cmStdString>::const_iterator it = this->Target->GetSystemIncludeDirectories().begin(); it != this->Target->GetSystemIncludeDirectories().end(); ++it) { - cmListFileBacktrace lfbt; cmGeneratorExpression ge(lfbt); + cmSystemTools::ExpandListArgument(ge.Parse(*it) + ->Evaluate(this->Makefile, + config, false, this->Target, + &dagChecker), result); + } + + std::set<cmStdString> uniqueDeps; + for(std::vector<std::string>::const_iterator li = impl->Libraries.begin(); + li != impl->Libraries.end(); ++li) + { + if (uniqueDeps.insert(*li).second) + { + cmTarget* tgt = this->Makefile->FindTargetToUse(li->c_str()); - cmGeneratorExpressionDAGChecker dagChecker(lfbt, - this->GetName(), - "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", 0, 0); + if (!tgt) + { + continue; + } - cmSystemTools::ExpandListArgument(ge.Parse(*it) - ->Evaluate(this->Makefile, - config, false, this->Target, - &dagChecker), result); + handleSystemIncludesDep(this->Makefile, *li, config, this->Target, + &dagChecker, result, excludeImported); + + std::vector<std::string> deps; + tgt->GetTransitivePropertyLinkLibraries(config, this->Target, deps); + + for(std::vector<std::string>::const_iterator di = deps.begin(); + di != deps.end(); ++di) + { + if (uniqueDeps.insert(*di).second) + { + handleSystemIncludesDep(this->Makefile, *di, config, this->Target, + &dagChecker, result, excludeImported); + } + } + } } + std::set<cmStdString> unique; for(std::vector<std::string>::iterator li = result.begin(); li != result.end(); ++li) { cmSystemTools::ConvertToUnixSlashes(*li); + unique.insert(*li); + } + result.clear(); + for(std::set<cmStdString>::iterator li = unique.begin(); + li != unique.end(); ++li) + { + result.push_back(*li); } IncludeCacheType::value_type entry(config_upper, result); iter = this->SystemIncludesCache.insert(entry).first; } - if (std::find(iter->second.begin(), - iter->second.end(), dir) != iter->second.end()) - { - return true; - } - return false; + std::string dirString = dir; + return std::binary_search(iter->second.begin(), iter->second.end(), + dirString); } //---------------------------------------------------------------------------- -bool cmGeneratorTarget::GetPropertyAsBool(const char *prop) +bool cmGeneratorTarget::GetPropertyAsBool(const char *prop) const { return this->Target->GetPropertyAsBool(prop); } //---------------------------------------------------------------------------- -std::vector<cmSourceFile*> const& cmGeneratorTarget::GetSourceFiles() +void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*> &files) const { - return this->Target->GetSourceFiles(); + this->Target->GetSourceFiles(files); } //---------------------------------------------------------------------------- void cmGeneratorTarget::ClassifySources() { cmsys::RegularExpression header(CM_HEADER_REGEX); - bool isObjLib = this->Target->GetType() == cmTarget::OBJECT_LIBRARY; + + cmTarget::TargetType targetType = this->Target->GetType(); + bool isObjLib = targetType == cmTarget::OBJECT_LIBRARY; + std::vector<cmSourceFile*> badObjLib; - std::vector<cmSourceFile*> const& sources = this->Target->GetSourceFiles(); + std::vector<cmSourceFile*> sources; + this->Target->GetSourceFiles(sources); for(std::vector<cmSourceFile*>::const_iterator si = sources.begin(); si != sources.end(); ++si) { @@ -126,6 +309,10 @@ void cmGeneratorTarget::ClassifySources() { this->CustomCommands.push_back(sf); } + else if(targetType == cmTarget::UTILITY) + { + this->ExtraSources.push_back(sf); + } else if(sf->GetPropertyAsBool("HEADER_FILE_ONLY")) { this->HeaderSources.push_back(sf); @@ -251,7 +438,8 @@ void cmGeneratorTarget::LookupObjectLibraries() } //---------------------------------------------------------------------------- -void cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs) +void +cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs) const { for(std::vector<cmTarget*>::const_iterator ti = this->ObjectLibraries.begin(); @@ -272,8 +460,288 @@ void cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs) } //---------------------------------------------------------------------------- +class cmTargetTraceDependencies +{ +public: + cmTargetTraceDependencies(cmGeneratorTarget* target); + void Trace(); +private: + cmTarget* Target; + cmGeneratorTarget* GeneratorTarget; + cmMakefile* Makefile; + cmGlobalGenerator const* GlobalGenerator; + typedef cmGeneratorTarget::SourceEntry SourceEntry; + SourceEntry* CurrentEntry; + std::queue<cmSourceFile*> SourceQueue; + std::set<cmSourceFile*> SourcesQueued; + typedef std::map<cmStdString, cmSourceFile*> NameMapType; + NameMapType NameMap; + + void QueueSource(cmSourceFile* sf); + void FollowName(std::string const& name); + void FollowNames(std::vector<std::string> const& names); + bool IsUtility(std::string const& dep); + void CheckCustomCommand(cmCustomCommand const& cc); + void CheckCustomCommands(const std::vector<cmCustomCommand>& commands); +}; + +//---------------------------------------------------------------------------- +cmTargetTraceDependencies +::cmTargetTraceDependencies(cmGeneratorTarget* target): + Target(target->Target), GeneratorTarget(target) +{ + // Convenience. + this->Makefile = this->Target->GetMakefile(); + this->GlobalGenerator = + this->Makefile->GetLocalGenerator()->GetGlobalGenerator(); + this->CurrentEntry = 0; + + // Queue all the source files already specified for the target. + std::vector<cmSourceFile*> sources; + this->Target->GetSourceFiles(sources); + for(std::vector<cmSourceFile*>::const_iterator si = sources.begin(); + si != sources.end(); ++si) + { + this->QueueSource(*si); + } + + // Queue pre-build, pre-link, and post-build rule dependencies. + this->CheckCustomCommands(this->Target->GetPreBuildCommands()); + this->CheckCustomCommands(this->Target->GetPreLinkCommands()); + this->CheckCustomCommands(this->Target->GetPostBuildCommands()); +} + +//---------------------------------------------------------------------------- +void cmTargetTraceDependencies::Trace() +{ + // Process one dependency at a time until the queue is empty. + while(!this->SourceQueue.empty()) + { + // Get the next source from the queue. + cmSourceFile* sf = this->SourceQueue.front(); + this->SourceQueue.pop(); + this->CurrentEntry = &this->GeneratorTarget->SourceEntries[sf]; + + // Queue dependencies added explicitly by the user. + if(const char* additionalDeps = sf->GetProperty("OBJECT_DEPENDS")) + { + std::vector<std::string> objDeps; + cmSystemTools::ExpandListArgument(additionalDeps, objDeps); + this->FollowNames(objDeps); + } + + // Queue the source needed to generate this file, if any. + this->FollowName(sf->GetFullPath()); + + // Queue dependencies added programatically by commands. + this->FollowNames(sf->GetDepends()); + + // Queue custom command dependencies. + if(cmCustomCommand const* cc = sf->GetCustomCommand()) + { + this->CheckCustomCommand(*cc); + } + } + this->CurrentEntry = 0; +} + +//---------------------------------------------------------------------------- +void cmTargetTraceDependencies::QueueSource(cmSourceFile* sf) +{ + if(this->SourcesQueued.insert(sf).second) + { + this->SourceQueue.push(sf); + + // Make sure this file is in the target. + this->Target->AddSourceFile(sf); + } +} + +//---------------------------------------------------------------------------- +void cmTargetTraceDependencies::FollowName(std::string const& name) +{ + NameMapType::iterator i = this->NameMap.find(name); + if(i == this->NameMap.end()) + { + // Check if we know how to generate this file. + cmSourceFile* sf = this->Makefile->GetSourceFileWithOutput(name.c_str()); + NameMapType::value_type entry(name, sf); + i = this->NameMap.insert(entry).first; + } + if(cmSourceFile* sf = i->second) + { + // Record the dependency we just followed. + if(this->CurrentEntry) + { + this->CurrentEntry->Depends.push_back(sf); + } + + this->QueueSource(sf); + } +} + +//---------------------------------------------------------------------------- +void +cmTargetTraceDependencies::FollowNames(std::vector<std::string> const& names) +{ + for(std::vector<std::string>::const_iterator i = names.begin(); + i != names.end(); ++i) + { + this->FollowName(*i); + } +} + +//---------------------------------------------------------------------------- +bool cmTargetTraceDependencies::IsUtility(std::string const& dep) +{ + // Dependencies on targets (utilities) are supposed to be named by + // just the target name. However for compatibility we support + // naming the output file generated by the target (assuming there is + // no output-name property which old code would not have set). In + // that case the target name will be the file basename of the + // dependency. + std::string util = cmSystemTools::GetFilenameName(dep); + if(cmSystemTools::GetFilenameLastExtension(util) == ".exe") + { + util = cmSystemTools::GetFilenameWithoutLastExtension(util); + } + + // Check for a target with this name. + if(cmTarget* t = this->Makefile->FindTargetToUse(util.c_str())) + { + // If we find the target and the dep was given as a full path, + // then make sure it was not a full path to something else, and + // the fact that the name matched a target was just a coincidence. + if(cmSystemTools::FileIsFullPath(dep.c_str())) + { + if(t->GetType() >= cmTarget::EXECUTABLE && + t->GetType() <= cmTarget::MODULE_LIBRARY) + { + // This is really only for compatibility so we do not need to + // worry about configuration names and output names. + std::string tLocation = t->GetLocation(0); + tLocation = cmSystemTools::GetFilenamePath(tLocation); + std::string depLocation = cmSystemTools::GetFilenamePath(dep); + depLocation = cmSystemTools::CollapseFullPath(depLocation.c_str()); + tLocation = cmSystemTools::CollapseFullPath(tLocation.c_str()); + if(depLocation == tLocation) + { + this->Target->AddUtility(util.c_str()); + return true; + } + } + } + else + { + // The original name of the dependency was not a full path. It + // must name a target, so add the target-level dependency. + this->Target->AddUtility(util.c_str()); + return true; + } + } + + // The dependency does not name a target built in this project. + return false; +} + +//---------------------------------------------------------------------------- +void +cmTargetTraceDependencies +::CheckCustomCommand(cmCustomCommand const& cc) +{ + // Transform command names that reference targets built in this + // project to corresponding target-level dependencies. + cmGeneratorExpression ge(cc.GetBacktrace()); + + // Add target-level dependencies referenced by generator expressions. + std::set<cmTarget*> targets; + + for(cmCustomCommandLines::const_iterator cit = cc.GetCommandLines().begin(); + cit != cc.GetCommandLines().end(); ++cit) + { + std::string const& command = *cit->begin(); + // Check for a target with this name. + if(cmTarget* t = this->Makefile->FindTargetToUse(command.c_str())) + { + if(t->GetType() == cmTarget::EXECUTABLE) + { + // The command refers to an executable target built in + // this project. Add the target-level dependency to make + // sure the executable is up to date before this custom + // command possibly runs. + this->Target->AddUtility(command.c_str()); + } + } + + // Check for target references in generator expressions. + for(cmCustomCommandLine::const_iterator cli = cit->begin(); + cli != cit->end(); ++cli) + { + const cmsys::auto_ptr<cmCompiledGeneratorExpression> cge + = ge.Parse(*cli); + cge->Evaluate(this->Makefile, 0, true); + std::set<cmTarget*> geTargets = cge->GetTargets(); + for(std::set<cmTarget*>::const_iterator it = geTargets.begin(); + it != geTargets.end(); ++it) + { + targets.insert(*it); + } + } + } + + for(std::set<cmTarget*>::iterator ti = targets.begin(); + ti != targets.end(); ++ti) + { + this->Target->AddUtility((*ti)->GetName()); + } + + // Queue the custom command dependencies. + std::vector<std::string> const& depends = cc.GetDepends(); + for(std::vector<std::string>::const_iterator di = depends.begin(); + di != depends.end(); ++di) + { + std::string const& dep = *di; + if(!this->IsUtility(dep)) + { + // The dependency does not name a target and may be a file we + // know how to generate. Queue it. + this->FollowName(dep); + } + } +} + +//---------------------------------------------------------------------------- +void +cmTargetTraceDependencies +::CheckCustomCommands(const std::vector<cmCustomCommand>& commands) +{ + for(std::vector<cmCustomCommand>::const_iterator cli = commands.begin(); + cli != commands.end(); ++cli) + { + this->CheckCustomCommand(*cli); + } +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::TraceDependencies() +{ + // CMake-generated targets have no dependencies to trace. Normally tracing + // would find nothing anyway, but when building CMake itself the "install" + // target command ends up referencing the "cmake" target but we do not + // really want the dependency because "install" depend on "all" anyway. + if(this->GetType() == cmTarget::GLOBAL_TARGET) + { + return; + } + + // Use a helper object to trace the dependencies. + cmTargetTraceDependencies tracer(this); + tracer.Trace(); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetAppleArchs(const char* config, - std::vector<std::string>& archVec) + std::vector<std::string>& archVec) const { const char* archs = 0; if(config && *config) @@ -293,7 +761,7 @@ void cmGeneratorTarget::GetAppleArchs(const char* config, } //---------------------------------------------------------------------------- -const char* cmGeneratorTarget::GetCreateRuleVariable() +const char* cmGeneratorTarget::GetCreateRuleVariable() const { switch(this->GetType()) { @@ -312,8 +780,96 @@ const char* cmGeneratorTarget::GetCreateRuleVariable() } //---------------------------------------------------------------------------- -std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories( - const char *config) +std::vector<std::string> +cmGeneratorTarget::GetIncludeDirectories(const char *config) const { return this->Target->GetIncludeDirectories(config); } + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GenerateTargetManifest(const char* config) const +{ + if (this->Target->IsImported()) + { + return; + } + cmMakefile* mf = this->Target->GetMakefile(); + cmLocalGenerator* lg = mf->GetLocalGenerator(); + cmGlobalGenerator* gg = lg->GetGlobalGenerator(); + + // Get the names. + std::string name; + std::string soName; + std::string realName; + std::string impName; + std::string pdbName; + if(this->GetType() == cmTarget::EXECUTABLE) + { + this->Target->GetExecutableNames(name, realName, impName, pdbName, + config); + } + else if(this->GetType() == cmTarget::STATIC_LIBRARY || + this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY) + { + this->Target->GetLibraryNames(name, soName, realName, impName, pdbName, + config); + } + else + { + return; + } + + // Get the directory. + std::string dir = this->Target->GetDirectory(config, false); + + // Add each name. + std::string f; + if(!name.empty()) + { + f = dir; + f += "/"; + f += name; + gg->AddToManifest(config? config:"", f); + } + if(!soName.empty()) + { + f = dir; + f += "/"; + f += soName; + gg->AddToManifest(config? config:"", f); + } + if(!realName.empty()) + { + f = dir; + f += "/"; + f += realName; + gg->AddToManifest(config? config:"", f); + } + if(!pdbName.empty()) + { + f = dir; + f += "/"; + f += pdbName; + gg->AddToManifest(config? config:"", f); + } + if(!impName.empty()) + { + f = this->Target->GetDirectory(config, true); + f += "/"; + f += impName; + gg->AddToManifest(config? config:"", f); + } +} + +bool cmStrictTargetComparison::operator()(cmTarget const* t1, + cmTarget const* t2) const +{ + int nameResult = strcmp(t1->GetName(), t2->GetName()); + if (nameResult == 0) + { + return strcmp(t1->GetMakefile()->GetStartOutputDirectory(), + t2->GetMakefile()->GetStartOutputDirectory()) < 0; + } + return nameResult < 0; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index dedfa60..a4caba1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -28,62 +28,95 @@ public: int GetType() const; const char *GetName() const; - const char *GetProperty(const char *prop); - bool GetPropertyAsBool(const char *prop); - std::vector<cmSourceFile*> const& GetSourceFiles(); + const char *GetProperty(const char *prop) const; + bool GetPropertyAsBool(const char *prop) const; + void GetSourceFiles(std::vector<cmSourceFile*>& files) const; + + void GetObjectSources(std::vector<cmSourceFile*> &) const; + const std::string& GetObjectName(cmSourceFile const* file); + + void AddObject(cmSourceFile *sf, std::string const&name); + bool HasExplicitObjectName(cmSourceFile const* file) const; + void AddExplicitObjectName(cmSourceFile* sf); + + void GetResxSources(std::vector<cmSourceFile*>&) const; + void GetIDLSources(std::vector<cmSourceFile*>&) const; + void GetExternalObjects(std::vector<cmSourceFile*>&) const; + void GetHeaderSources(std::vector<cmSourceFile*>&) const; + void GetExtraSources(std::vector<cmSourceFile*>&) const; + void GetCustomCommands(std::vector<cmSourceFile*>&) const; + void GetExpectedResxHeaders(std::set<std::string>&) const; cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; - cmGlobalGenerator* GlobalGenerator; - - /** Sources classified by purpose. */ - std::vector<cmSourceFile*> CustomCommands; - std::vector<cmSourceFile*> ExtraSources; - std::vector<cmSourceFile*> HeaderSources; - std::vector<cmSourceFile*> ObjectSources; - std::vector<cmSourceFile*> ExternalObjects; - std::vector<cmSourceFile*> IDLSources; - std::vector<cmSourceFile*> ResxSources; + cmGlobalGenerator const* GlobalGenerator; std::string ModuleDefinitionFile; - std::map<cmSourceFile const*, std::string> Objects; - std::set<cmSourceFile const*> ExplicitObjectName; - - std::set<std::string> ExpectedResxHeaders; - /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ std::string ObjectDirectory; - std::vector<cmTarget*> ObjectLibraries; - - void UseObjectLibraries(std::vector<std::string>& objs); + void UseObjectLibraries(std::vector<std::string>& objs) const; void GetAppleArchs(const char* config, - std::vector<std::string>& archVec); + std::vector<std::string>& archVec) const; ///! Return the rule variable used to create this type of target, // need to add CMAKE_(LANG) for full name. - const char* GetCreateRuleVariable(); + const char* GetCreateRuleVariable() const; /** Get the include directories for this target. */ - std::vector<std::string> GetIncludeDirectories(const char *config); + std::vector<std::string> GetIncludeDirectories(const char *config) const; - bool IsSystemIncludeDirectory(const char *dir, const char *config); + bool IsSystemIncludeDirectory(const char *dir, const char *config) const; + + /** Add the target output files to the global generator manifest. */ + void GenerateTargetManifest(const char* config) const; + + /** + * Trace through the source files in this target and add al source files + * that they depend on, used by all generators + */ + void TraceDependencies(); -private: void ClassifySources(); void LookupObjectLibraries(); - std::map<std::string, std::vector<std::string> > SystemIncludesCache; + /** Get sources that must be built before the given source. */ + std::vector<cmSourceFile*> const* GetSourceDepends(cmSourceFile* sf) const; + +private: + friend class cmTargetTraceDependencies; + struct SourceEntry { std::vector<cmSourceFile*> Depends; }; + typedef std::map<cmSourceFile*, SourceEntry> SourceEntriesType; + SourceEntriesType SourceEntries; + + std::vector<cmSourceFile*> CustomCommands; + std::vector<cmSourceFile*> ExtraSources; + std::vector<cmSourceFile*> HeaderSources; + std::vector<cmSourceFile*> ExternalObjects; + std::vector<cmSourceFile*> IDLSources; + std::vector<cmSourceFile*> ResxSources; + std::map<cmSourceFile const*, std::string> Objects; + std::set<cmSourceFile const*> ExplicitObjectName; + std::set<std::string> ExpectedResxHeaders; + std::vector<cmSourceFile*> ObjectSources; + std::vector<cmTarget*> ObjectLibraries; + mutable std::map<std::string, std::vector<std::string> > SystemIncludesCache; cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; -typedef std::map<cmTarget*, cmGeneratorTarget*> cmGeneratorTargetsType; +struct cmStrictTargetComparison { + bool operator()(cmTarget const* t1, cmTarget const* t2) const; +}; + +typedef std::map<cmTarget const*, + cmGeneratorTarget*, + cmStrictTargetComparison> cmGeneratorTargetsType; #endif diff --git a/Source/cmGetCMakePropertyCommand.h b/Source/cmGetCMakePropertyCommand.h index b77eaae..6c58bb4 100644 --- a/Source/cmGetCMakePropertyCommand.h +++ b/Source/cmGetCMakePropertyCommand.h @@ -39,31 +39,6 @@ public: */ virtual const char* GetName() const { return "get_cmake_property";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Get a property of the CMake instance."; - } - - /** - * Longer documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " get_cmake_property(VAR property)\n" - "Get a property from the CMake instance. " - "The value of the property is stored in the variable VAR. " - "If the property is not found, VAR will be set to \"NOTFOUND\". " - "Some supported properties " - "include: VARIABLES, CACHE_VARIABLES, COMMANDS, MACROS, and " - "COMPONENTS." - "\n" - "See also the more general get_property() command."; - } - cmTypeMacro(cmGetCMakePropertyCommand, cmCommand); }; diff --git a/Source/cmGetDirectoryPropertyCommand.h b/Source/cmGetDirectoryPropertyCommand.h index d0d5820..aea04ad 100644 --- a/Source/cmGetDirectoryPropertyCommand.h +++ b/Source/cmGetDirectoryPropertyCommand.h @@ -39,37 +39,6 @@ public: */ virtual const char* GetName() const { return "get_directory_property";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Get a property of DIRECTORY scope."; - } - - /** - * Longer documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " get_directory_property(<variable> [DIRECTORY <dir>] <prop-name>)\n" - "Store a property of directory scope in the named variable. " - "If the property is not defined the empty-string is returned. " - "The DIRECTORY argument specifies another directory from which " - "to retrieve the property value. " - "The specified directory must have already been traversed by " - "CMake." - "\n" - " get_directory_property(<variable> [DIRECTORY <dir>]\n" - " DEFINITION <var-name>)\n" - "Get a variable definition from a directory. " - "This form is useful to get a variable definition from another " - "directory." - "\n" - "See also the more general get_property() command."; - } - cmTypeMacro(cmGetDirectoryPropertyCommand, cmCommand); }; diff --git a/Source/cmGetFilenameComponentCommand.h b/Source/cmGetFilenameComponentCommand.h index 09af332..e2cd219 100644 --- a/Source/cmGetFilenameComponentCommand.h +++ b/Source/cmGetFilenameComponentCommand.h @@ -48,43 +48,6 @@ public: */ virtual const char* GetName() const { return "get_filename_component";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Get a specific component of a full filename."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " get_filename_component(<VAR> <FileName> <COMP> [CACHE])\n" - "Set <VAR> to a component of <FileName>, where <COMP> is one of:\n" - " DIRECTORY = Directory without file name\n" - " NAME = File name without directory\n" - " EXT = File name longest extension (.b.c from d/a.b.c)\n" - " NAME_WE = File name without directory or longest extension\n" - " ABSOLUTE = Full path to file\n" - " REALPATH = Full path to existing file with symlinks resolved\n" - " PATH = Legacy alias for DIRECTORY (use for CMake <= 2.8.11)\n" - "Paths are returned with forward slashes and have no trailing slahes. " - "The longest file extension is always considered. " - "If the optional CACHE argument is specified, the result variable is " - "added to the cache.\n" - " get_filename_component(<VAR> FileName\n" - " PROGRAM [PROGRAM_ARGS <ARG_VAR>]\n" - " [CACHE])\n" - "The program in FileName will be found in the system search path or " - "left as a full path. If PROGRAM_ARGS is present with PROGRAM, then " - "any command-line arguments present in the FileName string are split " - "from the program name and stored in <ARG_VAR>. This is used to " - "separate a program name from its arguments in a command line string."; - } - cmTypeMacro(cmGetFilenameComponentCommand, cmCommand); }; diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index faba7cd..a1454a3 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -298,7 +298,7 @@ bool cmGetPropertyCommand::HandleTargetMode() return this->StoreResult(target->GetName()); } } - return false; + return this->StoreResult((this->Variable + "-NOTFOUND").c_str()); } if(cmTarget* target = this->Makefile->FindTargetToUse(this->Name.c_str())) { diff --git a/Source/cmGetPropertyCommand.h b/Source/cmGetPropertyCommand.h index 3c597fd..e1630ff 100644 --- a/Source/cmGetPropertyCommand.h +++ b/Source/cmGetPropertyCommand.h @@ -41,58 +41,6 @@ public: */ virtual const char* GetName() const { return "get_property";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Get a property."; - } - - /** - * Longer documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " get_property(<variable>\n" - " <GLOBAL |\n" - " DIRECTORY [dir] |\n" - " TARGET <target> |\n" - " SOURCE <source> |\n" - " TEST <test> |\n" - " CACHE <entry> |\n" - " VARIABLE>\n" - " PROPERTY <name>\n" - " [SET | DEFINED | BRIEF_DOCS | FULL_DOCS])\n" - "Get one property from one object in a scope. " - "The first argument specifies the variable in which to store the " - "result. " - "The second argument determines the scope from which to get the " - "property. It must be one of the following:\n" - "GLOBAL scope is unique and does not accept a name.\n" - "DIRECTORY scope defaults to the current directory but another " - "directory (already processed by CMake) may be named by full or " - "relative path.\n" - "TARGET scope must name one existing target.\n" - "SOURCE scope must name one source file.\n" - "TEST scope must name one existing test.\n" - "CACHE scope must name one cache entry.\n" - "VARIABLE scope is unique and does not accept a name.\n" - "The required PROPERTY option is immediately followed by the name " - "of the property to get. " - "If the property is not set an empty value is returned. " - "If the SET option is given the variable is set to a boolean " - "value indicating whether the property has been set. " - "If the DEFINED option is given the variable is set to a boolean " - "value indicating whether the property has been defined " - "such as with define_property. " - "If BRIEF_DOCS or FULL_DOCS is given then the variable is set to " - "a string containing documentation for the requested property. " - "If documentation is requested for a property that has not been " - "defined NOTFOUND is returned."; - } - cmTypeMacro(cmGetPropertyCommand, cmCommand); private: enum OutType { OutValue, OutDefined, OutBriefDoc, OutFullDoc, OutSet }; diff --git a/Source/cmGetSourceFilePropertyCommand.h b/Source/cmGetSourceFilePropertyCommand.h index 2ba8103..338318e 100644 --- a/Source/cmGetSourceFilePropertyCommand.h +++ b/Source/cmGetSourceFilePropertyCommand.h @@ -34,30 +34,6 @@ public: */ virtual const char* GetName() const { return "get_source_file_property";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Get a property for a source file."; - } - - /** - * Longer documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " get_source_file_property(VAR file property)\n" - "Get a property from a source file. The value of the property is " - "stored in the variable VAR. If the property is not found, VAR " - "will be set to \"NOTFOUND\". Use set_source_files_properties to set " - "property values. Source file properties usually control how the " - "file is built. One property that is always there is LOCATION" - "\n" - "See also the more general get_property() command."; - } - cmTypeMacro(cmGetSourceFilePropertyCommand, cmCommand); }; diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx index 02f00a5..488cc28 100644 --- a/Source/cmGetTargetPropertyCommand.cxx +++ b/Source/cmGetTargetPropertyCommand.cxx @@ -40,7 +40,36 @@ bool cmGetTargetPropertyCommand cmTarget& target = *tgt; prop = target.GetProperty(args[2].c_str()); } - + else + { + bool issueMessage = false; + cmOStringStream e; + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0045)) + { + case cmPolicies::WARN: + issueMessage = true; + e << this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0045) << "\n"; + case cmPolicies::OLD: + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + issueMessage = true; + messageType = cmake::FATAL_ERROR; + } + if (issueMessage) + { + e << "get_target_property() called with non-existent target \"" + << targetName << "\"."; + this->Makefile->IssueMessage(messageType, e.str().c_str()); + if (messageType == cmake::FATAL_ERROR) + { + return false; + } + } + } if (prop) { this->Makefile->AddDefinition(var.c_str(), prop); diff --git a/Source/cmGetTargetPropertyCommand.h b/Source/cmGetTargetPropertyCommand.h index f5e1aa7..4985b3c 100644 --- a/Source/cmGetTargetPropertyCommand.h +++ b/Source/cmGetTargetPropertyCommand.h @@ -34,32 +34,6 @@ public: */ virtual const char* GetName() const { return "get_target_property";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Get a property from a target."; - } - - /** - * Longer documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " get_target_property(VAR target property)\n" - "Get a property from a target. The value of the property is " - "stored in the variable VAR. If the property is not found, VAR " - "will be set to \"NOTFOUND\". Use set_target_properties to set " - "property values. Properties are usually used to control how " - "a target is built, but some query the target instead. " - "This command can get properties for any target so far created. " - "The targets do not need to be in the current CMakeLists.txt file." - "\n" - "See also the more general get_property() command."; - } - cmTypeMacro(cmGetTargetPropertyCommand, cmCommand); }; diff --git a/Source/cmGetTestPropertyCommand.h b/Source/cmGetTestPropertyCommand.h index 01f54d9..2dccabe 100644 --- a/Source/cmGetTestPropertyCommand.h +++ b/Source/cmGetTestPropertyCommand.h @@ -34,29 +34,6 @@ public: */ virtual const char* GetName() const { return "get_test_property";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Get a property of the test."; - } - - /** - * Longer documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " get_test_property(test property VAR)\n" - "Get a property from the Test. The value of the property is " - "stored in the variable VAR. If the property is not found, VAR " - "will be set to \"NOTFOUND\". For a list of standard properties " - "you can type cmake --help-property-list" - "\n" - "See also the more general get_property() command."; - } - cmTypeMacro(cmGetTestPropertyCommand, cmCommand); }; diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx index 2a7d61d..6c20952 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.cxx +++ b/Source/cmGlobalBorlandMakefileGenerator.cxx @@ -59,5 +59,4 @@ void cmGlobalBorlandMakefileGenerator { entry.Name = cmGlobalBorlandMakefileGenerator::GetActualName(); entry.Brief = "Generates Borland makefiles."; - entry.Full = ""; } diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h index bd3db3e..70004ea 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.h +++ b/Source/cmGlobalBorlandMakefileGenerator.h @@ -44,6 +44,8 @@ public: */ virtual void EnableLanguage(std::vector<std::string>const& languages, cmMakefile *, bool optional); + + virtual bool AllowNotParallel() const { return false; } }; #endif diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 7f2b592..8a7eee4 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -18,7 +18,7 @@ #include "cmExternalMakefileProjectGenerator.h" #include "cmake.h" #include "cmMakefile.h" -#include "cmQtAutomoc.h" +#include "cmQtAutoGenerators.h" #include "cmSourceFile.h" #include "cmVersion.h" #include "cmTargetExport.h" @@ -27,8 +27,10 @@ #include "cmGeneratorTarget.h" #include "cmGeneratorExpression.h" #include "cmGeneratorExpressionEvaluationFile.h" +#include "cmExportBuildFileGenerator.h" #include <cmsys/Directory.hxx> +#include <cmsys/FStream.hxx> #if defined(CMAKE_BUILD_WITH_CMAKE) # include <cmsys/MD5.h> @@ -65,26 +67,12 @@ cmGlobalGenerator::cmGlobalGenerator() cmGlobalGenerator::~cmGlobalGenerator() { - // Delete any existing cmLocalGenerators - for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) - { - delete this->LocalGenerators[i]; - } - for(std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator - li = this->EvaluationFiles.begin(); - li != this->EvaluationFiles.end(); - ++li) - { - delete *li; - } - this->LocalGenerators.clear(); + this->ClearGeneratorMembers(); if (this->ExtraGenerator) { delete this->ExtraGenerator; } - - this->ClearGeneratorTargets(); } bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts) @@ -101,9 +89,29 @@ bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts) return false; } +std::string cmGlobalGenerator::SelectMakeProgram(const char* makeProgram, + std::string makeDefault) const +{ + if(cmSystemTools::IsOff(makeProgram)) + { + makeProgram = + this->CMakeInstance->GetCacheDefinition("CMAKE_MAKE_PROGRAM"); + if(cmSystemTools::IsOff(makeProgram)) + { + makeProgram = makeDefault.c_str(); + } + if(cmSystemTools::IsOff(makeProgram) && + !(makeProgram && *makeProgram)) + { + makeProgram = "CMAKE_MAKE_PROGRAM-NOTFOUND"; + } + } + return makeProgram; +} + void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang, cmMakefile *mf, - bool optional) + bool optional) const { std::string langComp = "CMAKE_"; langComp += lang; @@ -131,24 +139,24 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang, if((path.size() == 0 || !cmSystemTools::FileExists(path.c_str())) && (optional==false)) { - std::string message = "your "; - message += lang; - message += " compiler: \""; - message += name; - message += "\" was not found. Please set "; - message += langComp; - message += " to a valid compiler path or name."; - cmSystemTools::Error(message.c_str()); - path = name; + return; } std::string doc = lang; doc += " compiler."; const char* cname = this->GetCMakeInstance()-> GetCacheManager()->GetCacheValue(langComp.c_str()); std::string changeVars; - if(cname && (path != cname) && (optional==false)) + if(cname && !optional) { - std::string cnameString = cname; + std::string cnameString; + if(!cmSystemTools::FileIsFullPath(cname)) + { + cnameString = cmSystemTools::FindProgram(cname); + } + else + { + cnameString = cname; + } std::string pathString = path; // get rid of potentially multiple slashes: cmSystemTools::ConvertToUnixSlashes(cnameString); @@ -175,6 +183,46 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang, doc.c_str(), cmCacheManager::FILEPATH); } +void cmGlobalGenerator::AddBuildExportSet(cmExportBuildFileGenerator* gen) +{ + this->BuildExportSets[gen->GetMainExportFileName()] = gen; +} + +void +cmGlobalGenerator::AddBuildExportExportSet(cmExportBuildFileGenerator* gen) +{ + this->BuildExportSets[gen->GetMainExportFileName()] = gen; + this->BuildExportExportSets[gen->GetMainExportFileName()] = gen; +} + +bool cmGlobalGenerator::GenerateImportFile(const std::string &file) +{ + std::map<std::string, cmExportBuildFileGenerator*>::iterator it + = this->BuildExportSets.find(file); + if (it != this->BuildExportSets.end()) + { + bool result = it->second->GenerateImportFile(); + delete it->second; + it->second = 0; + this->BuildExportSets.erase(it); + return result; + } + return false; +} + +bool +cmGlobalGenerator::IsExportedTargetsFile(const std::string &filename) const +{ + const std::map<std::string, cmExportBuildFileGenerator*>::const_iterator it + = this->BuildExportSets.find(filename); + if (it == this->BuildExportSets.end()) + { + return false; + } + return this->BuildExportExportSets.find(filename) + == this->BuildExportExportSets.end(); +} + // Find the make program for the generator, required for try compiles void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf) { @@ -291,7 +339,7 @@ void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf) void cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *mf, bool) + cmMakefile *mf, bool optional) { if(languages.size() == 0) { @@ -327,6 +375,8 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, } } + bool fatalError = false; + mf->AddDefinition("RUN_CONFIGURE", true); std::string rootBin = mf->GetHomeOutputDirectory(); rootBin += cmake::GetCMakeFilesDirectory(); @@ -513,6 +563,65 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, this->SetLanguageEnabled("NONE", mf); continue; } + + // Check that the compiler was found. + std::string compilerName = "CMAKE_"; + compilerName += lang; + compilerName += "_COMPILER"; + std::string compilerEnv = "CMAKE_"; + compilerEnv += lang; + compilerEnv += "_COMPILER_ENV_VAR"; + cmOStringStream noCompiler; + const char* compilerFile = mf->GetDefinition(compilerName.c_str()); + if(!compilerFile || !*compilerFile || + cmSystemTools::IsNOTFOUND(compilerFile)) + { + noCompiler << + "No " << compilerName << " could be found.\n" + ; + } + else if(strcmp(lang, "RC") != 0) + { + if(!cmSystemTools::FileIsFullPath(compilerFile)) + { + noCompiler << + "The " << compilerName << ":\n" + " " << compilerFile << "\n" + "is not a full path and was not found in the PATH.\n" + ; + } + else if(!cmSystemTools::FileExists(compilerFile)) + { + noCompiler << + "The " << compilerName << ":\n" + " " << compilerFile << "\n" + "is not a full path to an existing compiler tool.\n" + ; + } + } + if(!noCompiler.str().empty()) + { + // Skip testing this language since the compiler is not found. + needTestLanguage[lang] = false; + if(!optional) + { + // The compiler was not found and it is not optional. Remove + // CMake(LANG)Compiler.cmake so we try again next time CMake runs. + std::string compilerLangFile = rootBin; + compilerLangFile += "/CMake"; + compilerLangFile += lang; + compilerLangFile += "Compiler.cmake"; + cmSystemTools::RemoveFile(compilerLangFile.c_str()); + if(!this->CMakeInstance->GetIsInTryCompile()) + { + this->PrintCompilerAdvice(noCompiler, lang, + mf->GetDefinition(compilerEnv.c_str())); + mf->IssueMessage(cmake::FATAL_ERROR, noCompiler.str()); + fatalError = true; + } + } + } + std::string langLoadedVar = "CMAKE_"; langLoadedVar += lang; langLoadedVar += "_INFORMATION_LOADED"; @@ -539,26 +648,12 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, } this->LanguagesReady.insert(lang); - std::string compilerName = "CMAKE_"; - compilerName += lang; - compilerName += "_COMPILER"; - std::string compilerLangFile = rootBin; - compilerLangFile += "/CMake"; - compilerLangFile += lang; - compilerLangFile += "Compiler.cmake"; // Test the compiler for the language just setup // (but only if a compiler has been actually found) // At this point we should have enough info for a try compile // which is used in the backward stuff // If the language is untested then test it now with a try compile. - if (!mf->IsSet(compilerName.c_str())) - { - // if the compiler did not work, then remove the - // CMake(LANG)Compiler.cmake file so that it will get tested the - // next time cmake is run - cmSystemTools::RemoveFile(compilerLangFile.c_str()); - } - else if(needTestLanguage[lang]) + if(needTestLanguage[lang]) { if (!this->CMakeInstance->GetIsInTryCompile()) { @@ -579,31 +674,12 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, // next time cmake is run if(!mf->IsOn(compilerWorks.c_str())) { + std::string compilerLangFile = rootBin; + compilerLangFile += "/CMake"; + compilerLangFile += lang; + compilerLangFile += "Compiler.cmake"; cmSystemTools::RemoveFile(compilerLangFile.c_str()); } - else - { - // load backwards compatibility stuff for C and CXX - // for old versions of CMake ListFiles C and CXX had some - // backwards compatibility files they have to load - // These files have a bunch of try compiles in them so - // should only be done - if (mf->NeedBackwardsCompatibility(1,4)) - { - if(strcmp(lang, "C") == 0) - { - ifpath = - mf->GetModulesFile("CMakeBackwardCompatibilityC.cmake"); - mf->ReadListFile(0,ifpath.c_str()); - } - if(strcmp(lang, "CXX") == 0) - { - ifpath = - mf->GetModulesFile("CMakeBackwardCompatibilityCXX.cmake"); - mf->ReadListFile(0,ifpath.c_str()); - } - } - } } // end if in try compile } // end need test language // Store the shared library flags so that we can satisfy CMP0018 @@ -616,6 +692,9 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, { this->LanguageToOriginalSharedLibFlags[lang] = sharedLibFlags; } + + // Translate compiler ids for compatibility. + this->CheckCompilerIdCompatibility(mf, lang); } // end for each language // Now load files that can override any settings on the platform or for @@ -629,17 +708,90 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, { mf->ReadListFile(0,projectCompatibility.c_str()); } + // Inform any extra generator of the new language. + if (this->ExtraGenerator) + { + this->ExtraGenerator->EnableLanguage(languages, mf, false); + } + + if(fatalError) + { + cmSystemTools::SetFatalErrorOccured(); + } +} + +//---------------------------------------------------------------------------- +void cmGlobalGenerator::PrintCompilerAdvice(std::ostream& os, + std::string lang, + const char* envVar) const +{ + // Subclasses override this method if they do not support this advice. + os << + "Tell CMake where to find the compiler by setting " + ; + if(envVar) + { + os << + "either the environment variable \"" << envVar << "\" or " + ; + } + os << + "the CMake cache entry CMAKE_" << lang << "_COMPILER " + "to the full path to the compiler, or to the compiler name " + "if it is in the PATH." + ; +} + +//---------------------------------------------------------------------------- +void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf, + std::string lang) const +{ + std::string compilerIdVar = "CMAKE_" + lang + "_COMPILER_ID"; + const char* compilerId = mf->GetDefinition(compilerIdVar.c_str()); + if(compilerId && strcmp(compilerId, "AppleClang") == 0) + { + cmPolicies* policies = this->CMakeInstance->GetPolicies(); + switch(mf->GetPolicyStatus(cmPolicies::CMP0025)) + { + case cmPolicies::WARN: + if(!this->CMakeInstance->GetIsInTryCompile()) + { + cmOStringStream w; + w << policies->GetPolicyWarning(cmPolicies::CMP0025) << "\n" + "Converting " << lang << + " compiler id \"AppleClang\" to \"Clang\" for compatibility." + ; + mf->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + } + case cmPolicies::OLD: + // OLD behavior is to convert AppleClang to Clang. + mf->AddDefinition(compilerIdVar.c_str(), "Clang"); + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + mf->IssueMessage( + cmake::FATAL_ERROR, + policies->GetRequiredPolicyError(cmPolicies::CMP0025) + ); + case cmPolicies::NEW: + // NEW behavior is to keep AppleClang. + break; + } + } } //---------------------------------------------------------------------------- const char* -cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) +cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) const { if(const char* lang = source.GetLanguage()) { - if(this->LanguageToOutputExtension.count(lang) > 0) + std::map<cmStdString, cmStdString>::const_iterator it = + this->LanguageToOutputExtension.find(lang); + + if(it != this->LanguageToOutputExtension.end()) { - return this->LanguageToOutputExtension[lang].c_str(); + return it->second.c_str(); } } else @@ -660,7 +812,7 @@ cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) } -const char* cmGlobalGenerator::GetLanguageFromExtension(const char* ext) +const char* cmGlobalGenerator::GetLanguageFromExtension(const char* ext) const { // if there is an extension and it starts with . then move past the // . because the extensions are not stored with a . in the map @@ -668,9 +820,11 @@ const char* cmGlobalGenerator::GetLanguageFromExtension(const char* ext) { ++ext; } - if(this->ExtensionToLanguage.count(ext) > 0) + std::map<cmStdString, cmStdString>::const_iterator it + = this->ExtensionToLanguage.find(ext); + if(it != this->ExtensionToLanguage.end()) { - return this->ExtensionToLanguage[ext].c_str(); + return it->second.c_str(); } return 0; } @@ -794,7 +948,7 @@ void cmGlobalGenerator::FillExtensionToLanguageMap(const char* l, } } -bool cmGlobalGenerator::IgnoreFile(const char* l) +bool cmGlobalGenerator::IgnoreFile(const char* l) const { if(this->GetLanguageFromExtension(l)) { @@ -814,18 +968,25 @@ void cmGlobalGenerator::ClearEnabledLanguages() } bool cmGlobalGenerator::IsDependedOn(const char* project, - cmTarget* targetIn) + cmTarget const* targetIn) { // Get all local gens for this project - std::vector<cmLocalGenerator*>* gens = &this->ProjectMap[project]; + std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator it = + this->ProjectMap.find(project); + if (it == this->ProjectMap.end()) + { + return false; + } + // loop over local gens and get the targets for each one - for(unsigned int i = 0; i < gens->size(); ++i) + for(std::vector<cmLocalGenerator*>::const_iterator geIt = it->second.begin(); + geIt != it->second.end(); ++geIt) { - cmTargets& targets = (*gens)[i]->GetMakefile()->GetTargets(); - for (cmTargets::iterator l = targets.begin(); + cmTargets const& targets = (*geIt)->GetMakefile()->GetTargets(); + for (cmTargets::const_iterator l = targets.begin(); l != targets.end(); l++) { - cmTarget& target = l->second; + cmTarget const& target = l->second; TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(target); if(tgtdeps.count(targetIn)) { @@ -839,23 +1000,7 @@ bool cmGlobalGenerator::IsDependedOn(const char* project, void cmGlobalGenerator::Configure() { this->FirstTimeProgress = 0.0f; - this->ClearGeneratorTargets(); - this->ExportSets.clear(); - // Delete any existing cmLocalGenerators - unsigned int i; - for (i = 0; i < this->LocalGenerators.size(); ++i) - { - delete this->LocalGenerators[i]; - } - this->LocalGenerators.clear(); - this->TargetDependencies.clear(); - this->TotalTargets.clear(); - this->ImportedTargets.clear(); - this->LocalGeneratorToTargetMap.clear(); - this->ProjectMap.clear(); - this->RuleHashes.clear(); - this->DirectoryContentMap.clear(); - this->BinaryDirectories.clear(); + this->ClearGeneratorMembers(); // start with this directory cmLocalGenerator *lg = this->CreateLocalGenerator(); @@ -917,7 +1062,21 @@ void cmGlobalGenerator::Configure() } } -bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() +cmExportBuildFileGenerator* +cmGlobalGenerator::GetExportedTargetsFile(const std::string &filename) const +{ + std::map<std::string, cmExportBuildFileGenerator*>::const_iterator it + = this->BuildExportSets.find(filename); + return it == this->BuildExportSets.end() ? 0 : it->second; +} + +//---------------------------------------------------------------------------- +void cmGlobalGenerator::AddCMP0042WarnTarget(const std::string& target) +{ + this->CMP0042WarnTargets.insert(target); +} + +bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const { // If the property is not enabled then okay. if(!this->CMakeInstance @@ -944,6 +1103,9 @@ void cmGlobalGenerator::Generate() // Start with an empty vector: this->FilesReplacedDuringGenerate.clear(); + // clear targets to issue warning CMP0042 for + this->CMP0042WarnTargets.clear(); + // Check whether this generator is allowed to run. if(!this->CheckALLOW_DUPLICATE_CUSTOM_TARGETS()) { @@ -956,9 +1118,14 @@ void cmGlobalGenerator::Generate() return; } + this->FinalizeTargetCompileInfo(); + +#ifdef CMAKE_BUILD_WITH_CMAKE // Iterate through all targets and set up automoc for those which have - // the AUTOMOC property set - this->CreateAutomocTargets(); + // the AUTOMOC, AUTOUIC or AUTORCC property set + AutogensType autogens; + this->CreateQtAutoGeneratorsTargets(autogens); +#endif // For each existing cmLocalGenerator unsigned int i; @@ -976,11 +1143,6 @@ void cmGlobalGenerator::Generate() (*targets)[tit->first] = tit->second; (*targets)[tit->first].SetMakefile(mf); } - - for ( tit = targets->begin(); tit != targets->end(); ++ tit ) - { - tit->second.AppendBuildInterfaceIncludes(); - } } // Add generator specific helper commands @@ -989,6 +1151,17 @@ void cmGlobalGenerator::Generate() this->LocalGenerators[i]->AddHelperCommands(); } + // Create per-target generator information. + this->CreateGeneratorTargets(); + +#ifdef CMAKE_BUILD_WITH_CMAKE + for (AutogensType::iterator it = autogens.begin(); it != autogens.end(); + ++it) + { + it->first.SetupAutoGenerateTarget(it->second); + } +#endif + // Trace the dependencies, after that no custom commands should be added // because their dependencies might not be handled correctly for (i = 0; i < this->LocalGenerators.size(); ++i) @@ -1002,8 +1175,7 @@ void cmGlobalGenerator::Generate() this->LocalGenerators[i]->GenerateTargetManifest(); } - // Create per-target generator information. - this->CreateGeneratorTargets(); + this->ComputeGeneratorTargetObjects(); this->ProcessEvaluationFiles(); @@ -1017,24 +1189,17 @@ void cmGlobalGenerator::Generate() // it builds by default. this->FillLocalGeneratorToTargetMap(); - for (i = 0; i < this->LocalGenerators.size(); ++i) - { - cmMakefile* mf = this->LocalGenerators[i]->GetMakefile(); - cmTargets* targets = &(mf->GetTargets()); - for ( cmTargets::iterator it = targets->begin(); - it != targets->end(); ++ it ) - { - it->second.FinalizeSystemIncludeDirectories(); - } - } - // Generate project files for (i = 0; i < this->LocalGenerators.size(); ++i) { this->LocalGenerators[i]->GetMakefile()->SetGeneratingBuildSystem(); this->SetCurrentLocalGenerator(this->LocalGenerators[i]); this->LocalGenerators[i]->Generate(); - this->LocalGenerators[i]->GenerateInstallRules(); + if(!this->LocalGenerators[i]->GetMakefile()->IsOn( + "CMAKE_SKIP_INSTALL_RULES")) + { + this->LocalGenerators[i]->GenerateInstallRules(); + } this->LocalGenerators[i]->GenerateTestFiles(); this->CMakeInstance->UpdateProgress("Generating", (static_cast<float>(i)+1.0f)/ @@ -1042,6 +1207,19 @@ void cmGlobalGenerator::Generate() } this->SetCurrentLocalGenerator(0); + for (std::map<std::string, cmExportBuildFileGenerator*>::iterator + it = this->BuildExportSets.begin(); it != this->BuildExportSets.end(); + ++it) + { + if (!it->second->GenerateImportFile() + && !cmSystemTools::GetErrorOccuredFlag()) + { + this->GetCMakeInstance() + ->IssueMessage(cmake::FATAL_ERROR, "Could not write export file.", + cmListFileBacktrace()); + return; + } + } // Update rule hashes. this->CheckRuleHashes(); @@ -1052,6 +1230,25 @@ void cmGlobalGenerator::Generate() this->ExtraGenerator->Generate(); } + if(!this->CMP0042WarnTargets.empty()) + { + cmOStringStream w; + w << + (this->GetCMakeInstance()->GetPolicies()-> + GetPolicyWarning(cmPolicies::CMP0042)) << "\n"; + w << "MACOSX_RPATH is not specified for" + " the following targets:\n"; + for(std::set<std::string>::iterator + iter = this->CMP0042WarnTargets.begin(); + iter != this->CMP0042WarnTargets.end(); + ++iter) + { + w << " " << *iter << "\n"; + } + this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, w.str(), + cmListFileBacktrace()); + } + this->CMakeInstance->UpdateProgress("Generating done", -1); } @@ -1063,8 +1260,8 @@ bool cmGlobalGenerator::ComputeTargetDepends() { return false; } - std::vector<cmTarget*> const& targets = ctd.GetTargets(); - for(std::vector<cmTarget*>::const_iterator ti = targets.begin(); + std::vector<cmTarget const*> const& targets = ctd.GetTargets(); + for(std::vector<cmTarget const*>::const_iterator ti = targets.begin(); ti != targets.end(); ++ti) { ctd.GetTargetDirectDepends(*ti, this->TargetDependencies[*ti]); @@ -1088,6 +1285,7 @@ bool cmGlobalGenerator::CheckTargets() target.GetType() == cmTarget::STATIC_LIBRARY || target.GetType() == cmTarget::SHARED_LIBRARY || target.GetType() == cmTarget::MODULE_LIBRARY || + target.GetType() == cmTarget::OBJECT_LIBRARY || target.GetType() == cmTarget::UTILITY) { if(!target.FindSourceFiles()) @@ -1101,11 +1299,9 @@ bool cmGlobalGenerator::CheckTargets() } //---------------------------------------------------------------------------- -void cmGlobalGenerator::CreateAutomocTargets() +void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens) { #ifdef CMAKE_BUILD_WITH_CMAKE - typedef std::vector<std::pair<cmQtAutomoc, cmTarget*> > Automocs; - Automocs automocs; for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) { cmTargets& targets = @@ -1120,48 +1316,49 @@ void cmGlobalGenerator::CreateAutomocTargets() target.GetType() == cmTarget::MODULE_LIBRARY || target.GetType() == cmTarget::OBJECT_LIBRARY) { - if(target.GetPropertyAsBool("AUTOMOC") && !target.IsImported()) + if((target.GetPropertyAsBool("AUTOMOC") + || target.GetPropertyAsBool("AUTOUIC") + || target.GetPropertyAsBool("AUTORCC")) + && !target.IsImported()) { - cmQtAutomoc automoc; - if(automoc.InitializeMocSourceFile(&target)) + cmQtAutoGenerators autogen; + if(autogen.InitializeAutogenTarget(&target)) { - automocs.push_back(std::make_pair(automoc, &target)); + autogens.push_back(AutogensType::value_type(autogen, &target)); } } } } } - for (Automocs::iterator it = automocs.begin(); it != automocs.end(); - ++it) - { - it->first.SetupAutomocTarget(it->second); - } +#else + (void)autogens; #endif } //---------------------------------------------------------------------------- -void cmGlobalGenerator::CreateGeneratorTargets() +void cmGlobalGenerator::FinalizeTargetCompileInfo() { // Construct per-target generator information. for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) { - cmGeneratorTargetsType generatorTargets; - cmMakefile *mf = this->LocalGenerators[i]->GetMakefile(); const std::vector<cmValueWithOrigin> noconfig_compile_definitions = mf->GetCompileDefinitionsEntries(); - std::vector<std::string> configs; - mf->GetConfigurations(configs); - cmTargets& targets = mf->GetTargets(); for(cmTargets::iterator ti = targets.begin(); ti != targets.end(); ++ti) { cmTarget* t = &ti->second; - { + t->AppendBuildInterfaceIncludes(); + + if (t->GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } + for (std::vector<cmValueWithOrigin>::const_iterator it = noconfig_compile_definitions.begin(); it != noconfig_compile_definitions.end(); ++it) @@ -1169,37 +1366,86 @@ void cmGlobalGenerator::CreateGeneratorTargets() t->InsertCompileDefinition(*it); } - for(std::vector<std::string>::const_iterator ci = configs.begin(); - ci != configs.end(); ++ci) + cmPolicies::PolicyStatus polSt + = mf->GetPolicyStatus(cmPolicies::CMP0043); + if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD) { - std::string defPropName = "COMPILE_DEFINITIONS_"; - defPropName += cmSystemTools::UpperCase(*ci); - t->AppendProperty(defPropName.c_str(), - mf->GetProperty(defPropName.c_str())); + std::vector<std::string> configs; + mf->GetConfigurations(configs); + + for(std::vector<std::string>::const_iterator ci = configs.begin(); + ci != configs.end(); ++ci) + { + std::string defPropName = "COMPILE_DEFINITIONS_"; + defPropName += cmSystemTools::UpperCase(*ci); + t->AppendProperty(defPropName.c_str(), + mf->GetProperty(defPropName.c_str())); + } } } + } +} - cmGeneratorTarget* gt = new cmGeneratorTarget(t); - this->GeneratorTargets[t] = gt; - this->ComputeTargetObjects(gt); - generatorTargets[t] = gt; - } +//---------------------------------------------------------------------------- +void cmGlobalGenerator::CreateGeneratorTargets(cmMakefile *mf) +{ + cmGeneratorTargetsType generatorTargets; + cmTargets& targets = mf->GetTargets(); + for(cmTargets::iterator ti = targets.begin(); + ti != targets.end(); ++ti) + { + cmTarget* t = &ti->second; + cmGeneratorTarget* gt = new cmGeneratorTarget(t); + this->GeneratorTargets[t] = gt; + generatorTargets[t] = gt; + } + + for(std::vector<cmTarget*>::const_iterator + j = mf->GetOwnedImportedTargets().begin(); + j != mf->GetOwnedImportedTargets().end(); ++j) + { + cmGeneratorTarget* gt = new cmGeneratorTarget(*j); + this->GeneratorTargets[*j] = gt; + generatorTargets[*j] = gt; + } + mf->SetGeneratorTargets(generatorTargets); +} - for(std::vector<cmTarget*>::const_iterator - j = mf->GetOwnedImportedTargets().begin(); - j != mf->GetOwnedImportedTargets().end(); ++j) +//---------------------------------------------------------------------------- +void cmGlobalGenerator::CreateGeneratorTargets() +{ + // Construct per-target generator information. + for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) + { + this->CreateGeneratorTargets(this->LocalGenerators[i]->GetMakefile()); + } +} + +//---------------------------------------------------------------------------- +void cmGlobalGenerator::ComputeGeneratorTargetObjects() +{ + // Construct per-target generator information. + for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) + { + cmMakefile *mf = this->LocalGenerators[i]->GetMakefile(); + cmGeneratorTargetsType targets = mf->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator ti = targets.begin(); + ti != targets.end(); ++ti) { - cmGeneratorTarget* gt = new cmGeneratorTarget(*j); - this->GeneratorTargets[*j] = gt; - generatorTargets[*j] = gt; + if (ti->second->Target->IsImported()) + { + continue; + } + cmGeneratorTarget* gt = ti->second; + gt->ClassifySources(); + gt->LookupObjectLibraries(); + this->ComputeTargetObjects(gt); } - - mf->SetGeneratorTargets(generatorTargets); } } //---------------------------------------------------------------------------- -void cmGlobalGenerator::ClearGeneratorTargets() +void cmGlobalGenerator::ClearGeneratorMembers() { for(cmGeneratorTargetsType::iterator i = this->GeneratorTargets.begin(); i != this->GeneratorTargets.end(); ++i) @@ -1207,10 +1453,44 @@ void cmGlobalGenerator::ClearGeneratorTargets() delete i->second; } this->GeneratorTargets.clear(); + + for(std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator + li = this->EvaluationFiles.begin(); + li != this->EvaluationFiles.end(); + ++li) + { + delete *li; + } + this->EvaluationFiles.clear(); + + for(std::map<std::string, cmExportBuildFileGenerator*>::iterator + i = this->BuildExportSets.begin(); + i != this->BuildExportSets.end(); ++i) + { + delete i->second; + } + this->BuildExportSets.clear(); + + for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) + { + delete this->LocalGenerators[i]; + } + this->LocalGenerators.clear(); + + this->ExportSets.clear(); + this->TargetDependencies.clear(); + this->TotalTargets.clear(); + this->ImportedTargets.clear(); + this->LocalGeneratorToTargetMap.clear(); + this->ProjectMap.clear(); + this->RuleHashes.clear(); + this->DirectoryContentMap.clear(); + this->BinaryDirectories.clear(); } //---------------------------------------------------------------------------- -cmGeneratorTarget* cmGlobalGenerator::GetGeneratorTarget(cmTarget* t) const +cmGeneratorTarget* +cmGlobalGenerator::GetGeneratorTarget(cmTarget const* t) const { cmGeneratorTargetsType::const_iterator ti = this->GeneratorTargets.find(t); if(ti == this->GeneratorTargets.end()) @@ -1244,6 +1524,10 @@ void cmGlobalGenerator::CheckLocalGenerators() for (cmTargets::iterator l = targets.begin(); l != targets.end(); l++) { + if (l->second.GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } const cmTarget::LinkLibraryVectorType& libs = l->second.GetOriginalLinkLibraries(); for(cmTarget::LinkLibraryVectorType::const_iterator lib = libs.begin(); @@ -1350,15 +1634,6 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir, this->FirstTimeProgress); } - std::string makeCommand = this->CMakeInstance-> - GetCacheManager()->GetCacheValue("CMAKE_MAKE_PROGRAM"); - if(makeCommand.size() == 0) - { - cmSystemTools::Error( - "Generator cannot find the appropriate make command."); - return 1; - } - std::string newTarget; if (target && strlen(target)) { @@ -1378,45 +1653,16 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir, const char* config = mf->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION"); return this->Build(srcdir,bindir,projectName, newTarget.c_str(), - output,makeCommand.c_str(),config,false,fast, + output,0,config,false,fast, this->TryCompileTimeout); } -std::string cmGlobalGenerator -::GenerateBuildCommand(const char* makeProgram, const char *projectName, - const char *projectDir, const char* additionalOptions, - const char *targetName, const char* config, - bool ignoreErrors, bool) +void cmGlobalGenerator::GenerateBuildCommand( + std::vector<std::string>& makeCommand, const char*, const char*, const char*, + const char*, const char*, bool, std::vector<std::string> const&) { - // Project name & dir and config are not used yet. - (void)projectName; - (void)projectDir; - (void)config; - - std::string makeCommand = - cmSystemTools::ConvertToUnixOutputPath(makeProgram); - - // Since we have full control over the invocation of nmake, let us - // make it quiet. - if ( strcmp(this->GetName(), "NMake Makefiles") == 0 ) - { - makeCommand += " /NOLOGO "; - } - if ( ignoreErrors ) - { - makeCommand += " -i"; - } - if ( additionalOptions ) - { - makeCommand += " "; - makeCommand += additionalOptions; - } - if ( targetName ) - { - makeCommand += " "; - makeCommand += targetName; - } - return makeCommand; + makeCommand.push_back( + "cmGlobalGenerator::GenerateBuildCommand not implemented"); } int cmGlobalGenerator::Build( @@ -1428,7 +1674,6 @@ int cmGlobalGenerator::Build( bool clean, bool fast, double timeout, cmSystemTools::OutputOption outputflag, - const char* extraOptions, std::vector<std::string> const& nativeOptions) { /** @@ -1456,17 +1701,17 @@ int cmGlobalGenerator::Build( // should we do a clean first? if (clean) { - std::string cleanCommand = - this->GenerateBuildCommand(makeCommandCSTR, projectName, bindir, - 0, "clean", config, false, fast); + std::vector<std::string> cleanCommand; + this->GenerateBuildCommand(cleanCommand, makeCommandCSTR, projectName, + bindir, "clean", config, fast); if(output) { *output += "\nRun Clean Command:"; - *output += cleanCommand; + *output += cmSystemTools::PrintSingleCommand(cleanCommand); *output += "\n"; } - if (!cmSystemTools::RunSingleCommand(cleanCommand.c_str(), outputPtr, + if (!cmSystemTools::RunSingleCommand(cleanCommand, outputPtr, &retVal, 0, outputflag, timeout)) { cmSystemTools::SetRunCommandHideConsole(hideconsole); @@ -1488,37 +1733,29 @@ int cmGlobalGenerator::Build( } // now build - std::string makeCommand = - this->GenerateBuildCommand(makeCommandCSTR, projectName, bindir, - extraOptions, target, - config, false, fast); + std::vector<std::string> makeCommand; + this->GenerateBuildCommand(makeCommand, makeCommandCSTR, projectName, + bindir, target, config, fast, nativeOptions); + std::string makeCommandStr = cmSystemTools::PrintSingleCommand(makeCommand); if(output) { *output += "\nRun Build Command:"; - *output += makeCommand; + *output += makeCommandStr; *output += "\n"; } - std::vector<cmStdString> command = - cmSystemTools::ParseArguments(makeCommand.c_str()); - for(std::vector<std::string>::const_iterator ni = nativeOptions.begin(); - ni != nativeOptions.end(); ++ni) - { - command.push_back(*ni); - } - - if (!cmSystemTools::RunSingleCommand(command, outputPtr, + if (!cmSystemTools::RunSingleCommand(makeCommand, outputPtr, &retVal, 0, outputflag, timeout)) { cmSystemTools::SetRunCommandHideConsole(hideconsole); cmSystemTools::Error ("Generator: execution of make failed. Make command was: ", - makeCommand.c_str()); + makeCommandStr.c_str()); if (output) { *output += *outputPtr; *output += "\nGenerator: execution of make failed. Make command was: " - + makeCommand + "\n"; + + makeCommandStr + "\n"; } // return to the original directory @@ -1543,6 +1780,46 @@ int cmGlobalGenerator::Build( return retVal; } +//---------------------------------------------------------------------------- +std::string cmGlobalGenerator::GenerateCMakeBuildCommand( + const char* target, const char* config, const char* native, + bool ignoreErrors) +{ + std::string makeCommand = cmSystemTools::GetCMakeCommand(); + makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str()); + makeCommand += " --build ."; + if(config && *config) + { + makeCommand += " --config \""; + makeCommand += config; + makeCommand += "\""; + } + if(target && *target) + { + makeCommand += " --target \""; + makeCommand += target; + makeCommand += "\""; + } + const char* sep = " -- "; + if(ignoreErrors) + { + const char* iflag = this->GetBuildIgnoreErrorsFlag(); + if(iflag && *iflag) + { + makeCommand += sep; + makeCommand += iflag; + sep = " "; + } + } + if(native && *native) + { + makeCommand += sep; + makeCommand += native; + } + return makeCommand; +} + +//---------------------------------------------------------------------------- void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg) { this->LocalGenerators.push_back(lg); @@ -1634,7 +1911,7 @@ void cmGlobalGenerator::SetConfiguredFilesPath(cmGlobalGenerator* gen) } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmLocalGenerator* gen) + cmLocalGenerator* gen) const { if(!gen || gen == root) { @@ -1654,9 +1931,10 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmTarget& target) + cmTarget const& target) const { - if(target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) + if(target.GetType() == cmTarget::INTERFACE_LIBRARY + || target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) { // This target is excluded from its directory. return true; @@ -1669,16 +1947,17 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, } } -void cmGlobalGenerator::GetEnabledLanguages(std::vector<std::string>& lang) +void +cmGlobalGenerator::GetEnabledLanguages(std::vector<std::string>& lang) const { - for(std::map<cmStdString, bool>::iterator i = + for(std::map<cmStdString, bool>::const_iterator i = this->LanguageEnabled.begin(); i != this->LanguageEnabled.end(); ++i) { lang.push_back(i->first); } } -int cmGlobalGenerator::GetLinkerPreference(const char* lang) +int cmGlobalGenerator::GetLinkerPreference(const char* lang) const { std::map<cmStdString, int>::const_iterator it = this->LanguageToLinkerPreference.find(lang); @@ -1724,10 +2003,10 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() { cmLocalGenerator* lg = *lgi; cmMakefile* mf = lg->GetMakefile(); - cmTargets& targets = mf->GetTargets(); - for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) + cmTargets const& targets = mf->GetTargets(); + for(cmTargets::const_iterator t = targets.begin(); t != targets.end(); ++t) { - cmTarget& target = t->second; + cmTarget const& target = t->second; // Consider the directory containing the target and all its // parents until something excludes the target. @@ -1735,7 +2014,7 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() clg = clg->GetParent()) { // This local generator includes the target. - std::set<cmTarget*>& targetSet = + std::set<cmTarget const*>& targetSet = this->LocalGeneratorToTargetMap[clg]; targetSet.insert(&target); @@ -1746,7 +2025,8 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() for(TargetDependSet::const_iterator ti = tgtdeps.begin(); ti != tgtdeps.end(); ++ti) { - targetSet.insert(*ti); + cmTarget const* ttt = *ti; + targetSet.insert(ttt); } } } @@ -1755,15 +2035,16 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() ///! Find a local generator by its startdirectory -cmLocalGenerator* cmGlobalGenerator::FindLocalGenerator(const char* start_dir) +cmLocalGenerator* +cmGlobalGenerator::FindLocalGenerator(const char* start_dir) const { - std::vector<cmLocalGenerator*>* gens = &this->LocalGenerators; - for(unsigned int i = 0; i < gens->size(); ++i) + for(std::vector<cmLocalGenerator*>::const_iterator it = + this->LocalGenerators.begin(); it != this->LocalGenerators.end(); ++it) { - std::string sd = (*gens)[i]->GetMakefile()->GetStartDirectory(); + std::string sd = (*it)->GetMakefile()->GetStartDirectory(); if (sd == start_dir) { - return (*gens)[i]; + return *it; } } return 0; @@ -1776,7 +2057,7 @@ void cmGlobalGenerator::AddAlias(const char *name, cmTarget *tgt) } //---------------------------------------------------------------------------- -bool cmGlobalGenerator::IsAlias(const char *name) +bool cmGlobalGenerator::IsAlias(const char *name) const { return this->AliasTargets.find(name) != this->AliasTargets.end(); } @@ -1784,15 +2065,16 @@ bool cmGlobalGenerator::IsAlias(const char *name) //---------------------------------------------------------------------------- cmTarget* cmGlobalGenerator::FindTarget(const char* project, const char* name, - bool excludeAliases) + bool excludeAliases) const { // if project specific if(project) { - std::vector<cmLocalGenerator*>* gens = &this->ProjectMap[project]; - for(unsigned int i = 0; i < gens->size(); ++i) + std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator + gens = this->ProjectMap.find(project); + for(unsigned int i = 0; i < gens->second.size(); ++i) { - cmTarget* ret = (*gens)[i]->GetMakefile()->FindTarget(name, + cmTarget* ret = (gens->second)[i]->GetMakefile()->FindTarget(name, excludeAliases); if(ret) { @@ -1805,14 +2087,14 @@ cmGlobalGenerator::FindTarget(const char* project, const char* name, { if (!excludeAliases) { - std::map<cmStdString, cmTarget*>::iterator ai + std::map<cmStdString, cmTarget*>::const_iterator ai = this->AliasTargets.find(name); if (ai != this->AliasTargets.end()) { return ai->second; } } - std::map<cmStdString,cmTarget *>::iterator i = + std::map<cmStdString,cmTarget *>::const_iterator i = this->TotalTargets.find ( name ); if ( i != this->TotalTargets.end() ) { @@ -1828,7 +2110,8 @@ cmGlobalGenerator::FindTarget(const char* project, const char* name, } //---------------------------------------------------------------------------- -bool cmGlobalGenerator::NameResolvesToFramework(const std::string& libname) +bool +cmGlobalGenerator::NameResolvesToFramework(const std::string& libname) const { if(cmSystemTools::IsPathToFramework(libname.c_str())) { @@ -1873,7 +2156,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) cmCustomCommandLines cpackCommandLines; std::vector<std::string> depends; cmCustomCommandLine singleLine; - singleLine.push_back(this->GetCMakeInstance()->GetCPackCommand()); + singleLine.push_back(cmSystemTools::GetCPackCommand()); if ( cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.' ) { singleLine.push_back("-C"); @@ -1914,7 +2197,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) cpackCommandLines.end()); singleLine.erase(singleLine.begin(), singleLine.end()); depends.erase(depends.begin(), depends.end()); - singleLine.push_back(this->GetCMakeInstance()->GetCPackCommand()); + singleLine.push_back(cmSystemTools::GetCPackCommand()); singleLine.push_back("--config"); configFile = mf->GetStartOutputDirectory();; configFile += "/CPackSourceConfig.cmake"; @@ -1940,7 +2223,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) cpackCommandLines.end()); singleLine.erase(singleLine.begin(), singleLine.end()); depends.erase(depends.begin(), depends.end()); - singleLine.push_back(this->GetCMakeInstance()->GetCTestCommand()); + singleLine.push_back(cmSystemTools::GetCTestCommand()); singleLine.push_back("--force-new-ctest-process"); if(cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.') { @@ -1966,11 +2249,11 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) singleLine.erase(singleLine.begin(), singleLine.end()); depends.erase(depends.begin(), depends.end()); - // Use CMAKE_EDIT_COMMAND for the edit_cache rule if it is defined. - // Otherwise default to the interactive command-line interface. - if(mf->GetDefinition("CMAKE_EDIT_COMMAND")) + // Use generator preference for the edit_cache rule if it is defined. + std::string edit_cmd = this->GetEditCacheCommand(); + if (!edit_cmd.empty()) { - singleLine.push_back(mf->GetDefinition("CMAKE_EDIT_COMMAND")); + singleLine.push_back(edit_cmd); singleLine.push_back("-H$(CMAKE_SOURCE_DIR)"); singleLine.push_back("-B$(CMAKE_BINARY_DIR)"); cpackCommandLines.push_back(singleLine); @@ -1982,13 +2265,14 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) else { singleLine.push_back(cmakeCommand); - singleLine.push_back("-i"); - singleLine.push_back("."); + singleLine.push_back("-E"); + singleLine.push_back("echo"); + singleLine.push_back("No interactive CMake dialog available."); cpackCommandLines.push_back(singleLine); (*targets)[editCacheTargetName] = this->CreateGlobalTarget( editCacheTargetName, - "Running interactive CMake command-line interface...", + "No interactive CMake dialog available...", &cpackCommandLines, depends, 0); } } @@ -2012,7 +2296,14 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) } //Install - if(this->InstallTargetEnabled) + bool skipInstallRules = mf->IsOn("CMAKE_SKIP_INSTALL_RULES"); + if(this->InstallTargetEnabled && skipInstallRules) + { + mf->IssueMessage(cmake::WARNING, + "CMAKE_SKIP_INSTALL_RULES was enabled even though " + "installation rules have been specified"); + } + else if(this->InstallTargetEnabled && !skipInstallRules) { if(!cmakeCfgIntDir || !*cmakeCfgIntDir || cmakeCfgIntDir[0] == '.') { @@ -2201,7 +2492,7 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget( // Store the custom command in the target. cmCustomCommand cc(0, no_outputs, no_depends, *commandLines, 0, workingDirectory); - target.GetPostBuildCommands().push_back(cc); + target.AddPostBuildCommand(cc); target.SetProperty("EchoString", message); std::vector<std::string>::iterator dit; for ( dit = depends.begin(); dit != depends.end(); ++ dit ) @@ -2236,11 +2527,13 @@ cmGlobalGenerator::GenerateRuleFile(std::string const& output) const //---------------------------------------------------------------------------- std::string cmGlobalGenerator::GetSharedLibFlagsForLanguage( - std::string const& l) + std::string const& l) const { - if(this->LanguageToOriginalSharedLibFlags.count(l) > 0) + std::map<cmStdString, cmStdString>::const_iterator it = + this->LanguageToOriginalSharedLibFlags.find(l); + if(it != this->LanguageToOriginalSharedLibFlags.end()) { - return this->LanguageToOriginalSharedLibFlags[l]; + return it->second; } return ""; } @@ -2256,7 +2549,7 @@ void cmGlobalGenerator::AppendDirectoryForConfig(const char*, const char*, //---------------------------------------------------------------------------- cmGlobalGenerator::TargetDependSet const& -cmGlobalGenerator::GetTargetDirectDepends(cmTarget & target) +cmGlobalGenerator::GetTargetDirectDepends(cmTarget const& target) { return this->TargetDependencies[&target]; } @@ -2273,6 +2566,37 @@ void cmGlobalGenerator::AddTarget(cmTarget* t) } } +bool cmGlobalGenerator::IsReservedTarget(std::string const& name) +{ + // The following is a list of targets reserved + // by one or more of the cmake generators. + + // Adding additional targets to this list will require a policy! + const char* reservedTargets[] = + { + "all", "ALL_BUILD", + "help", + "install", "INSTALL", + "preinstall", + "clean", + "edit_cache", + "rebuild_cache", + "test", "RUN_TESTS", + "package", "PACKAGE", + "package_source", + "ZERO_CHECK", + 0 + }; + + for(const char** reservedTarget = reservedTargets; + *reservedTarget; ++reservedTarget) + { + if(name == *reservedTarget) return true; + } + + return false; +} + void cmGlobalGenerator::SetExternalMakefileProjectGenerator( cmExternalMakefileProjectGenerator *extraGenerator) { @@ -2340,14 +2664,14 @@ void cmGlobalGenerator::GetTargetSets(TargetDependSet& projectTargets, } //---------------------------------------------------------------------------- -bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target) +bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target) const { return (target->GetType() == cmTarget::GLOBAL_TARGET || strcmp(target->GetName(), this->GetAllTargetName()) == 0); } //---------------------------------------------------------------------------- -void cmGlobalGenerator::AddTargetDepends(cmTarget* target, +void cmGlobalGenerator::AddTargetDepends(cmTarget const* target, TargetDependSet& projectTargets) { // add the target itself @@ -2358,7 +2682,7 @@ void cmGlobalGenerator::AddTargetDepends(cmTarget* target, TargetDependSet const& ts = this->GetTargetDirectDepends(*target); for(TargetDependSet::const_iterator i = ts.begin(); i != ts.end(); ++i) { - cmTarget* dtarget = *i; + cmTarget const* dtarget = *i; this->AddTargetDepends(dtarget, projectTargets); } } @@ -2460,9 +2784,9 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile, std::string const& home) { #if defined(_WIN32) || defined(__CYGWIN__) - std::ifstream fin(pfile.c_str(), std::ios::in | std::ios::binary); + cmsys::ifstream fin(pfile.c_str(), std::ios::in | std::ios::binary); #else - std::ifstream fin(pfile.c_str(), std::ios::in); + cmsys::ifstream fin(pfile.c_str(), std::ios::in); #endif if(!fin) { @@ -2555,6 +2879,10 @@ void cmGlobalGenerator::WriteSummary() for(std::map<cmStdString,cmTarget *>::const_iterator ti = this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti) { + if ((ti->second)->GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } this->WriteSummary(ti->second); fout << ti->second->GetSupportDirectory() << "\n"; } @@ -2590,7 +2918,8 @@ void cmGlobalGenerator::WriteSummary(cmTarget* target) // List the source files with any per-source labels. fout << "# Source files and their labels\n"; - std::vector<cmSourceFile*> const& sources = target->GetSourceFiles(); + std::vector<cmSourceFile*> sources; + target->GetSourceFiles(sources); for(std::vector<cmSourceFile*>::const_iterator si = sources.begin(); si != sources.end(); ++si) { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 18aba24..ebc2db5 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -31,6 +31,8 @@ class cmExternalMakefileProjectGenerator; class cmTarget; class cmInstallTargetGenerator; class cmInstallFilesGenerator; +class cmExportBuildFileGenerator; +class cmQtAutoGenerators; /** \class cmGlobalGenerator * \brief Responable for overseeing the generation process for the entire tree @@ -51,6 +53,10 @@ public: ///! Get the name for this generator virtual const char *GetName() const { return "Generic"; }; + /** Check whether the given name matches the current generator. */ + virtual bool MatchesGeneratorName(const char* name) const + { return strcmp(this->GetName(), name) == 0; } + /** Set the generator-specific toolset name. Returns true if toolset is supported and false otherwise. */ virtual bool SetGeneratorToolset(std::string const& ts); @@ -74,7 +80,7 @@ public: void SetLanguageEnabled(const char*, cmMakefile* mf); bool GetLanguageEnabled(const char*) const; void ClearEnabledLanguages(); - void GetEnabledLanguages(std::vector<std::string>& lang); + void GetEnabledLanguages(std::vector<std::string>& lang) const; /** * Try to determine system infomation such as shared library * extension, pthreads, byte order etc. @@ -87,7 +93,7 @@ public: * Intended to be called from EnableLanguage. */ void ResolveLanguageCompiler(const std::string &lang, cmMakefile *mf, - bool optional); + bool optional) const; /** * Try to determine system infomation, get it from another generator @@ -117,24 +123,28 @@ public: bool clean, bool fast, double timeout, cmSystemTools::OutputOption outputflag=cmSystemTools::OUTPUT_NONE, - const char* extraOptions = 0, std::vector<std::string> const& nativeOptions = std::vector<std::string>()); - virtual std::string GenerateBuildCommand( + virtual void GenerateBuildCommand( + std::vector<std::string>& makeCommand, const char* makeProgram, const char *projectName, const char *projectDir, - const char* additionalOptions, - const char *targetName, const char* config, - bool ignoreErrors, bool fast); + const char *targetName, const char* config, bool fast, + std::vector<std::string> const& makeOptions = std::vector<std::string>() + ); + /** Generate a "cmake --build" call for a given target and config. */ + std::string GenerateCMakeBuildCommand(const char* target, + const char* config, + const char* native, + bool ignoreErrors); ///! Set the CMake instance void SetCMakeInstance(cmake *cm); ///! Get the CMake instance - cmake *GetCMakeInstance() { return this->CMakeInstance; } - const cmake *GetCMakeInstance() const { return this->CMakeInstance; } + cmake *GetCMakeInstance() const { return this->CMakeInstance; } void SetConfiguredFilesPath(cmGlobalGenerator* gen); const std::vector<cmLocalGenerator *>& GetLocalGenerators() const { @@ -172,13 +182,13 @@ public: bool GetToolSupportsColor() const { return this->ToolSupportsColor; } ///! return the language for the given extension - const char* GetLanguageFromExtension(const char* ext); + const char* GetLanguageFromExtension(const char* ext) const; ///! is an extension to be ignored - bool IgnoreFile(const char* ext); + bool IgnoreFile(const char* ext) const; ///! What is the preference for linkers and this language (None or Prefered) - int GetLinkerPreference(const char* lang); + int GetLinkerPreference(const char* lang) const; ///! What is the object file extension for a given source file? - const char* GetLanguageOutputExtension(cmSourceFile const&); + const char* GetLanguageOutputExtension(cmSourceFile const&) const; ///! What is the configurations directory variable called? virtual const char* GetCMakeCFGIntDir() const { return "."; } @@ -193,24 +203,24 @@ public: /* * Determine what program to use for building the project. */ - void FindMakeProgram(cmMakefile*); + virtual void FindMakeProgram(cmMakefile*); ///! Find a target by name by searching the local generators. cmTarget* FindTarget(const char* project, const char* name, - bool excludeAliases = false); + bool excludeAliases = false) const; void AddAlias(const char *name, cmTarget *tgt); - bool IsAlias(const char *name); + bool IsAlias(const char *name) const; /** Determine if a name resolves to a framework on disk or a built target that is a framework. */ - bool NameResolvesToFramework(const std::string& libname); + bool NameResolvesToFramework(const std::string& libname) const; /** If check to see if the target is linked to by any other target in the project */ - bool IsDependedOn(const char* project, cmTarget* target); + bool IsDependedOn(const char* project, cmTarget const* target); ///! Find a local generator by its startdirectory - cmLocalGenerator* FindLocalGenerator(const char* start_dir); + cmLocalGenerator* FindLocalGenerator(const char* start_dir) const; /** Append the subdirectory for the given configuration. If anything is appended the given prefix and suffix will be appended around it, which @@ -234,6 +244,8 @@ public: void AddTarget(cmTarget* t); + static bool IsReservedTarget(std::string const& name); + virtual const char* GetAllTargetName() const { return "ALL_BUILD"; } virtual const char* GetInstallTargetName() const { return "INSTALL"; } virtual const char* GetInstallLocalTargetName() const { return 0; } @@ -246,15 +258,18 @@ public: virtual const char* GetRebuildCacheTargetName() const { return 0; } virtual const char* GetCleanTargetName() const { return 0; } + // Lookup edit_cache target command preferred by this generator. + virtual std::string GetEditCacheCommand() const { return ""; } + // Class to track a set of dependencies. typedef cmTargetDependSet TargetDependSet; // what targets does the specified target depend on directly // via a target_link_libraries or add_dependencies - TargetDependSet const& GetTargetDirectDepends(cmTarget & target); + TargetDependSet const& GetTargetDirectDepends(cmTarget const& target); /** Get per-target generator information. */ - cmGeneratorTarget* GetGeneratorTarget(cmTarget*) const; + cmGeneratorTarget* GetGeneratorTarget(cmTarget const*) const; const std::map<cmStdString, std::vector<cmLocalGenerator*> >& GetProjectMap() const {return this->ProjectMap;} @@ -278,7 +293,7 @@ public: i.e. "Can I build Debug and Release in the same tree?" */ virtual bool IsMultiConfig() { return false; } - std::string GetSharedLibFlagsForLanguage(std::string const& lang); + std::string GetSharedLibFlagsForLanguage(std::string const& lang) const; /** Generate an <output>.rule file path for a given command output. */ virtual std::string GenerateRuleFile(std::string const& output) const; @@ -293,6 +308,16 @@ public: void ProcessEvaluationFiles(); + std::map<std::string, cmExportBuildFileGenerator*>& GetBuildExportSets() + {return this->BuildExportSets;} + void AddBuildExportSet(cmExportBuildFileGenerator*); + void AddBuildExportExportSet(cmExportBuildFileGenerator*); + bool IsExportedTargetsFile(const std::string &filename) const; + bool GenerateImportFile(const std::string &file); + cmExportBuildFileGenerator* + GetExportedTargetsFile(const std::string &filename) const; + void AddCMP0042WarnTarget(const std::string& target); + protected: typedef std::vector<cmLocalGenerator*> GeneratorVector; // for a project collect all its targets by following depend @@ -300,26 +325,31 @@ protected: virtual void GetTargetSets(TargetDependSet& projectTargets, TargetDependSet& originalTargets, cmLocalGenerator* root, GeneratorVector const&); - virtual bool IsRootOnlyTarget(cmTarget* target); - void AddTargetDepends(cmTarget* target, TargetDependSet& projectTargets); + bool IsRootOnlyTarget(cmTarget* target) const; + void AddTargetDepends(cmTarget const* target, + TargetDependSet& projectTargets); void SetLanguageEnabledFlag(const char* l, cmMakefile* mf); void SetLanguageEnabledMaps(const char* l, cmMakefile* mf); void FillExtensionToLanguageMap(const char* l, cmMakefile* mf); virtual bool ComputeTargetDepends(); - virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS(); + virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const; bool CheckTargets(); - void CreateAutomocTargets(); + typedef std::vector<std::pair<cmQtAutoGenerators, + cmTarget const*> > AutogensType; + void CreateQtAutoGeneratorsTargets(AutogensType& autogens); + std::string SelectMakeProgram(const char* makeProgram, + std::string makeDefault = "") const; // Fill the ProjectMap, this must be called after LocalGenerators // has been populated. void FillProjectMap(); void CheckLocalGenerators(); - bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen); - bool IsExcluded(cmLocalGenerator* root, cmTarget& target); + bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; + bool IsExcluded(cmLocalGenerator* root, cmTarget const& target) const; void FillLocalGeneratorToTargetMap(); void CreateDefaultGlobalTargets(cmTargets* targets); cmTarget CreateGlobalTarget(const char* name, const char* message, @@ -337,13 +367,16 @@ protected: cmLocalGenerator* CurrentLocalGenerator; // map from project name to vector of local generators in that project std::map<cmStdString, std::vector<cmLocalGenerator*> > ProjectMap; - std::map<cmLocalGenerator*, std::set<cmTarget *> > LocalGeneratorToTargetMap; + std::map<cmLocalGenerator*, std::set<cmTarget const*> > + LocalGeneratorToTargetMap; // Set of named installation components requested by the project. std::set<cmStdString> InstallComponents; bool InstallTargetEnabled; // Sets of named target exports cmExportSetMap ExportSets; + std::map<std::string, cmExportBuildFileGenerator*> BuildExportSets; + std::map<std::string, cmExportBuildFileGenerator*> BuildExportExportSets; // Manifest of all targets that will be built for each configuration. // This is computed just before local generators generate. @@ -382,6 +415,11 @@ private: void WriteSummary(); void WriteSummary(cmTarget* target); + void FinalizeTargetCompileInfo(); + + virtual void PrintCompilerAdvice(std::ostream& os, std::string lang, + const char* envVar) const; + void CheckCompilerIdCompatibility(cmMakefile* mf, std::string lang) const; cmExternalMakefileProjectGenerator* ExtraGenerator; @@ -389,15 +427,21 @@ private: std::vector<std::string> FilesReplacedDuringGenerate; // Store computed inter-target dependencies. - typedef std::map<cmTarget *, TargetDependSet> TargetDependMap; + typedef std::map<cmTarget const*, TargetDependSet> TargetDependMap; TargetDependMap TargetDependencies; // Per-target generator information. cmGeneratorTargetsType GeneratorTargets; + friend class cmake; + void CreateGeneratorTargets(cmMakefile* mf); void CreateGeneratorTargets(); - void ClearGeneratorTargets(); + void ComputeGeneratorTargetObjects(); virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const; + void ClearGeneratorMembers(); + + virtual const char* GetBuildIgnoreErrorsFlag() const { return 0; } + // Cache directory content and target files to be built. struct DirectoryContent: public std::set<cmStdString> { @@ -411,6 +455,9 @@ private: // Set of binary directories on disk. std::set<cmStdString> BinaryDirectories; + + // track targets to issue CMP0042 warning for. + std::set<std::string> CMP0042WarnTargets; }; #endif diff --git a/Source/cmGlobalJOMMakefileGenerator.cxx b/Source/cmGlobalJOMMakefileGenerator.cxx index 4af0607..bc15ef2 100644 --- a/Source/cmGlobalJOMMakefileGenerator.cxx +++ b/Source/cmGlobalJOMMakefileGenerator.cxx @@ -65,5 +65,4 @@ void cmGlobalJOMMakefileGenerator { entry.Name = cmGlobalJOMMakefileGenerator::GetActualName(); entry.Brief = "Generates JOM makefiles."; - entry.Full = ""; } diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index a81c26c..ed0e15b 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -21,6 +21,7 @@ #include <cmsys/SystemTools.hxx> #include <cmsys/Directory.hxx> +#include <cmsys/FStream.hxx> //---------------------------------------------------------------------------- void cmGlobalKdevelopGenerator @@ -28,16 +29,6 @@ void cmGlobalKdevelopGenerator { entry.Name = this->GetName(); entry.Brief = "Generates KDevelop 3 project files."; - entry.Full = - "Project files for KDevelop 3 will be created in the top directory " - "and in every subdirectory which features a CMakeLists.txt file " - "containing a PROJECT() call. " - "If you change the settings using KDevelop cmake will try its best " - "to keep your changes when regenerating the project files. " - "Additionally a hierarchy of UNIX makefiles is generated into the " - "build tree. Any " - "standard UNIX-style make program can build the project through the " - "default make target. A \"make install\" target is also provided."; } cmGlobalKdevelopGenerator::cmGlobalKdevelopGenerator() @@ -85,7 +76,7 @@ void cmGlobalKdevelopGenerator::Generate() { if (ti->second.GetType()==cmTarget::EXECUTABLE) { - executable = ti->second.GetProperty("LOCATION"); + executable = ti->second.GetLocation(0); break; } } @@ -147,7 +138,8 @@ bool cmGlobalKdevelopGenerator for (cmTargets::iterator ti = targets.begin(); ti != targets.end(); ti++) { - const std::vector<cmSourceFile*>& sources=ti->second.GetSourceFiles(); + std::vector<cmSourceFile*> sources; + ti->second.GetSourceFiles(sources); for (std::vector<cmSourceFile*>::const_iterator si=sources.begin(); si!=sources.end(); si++) { @@ -199,7 +191,7 @@ bool cmGlobalKdevelopGenerator //check if the output file already exists and read it //insert all files which exist into the set of files - std::ifstream oldFilelist(filename.c_str()); + cmsys::ifstream oldFilelist(filename.c_str()); if (oldFilelist) { while (cmSystemTools::GetLineFromStream(oldFilelist, tmp)) @@ -320,7 +312,7 @@ void cmGlobalKdevelopGenerator const std::string& fileToOpen, const std::string& sessionFilename) { - std::ifstream oldProjectFile(filename.c_str()); + cmsys::ifstream oldProjectFile(filename.c_str()); if (!oldProjectFile) { this->CreateNewProjectFile(outputDir, projectDir, filename, @@ -472,7 +464,7 @@ void cmGlobalKdevelopGenerator " <numberofjobs>1</numberofjobs>\n" " <dontact>false</dontact>\n" " <makebin>" << this->GlobalGenerator->GetLocalGenerators()[0]-> - GetMakefile()->GetRequiredDefinition("CMAKE_BUILD_TOOL") + GetMakefile()->GetRequiredDefinition("CMAKE_MAKE_PROGRAM") << " </makebin>\n" " <selectedenvironment>default</selectedenvironment>\n" " <environments>\n" diff --git a/Source/cmGlobalMSYSMakefileGenerator.cxx b/Source/cmGlobalMSYSMakefileGenerator.cxx index d49639b..16f05e5 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.cxx +++ b/Source/cmGlobalMSYSMakefileGenerator.cxx @@ -13,6 +13,7 @@ #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" #include "cmake.h" +#include <cmsys/FStream.hxx> cmGlobalMSYSMakefileGenerator::cmGlobalMSYSMakefileGenerator() { @@ -27,7 +28,7 @@ cmGlobalMSYSMakefileGenerator::FindMinGW(std::string const& makeloc) { std::string fstab = makeloc; fstab += "/../etc/fstab"; - std::ifstream fin(fstab.c_str()); + cmsys::ifstream fin(fstab.c_str()); std::string path; std::string mount; std::string mingwBin; @@ -110,6 +111,4 @@ void cmGlobalMSYSMakefileGenerator { entry.Name = cmGlobalMSYSMakefileGenerator::GetActualName(); entry.Brief = "Generates MSYS makefiles."; - entry.Full = "The makefiles use /bin/sh as the shell. " - "They require msys to be installed on the machine."; } diff --git a/Source/cmGlobalMinGWMakefileGenerator.cxx b/Source/cmGlobalMinGWMakefileGenerator.cxx index 1f374d3..e00c7dd 100644 --- a/Source/cmGlobalMinGWMakefileGenerator.cxx +++ b/Source/cmGlobalMinGWMakefileGenerator.cxx @@ -49,6 +49,4 @@ void cmGlobalMinGWMakefileGenerator { entry.Name = cmGlobalMinGWMakefileGenerator::GetActualName(); entry.Brief = "Generates a make file for use with mingw32-make."; - entry.Full = "The makefiles generated use cmd.exe as the shell. " - "They do not require msys or a unix shell."; } diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx index 7af4ee3..4fbabe4 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.cxx +++ b/Source/cmGlobalNMakeMakefileGenerator.cxx @@ -65,5 +65,4 @@ void cmGlobalNMakeMakefileGenerator { entry.Name = cmGlobalNMakeMakefileGenerator::GetActualName(); entry.Brief = "Generates NMake makefiles."; - entry.Full = ""; } diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 1953546..5e1f1ed 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -102,6 +102,13 @@ std::string cmGlobalNinjaGenerator::EncodePath(const std::string &path) return EncodeLiteral(result); } +std::string cmGlobalNinjaGenerator::EncodeDepfileSpace(const std::string &path) +{ + std::string result = path; + cmSystemTools::ReplaceString(result, " ", "\\ "); + return result; +} + void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, const std::string& comment, const std::string& rule, @@ -236,9 +243,11 @@ void cmGlobalNinjaGenerator::AddCustomCommandRule() "$DESC", "Rule for running custom commands.", /*depfile*/ "", + /*deptype*/ "", /*rspfile*/ "", /*rspcontent*/ "", - /*restat*/ true); + /*restat*/ true, + /*generator*/ false); } void @@ -247,7 +256,7 @@ cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command, const std::string& comment, const cmNinjaDeps& outputs, const cmNinjaDeps& deps, - const cmNinjaDeps& orderOnlyDeps) + const cmNinjaDeps& orderOnly) { std::string cmd = command; #ifdef _WIN32 @@ -268,7 +277,7 @@ cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command, outputs, deps, cmNinjaDeps(), - orderOnlyDeps, + orderOnly, vars); } @@ -287,9 +296,13 @@ cmGlobalNinjaGenerator::AddMacOSXContentRule() this->AddRule("COPY_OSX_CONTENT", cmd.str(), "Copying OS X Content $out", - "Rule for copying OS X bundle content file." + "Rule for copying OS X bundle content file.", /*depfile*/ "", - /*rspfile*/ ""); + /*deptype*/ "", + /*rspfile*/ "", + /*rspcontent*/ "", + /*restat*/ false, + /*generator*/ false); } void @@ -320,6 +333,7 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os, const std::string& description, const std::string& comment, const std::string& depfile, + const std::string& deptype, const std::string& rspfile, const std::string& rspcontent, bool restat, @@ -355,6 +369,13 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os, os << "depfile = " << depfile << "\n"; } + // Write the deptype if any. + if (!deptype.empty()) + { + cmGlobalNinjaGenerator::Indent(os, 1); + os << "deps = " << deptype << "\n"; + } + // Write the command. cmGlobalNinjaGenerator::Indent(os, 1); os << "command = " << command << "\n"; @@ -470,10 +491,6 @@ void cmGlobalNinjaGenerator { entry.Name = cmGlobalNinjaGenerator::GetActualName(); entry.Brief = "Generates build.ninja files (experimental)."; - entry.Full = - "A build.ninja file is generated into the build tree. Recent " - "versions of the ninja program can build the project through the " - "\"all\" target. An \"install\" target is also provided."; } // Implemented in all cmGlobaleGenerator sub-classes. @@ -532,47 +549,34 @@ bool cmGlobalNinjaGenerator::UsingMinGW = false; // cmGlobalXCodeGenerator // Called by: // cmGlobalGenerator::Build() -std::string cmGlobalNinjaGenerator -::GenerateBuildCommand(const char* makeProgram, - const char* projectName, - const char* projectDir, - const char* additionalOptions, +void cmGlobalNinjaGenerator +::GenerateBuildCommand(std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* /*projectName*/, + const char* /*projectDir*/, const char* targetName, - const char* config, - bool ignoreErrors, - bool fast) + const char* /*config*/, + bool /*fast*/, + std::vector<std::string> const& makeOptions) { - // Project name & dir and config are not used yet. - (void)projectName; - (void)projectDir; - (void)config; - // Ninja does not have -i equivalent option yet. - (void)ignoreErrors; - // We do not handle fast build yet. - (void)fast; - - std::string makeCommand = - cmSystemTools::ConvertToUnixOutputPath(makeProgram); - - if(additionalOptions) - { - makeCommand += " "; - makeCommand += additionalOptions; - } - if(targetName) + makeCommand.push_back( + this->SelectMakeProgram(makeProgram) + ); + + makeCommand.insert(makeCommand.end(), + makeOptions.begin(), makeOptions.end()); + if(targetName && *targetName) { if(strcmp(targetName, "clean") == 0) { - makeCommand += " -t clean"; + makeCommand.push_back("-t"); + makeCommand.push_back("clean"); } else { - makeCommand += " "; - makeCommand += targetName; + makeCommand.push_back(targetName); } } - - return makeCommand; } //---------------------------------------------------------------------------- @@ -583,6 +587,7 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name, const std::string& description, const std::string& comment, const std::string& depfile, + const std::string& deptype, const std::string& rspfile, const std::string& rspcontent, bool restat, @@ -601,6 +606,7 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name, description, comment, depfile, + deptype, rspfile, rspcontent, restat, @@ -618,6 +624,13 @@ bool cmGlobalNinjaGenerator::HasRule(const std::string &name) //---------------------------------------------------------------------------- // Private virtual overrides +std::string cmGlobalNinjaGenerator::GetEditCacheCommand() const +{ + // Ninja by design does not run interactive tools in the terminal, + // so our only choice is cmake-gui. + return cmSystemTools::GetCMakeGUICommand(); +} + // TODO: Refactor to combine with cmGlobalUnixMakefileGenerator3 impl. void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const { @@ -631,15 +644,17 @@ void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const dir_max += "/"; gt->ObjectDirectory = dir_max; + std::vector<cmSourceFile*> objectSources; + gt->GetObjectSources(objectSources); // Compute the name of each object file. for(std::vector<cmSourceFile*>::iterator - si = gt->ObjectSources.begin(); - si != gt->ObjectSources.end(); ++si) + si = objectSources.begin(); + si != objectSources.end(); ++si) { cmSourceFile* sf = *si; std::string objectName = gt->LocalGenerator ->GetObjectFileNameWithoutTarget(*sf, dir_max); - gt->Objects[sf] = objectName; + gt->AddObject(sf, objectName); } } @@ -817,7 +832,7 @@ void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies() void cmGlobalNinjaGenerator -::AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs) +::AppendTargetOutputs(cmTarget const* target, cmNinjaDeps& outputs) { const char* configName = target->GetMakefile()->GetDefinition("CMAKE_BUILD_TYPE"); @@ -866,7 +881,7 @@ cmGlobalNinjaGenerator void cmGlobalNinjaGenerator -::AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs) +::AppendTargetDepends(cmTarget const* target, cmNinjaDeps& outputs) { if (target->GetType() == cmTarget::GLOBAL_TARGET) { // Global targets only depend on other utilities, which may not appear in @@ -877,7 +892,12 @@ cmGlobalNinjaGenerator cmTargetDependSet const& targetDeps = this->GetTargetDirectDepends(*target); for (cmTargetDependSet::const_iterator i = targetDeps.begin(); - i != targetDeps.end(); ++i) { + i != targetDeps.end(); ++i) + { + if ((*i)->GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } this->AppendTargetOutputs(*i, outputs); } } @@ -1084,6 +1104,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) "Re-running CMake...", "Rule for re-running cmake.", /*depfile=*/ "", + /*deptype=*/ "", /*rspfile=*/ "", /*rspcontent*/ "", /*restat=*/ false, @@ -1134,6 +1155,7 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) "Cleaning all built files...", "Rule for cleaning all built files.", /*depfile=*/ "", + /*deptype=*/ "", /*rspfile=*/ "", /*rspcontent*/ "", /*restat=*/ false, @@ -1156,6 +1178,7 @@ void cmGlobalNinjaGenerator::WriteTargetHelp(std::ostream& os) "All primary targets available:", "Rule for printing all primary targets available.", /*depfile=*/ "", + /*deptype=*/ "", /*rspfile=*/ "", /*rspcontent*/ "", /*restat=*/ false, diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index e046c7c..0d5fb44 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -64,6 +64,7 @@ public: static std::string EncodeIdent(const std::string &ident, std::ostream &vars); static std::string EncodeLiteral(const std::string &lit); static std::string EncodePath(const std::string &path); + static std::string EncodeDepfileSpace(const std::string &path); /** * Write the given @a comment to the output stream @a os. It @@ -104,7 +105,7 @@ public: const std::string& comment, const cmNinjaDeps& outputs, const cmNinjaDeps& deps = cmNinjaDeps(), - const cmNinjaDeps& orderOnlyDeps = cmNinjaDeps()); + const cmNinjaDeps& orderOnly = cmNinjaDeps()); void WriteMacOSXContentBuild(const std::string& input, const std::string& output); @@ -120,6 +121,7 @@ public: const std::string& description, const std::string& comment, const std::string& depfile, + const std::string& deptype, const std::string& rspfile, const std::string& rspcontent, bool restat, @@ -189,14 +191,16 @@ public: bool optional); /// Overloaded methods. @see cmGlobalGenerator::GenerateBuildCommand() - virtual std::string GenerateBuildCommand(const char* makeProgram, - const char* projectName, - const char* projectDir, - const char* additionalOptions, - const char* targetName, - const char* config, - bool ignoreErrors, - bool fast); + virtual void GenerateBuildCommand( + std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* projectName, + const char* projectDir, + const char* targetName, + const char* config, + bool fast, + std::vector<std::string> const& makeOptions = std::vector<std::string>() + ); // Setup target names virtual const char* GetAllTargetName() const { return "all"; } @@ -239,11 +243,12 @@ public: const std::string& command, const std::string& description, const std::string& comment, - const std::string& depfile = "", - const std::string& rspfile = "", - const std::string& rspcontent = "", - bool restat = false, - bool generator = false); + const std::string& depfile, + const std::string& deptype, + const std::string& rspfile, + const std::string& rspcontent, + bool restat, + bool generator); bool HasRule(const std::string& name); @@ -278,8 +283,8 @@ public: ASD.insert(deps.begin(), deps.end()); } - void AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs); - void AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs); + void AppendTargetOutputs(cmTarget const* target, cmNinjaDeps& outputs); + void AppendTargetDepends(cmTarget const* target, cmNinjaDeps& outputs); void AddDependencyToAll(cmTarget* target); void AddDependencyToAll(const std::string& input); @@ -299,10 +304,11 @@ protected: /// Overloaded methods. /// @see cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() - virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() { return true; } + virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const { return true; } private: + virtual std::string GetEditCacheCommand() const; /// @see cmGlobalGenerator::ComputeTargetObjects virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 88cd6e5..0b37a07 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -65,10 +65,42 @@ void cmGlobalUnixMakefileGenerator3 { entry.Name = cmGlobalUnixMakefileGenerator3::GetActualName(); entry.Brief = "Generates standard UNIX makefiles."; - entry.Full = - "A hierarchy of UNIX makefiles is generated into the build tree. Any " - "standard UNIX-style make program can build the project through the " - "default make target. A \"make install\" target is also provided."; +} + +//---------------------------------------------------------------------------- +std::string cmGlobalUnixMakefileGenerator3::GetEditCacheCommand() const +{ + // If generating for an extra IDE, the edit_cache target cannot + // launch a terminal-interactive tool, so always use cmake-gui. + if(this->GetExtraGeneratorName()) + { + return cmSystemTools::GetCMakeGUICommand(); + } + + // Use an internal cache entry to track the latest dialog used + // to edit the cache, and use that for the edit_cache target. + cmake* cm = this->GetCMakeInstance(); + std::string editCacheCommand = cm->GetCMakeEditCommand(); + if(!cm->GetCacheDefinition("CMAKE_EDIT_COMMAND") || + !editCacheCommand.empty()) + { + if(editCacheCommand.empty()) + { + editCacheCommand = cmSystemTools::GetCMakeCursesCommand(); + } + if(editCacheCommand.empty()) + { + editCacheCommand = cmSystemTools::GetCMakeGUICommand(); + } + if(!editCacheCommand.empty()) + { + cm->AddCacheEntry + ("CMAKE_EDIT_COMMAND", editCacheCommand.c_str(), + "Path to cache edit program executable.", cmCacheManager::INTERNAL); + } + } + const char* edit_cmd = cm->GetCacheDefinition("CMAKE_EDIT_COMMAND"); + return edit_cmd? edit_cmd : ""; } //---------------------------------------------------------------------------- @@ -88,21 +120,31 @@ cmGlobalUnixMakefileGenerator3 dir_max += "/"; gt->ObjectDirectory = dir_max; + std::vector<cmSourceFile*> objectSources; + gt->GetObjectSources(objectSources); // Compute the name of each object file. for(std::vector<cmSourceFile*>::iterator - si = gt->ObjectSources.begin(); - si != gt->ObjectSources.end(); ++si) + si = objectSources.begin(); + si != objectSources.end(); ++si) { cmSourceFile* sf = *si; bool hasSourceExtension = true; std::string objectName = gt->LocalGenerator ->GetObjectFileNameWithoutTarget(*sf, dir_max, &hasSourceExtension); - gt->Objects[sf] = objectName; + gt->AddObject(sf, objectName); lg->AddLocalObjectFile(target, sf, objectName, hasSourceExtension); } } +void cmGlobalUnixMakefileGenerator3::Configure() +{ + // Initialize CMAKE_EDIT_COMMAND cache entry. + this->GetEditCacheCommand(); + + this->cmGlobalGenerator::Configure(); +} + void cmGlobalUnixMakefileGenerator3::Generate() { // first do superclass method @@ -281,7 +323,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() // Save the generator name cmakefileStream << "# The generator used is:\n" - << "SET(CMAKE_DEPENDS_GENERATOR \"" << this->GetName() << "\")\n\n"; + << "set(CMAKE_DEPENDS_GENERATOR \"" << this->GetName() << "\")\n\n"; // for each cmMakefile get its list of dependencies std::vector<std::string> lfiles; @@ -312,7 +354,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() // Save the list to the cmake file. cmakefileStream << "# The top level Makefile was generated from the following files:\n" - << "SET(CMAKE_MAKEFILE_DEPENDS\n" + << "set(CMAKE_MAKEFILE_DEPENDS\n" << " \"" << lg->Convert(cache.c_str(), cmLocalGenerator::START_OUTPUT).c_str() << "\"\n"; @@ -335,7 +377,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() // Set the corresponding makefile in the cmake file. cmakefileStream << "# The corresponding makefile is:\n" - << "SET(CMAKE_MAKEFILE_OUTPUTS\n" + << "set(CMAKE_MAKEFILE_OUTPUTS\n" << " \"" << lg->Convert(makefileName.c_str(), cmLocalGenerator::START_OUTPUT).c_str() << "\"\n" @@ -348,7 +390,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() { cmakefileStream << "# Byproducts of CMake generate step:\n" - << "SET(CMAKE_MAKEFILE_PRODUCTS\n"; + << "set(CMAKE_MAKEFILE_PRODUCTS\n"; const std::vector<std::string>& outfiles = lg->GetMakefile()->GetOutputFiles(); for(std::vector<std::string>::const_iterator k = outfiles.begin(); @@ -390,7 +432,7 @@ void cmGlobalUnixMakefileGenerator3 cmakefileStream << "# Dependency information for all targets:\n"; cmakefileStream - << "SET(CMAKE_DEPEND_INFO_FILES\n"; + << "set(CMAKE_DEPEND_INFO_FILES\n"; for (unsigned int i = 0; i < lGenerators.size(); ++i) { lg = static_cast<cmLocalUnixMakefileGenerator3 *>(lGenerators[i]); @@ -431,22 +473,28 @@ cmGlobalUnixMakefileGenerator3 // The directory-level rule should depend on the target-level rules // for all targets in the directory. std::vector<std::string> depends; - for(cmTargets::iterator l = lg->GetMakefile()->GetTargets().begin(); - l != lg->GetMakefile()->GetTargets().end(); ++l) + cmGeneratorTargetsType targets = lg->GetMakefile()->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator l = targets.begin(); + l != targets.end(); ++l) { - if((l->second.GetType() == cmTarget::EXECUTABLE) || - (l->second.GetType() == cmTarget::STATIC_LIBRARY) || - (l->second.GetType() == cmTarget::SHARED_LIBRARY) || - (l->second.GetType() == cmTarget::MODULE_LIBRARY) || - (l->second.GetType() == cmTarget::OBJECT_LIBRARY) || - (l->second.GetType() == cmTarget::UTILITY)) + if((l->second->GetType() == cmTarget::EXECUTABLE) || + (l->second->GetType() == cmTarget::STATIC_LIBRARY) || + (l->second->GetType() == cmTarget::SHARED_LIBRARY) || + (l->second->GetType() == cmTarget::MODULE_LIBRARY) || + (l->second->GetType() == cmTarget::OBJECT_LIBRARY) || + (l->second->GetType() == cmTarget::UTILITY)) { + if(l->second->Target->IsImported()) + { + continue; + } // Add this to the list of depends rules in this directory. - if((!check_all || !l->second.GetPropertyAsBool("EXCLUDE_FROM_ALL")) && + if((!check_all || !l->second->GetPropertyAsBool("EXCLUDE_FROM_ALL")) && (!check_relink || - l->second.NeedRelinkBeforeInstall(lg->ConfigurationName.c_str()))) + l->second->Target + ->NeedRelinkBeforeInstall(lg->ConfigurationName.c_str()))) { - std::string tname = lg->GetRelativeTargetDirectory(l->second); + std::string tname = lg->GetRelativeTargetDirectory(*l->second->Target); tname += "/"; tname += pass; depends.push_back(tname); @@ -514,36 +562,29 @@ cmGlobalUnixMakefileGenerator3 this->WriteDirectoryRule2(ruleFileStream, lg, "preinstall", true, true); } - -std::string cmGlobalUnixMakefileGenerator3 -::GenerateBuildCommand(const char* makeProgram, const char *projectName, - const char *projectDir, const char* additionalOptions, - const char *targetName, const char* config, - bool ignoreErrors, bool fast) +//---------------------------------------------------------------------------- +void cmGlobalUnixMakefileGenerator3 +::GenerateBuildCommand(std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* /*projectName*/, + const char* /*projectDir*/, + const char* targetName, + const char* /*config*/, + bool fast, + std::vector<std::string> const& makeOptions) { - // Project name & dir and config are not used yet. - (void)projectName; - (void)projectDir; - (void)config; - - std::string makeCommand = - cmSystemTools::ConvertToUnixOutputPath(makeProgram); + makeCommand.push_back( + this->SelectMakeProgram(makeProgram) + ); // Since we have full control over the invocation of nmake, let us // make it quiet. if ( strcmp(this->GetName(), "NMake Makefiles") == 0 ) { - makeCommand += " /NOLOGO "; - } - if ( ignoreErrors ) - { - makeCommand += " -i"; - } - if ( additionalOptions ) - { - makeCommand += " "; - makeCommand += additionalOptions; + makeCommand.push_back("/NOLOGO"); } + makeCommand.insert(makeCommand.end(), + makeOptions.begin(), makeOptions.end()); if ( targetName && strlen(targetName)) { cmLocalUnixMakefileGenerator3 *lg; @@ -564,22 +605,19 @@ std::string cmGlobalUnixMakefileGenerator3 lg->GetMakefile()->MakeStartDirectoriesCurrent(); } - makeCommand += " \""; std::string tname = targetName; if(fast) { tname += "/fast"; } - tname = lg->Convert(tname.c_str(),cmLocalGenerator::HOME_OUTPUT, - cmLocalGenerator::MAKEFILE); - makeCommand += tname.c_str(); - makeCommand += "\""; + tname = lg->Convert(tname.c_str(),cmLocalGenerator::HOME_OUTPUT); + cmSystemTools::ConvertToOutputSlashes(tname); + makeCommand.push_back(tname); if (!this->LocalGenerators.size()) { delete lg; } } - return makeCommand; } //---------------------------------------------------------------------------- @@ -601,44 +639,50 @@ cmGlobalUnixMakefileGenerator3 lg = static_cast<cmLocalUnixMakefileGenerator3 *> (this->LocalGenerators[i]); // for each target Generate the rule files for each target. - cmTargets& targets = lg->GetMakefile()->GetTargets(); - for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) + cmGeneratorTargetsType targets = lg->GetMakefile()->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator t = targets.begin(); + t != targets.end(); ++t) { + if(t->second->Target->IsImported()) + { + continue; + } // Don't emit the same rule twice (e.g. two targets with the same // simple name) - if(t->second.GetName() && - strlen(t->second.GetName()) && - emitted.insert(t->second.GetName()).second && + if(t->second->GetName() && + strlen(t->second->GetName()) && + emitted.insert(t->second->GetName()).second && // Handle user targets here. Global targets are handled in // the local generator on a per-directory basis. - ((t->second.GetType() == cmTarget::EXECUTABLE) || - (t->second.GetType() == cmTarget::STATIC_LIBRARY) || - (t->second.GetType() == cmTarget::SHARED_LIBRARY) || - (t->second.GetType() == cmTarget::MODULE_LIBRARY) || - (t->second.GetType() == cmTarget::OBJECT_LIBRARY) || - (t->second.GetType() == cmTarget::UTILITY))) + ((t->second->GetType() == cmTarget::EXECUTABLE) || + (t->second->GetType() == cmTarget::STATIC_LIBRARY) || + (t->second->GetType() == cmTarget::SHARED_LIBRARY) || + (t->second->GetType() == cmTarget::MODULE_LIBRARY) || + (t->second->GetType() == cmTarget::OBJECT_LIBRARY) || + (t->second->GetType() == cmTarget::UTILITY))) { // Add a rule to build the target by name. lg->WriteDivider(ruleFileStream); ruleFileStream << "# Target rules for targets named " - << t->second.GetName() << "\n\n"; + << t->second->GetName() << "\n\n"; // Write the rule. commands.clear(); std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash(); tmp += "Makefile2"; commands.push_back(lg->GetRecursiveMakeCall - (tmp.c_str(),t->second.GetName())); + (tmp.c_str(),t->second->GetName())); depends.clear(); depends.push_back("cmake_check_build_system"); lg->WriteMakeRule(ruleFileStream, "Build rule for target.", - t->second.GetName(), depends, commands, + t->second->GetName(), depends, commands, true); // Add a fast rule to build the target - std::string localName = lg->GetRelativeTargetDirectory(t->second); + std::string localName = + lg->GetRelativeTargetDirectory(*t->second->Target); std::string makefileName; makefileName = localName; makefileName += "/build.make"; @@ -646,7 +690,7 @@ cmGlobalUnixMakefileGenerator3 commands.clear(); std::string makeTargetName = localName; makeTargetName += "/build"; - localName = t->second.GetName(); + localName = t->second->GetName(); localName += "/fast"; commands.push_back(lg->GetRecursiveMakeCall (makefileName.c_str(), makeTargetName.c_str())); @@ -655,11 +699,12 @@ cmGlobalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. - if(t->second.NeedRelinkBeforeInstall(lg->ConfigurationName.c_str())) + if(t->second->Target + ->NeedRelinkBeforeInstall(lg->ConfigurationName.c_str())) { - makeTargetName = lg->GetRelativeTargetDirectory(t->second); + makeTargetName = lg->GetRelativeTargetDirectory(*t->second->Target); makeTargetName += "/preinstall"; - localName = t->second.GetName(); + localName = t->second->GetName(); localName += "/preinstall"; depends.clear(); commands.clear(); @@ -693,25 +738,30 @@ cmGlobalUnixMakefileGenerator3 depends.push_back("cmake_check_build_system"); // for each target Generate the rule files for each target. - cmTargets& targets = lg->GetMakefile()->GetTargets(); - for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) + cmGeneratorTargetsType targets = lg->GetMakefile()->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator t = targets.begin(); + t != targets.end(); ++t) { - if (t->second.GetName() - && strlen(t->second.GetName()) - && ((t->second.GetType() == cmTarget::EXECUTABLE) - || (t->second.GetType() == cmTarget::STATIC_LIBRARY) - || (t->second.GetType() == cmTarget::SHARED_LIBRARY) - || (t->second.GetType() == cmTarget::MODULE_LIBRARY) - || (t->second.GetType() == cmTarget::OBJECT_LIBRARY) - || (t->second.GetType() == cmTarget::UTILITY))) + if(t->second->Target->IsImported()) + { + continue; + } + if (t->second->GetName() + && strlen(t->second->GetName()) + && ((t->second->GetType() == cmTarget::EXECUTABLE) + || (t->second->GetType() == cmTarget::STATIC_LIBRARY) + || (t->second->GetType() == cmTarget::SHARED_LIBRARY) + || (t->second->GetType() == cmTarget::MODULE_LIBRARY) + || (t->second->GetType() == cmTarget::OBJECT_LIBRARY) + || (t->second->GetType() == cmTarget::UTILITY))) { std::string makefileName; // Add a rule to build the target by name. - localName = lg->GetRelativeTargetDirectory(t->second); + localName = lg->GetRelativeTargetDirectory(*t->second->Target); makefileName = localName; makefileName += "/build.make"; - bool needRequiresStep = this->NeedRequiresStep(t->second); + bool needRequiresStep = this->NeedRequiresStep(*t->second->Target); lg->WriteDivider(ruleFileStream); ruleFileStream @@ -730,12 +780,12 @@ cmGlobalUnixMakefileGenerator3 makeTargetName = localName; makeTargetName += "/requires"; commands.push_back(lg->GetRecursiveMakeCall - (makefileName.c_str(),makeTargetName.c_str())); + (makefileName.c_str(),makeTargetName.c_str())); } makeTargetName = localName; makeTargetName += "/build"; commands.push_back(lg->GetRecursiveMakeCall - (makefileName.c_str(),makeTargetName.c_str())); + (makefileName.c_str(),makeTargetName.c_str())); // Write the rule. localName += "/all"; @@ -753,7 +803,7 @@ cmGlobalUnixMakefileGenerator3 cmLocalGenerator::SHELL); progCmd << " "; std::vector<unsigned long>& progFiles = - this->ProgressMap[&t->second].Marks; + this->ProgressMap[t->second->Target].Marks; for (std::vector<unsigned long>::iterator i = progFiles.begin(); i != progFiles.end(); ++i) { @@ -762,15 +812,15 @@ cmGlobalUnixMakefileGenerator3 commands.push_back(progCmd.str()); } progressDir = "Built target "; - progressDir += t->first; + progressDir += t->second->GetName(); lg->AppendEcho(commands,progressDir.c_str()); - this->AppendGlobalTargetDepends(depends,t->second); + this->AppendGlobalTargetDepends(depends,*t->second->Target); lg->WriteMakeRule(ruleFileStream, "All Build rule for target.", localName.c_str(), depends, commands, true); // add the all/all dependency - if(!this->IsExcluded(this->LocalGenerators[0], t->second)) + if(!this->IsExcluded(this->LocalGenerators[0], *t->second->Target)) { depends.clear(); depends.push_back(localName); @@ -793,9 +843,9 @@ cmGlobalUnixMakefileGenerator3 cmLocalGenerator::FULL, cmLocalGenerator::SHELL); // - std::set<cmTarget *> emitted; + std::set<cmTarget const*> emitted; progCmd << " " - << this->CountProgressMarksInTarget(&t->second, emitted); + << this->CountProgressMarksInTarget(t->second->Target, emitted); commands.push_back(progCmd.str()); } std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash(); @@ -813,7 +863,7 @@ cmGlobalUnixMakefileGenerator3 } depends.clear(); depends.push_back("cmake_check_build_system"); - localName = lg->GetRelativeTargetDirectory(t->second); + localName = lg->GetRelativeTargetDirectory(*t->second->Target); localName += "/rule"; lg->WriteMakeRule(ruleFileStream, "Build rule for subdir invocation for target.", @@ -824,12 +874,13 @@ cmGlobalUnixMakefileGenerator3 depends.clear(); depends.push_back(localName); lg->WriteMakeRule(ruleFileStream, "Convenience name for target.", - t->second.GetName(), depends, commands, true); + t->second->GetName(), depends, commands, true); // Add rules to prepare the target for installation. - if(t->second.NeedRelinkBeforeInstall(lg->ConfigurationName.c_str())) + if(t->second->Target + ->NeedRelinkBeforeInstall(lg->ConfigurationName.c_str())) { - localName = lg->GetRelativeTargetDirectory(t->second); + localName = lg->GetRelativeTargetDirectory(*t->second->Target); localName += "/preinstall"; depends.clear(); commands.clear(); @@ -839,7 +890,7 @@ cmGlobalUnixMakefileGenerator3 "Pre-install relink rule for target.", localName.c_str(), depends, commands, true); - if(!this->IsExcluded(this->LocalGenerators[0], t->second)) + if(!this->IsExcluded(this->LocalGenerators[0], *t->second->Target)) { depends.clear(); depends.push_back(localName); @@ -850,7 +901,7 @@ cmGlobalUnixMakefileGenerator3 } // add the clean rule - localName = lg->GetRelativeTargetDirectory(t->second); + localName = lg->GetRelativeTargetDirectory(*t->second->Target); makeTargetName = localName; makeTargetName += "/clean"; depends.clear(); @@ -870,8 +921,8 @@ cmGlobalUnixMakefileGenerator3 //---------------------------------------------------------------------------- size_t cmGlobalUnixMakefileGenerator3 -::CountProgressMarksInTarget(cmTarget* target, - std::set<cmTarget*>& emitted) +::CountProgressMarksInTarget(cmTarget const* target, + std::set<cmTarget const*>& emitted) { size_t count = 0; if(emitted.insert(target).second) @@ -881,6 +932,10 @@ cmGlobalUnixMakefileGenerator3 for(TargetDependSet::const_iterator di = depends.begin(); di != depends.end(); ++di) { + if ((*di)->GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } count += this->CountProgressMarksInTarget(*di, emitted); } } @@ -893,9 +948,10 @@ cmGlobalUnixMakefileGenerator3 ::CountProgressMarksInAll(cmLocalUnixMakefileGenerator3* lg) { size_t count = 0; - std::set<cmTarget*> emitted; - std::set<cmTarget*> const& targets = this->LocalGeneratorToTargetMap[lg]; - for(std::set<cmTarget*>::const_iterator t = targets.begin(); + std::set<cmTarget const*> emitted; + std::set<cmTarget const*> const& targets + = this->LocalGeneratorToTargetMap[lg]; + for(std::set<cmTarget const*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { count += this->CountProgressMarksInTarget(*t, emitted); @@ -916,7 +972,7 @@ cmGlobalUnixMakefileGenerator3::RecordTargetProgress( //---------------------------------------------------------------------------- bool cmGlobalUnixMakefileGenerator3::ProgressMapCompare -::operator()(cmTarget* l, cmTarget* r) const +::operator()(cmTarget const* l, cmTarget const* r) const { // Order by target name. if(int c = strcmp(l->GetName(), r->GetName())) @@ -967,6 +1023,10 @@ cmGlobalUnixMakefileGenerator3 { // Create the target-level dependency. cmTarget const* dep = *i; + if (dep->GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } cmLocalUnixMakefileGenerator3* lg3 = static_cast<cmLocalUnixMakefileGenerator3*> (dep->GetMakefile()->GetLocalGenerator()); diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 5e9dce3..9173751 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -77,6 +77,8 @@ public: virtual void EnableLanguage(std::vector<std::string>const& languages, cmMakefile *, bool optional); + virtual void Configure(); + /** * Generate the all required files for building this project/tree. This * basically creates a series of LocalGenerators for each directory and @@ -105,12 +107,16 @@ public: std::string GetEmptyRuleHackDepends() { return this->EmptyRuleHackDepends; } // change the build command for speed - virtual std::string GenerateBuildCommand - (const char* makeProgram, - const char *projectName, const char *projectDir, - const char* additionalOptions, - const char *targetName, - const char* config, bool ignoreErrors, bool fast); + virtual void GenerateBuildCommand( + std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* projectName, + const char* projectDir, + const char* targetName, + const char* config, + bool fast, + std::vector<std::string> const& makeOptions = std::vector<std::string>() + ); /** Record per-target progress information. */ void RecordTargetProgress(cmMakefileTargetGenerator* tg); @@ -119,6 +125,9 @@ public: const std::string &workingDirectory, const std::string &compileCommand); + /** Does the make tool tolerate .NOTPARALLEL? */ + virtual bool AllowNotParallel() const { return true; } + protected: void WriteMainMakefile2(); void WriteMainCMakefile(); @@ -152,7 +161,7 @@ protected: const char* GetRebuildCacheTargetName() const { return "rebuild_cache"; } const char* GetCleanTargetName() const { return "clean"; } - virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() { return true; } + virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const { return true; } // Some make programs (Borland) do not keep a rule if there are no // dependencies or commands. This is a problem for creating rules @@ -175,17 +184,20 @@ protected: std::vector<unsigned long> Marks; void WriteProgressVariables(unsigned long total, unsigned long& current); }; - struct ProgressMapCompare { bool operator()(cmTarget*,cmTarget*) const; }; - typedef std::map<cmTarget*, TargetProgress, + struct ProgressMapCompare { bool operator()(cmTarget const*, + cmTarget const*) const; }; + typedef std::map<cmTarget const*, TargetProgress, ProgressMapCompare> ProgressMapType; ProgressMapType ProgressMap; - size_t CountProgressMarksInTarget(cmTarget* target, - std::set<cmTarget*>& emitted); + size_t CountProgressMarksInTarget(cmTarget const* target, + std::set<cmTarget const*>& emitted); size_t CountProgressMarksInAll(cmLocalUnixMakefileGenerator3* lg); cmGeneratedFileStream *CommandDatabase; private: + virtual const char* GetBuildIgnoreErrorsFlag() const { return "-i"; } + virtual std::string GetEditCacheCommand() const; virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const; }; diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index b2a337c..6983ef9 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -18,47 +18,65 @@ #include "cmVisualStudioSlnParser.h" #include "cmake.h" -static const char vs10Win32generatorName[] = "Visual Studio 10"; -static const char vs10Win64generatorName[] = "Visual Studio 10 Win64"; -static const char vs10IA64generatorName[] = "Visual Studio 10 IA64"; +static const char vs10generatorName[] = "Visual Studio 10 2010"; + +// Map generator name without year to name with year. +static const char* cmVS10GenName(const char* name, std::string& genName) +{ + if(strncmp(name, vs10generatorName, sizeof(vs10generatorName)-6) != 0) + { + return 0; + } + const char* p = name + sizeof(vs10generatorName) - 6; + if(cmHasLiteralPrefix(p, " 2010")) + { + p += 5; + } + genName = std::string(vs10generatorName) + p; + return p; +} class cmGlobalVisualStudio10Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { - if(!strcmp(name, vs10Win32generatorName)) + virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const + { + std::string genName; + const char* p = cmVS10GenName(name, genName); + if(!p) + { return 0; } + name = genName.c_str(); + if(strcmp(p, "") == 0) { return new cmGlobalVisualStudio10Generator( name, NULL, NULL); } - if(!strcmp(name, vs10Win64generatorName)) + if(strcmp(p, " Win64") == 0) { return new cmGlobalVisualStudio10Generator( name, "x64", "CMAKE_FORCE_WIN64"); } - if(!strcmp(name, vs10IA64generatorName)) + if(strcmp(p, " IA64") == 0) { return new cmGlobalVisualStudio10Generator( name, "Itanium", "CMAKE_FORCE_IA64"); } return 0; - } + } - virtual void GetDocumentation(cmDocumentationEntry& entry) const { - entry.Name = "Visual Studio 10"; - entry.Brief = "Generates Visual Studio 10 (2010) project files."; - entry.Full = - "It is possible to append a space followed by the platform name " - "to create project files for a specific target platform. E.g. " - "\"Visual Studio 10 Win64\" will create project files for " - "the x64 processor; \"Visual Studio 10 IA64\" for Itanium."; - } + virtual void GetDocumentation(cmDocumentationEntry& entry) const + { + entry.Name = vs10generatorName; + entry.Brief = "Generates Visual Studio 10 (VS 2010) project files."; + } - virtual void GetGenerators(std::vector<std::string>& names) const { - names.push_back(vs10Win32generatorName); - names.push_back(vs10Win64generatorName); - names.push_back(vs10IA64generatorName); } + virtual void GetGenerators(std::vector<std::string>& names) const + { + names.push_back(vs10generatorName); + names.push_back(vs10generatorName + std::string(" IA64")); + names.push_back(vs10generatorName + std::string(" Win64")); + } }; //---------------------------------------------------------------------------- @@ -74,12 +92,24 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator( : cmGlobalVisualStudio8Generator(name, platformName, additionalPlatformDefinition) { - this->FindMakeProgramFile = "CMakeVS10FindMake.cmake"; std::string vc10Express; this->ExpressEdition = cmSystemTools::ReadRegistryValue( "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\10.0\\Setup\\VC;" "ProductDir", vc10Express, cmSystemTools::KeyWOW64_32); this->MasmEnabled = false; + this->MSBuildCommandInitialized = false; +} + +//---------------------------------------------------------------------------- +bool +cmGlobalVisualStudio10Generator::MatchesGeneratorName(const char* name) const +{ + std::string genName; + if(cmVS10GenName(name, genName)) + { + return genName == this->GetName(); + } + return false; } //---------------------------------------------------------------------------- @@ -225,50 +255,129 @@ std::string cmGlobalVisualStudio10Generator::GetUserMacrosRegKeyBase() return "Software\\Microsoft\\VisualStudio\\10.0\\vsmacros"; } +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio10Generator::FindMakeProgram(cmMakefile* mf) +{ + this->cmGlobalVisualStudio8Generator::FindMakeProgram(mf); + mf->AddDefinition("CMAKE_VS_MSBUILD_COMMAND", + this->GetMSBuildCommand().c_str()); +} + +//---------------------------------------------------------------------------- +std::string const& cmGlobalVisualStudio10Generator::GetMSBuildCommand() +{ + if(!this->MSBuildCommandInitialized) + { + this->MSBuildCommandInitialized = true; + this->MSBuildCommand = this->FindMSBuildCommand(); + } + return this->MSBuildCommand; +} + +//---------------------------------------------------------------------------- +std::string cmGlobalVisualStudio10Generator::FindMSBuildCommand() +{ + std::string msbuild; + std::string mskey = + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\"; + mskey += this->GetToolsVersion(); + mskey += ";MSBuildToolsPath"; + if(cmSystemTools::ReadRegistryValue(mskey.c_str(), msbuild, + cmSystemTools::KeyWOW64_32)) + { + cmSystemTools::ConvertToUnixSlashes(msbuild); + msbuild += "/"; + } + msbuild += "MSBuild.exe"; + return msbuild; +} -std::string cmGlobalVisualStudio10Generator -::GenerateBuildCommand(const char* makeProgram, - const char *projectName, const char *projectDir, - const char* additionalOptions, const char *targetName, - const char* config, bool ignoreErrors, bool fast) +//---------------------------------------------------------------------------- +std::string cmGlobalVisualStudio10Generator::FindDevEnvCommand() { - // now build the test - std::string makeCommand - = cmSystemTools::ConvertToOutputPath(makeProgram); - std::string lowerCaseCommand = makeCommand; - cmSystemTools::LowerCase(lowerCaseCommand); - - // If makeProgram is devenv, parent class knows how to generate command: - if (lowerCaseCommand.find("devenv") != std::string::npos || - lowerCaseCommand.find("VCExpress") != std::string::npos) + if(this->ExpressEdition) { - return cmGlobalVisualStudio7Generator::GenerateBuildCommand(makeProgram, - projectName, projectDir, additionalOptions, targetName, config, - ignoreErrors, fast); + // Visual Studio Express >= 10 do not have "devenv.com" or + // "VCExpress.exe" that we can use to build reliably. + // Tell the caller it needs to use MSBuild instead. + return ""; } + // Skip over the cmGlobalVisualStudio8Generator implementation because + // we expect a real devenv and do not want to look for VCExpress. + return this->cmGlobalVisualStudio71Generator::FindDevEnvCommand(); +} - // Otherwise, assume MSBuild command line, and construct accordingly. +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio10Generator::GenerateBuildCommand( + std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* projectName, + const char* projectDir, + const char* targetName, + const char* config, + bool fast, + std::vector<std::string> const& makeOptions) +{ + // Select the caller- or user-preferred make program, else MSBuild. + std::string makeProgramSelected = + this->SelectMakeProgram(makeProgram, this->GetMSBuildCommand()); - // if there are spaces in the makeCommand, assume a full path - // and convert it to a path with no spaces in it as the - // RunSingleCommand does not like spaces - if(makeCommand.find(' ') != std::string::npos) + // Check if the caller explicitly requested a devenv tool. + std::string makeProgramLower = makeProgramSelected; + cmSystemTools::LowerCase(makeProgramLower); + bool useDevEnv = + (makeProgramLower.find("devenv") != std::string::npos || + makeProgramLower.find("vcexpress") != std::string::npos); + + // MSBuild is preferred (and required for VS Express), but if the .sln has + // an Intel Fortran .vfproj then we have to use devenv. Parse it to find out. + cmSlnData slnData; + { + std::string slnFile; + if(projectDir && *projectDir) + { + slnFile = projectDir; + slnFile += "/"; + } + slnFile += projectName; + slnFile += ".sln"; + cmVisualStudioSlnParser parser; + if(parser.ParseFile(slnFile, slnData, + cmVisualStudioSlnParser::DataGroupProjects)) { - cmSystemTools::GetShortPath(makeCommand.c_str(), makeCommand); + std::vector<cmSlnProjectEntry> slnProjects = slnData.GetProjects(); + for(std::vector<cmSlnProjectEntry>::iterator i = slnProjects.begin(); + !useDevEnv && i != slnProjects.end(); ++i) + { + std::string proj = i->GetRelativePath(); + if(proj.size() > 7 && + proj.substr(proj.size()-7) == ".vfproj") + { + useDevEnv = true; + } + } } + } + if(useDevEnv) + { + // Use devenv to build solutions containing Intel Fortran projects. + cmGlobalVisualStudio7Generator::GenerateBuildCommand( + makeCommand, makeProgram, projectName, projectDir, + targetName, config, fast, makeOptions); + return; + } + + makeCommand.push_back(makeProgramSelected); + // msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD if(!targetName || strlen(targetName) == 0) { targetName = "ALL_BUILD"; } - bool clean = false; if ( targetName && strcmp(targetName, "clean") == 0 ) { - clean = true; - makeCommand += " "; - makeCommand += projectName; - makeCommand += ".sln "; - makeCommand += "/t:Clean "; + makeCommand.push_back(std::string(projectName)+".sln"); + makeCommand.push_back("/t:Clean"); } else { @@ -277,51 +386,29 @@ std::string cmGlobalVisualStudio10Generator if (targetProject.find('/') == std::string::npos) { // it might be in a subdir - cmVisualStudioSlnParser parser; - cmSlnData slnData; - std::string slnFile; - if (projectDir && *projectDir) - { - slnFile = projectDir; - slnFile += '/'; - slnFile += projectName; - } - else + if (cmSlnProjectEntry const* proj = + slnData.GetProjectByName(targetName)) { - slnFile = projectName; - } - if (parser.ParseFile(slnFile + ".sln", slnData, - cmVisualStudioSlnParser::DataGroupProjects)) - { - if (cmSlnProjectEntry const* proj = - slnData.GetProjectByName(targetName)) - { - targetProject = proj->GetRelativePath(); - cmSystemTools::ConvertToUnixSlashes(targetProject); - } + targetProject = proj->GetRelativePath(); + cmSystemTools::ConvertToUnixSlashes(targetProject); } } - makeCommand += " "; - makeCommand += targetProject; - makeCommand += " "; + makeCommand.push_back(targetProject); } - makeCommand += "/p:Configuration="; + std::string configArg = "/p:Configuration="; if(config && strlen(config)) { - makeCommand += config; + configArg += config; } else { - makeCommand += "Debug"; - } - makeCommand += " /p:VisualStudioVersion="; - makeCommand += this->GetIDEVersion(); - if ( additionalOptions ) - { - makeCommand += " "; - makeCommand += additionalOptions; + configArg += "Debug"; } - return makeCommand; + makeCommand.push_back(configArg); + makeCommand.push_back(std::string("/p:VisualStudioVersion=")+ + this->GetIDEVersion()); + makeCommand.insert(makeCommand.end(), + makeOptions.begin(), makeOptions.end()); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 31e122e..976d41f 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -28,13 +28,20 @@ public: const char* platformName, const char* additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); + virtual bool MatchesGeneratorName(const char* name) const; + virtual bool SetGeneratorToolset(std::string const& ts); - virtual std::string - GenerateBuildCommand(const char* makeProgram, - const char *projectName, const char *projectDir, - const char* additionalOptions, const char *targetName, - const char* config, bool ignoreErrors, bool); + virtual void GenerateBuildCommand( + std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* projectName, + const char* projectDir, + const char* targetName, + const char* config, + bool fast, + std::vector<std::string> const& makeOptions = std::vector<std::string>() + ); virtual void AddPlatformDefinitions(cmMakefile* mf); @@ -84,9 +91,13 @@ public: virtual const char* GetToolsVersion() { return "4.0"; } + virtual void FindMakeProgram(cmMakefile*); + protected: virtual const char* GetIDEVersion() { return "10.0"; } + std::string const& GetMSBuildCommand(); + std::string PlatformToolset; bool ExpressEdition; bool MasmEnabled; @@ -104,5 +115,11 @@ private: std::string SourceRel; }; LongestSourcePath LongestSource; + + std::string MSBuildCommand; + bool MSBuildCommandInitialized; + virtual std::string FindMSBuildCommand(); + virtual std::string FindDevEnvCommand(); + virtual std::string GetVSMakeProgram() { return this->GetMSBuildCommand(); } }; #endif diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 8ae7331..1f0c47a 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -13,42 +13,54 @@ #include "cmLocalVisualStudio10Generator.h" #include "cmMakefile.h" -static const char vs11generatorName[] = "Visual Studio 11"; +static const char vs11generatorName[] = "Visual Studio 11 2012"; + +// Map generator name without year to name with year. +static const char* cmVS11GenName(const char* name, std::string& genName) +{ + if(strncmp(name, vs11generatorName, sizeof(vs11generatorName)-6) != 0) + { + return 0; + } + const char* p = name + sizeof(vs11generatorName) - 6; + if(cmHasLiteralPrefix(p, " 2012")) + { + p += 5; + } + genName = std::string(vs11generatorName) + p; + return p; +} class cmGlobalVisualStudio11Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { - if(strstr(name, vs11generatorName) != name) - { - return 0; - } - - const char* p = name + sizeof(vs11generatorName) - 1; - if(p[0] == '\0') + virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const + { + std::string genName; + const char* p = cmVS11GenName(name, genName); + if(!p) + { return 0; } + name = genName.c_str(); + if(strcmp(p, "") == 0) { return new cmGlobalVisualStudio11Generator( name, NULL, NULL); } - - if(p[0] != ' ') + if(strcmp(p, " Win64") == 0) { - return 0; + return new cmGlobalVisualStudio11Generator( + name, "x64", "CMAKE_FORCE_WIN64"); } - - ++p; - - if(!strcmp(p, "ARM")) + if(strcmp(p, " ARM") == 0) { return new cmGlobalVisualStudio11Generator( name, "ARM", NULL); } - if(!strcmp(p, "Win64")) + if(*p++ != ' ') { - return new cmGlobalVisualStudio11Generator( - name, "x64", "CMAKE_FORCE_WIN64"); + return 0; } std::set<std::string> installedSDKs = @@ -63,19 +75,16 @@ public: new cmGlobalVisualStudio11Generator(name, p, NULL); ret->WindowsCEVersion = "8.00"; return ret; - } - - virtual void GetDocumentation(cmDocumentationEntry& entry) const { - entry.Name = "Visual Studio 11"; - entry.Brief = "Generates Visual Studio 11 (2012) project files."; - entry.Full = - "It is possible to append a space followed by the platform name " - "to create project files for a specific target platform. E.g. " - "\"Visual Studio 11 Win64\" will create project files for " - "the x64 processor; \"Visual Studio 11 ARM\" for ARM."; - } - - virtual void GetGenerators(std::vector<std::string>& names) const { + } + + virtual void GetDocumentation(cmDocumentationEntry& entry) const + { + entry.Name = vs11generatorName; + entry.Brief = "Generates Visual Studio 11 (VS 2012) project files."; + } + + virtual void GetGenerators(std::vector<std::string>& names) const + { names.push_back(vs11generatorName); names.push_back(vs11generatorName + std::string(" ARM")); names.push_back(vs11generatorName + std::string(" Win64")); @@ -85,9 +94,9 @@ public: for(std::set<std::string>::const_iterator i = installedSDKs.begin(); i != installedSDKs.end(); ++i) { - names.push_back("Visual Studio 11 " + *i); + names.push_back(std::string(vs11generatorName) + " " + *i); } - } + } }; //---------------------------------------------------------------------------- @@ -103,7 +112,6 @@ cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator( : cmGlobalVisualStudio10Generator(name, platformName, additionalPlatformDefinition) { - this->FindMakeProgramFile = "CMakeVS11FindMake.cmake"; std::string vc11Express; this->ExpressEdition = cmSystemTools::ReadRegistryValue( "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\11.0\\Setup\\VC;" @@ -112,6 +120,18 @@ cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator( } //---------------------------------------------------------------------------- +bool +cmGlobalVisualStudio11Generator::MatchesGeneratorName(const char* name) const +{ + std::string genName; + if(cmVS11GenName(name, genName)) + { + return genName == this->GetName(); + } + return false; +} + +//---------------------------------------------------------------------------- void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout) { fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n"; diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index 7cc7e69..7ef77e7 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -24,6 +24,8 @@ public: const char* platformName, const char* additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); + virtual bool MatchesGeneratorName(const char* name) const; + virtual void WriteSLNHeader(std::ostream& fout); ///! create the correct local generator diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx index c56dfff..3074794 100644 --- a/Source/cmGlobalVisualStudio12Generator.cxx +++ b/Source/cmGlobalVisualStudio12Generator.cxx @@ -13,47 +13,65 @@ #include "cmLocalVisualStudio10Generator.h" #include "cmMakefile.h" -static const char vs12Win32generatorName[] = "Visual Studio 12"; -static const char vs12Win64generatorName[] = "Visual Studio 12 Win64"; -static const char vs12ARMgeneratorName[] = "Visual Studio 12 ARM"; +static const char vs12generatorName[] = "Visual Studio 12 2013"; + +// Map generator name without year to name with year. +static const char* cmVS12GenName(const char* name, std::string& genName) +{ + if(strncmp(name, vs12generatorName, sizeof(vs12generatorName)-6) != 0) + { + return 0; + } + const char* p = name + sizeof(vs12generatorName) - 6; + if(cmHasLiteralPrefix(p, " 2013")) + { + p += 5; + } + genName = std::string(vs12generatorName) + p; + return p; +} class cmGlobalVisualStudio12Generator::Factory : public cmGlobalGeneratorFactory { public: - virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const { - if(!strcmp(name, vs12Win32generatorName)) + virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const + { + std::string genName; + const char* p = cmVS12GenName(name, genName); + if(!p) + { return 0; } + name = genName.c_str(); + if(strcmp(p, "") == 0) { return new cmGlobalVisualStudio12Generator( name, NULL, NULL); } - if(!strcmp(name, vs12Win64generatorName)) + if(strcmp(p, " Win64") == 0) { return new cmGlobalVisualStudio12Generator( name, "x64", "CMAKE_FORCE_WIN64"); } - if(!strcmp(name, vs12ARMgeneratorName)) + if(strcmp(p, " ARM") == 0) { return new cmGlobalVisualStudio12Generator( name, "ARM", NULL); } return 0; - } + } - virtual void GetDocumentation(cmDocumentationEntry& entry) const { - entry.Name = "Visual Studio 12"; - entry.Brief = "Generates Visual Studio 12 (2013) project files."; - entry.Full = - "It is possible to append a space followed by the platform name " - "to create project files for a specific target platform. E.g. " - "\"Visual Studio 12 Win64\" will create project files for " - "the x64 processor; \"Visual Studio 12 ARM\" for ARM."; - } + virtual void GetDocumentation(cmDocumentationEntry& entry) const + { + entry.Name = vs12generatorName; + entry.Brief = "Generates Visual Studio 12 (VS 2013) project files."; + } - virtual void GetGenerators(std::vector<std::string>& names) const { - names.push_back(vs12Win32generatorName); - names.push_back(vs12Win64generatorName); - names.push_back(vs12ARMgeneratorName); } + virtual void GetGenerators(std::vector<std::string>& names) const + { + names.push_back(vs12generatorName); + names.push_back(vs12generatorName + std::string(" ARM")); + names.push_back(vs12generatorName + std::string(" Win64")); + } }; //---------------------------------------------------------------------------- @@ -69,7 +87,6 @@ cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator( : cmGlobalVisualStudio11Generator(name, platformName, additionalPlatformDefinition) { - this->FindMakeProgramFile = "CMakeVS12FindMake.cmake"; std::string vc12Express; this->ExpressEdition = cmSystemTools::ReadRegistryValue( "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\12.0\\Setup\\VC;" @@ -78,6 +95,18 @@ cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator( } //---------------------------------------------------------------------------- +bool +cmGlobalVisualStudio12Generator::MatchesGeneratorName(const char* name) const +{ + std::string genName; + if(cmVS12GenName(name, genName)) + { + return genName == this->GetName(); + } + return false; +} + +//---------------------------------------------------------------------------- void cmGlobalVisualStudio12Generator::WriteSLNHeader(std::ostream& fout) { fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n"; diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h index 8c8aeb1..5a4a78d 100644 --- a/Source/cmGlobalVisualStudio12Generator.h +++ b/Source/cmGlobalVisualStudio12Generator.h @@ -24,6 +24,8 @@ public: const char* platformName, const char* additionalPlatformDefinition); static cmGlobalGeneratorFactory* NewFactory(); + virtual bool MatchesGeneratorName(const char* name) const; + virtual void WriteSLNHeader(std::ostream& fout); ///! create the correct local generator diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index b3fabda..6c458c3 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -14,6 +14,7 @@ #include "cmMakefile.h" #include "cmake.h" #include "cmGeneratedFileStream.h" +#include <cmsys/FStream.hxx> // Utility function to make a valid VS6 *.dsp filename out // of a CMake target name: @@ -32,7 +33,7 @@ std::string GetVS6TargetName(const std::string& targetName) cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator() { - this->FindMakeProgramFile = "CMakeVS6FindMake.cmake"; + this->MSDevCommandInitialized = false; } void cmGlobalVisualStudio6Generator @@ -77,52 +78,61 @@ void cmGlobalVisualStudio6Generator::GenerateConfigurations(cmMakefile* mf) } } -std::string cmGlobalVisualStudio6Generator -::GenerateBuildCommand(const char* makeProgram, - const char *projectName, - const char *projectDir, - const char* additionalOptions, - const char *targetName, - const char* config, - bool ignoreErrors, - bool) +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio6Generator::FindMakeProgram(cmMakefile* mf) { - // Visual studio 6 doesn't need project dir - (void) projectDir; - // Ingoring errors is not implemented in visual studio 6 - (void) ignoreErrors; + this->cmGlobalVisualStudioGenerator::FindMakeProgram(mf); + mf->AddDefinition("CMAKE_VS_MSDEV_COMMAND", + this->GetMSDevCommand().c_str()); +} - // now build the test - std::vector<std::string> mp; - mp.push_back("[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio" - "\\6.0\\Setup;VsCommonDir]/MSDev98/Bin"); - cmSystemTools::ExpandRegistryValues(mp[0]); - std::string originalCommand = makeProgram; - std::string makeCommand = - cmSystemTools::FindProgram(makeProgram, mp); - if(makeCommand.size() == 0) +//---------------------------------------------------------------------------- +std::string const& cmGlobalVisualStudio6Generator::GetMSDevCommand() +{ + if(!this->MSDevCommandInitialized) { - std::string e = "Generator cannot find Visual Studio 6 msdev program \""; - e += originalCommand; - e += "\" specified by CMAKE_MAKE_PROGRAM cache entry. "; - e += "Please fix the setting."; - cmSystemTools::Error(e.c_str()); - return ""; + this->MSDevCommandInitialized = true; + this->MSDevCommand = this->FindMSDevCommand(); } - makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str()); + return this->MSDevCommand; +} - // if there are spaces in the makeCommand, assume a full path - // and convert it to a path with no spaces in it as the - // RunSingleCommand does not like spaces -#if defined(_WIN32) && !defined(__CYGWIN__) - if(makeCommand.find(' ') != std::string::npos) +//---------------------------------------------------------------------------- +std::string cmGlobalVisualStudio6Generator::FindMSDevCommand() +{ + std::string vscmd; + std::string vskey = this->GetRegistryBase() + "\\Setup;VsCommonDir"; + if(cmSystemTools::ReadRegistryValue(vskey.c_str(), vscmd, + cmSystemTools::KeyWOW64_32)) { - cmSystemTools::GetShortPath(makeCommand.c_str(), makeCommand); + cmSystemTools::ConvertToUnixSlashes(vscmd); + vscmd += "/MSDev98/Bin/"; } -#endif - makeCommand += " "; - makeCommand += projectName; - makeCommand += ".dsw /MAKE \""; + vscmd += "msdev.exe"; + return vscmd; +} + +//---------------------------------------------------------------------------- +void +cmGlobalVisualStudio6Generator::GenerateBuildCommand( + std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* projectName, + const char* /*projectDir*/, + const char* targetName, + const char* config, + bool /*fast*/, + std::vector<std::string> const& makeOptions + ) +{ + // now build the test + makeCommand.push_back( + this->SelectMakeProgram(makeProgram, this->GetMSDevCommand()) + ); + + makeCommand.push_back(std::string(projectName)+".dsw"); + makeCommand.push_back("/MAKE"); + std::string targetArg; bool clean = false; if ( targetName && strcmp(targetName, "clean") == 0 ) { @@ -131,35 +141,32 @@ std::string cmGlobalVisualStudio6Generator } if (targetName && strlen(targetName)) { - makeCommand += targetName; + targetArg += targetName; } else { - makeCommand += "ALL_BUILD"; + targetArg += "ALL_BUILD"; } - makeCommand += " - "; + targetArg += " - "; if(config && strlen(config)) { - makeCommand += config; + targetArg += config; } else { - makeCommand += "Debug"; + targetArg += "Debug"; } + makeCommand.push_back(targetArg); if(clean) { - makeCommand += "\" /CLEAN"; + makeCommand.push_back("/CLEAN"); } else { - makeCommand += "\" /BUILD"; + makeCommand.push_back("/BUILD"); } - if ( additionalOptions ) - { - makeCommand += " "; - makeCommand += additionalOptions; - } - return makeCommand; + makeCommand.insert(makeCommand.end(), + makeOptions.begin(), makeOptions.end()); } ///! Create a local generator appropriate to this Global Generator @@ -199,7 +206,11 @@ void cmGlobalVisualStudio6Generator tt = orderedProjectTargets.begin(); tt != orderedProjectTargets.end(); ++tt) { - cmTarget* target = *tt; + cmTarget const* target = *tt; + if(target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } // Write the project into the DSW file const char* expath = target->GetProperty("EXTERNAL_MSPROJECT"); if(expath) @@ -234,7 +245,7 @@ void cmGlobalVisualStudio6Generator fname += "/"; fname += root->GetMakefile()->GetProjectName(); fname += ".dsw"; - std::ofstream fout(fname.c_str()); + cmsys::ofstream fout(fname.c_str()); if(!fout) { cmSystemTools::Error("Error can not open DSW file for write: ", @@ -261,7 +272,7 @@ void cmGlobalVisualStudio6Generator::OutputDSWFile() void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout, const char* dspname, const char* dir, - cmTarget& target) + cmTarget const& target) { fout << "#########################################################" "######################\n\n"; @@ -354,7 +365,7 @@ void cmGlobalVisualStudio6Generator::WriteDSWHeader(std::ostream& fout) //---------------------------------------------------------------------------- std::string -cmGlobalVisualStudio6Generator::WriteUtilityDepend(cmTarget* target) +cmGlobalVisualStudio6Generator::WriteUtilityDepend(cmTarget const* target) { std::string pname = target->GetName(); pname += "_UTILITY"; @@ -401,7 +412,6 @@ void cmGlobalVisualStudio6Generator { entry.Name = cmGlobalVisualStudio6Generator::GetActualName(); entry.Brief = "Generates Visual Studio 6 project files."; - entry.Full = ""; } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index 6bd39ca..5521410 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -52,14 +52,16 @@ public: * Try running cmake and building a file. This is used for dynalically * loaded commands, not as part of the usual build process. */ - virtual std::string GenerateBuildCommand(const char* makeProgram, - const char *projectName, - const char *projectDir, - const char* additionalOptions, - const char *targetName, - const char* config, - bool ignoreErrors, - bool fast); + virtual void GenerateBuildCommand( + std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* projectName, + const char* projectDir, + const char* targetName, + const char* config, + bool fast, + std::vector<std::string> const& makeOptions = std::vector<std::string>() + ); /** * Generate the all required files for building this project/tree. This @@ -87,19 +89,26 @@ public: ///! What is the configurations directory variable called? virtual const char* GetCMakeCFGIntDir() const { return "$(IntDir)"; } + virtual void FindMakeProgram(cmMakefile*); + protected: virtual const char* GetIDEVersion() { return "6.0"; } private: + virtual std::string GetVSMakeProgram() { return this->GetMSDevCommand(); } void GenerateConfigurations(cmMakefile* mf); void WriteDSWFile(std::ostream& fout); void WriteDSWHeader(std::ostream& fout); void WriteProject(std::ostream& fout, - const char* name, const char* path, cmTarget &t); + const char* name, const char* path, cmTarget const& t); void WriteExternalProject(std::ostream& fout, const char* name, const char* path, const std::set<cmStdString>& dependencies); void WriteDSWFooter(std::ostream& fout); - virtual std::string WriteUtilityDepend(cmTarget* target); + virtual std::string WriteUtilityDepend(cmTarget const* target); + std::string MSDevCommand; + bool MSDevCommandInitialized; + std::string const& GetMSDevCommand(); + std::string FindMSDevCommand(); }; #endif diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 51efc46..22e4f08 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -19,7 +19,6 @@ cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator( const char* platformName) : cmGlobalVisualStudio7Generator(platformName) { - this->FindMakeProgramFile = "CMakeVS71FindMake.cmake"; this->ProjectConfigurationSectionName = "ProjectConfiguration"; } @@ -158,7 +157,7 @@ void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout, const char* dspname, const char* dir, - cmTarget& t) + cmTarget const& t) { // check to see if this is a fortran build const char* ext = ".vcproj"; @@ -210,7 +209,7 @@ void cmGlobalVisualStudio71Generator ::WriteProjectDepends(std::ostream& fout, const char*, - const char*, cmTarget& target) + const char*, cmTarget const& target) { VSDependSet const& depends = this->VSTargetDepends[&target]; for(VSDependSet::const_iterator di = depends.begin(); @@ -241,7 +240,7 @@ void cmGlobalVisualStudio71Generator const std::set<cmStdString>& depends) { fout << "Project(\"{" - << (typeGuid ? typeGuid : "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942") + << (typeGuid ? typeGuid : this->ExternalProjectType(location)) << "}\") = \"" << name << "\", \"" << this->ConvertToSolutionPath(location) << "\", \"{" @@ -313,5 +312,4 @@ void cmGlobalVisualStudio71Generator { entry.Name = cmGlobalVisualStudio71Generator::GetActualName(); entry.Brief = "Generates Visual Studio .NET 2003 project files."; - entry.Full = ""; } diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index e136db7..04e3a55 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -59,9 +59,11 @@ protected: std::vector<cmLocalGenerator*>& generators); virtual void WriteSolutionConfigurations(std::ostream& fout); virtual void WriteProject(std::ostream& fout, - const char* name, const char* path, cmTarget &t); + const char* name, const char* path, + cmTarget const& t); virtual void WriteProjectDepends(std::ostream& fout, - const char* name, const char* path, cmTarget &t); + const char* name, const char* path, + cmTarget const& t); virtual void WriteProjectConfigurations( std::ostream& fout, const char* name, cmTarget::TargetType type, const std::set<std::string>& configsPartOfDefaultBuild, diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index b475665..bb63289 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -16,11 +16,13 @@ #include "cmLocalVisualStudio7Generator.h" #include "cmMakefile.h" #include "cmake.h" +#include <cmsys/Encoding.hxx> cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator( const char* platformName) { - this->FindMakeProgramFile = "CMakeVS7FindMake.cmake"; + this->IntelProjectVersion = 0; + this->DevEnvCommandInitialized = false; if (!platformName) { @@ -29,6 +31,45 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator( this->PlatformName = platformName; } +cmGlobalVisualStudio7Generator::~cmGlobalVisualStudio7Generator() +{ + free(this->IntelProjectVersion); +} + +// Package GUID of Intel Visual Fortran plugin to VS IDE +#define CM_INTEL_PLUGIN_GUID "{B68A201D-CB9B-47AF-A52F-7EEC72E217E4}" + +const char* cmGlobalVisualStudio7Generator::GetIntelProjectVersion() +{ + if(!this->IntelProjectVersion) + { + // Compute the version of the Intel plugin to the VS IDE. + // If the key does not exist then use a default guess. + std::string intelVersion; + std::string vskey = this->GetRegistryBase(); + vskey += "\\Packages\\" CM_INTEL_PLUGIN_GUID ";ProductVersion"; + cmSystemTools::ReadRegistryValue(vskey.c_str(), intelVersion, + cmSystemTools::KeyWOW64_32); + unsigned int intelVersionNumber = ~0u; + sscanf(intelVersion.c_str(), "%u", &intelVersionNumber); + if(intelVersionNumber >= 11) + { + // Default to latest known project file version. + intelVersion = "11.0"; + } + else if(intelVersionNumber == 10) + { + // Version 10.x actually uses 9.10 in project files! + intelVersion = "9.10"; + } + else + { + // Version <= 9: use ProductVersion from registry. + } + this->IntelProjectVersion = strdup(intelVersion.c_str()); + } + return this->IntelProjectVersion; +} void cmGlobalVisualStudio7Generator ::EnableLanguage(std::vector<std::string>const & lang, @@ -36,7 +77,6 @@ void cmGlobalVisualStudio7Generator { mf->AddDefinition("CMAKE_GENERATOR_RC", "rc"); mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); - mf->AddDefinition("CMAKE_GENERATOR_FC", "ifort"); this->AddPlatformDefinitions(mf); if(!mf->GetDefinition("CMAKE_CONFIGURATION_TYPES")) { @@ -71,35 +111,103 @@ void cmGlobalVisualStudio7Generator } -std::string cmGlobalVisualStudio7Generator -::GenerateBuildCommand(const char* makeProgram, - const char *projectName, const char *projectDir, - const char* additionalOptions, const char *targetName, - const char* config, bool ignoreErrors, bool) +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio7Generator::FindMakeProgram(cmMakefile* mf) { - // Visual studio 7 doesn't need project dir - (void) projectDir; - // Ingoring errors is not implemented in visual studio 6 - (void) ignoreErrors; + this->cmGlobalVisualStudioGenerator::FindMakeProgram(mf); + mf->AddDefinition("CMAKE_VS_DEVENV_COMMAND", + this->GetDevEnvCommand().c_str()); +} - // now build the test - std::string makeCommand = - cmSystemTools::ConvertToOutputPath(makeProgram); - std::string lowerCaseCommand = makeCommand; - cmSystemTools::LowerCase(lowerCaseCommand); +//---------------------------------------------------------------------------- +std::string const& cmGlobalVisualStudio7Generator::GetDevEnvCommand() +{ + if(!this->DevEnvCommandInitialized) + { + this->DevEnvCommandInitialized = true; + this->DevEnvCommand = this->FindDevEnvCommand(); + } + return this->DevEnvCommand; +} - // if there are spaces in the makeCommand, assume a full path - // and convert it to a path with no spaces in it as the - // RunSingleCommand does not like spaces -#if defined(_WIN32) && !defined(__CYGWIN__) - if(makeCommand.find(' ') != std::string::npos) +//---------------------------------------------------------------------------- +std::string cmGlobalVisualStudio7Generator::FindDevEnvCommand() +{ + std::string vscmd; + std::string vskey = this->GetRegistryBase() + ";InstallDir"; + if(cmSystemTools::ReadRegistryValue(vskey.c_str(), vscmd, + cmSystemTools::KeyWOW64_32)) { - cmSystemTools::GetShortPath(makeCommand.c_str(), makeCommand); + cmSystemTools::ConvertToUnixSlashes(vscmd); + vscmd += "/"; } -#endif - makeCommand += " "; - makeCommand += projectName; - makeCommand += ".sln "; + vscmd += "devenv.com"; + return vscmd; +} + +//---------------------------------------------------------------------------- +const char* cmGlobalVisualStudio7Generator::ExternalProjectType( + const char* location) +{ + std::string extension = cmSystemTools::GetFilenameLastExtension(location); + if (extension == ".vbproj") + { + return "F184B08F-C81C-45F6-A57F-5ABD9991F28F"; + } + else if (extension == ".csproj") + { + return "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC"; + } + else if (extension == ".fsproj") + { + return "F2A71F9B-5D33-465A-A702-920D77279786"; + } + else if (extension == ".vdproj") + { + return "54435603-DBB4-11D2-8724-00A0C9A8B90C"; + } + else if (extension == ".dbproj") + { + return "C8D11400-126E-41CD-887F-60BD40844F9E"; + } + else if (extension == ".wixproj") + { + return "930C7802-8A8C-48F9-8165-68863BCCD9DD"; + } + else if (extension == ".pyproj") + { + return "888888A0-9F3D-457C-B088-3A5042F75D52"; + } + return "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942"; +} +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio7Generator::GenerateBuildCommand( + std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* projectName, + const char* /*projectDir*/, + const char* targetName, + const char* config, + bool /*fast*/, + std::vector<std::string> const& makeOptions) +{ + // Select the caller- or user-preferred make program, else devenv. + std::string makeProgramSelected = + this->SelectMakeProgram(makeProgram, this->GetDevEnvCommand()); + + // Ignore the above preference if it is msbuild. + // Assume any other value is either a devenv or + // command-line compatible with devenv. + std::string makeProgramLower = makeProgramSelected; + cmSystemTools::LowerCase(makeProgramLower); + if(makeProgramLower.find("msbuild") != std::string::npos) + { + makeProgramSelected = this->GetDevEnvCommand(); + } + + makeCommand.push_back(makeProgramSelected); + + makeCommand.push_back(std::string(projectName) + ".sln"); bool clean = false; if ( targetName && strcmp(targetName, "clean") == 0 ) { @@ -108,37 +216,33 @@ std::string cmGlobalVisualStudio7Generator } if(clean) { - makeCommand += "/clean "; + makeCommand.push_back("/clean"); } else { - makeCommand += "/build "; + makeCommand.push_back("/build"); } if(config && strlen(config)) { - makeCommand += config; + makeCommand.push_back(config); } else { - makeCommand += "Debug"; + makeCommand.push_back("Debug"); } - makeCommand += " /project "; + makeCommand.push_back("/project"); if (targetName && strlen(targetName)) { - makeCommand += targetName; + makeCommand.push_back(targetName); } else { - makeCommand += "ALL_BUILD"; - } - if ( additionalOptions ) - { - makeCommand += " "; - makeCommand += additionalOptions; + makeCommand.push_back("ALL_BUILD"); } - return makeCommand; + makeCommand.insert(makeCommand.end(), + makeOptions.begin(), makeOptions.end()); } ///! Create a local generator appropriate to this Global Generator @@ -156,6 +260,8 @@ void cmGlobalVisualStudio7Generator::AddPlatformDefinitions(cmMakefile* mf) { cmGlobalVisualStudioGenerator::AddPlatformDefinitions(mf); mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName()); + mf->AddDefinition("CMAKE_VS_INTEL_Fortran_PROJECT_VERSION", + this->GetIntelProjectVersion()); } void cmGlobalVisualStudio7Generator::GenerateConfigurations(cmMakefile* mf) @@ -264,7 +370,11 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations( for(OrderedTargetDependSet::const_iterator tt = projectTargets.begin(); tt != projectTargets.end(); ++tt) { - cmTarget* target = *tt; + cmTarget const* target = *tt; + if(target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } const char* expath = target->GetProperty("EXTERNAL_MSPROJECT"); if(expath) { @@ -301,7 +411,11 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( for(OrderedTargetDependSet::const_iterator tt = projectTargets.begin(); tt != projectTargets.end(); ++tt) { - cmTarget* target = *tt; + cmTarget const* target = *tt; + if(target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } bool written = false; // handle external vc project files @@ -391,7 +505,11 @@ void cmGlobalVisualStudio7Generator::WriteTargetDepends( for(OrderedTargetDependSet::const_iterator tt = projectTargets.begin(); tt != projectTargets.end(); ++tt) { - cmTarget* target = *tt; + cmTarget const* target = *tt; + if(target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } cmMakefile* mf = target->GetMakefile(); const char *vcprojName = target->GetProperty("GENERATOR_FILE_NAME"); @@ -536,7 +654,7 @@ cmGlobalVisualStudio7Generator::ConvertToSolutionPath(const char* path) // the libraries it uses are also done here void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout, const char* dspname, - const char* dir, cmTarget& target) + const char* dir, cmTarget const& target) { // check to see if this is a fortran build const char* ext = ".vcproj"; @@ -576,7 +694,7 @@ void cmGlobalVisualStudio7Generator ::WriteProjectDepends(std::ostream& fout, const char* dspname, - const char*, cmTarget& target) + const char*, cmTarget const& target) { int depcount = 0; std::string dspguid = this->GetGUID(dspname); @@ -647,7 +765,7 @@ void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& fout, std::string d = cmSystemTools::ConvertToOutputPath(location); fout << "Project(" << "\"{" - << (typeGuid ? typeGuid : "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942") + << (typeGuid ? typeGuid : this->ExternalProjectType(location)) << "}\") = \"" << name << "\", \"" << this->ConvertToSolutionPath(location) << "\", \"{" @@ -736,7 +854,7 @@ void cmGlobalVisualStudio7Generator::WriteSLNHeader(std::ostream& fout) //---------------------------------------------------------------------------- std::string -cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget* target) +cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target) { std::string pname = target->GetName(); pname += "_UTILITY"; @@ -815,11 +933,11 @@ void cmGlobalVisualStudio7Generator::CreateGUID(const char* name) } std::string ret; UUID uid; - unsigned char *uidstr; + unsigned short *uidstr; UuidCreate(&uid); - UuidToString(&uid,&uidstr); - ret = reinterpret_cast<char*>(uidstr); - RpcStringFree(&uidstr); + UuidToStringW(&uid,&uidstr); + ret = cmsys::Encoding::ToNarrow(reinterpret_cast<wchar_t*>(uidstr)); + RpcStringFreeW(&uidstr); ret = cmSystemTools::UpperCase(ret); this->CMakeInstance->AddCacheEntry(guidStoreName.c_str(), ret.c_str(), "Stored GUID", @@ -837,7 +955,6 @@ void cmGlobalVisualStudio7Generator { entry.Name = cmGlobalVisualStudio7Generator::GetActualName(); entry.Brief = "Generates Visual Studio .NET 2002 project files."; - entry.Full = ""; } //---------------------------------------------------------------------------- @@ -858,7 +975,7 @@ cmGlobalVisualStudio7Generator std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(const char* project, - cmTarget* target) + cmTarget const* target) { std::set<std::string> activeConfigs; // if it is a utilitiy target then only make it part of the diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 4d22cff..f69bd84 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -27,6 +27,8 @@ class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator { public: cmGlobalVisualStudio7Generator(const char* platformName = NULL); + ~cmGlobalVisualStudio7Generator(); + static cmGlobalGeneratorFactory* NewFactory() { return new cmGlobalGeneratorSimpleFactory <cmGlobalVisualStudio7Generator>(); } @@ -58,14 +60,16 @@ public: * Try running cmake and building a file. This is used for dynamically * loaded commands, not as part of the usual build process. */ - virtual std::string GenerateBuildCommand(const char* makeProgram, - const char *projectName, - const char *projectDir, - const char* additionalOptions, - const char *targetName, - const char* config, - bool ignoreErrors, - bool fast); + virtual void GenerateBuildCommand( + std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* projectName, + const char* projectDir, + const char* targetName, + const char* config, + bool fast, + std::vector<std::string> const& makeOptions = std::vector<std::string>() + ); /** * Generate the all required files for building this project/tree. This @@ -101,18 +105,29 @@ public: LinkLibraryDependencies and link to .sln dependencies. */ virtual bool NeedLinkLibraryDependencies(cmTarget&) { return false; } + const char* GetIntelProjectVersion(); + + virtual void FindMakeProgram(cmMakefile*); + protected: virtual const char* GetIDEVersion() { return "7.0"; } + std::string const& GetDevEnvCommand(); + virtual std::string FindDevEnvCommand(); + + static const char* ExternalProjectType(const char* location); + static cmIDEFlagTable const* GetExtraFlagTableVS7(); virtual void OutputSLNFile(cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators); virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators); virtual void WriteProject(std::ostream& fout, - const char* name, const char* path, cmTarget &t); + const char* name, const char* path, + cmTarget const& t); virtual void WriteProjectDepends(std::ostream& fout, - const char* name, const char* path, cmTarget &t); + const char* name, const char* path, + cmTarget const&t); virtual void WriteProjectConfigurations( std::ostream& fout, const char* name, cmTarget::TargetType type, const std::set<std::string>& configsPartOfDefaultBuild, @@ -121,7 +136,7 @@ protected: cmLocalGenerator* root); virtual void WriteSLNFooter(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout); - virtual std::string WriteUtilityDepend(cmTarget* target); + virtual std::string WriteUtilityDepend(cmTarget const* target); virtual void WriteTargetsToSolution( std::ostream& fout, @@ -147,7 +162,7 @@ protected: std::string ConvertToSolutionPath(const char* path); std::set<std::string> IsPartOfDefaultBuild(const char* project, - cmTarget* target); + cmTarget const* target); std::vector<std::string> Configurations; std::map<cmStdString, cmStdString> GUIDMap; @@ -159,6 +174,12 @@ protected: // There is one SLN file per project. std::string CurrentProject; std::string PlatformName; + +private: + char* IntelProjectVersion; + std::string DevEnvCommand; + bool DevEnvCommandInitialized; + virtual std::string GetVSMakeProgram() { return this->GetDevEnvCommand(); } }; #define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZERO_CHECK" diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index e4244e0..12c240b 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -65,11 +65,6 @@ public: virtual void GetDocumentation(cmDocumentationEntry& entry) const { entry.Name = vs8generatorName; entry.Brief = "Generates Visual Studio 8 2005 project files."; - entry.Full = - "It is possible to append a space followed by the platform name " - "to create project files for a specific target platform. E.g. " - "\"Visual Studio 8 2005 Win64\" will create project files for " - "the x64 processor."; } virtual void GetGenerators(std::vector<std::string>& names) const { @@ -99,7 +94,6 @@ cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator( const char* additionalPlatformDefinition) : cmGlobalVisualStudio71Generator(platformName) { - this->FindMakeProgramFile = "CMakeVS8FindMake.cmake"; this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms"; this->Name = name; @@ -110,6 +104,26 @@ cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator( } //---------------------------------------------------------------------------- +std::string cmGlobalVisualStudio8Generator::FindDevEnvCommand() +{ + // First look for VCExpress. + std::string vsxcmd; + std::string vsxkey = + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\"; + vsxkey += this->GetIDEVersion(); + vsxkey += ";InstallDir"; + if(cmSystemTools::ReadRegistryValue(vsxkey.c_str(), vsxcmd, + cmSystemTools::KeyWOW64_32)) + { + cmSystemTools::ConvertToUnixSlashes(vsxcmd); + vsxcmd += "/VCExpress.exe"; + return vsxcmd; + } + // Now look for devenv. + return this->cmGlobalVisualStudio71Generator::FindDevEnvCommand(); +} + +//---------------------------------------------------------------------------- ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualStudio8Generator::CreateLocalGenerator() { @@ -147,7 +161,6 @@ void cmGlobalVisualStudio8Generator { entry.Name = cmGlobalVisualStudio8Generator::GetActualName(); entry.Brief = "Generates Visual Studio 8 2005 project files."; - entry.Full = ""; } //---------------------------------------------------------------------------- @@ -202,7 +215,7 @@ std::string cmGlobalVisualStudio8Generator::GetUserMacrosRegKeyBase() } //---------------------------------------------------------------------------- -void cmGlobalVisualStudio8Generator::AddCheckTarget() +bool cmGlobalVisualStudio8Generator::AddCheckTarget() { // Add a special target on which all other targets depend that // checks the build system and optionally re-runs CMake. @@ -216,7 +229,7 @@ void cmGlobalVisualStudio8Generator::AddCheckTarget() // Skip the target if no regeneration is to be done. if(mf->IsOn("CMAKE_SUPPRESS_REGENERATION")) { - return; + return false; } std::string cmake_command = mf->GetRequiredDefinition("CMAKE_COMMAND"); @@ -315,21 +328,24 @@ void cmGlobalVisualStudio8Generator::AddCheckTarget() cmSystemTools::Error("Error adding rule for ", stamps[0].c_str()); } } + + return true; } //---------------------------------------------------------------------------- void cmGlobalVisualStudio8Generator::Generate() { - this->AddCheckTarget(); - - // All targets depend on the build-system check target. - for(std::map<cmStdString,cmTarget *>::const_iterator - ti = this->TotalTargets.begin(); - ti != this->TotalTargets.end(); ++ti) + if(this->AddCheckTarget()) { - if(ti->first != CMAKE_CHECK_BUILD_SYSTEM_TARGET) + // All targets depend on the build-system check target. + for(std::map<cmStdString,cmTarget *>::const_iterator + ti = this->TotalTargets.begin(); + ti != this->TotalTargets.end(); ++ti) { - ti->second->AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET); + if(ti->first != CMAKE_CHECK_BUILD_SYSTEM_TARGET) + { + ti->second->AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET); + } } } @@ -399,13 +415,17 @@ bool cmGlobalVisualStudio8Generator::ComputeTargetDepends() //---------------------------------------------------------------------------- void cmGlobalVisualStudio8Generator::WriteProjectDepends( - std::ostream& fout, const char*, const char*, cmTarget& t) + std::ostream& fout, const char*, const char*, cmTarget const& t) { TargetDependSet const& unordered = this->GetTargetDirectDepends(t); OrderedTargetDependSet depends(unordered); for(OrderedTargetDependSet::const_iterator i = depends.begin(); i != depends.end(); ++i) { + if((*i)->GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } std::string guid = this->GetGUID((*i)->GetName()); fout << "\t\t{" << guid << "} = {" << guid << "}\n"; } @@ -422,7 +442,8 @@ bool cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies( { if(cmTarget* depTarget = this->FindTarget(0, ui->c_str())) { - if(depTarget->GetProperty("EXTERNAL_MSPROJECT")) + if(depTarget->GetType() != cmTarget::INTERFACE_LIBRARY + && depTarget->GetProperty("EXTERNAL_MSPROJECT")) { // This utility dependency names an external .vcproj target. // We use LinkLibraryDependencies="true" to link to it without diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index d181742..5b952c4 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -69,9 +69,11 @@ public: protected: virtual const char* GetIDEVersion() { return "8.0"; } + virtual std::string FindDevEnvCommand(); + virtual bool VSLinksDependencies() const { return false; } - void AddCheckTarget(); + bool AddCheckTarget(); static cmIDEFlagTable const* GetExtraFlagTableVS8(); virtual void WriteSLNHeader(std::ostream& fout); @@ -82,7 +84,7 @@ protected: const char* platformMapping = NULL); virtual bool ComputeTargetDepends(); virtual void WriteProjectDepends(std::ostream& fout, const char* name, - const char* path, cmTarget &t); + const char* path, cmTarget const& t); std::string Name; std::string WindowsCEVersion; diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index fba6ed1..ccc27ad 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -70,11 +70,6 @@ public: virtual void GetDocumentation(cmDocumentationEntry& entry) const { entry.Name = vs9generatorName; entry.Brief = "Generates Visual Studio 9 2008 project files."; - entry.Full = - "It is possible to append a space followed by the platform name " - "to create project files for a specific target platform. E.g. " - "\"Visual Studio 9 2008 Win64\" will create project files for " - "the x64 processor; \"Visual Studio 9 2008 IA64\" for Itanium."; } virtual void GetGenerators(std::vector<std::string>& names) const { @@ -106,7 +101,6 @@ cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator( : cmGlobalVisualStudio8Generator(name, platformName, additionalPlatformDefinition) { - this->FindMakeProgramFile = "CMakeVS9FindMake.cmake"; } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 5931016..42492e6 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -17,6 +17,7 @@ #include "cmMakefile.h" #include "cmSourceFile.h" #include "cmTarget.h" +#include <cmsys/Encoding.hxx> //---------------------------------------------------------------------------- cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator() @@ -128,9 +129,11 @@ cmGlobalVisualStudioGenerator // Count the number of object files with each name. Note that // windows file names are not case sensitive. std::map<cmStdString, int> counts; + std::vector<cmSourceFile*> objectSources; + gt->GetObjectSources(objectSources); for(std::vector<cmSourceFile*>::const_iterator - si = gt->ObjectSources.begin(); - si != gt->ObjectSources.end(); ++si) + si = objectSources.begin(); + si != objectSources.end(); ++si) { cmSourceFile* sf = *si; std::string objectNameLower = cmSystemTools::LowerCase( @@ -142,8 +145,8 @@ cmGlobalVisualStudioGenerator // For all source files producing duplicate names we need unique // object name computation. for(std::vector<cmSourceFile*>::const_iterator - si = gt->ObjectSources.begin(); - si != gt->ObjectSources.end(); ++si) + si = objectSources.begin(); + si != objectSources.end(); ++si) { cmSourceFile* sf = *si; std::string objectName = @@ -151,10 +154,10 @@ cmGlobalVisualStudioGenerator objectName += ".obj"; if(counts[cmSystemTools::LowerCase(objectName)] > 1) { - gt->ExplicitObjectName.insert(sf); + gt->AddExplicitObjectName(sf); objectName = lg->GetObjectFileNameWithoutTarget(*sf, dir_max); } - gt->Objects[sf] = objectName; + gt->AddObject(sf, objectName); } std::string dir = gt->Makefile->GetCurrentOutputDirectory(); @@ -314,7 +317,7 @@ std::string cmGlobalVisualStudioGenerator::GetUserMacrosRegKeyBase() } //---------------------------------------------------------------------------- -void cmGlobalVisualStudioGenerator::FillLinkClosure(cmTarget* target, +void cmGlobalVisualStudioGenerator::FillLinkClosure(cmTarget const* target, TargetSet& linked) { if(linked.insert(target).second) @@ -347,8 +350,12 @@ cmGlobalVisualStudioGenerator::GetTargetLinkClosure(cmTarget* target) //---------------------------------------------------------------------------- void cmGlobalVisualStudioGenerator::FollowLinkDepends( - cmTarget* target, std::set<cmTarget*>& linked) + cmTarget const* target, std::set<cmTarget const*>& linked) { + if(target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return; + } if(linked.insert(target).second && target->GetType() == cmTarget::STATIC_LIBRARY) { @@ -392,7 +399,7 @@ bool cmGlobalVisualStudioGenerator::ComputeTargetDepends() } //---------------------------------------------------------------------------- -static bool VSLinkable(cmTarget* t) +static bool VSLinkable(cmTarget const* t) { return t->IsLinkable() || t->GetType() == cmTarget::OBJECT_LIBRARY; } @@ -434,7 +441,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) // Collect implicit link dependencies (target_link_libraries). // Static libraries cannot depend on their link implementation // due to behavior (2), but they do not really need to. - std::set<cmTarget*> linkDepends; + std::set<cmTarget const*> linkDepends; if(target.GetType() != cmTarget::STATIC_LIBRARY) { for(TargetDependSet::const_iterator di = depends.begin(); @@ -449,7 +456,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) } // Collect explicit util dependencies (add_dependencies). - std::set<cmTarget*> utilDepends; + std::set<cmTarget const*> utilDepends; for(TargetDependSet::const_iterator di = depends.begin(); di != depends.end(); ++di) { @@ -469,18 +476,18 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) } // Emit link dependencies. - for(std::set<cmTarget*>::iterator di = linkDepends.begin(); + for(std::set<cmTarget const*>::iterator di = linkDepends.begin(); di != linkDepends.end(); ++di) { - cmTarget* dep = *di; + cmTarget const* dep = *di; vsTargetDepend.insert(dep->GetName()); } // Emit util dependencies. Possibly use intermediate targets. - for(std::set<cmTarget*>::iterator di = utilDepends.begin(); + for(std::set<cmTarget const*>::iterator di = utilDepends.begin(); di != utilDepends.end(); ++di) { - cmTarget* dep = *di; + cmTarget const* dep = *di; if(allowLinkable || !VSLinkable(dep) || linked.count(dep)) { // Direct dependency allowed. @@ -496,6 +503,19 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) } //---------------------------------------------------------------------------- +void cmGlobalVisualStudioGenerator::FindMakeProgram(cmMakefile* mf) +{ + // Visual Studio generators know how to lookup their build tool + // directly instead of needing a helper module to do it, so we + // do not actually need to put CMAKE_MAKE_PROGRAM into the cache. + if(cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) + { + mf->AddDefinition("CMAKE_MAKE_PROGRAM", + this->GetVSMakeProgram().c_str()); + } +} + +//---------------------------------------------------------------------------- void cmGlobalVisualStudioGenerator::AddPlatformDefinitions(cmMakefile* mf) { if(this->AdditionalPlatformDefinition) @@ -505,7 +525,8 @@ void cmGlobalVisualStudioGenerator::AddPlatformDefinitions(cmMakefile* mf) } //---------------------------------------------------------------------------- -std::string cmGlobalVisualStudioGenerator::GetUtilityDepend(cmTarget* target) +std::string +cmGlobalVisualStudioGenerator::GetUtilityDepend(cmTarget const* target) { UtilityDependsMap::iterator i = this->UtilityDepends.find(target); if(i == this->UtilityDepends.end()) @@ -542,52 +563,53 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile, keyname = regKeyBase + "\\OtherProjects7"; hkey = NULL; - result = RegOpenKeyEx(HKEY_CURRENT_USER, keyname.c_str(), - 0, KEY_READ, &hkey); + result = RegOpenKeyExW(HKEY_CURRENT_USER, + cmsys::Encoding::ToWide(keyname).c_str(), + 0, KEY_READ, &hkey); if (ERROR_SUCCESS == result) { // Iterate the subkeys and look for the values of interest in each subkey: - CHAR subkeyname[256]; - DWORD cch_subkeyname = sizeof(subkeyname)/sizeof(subkeyname[0]); - CHAR keyclass[256]; - DWORD cch_keyclass = sizeof(keyclass)/sizeof(keyclass[0]); + wchar_t subkeyname[256]; + DWORD cch_subkeyname = sizeof(subkeyname)*sizeof(subkeyname[0]); + wchar_t keyclass[256]; + DWORD cch_keyclass = sizeof(keyclass)*sizeof(keyclass[0]); FILETIME lastWriteTime; lastWriteTime.dwHighDateTime = 0; lastWriteTime.dwLowDateTime = 0; - while (ERROR_SUCCESS == RegEnumKeyEx(hkey, index, subkeyname, + while (ERROR_SUCCESS == RegEnumKeyExW(hkey, index, subkeyname, &cch_subkeyname, 0, keyclass, &cch_keyclass, &lastWriteTime)) { // Open the subkey and query the values of interest: HKEY hsubkey = NULL; - result = RegOpenKeyEx(hkey, subkeyname, 0, KEY_READ, &hsubkey); + result = RegOpenKeyExW(hkey, subkeyname, 0, KEY_READ, &hsubkey); if (ERROR_SUCCESS == result) { DWORD valueType = REG_SZ; - CHAR data1[256]; - DWORD cch_data1 = sizeof(data1)/sizeof(data1[0]); - RegQueryValueEx(hsubkey, "Path", 0, &valueType, + wchar_t data1[256]; + DWORD cch_data1 = sizeof(data1)*sizeof(data1[0]); + RegQueryValueExW(hsubkey, L"Path", 0, &valueType, (LPBYTE) &data1[0], &cch_data1); DWORD data2 = 0; DWORD cch_data2 = sizeof(data2); - RegQueryValueEx(hsubkey, "Security", 0, &valueType, + RegQueryValueExW(hsubkey, L"Security", 0, &valueType, (LPBYTE) &data2, &cch_data2); DWORD data3 = 0; DWORD cch_data3 = sizeof(data3); - RegQueryValueEx(hsubkey, "StorageFormat", 0, &valueType, + RegQueryValueExW(hsubkey, L"StorageFormat", 0, &valueType, (LPBYTE) &data3, &cch_data3); - s2 = cmSystemTools::LowerCase(data1); + s2 = cmSystemTools::LowerCase(cmsys::Encoding::ToNarrow(data1)); cmSystemTools::ConvertToUnixSlashes(s2); if (s2 == s1) { macrosRegistered = true; } - std::string fullname(data1); + std::string fullname = cmsys::Encoding::ToNarrow(data1); std::string filename; std::string filepath; std::string filepathname; @@ -619,8 +641,8 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile, } ++index; - cch_subkeyname = sizeof(subkeyname)/sizeof(subkeyname[0]); - cch_keyclass = sizeof(keyclass)/sizeof(keyclass[0]); + cch_subkeyname = sizeof(subkeyname)*sizeof(subkeyname[0]); + cch_keyclass = sizeof(keyclass)*sizeof(keyclass[0]); lastWriteTime.dwHighDateTime = 0; lastWriteTime.dwLowDateTime = 0; } @@ -645,27 +667,28 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile, keyname = regKeyBase + "\\RecordingProject7"; hkey = NULL; - result = RegOpenKeyEx(HKEY_CURRENT_USER, keyname.c_str(), - 0, KEY_READ, &hkey); + result = RegOpenKeyExW(HKEY_CURRENT_USER, + cmsys::Encoding::ToWide(keyname).c_str(), + 0, KEY_READ, &hkey); if (ERROR_SUCCESS == result) { DWORD valueType = REG_SZ; - CHAR data1[256]; - DWORD cch_data1 = sizeof(data1)/sizeof(data1[0]); - RegQueryValueEx(hkey, "Path", 0, &valueType, + wchar_t data1[256]; + DWORD cch_data1 = sizeof(data1)*sizeof(data1[0]); + RegQueryValueExW(hkey, L"Path", 0, &valueType, (LPBYTE) &data1[0], &cch_data1); DWORD data2 = 0; DWORD cch_data2 = sizeof(data2); - RegQueryValueEx(hkey, "Security", 0, &valueType, + RegQueryValueExW(hkey, L"Security", 0, &valueType, (LPBYTE) &data2, &cch_data2); DWORD data3 = 0; DWORD cch_data3 = sizeof(data3); - RegQueryValueEx(hkey, "StorageFormat", 0, &valueType, + RegQueryValueExW(hkey, L"StorageFormat", 0, &valueType, (LPBYTE) &data3, &cch_data3); - s2 = cmSystemTools::LowerCase(data1); + s2 = cmSystemTools::LowerCase(cmsys::Encoding::ToNarrow(data1)); cmSystemTools::ConvertToUnixSlashes(s2); if (s2 == s1) { @@ -697,24 +720,27 @@ void WriteVSMacrosFileRegistryEntry( { std::string keyname = regKeyBase + "\\OtherProjects7"; HKEY hkey = NULL; - LONG result = RegOpenKeyEx(HKEY_CURRENT_USER, keyname.c_str(), 0, + LONG result = RegOpenKeyExW(HKEY_CURRENT_USER, + cmsys::Encoding::ToWide(keyname).c_str(), 0, KEY_READ|KEY_WRITE, &hkey); if (ERROR_SUCCESS == result) { // Create the subkey and set the values of interest: HKEY hsubkey = NULL; - char lpClass[] = ""; - result = RegCreateKeyEx(hkey, nextAvailableSubKeyName.c_str(), 0, - lpClass, 0, KEY_READ|KEY_WRITE, 0, &hsubkey, 0); + wchar_t lpClass[] = L""; + result = RegCreateKeyExW(hkey, + cmsys::Encoding::ToWide(nextAvailableSubKeyName).c_str(), 0, + lpClass, 0, KEY_READ|KEY_WRITE, 0, &hsubkey, 0); if (ERROR_SUCCESS == result) { DWORD dw = 0; std::string s(macrosFile); cmSystemTools::ReplaceString(s, "/", "\\"); + std::wstring ws = cmsys::Encoding::ToWide(s); - result = RegSetValueEx(hsubkey, "Path", 0, REG_SZ, (LPBYTE) s.c_str(), - static_cast<DWORD>(strlen(s.c_str()) + 1)); + result = RegSetValueExW(hsubkey, L"Path", 0, REG_SZ, (LPBYTE)ws.c_str(), + static_cast<DWORD>(ws.size() + 1)*sizeof(wchar_t)); if (ERROR_SUCCESS != result) { std::cout << "error result 1: " << result << std::endl; @@ -724,7 +750,7 @@ void WriteVSMacrosFileRegistryEntry( // Security value is always "1" for sample macros files (seems to be "2" // if you put the file somewhere outside the standard VSMacros folder) dw = 1; - result = RegSetValueEx(hsubkey, "Security", + result = RegSetValueExW(hsubkey, L"Security", 0, REG_DWORD, (LPBYTE) &dw, sizeof(DWORD)); if (ERROR_SUCCESS != result) { @@ -734,7 +760,7 @@ void WriteVSMacrosFileRegistryEntry( // StorageFormat value is always "0" for sample macros files dw = 0; - result = RegSetValueEx(hsubkey, "StorageFormat", + result = RegSetValueExW(hsubkey, L"StorageFormat", 0, REG_DWORD, (LPBYTE) &dw, sizeof(DWORD)); if (ERROR_SUCCESS != result) { @@ -822,7 +848,8 @@ void RegisterVisualStudioMacros(const std::string& macrosFile, } } } -bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget& target) +bool +cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) { // check to see if this is a fortran build std::set<cmStdString> languages; diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index b665158..eab613d 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -60,7 +60,7 @@ public: const char* vsSolutionFile = 0); // return true if target is fortran only - bool TargetIsFortranOnly(cmTarget& t); + bool TargetIsFortranOnly(cmTarget const& t); /** Get the top-level registry key for this VS version. */ std::string GetRegistryBase(); @@ -75,13 +75,15 @@ public: /** Return true if building for Windows CE */ virtual bool TargetsWindowsCE() const { return false; } - class TargetSet: public std::set<cmTarget*> {}; + class TargetSet: public std::set<cmTarget const*> {}; struct TargetCompare { bool operator()(cmTarget const* l, cmTarget const* r) const; }; class OrderedTargetDependSet; + virtual void FindMakeProgram(cmMakefile*); + protected: // Does this VS version link targets to each other if there are // dependencies in the SLN file? This was done for VS versions @@ -94,26 +96,29 @@ protected: virtual bool ComputeTargetDepends(); class VSDependSet: public std::set<cmStdString> {}; - class VSDependMap: public std::map<cmTarget*, VSDependSet> {}; + class VSDependMap: public std::map<cmTarget const*, VSDependSet> {}; VSDependMap VSTargetDepends; void ComputeVSTargetDepends(cmTarget&); bool CheckTargetLinks(cmTarget& target, const char* name); std::string GetUtilityForTarget(cmTarget& target, const char*); - virtual std::string WriteUtilityDepend(cmTarget*) = 0; - std::string GetUtilityDepend(cmTarget* target); - typedef std::map<cmTarget*, cmStdString> UtilityDependsMap; + virtual std::string WriteUtilityDepend(cmTarget const*) = 0; + std::string GetUtilityDepend(cmTarget const* target); + typedef std::map<cmTarget const*, cmStdString> UtilityDependsMap; UtilityDependsMap UtilityDepends; const char* AdditionalPlatformDefinition; private: + virtual std::string GetVSMakeProgram() = 0; + void PrintCompilerAdvice(std::ostream&, std::string, const char*) const {} void ComputeTargetObjects(cmGeneratorTarget* gt) const; - void FollowLinkDepends(cmTarget* target, std::set<cmTarget*>& linked); + void FollowLinkDepends(cmTarget const* target, + std::set<cmTarget const*>& linked); class TargetSetMap: public std::map<cmTarget*, TargetSet> {}; TargetSetMap TargetLinkClosure; - void FillLinkClosure(cmTarget* target, TargetSet& linked); + void FillLinkClosure(cmTarget const* target, TargetSet& linked); TargetSet const& GetTargetLinkClosure(cmTarget* target); }; diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx index e3cebc4..98ce685 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.cxx +++ b/Source/cmGlobalWatcomWMakeGenerator.cxx @@ -47,7 +47,7 @@ cmLocalGenerator *cmGlobalWatcomWMakeGenerator::CreateLocalGenerator() lg->SetDefineWindowsNULL(true); lg->SetWindowsShell(true); lg->SetWatcomWMake(true); - lg->SetMakeSilentFlag("-s -h"); + lg->SetMakeSilentFlag("-s -h -e"); lg->SetGlobalGenerator(this); lg->SetIgnoreLibPrefix(true); lg->SetPassMakeflags(false); @@ -62,5 +62,4 @@ void cmGlobalWatcomWMakeGenerator { entry.Name = cmGlobalWatcomWMakeGenerator::GetActualName(); entry.Brief = "Generates Watcom WMake makefiles."; - entry.Full = ""; } diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h index 23e60a1..d5350ef 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.h +++ b/Source/cmGlobalWatcomWMakeGenerator.h @@ -43,6 +43,8 @@ public: */ virtual void EnableLanguage(std::vector<std::string>const& languages, cmMakefile *, bool optional); + + virtual bool AllowNotParallel() const { return false; } }; #endif diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 0a2b32b..f7a42fc 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -257,39 +257,30 @@ void cmGlobalXCodeGenerator::EnableLanguage(std::vector<std::string>const& } //---------------------------------------------------------------------------- -std::string cmGlobalXCodeGenerator -::GenerateBuildCommand(const char* makeProgram, - const char *projectName, - const char *projectDir, - const char* additionalOptions, - const char *targetName, - const char* config, - bool ignoreErrors, - bool) -{ - // Config is not used yet - (void) ignoreErrors; - (void) projectDir; - +void +cmGlobalXCodeGenerator::GenerateBuildCommand( + std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* projectName, + const char* /*projectDir*/, + const char* targetName, + const char* config, + bool /*fast*/, + std::vector<std::string> const& makeOptions) +{ // now build the test - if(makeProgram == 0 || !strlen(makeProgram)) - { - cmSystemTools::Error( - "Generator cannot find the appropriate make command."); - return ""; - } - std::string makeCommand = - cmSystemTools::ConvertToOutputPath(makeProgram); - std::string lowerCaseCommand = makeCommand; - cmSystemTools::LowerCase(lowerCaseCommand); + makeCommand.push_back( + this->SelectMakeProgram(makeProgram, "xcodebuild") + ); - makeCommand += " -project "; - makeCommand += projectName; - makeCommand += ".xcode"; + makeCommand.push_back("-project"); + std::string projectArg = projectName; + projectArg += ".xcode"; if(this->XcodeVersion > 20) { - makeCommand += "proj"; + projectArg += "proj"; } + makeCommand.push_back(projectArg); bool clean = false; if ( targetName && strcmp(targetName, "clean") == 0 ) @@ -299,13 +290,13 @@ std::string cmGlobalXCodeGenerator } if(clean) { - makeCommand += " clean"; + makeCommand.push_back("clean"); } else { - makeCommand += " build"; + makeCommand.push_back("build"); } - makeCommand += " -target "; + makeCommand.push_back("-target"); // if it is a null string for config don't use it if(config && *config == 0) { @@ -313,27 +304,24 @@ std::string cmGlobalXCodeGenerator } if (targetName && strlen(targetName)) { - makeCommand += targetName; + makeCommand.push_back(targetName); } else { - makeCommand += "ALL_BUILD"; + makeCommand.push_back("ALL_BUILD"); } if(this->XcodeVersion == 15) { - makeCommand += " -buildstyle Development "; + makeCommand.push_back("-buildstyle"); + makeCommand.push_back("Development"); } else { - makeCommand += " -configuration "; - makeCommand += config?config:"Debug"; + makeCommand.push_back("-configuration"); + makeCommand.push_back(config?config:"Debug"); } - if ( additionalOptions ) - { - makeCommand += " "; - makeCommand += additionalOptions; - } - return makeCommand; + makeCommand.insert(makeCommand.end(), + makeOptions.begin(), makeOptions.end()); } //---------------------------------------------------------------------------- @@ -500,7 +488,8 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, dir.c_str()); } - if(!target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) + if(target.GetType() != cmTarget::INTERFACE_LIBRARY + && !target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) { allbuild->AddUtility(target.GetName()); } @@ -876,10 +865,23 @@ cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath( ext = realExt.substr(1); } - std::string sourcecode = GetSourcecodeValueFromFileExtension(ext, lang); - - fileRef->AddAttribute("explicitFileType", - this->CreateString(sourcecode.c_str())); + // If fullpath references a directory, then we need to specify + // lastKnownFileType as folder in order for Xcode to be able to open the + // contents of the folder (Xcode 4.6 does not like explicitFileType=folder). + if(cmSystemTools::FileIsDirectory(fullpath.c_str())) + { + fileRef->AddAttribute("lastKnownFileType", + this->CreateString("folder")); + } + else + { + std::string sourcecode = GetSourcecodeValueFromFileExtension(ext, lang); + const char* attribute = (sourcecode == "file.storyboard") ? + "lastKnownFileType" : + "explicitFileType"; + fileRef->AddAttribute(attribute, + this->CreateString(sourcecode.c_str())); + } // Store the file path relative to the top of the source tree. std::string path = this->RelativeToSource(fullpath.c_str()); @@ -976,6 +978,11 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, continue; } + if(cmtarget.GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } + if(cmtarget.GetType() == cmTarget::UTILITY || cmtarget.GetType() == cmTarget::GLOBAL_TARGET) { @@ -984,7 +991,8 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, } // organize the sources - std::vector<cmSourceFile*> classes = cmtarget.GetSourceFiles(); + std::vector<cmSourceFile*> classes; + cmtarget.GetSourceFiles(classes); std::sort(classes.begin(), classes.end(), cmSourceFilePathCompare()); std::vector<cmXCodeObject*> externalObjFiles; @@ -1004,7 +1012,8 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, cmTarget::SourceFileFlags tsFlags = cmtarget.GetTargetSourceFileFlags(*i); - if(strcmp(filetype->GetString(), "compiled.mach-o.objfile") == 0) + if(filetype && + strcmp(filetype->GetString(), "compiled.mach-o.objfile") == 0) { externalObjFiles.push_back(xsf); } @@ -1352,7 +1361,8 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, postbuild.push_back(command); } - std::vector<cmSourceFile*>const &classes = cmtarget.GetSourceFiles(); + std::vector<cmSourceFile*> classes; + cmtarget.GetSourceFiles(classes); // add all the sources std::vector<cmCustomCommand> commands; for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); @@ -1686,6 +1696,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, cmXCodeObject* buildSettings, const char* configName) { + if(target.GetType() == cmTarget::INTERFACE_LIBRARY) + { + return; + } + std::string flags; std::string defFlags; bool shared = ((target.GetType() == cmTarget::SHARED_LIBRARY) || @@ -2429,7 +2444,8 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) // Add source files without build rules for editing convenience. if(cmtarget.GetType() == cmTarget::UTILITY) { - std::vector<cmSourceFile*> const& sources = cmtarget.GetSourceFiles(); + std::vector<cmSourceFile*> sources; + cmtarget.GetSourceFiles(sources); for(std::vector<cmSourceFile*>::const_iterator i = sources.begin(); i != sources.end(); ++i) { @@ -2550,6 +2566,10 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, cmXCodeObject* buildPhases) { + if(cmtarget.GetType() == cmTarget::INTERFACE_LIBRARY) + { + return 0; + } cmXCodeObject* target = this->CreateObject(cmXCodeObject::PBXNativeTarget); target->AddAttribute("buildPhases", buildPhases); @@ -2609,7 +2629,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, } //---------------------------------------------------------------------------- -cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget* t) +cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget const* t) { if(!t) { @@ -2756,6 +2776,10 @@ void cmGlobalXCodeGenerator ::AddDependAndLinkInformation(cmXCodeObject* target) { cmTarget* cmtarget = target->GetTarget(); + if(cmtarget->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return; + } if(!cmtarget) { cmSystemTools::Error("Error no target on xobject\n"); @@ -2867,7 +2891,8 @@ void cmGlobalXCodeGenerator { linkLibs += this->XCodeEscapePath(li->Value.c_str()); } - else + else if (!li->Target + || li->Target->GetType() != cmTarget::INTERFACE_LIBRARY) { linkLibs += li->Value; } @@ -2909,6 +2934,10 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, { continue; } + if(cmtarget.GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } // add the soon to be generated Info.plist file as a source for a // MACOSX_BUNDLE file @@ -2919,7 +2948,8 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, cmtarget.AddSourceFile(sf); } - std::vector<cmSourceFile*> classes = cmtarget.GetSourceFiles(); + std::vector<cmSourceFile*> classes; + cmtarget.GetSourceFiles(classes); // Put cmSourceFile instances in proper groups: for(std::vector<cmSourceFile*>::const_iterator s = classes.begin(); @@ -3009,23 +3039,23 @@ cmXCodeObject* cmGlobalXCodeGenerator cmStdString curr_tgt_folder; for(std::vector<std::string>::size_type i = 0; i < tgt_folders.size();i++) { - curr_tgt_folder += tgt_folders[i]; - it = this->TargetGroup.find(curr_tgt_folder); - if(it == this->TargetGroup.end()) + if (i != 0) { - tgroup = this->CreatePBXGroup(tgroup,tgt_folders[i]); - this->TargetGroup[curr_tgt_folder] = tgroup; + curr_tgt_folder += "/"; } - else + curr_tgt_folder += tgt_folders[i]; + it = this->TargetGroup.find(curr_tgt_folder); + if(it != this->TargetGroup.end()) { tgroup = it->second; continue; } + tgroup = this->CreatePBXGroup(tgroup,tgt_folders[i]); + this->TargetGroup[curr_tgt_folder] = tgroup; if(i == 0) { this->SourcesGroupChildren->AddObject(tgroup); } - curr_tgt_folder += "/"; } } this->TargetGroup[target] = tgroup; @@ -3648,7 +3678,6 @@ void cmGlobalXCodeGenerator::GetDocumentation(cmDocumentationEntry& entry) { entry.Name = cmGlobalXCodeGenerator::GetActualName(); entry.Brief = "Generate Xcode project files."; - entry.Full = ""; } //---------------------------------------------------------------------------- @@ -3900,9 +3929,11 @@ cmGlobalXCodeGenerator // to avoid exact duplicate file names. Note that Mac file names are not // typically case sensitive, hence the LowerCase. std::map<cmStdString, int> counts; + std::vector<cmSourceFile*> objectSources; + gt->GetObjectSources(objectSources); for(std::vector<cmSourceFile*>::const_iterator - si = gt->ObjectSources.begin(); - si != gt->ObjectSources.end(); ++si) + si = objectSources.begin(); + si != objectSources.end(); ++si) { cmSourceFile* sf = *si; std::string objectName = @@ -3916,7 +3947,7 @@ cmGlobalXCodeGenerator // TODO: emit warning about duplicate name? } - gt->Objects[sf] = objectName; + gt->AddObject(sf, objectName); } const char* configName = this->GetCMakeCFGIntDir(); diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index c053943..ae7f07e 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -53,14 +53,16 @@ public: * Try running cmake and building a file. This is used for dynalically * loaded commands, not as part of the usual build process. */ - virtual std::string GenerateBuildCommand(const char* makeProgram, - const char *projectName, - const char *projectDir, - const char* additionalOptions, - const char *targetName, - const char* config, - bool ignoreErrors, - bool fast); + virtual void GenerateBuildCommand( + std::vector<std::string>& makeCommand, + const char* makeProgram, + const char* projectName, + const char* projectDir, + const char* targetName, + const char* config, + bool fast, + std::vector<std::string> const& makeOptions = std::vector<std::string>() + ); /** * Generate the all required files for building this project/tree. This @@ -123,7 +125,7 @@ private: multipleOutputPairs ); - cmXCodeObject* FindXCodeTarget(cmTarget*); + cmXCodeObject* FindXCodeTarget(cmTarget const*); std::string GetOrCreateId(const char* name, const char* id); // create cmXCodeObject from these functions so that memory can be managed @@ -210,6 +212,7 @@ protected: std::vector<cmXCodeObject*> XCodeObjects; cmXCodeObject* RootObject; private: + void PrintCompilerAdvice(std::ostream&, std::string, const char*) const {} void ComputeTargetObjects(cmGeneratorTarget* gt) const; std::string GetObjectsNormalDirectory( diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 4816da9..3a7070e 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -534,8 +534,8 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt) ostr << this->GraphNodePrefix << cnt++; this->TargetNamesNodes[libName] = ostr.str(); this->TargetPtrs[libName] = NULL; - //str << " \"" << ostr.c_str() << "\" [ label=\"" << libName - //<< "\" shape=\"ellipse\"];" << std::endl; + // str << " \"" << ostr.c_str() << "\" [ label=\"" << libName + // << "\" shape=\"ellipse\"];" << std::endl; } } } diff --git a/Source/cmHexFileConverter.cxx b/Source/cmHexFileConverter.cxx index a540825..6ea597e 100644 --- a/Source/cmHexFileConverter.cxx +++ b/Source/cmHexFileConverter.cxx @@ -166,7 +166,7 @@ cmHexFileConverter::FileType cmHexFileConverter::DetermineFileType( const char* inFileName) { char buf[1024]; - FILE* inFile = fopen(inFileName, "rb"); + FILE* inFile = cmsys::SystemTools::Fopen(inFileName, "rb"); if (inFile == 0) { return Binary; @@ -223,8 +223,8 @@ bool cmHexFileConverter::TryConvert(const char* inFileName, } // try to open the file - FILE* inFile = fopen(inFileName, "rb"); - FILE* outFile = fopen(outFileName, "wb"); + FILE* inFile = cmsys::SystemTools::Fopen(inFileName, "rb"); + FILE* outFile = cmsys::SystemTools::Fopen(outFileName, "wb"); if ((inFile == 0) || (outFile == 0)) { if (inFile != 0) diff --git a/Source/cmIfCommand.h b/Source/cmIfCommand.h index f794b78..f2633ad 100644 --- a/Source/cmIfCommand.h +++ b/Source/cmIfCommand.h @@ -66,187 +66,10 @@ public: virtual const char* GetName() const { return "if";} /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Conditionally execute a group of commands."; - } - - /** * This determines if the command is invoked when in script mode. */ virtual bool IsScriptable() const { return true; } - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " if(expression)\n" - " # then section.\n" - " COMMAND1(ARGS ...)\n" - " COMMAND2(ARGS ...)\n" - " ...\n" - " elseif(expression2)\n" - " # elseif section.\n" - " COMMAND1(ARGS ...)\n" - " COMMAND2(ARGS ...)\n" - " ...\n" - " else(expression)\n" - " # else section.\n" - " COMMAND1(ARGS ...)\n" - " COMMAND2(ARGS ...)\n" - " ...\n" - " endif(expression)\n" - "Evaluates the given expression. If the result is true, the commands " - "in the THEN section are invoked. Otherwise, the commands in the " - "else section are invoked. The elseif and else sections are " - "optional. You may have multiple elseif clauses. Note that " - "the expression in the else and endif clause is optional. Long " - "expressions can be used and there is a traditional order of " - "precedence. " - "Parenthetical expressions are evaluated first followed by unary " - "operators such as EXISTS, COMMAND, and DEFINED. " - "Then any EQUAL, LESS, GREATER, STRLESS, STRGREATER, STREQUAL, MATCHES " - "will be evaluated. Then NOT operators and finally AND, OR operators " - "will be evaluated. Possible expressions are:\n" - " if(<constant>)\n" - "True if the constant is 1, ON, YES, TRUE, Y, or a non-zero number. " - "False if the constant is 0, OFF, NO, FALSE, N, IGNORE, NOTFOUND, '', " - "or ends in the suffix '-NOTFOUND'. " - "Named boolean constants are case-insensitive. " - "If the argument is not one of these constants, " - "it is treated as a variable:" - "\n" - " if(<variable>)\n" - "True if the variable is defined to a value that is not a false " - "constant. False otherwise. " - "(Note macro arguments are not variables.)" - "\n" - " if(NOT <expression>)\n" - "True if the expression is not true." - "\n" - " if(<expr1> AND <expr2>)\n" - "True if both expressions would be considered true individually." - "\n" - " if(<expr1> OR <expr2>)\n" - "True if either expression would be considered true individually." - "\n" - " if(COMMAND command-name)\n" - "True if the given name is a command, macro or function that can be " - "invoked.\n" - " if(POLICY policy-id)\n" - "True if the given name is an existing policy " - "(of the form CMP<NNNN>).\n" - " if(TARGET target-name)\n" - "True if the given name is an existing target, built or imported.\n" - " if(EXISTS file-name)\n" - " if(EXISTS directory-name)\n" - "True if the named file or directory exists. " - "Behavior is well-defined only for full paths.\n" - " if(file1 IS_NEWER_THAN file2)\n" - "True if file1 is newer than file2 or if one of the two files " - "doesn't exist. " - "Behavior is well-defined only for full paths. " - "If the file time stamps are exactly the same, an " - "IS_NEWER_THAN comparison returns true, so that any dependent " - "build operations will occur in the event of a tie. " - "This includes the case of passing the same file name for both " - "file1 and file2.\n" - " if(IS_DIRECTORY directory-name)\n" - "True if the given name is a directory. " - "Behavior is well-defined only for full paths.\n" - " if(IS_SYMLINK file-name)\n" - "True if the given name is a symbolic link. " - "Behavior is well-defined only for full paths.\n" - " if(IS_ABSOLUTE path)\n" - "True if the given path is an absolute path.\n" - " if(<variable|string> MATCHES regex)\n" - "True if the given string or variable's value matches the given " - "regular expression.\n" - " if(<variable|string> LESS <variable|string>)\n" - " if(<variable|string> GREATER <variable|string>)\n" - " if(<variable|string> EQUAL <variable|string>)\n" - "True if the given string or variable's value is a valid number and " - "the inequality or equality is true.\n" - " if(<variable|string> STRLESS <variable|string>)\n" - " if(<variable|string> STRGREATER <variable|string>)\n" - " if(<variable|string> STREQUAL <variable|string>)\n" - "True if the given string or variable's value is lexicographically " - "less (or greater, or equal) than the string or variable on the right.\n" - " if(<variable|string> VERSION_LESS <variable|string>)\n" - " if(<variable|string> VERSION_EQUAL <variable|string>)\n" - " if(<variable|string> VERSION_GREATER <variable|string>)\n" - "Component-wise integer version number comparison (version format is " - "major[.minor[.patch[.tweak]]]).\n" - " if(DEFINED <variable>)\n" - "True if the given variable is defined. It does not matter if the " - "variable is true or false just if it has been set.\n" - " if((expression) AND (expression OR (expression)))\n" - "The expressions inside the parenthesis are evaluated first and " - "then the remaining expression is evaluated as in the previous " - "examples. Where there are nested parenthesis the innermost are " - "evaluated as part of evaluating the expression " - "that contains them." - "\n" - - "The if command was written very early in CMake's history, predating " - "the ${} variable evaluation syntax, and for convenience evaluates " - "variables named by its arguments as shown in the above signatures. " - "Note that normal variable evaluation with ${} applies before the " - "if command even receives the arguments. " - "Therefore code like\n" - " set(var1 OFF)\n" - " set(var2 \"var1\")\n" - " if(${var2})\n" - "appears to the if command as\n" - " if(var1)\n" - "and is evaluated according to the if(<variable>) case " - "documented above. " - "The result is OFF which is false. " - "However, if we remove the ${} from the example then the command sees\n" - " if(var2)\n" - "which is true because var2 is defined to \"var1\" which is not " - "a false constant." - "\n" - "Automatic evaluation applies in the other cases whenever the " - "above-documented signature accepts <variable|string>:\n" - - "1) The left hand argument to MATCHES is first checked to see " - "if it is a defined variable, if so the variable's value is " - "used, otherwise the original value is used. \n" - - "2) If the left hand argument to MATCHES is missing it returns " - "false without error \n" - - "3) Both left and right hand arguments to LESS GREATER EQUAL " - "are independently tested to see if they are defined variables, " - "if so their defined values are used otherwise the original " - "value is used. \n" - - "4) Both left and right hand arguments to STRLESS STREQUAL " - "STRGREATER are independently tested to see if they are defined " - "variables, if so their defined values are used otherwise the " - "original value is used. \n" - - "5) Both left and right hand argumemnts to VERSION_LESS " - "VERSION_EQUAL VERSION_GREATER are independently tested to see " - "if they are defined variables, if so their defined values are " - "used otherwise the original value is used. \n" - - "6) The right hand argument to NOT is tested to see if it is a " - "boolean constant, if so the value is used, otherwise it is " - "assumed to be a variable and it is dereferenced. \n" - - "7) The left and right hand arguments to AND OR are " - "independently tested to see if they are boolean constants, if " - "so they are used as such, otherwise they are assumed to be " - "variables and are dereferenced. \n" - ; - } - // this is a shared function for both If and Else to determine if the // arguments were valid, and if so, was the response true. If there is // an error, the errorString will be set. diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx index bb891d6..e8ee33f 100644 --- a/Source/cmIncludeCommand.cxx +++ b/Source/cmIncludeCommand.cxx @@ -19,7 +19,7 @@ bool cmIncludeCommand if (args.size()< 1 || args.size() > 4) { this->SetError("called with wrong number of arguments. " - "Include only takes one file."); + "include() only takes one file."); return false; } bool optional = false; @@ -88,6 +88,48 @@ bool cmIncludeCommand fname = mfile.c_str(); } } + + std::string fname_abs = + cmSystemTools::CollapseFullPath(fname.c_str(), + this->Makefile->GetStartDirectory()); + + cmGlobalGenerator *gg = this->Makefile->GetLocalGenerator() + ->GetGlobalGenerator(); + if (gg->IsExportedTargetsFile(fname_abs)) + { + const char *modal = 0; + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0024)) + { + case cmPolicies::WARN: + modal = "should"; + case cmPolicies::OLD: + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + modal = "may"; + messageType = cmake::FATAL_ERROR; + } + if (modal) + { + cmOStringStream e; + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0024)) << "\n"; + e << "The file\n " << fname_abs << "\nwas generated by the export() " + "command. It " << modal << " not be used as the argument to the " + "include() command. Use ALIAS targets instead to refer to targets " + "by alternative names.\n"; + this->Makefile->IssueMessage(messageType, e.str().c_str()); + if (messageType == cmake::FATAL_ERROR) + { + return false; + } + } + gg->GenerateImportFile(fname_abs); + } + std::string fullFilePath; bool readit = this->Makefile->ReadListFile( this->Makefile->GetCurrentListFile(), diff --git a/Source/cmIncludeCommand.h b/Source/cmIncludeCommand.h index d97b7c3..267723d 100644 --- a/Source/cmIncludeCommand.h +++ b/Source/cmIncludeCommand.h @@ -15,9 +15,7 @@ #include "cmCommand.h" /** \class cmIncludeCommand - * \brief - * - * cmIncludeCommand defines a list of distant + * \brief cmIncludeCommand defines a list of distant * files that can be "included" in the current list file. * In almost every sense, this is identical to a C/C++ * #include command. Arguments are first expended as usual. @@ -50,41 +48,6 @@ public: */ virtual const char* GetName() const {return "include";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Load and run CMake code from a file or module."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " include(<file|module> [OPTIONAL] [RESULT_VARIABLE <VAR>]\n" - " [NO_POLICY_SCOPE])\n" - "Load and run CMake code from the file given. " - "Variable reads and writes access the scope of the caller " - "(dynamic scoping). " - "If OPTIONAL is present, then no error " - "is raised if the file does not exist. If RESULT_VARIABLE is given " - "the variable will be set to the full filename which " - "has been included or NOTFOUND if it failed.\n" - "If a module is specified instead of a file, the file with name " - "<modulename>.cmake is searched first in CMAKE_MODULE_PATH, then in the " - "CMake module directory. There is one exception to this: if the file " - "which calls include() is located itself in the CMake module directory, " - "then first the CMake module directory is searched and " - "CMAKE_MODULE_PATH afterwards. See also policy CMP0017." - "\n" - "See the cmake_policy() command documentation for discussion of the " - "NO_POLICY_SCOPE option." - ; - } - cmTypeMacro(cmIncludeCommand, cmCommand); }; diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx index 30c1743..e20fe02 100644 --- a/Source/cmIncludeDirectoryCommand.cxx +++ b/Source/cmIncludeDirectoryCommand.cxx @@ -55,7 +55,7 @@ bool cmIncludeDirectoryCommand std::vector<std::string> includes; - GetIncludes(*i, includes); + this->GetIncludes(*i, includes); if (before) { diff --git a/Source/cmIncludeDirectoryCommand.h b/Source/cmIncludeDirectoryCommand.h index 77a340a..c621dcb 100644 --- a/Source/cmIncludeDirectoryCommand.h +++ b/Source/cmIncludeDirectoryCommand.h @@ -43,44 +43,6 @@ public: */ virtual const char* GetName() const { return "include_directories";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Add include directories to the build."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " include_directories([AFTER|BEFORE] [SYSTEM] dir1 dir2 ...)\n" - "Add the given directories to those the compiler uses to search " - "for include files. Relative paths are interpreted as relative to " - "the current source directory. \n" - "The include directories are added to the directory property " - "INCLUDE_DIRECTORIES for the current CMakeLists file. " - "They are also added to the target property INCLUDE_DIRECTORIES " - "for each target in the current CMakeLists file. " - "The target property values are the ones used by the generators." - "\n" - "By default the directories are appended onto the current list of " - "directories. " - "This default behavior can be changed by setting " - "CMAKE_INCLUDE_DIRECTORIES_BEFORE to ON. " - "By using AFTER or BEFORE explicitly, you can select between " - "appending and prepending, independent of the default. " - "\n" - "If the SYSTEM option is given, the compiler will be told the " - "directories are meant as system include directories on some " - "platforms (signalling this setting might achieve effects such as " - "the compiler skipping warnings, or these fixed-install system files " - "not being considered in dependency calculations - see compiler docs)."; - } - cmTypeMacro(cmIncludeDirectoryCommand, cmCommand); protected: diff --git a/Source/cmIncludeExternalMSProjectCommand.h b/Source/cmIncludeExternalMSProjectCommand.h index d5cec01..8ca674f 100644 --- a/Source/cmIncludeExternalMSProjectCommand.h +++ b/Source/cmIncludeExternalMSProjectCommand.h @@ -44,38 +44,6 @@ public: */ virtual const char* GetName() const {return "include_external_msproject";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Include an external Microsoft project file in a workspace."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " include_external_msproject(projectname location\n" - " [TYPE projectTypeGUID]\n" - " [GUID projectGUID]\n" - " [PLATFORM platformName]\n" - " dep1 dep2 ...)\n" - "Includes an external Microsoft project in the generated workspace " - "file. Currently does nothing on UNIX. This will create a " - "target named [projectname]. This can be used in the add_dependencies " - "command to make things depend on the external project." - "\n" - "TYPE, GUID and PLATFORM are optional parameters that allow one " - "to specify the type of project, id (GUID) of the project and " - "the name of the target platform. " - "This is useful for projects requiring values other than the default " - "(e.g. WIX projects). " - "These options are not supported by the Visual Studio 6 generator."; - } - cmTypeMacro(cmIncludeExternalMSProjectCommand, cmCommand); }; diff --git a/Source/cmIncludeRegularExpressionCommand.h b/Source/cmIncludeRegularExpressionCommand.h index 2e41775..0c5fa6f 100644 --- a/Source/cmIncludeRegularExpressionCommand.h +++ b/Source/cmIncludeRegularExpressionCommand.h @@ -43,30 +43,6 @@ public: */ virtual const char* GetName() const {return "include_regular_expression";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Set the regular expression used for dependency checking."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " include_regular_expression(regex_match [regex_complain])\n" - "Set the regular expressions used in dependency checking. Only files " - "matching regex_match will be traced as dependencies. Only files " - "matching regex_complain will generate warnings if they cannot be " - "found " - "(standard header paths are not searched). The defaults are:\n" - " regex_match = \"^.*$\" (match everything)\n" - " regex_complain = \"^$\" (match empty string only)"; - } - cmTypeMacro(cmIncludeRegularExpressionCommand, cmCommand); }; diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 3c76bd6..10578f2 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -379,7 +379,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) target->GetType() != cmTarget::STATIC_LIBRARY && target->GetType() != cmTarget::SHARED_LIBRARY && target->GetType() != cmTarget::MODULE_LIBRARY && - target->GetType() != cmTarget::OBJECT_LIBRARY) + target->GetType() != cmTarget::OBJECT_LIBRARY && + target->GetType() != cmTarget::INTERFACE_LIBRARY) { cmOStringStream e; e << "TARGETS given target \"" << (*targetIt) @@ -626,6 +627,11 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) } } break; + case cmTarget::INTERFACE_LIBRARY: + // Nothing to do. An INTERFACE_LIBRARY can be installed, but the + // only effect of that is to make it exportable. It installs no + // other files itself. + break; default: // This should never happen due to the above type check. // Ignore the case. @@ -639,7 +645,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) // generators for them. bool createInstallGeneratorsForTargetFileSets = true; - if(target.IsFrameworkOnApple()) + if(target.IsFrameworkOnApple() + || target.GetType() == cmTarget::INTERFACE_LIBRARY) { createInstallGeneratorsForTargetFileSets = false; } diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h index 6509501..9db2490 100644 --- a/Source/cmInstallCommand.h +++ b/Source/cmInstallCommand.h @@ -43,307 +43,6 @@ public: */ virtual const char* GetName() const { return "install";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Specify rules to run at install time."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - "This command generates installation rules for a project. " - "Rules specified by calls to this command within a source directory " - "are executed in order during installation. " - "The order across directories is not defined." - "\n" - "There are multiple signatures for this command. Some of them define " - "installation properties for files and targets. Properties common to " - "multiple signatures are covered here but they are valid only for " - "signatures that specify them.\n" - "DESTINATION arguments specify " - "the directory on disk to which a file will be installed. " - "If a full path (with a leading slash or drive letter) is given it " - "is used directly. If a relative path is given it is interpreted " - "relative to the value of CMAKE_INSTALL_PREFIX. The prefix can " - "be relocated at install time using DESTDIR mechanism explained in the " - "CMAKE_INSTALL_PREFIX variable documentation.\n" - "PERMISSIONS arguments specify permissions for installed files. " - "Valid permissions are " - "OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, " - "GROUP_READ, GROUP_WRITE, GROUP_EXECUTE, " - "WORLD_READ, WORLD_WRITE, WORLD_EXECUTE, " - "SETUID, and SETGID. " - "Permissions that do not make sense on certain platforms are ignored " - "on those platforms.\n" - "The CONFIGURATIONS argument specifies a list of build configurations " - "for which the install rule applies (Debug, Release, etc.).\n" - "The COMPONENT argument specifies an installation component name " - "with which the install rule is associated, such as \"runtime\" or " - "\"development\". During component-specific installation only " - "install rules associated with the given component name will be " - "executed. During a full installation all components are installed." - " If COMPONENT is not provided a default component \"Unspecified\" is" - " created. The default component name may be controlled with the " - "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME variable.\n" - "The RENAME argument specifies a name for an installed file that " - "may be different from the original file. Renaming is allowed only " - "when a single file is installed by the command.\n" - "The OPTIONAL argument specifies that it is not an error if the " - "file to be installed does not exist. " - "\n" - "The TARGETS signature:\n" - " install(TARGETS targets... [EXPORT <export-name>]\n" - " [[ARCHIVE|LIBRARY|RUNTIME|FRAMEWORK|BUNDLE|\n" - " PRIVATE_HEADER|PUBLIC_HEADER|RESOURCE]\n" - " [DESTINATION <dir>]\n" - " [INCLUDES DESTINATION [<dir> ...]]\n" - " [PERMISSIONS permissions...]\n" - " [CONFIGURATIONS [Debug|Release|...]]\n" - " [COMPONENT <component>]\n" - " [OPTIONAL] [NAMELINK_ONLY|NAMELINK_SKIP]\n" - " ] [...])\n" - "The TARGETS form specifies rules for installing targets from a " - "project. There are five kinds of target files that may be " - "installed: ARCHIVE, LIBRARY, RUNTIME, FRAMEWORK, and BUNDLE. " - - "Executables are treated as RUNTIME targets, except that those " - "marked with the MACOSX_BUNDLE property are treated as BUNDLE " - "targets on OS X. " - "Static libraries are always treated as ARCHIVE targets. " - "Module libraries are always treated as LIBRARY targets. " - "For non-DLL platforms shared libraries are treated as LIBRARY " - "targets, except that those marked with the FRAMEWORK property " - "are treated as FRAMEWORK targets on OS X. " - "For DLL platforms the DLL part of a shared library is treated as " - "a RUNTIME target and the corresponding import library is treated as " - "an ARCHIVE target. " - "All Windows-based systems including Cygwin are DLL platforms. " - "The ARCHIVE, LIBRARY, RUNTIME, and FRAMEWORK " - "arguments change the type of target to which the subsequent " - "properties " - "apply. If none is given the installation properties apply to " - "all target types. If only one is given then only targets of that " - "type will be installed (which can be used to install just a DLL or " - "just an import library)." - "The INCLUDES DESTINATION specifies a list of directories which will " - "be added to the INTERFACE_INCLUDE_DIRECTORIES of the <targets> when " - "exported by install(EXPORT). If a relative path is specified, it is " - "treated as relative to the $<INSTALL_PREFIX>." - "\n" - "The PRIVATE_HEADER, PUBLIC_HEADER, and RESOURCE arguments cause " - "subsequent properties to be applied to installing a FRAMEWORK " - "shared library target's associated files on non-Apple platforms. " - "Rules defined by these arguments are ignored on Apple platforms " - "because the associated files are installed into the appropriate " - "locations inside the framework folder. " - "See documentation of the PRIVATE_HEADER, PUBLIC_HEADER, and RESOURCE " - "target properties for details." - "\n" - "Either NAMELINK_ONLY or NAMELINK_SKIP may be specified as a LIBRARY " - "option. " - "On some platforms a versioned shared library has a symbolic link " - "such as\n" - " lib<name>.so -> lib<name>.so.1\n" - "where \"lib<name>.so.1\" is the soname of the library and " - "\"lib<name>.so\" is a \"namelink\" allowing linkers to find the " - "library when given \"-l<name>\". " - "The NAMELINK_ONLY option causes installation of only the namelink " - "when a library target is installed. " - "The NAMELINK_SKIP option causes installation of library files other " - "than the namelink when a library target is installed. " - "When neither option is given both portions are installed. " - "On platforms where versioned shared libraries do not have namelinks " - "or when a library is not versioned the NAMELINK_SKIP option installs " - "the library and the NAMELINK_ONLY option installs nothing. " - "See the VERSION and SOVERSION target properties for details on " - "creating versioned shared libraries." - "\n" - "One or more groups of properties may be specified in a single call " - "to the TARGETS form of this command. A target may be installed more " - "than once to different locations. Consider hypothetical " - "targets \"myExe\", \"mySharedLib\", and \"myStaticLib\". The code\n" - " install(TARGETS myExe mySharedLib myStaticLib\n" - " RUNTIME DESTINATION bin\n" - " LIBRARY DESTINATION lib\n" - " ARCHIVE DESTINATION lib/static)\n" - " install(TARGETS mySharedLib DESTINATION /some/full/path)\n" - "will install myExe to <prefix>/bin and myStaticLib to " - "<prefix>/lib/static. " - "On non-DLL platforms mySharedLib will be installed to <prefix>/lib " - "and /some/full/path. On DLL platforms the mySharedLib DLL will be " - "installed to <prefix>/bin and /some/full/path and its import library " - "will be installed to <prefix>/lib/static and /some/full/path." - "\n" - "The EXPORT option associates the installed target files with an " - "export called <export-name>. " - "It must appear before any RUNTIME, LIBRARY, or ARCHIVE options. " - "To actually install the export file itself, call install(EXPORT). " - "See documentation of the install(EXPORT ...) signature below for " - "details." - "\n" - "Installing a target with EXCLUDE_FROM_ALL set to true has " - "undefined behavior." - "\n" - "The FILES signature:\n" - " install(FILES files... DESTINATION <dir>\n" - " [PERMISSIONS permissions...]\n" - " [CONFIGURATIONS [Debug|Release|...]]\n" - " [COMPONENT <component>]\n" - " [RENAME <name>] [OPTIONAL])\n" - "The FILES form specifies rules for installing files for a " - "project. File names given as relative paths are interpreted with " - "respect to the current source directory. Files installed by this " - "form are by default given permissions OWNER_WRITE, OWNER_READ, " - "GROUP_READ, and WORLD_READ if no PERMISSIONS argument is given." - "\n" - "The PROGRAMS signature:\n" - " install(PROGRAMS files... DESTINATION <dir>\n" - " [PERMISSIONS permissions...]\n" - " [CONFIGURATIONS [Debug|Release|...]]\n" - " [COMPONENT <component>]\n" - " [RENAME <name>] [OPTIONAL])\n" - "The PROGRAMS form is identical to the FILES form except that the " - "default permissions for the installed file also include " - "OWNER_EXECUTE, GROUP_EXECUTE, and WORLD_EXECUTE. " - "This form is intended to install programs that are not targets, " - "such as shell scripts. Use the TARGETS form to install targets " - "built within the project." - "\n" - "The DIRECTORY signature:\n" - " install(DIRECTORY dirs... DESTINATION <dir>\n" - " [FILE_PERMISSIONS permissions...]\n" - " [DIRECTORY_PERMISSIONS permissions...]\n" - " [USE_SOURCE_PERMISSIONS] [OPTIONAL]\n" - " [CONFIGURATIONS [Debug|Release|...]]\n" - " [COMPONENT <component>] [FILES_MATCHING]\n" - " [[PATTERN <pattern> | REGEX <regex>]\n" - " [EXCLUDE] [PERMISSIONS permissions...]] [...])\n" - "The DIRECTORY form installs contents of one or more directories " - "to a given destination. " - "The directory structure is copied verbatim to the destination. " - "The last component of each directory name is appended to the " - "destination directory but a trailing slash may be used to " - "avoid this because it leaves the last component empty. " - "Directory names given as relative paths are interpreted with " - "respect to the current source directory. " - "If no input directory names are given the destination directory " - "will be created but nothing will be installed into it. " - "The FILE_PERMISSIONS and DIRECTORY_PERMISSIONS options specify " - "permissions given to files and directories in the destination. " - "If USE_SOURCE_PERMISSIONS is specified and FILE_PERMISSIONS is not, " - "file permissions will be copied from the source directory structure. " - "If no permissions are specified files will be given the default " - "permissions specified in the FILES form of the command, and the " - "directories will be given the default permissions specified in the " - "PROGRAMS form of the command.\n" - - "Installation of directories may be controlled with fine granularity " - "using the PATTERN or REGEX options. These \"match\" options specify a " - "globbing pattern or regular expression to match directories or files " - "encountered within input directories. They may be used to apply " - "certain options (see below) to a subset of the files and directories " - "encountered. " - "The full path to each input file or directory " - "(with forward slashes) is matched against the expression. " - "A PATTERN will match only complete file names: the portion of the " - "full path matching the pattern must occur at the end of the file name " - "and be preceded by a slash. " - "A REGEX will match any portion of the full path but it may use " - "'/' and '$' to simulate the PATTERN behavior. " - "By default all files and directories are installed whether " - "or not they are matched. " - "The FILES_MATCHING option may be given before the first match option " - "to disable installation of files (but not directories) not matched by " - "any expression. For example, the code\n" - " install(DIRECTORY src/ DESTINATION include/myproj\n" - " FILES_MATCHING PATTERN \"*.h\")\n" - "will extract and install header files from a source tree.\n" - "Some options may follow a PATTERN or REGEX expression and are " - "applied only to files or directories matching them. " - "The EXCLUDE option will skip the matched file or directory. " - "The PERMISSIONS option overrides the permissions setting for the " - "matched file or directory. " - "For example the code\n" - " install(DIRECTORY icons scripts/ DESTINATION share/myproj\n" - " PATTERN \"CVS\" EXCLUDE\n" - " PATTERN \"scripts/*\"\n" - " PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ\n" - " GROUP_EXECUTE GROUP_READ)\n" - "will install the icons directory to share/myproj/icons and the " - "scripts directory to share/myproj. The icons will get default file " - "permissions, the scripts will be given specific permissions, and " - "any CVS directories will be excluded." - "\n" - "The SCRIPT and CODE signature:\n" - " install([[SCRIPT <file>] [CODE <code>]] [...])\n" - "The SCRIPT form will invoke the given CMake script files during " - "installation. If the script file name is a relative path " - "it will be interpreted with respect to the current source directory. " - "The CODE form will invoke the given CMake code during installation. " - "Code is specified as a single argument inside a double-quoted string. " - "For example, the code\n" - " install(CODE \"MESSAGE(\\\"Sample install message.\\\")\")\n" - "will print a message during installation.\n" - "" - "The EXPORT signature:\n" - " install(EXPORT <export-name> DESTINATION <dir>\n" - " [NAMESPACE <namespace>] [FILE <name>.cmake]\n" - " [PERMISSIONS permissions...]\n" - " [CONFIGURATIONS [Debug|Release|...]]\n" - " [EXPORT_LINK_INTERFACE_LIBRARIES]\n" - " [COMPONENT <component>])\n" - "The EXPORT form generates and installs a CMake file containing code " - "to import targets from the installation tree into another project. " - "Target installations are associated with the export <export-name> " - "using the EXPORT option of the install(TARGETS ...) signature " - "documented above. The NAMESPACE option will prepend <namespace> to " - "the target names as they are written to the import file. " - "By default the generated file will be called <export-name>.cmake but " - "the FILE option may be used to specify a different name. The value " - "given to the FILE option must be a file name with the \".cmake\" " - "extension. " - "If a CONFIGURATIONS option is given then the file will only be " - "installed when one of the named configurations is installed. " - "Additionally, the generated import file will reference only the " - "matching target configurations. " - "The EXPORT_LINK_INTERFACE_LIBRARIES keyword, if present, causes the " - "contents of the properties matching " - "(IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)? to be exported, when " - "policy CMP0022 is NEW. " - "If a COMPONENT option is specified that does not match that given " - "to the targets associated with <export-name> the behavior is " - "undefined. " - "If a library target is included in the export but " - "a target to which it links is not included the behavior is " - "unspecified." - "\n" - "The EXPORT form is useful to help outside projects use targets built " - "and installed by the current project. For example, the code\n" - " install(TARGETS myexe EXPORT myproj DESTINATION bin)\n" - " install(EXPORT myproj NAMESPACE mp_ DESTINATION lib/myproj)\n" - "will install the executable myexe to <prefix>/bin and code to import " - "it in the file \"<prefix>/lib/myproj/myproj.cmake\". " - "An outside project may load this file with the include command " - "and reference the myexe executable from the installation tree using " - "the imported target name mp_myexe as if the target were built " - "in its own tree." - "\n" - "NOTE: This command supercedes the INSTALL_TARGETS command and the " - "target properties PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT. " - "It also replaces the FILES forms of the INSTALL_FILES and " - "INSTALL_PROGRAMS commands. " - "The processing order of these install rules relative to those " - "generated by INSTALL_TARGETS, INSTALL_FILES, and INSTALL_PROGRAMS " - "commands is not defined.\n" - ; - } - cmTypeMacro(cmInstallCommand, cmCommand); private: diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx index 91ea861..236ca1f 100644 --- a/Source/cmInstallCommandArguments.cxx +++ b/Source/cmInstallCommandArguments.cxx @@ -228,11 +228,6 @@ void cmInstallCommandIncludesArgument::Parse( for ( ; it != args->end(); ++it) { std::string dir = *it; - if (!cmSystemTools::FileIsFullPath(it->c_str()) - && cmGeneratorExpression::Find(*it) == std::string::npos) - { - dir = "$<INSTALL_PREFIX>/" + dir; - } cmSystemTools::ConvertToUnixSlashes(dir); this->IncludeDirs.push_back(dir); } diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 3e9e6ac..1287ea6 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -183,11 +183,11 @@ cmInstallExportGenerator::GenerateScriptConfigs(std::ostream& os, { files.push_back(i->second); std::string config_test = this->CreateConfigTest(i->first.c_str()); - os << indent << "IF(" << config_test << ")\n"; + os << indent << "if(" << config_test << ")\n"; this->AddInstallRule(os, cmInstallType_FILES, files, false, this->FilePermissions.c_str(), 0, 0, 0, indent.Next()); - os << indent << "ENDIF(" << config_test << ")\n"; + os << indent << "endif()\n"; files.clear(); } } @@ -202,23 +202,23 @@ void cmInstallExportGenerator::GenerateScriptActions(std::ostream& os, installedDir += "/"; std::string installedFile = installedDir; installedFile += this->FileName; - os << indent << "IF(EXISTS \"" << installedFile << "\")\n"; + os << indent << "if(EXISTS \"" << installedFile << "\")\n"; Indent indentN = indent.Next(); Indent indentNN = indentN.Next(); Indent indentNNN = indentNN.Next(); - os << indentN << "FILE(DIFFERENT EXPORT_FILE_CHANGED FILES\n" + os << indentN << "file(DIFFERENT 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(EXPORT_FILE_CHANGED)\n"; + os << indentNN << "file(GLOB OLD_CONFIG_FILES \"" << installedDir << this->EFGen->GetConfigImportFileGlob() << "\")\n"; - os << indentNN << "IF(OLD_CONFIG_FILES)\n"; - os << indentNNN << "MESSAGE(STATUS \"Old export file \\\"" << installedFile + os << indentNN << "if(OLD_CONFIG_FILES)\n"; + os << indentNNN << "message(STATUS \"Old export file \\\"" << installedFile << "\\\" will be replaced. Removing files [${OLD_CONFIG_FILES}].\")\n"; - os << indentNNN << "FILE(REMOVE ${OLD_CONFIG_FILES})\n"; - os << indentNN << "ENDIF(OLD_CONFIG_FILES)\n"; - os << indentN << "ENDIF(EXPORT_FILE_CHANGED)\n"; - os << indent << "ENDIF()\n"; + os << indentNNN << "file(REMOVE ${OLD_CONFIG_FILES})\n"; + os << indentNN << "endif()\n"; + os << indentN << "endif()\n"; + os << indent << "endif()\n"; // Install the main export file. std::vector<std::string> files; diff --git a/Source/cmInstallFilesCommand.h b/Source/cmInstallFilesCommand.h index bb0a6cc..5583fe4 100644 --- a/Source/cmInstallFilesCommand.h +++ b/Source/cmInstallFilesCommand.h @@ -44,14 +44,6 @@ public: virtual const char* GetName() const { return "install_files";} /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Deprecated. Use the install(FILES ) command instead."; - } - - /** * This is called at the end after all the information * specified by the command is accumulated. Most commands do * not implement this method. At this point, reading and @@ -60,37 +52,6 @@ public: virtual void FinalPass(); virtual bool HasFinalPass() const { return !this->IsFilesForm; } - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - "This command has been superceded by the install command. It " - "is provided for compatibility with older CMake code. " - "The FILES form is directly replaced by the FILES form of the " - "install command. The regexp form can be expressed " - "more clearly using the GLOB form of the file command.\n" - " install_files(<dir> extension file file ...)\n" - "Create rules to install the listed files with the given extension " - "into the given directory. " - "Only files existing in the current source tree or its corresponding " - "location in the binary tree may be listed. " - "If a file specified already has an extension, that extension will be " - "removed first. This is useful for providing lists of source files " - "such as foo.cxx when you want the corresponding foo.h to be " - "installed. A typical extension is '.h'.\n" - " install_files(<dir> regexp)\n" - "Any files in the current source directory that match the regular " - "expression will be installed.\n" - " install_files(<dir> FILES file file ...)\n" - "Any files listed after the FILES keyword will be " - "installed explicitly from the names given. Full paths are allowed in " - "this form.\n" - "The directory <dir> is relative to the installation prefix, which " - "is stored in the variable CMAKE_INSTALL_PREFIX."; - } - /** This command is kept for compatibility with older CMake versions. */ virtual bool IsDiscouraged() const { diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx index 3be2c2b..d105a0c 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -80,18 +80,18 @@ void cmInstallGenerator } } os << "\")\n"; - os << indent << "IF (CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)\n"; + os << indent << "if(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)\n"; os << indent << indent << "message(WARNING \"ABSOLUTE path INSTALL " << "DESTINATION : ${CMAKE_ABSOLUTE_DESTINATION_FILES}\")\n"; - os << indent << "ENDIF (CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)\n"; + os << indent << "endif()\n"; - os << indent << "IF (CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)\n"; + os << indent << "if(CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)\n"; os << indent << indent << "message(FATAL_ERROR \"ABSOLUTE path INSTALL " << "DESTINATION forbidden (by caller): " << "${CMAKE_ABSOLUTE_DESTINATION_FILES}\")\n"; - os << indent << "ENDIF (CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)\n"; + os << indent << "endif()\n"; } - os << "FILE(INSTALL DESTINATION \"" << dest << "\" TYPE " << stype.c_str(); + os << "file(INSTALL DESTINATION \"" << dest << "\" TYPE " << stype.c_str(); if(optional) { os << " OPTIONAL"; @@ -153,13 +153,13 @@ void cmInstallGenerator::GenerateScript(std::ostream& os) // Begin this block of installation. std::string component_test = this->CreateComponentTest(this->Component.c_str()); - os << indent << "IF(" << component_test << ")\n"; + os << indent << "if(" << component_test << ")\n"; // Generate the script possibly with per-configuration code. this->GenerateScriptConfigs(os, indent.Next()); // End this block of installation. - os << indent << "ENDIF(" << component_test << ")\n\n"; + os << indent << "endif()\n\n"; } //---------------------------------------------------------------------------- diff --git a/Source/cmInstallProgramsCommand.h b/Source/cmInstallProgramsCommand.h index 27a0498..95acfa2 100644 --- a/Source/cmInstallProgramsCommand.h +++ b/Source/cmInstallProgramsCommand.h @@ -44,14 +44,6 @@ public: virtual const char* GetName() const { return "install_programs";} /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Deprecated. Use the install(PROGRAMS ) command instead."; - } - - /** * This is called at the end after all the information * specified by the command is accumulated. Most commands do * not implement this method. At this point, reading and @@ -61,33 +53,6 @@ public: virtual bool HasFinalPass() const { return true; } - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - "This command has been superceded by the install command. It " - "is provided for compatibility with older CMake code. " - "The FILES form is directly replaced by the PROGRAMS form of the " - "INSTALL command. The regexp form can be expressed more clearly " - "using the GLOB form of the FILE command.\n" - " install_programs(<dir> file1 file2 [file3 ...])\n" - " install_programs(<dir> FILES file1 [file2 ...])\n" - "Create rules to install the listed programs into the given directory. " - "Use the FILES argument to guarantee that the file list version of " - "the command will be used even when there is only one argument.\n" - " install_programs(<dir> regexp)\n" - "In the second form any program in the current source directory that " - "matches the regular expression will be installed.\n" - "This command is intended to install programs that are not built " - "by cmake, such as shell scripts. See the TARGETS form of " - "the INSTALL command to " - "create installation rules for targets built by cmake.\n" - "The directory <dir> is relative to the installation prefix, which " - "is stored in the variable CMAKE_INSTALL_PREFIX."; - } - /** This command is kept for compatibility with older CMake versions. */ virtual bool IsDiscouraged() const { diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx index bcfbe63..1ecf021 100644 --- a/Source/cmInstallScriptGenerator.cxx +++ b/Source/cmInstallScriptGenerator.cxx @@ -32,7 +32,7 @@ void cmInstallScriptGenerator::GenerateScript(std::ostream& os) Indent indent; std::string component_test = this->CreateComponentTest(this->Component.c_str()); - os << indent << "IF(" << component_test << ")\n"; + os << indent << "if(" << component_test << ")\n"; if(this->Code) { @@ -40,8 +40,8 @@ void cmInstallScriptGenerator::GenerateScript(std::ostream& os) } else { - os << indent.Next() << "INCLUDE(\"" << this->Script << "\")\n"; + os << indent.Next() << "include(\"" << this->Script << "\")\n"; } - os << indent << "ENDIF(" << component_test << ")\n\n"; + os << indent << "endif()\n\n"; } diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index c9624c8..68f45a6 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -90,6 +90,11 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, case cmTarget::STATIC_LIBRARY: type = cmInstallType_STATIC_LIBRARY; break; case cmTarget::SHARED_LIBRARY: type = cmInstallType_SHARED_LIBRARY; break; case cmTarget::MODULE_LIBRARY: type = cmInstallType_MODULE_LIBRARY; break; + case cmTarget::INTERFACE_LIBRARY: + // Not reachable. We never create a cmInstallTargetGenerator for + // an INTERFACE_LIBRARY. + assert(!"INTERFACE_LIBRARY targets have no installable outputs."); + break; case cmTarget::OBJECT_LIBRARY: case cmTarget::UTILITY: case cmTarget::GLOBAL_TARGET: @@ -323,9 +328,10 @@ cmInstallTargetGenerator::GetInstallFilename(const char* config) const } //---------------------------------------------------------------------------- -std::string cmInstallTargetGenerator::GetInstallFilename(cmTarget* target, - const char* config, - NameType nameType) +std::string +cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, + const char* config, + NameType nameType) { std::string fname; // Compute the name of the library. @@ -407,10 +413,10 @@ cmInstallTargetGenerator std::string tws = tw.str(); if(!tws.empty()) { - os << indent << "IF(EXISTS \"" << file << "\" AND\n" + os << indent << "if(EXISTS \"" << file << "\" AND\n" << indent << " NOT IS_SYMLINK \"" << file << "\")\n"; os << tws; - os << indent << "ENDIF()\n"; + os << indent << "endif()\n"; } } @@ -434,7 +440,7 @@ cmInstallTargetGenerator if(!tws.empty()) { Indent indent2 = indent.Next().Next(); - os << indent << "FOREACH(file\n"; + os << indent << "foreach(file\n"; for(std::vector<std::string>::const_iterator i = files.begin(); i != files.end(); ++i) { @@ -442,7 +448,7 @@ cmInstallTargetGenerator } os << indent2 << ")\n"; os << tws; - os << indent << "ENDFOREACH()\n"; + os << indent << "endforeach()\n"; } } } @@ -510,11 +516,12 @@ cmInstallTargetGenerator std::map<cmStdString, cmStdString> install_name_remap; if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config)) { - std::set<cmTarget*> const& sharedLibs = cli->GetSharedLibrariesLinked(); - for(std::set<cmTarget*>::const_iterator j = sharedLibs.begin(); + std::set<cmTarget const*> const& sharedLibs + = cli->GetSharedLibrariesLinked(); + for(std::set<cmTarget const*>::const_iterator j = sharedLibs.begin(); j != sharedLibs.end(); ++j) { - cmTarget* tgt = *j; + cmTarget const* tgt = *j; // The install_name of an imported target does not change. if(tgt->IsImported()) @@ -577,7 +584,7 @@ cmInstallTargetGenerator // install_name value and references. if(!new_id.empty() || !install_name_remap.empty()) { - os << indent << "EXECUTE_PROCESS(COMMAND \"" << installNameTool; + os << indent << "execute_process(COMMAND \"" << installNameTool; os << "\""; if(!new_id.empty()) { @@ -626,7 +633,7 @@ cmInstallTargetGenerator // Write a rule to remove the installed file if its rpath is not the // new rpath. This is needed for existing build/install trees when // the installed rpath changes but the file is not rebuilt. - os << indent << "FILE(RPATH_CHECK\n" + os << indent << "file(RPATH_CHECK\n" << indent << " FILE \"" << toDestDirPath << "\"\n" << indent << " RPATH \"" << newRpath << "\")\n"; } @@ -697,12 +704,12 @@ cmInstallTargetGenerator // Write a rule to run chrpath to set the install-tree RPATH if(newRpath.empty()) { - os << indent << "FILE(RPATH_REMOVE\n" + os << indent << "file(RPATH_REMOVE\n" << indent << " FILE \"" << toDestDirPath << "\")\n"; } else { - os << indent << "FILE(RPATH_CHANGE\n" + os << indent << "file(RPATH_CHANGE\n" << indent << " FILE \"" << toDestDirPath << "\"\n" << indent << " OLD_RPATH \"" << oldRpath << "\"\n" << indent << " NEW_RPATH \"" << newRpath << "\")\n"; @@ -736,11 +743,11 @@ cmInstallTargetGenerator::AddStripRule(std::ostream& os, return; } - os << indent << "IF(CMAKE_INSTALL_DO_STRIP)\n"; - os << indent << " EXECUTE_PROCESS(COMMAND \"" + os << indent << "if(CMAKE_INSTALL_DO_STRIP)\n"; + os << indent << " execute_process(COMMAND \"" << this->Target->GetMakefile()->GetDefinition("CMAKE_STRIP") << "\" \"" << toDestDirPath << "\")\n"; - os << indent << "ENDIF(CMAKE_INSTALL_DO_STRIP)\n"; + os << indent << "endif()\n"; } //---------------------------------------------------------------------------- @@ -769,6 +776,6 @@ cmInstallTargetGenerator::AddRanlibRule(std::ostream& os, return; } - os << indent << "EXECUTE_PROCESS(COMMAND \"" + os << indent << "execute_process(COMMAND \"" << ranlib << "\" \"" << toDestDirPath << "\")\n"; } diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 8cf72f9..18c3957 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -53,7 +53,8 @@ public: NameReal }; - static std::string GetInstallFilename(cmTarget*target, const char* config, + static std::string GetInstallFilename(cmTarget const* target, + const char* config, NameType nameType = NameNormal); cmTarget* GetTarget() const { return this->Target; } diff --git a/Source/cmInstallTargetsCommand.h b/Source/cmInstallTargetsCommand.h index c47b387..2aa34db 100644 --- a/Source/cmInstallTargetsCommand.h +++ b/Source/cmInstallTargetsCommand.h @@ -44,30 +44,6 @@ public: */ virtual const char* GetName() const { return "install_targets";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Deprecated. Use the install(TARGETS ) command instead."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - "This command has been superceded by the install command. It " - "is provided for compatibility with older CMake code.\n" - " install_targets(<dir> [RUNTIME_DIRECTORY dir] target target)\n" - "Create rules to install the listed targets into the given directory. " - "The directory <dir> is relative to the installation prefix, which " - "is stored in the variable CMAKE_INSTALL_PREFIX. If RUNTIME_DIRECTORY " - "is specified, then on systems with special runtime files " - "(Windows DLL), the files will be copied to that directory."; - } - /** This command is kept for compatibility with older CMake versions. */ virtual bool IsDiscouraged() const { diff --git a/Source/cmLinkDirectoriesCommand.h b/Source/cmLinkDirectoriesCommand.h index 9218f44..c6eb40c 100644 --- a/Source/cmLinkDirectoriesCommand.h +++ b/Source/cmLinkDirectoriesCommand.h @@ -45,33 +45,6 @@ public: */ virtual const char* GetName() const { return "link_directories";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Specify directories in which the linker will look for libraries."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " link_directories(directory1 directory2 ...)\n" - "Specify the paths in which the linker should search for libraries. " - "The command will apply only to targets created after it is called. " - "Relative paths given to this command are interpreted as relative to " - "the current source directory, see CMP0015. \n" - "Note that this command is rarely necessary. Library locations " - "returned by find_package() and find_library() are absolute paths. " - "Pass these absolute library file paths directly to the " - "target_link_libraries() command. CMake will ensure the linker finds " - "them." - ; - } - cmTypeMacro(cmLinkDirectoriesCommand, cmCommand); private: void AddLinkDir(std::string const& dir); diff --git a/Source/cmLinkLibrariesCommand.h b/Source/cmLinkLibrariesCommand.h index c450a1c..74de23c 100644 --- a/Source/cmLinkLibrariesCommand.h +++ b/Source/cmLinkLibrariesCommand.h @@ -44,31 +44,6 @@ public: */ virtual const char* GetName() const { return "link_libraries";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Deprecated. Use the target_link_libraries() command instead."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - "Link libraries to all targets added later.\n" - " link_libraries(library1 <debug | optimized> library2 ...)\n" - "Specify a list of libraries to be linked into " - "any following targets (typically added with the add_executable " - "or add_library calls). This command is passed " - "down to all subdirectories. " - "The debug and optimized strings may be used to indicate that " - "the next library listed is to be used only for that specific " - "type of build."; - } - /** This command is kept for compatibility with older CMake versions. */ virtual bool IsDiscouraged() const { diff --git a/Source/cmListCommand.h b/Source/cmListCommand.h index f20aa8a..0cb5da2 100644 --- a/Source/cmListCommand.h +++ b/Source/cmListCommand.h @@ -46,66 +46,6 @@ public: */ virtual const char* GetName() const { return "list";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "List operations."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " list(LENGTH <list> <output variable>)\n" - " list(GET <list> <element index> [<element index> ...]\n" - " <output variable>)\n" - " list(APPEND <list> <element> [<element> ...])\n" - " list(FIND <list> <value> <output variable>)\n" - " list(INSERT <list> <element_index> <element> [<element> ...])\n" - " list(REMOVE_ITEM <list> <value> [<value> ...])\n" - " list(REMOVE_AT <list> <index> [<index> ...])\n" - " list(REMOVE_DUPLICATES <list>)\n" - " list(REVERSE <list>)\n" - " list(SORT <list>)\n" - "LENGTH will return a given list's length.\n" - "GET will return list of elements specified by indices from the list.\n" - "APPEND will append elements to the list.\n" - "FIND will return the index of the element specified in the list or -1 " - "if it wasn't found.\n" - "INSERT will insert elements to the list to the specified location.\n" - "REMOVE_AT and REMOVE_ITEM will remove items from the list. The " - "difference is that REMOVE_ITEM will remove the given items, while " - "REMOVE_AT will remove the items at the given indices.\n" - "REMOVE_DUPLICATES will remove duplicated items in the list.\n" - "REVERSE reverses the contents of the list in-place.\n" - "SORT sorts the list in-place alphabetically.\n" - "The list subcommands APPEND, INSERT, REMOVE_AT, REMOVE_ITEM, " - "REMOVE_DUPLICATES, REVERSE and SORT may create new values for " - "the list within the current CMake variable scope. Similar to " - "the SET command, the LIST command creates new variable values " - "in the current scope, even if the list itself is actually " - "defined in a parent scope. To propagate the results of these " - "operations upwards, use SET with PARENT_SCOPE, SET with CACHE " - "INTERNAL, or some other means of value propagation.\n" - "NOTES: A list in cmake is a ; separated group of strings. " - "To create a list the set command can be used. For example, " - "set(var a b c d e) creates a list with a;b;c;d;e, and " - "set(var \"a b c d e\") creates a string or a list with one " - "item in it.\n" - "When specifying index values, if <element index> is 0 or" - " greater, it is indexed from the " - "beginning of the list, with 0 representing the first list element. " - "If <element index> is -1 or lesser, it is indexed from the end of " - "the list, with -1 representing the last list element. Be careful " - "when counting with negative indices: they do not start from 0. " - "-0 is equivalent to 0, the first list element.\n" - ; - } - cmTypeMacro(cmListCommand, cmCommand); protected: bool HandleLengthCommand(std::vector<std::string> const& args); diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 898f379..7461d37 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -29,14 +29,14 @@ struct cmListFileParser ~cmListFileParser(); bool ParseFile(); bool ParseFunction(const char* name, long line); - void AddArgument(cmListFileLexer_Token* token, + bool AddArgument(cmListFileLexer_Token* token, cmListFileArgument::Delimiter delim); cmListFile* ListFile; cmMakefile* Makefile; const char* FileName; cmListFileLexer* Lexer; cmListFileFunction Function; - enum { SeparationOkay, SeparationWarning } Separation; + enum { SeparationOkay, SeparationWarning, SeparationError} Separation; }; //---------------------------------------------------------------------------- @@ -57,13 +57,26 @@ cmListFileParser::~cmListFileParser() bool cmListFileParser::ParseFile() { // Open the file. - if(!cmListFileLexer_SetFileName(this->Lexer, this->FileName)) + cmListFileLexer_BOM bom; + if(!cmListFileLexer_SetFileName(this->Lexer, this->FileName, &bom)) { cmSystemTools::Error("cmListFileCache: error can not open file ", this->FileName); return false; } + // Verify the Byte-Order-Mark, if any. + if(bom != cmListFileLexer_BOM_None && + bom != cmListFileLexer_BOM_UTF8) + { + cmListFileLexer_SetFileName(this->Lexer, 0, 0); + cmOStringStream m; + m << "File\n " << this->FileName << "\n" + << "starts with a Byte-Order-Mark that is not UTF-8."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, m.str()); + return false; + } + // Use a simple recursive-descent parser to process the token // stream. bool haveNewline = true; @@ -77,6 +90,10 @@ bool cmListFileParser::ParseFile() { haveNewline = true; } + else if(token->type == cmListFileLexer_Token_CommentBracket) + { + haveNewline = false; + } else if(token->type == cmListFileLexer_Token_Identifier) { if(haveNewline) @@ -288,7 +305,10 @@ bool cmListFileParser::ParseFunction(const char* name, long line) { parenDepth++; this->Separation = SeparationOkay; - this->AddArgument(token, cmListFileArgument::Unquoted); + if(!this->AddArgument(token, cmListFileArgument::Unquoted)) + { + return false; + } } else if(token->type == cmListFileLexer_Token_ParenRight) { @@ -298,20 +318,41 @@ bool cmListFileParser::ParseFunction(const char* name, long line) } parenDepth--; this->Separation = SeparationOkay; - this->AddArgument(token, cmListFileArgument::Unquoted); + if(!this->AddArgument(token, cmListFileArgument::Unquoted)) + { + return false; + } this->Separation = SeparationWarning; } else if(token->type == cmListFileLexer_Token_Identifier || token->type == cmListFileLexer_Token_ArgumentUnquoted) { - this->AddArgument(token, cmListFileArgument::Unquoted); + if(!this->AddArgument(token, cmListFileArgument::Unquoted)) + { + return false; + } this->Separation = SeparationWarning; } else if(token->type == cmListFileLexer_Token_ArgumentQuoted) { - this->AddArgument(token, cmListFileArgument::Quoted); + if(!this->AddArgument(token, cmListFileArgument::Quoted)) + { + return false; + } this->Separation = SeparationWarning; } + else if(token->type == cmListFileLexer_Token_ArgumentBracket) + { + if(!this->AddArgument(token, cmListFileArgument::Bracket)) + { + return false; + } + this->Separation = SeparationError; + } + else if(token->type == cmListFileLexer_Token_CommentBracket) + { + this->Separation = SeparationError; + } else { // Error. @@ -338,42 +379,32 @@ bool cmListFileParser::ParseFunction(const char* name, long line) } //---------------------------------------------------------------------------- -void cmListFileParser::AddArgument(cmListFileLexer_Token* token, +bool cmListFileParser::AddArgument(cmListFileLexer_Token* token, cmListFileArgument::Delimiter delim) { cmListFileArgument a(token->text, delim, this->FileName, token->line); this->Function.Arguments.push_back(a); - if(delim == cmListFileArgument::Unquoted) - { - // Warn about a future behavior change. - const char* c = a.Value.c_str(); - if(*c++ == '[') - { - while(*c == '=') - { ++c; } - if(*c == '[') - { - cmOStringStream m; - m << "Syntax Warning in cmake code at\n" - << " " << this->FileName << ":" << token->line << ":" - << token->column << "\n" - << "A future version of CMake may treat unquoted argument:\n" - << " " << a.Value << "\n" - << "as an opening long bracket. Double-quote the argument."; - this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str().c_str()); - } - } - } if(this->Separation == SeparationOkay) { - return; + return true; } + bool isError = (this->Separation == SeparationError || + delim == cmListFileArgument::Bracket); cmOStringStream m; - m << "Syntax Warning in cmake code at\n" + m << "Syntax " << (isError? "Error":"Warning") << " in cmake code at\n" << " " << this->FileName << ":" << token->line << ":" << token->column << "\n" << "Argument not separated from preceding token by whitespace."; - this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str().c_str()); + if(isError) + { + this->Makefile->IssueMessage(cmake::FATAL_ERROR, m.str().c_str()); + return false; + } + else + { + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str().c_str()); + return true; + } } //---------------------------------------------------------------------------- diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h index 7bb3b34..bede25e 100644 --- a/Source/cmListFileCache.h +++ b/Source/cmListFileCache.h @@ -28,7 +28,8 @@ struct cmListFileArgument enum Delimiter { Unquoted, - Quoted + Quoted, + Bracket }; cmListFileArgument(): Value(), Delim(Unquoted), FilePath(0), Line(0) {} cmListFileArgument(const cmListFileArgument& r): diff --git a/Source/cmListFileLexer.c b/Source/cmListFileLexer.c index 2841fe5..bfa388e 100644 --- a/Source/cmListFileLexer.c +++ b/Source/cmListFileLexer.c @@ -369,8 +369,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 16 -#define YY_END_OF_BUFFER 17 +#define YY_NUM_RULES 23 +#define YY_END_OF_BUFFER 24 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -378,13 +378,16 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[45] = +static yyconst flex_int16_t yy_accept[77] = { 0, - 0, 0, 0, 0, 17, 6, 14, 1, 8, 2, - 6, 3, 4, 6, 15, 9, 11, 12, 13, 6, - 0, 6, 0, 14, 2, 0, 5, 6, 9, 0, - 10, 0, 7, 0, 0, 0, 7, 0, 7, 0, - 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, + 24, 13, 21, 1, 15, 3, 13, 5, 6, 7, + 22, 22, 16, 18, 19, 20, 10, 11, 8, 12, + 9, 4, 13, 0, 13, 0, 21, 0, 0, 7, + 13, 0, 13, 0, 2, 0, 13, 16, 0, 17, + 10, 8, 4, 0, 14, 0, 0, 0, 0, 14, + 0, 0, 14, 0, 0, 0, 2, 14, 0, 0, + 0, 0, 0, 0, 0, 0 } ; static yyconst flex_int32_t yy_ec[256] = @@ -395,14 +398,14 @@ static yyconst flex_int32_t yy_ec[256] = 1, 2, 1, 5, 6, 7, 1, 1, 1, 8, 9, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 1, 1, - 1, 1, 1, 1, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 1, 12, 1, 1, 11, 1, 11, 11, 11, 11, - - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 1, 1, 1, 1, 1, 1, 1, 1, + 11, 1, 1, 1, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 13, 14, 15, 1, 12, 1, 12, 12, 12, 12, + + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -419,72 +422,111 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[13] = +static yyconst flex_int32_t yy_meta[16] = { 0, - 1, 2, 3, 2, 4, 1, 1, 1, 5, 5, - 5, 1 + 1, 1, 2, 3, 4, 3, 1, 3, 5, 6, + 1, 6, 1, 1, 7 } ; -static yyconst flex_int16_t yy_base[56] = +static yyconst flex_int16_t yy_base[95] = { 0, - 0, 0, 10, 20, 38, 32, 0, 109, 109, 0, - 28, 109, 109, 35, 0, 23, 109, 109, 44, 0, - 49, 26, 0, 0, 0, 22, 0, 0, 18, 24, - 109, 0, 61, 20, 0, 18, 0, 17, 16, 0, - 12, 11, 10, 109, 73, 16, 78, 83, 88, 93, - 12, 98, 11, 103, 9 + 0, 0, 13, 25, 14, 16, 17, 18, 90, 88, + 88, 39, 20, 237, 237, 74, 78, 237, 237, 13, + 54, 0, 71, 237, 237, 31, 0, 237, 73, 237, + 237, 0, 0, 65, 75, 0, 33, 30, 72, 0, + 0, 75, 70, 0, 74, 0, 0, 62, 70, 237, + 0, 63, 0, 85, 99, 65, 111, 62, 34, 0, + 54, 116, 0, 54, 127, 51, 237, 50, 0, 48, + 47, 39, 33, 29, 17, 237, 136, 143, 150, 157, + 164, 171, 178, 184, 191, 198, 201, 207, 214, 217, + 219, 225, 228, 230 + } ; -static yyconst flex_int16_t yy_def[56] = +static yyconst flex_int16_t yy_def[95] = { 0, - 44, 1, 45, 45, 44, 44, 46, 44, 44, 47, - 6, 44, 44, 6, 48, 49, 44, 44, 49, 6, - 44, 6, 50, 46, 47, 51, 14, 6, 49, 49, - 44, 21, 44, 21, 52, 53, 33, 51, 33, 54, - 55, 53, 55, 0, 44, 44, 44, 44, 44, 44, - 44, 44, 44, 44, 44 + 76, 1, 77, 77, 78, 78, 79, 79, 80, 80, + 76, 76, 76, 76, 76, 76, 12, 76, 76, 12, + 76, 81, 82, 76, 76, 82, 83, 76, 76, 76, + 76, 84, 12, 85, 12, 86, 76, 76, 87, 20, + 12, 88, 12, 21, 76, 89, 12, 82, 82, 76, + 83, 76, 84, 85, 76, 54, 85, 90, 76, 55, + 87, 88, 55, 62, 88, 91, 76, 55, 92, 93, + 90, 94, 91, 93, 94, 0, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76 + } ; -static yyconst flex_int16_t yy_nxt[122] = +static yyconst flex_int16_t yy_nxt[253] = { 0, - 6, 7, 8, 7, 9, 10, 11, 12, 13, 6, - 14, 15, 17, 43, 18, 42, 38, 24, 32, 33, - 32, 19, 17, 36, 18, 37, 33, 41, 29, 30, - 37, 19, 20, 36, 30, 26, 21, 44, 22, 44, - 44, 20, 20, 23, 27, 27, 31, 44, 29, 32, - 32, 44, 44, 33, 44, 34, 44, 44, 32, 32, - 35, 33, 44, 44, 44, 21, 44, 39, 44, 44, - 33, 33, 40, 16, 16, 16, 16, 16, 25, 25, - 44, 25, 25, 28, 28, 44, 28, 28, 29, 29, - 44, 44, 29, 20, 20, 44, 20, 20, 32, 32, - - 44, 32, 32, 33, 33, 44, 33, 33, 5, 44, - 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, - 44 + 12, 13, 14, 13, 15, 16, 17, 18, 19, 12, + 12, 20, 21, 22, 12, 24, 28, 25, 28, 28, + 28, 37, 40, 37, 40, 62, 26, 24, 29, 25, + 29, 31, 31, 50, 37, 48, 37, 54, 26, 33, + 59, 63, 45, 34, 59, 35, 45, 62, 33, 33, + 33, 33, 36, 33, 41, 55, 54, 58, 42, 63, + 43, 72, 60, 41, 44, 41, 45, 46, 41, 55, + 55, 56, 70, 52, 48, 49, 67, 66, 57, 63, + 60, 64, 58, 52, 49, 39, 38, 76, 65, 55, + 14, 56, 14, 76, 76, 76, 76, 76, 57, 55, + + 76, 76, 76, 34, 76, 68, 76, 76, 55, 55, + 55, 55, 69, 55, 54, 76, 54, 76, 54, 54, + 63, 76, 64, 76, 76, 76, 76, 76, 76, 65, + 62, 76, 62, 76, 62, 62, 23, 23, 23, 23, + 23, 23, 23, 27, 27, 27, 27, 27, 27, 27, + 30, 30, 30, 30, 30, 30, 30, 32, 32, 32, + 32, 32, 32, 32, 47, 76, 47, 47, 47, 47, + 47, 48, 76, 48, 76, 48, 48, 48, 51, 76, + 51, 51, 51, 51, 53, 76, 53, 53, 53, 53, + 53, 54, 76, 76, 54, 76, 54, 54, 33, 76, + + 33, 33, 33, 33, 33, 61, 61, 62, 76, 76, + 62, 76, 62, 62, 41, 76, 41, 41, 41, 41, + 41, 71, 71, 73, 73, 55, 76, 55, 55, 55, + 55, 55, 74, 74, 75, 75, 11, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76 } ; -static yyconst flex_int16_t yy_chk[122] = +static yyconst flex_int16_t yy_chk[253] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 3, 55, 3, 53, 51, 46, 43, 42, - 41, 3, 4, 39, 4, 38, 36, 34, 30, 29, - 26, 4, 6, 22, 16, 11, 6, 5, 6, 0, - 0, 6, 6, 6, 14, 14, 19, 0, 19, 21, - 21, 0, 0, 21, 0, 21, 0, 0, 21, 21, - 21, 33, 0, 0, 0, 33, 0, 33, 0, 0, - 33, 33, 33, 45, 45, 45, 45, 45, 47, 47, - 0, 47, 47, 48, 48, 0, 48, 48, 49, 49, - 0, 0, 49, 50, 50, 0, 50, 50, 52, 52, - - 0, 52, 52, 54, 54, 0, 54, 54, 44, 44, - 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, - 44 + 1, 1, 1, 1, 1, 3, 5, 3, 6, 7, + 8, 13, 20, 13, 20, 75, 3, 4, 5, 4, + 6, 7, 8, 26, 37, 26, 37, 74, 4, 12, + 38, 73, 38, 12, 59, 12, 59, 72, 12, 12, + 12, 12, 12, 12, 21, 71, 70, 68, 21, 66, + 21, 64, 61, 21, 21, 21, 21, 21, 21, 34, + 58, 34, 56, 52, 49, 48, 45, 43, 34, 42, + 39, 42, 35, 29, 23, 17, 16, 11, 42, 54, + 10, 54, 9, 0, 0, 0, 0, 0, 54, 55, + + 0, 0, 0, 55, 0, 55, 0, 0, 55, 55, + 55, 55, 55, 55, 57, 0, 57, 0, 57, 57, + 62, 0, 62, 0, 0, 0, 0, 0, 0, 62, + 65, 0, 65, 0, 65, 65, 77, 77, 77, 77, + 77, 77, 77, 78, 78, 78, 78, 78, 78, 78, + 79, 79, 79, 79, 79, 79, 79, 80, 80, 80, + 80, 80, 80, 80, 81, 0, 81, 81, 81, 81, + 81, 82, 0, 82, 0, 82, 82, 82, 83, 0, + 83, 83, 83, 83, 84, 0, 84, 84, 84, 84, + 84, 85, 0, 0, 85, 0, 85, 85, 86, 0, + + 86, 86, 86, 86, 86, 87, 87, 88, 0, 0, + 88, 0, 88, 88, 89, 0, 89, 89, 89, 89, + 89, 90, 90, 91, 91, 92, 0, 92, 92, 92, + 92, 92, 93, 93, 94, 94, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76 } ; /* Table of booleans, true if rule could match eol. */ -static yyconst flex_int32_t yy_rule_can_match_eol[17] = +static yyconst flex_int32_t yy_rule_can_match_eol[24] = { 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, }; +1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, }; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. @@ -527,6 +569,9 @@ Modify cmListFileLexer.c: */ #include "cmStandardLexer.h" +#ifdef WIN32 +#include <cmsys/Encoding.h> +#endif /* Setup the proper cmListFileLexer_yylex declaration. */ #define YY_EXTRA_TYPE cmListFileLexer* @@ -538,10 +583,13 @@ Modify cmListFileLexer.c: struct cmListFileLexer_s { cmListFileLexer_Token token; + int bracket; + int comment; int line; int column; int size; FILE* file; + size_t cr; char* string_buffer; char* string_position; int string_left; @@ -564,10 +612,16 @@ static void cmListFileLexerDestroy(cmListFileLexer* lexer); /*--------------------------------------------------------------------------*/ -#line 570 "cmListFileLexer.c" + + + +#line 621 "cmListFileLexer.c" #define INITIAL 0 #define STRING 1 +#define BRACKET 2 +#define BRACKETEND 3 +#define COMMENT 4 #ifndef YY_NO_UNISTD_H /* Special case for "unistd.h", since it is non-ANSI. We include it way @@ -793,10 +847,10 @@ YY_DECL int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; -#line 82 "cmListFileLexer.in.l" +#line 91 "cmListFileLexer.in.l" -#line 804 "cmListFileLexer.c" +#line 858 "cmListFileLexer.c" if ( !yyg->yy_init ) { @@ -849,13 +903,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 45 ) + if ( yy_current_state >= 77 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_base[yy_current_state] != 109 ); + while ( yy_base[yy_current_state] != 237 ); yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -894,69 +948,168 @@ do_action: /* This label is used only to access EOF actions. */ case 1: /* rule 1 can match eol */ YY_RULE_SETUP -#line 84 "cmListFileLexer.in.l" +#line 93 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_Newline; cmListFileLexerSetToken(lexer, yytext, yyleng); ++lexer->line; lexer->column = 1; + BEGIN(INITIAL); return 1; } case 2: +/* rule 2 can match eol */ YY_RULE_SETUP -#line 92 "cmListFileLexer.in.l" +#line 102 "cmListFileLexer.in.l" { - lexer->column += yyleng; + const char* bracket = yytext; + lexer->comment = yytext[0] == '#'; + if(lexer->comment) + { + lexer->token.type = cmListFileLexer_Token_CommentBracket; + bracket += 1; + } + else + { + lexer->token.type = cmListFileLexer_Token_ArgumentBracket; + } + cmListFileLexerSetToken(lexer, "", 0); + lexer->bracket = (int)(strchr(bracket+1, '[') - bracket); + if(yytext[yyleng-1] == '\n') + { + ++lexer->line; + lexer->column = 1; + } + else + { + lexer->column += yyleng; + } + BEGIN(BRACKET); } YY_BREAK case 3: YY_RULE_SETUP -#line 96 "cmListFileLexer.in.l" +#line 128 "cmListFileLexer.in.l" +{ + lexer->column += yyleng; + BEGIN(COMMENT); +} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 133 "cmListFileLexer.in.l" +{ + lexer->column += yyleng; +} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 137 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_ParenLeft; cmListFileLexerSetToken(lexer, yytext, yyleng); lexer->column += yyleng; return 1; } -case 4: +case 6: YY_RULE_SETUP -#line 103 "cmListFileLexer.in.l" +#line 144 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_ParenRight; cmListFileLexerSetToken(lexer, yytext, yyleng); lexer->column += yyleng; return 1; } -case 5: +case 7: YY_RULE_SETUP -#line 110 "cmListFileLexer.in.l" +#line 151 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_Identifier; cmListFileLexerSetToken(lexer, yytext, yyleng); lexer->column += yyleng; return 1; } -case 6: +case 8: +YY_RULE_SETUP +#line 158 "cmListFileLexer.in.l" +{ + /* Handle ]]====]=======]*/ + cmListFileLexerAppend(lexer, yytext, yyleng); + lexer->column += yyleng; + if(yyleng == lexer->bracket) + { + BEGIN(BRACKETEND); + } +} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 168 "cmListFileLexer.in.l" +{ + lexer->column += yyleng; + /* Erase the partial bracket from the token. */ + lexer->token.length -= lexer->bracket; + lexer->token.text[lexer->token.length] = 0; + BEGIN(INITIAL); + return 1; +} +case 10: +YY_RULE_SETUP +#line 177 "cmListFileLexer.in.l" +{ + cmListFileLexerAppend(lexer, yytext, yyleng); + lexer->column += yyleng; +} + YY_BREAK +case 11: +/* rule 11 can match eol */ +YY_RULE_SETUP +#line 182 "cmListFileLexer.in.l" +{ + cmListFileLexerAppend(lexer, yytext, yyleng); + ++lexer->line; + lexer->column = 1; + BEGIN(BRACKET); +} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 189 "cmListFileLexer.in.l" +{ + cmListFileLexerAppend(lexer, yytext, yyleng); + lexer->column += yyleng; + BEGIN(BRACKET); +} + YY_BREAK +case YY_STATE_EOF(BRACKET): +case YY_STATE_EOF(BRACKETEND): +#line 195 "cmListFileLexer.in.l" +{ + lexer->token.type = cmListFileLexer_Token_BadBracket; + BEGIN(INITIAL); + return 1; +} +case 13: YY_RULE_SETUP -#line 117 "cmListFileLexer.in.l" +#line 201 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted; cmListFileLexerSetToken(lexer, yytext, yyleng); lexer->column += yyleng; return 1; } -case 7: +case 14: YY_RULE_SETUP -#line 124 "cmListFileLexer.in.l" +#line 208 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted; cmListFileLexerSetToken(lexer, yytext, yyleng); lexer->column += yyleng; return 1; } -case 8: +case 15: YY_RULE_SETUP -#line 131 "cmListFileLexer.in.l" +#line 215 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_ArgumentQuoted; cmListFileLexerSetToken(lexer, "", 0); @@ -964,69 +1117,69 @@ YY_RULE_SETUP BEGIN(STRING); } YY_BREAK -case 9: +case 16: YY_RULE_SETUP -#line 138 "cmListFileLexer.in.l" +#line 222 "cmListFileLexer.in.l" { cmListFileLexerAppend(lexer, yytext, yyleng); lexer->column += yyleng; } YY_BREAK -case 10: -/* rule 10 can match eol */ +case 17: +/* rule 17 can match eol */ YY_RULE_SETUP -#line 143 "cmListFileLexer.in.l" +#line 227 "cmListFileLexer.in.l" { - cmListFileLexerAppend(lexer, yytext, yyleng); + /* Continuation: text is not part of string */ ++lexer->line; lexer->column = 1; } YY_BREAK -case 11: -/* rule 11 can match eol */ +case 18: +/* rule 18 can match eol */ YY_RULE_SETUP -#line 149 "cmListFileLexer.in.l" +#line 233 "cmListFileLexer.in.l" { cmListFileLexerAppend(lexer, yytext, yyleng); ++lexer->line; lexer->column = 1; } YY_BREAK -case 12: +case 19: YY_RULE_SETUP -#line 155 "cmListFileLexer.in.l" +#line 239 "cmListFileLexer.in.l" { lexer->column += yyleng; BEGIN(INITIAL); return 1; } -case 13: +case 20: YY_RULE_SETUP -#line 161 "cmListFileLexer.in.l" +#line 245 "cmListFileLexer.in.l" { cmListFileLexerAppend(lexer, yytext, yyleng); lexer->column += yyleng; } YY_BREAK case YY_STATE_EOF(STRING): -#line 166 "cmListFileLexer.in.l" +#line 250 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_BadString; BEGIN(INITIAL); return 1; } -case 14: +case 21: YY_RULE_SETUP -#line 172 "cmListFileLexer.in.l" +#line 256 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_Space; cmListFileLexerSetToken(lexer, yytext, yyleng); lexer->column += yyleng; return 1; } -case 15: +case 22: YY_RULE_SETUP -#line 179 "cmListFileLexer.in.l" +#line 263 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_BadCharacter; cmListFileLexerSetToken(lexer, yytext, yyleng); @@ -1034,18 +1187,19 @@ YY_RULE_SETUP return 1; } case YY_STATE_EOF(INITIAL): -#line 186 "cmListFileLexer.in.l" +case YY_STATE_EOF(COMMENT): +#line 270 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_None; cmListFileLexerSetToken(lexer, 0, 0); return 0; } -case 16: +case 23: YY_RULE_SETUP -#line 192 "cmListFileLexer.in.l" +#line 276 "cmListFileLexer.in.l" ECHO; YY_BREAK -#line 1064 "cmListFileLexer.c" +#line 1220 "cmListFileLexer.c" case YY_END_OF_BUFFER: { @@ -1337,7 +1491,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 45 ) + if ( yy_current_state >= 77 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1366,11 +1520,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 45 ) + if ( yy_current_state >= 77 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 44); + yy_is_jam = (yy_current_state == 76); return yy_is_jam ? 0 : yy_current_state; } @@ -2166,7 +2320,7 @@ void cmListFileLexer_yyfree (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 192 "cmListFileLexer.in.l" +#line 276 "cmListFileLexer.in.l" @@ -2243,7 +2397,38 @@ static int cmListFileLexerInput(cmListFileLexer* lexer, char* buffer, { if(lexer->file) { - return (int)fread(buffer, 1, bufferSize, lexer->file); + /* Convert CRLF -> LF explicitly. The C FILE "t"ext mode + does not convert newlines on all platforms. Move any + trailing CR to the start of the buffer for the next read. */ + size_t cr = lexer->cr; + size_t n; + buffer[0] = '\r'; + n = fread(buffer+cr, 1, bufferSize-cr, lexer->file); + if(n) + { + char* o = buffer; + const char* i = buffer; + const char* e; + n += cr; + cr = (buffer[n-1] == '\r')? 1:0; + e = buffer + n - cr; + while(i != e) + { + if(i[0] == '\r' && i[1] == '\n') + { + ++i; + } + *o++ = *i++; + } + n = o - buffer; + } + else + { + n = cr; + cr = 0; + } + lexer->cr = cr; + return n; } else if(lexer->string_left) { @@ -2271,6 +2456,7 @@ static void cmListFileLexerInit(cmListFileLexer* lexer) /*--------------------------------------------------------------------------*/ static void cmListFileLexerDestroy(cmListFileLexer* lexer) { + cmListFileLexerSetToken(lexer, 0, 0); if(lexer->file || lexer->string_buffer) { cmListFileLexer_yylex_destroy(lexer->scanner); @@ -2306,19 +2492,74 @@ cmListFileLexer* cmListFileLexer_New() /*--------------------------------------------------------------------------*/ void cmListFileLexer_Delete(cmListFileLexer* lexer) { - cmListFileLexer_SetFileName(lexer, 0); + cmListFileLexer_SetFileName(lexer, 0, 0); free(lexer); } /*--------------------------------------------------------------------------*/ -int cmListFileLexer_SetFileName(cmListFileLexer* lexer, const char* name) +static cmListFileLexer_BOM cmListFileLexer_ReadBOM(FILE* f) +{ + unsigned char b[2]; + if(fread(b, 1, 2, f) == 2) + { + if(b[0] == 0xEF && b[1] == 0xBB) + { + if(fread(b, 1, 1, f) == 1 && b[0] == 0xBF) + { + return cmListFileLexer_BOM_UTF8; + } + } + else if(b[0] == 0xFE && b[1] == 0xFF) + { + /* UTF-16 BE */ + return cmListFileLexer_BOM_UTF16BE; + } + else if(b[0] == 0 && b[1] == 0) + { + if(fread(b, 1, 2, f) == 2 && b[0] == 0xFE && b[1] == 0xFF) + { + return cmListFileLexer_BOM_UTF32BE; + } + } + else if(b[0] == 0xFF && b[1] == 0xFE) + { + fpos_t p; + fgetpos(f, &p); + if(fread(b, 1, 2, f) == 2 && b[0] == 0 && b[1] == 0) + { + return cmListFileLexer_BOM_UTF32LE; + } + fsetpos(f, &p); + return cmListFileLexer_BOM_UTF16LE; + } + } + rewind(f); + return cmListFileLexer_BOM_None; +} + +/*--------------------------------------------------------------------------*/ +int cmListFileLexer_SetFileName(cmListFileLexer* lexer, const char* name, + cmListFileLexer_BOM* bom) { int result = 1; cmListFileLexerDestroy(lexer); if(name) { - lexer->file = fopen(name, "r"); - if(!lexer->file) +#ifdef _WIN32 + wchar_t* wname = cmsysEncoding_DupToWide(name); + lexer->file = _wfopen(wname, L"rb"); + free(wname); +#else + lexer->file = fopen(name, "rb"); +#endif + if(lexer->file) + { + if(bom) + { + *bom = cmListFileLexer_ReadBOM(lexer->file); + } + } + else { result = 0; } @@ -2364,7 +2605,7 @@ cmListFileLexer_Token* cmListFileLexer_Scan(cmListFileLexer* lexer) } else { - cmListFileLexer_SetFileName(lexer, 0); + cmListFileLexer_SetFileName(lexer, 0, 0); return 0; } } @@ -2410,7 +2651,10 @@ const char* cmListFileLexer_GetTypeAsString(cmListFileLexer* lexer, case cmListFileLexer_Token_ParenRight: return "right paren"; case cmListFileLexer_Token_ArgumentUnquoted: return "unquoted argument"; case cmListFileLexer_Token_ArgumentQuoted: return "quoted argument"; + case cmListFileLexer_Token_ArgumentBracket: return "bracket argument"; + case cmListFileLexer_Token_CommentBracket: return "bracket comment"; case cmListFileLexer_Token_BadCharacter: return "bad character"; + case cmListFileLexer_Token_BadBracket: return "unterminated bracket"; case cmListFileLexer_Token_BadString: return "unterminated string"; } return "unknown token"; diff --git a/Source/cmListFileLexer.h b/Source/cmListFileLexer.h index cc78b5c..bd2868a 100644 --- a/Source/cmListFileLexer.h +++ b/Source/cmListFileLexer.h @@ -22,7 +22,10 @@ typedef enum cmListFileLexer_Type_e cmListFileLexer_Token_ParenRight, cmListFileLexer_Token_ArgumentUnquoted, cmListFileLexer_Token_ArgumentQuoted, + cmListFileLexer_Token_ArgumentBracket, + cmListFileLexer_Token_CommentBracket, cmListFileLexer_Token_BadCharacter, + cmListFileLexer_Token_BadBracket, cmListFileLexer_Token_BadString } cmListFileLexer_Type; @@ -36,6 +39,17 @@ struct cmListFileLexer_Token_s int column; }; +enum cmListFileLexer_BOM_e +{ + cmListFileLexer_BOM_None, + cmListFileLexer_BOM_UTF8, + cmListFileLexer_BOM_UTF16BE, + cmListFileLexer_BOM_UTF16LE, + cmListFileLexer_BOM_UTF32BE, + cmListFileLexer_BOM_UTF32LE +}; +typedef enum cmListFileLexer_BOM_e cmListFileLexer_BOM; + typedef struct cmListFileLexer_s cmListFileLexer; #ifdef __cplusplus @@ -44,7 +58,8 @@ extern "C" #endif cmListFileLexer* cmListFileLexer_New(); -int cmListFileLexer_SetFileName(cmListFileLexer*, const char*); +int cmListFileLexer_SetFileName(cmListFileLexer*, const char*, + cmListFileLexer_BOM* bom); int cmListFileLexer_SetString(cmListFileLexer*, const char*); cmListFileLexer_Token* cmListFileLexer_Scan(cmListFileLexer*); long cmListFileLexer_GetCurrentLine(cmListFileLexer*); diff --git a/Source/cmListFileLexer.in.l b/Source/cmListFileLexer.in.l index 12b53ee..ed4bf6b 100644 --- a/Source/cmListFileLexer.in.l +++ b/Source/cmListFileLexer.in.l @@ -31,6 +31,9 @@ Modify cmListFileLexer.c: */ #include "cmStandardLexer.h" +#ifdef WIN32 +#include <cmsys/Encoding.h> +#endif /* Setup the proper cmListFileLexer_yylex declaration. */ #define YY_EXTRA_TYPE cmListFileLexer* @@ -42,10 +45,13 @@ Modify cmListFileLexer.c: struct cmListFileLexer_s { cmListFileLexer_Token token; + int bracket; + int comment; int line; int column; int size; FILE* file; + size_t cr; char* string_buffer; char* string_position; int string_left; @@ -74,22 +80,57 @@ static void cmListFileLexerDestroy(cmListFileLexer* lexer); %option noyywrap %pointer %x STRING +%x BRACKET +%x BRACKETEND +%x COMMENT MAKEVAR \$\([A-Za-z0-9_]*\) -UNQUOTED ([^ \t\r\n\(\)#\\\"]|\\.) -LEGACY {MAKEVAR}|{UNQUOTED}|\"({MAKEVAR}|{UNQUOTED}|[ \t])*\" +UNQUOTED ([^ \t\r\n\(\)#\\\"[=]|\\.) +LEGACY {MAKEVAR}|{UNQUOTED}|\"({MAKEVAR}|{UNQUOTED}|[ \t[=])*\" %% -\n { +<INITIAL,COMMENT>\n { lexer->token.type = cmListFileLexer_Token_Newline; cmListFileLexerSetToken(lexer, yytext, yyleng); ++lexer->line; lexer->column = 1; + BEGIN(INITIAL); return 1; } -#.* { +#?\[=*\[\n? { + const char* bracket = yytext; + lexer->comment = yytext[0] == '#'; + if(lexer->comment) + { + lexer->token.type = cmListFileLexer_Token_CommentBracket; + bracket += 1; + } + else + { + lexer->token.type = cmListFileLexer_Token_ArgumentBracket; + } + cmListFileLexerSetToken(lexer, "", 0); + lexer->bracket = (int)(strchr(bracket+1, '[') - bracket); + if(yytext[yyleng-1] == '\n') + { + ++lexer->line; + lexer->column = 1; + } + else + { + lexer->column += yyleng; + } + BEGIN(BRACKET); +} + +# { + lexer->column += yyleng; + BEGIN(COMMENT); +} + +<COMMENT>.* { lexer->column += yyleng; } @@ -107,21 +148,64 @@ LEGACY {MAKEVAR}|{UNQUOTED}|\"({MAKEVAR}|{UNQUOTED}|[ \t])*\" return 1; } -[A-Za-z_][A-Za-z0-9_]+ { +[A-Za-z_][A-Za-z0-9_]* { lexer->token.type = cmListFileLexer_Token_Identifier; cmListFileLexerSetToken(lexer, yytext, yyleng); lexer->column += yyleng; return 1; } -({UNQUOTED})({UNQUOTED})* { +<BRACKET>\]=* { + /* Handle ]]====]=======]*/ + cmListFileLexerAppend(lexer, yytext, yyleng); + lexer->column += yyleng; + if(yyleng == lexer->bracket) + { + BEGIN(BRACKETEND); + } +} + +<BRACKETEND>\] { + lexer->column += yyleng; + /* Erase the partial bracket from the token. */ + lexer->token.length -= lexer->bracket; + lexer->token.text[lexer->token.length] = 0; + BEGIN(INITIAL); + return 1; +} + +<BRACKET>([^]\n])+ { + cmListFileLexerAppend(lexer, yytext, yyleng); + lexer->column += yyleng; +} + +<BRACKET,BRACKETEND>\n { + cmListFileLexerAppend(lexer, yytext, yyleng); + ++lexer->line; + lexer->column = 1; + BEGIN(BRACKET); +} + +<BRACKET,BRACKETEND>. { + cmListFileLexerAppend(lexer, yytext, yyleng); + lexer->column += yyleng; + BEGIN(BRACKET); +} + +<BRACKET,BRACKETEND><<EOF>> { + lexer->token.type = cmListFileLexer_Token_BadBracket; + BEGIN(INITIAL); + return 1; +} + +({UNQUOTED}|=|\[=*{UNQUOTED})({UNQUOTED}|[[=])* { lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted; cmListFileLexerSetToken(lexer, yytext, yyleng); lexer->column += yyleng; return 1; } -({MAKEVAR}|{UNQUOTED})({LEGACY})* { +({MAKEVAR}|{UNQUOTED}|=|\[=*{LEGACY})({LEGACY}|[[=])* { lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted; cmListFileLexerSetToken(lexer, yytext, yyleng); lexer->column += yyleng; @@ -141,7 +225,7 @@ LEGACY {MAKEVAR}|{UNQUOTED}|\"({MAKEVAR}|{UNQUOTED}|[ \t])*\" } <STRING>\\\n { - cmListFileLexerAppend(lexer, yytext, yyleng); + /* Continuation: text is not part of string */ ++lexer->line; lexer->column = 1; } @@ -264,7 +348,38 @@ static int cmListFileLexerInput(cmListFileLexer* lexer, char* buffer, { if(lexer->file) { - return (int)fread(buffer, 1, bufferSize, lexer->file); + /* Convert CRLF -> LF explicitly. The C FILE "t"ext mode + does not convert newlines on all platforms. Move any + trailing CR to the start of the buffer for the next read. */ + size_t cr = lexer->cr; + size_t n; + buffer[0] = '\r'; + n = fread(buffer+cr, 1, bufferSize-cr, lexer->file); + if(n) + { + char* o = buffer; + const char* i = buffer; + const char* e; + n += cr; + cr = (buffer[n-1] == '\r')? 1:0; + e = buffer + n - cr; + while(i != e) + { + if(i[0] == '\r' && i[1] == '\n') + { + ++i; + } + *o++ = *i++; + } + n = o - buffer; + } + else + { + n = cr; + cr = 0; + } + lexer->cr = cr; + return n; } else if(lexer->string_left) { @@ -292,6 +407,7 @@ static void cmListFileLexerInit(cmListFileLexer* lexer) /*--------------------------------------------------------------------------*/ static void cmListFileLexerDestroy(cmListFileLexer* lexer) { + cmListFileLexerSetToken(lexer, 0, 0); if(lexer->file || lexer->string_buffer) { cmListFileLexer_yylex_destroy(lexer->scanner); @@ -327,19 +443,74 @@ cmListFileLexer* cmListFileLexer_New() /*--------------------------------------------------------------------------*/ void cmListFileLexer_Delete(cmListFileLexer* lexer) { - cmListFileLexer_SetFileName(lexer, 0); + cmListFileLexer_SetFileName(lexer, 0, 0); free(lexer); } /*--------------------------------------------------------------------------*/ -int cmListFileLexer_SetFileName(cmListFileLexer* lexer, const char* name) +static cmListFileLexer_BOM cmListFileLexer_ReadBOM(FILE* f) +{ + unsigned char b[2]; + if(fread(b, 1, 2, f) == 2) + { + if(b[0] == 0xEF && b[1] == 0xBB) + { + if(fread(b, 1, 1, f) == 1 && b[0] == 0xBF) + { + return cmListFileLexer_BOM_UTF8; + } + } + else if(b[0] == 0xFE && b[1] == 0xFF) + { + /* UTF-16 BE */ + return cmListFileLexer_BOM_UTF16BE; + } + else if(b[0] == 0 && b[1] == 0) + { + if(fread(b, 1, 2, f) == 2 && b[0] == 0xFE && b[1] == 0xFF) + { + return cmListFileLexer_BOM_UTF32BE; + } + } + else if(b[0] == 0xFF && b[1] == 0xFE) + { + fpos_t p; + fgetpos(f, &p); + if(fread(b, 1, 2, f) == 2 && b[0] == 0 && b[1] == 0) + { + return cmListFileLexer_BOM_UTF32LE; + } + fsetpos(f, &p); + return cmListFileLexer_BOM_UTF16LE; + } + } + rewind(f); + return cmListFileLexer_BOM_None; +} + +/*--------------------------------------------------------------------------*/ +int cmListFileLexer_SetFileName(cmListFileLexer* lexer, const char* name, + cmListFileLexer_BOM* bom) { int result = 1; cmListFileLexerDestroy(lexer); if(name) { - lexer->file = fopen(name, "r"); - if(!lexer->file) +#ifdef _WIN32 + wchar_t* wname = cmsysEncoding_DupToWide(name); + lexer->file = _wfopen(wname, L"rb"); + free(wname); +#else + lexer->file = fopen(name, "rb"); +#endif + if(lexer->file) + { + if(bom) + { + *bom = cmListFileLexer_ReadBOM(lexer->file); + } + } + else { result = 0; } @@ -385,7 +556,7 @@ cmListFileLexer_Token* cmListFileLexer_Scan(cmListFileLexer* lexer) } else { - cmListFileLexer_SetFileName(lexer, 0); + cmListFileLexer_SetFileName(lexer, 0, 0); return 0; } } @@ -431,7 +602,10 @@ const char* cmListFileLexer_GetTypeAsString(cmListFileLexer* lexer, case cmListFileLexer_Token_ParenRight: return "right paren"; case cmListFileLexer_Token_ArgumentUnquoted: return "unquoted argument"; case cmListFileLexer_Token_ArgumentQuoted: return "quoted argument"; + case cmListFileLexer_Token_ArgumentBracket: return "bracket argument"; + case cmListFileLexer_Token_CommentBracket: return "bracket comment"; case cmListFileLexer_Token_BadCharacter: return "bad character"; + case cmListFileLexer_Token_BadBracket: return "unterminated bracket"; case cmListFileLexer_Token_BadString: return "unterminated string"; } return "unknown token"; diff --git a/Source/cmLoadCacheCommand.cxx b/Source/cmLoadCacheCommand.cxx index 462e086..dfd98fa 100644 --- a/Source/cmLoadCacheCommand.cxx +++ b/Source/cmLoadCacheCommand.cxx @@ -12,6 +12,7 @@ #include "cmLoadCacheCommand.h" #include <cmsys/RegularExpression.hxx> +#include <cmsys/FStream.hxx> // cmLoadCacheCommand bool cmLoadCacheCommand @@ -115,7 +116,7 @@ bool cmLoadCacheCommand::ReadWithPrefix(std::vector<std::string> const& args) } // Read the cache file. - std::ifstream fin(cacheFile.c_str()); + cmsys::ifstream fin(cacheFile.c_str()); // This is a big hack read loop to overcome a buggy ifstream // implementation on HP-UX. This should work on all platforms even diff --git a/Source/cmLoadCacheCommand.h b/Source/cmLoadCacheCommand.h index f55cbb3..c8f7236 100644 --- a/Source/cmLoadCacheCommand.h +++ b/Source/cmLoadCacheCommand.h @@ -42,39 +42,6 @@ public: */ virtual const char* GetName() const { return "load_cache";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Load in the values from another project's CMake cache."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " load_cache(pathToCacheFile READ_WITH_PREFIX\n" - " prefix entry1...)\n" - "Read the cache and store the requested entries in variables with " - "their name prefixed with the given prefix. " - "This only reads the values, and does not create entries in the local " - "project's cache.\n" - " load_cache(pathToCacheFile [EXCLUDE entry1...]\n" - " [INCLUDE_INTERNALS entry1...])\n" - "Load in the values from another cache and store them in the local " - "project's cache as internal entries. This is useful for a project " - "that depends on another project built in a different tree. " - "EXCLUDE option can be used to provide a list of entries to be " - "excluded. " - "INCLUDE_INTERNALS can be used to provide a list of internal entries " - "to be included. Normally, no internal entries are brought in. Use " - "of this form of the command is strongly discouraged, but it is " - "provided for backward compatibility."; - } - cmTypeMacro(cmLoadCacheCommand, cmCommand); protected: diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx index b2acf06..21ee0fe 100644 --- a/Source/cmLoadCommandCommand.cxx +++ b/Source/cmLoadCommandCommand.cxx @@ -71,23 +71,6 @@ public: */ virtual const char* GetName() const { return info.Name; } - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - if (this->info.GetTerseDocumentation) - { - cmLoadedCommand::InstallSignalHandlers(info.Name); - const char* ret = info.GetTerseDocumentation(); - cmLoadedCommand::InstallSignalHandlers(info.Name, 1); - return ret; - } - else - { - return "LoadedCommand without any additional documentation"; - } - } static const char* LastName; static void TrapsForSignals(int sig) { @@ -120,24 +103,6 @@ public: } } - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - if (this->info.GetFullDocumentation) - { - cmLoadedCommand::InstallSignalHandlers(info.Name); - const char* ret = info.GetFullDocumentation(); - cmLoadedCommand::InstallSignalHandlers(info.Name, 1); - return ret; - } - else - { - return "LoadedCommand without any additional documentation"; - } - } - cmTypeMacro(cmLoadedCommand, cmCommand); cmLoadedCommandInfo info; @@ -224,6 +189,9 @@ cmLoadedCommand::~cmLoadedCommand() bool cmLoadCommandCommand ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) { + if(this->Disallowed(cmPolicies::CMP0031, + "The load_command command should not be called; see CMP0031.")) + { return true; } if(args.size() < 1 ) { return true; diff --git a/Source/cmLoadCommandCommand.h b/Source/cmLoadCommandCommand.h index f0b34ee..11bcf09 100644 --- a/Source/cmLoadCommandCommand.h +++ b/Source/cmLoadCommandCommand.h @@ -14,59 +14,14 @@ #include "cmCommand.h" -/** \class cmLoadCommandCommand - * \brief Load in a Command plugin - * - * cmLoadCommandCommand loads a command into CMake - */ class cmLoadCommandCommand : public cmCommand { public: - /** - * This is a virtual constructor for the command. - */ - virtual cmCommand* Clone() - { - return new cmLoadCommandCommand; - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ + virtual cmCommand* Clone() { return new cmLoadCommandCommand; } virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); - - /** - * The name of the command as specified in CMakeList.txt. - */ virtual const char* GetName() const {return "load_command";} - - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Load a command into a running CMake."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " load_command(COMMAND_NAME <loc1> [loc2 ...])\n" - "The given locations are searched for a library whose name is " - "cmCOMMAND_NAME. If found, it is loaded as a module and the command " - "is added to the set of available CMake commands. Usually, " - "TRY_COMPILE is used before this command to compile the module. " - "If the command is successfully loaded a variable named\n" - " CMAKE_LOADED_COMMAND_<COMMAND_NAME>\n" - "will be set to the full path of the module that was loaded. " - "Otherwise the variable will not be set."; - } - + virtual bool IsDiscouraged() const { return true; } cmTypeMacro(cmLoadCommandCommand, cmCommand); }; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 9c04109..3effe38 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -37,7 +37,8 @@ #include <assert.h> #if defined(__HAIKU__) -#include <StorageKit.h> +#include <FindDirectory.h> +#include <StorageDefs.h> #endif cmLocalGenerator::cmLocalGenerator() @@ -256,10 +257,15 @@ void cmLocalGenerator::ConfigureFinalPass() void cmLocalGenerator::TraceDependencies() { // Generate the rule files for each target. - cmTargets& targets = this->Makefile->GetTargets(); - for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) + cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator t = targets.begin(); + t != targets.end(); ++t) { - t->second.TraceDependencies(); + if (t->second->Target->IsImported()) + { + continue; + } + t->second->TraceDependencies(); } } @@ -297,7 +303,7 @@ void cmLocalGenerator::GenerateTestFiles() this->Makefile->GetProperty("TEST_INCLUDE_FILE"); if ( testIncludeFile ) { - fout << "INCLUDE(\"" << testIncludeFile << "\")" << std::endl; + fout << "include(\"" << testIncludeFile << "\")" << std::endl; } // Ask each test generator to write its code. @@ -313,7 +319,8 @@ void cmLocalGenerator::GenerateTestFiles() size_t i; for(i = 0; i < this->Children.size(); ++i) { - fout << "SUBDIRS("; + // TODO: Use add_subdirectory instead? + fout << "subdirs("; std::string outP = this->Children[i]->GetMakefile()->GetStartOutputDirectory(); fout << this->Convert(outP.c_str(),START_OUTPUT); @@ -348,16 +355,17 @@ void cmLocalGenerator::GenerateInstallRules() prefix = prefix_win32.c_str(); } #elif defined(__HAIKU__) + char dir[B_PATH_NAME_LENGTH]; if (!prefix) { - BPath dir; - if (find_directory(B_COMMON_DIRECTORY, &dir) == B_OK) + if (find_directory(B_SYSTEM_DIRECTORY, -1, false, dir, sizeof(dir)) + == B_OK) { - prefix = dir.Path(); + prefix = dir; } else { - prefix = "/boot/common"; + prefix = "/boot/system"; } } #else @@ -366,6 +374,11 @@ void cmLocalGenerator::GenerateInstallRules() prefix = "/usr/local"; } #endif + if (const char *stagingPrefix + = this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX")) + { + prefix = stagingPrefix; + } // Compute the set of configurations. std::vector<std::string> configurationTypes; @@ -416,39 +429,39 @@ void cmLocalGenerator::GenerateInstallRules() fout << "# Install script for directory: " << this->Makefile->GetCurrentDirectory() << std::endl << std::endl; fout << "# Set the install prefix" << std::endl - << "IF(NOT DEFINED CMAKE_INSTALL_PREFIX)" << std::endl - << " SET(CMAKE_INSTALL_PREFIX \"" << prefix << "\")" << std::endl - << "ENDIF(NOT DEFINED CMAKE_INSTALL_PREFIX)" << std::endl - << "STRING(REGEX REPLACE \"/$\" \"\" CMAKE_INSTALL_PREFIX " + << "if(NOT DEFINED CMAKE_INSTALL_PREFIX)" << std::endl + << " set(CMAKE_INSTALL_PREFIX \"" << prefix << "\")" << std::endl + << "endif()" << std::endl + << "string(REGEX REPLACE \"/$\" \"\" CMAKE_INSTALL_PREFIX " << "\"${CMAKE_INSTALL_PREFIX}\")" << std::endl << std::endl; // Write support code for generating per-configuration install rules. fout << "# Set the install configuration name.\n" - "IF(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)\n" - " IF(BUILD_TYPE)\n" - " STRING(REGEX REPLACE \"^[^A-Za-z0-9_]+\" \"\"\n" + "if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)\n" + " if(BUILD_TYPE)\n" + " string(REGEX REPLACE \"^[^A-Za-z0-9_]+\" \"\"\n" " CMAKE_INSTALL_CONFIG_NAME \"${BUILD_TYPE}\")\n" - " ELSE(BUILD_TYPE)\n" - " SET(CMAKE_INSTALL_CONFIG_NAME \"" << default_config << "\")\n" - " ENDIF(BUILD_TYPE)\n" - " MESSAGE(STATUS \"Install configuration: " + " else()\n" + " set(CMAKE_INSTALL_CONFIG_NAME \"" << default_config << "\")\n" + " endif()\n" + " message(STATUS \"Install configuration: " "\\\"${CMAKE_INSTALL_CONFIG_NAME}\\\"\")\n" - "ENDIF(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)\n" + "endif()\n" "\n"; // Write support code for dealing with component-specific installs. fout << "# Set the component getting installed.\n" - "IF(NOT CMAKE_INSTALL_COMPONENT)\n" - " IF(COMPONENT)\n" - " MESSAGE(STATUS \"Install component: \\\"${COMPONENT}\\\"\")\n" - " SET(CMAKE_INSTALL_COMPONENT \"${COMPONENT}\")\n" - " ELSE(COMPONENT)\n" - " SET(CMAKE_INSTALL_COMPONENT)\n" - " ENDIF(COMPONENT)\n" - "ENDIF(NOT CMAKE_INSTALL_COMPONENT)\n" + "if(NOT CMAKE_INSTALL_COMPONENT)\n" + " if(COMPONENT)\n" + " message(STATUS \"Install component: \\\"${COMPONENT}\\\"\")\n" + " set(CMAKE_INSTALL_COMPONENT \"${COMPONENT}\")\n" + " else()\n" + " set(CMAKE_INSTALL_COMPONENT)\n" + " endif()\n" + "endif()\n" "\n"; // Copy user-specified install options to the install code. @@ -457,9 +470,9 @@ void cmLocalGenerator::GenerateInstallRules() { fout << "# Install shared libraries without execute permission?\n" - "IF(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)\n" - " SET(CMAKE_INSTALL_SO_NO_EXE \"" << so_no_exe << "\")\n" - "ENDIF(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)\n" + "if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)\n" + " set(CMAKE_INSTALL_SO_NO_EXE \"" << so_no_exe << "\")\n" + "endif()\n" "\n"; } @@ -479,7 +492,7 @@ void cmLocalGenerator::GenerateInstallRules() // Include install scripts from subdirectories. if(!this->Children.empty()) { - fout << "IF(NOT CMAKE_INSTALL_LOCAL_ONLY)\n"; + fout << "if(NOT CMAKE_INSTALL_LOCAL_ONLY)\n"; fout << " # Include the install script for each subdirectory.\n"; for(std::vector<cmLocalGenerator*>::const_iterator ci = this->Children.begin(); ci != this->Children.end(); ++ci) @@ -488,34 +501,34 @@ void cmLocalGenerator::GenerateInstallRules() { std::string odir = (*ci)->GetMakefile()->GetStartOutputDirectory(); cmSystemTools::ConvertToUnixSlashes(odir); - fout << " INCLUDE(\"" << odir.c_str() + fout << " include(\"" << odir.c_str() << "/cmake_install.cmake\")" << std::endl; } } fout << "\n"; - fout << "ENDIF(NOT CMAKE_INSTALL_LOCAL_ONLY)\n\n"; + fout << "endif()\n\n"; } // Record the install manifest. if ( toplevel_install ) { fout << - "IF(CMAKE_INSTALL_COMPONENT)\n" - " SET(CMAKE_INSTALL_MANIFEST \"install_manifest_" + "if(CMAKE_INSTALL_COMPONENT)\n" + " set(CMAKE_INSTALL_MANIFEST \"install_manifest_" "${CMAKE_INSTALL_COMPONENT}.txt\")\n" - "ELSE(CMAKE_INSTALL_COMPONENT)\n" - " SET(CMAKE_INSTALL_MANIFEST \"install_manifest.txt\")\n" - "ENDIF(CMAKE_INSTALL_COMPONENT)\n\n"; + "else()\n" + " set(CMAKE_INSTALL_MANIFEST \"install_manifest.txt\")\n" + "endif()\n\n"; fout - << "FILE(WRITE \"" + << "file(WRITE \"" << homedir.c_str() << "/${CMAKE_INSTALL_MANIFEST}\" " << "\"\")" << std::endl; fout - << "FOREACH(file ${CMAKE_INSTALL_MANIFEST_FILES})" << std::endl - << " FILE(APPEND \"" + << "foreach(file ${CMAKE_INSTALL_MANIFEST_FILES})" << std::endl + << " file(APPEND \"" << homedir.c_str() << "/${CMAKE_INSTALL_MANIFEST}\" " << "\"${file}\\n\")" << std::endl - << "ENDFOREACH(file)" << std::endl; + << "endforeach()" << std::endl; } } @@ -527,10 +540,19 @@ void cmLocalGenerator::GenerateTargetManifest() this->Makefile->GetConfigurations(configNames); // Add our targets to the manifest for each configuration. - cmTargets& targets = this->Makefile->GetTargets(); - for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) + cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator t = targets.begin(); + t != targets.end(); ++t) { - cmTarget& target = t->second; + cmGeneratorTarget& target = *t->second; + if (target.Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } + if (target.Target->IsImported()) + { + continue; + } if(configNames.empty()) { target.GenerateTargetManifest(0); @@ -635,7 +657,8 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmStdString objs; std::vector<std::string> objVector; // Add all the sources outputs to the depends of the target - std::vector<cmSourceFile*> const& classes = target.GetSourceFiles(); + std::vector<cmSourceFile*> classes; + target.GetSourceFiles(classes); for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); i != classes.end(); ++i) { @@ -793,6 +816,7 @@ static const char* ruleReplaceVars[] = "CMAKE_CURRENT_BINARY_DIR", "CMAKE_RANLIB", "CMAKE_LINKER", + "CMAKE_CL_SHOWINCLUDES_PREFIX", 0 }; @@ -1038,11 +1062,38 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, // If this is the compiler then look for the extra variable // _COMPILER_ARG1 which must be the first argument to the compiler const char* compilerArg1 = 0; + const char* compilerTarget = 0; + const char* compilerOptionTarget = 0; + const char* compilerExternalToolchain = 0; + const char* compilerOptionExternalToolchain = 0; + const char* compilerSysroot = 0; + const char* compilerOptionSysroot = 0; if(actualReplace == "CMAKE_${LANG}_COMPILER") { std::string arg1 = actualReplace + "_ARG1"; cmSystemTools::ReplaceString(arg1, "${LANG}", lang); compilerArg1 = this->Makefile->GetDefinition(arg1.c_str()); + compilerTarget + = this->Makefile->GetDefinition( + (std::string("CMAKE_") + lang + "_COMPILER_TARGET").c_str()); + compilerOptionTarget + = this->Makefile->GetDefinition( + (std::string("CMAKE_") + lang + + "_COMPILE_OPTIONS_TARGET").c_str()); + compilerExternalToolchain + = this->Makefile->GetDefinition( + (std::string("CMAKE_") + lang + + "_COMPILER_EXTERNAL_TOOLCHAIN").c_str()); + compilerOptionExternalToolchain + = this->Makefile->GetDefinition( + (std::string("CMAKE_") + lang + + "_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN").c_str()); + compilerSysroot + = this->Makefile->GetDefinition("CMAKE_SYSROOT"); + compilerOptionSysroot + = this->Makefile->GetDefinition( + (std::string("CMAKE_") + lang + + "_COMPILE_OPTIONS_SYSROOT").c_str()); } if(actualReplace.find("${LANG}") != actualReplace.npos) { @@ -1063,6 +1114,24 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, ret += " "; ret += compilerArg1; } + if (compilerTarget && compilerOptionTarget) + { + ret += " "; + ret += compilerOptionTarget; + ret += compilerTarget; + } + if (compilerExternalToolchain && compilerOptionExternalToolchain) + { + ret += " "; + ret += compilerOptionExternalToolchain; + ret += this->EscapeForShell(compilerExternalToolchain, true); + } + if (compilerSysroot && compilerOptionSysroot) + { + ret += " "; + ret += compilerOptionSysroot; + ret += this->EscapeForShell(compilerSysroot, true); + } return ret; } return replace; @@ -1250,6 +1319,12 @@ std::string cmLocalGenerator::GetIncludeFlags( sysIncludeFlag = this->Makefile->GetDefinition(sysFlagVar.c_str()); } + std::string fwSearchFlagVar = "CMAKE_"; + fwSearchFlagVar += lang; + fwSearchFlagVar += "_FRAMEWORK_SEARCH_FLAG"; + const char* fwSearchFlag = + this->Makefile->GetDefinition(fwSearchFlagVar.c_str()); + bool flagUsed = false; std::set<cmStdString> emitted; #ifdef __APPLE__ @@ -1258,7 +1333,7 @@ std::string cmLocalGenerator::GetIncludeFlags( std::vector<std::string>::const_iterator i; for(i = includes.begin(); i != includes.end(); ++i) { - if(this->Makefile->IsOn("APPLE") + if(fwSearchFlag && *fwSearchFlag && this->Makefile->IsOn("APPLE") && cmSystemTools::IsPathToFramework(i->c_str())) { std::string frameworkDir = *i; @@ -1268,8 +1343,8 @@ std::string cmLocalGenerator::GetIncludeFlags( { OutputFormat format = forResponseFile? RESPONSE : SHELL; includeFlags - << "-F" << this->Convert(frameworkDir.c_str(), - START_OUTPUT, format, true) + << fwSearchFlag << this->Convert(frameworkDir.c_str(), + START_OUTPUT, format, true) << " "; } continue; @@ -1320,7 +1395,7 @@ std::string cmLocalGenerator::GetIncludeFlags( //---------------------------------------------------------------------------- void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines, - cmTarget* target, + cmTarget const* target, const char* config) { std::vector<std::string> targetDefines; @@ -1403,34 +1478,6 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, includeBinaryDir = true; } - // CMake versions below 2.0 would add the source tree to the -I path - // automatically. Preserve compatibility. - if(this->NeedBackwardsCompatibility(1,9)) - { - includeSourceDir = true; - } - - // Hack for VTK 4.0 - 4.4 which depend on the old behavior but do - // not set the backwards compatibility level automatically. - const char* vtkSourceDir = - this->Makefile->GetDefinition("VTK_SOURCE_DIR"); - if(vtkSourceDir) - { - const char* vtk_major = - this->Makefile->GetDefinition("VTK_MAJOR_VERSION"); - const char* vtk_minor = - this->Makefile->GetDefinition("VTK_MINOR_VERSION"); - vtk_major = vtk_major? vtk_major : "4"; - vtk_minor = vtk_minor? vtk_minor : "4"; - int vmajor = 0; - int vminor = 0; - if(sscanf(vtk_major, "%d", &vmajor) && - sscanf(vtk_minor, "%d", &vminor) && vmajor == 4 && vminor <= 4) - { - includeSourceDir = true; - } - } - // Do not repeat an include path. std::set<cmStdString> emitted; @@ -1458,6 +1505,8 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, return; } + std::string rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT"); + std::vector<std::string> implicitDirs; // Load implicit include directories for this language. std::string impDirVar = "CMAKE_"; @@ -1470,7 +1519,9 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, for(std::vector<std::string>::const_iterator i = impDirVec.begin(); i != impDirVec.end(); ++i) { - emitted.insert(*i); + std::string d = rootPath + *i; + cmSystemTools::ConvertToUnixSlashes(d); + emitted.insert(d); if (!stripImplicitInclDirs) { implicitDirs.push_back(*i); @@ -1581,7 +1632,8 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, if(this->Makefile->IsOn("WIN32") && !(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW"))) { - const std::vector<cmSourceFile*>& sources = target->GetSourceFiles(); + std::vector<cmSourceFile*> sources; + target->GetSourceFiles(sources); for(std::vector<cmSourceFile*>::const_iterator i = sources.begin(); i != sources.end(); ++i) { @@ -1767,13 +1819,21 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, } // Append the framework search path flags. - std::vector<std::string> const& fwDirs = cli.GetFrameworkPaths(); - for(std::vector<std::string>::const_iterator fdi = fwDirs.begin(); - fdi != fwDirs.end(); ++fdi) + std::string fwSearchFlagVar = "CMAKE_"; + fwSearchFlagVar += linkLanguage; + fwSearchFlagVar += "_FRAMEWORK_SEARCH_FLAG"; + const char* fwSearchFlag = + this->Makefile->GetDefinition(fwSearchFlagVar.c_str()); + if(fwSearchFlag && *fwSearchFlag) { - frameworkPath += "-F"; - frameworkPath += this->Convert(fdi->c_str(), NONE, SHELL, false); - frameworkPath += " "; + std::vector<std::string> const& fwDirs = cli.GetFrameworkPaths(); + for(std::vector<std::string>::const_iterator fdi = fwDirs.begin(); + fdi != fwDirs.end(); ++fdi) + { + frameworkPath += fwSearchFlag; + frameworkPath += this->Convert(fdi->c_str(), NONE, SHELL, false); + frameworkPath += " "; + } } // Append the library search path flags. @@ -1793,6 +1853,10 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, ItemVector const& items = cli.GetItems(); for(ItemVector::const_iterator li = items.begin(); li != items.end(); ++li) { + if(li->Target && li->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } if(li->IsPath) { linkLibs += this->ConvertToLinkReference(li->Value); @@ -1996,6 +2060,10 @@ bool cmLocalGenerator::GetRealDependency(const char* inName, // An object library has no single file on which to depend. // This was listed to get the target-level dependency. return false; + case cmTarget::INTERFACE_LIBRARY: + // An interface library has no file on which to depend. + // This was listed to get the target-level dependency. + return false; case cmTarget::UTILITY: case cmTarget::GLOBAL_TARGET: // A utility target has no file on which to depend. This was listed @@ -2755,6 +2823,11 @@ cmLocalGenerator cmTargets& tgts = this->Makefile->GetTargets(); for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l) { + if (l->second.GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } + // Include the user-specified pre-install script for this target. if(const char* preinstall = l->second.GetProperty("PRE_INSTALL_SCRIPT")) { @@ -3046,7 +3119,7 @@ cmLocalGenerator // Decide whether this language wants to replace the source // extension with the object extension. For CMake 2.4 // compatibility do this by default. - bool replaceExt = this->NeedBackwardsCompatibility(2, 4); + bool replaceExt = this->NeedBackwardsCompatibility_2_4(); if(!replaceExt) { if(const char* lang = source.GetLanguage()) @@ -3293,9 +3366,7 @@ unsigned int cmLocalGenerator::GetBackwardsCompatibility() } //---------------------------------------------------------------------------- -bool cmLocalGenerator::NeedBackwardsCompatibility(unsigned int major, - unsigned int minor, - unsigned int patch) +bool cmLocalGenerator::NeedBackwardsCompatibility_2_4() { // Check the policy to decide whether to pay attention to this // variable. @@ -3323,7 +3394,7 @@ bool cmLocalGenerator::NeedBackwardsCompatibility(unsigned int major, // equal to or lower than the given version. unsigned int actual_compat = this->GetBackwardsCompatibility(); return (actual_compat && - actual_compat <= CMake_VERSION_ENCODE(major, minor, patch)); + actual_compat <= CMake_VERSION_ENCODE(2, 4, 255)); } //---------------------------------------------------------------------------- diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 10f0b1a..ad662d5 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -224,8 +224,9 @@ public: bool stripImplicitInclDirs = true); void AddCompileOptions(std::string& flags, cmTarget* target, const char* lang, const char* config); - void AddCompileDefinitions(std::set<std::string>& defines, cmTarget* target, - const char* config); + void AddCompileDefinitions(std::set<std::string>& defines, + cmTarget const* target, + const char* config); /** Compute the language used to compile the given source file. */ const char* GetSourceFileLanguage(const cmSourceFile& source); @@ -266,6 +267,7 @@ public: const char* Defines; const char* RuleLauncher; const char* DependencyFile; + const char* FilterPrefix; }; /** Set whether to treat conversions to SHELL as a link script shell. */ @@ -324,9 +326,7 @@ public: /** * Test whether compatibility is set to a given version or lower. */ - bool NeedBackwardsCompatibility(unsigned int major, - unsigned int minor, - unsigned int patch = 0xFFu); + bool NeedBackwardsCompatibility_2_4(); /** * Generate a Mac OS X application bundle Info.plist file. diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index a522e37..cd12c9d 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -17,7 +17,6 @@ #include "cmNinjaTargetGenerator.h" #include "cmGeneratedFileStream.h" #include "cmSourceFile.h" -#include "cmComputeLinkInformation.h" #include "cmake.h" #include <assert.h> @@ -49,20 +48,42 @@ void cmLocalNinjaGenerator::Generate() this->WriteProcessedMakefile(this->GetRulesFileStream()); #endif - this->WriteBuildFileTop(); + // We do that only once for the top CMakeLists.txt file. + if(this->isRootMakefile()) + { + this->WriteBuildFileTop(); + + this->WritePools(this->GetRulesFileStream()); + + const std::string showIncludesPrefix = this->GetMakefile() + ->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX"); + if (!showIncludesPrefix.empty()) + { + cmGlobalNinjaGenerator::WriteComment(this->GetRulesFileStream(), + "localized /showIncludes string"); + this->GetRulesFileStream() + << "msvc_deps_prefix = " << showIncludesPrefix << "\n\n"; + } + } - cmTargets& targets = this->GetMakefile()->GetTargets(); - for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) + cmGeneratorTargetsType targets = this->GetMakefile()->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator t = targets.begin(); + t != targets.end(); ++t) { - cmNinjaTargetGenerator* tg = cmNinjaTargetGenerator::New(&t->second); + if (t->second->Target->GetType() == cmTarget::INTERFACE_LIBRARY + || t->second->Target->IsImported()) + { + continue; + } + cmNinjaTargetGenerator* tg = cmNinjaTargetGenerator::New(t->second); if(tg) { tg->Generate(); // Add the target to "all" if required. if (!this->GetGlobalNinjaGenerator()->IsExcluded( this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], - t->second)) - this->GetGlobalNinjaGenerator()->AddDependencyToAll(&t->second); + *t->second->Target)) + this->GetGlobalNinjaGenerator()->AddDependencyToAll(t->second->Target); delete tg; } } @@ -164,10 +185,6 @@ bool cmLocalNinjaGenerator::isRootMakefile() const void cmLocalNinjaGenerator::WriteBuildFileTop() { - // We do that only once for the top CMakeLists.txt file. - if(!this->isRootMakefile()) - return; - // For the build file. this->WriteProjectHeader(this->GetBuildFileStream()); this->WriteNinjaFilesInclusion(this->GetBuildFileStream()); @@ -186,6 +203,39 @@ void cmLocalNinjaGenerator::WriteProjectHeader(std::ostream& os) cmGlobalNinjaGenerator::WriteDivider(os); } +void cmLocalNinjaGenerator::WritePools(std::ostream& os) +{ + cmGlobalNinjaGenerator::WriteDivider(os); + + const char* jobpools = this->GetCMakeInstance() + ->GetProperty("JOB_POOLS", cmProperty::GLOBAL); + if (jobpools) + { + cmGlobalNinjaGenerator::WriteComment(os, + "Pools defined by global property JOB_POOLS"); + std::vector<std::string> pools; + cmSystemTools::ExpandListArgument(jobpools, pools); + for (size_t i = 0; i < pools.size(); ++i) + { + const std::string pool = pools[i]; + const std::string::size_type eq = pool.find("="); + unsigned int jobs; + if (eq != std::string::npos && + sscanf(pool.c_str() + eq, "=%u", &jobs) == 1) + { + os << "pool " << pool.substr(0, eq) << std::endl; + os << " depth = " << jobs << std::endl; + os << std::endl; + } + else + { + cmSystemTools::Error("Invalid pool defined by property 'JOB_POOLS': ", + pool.c_str()); + } + } + } +} + void cmLocalNinjaGenerator::WriteNinjaFilesInclusion(std::ostream& os) { cmGlobalNinjaGenerator::WriteDivider(os); @@ -278,16 +328,32 @@ std::string cmLocalNinjaGenerator::BuildCommandLine( cmOStringStream cmd; for (std::vector<std::string>::const_iterator li = cmdLines.begin(); - li != cmdLines.end(); ++li) { - if (li != cmdLines.begin()) { - cmd << " && "; + li != cmdLines.end(); ++li) #ifdef _WIN32 - } else if (cmdLines.size() > 1) { - cmd << "cmd.exe /c "; -#endif + { + if (li != cmdLines.begin()) + { + cmd << " && "; + } + else if (cmdLines.size() > 1) + { + cmd << "cmd.exe /C \""; + } + cmd << *li; } + if (cmdLines.size() > 1) + { + cmd << "\""; + } +#else + { + if (li != cmdLines.begin()) + { + cmd << " && "; + } cmd << *li; - } + } +#endif return cmd.str(); } @@ -309,9 +375,13 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc, cdCmd << cdStr << this->ConvertToOutputFormat(wd, SHELL); cmdLines.push_back(cdCmd.str()); } + + std::string launcher = this->MakeCustomLauncher(*cc); + for (unsigned i = 0; i != ccg.GetNumberOfCommands(); ++i) { - cmdLines.push_back(this->ConvertToOutputFormat(ccg.GetCommand(i).c_str(), - SHELL)); + cmdLines.push_back(launcher + + this->ConvertToOutputFormat(ccg.GetCommand(i).c_str(), SHELL)); + std::string& cmd = cmdLines.back(); ccg.AppendArguments(i, cmd); } @@ -398,3 +468,39 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements() this->WriteCustomCommandBuildStatement(i->first, ccTargetDeps); } } + +std::string cmLocalNinjaGenerator::MakeCustomLauncher( + const cmCustomCommand& cc) +{ + const char* property = "RULE_LAUNCH_CUSTOM"; + const char* property_value = this->Makefile->GetProperty(property); + + if(!property_value || !*property_value) + { + return std::string(); + } + + // Expand rules in the empty string. It may insert the launcher and + // perform replacements. + RuleVariables vars; + vars.RuleLauncher = property; + std::string output; + const std::vector<std::string>& outputs = cc.GetOutputs(); + if(!outputs.empty()) + { + RelativeRoot relative_root = + cc.GetWorkingDirectory() ? NONE : START_OUTPUT; + + output = this->Convert(outputs[0].c_str(), relative_root, SHELL); + } + vars.Output = output.c_str(); + + std::string launcher; + this->ExpandRuleVariables(launcher, vars); + if(!launcher.empty()) + { + launcher += " "; + } + + return launcher; +} diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index c450841..ea854c6 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -112,6 +112,7 @@ private: void WriteProjectHeader(std::ostream& os); void WriteNinjaFilesInclusion(std::ostream& os); void WriteProcessedMakefile(std::ostream& os); + void WritePools(std::ostream& os); void SetConfigName(); @@ -121,6 +122,7 @@ private: void WriteCustomCommandBuildStatements(); + std::string MakeCustomLauncher(const cmCustomCommand& cc); std::string ConfigName; std::string HomeRelativeOutputPath; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 56da1f9..93722d1 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -145,13 +145,19 @@ void cmLocalUnixMakefileGenerator3::Generate() this->Makefile->IsOn("CMAKE_SKIP_ASSEMBLY_SOURCE_RULES"); // Generate the rule files for each target. - cmTargets& targets = this->Makefile->GetTargets(); + cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); cmGlobalUnixMakefileGenerator3* gg = static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator); - for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) + for(cmGeneratorTargetsType::iterator t = targets.begin(); + t != targets.end(); ++t) { + if (t->second->Target->GetType() == cmTarget::INTERFACE_LIBRARY + || t->second->Target->IsImported()) + { + continue; + } cmsys::auto_ptr<cmMakefileTargetGenerator> tg( - cmMakefileTargetGenerator::New(&(t->second))); + cmMakefileTargetGenerator::New(t->second)); if (tg.get()) { tg->WriteRuleFiles(); @@ -372,21 +378,27 @@ void cmLocalUnixMakefileGenerator3 // for each target we just provide a rule to cd up to the top and do a make // on the target - cmTargets& targets = this->Makefile->GetTargets(); + cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); std::string localName; - for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) - { - if((t->second.GetType() == cmTarget::EXECUTABLE) || - (t->second.GetType() == cmTarget::STATIC_LIBRARY) || - (t->second.GetType() == cmTarget::SHARED_LIBRARY) || - (t->second.GetType() == cmTarget::MODULE_LIBRARY) || - (t->second.GetType() == cmTarget::OBJECT_LIBRARY) || - (t->second.GetType() == cmTarget::UTILITY)) + for(cmGeneratorTargetsType::iterator t = targets.begin(); + t != targets.end(); ++t) + { + if((t->second->GetType() == cmTarget::EXECUTABLE) || + (t->second->GetType() == cmTarget::STATIC_LIBRARY) || + (t->second->GetType() == cmTarget::SHARED_LIBRARY) || + (t->second->GetType() == cmTarget::MODULE_LIBRARY) || + (t->second->GetType() == cmTarget::OBJECT_LIBRARY) || + (t->second->GetType() == cmTarget::UTILITY)) { - emitted.insert(t->second.GetName()); + if (t->second->Target->IsImported()) + { + continue; + } + + emitted.insert(t->second->GetName()); // for subdirs add a rule to build this specific target by name. - localName = this->GetRelativeTargetDirectory(t->second); + localName = this->GetRelativeTargetDirectory(*t->second->Target); localName += "/rule"; commands.clear(); depends.clear(); @@ -403,22 +415,23 @@ void cmLocalUnixMakefileGenerator3 localName.c_str(), depends, commands, true); // Add a target with the canonical name (no prefix, suffix or path). - if(localName != t->second.GetName()) + if(localName != t->second->GetName()) { commands.clear(); depends.push_back(localName); this->WriteMakeRule(ruleFileStream, "Convenience name for target.", - t->second.GetName(), depends, commands, true); + t->second->GetName(), depends, commands, true); } // Add a fast rule to build the target - std::string makefileName = this->GetRelativeTargetDirectory(t->second); + std::string makefileName = + this->GetRelativeTargetDirectory(*t->second->Target); makefileName += "/build.make"; // make sure the makefile name is suitable for a makefile std::string makeTargetName = - this->GetRelativeTargetDirectory(t->second); + this->GetRelativeTargetDirectory(*t->second->Target); makeTargetName += "/build"; - localName = t->second.GetName(); + localName = t->second->GetName(); localName += "/fast"; depends.clear(); commands.clear(); @@ -432,11 +445,12 @@ void cmLocalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. - if(t->second.NeedRelinkBeforeInstall(this->ConfigurationName.c_str())) + if(t->second->Target + ->NeedRelinkBeforeInstall(this->ConfigurationName.c_str())) { - makeTargetName = this->GetRelativeTargetDirectory(t->second); + makeTargetName = this->GetRelativeTargetDirectory(*t->second->Target); makeTargetName += "/preinstall"; - localName = t->second.GetName(); + localName = t->second->GetName(); localName += "/preinstall"; depends.clear(); commands.clear(); @@ -474,9 +488,9 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile() // Setup relative path conversion tops. infoFileStream << "# Relative path conversion top directories.\n" - << "SET(CMAKE_RELATIVE_PATH_TOP_SOURCE \"" << this->RelativePathTopSource + << "set(CMAKE_RELATIVE_PATH_TOP_SOURCE \"" << this->RelativePathTopSource << "\")\n" - << "SET(CMAKE_RELATIVE_PATH_TOP_BINARY \"" << this->RelativePathTopBinary + << "set(CMAKE_RELATIVE_PATH_TOP_BINARY \"" << this->RelativePathTopBinary << "\")\n" << "\n"; @@ -485,7 +499,7 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile() { infoFileStream << "# Force unix paths in dependencies.\n" - << "SET(CMAKE_FORCE_UNIX_PATHS 1)\n" + << "set(CMAKE_FORCE_UNIX_PATHS 1)\n" << "\n"; } @@ -495,21 +509,21 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile() << "# The C and CXX include file regular expressions for " << "this directory.\n"; infoFileStream - << "SET(CMAKE_C_INCLUDE_REGEX_SCAN "; + << "set(CMAKE_C_INCLUDE_REGEX_SCAN "; this->WriteCMakeArgument(infoFileStream, this->Makefile->GetIncludeRegularExpression()); infoFileStream << ")\n"; infoFileStream - << "SET(CMAKE_C_INCLUDE_REGEX_COMPLAIN "; + << "set(CMAKE_C_INCLUDE_REGEX_COMPLAIN "; this->WriteCMakeArgument(infoFileStream, this->Makefile->GetComplainRegularExpression()); infoFileStream << ")\n"; infoFileStream - << "SET(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN})\n"; + << "set(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN})\n"; infoFileStream - << "SET(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN " + << "set(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN " "${CMAKE_C_INCLUDE_REGEX_COMPLAIN})\n"; } @@ -698,17 +712,6 @@ cmLocalUnixMakefileGenerator3 << "# Escaping for special characters.\n" << "EQUALS = =\n" << "\n"; - - if(const char* edit_cmd = - this->Makefile->GetDefinition("CMAKE_EDIT_COMMAND")) - { - makefileStream - << "# The program to use to edit the cache.\n" - << "CMAKE_EDIT_COMMAND = " - << this->ConvertShellCommand(edit_cmd, FULL) << "\n" - << "\n"; - } - makefileStream << "# The top-level source directory on which CMake was run.\n" << "CMAKE_SOURCE_DIR = " @@ -1158,27 +1161,25 @@ cmLocalUnixMakefileGenerator3 const std::vector<std::string>& files, cmTarget& target, const char* filename) { + std::string cleanfile = this->Makefile->GetCurrentOutputDirectory(); + cleanfile += "/"; + cleanfile += this->GetTargetDirectory(target); + cleanfile += "/cmake_clean"; + if(filename) + { + cleanfile += "_"; + cleanfile += filename; + } + cleanfile += ".cmake"; + std::string cleanfilePath = this->Convert(cleanfile.c_str(), FULL); + cmsys::ofstream fout(cleanfilePath.c_str()); + if(!fout) + { + cmSystemTools::Error("Could not create ", cleanfilePath.c_str()); + } if(!files.empty()) { - std::string cleanfile = this->Makefile->GetCurrentOutputDirectory(); - cleanfile += "/"; - cleanfile += this->GetTargetDirectory(target); - cleanfile += "/cmake_clean"; - if(filename) - { - cleanfile += "_"; - cleanfile += filename; - } - cleanfile += ".cmake"; - std::string cleanfilePath = this->Convert(cleanfile.c_str(), FULL); - std::ofstream fout(cleanfilePath.c_str()); - if(!fout) - { - cmSystemTools::Error("Could not create ", cleanfilePath.c_str()); - } - fout << "FILE(REMOVE_RECURSE\n"; - std::string remove = "$(CMAKE_COMMAND) -P "; - remove += this->Convert(cleanfile.c_str(), START_OUTPUT, SHELL); + fout << "file(REMOVE_RECURSE\n"; for(std::vector<std::string>::const_iterator f = files.begin(); f != files.end(); ++f) { @@ -1186,27 +1187,29 @@ cmLocalUnixMakefileGenerator3 fout << " " << this->EscapeForCMake(fc.c_str()) << "\n"; } fout << ")\n"; - commands.push_back(remove); - - // For the main clean rule add per-language cleaning. - if(!filename) + } + std::string remove = "$(CMAKE_COMMAND) -P "; + remove += this->Convert(cleanfile.c_str(), START_OUTPUT, SHELL); + commands.push_back(remove); + + // For the main clean rule add per-language cleaning. + if(!filename) + { + // Get the set of source languages in the target. + std::set<cmStdString> languages; + target.GetLanguages(languages); + fout << "\n" + << "# Per-language clean rules from dependency scanning.\n" + << "foreach(lang"; + for(std::set<cmStdString>::const_iterator l = languages.begin(); + l != languages.end(); ++l) { - // Get the set of source languages in the target. - std::set<cmStdString> languages; - target.GetLanguages(languages); - fout << "\n" - << "# Per-language clean rules from dependency scanning.\n" - << "FOREACH(lang"; - for(std::set<cmStdString>::const_iterator l = languages.begin(); - l != languages.end(); ++l) - { - fout << " " << *l; - } - fout << ")\n" - << " INCLUDE(" << this->GetTargetDirectory(target) - << "/cmake_clean_${lang}.cmake OPTIONAL)\n" - << "ENDFOREACH(lang)\n"; + fout << " " << *l; } + fout << ")\n" + << " include(" << this->GetTargetDirectory(target) + << "/cmake_clean_${lang}.cmake OPTIONAL)\n" + << "endforeach()\n"; } } @@ -1682,6 +1685,17 @@ void cmLocalUnixMakefileGenerator3 "default_target", depends, no_commands, true); + + // Help out users that try "gmake target1 target2 -j". + cmGlobalUnixMakefileGenerator3* gg = + static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator); + if(gg->AllowNotParallel()) + { + std::vector<std::string> no_depends; + this->WriteMakeRule(ruleFileStream, + "Allow only one \"make -f Makefile2\" at a time, but pass parallelism.", + ".NOTPARALLEL", no_depends, no_commands, true); + } } this->WriteSpecialTargetsTop(ruleFileStream); @@ -1915,7 +1929,7 @@ void cmLocalUnixMakefileGenerator3 cmakefileStream << "# The set of languages for which implicit dependencies are needed:\n"; cmakefileStream - << "SET(CMAKE_DEPENDS_LANGUAGES\n"; + << "set(CMAKE_DEPENDS_LANGUAGES\n"; for(ImplicitDependLanguageMap::const_iterator l = implicitLangs.begin(); l != implicitLangs.end(); ++l) { @@ -1930,7 +1944,7 @@ void cmLocalUnixMakefileGenerator3 l = implicitLangs.begin(); l != implicitLangs.end(); ++l) { cmakefileStream - << "SET(CMAKE_DEPENDS_CHECK_" << l->first.c_str() << "\n"; + << "set(CMAKE_DEPENDS_CHECK_" << l->first.c_str() << "\n"; ImplicitDependFileMap const& implicitPairs = l->second; // for each file pair @@ -1954,7 +1968,7 @@ void cmLocalUnixMakefileGenerator3 if(cid && *cid) { cmakefileStream - << "SET(CMAKE_" << l->first.c_str() << "_COMPILER_ID \"" + << "set(CMAKE_" << l->first.c_str() << "_COMPILER_ID \"" << cid << "\")\n"; } } @@ -1968,7 +1982,7 @@ void cmLocalUnixMakefileGenerator3 cmakefileStream << "\n" << "# Preprocessor definitions for this target.\n" - << "SET(CMAKE_TARGET_DEFINITIONS\n"; + << "set(CMAKE_TARGET_DEFINITIONS\n"; for(std::set<std::string>::const_iterator di = defines.begin(); di != defines.end(); ++di) { @@ -1995,7 +2009,7 @@ void cmLocalUnixMakefileGenerator3 if(!transformRules.empty()) { cmakefileStream - << "SET(CMAKE_INCLUDE_TRANSFORMS\n"; + << "set(CMAKE_INCLUDE_TRANSFORMS\n"; for(std::vector<std::string>::const_iterator tri = transformRules.begin(); tri != transformRules.end(); ++tri) { diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index c3789a0..aedd6ed 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -76,6 +76,10 @@ void cmLocalVisualStudio10Generator::Generate() cmTargets &tgts = this->Makefile->GetTargets(); for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l) { + if(l->second.GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } if(static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator) ->TargetIsFortranOnly(l->second)) { diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index e5b4057..fb12521 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -21,6 +21,7 @@ #include "cmComputeLinkInformation.h" #include <cmsys/RegularExpression.hxx> +#include <cmsys/FStream.hxx> cmLocalVisualStudio6Generator::cmLocalVisualStudio6Generator(): cmLocalVisualStudioGenerator(VS6) @@ -91,6 +92,11 @@ void cmLocalVisualStudio6Generator::AddCMakeListsRules() for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { + if (l->second.GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } + // Add a rule to regenerate the build system when the target // specification source changes. const char* suppRegenRule = @@ -146,8 +152,10 @@ void cmLocalVisualStudio6Generator::OutputDSPFile() case cmTarget::GLOBAL_TARGET: this->SetBuildType(UTILITY, l->first.c_str(), l->second); break; + case cmTarget::INTERFACE_LIBRARY: + continue; default: - cmSystemTools::Error("Bad target type", l->first.c_str()); + cmSystemTools::Error("Bad target type: ", l->first.c_str()); break; } // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace @@ -165,7 +173,7 @@ void cmLocalVisualStudio6Generator::OutputDSPFile() dir += l->first.substr(0, pos); if(!cmSystemTools::MakeDirectory(dir.c_str())) { - cmSystemTools::Error("Error creating directory ", dir.c_str()); + cmSystemTools::Error("Error creating directory: ", dir.c_str()); } } this->CreateSingleDSP(l->first.c_str(),l->second); @@ -193,7 +201,7 @@ void cmLocalVisualStudio6Generator::CreateSingleDSP(const char *lname, // save the name of the real dsp file std::string realDSP = fname; fname += ".cmake"; - std::ofstream fout(fname.c_str()); + cmsys::ofstream fout(fname.c_str()); if(!fout) { cmSystemTools::Error("Error Writing ", fname.c_str()); @@ -306,7 +314,8 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups(); // get the classes from the source lists then add them to the groups - std::vector<cmSourceFile*> const & classes = target.GetSourceFiles(); + std::vector<cmSourceFile*> classes; + target.GetSourceFiles(classes); // now all of the source files have been properly assigned to the target // now stick them into source groups using the reg expressions @@ -329,11 +338,11 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, std::string path = cmSystemTools::GetFilenamePath(source); cmSystemTools::MakeDirectory(path.c_str()); #if defined(_WIN32) || defined(__CYGWIN__) - std::ofstream sourceFout(source.c_str(), + cmsys::ofstream sourceFout(source.c_str(), std::ios::binary | std::ios::out | std::ios::trunc); #else - std::ofstream sourceFout(source.c_str(), + cmsys::ofstream sourceFout(source.c_str(), std::ios::out | std::ios::trunc); #endif if(sourceFout) @@ -393,9 +402,9 @@ void cmLocalVisualStudio6Generator std::string compileFlags; std::vector<std::string> depends; std::string objectNameDir; - if(gt->ExplicitObjectName.find(*sf) != gt->ExplicitObjectName.end()) + if(gt->HasExplicitObjectName(*sf)) { - objectNameDir = cmSystemTools::GetFilenamePath(gt->Objects[*sf]); + objectNameDir = cmSystemTools::GetFilenamePath(gt->GetObjectName(*sf)); } // Add per-source file flags. @@ -751,7 +760,7 @@ void cmLocalVisualStudio6Generator::SetBuildType(BuildType b, // once the build type is set, determine what configurations are // possible - std::ifstream fin(this->DSPHeaderTemplate.c_str()); + cmsys::ifstream fin(this->DSPHeaderTemplate.c_str()); cmsys::RegularExpression reg("# Name "); if(!fin) @@ -1445,7 +1454,7 @@ void cmLocalVisualStudio6Generator std::string customRuleCodeRelWithDebInfo = this->CreateTargetRules(target, "RELWITHDEBINFO", libName); - std::ifstream fin(this->DSPHeaderTemplate.c_str()); + cmsys::ifstream fin(this->DSPHeaderTemplate.c_str()); if(!fin) { cmSystemTools::Error("Error Reading ", this->DSPHeaderTemplate.c_str()); @@ -1778,7 +1787,7 @@ void cmLocalVisualStudio6Generator void cmLocalVisualStudio6Generator::WriteDSPFooter(std::ostream& fout) { - std::ifstream fin(this->DSPFooterTemplate.c_str()); + cmsys::ifstream fin(this->DSPFooterTemplate.c_str()); if(!fin) { cmSystemTools::Error("Error Reading ", @@ -1839,7 +1848,8 @@ void cmLocalVisualStudio6Generator options += this->ConvertToOptionallyRelativeOutputPath(l->Value.c_str()); } - else + else if (!l->Target + || l->Target->GetType() != cmTarget::INTERFACE_LIBRARY) { options += l->Value; } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index bd6c860..57a4880 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -27,9 +27,6 @@ #include <ctype.h> // for isspace -// Package GUID of Intel Visual Fortran plugin to VS IDE -#define CM_INTEL_PLUGIN_GUID "{B68A201D-CB9B-47AF-A52F-7EEC72E217E4}" - static bool cmLVS6G_IsFAT(const char* dir); class cmLocalVisualStudio7GeneratorInternals @@ -78,6 +75,10 @@ void cmLocalVisualStudio7Generator::AddHelperCommands() static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator); for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { + if(l->second.GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } const char* path = l->second.GetProperty("EXTERNAL_MSPROJECT"); if(path) { @@ -181,6 +182,10 @@ void cmLocalVisualStudio7Generator::WriteProjectFiles() for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { + if(l->second.GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace // so don't build a projectfile for it if(!l->second.GetProperty("EXTERNAL_MSPROJECT")) @@ -200,7 +205,7 @@ void cmLocalVisualStudio7Generator::WriteStampFiles() cmSystemTools::MakeDirectory(stampName.c_str()); stampName += "/"; stampName += "generate.stamp"; - std::ofstream stamp(stampName.c_str()); + cmsys::ofstream stamp(stampName.c_str()); stamp << "# CMake generation timestamp file for this directory.\n"; // Create a helper file so CMake can determine when it is run @@ -211,7 +216,7 @@ void cmLocalVisualStudio7Generator::WriteStampFiles() // the stamp file can just be touched. std::string depName = stampName; depName += ".depend"; - std::ofstream depFile(depName.c_str()); + cmsys::ofstream depFile(depName.c_str()); depFile << "# CMake generation dependency list for this directory.\n"; std::vector<std::string> const& listFiles = this->Makefile->GetListFiles(); for(std::vector<std::string>::const_iterator lf = listFiles.begin(); @@ -477,6 +482,8 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] = {"AssemblerListingLocation", "Fa", "ASM List Location", "", cmVS7FlagTable::UserValue}, + {"ProgramDataBaseFileName", "Fd", "Program Database File Name", "", + cmVS7FlagTable::UserValue}, // boolean flags {"BufferSecurityCheck", "GS", "Buffer security check", "TRUE", 0}, @@ -1258,6 +1265,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, } case cmTarget::UTILITY: case cmTarget::GLOBAL_TARGET: + case cmTarget::INTERFACE_LIBRARY: break; } } @@ -1288,7 +1296,8 @@ cmLocalVisualStudio7GeneratorInternals cmLocalGenerator::UNCHANGED); fout << lg->ConvertToXMLOutputPath(rel.c_str()) << " "; } - else + else if (!l->Target + || l->Target->GetType() != cmTarget::INTERFACE_LIBRARY) { fout << l->Value << " "; } @@ -1372,7 +1381,8 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, // get the classes from the source lists then add them to the groups this->ModuleDefinitionFile = ""; - std::vector<cmSourceFile*>const & classes = target.GetSourceFiles(); + std::vector<cmSourceFile*> classes; + target.GetSourceFiles(classes); for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); i != classes.end(); i++) { @@ -1459,9 +1469,9 @@ cmLocalVisualStudio7GeneratorFCInfo cmGeneratorTarget* gt = lg->GetGlobalGenerator()->GetGeneratorTarget(&target); std::string objectName; - if(gt->ExplicitObjectName.find(&sf) != gt->ExplicitObjectName.end()) + if(gt->HasExplicitObjectName(&sf)) { - objectName = gt->Objects[&sf]; + objectName = gt->GetObjectName(&sf); } // Compute per-source, per-config information. @@ -1817,7 +1827,7 @@ WriteCustomRule(std::ostream& fout, // make sure the rule runs reliably. if(!cmSystemTools::FileExists(source)) { - std::ofstream depout(source); + cmsys::ofstream depout(source); depout << "Artificial dependency for a custom command.\n"; } fout << this->ConvertToXMLOutputPath(source); @@ -1951,35 +1961,10 @@ cmLocalVisualStudio7Generator cmGlobalVisualStudio7Generator* gg = static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator); - - // Compute the version of the Intel plugin to the VS IDE. - // If the key does not exist then use a default guess. - std::string intelVersion; - std::string vskey = gg->GetRegistryBase(); - vskey += "\\Packages\\" CM_INTEL_PLUGIN_GUID ";ProductVersion"; - cmSystemTools::ReadRegistryValue(vskey.c_str(), intelVersion, - cmSystemTools::KeyWOW64_32); - unsigned int intelVersionNumber = ~0u; - sscanf(intelVersion.c_str(), "%u", &intelVersionNumber); - if(intelVersionNumber >= 11) - { - // Default to latest known project file version. - intelVersion = "11.0"; - } - else if(intelVersionNumber == 10) - { - // Version 10.x actually uses 9.10 in project files! - intelVersion = "9.10"; - } - else - { - // Version <= 9: use ProductVersion from registry. - } - fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n" << "<VisualStudioProject\n" << "\tProjectCreator=\"Intel Fortran\"\n" - << "\tVersion=\"" << intelVersion << "\"\n"; + << "\tVersion=\"" << gg->GetIntelProjectVersion() << "\"\n"; const char* keyword = target.GetProperty("VS_KEYWORD"); if(!keyword) { @@ -2068,6 +2053,11 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, fout << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\"\n"; } this->WriteProjectSCC(fout, target); + if(const char* targetFrameworkVersion = + target.GetProperty("VS_DOTNET_TARGET_FRAMEWORK_VERSION")) + { + fout << "\tTargetFrameworkVersion=\"" << targetFrameworkVersion << "\"\n"; + } fout << "\tKeyword=\"" << keyword << "\">\n" << "\t<Platforms>\n" << "\t\t<Platform\n\t\t\tName=\"" << this->PlatformName << "\"/>\n" @@ -2235,7 +2225,7 @@ static bool cmLVS6G_IsFAT(const char* dir) char volRoot[4] = "_:/"; volRoot[0] = dir[0]; char fsName[16]; - if(GetVolumeInformation(volRoot, 0, 0, 0, 0, 0, fsName, 16) && + if(GetVolumeInformationA(volRoot, 0, 0, 0, 0, 0, fsName, 16) && strstr(fsName, "FAT") != 0) { return true; diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index 7c5f69d..a9a27b9 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -12,6 +12,7 @@ #include "cmLocalXCodeGenerator.h" #include "cmGlobalXCodeGenerator.h" #include "cmSourceFile.h" +#include "cmMakefile.h" //---------------------------------------------------------------------------- cmLocalXCodeGenerator::cmLocalXCodeGenerator() @@ -42,3 +43,31 @@ void cmLocalXCodeGenerator::AppendFlagEscape(std::string& flags, static_cast<cmGlobalXCodeGenerator*>(this->GlobalGenerator); gg->AppendFlag(flags, rawFlag); } + +//---------------------------------------------------------------------------- +void cmLocalXCodeGenerator::Generate() +{ + cmLocalGenerator::Generate(); + + cmTargets& targets = this->Makefile->GetTargets(); + for(cmTargets::iterator iter = targets.begin(); + iter != targets.end(); ++iter) + { + cmTarget* t = &iter->second; + t->HasMacOSXRpathInstallNameDir(NULL); + } +} + +//---------------------------------------------------------------------------- +void cmLocalXCodeGenerator::GenerateInstallRules() +{ + cmLocalGenerator::GenerateInstallRules(); + + cmTargets& targets = this->Makefile->GetTargets(); + for(cmTargets::iterator iter = targets.begin(); + iter != targets.end(); ++iter) + { + cmTarget* t = &iter->second; + t->HasMacOSXRpathInstallNameDir(NULL); + } +} diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h index d97a41c..edd2f5b 100644 --- a/Source/cmLocalXCodeGenerator.h +++ b/Source/cmLocalXCodeGenerator.h @@ -29,6 +29,8 @@ public: virtual ~cmLocalXCodeGenerator(); virtual std::string GetTargetDirectory(cmTarget const& target) const; virtual void AppendFlagEscape(std::string& flags, const char* rawFlag); + virtual void Generate(); + virtual void GenerateInstallRules(); private: }; diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index 8ba612c..499d3c6 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -67,24 +67,6 @@ public: */ virtual const char* GetName() const { return this->Args[0].c_str(); } - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - std::string docs = "Macro named: "; - docs += this->GetName(); - return docs.c_str(); - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return this->GetTerseDocumentation(); - } - cmTypeMacro(cmMacroHelperCommand, cmCommand); std::vector<std::string> Args; @@ -158,75 +140,82 @@ bool cmMacroHelperCommand::InvokeInitialPass // Set the FilePath on the arguments to match the function since it is // not stored and the original values may be freed k->FilePath = this->FilePath.c_str(); - tmps = k->Value; - // replace formal arguments - for (unsigned int j = 1; j < this->Args.size(); ++j) + if(k->Delim == cmListFileArgument::Bracket) { - variable = "${"; - variable += this->Args[j]; - variable += "}"; - cmSystemTools::ReplaceString(tmps, variable.c_str(), - expandedArgs[j-1].c_str()); + arg.Value = k->Value; } - // replace argc - cmSystemTools::ReplaceString(tmps, "${ARGC}",argcDef.c_str()); - - // repleace ARGN - if (tmps.find("${ARGN}") != std::string::npos) + else { - if (!argnDefInitialized) + tmps = k->Value; + // replace formal arguments + for (unsigned int j = 1; j < this->Args.size(); ++j) + { + variable = "${"; + variable += this->Args[j]; + variable += "}"; + cmSystemTools::ReplaceString(tmps, variable.c_str(), + expandedArgs[j-1].c_str()); + } + // replace argc + cmSystemTools::ReplaceString(tmps, "${ARGC}",argcDef.c_str()); + + // repleace ARGN + if (tmps.find("${ARGN}") != std::string::npos) { - std::vector<std::string>::const_iterator eit; - std::vector<std::string>::size_type cnt = 0; - for ( eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit ) + if (!argnDefInitialized) { - if ( cnt >= this->Args.size()-1 ) + std::vector<std::string>::const_iterator eit; + std::vector<std::string>::size_type cnt = 0; + for(eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit) { - if ( argnDef.size() > 0 ) + if ( cnt >= this->Args.size()-1 ) { - argnDef += ";"; + if ( argnDef.size() > 0 ) + { + argnDef += ";"; + } + argnDef += *eit; } - argnDef += *eit; + cnt ++; } - cnt ++; + argnDefInitialized = true; } - argnDefInitialized = true; + cmSystemTools::ReplaceString(tmps, "${ARGN}", argnDef.c_str()); } - cmSystemTools::ReplaceString(tmps, "${ARGN}", argnDef.c_str()); - } - - // if the current argument of the current function has ${ARGV in it - // then try replacing ARGV values - if (tmps.find("${ARGV") != std::string::npos) - { - char argvName[60]; - // repleace ARGV, compute it only once - if (!argvDefInitialized) + // if the current argument of the current function has ${ARGV in it + // then try replacing ARGV values + if (tmps.find("${ARGV") != std::string::npos) { - std::vector<std::string>::const_iterator eit; - for ( eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit ) + char argvName[60]; + + // repleace ARGV, compute it only once + if (!argvDefInitialized) { - if ( argvDef.size() > 0 ) + std::vector<std::string>::const_iterator eit; + for(eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit) { - argvDef += ";"; + if ( argvDef.size() > 0 ) + { + argvDef += ";"; + } + argvDef += *eit; } - argvDef += *eit; + argvDefInitialized = true; } - argvDefInitialized = true; - } - cmSystemTools::ReplaceString(tmps, "${ARGV}", argvDef.c_str()); + cmSystemTools::ReplaceString(tmps, "${ARGV}", argvDef.c_str()); - // also replace the ARGV1 ARGV2 ... etc - for (unsigned int t = 0; t < expandedArgs.size(); ++t) - { - sprintf(argvName,"${ARGV%i}",t); - cmSystemTools::ReplaceString(tmps, argvName, - expandedArgs[t].c_str()); + // also replace the ARGV1 ARGV2 ... etc + for (unsigned int t = 0; t < expandedArgs.size(); ++t) + { + sprintf(argvName,"${ARGV%i}",t); + cmSystemTools::ReplaceString(tmps, argvName, + expandedArgs[t].c_str()); + } } - } - arg.Value = tmps; + arg.Value = tmps; + } arg.Delim = k->Delim; arg.FilePath = k->FilePath; arg.Line = k->Line; diff --git a/Source/cmMacroCommand.h b/Source/cmMacroCommand.h index aedbb4d..4c585d8 100644 --- a/Source/cmMacroCommand.h +++ b/Source/cmMacroCommand.h @@ -59,50 +59,6 @@ public: */ virtual const char* GetName() const { return "macro";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Start recording a macro for later invocation as a command."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " macro(<name> [arg1 [arg2 [arg3 ...]]])\n" - " COMMAND1(ARGS ...)\n" - " COMMAND2(ARGS ...)\n" - " ...\n" - " endmacro(<name>)\n" - "Define a macro named <name> that takes arguments named " - "arg1 arg2 arg3 (...). Commands listed after macro, " - "but before the matching endmacro, are not invoked until the macro " - "is invoked. When it is invoked, the commands recorded in the " - "macro are first modified by replacing formal parameters (${arg1}) " - "with the arguments passed, and then invoked as normal commands. In " - "addition to referencing the formal parameters you can reference " - "the values ${ARGC} which will be set to the number of arguments " - "passed into the function as well as ${ARGV0} ${ARGV1} ${ARGV2} " - "... which " - "will have the actual values of the arguments passed in. This " - "facilitates creating macros with optional arguments. Additionally " - "${ARGV} holds the list of all arguments given to the macro and " - "${ARGN} " - "holds the list of arguments past the last expected argument. " - "Note that the parameters to a macro and values such as ARGN " - "are not variables in the usual CMake sense. They are string " - "replacements much like the C preprocessor would do with a macro. " - "If you want true CMake variables and/or better CMake scope control " - "you should look at the function command." - "\n" - "See the cmake_policy() command documentation for the behavior of " - "policies inside macros." - ; - } cmTypeMacro(cmMacroCommand, cmCommand); }; diff --git a/Source/cmMakeDepend.cxx b/Source/cmMakeDepend.cxx index 2ae35ef..615e6f2 100644 --- a/Source/cmMakeDepend.cxx +++ b/Source/cmMakeDepend.cxx @@ -14,6 +14,7 @@ #include "cmGeneratorExpression.h" #include <cmsys/RegularExpression.hxx> +#include <cmsys/FStream.hxx> void cmDependInformation::AddDependencies(cmDependInformation* info) { @@ -217,7 +218,7 @@ void cmMakeDepend::DependWalk(cmDependInformation* info) { cmsys::RegularExpression includeLine ("^[ \t]*#[ \t]*include[ \t]*[<\"]([^\">]+)[\">]"); - std::ifstream fin(info->FullPath.c_str()); + cmsys::ifstream fin(info->FullPath.c_str()); if(!fin) { cmSystemTools::Error("Cannot open ", info->FullPath.c_str()); diff --git a/Source/cmMakeDirectoryCommand.h b/Source/cmMakeDirectoryCommand.h index a0f866a..49a4009 100644 --- a/Source/cmMakeDirectoryCommand.h +++ b/Source/cmMakeDirectoryCommand.h @@ -51,26 +51,6 @@ public: */ virtual bool IsScriptable() const { return true; } - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Deprecated. Use the file(MAKE_DIRECTORY ) command instead."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " make_directory(directory)\n" - "Creates the specified directory. Full paths should be given. Any " - "parent directories that do not exist will also be created. Use with " - "care."; - } - /** This command is kept for compatibility with older CMake versions. */ virtual bool IsDiscouraged() const { diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 34541e9..479e712 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -21,9 +21,7 @@ #include "cmCacheManager.h" #include "cmFunctionBlocker.h" #include "cmListFileCache.h" -#include "cmDocumentGeneratorExpressions.h" #include "cmCommandArgumentParserHelper.h" -#include "cmDocumentCompileDefinitions.h" #include "cmGeneratorExpression.h" #include "cmTest.h" #ifdef CMAKE_BUILD_WITH_CMAKE @@ -36,7 +34,7 @@ #include <stdlib.h> // required for atoi #include <cmsys/RegularExpression.hxx> - +#include <cmsys/FStream.hxx> #include <cmsys/auto_ptr.hxx> #include <stack> @@ -801,22 +799,6 @@ void cmMakefile::SetLocalGenerator(cmLocalGenerator* lg) this->CheckSystemVars = this->GetCMakeInstance()->GetCheckSystemVars(); } -bool cmMakefile::NeedBackwardsCompatibility(unsigned int major, - unsigned int minor, - unsigned int patch) -{ - if(this->LocalGenerator) - { - return - this->LocalGenerator->NeedBackwardsCompatibility(major, minor, patch); - } - else - { - return false; - } -} - - namespace { struct file_not_persistent @@ -873,17 +855,23 @@ void cmMakefile::ConfigureFinalPass() this->FinalPass(); const char* oldValue = this->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY"); - if (oldValue && atof(oldValue) <= 1.2) + if (oldValue && cmSystemTools::VersionCompare( + cmSystemTools::OP_LESS, oldValue, "2.4")) { - cmSystemTools::Error("You have requested backwards compatibility " - "with CMake version 1.2 or earlier. This version " - "of CMake only supports backwards compatibility " - "with CMake 1.4 or later. For compatibility with " - "1.2 or earlier please use CMake 2.0"); + this->IssueMessage( + cmake::FATAL_ERROR, + "You have set CMAKE_BACKWARDS_COMPATIBILITY to a CMake version less " + "than 2.4. This version of CMake only supports backwards compatibility " + "with CMake 2.4 or later. For compatibility with older versions please " + "use any CMake 2.8.x release or lower."); } for (cmTargets::iterator l = this->Targets.begin(); l != this->Targets.end(); l++) { + if (l->second.GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } l->second.FinishConfigure(); } } @@ -900,34 +888,61 @@ cmMakefile::AddCustomCommandToTarget(const char* target, { // Find the target to which to add the custom command. cmTargets::iterator ti = this->Targets.find(target); - if(ti != this->Targets.end()) + + if(ti == this->Targets.end()) { - if(ti->second.GetType() == cmTarget::OBJECT_LIBRARY) + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + bool issueMessage = false; + switch(this->GetPolicyStatus(cmPolicies::CMP0040)) { - cmOStringStream e; - e << "Target \"" << target << "\" is an OBJECT library " - "that may not have PRE_BUILD, PRE_LINK, or POST_BUILD commands."; - this->IssueMessage(cmake::FATAL_ERROR, e.str()); - return; + case cmPolicies::WARN: + issueMessage = true; + case cmPolicies::OLD: + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + issueMessage = true; + messageType = cmake::FATAL_ERROR; } - // Add the command to the appropriate build step for the target. - std::vector<std::string> no_output; - cmCustomCommand cc(this, no_output, depends, - commandLines, comment, workingDir); - cc.SetEscapeOldStyle(escapeOldStyle); - cc.SetEscapeAllowMakeVars(true); - switch(type) + + if(issueMessage) { - case cmTarget::PRE_BUILD: - ti->second.GetPreBuildCommands().push_back(cc); - break; - case cmTarget::PRE_LINK: - ti->second.GetPreLinkCommands().push_back(cc); - break; - case cmTarget::POST_BUILD: - ti->second.GetPostBuildCommands().push_back(cc); - break; + cmOStringStream e; + e << (this->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0040)) << "\n"; + e << "The target name \"" << target << "\" is unknown in this context."; + IssueMessage(messageType, e.str().c_str()); } + + return; + } + + if(ti->second.GetType() == cmTarget::OBJECT_LIBRARY) + { + cmOStringStream e; + e << "Target \"" << target << "\" is an OBJECT library " + "that may not have PRE_BUILD, PRE_LINK, or POST_BUILD commands."; + this->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; + } + // Add the command to the appropriate build step for the target. + std::vector<std::string> no_output; + cmCustomCommand cc(this, no_output, depends, + commandLines, comment, workingDir); + cc.SetEscapeOldStyle(escapeOldStyle); + cc.SetEscapeAllowMakeVars(true); + switch(type) + { + case cmTarget::PRE_BUILD: + ti->second.AddPreBuildCommand(cc); + break; + case cmTarget::PRE_LINK: + ti->second.AddPreLinkCommand(cc); + break; + case cmTarget::POST_BUILD: + ti->second.AddPostBuildCommand(cc); + break; } } @@ -1458,11 +1473,10 @@ void cmMakefile::AddLinkLibraryForTarget(const char *target, this->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(0,lib); if(tgt) { - // CMake versions below 2.4 allowed linking to modules. - bool allowModules = this->NeedBackwardsCompatibility(2,2); // if it is not a static or shared library then you can not link to it if(!((tgt->GetType() == cmTarget::STATIC_LIBRARY) || (tgt->GetType() == cmTarget::SHARED_LIBRARY) || + (tgt->GetType() == cmTarget::INTERFACE_LIBRARY) || tgt->IsExecutableWithExports())) { cmOStringStream e; @@ -1471,24 +1485,7 @@ void cmMakefile::AddLinkLibraryForTarget(const char *target, << " may not be linked into another target. " << "One may link only to STATIC or SHARED libraries, or " << "to executables with the ENABLE_EXPORTS property set."; - // in older versions of cmake linking to modules was allowed - if( tgt->GetType() == cmTarget::MODULE_LIBRARY ) - { - e << "\n" - << "If you are developing a new project, re-organize it to avoid " - << "linking to modules. " - << "If you are just trying to build an existing project, " - << "set CMAKE_BACKWARDS_COMPATIBILITY to 2.2 or lower to allow " - << "linking to modules."; - } - // if no modules are allowed then this is always an error - if(!allowModules || - // if we allow modules but the type is not a module then it is - // still an error - (allowModules && tgt->GetType() != cmTarget::MODULE_LIBRARY)) - { - this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); - } + this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); } } i->second.AddLinkLibrary( *this, target, lib, llt ); @@ -1604,20 +1601,22 @@ void cmMakefile::InitializeFromParent() } // compile definitions property and per-config versions - { - this->SetProperty("COMPILE_DEFINITIONS", - parent->GetProperty("COMPILE_DEFINITIONS")); - std::vector<std::string> configs; - this->GetConfigurations(configs); - for(std::vector<std::string>::const_iterator ci = configs.begin(); - ci != configs.end(); ++ci) - { - std::string defPropName = "COMPILE_DEFINITIONS_"; - defPropName += cmSystemTools::UpperCase(*ci); - this->SetProperty(defPropName.c_str(), - parent->GetProperty(defPropName.c_str())); + cmPolicies::PolicyStatus polSt = this->GetPolicyStatus(cmPolicies::CMP0043); + if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD) + { + this->SetProperty("COMPILE_DEFINITIONS", + parent->GetProperty("COMPILE_DEFINITIONS")); + std::vector<std::string> configs; + this->GetConfigurations(configs); + for(std::vector<std::string>::const_iterator ci = configs.begin(); + ci != configs.end(); ++ci) + { + std::string defPropName = "COMPILE_DEFINITIONS_"; + defPropName += cmSystemTools::UpperCase(*ci); + const char* prop = parent->GetProperty(defPropName.c_str()); + this->SetProperty(defPropName.c_str(), prop); + } } - } // link libraries this->LinkLibraries = parent->LinkLibraries; @@ -1777,14 +1776,6 @@ void cmMakefile::AddDefinition(const char* name, const char* value) return; } -#ifdef CMAKE_STRICT - if (this->GetCMakeInstance()) - { - this->GetCMakeInstance()-> - RecordPropertyAccess(name,cmProperty::VARIABLE); - } -#endif - this->Internal->VarStack.top().Set(name, value); if (this->Internal->VarUsageStack.size() && this->VariableInitialized(name)) @@ -1990,6 +1981,7 @@ void cmMakefile::AddGlobalLinkInformation(const char* name, cmTarget& target) { case cmTarget::UTILITY: case cmTarget::GLOBAL_TARGET: + case cmTarget::INTERFACE_LIBRARY: return; default:; } @@ -2017,7 +2009,8 @@ cmTarget* cmMakefile::AddLibrary(const char* lname, cmTarget::TargetType type, if ( (type != cmTarget::STATIC_LIBRARY) && (type != cmTarget::SHARED_LIBRARY) && (type != cmTarget::MODULE_LIBRARY) - && (type != cmTarget::OBJECT_LIBRARY)) + && (type != cmTarget::OBJECT_LIBRARY) + && (type != cmTarget::INTERFACE_LIBRARY)) { this->IssueMessage(cmake::INTERNAL_ERROR, "cmMakefile::AddLibrary given invalid target type."); @@ -2269,6 +2262,10 @@ void cmMakefile::ExpandVariablesCMP0019() l != this->Targets.end(); ++l) { cmTarget &t = l->second; + if (t.GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } includeDirs = t.GetProperty("INCLUDE_DIRECTORIES"); if(mightExpandVariablesCMP0019(includeDirs)) { @@ -2445,13 +2442,6 @@ bool cmMakefile::IsDefinitionSet(const char* name) const const char* cmMakefile::GetDefinition(const char* name) const { -#ifdef CMAKE_STRICT - if (this->GetCMakeInstance()) - { - this->GetCMakeInstance()-> - RecordPropertyAccess(name,cmProperty::VARIABLE); - } -#endif if (this->WarnUnused) { this->Internal->VarUsageStack.top().insert(name); @@ -2881,6 +2871,12 @@ bool cmMakefile::ExpandArguments( outArgs.reserve(inArgs.size()); for(i = inArgs.begin(); i != inArgs.end(); ++i) { + // No expansion in a bracket argument. + if(i->Delim == cmListFileArgument::Bracket) + { + outArgs.push_back(i->Value); + continue; + } // Expand the variables in the argument. value = i->Value; this->ExpandVariablesInString(value, false, false, false, @@ -3113,7 +3109,6 @@ int cmMakefile::TryCompile(const char *srcdir, const char *bindir, cm.SetHomeOutputDirectory(bindir); cm.SetStartDirectory(srcdir); cm.SetStartOutputDirectory(bindir); - cm.SetCMakeCommand(cmakeCommand.c_str()); cm.SetGeneratorToolset(this->GetCMakeInstance()->GetGeneratorToolset()); cm.LoadCache(); if(!gg->IsMultiConfig()) @@ -3506,7 +3501,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, } std::string tempOutputFile = soutfile; tempOutputFile += ".tmp"; - std::ofstream fout(tempOutputFile.c_str(), omode); + cmsys::ofstream fout(tempOutputFile.c_str(), omode); if(!fout) { cmSystemTools::Error( @@ -3515,7 +3510,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, cmSystemTools::ReportLastSystemError(""); return 0; } - std::ifstream fin(sinfile.c_str()); + cmsys::ifstream fin(sinfile.c_str()); if(!fin) { cmSystemTools::Error("Could not open file for read in copy operation ", @@ -3864,21 +3859,19 @@ const char* cmMakefile::GetFeature(const char* feature, const char* config) return 0; } -cmTarget* cmMakefile::FindTarget(const char* name, bool excludeAliases) +cmTarget* cmMakefile::FindTarget(const char* name, bool excludeAliases) const { if (!excludeAliases) { - std::map<std::string, cmTarget*>::iterator i + std::map<std::string, cmTarget*>::const_iterator i = this->AliasTargets.find(name); if (i != this->AliasTargets.end()) { return i->second; } } - cmTargets& tgts = this->GetTargets(); - - cmTargets::iterator i = tgts.find ( name ); - if ( i != tgts.end() ) + cmTargets::iterator i = this->Targets.find( name ); + if ( i != this->Targets.end() ) { return &i->second; } @@ -4036,243 +4029,14 @@ void cmMakefile::RaiseScope(const char *var, const char *varDef) void cmMakefile::DefineProperties(cmake *cm) { cm->DefineProperty - ("ADDITIONAL_MAKE_CLEAN_FILES", cmProperty::DIRECTORY, - "Additional files to clean during the make clean stage.", - "A list of files that will be cleaned as a part of the " - "\"make clean\" stage. "); - - cm->DefineProperty - ("CLEAN_NO_CUSTOM", cmProperty::DIRECTORY, - "Should the output of custom commands be left.", - "If this is true then the outputs of custom commands for this " - "directory will not be removed during the \"make clean\" stage. "); - - cm->DefineProperty - ("LISTFILE_STACK", cmProperty::DIRECTORY, - "The current stack of listfiles being processed.", - "This property is mainly useful when trying to debug errors " - "in your CMake scripts. It returns a list of what list files " - "are currently being processed, in order. So if one listfile " - "does an INCLUDE command then that is effectively pushing " - "the included listfile onto the stack.", false); - - cm->DefineProperty - ("TEST_INCLUDE_FILE", cmProperty::DIRECTORY, - "A cmake file that will be included when ctest is run.", - "If you specify TEST_INCLUDE_FILE, that file will be " - "included and processed when ctest is run on the directory."); - - cm->DefineProperty - ("COMPILE_DEFINITIONS", cmProperty::DIRECTORY, - "Preprocessor definitions for compiling a directory's sources.", - "The COMPILE_DEFINITIONS property may be set to a " - "semicolon-separated list of preprocessor " - "definitions using the syntax VAR or VAR=value. Function-style " - "definitions are not supported. CMake will automatically escape " - "the value correctly for the native build system (note that CMake " - "language syntax may require escapes to specify some values). " - "This property may be set on a per-configuration basis using the name " - "COMPILE_DEFINITIONS_<CONFIG> where <CONFIG> is an upper-case name " - "(ex. \"COMPILE_DEFINITIONS_DEBUG\"). " - "This property will be initialized in each directory by its value " - "in the directory's parent.\n" - "CMake will automatically drop some definitions that " - "are not supported by the native build tool. " - "The VS6 IDE does not support definition values with spaces " - "(but NMake does).\n" - CM_DOCUMENT_COMPILE_DEFINITIONS_DISCLAIMER); - - cm->DefineProperty - ("COMPILE_DEFINITIONS_<CONFIG>", cmProperty::DIRECTORY, - "Per-configuration preprocessor definitions in a directory.", - "This is the configuration-specific version of COMPILE_DEFINITIONS. " - "This property will be initialized in each directory by its value " - "in the directory's parent.\n"); - - cm->DefineProperty - ("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM", cmProperty::DIRECTORY, - "Specify #include line transforms for dependencies in a directory.", - "This property specifies rules to transform macro-like #include lines " - "during implicit dependency scanning of C and C++ source files. " - "The list of rules must be semicolon-separated with each entry of " - "the form \"A_MACRO(%)=value-with-%\" (the % must be literal). " - "During dependency scanning occurrences of A_MACRO(...) on #include " - "lines will be replaced by the value given with the macro argument " - "substituted for '%'. For example, the entry\n" - " MYDIR(%)=<mydir/%>\n" - "will convert lines of the form\n" - " #include MYDIR(myheader.h)\n" - "to\n" - " #include <mydir/myheader.h>\n" - "allowing the dependency to be followed.\n" - "This property applies to sources in all targets within a directory. " - "The property value is initialized in each directory by its value " - "in the directory's parent."); - - cm->DefineProperty - ("EXCLUDE_FROM_ALL", cmProperty::DIRECTORY, - "Exclude the directory from the all target of its parent.", - "A property on a directory that indicates if its targets are excluded " - "from the default build target. If it is not, then with a Makefile " - "for example typing make will cause the targets to be built. " - "The same concept applies to the default build of other generators.", - false); - - cm->DefineProperty - ("PARENT_DIRECTORY", cmProperty::DIRECTORY, - "Source directory that added current subdirectory.", - "This read-only property specifies the source directory that " - "added the current source directory as a subdirectory of the build. " - "In the top-level directory the value is the empty-string.", false); - - cm->DefineProperty - ("INCLUDE_REGULAR_EXPRESSION", cmProperty::DIRECTORY, - "Include file scanning regular expression.", - "This read-only property specifies the regular expression used " - "during dependency scanning to match include files that should " - "be followed. See the include_regular_expression command.", false); - - cm->DefineProperty - ("INTERPROCEDURAL_OPTIMIZATION", cmProperty::DIRECTORY, - "Enable interprocedural optimization for targets in a directory.", - "If set to true, enables interprocedural optimizations " - "if they are known to be supported by the compiler."); - - cm->DefineProperty - ("INTERPROCEDURAL_OPTIMIZATION_<CONFIG>", cmProperty::DIRECTORY, - "Per-configuration interprocedural optimization for a directory.", - "This is a per-configuration version of INTERPROCEDURAL_OPTIMIZATION. " - "If set, this property overrides the generic property " - "for the named configuration."); - - cm->DefineProperty - ("VARIABLES", cmProperty::DIRECTORY, - "List of variables defined in the current directory.", - "This read-only property specifies the list of CMake variables " - "currently defined. " - "It is intended for debugging purposes.", false); - - cm->DefineProperty - ("CACHE_VARIABLES", cmProperty::DIRECTORY, - "List of cache variables available in the current directory.", - "This read-only property specifies the list of CMake cache " - "variables currently defined. " - "It is intended for debugging purposes.", false); - - cm->DefineProperty - ("MACROS", cmProperty::DIRECTORY, - "List of macro commands available in the current directory.", - "This read-only property specifies the list of CMake macros " - "currently defined. " - "It is intended for debugging purposes. " - "See the macro command.", false); - - cm->DefineProperty - ("DEFINITIONS", cmProperty::DIRECTORY, - "For CMake 2.4 compatibility only. Use COMPILE_DEFINITIONS instead.", - "This read-only property specifies the list of flags given so far " - "to the add_definitions command. " - "It is intended for debugging purposes. " - "Use the COMPILE_DEFINITIONS instead.", false); - - cm->DefineProperty - ("INCLUDE_DIRECTORIES", cmProperty::DIRECTORY, - "List of preprocessor include file search directories.", - "This property specifies the list of directories given " - "so far to the include_directories command. " - "This property exists on directories and targets. " - "In addition to accepting values from the include_directories " - "command, values may be set directly on any directory or any " - "target using the set_property command. " - "A target gets its initial value for this property from the value " - "of the directory property. " - "A directory gets its initial value from its parent directory if " - "it has one. " - "Both directory and target property values are adjusted by calls " - "to the include_directories command." - "\n" - "The target property values are used by the generators to set " - "the include paths for the compiler. " - "See also the include_directories command."); - - cm->DefineProperty - ("COMPILE_OPTIONS", cmProperty::DIRECTORY, - "List of options to pass to the compiler.", - "This property specifies the list of directories given " - "so far for this property. " - "This property exists on directories and targets." - "\n" - "The target property values are used by the generators to set " - "the options for the compiler.\n" - "Contents of COMPILE_OPTIONS may use \"generator expressions\" with " - "the syntax \"$<...>\". " - CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS); - - cm->DefineProperty - ("LINK_DIRECTORIES", cmProperty::DIRECTORY, - "List of linker search directories.", - "This read-only property specifies the list of directories given " - "so far to the link_directories command. " - "It is intended for debugging purposes.", false); - - cm->DefineProperty ("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, - "Specify a launcher for compile rules.", - "See the global property of the same name for details. " - "This overrides the global property for a directory.", - true); + "", "", true); cm->DefineProperty ("RULE_LAUNCH_LINK", cmProperty::DIRECTORY, - "Specify a launcher for link rules.", - "See the global property of the same name for details. " - "This overrides the global property for a directory.", - true); + "", "", true); cm->DefineProperty ("RULE_LAUNCH_CUSTOM", cmProperty::DIRECTORY, - "Specify a launcher for custom rules.", - "See the global property of the same name for details. " - "This overrides the global property for a directory.", - true); - - cm->DefineProperty - ("VS_GLOBAL_SECTION_PRE_<section>", cmProperty::DIRECTORY, - "Specify a preSolution global section in Visual Studio.", - "Setting a property like this generates an entry of the following form " - "in the solution file:\n" - " GlobalSection(<section>) = preSolution\n" - " <contents based on property value>\n" - " EndGlobalSection\n" - "The property must be set to a semicolon-separated list of key=value " - "pairs. Each such pair will be transformed into an entry in the solution " - "global section. Whitespace around key and value is ignored. List " - "elements which do not contain an equal sign are skipped." - "\n" - "This property only works for Visual Studio 7 and above; it is ignored " - "on other generators. The property only applies when set on a directory " - "whose CMakeLists.txt contains a project() command."); - cm->DefineProperty - ("VS_GLOBAL_SECTION_POST_<section>", cmProperty::DIRECTORY, - "Specify a postSolution global section in Visual Studio.", - "Setting a property like this generates an entry of the following form " - "in the solution file:\n" - " GlobalSection(<section>) = postSolution\n" - " <contents based on property value>\n" - " EndGlobalSection\n" - "The property must be set to a semicolon-separated list of key=value " - "pairs. Each such pair will be transformed into an entry in the solution " - "global section. Whitespace around key and value is ignored. List " - "elements which do not contain an equal sign are skipped." - "\n" - "This property only works for Visual Studio 7 and above; it is ignored " - "on other generators. The property only applies when set on a directory " - "whose CMakeLists.txt contains a project() command." - "\n" - "Note that CMake generates postSolution sections ExtensibilityGlobals " - "and ExtensibilityAddIns by default. If you set the corresponding " - "property, it will override the default section. For example, setting " - "VS_GLOBAL_SECTION_POST_ExtensibilityGlobals will override the default " - "contents of the ExtensibilityGlobals section, while keeping " - "ExtensibilityAddIns on its default."); + "", "", true); } //---------------------------------------------------------------------------- @@ -4283,8 +4047,8 @@ cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type, // Create the target. cmsys::auto_ptr<cmTarget> target(new cmTarget); target->SetType(type, name); - target->SetMakefile(this); target->MarkAsImported(); + target->SetMakefile(this); // Add to the set of available imported targets. this->ImportedTargets[name] = target.get(); @@ -4332,8 +4096,11 @@ bool cmMakefile::IsAlias(const char *name) //---------------------------------------------------------------------------- cmGeneratorTarget* cmMakefile::FindGeneratorTargetToUse(const char* name) { - cmTarget *t = this->FindTargetToUse(name); - return this->LocalGenerator->GetGlobalGenerator()->GetGeneratorTarget(t); + if (cmTarget *t = this->FindTargetToUse(name)) + { + return this->LocalGenerator->GetGlobalGenerator()->GetGeneratorTarget(t); + } + return 0; } //---------------------------------------------------------------------------- @@ -4477,6 +4244,18 @@ bool cmMakefile::EnforceUniqueDir(const char* srcPath, const char* binPath) } //---------------------------------------------------------------------------- +void cmMakefile::AddQtUiFileWithOptions(cmSourceFile *sf) +{ + this->QtUiFilesWithOptions.push_back(sf); +} + +//---------------------------------------------------------------------------- +std::vector<cmSourceFile*> cmMakefile::GetQtUiFilesWithOptions() const +{ + return this->QtUiFilesWithOptions; +} + +//---------------------------------------------------------------------------- cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 8bce9fd..d9fc93c 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -146,13 +146,6 @@ public: { return this->LocalGenerator;} /** - * Test whether compatibility is set to a given version or lower. - */ - bool NeedBackwardsCompatibility(unsigned int major, - unsigned int minor, - unsigned int patch = 0xFFu); - - /** * Help enforce global target name uniqueness. */ bool EnforceUniqueName(std::string const& name, std::string& msg, @@ -540,7 +533,7 @@ public: this->GeneratorTargets = targets; } - cmTarget* FindTarget(const char* name, bool excludeAliases = false); + cmTarget* FindTarget(const char* name, bool excludeAliases = false) const; /** Find a target to use in place of the given name. The target returned may be imported or built within the project. */ @@ -884,6 +877,9 @@ public: bool IsGeneratingBuildSystem(){ return this->GeneratingBuildSystem; } void SetGeneratingBuildSystem(){ this->GeneratingBuildSystem = true; } + void AddQtUiFileWithOptions(cmSourceFile *sf); + std::vector<cmSourceFile*> GetQtUiFilesWithOptions() const; + std::set<cmStdString> const & GetSystemIncludeDirectories() const { return this->SystemIncludeDirectories; } @@ -906,7 +902,7 @@ protected: std::string ProjectName; // project name // libraries, classes, and executables - cmTargets Targets; + mutable cmTargets Targets; std::map<std::string, cmTarget*> AliasTargets; cmGeneratorTargetsType GeneratorTargets; std::vector<cmSourceFile*> SourceFiles; @@ -961,7 +957,6 @@ private: bool EnforceUniqueDir(const char* srcPath, const char* binPath); - void ReadSources(std::ifstream& fin, bool t); friend class cmMakeDepend; // make depend needs direct access // to the Sources array void PrintStringVector(const char* s, const @@ -1041,7 +1036,6 @@ private: void EnforceDirectoryLevelRules(); bool GeneratingBuildSystem; - /** * Old version of GetSourceFileWithOutput(const char*) kept for * backward-compatibility. It implements a linear search and support @@ -1062,6 +1056,8 @@ private: cmSourceFile* source); void UpdateOutputToSourceMap(std::string const& output, cmSourceFile* source); + + std::vector<cmSourceFile*> QtUiFilesWithOptions; }; //---------------------------------------------------------------------------- diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index e4219a9..69b8092 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -21,15 +21,15 @@ //---------------------------------------------------------------------------- cmMakefileExecutableTargetGenerator -::cmMakefileExecutableTargetGenerator(cmTarget* target): - cmMakefileTargetGenerator(target) +::cmMakefileExecutableTargetGenerator(cmGeneratorTarget* target): + cmMakefileTargetGenerator(target->Target) { this->CustomCommandDriver = OnDepends; this->Target->GetExecutableNames( this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, this->ConfigName); - this->OSXBundleGenerator = new cmOSXBundleGenerator(this->Target, + this->OSXBundleGenerator = new cmOSXBundleGenerator(target, this->ConfigName); this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders); } @@ -338,13 +338,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) vars.CMTarget = this->Target; vars.Language = linkLanguage; vars.Objects = buildObjs.c_str(); - std::string objdir = cmake::GetCMakeFilesDirectoryPostSlash(); - objdir += this->Target->GetName(); - objdir += ".dir"; - objdir = this->Convert(objdir.c_str(), - cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::SHELL); - vars.ObjectDir = objdir.c_str(); + std::string objectDir = this->Target->GetSupportDirectory(); + objectDir = this->Convert(objectDir.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL); + vars.ObjectDir = objectDir.c_str(); vars.Target = targetOutPathReal.c_str(); vars.TargetPDB = targetOutPathPDB.c_str(); diff --git a/Source/cmMakefileExecutableTargetGenerator.h b/Source/cmMakefileExecutableTargetGenerator.h index 3b18166..940226b 100644 --- a/Source/cmMakefileExecutableTargetGenerator.h +++ b/Source/cmMakefileExecutableTargetGenerator.h @@ -17,7 +17,7 @@ class cmMakefileExecutableTargetGenerator: public cmMakefileTargetGenerator { public: - cmMakefileExecutableTargetGenerator(cmTarget* target); + cmMakefileExecutableTargetGenerator(cmGeneratorTarget* target); virtual ~cmMakefileExecutableTargetGenerator(); /* the main entry point for this class. Writes the Makefiles associated diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index ea9663f..d6a0cd4 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -21,15 +21,18 @@ //---------------------------------------------------------------------------- cmMakefileLibraryTargetGenerator -::cmMakefileLibraryTargetGenerator(cmTarget* target): - cmMakefileTargetGenerator(target) +::cmMakefileLibraryTargetGenerator(cmGeneratorTarget* target): + cmMakefileTargetGenerator(target->Target) { this->CustomCommandDriver = OnDepends; - this->Target->GetLibraryNames( - this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, - this->TargetNameImport, this->TargetNamePDB, this->ConfigName); + if (this->Target->GetType() != cmTarget::INTERFACE_LIBRARY) + { + this->Target->GetLibraryNames( + this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, + this->TargetNameImport, this->TargetNamePDB, this->ConfigName); + } - this->OSXBundleGenerator = new cmOSXBundleGenerator(this->Target, + this->OSXBundleGenerator = new cmOSXBundleGenerator(target, this->ConfigName); this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders); } @@ -577,13 +580,11 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules vars.CMTarget = this->Target; vars.Language = linkLanguage; vars.Objects = buildObjs.c_str(); - std::string objdir = cmake::GetCMakeFilesDirectoryPostSlash(); - objdir += this->Target->GetName(); - objdir += ".dir"; - objdir = this->Convert(objdir.c_str(), - cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::SHELL); - vars.ObjectDir = objdir.c_str(); + std::string objectDir = this->Target->GetSupportDirectory(); + objectDir = this->Convert(objectDir.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL); + vars.ObjectDir = objectDir.c_str(); vars.Target = targetOutPathReal.c_str(); vars.LinkLibraries = linkLibs.c_str(); vars.ObjectsQuoted = buildObjs.c_str(); diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h index 07f828b..1487b56 100644 --- a/Source/cmMakefileLibraryTargetGenerator.h +++ b/Source/cmMakefileLibraryTargetGenerator.h @@ -18,7 +18,7 @@ class cmMakefileLibraryTargetGenerator: public cmMakefileTargetGenerator { public: - cmMakefileLibraryTargetGenerator(cmTarget* target); + cmMakefileLibraryTargetGenerator(cmGeneratorTarget* target); virtual ~cmMakefileLibraryTargetGenerator(); /* the main entry point for this class. Writes the Makefiles associated diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 0829cab..7f90078 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -21,11 +21,13 @@ #include "cmTarget.h" #include "cmake.h" #include "cmComputeLinkInformation.h" +#include "cmGeneratorExpression.h" #include "cmMakefileExecutableTargetGenerator.h" #include "cmMakefileLibraryTargetGenerator.h" #include "cmMakefileUtilityTargetGenerator.h" +#include <ctype.h> cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmTarget* target) : OSXBundleGenerator(0) @@ -61,7 +63,7 @@ cmMakefileTargetGenerator::~cmMakefileTargetGenerator() } cmMakefileTargetGenerator * -cmMakefileTargetGenerator::New(cmTarget *tgt) +cmMakefileTargetGenerator::New(cmGeneratorTarget *tgt) { cmMakefileTargetGenerator *result = 0; @@ -131,7 +133,14 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() this->Makefile->GetProperty ("ADDITIONAL_MAKE_CLEAN_FILES")) { - cmSystemTools::ExpandListArgument(additional_clean_files, + const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); + cmListFileBacktrace lfbt; + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = + ge.Parse(additional_clean_files); + + cmSystemTools::ExpandListArgument(cge->Evaluate(this->Makefile, config, + false, this->Target, 0, 0), this->CleanFiles); } @@ -142,9 +151,11 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() // First generate the object rule files. Save a list of all object // files for this target. + std::vector<cmSourceFile*> customCommands; + this->GeneratorTarget->GetCustomCommands(customCommands); for(std::vector<cmSourceFile*>::const_iterator - si = this->GeneratorTarget->CustomCommands.begin(); - si != this->GeneratorTarget->CustomCommands.end(); ++si) + si = customCommands.begin(); + si != customCommands.end(); ++si) { cmCustomCommand const* cc = (*si)->GetCustomCommand(); this->GenerateCustomRuleFile(*cc); @@ -161,21 +172,28 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() } } } + std::vector<cmSourceFile*> headerSources; + this->GeneratorTarget->GetHeaderSources(headerSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( - this->GeneratorTarget->HeaderSources, + headerSources, this->MacOSXContentGenerator); + std::vector<cmSourceFile*> extraSources; + this->GeneratorTarget->GetExtraSources(extraSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( - this->GeneratorTarget->ExtraSources, + extraSources, this->MacOSXContentGenerator); + std::vector<cmSourceFile*> externalObjects; + this->GeneratorTarget->GetExternalObjects(externalObjects); for(std::vector<cmSourceFile*>::const_iterator - si = this->GeneratorTarget->ExternalObjects.begin(); - si != this->GeneratorTarget->ExternalObjects.end(); ++si) + si = externalObjects.begin(); + si != externalObjects.end(); ++si) { this->ExternalObjects.push_back((*si)->GetFullPath()); } + std::vector<cmSourceFile*> objectSources; + this->GeneratorTarget->GetObjectSources(objectSources); for(std::vector<cmSourceFile*>::const_iterator - si = this->GeneratorTarget->ObjectSources.begin(); - si != this->GeneratorTarget->ObjectSources.end(); ++si) + si = objectSources.begin(); si != objectSources.end(); ++si) { // Generate this object file's rule file. this->WriteObjectRuleFiles(**si); @@ -283,7 +301,7 @@ std::string cmMakefileTargetGenerator::GetFlags(const std::string &l) // Add include directory flags. this->LocalGenerator-> - AppendFlags(flags,this->GetFrameworkFlags().c_str()); + AppendFlags(flags,this->GetFrameworkFlags(l).c_str()); // Add target-specific flags. this->LocalGenerator->AddCompileOptions(flags, this->Target, @@ -412,7 +430,8 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source) } // Get the full path name of the object file. - std::string const& objectName = this->GeneratorTarget->Objects[&source]; + std::string const& objectName = this->GeneratorTarget + ->GetObjectName(&source); std::string obj = this->LocalGenerator->GetTargetDirectory(*this->Target); obj += "/"; obj += objectName; @@ -638,7 +657,7 @@ cmMakefileTargetGenerator cmLocalGenerator::NONE, cmLocalGenerator::SHELL).c_str(); vars.Object = shellObj.c_str(); - std::string objectDir = cmSystemTools::GetFilenamePath(obj); + std::string objectDir = this->Target->GetSupportDirectory(); objectDir = this->Convert(objectDir.c_str(), cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); @@ -968,7 +987,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() *this->InfoFileStream << "\n" << "# Pairs of files generated by the same build rule.\n" - << "SET(CMAKE_MULTIPLE_OUTPUT_PAIRS\n"; + << "set(CMAKE_MULTIPLE_OUTPUT_PAIRS\n"; for(MultipleOutputPairsType::const_iterator pi = this->MultipleOutputPairs.begin(); pi != this->MultipleOutputPairs.end(); ++pi) @@ -986,7 +1005,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() *this->InfoFileStream << "\n" << "# Targets to which this target links.\n" - << "SET(CMAKE_TARGET_LINKED_INFO_FILES\n"; + << "set(CMAKE_TARGET_LINKED_INFO_FILES\n"; std::set<cmTarget const*> emitted; const char* cfg = this->LocalGenerator->ConfigurationName.c_str(); if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) @@ -996,7 +1015,12 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() i = items.begin(); i != items.end(); ++i) { cmTarget const* linkee = i->Target; - if(linkee && !linkee->IsImported() && emitted.insert(linkee).second) + if(linkee && !linkee->IsImported() + // We can ignore the INTERFACE_LIBRARY items because + // Target->GetLinkInformation already processed their + // link interface and they don't have any output themselves. + && linkee->GetType() != cmTarget::INTERFACE_LIBRARY + && emitted.insert(linkee).second) { cmMakefile* mf = linkee->GetMakefile(); cmLocalGenerator* lg = mf->GetLocalGenerator(); @@ -1018,7 +1042,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() *this->InfoFileStream << "\n" << "# Fortran module output directory.\n" - << "SET(CMAKE_Fortran_TARGET_MODULE_DIR \"" << mdir << "\")\n"; + << "set(CMAKE_Fortran_TARGET_MODULE_DIR \"" << mdir << "\")\n"; } // Target-specific include directories: @@ -1026,7 +1050,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() << "\n" << "# The include file search paths:\n"; *this->InfoFileStream - << "SET(CMAKE_C_TARGET_INCLUDE_PATH\n"; + << "set(CMAKE_C_TARGET_INCLUDE_PATH\n"; std::vector<std::string> includes; const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); @@ -1045,13 +1069,13 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() *this->InfoFileStream << " )\n"; *this->InfoFileStream - << "SET(CMAKE_CXX_TARGET_INCLUDE_PATH " + << "set(CMAKE_CXX_TARGET_INCLUDE_PATH " << "${CMAKE_C_TARGET_INCLUDE_PATH})\n"; *this->InfoFileStream - << "SET(CMAKE_Fortran_TARGET_INCLUDE_PATH " + << "set(CMAKE_Fortran_TARGET_INCLUDE_PATH " << "${CMAKE_C_TARGET_INCLUDE_PATH})\n"; *this->InfoFileStream - << "SET(CMAKE_ASM_TARGET_INCLUDE_PATH " + << "set(CMAKE_ASM_TARGET_INCLUDE_PATH " << "${CMAKE_C_TARGET_INCLUDE_PATH})\n"; // and now write the rule to use it @@ -1128,8 +1152,8 @@ cmMakefileTargetGenerator ::DriveCustomCommands(std::vector<std::string>& depends) { // Depend on all custom command outputs. - const std::vector<cmSourceFile*>& sources = - this->Target->GetSourceFiles(); + std::vector<cmSourceFile*> sources; + this->Target->GetSourceFiles(sources); for(std::vector<cmSourceFile*>::const_iterator source = sources.begin(); source != sources.end(); ++source) { @@ -1505,13 +1529,21 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule(const char* main_output, } //---------------------------------------------------------------------------- -std::string cmMakefileTargetGenerator::GetFrameworkFlags() +std::string cmMakefileTargetGenerator::GetFrameworkFlags(std::string const& l) { if(!this->Makefile->IsOn("APPLE")) { return std::string(); } + std::string fwSearchFlagVar = "CMAKE_" + l + "_FRAMEWORK_SEARCH_FLAG"; + const char* fwSearchFlag = + this->Makefile->GetDefinition(fwSearchFlagVar.c_str()); + if(!(fwSearchFlag && *fwSearchFlag)) + { + return std::string(); + } + std::set<cmStdString> emitted; #ifdef __APPLE__ /* don't insert this when crosscompiling e.g. to iphone */ emitted.insert("/System/Library/Frameworks"); @@ -1546,7 +1578,7 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags() { if(emitted.insert(*i).second) { - flags += "-F"; + flags += fwSearchFlag; flags += this->Convert(i->c_str(), cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL, true); @@ -1672,10 +1704,42 @@ void cmMakefileTargetGenerator::RemoveForbiddenFlags(const char* flagVar, this->Makefile->GetSafeDefinition(removeFlags.c_str()); std::vector<std::string> removeList; cmSystemTools::ExpandListArgument(removeflags, removeList); + for(std::vector<std::string>::iterator i = removeList.begin(); i != removeList.end(); ++i) { - cmSystemTools::ReplaceString(linkFlags, i->c_str(), ""); + std::string tmp; + std::string::size_type lastPosition = 0; + + for(;;) + { + std::string::size_type position = linkFlags.find(*i, lastPosition); + + if(position == std::string::npos) + { + tmp += linkFlags.substr(lastPosition); + break; + } + else + { + std::string::size_type prefixLength = position - lastPosition; + tmp += linkFlags.substr(lastPosition, prefixLength); + lastPosition = position + i->length(); + + bool validFlagStart = position == 0 || + isspace(linkFlags[position - 1]); + + bool validFlagEnd = lastPosition == linkFlags.size() || + isspace(linkFlags[lastPosition]); + + if(!validFlagStart || !validFlagEnd) + { + tmp += *i; + } + } + } + + linkFlags = tmp; } } diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index f7a1e2e..4f8fafa 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -38,7 +38,7 @@ public: virtual ~cmMakefileTargetGenerator(); // construct using this factory call - static cmMakefileTargetGenerator *New(cmTarget *tgt); + static cmMakefileTargetGenerator *New(cmGeneratorTarget *tgt); /* the main entry point for this class. Writes the Makefiles associated with this target */ @@ -124,7 +124,7 @@ protected: void DriveCustomCommands(std::vector<std::string>& depends); // Return the a string with -F flags on apple - std::string GetFrameworkFlags(); + std::string GetFrameworkFlags(std::string const& l); void AppendFortranFormatFlags(std::string& flags, cmSourceFile& source); diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx index 1fa4e95..7751ad9 100644 --- a/Source/cmMakefileUtilityTargetGenerator.cxx +++ b/Source/cmMakefileUtilityTargetGenerator.cxx @@ -20,11 +20,11 @@ //---------------------------------------------------------------------------- cmMakefileUtilityTargetGenerator -::cmMakefileUtilityTargetGenerator(cmTarget* target): - cmMakefileTargetGenerator(target) +::cmMakefileUtilityTargetGenerator(cmGeneratorTarget* target): + cmMakefileTargetGenerator(target->Target) { this->CustomCommandDriver = OnUtility; - this->OSXBundleGenerator = new cmOSXBundleGenerator(this->Target, + this->OSXBundleGenerator = new cmOSXBundleGenerator(target, this->ConfigName); this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders); } diff --git a/Source/cmMakefileUtilityTargetGenerator.h b/Source/cmMakefileUtilityTargetGenerator.h index fc47b38..8f99300 100644 --- a/Source/cmMakefileUtilityTargetGenerator.h +++ b/Source/cmMakefileUtilityTargetGenerator.h @@ -18,7 +18,7 @@ class cmMakefileUtilityTargetGenerator: public cmMakefileTargetGenerator { public: - cmMakefileUtilityTargetGenerator(cmTarget* target); + cmMakefileUtilityTargetGenerator(cmGeneratorTarget* target); virtual ~cmMakefileUtilityTargetGenerator(); /* the main entry point for this class. Writes the Makefiles associated diff --git a/Source/cmMarkAsAdvancedCommand.h b/Source/cmMarkAsAdvancedCommand.h index 246eb8a..b65e4a8 100644 --- a/Source/cmMarkAsAdvancedCommand.h +++ b/Source/cmMarkAsAdvancedCommand.h @@ -43,33 +43,6 @@ public: virtual const char* GetName() const {return "mark_as_advanced";} /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Mark cmake cached variables as advanced."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " mark_as_advanced([CLEAR|FORCE] VAR VAR2 VAR...)\n" - "Mark the named cached variables as advanced. An advanced variable " - "will not be displayed in any of the cmake GUIs unless the show " - "advanced option is on. " - "If CLEAR is the first argument advanced variables are changed back " - "to unadvanced. " - "If FORCE is the first argument, then the variable is made advanced. " - "If neither FORCE nor CLEAR is specified, new values will be marked as " - "advanced, but if the variable already has an advanced/non-advanced " - "state, it will not be changed.\n" - "It does nothing in script mode."; - } - - /** * This determines if the command is invoked when in script mode. * mark_as_advanced() will have no effect in script mode, but this will * make many of the modules usable in cmake/ctest scripts, (among them diff --git a/Source/cmMathCommand.h b/Source/cmMathCommand.h index dc0ceb3..c826ef1 100644 --- a/Source/cmMathCommand.h +++ b/Source/cmMathCommand.h @@ -43,28 +43,6 @@ public: */ virtual const char* GetName() const { return "math";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Mathematical expressions."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " math(EXPR <output variable> <math expression>)\n" - "EXPR evaluates mathematical expression and returns result in the " - "output variable. Example mathematical expression is " - "'5 * ( 10 + 13 )'. Supported operators are " - "+ - * / % | & ^ ~ << >> * / %. They have the same meaning " - " as they do in C code."; - } - cmTypeMacro(cmMathCommand, cmCommand); protected: diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx index e1dbf34..d85e720 100644 --- a/Source/cmMessageCommand.cxx +++ b/Source/cmMessageCommand.cxx @@ -52,6 +52,23 @@ bool cmMessageCommand status = true; ++i; } + else if (*i == "DEPRECATION") + { + if (this->Makefile->IsOn("CMAKE_ERROR_DEPRECATED")) + { + fatal = true; + type = cmake::DEPRECATION_ERROR; + } + else if (this->Makefile->IsOn("CMAKE_WARN_DEPRECATED")) + { + type = cmake::DEPRECATION_WARNING; + } + else + { + return true; + } + ++i; + } for(;i != args.end(); ++i) { diff --git a/Source/cmMessageCommand.h b/Source/cmMessageCommand.h index fc61810..fec9a32 100644 --- a/Source/cmMessageCommand.h +++ b/Source/cmMessageCommand.h @@ -46,45 +46,6 @@ public: */ virtual bool IsScriptable() const { return true; } - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Display a message to the user."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " message([STATUS|WARNING|AUTHOR_WARNING|FATAL_ERROR|SEND_ERROR]\n" - " \"message to display\" ...)\n" - "The optional keyword determines the type of message:\n" - " (none) = Important information\n" - " STATUS = Incidental information\n" - " WARNING = CMake Warning, continue processing\n" - " AUTHOR_WARNING = CMake Warning (dev), continue processing\n" - " SEND_ERROR = CMake Error, continue processing,\n" - " but skip generation\n" - " FATAL_ERROR = CMake Error, stop processing and generation\n" - "The CMake command-line tool displays STATUS messages on stdout " - "and all other message types on stderr. " - "The CMake GUI displays all messages in its log area. " - "The interactive dialogs (ccmake and CMakeSetup) show STATUS messages " - "one at a time on a status line and other messages in interactive " - "pop-up boxes." - "\n" - "CMake Warning and Error message text displays using a simple " - "markup language. " - "Non-indented text is formatted in line-wrapped paragraphs delimited " - "by newlines. " - "Indented text is considered pre-formatted." - ; - } - cmTypeMacro(cmMessageCommand, cmCommand); }; diff --git a/Source/cmNewLineStyle.cxx b/Source/cmNewLineStyle.cxx index 6f7b6a9..a7d7429 100644 --- a/Source/cmNewLineStyle.cxx +++ b/Source/cmNewLineStyle.cxx @@ -78,7 +78,7 @@ const std::string cmNewLineStyle::GetCharacters() const return "\r\n"; default: ; - }; + } return ""; } diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 57adeba..73ba815 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -17,6 +17,7 @@ #include "cmGeneratedFileStream.h" #include "cmMakefile.h" #include "cmOSXBundleGenerator.h" +#include "cmGeneratorTarget.h" #include <assert.h> #include <algorithm> @@ -27,8 +28,8 @@ cmNinjaNormalTargetGenerator:: -cmNinjaNormalTargetGenerator(cmTarget* target) - : cmNinjaTargetGenerator(target) +cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) + : cmNinjaTargetGenerator(target->Target) , TargetNameOut() , TargetNameSO() , TargetNameReal() @@ -36,15 +37,16 @@ cmNinjaNormalTargetGenerator(cmTarget* target) , TargetNamePDB() , TargetLinkLanguage(0) { - this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName()); + this->TargetLinkLanguage = target->Target + ->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmTarget::EXECUTABLE) - target->GetExecutableNames(this->TargetNameOut, + target->Target->GetExecutableNames(this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, GetLocalGenerator()->GetConfigName()); else - target->GetLibraryNames(this->TargetNameOut, + target->Target->GetLibraryNames(this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, this->TargetNameImport, @@ -55,7 +57,7 @@ cmNinjaNormalTargetGenerator(cmTarget* target) { // on Windows the output dir is already needed at compile time // ensure the directory exists (OutDir test) - EnsureDirectoryExists(target->GetDirectory(this->GetConfigName())); + EnsureDirectoryExists(target->Target->GetDirectory(this->GetConfigName())); } this->OSXBundleGenerator = new cmOSXBundleGenerator(target, @@ -261,8 +263,11 @@ cmNinjaNormalTargetGenerator description.str(), comment.str(), /*depfile*/ "", + /*deptype*/ "", rspfile, - rspcontent); + rspcontent, + /*restat*/ false, + /*generator*/ false); } if (this->TargetNameOut != this->TargetNameReal && @@ -277,14 +282,28 @@ cmNinjaNormalTargetGenerator " -E cmake_symlink_executable" " $in $out && $POST_BUILD", "Creating executable symlink $out", - "Rule for creating executable symlink."); + "Rule for creating " + "executable symlink.", + /*depfile*/ "", + /*deptype*/ "", + /*rspfile*/ "", + /*rspcontent*/ "", + /*restat*/ false, + /*generator*/ false); else this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_LIBRARY", cmakeCommand + " -E cmake_symlink_library" " $in $SONAME $out && $POST_BUILD", "Creating library symlink $out", - "Rule for creating library symlink."); + "Rule for creating " + "library symlink.", + /*depfile*/ "", + /*deptype*/ "", + /*rspfile*/ "", + /*rspcontent*/ "", + /*restat*/ false, + /*generator*/ false); } } @@ -445,6 +464,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() linkPath, this->GetGeneratorTarget()); + this->addPoolNinjaVariable("JOB_POOL_LINK", this->GetTarget(), vars); + this->AddModuleDefinitionFlag(vars["LINK_FLAGS"]); vars["LINK_FLAGS"] = cmGlobalNinjaGenerator ::EncodeLiteral(vars["LINK_FLAGS"]); @@ -517,7 +538,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() std::replace(linkLibraries.begin(), linkLibraries.end(), '\\', '/'); } - std::vector<cmCustomCommand> *cmdLists[3] = { + const std::vector<cmCustomCommand> *cmdLists[3] = { &this->GetTarget()->GetPreBuildCommands(), &this->GetTarget()->GetPreLinkCommands(), &this->GetTarget()->GetPostBuildCommands() diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h index 284804b..c7a089c 100644 --- a/Source/cmNinjaNormalTargetGenerator.h +++ b/Source/cmNinjaNormalTargetGenerator.h @@ -21,11 +21,12 @@ class cmSourceFile; class cmOSXBundleGenerator; +class cmGeneratorTarget; class cmNinjaNormalTargetGenerator : public cmNinjaTargetGenerator { public: - cmNinjaNormalTargetGenerator(cmTarget* target); + cmNinjaNormalTargetGenerator(cmGeneratorTarget* target); ~cmNinjaNormalTargetGenerator(); void Generate(); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 898aa0e..82f8d1b 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -26,7 +26,7 @@ #include <algorithm> cmNinjaTargetGenerator * -cmNinjaTargetGenerator::New(cmTarget* target) +cmNinjaTargetGenerator::New(cmGeneratorTarget* target) { switch (target->GetType()) { @@ -44,7 +44,7 @@ cmNinjaTargetGenerator::New(cmTarget* target) // We only want to process global targets that live in the home // (i.e. top-level) directory. CMake creates copies of these targets // in every directory, which we don't need. - cmMakefile *mf = target->GetMakefile(); + cmMakefile *mf = target->Target->GetMakefile(); if (strcmp(mf->GetStartDirectory(), mf->GetHomeDirectory()) == 0) return new cmNinjaUtilityTargetGenerator(target); // else fallthrough @@ -187,6 +187,21 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, return flags; } + +bool cmNinjaTargetGenerator::needsDepFile(const std::string& lang) +{ + cmMakefile* mf = this->GetMakefile(); + + const bool usingMSVC = std::string("MSVC") == + (mf->GetDefinition("CMAKE_C_COMPILER_ID") ? + mf->GetSafeDefinition("CMAKE_C_COMPILER_ID") : + mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID")); + + return !usingMSVC || lang == "RC"; +} + + + // TODO: Refactor with // void cmMakefileTargetGenerator::WriteTargetLanguageFlags(). std::string @@ -261,7 +276,8 @@ cmNinjaTargetGenerator std::string path = this->LocalGenerator->GetHomeRelativeOutputPath(); if(!path.empty()) path += "/"; - std::string const& objectName = this->GeneratorTarget->Objects[source]; + std::string const& objectName = this->GeneratorTarget + ->GetObjectName(source); path += this->LocalGenerator->GetTargetDirectory(*this->Target); path += "/"; path += objectName; @@ -331,77 +347,79 @@ cmNinjaTargetGenerator void cmNinjaTargetGenerator -::WriteCompileRule(const std::string& language) +::WriteCompileRule(const std::string& lang) { cmLocalGenerator::RuleVariables vars; vars.RuleLauncher = "RULE_LAUNCH_COMPILE"; vars.CMTarget = this->GetTarget(); - std::string lang = language; vars.Language = lang.c_str(); vars.Source = "$in"; vars.Object = "$out"; - std::string flags = "$FLAGS"; vars.Defines = "$DEFINES"; vars.TargetPDB = "$TARGET_PDB"; vars.ObjectDir = "$OBJECT_DIR"; cmMakefile* mf = this->GetMakefile(); - bool useClDeps = false; - std::string clBinary; - std::string clDepsBinary; - std::string clShowPrefix; - if (lang == "C" || lang == "CXX" || lang == "RC") + const std::string cId = mf->GetDefinition("CMAKE_C_COMPILER_ID") + ? mf->GetSafeDefinition("CMAKE_C_COMPILER_ID") + : mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID"); + + const bool usingMSVC = (cId == "MSVC" || cId == "Intel"); + + // Tell ninja dependency format so all deps can be loaded into a database + std::string deptype; + std::string depfile; + std::string cldeps; + std::string flags = "$FLAGS"; + if (usingMSVC) { - clDepsBinary = mf->GetSafeDefinition("CMAKE_CMCLDEPS_EXECUTABLE"); - if (!clDepsBinary.empty() && !mf->GetIsSourceFileTryCompile()) + if (!mf->GetIsSourceFileTryCompile() && lang == "RC") { - clShowPrefix = mf->GetSafeDefinition("CMAKE_CL_SHOWINCLUDE_PREFIX"); - clBinary = mf->GetDefinition("CMAKE_C_COMPILER") ? - mf->GetSafeDefinition("CMAKE_C_COMPILER") : - mf->GetSafeDefinition("CMAKE_CXX_COMPILER"); - if (!clBinary.empty() && !clShowPrefix.empty()) - { - useClDeps = true; - const std::string quote = " \""; - clBinary = quote + clBinary + "\" "; - clDepsBinary = quote + clDepsBinary + "\" "; - clShowPrefix = quote + clShowPrefix + "\" "; - vars.DependencyFile = "$DEP_FILE"; - } + deptype = "gcc"; + depfile = "$DEP_FILE"; + const std::string cl = mf->GetDefinition("CMAKE_C_COMPILER") ? + mf->GetSafeDefinition("CMAKE_C_COMPILER") : + mf->GetSafeDefinition("CMAKE_CXX_COMPILER"); + cldeps = "\""; + cldeps += mf->GetSafeDefinition("CMAKE_CMCLDEPS_EXECUTABLE"); + cldeps += "\" " + lang + " $in \"$DEP_FILE\" $out \""; + cldeps += mf->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX"); + cldeps += "\" \"" + cl + "\" "; + } + else + { + deptype = "msvc"; + depfile = ""; + flags += " /showIncludes"; } } - - - std::string depfile; - std::string depfileFlagsName = "CMAKE_DEPFILE_FLAGS_" + language; - const char *depfileFlags = mf->GetDefinition(depfileFlagsName.c_str()); - if (depfileFlags || useClDeps) { - std::string depFlagsStr = depfileFlags ? depfileFlags : ""; + else + { + deptype = "gcc"; depfile = "$DEP_FILE"; - cmSystemTools::ReplaceString(depFlagsStr, "<DEPFILE>", "\"$DEP_FILE\""); - cmSystemTools::ReplaceString(depFlagsStr, "<OBJECT>", "$out"); - cmSystemTools::ReplaceString(depFlagsStr, "<CMAKE_C_COMPILER>", - mf->GetDefinition("CMAKE_C_COMPILER")); - flags += " " + depFlagsStr; - } - vars.Flags = flags.c_str(); + const std::string flagsName = "CMAKE_DEPFILE_FLAGS_" + lang; + std::string depfileFlags = mf->GetSafeDefinition(flagsName.c_str()); + if (!depfileFlags.empty()) + { + cmSystemTools::ReplaceString(depfileFlags, "<DEPFILE>", "$DEP_FILE"); + cmSystemTools::ReplaceString(depfileFlags, "<OBJECT>", "$out"); + cmSystemTools::ReplaceString(depfileFlags, "<CMAKE_C_COMPILER>", + mf->GetDefinition("CMAKE_C_COMPILER")); + flags += " " + depfileFlags; + } + } + vars.Flags = flags.c_str(); + vars.DependencyFile = depfile.c_str(); // Rule for compiling object file. - std::string compileCmdVar = "CMAKE_"; - compileCmdVar += language; - compileCmdVar += "_COMPILE_OBJECT"; - std::string compileCmd = mf->GetRequiredDefinition(compileCmdVar.c_str()); + const std::string cmdVar = std::string("CMAKE_") + lang + "_COMPILE_OBJECT"; + std::string compileCmd = mf->GetRequiredDefinition(cmdVar.c_str()); std::vector<std::string> compileCmds; cmSystemTools::ExpandListArgument(compileCmd, compileCmds); - if(useClDeps) - { - std::string cmdPrefix = clDepsBinary + lang + " $in \"$DEP_FILE\" $out " + - clShowPrefix + clBinary; - compileCmds.front().insert(0, cmdPrefix); - } + compileCmds.front().insert(0, cldeps); for (std::vector<std::string>::iterator i = compileCmds.begin(); i != compileCmds.end(); ++i) @@ -413,14 +431,19 @@ cmNinjaTargetGenerator // Write the rule for compiling file of the given language. cmOStringStream comment; - comment << "Rule for compiling " << language << " files."; + comment << "Rule for compiling " << lang << " files."; cmOStringStream description; - description << "Building " << language << " object $out"; - this->GetGlobalGenerator()->AddRule(this->LanguageCompilerRule(language), + description << "Building " << lang << " object $out"; + this->GetGlobalGenerator()->AddRule(this->LanguageCompilerRule(lang), cmdLine, description.str(), comment.str(), - depfile); + depfile, + deptype, + /*rspfile*/ "", + /*rspcontent*/ "", + /*restat*/ false, + /*generator*/ false); } void @@ -436,28 +459,37 @@ cmNinjaTargetGenerator << this->GetTargetName() << "\n\n"; + std::vector<cmSourceFile*> customCommands; + this->GeneratorTarget->GetCustomCommands(customCommands); for(std::vector<cmSourceFile*>::const_iterator - si = this->GeneratorTarget->CustomCommands.begin(); - si != this->GeneratorTarget->CustomCommands.end(); ++si) + si = customCommands.begin(); + si != customCommands.end(); ++si) { cmCustomCommand const* cc = (*si)->GetCustomCommand(); this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget()); } + std::vector<cmSourceFile*> headerSources; + this->GeneratorTarget->GetHeaderSources(headerSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( - this->GeneratorTarget->HeaderSources, + headerSources, this->MacOSXContentGenerator); + std::vector<cmSourceFile*> extraSources; + this->GeneratorTarget->GetExtraSources(extraSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( - this->GeneratorTarget->ExtraSources, + extraSources, this->MacOSXContentGenerator); + std::vector<cmSourceFile*> externalObjects; + this->GeneratorTarget->GetExternalObjects(externalObjects); for(std::vector<cmSourceFile*>::const_iterator - si = this->GeneratorTarget->ExternalObjects.begin(); - si != this->GeneratorTarget->ExternalObjects.end(); ++si) + si = externalObjects.begin(); + si != externalObjects.end(); ++si) { this->Objects.push_back(this->GetSourceFilePath(*si)); } + std::vector<cmSourceFile*> objectSources; + this->GeneratorTarget->GetObjectSources(objectSources); for(std::vector<cmSourceFile*>::const_iterator - si = this->GeneratorTarget->ObjectSources.begin(); - si != this->GeneratorTarget->ObjectSources.end(); ++si) + si = objectSources.begin(); si != objectSources.end(); ++si) { this->WriteObjectBuildStatement(*si); } @@ -517,9 +549,11 @@ cmNinjaTargetGenerator } // Add order-only dependencies on custom command outputs. + std::vector<cmSourceFile*> customCommands; + this->GeneratorTarget->GetCustomCommands(customCommands); for(std::vector<cmSourceFile*>::const_iterator - si = this->GeneratorTarget->CustomCommands.begin(); - si != this->GeneratorTarget->CustomCommands.end(); ++si) + si = customCommands.begin(); + si != customCommands.end(); ++si) { cmCustomCommand const* cc = (*si)->GetCustomCommand(); const std::vector<std::string>& ccoutputs = cc->GetOutputs(); @@ -540,14 +574,19 @@ cmNinjaTargetGenerator cmNinjaVars vars; vars["FLAGS"] = this->ComputeFlagsForObject(source, language); vars["DEFINES"] = this->ComputeDefines(source, language); - vars["DEP_FILE"] = objectFileName + ".d";; + if (needsDepFile(language)) { + vars["DEP_FILE"] = + cmGlobalNinjaGenerator::EncodeDepfileSpace(objectFileName + ".d"); + } EnsureParentDirectoryExists(objectFileName); - std::string objectDir = cmSystemTools::GetFilenamePath(objectFileName); + std::string objectDir = this->Target->GetSupportDirectory(); vars["OBJECT_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat( ConvertToNinjaPath(objectDir.c_str()).c_str(), cmLocalGenerator::SHELL); + this->addPoolNinjaVariable("JOB_POOL_COMPILE", this->GetTarget(), vars); + this->SetMsvcTargetPdbVariable(vars); if(this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS")) @@ -701,3 +740,14 @@ cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()( // Add as a dependency of all target so that it gets called. this->Generator->GetGlobalGenerator()->AddDependencyToAll(output); } + +void cmNinjaTargetGenerator::addPoolNinjaVariable(const char* pool_property, + cmTarget* target, + cmNinjaVars& vars) +{ + const char* pool = target->GetProperty(pool_property); + if (pool) + { + vars["pool"] = pool; + } +} diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index cf06bfd..2ce1ed7 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -30,7 +30,7 @@ class cmNinjaTargetGenerator { public: /// Create a cmNinjaTargetGenerator according to the @a target's type. - static cmNinjaTargetGenerator* New(cmTarget* target); + static cmNinjaTargetGenerator* New(cmGeneratorTarget* target); /// Build a NinjaTargetGenerator. cmNinjaTargetGenerator(cmTarget* target); @@ -42,6 +42,8 @@ public: std::string GetTargetName() const; + bool needsDepFile(const std::string& lang); + protected: bool SetMsvcTargetPdbVariable(cmNinjaVars&) const; @@ -134,12 +136,15 @@ protected: }; friend struct MacOSXContentGeneratorType; -protected: + MacOSXContentGeneratorType* MacOSXContentGenerator; // Properly initialized by sub-classes. cmOSXBundleGenerator* OSXBundleGenerator; std::set<cmStdString> MacContentFolders; + void addPoolNinjaVariable(const char* pool_property, + cmTarget* target, + cmNinjaVars& vars); private: cmTarget* Target; diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index 755ce6e..1a7b445 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -18,8 +18,9 @@ #include "cmSourceFile.h" #include "cmTarget.h" -cmNinjaUtilityTargetGenerator::cmNinjaUtilityTargetGenerator(cmTarget *target) - : cmNinjaTargetGenerator(target) {} +cmNinjaUtilityTargetGenerator::cmNinjaUtilityTargetGenerator( + cmGeneratorTarget *target) + : cmNinjaTargetGenerator(target->Target) {} cmNinjaUtilityTargetGenerator::~cmNinjaUtilityTargetGenerator() {} @@ -41,8 +42,8 @@ void cmNinjaUtilityTargetGenerator::Generate() } } - const std::vector<cmSourceFile*>& sources = - this->GetTarget()->GetSourceFiles(); + std::vector<cmSourceFile*> sources; + this->GetTarget()->GetSourceFiles(sources); for(std::vector<cmSourceFile*>::const_iterator source = sources.begin(); source != sources.end(); ++source) { diff --git a/Source/cmNinjaUtilityTargetGenerator.h b/Source/cmNinjaUtilityTargetGenerator.h index 8b82ce4..add0291 100644 --- a/Source/cmNinjaUtilityTargetGenerator.h +++ b/Source/cmNinjaUtilityTargetGenerator.h @@ -21,7 +21,7 @@ class cmSourceFile; class cmNinjaUtilityTargetGenerator : public cmNinjaTargetGenerator { public: - cmNinjaUtilityTargetGenerator(cmTarget* target); + cmNinjaUtilityTargetGenerator(cmGeneratorTarget* target); ~cmNinjaUtilityTargetGenerator(); void Generate(); diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index a475c7c..9a340dc 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -18,10 +18,10 @@ //---------------------------------------------------------------------------- cmOSXBundleGenerator:: -cmOSXBundleGenerator(cmTarget* target, +cmOSXBundleGenerator(cmGeneratorTarget* target, const char* configName) - : Target(target) - , Makefile(target->GetMakefile()) + : Target(target->Target) + , Makefile(target->Target->GetMakefile()) , LocalGenerator(Makefile->GetLocalGenerator()) , ConfigName(configName) , MacContentFolders(0) diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h index ec82b9a..29b7611 100644 --- a/Source/cmOSXBundleGenerator.h +++ b/Source/cmOSXBundleGenerator.h @@ -21,11 +21,12 @@ class cmTarget; class cmMakefile; class cmLocalGenerator; +class cmGeneratorTarget; class cmOSXBundleGenerator { public: - cmOSXBundleGenerator(cmTarget* target, + cmOSXBundleGenerator(cmGeneratorTarget* target, const char* configName); // create an app bundle at a given root, and return diff --git a/Source/cmOptionCommand.h b/Source/cmOptionCommand.h index 7d02400..89e3ac1 100644 --- a/Source/cmOptionCommand.h +++ b/Source/cmOptionCommand.h @@ -43,29 +43,6 @@ public: virtual const char* GetName() const {return "option";} /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Provides an option that the user can optionally select."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " option(<option_variable> \"help string describing option\"\n" - " [initial value])\n" - "Provide an option for the user to select as ON or OFF. If no " - "initial value is provided, OFF is used.\n" - "If you have options that depend on the values of other " - "options, see the module help for CMakeDependentOption." - ; - } - - /** * This determines if the command is invoked when in script mode. */ virtual bool IsScriptable() const { return true; } diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index 0220825..86beb97 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -273,7 +273,7 @@ bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir) //---------------------------------------------------------------------------- cmOrderDirectories::cmOrderDirectories(cmGlobalGenerator* gg, - cmTarget* target, + cmTarget const* target, const char* purpose) { this->GlobalGenerator = gg; diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h index 96a75de..76bf429 100644 --- a/Source/cmOrderDirectories.h +++ b/Source/cmOrderDirectories.h @@ -27,7 +27,7 @@ class cmTarget; class cmOrderDirectories { public: - cmOrderDirectories(cmGlobalGenerator* gg, cmTarget* target, + cmOrderDirectories(cmGlobalGenerator* gg, cmTarget const* target, const char* purpose); ~cmOrderDirectories(); void AddRuntimeLibrary(std::string const& fullPath, const char* soname = 0); @@ -41,7 +41,7 @@ public: std::vector<std::string> const& GetOrderedDirectories(); private: cmGlobalGenerator* GlobalGenerator; - cmTarget* Target; + cmTarget const* Target; std::string Purpose; bool Computed; diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index 01fc2cf..c0d9e99 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -11,6 +11,7 @@ ============================================================================*/ #include "cmOutputRequiredFilesCommand.h" #include "cmMakeDepend.h" +#include <cmsys/FStream.hxx> class cmLBDepend : public cmMakeDepend { @@ -22,7 +23,7 @@ class cmLBDepend : public cmMakeDepend void cmLBDepend::DependWalk(cmDependInformation* info) { - std::ifstream fin(info->FullPath.c_str()); + cmsys::ifstream fin(info->FullPath.c_str()); if(!fin) { cmSystemTools::Error("error can not open ", info->FullPath.c_str()); @@ -32,7 +33,7 @@ void cmLBDepend::DependWalk(cmDependInformation* info) std::string line; while(cmSystemTools::GetLineFromStream(fin, line)) { - if(!strncmp(line.c_str(), "#include", 8)) + if(cmHasLiteralPrefix(line.c_str(), "#include")) { // if it is an include line then create a string class std::string currentline = line; @@ -174,6 +175,9 @@ void cmLBDepend::DependWalk(cmDependInformation* info) bool cmOutputRequiredFilesCommand ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) { + if(this->Disallowed(cmPolicies::CMP0032, + "The output_required_files command should not be called; see CMP0032.")) + { return true; } if(args.size() != 2 ) { this->SetError("called with incorrect number of arguments"); @@ -193,7 +197,7 @@ bool cmOutputRequiredFilesCommand if (info) { // write them out - FILE *fout = fopen(this->OutputFile.c_str(),"w"); + FILE *fout = cmsys::SystemTools::Fopen(this->OutputFile.c_str(),"w"); if(!fout) { std::string err = "Can not open output file: "; diff --git a/Source/cmOutputRequiredFilesCommand.h b/Source/cmOutputRequiredFilesCommand.h index 1d7e394..dd5ed6c 100644 --- a/Source/cmOutputRequiredFilesCommand.h +++ b/Source/cmOutputRequiredFilesCommand.h @@ -15,69 +15,19 @@ #include "cmCommand.h" #include "cmMakeDepend.h" -/** \class cmOutputRequiredFilesCommand - * \brief Output a list of required files for a source file - * - */ class cmOutputRequiredFilesCommand : public cmCommand { public: - /** - * This is a virtual constructor for the command. - */ - virtual cmCommand* Clone() - { - return new cmOutputRequiredFilesCommand; - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ + cmTypeMacro(cmOutputRequiredFilesCommand, cmCommand); + virtual cmCommand* Clone() { return new cmOutputRequiredFilesCommand; } virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); - - /** - * The name of the command as specified in CMakeList.txt. - */ virtual const char* GetName() const { return "output_required_files";} + virtual bool IsDiscouraged() const { return true; } - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Deprecated. Approximate C preprocessor dependency scanning."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - "This command exists only because ancient CMake versions provided it. " - "CMake handles preprocessor dependency scanning automatically using a " - "more advanced scanner.\n" - " output_required_files(srcfile outputfile)\n" - "Outputs a list of all the source files that are required by the " - "specified srcfile. This list is written into outputfile. This is " - "similar to writing out the dependencies for srcfile except that it " - "jumps from .h files into .cxx, .c and .cpp files if possible."; - } - - /** This command is kept for compatibility with older CMake versions. */ - virtual bool IsDiscouraged() const - { - return true; - } - - - cmTypeMacro(cmOutputRequiredFilesCommand, cmCommand); void ListDependencies(cmDependInformation const *info, FILE *fout, std::set<cmDependInformation const*> *visited); - private: std::string File; std::string OutputFile; diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index a823f05..020a782 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -19,23 +19,21 @@ public: cmPolicy(cmPolicies::PolicyID iD, const char *idString, const char *shortDescription, - const char *longDescription, unsigned int majorVersionIntroduced, unsigned int minorVersionIntroduced, unsigned int patchVersionIntroduced, unsigned int tweakVersionIntroduced, cmPolicies::PolicyStatus status) { - if (!idString || !shortDescription || ! longDescription) - { + if (!idString || !shortDescription) + { cmSystemTools::Error("Attempt to define a policy without " "all parameters being specified!"); return; - } + } this->ID = iD; this->IDString = idString; this->ShortDescription = shortDescription; - this->LongDescription = longDescription; this->MajorVersionIntroduced = majorVersionIntroduced; this->MinorVersionIntroduced = minorVersionIntroduced; this->PatchVersionIntroduced = patchVersionIntroduced; @@ -61,36 +59,35 @@ public: unsigned int tweakV) { if (majorV < this->MajorVersionIntroduced) - { + { return true; - } + } if (majorV > this->MajorVersionIntroduced) - { + { return false; - } + } if (minorV < this->MinorVersionIntroduced) - { + { return true; - } + } if (minorV > this->MinorVersionIntroduced) - { + { return false; - } + } if (patchV < this->PatchVersionIntroduced) - { + { return true; - } + } if (patchV > this->PatchVersionIntroduced) - { + { return false; - } + } return (tweakV < this->TweakVersionIntroduced); } cmPolicies::PolicyID ID; std::string IDString; std::string ShortDescription; - std::string LongDescription; unsigned int MajorVersionIntroduced; unsigned int MinorVersionIntroduced; unsigned int PatchVersionIntroduced; @@ -104,503 +101,241 @@ cmPolicies::cmPolicies() this->DefinePolicy( CMP0000, "CMP0000", "A minimum required CMake version must be specified.", - "CMake requires that projects specify the version of CMake to which " - "they have been written. " - "This policy has been put in place so users trying to build the project " - "may be told when they need to update their CMake. " - "Specifying a version also helps the project build with CMake versions " - "newer than that specified. " - "Use the cmake_minimum_required command at the top of your main " - " CMakeLists.txt file:\n" - " cmake_minimum_required(VERSION <major>.<minor>)\n" - "where \"<major>.<minor>\" is the version of CMake you want to support " - "(such as \"2.6\"). " - "The command will ensure that at least the given version of CMake is " - "running and help newer versions be compatible with the project. " - "See documentation of cmake_minimum_required for details.\n" - "Note that the command invocation must appear in the CMakeLists.txt " - "file itself; a call in an included file is not sufficient. " - "However, the cmake_policy command may be called to set policy " - "CMP0000 to OLD or NEW behavior explicitly. " - "The OLD behavior is to silently ignore the missing invocation. " - "The NEW behavior is to issue an error instead of a warning. " - "An included file may set CMP0000 explicitly to affect how this " - "policy is enforced for the main CMakeLists.txt file.", 2,6,0,0, cmPolicies::WARN ); this->DefinePolicy( CMP0001, "CMP0001", "CMAKE_BACKWARDS_COMPATIBILITY should no longer be used.", - "The OLD behavior is to check CMAKE_BACKWARDS_COMPATIBILITY and present " - "it to the user. " - "The NEW behavior is to ignore CMAKE_BACKWARDS_COMPATIBILITY " - "completely.\n" - "In CMake 2.4 and below the variable CMAKE_BACKWARDS_COMPATIBILITY was " - "used to request compatibility with earlier versions of CMake. " - "In CMake 2.6 and above all compatibility issues are handled by policies " - "and the cmake_policy command. " - "However, CMake must still check CMAKE_BACKWARDS_COMPATIBILITY for " - "projects written for CMake 2.4 and below.", 2,6,0,0, cmPolicies::WARN ); this->DefinePolicy( CMP0002, "CMP0002", "Logical target names must be globally unique.", - "Targets names created with " - "add_executable, add_library, or add_custom_target " - "are logical build target names. " - "Logical target names must be globally unique because:\n" - " - Unique names may be referenced unambiguously both in CMake\n" - " code and on make tool command lines.\n" - " - Logical names are used by Xcode and VS IDE generators\n" - " to produce meaningful project names for the targets.\n" - "The logical name of executable and library targets does not " - "have to correspond to the physical file names built. " - "Consider using the OUTPUT_NAME target property to create two " - "targets with the same physical name while keeping logical " - "names distinct. " - "Custom targets must simply have globally unique names (unless one " - "uses the global property ALLOW_DUPLICATE_CUSTOM_TARGETS with a " - "Makefiles generator).", 2,6,0,0, cmPolicies::WARN ); this->DefinePolicy( CMP0003, "CMP0003", "Libraries linked via full path no longer produce linker search paths.", - "This policy affects how libraries whose full paths are NOT known " - "are found at link time, but was created due to a change in how CMake " - "deals with libraries whose full paths are known. " - "Consider the code\n" - " target_link_libraries(myexe /path/to/libA.so)\n" - "CMake 2.4 and below implemented linking to libraries whose full paths " - "are known by splitting them on the link line into separate components " - "consisting of the linker search path and the library name. " - "The example code might have produced something like\n" - " ... -L/path/to -lA ...\n" - "in order to link to library A. " - "An analysis was performed to order multiple link directories such that " - "the linker would find library A in the desired location, but there " - "are cases in which this does not work. " - "CMake versions 2.6 and above use the more reliable approach of passing " - "the full path to libraries directly to the linker in most cases. " - "The example code now produces something like\n" - " ... /path/to/libA.so ....\n" - "Unfortunately this change can break code like\n" - " target_link_libraries(myexe /path/to/libA.so B)\n" - "where \"B\" is meant to find \"/path/to/libB.so\". " - "This code is wrong because the user is asking the linker to find " - "library B but has not provided a linker search path (which may be " - "added with the link_directories command). " - "However, with the old linking implementation the code would work " - "accidentally because the linker search path added for library A " - "allowed library B to be found." - "\n" - "In order to support projects depending on linker search paths " - "added by linking to libraries with known full paths, the OLD " - "behavior for this policy will add the linker search paths even " - "though they are not needed for their own libraries. " - "When this policy is set to OLD, CMake will produce a link line such as\n" - " ... -L/path/to /path/to/libA.so -lB ...\n" - "which will allow library B to be found as it was previously. " - "When this policy is set to NEW, CMake will produce a link line such as\n" - " ... /path/to/libA.so -lB ...\n" - "which more accurately matches what the project specified." - "\n" - "The setting for this policy used when generating the link line is that " - "in effect when the target is created by an add_executable or " - "add_library command. For the example described above, the code\n" - " cmake_policy(SET CMP0003 OLD) # or cmake_policy(VERSION 2.4)\n" - " add_executable(myexe myexe.c)\n" - " target_link_libraries(myexe /path/to/libA.so B)\n" - "will work and suppress the warning for this policy. " - "It may also be updated to work with the corrected linking approach:\n" - " cmake_policy(SET CMP0003 NEW) # or cmake_policy(VERSION 2.6)\n" - " link_directories(/path/to) # needed to find library B\n" - " add_executable(myexe myexe.c)\n" - " target_link_libraries(myexe /path/to/libA.so B)\n" - "Even better, library B may be specified with a full path:\n" - " add_executable(myexe myexe.c)\n" - " target_link_libraries(myexe /path/to/libA.so /path/to/libB.so)\n" - "When all items on the link line have known paths CMake does not check " - "this policy so it has no effect.\n" - "Note that the warning for this policy will be issued for at most " - "one target. This avoids flooding users with messages for every " - "target when setting the policy once will probably fix all targets.", 2,6,0,0, cmPolicies::WARN); this->DefinePolicy( CMP0004, "CMP0004", "Libraries linked may not have leading or trailing whitespace.", - "CMake versions 2.4 and below silently removed leading and trailing " - "whitespace from libraries linked with code like\n" - " target_link_libraries(myexe \" A \")\n" - "This could lead to subtle errors in user projects.\n" - "The OLD behavior for this policy is to silently remove leading and " - "trailing whitespace. " - "The NEW behavior for this policy is to diagnose the existence of " - "such whitespace as an error. " - "The setting for this policy used when checking the library names is " - "that in effect when the target is created by an add_executable or " - "add_library command.", 2,6,0,0, cmPolicies::WARN); this->DefinePolicy( CMP0005, "CMP0005", "Preprocessor definition values are now escaped automatically.", - "This policy determines whether or not CMake should generate escaped " - "preprocessor definition values added via add_definitions. " - "CMake versions 2.4 and below assumed that only trivial values would " - "be given for macros in add_definitions calls. " - "It did not attempt to escape non-trivial values such as string " - "literals in generated build rules. " - "CMake versions 2.6 and above support escaping of most values, but " - "cannot assume the user has not added escapes already in an attempt to " - "work around limitations in earlier versions.\n" - "The OLD behavior for this policy is to place definition values given " - "to add_definitions directly in the generated build rules without " - "attempting to escape anything. " - "The NEW behavior for this policy is to generate correct escapes " - "for all native build tools automatically. " - "See documentation of the COMPILE_DEFINITIONS target property for " - "limitations of the escaping implementation.", 2,6,0,0, cmPolicies::WARN); this->DefinePolicy( CMP0006, "CMP0006", "Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION.", - "This policy determines whether the install(TARGETS) command must be " - "given a BUNDLE DESTINATION when asked to install a target with the " - "MACOSX_BUNDLE property set. " - "CMake 2.4 and below did not distinguish application bundles from " - "normal executables when installing targets. " - "CMake 2.6 provides a BUNDLE option to the install(TARGETS) command " - "that specifies rules specific to application bundles on the Mac. " - "Projects should use this option when installing a target with the " - "MACOSX_BUNDLE property set.\n" - "The OLD behavior for this policy is to fall back to the RUNTIME " - "DESTINATION if a BUNDLE DESTINATION is not given. " - "The NEW behavior for this policy is to produce an error if a bundle " - "target is installed without a BUNDLE DESTINATION.", 2,6,0,0, cmPolicies::WARN); this->DefinePolicy( CMP0007, "CMP0007", "list command no longer ignores empty elements.", - "This policy determines whether the list command will " - "ignore empty elements in the list. " - "CMake 2.4 and below list commands ignored all empty elements" - " in the list. For example, a;b;;c would have length 3 and not 4. " - "The OLD behavior for this policy is to ignore empty list elements. " - "The NEW behavior for this policy is to correctly count empty " - "elements in a list. ", 2,6,0,0, cmPolicies::WARN); this->DefinePolicy( CMP0008, "CMP0008", "Libraries linked by full-path must have a valid library file name.", - "In CMake 2.4 and below it is possible to write code like\n" - " target_link_libraries(myexe /full/path/to/somelib)\n" - "where \"somelib\" is supposed to be a valid library file name " - "such as \"libsomelib.a\" or \"somelib.lib\". " - "For Makefile generators this produces an error at build time " - "because the dependency on the full path cannot be found. " - "For VS IDE and Xcode generators this used to work by accident because " - "CMake would always split off the library directory and ask the " - "linker to search for the library by name (-lsomelib or somelib.lib). " - "Despite the failure with Makefiles, some projects have code like this " - "and build only with VS and/or Xcode. " - "This version of CMake prefers to pass the full path directly to the " - "native build tool, which will fail in this case because it does " - "not name a valid library file." - "\n" - "This policy determines what to do with full paths that do not appear " - "to name a valid library file. " - "The OLD behavior for this policy is to split the library name from the " - "path and ask the linker to search for it. " - "The NEW behavior for this policy is to trust the given path and " - "pass it directly to the native build tool unchanged.", 2,6,1,0, cmPolicies::WARN); this->DefinePolicy( CMP0009, "CMP0009", "FILE GLOB_RECURSE calls should not follow symlinks by default.", - "In CMake 2.6.1 and below, FILE GLOB_RECURSE calls would follow " - "through symlinks, sometimes coming up with unexpectedly large " - "result sets because of symlinks to top level directories that " - "contain hundreds of thousands of files." - "\n" - "This policy determines whether or not to follow symlinks " - "encountered during a FILE GLOB_RECURSE call. " - "The OLD behavior for this policy is to follow the symlinks. " - "The NEW behavior for this policy is not to follow the symlinks " - "by default, but only if FOLLOW_SYMLINKS is given as an additional " - "argument to the FILE command.", 2,6,2,0, cmPolicies::WARN); this->DefinePolicy( CMP0010, "CMP0010", "Bad variable reference syntax is an error.", - "In CMake 2.6.2 and below, incorrect variable reference syntax such as " - "a missing close-brace (\"${FOO\") was reported but did not stop " - "processing of CMake code. " - "This policy determines whether a bad variable reference is an error. " - "The OLD behavior for this policy is to warn about the error, leave " - "the string untouched, and continue. " - "The NEW behavior for this policy is to report an error.", 2,6,3,0, cmPolicies::WARN); this->DefinePolicy( CMP0011, "CMP0011", "Included scripts do automatic cmake_policy PUSH and POP.", - "In CMake 2.6.2 and below, CMake Policy settings in scripts loaded by " - "the include() and find_package() commands would affect the includer. " - "Explicit invocations of cmake_policy(PUSH) and cmake_policy(POP) were " - "required to isolate policy changes and protect the includer. " - "While some scripts intend to affect the policies of their includer, " - "most do not. " - "In CMake 2.6.3 and above, include() and find_package() by default PUSH " - "and POP an entry on the policy stack around an included script, " - "but provide a NO_POLICY_SCOPE option to disable it. " - "This policy determines whether or not to imply NO_POLICY_SCOPE for " - "compatibility. " - "The OLD behavior for this policy is to imply NO_POLICY_SCOPE for " - "include() and find_package() commands. " - "The NEW behavior for this policy is to allow the commands to do their " - "default cmake_policy PUSH and POP.", 2,6,3,0, cmPolicies::WARN); this->DefinePolicy( CMP0012, "CMP0012", "if() recognizes numbers and boolean constants.", - "In CMake versions 2.6.4 and lower the if() command implicitly " - "dereferenced arguments corresponding to variables, even those named " - "like numbers or boolean constants, except for 0 and 1. " - "Numbers and boolean constants such as true, false, yes, no, " - "on, off, y, n, notfound, ignore (all case insensitive) were recognized " - "in some cases but not all. " - "For example, the code \"if(TRUE)\" might have evaluated as false. " - "Numbers such as 2 were recognized only in " - "boolean expressions like \"if(NOT 2)\" (leading to false) " - "but not as a single-argument like \"if(2)\" (also leading to false). " - "Later versions of CMake prefer to treat numbers and boolean constants " - "literally, so they should not be used as variable names." - "\n" - "The OLD behavior for this policy is to implicitly dereference variables " - "named like numbers and boolean constants. " - "The NEW behavior for this policy is to recognize numbers and " - "boolean constants without dereferencing variables with such names.", 2,8,0,0, cmPolicies::WARN); this->DefinePolicy( CMP0013, "CMP0013", "Duplicate binary directories are not allowed.", - "CMake 2.6.3 and below silently permitted add_subdirectory() calls " - "to create the same binary directory multiple times. " - "During build system generation files would be written and then " - "overwritten in the build tree and could lead to strange behavior. " - "CMake 2.6.4 and above explicitly detect duplicate binary directories. " - "CMake 2.6.4 always considers this case an error. " - "In CMake 2.8.0 and above this policy determines whether or not " - "the case is an error. " - "The OLD behavior for this policy is to allow duplicate binary " - "directories. " - "The NEW behavior for this policy is to disallow duplicate binary " - "directories with an error.", 2,8,0,0, cmPolicies::WARN); this->DefinePolicy( CMP0014, "CMP0014", "Input directories must have CMakeLists.txt.", - "CMake versions before 2.8 silently ignored missing CMakeLists.txt " - "files in directories referenced by add_subdirectory() or subdirs(), " - "treating them as if present but empty. " - "In CMake 2.8.0 and above this policy determines whether or not " - "the case is an error. " - "The OLD behavior for this policy is to silently ignore the problem. " - "The NEW behavior for this policy is to report an error.", 2,8,0,0, cmPolicies::WARN); this->DefinePolicy( CMP0015, "CMP0015", "link_directories() treats paths relative to the source dir.", - "In CMake 2.8.0 and lower the link_directories() command passed relative " - "paths unchanged to the linker. " - "In CMake 2.8.1 and above the link_directories() command prefers to " - "interpret relative paths with respect to CMAKE_CURRENT_SOURCE_DIR, " - "which is consistent with include_directories() and other commands. " - "The OLD behavior for this policy is to use relative paths verbatim in " - "the linker command. " - "The NEW behavior for this policy is to convert relative paths to " - "absolute paths by appending the relative path to " - "CMAKE_CURRENT_SOURCE_DIR.", 2,8,1,0, cmPolicies::WARN); this->DefinePolicy( CMP0016, "CMP0016", "target_link_libraries() reports error if its only argument " "is not a target.", - "In CMake 2.8.2 and lower the target_link_libraries() command silently " - "ignored if it was called with only one argument, and this argument " - "wasn't a valid target. " - "In CMake 2.8.3 and above it reports an error in this case.", 2,8,3,0, cmPolicies::WARN); this->DefinePolicy( CMP0017, "CMP0017", "Prefer files from the CMake module directory when including from there.", - "Starting with CMake 2.8.4, if a cmake-module shipped with CMake (i.e. " - "located in the CMake module directory) calls include() or " - "find_package(), the files located in the CMake module directory are " - "preferred over the files in CMAKE_MODULE_PATH. " - "This makes sure that the modules belonging to " - "CMake always get those files included which they expect, and against " - "which they were developed and tested. " - "In all other cases, the files found in " - "CMAKE_MODULE_PATH still take precedence over the ones in " - "the CMake module directory. " - "The OLD behaviour is to always prefer files from CMAKE_MODULE_PATH over " - "files from the CMake modules directory.", 2,8,4,0, cmPolicies::WARN); this->DefinePolicy( CMP0018, "CMP0018", "Ignore CMAKE_SHARED_LIBRARY_<Lang>_FLAGS variable.", - "CMake 2.8.8 and lower compiled sources in SHARED and MODULE libraries " - "using the value of the undocumented CMAKE_SHARED_LIBRARY_<Lang>_FLAGS " - "platform variable. The variable contained platform-specific flags " - "needed to compile objects for shared libraries. Typically it included " - "a flag such as -fPIC for position independent code but also included " - "other flags needed on certain platforms. CMake 2.8.9 and higher " - "prefer instead to use the POSITION_INDEPENDENT_CODE target property to " - "determine what targets should be position independent, and new " - "undocumented platform variables to select flags while ignoring " - "CMAKE_SHARED_LIBRARY_<Lang>_FLAGS completely." - "\n" - "The default for either approach produces identical compilation flags, " - "but if a project modifies CMAKE_SHARED_LIBRARY_<Lang>_FLAGS from its " - "original value this policy determines which approach to use." - "\n" - "The OLD behavior for this policy is to ignore the " - "POSITION_INDEPENDENT_CODE property for all targets and use the modified " - "value of CMAKE_SHARED_LIBRARY_<Lang>_FLAGS for SHARED and MODULE " - "libraries." - "\n" - "The NEW behavior for this policy is to ignore " - "CMAKE_SHARED_LIBRARY_<Lang>_FLAGS whether it is modified or not and " - "honor the POSITION_INDEPENDENT_CODE target property.", 2,8,9,0, cmPolicies::WARN); this->DefinePolicy( CMP0019, "CMP0019", "Do not re-expand variables in include and link information.", - "CMake 2.8.10 and lower re-evaluated values given to the " - "include_directories, link_directories, and link_libraries " - "commands to expand any leftover variable references at the " - "end of the configuration step. " - "This was for strict compatibility with VERY early CMake versions " - "because all variable references are now normally evaluated during " - "CMake language processing. " - "CMake 2.8.11 and higher prefer to skip the extra evaluation." - "\n" - "The OLD behavior for this policy is to re-evaluate the values " - "for strict compatibility. " - "The NEW behavior for this policy is to leave the values untouched.", 2,8,11,0, cmPolicies::WARN); this->DefinePolicy( CMP0020, "CMP0020", "Automatically link Qt executables to qtmain target on Windows.", - "CMake 2.8.10 and lower required users of Qt to always specify a link " - "dependency to the qtmain.lib static library manually on Windows. CMake " - "2.8.11 gained the ability to evaluate generator expressions while " - "determining the link dependencies from IMPORTED targets. This allows " - "CMake itself to automatically link executables which link to Qt to the " - "qtmain.lib library when using IMPORTED Qt targets. For applications " - "already linking to qtmain.lib, this should have little impact. For " - "applications which supply their own alternative WinMain implementation " - "and for applications which use the QAxServer library, this automatic " - "linking will need to be disabled as per the documentation." - "\n" - "The OLD behavior for this policy is not to link executables to " - "qtmain.lib automatically when they link to the QtCore IMPORTED" - "target. " - "The NEW behavior for this policy is to link executables to " - "qtmain.lib automatically when they link to QtCore IMPORTED target.", 2,8,11,0, cmPolicies::WARN); this->DefinePolicy( CMP0021, "CMP0021", "Fatal error on relative paths in INCLUDE_DIRECTORIES target property.", - "CMake 2.8.10.2 and lower allowed the INCLUDE_DIRECTORIES target " - "property to contain relative paths. The base path for such relative " - "entries is not well defined. CMake 2.8.12 issues a FATAL_ERROR if the " - "INCLUDE_DIRECTORIES property contains a relative path." - "\n" - "The OLD behavior for this policy is not to warn about relative paths in " - "the INCLUDE_DIRECTORIES target property. " - "The NEW behavior for this policy is to issue a FATAL_ERROR if " - "INCLUDE_DIRECTORIES contains a relative path.", 2,8,12,0, cmPolicies::WARN); this->DefinePolicy( CMP0022, "CMP0022", "INTERFACE_LINK_LIBRARIES defines the link interface.", - "CMake 2.8.11 constructed the 'link interface' of a target from " - "properties matching (IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?. " - "The modern way to specify config-sensitive content is to use generator " - "expressions and the IMPORTED_ prefix makes uniform processing of the " - "link interface with generator expressions impossible. The " - "INTERFACE_LINK_LIBRARIES target property was introduced as a " - "replacement in CMake 2.8.12. This new property is named consistently " - "with the INTERFACE_COMPILE_DEFINITIONS, INTERFACE_INCLUDE_DIRECTORIES " - "and INTERFACE_COMPILE_OPTIONS properties. For in-build targets, CMake " - "will use the INTERFACE_LINK_LIBRARIES property as the source of the " - "link interface only if policy CMP0022 is NEW. " - "When exporting a target which has this policy set to NEW, only the " - "INTERFACE_LINK_LIBRARIES property will be processed and generated for " - "the IMPORTED target by default. A new option to the install(EXPORT) " - "and export commands allows export of the old-style properties for " - "compatibility with downstream users of CMake versions older than " - "2.8.12. " - "The target_link_libraries command will no longer populate the " - "properties matching LINK_INTERFACE_LIBRARIES(_<CONFIG>)? if this policy " - "is NEW." - "\n" - "The OLD behavior for this policy is to ignore the " - "INTERFACE_LINK_LIBRARIES property for in-build targets. " - "The NEW behavior for this policy is to use the INTERFACE_LINK_LIBRARIES " - "property for in-build targets, and ignore the old properties matching " - "(IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?.", 2,8,12,0, cmPolicies::WARN); this->DefinePolicy( CMP0023, "CMP0023", "Plain and keyword target_link_libraries signatures cannot be mixed.", - "CMake 2.8.12 introduced the target_link_libraries signature using " - "the PUBLIC, PRIVATE, and INTERFACE keywords to generalize the " - "LINK_PUBLIC and LINK_PRIVATE keywords introduced in CMake 2.8.7. " - "Use of signatures with any of these keywords sets the link interface " - "of a target explicitly, even if empty. " - "This produces confusing behavior when used in combination with the " - "historical behavior of the plain target_link_libraries signature. " - "For example, consider the code:\n" - " target_link_libraries(mylib A)\n" - " target_link_libraries(mylib PRIVATE B)\n" - "After the first line the link interface has not been set explicitly " - "so CMake would use the link implementation, A, as the link interface. " - "However, the second line sets the link interface to empty. " - "In order to avoid this subtle behavior CMake now prefers to disallow " - "mixing the plain and keyword signatures of target_link_libraries for " - "a single target." - "\n" - "The OLD behavior for this policy is to allow keyword and plain " - "target_link_libraries signatures to be mixed. " - "The NEW behavior for this policy is to not to allow mixing of the " - "keyword and plain signatures.", 2,8,12,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0024, "CMP0024", + "Disallow include export result.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0025, "CMP0025", + "Compiler id for Apple Clang is now AppleClang.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0026, "CMP0026", + "Disallow use of the LOCATION target property.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0027, "CMP0027", + "Conditionally linked imported targets with missing include directories.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0028, "CMP0028", + "Double colon in target name means ALIAS or IMPORTED target.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0029, "CMP0029", + "The subdir_depends command should not be called.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0030, "CMP0030", + "The use_mangled_mesa command should not be called.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0031, "CMP0031", + "The load_command command should not be called.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0032, "CMP0032", + "The output_required_files command should not be called.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0033, "CMP0033", + "The export_library_dependencies command should not be called.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0034, "CMP0034", + "The utility_source command should not be called.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0035, "CMP0035", + "The variable_requires command should not be called.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0036, "CMP0036", + "The build_name command should not be called.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0037, "CMP0037", + "Target names should not be reserved and should match a validity pattern.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0038, "CMP0038", + "Targets may not link directly to themselves.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0039, "CMP0039", + "Utility targets may not have link dependencies.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0040, "CMP0040", + "The target in the TARGET signature of add_custom_command() must exist.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0041, "CMP0041", + "Error on relative include with generator expression.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0042, "CMP0042", + "MACOSX_RPATH is enabled by default.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0043, "CMP0043", + "Ignore COMPILE_DEFINITIONS_<Config> properties.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0044, "CMP0044", + "Case sensitive <LANG>_COMPILER_ID generator expressions.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0045, "CMP0045", + "Error on non-existent target in get_target_property.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0046, "CMP0046", + "Error on non-existent dependency in add_dependencies.", + 3,0,0,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() @@ -609,15 +344,14 @@ cmPolicies::~cmPolicies() std::map<cmPolicies::PolicyID,cmPolicy *>::iterator i = this->Policies.begin(); for (;i != this->Policies.end(); ++i) - { + { delete i->second; - } + } } void cmPolicies::DefinePolicy(cmPolicies::PolicyID iD, const char *idString, const char *shortDescription, - const char *longDescription, unsigned int majorVersionIntroduced, unsigned int minorVersionIntroduced, unsigned int patchVersionIntroduced, @@ -626,15 +360,14 @@ void cmPolicies::DefinePolicy(cmPolicies::PolicyID iD, { // a policy must be unique and can only be defined once if (this->Policies.find(iD) != this->Policies.end()) - { + { cmSystemTools::Error("Attempt to redefine a CMake policy for policy " "ID ", this->GetPolicyIDString(iD).c_str()); return; - } + } this->Policies[iD] = new cmPolicy(iD, idString, shortDescription, - longDescription, majorVersionIntroduced, minorVersionIntroduced, patchVersionIntroduced, @@ -674,15 +407,9 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf, if (majorVer < 2 || (majorVer == 2 && minorVer < 4)) { mf->IssueMessage(cmake::FATAL_ERROR, - "An attempt was made to set the policy version of CMake to something " - "earlier than \"2.4\". " - "In CMake 2.4 and below backwards compatibility was handled with the " - "CMAKE_BACKWARDS_COMPATIBILITY variable. " - "In order to get compatibility features supporting versions earlier " - "than 2.4 set policy CMP0001 to OLD to tell CMake to check the " - "CMAKE_BACKWARDS_COMPATIBILITY variable. " - "One way to do this is to set the policy version to 2.4 exactly." - ); + "Compatibility with CMake < 2.4 is not supported by CMake >= 3.0. " + "For compatibility with older versions please use any CMake 2.8.x " + "release or lower."); return false; } @@ -784,15 +511,15 @@ bool cmPolicies::GetPolicyDefault(cmMakefile* mf, std::string const& policy, bool cmPolicies::GetPolicyID(const char *id, cmPolicies::PolicyID &pid) { if (!id || strlen(id) < 1) - { + { return false; - } + } std::map<std::string,cmPolicies::PolicyID>::iterator pos = this->PolicyStringMap.find(id); if (pos == this->PolicyStringMap.end()) - { + { return false; - } + } pid = pos->second; return true; } @@ -802,9 +529,9 @@ std::string cmPolicies::GetPolicyIDString(cmPolicies::PolicyID pid) std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos = this->Policies.find(pid); if (pos == this->Policies.end()) - { + { return ""; - } + } return pos->second->IDString; } @@ -815,11 +542,11 @@ std::string cmPolicies::GetPolicyWarning(cmPolicies::PolicyID id) std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos = this->Policies.find(id); if (pos == this->Policies.end()) - { + { cmSystemTools::Error( "Request for warning text for undefined policy!"); return "Request for warning text for undefined policy!"; - } + } cmOStringStream msg; msg << @@ -839,11 +566,11 @@ std::string cmPolicies::GetRequiredPolicyError(cmPolicies::PolicyID id) std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos = this->Policies.find(id); if (pos == this->Policies.end()) - { + { cmSystemTools::Error( "Request for error text for undefined policy!"); return "Request for error text for undefined policy!"; - } + } cmOStringStream error; error << @@ -869,60 +596,14 @@ cmPolicies::GetPolicyStatus(cmPolicies::PolicyID id) std::map<cmPolicies::PolicyID,cmPolicy *>::iterator pos = this->Policies.find(id); if (pos == this->Policies.end()) - { + { // TODO is this right? return cmPolicies::WARN; - } + } return pos->second->Status; } -void cmPolicies::GetDocumentation(std::vector<cmDocumentationEntry>& v) -{ - // now loop over all the policies and set them as appropriate - std::map<cmPolicies::PolicyID,cmPolicy *>::iterator i - = this->Policies.begin(); - for (;i != this->Policies.end(); ++i) - { - cmOStringStream full; - full << i->second->LongDescription; - full << "\nThis policy was introduced in CMake version "; - full << i->second->GetVersionString() << "."; - if(i->first != cmPolicies::CMP0000) - { - full << " " - << "CMake version " << cmVersion::GetCMakeVersion() << " "; - // add in some more text here based on status - switch (i->second->Status) - { - case cmPolicies::WARN: - full << "warns when the policy is not set and uses OLD behavior. " - << "Use the cmake_policy command to set it to OLD or NEW " - << "explicitly."; - break; - case cmPolicies::OLD: - full << "defaults to the OLD behavior for this policy."; - break; - case cmPolicies::NEW: - full << "defaults to the NEW behavior for this policy."; - break; - case cmPolicies::REQUIRED_IF_USED: - full << "requires the policy to be set to NEW if you use it. " - << "Use the cmake_policy command to set it to NEW."; - break; - case cmPolicies::REQUIRED_ALWAYS: - full << "requires the policy to be set to NEW. " - << "Use the cmake_policy command to set it to NEW."; - break; - } - } - cmDocumentationEntry e(i->second->IDString.c_str(), - i->second->ShortDescription.c_str(), - full.str().c_str()); - v.push_back(e); - } -} - //---------------------------------------------------------------------------- std::string cmPolicies::GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id) diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 5b843a9..38f47f1 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -74,6 +74,32 @@ public: /// target property CMP0022, ///< INTERFACE_LINK_LIBRARIES defines the link interface CMP0023, ///< Disallow mixing keyword and plain tll signatures + CMP0024, ///< Disallow including export() result. + CMP0025, ///< Compiler id for Apple Clang is now AppleClang + CMP0026, ///< Disallow use of the LOCATION target property. + CMP0027, ///< Conditionally linked imported targets with missing include + /// directories. + CMP0028, ///< Double colon in target name means ALIAS or IMPORTED target. + CMP0029, ///< Disallow command: subdir_depends + CMP0030, ///< Disallow command: use_mangled_mesa + CMP0031, ///< Disallow command: load_command + CMP0032, ///< Disallow command: output_required_files + CMP0033, ///< Disallow command: export_library_dependencies + CMP0034, ///< Disallow command: utility_source + CMP0035, ///< Disallow command: variable_requires + CMP0036, ///< Disallow command: build_name + CMP0037, ///< Target names should not be reserved and + /// should match a validity pattern. + CMP0038, ///< Targets may not link directly to themselves + CMP0039, ///< Utility targets may not have link dependencies + CMP0040, ///< The target in the TARGET signature of + /// add_custom_command() must exist. + CMP0041, ///< Error on relative include with generator expression + CMP0042, ///< Enable MACOSX_RPATH by default + CMP0043, ///< Ignore COMPILE_DEFINITIONS_<Config> properties + CMP0044, ///< Case sensitive <LANG>_COMPILER_ID generator expressions + CMP0045, ///< Error on non-existent target in get_target_property + CMP0046, ///< Error on non-existent dependency in add_dependencies /** \brief Always the last entry. * @@ -94,7 +120,6 @@ public: void DefinePolicy(cmPolicies::PolicyID id, const char *stringID, const char *shortDescription, - const char *longDescription, unsigned int majorVersionIntroduced, unsigned int minorVersionIntroduced, unsigned int patchVersionIntroduced, @@ -113,9 +138,6 @@ public: ///! return an error string for when a required policy is unspecified std::string GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id); - ///! Get docs for policies - void GetDocumentation(std::vector<cmDocumentationEntry>& v); - /** Represent a set of policy values. */ typedef std::map<PolicyID, PolicyStatus> PolicyMap; diff --git a/Source/cmProjectCommand.h b/Source/cmProjectCommand.h index 9547c4c..f7d086d 100644 --- a/Source/cmProjectCommand.h +++ b/Source/cmProjectCommand.h @@ -45,41 +45,6 @@ public: */ virtual const char* GetName() const {return "project";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Set a name for the entire project."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " project(<projectname> [languageName1 languageName2 ... ] )\n" - "Sets the name of the project. " - "Additionally this sets the variables <projectName>_BINARY_DIR and " - "<projectName>_SOURCE_DIR to the respective values.\n" - "Optionally you can specify which languages your project supports. " - "Example languages are CXX (i.e. C++), C, Fortran, etc. " - "By default C and CXX are enabled. E.g. if you do not have a " - "C++ compiler, you can disable the check for it by explicitly listing " - "the languages you want to support, e.g. C. By using the special " - "language \"NONE\" all checks for any language can be disabled. " - "If a variable exists called CMAKE_PROJECT_<projectName>_INCLUDE, " - "the file pointed to by that variable will be included as the last step " - "of the project command." - "\n" - "The top-level CMakeLists.txt file for a project must contain a " - "literal, direct call to the project() command; loading one through " - "the include() command is not sufficient. " - "If no such call exists CMake will implicitly add one to the top that " - "enables the default languages (C and CXX)."; - } - cmTypeMacro(cmProjectCommand, cmCommand); }; diff --git a/Source/cmPropertyDefinition.cxx b/Source/cmPropertyDefinition.cxx index b80c863..abc57ce 100644 --- a/Source/cmPropertyDefinition.cxx +++ b/Source/cmPropertyDefinition.cxx @@ -12,20 +12,10 @@ #include "cmPropertyDefinition.h" #include "cmSystemTools.h" -cmDocumentationEntry cmPropertyDefinition::GetDocumentation() const -{ - cmDocumentationEntry e; - e.Name = this->Name; - e.Brief = this->ShortDescription; - e.Full = this->FullDescription; - return e; -} - void cmPropertyDefinition ::DefineProperty(const char *name, cmProperty::ScopeType scope, const char *shortDescription, const char *fullDescription, - const char *sec, bool chain) { this->Name = name; @@ -39,9 +29,5 @@ void cmPropertyDefinition { this->FullDescription = fullDescription; } - if (sec) - { - this->DocumentationSection = sec; - } } diff --git a/Source/cmPropertyDefinition.h b/Source/cmPropertyDefinition.h index 296366d..1b6a7a6 100644 --- a/Source/cmPropertyDefinition.h +++ b/Source/cmPropertyDefinition.h @@ -30,22 +30,14 @@ public: void DefineProperty(const char *name, cmProperty::ScopeType scope, const char *ShortDescription, const char *FullDescription, - const char *DocumentationSection, bool chained); - /// Get the documentation string - cmDocumentationEntry GetDocumentation() const; - /// Default constructor cmPropertyDefinition() { this->Chained = false; }; /// Is the property chained? bool IsChained() const { return this->Chained; }; - /// Get the section if any - const std::string &GetDocumentationSection() const { - return this->DocumentationSection; }; - /// Get the scope cmProperty::ScopeType GetScope() const { return this->Scope; }; @@ -62,7 +54,6 @@ protected: std::string Name; std::string ShortDescription; std::string FullDescription; - std::string DocumentationSection; cmProperty::ScopeType Scope; bool Chained; }; diff --git a/Source/cmPropertyDefinitionMap.cxx b/Source/cmPropertyDefinitionMap.cxx index 20fa07c..db29504 100644 --- a/Source/cmPropertyDefinitionMap.cxx +++ b/Source/cmPropertyDefinitionMap.cxx @@ -17,7 +17,6 @@ void cmPropertyDefinitionMap ::DefineProperty(const char *name, cmProperty::ScopeType scope, const char *ShortDescription, const char *FullDescription, - const char *DocumentationSection, bool chain) { if (!name) @@ -31,64 +30,7 @@ void cmPropertyDefinitionMap { prop = &(*this)[name]; prop->DefineProperty(name,scope,ShortDescription, FullDescription, - DocumentationSection, chain); - } -} - -void cmPropertyDefinitionMap -::GetPropertiesDocumentation(std::map<std::string, - cmDocumentationSection *>& v) const -{ - for(cmPropertyDefinitionMap::const_iterator j = this->begin(); - j != this->end(); ++j) - { - // add a section if needed - std::string secName = j->second.GetDocumentationSection(); - // if a section was not specified then use the scope - if (!secName.size()) - { - switch (j->second.GetScope()) - { - case cmProperty::GLOBAL: - secName = "Properties of Global Scope"; - break; - case cmProperty::TARGET: - secName = "Properties on Targets"; - break; - case cmProperty::SOURCE_FILE: - secName = "Properties on Source Files"; - break; - case cmProperty::DIRECTORY: - secName = "Properties on Directories"; - break; - case cmProperty::TEST: - secName = "Properties on Tests"; - break; - case cmProperty::CACHE: - secName = "Properties on Cache Entries"; - break; - case cmProperty::VARIABLE: - secName = "Variables"; - break; - case cmProperty::CACHED_VARIABLE: - secName = "Cached Variables"; - break; - default: - secName = "Properties of Unknown Scope"; - break; - } - } - if (!v[secName]) - { - v[secName] = new - cmDocumentationSection(secName.c_str(), - cmSystemTools::UpperCase(secName).c_str()); - } - cmDocumentationEntry e = j->second.GetDocumentation(); - if (e.Brief.size() || e.Full.size()) - { - v[secName]->Append(e); - } + chain); } } diff --git a/Source/cmPropertyDefinitionMap.h b/Source/cmPropertyDefinitionMap.h index 007e265..736e243 100644 --- a/Source/cmPropertyDefinitionMap.h +++ b/Source/cmPropertyDefinitionMap.h @@ -24,7 +24,6 @@ public: void DefineProperty(const char *name, cmProperty::ScopeType scope, const char *ShortDescription, const char *FullDescription, - const char *DocumentaitonSection, bool chain); // has a named property been defined @@ -32,9 +31,6 @@ public: // is a named property set to chain bool IsPropertyChained(const char *name); - - void GetPropertiesDocumentation(std::map<std::string, - cmDocumentationSection *>&) const; }; #endif diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx index 78f378a..e94e3e9 100644 --- a/Source/cmPropertyMap.cxx +++ b/Source/cmPropertyMap.cxx @@ -40,19 +40,7 @@ void cmPropertyMap::SetProperty(const char *name, const char *value, this->erase(name); return; } -#ifdef CMAKE_STRICT - if (!this->CMakeInstance) - { - cmSystemTools::Error("CMakeInstance not set on a property map!"); - abort(); - } - else - { - this->CMakeInstance->RecordPropertyAccess(name,scope); - } -#else (void)scope; -#endif cmProperty *prop = this->GetOrCreateProperty(name); prop->Set(name,value); @@ -66,19 +54,7 @@ void cmPropertyMap::AppendProperty(const char* name, const char* value, { return; } -#ifdef CMAKE_STRICT - if (!this->CMakeInstance) - { - cmSystemTools::Error("CMakeInstance not set on a property map!"); - abort(); - } - else - { - this->CMakeInstance->RecordPropertyAccess(name,scope); - } -#else (void)scope; -#endif cmProperty *prop = this->GetOrCreateProperty(name); prop->Append(name,value,asString); @@ -95,19 +71,6 @@ const char *cmPropertyMap return 0; } - // has the property been defined? -#ifdef CMAKE_STRICT - if (!this->CMakeInstance) - { - cmSystemTools::Error("CMakeInstance not set on a property map!"); - abort(); - } - else - { - this->CMakeInstance->RecordPropertyAccess(name,scope); - } -#endif - cmPropertyMap::const_iterator it = this->find(name); if (it == this->end()) { diff --git a/Source/cmQTWrapCPPCommand.h b/Source/cmQTWrapCPPCommand.h index 4863402..868eb91 100644 --- a/Source/cmQTWrapCPPCommand.h +++ b/Source/cmQTWrapCPPCommand.h @@ -46,27 +46,6 @@ public: * The name of the command as specified in CMakeList.txt. */ virtual const char* GetName() const { return "qt_wrap_cpp";} - - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Create Qt Wrappers."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " qt_wrap_cpp(resultingLibraryName DestName\n" - " SourceLists ...)\n" - "Produce moc files for all the .h files listed in the SourceLists. " - "The moc files will be added to the library using the DestName " - "source list."; - } }; diff --git a/Source/cmQTWrapUICommand.h b/Source/cmQTWrapUICommand.h index b15c5cd..3406dac 100644 --- a/Source/cmQTWrapUICommand.h +++ b/Source/cmQTWrapUICommand.h @@ -44,30 +44,6 @@ public: * The name of the command as specified in CMakeList.txt. */ virtual const char* GetName() const { return "qt_wrap_ui";} - - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Create Qt user interfaces Wrappers."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " qt_wrap_ui(resultingLibraryName HeadersDestName\n" - " SourcesDestName SourceLists ...)\n" - "Produce .h and .cxx files for all the .ui files listed " - "in the SourceLists. " - "The .h files will be added to the library using the HeadersDestName" - "source list. " - "The .cxx files will be added to the library using the SourcesDestName" - "source list."; - } }; diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutoGenerators.cxx index 93e39ab..da22ab5 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -23,25 +23,39 @@ #include <cmsys/Terminal.h> #include <cmsys/ios/sstream> +#include <cmsys/FStream.hxx> +#include <assert.h> #include <string.h> #if defined(__APPLE__) #include <unistd.h> #endif -#include "cmQtAutomoc.h" +#include "cmQtAutoGenerators.h" -static bool containsQ_OBJECT(const std::string& text) +static bool requiresMocing(const std::string& text, std::string ¯oName) { // this simple check is much much faster than the regexp - if (strstr(text.c_str(), "Q_OBJECT") == NULL) + if (strstr(text.c_str(), "Q_OBJECT") == NULL + && strstr(text.c_str(), "Q_GADGET") == NULL) { return false; } cmsys::RegularExpression qObjectRegExp("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]"); - return qObjectRegExp.find(text); + if (qObjectRegExp.find(text)) + { + macroName = "Q_OBJECT"; + return true; + } + cmsys::RegularExpression qGadgetRegExp("[\n][ \t]*Q_GADGET[^a-zA-Z0-9_]"); + if (qGadgetRegExp.find(text)) + { + macroName = "Q_GADGET"; + return true; + } + return false; } @@ -101,10 +115,12 @@ static void copyTargetProperty(cmTarget* destinationTarget, } -cmQtAutomoc::cmQtAutomoc() +cmQtAutoGenerators::cmQtAutoGenerators() :Verbose(cmsys::SystemTools::GetEnv("VERBOSE") != 0) ,ColorOutput(true) ,RunMocFailed(false) +,RunUicFailed(false) +,RunRccFailed(false) ,GenerateAll(false) { @@ -123,7 +139,25 @@ cmQtAutomoc::cmQtAutomoc() } } -bool cmQtAutomoc::InitializeMocSourceFile(cmTarget* target) +static std::string getAutogenTargetName(cmTarget const* target) +{ + std::string autogenTargetName = target->GetName(); + autogenTargetName += "_automoc"; + return autogenTargetName; +} + +static std::string getAutogenTargetDir(cmTarget const* target) +{ + cmMakefile* makefile = target->GetMakefile(); + std::string targetDir = makefile->GetCurrentOutputDirectory(); + targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory(); + targetDir += "/"; + targetDir += getAutogenTargetName(target); + targetDir += ".dir/"; + return targetDir; +} + +bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) { cmMakefile* makefile = target->GetMakefile(); // don't do anything if there is no Qt4 or Qt5Core (which contains moc): @@ -137,79 +171,30 @@ bool cmQtAutomoc::InitializeMocSourceFile(cmTarget* target) return false; } - std::string automocTargetName = target->GetName(); - automocTargetName += "_automoc"; - std::string mocCppFile = makefile->GetCurrentOutputDirectory(); - mocCppFile += "/"; - mocCppFile += automocTargetName; - mocCppFile += ".cpp"; - cmSourceFile* mocCppSource = makefile->GetOrCreateSource(mocCppFile.c_str(), - true); - makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", - mocCppFile.c_str(), false); - - target->AddSourceFile(mocCppSource); - return true; -} - -static void GetCompileDefinitionsAndDirectories(cmTarget *target, - const char * config, - std::string &incs, - std::string &defs) -{ - cmMakefile* makefile = target->GetMakefile(); - cmLocalGenerator* localGen = makefile->GetLocalGenerator(); - std::vector<std::string> includeDirs; - cmGeneratorTarget gtgt(target); - // Get the include dirs for this target, without stripping the implicit - // include dirs off, see http://public.kitware.com/Bug/view.php?id=13667 - localGen->GetIncludeDirectories(includeDirs, >gt, "CXX", config, false); - const char* sep = ""; - incs = ""; - for(std::vector<std::string>::const_iterator incDirIt = includeDirs.begin(); - incDirIt != includeDirs.end(); - ++incDirIt) - { - incs += sep; - sep = ";"; - incs += *incDirIt; - } - - std::set<std::string> defines; - localGen->AddCompileDefinitions(defines, target, config); - - sep = ""; - for(std::set<std::string>::const_iterator defIt = defines.begin(); - defIt != defines.end(); - ++defIt) + if (target->GetPropertyAsBool("AUTOMOC")) { - defs += sep; - sep = ";"; - defs += *defIt; + std::string automocTargetName = getAutogenTargetName(target); + std::string mocCppFile = makefile->GetCurrentOutputDirectory(); + mocCppFile += "/"; + mocCppFile += automocTargetName; + mocCppFile += ".cpp"; + cmSourceFile* mocCppSource = makefile->GetOrCreateSource( + mocCppFile.c_str(), + true); + makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", + mocCppFile.c_str(), false); + + target->AddSourceFile(mocCppSource); } -} + // create a custom target for running generators at buildtime: + std::string autogenTargetName = getAutogenTargetName(target); -void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) -{ - cmMakefile* makefile = target->GetMakefile(); - const char* targetName = target->GetName(); - - bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE"); - - // create a custom target for running automoc at buildtime: - std::string automocTargetName = targetName; - automocTargetName += "_automoc"; - - std::string targetDir = makefile->GetCurrentOutputDirectory(); - targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory(); - targetDir += "/"; - targetDir += automocTargetName; - targetDir += ".dir/"; + std::string targetDir = getAutogenTargetDir(target); cmCustomCommandLine currentLine; currentLine.push_back(makefile->GetSafeDefinition("CMAKE_COMMAND")); currentLine.push_back("-E"); - currentLine.push_back("cmake_automoc"); + currentLine.push_back("cmake_autogen"); currentLine.push_back(targetDir); currentLine.push_back("$<CONFIGURATION>"); @@ -220,8 +205,39 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) "", makefile->GetCurrentOutputDirectory()); std::vector<std::string> depends; - std::string automocComment = "Automoc for target "; - automocComment += targetName; + if (const char *autogenDepends = + target->GetProperty("AUTOGEN_TARGET_DEPENDS")) + { + cmSystemTools::ExpandListArgument(autogenDepends, depends); + } + std::vector<std::string> toolNames; + if (target->GetPropertyAsBool("AUTOMOC")) + { + toolNames.push_back("moc"); + } + if (target->GetPropertyAsBool("AUTOUIC")) + { + toolNames.push_back("uic"); + } + if (target->GetPropertyAsBool("AUTORCC")) + { + toolNames.push_back("rcc"); + this->InitializeAutoRccTarget(target); + } + + std::string tools = toolNames[0]; + toolNames.erase(toolNames.begin()); + while (toolNames.size() > 1) + { + tools += ", " + toolNames[0]; + toolNames.erase(toolNames.begin()); + } + if (toolNames.size() == 1) + { + tools += " and " + toolNames[0]; + } + std::string autogenComment = "Automatic " + tools + " for target "; + autogenComment += target->GetName(); #if defined(_WIN32) && !defined(__CYGWIN__) bool usePRE_BUILD = false; @@ -244,42 +260,202 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) // PRE_BUILD will work for an OBJECT_LIBRARY in this specific case. std::vector<std::string> no_output; cmCustomCommand cc(makefile, no_output, depends, - commandLines, automocComment.c_str(), + commandLines, autogenComment.c_str(), workingDirectory.c_str()); cc.SetEscapeOldStyle(false); cc.SetEscapeAllowMakeVars(true); - target->GetPreBuildCommands().push_back(cc); + target->AddPreBuildCommand(cc); } else #endif { - cmTarget* automocTarget = makefile->AddUtilityCommand( - automocTargetName.c_str(), true, + cmTarget* autogenTarget = makefile->AddUtilityCommand( + autogenTargetName.c_str(), true, workingDirectory.c_str(), depends, - commandLines, false, automocComment.c_str()); + commandLines, false, autogenComment.c_str()); // Set target folder - const char* automocFolder = makefile->GetCMakeInstance()->GetProperty( + const char* autogenFolder = makefile->GetCMakeInstance()->GetProperty( "AUTOMOC_TARGETS_FOLDER"); - if (automocFolder && *automocFolder) + if (!autogenFolder) + { + autogenFolder = makefile->GetCMakeInstance()->GetProperty( + "AUTOGEN_TARGETS_FOLDER"); + } + if (autogenFolder && *autogenFolder) { - automocTarget->SetProperty("FOLDER", automocFolder); + autogenTarget->SetProperty("FOLDER", autogenFolder); } else { // inherit FOLDER property from target (#13688) - copyTargetProperty(automocTarget, target, "FOLDER"); + copyTargetProperty(autogenTarget, target, "FOLDER"); } - target->AddUtility(automocTargetName.c_str()); + target->AddUtility(autogenTargetName.c_str()); + } + + return true; +} + +static void GetCompileDefinitionsAndDirectories(cmTarget const* target, + const char * config, + std::string &incs, + std::string &defs) +{ + cmMakefile* makefile = target->GetMakefile(); + cmLocalGenerator* localGen = makefile->GetLocalGenerator(); + std::vector<std::string> includeDirs; + cmGeneratorTarget *gtgt = target->GetMakefile()->GetLocalGenerator() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + // Get the include dirs for this target, without stripping the implicit + // include dirs off, see http://public.kitware.com/Bug/view.php?id=13667 + localGen->GetIncludeDirectories(includeDirs, gtgt, "CXX", config, false); + const char* sep = ""; + incs = ""; + for(std::vector<std::string>::const_iterator incDirIt = includeDirs.begin(); + incDirIt != includeDirs.end(); + ++incDirIt) + { + incs += sep; + sep = ";"; + incs += *incDirIt; + } + + std::set<std::string> defines; + localGen->AddCompileDefinitions(defines, target, config); + + sep = ""; + for(std::set<std::string>::const_iterator defIt = defines.begin(); + defIt != defines.end(); + ++defIt) + { + defs += sep; + sep = ";"; + defs += *defIt; + } +} + +void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) +{ + cmMakefile* makefile = target->GetMakefile(); + + // forget the variables added here afterwards again: + cmMakefile::ScopePushPop varScope(makefile); + static_cast<void>(varScope); + + // create a custom target for running generators at buildtime: + std::string autogenTargetName = getAutogenTargetName(target); + + makefile->AddDefinition("_moc_target_name", + cmLocalGenerator::EscapeForCMake(autogenTargetName.c_str()).c_str()); + + std::string targetDir = getAutogenTargetDir(target); + + const char *qtVersion = makefile->GetDefinition("Qt5Core_VERSION_MAJOR"); + if (!qtVersion) + { + qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); + } + if (const char *targetQtVersion = + target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", 0)) + { + qtVersion = targetQtVersion; + } + if (qtVersion) + { + makefile->AddDefinition("_target_qt_version", qtVersion); + } + + std::map<std::string, std::string> configIncludes; + std::map<std::string, std::string> configDefines; + std::map<std::string, std::string> configUicOptions; + + if (target->GetPropertyAsBool("AUTOMOC")) + { + this->SetupAutoMocTarget(target, autogenTargetName, + configIncludes, configDefines); + } + if (target->GetPropertyAsBool("AUTOUIC")) + { + this->SetupAutoUicTarget(target, configUicOptions); + } + if (target->GetPropertyAsBool("AUTORCC")) + { + this->SetupAutoRccTarget(target); + } + + const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT"); + std::string inputFile = cmakeRoot; + inputFile += "/Modules/AutogenInfo.cmake.in"; + std::string outputFile = targetDir; + outputFile += "/AutogenInfo.cmake"; + makefile->ConfigureFile(inputFile.c_str(), outputFile.c_str(), + false, true, false); + + if (!configDefines.empty() + || !configIncludes.empty() + || !configUicOptions.empty()) + { + cmsys::ofstream infoFile(outputFile.c_str(), std::ios::app); + if ( !infoFile ) + { + std::string error = "Internal CMake error when trying to open file: "; + error += outputFile.c_str(); + error += " for writing."; + cmSystemTools::Error(error.c_str()); + return; + } + if (!configDefines.empty()) + { + for (std::map<std::string, std::string>::iterator + it = configDefines.begin(), end = configDefines.end(); + it != end; ++it) + { + infoFile << "set(AM_MOC_COMPILE_DEFINITIONS_" << it->first << + " " << it->second << ")\n"; + } + } + if (!configIncludes.empty()) + { + for (std::map<std::string, std::string>::iterator + it = configIncludes.begin(), end = configIncludes.end(); + it != end; ++it) + { + infoFile << "set(AM_MOC_INCLUDES_" << it->first << + " " << it->second << ")\n"; + } + } + if (!configUicOptions.empty()) + { + for (std::map<std::string, std::string>::iterator + it = configUicOptions.begin(), end = configUicOptions.end(); + it != end; ++it) + { + infoFile << "set(AM_UIC_TARGET_OPTIONS_" << it->first << + " " << it->second << ")\n"; + } + } } +} + +void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, + const std::string &autogenTargetName, + std::map<std::string, std::string> &configIncludes, + std::map<std::string, std::string> &configDefines) +{ + cmMakefile* makefile = target->GetMakefile(); - // configure a file to get all information to automoc at buildtime: std::string _moc_files; std::string _moc_headers; const char* sepFiles = ""; const char* sepHeaders = ""; - const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles(); + std::vector<cmSourceFile*> srcFiles; + target->GetSourceFiles(srcFiles); + + std::string skip_moc; + const char *sep = ""; for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); @@ -291,41 +467,46 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC")); bool generated = cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED")); - if ((skip==false) && (generated == false)) + if (!generated) { - std::string ext = sf->GetExtension(); - cmSystemTools::FileFormat fileType = cmSystemTools::GetFileFormat( - ext.c_str()); - if (fileType == cmSystemTools::CXX_FILE_FORMAT) + if (skip) { - _moc_files += sepFiles; - _moc_files += absFile; - sepFiles = ";"; + skip_moc += sep; + skip_moc += absFile; + sep = ";"; } - else if (fileType == cmSystemTools::HEADER_FILE_FORMAT) + else { - _moc_headers += sepHeaders; - _moc_headers += absFile; - sepHeaders = ";"; + std::string ext = sf->GetExtension(); + cmSystemTools::FileFormat fileType = cmSystemTools::GetFileFormat( + ext.c_str()); + if (fileType == cmSystemTools::CXX_FILE_FORMAT) + { + _moc_files += sepFiles; + _moc_files += absFile; + sepFiles = ";"; + } + else if (fileType == cmSystemTools::HEADER_FILE_FORMAT) + { + _moc_headers += sepHeaders; + _moc_headers += absFile; + sepHeaders = ";"; + } } } } const char* tmp = target->GetProperty("AUTOMOC_MOC_OPTIONS"); std::string _moc_options = (tmp!=0 ? tmp : ""); - - // forget the variables added here afterwards again: - cmMakefile::ScopePushPop varScope(makefile); - static_cast<void>(varScope); - - makefile->AddDefinition("_moc_target_name", - cmLocalGenerator::EscapeForCMake(automocTargetName.c_str()).c_str()); makefile->AddDefinition("_moc_options", cmLocalGenerator::EscapeForCMake(_moc_options.c_str()).c_str()); makefile->AddDefinition("_moc_files", cmLocalGenerator::EscapeForCMake(_moc_files.c_str()).c_str()); + makefile->AddDefinition("_skip_moc", + cmLocalGenerator::EscapeForCMake(skip_moc.c_str()).c_str()); makefile->AddDefinition("_moc_headers", cmLocalGenerator::EscapeForCMake(_moc_headers.c_str()).c_str()); + bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE"); makefile->AddDefinition("_moc_relaxed_mode", relaxedMode ? "TRUE" : "FALSE"); std::string _moc_incs; @@ -340,9 +521,6 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) makefile->AddDefinition("_moc_compile_defs", cmLocalGenerator::EscapeForCMake(_moc_compile_defs.c_str()).c_str()); - std::map<std::string, std::string> configIncludes; - std::map<std::string, std::string> configDefines; - for (std::vector<std::string>::const_iterator li = configs.begin(); li != configs.end(); ++li) { @@ -353,7 +531,7 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) config_moc_compile_defs); if (config_moc_incs != _moc_incs) { - configIncludes["_moc_incs_" + *li] = + configIncludes[*li] = cmLocalGenerator::EscapeForCMake(config_moc_incs.c_str()); if(_moc_incs.empty()) { @@ -362,7 +540,7 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) } if (config_moc_compile_defs != _moc_compile_defs) { - configDefines["_moc_compile_defs_" + *li] = + configDefines[*li] = cmLocalGenerator::EscapeForCMake(config_moc_compile_defs.c_str()); if(_moc_compile_defs.empty()) { @@ -371,33 +549,17 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) } } - const char *qtVersion = makefile->GetDefinition("Qt5Core_VERSION_MAJOR"); - if (!qtVersion) - { - qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); - } - if (const char *targetQtVersion = - target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", 0)) - { - qtVersion = targetQtVersion; - } - if (qtVersion) - { - makefile->AddDefinition("_target_qt_version", qtVersion); - } - - { const char *qtMoc = makefile->GetSafeDefinition("QT_MOC_EXECUTABLE"); makefile->AddDefinition("_qt_moc_executable", qtMoc); - } + const char *qtVersion = makefile->GetDefinition("_target_qt_version"); if (strcmp(qtVersion, "5") == 0) { cmTarget *qt5Moc = makefile->FindTargetToUse("Qt5::moc"); if (!qt5Moc) { cmSystemTools::Error("Qt5::moc target not found ", - automocTargetName.c_str()); + autogenTargetName.c_str()); return; } makefile->AddDefinition("_qt_moc_executable", qt5Moc->GetLocation(0)); @@ -407,68 +569,404 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) if (strcmp(qtVersion, "4") != 0) { cmSystemTools::Error("The CMAKE_AUTOMOC feature supports only Qt 4 and " - "Qt 5 ", automocTargetName.c_str()); + "Qt 5 ", autogenTargetName.c_str()); } } +} - const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT"); - std::string inputFile = cmakeRoot; - inputFile += "/Modules/AutomocInfo.cmake.in"; - std::string outputFile = targetDir; - outputFile += "/AutomocInfo.cmake"; - makefile->ConfigureFile(inputFile.c_str(), outputFile.c_str(), - false, true, false); +void cmQtAutoGenerators::MergeUicOptions(std::vector<std::string> &opts, + const std::vector<std::string> &fileOpts, + bool isQt5) +{ + static const char* valueOptions[] = { + "tr", + "translate", + "postfix", + "generator", + "include", // Since Qt 5.3 + "g" + }; + std::vector<std::string> extraOpts; + for(std::vector<std::string>::const_iterator it = fileOpts.begin(); + it != fileOpts.end(); ++it) + { + std::vector<std::string>::iterator existingIt + = std::find(opts.begin(), opts.end(), *it); + if (existingIt != opts.end()) + { + const char *o = it->c_str(); + if (*o == '-') + { + ++o; + } + if (isQt5 && *o == '-') + { + ++o; + } + if (std::find_if(cmArrayBegin(valueOptions), cmArrayEnd(valueOptions), + cmStrCmp(o)) != cmArrayEnd(valueOptions)) + { + assert(existingIt + 1 != opts.end()); + *(existingIt + 1) = *(it + 1); + ++it; + } + } + else + { + extraOpts.push_back(*it); + } + } + opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); +} + +static void GetUicOpts(cmTarget const* target, const char * config, + std::string &optString) +{ + std::vector<std::string> opts; + target->GetAutoUicOptions(opts, config); - if (!configDefines.empty() || !configIncludes.empty()) + const char* sep = ""; + for(std::vector<std::string>::const_iterator optIt = opts.begin(); + optIt != opts.end(); + ++optIt) { - std::ofstream infoFile(outputFile.c_str(), std::ios::app); - if ( !infoFile ) + optString += sep; + sep = ";"; + optString += *optIt; + } +} + +void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, + std::map<std::string, std::string> &configUicOptions) +{ + cmMakefile *makefile = target->GetMakefile(); + + const char *qtUic = makefile->GetSafeDefinition("QT_UIC_EXECUTABLE"); + makefile->AddDefinition("_qt_uic_executable", qtUic); + + std::vector<cmSourceFile*> srcFiles; + target->GetSourceFiles(srcFiles); + + std::string skip_uic; + const char *sep = ""; + + bool skip = target->GetPropertyAsBool("SKIP_AUTOUIC"); + + std::set<cmStdString> skipped; + + for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); + fileIt != srcFiles.end(); + ++fileIt) + { + cmSourceFile* sf = *fileIt; + std::string absFile = cmsys::SystemTools::GetRealPath( + sf->GetFullPath().c_str()); + if (!skip) { - std::string error = "Internal CMake error when trying to open file: "; - error += outputFile.c_str(); - error += " for writing."; - cmSystemTools::Error(error.c_str()); - return; + skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOUIC")); } - if (!configDefines.empty()) + + if (skip) { - for (std::map<std::string, std::string>::iterator - it = configDefines.begin(), end = configDefines.end(); - it != end; ++it) + skip_uic += sep; + skip_uic += absFile; + sep = ";"; + skipped.insert(absFile); + } + } + + makefile->AddDefinition("_skip_uic", + cmLocalGenerator::EscapeForCMake(skip_uic.c_str()).c_str()); + + std::vector<cmSourceFile*> uiFilesWithOptions + = makefile->GetQtUiFilesWithOptions(); + + std::string uiFileFiles; + std::string uiFileOptions; + sep = ""; + + const char *qtVersion = makefile->GetDefinition("_target_qt_version"); + + std::string _uic_opts; + std::vector<std::string> configs; + const char *config = makefile->GetConfigurations(configs); + GetUicOpts(target, config, _uic_opts); + + if (!_uic_opts.empty()) + { + _uic_opts = cmLocalGenerator::EscapeForCMake(_uic_opts.c_str()); + makefile->AddDefinition("_uic_target_options", _uic_opts.c_str()); + } + for (std::vector<std::string>::const_iterator li = configs.begin(); + li != configs.end(); ++li) + { + std::string config_uic_opts; + GetUicOpts(target, li->c_str(), config_uic_opts); + if (config_uic_opts != _uic_opts) + { + configUicOptions[*li] = + cmLocalGenerator::EscapeForCMake(config_uic_opts.c_str()); + if(_uic_opts.empty()) { - infoFile << "SET(AM_MOC_COMPILE_DEFINITIONS_" << it->first << - " " << it->second << ")\n"; + _uic_opts = config_uic_opts; } } - if (!configIncludes.empty()) + } + + for(std::vector<cmSourceFile*>::const_iterator fileIt = + uiFilesWithOptions.begin(); + fileIt != uiFilesWithOptions.end(); + ++fileIt) + { + cmSourceFile* sf = *fileIt; + std::string absFile = cmsys::SystemTools::GetRealPath( + sf->GetFullPath().c_str()); + + if (!skipped.insert(absFile).second) { - for (std::map<std::string, std::string>::iterator - it = configIncludes.begin(), end = configIncludes.end(); - it != end; ++it) + continue; + } + uiFileFiles += sep; + uiFileFiles += absFile; + uiFileOptions += sep; + std::string opts = sf->GetProperty("AUTOUIC_OPTIONS"); + cmSystemTools::ReplaceString(opts, ";", "@list_sep@"); + uiFileOptions += opts; + sep = ";"; + } + + makefile->AddDefinition("_qt_uic_options_files", + cmLocalGenerator::EscapeForCMake(uiFileFiles.c_str()).c_str()); + makefile->AddDefinition("_qt_uic_options_options", + cmLocalGenerator::EscapeForCMake(uiFileOptions.c_str()).c_str()); + + const char* targetName = target->GetName(); + if (strcmp(qtVersion, "5") == 0) + { + cmTarget *qt5Uic = makefile->FindTargetToUse("Qt5::uic"); + if (!qt5Uic) + { + // Project does not use Qt5Widgets, but has AUTOUIC ON anyway + makefile->RemoveDefinition("_qt_uic_executable"); + } + else + { + makefile->AddDefinition("_qt_uic_executable", qt5Uic->GetLocation(0)); + } + } + else + { + if (strcmp(qtVersion, "4") != 0) + { + cmSystemTools::Error("The CMAKE_AUTOUIC feature supports only Qt 4 and " + "Qt 5 ", targetName); + } + } +} + +void cmQtAutoGenerators::MergeRccOptions(std::vector<std::string> &opts, + const std::vector<std::string> &fileOpts, + bool isQt5) +{ + static const char* valueOptions[] = { + "name", + "root", + "compress", + "threshold" + }; + std::vector<std::string> extraOpts; + for(std::vector<std::string>::const_iterator it = fileOpts.begin(); + it != fileOpts.end(); ++it) + { + std::vector<std::string>::iterator existingIt + = std::find(opts.begin(), opts.end(), *it); + if (existingIt != opts.end()) + { + const char *o = it->c_str(); + if (*o == '-') { - infoFile << "SET(AM_MOC_INCLUDES_" << it->first << - " " << it->second << ")\n"; + ++o; + } + if (isQt5 && *o == '-') + { + ++o; + } + if (std::find_if(cmArrayBegin(valueOptions), cmArrayEnd(valueOptions), + cmStrCmp(o)) != cmArrayEnd(valueOptions)) + { + assert(existingIt + 1 != opts.end()); + *(existingIt + 1) = *(it + 1); + ++it; + } + } + else + { + extraOpts.push_back(*it); + } + } + opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); +} + +void cmQtAutoGenerators::InitializeAutoRccTarget(cmTarget* target) +{ + cmMakefile *makefile = target->GetMakefile(); + + std::vector<cmSourceFile*> srcFiles; + target->GetSourceFiles(srcFiles); + + std::vector<cmSourceFile*> newFiles; + + for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); + fileIt != srcFiles.end(); + ++fileIt) + { + cmSourceFile* sf = *fileIt; + std::string ext = sf->GetExtension(); + if (ext == "qrc") + { + std::string absFile = cmsys::SystemTools::GetRealPath( + sf->GetFullPath().c_str()); + bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")); + + if (!skip) + { + std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(absFile); + + std::string rcc_output_file = makefile->GetCurrentOutputDirectory(); + rcc_output_file += "/qrc_" + basename + ".cpp"; + makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", + rcc_output_file.c_str(), false); + cmSourceFile* rccCppSource + = makefile->GetOrCreateSource(rcc_output_file.c_str(), true); + newFiles.push_back(rccCppSource); } } } + + for(std::vector<cmSourceFile*>::const_iterator fileIt = newFiles.begin(); + fileIt != newFiles.end(); + ++fileIt) + { + target->AddSourceFile(*fileIt); + } } +void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) +{ + std::string _rcc_files; + const char* sepRccFiles = ""; + cmMakefile *makefile = target->GetMakefile(); + + std::vector<cmSourceFile*> srcFiles; + target->GetSourceFiles(srcFiles); + + std::string rccFileFiles; + std::string rccFileOptions; + const char *sep = ""; + + const char *qtVersion = makefile->GetDefinition("_target_qt_version"); + + std::vector<std::string> rccOptions; + if (const char* opts = target->GetProperty("AUTORCC_OPTIONS")) + { + cmSystemTools::ExpandListArgument(opts, rccOptions); + } + + for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); + fileIt != srcFiles.end(); + ++fileIt) + { + cmSourceFile* sf = *fileIt; + std::string ext = sf->GetExtension(); + if (ext == "qrc") + { + std::string absFile = cmsys::SystemTools::GetRealPath( + sf->GetFullPath().c_str()); + bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")); + + if (!skip) + { + _rcc_files += sepRccFiles; + _rcc_files += absFile; + sepRccFiles = ";"; + + if (const char *prop = sf->GetProperty("AUTORCC_OPTIONS")) + { + std::vector<std::string> optsVec; + cmSystemTools::ExpandListArgument(prop, optsVec); + this->MergeRccOptions(rccOptions, optsVec, + strcmp(qtVersion, "5") == 0); + } + + if (!rccOptions.empty()) + { + rccFileFiles += sep; + rccFileFiles += absFile; + rccFileOptions += sep; + } + const char *listSep = ""; + for(std::vector<std::string>::const_iterator it = rccOptions.begin(); + it != rccOptions.end(); + ++it) + { + rccFileOptions += listSep; + rccFileOptions += *it; + listSep = "@list_sep@"; + } + sep = ";"; + } + } + } + + makefile->AddDefinition("_rcc_files", + cmLocalGenerator::EscapeForCMake(_rcc_files.c_str()).c_str()); + + makefile->AddDefinition("_qt_rcc_options_files", + cmLocalGenerator::EscapeForCMake(rccFileFiles.c_str()).c_str()); + makefile->AddDefinition("_qt_rcc_options_options", + cmLocalGenerator::EscapeForCMake(rccFileOptions.c_str()).c_str()); -bool cmQtAutomoc::Run(const char* targetDirectory, const char *config) + const char *qtRcc = makefile->GetSafeDefinition("QT_RCC_EXECUTABLE"); + makefile->AddDefinition("_qt_rcc_executable", qtRcc); + + const char* targetName = target->GetName(); + if (strcmp(qtVersion, "5") == 0) + { + cmTarget *qt5Rcc = makefile->FindTargetToUse("Qt5::rcc"); + if (!qt5Rcc) + { + cmSystemTools::Error("Qt5::rcc target not found ", + targetName); + return; + } + makefile->AddDefinition("_qt_rcc_executable", qt5Rcc->GetLocation(0)); + } + else + { + if (strcmp(qtVersion, "4") != 0) + { + cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and " + "Qt 5 ", targetName); + } + } +} + +bool cmQtAutoGenerators::Run(const char* targetDirectory, const char *config) { bool success = true; cmake cm; cmGlobalGenerator* gg = this->CreateGlobalGenerator(&cm, targetDirectory); cmMakefile* makefile = gg->GetCurrentLocalGenerator()->GetMakefile(); - this->ReadAutomocInfoFile(makefile, targetDirectory, config); + this->ReadAutogenInfoFile(makefile, targetDirectory, config); this->ReadOldMocDefinitionsFile(makefile, targetDirectory); this->Init(); if (this->QtMajorVersion == "4" || this->QtMajorVersion == "5") { - success = this->RunAutomoc(makefile); + success = this->RunAutogen(makefile); } this->WriteOldMocDefinitionsFile(targetDirectory); @@ -480,7 +978,7 @@ bool cmQtAutomoc::Run(const char* targetDirectory, const char *config) } -cmGlobalGenerator* cmQtAutomoc::CreateGlobalGenerator(cmake* cm, +cmGlobalGenerator* cmQtAutoGenerators::CreateGlobalGenerator(cmake* cm, const char* targetDirectory) { cmGlobalGenerator* gg = new cmGlobalGenerator(); @@ -497,13 +995,13 @@ cmGlobalGenerator* cmQtAutomoc::CreateGlobalGenerator(cmake* cm, } -bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, +bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, const char* targetDirectory, const char *config) { std::string filename(cmSystemTools::CollapseFullPath(targetDirectory)); cmSystemTools::ConvertToUnixSlashes(filename); - filename += "/AutomocInfo.cmake"; + filename += "/AutogenInfo.cmake"; if (!makefile->ReadListFile(0, filename.c_str())) { @@ -518,12 +1016,17 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, "AM_Qt5Core_VERSION_MAJOR"); } this->Sources = makefile->GetSafeDefinition("AM_SOURCES"); + this->RccSources = makefile->GetSafeDefinition("AM_RCC_SOURCES"); + this->SkipMoc = makefile->GetSafeDefinition("AM_SKIP_MOC"); + this->SkipUic = makefile->GetSafeDefinition("AM_SKIP_UIC"); this->Headers = makefile->GetSafeDefinition("AM_HEADERS"); this->IncludeProjectDirsBefore = makefile->IsOn( "AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE"); this->Srcdir = makefile->GetSafeDefinition("AM_CMAKE_CURRENT_SOURCE_DIR"); this->Builddir = makefile->GetSafeDefinition("AM_CMAKE_CURRENT_BINARY_DIR"); this->MocExecutable = makefile->GetSafeDefinition("AM_QT_MOC_EXECUTABLE"); + this->UicExecutable = makefile->GetSafeDefinition("AM_QT_UIC_EXECUTABLE"); + this->RccExecutable = makefile->GetSafeDefinition("AM_QT_RCC_EXECUTABLE"); std::string compileDefsPropOrig = "AM_MOC_COMPILE_DEFINITIONS"; std::string compileDefsProp = compileDefsPropOrig; if(config) @@ -549,6 +1052,63 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, this->ProjectSourceDir = makefile->GetSafeDefinition("AM_CMAKE_SOURCE_DIR"); this->TargetName = makefile->GetSafeDefinition("AM_TARGET_NAME"); + { + const char *uicOptionsFiles + = makefile->GetSafeDefinition("AM_UIC_OPTIONS_FILES"); + std::string uicOptionsPropOrig = "AM_UIC_TARGET_OPTIONS"; + std::string uicOptionsProp = uicOptionsPropOrig; + if(config) + { + uicOptionsProp += "_"; + uicOptionsProp += config; + } + const char *uicTargetOptions + = makefile->GetSafeDefinition(uicOptionsProp.c_str()); + cmSystemTools::ExpandListArgument( + uicTargetOptions ? uicTargetOptions + : makefile->GetSafeDefinition(includesPropOrig.c_str()), + this->UicTargetOptions); + const char *uicOptionsOptions + = makefile->GetSafeDefinition("AM_UIC_OPTIONS_OPTIONS"); + std::vector<std::string> uicFilesVec; + cmSystemTools::ExpandListArgument(uicOptionsFiles, uicFilesVec); + std::vector<std::string> uicOptionsVec; + cmSystemTools::ExpandListArgument(uicOptionsOptions, uicOptionsVec); + if (uicFilesVec.size() != uicOptionsVec.size()) + { + return false; + } + for (std::vector<std::string>::iterator fileIt = uicFilesVec.begin(), + optionIt = uicOptionsVec.begin(); + fileIt != uicFilesVec.end(); + ++fileIt, ++optionIt) + { + cmSystemTools::ReplaceString(*optionIt, "@list_sep@", ";"); + this->UicOptions[*fileIt] = *optionIt; + } + } + { + const char *rccOptionsFiles + = makefile->GetSafeDefinition("AM_RCC_OPTIONS_FILES"); + const char *rccOptionsOptions + = makefile->GetSafeDefinition("AM_RCC_OPTIONS_OPTIONS"); + std::vector<std::string> rccFilesVec; + cmSystemTools::ExpandListArgument(rccOptionsFiles, rccFilesVec); + std::vector<std::string> rccOptionsVec; + cmSystemTools::ExpandListArgument(rccOptionsOptions, rccOptionsVec); + if (rccFilesVec.size() != rccOptionsVec.size()) + { + return false; + } + for (std::vector<std::string>::iterator fileIt = rccFilesVec.begin(), + optionIt = rccOptionsVec.begin(); + fileIt != rccFilesVec.end(); + ++fileIt, ++optionIt) + { + cmSystemTools::ReplaceString(*optionIt, "@list_sep@", ";"); + this->RccOptions[*fileIt] = *optionIt; + } + } this->CurrentCompileSettingsStr = this->MakeCompileSettingsString(makefile); this->RelaxedMode = makefile->IsOn("AM_RELAXED_MODE"); @@ -557,7 +1117,7 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, } -std::string cmQtAutomoc::MakeCompileSettingsString(cmMakefile* makefile) +std::string cmQtAutoGenerators::MakeCompileSettingsString(cmMakefile* makefile) { std::string s; s += makefile->GetSafeDefinition("AM_MOC_COMPILE_DEFINITIONS"); @@ -574,7 +1134,7 @@ std::string cmQtAutomoc::MakeCompileSettingsString(cmMakefile* makefile) } -bool cmQtAutomoc::ReadOldMocDefinitionsFile(cmMakefile* makefile, +bool cmQtAutoGenerators::ReadOldMocDefinitionsFile(cmMakefile* makefile, const char* targetDirectory) { std::string filename(cmSystemTools::CollapseFullPath(targetDirectory)); @@ -590,7 +1150,8 @@ bool cmQtAutomoc::ReadOldMocDefinitionsFile(cmMakefile* makefile, } -void cmQtAutomoc::WriteOldMocDefinitionsFile(const char* targetDirectory) +void +cmQtAutoGenerators::WriteOldMocDefinitionsFile(const char* targetDirectory) { std::string filename(cmSystemTools::CollapseFullPath(targetDirectory)); cmSystemTools::ConvertToUnixSlashes(filename); @@ -607,7 +1168,7 @@ void cmQtAutomoc::WriteOldMocDefinitionsFile(const char* targetDirectory) } -void cmQtAutomoc::Init() +void cmQtAutoGenerators::Init() { this->OutMocCppFilename = this->Builddir; this->OutMocCppFilename += this->TargetName; @@ -694,7 +1255,7 @@ void cmQtAutomoc::Init() } -bool cmQtAutomoc::RunAutomoc(cmMakefile* makefile) +bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) { if (!cmsys::SystemTools::FileExists(this->OutMocCppFilename.c_str()) || (this->OldCompileSettingsStr != this->CurrentCompileSettingsStr)) @@ -721,26 +1282,56 @@ bool cmQtAutomoc::RunAutomoc(cmMakefile* makefile) const std::vector<std::string>& headerExtensions = makefile->GetHeaderExtensions(); + std::vector<std::string> includedUis; + std::vector<std::string> skippedUis; + std::vector<std::string> uicSkipped; + cmSystemTools::ExpandListArgument(this->SkipUic, uicSkipped); + for (std::vector<std::string>::const_iterator it = sourceFiles.begin(); it != sourceFiles.end(); ++it) { + const bool skipUic = std::find(uicSkipped.begin(), uicSkipped.end(), *it) + != uicSkipped.end(); + std::vector<std::string>& uiFiles = skipUic ? skippedUis : includedUis; const std::string &absFilename = *it; if (this->Verbose) { - std::cout << "AUTOMOC: Checking " << absFilename << std::endl; + std::cout << "AUTOGEN: Checking " << absFilename << std::endl; } if (this->RelaxedMode) { - this->ParseCppFile(absFilename, headerExtensions, includedMocs); + this->ParseCppFile(absFilename, headerExtensions, includedMocs, + uiFiles); } else { - this->StrictParseCppFile(absFilename, headerExtensions, includedMocs); + this->StrictParseCppFile(absFilename, headerExtensions, includedMocs, + uiFiles); } this->SearchHeadersForCppFile(absFilename, headerExtensions, headerFiles); } + { + std::vector<std::string> mocSkipped; + cmSystemTools::ExpandListArgument(this->SkipMoc, mocSkipped); + for (std::vector<std::string>::const_iterator it = mocSkipped.begin(); + it != mocSkipped.end(); + ++it) + { + if (std::find(uicSkipped.begin(), uicSkipped.end(), *it) + != uicSkipped.end()) + { + const std::string &absFilename = *it; + if (this->Verbose) + { + std::cout << "AUTOGEN: Checking " << absFilename << std::endl; + } + this->ParseForUic(absFilename, includedUis); + } + } + } + std::vector<std::string> headerFilesVec; cmSystemTools::ExpandListArgument(this->Headers, headerFilesVec); for (std::vector<std::string>::const_iterator it = headerFilesVec.begin(); @@ -752,7 +1343,7 @@ bool cmQtAutomoc::RunAutomoc(cmMakefile* makefile) // key = moc source filepath, value = moc output filename std::map<std::string, std::string> notIncludedMocs; - this->ParseHeaders(headerFiles, includedMocs, notIncludedMocs); + this->ParseHeaders(headerFiles, includedMocs, notIncludedMocs, includedUis); // run moc on all the moc's that are #included in source files for(std::map<std::string, std::string>::const_iterator @@ -762,6 +1353,17 @@ bool cmQtAutomoc::RunAutomoc(cmMakefile* makefile) { this->GenerateMoc(it->first, it->second); } + for(std::vector<std::string>::const_iterator it = includedUis.begin(); + it != includedUis.end(); + ++it) + { + this->GenerateUi(*it); + } + + if(!this->RccExecutable.empty()) + { + this->GenerateQrc(); + } cmsys_ios::stringstream outStream; outStream << "/* This file is autogenerated, do not edit*/\n"; @@ -791,7 +1393,18 @@ bool cmQtAutomoc::RunAutomoc(cmMakefile* makefile) if (this->RunMocFailed) { - std::cerr << "moc failed..."<< std::endl; + std::cerr << "moc failed..." << std::endl; + return false; + } + + if (this->RunUicFailed) + { + std::cerr << "uic failed..." << std::endl; + return false; + } + if (this->RunRccFailed) + { + std::cerr << "rcc failed..." << std::endl; return false; } outStream.flush(); @@ -818,9 +1431,10 @@ bool cmQtAutomoc::RunAutomoc(cmMakefile* makefile) } -void cmQtAutomoc::ParseCppFile(const std::string& absFilename, +void cmQtAutoGenerators::ParseCppFile(const std::string& absFilename, const std::vector<std::string>& headerExtensions, - std::map<std::string, std::string>& includedMocs) + std::map<std::string, std::string>& includedMocs, + std::vector<std::string> &includedUis) { cmsys::RegularExpression mocIncludeRegExp( "[\n][ \t]*#[ \t]*include[ \t]+" @@ -829,7 +1443,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, const std::string contentsString = this->ReadAll(absFilename); if (contentsString.empty()) { - std::cerr << "AUTOMOC: warning: " << absFilename << ": file is empty\n" + std::cerr << "AUTOGEN: warning: " << absFilename << ": file is empty\n" << std::endl; return; } @@ -837,7 +1451,8 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/'; const std::string scannedFileBasename = cmsys::SystemTools:: GetFilenameWithoutLastExtension(absFilename); - const bool cppContainsQ_OBJECT = containsQ_OBJECT(contentsString); + std::string macroName; + const bool requiresMoc = requiresMocing(contentsString, macroName); bool dotMocIncluded = false; bool mocUnderscoreIncluded = false; std::string ownMocUnderscoreFile; @@ -888,7 +1503,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, } else { - std::cerr << "AUTOMOC: error: " << absFilename << " The file " + std::cerr << "AUTOGEN: error: " << absFilename << " The file " << "includes the moc file \"" << currentMoc << "\", " << "but could not find header \"" << basename << '{' << this->Join(headerExtensions, ',') << "}\" "; @@ -908,7 +1523,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, else { std::string fileToMoc = absFilename; - if ((basename != scannedFileBasename) || (cppContainsQ_OBJECT==false)) + if ((basename != scannedFileBasename) || (requiresMoc==false)) { std::string mocSubDir = extractSubDir(absPath, currentMoc); std::string headerToMoc = findMatchingHeader( @@ -917,12 +1532,12 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, { // this is for KDE4 compatibility: fileToMoc = headerToMoc; - if ((cppContainsQ_OBJECT==false) &&(basename==scannedFileBasename)) + if ((requiresMoc==false) &&(basename==scannedFileBasename)) { - std::cerr << "AUTOMOC: warning: " << absFilename << ": The file " + std::cerr << "AUTOGEN: warning: " << absFilename << ": The file " "includes the moc file \"" << currentMoc << - "\", but does not contain a Q_OBJECT macro. " - "Running moc on " + "\", but does not contain a " << macroName + << " macro. Running moc on " << "\"" << headerToMoc << "\" ! Include \"moc_" << basename << ".cpp\" for a compatiblity with " "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n" @@ -930,7 +1545,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, } else { - std::cerr << "AUTOMOC: warning: " << absFilename << ": The file " + std::cerr << "AUTOGEN: warning: " << absFilename << ": The file " "includes the moc file \"" << currentMoc << "\" instead of \"moc_" << basename << ".cpp\". " "Running moc on " @@ -942,7 +1557,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, } else { - std::cerr <<"AUTOMOC: error: " << absFilename << ": The file " + std::cerr <<"AUTOGEN: error: " << absFilename << ": The file " "includes the moc file \"" << currentMoc << "\", which seems to be the moc file from a different " "source file. CMake also could not find a matching " @@ -960,18 +1575,20 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, matchOffset += mocIncludeRegExp.end(); } while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset)); } + this->ParseForUic(absFilename, contentsString, includedUis); // In this case, check whether the scanned file itself contains a Q_OBJECT. // If this is the case, the moc_foo.cpp should probably be generated from // foo.cpp instead of foo.h, because otherwise it won't build. // But warn, since this is not how it is supposed to be used. - if ((dotMocIncluded == false) && (cppContainsQ_OBJECT == true)) + if ((dotMocIncluded == false) && (requiresMoc == true)) { if (mocUnderscoreIncluded == true) { // this is for KDE4 compatibility: - std::cerr << "AUTOMOC: warning: " << absFilename << ": The file " - << "contains a Q_OBJECT macro, but does not include " + std::cerr << "AUTOGEN: warning: " << absFilename << ": The file " + << "contains a " << macroName << " macro, but does not " + "include " << "\"" << scannedFileBasename << ".moc\", but instead " "includes " << "\"" << ownMocUnderscoreFile << "\". Running moc on " @@ -985,8 +1602,9 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, else { // otherwise always error out since it will not compile: - std::cerr << "AUTOMOC: error: " << absFilename << ": The file " - << "contains a Q_OBJECT macro, but does not include " + std::cerr << "AUTOGEN: error: " << absFilename << ": The file " + << "contains a " << macroName << " macro, but does not " + "include " << "\"" << scannedFileBasename << ".moc\" !\n" << std::endl; ::exit(EXIT_FAILURE); @@ -996,9 +1614,10 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, } -void cmQtAutomoc::StrictParseCppFile(const std::string& absFilename, +void cmQtAutoGenerators::StrictParseCppFile(const std::string& absFilename, const std::vector<std::string>& headerExtensions, - std::map<std::string, std::string>& includedMocs) + std::map<std::string, std::string>& includedMocs, + std::vector<std::string>& includedUis) { cmsys::RegularExpression mocIncludeRegExp( "[\n][ \t]*#[ \t]*include[ \t]+" @@ -1007,7 +1626,7 @@ void cmQtAutomoc::StrictParseCppFile(const std::string& absFilename, const std::string contentsString = this->ReadAll(absFilename); if (contentsString.empty()) { - std::cerr << "AUTOMOC: warning: " << absFilename << ": file is empty\n" + std::cerr << "AUTOGEN: warning: " << absFilename << ": file is empty\n" << std::endl; return; } @@ -1054,7 +1673,7 @@ void cmQtAutomoc::StrictParseCppFile(const std::string& absFilename, } else { - std::cerr << "AUTOMOC: error: " << absFilename << " The file " + std::cerr << "AUTOGEN: error: " << absFilename << " The file " << "includes the moc file \"" << currentMoc << "\", " << "but could not find header \"" << basename << '{' << this->Join(headerExtensions, ',') << "}\" "; @@ -1075,7 +1694,7 @@ void cmQtAutomoc::StrictParseCppFile(const std::string& absFilename, { if (basename != scannedFileBasename) { - std::cerr <<"AUTOMOC: error: " << absFilename << ": The file " + std::cerr <<"AUTOGEN: error: " << absFilename << ": The file " "includes the moc file \"" << currentMoc << "\", which seems to be the moc file from a different " "source file. This is not supported. " @@ -1089,16 +1708,19 @@ void cmQtAutomoc::StrictParseCppFile(const std::string& absFilename, matchOffset += mocIncludeRegExp.end(); } while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset)); } + this->ParseForUic(absFilename, contentsString, includedUis); // In this case, check whether the scanned file itself contains a Q_OBJECT. // If this is the case, the moc_foo.cpp should probably be generated from // foo.cpp instead of foo.h, because otherwise it won't build. // But warn, since this is not how it is supposed to be used. - if ((dotMocIncluded == false) && (containsQ_OBJECT(contentsString))) + std::string macroName; + if ((dotMocIncluded == false) && (requiresMocing(contentsString, + macroName))) { // otherwise always error out since it will not compile: - std::cerr << "AUTOMOC: error: " << absFilename << ": The file " - << "contains a Q_OBJECT macro, but does not include " + std::cerr << "AUTOGEN: error: " << absFilename << ": The file " + << "contains a " << macroName << " macro, but does not include " << "\"" << scannedFileBasename << ".moc\" !\n" << std::endl; ::exit(EXIT_FAILURE); @@ -1107,7 +1729,63 @@ void cmQtAutomoc::StrictParseCppFile(const std::string& absFilename, } -void cmQtAutomoc::SearchHeadersForCppFile(const std::string& absFilename, +void cmQtAutoGenerators::ParseForUic(const std::string& absFilename, + std::vector<std::string>& includedUis) +{ + if (this->UicExecutable.empty()) + { + return; + } + const std::string contentsString = this->ReadAll(absFilename); + if (contentsString.empty()) + { + std::cerr << "AUTOGEN: warning: " << absFilename << ": file is empty\n" + << std::endl; + return; + } + this->ParseForUic(absFilename, contentsString, includedUis); +} + + +void cmQtAutoGenerators::ParseForUic(const std::string&, + const std::string& contentsString, + std::vector<std::string>& includedUis) +{ + if (this->UicExecutable.empty()) + { + return; + } + cmsys::RegularExpression uiIncludeRegExp( + "[\n][ \t]*#[ \t]*include[ \t]+" + "[\"<](([^ \">]+/)?ui_[^ \">/]+\\.h)[\">]"); + + std::string::size_type matchOffset = 0; + + matchOffset = 0; + if ((strstr(contentsString.c_str(), "ui_") != NULL) + && (uiIncludeRegExp.find(contentsString))) + { + do + { + const std::string currentUi = uiIncludeRegExp.match(1); + + std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(currentUi); + + // basename should be the part of the ui filename used for + // finding the correct header, so we need to remove the ui_ part + basename = basename.substr(3); + + includedUis.push_back(basename); + + matchOffset += uiIncludeRegExp.end(); + } while(uiIncludeRegExp.find(contentsString.c_str() + matchOffset)); + } +} + + +void +cmQtAutoGenerators::SearchHeadersForCppFile(const std::string& absFilename, const std::vector<std::string>& headerExtensions, std::set<std::string>& absHeaders) { @@ -1143,40 +1821,41 @@ void cmQtAutomoc::SearchHeadersForCppFile(const std::string& absFilename, } -void cmQtAutomoc::ParseHeaders(const std::set<std::string>& absHeaders, +void cmQtAutoGenerators::ParseHeaders(const std::set<std::string>& absHeaders, const std::map<std::string, std::string>& includedMocs, - std::map<std::string, std::string>& notIncludedMocs) + std::map<std::string, std::string>& notIncludedMocs, + std::vector<std::string>& includedUis) { for(std::set<std::string>::const_iterator hIt=absHeaders.begin(); hIt!=absHeaders.end(); ++hIt) { const std::string& headerName = *hIt; + const std::string contents = this->ReadAll(headerName); if (includedMocs.find(headerName) == includedMocs.end()) { if (this->Verbose) { - std::cout << "AUTOMOC: Checking " << headerName << std::endl; + std::cout << "AUTOGEN: Checking " << headerName << std::endl; } const std::string basename = cmsys::SystemTools:: GetFilenameWithoutLastExtension(headerName); const std::string currentMoc = "moc_" + basename + ".cpp"; - const std::string contents = this->ReadAll(headerName); - if (containsQ_OBJECT(contents)) + std::string macroName; + if (requiresMocing(contents, macroName)) { //std::cout << "header contains Q_OBJECT macro"; notIncludedMocs[headerName] = currentMoc; } } + this->ParseForUic(headerName, contents, includedUis); } - } - -bool cmQtAutomoc::GenerateMoc(const std::string& sourceFile, +bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile, const std::string& mocFileName) { const std::string mocFilePath = this->Builddir + mocFileName; @@ -1242,7 +1921,7 @@ bool cmQtAutomoc::GenerateMoc(const std::string& sourceFile, bool result = cmSystemTools::RunSingleCommand(command, &output, &retVal); if (!result || retVal) { - std::cerr << "AUTOMOC: error: process for " << mocFilePath <<" failed:\n" + std::cerr << "AUTOGEN: error: process for " << mocFilePath <<" failed:\n" << output << std::endl; this->RunMocFailed = true; cmSystemTools::RemoveFile(mocFilePath.c_str()); @@ -1252,8 +1931,152 @@ bool cmQtAutomoc::GenerateMoc(const std::string& sourceFile, return false; } +bool cmQtAutoGenerators::GenerateUi(const std::string& uiFileName) +{ + if (!cmsys::SystemTools::FileExists(this->Builddir.c_str(), false)) + { + cmsys::SystemTools::MakeDirectory(this->Builddir.c_str()); + } + + std::string ui_output_file = "ui_" + uiFileName + ".h"; + std::string ui_input_file = this->Srcdir + uiFileName + ".ui"; + + int sourceNewerThanUi = 0; + bool success = cmsys::SystemTools::FileTimeCompare(ui_input_file.c_str(), + (this->Builddir + ui_output_file).c_str(), + &sourceNewerThanUi); + if (this->GenerateAll || !success || sourceNewerThanUi >= 0) + { + std::string msg = "Generating "; + msg += ui_output_file; + cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue + |cmsysTerminal_Color_ForegroundBold, + msg.c_str(), true, this->ColorOutput); + + std::vector<cmStdString> command; + command.push_back(this->UicExecutable); + + std::string options; + std::vector<std::string> opts = this->UicTargetOptions; + std::map<std::string, std::string>::const_iterator optionIt + = this->UicOptions.find(ui_input_file); + if (optionIt != this->UicOptions.end()) + { + std::vector<std::string> fileOpts; + cmSystemTools::ExpandListArgument(optionIt->second, fileOpts); + this->MergeUicOptions(opts, fileOpts, this->QtMajorVersion == "5"); + } + for(std::vector<std::string>::const_iterator optIt = opts.begin(); + optIt != opts.end(); + ++optIt) + { + command.push_back(*optIt); + } + + command.push_back("-o"); + command.push_back(this->Builddir + ui_output_file); + command.push_back(ui_input_file); + + if (this->Verbose) + { + for(std::vector<cmStdString>::const_iterator cmdIt = command.begin(); + cmdIt != command.end(); + ++cmdIt) + { + std::cout << *cmdIt << " "; + } + std::cout << std::endl; + } + std::string output; + int retVal = 0; + bool result = cmSystemTools::RunSingleCommand(command, &output, &retVal); + if (!result || retVal) + { + std::cerr << "AUTOUIC: error: process for " << ui_output_file << + " failed:\n" << output << std::endl; + this->RunUicFailed = true; + cmSystemTools::RemoveFile(ui_output_file.c_str()); + return false; + } + return true; + } + return false; +} + +bool cmQtAutoGenerators::GenerateQrc() +{ + std::vector<std::string> sourceFiles; + cmSystemTools::ExpandListArgument(this->RccSources, sourceFiles); + + for(std::vector<std::string>::const_iterator si = sourceFiles.begin(); + si != sourceFiles.end(); ++si) + { + std::string ext = cmsys::SystemTools::GetFilenameLastExtension(*si); + + if (ext != ".qrc") + { + continue; + } + std::vector<cmStdString> command; + command.push_back(this->RccExecutable); + + std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(*si); + + std::string rcc_output_file = this->Builddir + "qrc_" + basename + ".cpp"; + + int sourceNewerThanQrc = 0; + bool success = cmsys::SystemTools::FileTimeCompare(si->c_str(), + rcc_output_file.c_str(), + &sourceNewerThanQrc); + if (this->GenerateAll || !success || sourceNewerThanQrc >= 0) + { + std::string options; + std::map<std::string, std::string>::const_iterator optionIt + = this->RccOptions.find(*si); + if (optionIt != this->RccOptions.end()) + { + std::vector<std::string> opts; + cmSystemTools::ExpandListArgument(optionIt->second, opts); + for(std::vector<std::string>::const_iterator optIt = opts.begin(); + optIt != opts.end(); + ++optIt) + { + command.push_back(*optIt); + } + } + + command.push_back("-o"); + command.push_back(rcc_output_file); + command.push_back(*si); + + if (this->Verbose) + { + for(std::vector<cmStdString>::const_iterator cmdIt = command.begin(); + cmdIt != command.end(); + ++cmdIt) + { + std::cout << *cmdIt << " "; + } + std::cout << std::endl; + } + std::string output; + int retVal = 0; + bool result = cmSystemTools::RunSingleCommand(command, &output, &retVal); + if (!result || retVal) + { + std::cerr << "AUTORCC: error: process for " << rcc_output_file << + " failed:\n" << output << std::endl; + this->RunRccFailed = true; + cmSystemTools::RemoveFile(rcc_output_file.c_str()); + return false; + } + } + } + return true; +} -std::string cmQtAutomoc::Join(const std::vector<std::string>& lst, +std::string cmQtAutoGenerators::Join(const std::vector<std::string>& lst, char separator) { if (lst.empty()) @@ -1273,13 +2096,15 @@ std::string cmQtAutomoc::Join(const std::vector<std::string>& lst, } -bool cmQtAutomoc::StartsWith(const std::string& str, const std::string& with) +bool cmQtAutoGenerators::StartsWith(const std::string& str, + const std::string& with) { return (str.substr(0, with.length()) == with); } -bool cmQtAutomoc::EndsWith(const std::string& str, const std::string& with) +bool cmQtAutoGenerators::EndsWith(const std::string& str, + const std::string& with) { if (with.length() > (str.length())) { @@ -1289,9 +2114,9 @@ bool cmQtAutomoc::EndsWith(const std::string& str, const std::string& with) } -std::string cmQtAutomoc::ReadAll(const std::string& filename) +std::string cmQtAutoGenerators::ReadAll(const std::string& filename) { - std::ifstream file(filename.c_str()); + cmsys::ifstream file(filename.c_str()); cmsys_ios::stringstream stream; stream << file.rdbuf(); file.close(); diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutoGenerators.h index ebeeb0e..80123d8 100644 --- a/Source/cmQtAutomoc.h +++ b/Source/cmQtAutoGenerators.h @@ -11,26 +11,35 @@ See the License for more information. ============================================================================*/ -#ifndef cmQtAutomoc_h -#define cmQtAutomoc_h +#ifndef cmQtAutoGenerators_h +#define cmQtAutoGenerators_h class cmGlobalGenerator; class cmMakefile; -class cmQtAutomoc +class cmQtAutoGenerators { public: - cmQtAutomoc(); + cmQtAutoGenerators(); bool Run(const char* targetDirectory, const char *config); - bool InitializeMocSourceFile(cmTarget* target); - void SetupAutomocTarget(cmTarget* target); + bool InitializeAutogenTarget(cmTarget* target); + void SetupAutoGenerateTarget(cmTarget const* target); private: + void SetupAutoMocTarget(cmTarget const* target, + const std::string &autogenTargetName, + std::map<std::string, std::string> &configIncludes, + std::map<std::string, std::string> &configDefines); + void SetupAutoUicTarget(cmTarget const* target, + std::map<std::string, std::string> &configUicOptions); + void InitializeAutoRccTarget(cmTarget* target); + void SetupAutoRccTarget(cmTarget const* target); + cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, const char* targetDirectory); - bool ReadAutomocInfoFile(cmMakefile* makefile, + bool ReadAutogenInfoFile(cmMakefile* makefile, const char* targetDirectory, const char *config); bool ReadOldMocDefinitionsFile(cmMakefile* makefile, @@ -39,22 +48,34 @@ private: std::string MakeCompileSettingsString(cmMakefile* makefile); - bool RunAutomoc(cmMakefile* makefile); + bool RunAutogen(cmMakefile* makefile); bool GenerateMoc(const std::string& sourceFile, const std::string& mocFileName); + bool GenerateUi(const std::string& uiFileName); + bool GenerateQrc(); void ParseCppFile(const std::string& absFilename, const std::vector<std::string>& headerExtensions, - std::map<std::string, std::string>& includedMocs); + std::map<std::string, std::string>& includedMocs, + std::vector<std::string>& includedUis); void StrictParseCppFile(const std::string& absFilename, const std::vector<std::string>& headerExtensions, - std::map<std::string, std::string>& includedMocs); + std::map<std::string, std::string>& includedMocs, + std::vector<std::string>& includedUis); void SearchHeadersForCppFile(const std::string& absFilename, const std::vector<std::string>& headerExtensions, std::set<std::string>& absHeaders); void ParseHeaders(const std::set<std::string>& absHeaders, const std::map<std::string, std::string>& includedMocs, - std::map<std::string, std::string>& notIncludedMocs); + std::map<std::string, std::string>& notIncludedMocs, + std::vector<std::string>& includedUis); + + void ParseForUic(const std::string& fileName, + const std::string& contentsString, + std::vector<std::string>& includedUis); + + void ParseForUic(const std::string& fileName, + std::vector<std::string>& includedUis); void Init(); @@ -63,13 +84,24 @@ private: bool StartsWith(const std::string& str, const std::string& with); std::string ReadAll(const std::string& filename); + void MergeUicOptions(std::vector<std::string> &opts, + const std::vector<std::string> &fileOpts, bool isQt5); + + void MergeRccOptions(std::vector<std::string> &opts, + const std::vector<std::string> &fileOpts, bool isQt5); + std::string QtMajorVersion; std::string Sources; + std::string RccSources; + std::string SkipMoc; + std::string SkipUic; std::string Headers; bool IncludeProjectDirsBefore; std::string Srcdir; std::string Builddir; std::string MocExecutable; + std::string UicExecutable; + std::string RccExecutable; std::string MocCompileDefinitionsStr; std::string MocIncludesStr; std::string MocOptionsStr; @@ -84,10 +116,15 @@ private: std::list<std::string> MocIncludes; std::list<std::string> MocDefinitions; std::vector<std::string> MocOptions; + std::vector<std::string> UicTargetOptions; + std::map<std::string, std::string> UicOptions; + std::map<std::string, std::string> RccOptions; bool Verbose; bool ColorOutput; bool RunMocFailed; + bool RunUicFailed; + bool RunRccFailed; bool GenerateAll; bool RelaxedMode; diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx new file mode 100644 index 0000000..11a9913 --- /dev/null +++ b/Source/cmRST.cxx @@ -0,0 +1,510 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2013 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmRST.h" + +#include "cmSystemTools.h" +#include "cmVersion.h" +#include <cmsys/FStream.hxx> +#include <ctype.h> + +//---------------------------------------------------------------------------- +cmRST::cmRST(std::ostream& os, std::string const& docroot): + OS(os), + DocRoot(docroot), + IncludeDepth(0), + OutputLinePending(false), + LastLineEndedInColonColon(false), + Markup(MarkupNone), + Directive(DirectiveNone), + CMakeDirective("^.. (cmake:)?(" + "command|variable" + ")::[ \t]+([^ \t\n]+)$"), + CMakeModuleDirective("^.. cmake-module::[ \t]+([^ \t\n]+)$"), + ParsedLiteralDirective("^.. parsed-literal::[ \t]*(.*)$"), + CodeBlockDirective("^.. code-block::[ \t]*(.*)$"), + ReplaceDirective("^.. (\\|[^|]+\\|) replace::[ \t]*(.*)$"), + IncludeDirective("^.. include::[ \t]+([^ \t\n]+)$"), + TocTreeDirective("^.. toctree::[ \t]*(.*)$"), + ProductionListDirective("^.. productionlist::[ \t]*(.*)$"), + NoteDirective("^.. note::[ \t]*(.*)$"), + ModuleRST("^#\\[(=*)\\[\\.rst:$"), + CMakeRole("(:cmake)?:(" + "command|generator|variable|module|policy|" + "prop_cache|prop_dir|prop_gbl|prop_sf|prop_test|prop_tgt|" + "manual" + "):`(<*([^`<]|[^` \t]<)*)([ \t]+<[^`]*>)?`"), + Substitution("(^|[^A-Za-z0-9_])" + "((\\|[^| \t\r\n]([^|\r\n]*[^| \t\r\n])?\\|)(__|_|))" + "([^A-Za-z0-9_]|$)") +{ + this->Replace["|release|"] = cmVersion::GetCMakeVersion(); +} + +//---------------------------------------------------------------------------- +bool cmRST::ProcessFile(std::string const& fname, bool isModule) +{ + cmsys::ifstream fin(fname.c_str()); + if(fin) + { + this->DocDir = cmSystemTools::GetFilenamePath(fname); + if(isModule) + { + this->ProcessModule(fin); + } + else + { + this->ProcessRST(fin); + } + this->OutputLinePending = true; + return true; + } + return false; +} + +//---------------------------------------------------------------------------- +void cmRST::ProcessRST(std::istream& is) +{ + std::string line; + while(cmSystemTools::GetLineFromStream(is, line)) + { + this->ProcessLine(line); + } + this->Reset(); +} + +//---------------------------------------------------------------------------- +void cmRST::ProcessModule(std::istream& is) +{ + std::string line; + std::string rst; + while(cmSystemTools::GetLineFromStream(is, line)) + { + if(!rst.empty() && rst != "#") + { + // Bracket mode: check for end bracket + std::string::size_type pos = line.find(rst); + if(pos == line.npos) + { + this->ProcessLine(line); + } + else + { + if(line[0] != '#') + { + this->ProcessLine(line.substr(0, pos)); + } + rst = ""; + this->Reset(); + this->OutputLinePending = true; + } + } + else + { + // Line mode: check for .rst start (bracket or line) + if(rst == "#") + { + if(line == "#") + { + this->ProcessLine(""); + continue; + } + else if(line.substr(0, 2) == "# ") + { + this->ProcessLine(line.substr(2, line.npos)); + continue; + } + else + { + rst = ""; + this->Reset(); + this->OutputLinePending = true; + } + } + if(line == "#.rst:") + { + rst = "#"; + } + else if(this->ModuleRST.find(line)) + { + rst = "]" + this->ModuleRST.match(1) + "]"; + } + } + } + if(rst == "#") + { + this->Reset(); + } +} + +//---------------------------------------------------------------------------- +void cmRST::Reset() +{ + if(!this->MarkupLines.empty()) + { + this->UnindentLines(this->MarkupLines); + } + switch(this->Directive) + { + case DirectiveNone: break; + case DirectiveParsedLiteral: this->ProcessDirectiveParsedLiteral(); break; + case DirectiveLiteralBlock: this->ProcessDirectiveLiteralBlock(); break; + case DirectiveCodeBlock: this->ProcessDirectiveCodeBlock(); break; + case DirectiveReplace: this->ProcessDirectiveReplace(); break; + case DirectiveTocTree: this->ProcessDirectiveTocTree(); break; + } + this->Markup = MarkupNone; + this->Directive = DirectiveNone; + this->MarkupLines.clear(); +} + +//---------------------------------------------------------------------------- +void cmRST::ProcessLine(std::string const& line) +{ + bool lastLineEndedInColonColon = this->LastLineEndedInColonColon; + this->LastLineEndedInColonColon = false; + + // A line starting in .. is an explicit markup start. + if(line == ".." || (line.size() >= 3 && line[0] == '.' && + line[1] == '.' && isspace(line[2]))) + { + this->Reset(); + this->Markup = (line.find_first_not_of(" \t", 2) == line.npos ? + MarkupEmpty : MarkupNormal); + if(this->CMakeDirective.find(line)) + { + // Output cmake domain directives and their content normally. + this->NormalLine(line); + } + else if(this->CMakeModuleDirective.find(line)) + { + // Process cmake-module directive: scan .cmake file comments. + std::string file = this->CMakeModuleDirective.match(1); + if(file.empty() || !this->ProcessInclude(file, IncludeModule)) + { + this->NormalLine(line); + } + } + else if(this->ParsedLiteralDirective.find(line)) + { + // Record the literal lines to output after whole block. + this->Directive = DirectiveParsedLiteral; + this->MarkupLines.push_back(this->ParsedLiteralDirective.match(1)); + } + else if(this->CodeBlockDirective.find(line)) + { + // Record the literal lines to output after whole block. + // Ignore the language spec and record the opening line as blank. + this->Directive = DirectiveCodeBlock; + this->MarkupLines.push_back(""); + } + else if(this->ReplaceDirective.find(line)) + { + // Record the replace directive content. + this->Directive = DirectiveReplace; + this->ReplaceName = this->ReplaceDirective.match(1); + this->MarkupLines.push_back(this->ReplaceDirective.match(2)); + } + else if(this->IncludeDirective.find(line)) + { + // Process the include directive or output the directive and its + // content normally if it fails. + std::string file = this->IncludeDirective.match(1); + if(file.empty() || !this->ProcessInclude(file, IncludeNormal)) + { + this->NormalLine(line); + } + } + else if(this->TocTreeDirective.find(line)) + { + // Record the toctree entries to process after whole block. + this->Directive = DirectiveTocTree; + this->MarkupLines.push_back(this->TocTreeDirective.match(1)); + } + else if(this->ProductionListDirective.find(line)) + { + // Output productionlist directives and their content normally. + this->NormalLine(line); + } + else if(this->NoteDirective.find(line)) + { + // Output note directives and their content normally. + this->NormalLine(line); + } + } + // An explicit markup start followed nothing but whitespace and a + // blank line does not consume any indented text following. + else if(this->Markup == MarkupEmpty && line.empty()) + { + this->NormalLine(line); + } + // Indented lines following an explicit markup start are explicit markup. + else if(this->Markup && (line.empty() || isspace(line[0]))) + { + this->Markup = MarkupNormal; + // Record markup lines if the start line was recorded. + if(!this->MarkupLines.empty()) + { + this->MarkupLines.push_back(line); + } + } + // A blank line following a paragraph ending in "::" starts a literal block. + else if(lastLineEndedInColonColon && line.empty()) + { + // Record the literal lines to output after whole block. + this->Markup = MarkupNormal; + this->Directive = DirectiveLiteralBlock; + this->MarkupLines.push_back(""); + this->OutputLine("", false); + } + // Print non-markup lines. + else + { + this->NormalLine(line); + this->LastLineEndedInColonColon = (line.size() >= 2 + && line[line.size()-2] == ':' && line[line.size()-1] == ':'); + } +} + +//---------------------------------------------------------------------------- +void cmRST::NormalLine(std::string const& line) +{ + this->Reset(); + this->OutputLine(line, true); +} + +//---------------------------------------------------------------------------- +void cmRST::OutputLine(std::string const& line_in, bool inlineMarkup) +{ + if(this->OutputLinePending) + { + this->OS << "\n"; + this->OutputLinePending = false; + } + if(inlineMarkup) + { + std::string line = this->ReplaceSubstitutions(line_in); + std::string::size_type pos = 0; + while(this->CMakeRole.find(line.c_str()+pos)) + { + this->OS << line.substr(pos, this->CMakeRole.start()); + std::string text = this->CMakeRole.match(3); + // If a command reference has no explicit target and + // no explicit "(...)" then add "()" to the text. + if(this->CMakeRole.match(2) == "command" && + this->CMakeRole.match(5).empty() && + text.find_first_of("()") == text.npos) + { + text += "()"; + } + this->OS << "``" << text << "``"; + pos += this->CMakeRole.end(); + } + this->OS << line.substr(pos) << "\n"; + } + else + { + this->OS << line_in << "\n"; + } +} + +//---------------------------------------------------------------------------- +std::string cmRST::ReplaceSubstitutions(std::string const& line) +{ + std::string out; + std::string::size_type pos = 0; + while(this->Substitution.find(line.c_str()+pos)) + { + std::string::size_type start = this->Substitution.start(2); + std::string::size_type end = this->Substitution.end(2); + std::string substitute = this->Substitution.match(3); + std::map<cmStdString, cmStdString>::iterator + replace = this->Replace.find(substitute); + if(replace != this->Replace.end()) + { + std::pair<std::set<cmStdString>::iterator, bool> replaced = + this->Replaced.insert(substitute); + if(replaced.second) + { + substitute = this->ReplaceSubstitutions(replace->second); + this->Replaced.erase(replaced.first); + } + } + out += line.substr(pos, start); + out += substitute; + pos += end; + } + out += line.substr(pos); + return out; +} + +//---------------------------------------------------------------------------- +void cmRST::OutputMarkupLines(bool inlineMarkup) +{ + for(std::vector<std::string>::iterator i = this->MarkupLines.begin(); + i != this->MarkupLines.end(); ++i) + { + std::string line = *i; + if(!line.empty()) + { + line = " " + line; + } + this->OutputLine(line, inlineMarkup); + } + this->OutputLinePending = true; +} + +//---------------------------------------------------------------------------- +bool cmRST::ProcessInclude(std::string file, IncludeType type) +{ + bool found = false; + if(this->IncludeDepth < 10) + { + cmRST r(this->OS, this->DocRoot); + r.IncludeDepth = this->IncludeDepth + 1; + r.OutputLinePending = this->OutputLinePending; + if(type != IncludeTocTree) + { + r.Replace = this->Replace; + } + if(file[0] == '/') + { + file = this->DocRoot + file; + } + else + { + file = this->DocDir + "/" + file; + } + found = r.ProcessFile(file, type == IncludeModule); + if(type != IncludeTocTree) + { + this->Replace = r.Replace; + } + this->OutputLinePending = r.OutputLinePending; + } + return found; +} + +//---------------------------------------------------------------------------- +void cmRST::ProcessDirectiveParsedLiteral() +{ + this->OutputMarkupLines(true); +} + +//---------------------------------------------------------------------------- +void cmRST::ProcessDirectiveLiteralBlock() +{ + this->OutputMarkupLines(false); +} + +//---------------------------------------------------------------------------- +void cmRST::ProcessDirectiveCodeBlock() +{ + this->OutputMarkupLines(false); +} + +//---------------------------------------------------------------------------- +void cmRST::ProcessDirectiveReplace() +{ + // Record markup lines as replacement text. + std::string& replacement = this->Replace[this->ReplaceName]; + const char* sep = ""; + for(std::vector<std::string>::iterator i = this->MarkupLines.begin(); + i != this->MarkupLines.end(); ++i) + { + replacement += sep; + replacement += *i; + sep = " "; + } + this->ReplaceName = ""; +} + +//---------------------------------------------------------------------------- +void cmRST::ProcessDirectiveTocTree() +{ + // Process documents referenced by toctree directive. + for(std::vector<std::string>::iterator i = this->MarkupLines.begin(); + i != this->MarkupLines.end(); ++i) + { + if(!i->empty() && i->find_first_of(":") == i->npos) + { + this->ProcessInclude(*i + ".rst", IncludeTocTree); + } + } +} + +//---------------------------------------------------------------------------- +void cmRST::UnindentLines(std::vector<std::string>& lines) +{ + // Remove the common indentation from the second and later lines. + std::string indentText; + std::string::size_type indentEnd = 0; + bool first = true; + for(size_t i = 1; i < lines.size(); ++i) + { + std::string const& line = lines[i]; + + // Do not consider empty lines. + if(line.empty()) + { + continue; + } + + // Record indentation on first non-empty line. + if(first) + { + first = false; + indentEnd = line.find_first_not_of(" \t"); + indentText = line.substr(0, indentEnd); + continue; + } + + // Truncate indentation to match that on this line. + if(line.size() < indentEnd) + { + indentEnd = line.size(); + } + for(std::string::size_type j = 0; j != indentEnd; ++j) + { + if(line[j] != indentText[j]) + { + indentEnd = j; + break; + } + } + } + + // Update second and later lines. + for(size_t i = 1; i < lines.size(); ++i) + { + std::string& line = lines[i]; + if(!line.empty()) + { + line = line.substr(indentEnd); + } + } + + // Drop leading blank lines. + size_t leadingEmpty = 0; + for(size_t i = 0; i < lines.size() && lines[i].empty(); ++i) + { + ++leadingEmpty; + } + lines.erase(lines.begin(), lines.begin()+leadingEmpty); + + // Drop trailing blank lines. + size_t trailingEmpty = 0; + for(size_t i = lines.size(); i > 0 && lines[i-1].empty(); --i) + { + ++trailingEmpty; + } + lines.erase(lines.end()-trailingEmpty, lines.end()); +} diff --git a/Source/cmRST.h b/Source/cmRST.h new file mode 100644 index 0000000..3356008 --- /dev/null +++ b/Source/cmRST.h @@ -0,0 +1,100 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2013 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef _cmRST_h +#define _cmRST_h + +#include "cmStandardIncludes.h" + +#include <cmsys/RegularExpression.hxx> + +/** \class cmRST + * \brief Perform basic .rst processing for command-line help + * + * This class implements a subset of reStructuredText and Sphinx + * document processing. It is used to print command-line help. + * + * If you modify the capabilities of this class, be sure to update + * the Help/manual/cmake-developer.7.rst documentation and to update + * the Tests/CMakeLib/testRST.(rst|expect) test input and output. + */ +class cmRST +{ +public: + cmRST(std::ostream& os, std::string const& docroot); + bool ProcessFile(std::string const& fname, bool isModule = false); +private: + enum IncludeType + { + IncludeNormal, + IncludeModule, + IncludeTocTree + }; + enum MarkupType + { + MarkupNone, + MarkupNormal, + MarkupEmpty + }; + enum DirectiveType + { + DirectiveNone, + DirectiveParsedLiteral, + DirectiveLiteralBlock, + DirectiveCodeBlock, + DirectiveReplace, + DirectiveTocTree + }; + + void ProcessRST(std::istream& is); + void ProcessModule(std::istream& is); + void Reset(); + void ProcessLine(std::string const& line); + void NormalLine(std::string const& line); + void OutputLine(std::string const& line, bool inlineMarkup); + std::string ReplaceSubstitutions(std::string const& line); + void OutputMarkupLines(bool inlineMarkup); + bool ProcessInclude(std::string file, IncludeType type); + void ProcessDirectiveParsedLiteral(); + void ProcessDirectiveLiteralBlock(); + void ProcessDirectiveCodeBlock(); + void ProcessDirectiveReplace(); + void ProcessDirectiveTocTree(); + static void UnindentLines(std::vector<std::string>& lines); + + std::ostream& OS; + std::string DocRoot; + int IncludeDepth; + bool OutputLinePending; + bool LastLineEndedInColonColon; + MarkupType Markup; + DirectiveType Directive; + cmsys::RegularExpression CMakeDirective; + cmsys::RegularExpression CMakeModuleDirective; + cmsys::RegularExpression ParsedLiteralDirective; + cmsys::RegularExpression CodeBlockDirective; + cmsys::RegularExpression ReplaceDirective; + cmsys::RegularExpression IncludeDirective; + cmsys::RegularExpression TocTreeDirective; + cmsys::RegularExpression ProductionListDirective; + cmsys::RegularExpression NoteDirective; + cmsys::RegularExpression ModuleRST; + cmsys::RegularExpression CMakeRole; + cmsys::RegularExpression Substitution; + + std::vector<std::string> MarkupLines; + std::string DocDir; + std::map<cmStdString, cmStdString> Replace; + std::set<cmStdString> Replaced; + std::string ReplaceName; +}; + +#endif diff --git a/Source/cmRemoveCommand.h b/Source/cmRemoveCommand.h index 5aedc26..ad73908 100644 --- a/Source/cmRemoveCommand.h +++ b/Source/cmRemoveCommand.h @@ -47,26 +47,6 @@ public: */ virtual const char* GetName() const {return "remove";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Deprecated. Use the list(REMOVE_ITEM ) command instead."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " remove(VAR VALUE VALUE ...)\n" - "Removes VALUE from the variable VAR. " - "This is typically used to remove entries from a vector " - "(e.g. semicolon separated list). VALUE is expanded."; - } - /** This command is kept for compatibility with older CMake versions. */ virtual bool IsDiscouraged() const { diff --git a/Source/cmRemoveDefinitionsCommand.h b/Source/cmRemoveDefinitionsCommand.h index 18f6171..4e291fc 100644 --- a/Source/cmRemoveDefinitionsCommand.h +++ b/Source/cmRemoveDefinitionsCommand.h @@ -44,25 +44,6 @@ public: */ virtual const char* GetName() const {return "remove_definitions";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Removes -D define flags added by add_definitions."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " remove_definitions(-DFOO -DBAR ...)\n" - "Removes flags (added by add_definitions) from the compiler command " - "line for sources in the current directory and below."; - } - cmTypeMacro(cmRemoveDefinitionsCommand, cmCommand); }; diff --git a/Source/cmReturnCommand.h b/Source/cmReturnCommand.h index a6e87ef..2822b62 100644 --- a/Source/cmReturnCommand.h +++ b/Source/cmReturnCommand.h @@ -47,32 +47,6 @@ public: */ virtual const char* GetName() const {return "return";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Return from a file, directory or function."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " return()\n" - "Returns from a file, directory or function. When this command is " - "encountered in an included file (via include() or find_package()), " - "it causes processing of the current file to stop and control is " - "returned to the including file. If it is encountered in a file which " - "is not included by another file, e.g. a CMakeLists.txt, control is " - "returned to the parent directory if there is one. " - "If return is called in a function, control is returned to the caller " - "of the function. Note that a macro " - "is not a function and does not handle return like a function does."; - } - cmTypeMacro(cmReturnCommand, cmCommand); }; diff --git a/Source/cmScriptGenerator.cxx b/Source/cmScriptGenerator.cxx index cabe98a..3b6a49b 100644 --- a/Source/cmScriptGenerator.cxx +++ b/Source/cmScriptGenerator.cxx @@ -185,9 +185,9 @@ void cmScriptGenerator::GenerateScriptActionsOnce(std::ostream& os, { // Generate a per-configuration block. std::string config_test = this->CreateConfigTest(this->Configurations); - os << indent << "IF(" << config_test << ")\n"; + os << indent << "if(" << config_test << ")\n"; this->GenerateScriptActions(os, indent.Next()); - os << indent << "ENDIF(" << config_test << ")\n"; + os << indent << "endif(" << config_test << ")\n"; } } @@ -219,7 +219,7 @@ void cmScriptGenerator::GenerateScriptActionsPerConfig(std::ostream& os, { // Generate a per-configuration block. std::string config_test = this->CreateConfigTest(config); - os << indent << (first? "IF(" : "ELSEIF(") << config_test << ")\n"; + os << indent << (first? "if(" : "elseif(") << config_test << ")\n"; this->GenerateScriptForConfig(os, config, indent.Next()); first = false; } @@ -228,10 +228,10 @@ void cmScriptGenerator::GenerateScriptActionsPerConfig(std::ostream& os, { if(this->NeedsScriptNoConfig()) { - os << indent << "ELSE()\n"; + os << indent << "else()\n"; this->GenerateScriptNoConfig(os, indent.Next()); } - os << indent << "ENDIF()\n"; + os << indent << "endif()\n"; } } } diff --git a/Source/cmSeparateArgumentsCommand.h b/Source/cmSeparateArgumentsCommand.h index d62baf7..ce02360 100644 --- a/Source/cmSeparateArgumentsCommand.h +++ b/Source/cmSeparateArgumentsCommand.h @@ -47,43 +47,6 @@ public: */ virtual const char* GetName() const {return "separate_arguments";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return - "Parse space-separated arguments into a semicolon-separated list."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " separate_arguments(<var> <UNIX|WINDOWS>_COMMAND \"<args>\")\n" - "Parses a unix- or windows-style command-line string \"<args>\" and " - "stores a semicolon-separated list of the arguments in <var>. " - "The entire command line must be given in one \"<args>\" argument." - "\n" - "The UNIX_COMMAND mode separates arguments by unquoted whitespace. " - "It recognizes both single-quote and double-quote pairs. " - "A backslash escapes the next literal character (\\\" is \"); " - "there are no special escapes (\\n is just n)." - "\n" - "The WINDOWS_COMMAND mode parses a windows command-line using the " - "same syntax the runtime library uses to construct argv at startup. " - "It separates arguments by whitespace that is not double-quoted. " - "Backslashes are literal unless they precede double-quotes. " - "See the MSDN article \"Parsing C Command-Line Arguments\" for details." - "\n" - " separate_arguments(VARIABLE)\n" - "Convert the value of VARIABLE to a semi-colon separated list. " - "All spaces are replaced with ';'. This helps with generating " - "command lines."; - } - cmTypeMacro(cmSeparateArgumentsCommand, cmCommand); }; diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index 20f38be..36363a1 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -23,7 +23,7 @@ bool cmSetCommand // watch for ENV signatures const char* variable = args[0].c_str(); // VAR is always first - if (!strncmp(variable,"ENV{",4) && strlen(variable) > 5) + if (cmHasLiteralPrefix(variable, "ENV{") && strlen(variable) > 5) { // what is the variable name char *varName = new char [strlen(variable)]; @@ -62,9 +62,17 @@ bool cmSetCommand this->Makefile->RemoveDefinition(args[0].c_str()); return true; } + // SET (VAR PARENT_SCOPE) // Removes the definition of VAR + // in the parent scope. + else if (args.size() == 2 && args[args.size()-1] == "PARENT_SCOPE") + { + this->Makefile->RaiseScope(variable, 0); + return true; + } // here are the remaining options // SET (VAR value ) + // SET (VAR value PARENT_SCOPE) // SET (VAR CACHE TYPE "doc String" [FORCE]) // SET (VAR value CACHE TYPE "doc string" [FORCE]) std::string value; // optional @@ -114,15 +122,8 @@ bool cmSetCommand if (parentScope) { - if (value.empty()) - { - this->Makefile->RaiseScope(variable, 0); - } - else - { - this->Makefile->RaiseScope(variable, value.c_str()); - } - return true; + this->Makefile->RaiseScope(variable, value.c_str()); + return true; } diff --git a/Source/cmSetCommand.h b/Source/cmSetCommand.h index fe1d58d..6cef0a0 100644 --- a/Source/cmSetCommand.h +++ b/Source/cmSetCommand.h @@ -47,114 +47,6 @@ public: */ virtual const char* GetName() const {return "set";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Set a CMake, cache or environment variable to a given value."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " set(<variable> <value>\n" - " [[CACHE <type> <docstring> [FORCE]] | PARENT_SCOPE])\n" - "Within CMake sets <variable> to the value <value>. " - "<value> is expanded before <variable> is set to it. " - "Normally, set will set a regular CMake variable. " - "If CACHE is present, then the <variable> is put in the cache " - "instead, unless it is already in the cache. " - "See section 'Variable types in CMake' below for details of " - "regular and cache variables and their interactions. " - "If CACHE is used, <type> and <docstring> are required. <type> is used " - "by the CMake GUI to choose a widget with which the user sets a value. " - "The value for <type> may be one of\n" - " FILEPATH = File chooser dialog.\n" - " PATH = Directory chooser dialog.\n" - " STRING = Arbitrary string.\n" - " BOOL = Boolean ON/OFF checkbox.\n" - " INTERNAL = No GUI entry (used for persistent variables).\n" - "If <type> is INTERNAL, the cache variable is marked as internal, " - "and will not be shown to the user in tools like cmake-gui. " - "This is intended for values that should be persisted in the cache, " - "but which users should not normally change. INTERNAL implies FORCE." - "\n" - "Normally, set(...CACHE...) creates cache variables, but does not " - "modify them. " - "If FORCE is specified, the value of the cache variable is set, even " - "if the variable is already in the cache. This should normally be " - "avoided, as it will remove any changes to the cache variable's value " - "by the user.\n" - "If PARENT_SCOPE is present, the variable will be set in the scope " - "above the current scope. Each new directory or function creates a new " - "scope. This command will set the value of a variable into the parent " - "directory or calling function (whichever is applicable to the case at " - "hand). PARENT_SCOPE cannot be combined with CACHE.\n" - "If <value> is not specified then the variable is removed " - "instead of set. See also: the unset() command.\n" - " set(<variable> <value1> ... <valueN>)\n" - "In this case <variable> is set to a semicolon separated list of " - "values.\n" - "<variable> can be an environment variable such as:\n" - " set( ENV{PATH} /home/martink )\n" - "in which case the environment variable will be set.\n" - "*** Variable types in CMake ***\n" - "In CMake there are two types of variables: normal variables and cache " - "variables. Normal variables are meant for the internal use of the " - "script (just like variables in most programming languages); they are " - "not persisted across CMake runs. " - "Cache variables (unless set with INTERNAL) are mostly intended for " - "configuration settings where the first CMake run determines a " - "suitable default value, which the user can then override, by editing " - "the cache with tools such as ccmake or cmake-gui. " - "Cache variables are stored in the CMake cache file, and " - "are persisted across CMake runs. \n" - "Both types can exist at the same time with the same name " - "but different values. " - "When ${FOO} is evaluated, CMake first looks for " - "a normal variable 'FOO' in scope and uses it if set. " - "If and only if no normal variable exists then it falls back to the " - "cache variable 'FOO'.\n" - "Some examples:\n" - "The code 'set(FOO \"x\")' sets the normal variable 'FOO'. It does not " - "touch the cache, but it will hide any existing cache value 'FOO'.\n" - "The code 'set(FOO \"x\" CACHE ...)' checks for 'FOO' in the cache, " - "ignoring any normal variable of the same name. If 'FOO' is in the " - "cache then nothing happens to either the normal variable or the cache " - "variable. If 'FOO' is not in the cache, then it is added to the " - "cache.\n" - "Finally, whenever a cache variable is added or modified by a command, " - "CMake also *removes* the normal variable of the same name from the " - "current scope so that an immediately following evaluation of " - "it will expose the newly cached value.\n" - "Normally projects should avoid using normal and cache variables of " - "the same name, as this interaction can be hard to follow. " - "However, in some situations it can be useful. " - "One example (used by some projects):" - "\n" - "A project has a subproject in its source tree. The child project has " - "its own CMakeLists.txt, which is included from the parent " - "CMakeLists.txt using add_subdirectory(). " - "Now, if the parent and the child project provide the same option " - "(for example a compiler option), the parent gets the first chance " - "to add a user-editable option to the cache. " - "Normally, the child would then use the same value " - "that the parent uses. " - "However, it may be necessary to hard-code the value for the child " - "project's option while still allowing the user to edit the value used " - "by the parent project. The parent project can achieve this simply by " - "setting a normal variable with the same name as the option in a scope " - "sufficient to hide the option's cache variable from the child " - "completely. The parent has already set the cache variable, so the " - "child's set(...CACHE...) will do nothing, and evaluating the option " - "variable will use the value from the normal variable, which hides the " - "cache variable."; - } - cmTypeMacro(cmSetCommand, cmCommand); }; diff --git a/Source/cmSetDirectoryPropertiesCommand.h b/Source/cmSetDirectoryPropertiesCommand.h index 8a50c60..6240598 100644 --- a/Source/cmSetDirectoryPropertiesCommand.h +++ b/Source/cmSetDirectoryPropertiesCommand.h @@ -40,14 +40,6 @@ public: virtual const char* GetName() const { return "set_directory_properties";} /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Set a property of the directory."; - } - - /** * Static entry point for use by other commands */ static bool RunCommand(cmMakefile *mf, @@ -55,21 +47,6 @@ public: std::vector<std::string>::const_iterator aitend, std::string &errors); - /** - * Longer documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " set_directory_properties(PROPERTIES prop1 value1 prop2 value2)\n" - "Set a property for the current directory and subdirectories. If the " - "property is not found, CMake will report an error. The properties " - "include: INCLUDE_DIRECTORIES, LINK_DIRECTORIES, " - "INCLUDE_REGULAR_EXPRESSION, and ADDITIONAL_MAKE_CLEAN_FILES. " - "ADDITIONAL_MAKE_CLEAN_FILES is a list of files that will be cleaned " - "as a part of \"make clean\" stage."; - } - cmTypeMacro(cmSetDirectoryPropertiesCommand, cmCommand); }; diff --git a/Source/cmSetPropertyCommand.h b/Source/cmSetPropertyCommand.h index 830299d..5470314 100644 --- a/Source/cmSetPropertyCommand.h +++ b/Source/cmSetPropertyCommand.h @@ -37,53 +37,6 @@ public: virtual const char* GetName() const { return "set_property";} /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Set a named property in a given scope."; - } - - /** - * Longer documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " set_property(<GLOBAL |\n" - " DIRECTORY [dir] |\n" - " TARGET [target1 [target2 ...]] |\n" - " SOURCE [src1 [src2 ...]] |\n" - " TEST [test1 [test2 ...]] |\n" - " CACHE [entry1 [entry2 ...]]>\n" - " [APPEND] [APPEND_STRING]\n" - " PROPERTY <name> [value1 [value2 ...]])\n" - "Set one property on zero or more objects of a scope. " - "The first argument determines the scope in which the property " - "is set. It must be one of the following:\n" - "GLOBAL scope is unique and does not accept a name.\n" - "DIRECTORY scope defaults to the current directory but another " - "directory (already processed by CMake) may be named by full or " - "relative path.\n" - "TARGET scope may name zero or more existing targets.\n" - "SOURCE scope may name zero or more source files. " - "Note that source file properties are visible only to targets " - "added in the same directory (CMakeLists.txt).\n" - "TEST scope may name zero or more existing tests.\n" - "CACHE scope must name zero or more cache existing entries.\n" - "The required PROPERTY option is immediately followed by the name " - "of the property to set. Remaining arguments are used to " - "compose the property value in the form of a semicolon-separated " - "list. " - "If the APPEND option is given the list is appended to any " - "existing property value." - "If the APPEND_STRING option is given the string is append to any " - "existing property value as string, i.e. it results in a longer " - "string and not a list of strings." - ; - } - - /** * This determines if the command is invoked when in script mode. */ virtual bool IsScriptable() const { return true; } diff --git a/Source/cmSetSourceFilesPropertiesCommand.h b/Source/cmSetSourceFilesPropertiesCommand.h index f7009e7..8541a96 100644 --- a/Source/cmSetSourceFilesPropertiesCommand.h +++ b/Source/cmSetSourceFilesPropertiesCommand.h @@ -34,31 +34,6 @@ public: */ virtual const char* GetName() const { return "set_source_files_properties";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Source files can have properties that affect how they are built."; - } - - /** - * Longer documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " set_source_files_properties([file1 [file2 [...]]]\n" - " PROPERTIES prop1 value1\n" - " [prop2 value2 [...]])\n" - "Set properties associated with source files using a key/value " - "paired list. " - "See properties documentation for those known to CMake. " - "Unrecognized properties are ignored. " - "Source file properties are visible only to targets " - "added in the same directory (CMakeLists.txt)."; - } - cmTypeMacro(cmSetSourceFilesPropertiesCommand, cmCommand); static bool RunCommand(cmMakefile *mf, diff --git a/Source/cmSetTargetPropertiesCommand.h b/Source/cmSetTargetPropertiesCommand.h index cf9c193..6221a18 100644 --- a/Source/cmSetTargetPropertiesCommand.h +++ b/Source/cmSetTargetPropertiesCommand.h @@ -35,133 +35,12 @@ public: virtual const char* GetName() const { return "set_target_properties";} /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Targets can have properties that affect how they are built."; - } - - /** * Used by this command and cmSetPropertiesCommand */ static bool SetOneTarget(const char *tname, std::vector<std::string> &propertyPairs, cmMakefile *mf); - /** - * Longer documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " set_target_properties(target1 target2 ...\n" - " PROPERTIES prop1 value1\n" - " prop2 value2 ...)\n" - "Set properties on a target. The syntax for the command is to " - "list all the files you want " - "to change, and then provide the values you want to set next. " - "You can use any prop value pair you want and " - "extract it later with the GET_TARGET_PROPERTY command.\n" - "Properties that affect the name of a target's output file are " - "as follows. " - "The PREFIX and SUFFIX properties override the default target name " - "prefix (such as \"lib\") and suffix (such as \".so\"). " - "IMPORT_PREFIX and IMPORT_SUFFIX are the equivalent properties for " - "the import library corresponding to a DLL " - "(for SHARED library targets). " - "OUTPUT_NAME sets the real name of a target when it is built and " - "can be used to help create two targets of the same name even though " - "CMake requires unique logical target names. There is also a " - "<CONFIG>_OUTPUT_NAME that can set the output name on a " - "per-configuration basis. " - "<CONFIG>_POSTFIX sets a postfix for the real name of the target " - "when it is built under the configuration named by <CONFIG> " - "(in upper-case, such as \"DEBUG_POSTFIX\"). The value of " - "this property is initialized when the target is created to the " - "value of the variable CMAKE_<CONFIG>_POSTFIX (except for executable " - "targets because earlier CMake versions which did not use this " - "variable for executables)." - "\n" - "The LINK_FLAGS property can be used to add extra flags to the " - "link step of a target. LINK_FLAGS_<CONFIG> will add to the " - "configuration <CONFIG>, " - "for example, DEBUG, RELEASE, MINSIZEREL, RELWITHDEBINFO. " - "DEFINE_SYMBOL sets the name of the preprocessor symbol defined when " - "compiling sources in a shared library. " - "If not set here then it is set to target_EXPORTS by default " - "(with some substitutions if the target is not a valid C " - "identifier). This is useful for headers to know whether they are " - "being included from inside their library or outside to properly " - "setup dllexport/dllimport decorations. " - "The COMPILE_FLAGS property sets additional compiler flags used " - "to build sources within the target. It may also be used to pass " - "additional preprocessor definitions." - "\n" - "The LINKER_LANGUAGE property is used to change the tool " - "used to link an executable or shared library. The default is " - "set the language to match the files in the library. CXX and C " - "are common values for this property." - "\n" - "For shared libraries VERSION and SOVERSION can be used to specify " - "the build version and API version respectively. When building or " - "installing appropriate symlinks are created if the platform " - "supports symlinks and the linker supports so-names. " - "If only one of both is specified the missing is assumed to have " - "the same version number. " - "For executables VERSION can be used to specify the build version. " - "When building or installing appropriate symlinks are created if " - "the platform supports symlinks. " - "For shared libraries and executables on Windows the VERSION " - "attribute is parsed to extract a \"major.minor\" version number. " - "These numbers are used as the image version of the binary. " - "\n" - "There are a few properties used to specify RPATH rules. " - "INSTALL_RPATH is a semicolon-separated list specifying the rpath " - "to use in installed targets (for platforms that support it). " - "INSTALL_RPATH_USE_LINK_PATH is a boolean that if set to true will " - "append directories in the linker search path and outside the " - "project to the INSTALL_RPATH. " - "SKIP_BUILD_RPATH is a boolean specifying whether to skip automatic " - "generation of an rpath allowing the target to run from the " - "build tree. " - "BUILD_WITH_INSTALL_RPATH is a boolean specifying whether to link " - "the target in the build tree with the INSTALL_RPATH. This takes " - "precedence over SKIP_BUILD_RPATH and avoids the need for relinking " - "before installation. INSTALL_NAME_DIR is a string specifying the " - "directory portion of the \"install_name\" field of shared libraries " - "on Mac OSX to use in the installed targets. " - "When the target is created the values of " - "the variables CMAKE_INSTALL_RPATH, " - "CMAKE_INSTALL_RPATH_USE_LINK_PATH, CMAKE_SKIP_BUILD_RPATH, " - "CMAKE_BUILD_WITH_INSTALL_RPATH, and CMAKE_INSTALL_NAME_DIR " - "are used to initialize these properties.\n" - "PROJECT_LABEL can be used to change the name of " - "the target in an IDE like visual studio. VS_KEYWORD can be set " - "to change the visual studio keyword, for example Qt integration " - "works better if this is set to Qt4VSv1.0.\n" - "VS_SCC_PROJECTNAME, VS_SCC_LOCALPATH, VS_SCC_PROVIDER and " - "VS_SCC_AUXPATH can be set " - "to add support for source control bindings in a Visual Studio " - "project file.\n" - "VS_GLOBAL_<variable> can be set to add a Visual Studio " - "project-specific global variable. " - "Qt integration works better if VS_GLOBAL_QtVersion is set to " - "the Qt version FindQt4.cmake found. For example, \"4.7.3\"\n" - "The PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT properties are the " - "old way to specify CMake scripts to run before and after " - "installing a target. They are used only when the old " - "INSTALL_TARGETS command is used to install the target. Use the " - "INSTALL command instead." - "\n" - "The EXCLUDE_FROM_DEFAULT_BUILD property is used by the visual " - "studio generators. If it is set to 1 the target will not be " - "part of the default build when you select \"Build Solution\". " - "This can also be set on a per-configuration basis using " - "EXCLUDE_FROM_DEFAULT_BUILD_<CONFIG>." - ; - } - cmTypeMacro(cmSetTargetPropertiesCommand, cmCommand); }; diff --git a/Source/cmSetTestsPropertiesCommand.h b/Source/cmSetTestsPropertiesCommand.h index 3a59218..9e85495 100644 --- a/Source/cmSetTestsPropertiesCommand.h +++ b/Source/cmSetTestsPropertiesCommand.h @@ -34,40 +34,6 @@ public: */ virtual const char* GetName() const { return "set_tests_properties";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Set a property of the tests."; - } - - /** - * Longer documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " set_tests_properties(test1 [test2...] PROPERTIES prop1 value1 prop2" - " value2)\n" - "Set a property for the tests. If the property is not found, CMake " - "will report an error. The properties include:\n" - "WILL_FAIL: If set to true, this will invert the pass/fail flag of the" - " test.\n" - "PASS_REGULAR_EXPRESSION: If set, the test output will be checked " - "against the specified regular expressions and at least one of the" - " regular " - "expressions has to match, otherwise the test will fail.\n" - " Example: PASS_REGULAR_EXPRESSION \"TestPassed;All ok\"\n" - "FAIL_REGULAR_EXPRESSION: If set, if the output will match to one of " - "specified regular expressions, the test will fail.\n" - " Example: PASS_REGULAR_EXPRESSION \"[^a-z]Error;ERROR;Failed\"\n" - "Both PASS_REGULAR_EXPRESSION and FAIL_REGULAR_EXPRESSION expect a " - "list of regular expressions.\n" - "TIMEOUT: Setting this will limit the test runtime to the number of " - "seconds specified.\n"; - } - cmTypeMacro(cmSetTestsPropertiesCommand, cmCommand); static bool SetOneTest(const char *tname, diff --git a/Source/cmSiteNameCommand.h b/Source/cmSiteNameCommand.h index 52a63bc..eb9d4d8 100644 --- a/Source/cmSiteNameCommand.h +++ b/Source/cmSiteNameCommand.h @@ -47,23 +47,6 @@ public: */ virtual const char* GetName() const {return "site_name";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Set the given variable to the name of the computer."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " site_name(variable)\n"; - } - cmTypeMacro(cmSiteNameCommand, cmCommand); }; diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 8bb7d96..ec98c2c 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -16,7 +16,6 @@ #include "cmMakefile.h" #include "cmSystemTools.h" #include "cmake.h" -#include "cmDocumentCompileDefinitions.h" //---------------------------------------------------------------------------- cmSourceFile::cmSourceFile(cmMakefile* mf, const char* name): @@ -288,6 +287,17 @@ void cmSourceFile::SetProperty(const char* prop, const char* value) } this->Properties.SetProperty(prop, value, cmProperty::SOURCE_FILE); + + std::string ext = + cmSystemTools::GetFilenameLastExtension(this->Location.GetName()); + if (ext == ".ui") + { + cmMakefile* mf = this->Location.GetMakefile(); + if (strcmp(prop, "AUTOUIC_OPTIONS") == 0) + { + mf->AddQtUiFileWithOptions(this); + } + } } //---------------------------------------------------------------------------- @@ -382,176 +392,3 @@ void cmSourceFile::SetCustomCommand(cmCustomCommand* cc) this->CustomCommand = cc; delete old; } - -//---------------------------------------------------------------------------- -void cmSourceFile::DefineProperties(cmake *cm) -{ - // define properties - cm->DefineProperty - ("ABSTRACT", cmProperty::SOURCE_FILE, - "Is this source file an abstract class.", - "A property on a source file that indicates if the source file " - "represents a class that is abstract. This only makes sense for " - "languages that have a notion of an abstract class and it is " - "only used by some tools that wrap classes into other languages."); - - cm->DefineProperty - ("COMPILE_FLAGS", cmProperty::SOURCE_FILE, - "Additional flags to be added when compiling this source file.", - "These flags will be added to the list of compile flags when " - "this source file builds. Use COMPILE_DEFINITIONS to pass additional " - "preprocessor definitions."); - - cm->DefineProperty - ("COMPILE_DEFINITIONS", cmProperty::SOURCE_FILE, - "Preprocessor definitions for compiling a source file.", - "The COMPILE_DEFINITIONS property may be set to a " - "semicolon-separated list of preprocessor " - "definitions using the syntax VAR or VAR=value. Function-style " - "definitions are not supported. CMake will automatically escape " - "the value correctly for the native build system (note that CMake " - "language syntax may require escapes to specify some values). " - "This property may be set on a per-configuration basis using the name " - "COMPILE_DEFINITIONS_<CONFIG> where <CONFIG> is an upper-case name " - "(ex. \"COMPILE_DEFINITIONS_DEBUG\").\n" - "CMake will automatically drop some definitions that " - "are not supported by the native build tool. " - "The VS6 IDE does not support definition values with spaces " - "(but NMake does). Xcode does not support per-configuration " - "definitions on source files.\n" - CM_DOCUMENT_COMPILE_DEFINITIONS_DISCLAIMER); - - cm->DefineProperty - ("COMPILE_DEFINITIONS_<CONFIG>", cmProperty::SOURCE_FILE, - "Per-configuration preprocessor definitions on a source file.", - "This is the configuration-specific version of " - "COMPILE_DEFINITIONS. Note that Xcode does not support " - "per-configuration source file flags so this property will " - "be ignored by the Xcode generator."); - - cm->DefineProperty - ("EXTERNAL_OBJECT", cmProperty::SOURCE_FILE, - "If set to true then this is an object file.", - "If this property is set to true then the source file " - "is really an object file and should not be compiled. " - "It will still be linked into the target though."); - - cm->DefineProperty - ("Fortran_FORMAT", cmProperty::SOURCE_FILE, - "Set to FIXED or FREE to indicate the Fortran source layout.", - "This property tells CMake whether a given Fortran source file " - "uses fixed-format or free-format. " - "CMake will pass the corresponding format flag to the compiler. " - "Consider using the target-wide Fortran_FORMAT property if all " - "source files in a target share the same format."); - - cm->DefineProperty - ("GENERATED", cmProperty::SOURCE_FILE, - "Is this source file generated as part of the build process.", - "If a source file is generated by the build process CMake will " - "handle it differently in terms of dependency checking etc. " - "Otherwise having a non-existent source file could create problems."); - - cm->DefineProperty - ("HEADER_FILE_ONLY", cmProperty::SOURCE_FILE, - "Is this source file only a header file.", - "A property on a source file that indicates if the source file " - "is a header file with no associated implementation. This is " - "set automatically based on the file extension and is used by " - "CMake to determine if certain dependency information should be " - "computed."); - - cm->DefineProperty - ("KEEP_EXTENSION", cmProperty::SOURCE_FILE, - "Make the output file have the same extension as the source file.", - "If this property is set then the file extension of the output " - "file will be the same as that of the source file. Normally " - "the output file extension is computed based on the language " - "of the source file, for example .cxx will go to a .o extension."); - - cm->DefineProperty - ("LABELS", cmProperty::SOURCE_FILE, - "Specify a list of text labels associated with a source file.", - "This property has meaning only when the source file is listed in " - "a target whose LABELS property is also set. " - "No other semantics are currently specified."); - - cm->DefineProperty - ("LANGUAGE", cmProperty::SOURCE_FILE, - "What programming language is the file.", - "A property that can be set to indicate what programming language " - "the source file is. If it is not set the language is determined " - "based on the file extension. Typical values are CXX C etc. Setting " - "this property for a file means this file will be compiled. " - "Do not set this for headers or files that should not be compiled."); - - cm->DefineProperty - ("LOCATION", cmProperty::SOURCE_FILE, - "The full path to a source file.", - "A read only property on a SOURCE FILE that contains the full path " - "to the source file."); - - cm->DefineProperty - ("MACOSX_PACKAGE_LOCATION", cmProperty::SOURCE_FILE, - "Place a source file inside a Mac OS X bundle, CFBundle, or framework.", - "Executable targets with the MACOSX_BUNDLE property set are built " - "as Mac OS X application bundles on Apple platforms. " - "Shared library targets with the FRAMEWORK property set are built " - "as Mac OS X frameworks on Apple platforms. " - "Module library targets with the BUNDLE property set are built " - "as Mac OS X CFBundle bundles on Apple platforms. " - "Source files listed in the target with this property set will " - "be copied to a directory inside the bundle or framework content " - "folder specified by the property value. " - "For bundles the content folder is \"<name>.app/Contents\". " - "For frameworks the content folder is " - "\"<name>.framework/Versions/<version>\". " - "For cfbundles the content folder is " - "\"<name>.bundle/Contents\" (unless the extension is changed). " - "See the PUBLIC_HEADER, PRIVATE_HEADER, and RESOURCE target " - "properties for specifying files meant for Headers, PrivateHeaders, " - "or Resources directories."); - - cm->DefineProperty - ("OBJECT_DEPENDS", cmProperty::SOURCE_FILE, - "Additional files on which a compiled object file depends.", - "Specifies a semicolon-separated list of full-paths to files on which " - "any object files compiled from this source file depend. " - "An object file will be recompiled if any of the named files is newer " - "than it.\n" - "This property need not be used to specify the dependency of a " - "source file on a generated header file that it includes. " - "Although the property was originally introduced for this purpose, it " - "is no longer necessary. " - "If the generated header file is created by a custom command in the " - "same target as the source file, the automatic dependency scanning " - "process will recognize the dependency. " - "If the generated header file is created by another target, an " - "inter-target dependency should be created with the add_dependencies " - "command (if one does not already exist due to linking relationships)."); - - cm->DefineProperty - ("OBJECT_OUTPUTS", cmProperty::SOURCE_FILE, - "Additional outputs for a Makefile rule.", - "Additional outputs created by compilation of this source file. " - "If any of these outputs is missing the object will be recompiled. " - "This is supported only on Makefile generators and will be ignored " - "on other generators."); - - cm->DefineProperty - ("SYMBOLIC", cmProperty::SOURCE_FILE, - "Is this just a name for a rule.", - "If SYMBOLIC (boolean) is set to true the build system will be " - "informed that the source file is not actually created on disk but " - "instead used as a symbolic name for a build rule."); - - cm->DefineProperty - ("WRAP_EXCLUDE", cmProperty::SOURCE_FILE, - "Exclude this source file from any code wrapping techniques.", - "Some packages can wrap source files into alternate languages " - "to provide additional functionality. For example, C++ code " - "can be wrapped into Java or Python etc using SWIG etc. " - "If WRAP_EXCLUDE is set to true (1 etc) that indicates that " - "this source file should not be wrapped."); -} - diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index 6c68b87..4440b05 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -90,9 +90,6 @@ public: // Get the properties cmPropertyMap &GetProperties() { return this->Properties; }; - // Define the properties - static void DefineProperties(cmake *cm); - /** * Check whether the given source file location could refer to this * source. diff --git a/Source/cmSourceGroupCommand.h b/Source/cmSourceGroupCommand.h index 9f6b7e4..5d8b48c 100644 --- a/Source/cmSourceGroupCommand.h +++ b/Source/cmSourceGroupCommand.h @@ -43,36 +43,6 @@ public: */ virtual const char* GetName() const {return "source_group";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Define a grouping for sources in the makefile."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " source_group(name [REGULAR_EXPRESSION regex] " - "[FILES src1 src2 ...])\n" - "Defines a group into which sources will be placed in project files. " - "This is mainly used to setup file tabs in Visual Studio. " - "Any file whose name is listed or matches the regular expression will " - "be placed in this group. If a file matches multiple groups, the LAST " - "group that explicitly lists the file will be favored, if any. If no " - "group explicitly lists the file, the LAST group whose regular " - "expression matches the file will be favored.\n" - "The name of the group may contain backslashes to specify subgroups:\n" - " source_group(outer\\\\inner ...)\n" - "For backwards compatibility, this command also supports the " - "format:\n" - " source_group(name regex)"; - } - cmTypeMacro(cmSourceGroupCommand, cmCommand); }; diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index a4aec2e..ebfa8f9 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -321,14 +321,12 @@ struct cmDocumentationEntry { std::string Name; std::string Brief; - std::string Full; cmDocumentationEntry(){}; - cmDocumentationEntry(const char *doc[3]) + cmDocumentationEntry(const char *doc[2]) { if (doc[0]) this->Name = doc[0]; - if (doc[1]) this->Brief = doc[1]; - if (doc[2]) this->Full = doc[2]; }; - cmDocumentationEntry(const char *n, const char *b, const char *f) - { if (n) this->Name = n; if (b) this->Brief = b; if (f) this->Full = f; }; + if (doc[1]) this->Brief = doc[1];}; + cmDocumentationEntry(const char *n, const char *b) + { if (n) this->Name = n; if (b) this->Brief = b; }; }; /** Data structure to represent a single command line. */ @@ -379,6 +377,90 @@ static thisClass* SafeDownCast(cmObject *c) \ return 0;\ } +inline bool cmHasLiteralPrefixImpl(const std::string &str1, + const char *str2, + size_t N) +{ + return strncmp(str1.c_str(), str2, N) == 0; +} + +inline bool cmHasLiteralPrefixImpl(const char* str1, + const char *str2, + size_t N) +{ + return strncmp(str1, str2, N) == 0; +} + +inline bool cmHasLiteralSuffixImpl(const std::string &str1, + const char *str2, + size_t N) +{ + size_t len = str1.size(); + return len >= N && strcmp(str1.c_str() + len - N, str2) == 0; +} + +inline bool cmHasLiteralSuffixImpl(const char* str1, + const char* str2, + size_t N) +{ + size_t len = strlen(str1); + return len >= N && strcmp(str1 + len - N, str2) == 0; +} + +#if defined(_MSC_VER) && _MSC_VER < 1300 \ + || defined(__GNUC__) && __GNUC__ < 3 \ + || defined(__BORLANDC__) + +#define cmArrayBegin(a) a +#define cmArraySize(a) (sizeof(a)/sizeof(*a)) +#define cmArrayEnd(a) a + cmArraySize(a) + +#define cmHasLiteralPrefix(STR1, STR2) \ + cmHasLiteralPrefixImpl(STR1, "" STR2 "", sizeof(STR2) - 1) + +#define cmHasLiteralSuffix(STR1, STR2) \ + cmHasLiteralSuffixImpl(STR1, "" STR2 "", sizeof(STR2) - 1) + +#else +template<typename T, size_t N> +const T* cmArrayBegin(const T (&a)[N]) { return a; } +template<typename T, size_t N> +const T* cmArrayEnd(const T (&a)[N]) { return a + N; } +template<typename T, size_t N> +size_t cmArraySize(const T (&)[N]) { return N; } + +template<typename T, size_t N> +bool cmHasLiteralPrefix(T str1, const char (&str2)[N]) +{ + return cmHasLiteralPrefixImpl(str1, str2, N - 1); +} + +template<typename T, size_t N> +bool cmHasLiteralSuffix(T str1, const char (&str2)[N]) +{ + return cmHasLiteralSuffixImpl(str1, str2, N - 1); +} + +#endif + +struct cmStrCmp { + cmStrCmp(const char *test) : m_test(test) {} + cmStrCmp(std::string &test) : m_test(test.c_str()) {} + + bool operator()(const char * input) const + { + return strcmp(input, m_test) == 0; + } + + // For use with binary_search + bool operator()(const char *str1, const char *str2) const + { + return strcmp(str1, str2) < 0; + } + +private: + const char * const m_test; +}; #endif diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 68ba13f..f9b69e3 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -73,6 +73,10 @@ bool cmStringCommand { return this->HandleLengthCommand(args); } + else if(subCommand == "CONCAT") + { + return this->HandleConcatCommand(args); + } else if(subCommand == "SUBSTRING") { return this->HandleSubstringCommand(args); @@ -768,6 +772,27 @@ bool cmStringCommand //---------------------------------------------------------------------------- bool cmStringCommand +::HandleConcatCommand(std::vector<std::string> const& args) +{ + if(args.size() < 2) + { + this->SetError("sub-command CONCAT requires at least one argument."); + return false; + } + + std::string const& variableName = args[1]; + std::string value; + for(unsigned int i = 2; i < args.size(); ++i) + { + value += args[i]; + } + + this->Makefile->AddDefinition(variableName.c_str(), value.c_str()); + return true; +} + +//---------------------------------------------------------------------------- +bool cmStringCommand ::HandleMakeCIdentifierCommand(std::vector<std::string> const& args) { if(args.size() != 3) diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h index f584cfd..66b48e6 100644 --- a/Source/cmStringCommand.h +++ b/Source/cmStringCommand.h @@ -52,136 +52,6 @@ public: */ virtual const char* GetName() const { return "string";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "String operations."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " string(REGEX MATCH <regular_expression>\n" - " <output variable> <input> [<input>...])\n" - " string(REGEX MATCHALL <regular_expression>\n" - " <output variable> <input> [<input>...])\n" - " string(REGEX REPLACE <regular_expression>\n" - " <replace_expression> <output variable>\n" - " <input> [<input>...])\n" - " string(REPLACE <match_string>\n" - " <replace_string> <output variable>\n" - " <input> [<input>...])\n" - " string(<MD5|SHA1|SHA224|SHA256|SHA384|SHA512>\n" - " <output variable> <input>)\n" - " string(COMPARE EQUAL <string1> <string2> <output variable>)\n" - " string(COMPARE NOTEQUAL <string1> <string2> <output variable>)\n" - " string(COMPARE LESS <string1> <string2> <output variable>)\n" - " string(COMPARE GREATER <string1> <string2> <output variable>)\n" - " string(ASCII <number> [<number> ...] <output variable>)\n" - " string(CONFIGURE <string1> <output variable>\n" - " [@ONLY] [ESCAPE_QUOTES])\n" - " string(TOUPPER <string1> <output variable>)\n" - " string(TOLOWER <string1> <output variable>)\n" - " string(LENGTH <string> <output variable>)\n" - " string(SUBSTRING <string> <begin> <length> <output variable>)\n" - " string(STRIP <string> <output variable>)\n" - " string(RANDOM [LENGTH <length>] [ALPHABET <alphabet>]\n" - " [RANDOM_SEED <seed>] <output variable>)\n" - " string(FIND <string> <substring> <output variable> [REVERSE])\n" - " string(TIMESTAMP <output variable> [<format string>] [UTC])\n" - " string(MAKE_C_IDENTIFIER <input string> <output variable>)\n" - "REGEX MATCH will match the regular expression once and store the " - "match in the output variable.\n" - "REGEX MATCHALL will match the regular expression as many times as " - "possible and store the matches in the output variable as a list.\n" - "REGEX REPLACE will match the regular expression as many times as " - "possible and substitute the replacement expression for the match " - "in the output. The replace expression may refer to paren-delimited " - "subexpressions of the match using \\1, \\2, ..., \\9. Note that " - "two backslashes (\\\\1) are required in CMake code to get a " - "backslash through argument parsing.\n" - "REPLACE will replace all occurrences of match_string in the input with " - "replace_string and store the result in the output.\n" - "MD5, SHA1, SHA224, SHA256, SHA384, and SHA512 " - "will compute a cryptographic hash of the input string.\n" - "COMPARE EQUAL/NOTEQUAL/LESS/GREATER will compare the strings and " - "store true or false in the output variable.\n" - "ASCII will convert all numbers into corresponding ASCII characters.\n" - "CONFIGURE will transform a string like CONFIGURE_FILE transforms " - "a file.\n" - "TOUPPER/TOLOWER will convert string to upper/lower characters.\n" - "LENGTH will return a given string's length.\n" - "SUBSTRING will return a substring of a given string. If length is " - "-1 the remainder of the string starting at begin will be returned.\n" - "STRIP will return a substring of a given string with leading " - "and trailing spaces removed.\n" - "RANDOM will return a random string of given length consisting of " - "characters from the given alphabet. Default length is 5 " - "characters and default alphabet is all numbers and upper and " - "lower case letters. If an integer RANDOM_SEED is given, its " - "value will be used to seed the random number generator.\n" - "FIND will return the position where the given substring was found " - "in the supplied string. If the REVERSE flag was used, the command " - "will search for the position of the last occurrence of the " - "specified substring.\n" - "The following characters have special meaning in regular expressions:\n" - " ^ Matches at beginning of input\n" - " $ Matches at end of input\n" - " . Matches any single character\n" - " [ ] Matches any character(s) inside the brackets\n" - " [^ ] Matches any character(s) not inside the brackets\n" - " - Inside brackets, specifies an inclusive range between\n" - " characters on either side e.g. [a-f] is [abcdef]\n" - " To match a literal - using brackets, make it the first\n" - " or the last character e.g. [+*/-] matches basic\n" - " mathematical operators.\n" - " * Matches preceding pattern zero or more times\n" - " + Matches preceding pattern one or more times\n" - " ? Matches preceding pattern zero or once only\n" - " | Matches a pattern on either side of the |\n" - " () Saves a matched subexpression, which can be referenced \n" - " in the REGEX REPLACE operation. Additionally it is saved\n" - " by all regular expression-related commands, including \n" - " e.g. if( MATCHES ), in the variables CMAKE_MATCH_(0..9).\n" - "*, + and ? have higher precedence than concatenation. | has lower " - "precedence than concatenation. This means that the regular expression " - "\"^ab+d$\" matches \"abbd\" but not \"ababd\", and the regular " - "expression \"^(ab|cd)$\" matches \"ab\" but not \"abd\".\n" - "TIMESTAMP will write a string representation of " - "the current date and/or time to the output variable.\n" - "Should the command be unable to obtain a timestamp " - "the output variable will be set to the empty string \"\".\n" - "The optional UTC flag requests the current date/time " - "representation to be in Coordinated Universal Time (UTC) " - "rather than local time.\n" - "The optional <format string> may contain the following " - "format specifiers: \n" - " %d The day of the current month (01-31).\n" - " %H The hour on a 24-hour clock (00-23).\n" - " %I The hour on a 12-hour clock (01-12).\n" - " %j The day of the current year (001-366).\n" - " %m The month of the current year (01-12).\n" - " %M The minute of the current hour (00-59).\n" - " %S The second of the current minute.\n" - " 60 represents a leap second. (00-60)\n" - " %U The week number of the current year (00-53).\n" - " %w The day of the current week. 0 is Sunday. (0-6)\n" - " %y The last two digits of the current year (00-99)\n" - " %Y The current year. \n" - "Unknown format specifiers will be ignored " - "and copied to the output as-is.\n" - "If no explicit <format string> is given it will default to:\n" - " %Y-%m-%dT%H:%M:%S for local time.\n" - " %Y-%m-%dT%H:%M:%SZ for UTC.\n" - "MAKE_C_IDENTIFIER will write a string which can be used as an " - "identifier in C."; - } - cmTypeMacro(cmStringCommand, cmCommand); static void ClearMatches(cmMakefile* mf); static void StoreMatches(cmMakefile* mf, cmsys::RegularExpression& re); @@ -199,6 +69,7 @@ protected: bool HandleReplaceCommand(std::vector<std::string> const& args); bool HandleLengthCommand(std::vector<std::string> const& args); bool HandleSubstringCommand(std::vector<std::string> const& args); + bool HandleConcatCommand(std::vector<std::string> const& args); bool HandleStripCommand(std::vector<std::string> const& args); bool HandleRandomCommand(std::vector<std::string> const& args); bool HandleFindCommand(std::vector<std::string> const& args); diff --git a/Source/cmSubdirCommand.h b/Source/cmSubdirCommand.h index 618d5ff..8be8335 100644 --- a/Source/cmSubdirCommand.h +++ b/Source/cmSubdirCommand.h @@ -44,40 +44,6 @@ public: */ virtual const char* GetName() const { return "subdirs";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Deprecated. Use the add_subdirectory() command instead."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - "Add a list of subdirectories to the build.\n" - " subdirs(dir1 dir2 ..." - "[EXCLUDE_FROM_ALL exclude_dir1 exclude_dir2 ...]\n" - " [PREORDER] )\n" - "Add a list of subdirectories to the build. The add_subdirectory " - "command should be used instead of subdirs although subdirs will " - "still work. " - "This will cause any CMakeLists.txt files in the sub directories " - "to be processed by CMake. Any directories after the PREORDER flag " - "are traversed first by makefile builds, the PREORDER flag has no " - "effect on IDE projects. " - " Any directories after the EXCLUDE_FROM_ALL marker " - "will not be included in the top level makefile or project file. " - "This is useful for having CMake create makefiles or projects for " - "a set of examples in a project. You would want CMake to " - "generate makefiles or project files for all the examples at " - "the same time, but you would not want them to show up in the " - "top level project or be built each time make is run from the top."; - } - /** This command is kept for compatibility with older CMake versions. */ virtual bool IsDiscouraged() const { diff --git a/Source/cmSubdirDependsCommand.cxx b/Source/cmSubdirDependsCommand.cxx index 2af7bf1..9381983 100644 --- a/Source/cmSubdirDependsCommand.cxx +++ b/Source/cmSubdirDependsCommand.cxx @@ -11,10 +11,10 @@ ============================================================================*/ #include "cmSubdirDependsCommand.h" -// cmSubdirDependsCommand bool cmSubdirDependsCommand::InitialPass(std::vector<std::string> const& , cmExecutionStatus &) { + this->Disallowed(cmPolicies::CMP0029, + "The subdir_depends command should not be called; see CMP0029."); return true; } - diff --git a/Source/cmSubdirDependsCommand.h b/Source/cmSubdirDependsCommand.h index b274d01..f78cfb7 100644 --- a/Source/cmSubdirDependsCommand.h +++ b/Source/cmSubdirDependsCommand.h @@ -14,64 +14,15 @@ #include "cmCommand.h" -/** \class cmSubdirDependsCommand - * \brief Legacy command. Do not use. - * - * cmSubdirDependsCommand has been left in CMake for compatability with - * projects already using it. Its functionality in supporting parallel - * builds is now automatic. The command does not do anything. - */ class cmSubdirDependsCommand : public cmCommand { public: - /** - * This is a virtual constructor for the command. - */ - virtual cmCommand* Clone() - { - return new cmSubdirDependsCommand; - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ + virtual cmCommand* Clone() { return new cmSubdirDependsCommand; } virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); - - /** - * The name of the command as specified in CMakeList.txt. - */ virtual const char* GetName() const { return "subdir_depends";} - - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Deprecated. Does nothing."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " subdir_depends(subdir dep1 dep2 ...)\n" - "Does not do anything. This command used to help projects order " - "parallel builds correctly. This functionality is now automatic."; - } - - /** This command is kept for compatibility with older CMake versions. */ - virtual bool IsDiscouraged() const - { - return true; - } - + virtual bool IsDiscouraged() const { return true; } cmTypeMacro(cmSubdirDependsCommand, cmCommand); }; - - #endif diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 9ec4938..41c7509 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -25,12 +25,14 @@ #include <cmsys/RegularExpression.hxx> #include <cmsys/Directory.hxx> #include <cmsys/System.h> +#include <cmsys/Encoding.hxx> #if defined(CMAKE_BUILD_WITH_CMAKE) # include "cmArchiveWrite.h" # include <cm_libarchive.h> # include <cmsys/Terminal.h> #endif #include <cmsys/stl/algorithm> +#include <cmsys/FStream.hxx> #if defined(_WIN32) # include <windows.h> @@ -43,6 +45,10 @@ # include <sys/wait.h> #endif +#if defined(__APPLE__) +# include <mach-o/dyld.h> +#endif + #include <sys/stat.h> #if defined(_WIN32) && \ @@ -115,19 +121,6 @@ bool cmSystemTools::s_FatalErrorOccured = false; bool cmSystemTools::s_DisableMessages = false; bool cmSystemTools::s_ForceUnixPaths = false; -std::string cmSystemTools::s_Windows9xComspecSubstitute = "command.com"; -void cmSystemTools::SetWindows9xComspecSubstitute(const char* str) -{ - if ( str ) - { - cmSystemTools::s_Windows9xComspecSubstitute = str; - } -} -const char* cmSystemTools::GetWindows9xComspecSubstitute() -{ - return cmSystemTools::s_Windows9xComspecSubstitute.c_str(); -} - void (*cmSystemTools::s_ErrorCallback)(const char*, const char*, bool&, void*); void (*cmSystemTools::s_StdoutCallback)(const char*, int len, void*); @@ -200,6 +193,13 @@ std::string cmSystemTools::EscapeQuotes(const char* str) return result; } +std::string cmSystemTools::HelpFileName(std::string name) +{ + cmSystemTools::ReplaceString(name, "<", ""); + cmSystemTools::ReplaceString(name, ">", ""); + return name; +} + std::string cmSystemTools::TrimWhitespace(const std::string& s) { std::string::const_iterator start = s.begin(); @@ -360,18 +360,11 @@ bool cmSystemTools::IsOn(const char* val) bool cmSystemTools::IsNOTFOUND(const char* val) { - size_t len = strlen(val); - const char* notfound = "-NOTFOUND"; - const size_t lenNotFound = 9; - if(len < lenNotFound-1) - { - return false; - } - if(len == lenNotFound-1) + if(strcmp(val, "NOTFOUND") == 0) { - return ( strcmp(val, "NOTFOUND") == 0); + return true; } - return ((strncmp((val + (len - lenNotFound)), notfound, lenNotFound) == 0)); + return cmHasLiteralSuffix(val, "-NOTFOUND"); } @@ -618,8 +611,24 @@ bool cmSystemTools::RunSingleCommand(std::vector<cmStdString>const& command, OutputOption outputflag , double timeout ) { + std::vector<std::string> cmd; + for(std::vector<cmStdString>::const_iterator i = command.begin(); + i != command.end(); ++i) + { + cmd.push_back(*i); + } + return cmSystemTools::RunSingleCommand(cmd, output, retVal, dir, + outputflag, timeout); +} + +bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command, + std::string* output , + int* retVal , const char* dir , + OutputOption outputflag , + double timeout ) +{ std::vector<const char*> argv; - for(std::vector<cmStdString>::const_iterator a = command.begin(); + for(std::vector<std::string>::const_iterator a = command.begin(); a != command.end(); ++a) { argv.push_back(a->c_str()); @@ -780,350 +789,22 @@ bool cmSystemTools::RunSingleCommand( return cmSystemTools::RunSingleCommand(args, output,retVal, dir, outputflag, timeout); } -bool cmSystemTools::RunCommand(const char* command, - std::string& output, - const char* dir, - bool verbose, - int timeout) -{ - int dummy; - return cmSystemTools::RunCommand(command, output, dummy, - dir, verbose, timeout); -} - -#if defined(WIN32) && !defined(__CYGWIN__) -#include "cmWin32ProcessExecution.h" -// use this for shell commands like echo and dir -bool RunCommandViaWin32(const char* command, - const char* dir, - std::string& output, - int& retVal, - bool verbose, - int timeout) -{ -#if defined(__BORLANDC__) - return - cmWin32ProcessExecution:: - BorlandRunCommand(command, dir, output, - retVal, - verbose, timeout, - cmSystemTools::GetRunCommandHideConsole()); -#else // Visual studio - ::SetLastError(ERROR_SUCCESS); - if ( ! command ) - { - cmSystemTools::Error("No command specified"); - return false; - } - cmWin32ProcessExecution resProc; - if(cmSystemTools::GetRunCommandHideConsole()) - { - resProc.SetHideWindows(true); - } - - if ( cmSystemTools::GetWindows9xComspecSubstitute() ) - { - resProc.SetConsoleSpawn(cmSystemTools::GetWindows9xComspecSubstitute() ); - } - if ( !resProc.StartProcess(command, dir, verbose) ) - { - output = resProc.GetOutput(); - if(verbose) - { - cmSystemTools::Stdout(output.c_str()); - } - return false; - } - resProc.Wait(timeout); - output = resProc.GetOutput(); - retVal = resProc.GetExitValue(); - return true; -#endif -} -// use this for shell commands like echo and dir -bool RunCommandViaSystem(const char* command, - const char* dir, - std::string& output, - int& retVal, - bool verbose) +std::string +cmSystemTools::PrintSingleCommand(std::vector<std::string> const& command) { - std::cout << "@@ " << command << std::endl; - - std::string commandInDir; - if(dir) + std::string commandStr; + const char* sep = ""; + for(std::vector<std::string>::const_iterator i = command.begin(); + i != command.end(); ++i) { - commandInDir = "cd "; - commandInDir += cmSystemTools::ConvertToOutputPath(dir); - commandInDir += " && "; - commandInDir += command; + commandStr += sep; + commandStr += "\""; + commandStr += *i; + commandStr += "\""; + sep = " "; } - else - { - commandInDir = command; - } - command = commandInDir.c_str(); - std::string commandToFile = command; - commandToFile += " > "; - std::string tempFile; - tempFile += _tempnam(0, "cmake"); - - commandToFile += tempFile; - retVal = system(commandToFile.c_str()); - std::ifstream fin(tempFile.c_str()); - if(!fin) - { - if(verbose) - { - std::string errormsg = "RunCommand produced no output: command: \""; - errormsg += command; - errormsg += "\""; - errormsg += "\nOutput file: "; - errormsg += tempFile; - cmSystemTools::Error(errormsg.c_str()); - } - fin.close(); - cmSystemTools::RemoveFile(tempFile.c_str()); - return false; - } - bool multiLine = false; - std::string line; - while(cmSystemTools::GetLineFromStream(fin, line)) - { - output += line; - if(multiLine) - { - output += "\n"; - } - multiLine = true; - } - fin.close(); - cmSystemTools::RemoveFile(tempFile.c_str()); - return true; -} - -#else // We have popen - -// BeOS seems to return from a successful pclose() before the process has -// legitimately exited, or at least before SIGCHLD is thrown...the signal may -// come quite some time after pclose returns! This causes havoc with later -// parts of CMake that expect to catch the signal from other child processes, -// so we explicitly wait to catch it here. This should be safe to do with -// popen() so long as we don't actually collect the zombie process ourselves. -#ifdef __BEOS__ -#include <signal.h> -#undef SIGBUS // this is the same as SIGSEGV on BeOS and causes issues below. -static volatile bool beos_seen_signal = false; -static void beos_popen_workaround(int sig) -{ - beos_seen_signal = true; -} -#endif - -bool RunCommandViaPopen(const char* command, - const char* dir, - std::string& output, - int& retVal, - bool verbose, - int /*timeout*/) -{ - // if only popen worked on windows..... - std::string commandInDir; - if(dir) - { - commandInDir = "cd \""; - commandInDir += dir; - commandInDir += "\" && "; - commandInDir += command; - } - else - { - commandInDir = command; - } -#ifndef __VMS - commandInDir += " 2>&1"; -#endif - command = commandInDir.c_str(); - const int BUFFER_SIZE = 4096; - char buffer[BUFFER_SIZE]; - if(verbose) - { - cmSystemTools::Stdout("running "); - cmSystemTools::Stdout(command); - cmSystemTools::Stdout("\n"); - } - fflush(stdout); - fflush(stderr); - -#ifdef __BEOS__ - beos_seen_signal = false; - signal(SIGCHLD, beos_popen_workaround); -#endif - - FILE* cpipe = popen(command, "r"); - if(!cpipe) - { -#ifdef __BEOS__ - signal(SIGCHLD, SIG_DFL); -#endif - return false; - } - if (!fgets(buffer, BUFFER_SIZE, cpipe)) - { - buffer[0] = 0; - } - while(!feof(cpipe)) - { - if(verbose) - { - cmSystemTools::Stdout(buffer); - } - output += buffer; - if(!fgets(buffer, BUFFER_SIZE, cpipe)) - { - buffer[0] = 0; - } - } - - retVal = pclose(cpipe); - -#ifdef __BEOS__ - for (int i = 0; (!beos_seen_signal) && (i < 3); i++) - { - ::sleep(1); // signals should interrupt this... - } - - if (!beos_seen_signal) - { - signal(SIGCHLD, SIG_DFL); // oh well, didn't happen. Go on anyhow. - } -#endif - - if (WIFEXITED(retVal)) - { - retVal = WEXITSTATUS(retVal); - return true; - } - if (WIFSIGNALED(retVal)) - { - retVal = WTERMSIG(retVal); - cmOStringStream error; - error << "\nProcess terminated due to "; - switch (retVal) - { -#ifdef SIGKILL - case SIGKILL: - error << "SIGKILL"; - break; -#endif -#ifdef SIGFPE - case SIGFPE: - error << "SIGFPE"; - break; -#endif -#ifndef __HAIKU__ -#ifdef SIGBUS - case SIGBUS: - error << "SIGBUS"; - break; -#endif -#endif -#ifdef SIGSEGV - case SIGSEGV: - error << "SIGSEGV"; - break; -#endif - default: - error << "signal " << retVal; - break; - } - output += error.str(); - } - return false; -} - -#endif // endif WIN32 not CYGWIN - - -// run a command unix uses popen (easy) -// windows uses system and ShortPath -bool cmSystemTools::RunCommand(const char* command, - std::string& output, - int &retVal, - const char* dir, - bool verbose, - int timeout) -{ - if(s_DisableRunCommandOutput) - { - verbose = false; - } - -#if defined(WIN32) && !defined(__CYGWIN__) - // if the command does not start with a quote, then - // try to find the program, and if the program can not be - // found use system to run the command as it must be a built in - // shell command like echo or dir - int count = 0; - if(command[0] == '\"') - { - // count the number of quotes - for(const char* s = command; *s != 0; ++s) - { - if(*s == '\"') - { - count++; - if(count > 2) - { - break; - } - } - } - // if there are more than two double quotes use - // GetShortPathName, the cmd.exe program in windows which - // is used by system fails to execute if there are more than - // one set of quotes in the arguments - if(count > 2) - { - cmsys::RegularExpression quoted("^\"([^\"]*)\"[ \t](.*)"); - if(quoted.find(command)) - { - std::string shortCmd; - std::string cmd = quoted.match(1); - std::string args = quoted.match(2); - if(! cmSystemTools::FileExists(cmd.c_str()) ) - { - shortCmd = cmd; - } - else if(!cmSystemTools::GetShortPath(cmd.c_str(), shortCmd)) - { - cmSystemTools::Error("GetShortPath failed for " , cmd.c_str()); - return false; - } - shortCmd += " "; - shortCmd += args; - - //return RunCommandViaSystem(shortCmd.c_str(), dir, - // output, retVal, verbose); - //return WindowsRunCommand(shortCmd.c_str(), dir, - //output, retVal, verbose); - return RunCommandViaWin32(shortCmd.c_str(), dir, - output, retVal, verbose, timeout); - } - else - { - cmSystemTools::Error("Could not parse command line with quotes ", - command); - } - } - } - // if there is only one set of quotes or no quotes then just run the command - //return RunCommandViaSystem(command, dir, output, retVal, verbose); - //return WindowsRunCommand(command, dir, output, retVal, verbose); - return ::RunCommandViaWin32(command, dir, output, retVal, verbose, timeout); -#else - return ::RunCommandViaPopen(command, dir, output, retVal, verbose, timeout); -#endif + return commandStr; } bool cmSystemTools::DoesFileExistWithExtensions( @@ -1194,19 +875,23 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname) Try multiple times since we may be racing against another process creating/opening the destination file just before our MoveFileEx. */ int tries = 5; - while(!MoveFileEx(oldname, newname, MOVEFILE_REPLACE_EXISTING) && --tries) + while(!MoveFileExW(cmsys::Encoding::ToWide(oldname).c_str(), + cmsys::Encoding::ToWide(newname).c_str(), + MOVEFILE_REPLACE_EXISTING) && --tries) { // Try again only if failure was due to access permissions. if(GetLastError() != ERROR_ACCESS_DENIED) { return false; } - DWORD attrs = GetFileAttributes(newname); + DWORD attrs = + GetFileAttributesW(cmsys::Encoding::ToWide(newname).c_str()); if((attrs != INVALID_FILE_ATTRIBUTES) && (attrs & FILE_ATTRIBUTE_READONLY)) { // Remove the read-only attribute from the destination file. - SetFileAttributes(newname, attrs & ~FILE_ATTRIBUTE_READONLY); + SetFileAttributesW(cmsys::Encoding::ToWide(newname).c_str(), + attrs & ~FILE_ATTRIBUTE_READONLY); } else { @@ -1741,7 +1426,7 @@ bool cmSystemTools::CreateTar(const char* outFileName, { #if defined(CMAKE_BUILD_WITH_CMAKE) std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - std::ofstream fout(outFileName, std::ios::out | cmsys_ios_binary); + cmsys::ofstream fout(outFileName, std::ios::out | cmsys_ios_binary); if(!fout) { std::string e = "Cannot open output file \""; @@ -1970,18 +1655,23 @@ bool extract_tar(const char* outFileName, bool verbose, archive_error_string(a)); break; } - if (verbose && extract) - { - cmSystemTools::Stdout("x "); - cmSystemTools::Stdout(archive_entry_pathname(entry)); - } - if(verbose && !extract) + if(verbose) { - list_item_verbose(stdout, entry); + if(extract) + { + cmSystemTools::Stdout("x "); + cmSystemTools::Stdout(archive_entry_pathname(entry)); + } + else + { + list_item_verbose(stdout, entry); + } + cmSystemTools::Stdout("\n"); } else if(!extract) { cmSystemTools::Stdout(archive_entry_pathname(entry)); + cmSystemTools::Stdout("\n"); } if(extract) { @@ -1995,15 +1685,7 @@ bool extract_tar(const char* outFileName, bool verbose, } r = archive_write_header(ext, entry); - if (r != ARCHIVE_OK) - { - cmSystemTools::Error("Problem with archive_write_header(): ", - archive_error_string(ext)); - cmSystemTools::Error("Current file: ", - archive_entry_pathname(entry)); - break; - } - else + if (r == ARCHIVE_OK) { copy_data(a, ext); r = archive_write_finish_entry(ext); @@ -2014,10 +1696,22 @@ bool extract_tar(const char* outFileName, bool verbose, break; } } - } - if (verbose || !extract) - { - cmSystemTools::Stdout("\n"); +#ifdef _WIN32 + else if(const char* linktext = archive_entry_symlink(entry)) + { + std::cerr << "cmake -E tar: warning: skipping symbolic link \"" + << archive_entry_pathname(entry) << "\" -> \"" + << linktext << "\"." << std::endl; + } +#endif + else + { + cmSystemTools::Error("Problem with archive_write_header(): ", + archive_error_string(ext)); + cmSystemTools::Error("Current file: ", + archive_entry_pathname(entry)); + break; + } } } archive_read_close(a); @@ -2189,10 +1883,12 @@ bool cmSystemTools::CopyFileTime(const char* fromFile, const char* toFile) { #if defined(_WIN32) && !defined(__CYGWIN__) cmSystemToolsWindowsHandle hFrom = - CreateFile(fromFile, GENERIC_READ, FILE_SHARE_READ, 0, - OPEN_EXISTING, 0, 0); + CreateFileW(cmsys::Encoding::ToWide(fromFile).c_str(), + GENERIC_READ, FILE_SHARE_READ, 0, + OPEN_EXISTING, 0, 0); cmSystemToolsWindowsHandle hTo = - CreateFile(toFile, GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); + CreateFileW(cmsys::Encoding::ToWide(toFile).c_str(), + GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); if(!hFrom || !hTo) { return false; @@ -2243,7 +1939,8 @@ bool cmSystemTools::FileTimeGet(const char* fname, cmSystemToolsFileTime* t) { #if defined(_WIN32) && !defined(__CYGWIN__) cmSystemToolsWindowsHandle h = - CreateFile(fname, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); + CreateFileW(cmsys::Encoding::ToWide(fname).c_str(), + GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); if(!h) { return false; @@ -2269,7 +1966,8 @@ bool cmSystemTools::FileTimeSet(const char* fname, cmSystemToolsFileTime* t) { #if defined(_WIN32) && !defined(__CYGWIN__) cmSystemToolsWindowsHandle h = - CreateFile(fname, GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); + CreateFileW(cmsys::Encoding::ToWide(fname).c_str(), + GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); if(!h) { return false; @@ -2333,7 +2031,7 @@ unsigned int cmSystemTools::RandomSeed() } seed; // Try using a real random source. - std::ifstream fin("/dev/urandom"); + cmsys::ifstream fin("/dev/urandom"); if(fin && fin.read(seed.bytes, sizeof(seed)) && fin.gcount() == sizeof(seed)) { @@ -2353,16 +2051,60 @@ unsigned int cmSystemTools::RandomSeed() } //---------------------------------------------------------------------------- -static std::string cmSystemToolsExecutableDirectory; -void cmSystemTools::FindExecutableDirectory(const char* argv0) -{ +static std::string cmSystemToolsCMakeCommand; +static std::string cmSystemToolsCTestCommand; +static std::string cmSystemToolsCPackCommand; +static std::string cmSystemToolsCMakeCursesCommand; +static std::string cmSystemToolsCMakeGUICommand; +static std::string cmSystemToolsCMakeRoot; +void cmSystemTools::FindCMakeResources(const char* argv0) +{ + std::string exe_dir; #if defined(_WIN32) && !defined(__CYGWIN__) (void)argv0; // ignore this on windows - char modulepath[_MAX_PATH]; - ::GetModuleFileName(NULL, modulepath, sizeof(modulepath)); - cmSystemToolsExecutableDirectory = - cmSystemTools::GetFilenamePath(modulepath); - return; + wchar_t modulepath[_MAX_PATH]; + ::GetModuleFileNameW(NULL, modulepath, sizeof(modulepath)); + exe_dir = + cmSystemTools::GetFilenamePath(cmsys::Encoding::ToNarrow(modulepath)); +#elif defined(__APPLE__) + (void)argv0; // ignore this on OS X +# define CM_EXE_PATH_LOCAL_SIZE 16384 + char exe_path_local[CM_EXE_PATH_LOCAL_SIZE]; +# if defined(MAC_OS_X_VERSION_10_3) && !defined(MAC_OS_X_VERSION_10_4) + unsigned long exe_path_size = CM_EXE_PATH_LOCAL_SIZE; +# else + uint32_t exe_path_size = CM_EXE_PATH_LOCAL_SIZE; +# endif +# undef CM_EXE_PATH_LOCAL_SIZE + char* exe_path = exe_path_local; + if(_NSGetExecutablePath(exe_path, &exe_path_size) < 0) + { + exe_path = (char*)malloc(exe_path_size); + _NSGetExecutablePath(exe_path, &exe_path_size); + } + exe_dir = + cmSystemTools::GetFilenamePath( + cmSystemTools::GetRealPath(exe_path)); + if(exe_path != exe_path_local) + { + free(exe_path); + } + if(cmSystemTools::GetFilenameName(exe_dir) == "MacOS") + { + // The executable is inside an application bundle. + // Look for ../bin (install tree) and then fall back to + // ../../../bin (build tree). + exe_dir = cmSystemTools::GetFilenamePath(exe_dir); + if(cmSystemTools::FileExists((exe_dir+"/bin/cmake").c_str())) + { + exe_dir += "/bin"; + } + else + { + exe_dir = cmSystemTools::GetFilenamePath(exe_dir); + exe_dir = cmSystemTools::GetFilenamePath(exe_dir); + } + } #else std::string errorMsg; std::string exe; @@ -2370,7 +2112,7 @@ void cmSystemTools::FindExecutableDirectory(const char* argv0) { // remove symlinks exe = cmSystemTools::GetRealPath(exe.c_str()); - cmSystemToolsExecutableDirectory = + exe_dir = cmSystemTools::GetFilenamePath(exe.c_str()); } else @@ -2378,12 +2120,99 @@ void cmSystemTools::FindExecutableDirectory(const char* argv0) // ??? } #endif + cmSystemToolsCMakeCommand = exe_dir; + cmSystemToolsCMakeCommand += "/cmake"; + cmSystemToolsCMakeCommand += cmSystemTools::GetExecutableExtension(); + cmSystemToolsCTestCommand = exe_dir; + cmSystemToolsCTestCommand += "/ctest"; + cmSystemToolsCTestCommand += cmSystemTools::GetExecutableExtension(); + cmSystemToolsCPackCommand = exe_dir; + cmSystemToolsCPackCommand += "/cpack"; + cmSystemToolsCPackCommand += cmSystemTools::GetExecutableExtension(); + cmSystemToolsCMakeGUICommand = exe_dir; + cmSystemToolsCMakeGUICommand += "/cmake-gui"; + cmSystemToolsCMakeGUICommand += cmSystemTools::GetExecutableExtension(); + if(!cmSystemTools::FileExists(cmSystemToolsCMakeGUICommand.c_str())) + { + cmSystemToolsCMakeGUICommand = ""; + } + cmSystemToolsCMakeCursesCommand = exe_dir; + cmSystemToolsCMakeCursesCommand += "/ccmake"; + cmSystemToolsCMakeCursesCommand += cmSystemTools::GetExecutableExtension(); + if(!cmSystemTools::FileExists(cmSystemToolsCMakeCursesCommand.c_str())) + { + cmSystemToolsCMakeCursesCommand = ""; + } + +#ifdef CMAKE_BUILD_WITH_CMAKE + // Install tree has "<prefix>/bin/cmake" and "<prefix><CMAKE_DATA_DIR>". + std::string dir = cmSystemTools::GetFilenamePath(exe_dir); + cmSystemToolsCMakeRoot = dir + CMAKE_DATA_DIR; + if(!cmSystemTools::FileExists( + (cmSystemToolsCMakeRoot+"/Modules/CMake.cmake").c_str())) + { + // Build tree has "<build>/bin[/<config>]/cmake" and + // "<build>/CMakeFiles/CMakeSourceDir.txt". + std::string src_dir_txt = dir + "/CMakeFiles/CMakeSourceDir.txt"; + cmsys::ifstream fin(src_dir_txt.c_str()); + std::string src_dir; + if(fin && cmSystemTools::GetLineFromStream(fin, src_dir) && + cmSystemTools::FileIsDirectory(src_dir.c_str())) + { + cmSystemToolsCMakeRoot = src_dir; + } + else + { + dir = cmSystemTools::GetFilenamePath(dir); + src_dir_txt = dir + "/CMakeFiles/CMakeSourceDir.txt"; + cmsys::ifstream fin2(src_dir_txt.c_str()); + if(fin2 && cmSystemTools::GetLineFromStream(fin2, src_dir) && + cmSystemTools::FileIsDirectory(src_dir.c_str())) + { + cmSystemToolsCMakeRoot = src_dir; + } + } + } +#else + // Bootstrap build knows its source. + cmSystemToolsCMakeRoot = CMAKE_ROOT_DIR; +#endif +} + +//---------------------------------------------------------------------------- +std::string const& cmSystemTools::GetCMakeCommand() +{ + return cmSystemToolsCMakeCommand; +} + +//---------------------------------------------------------------------------- +std::string const& cmSystemTools::GetCTestCommand() +{ + return cmSystemToolsCTestCommand; +} + +//---------------------------------------------------------------------------- +std::string const& cmSystemTools::GetCPackCommand() +{ + return cmSystemToolsCPackCommand; +} + +//---------------------------------------------------------------------------- +std::string const& cmSystemTools::GetCMakeCursesCommand() +{ + return cmSystemToolsCMakeCursesCommand; +} + +//---------------------------------------------------------------------------- +std::string const& cmSystemTools::GetCMakeGUICommand() +{ + return cmSystemToolsCMakeGUICommand; } //---------------------------------------------------------------------------- -const char* cmSystemTools::GetExecutableDirectory() +std::string const& cmSystemTools::GetCMakeRoot() { - return cmSystemToolsExecutableDirectory.c_str(); + return cmSystemToolsCMakeRoot; } //---------------------------------------------------------------------------- @@ -2671,7 +2500,7 @@ bool cmSystemTools::ChangeRPath(std::string const& file, { // Open the file for update. - std::ofstream f(file.c_str(), + cmsys::ofstream f(file.c_str(), std::ios::in | std::ios::out | std::ios::binary); if(!f) { @@ -2869,7 +2698,7 @@ bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg, } // Open the file for update. - std::ofstream f(file.c_str(), + cmsys::ofstream f(file.c_str(), std::ios::in | std::ios::out | std::ios::binary); if(!f) { diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 9d7dae9..4e854c8 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -49,6 +49,9 @@ public: ///! Escape quotes in a string. static std::string EscapeQuotes(const char* str); + /** Map help document name to file name. */ + static std::string HelpFileName(std::string); + /** * Returns a string that has whitespace removed from the start and the end. */ @@ -188,23 +191,6 @@ public: static std::string ComputeStringMD5(const char* input); /** - * Run an executable command and put the stdout in output. - * A temporary file is created in the binaryDir for storing the - * output because windows does not have popen. - * - * If verbose is false, no user-viewable output from the program - * being run will be generated. - * - * If timeout is specified, the command will be terminated after - * timeout expires. - */ - static bool RunCommand(const char* command, std::string& output, - const char* directory = 0, - bool verbose = true, int timeout = 0); - static bool RunCommand(const char* command, std::string& output, - int &retVal, const char* directory = 0, - bool verbose = true, int timeout = 0); - /** * Run a single executable command * * Output is controlled with outputflag. If outputflag is OUTPUT_NONE, no @@ -242,12 +228,19 @@ public: * the command to run, and each argument to the command should * be in comand[1]...command[command.size()] */ + static bool RunSingleCommand(std::vector<std::string> const& command, + std::string* output = 0, + int* retVal = 0, const char* dir = 0, + OutputOption outputflag = OUTPUT_MERGE, + double timeout = 0.0); static bool RunSingleCommand(std::vector<cmStdString> const& command, std::string* output = 0, int* retVal = 0, const char* dir = 0, OutputOption outputflag = OUTPUT_MERGE, double timeout = 0.0); + static std::string PrintSingleCommand(std::vector<std::string> const&); + /** * Parse arguments out of a single string command */ @@ -309,14 +302,6 @@ public: */ static FileFormat GetFileFormat(const char* ext); - /** - * On Windows 9x we need a comspec (command.com) substitute to run - * programs correctly. This string has to be constant available - * through the running of program. This method does not create a copy. - */ - static void SetWindows9xComspecSubstitute(const char*); - static const char* GetWindows9xComspecSubstitute(); - /** Windows if this is true, the CreateProcess in RunCommand will * not show new consol windows when running programs. */ @@ -428,13 +413,16 @@ public: /** Random seed generation. */ static unsigned int RandomSeed(); - /** Find the directory containing the running executable. Save it - in a global location to be queried by GetExecutableDirectory - later. */ - static void FindExecutableDirectory(const char* argv0); + /** Find the directory containing CMake executables. */ + static void FindCMakeResources(const char* argv0); - /** Get the directory containing the currently running executable. */ - static const char* GetExecutableDirectory(); + /** Get the CMake resource paths, after FindCMakeResources. */ + static std::string const& GetCTestCommand(); + static std::string const& GetCPackCommand(); + static std::string const& GetCMakeCommand(); + static std::string const& GetCMakeGUICommand(); + static std::string const& GetCMakeCursesCommand(); + static std::string const& GetCMakeRoot(); #if defined(CMAKE_BUILD_WITH_CMAKE) /** Echo a message in color using KWSys's Terminal cprintf. */ @@ -485,8 +473,6 @@ private: static void* s_ErrorCallbackClientData; static void* s_StdoutCallbackClientData; static void* s_InterruptCallbackClientData; - - static std::string s_Windows9xComspecSubstitute; }; #endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ac655da..24fa0c5 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -16,18 +16,15 @@ #include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" #include "cmComputeLinkInformation.h" -#include "cmDocumentCompileDefinitions.h" -#include "cmDocumentGeneratorExpressions.h" -#include "cmDocumentLocationUndefined.h" #include "cmListFileCache.h" #include "cmGeneratorExpression.h" #include "cmGeneratorExpressionDAGChecker.h" #include <cmsys/RegularExpression.hxx> #include <map> #include <set> -#include <queue> #include <stdlib.h> // required for atof #include <assert.h> +#include <errno.h> const char* cmTarget::GetTargetTypeName(TargetType targetType) { @@ -47,6 +44,8 @@ const char* cmTarget::GetTargetTypeName(TargetType targetType) return "UTILITY"; case cmTarget::GLOBAL_TARGET: return "GLOBAL_TARGET"; + case cmTarget::INTERFACE_LIBRARY: + return "INTERFACE_LIBRARY"; case cmTarget::UNKNOWN_LIBRARY: return "UNKNOWN_LIBRARY"; } @@ -72,9 +71,9 @@ struct cmTarget::ImportInfo cmTarget::LinkInterface LinkInterface; }; -struct TargetConfigPair : public std::pair<cmTarget*, std::string> { - TargetConfigPair(cmTarget* tgt, const std::string &config) - : std::pair<cmTarget*, std::string>(tgt, config) {} +struct TargetConfigPair : public std::pair<cmTarget const* , std::string> { + TargetConfigPair(cmTarget const* tgt, const std::string &config) + : std::pair<cmTarget const* , std::string>(tgt, config) {} }; //---------------------------------------------------------------------------- @@ -83,19 +82,18 @@ class cmTargetInternals public: cmTargetInternals() { + this->PolicyWarnedCMP0022 = false; this->SourceFileFlagsConstructed = false; } - cmTargetInternals(cmTargetInternals const& r) + cmTargetInternals(cmTargetInternals const&) { + this->PolicyWarnedCMP0022 = false; this->SourceFileFlagsConstructed = false; - // Only some of these entries are part of the object state. - // Others not copied here are result caches. - this->SourceEntries = r.SourceEntries; } ~cmTargetInternals(); typedef cmTarget::SourceFileFlags SourceFileFlags; - std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap; - bool SourceFileFlagsConstructed; + mutable std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap; + mutable bool SourceFileFlagsConstructed; // The backtrace when the target was created. cmListFileBacktrace Backtrace; @@ -109,6 +107,7 @@ public: typedef std::map<TargetConfigPair, OptionalLinkInterface> LinkInterfaceMapType; LinkInterfaceMapType LinkInterfaceMap; + bool PolicyWarnedCMP0022; typedef std::map<cmStdString, cmTarget::OutputInfo> OutputInfoMapType; OutputInfoMapType OutputInfoMap; @@ -126,10 +125,6 @@ public: LinkClosureMapType; LinkClosureMapType LinkClosureMap; - struct SourceEntry { std::vector<cmSourceFile*> Depends; }; - typedef std::map<cmSourceFile*, SourceEntry> SourceEntriesType; - SourceEntriesType SourceEntries; - struct TargetPropertyEntry { TargetPropertyEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge, const std::string &targetName = std::string()) @@ -142,18 +137,18 @@ public: std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries; std::vector<TargetPropertyEntry*> CompileOptionsEntries; std::vector<TargetPropertyEntry*> CompileDefinitionsEntries; - std::vector<cmValueWithOrigin> LinkInterfacePropertyEntries; + std::vector<cmValueWithOrigin> LinkImplementationPropertyEntries; - std::map<std::string, std::vector<TargetPropertyEntry*> > + mutable std::map<std::string, std::vector<TargetPropertyEntry*> > CachedLinkInterfaceIncludeDirectoriesEntries; - std::map<std::string, std::vector<TargetPropertyEntry*> > + mutable std::map<std::string, std::vector<TargetPropertyEntry*> > CachedLinkInterfaceCompileOptionsEntries; - std::map<std::string, std::vector<TargetPropertyEntry*> > + mutable std::map<std::string, std::vector<TargetPropertyEntry*> > CachedLinkInterfaceCompileDefinitionsEntries; - std::map<std::string, bool> CacheLinkInterfaceIncludeDirectoriesDone; - std::map<std::string, bool> CacheLinkInterfaceCompileDefinitionsDone; - std::map<std::string, bool> CacheLinkInterfaceCompileOptionsDone; + mutable std::map<std::string, bool> CacheLinkInterfaceIncludeDirectoriesDone; + mutable std::map<std::string, bool> CacheLinkInterfaceCompileDefinitionsDone; + mutable std::map<std::string, bool> CacheLinkInterfaceCompileOptionsDone; }; //---------------------------------------------------------------------------- @@ -217,1370 +212,14 @@ cmTarget::cmTarget() void cmTarget::DefineProperties(cmake *cm) { cm->DefineProperty - ("AUTOMOC", cmProperty::TARGET, - "Should the target be processed with automoc (for Qt projects).", - "AUTOMOC is a boolean specifying whether CMake will handle " - "the Qt moc preprocessor automatically, i.e. without having to use " - "the QT4_WRAP_CPP() or QT5_WRAP_CPP() macro. Currently Qt4 and Qt5 are " - "supported. " - "When this property is set to TRUE, CMake will scan the source files " - "at build time and invoke moc accordingly. " - "If an #include statement like #include \"moc_foo.cpp\" is found, " - "the Q_OBJECT class declaration is expected in the header, and moc is " - "run on the header file. " - "If an #include statement like #include \"foo.moc\" is found, " - "then a Q_OBJECT is expected in the current source file and moc " - "is run on the file itself. " - "Additionally, all header files are parsed for Q_OBJECT macros, " - "and if found, moc is also executed on those files. The resulting " - "moc files, which are not included as shown above in any of the source " - "files are included in a generated <targetname>_automoc.cpp file, " - "which is compiled as part of the target." - "This property is initialized by the value of the variable " - "CMAKE_AUTOMOC if it is set when a target is created.\n" - "Additional command line options for moc can be set via the " - "AUTOMOC_MOC_OPTIONS property.\n" - "By setting the CMAKE_AUTOMOC_RELAXED_MODE variable to TRUE the rules " - "for searching the files which will be processed by moc can be relaxed. " - "See the documentation for this variable for more details.\n" - "The global property AUTOMOC_TARGETS_FOLDER can be used to group the " - "automoc targets together in an IDE, e.g. in MSVS."); - - cm->DefineProperty - ("AUTOMOC_MOC_OPTIONS", cmProperty::TARGET, - "Additional options for moc when using automoc (see the AUTOMOC property)", - "This property is only used if the AUTOMOC property is set to TRUE for " - "this target. In this case, it holds additional command line options " - "which will be used when moc is executed during the build, i.e. it is " - "equivalent to the optional OPTIONS argument of the qt4_wrap_cpp() " - "macro.\n" - "By default it is empty."); - - cm->DefineProperty - ("BUILD_WITH_INSTALL_RPATH", cmProperty::TARGET, - "Should build tree targets have install tree rpaths.", - "BUILD_WITH_INSTALL_RPATH is a boolean specifying whether to link " - "the target in the build tree with the INSTALL_RPATH. This takes " - "precedence over SKIP_BUILD_RPATH and avoids the need for relinking " - "before installation. " - "This property is initialized by the value of the variable " - "CMAKE_BUILD_WITH_INSTALL_RPATH if it is set when a target is created."); - - cm->DefineProperty - ("COMPILE_FLAGS", cmProperty::TARGET, - "Additional flags to use when compiling this target's sources.", - "The COMPILE_FLAGS property sets additional compiler flags used " - "to build sources within the target. Use COMPILE_DEFINITIONS " - "to pass additional preprocessor definitions."); - - cm->DefineProperty - ("COMPILE_DEFINITIONS", cmProperty::TARGET, - "Preprocessor definitions for compiling a target's sources.", - "The COMPILE_DEFINITIONS property may be set to a " - "semicolon-separated list of preprocessor " - "definitions using the syntax VAR or VAR=value. Function-style " - "definitions are not supported. CMake will automatically escape " - "the value correctly for the native build system (note that CMake " - "language syntax may require escapes to specify some values). " - "This property may be set on a per-configuration basis using the name " - "COMPILE_DEFINITIONS_<CONFIG> where <CONFIG> is an upper-case name " - "(ex. \"COMPILE_DEFINITIONS_DEBUG\").\n" - "CMake will automatically drop some definitions that " - "are not supported by the native build tool. " - "The VS6 IDE does not support definition values with spaces " - "(but NMake does).\n" - "Contents of COMPILE_DEFINITIONS may use \"generator expressions\" with " - "the syntax \"$<...>\". " - CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS - CM_DOCUMENT_COMPILE_DEFINITIONS_DISCLAIMER); - - cm->DefineProperty - ("COMPILE_DEFINITIONS_<CONFIG>", cmProperty::TARGET, - "Per-configuration preprocessor definitions on a target.", - "This is the configuration-specific version of COMPILE_DEFINITIONS."); - - cm->DefineProperty - ("COMPILE_OPTIONS", cmProperty::TARGET, - "List of options to pass to the compiler.", - "This property specifies the list of options specified " - "so far for this property. " - "This property exists on directories and targets." - "\n" - "The target property values are used by the generators to set " - "the options for the compiler.\n" - "Contents of COMPILE_OPTIONS may use \"generator expressions\" with " - "the syntax \"$<...>\". " - CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS); - - cm->DefineProperty - ("INTERFACE_COMPILE_OPTIONS", cmProperty::TARGET, - "List of interface options to pass to the compiler.", - "Targets may populate this property to publish the compile options " - "required to compile against the headers for the target. Consuming " - "targets can add entries to their own COMPILE_OPTIONS property such " - "as $<TARGET_PROPERTY:foo,INTERFACE_COMPILE_OPTIONS> to use the " - "compile options specified in the interface of 'foo'." - "\n" - CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS); - - cm->DefineProperty - ("DEFINE_SYMBOL", cmProperty::TARGET, - "Define a symbol when compiling this target's sources.", - "DEFINE_SYMBOL sets the name of the preprocessor symbol defined when " - "compiling sources in a shared library. " - "If not set here then it is set to target_EXPORTS by default " - "(with some substitutions if the target is not a valid C " - "identifier). This is useful for headers to know whether they are " - "being included from inside their library or outside to properly " - "setup dllexport/dllimport decorations. "); - - cm->DefineProperty - ("DEBUG_POSTFIX", cmProperty::TARGET, - "See target property <CONFIG>_POSTFIX.", - "This property is a special case of the more-general <CONFIG>_POSTFIX " - "property for the DEBUG configuration."); - - cm->DefineProperty - ("<CONFIG>_POSTFIX", cmProperty::TARGET, - "Postfix to append to the target file name for configuration <CONFIG>.", - "When building with configuration <CONFIG> the value of this property " - "is appended to the target file name built on disk. " - "For non-executable targets, this property is initialized by the value " - "of the variable CMAKE_<CONFIG>_POSTFIX if it is set when a target is " - "created. " - "This property is ignored on the Mac for Frameworks and App Bundles."); - - cm->DefineProperty - ("EchoString", cmProperty::TARGET, - "A message to be displayed when the target is built.", - "A message to display on some generators (such as makefiles) when " - "the target is built."); - - cm->DefineProperty - ("BUNDLE", cmProperty::TARGET, - "This target is a CFBundle on the Mac.", - "If a module library target has this property set to true it will " - "be built as a CFBundle when built on the mac. It will have the " - "directory structure required for a CFBundle and will be suitable " - "to be used for creating Browser Plugins or other application " - "resources."); - - cm->DefineProperty - ("BUNDLE_EXTENSION", cmProperty::TARGET, - "The file extension used to name a BUNDLE target on the Mac.", - "The default value is \"bundle\" - you can also use \"plugin\" or " - "whatever file extension is required by the host app for your " - "bundle."); - - cm->DefineProperty - ("EXCLUDE_FROM_DEFAULT_BUILD", cmProperty::TARGET, - "Exclude target from \"Build Solution\".", - "This property is only used by Visual Studio generators 7 and above. " - "When set to TRUE, the target will not be built when you press " - "\"Build Solution\"."); - - cm->DefineProperty - ("EXCLUDE_FROM_DEFAULT_BUILD_<CONFIG>", cmProperty::TARGET, - "Per-configuration version of target exclusion from \"Build Solution\". ", - "This is the configuration-specific version of " - "EXCLUDE_FROM_DEFAULT_BUILD. If the generic EXCLUDE_FROM_DEFAULT_BUILD " - "is also set on a target, EXCLUDE_FROM_DEFAULT_BUILD_<CONFIG> takes " - "precedence in configurations for which it has a value."); - - cm->DefineProperty - ("FRAMEWORK", cmProperty::TARGET, - "This target is a framework on the Mac.", - "If a shared library target has this property set to true it will " - "be built as a framework when built on the mac. It will have the " - "directory structure required for a framework and will be suitable " - "to be used with the -framework option"); - - cm->DefineProperty - ("HAS_CXX", cmProperty::TARGET, - "Link the target using the C++ linker tool (obsolete).", - "This is equivalent to setting the LINKER_LANGUAGE property to CXX. " - "See that property's documentation for details."); - - cm->DefineProperty - ("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM", cmProperty::TARGET, - "Specify #include line transforms for dependencies in a target.", - "This property specifies rules to transform macro-like #include lines " - "during implicit dependency scanning of C and C++ source files. " - "The list of rules must be semicolon-separated with each entry of " - "the form \"A_MACRO(%)=value-with-%\" (the % must be literal). " - "During dependency scanning occurrences of A_MACRO(...) on #include " - "lines will be replaced by the value given with the macro argument " - "substituted for '%'. For example, the entry\n" - " MYDIR(%)=<mydir/%>\n" - "will convert lines of the form\n" - " #include MYDIR(myheader.h)\n" - "to\n" - " #include <mydir/myheader.h>\n" - "allowing the dependency to be followed.\n" - "This property applies to sources in the target on which it is set."); - - cm->DefineProperty - ("IMPORT_PREFIX", cmProperty::TARGET, - "What comes before the import library name.", - "Similar to the target property PREFIX, but used for import libraries " - "(typically corresponding to a DLL) instead of regular libraries. " - "A target property that can be set to override the prefix " - "(such as \"lib\") on an import library name."); - - cm->DefineProperty - ("IMPORT_SUFFIX", cmProperty::TARGET, - "What comes after the import library name.", - "Similar to the target property SUFFIX, but used for import libraries " - "(typically corresponding to a DLL) instead of regular libraries. " - "A target property that can be set to override the suffix " - "(such as \".lib\") on an import library name."); - - cm->DefineProperty - ("IMPORTED", cmProperty::TARGET, - "Read-only indication of whether a target is IMPORTED.", - "The boolean value of this property is true for targets created with " - "the IMPORTED option to add_executable or add_library. " - "It is false for targets built within the project."); - - cm->DefineProperty - ("IMPORTED_CONFIGURATIONS", cmProperty::TARGET, - "Configurations provided for an IMPORTED target.", - "Set this to the list of configuration names available for an " - "IMPORTED target. " - "The names correspond to configurations defined in the project from " - "which the target is imported. " - "If the importing project uses a different set of configurations " - "the names may be mapped using the MAP_IMPORTED_CONFIG_<CONFIG> " - "property. " - "Ignored for non-imported targets."); - - cm->DefineProperty - ("IMPORTED_IMPLIB", cmProperty::TARGET, - "Full path to the import library for an IMPORTED target.", - "Set this to the location of the \".lib\" part of a windows DLL. " - "Ignored for non-imported targets."); - - cm->DefineProperty - ("IMPORTED_IMPLIB_<CONFIG>", cmProperty::TARGET, - "<CONFIG>-specific version of IMPORTED_IMPLIB property.", - "Configuration names correspond to those provided by the project " - "from which the target is imported."); - - cm->DefineProperty - ("IMPORTED_LINK_DEPENDENT_LIBRARIES", cmProperty::TARGET, - "Dependent shared libraries of an imported shared library.", - "Shared libraries may be linked to other shared libraries as part " - "of their implementation. On some platforms the linker searches " - "for the dependent libraries of shared libraries they are including " - "in the link. " - "Set this property to the list of dependent shared libraries of an " - "imported library. " - "The list " - "should be disjoint from the list of interface libraries in the " - "INTERFACE_LINK_LIBRARIES property. On platforms requiring " - "dependent shared libraries to be found at link time CMake uses this " - "list to add appropriate files or paths to the link command line. " - "Ignored for non-imported targets."); - - cm->DefineProperty - ("IMPORTED_LINK_DEPENDENT_LIBRARIES_<CONFIG>", cmProperty::TARGET, - "<CONFIG>-specific version of IMPORTED_LINK_DEPENDENT_LIBRARIES.", - "Configuration names correspond to those provided by the project " - "from which the target is imported. " - "If set, this property completely overrides the generic property " - "for the named configuration."); - - cm->DefineProperty - ("IMPORTED_LINK_INTERFACE_LIBRARIES", cmProperty::TARGET, - "Transitive link interface of an IMPORTED target.", - "Set this to the list of libraries whose interface is included when " - "an IMPORTED library target is linked to another target. " - "The libraries will be included on the link line for the target. " - "Unlike the LINK_INTERFACE_LIBRARIES property, this property applies " - "to all imported target types, including STATIC libraries. " - "This property is ignored for non-imported targets.\n" - "This property is ignored if the target also has a non-empty " - "INTERFACE_LINK_LIBRARIES property.\n" - "This property is deprecated. Use INTERFACE_LINK_LIBRARIES instead."); - - cm->DefineProperty - ("IMPORTED_LINK_INTERFACE_LIBRARIES_<CONFIG>", cmProperty::TARGET, - "<CONFIG>-specific version of IMPORTED_LINK_INTERFACE_LIBRARIES.", - "Configuration names correspond to those provided by the project " - "from which the target is imported. " - "If set, this property completely overrides the generic property " - "for the named configuration.\n" - "This property is ignored if the target also has a non-empty " - "INTERFACE_LINK_LIBRARIES property.\n" - "This property is deprecated. Use INTERFACE_LINK_LIBRARIES instead."); - - cm->DefineProperty - ("IMPORTED_LINK_INTERFACE_LANGUAGES", cmProperty::TARGET, - "Languages compiled into an IMPORTED static library.", - "Set this to the list of languages of source files compiled to " - "produce a STATIC IMPORTED library (such as \"C\" or \"CXX\"). " - "CMake accounts for these languages when computing how to link a " - "target to the imported library. " - "For example, when a C executable links to an imported C++ static " - "library CMake chooses the C++ linker to satisfy language runtime " - "dependencies of the static library. " - "\n" - "This property is ignored for targets that are not STATIC libraries. " - "This property is ignored for non-imported targets."); - - cm->DefineProperty - ("IMPORTED_LINK_INTERFACE_LANGUAGES_<CONFIG>", cmProperty::TARGET, - "<CONFIG>-specific version of IMPORTED_LINK_INTERFACE_LANGUAGES.", - "Configuration names correspond to those provided by the project " - "from which the target is imported. " - "If set, this property completely overrides the generic property " - "for the named configuration."); - - cm->DefineProperty - ("IMPORTED_LINK_INTERFACE_MULTIPLICITY", cmProperty::TARGET, - "Repetition count for cycles of IMPORTED static libraries.", - "This is LINK_INTERFACE_MULTIPLICITY for IMPORTED targets."); - cm->DefineProperty - ("IMPORTED_LINK_INTERFACE_MULTIPLICITY_<CONFIG>", cmProperty::TARGET, - "<CONFIG>-specific version of IMPORTED_LINK_INTERFACE_MULTIPLICITY.", - "If set, this property completely overrides the generic property " - "for the named configuration."); - - cm->DefineProperty - ("IMPORTED_LOCATION", cmProperty::TARGET, - "Full path to the main file on disk for an IMPORTED target.", - "Set this to the location of an IMPORTED target file on disk. " - "For executables this is the location of the executable file. " - "For bundles on OS X this is the location of the executable file " - "inside Contents/MacOS under the application bundle folder. " - "For static libraries and modules this is the location of the " - "library or module. " - "For shared libraries on non-DLL platforms this is the location of " - "the shared library. " - "For frameworks on OS X this is the location of the library file " - "symlink just inside the framework folder. " - "For DLLs this is the location of the \".dll\" part of the library. " - "For UNKNOWN libraries this is the location of the file to be linked. " - "Ignored for non-imported targets." - "\n" - "Projects may skip IMPORTED_LOCATION if the configuration-specific " - "property IMPORTED_LOCATION_<CONFIG> is set. " - "To get the location of an imported target read one of the " - "LOCATION or LOCATION_<CONFIG> properties."); - - cm->DefineProperty - ("IMPORTED_LOCATION_<CONFIG>", cmProperty::TARGET, - "<CONFIG>-specific version of IMPORTED_LOCATION property.", - "Configuration names correspond to those provided by the project " - "from which the target is imported."); - - cm->DefineProperty - ("IMPORTED_SONAME", cmProperty::TARGET, - "The \"soname\" of an IMPORTED target of shared library type.", - "Set this to the \"soname\" embedded in an imported shared library. " - "This is meaningful only on platforms supporting the feature. " - "Ignored for non-imported targets."); - - cm->DefineProperty - ("IMPORTED_SONAME_<CONFIG>", cmProperty::TARGET, - "<CONFIG>-specific version of IMPORTED_SONAME property.", - "Configuration names correspond to those provided by the project " - "from which the target is imported."); - - cm->DefineProperty - ("IMPORTED_NO_SONAME", cmProperty::TARGET, - "Specifies that an IMPORTED shared library target has no \"soname\". ", - "Set this property to true for an imported shared library file that " - "has no \"soname\" field. " - "CMake may adjust generated link commands for some platforms to prevent " - "the linker from using the path to the library in place of its missing " - "soname. " - "Ignored for non-imported targets."); - - cm->DefineProperty - ("IMPORTED_NO_SONAME_<CONFIG>", cmProperty::TARGET, - "<CONFIG>-specific version of IMPORTED_NO_SONAME property.", - "Configuration names correspond to those provided by the project " - "from which the target is imported."); - - cm->DefineProperty - ("EXCLUDE_FROM_ALL", cmProperty::TARGET, - "Exclude the target from the all target.", - "A property on a target that indicates if the target is excluded " - "from the default build target. If it is not, then with a Makefile " - "for example typing make will cause this target to be built. " - "The same concept applies to the default build of other generators. " - "Installing a target with EXCLUDE_FROM_ALL set to true has " - "undefined behavior."); - - cm->DefineProperty - ("LINK_LIBRARIES", cmProperty::TARGET, - "List of direct link dependencies.", - "This property specifies the list of libraries or targets which will be " - "used for linking. " - "In addition to accepting values from the target_link_libraries " - "command, values may be set directly on any target using the " - "set_property command. " - "\n" - "The target property values are used by the generators to set " - "the link libraries for the compiler. " - "See also the target_link_libraries command.\n" - "Contents of LINK_LIBRARIES may use \"generator expressions\" with " - "the syntax \"$<...>\". " - CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS); - - cm->DefineProperty - ("INCLUDE_DIRECTORIES", cmProperty::TARGET, - "List of preprocessor include file search directories.", - "This property specifies the list of directories given " - "so far to the include_directories command. " - "This property exists on directories and targets. " - "In addition to accepting values from the include_directories " - "command, values may be set directly on any directory or any " - "target using the set_property command. " - "A target gets its initial value for this property from the value " - "of the directory property. " - "A directory gets its initial value from its parent directory if " - "it has one. " - "Both directory and target property values are adjusted by calls " - "to the include_directories command." - "\n" - "The target property values are used by the generators to set " - "the include paths for the compiler. " - "See also the include_directories command.\n" - "Contents of INCLUDE_DIRECTORIES may use \"generator expressions\" with " - "the syntax \"$<...>\". " - CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS); - - cm->DefineProperty - ("INSTALL_NAME_DIR", cmProperty::TARGET, - "Mac OSX directory name for installed targets.", - "INSTALL_NAME_DIR is a string specifying the " - "directory portion of the \"install_name\" field of shared libraries " - "on Mac OSX to use in the installed targets. "); - - cm->DefineProperty - ("INSTALL_RPATH", cmProperty::TARGET, - "The rpath to use for installed targets.", - "A semicolon-separated list specifying the rpath " - "to use in installed targets (for platforms that support it). " - "This property is initialized by the value of the variable " - "CMAKE_INSTALL_RPATH if it is set when a target is created."); - - cm->DefineProperty - ("INSTALL_RPATH_USE_LINK_PATH", cmProperty::TARGET, - "Add paths to linker search and installed rpath.", - "INSTALL_RPATH_USE_LINK_PATH is a boolean that if set to true will " - "append directories in the linker search path and outside the " - "project to the INSTALL_RPATH. " - "This property is initialized by the value of the variable " - "CMAKE_INSTALL_RPATH_USE_LINK_PATH if it is set when a target is " - "created."); - - cm->DefineProperty - ("INTERPROCEDURAL_OPTIMIZATION", cmProperty::TARGET, - "Enable interprocedural optimization for a target.", - "If set to true, enables interprocedural optimizations " - "if they are known to be supported by the compiler."); - - cm->DefineProperty - ("INTERPROCEDURAL_OPTIMIZATION_<CONFIG>", cmProperty::TARGET, - "Per-configuration interprocedural optimization for a target.", - "This is a per-configuration version of INTERPROCEDURAL_OPTIMIZATION. " - "If set, this property overrides the generic property " - "for the named configuration."); - - cm->DefineProperty - ("LABELS", cmProperty::TARGET, - "Specify a list of text labels associated with a target.", - "Target label semantics are currently unspecified."); - - cm->DefineProperty - ("LINK_FLAGS", cmProperty::TARGET, - "Additional flags to use when linking this target.", - "The LINK_FLAGS property can be used to add extra flags to the " - "link step of a target. LINK_FLAGS_<CONFIG> will add to the " - "configuration <CONFIG>, " - "for example, DEBUG, RELEASE, MINSIZEREL, RELWITHDEBINFO. "); - - cm->DefineProperty - ("LINK_FLAGS_<CONFIG>", cmProperty::TARGET, - "Per-configuration linker flags for a target.", - "This is the configuration-specific version of LINK_FLAGS."); - -#define CM_LINK_SEARCH_SUMMARY \ - "Some linkers support switches such as -Bstatic and -Bdynamic " \ - "to determine whether to use static or shared libraries for -lXXX " \ - "options. CMake uses these options to set the link type for " \ - "libraries whose full paths are not known or (in some cases) are in " \ - "implicit link directories for the platform. " - - cm->DefineProperty - ("LINK_SEARCH_START_STATIC", cmProperty::TARGET, - "Assume the linker looks for static libraries by default.", - CM_LINK_SEARCH_SUMMARY - "By default the linker search type is assumed to be -Bdynamic at " - "the beginning of the library list. This property switches the " - "assumption to -Bstatic. It is intended for use when linking an " - "executable statically (e.g. with the GNU -static option). " - "See also LINK_SEARCH_END_STATIC."); - - cm->DefineProperty - ("LINK_SEARCH_END_STATIC", cmProperty::TARGET, - "End a link line such that static system libraries are used.", - CM_LINK_SEARCH_SUMMARY - "By default CMake adds an option at the end of the library list (if " - "necessary) to set the linker search type back to its starting type. " - "This property switches the final linker search type to -Bstatic " - "regardless of how it started. " - "See also LINK_SEARCH_START_STATIC."); - - cm->DefineProperty - ("LINKER_LANGUAGE", cmProperty::TARGET, - "Specifies language whose compiler will invoke the linker.", - "For executables, shared libraries, and modules, this sets the " - "language whose compiler is used to link the target " - "(such as \"C\" or \"CXX\"). " - "A typical value for an executable is the language of the source " - "file providing the program entry point (main). " - "If not set, the language with the highest linker preference " - "value is the default. " - "See documentation of CMAKE_<LANG>_LINKER_PREFERENCE variables." - "\n" - "If this property is not set by the user, it will be calculated at " - "generate-time by CMake." - ); - - cm->DefineProperty - ("LOCATION", cmProperty::TARGET, - "Read-only location of a target on disk.", - "For an imported target, this read-only property returns the value of " - "the LOCATION_<CONFIG> property for an unspecified configuration " - "<CONFIG> provided by the target.\n" - "For a non-imported target, this property is provided for compatibility " - "with CMake 2.4 and below. " - "It was meant to get the location of an executable target's output file " - "for use in add_custom_command. " - "The path may contain a build-system-specific portion that " - "is replaced at build time with the configuration getting built " - "(such as \"$(ConfigurationName)\" in VS). " - "In CMake 2.6 and above add_custom_command automatically recognizes a " - "target name in its COMMAND and DEPENDS options and computes the " - "target location. " - "In CMake 2.8.4 and above add_custom_command recognizes generator " - "expressions to refer to target locations anywhere in the command. " - "Therefore this property is not needed for creating custom commands." - CM_LOCATION_UNDEFINED_BEHAVIOR("reading this property")); - - cm->DefineProperty - ("LOCATION_<CONFIG>", cmProperty::TARGET, - "Read-only property providing a target location on disk.", - "A read-only property that indicates where a target's main file is " - "located on disk for the configuration <CONFIG>. " - "The property is defined only for library and executable targets. " - "An imported target may provide a set of configurations different " - "from that of the importing project. " - "By default CMake looks for an exact-match but otherwise uses an " - "arbitrary available configuration. " - "Use the MAP_IMPORTED_CONFIG_<CONFIG> property to map imported " - "configurations explicitly." - CM_LOCATION_UNDEFINED_BEHAVIOR("reading this property")); - - cm->DefineProperty - ("LINK_DEPENDS", cmProperty::TARGET, - "Additional files on which a target binary depends for linking.", - "Specifies a semicolon-separated list of full-paths to files on which " - "the link rule for this target depends. " - "The target binary will be linked if any of the named files is newer " - "than it." - "\n" - "This property is ignored by non-Makefile generators. " - "It is intended to specify dependencies on \"linker scripts\" for " - "custom Makefile link rules."); - - cm->DefineProperty - ("LINK_DEPENDS_NO_SHARED", cmProperty::TARGET, - "Do not depend on linked shared library files.", - "Set this property to true to tell CMake generators not to add " - "file-level dependencies on the shared library files linked by " - "this target. " - "Modification to the shared libraries will not be sufficient to " - "re-link this target. " - "Logical target-level dependencies will not be affected so the " - "linked shared libraries will still be brought up to date before " - "this target is built." - "\n" - "This property is initialized by the value of the variable " - "CMAKE_LINK_DEPENDS_NO_SHARED if it is set when a target is " - "created."); - - cm->DefineProperty - ("LINK_INTERFACE_LIBRARIES", cmProperty::TARGET, - "List public interface libraries for a shared library or executable.", - "By default linking to a shared library target transitively " - "links to targets with which the library itself was linked. " - "For an executable with exports (see the ENABLE_EXPORTS property) " - "no default transitive link dependencies are used. " - "This property replaces the default transitive link dependencies with " - "an explicit list. " - "When the target is linked into another target the libraries " - "listed (and recursively their link interface libraries) will be " - "provided to the other target also. " - "If the list is empty then no transitive link dependencies will be " - "incorporated when this target is linked into another target even if " - "the default set is non-empty. " - "This property is initialized by the value of the variable " - "CMAKE_LINK_INTERFACE_LIBRARIES if it is set when a target is " - "created. " - "This property is ignored for STATIC libraries.\n" - "This property is overriden by the INTERFACE_LINK_LIBRARIES property if " - "policy CMP0022 is NEW.\n" - "This property is deprecated. Use INTERFACE_LINK_LIBRARIES instead."); - - cm->DefineProperty - ("LINK_INTERFACE_LIBRARIES_<CONFIG>", cmProperty::TARGET, - "Per-configuration list of public interface libraries for a target.", - "This is the configuration-specific version of " - "LINK_INTERFACE_LIBRARIES. " - "If set, this property completely overrides the generic property " - "for the named configuration.\n" - "This property is overriden by the INTERFACE_LINK_LIBRARIES property if " - "policy CMP0022 is NEW.\n" - "This property is deprecated. Use INTERFACE_LINK_LIBRARIES instead."); - - cm->DefineProperty - ("INTERFACE_LINK_LIBRARIES", cmProperty::TARGET, - "List public interface libraries for a shared library or executable.", - "This property contains the list of transitive link dependencies. " - "When the target is linked into another target the libraries " - "listed (and recursively their link interface libraries) will be " - "provided to the other target also. " - "This property is overriden by the LINK_INTERFACE_LIBRARIES or " - "LINK_INTERFACE_LIBRARIES_<CONFIG> property if " - "policy CMP0022 is OLD or unset.\n" - "\n" - CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS); - - cm->DefineProperty - ("INTERFACE_INCLUDE_DIRECTORIES", cmProperty::TARGET, - "List of public include directories for a library.", - "Targets may populate this property to publish the include directories " - "required to compile against the headers for the target. Consuming " - "targets can add entries to their own INCLUDE_DIRECTORIES property such " - "as $<TARGET_PROPERTY:foo,INTERFACE_INCLUDE_DIRECTORIES> to use the " - "include directories specified in the interface of 'foo'." - "\n" - CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS); - - cm->DefineProperty - ("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", cmProperty::TARGET, - "List of public system include directories for a library.", - "Targets may populate this property to publish the include directories " - "which contain system headers, and therefore should not result in " - "compiler warnings. Consuming targets will then mark the same include " - "directories as system headers." - "\n" - CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS); - - cm->DefineProperty - ("INTERFACE_COMPILE_DEFINITIONS", cmProperty::TARGET, - "List of public compile definitions for a library.", - "Targets may populate this property to publish the compile definitions " - "required to compile against the headers for the target. Consuming " - "targets can add entries to their own COMPILE_DEFINITIONS property such " - "as $<TARGET_PROPERTY:foo,INTERFACE_COMPILE_DEFINITIONS> to use the " - "compile definitions specified in the interface of 'foo'." - "\n" - CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS); - - cm->DefineProperty - ("LINK_INTERFACE_MULTIPLICITY", cmProperty::TARGET, - "Repetition count for STATIC libraries with cyclic dependencies.", - "When linking to a STATIC library target with cyclic dependencies the " - "linker may need to scan more than once through the archives in the " - "strongly connected component of the dependency graph. " - "CMake by default constructs the link line so that the linker will " - "scan through the component at least twice. " - "This property specifies the minimum number of scans if it is larger " - "than the default. " - "CMake uses the largest value specified by any target in a component."); - cm->DefineProperty - ("LINK_INTERFACE_MULTIPLICITY_<CONFIG>", cmProperty::TARGET, - "Per-configuration repetition count for cycles of STATIC libraries.", - "This is the configuration-specific version of " - "LINK_INTERFACE_MULTIPLICITY. " - "If set, this property completely overrides the generic property " - "for the named configuration."); - - cm->DefineProperty - ("MAP_IMPORTED_CONFIG_<CONFIG>", cmProperty::TARGET, - "Map from project configuration to IMPORTED target's configuration.", - "Set this to the list of configurations of an imported target that " - "may be used for the current project's <CONFIG> configuration. " - "Targets imported from another project may not provide the same set " - "of configuration names available in the current project. " - "Setting this property tells CMake what imported configurations are " - "suitable for use when building the <CONFIG> configuration. " - "The first configuration in the list found to be provided by the " - "imported target is selected. If this property is set and no matching " - "configurations are available, then the imported target is considered " - "to be not found. This property is ignored for non-imported targets.", - false /* TODO: make this chained */ ); - - cm->DefineProperty - ("OSX_ARCHITECTURES", cmProperty::TARGET, - "Target specific architectures for OS X.", - "The OSX_ARCHITECTURES property sets the target binary architecture " - "for targets on OS X. " - "This property is initialized by the value of the variable " - "CMAKE_OSX_ARCHITECTURES if it is set when a target is created. " - "Use OSX_ARCHITECTURES_<CONFIG> to set the binary architectures on a " - "per-configuration basis. " - "<CONFIG> is an upper-case name (ex: \"OSX_ARCHITECTURES_DEBUG\")."); - - cm->DefineProperty - ("OSX_ARCHITECTURES_<CONFIG>", cmProperty::TARGET, - "Per-configuration OS X binary architectures for a target.", - "This property is the configuration-specific version of " - "OSX_ARCHITECTURES."); - - cm->DefineProperty - ("NAME", cmProperty::TARGET, - "Logical name for the target.", - "Read-only logical name for the target as used by CMake."); - - cm->DefineProperty - ("EXPORT_NAME", cmProperty::TARGET, - "Exported name for target files.", - "This sets the name for the IMPORTED target generated when it this " - "target is is exported. " - "If not set, the logical target name is used by default."); - - cm->DefineProperty - ("OUTPUT_NAME", cmProperty::TARGET, - "Output name for target files.", - "This sets the base name for output files created for an executable or " - "library target. " - "If not set, the logical target name is used by default."); - - cm->DefineProperty - ("OUTPUT_NAME_<CONFIG>", cmProperty::TARGET, - "Per-configuration target file base name.", - "This is the configuration-specific version of OUTPUT_NAME."); - - cm->DefineProperty - ("ALIASED_TARGET", cmProperty::TARGET, - "Name of target aliased by this target.", - "If this is an ALIAS target, this property contains the name of the " - "target aliased."); - - cm->DefineProperty - ("<CONFIG>_OUTPUT_NAME", cmProperty::TARGET, - "Old per-configuration target file base name.", - "This is a configuration-specific version of OUTPUT_NAME. " - "Use OUTPUT_NAME_<CONFIG> instead."); - - cm->DefineProperty - ("PDB_NAME", cmProperty::TARGET, - "Output name for MS debug symbols .pdb file from linker.", - "Set the base name for debug symbols file created for an " - "executable or shared library target. " - "If not set, the logical target name is used by default. " - "\n" - "This property is not implemented by the Visual Studio 6 generator."); - - cm->DefineProperty - ("PDB_NAME_<CONFIG>", cmProperty::TARGET, - "Per-configuration name for MS debug symbols .pdb file. ", - "This is the configuration-specific version of PDB_NAME. " - "\n" - "This property is not implemented by the Visual Studio 6 generator."); - - cm->DefineProperty - ("PRE_INSTALL_SCRIPT", cmProperty::TARGET, - "Deprecated install support.", - "The PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT properties are the " - "old way to specify CMake scripts to run before and after " - "installing a target. They are used only when the old " - "INSTALL_TARGETS command is used to install the target. Use the " - "INSTALL command instead."); - - cm->DefineProperty - ("PREFIX", cmProperty::TARGET, - "What comes before the library name.", - "A target property that can be set to override the prefix " - "(such as \"lib\") on a library name."); - - cm->DefineProperty - ("<LANG>_VISIBILITY_PRESET", cmProperty::TARGET, - "Value for symbol visibility compile flags", - "The <LANG>_VISIBILITY_PRESET property determines the value passed in " - "a visibility related compile option, such as -fvisibility= for <LANG>. " - "This property only has an affect for libraries and executables with " - "exports. This property is initialized by the value of the variable " - "CMAKE_<LANG>_VISIBILITY_PRESET if it is set when a target is created."); - - cm->DefineProperty - ("VISIBILITY_INLINES_HIDDEN", cmProperty::TARGET, - "Whether to add a compile flag to hide symbols of inline functions", - "The VISIBILITY_INLINES_HIDDEN property determines whether a flag for " - "hiding symbols for inline functions. the value passed used in " - "a visibility related compile option, such as -fvisibility=. This " - "property only has an affect for libraries and executables with " - "exports. This property is initialized by the value of the variable " - "CMAKE_VISIBILITY_INLINES_HIDDEN if it is set when a target is " - "created."); - - cm->DefineProperty - ("POSITION_INDEPENDENT_CODE", cmProperty::TARGET, - "Whether to create a position-independent target", - "The POSITION_INDEPENDENT_CODE property determines whether position " - "independent executables or shared libraries will be created. " - "This property is true by default for SHARED and MODULE library " - "targets and false otherwise. " - "This property is initialized by the value of the variable " - "CMAKE_POSITION_INDEPENDENT_CODE if it is set when a target is " - "created."); - - cm->DefineProperty - ("INTERFACE_POSITION_INDEPENDENT_CODE", cmProperty::TARGET, - "Whether consumers need to create a position-independent target", - "The INTERFACE_POSITION_INDEPENDENT_CODE property informs consumers of " - "this target whether they must set their POSITION_INDEPENDENT_CODE " - "property to ON. If this property is set to ON, then the " - "POSITION_INDEPENDENT_CODE property on all consumers will be set to " - "ON. Similarly, if this property is set to OFF, then the " - "POSITION_INDEPENDENT_CODE property on all consumers will be set to " - "OFF. If this property is undefined, then consumers will determine " - "their POSITION_INDEPENDENT_CODE property by other means. Consumers " - "must ensure that the targets that they link to have a consistent " - "requirement for their INTERFACE_POSITION_INDEPENDENT_CODE property."); - - cm->DefineProperty - ("COMPATIBLE_INTERFACE_BOOL", cmProperty::TARGET, - "Properties which must be compatible with their link interface", - "The COMPATIBLE_INTERFACE_BOOL property may contain a list of properties" - "for this target which must be consistent when evaluated as a boolean " - "in the INTERFACE of all linked dependees. For example, if a " - "property \"FOO\" appears in the list, then for each dependee, the " - "\"INTERFACE_FOO\" property content in all of its dependencies must be " - "consistent with each other, and with the \"FOO\" property in the " - "dependee. Consistency in this sense has the meaning that if the " - "property is set, then it must have the same boolean value as all " - "others, and if the property is not set, then it is ignored. Note that " - "for each dependee, the set of properties from this property must not " - "intersect with the set of properties from the " - "COMPATIBLE_INTERFACE_STRING property."); - - cm->DefineProperty - ("COMPATIBLE_INTERFACE_STRING", cmProperty::TARGET, - "Properties which must be string-compatible with their link interface", - "The COMPATIBLE_INTERFACE_STRING property may contain a list of " - "properties for this target which must be the same when evaluated as " - "a string in the INTERFACE of all linked dependees. For example, " - "if a property \"FOO\" appears in the list, then for each dependee, the " - "\"INTERFACE_FOO\" property content in all of its dependencies must be " - "equal with each other, and with the \"FOO\" property in the dependee. " - "If the property is not set, then it is ignored. Note that for each " - "dependee, the set of properties from this property must not intersect " - "with the set of properties from the COMPATIBLE_INTERFACE_BOOL " - "property."); - - cm->DefineProperty - ("POST_INSTALL_SCRIPT", cmProperty::TARGET, - "Deprecated install support.", - "The PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT properties are the " - "old way to specify CMake scripts to run before and after " - "installing a target. They are used only when the old " - "INSTALL_TARGETS command is used to install the target. Use the " - "INSTALL command instead."); - - cm->DefineProperty - ("PRIVATE_HEADER", cmProperty::TARGET, - "Specify private header files in a FRAMEWORK shared library target.", - "Shared library targets marked with the FRAMEWORK property generate " - "frameworks on OS X and normal shared libraries on other platforms. " - "This property may be set to a list of header files to be placed " - "in the PrivateHeaders directory inside the framework folder. " - "On non-Apple platforms these headers may be installed using the " - "PRIVATE_HEADER option to the install(TARGETS) command."); - - cm->DefineProperty - ("PUBLIC_HEADER", cmProperty::TARGET, - "Specify public header files in a FRAMEWORK shared library target.", - "Shared library targets marked with the FRAMEWORK property generate " - "frameworks on OS X and normal shared libraries on other platforms. " - "This property may be set to a list of header files to be placed " - "in the Headers directory inside the framework folder. " - "On non-Apple platforms these headers may be installed using the " - "PUBLIC_HEADER option to the install(TARGETS) command."); - - cm->DefineProperty - ("RESOURCE", cmProperty::TARGET, - "Specify resource files in a FRAMEWORK shared library target.", - "Shared library targets marked with the FRAMEWORK property generate " - "frameworks on OS X and normal shared libraries on other platforms. " - "This property may be set to a list of files to be placed " - "in the Resources directory inside the framework folder. " - "On non-Apple platforms these files may be installed using the " - "RESOURCE option to the install(TARGETS) command."); - - cm->DefineProperty ("RULE_LAUNCH_COMPILE", cmProperty::TARGET, - "Specify a launcher for compile rules.", - "See the global property of the same name for details. " - "This overrides the global and directory property for a target.", - true); + "", "", true); cm->DefineProperty ("RULE_LAUNCH_LINK", cmProperty::TARGET, - "Specify a launcher for link rules.", - "See the global property of the same name for details. " - "This overrides the global and directory property for a target.", - true); + "", "", true); cm->DefineProperty ("RULE_LAUNCH_CUSTOM", cmProperty::TARGET, - "Specify a launcher for custom rules.", - "See the global property of the same name for details. " - "This overrides the global and directory property for a target.", - true); - - cm->DefineProperty - ("SKIP_BUILD_RPATH", cmProperty::TARGET, - "Should rpaths be used for the build tree.", - "SKIP_BUILD_RPATH is a boolean specifying whether to skip automatic " - "generation of an rpath allowing the target to run from the " - "build tree. " - "This property is initialized by the value of the variable " - "CMAKE_SKIP_BUILD_RPATH if it is set when a target is created."); - - cm->DefineProperty - ("NO_SONAME", cmProperty::TARGET, - "Whether to set \"soname\" when linking a shared library or module.", - "Enable this boolean property if a generated shared library or module " - "should not have \"soname\" set. Default is to set \"soname\" on all " - "shared libraries and modules as long as the platform supports it. " - "Generally, use this property only for leaf private libraries or " - "plugins. If you use it on normal shared libraries which other targets " - "link against, on some platforms a linker will insert a full path to " - "the library (as specified at link time) into the dynamic section of " - "the dependent binary. Therefore, once installed, dynamic loader may " - "eventually fail to locate the library for the binary."); - - cm->DefineProperty - ("SOVERSION", cmProperty::TARGET, - "What version number is this target.", - "For shared libraries VERSION and SOVERSION can be used to specify " - "the build version and API version respectively. When building or " - "installing appropriate symlinks are created if the platform " - "supports symlinks and the linker supports so-names. " - "If only one of both is specified the missing is assumed to have " - "the same version number. " - "SOVERSION is ignored if NO_SONAME property is set. " - "For shared libraries and executables on Windows the VERSION " - "attribute is parsed to extract a \"major.minor\" version number. " - "These numbers are used as the image version of the binary. "); - - cm->DefineProperty - ("STATIC_LIBRARY_FLAGS", cmProperty::TARGET, - "Extra flags to use when linking static libraries.", - "Extra flags to use when linking a static library."); - - cm->DefineProperty - ("STATIC_LIBRARY_FLAGS_<CONFIG>", cmProperty::TARGET, - "Per-configuration flags for creating a static library.", - "This is the configuration-specific version of STATIC_LIBRARY_FLAGS."); - - cm->DefineProperty - ("SUFFIX", cmProperty::TARGET, - "What comes after the target name.", - "A target property that can be set to override the suffix " - "(such as \".so\" or \".exe\") on the name of a library, module or " - "executable."); - - cm->DefineProperty - ("TYPE", cmProperty::TARGET, - "The type of the target.", - "This read-only property can be used to test the type of the given " - "target. It will be one of STATIC_LIBRARY, MODULE_LIBRARY, " - "SHARED_LIBRARY, EXECUTABLE or one of the internal target types."); - - cm->DefineProperty - ("VERSION", cmProperty::TARGET, - "What version number is this target.", - "For shared libraries VERSION and SOVERSION can be used to specify " - "the build version and API version respectively. When building or " - "installing appropriate symlinks are created if the platform " - "supports symlinks and the linker supports so-names. " - "If only one of both is specified the missing is assumed to have " - "the same version number. " - "For executables VERSION can be used to specify the build version. " - "When building or installing appropriate symlinks are created if " - "the platform supports symlinks. " - "For shared libraries and executables on Windows the VERSION " - "attribute is parsed to extract a \"major.minor\" version number. " - "These numbers are used as the image version of the binary. "); - - - cm->DefineProperty - ("WIN32_EXECUTABLE", cmProperty::TARGET, - "Build an executable with a WinMain entry point on windows.", - "When this property is set to true the executable when linked " - "on Windows will be created with a WinMain() entry point instead " - "of just main(). " - "This makes it a GUI executable instead of a console application. " - "See the CMAKE_MFC_FLAG variable documentation to configure use " - "of MFC for WinMain executables. " - "This property is initialized by the value of the variable " - "CMAKE_WIN32_EXECUTABLE if it is set when a target is created."); - - cm->DefineProperty - ("MACOSX_BUNDLE", cmProperty::TARGET, - "Build an executable as an application bundle on Mac OS X.", - "When this property is set to true the executable when built " - "on Mac OS X will be created as an application bundle. " - "This makes it a GUI executable that can be launched from " - "the Finder. " - "See the MACOSX_BUNDLE_INFO_PLIST target property for information " - "about creation of the Info.plist file for the application bundle. " - "This property is initialized by the value of the variable " - "CMAKE_MACOSX_BUNDLE if it is set when a target is created."); - - cm->DefineProperty - ("MACOSX_BUNDLE_INFO_PLIST", cmProperty::TARGET, - "Specify a custom Info.plist template for a Mac OS X App Bundle.", - "An executable target with MACOSX_BUNDLE enabled will be built as an " - "application bundle on Mac OS X. " - "By default its Info.plist file is created by configuring a template " - "called MacOSXBundleInfo.plist.in located in the CMAKE_MODULE_PATH. " - "This property specifies an alternative template file name which " - "may be a full path.\n" - "The following target properties may be set to specify content to " - "be configured into the file:\n" - " MACOSX_BUNDLE_INFO_STRING\n" - " MACOSX_BUNDLE_ICON_FILE\n" - " MACOSX_BUNDLE_GUI_IDENTIFIER\n" - " MACOSX_BUNDLE_LONG_VERSION_STRING\n" - " MACOSX_BUNDLE_BUNDLE_NAME\n" - " MACOSX_BUNDLE_SHORT_VERSION_STRING\n" - " MACOSX_BUNDLE_BUNDLE_VERSION\n" - " MACOSX_BUNDLE_COPYRIGHT\n" - "CMake variables of the same name may be set to affect all targets " - "in a directory that do not have each specific property set. " - "If a custom Info.plist is specified by this property it may of course " - "hard-code all the settings instead of using the target properties."); - - cm->DefineProperty - ("MACOSX_FRAMEWORK_INFO_PLIST", cmProperty::TARGET, - "Specify a custom Info.plist template for a Mac OS X Framework.", - "A library target with FRAMEWORK enabled will be built as a " - "framework on Mac OS X. " - "By default its Info.plist file is created by configuring a template " - "called MacOSXFrameworkInfo.plist.in located in the CMAKE_MODULE_PATH. " - "This property specifies an alternative template file name which " - "may be a full path.\n" - "The following target properties may be set to specify content to " - "be configured into the file:\n" - " MACOSX_FRAMEWORK_ICON_FILE\n" - " MACOSX_FRAMEWORK_IDENTIFIER\n" - " MACOSX_FRAMEWORK_SHORT_VERSION_STRING\n" - " MACOSX_FRAMEWORK_BUNDLE_VERSION\n" - "CMake variables of the same name may be set to affect all targets " - "in a directory that do not have each specific property set. " - "If a custom Info.plist is specified by this property it may of course " - "hard-code all the settings instead of using the target properties."); - - cm->DefineProperty - ("MACOSX_RPATH", cmProperty::TARGET, - "Whether to use rpaths on Mac OS X.", - "When this property is set to true, the directory portion of the" - "\"install_name\" field of shared libraries will default to \"@rpath\"." - "Runtime paths will also be embedded in binaries using this target." - "This property is initialized by the value of the variable " - "CMAKE_MACOSX_RPATH if it is set when a target is created."); - - cm->DefineProperty - ("ENABLE_EXPORTS", cmProperty::TARGET, - "Specify whether an executable exports symbols for loadable modules.", - "Normally an executable does not export any symbols because it is " - "the final program. It is possible for an executable to export " - "symbols to be used by loadable modules. When this property is " - "set to true CMake will allow other targets to \"link\" to the " - "executable with the TARGET_LINK_LIBRARIES command. " - "On all platforms a target-level dependency on the executable is " - "created for targets that link to it. " - "For DLL platforms an import library will be created for the " - "exported symbols and then used for linking. " - "All Windows-based systems including Cygwin are DLL platforms. " - "For non-DLL platforms that require all symbols to be resolved at " - "link time, such as Mac OS X, the module will \"link\" to the " - "executable using a flag like \"-bundle_loader\". " - "For other non-DLL platforms the link rule is simply ignored since " - "the dynamic loader will automatically bind symbols when the " - "module is loaded. " - ); - - cm->DefineProperty - ("Fortran_FORMAT", cmProperty::TARGET, - "Set to FIXED or FREE to indicate the Fortran source layout.", - "This property tells CMake whether the Fortran source files " - "in a target use fixed-format or free-format. " - "CMake will pass the corresponding format flag to the compiler. " - "Use the source-specific Fortran_FORMAT property to change the " - "format of a specific source file. " - "If the variable CMAKE_Fortran_FORMAT is set when a target " - "is created its value is used to initialize this property."); - - cm->DefineProperty - ("Fortran_MODULE_DIRECTORY", cmProperty::TARGET, - "Specify output directory for Fortran modules provided by the target.", - "If the target contains Fortran source files that provide modules " - "and the compiler supports a module output directory this specifies " - "the directory in which the modules will be placed. " - "When this property is not set the modules will be placed in the " - "build directory corresponding to the target's source directory. " - "If the variable CMAKE_Fortran_MODULE_DIRECTORY is set when a target " - "is created its value is used to initialize this property." - "\n" - "Note that some compilers will automatically search the module output " - "directory for modules USEd during compilation but others will not. " - "If your sources USE modules their location must be specified by " - "INCLUDE_DIRECTORIES regardless of this property."); - - cm->DefineProperty - ("GNUtoMS", cmProperty::TARGET, - "Convert GNU import library (.dll.a) to MS format (.lib).", - "When linking a shared library or executable that exports symbols " - "using GNU tools on Windows (MinGW/MSYS) with Visual Studio installed " - "convert the import library (.dll.a) from GNU to MS format (.lib). " - "Both import libraries will be installed by install(TARGETS) and " - "exported by install(EXPORT) and export() to be linked by applications " - "with either GNU- or MS-compatible tools." - "\n" - "If the variable CMAKE_GNUtoMS is set when a target " - "is created its value is used to initialize this property. " - "The variable must be set prior to the first command that enables " - "a language such as project() or enable_language(). " - "CMake provides the variable as an option to the user automatically " - "when configuring on Windows with GNU tools."); - - cm->DefineProperty - ("XCODE_ATTRIBUTE_<an-attribute>", cmProperty::TARGET, - "Set Xcode target attributes directly.", - "Tell the Xcode generator to set '<an-attribute>' to a given value " - "in the generated Xcode project. Ignored on other generators."); - - cm->DefineProperty - ("GENERATOR_FILE_NAME", cmProperty::TARGET, - "Generator's file for this target.", - "An internal property used by some generators to record the name of the " - "project or dsp file associated with this target. Note that at configure " - "time, this property is only set for targets created by " - "include_external_msproject()."); - - cm->DefineProperty - ("SOURCES", cmProperty::TARGET, - "Source names specified for a target.", - "Read-only list of sources specified for a target. " - "The names returned are suitable for passing to the " - "set_source_files_properties command."); - - cm->DefineProperty - ("FOLDER", cmProperty::TARGET, - "Set the folder name. Use to organize targets in an IDE.", - "Targets with no FOLDER property will appear as top level " - "entities in IDEs like Visual Studio. Targets with the same " - "FOLDER property value will appear next to each other in a " - "folder of that name. To nest folders, use FOLDER values such " - "as 'GUI/Dialogs' with '/' characters separating folder levels."); - - cm->DefineProperty - ("PROJECT_LABEL", cmProperty::TARGET, - "Change the name of a target in an IDE.", - "Can be used to change the name of the target in an IDE " - "like Visual Studio. "); - cm->DefineProperty - ("VS_KEYWORD", cmProperty::TARGET, - "Visual Studio project keyword.", - "Can be set to change the visual studio keyword, for example " - "Qt integration works better if this is set to Qt4VSv1.0. "); - cm->DefineProperty - ("VS_SCC_PROVIDER", cmProperty::TARGET, - "Visual Studio Source Code Control Provider.", - "Can be set to change the visual studio source code control " - "provider property."); - cm->DefineProperty - ("VS_SCC_LOCALPATH", cmProperty::TARGET, - "Visual Studio Source Code Control Local Path.", - "Can be set to change the visual studio source code control " - "local path property."); - cm->DefineProperty - ("VS_SCC_PROJECTNAME", cmProperty::TARGET, - "Visual Studio Source Code Control Project.", - "Can be set to change the visual studio source code control " - "project name property."); - cm->DefineProperty - ("VS_SCC_AUXPATH", cmProperty::TARGET, - "Visual Studio Source Code Control Aux Path.", - "Can be set to change the visual studio source code control " - "auxpath property."); - cm->DefineProperty - ("VS_GLOBAL_PROJECT_TYPES", cmProperty::TARGET, - "Visual Studio project type(s).", - "Can be set to one or more UUIDs recognized by Visual Studio " - "to indicate the type of project. This value is copied " - "verbatim into the generated project file. Example for a " - "managed C++ unit testing project:\n" - " {3AC096D0-A1C2-E12C-1390-A8335801FDAB};" - "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\n" - "UUIDs are semicolon-delimited."); - cm->DefineProperty - ("VS_GLOBAL_KEYWORD", cmProperty::TARGET, - "Visual Studio project keyword.", - "Sets the \"keyword\" attribute for a generated Visual Studio " - "project. Defaults to \"Win32Proj\". You may wish to override " - "this value with \"ManagedCProj\", for example, in a Visual " - "Studio managed C++ unit test project."); - cm->DefineProperty - ("VS_GLOBAL_ROOTNAMESPACE", cmProperty::TARGET, - "Visual Studio project root namespace.", - "Sets the \"RootNamespace\" attribute for a generated Visual Studio " - "project. The attribute will be generated only if this is set."); - cm->DefineProperty - ("VS_DOTNET_TARGET_FRAMEWORK_VERSION", cmProperty::TARGET, - "Specify the .NET target framework version.", - "Used to specify the .NET target framework version for C++/CLI. " - "For example, \"v4.5\"."); - cm->DefineProperty - ("VS_DOTNET_REFERENCES", cmProperty::TARGET, - "Visual Studio managed project .NET references", - "Adds one or more semicolon-delimited .NET references to a " - "generated Visual Studio project. For example, \"System;" - "System.Windows.Forms\"."); - cm->DefineProperty - ("VS_WINRT_EXTENSIONS", cmProperty::TARGET, - "Visual Studio project C++/CX language extensions for Windows Runtime", - "Can be set to enable C++/CX language extensions."); - cm->DefineProperty - ("VS_WINRT_REFERENCES", cmProperty::TARGET, - "Visual Studio project Windows Runtime Metadata references", - "Adds one or more semicolon-delimited WinRT references to a " - "generated Visual Studio project. For example, \"Windows;" - "Windows.UI.Core\"."); - cm->DefineProperty - ("VS_GLOBAL_<variable>", cmProperty::TARGET, - "Visual Studio project-specific global variable.", - "Tell the Visual Studio generator to set the global variable " - "'<variable>' to a given value in the generated Visual Studio " - "project. Ignored on other generators. Qt integration works " - "better if VS_GLOBAL_QtVersion is set to the version " - "FindQt4.cmake found. For example, \"4.7.3\""); - -#define CM_TARGET_FILE_TYPES_DOC \ - "There are three kinds of target files that may be built: " \ - "archive, library, and runtime. " \ - "Executables are always treated as runtime targets. " \ - "Static libraries are always treated as archive targets. " \ - "Module libraries are always treated as library targets. " \ - "For non-DLL platforms shared libraries are treated as library " \ - "targets. " \ - "For DLL platforms the DLL part of a shared library is treated as " \ - "a runtime target and the corresponding import library is treated as " \ - "an archive target. " \ - "All Windows-based systems including Cygwin are DLL platforms." - -#define CM_TARGET_OUTDIR_DOC(TYPE, type) \ - "This property specifies the directory into which " #type " target " \ - "files should be built. " \ - "Multi-configuration generators (VS, Xcode) append " \ - "a per-configuration subdirectory to the specified directory. " \ - CM_TARGET_FILE_TYPES_DOC " " \ - "This property is initialized by the value of the variable " \ - "CMAKE_" #TYPE "_OUTPUT_DIRECTORY if it is set when a target is created." - -#define CM_TARGET_OUTDIR_CONFIG_DOC(TYPE) \ - "This is a per-configuration version of " #TYPE "_OUTPUT_DIRECTORY, " \ - "but multi-configuration generators (VS, Xcode) do NOT append " \ - "a per-configuration subdirectory to the specified directory. " \ - "This property is initialized by the value of the variable " \ - "CMAKE_" #TYPE "_OUTPUT_DIRECTORY_<CONFIG> " \ - "if it is set when a target is created." - - cm->DefineProperty - ("ARCHIVE_OUTPUT_DIRECTORY", cmProperty::TARGET, - "Output directory in which to build ARCHIVE target files.", - CM_TARGET_OUTDIR_DOC(ARCHIVE, archive)); - cm->DefineProperty - ("ARCHIVE_OUTPUT_DIRECTORY_<CONFIG>", cmProperty::TARGET, - "Per-configuration output directory for ARCHIVE target files.", - CM_TARGET_OUTDIR_CONFIG_DOC(ARCHIVE)); - cm->DefineProperty - ("LIBRARY_OUTPUT_DIRECTORY", cmProperty::TARGET, - "Output directory in which to build LIBRARY target files.", - CM_TARGET_OUTDIR_DOC(LIBRARY, library)); - cm->DefineProperty - ("LIBRARY_OUTPUT_DIRECTORY_<CONFIG>", cmProperty::TARGET, - "Per-configuration output directory for LIBRARY target files.", - CM_TARGET_OUTDIR_CONFIG_DOC(LIBRARY)); - cm->DefineProperty - ("RUNTIME_OUTPUT_DIRECTORY", cmProperty::TARGET, - "Output directory in which to build RUNTIME target files.", - CM_TARGET_OUTDIR_DOC(RUNTIME, runtime)); - cm->DefineProperty - ("RUNTIME_OUTPUT_DIRECTORY_<CONFIG>", cmProperty::TARGET, - "Per-configuration output directory for RUNTIME target files.", - CM_TARGET_OUTDIR_CONFIG_DOC(RUNTIME)); - - cm->DefineProperty - ("PDB_OUTPUT_DIRECTORY", cmProperty::TARGET, - "Output directory for MS debug symbols .pdb file from linker.", - "This property specifies the directory into which the MS debug symbols " - "will be placed by the linker. " - "This property is initialized by the value of the variable " - "CMAKE_PDB_OUTPUT_DIRECTORY if it is set when a target is created." - "\n" - "This property is not implemented by the Visual Studio 6 generator."); - cm->DefineProperty - ("PDB_OUTPUT_DIRECTORY_<CONFIG>", cmProperty::TARGET, - "Per-configuration output directory for MS debug symbols .pdb files.", - "This is a per-configuration version of PDB_OUTPUT_DIRECTORY, " - "but multi-configuration generators (VS, Xcode) do NOT append " - "a per-configuration subdirectory to the specified directory. " - "This property is initialized by the value of the variable " - "CMAKE_PDB_OUTPUT_DIRECTORY_<CONFIG> " - "if it is set when a target is created." - "\n" - "This property is not implemented by the Visual Studio 6 generator."); - - cm->DefineProperty - ("ARCHIVE_OUTPUT_NAME", cmProperty::TARGET, - "Output name for ARCHIVE target files.", - "This property specifies the base name for archive target files. " - "It overrides OUTPUT_NAME and OUTPUT_NAME_<CONFIG> properties. " - CM_TARGET_FILE_TYPES_DOC); - cm->DefineProperty - ("ARCHIVE_OUTPUT_NAME_<CONFIG>", cmProperty::TARGET, - "Per-configuration output name for ARCHIVE target files.", - "This is the configuration-specific version of ARCHIVE_OUTPUT_NAME."); - cm->DefineProperty - ("LIBRARY_OUTPUT_NAME", cmProperty::TARGET, - "Output name for LIBRARY target files.", - "This property specifies the base name for library target files. " - "It overrides OUTPUT_NAME and OUTPUT_NAME_<CONFIG> properties. " - CM_TARGET_FILE_TYPES_DOC); - cm->DefineProperty - ("LIBRARY_OUTPUT_NAME_<CONFIG>", cmProperty::TARGET, - "Per-configuration output name for LIBRARY target files.", - "This is the configuration-specific version of LIBRARY_OUTPUT_NAME."); - cm->DefineProperty - ("RUNTIME_OUTPUT_NAME", cmProperty::TARGET, - "Output name for RUNTIME target files.", - "This property specifies the base name for runtime target files. " - "It overrides OUTPUT_NAME and OUTPUT_NAME_<CONFIG> properties. " - CM_TARGET_FILE_TYPES_DOC); - cm->DefineProperty - ("RUNTIME_OUTPUT_NAME_<CONFIG>", cmProperty::TARGET, - "Per-configuration output name for RUNTIME target files.", - "This is the configuration-specific version of RUNTIME_OUTPUT_NAME."); + "", "", true); } void cmTarget::SetType(TargetType type, const char* name) @@ -1617,27 +256,34 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->IsApple = this->Makefile->IsOn("APPLE"); // Setup default property values. - this->SetPropertyDefault("INSTALL_NAME_DIR", 0); - this->SetPropertyDefault("INSTALL_RPATH", ""); - this->SetPropertyDefault("INSTALL_RPATH_USE_LINK_PATH", "OFF"); - this->SetPropertyDefault("SKIP_BUILD_RPATH", "OFF"); - this->SetPropertyDefault("BUILD_WITH_INSTALL_RPATH", "OFF"); - this->SetPropertyDefault("ARCHIVE_OUTPUT_DIRECTORY", 0); - this->SetPropertyDefault("LIBRARY_OUTPUT_DIRECTORY", 0); - this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", 0); - this->SetPropertyDefault("PDB_OUTPUT_DIRECTORY", 0); - this->SetPropertyDefault("Fortran_FORMAT", 0); - this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0); - this->SetPropertyDefault("GNUtoMS", 0); - this->SetPropertyDefault("OSX_ARCHITECTURES", 0); - this->SetPropertyDefault("AUTOMOC", 0); - this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", 0); - this->SetPropertyDefault("LINK_DEPENDS_NO_SHARED", 0); - this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", 0); - this->SetPropertyDefault("WIN32_EXECUTABLE", 0); - this->SetPropertyDefault("MACOSX_BUNDLE", 0); - this->SetPropertyDefault("MACOSX_RPATH", 0); - + if (this->GetType() != INTERFACE_LIBRARY) + { + this->SetPropertyDefault("INSTALL_NAME_DIR", 0); + this->SetPropertyDefault("INSTALL_RPATH", ""); + this->SetPropertyDefault("INSTALL_RPATH_USE_LINK_PATH", "OFF"); + this->SetPropertyDefault("SKIP_BUILD_RPATH", "OFF"); + this->SetPropertyDefault("BUILD_WITH_INSTALL_RPATH", "OFF"); + this->SetPropertyDefault("ARCHIVE_OUTPUT_DIRECTORY", 0); + this->SetPropertyDefault("LIBRARY_OUTPUT_DIRECTORY", 0); + this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", 0); + this->SetPropertyDefault("PDB_OUTPUT_DIRECTORY", 0); + this->SetPropertyDefault("Fortran_FORMAT", 0); + this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0); + this->SetPropertyDefault("GNUtoMS", 0); + this->SetPropertyDefault("OSX_ARCHITECTURES", 0); + this->SetPropertyDefault("AUTOMOC", 0); + this->SetPropertyDefault("AUTOUIC", 0); + this->SetPropertyDefault("AUTORCC", 0); + this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", 0); + this->SetPropertyDefault("AUTOUIC_OPTIONS", 0); + this->SetPropertyDefault("AUTORCC_OPTIONS", 0); + this->SetPropertyDefault("LINK_DEPENDS_NO_SHARED", 0); + this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", 0); + this->SetPropertyDefault("WIN32_EXECUTABLE", 0); + this->SetPropertyDefault("MACOSX_BUNDLE", 0); + this->SetPropertyDefault("MACOSX_RPATH", 0); + this->SetPropertyDefault("NO_SYSTEM_FROM_IMPORTED", 0); + } // Collect the set of configuration types. std::vector<std::string> configNames; @@ -1649,6 +295,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) "LIBRARY_OUTPUT_DIRECTORY_", "RUNTIME_OUTPUT_DIRECTORY_", "PDB_OUTPUT_DIRECTORY_", + "MAP_IMPORTED_CONFIG_", 0}; for(std::vector<std::string>::iterator ci = configNames.begin(); ci != configNames.end(); ++ci) @@ -1656,6 +303,11 @@ void cmTarget::SetMakefile(cmMakefile* mf) std::string configUpper = cmSystemTools::UpperCase(*ci); for(const char** p = configProps; *p; ++p) { + if (this->TargetTypeValue == INTERFACE_LIBRARY + && strcmp(*p, "MAP_IMPORTED_CONFIG_") != 0) + { + continue; + } std::string property = *p; property += configUpper; this->SetPropertyDefault(property.c_str(), 0); @@ -1667,7 +319,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) // did not support this variable. Projects may still specify the // property directly. TODO: Make this depend on backwards // compatibility setting. - if(this->TargetTypeValue != cmTarget::EXECUTABLE) + if(this->TargetTypeValue != cmTarget::EXECUTABLE + && this->TargetTypeValue != cmTarget::INTERFACE_LIBRARY) { std::string property = cmSystemTools::UpperCase(*ci); property += "_POSTFIX"; @@ -1678,46 +331,54 @@ void cmTarget::SetMakefile(cmMakefile* mf) // Save the backtrace of target construction. this->Makefile->GetBacktrace(this->Internal->Backtrace); - // Initialize the INCLUDE_DIRECTORIES property based on the current value - // of the same directory property: - const std::vector<cmValueWithOrigin> parentIncludes = - this->Makefile->GetIncludeDirectoriesEntries(); - - for (std::vector<cmValueWithOrigin>::const_iterator it - = parentIncludes.begin(); it != parentIncludes.end(); ++it) + if (!this->IsImported()) { - this->InsertInclude(*it); - } + // Initialize the INCLUDE_DIRECTORIES property based on the current value + // of the same directory property: + const std::vector<cmValueWithOrigin> parentIncludes = + this->Makefile->GetIncludeDirectoriesEntries(); - const std::set<cmStdString> parentSystemIncludes = - this->Makefile->GetSystemIncludeDirectories(); + for (std::vector<cmValueWithOrigin>::const_iterator it + = parentIncludes.begin(); it != parentIncludes.end(); ++it) + { + this->InsertInclude(*it); + } + const std::set<cmStdString> parentSystemIncludes = + this->Makefile->GetSystemIncludeDirectories(); - for (std::set<cmStdString>::const_iterator it - = parentSystemIncludes.begin(); - it != parentSystemIncludes.end(); ++it) - { - this->SystemIncludeDirectories.insert(*it); - } + for (std::set<cmStdString>::const_iterator it + = parentSystemIncludes.begin(); + it != parentSystemIncludes.end(); ++it) + { + this->SystemIncludeDirectories.insert(*it); + } - const std::vector<cmValueWithOrigin> parentOptions = - this->Makefile->GetCompileOptionsEntries(); + const std::vector<cmValueWithOrigin> parentOptions = + this->Makefile->GetCompileOptionsEntries(); - for (std::vector<cmValueWithOrigin>::const_iterator it - = parentOptions.begin(); it != parentOptions.end(); ++it) - { - this->InsertCompileOption(*it); + for (std::vector<cmValueWithOrigin>::const_iterator it + = parentOptions.begin(); it != parentOptions.end(); ++it) + { + this->InsertCompileOption(*it); + } } - this->SetPropertyDefault("C_VISIBILITY_PRESET", 0); - this->SetPropertyDefault("CXX_VISIBILITY_PRESET", 0); - this->SetPropertyDefault("VISIBILITY_INLINES_HIDDEN", 0); + if (this->GetType() != INTERFACE_LIBRARY) + { + this->SetPropertyDefault("C_VISIBILITY_PRESET", 0); + this->SetPropertyDefault("CXX_VISIBILITY_PRESET", 0); + this->SetPropertyDefault("VISIBILITY_INLINES_HIDDEN", 0); + } if(this->TargetTypeValue == cmTarget::SHARED_LIBRARY || this->TargetTypeValue == cmTarget::MODULE_LIBRARY) { this->SetProperty("POSITION_INDEPENDENT_CODE", "True"); } - this->SetPropertyDefault("POSITION_INDEPENDENT_CODE", 0); + if (this->GetType() != INTERFACE_LIBRARY) + { + this->SetPropertyDefault("POSITION_INDEPENDENT_CODE", 0); + } // Record current policies for later use. #define CAPTURE_TARGET_POLICY(POLICY) \ @@ -1727,6 +388,37 @@ void cmTarget::SetMakefile(cmMakefile* mf) CM_FOR_EACH_TARGET_POLICY(CAPTURE_TARGET_POLICY) #undef CAPTURE_TARGET_POLICY + + if (this->TargetTypeValue == INTERFACE_LIBRARY) + { + // This policy is checked in a few conditions. The properties relevant + // to the policy are always ignored for INTERFACE_LIBRARY targets, + // so ensure that the conditions don't lead to nonsense. + this->PolicyStatusCMP0022 = cmPolicies::NEW; + } + + this->SetPropertyDefault("JOB_POOL_COMPILE", 0); + this->SetPropertyDefault("JOB_POOL_LINK", 0); +} + +//---------------------------------------------------------------------------- +void cmTarget::AddUtility(const char *u, cmMakefile *makefile) +{ + this->Utilities.insert(u); + if(makefile) + { + makefile->GetBacktrace(UtilityBacktraces[u]); + } +} + +//---------------------------------------------------------------------------- +cmListFileBacktrace const* cmTarget::GetUtilityBacktrace(const char *u) const +{ + std::map<cmStdString, cmListFileBacktrace>::const_iterator i = + this->UtilityBacktraces.find(u); + if(i == this->UtilityBacktraces.end()) return 0; + + return &i->second; } //---------------------------------------------------------------------------- @@ -1779,24 +471,25 @@ std::string cmTarget::GetSupportDirectory() const } //---------------------------------------------------------------------------- -bool cmTarget::IsExecutableWithExports() +bool cmTarget::IsExecutableWithExports() const { return (this->GetType() == cmTarget::EXECUTABLE && this->GetPropertyAsBool("ENABLE_EXPORTS")); } //---------------------------------------------------------------------------- -bool cmTarget::IsLinkable() +bool cmTarget::IsLinkable() const { return (this->GetType() == cmTarget::STATIC_LIBRARY || this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY || this->GetType() == cmTarget::UNKNOWN_LIBRARY || + this->GetType() == cmTarget::INTERFACE_LIBRARY || this->IsExecutableWithExports()); } //---------------------------------------------------------------------------- -bool cmTarget::HasImportLibrary() +bool cmTarget::HasImportLibrary() const { return (this->DLLPlatform && (this->GetType() == cmTarget::SHARED_LIBRARY || @@ -1804,7 +497,7 @@ bool cmTarget::HasImportLibrary() } //---------------------------------------------------------------------------- -bool cmTarget::IsFrameworkOnApple() +bool cmTarget::IsFrameworkOnApple() const { return (this->GetType() == cmTarget::SHARED_LIBRARY && this->Makefile->IsOn("APPLE") && @@ -1812,7 +505,7 @@ bool cmTarget::IsFrameworkOnApple() } //---------------------------------------------------------------------------- -bool cmTarget::IsAppBundleOnApple() +bool cmTarget::IsAppBundleOnApple() const { return (this->GetType() == cmTarget::EXECUTABLE && this->Makefile->IsOn("APPLE") && @@ -1820,7 +513,7 @@ bool cmTarget::IsAppBundleOnApple() } //---------------------------------------------------------------------------- -bool cmTarget::IsCFBundleOnApple() +bool cmTarget::IsCFBundleOnApple() const { return (this->GetType() == cmTarget::MODULE_LIBRARY && this->Makefile->IsOn("APPLE") && @@ -1828,292 +521,13 @@ bool cmTarget::IsCFBundleOnApple() } //---------------------------------------------------------------------------- -bool cmTarget::IsBundleOnApple() +bool cmTarget::IsBundleOnApple() const { return this->IsFrameworkOnApple() || this->IsAppBundleOnApple() || this->IsCFBundleOnApple(); } //---------------------------------------------------------------------------- -class cmTargetTraceDependencies -{ -public: - cmTargetTraceDependencies(cmTarget* target, cmTargetInternals* internal); - void Trace(); -private: - cmTarget* Target; - cmTargetInternals* Internal; - cmMakefile* Makefile; - cmGlobalGenerator* GlobalGenerator; - typedef cmTargetInternals::SourceEntry SourceEntry; - SourceEntry* CurrentEntry; - std::queue<cmSourceFile*> SourceQueue; - std::set<cmSourceFile*> SourcesQueued; - typedef std::map<cmStdString, cmSourceFile*> NameMapType; - NameMapType NameMap; - - void QueueSource(cmSourceFile* sf); - void FollowName(std::string const& name); - void FollowNames(std::vector<std::string> const& names); - bool IsUtility(std::string const& dep); - void CheckCustomCommand(cmCustomCommand const& cc); - void CheckCustomCommands(const std::vector<cmCustomCommand>& commands); -}; - -//---------------------------------------------------------------------------- -cmTargetTraceDependencies -::cmTargetTraceDependencies(cmTarget* target, cmTargetInternals* internal): - Target(target), Internal(internal) -{ - // Convenience. - this->Makefile = this->Target->GetMakefile(); - this->GlobalGenerator = - this->Makefile->GetLocalGenerator()->GetGlobalGenerator(); - this->CurrentEntry = 0; - - // Queue all the source files already specified for the target. - std::vector<cmSourceFile*> const& sources = this->Target->GetSourceFiles(); - for(std::vector<cmSourceFile*>::const_iterator si = sources.begin(); - si != sources.end(); ++si) - { - this->QueueSource(*si); - } - - // Queue pre-build, pre-link, and post-build rule dependencies. - this->CheckCustomCommands(this->Target->GetPreBuildCommands()); - this->CheckCustomCommands(this->Target->GetPreLinkCommands()); - this->CheckCustomCommands(this->Target->GetPostBuildCommands()); -} - -//---------------------------------------------------------------------------- -void cmTargetTraceDependencies::Trace() -{ - // Process one dependency at a time until the queue is empty. - while(!this->SourceQueue.empty()) - { - // Get the next source from the queue. - cmSourceFile* sf = this->SourceQueue.front(); - this->SourceQueue.pop(); - this->CurrentEntry = &this->Internal->SourceEntries[sf]; - - // Queue dependencies added explicitly by the user. - if(const char* additionalDeps = sf->GetProperty("OBJECT_DEPENDS")) - { - std::vector<std::string> objDeps; - cmSystemTools::ExpandListArgument(additionalDeps, objDeps); - this->FollowNames(objDeps); - } - - // Queue the source needed to generate this file, if any. - this->FollowName(sf->GetFullPath()); - - // Queue dependencies added programatically by commands. - this->FollowNames(sf->GetDepends()); - - // Queue custom command dependencies. - if(cmCustomCommand const* cc = sf->GetCustomCommand()) - { - this->CheckCustomCommand(*cc); - } - } - this->CurrentEntry = 0; -} - -//---------------------------------------------------------------------------- -void cmTargetTraceDependencies::QueueSource(cmSourceFile* sf) -{ - if(this->SourcesQueued.insert(sf).second) - { - this->SourceQueue.push(sf); - - // Make sure this file is in the target. - this->Target->AddSourceFile(sf); - } -} - -//---------------------------------------------------------------------------- -void cmTargetTraceDependencies::FollowName(std::string const& name) -{ - NameMapType::iterator i = this->NameMap.find(name); - if(i == this->NameMap.end()) - { - // Check if we know how to generate this file. - cmSourceFile* sf = this->Makefile->GetSourceFileWithOutput(name.c_str()); - NameMapType::value_type entry(name, sf); - i = this->NameMap.insert(entry).first; - } - if(cmSourceFile* sf = i->second) - { - // Record the dependency we just followed. - if(this->CurrentEntry) - { - this->CurrentEntry->Depends.push_back(sf); - } - - this->QueueSource(sf); - } -} - -//---------------------------------------------------------------------------- -void -cmTargetTraceDependencies::FollowNames(std::vector<std::string> const& names) -{ - for(std::vector<std::string>::const_iterator i = names.begin(); - i != names.end(); ++i) - { - this->FollowName(*i); - } -} - -//---------------------------------------------------------------------------- -bool cmTargetTraceDependencies::IsUtility(std::string const& dep) -{ - // Dependencies on targets (utilities) are supposed to be named by - // just the target name. However for compatibility we support - // naming the output file generated by the target (assuming there is - // no output-name property which old code would not have set). In - // that case the target name will be the file basename of the - // dependency. - std::string util = cmSystemTools::GetFilenameName(dep); - if(cmSystemTools::GetFilenameLastExtension(util) == ".exe") - { - util = cmSystemTools::GetFilenameWithoutLastExtension(util); - } - - // Check for a target with this name. - if(cmTarget* t = this->Makefile->FindTargetToUse(util.c_str())) - { - // If we find the target and the dep was given as a full path, - // then make sure it was not a full path to something else, and - // the fact that the name matched a target was just a coincidence. - if(cmSystemTools::FileIsFullPath(dep.c_str())) - { - if(t->GetType() >= cmTarget::EXECUTABLE && - t->GetType() <= cmTarget::MODULE_LIBRARY) - { - // This is really only for compatibility so we do not need to - // worry about configuration names and output names. - std::string tLocation = t->GetLocation(0); - tLocation = cmSystemTools::GetFilenamePath(tLocation); - std::string depLocation = cmSystemTools::GetFilenamePath(dep); - depLocation = cmSystemTools::CollapseFullPath(depLocation.c_str()); - tLocation = cmSystemTools::CollapseFullPath(tLocation.c_str()); - if(depLocation == tLocation) - { - this->Target->AddUtility(util.c_str()); - return true; - } - } - } - else - { - // The original name of the dependency was not a full path. It - // must name a target, so add the target-level dependency. - this->Target->AddUtility(util.c_str()); - return true; - } - } - - // The dependency does not name a target built in this project. - return false; -} - -//---------------------------------------------------------------------------- -void -cmTargetTraceDependencies -::CheckCustomCommand(cmCustomCommand const& cc) -{ - // Transform command names that reference targets built in this - // project to corresponding target-level dependencies. - cmGeneratorExpression ge(cc.GetBacktrace()); - - // Add target-level dependencies referenced by generator expressions. - std::set<cmTarget*> targets; - - for(cmCustomCommandLines::const_iterator cit = cc.GetCommandLines().begin(); - cit != cc.GetCommandLines().end(); ++cit) - { - std::string const& command = *cit->begin(); - // Check for a target with this name. - if(cmTarget* t = this->Makefile->FindTargetToUse(command.c_str())) - { - if(t->GetType() == cmTarget::EXECUTABLE) - { - // The command refers to an executable target built in - // this project. Add the target-level dependency to make - // sure the executable is up to date before this custom - // command possibly runs. - this->Target->AddUtility(command.c_str()); - } - } - - // Check for target references in generator expressions. - for(cmCustomCommandLine::const_iterator cli = cit->begin(); - cli != cit->end(); ++cli) - { - const cmsys::auto_ptr<cmCompiledGeneratorExpression> cge - = ge.Parse(*cli); - cge->Evaluate(this->Makefile, 0, true); - std::set<cmTarget*> geTargets = cge->GetTargets(); - for(std::set<cmTarget*>::const_iterator it = geTargets.begin(); - it != geTargets.end(); ++it) - { - targets.insert(*it); - } - } - } - - for(std::set<cmTarget*>::iterator ti = targets.begin(); - ti != targets.end(); ++ti) - { - this->Target->AddUtility((*ti)->GetName()); - } - - // Queue the custom command dependencies. - std::vector<std::string> const& depends = cc.GetDepends(); - for(std::vector<std::string>::const_iterator di = depends.begin(); - di != depends.end(); ++di) - { - std::string const& dep = *di; - if(!this->IsUtility(dep)) - { - // The dependency does not name a target and may be a file we - // know how to generate. Queue it. - this->FollowName(dep); - } - } -} - -//---------------------------------------------------------------------------- -void -cmTargetTraceDependencies -::CheckCustomCommands(const std::vector<cmCustomCommand>& commands) -{ - for(std::vector<cmCustomCommand>::const_iterator cli = commands.begin(); - cli != commands.end(); ++cli) - { - this->CheckCustomCommand(*cli); - } -} - -//---------------------------------------------------------------------------- -void cmTarget::TraceDependencies() -{ - // CMake-generated targets have no dependencies to trace. Normally tracing - // would find nothing anyway, but when building CMake itself the "install" - // target command ends up referencing the "cmake" target but we do not - // really want the dependency because "install" depend on "all" anyway. - if(this->GetType() == cmTarget::GLOBAL_TARGET) - { - return; - } - - // Use a helper object to trace the dependencies. - cmTargetTraceDependencies tracer(this, this->Internal.Get()); - tracer.Trace(); -} - -//---------------------------------------------------------------------------- bool cmTarget::FindSourceFiles() { for(std::vector<cmSourceFile*>::const_iterator @@ -2136,39 +550,22 @@ bool cmTarget::FindSourceFiles() } //---------------------------------------------------------------------------- -std::vector<cmSourceFile*> const& cmTarget::GetSourceFiles() +void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files) const { - return this->SourceFiles; + files = this->SourceFiles; } //---------------------------------------------------------------------------- void cmTarget::AddSourceFile(cmSourceFile* sf) { - typedef cmTargetInternals::SourceEntriesType SourceEntriesType; - SourceEntriesType::iterator i = this->Internal->SourceEntries.find(sf); - if(i == this->Internal->SourceEntries.end()) + if (std::find(this->SourceFiles.begin(), this->SourceFiles.end(), sf) + == this->SourceFiles.end()) { - typedef cmTargetInternals::SourceEntry SourceEntry; - SourceEntriesType::value_type entry(sf, SourceEntry()); - i = this->Internal->SourceEntries.insert(entry).first; this->SourceFiles.push_back(sf); } } //---------------------------------------------------------------------------- -std::vector<cmSourceFile*> const* -cmTarget::GetSourceDepends(cmSourceFile* sf) -{ - typedef cmTargetInternals::SourceEntriesType SourceEntriesType; - SourceEntriesType::iterator i = this->Internal->SourceEntries.find(sf); - if(i != this->Internal->SourceEntries.end()) - { - return &i->second.Depends; - } - return 0; -} - -//---------------------------------------------------------------------------- void cmTarget::AddSources(std::vector<std::string> const& srcs) { for(std::vector<std::string>::const_iterator i = srcs.begin(); @@ -2203,7 +600,7 @@ cmSourceFile* cmTarget::AddSource(const char* s) //---------------------------------------------------------------------------- void cmTarget::ProcessSourceExpression(std::string const& expr) { - if(strncmp(expr.c_str(), "$<TARGET_OBJECTS:", 17) == 0 && + if(cmHasLiteralPrefix(expr.c_str(), "$<TARGET_OBJECTS:") && expr[expr.size()-1] == '>') { std::string objLibName = expr.substr(17, expr.size()-18); @@ -2220,7 +617,7 @@ void cmTarget::ProcessSourceExpression(std::string const& expr) //---------------------------------------------------------------------------- struct cmTarget::SourceFileFlags -cmTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) +cmTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const { struct SourceFileFlags flags; this->ConstructSourceFileFlags(); @@ -2234,7 +631,7 @@ cmTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) } //---------------------------------------------------------------------------- -void cmTarget::ConstructSourceFileFlags() +void cmTarget::ConstructSourceFileFlags() const { if(this->Internal->SourceFileFlagsConstructed) { @@ -2296,7 +693,8 @@ void cmTarget::ConstructSourceFileFlags() // Handle the MACOSX_PACKAGE_LOCATION property on source files that // were not listed in one of the other lists. - std::vector<cmSourceFile*> const& sources = this->GetSourceFiles(); + std::vector<cmSourceFile*> sources; + this->GetSourceFiles(sources); for(std::vector<cmSourceFile*>::const_iterator si = sources.begin(); si != sources.end(); ++si) { @@ -2331,16 +729,10 @@ void cmTarget::MergeLinkLibraries( cmMakefile& mf, i += this->PrevLinkedLibraries.size(); for( ; i != libs.end(); ++i ) { - // We call this so that the dependencies get written to the cache + // This is equivalent to the target_link_libraries plain signature. this->AddLinkLibrary( mf, selfname, i->first.c_str(), i->second ); - - if (this->GetType() == cmTarget::STATIC_LIBRARY) - { - this->AppendProperty("INTERFACE_LINK_LIBRARIES", - ("$<LINK_ONLY:" + - this->GetDebugGeneratorExpressions(i->first.c_str(), i->second) + - ">").c_str()); - } + this->AppendProperty("INTERFACE_LINK_LIBRARIES", + this->GetDebugGeneratorExpressions(i->first.c_str(), i->second).c_str()); } this->PrevLinkedLibraries = libs; } @@ -2356,13 +748,13 @@ void cmTarget::AddLinkDirectory(const char* d) } //---------------------------------------------------------------------------- -const std::vector<std::string>& cmTarget::GetLinkDirectories() +const std::vector<std::string>& cmTarget::GetLinkDirectories() const { return this->LinkDirectories; } //---------------------------------------------------------------------------- -cmTarget::LinkLibraryType cmTarget::ComputeLinkType(const char* config) +cmTarget::LinkLibraryType cmTarget::ComputeLinkType(const char* config) const { // No configuration is always optimized. if(!(config && *config)) @@ -2418,15 +810,16 @@ void cmTarget::ClearDependencyInformation( cmMakefile& mf, } //---------------------------------------------------------------------------- -bool cmTarget::NameResolvesToFramework(const std::string& libname) +bool cmTarget::NameResolvesToFramework(const std::string& libname) const { - return this->GetMakefile()->GetLocalGenerator()->GetGlobalGenerator()-> + return this->Makefile->GetLocalGenerator()->GetGlobalGenerator()-> NameResolvesToFramework(libname); } //---------------------------------------------------------------------------- void cmTarget::GetDirectLinkLibraries(const char *config, - std::vector<std::string> &libs, cmTarget *head) + std::vector<std::string> &libs, + cmTarget const* head) const { const char *prop = this->GetProperty("LINK_LIBRARIES"); if (prop) @@ -2458,8 +851,32 @@ void cmTarget::GetDirectLinkLibraries(const char *config, } //---------------------------------------------------------------------------- +void cmTarget::GetInterfaceLinkLibraries(const char *config, + std::vector<std::string> &libs, + cmTarget const* head) const +{ + const char *prop = this->GetProperty("INTERFACE_LINK_LIBRARIES"); + if (prop) + { + cmListFileBacktrace lfbt; + cmGeneratorExpression ge(lfbt); + const cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop); + + cmGeneratorExpressionDAGChecker dagChecker(lfbt, + this->GetName(), + "INTERFACE_LINK_LIBRARIES", 0, 0); + cmSystemTools::ExpandListArgument(cge->Evaluate(this->Makefile, + config, + false, + head, + &dagChecker), + libs); + } +} + +//---------------------------------------------------------------------------- std::string cmTarget::GetDebugGeneratorExpressions(const std::string &value, - cmTarget::LinkLibraryType llt) + cmTarget::LinkLibraryType llt) const { if (llt == GENERAL) { @@ -2557,14 +974,8 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, const char *target, const char* lib, LinkLibraryType llt) { - // Never add a self dependency, even if the user asks for it. - if(strcmp( target, lib ) == 0) - { - return; - } - - { cmTarget *tgt = this->Makefile->FindTargetToUse(lib); + { const bool isNonImportedTarget = tgt && !tgt->IsImported(); const std::string libName = (isNonImportedTarget && llt != GENERAL) @@ -2575,7 +986,9 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, llt).c_str()); } - if (cmGeneratorExpression::Find(lib) != std::string::npos) + if (cmGeneratorExpression::Find(lib) != std::string::npos + || (tgt && tgt->GetType() == INTERFACE_LIBRARY) + || (strcmp( target, lib ) == 0)) { return; } @@ -2650,39 +1063,6 @@ cmTarget::AddSystemIncludeDirectories(const std::vector<std::string> &incs) } //---------------------------------------------------------------------------- -void cmTarget::FinalizeSystemIncludeDirectories() -{ - for (std::vector<cmValueWithOrigin>::const_iterator - it = this->Internal->LinkInterfacePropertyEntries.begin(), - end = this->Internal->LinkInterfacePropertyEntries.end(); - it != end; ++it) - { - { - cmListFileBacktrace lfbt; - cmGeneratorExpression ge(lfbt); - cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = - ge.Parse(it->Value); - std::string targetName = cge->Evaluate(this->Makefile, 0, - false, this, 0, 0); - if (!this->Makefile->FindTargetToUse(targetName.c_str())) - { - continue; - } - } - std::string includeGenex = "$<TARGET_PROPERTY:" + - it->Value + ",INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>"; - if (cmGeneratorExpression::Find(it->Value) != std::string::npos) - { - // Because it->Value is a generator expression, ensure that it - // evaluates to the non-empty string before being used in the - // TARGET_PROPERTY expression. - includeGenex = "$<$<BOOL:" + it->Value + ">:" + includeGenex + ">"; - } - this->SystemIncludeDirectories.insert(includeGenex); - } -} - -//---------------------------------------------------------------------------- void cmTarget::AnalyzeLibDependencies( const cmMakefile& mf ) { @@ -2976,12 +1356,57 @@ void cmTarget::GatherDependencies( const cmMakefile& mf, } //---------------------------------------------------------------------------- +static bool whiteListedInterfaceProperty(const char *prop) +{ + if(cmHasLiteralPrefix(prop, "INTERFACE_")) + { + return true; + } + static const char* builtIns[] = { + // ###: This must remain sorted. It is processed with a binary search. + "COMPATIBLE_INTERFACE_BOOL", + "COMPATIBLE_INTERFACE_NUMBER_MAX", + "COMPATIBLE_INTERFACE_NUMBER_MIN", + "COMPATIBLE_INTERFACE_STRING", + "EXPORT_NAME", + "IMPORTED", + "NAME", + "TYPE" + }; + + if (std::binary_search(cmArrayBegin(builtIns), + cmArrayEnd(builtIns), + prop, + cmStrCmp(prop))) + { + return true; + } + + if (cmHasLiteralPrefix(prop, "MAP_IMPORTED_CONFIG_")) + { + return true; + } + + return false; +} + +//---------------------------------------------------------------------------- void cmTarget::SetProperty(const char* prop, const char* value) { if (!prop) { return; } + if (this->GetType() == INTERFACE_LIBRARY + && !whiteListedInterfaceProperty(prop)) + { + cmOStringStream e; + e << "INTERFACE_LIBRARY targets may only have whitelisted properties. " + "The property \"" << prop << "\" is not allowed."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + return; + } + if (strcmp(prop, "NAME") == 0) { cmOStringStream e; @@ -3032,16 +1457,12 @@ void cmTarget::SetProperty(const char* prop, const char* value) } if (strcmp(prop, "LINK_LIBRARIES") == 0) { - this->Internal->LinkInterfacePropertyEntries.clear(); - if (cmGeneratorExpression::IsValidTargetName(value) - || cmGeneratorExpression::Find(value) != std::string::npos) - { - cmListFileBacktrace lfbt; - this->Makefile->GetBacktrace(lfbt); - cmValueWithOrigin entry(value, lfbt); - this->Internal->LinkInterfacePropertyEntries.push_back(entry); - } - // Fall through + this->Internal->LinkImplementationPropertyEntries.clear(); + cmListFileBacktrace lfbt; + this->Makefile->GetBacktrace(lfbt); + cmValueWithOrigin entry(value, lfbt); + this->Internal->LinkImplementationPropertyEntries.push_back(entry); + return; } this->Properties.SetProperty(prop, value, cmProperty::TARGET); this->MaybeInvalidatePropertyCache(prop); @@ -3055,6 +1476,15 @@ void cmTarget::AppendProperty(const char* prop, const char* value, { return; } + if (this->GetType() == INTERFACE_LIBRARY + && !whiteListedInterfaceProperty(prop)) + { + cmOStringStream e; + e << "INTERFACE_LIBRARY targets may only have whitelisted properties. " + "The property \"" << prop << "\" is not allowed."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + return; + } if (strcmp(prop, "NAME") == 0) { cmOStringStream e; @@ -3099,22 +1529,18 @@ void cmTarget::AppendProperty(const char* prop, const char* value, } if (strcmp(prop, "LINK_LIBRARIES") == 0) { - if (cmGeneratorExpression::IsValidTargetName(value) - || cmGeneratorExpression::Find(value) != std::string::npos) - { - cmListFileBacktrace lfbt; - this->Makefile->GetBacktrace(lfbt); - cmValueWithOrigin entry(value, lfbt); - this->Internal->LinkInterfacePropertyEntries.push_back(entry); - } - // Fall through + cmListFileBacktrace lfbt; + this->Makefile->GetBacktrace(lfbt); + cmValueWithOrigin entry(value, lfbt); + this->Internal->LinkImplementationPropertyEntries.push_back(entry); + return; } this->Properties.AppendProperty(prop, value, cmProperty::TARGET, asString); this->MaybeInvalidatePropertyCache(prop); } //---------------------------------------------------------------------------- -const char* cmTarget::GetExportName() +const char* cmTarget::GetExportName() const { const char *exportName = this->GetProperty("EXPORT_NAME"); @@ -3139,6 +1565,7 @@ void cmTarget::AppendBuildInterfaceIncludes() if(this->GetType() != cmTarget::SHARED_LIBRARY && this->GetType() != cmTarget::STATIC_LIBRARY && this->GetType() != cmTarget::MODULE_LIBRARY && + this->GetType() != cmTarget::INTERFACE_LIBRARY && !this->IsExecutableWithExports()) { return; @@ -3207,7 +1634,7 @@ void cmTarget::InsertCompileDefinition(const cmValueWithOrigin &entry, } //---------------------------------------------------------------------------- -static void processIncludeDirectories(cmTarget *tgt, +static void processIncludeDirectories(cmTarget const* tgt, const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, std::vector<std::string> &includes, std::set<std::string> &uniqueIncludes, @@ -3241,19 +1668,56 @@ static void processIncludeDirectories(cmTarget *tgt, } } std::string usedIncludes; + cmListFileBacktrace lfbt; for(std::vector<std::string>::iterator li = entryIncludes.begin(); li != entryIncludes.end(); ++li) { - cmTarget *dependentTarget = - mf->FindTargetToUse((*it)->TargetName.c_str()); + std::string targetName = (*it)->TargetName; + std::string evaluatedTargetName; + { + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = + ge.Parse(targetName); + evaluatedTargetName = cge->Evaluate(mf, config, false, tgt, 0, 0); + } + + cmTarget *dependentTarget = mf->FindTargetToUse(targetName.c_str()); const bool fromImported = dependentTarget && dependentTarget->IsImported(); - if (fromImported && !cmSystemTools::FileExists(li->c_str())) + cmTarget *evaluatedDependentTarget = + (targetName != evaluatedTargetName) + ? mf->FindTargetToUse(evaluatedTargetName.c_str()) + : 0; + + targetName = evaluatedTargetName; + + const bool fromEvaluatedImported = evaluatedDependentTarget + && evaluatedDependentTarget->IsImported(); + + if ((fromImported || fromEvaluatedImported) + && !cmSystemTools::FileExists(li->c_str())) { cmOStringStream e; - e << "Imported target \"" << (*it)->TargetName << "\" includes " + cmake::MessageType messageType = cmake::FATAL_ERROR; + if (fromEvaluatedImported) + { + switch(mf->GetPolicyStatus(cmPolicies::CMP0027)) + { + case cmPolicies::WARN: + e << (mf->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0027)) << "\n"; + case cmPolicies::OLD: + messageType = cmake::AUTHOR_WARNING; + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + break; + } + } + e << "Imported target \"" << targetName << "\" includes " "non-existent path\n \"" << *li << "\"\nin its " "INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n" "* The path was deleted, renamed, or moved to another " @@ -3262,7 +1726,7 @@ static void processIncludeDirectories(cmTarget *tgt, "successfully.\n" "* The installation package was faulty and references files it " "does not provide.\n"; - tgt->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + tgt->GetMakefile()->IssueMessage(messageType, e.str().c_str()); return; } @@ -3271,9 +1735,9 @@ static void processIncludeDirectories(cmTarget *tgt, cmOStringStream e; bool noMessage = false; cmake::MessageType messageType = cmake::FATAL_ERROR; - if (!(*it)->TargetName.empty()) + if (!targetName.empty()) { - e << "Target \"" << (*it)->TargetName << "\" contains relative " + e << "Target \"" << targetName << "\" contains relative " "path in its INTERFACE_INCLUDE_DIRECTORIES:\n" " \"" << *li << "\""; } @@ -3283,7 +1747,6 @@ static void processIncludeDirectories(cmTarget *tgt, { case cmPolicies::WARN: { - cmOStringStream w; e << (mf->GetPolicies() ->GetPolicyWarning(cmPolicies::CMP0021)) << "\n"; messageType = cmake::AUTHOR_WARNING; @@ -3340,7 +1803,8 @@ static void processIncludeDirectories(cmTarget *tgt, } //---------------------------------------------------------------------------- -std::vector<std::string> cmTarget::GetIncludeDirectories(const char *config) +std::vector<std::string> +cmTarget::GetIncludeDirectories(const char *config) const { std::vector<std::string> includes; std::set<std::string> uniqueIncludes; @@ -3350,8 +1814,6 @@ std::vector<std::string> cmTarget::GetIncludeDirectories(const char *config) this->GetName(), "INCLUDE_DIRECTORIES", 0, 0); - this->AppendBuildInterfaceIncludes(); - std::vector<std::string> debugProperties; const char *debugProp = this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); @@ -3383,10 +1845,15 @@ std::vector<std::string> cmTarget::GetIncludeDirectories(const char *config) if (!this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[configString]) { for (std::vector<cmValueWithOrigin>::const_iterator - it = this->Internal->LinkInterfacePropertyEntries.begin(), - end = this->Internal->LinkInterfacePropertyEntries.end(); + it = this->Internal->LinkImplementationPropertyEntries.begin(), + end = this->Internal->LinkImplementationPropertyEntries.end(); it != end; ++it) { + if (!cmGeneratorExpression::IsValidTargetName(it->Value) + && cmGeneratorExpression::Find(it->Value) == std::string::npos) + { + continue; + } { cmGeneratorExpression ge(lfbt); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = @@ -3469,7 +1936,7 @@ std::vector<std::string> cmTarget::GetIncludeDirectories(const char *config) } //---------------------------------------------------------------------------- -static void processCompileOptionsInternal(cmTarget *tgt, +static void processCompileOptionsInternal(cmTarget const* tgt, const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, std::vector<std::string> &options, std::set<std::string> &uniqueOptions, @@ -3528,7 +1995,7 @@ static void processCompileOptionsInternal(cmTarget *tgt, } //---------------------------------------------------------------------------- -static void processCompileOptions(cmTarget *tgt, +static void processCompileOptions(cmTarget const* tgt, const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, std::vector<std::string> &options, std::set<std::string> &uniqueOptions, @@ -3540,8 +2007,34 @@ static void processCompileOptions(cmTarget *tgt, } //---------------------------------------------------------------------------- +void cmTarget::GetAutoUicOptions(std::vector<std::string> &result, + const char *config) const +{ + const char *prop + = this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", + config); + if (!prop) + { + return; + } + cmListFileBacktrace lfbt; + cmGeneratorExpression ge(lfbt); + + cmGeneratorExpressionDAGChecker dagChecker(lfbt, + this->GetName(), + "AUTOUIC_OPTIONS", 0, 0); + cmSystemTools::ExpandListArgument(ge.Parse(prop) + ->Evaluate(this->Makefile, + config, + false, + this, + &dagChecker), + result); +} + +//---------------------------------------------------------------------------- void cmTarget::GetCompileOptions(std::vector<std::string> &result, - const char *config) + const char *config) const { std::set<std::string> uniqueOptions; cmListFileBacktrace lfbt; @@ -3581,10 +2074,15 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result, if (!this->Internal->CacheLinkInterfaceCompileOptionsDone[configString]) { for (std::vector<cmValueWithOrigin>::const_iterator - it = this->Internal->LinkInterfacePropertyEntries.begin(), - end = this->Internal->LinkInterfacePropertyEntries.end(); + it = this->Internal->LinkImplementationPropertyEntries.begin(), + end = this->Internal->LinkImplementationPropertyEntries.end(); it != end; ++it) { + if (!cmGeneratorExpression::IsValidTargetName(it->Value) + && cmGeneratorExpression::Find(it->Value) == std::string::npos) + { + continue; + } { cmGeneratorExpression ge(lfbt); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = @@ -3635,7 +2133,7 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result, } //---------------------------------------------------------------------------- -static void processCompileDefinitions(cmTarget *tgt, +static void processCompileDefinitions(cmTarget const* tgt, const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, std::vector<std::string> &options, std::set<std::string> &uniqueOptions, @@ -3649,7 +2147,7 @@ static void processCompileDefinitions(cmTarget *tgt, //---------------------------------------------------------------------------- void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, - const char *config) + const char *config) const { std::set<std::string> uniqueOptions; cmListFileBacktrace lfbt; @@ -3689,10 +2187,15 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, if (!this->Internal->CacheLinkInterfaceCompileDefinitionsDone[configString]) { for (std::vector<cmValueWithOrigin>::const_iterator - it = this->Internal->LinkInterfacePropertyEntries.begin(), - end = this->Internal->LinkInterfacePropertyEntries.end(); + it = this->Internal->LinkImplementationPropertyEntries.begin(), + end = this->Internal->LinkImplementationPropertyEntries.end(); it != end; ++it) { + if (!cmGeneratorExpression::IsValidTargetName(it->Value) + && cmGeneratorExpression::Find(it->Value) == std::string::npos) + { + continue; + } { cmGeneratorExpression ge(lfbt); cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = @@ -3727,14 +2230,34 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, std::string configPropName = "COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config); const char *configProp = this->GetProperty(configPropName.c_str()); - std::string defsString = (configProp ? configProp : ""); - - cmGeneratorExpression ge(lfbt); - cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = - ge.Parse(defsString); - this->Internal - ->CachedLinkInterfaceCompileDefinitionsEntries[configString].push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + if (configProp) + { + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) + { + case cmPolicies::WARN: + { + cmOStringStream e; + e << this->Makefile->GetCMakeInstance()->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0043); + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, + e.str().c_str()); + } + case cmPolicies::OLD: + { + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = + ge.Parse(configProp); + this->Internal + ->CachedLinkInterfaceCompileDefinitionsEntries[configString] + .push_back(new cmTargetInternals::TargetPropertyEntry(cge)); + } + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + break; + } + } } } @@ -3763,11 +2286,11 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, void cmTarget::MaybeInvalidatePropertyCache(const char* prop) { // Wipe out maps caching information affected by this property. - if(this->IsImported() && strncmp(prop, "IMPORTED", 8) == 0) + if(this->IsImported() && cmHasLiteralPrefix(prop, "IMPORTED")) { this->Internal->ImportInfoMap.clear(); } - if(!this->IsImported() && strncmp(prop, "LINK_INTERFACE_", 15) == 0) + if(!this->IsImported() && cmHasLiteralPrefix(prop, "LINK_INTERFACE_")) { this->ClearLinkMaps(); } @@ -3840,24 +2363,24 @@ static void cmTargetCheckINTERFACE_LINK_LIBRARIES(const char* value, } //---------------------------------------------------------------------------- -void cmTarget::CheckProperty(const char* prop, cmMakefile* context) +void cmTarget::CheckProperty(const char* prop, cmMakefile* context) const { // Certain properties need checking. - if(strncmp(prop, "LINK_INTERFACE_LIBRARIES", 24) == 0) + if(cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES")) { if(const char* value = this->GetProperty(prop)) { cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, value, context, false); } } - if(strncmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES", 33) == 0) + if(cmHasLiteralPrefix(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES")) { if(const char* value = this->GetProperty(prop)) { cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, value, context, true); } } - if(strncmp(prop, "INTERFACE_LINK_LIBRARIES", 24) == 0) + if(cmHasLiteralPrefix(prop, "INTERFACE_LINK_LIBRARIES")) { if(const char* value = this->GetProperty(prop)) { @@ -3873,7 +2396,7 @@ void cmTarget::MarkAsImported() } //---------------------------------------------------------------------------- -bool cmTarget::HaveWellDefinedOutputFiles() +bool cmTarget::HaveWellDefinedOutputFiles() const { return this->GetType() == cmTarget::STATIC_LIBRARY || @@ -3883,7 +2406,7 @@ bool cmTarget::HaveWellDefinedOutputFiles() } //---------------------------------------------------------------------------- -cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) +cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) const { // There is no output information for imported targets. if(this->IsImported()) @@ -3928,7 +2451,7 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) } //---------------------------------------------------------------------------- -std::string cmTarget::GetDirectory(const char* config, bool implib) +std::string cmTarget::GetDirectory(const char* config, bool implib) const { if (this->IsImported()) { @@ -3946,7 +2469,7 @@ std::string cmTarget::GetDirectory(const char* config, bool implib) } //---------------------------------------------------------------------------- -std::string cmTarget::GetPDBDirectory(const char* config) +std::string cmTarget::GetPDBDirectory(const char* config) const { if(OutputInfo const* info = this->GetOutputInfo(config)) { @@ -3957,7 +2480,7 @@ std::string cmTarget::GetPDBDirectory(const char* config) } //---------------------------------------------------------------------------- -const char* cmTarget::GetLocation(const char* config) +const char* cmTarget::GetLocation(const char* config) const { if (this->IsImported()) { @@ -3970,29 +2493,36 @@ const char* cmTarget::GetLocation(const char* config) } //---------------------------------------------------------------------------- -const char* cmTarget::ImportedGetLocation(const char* config) +const char* cmTarget::ImportedGetLocation(const char* config) const { - this->Location = this->ImportedGetFullPath(config, false); - return this->Location.c_str(); + static std::string location; + location = this->ImportedGetFullPath(config, false); + return location.c_str(); } //---------------------------------------------------------------------------- -const char* cmTarget::NormalGetLocation(const char* config) +const char* cmTarget::NormalGetLocation(const char* config) const { + static std::string location; // Handle the configuration-specific case first. if(config) { - this->Location = this->GetFullPath(config, false); - return this->Location.c_str(); + location = this->GetFullPath(config, false); + return location.c_str(); } // Now handle the deprecated build-time configuration location. - this->Location = this->GetDirectory(); + location = this->GetDirectory(); + if(!location.empty()) + { + location += "/"; + } const char* cfgid = this->Makefile->GetDefinition("CMAKE_CFG_INTDIR"); if(cfgid && strcmp(cfgid, ".") != 0) { - this->Location += "/"; - this->Location += cfgid; + location += "/"; + location += cfgid; + location += "/"; } if(this->IsAppBundleOnApple()) @@ -4000,17 +2530,17 @@ const char* cmTarget::NormalGetLocation(const char* config) std::string macdir = this->BuildMacContentDirectory("", config, false); if(!macdir.empty()) { - this->Location += "/"; - this->Location += macdir; + location += "/"; + location += macdir; } } - this->Location += "/"; - this->Location += this->GetFullName(config, false); - return this->Location.c_str(); + location += "/"; + location += this->GetFullName(config, false); + return location.c_str(); } //---------------------------------------------------------------------------- -void cmTarget::GetTargetVersion(int& major, int& minor) +void cmTarget::GetTargetVersion(int& major, int& minor) const { int patch; this->GetTargetVersion(false, major, minor, patch); @@ -4018,13 +2548,15 @@ void cmTarget::GetTargetVersion(int& major, int& minor) //---------------------------------------------------------------------------- void cmTarget::GetTargetVersion(bool soversion, - int& major, int& minor, int& patch) + int& major, int& minor, int& patch) const { // Set the default values. major = 0; minor = 0; patch = 0; + assert(this->GetType() != INTERFACE_LIBRARY); + // Look for a VERSION or SOVERSION property. const char* prop = soversion? "SOVERSION" : "VERSION"; if(const char* version = this->GetProperty(prop)) @@ -4046,7 +2578,7 @@ void cmTarget::GetTargetVersion(bool soversion, } //---------------------------------------------------------------------------- -const char* cmTarget::GetFeature(const char* feature, const char* config) +const char* cmTarget::GetFeature(const char* feature, const char* config) const { if(config && *config) { @@ -4066,20 +2598,67 @@ const char* cmTarget::GetFeature(const char* feature, const char* config) } //---------------------------------------------------------------------------- -const char *cmTarget::GetProperty(const char* prop) +const char *cmTarget::GetProperty(const char* prop) const { return this->GetProperty(prop, cmProperty::TARGET); } //---------------------------------------------------------------------------- +bool cmTarget::HandleLocationPropertyPolicy() const +{ + if (this->IsImported()) + { + return true; + } + const char *modal = 0; + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0026)) + { + case cmPolicies::WARN: + modal = "should"; + case cmPolicies::OLD: + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + modal = "may"; + messageType = cmake::FATAL_ERROR; + } + + if (modal) + { + cmOStringStream e; + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0026)) << "\n"; + e << "The LOCATION property " << modal << " not be read from target \"" + << this->GetName() << "\". Use the target name directly with " + "add_custom_command, or use the generator expression $<TARGET_FILE>, " + "as appropriate.\n"; + this->Makefile->IssueMessage(messageType, e.str().c_str()); + } + + return messageType != cmake::FATAL_ERROR; +} + +//---------------------------------------------------------------------------- const char *cmTarget::GetProperty(const char* prop, - cmProperty::ScopeType scope) + cmProperty::ScopeType scope) const { if(!prop) { return 0; } + if (this->GetType() == INTERFACE_LIBRARY + && !whiteListedInterfaceProperty(prop)) + { + cmOStringStream e; + e << "INTERFACE_LIBRARY targets may only have whitelisted properties. " + "The property \"" << prop << "\" is not allowed."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + return 0; + } + if (strcmp(prop, "NAME") == 0) { return this->GetName(); @@ -4095,6 +2674,11 @@ const char *cmTarget::GetProperty(const char* prop, { if(strcmp(prop,"LOCATION") == 0) { + if (!this->HandleLocationPropertyPolicy()) + { + return 0; + } + // Set the LOCATION property of the target. // // For an imported target this is the location of an arbitrary @@ -4104,27 +2688,21 @@ const char *cmTarget::GetProperty(const char* prop, // cannot take into account the per-configuration name of the // target because the configuration type may not be known at // CMake time. - this->SetProperty("LOCATION", this->GetLocation(0)); + this->Properties.SetProperty("LOCATION", this->GetLocation(0), + cmProperty::TARGET); } // Support "LOCATION_<CONFIG>". - if(strncmp(prop, "LOCATION_", 9) == 0) - { - std::string configName = prop+9; - this->SetProperty(prop, this->GetLocation(configName.c_str())); - } - else + if(cmHasLiteralPrefix(prop, "LOCATION_")) { - // Support "<CONFIG>_LOCATION" for compatiblity. - int len = static_cast<int>(strlen(prop)); - if(len > 9 && strcmp(prop+len-9, "_LOCATION") == 0) + if (!this->HandleLocationPropertyPolicy()) { - std::string configName(prop, len-9); - if(configName != "IMPORTED") - { - this->SetProperty(prop, this->GetLocation(configName.c_str())); - } + return 0; } + std::string configName = prop+9; + this->Properties.SetProperty(prop, + this->GetLocation(configName.c_str()), + cmProperty::TARGET); } } if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0) @@ -4181,6 +2759,22 @@ const char *cmTarget::GetProperty(const char* prop, } return output.c_str(); } + if(strcmp(prop,"LINK_LIBRARIES") == 0) + { + static std::string output; + output = ""; + std::string sep; + for (std::vector<cmValueWithOrigin>::const_iterator + it = this->Internal->LinkImplementationPropertyEntries.begin(), + end = this->Internal->LinkImplementationPropertyEntries.end(); + it != end; ++it) + { + output += sep; + output += it->Value; + sep = ";"; + } + return output.c_str(); + } if (strcmp(prop,"IMPORTED") == 0) { @@ -4211,7 +2805,8 @@ const char *cmTarget::GetProperty(const char* prop, // Append this list entry. ss << sname; } - this->SetProperty("SOURCES", ss.str().c_str()); + this->Properties.SetProperty("SOURCES", ss.str().c_str(), + cmProperty::TARGET); } // the type property returns what type the target is @@ -4230,7 +2825,7 @@ const char *cmTarget::GetProperty(const char* prop, } //---------------------------------------------------------------------------- -bool cmTarget::GetPropertyAsBool(const char* prop) +bool cmTarget::GetPropertyAsBool(const char* prop) const { return cmSystemTools::IsOn(this->GetProperty(prop)); } @@ -4239,13 +2834,13 @@ bool cmTarget::GetPropertyAsBool(const char* prop) class cmTargetCollectLinkLanguages { public: - cmTargetCollectLinkLanguages(cmTarget* target, const char* config, + cmTargetCollectLinkLanguages(cmTarget const* target, const char* config, std::set<cmStdString>& languages, - cmTarget* head): + cmTarget const* head): Config(config), Languages(languages), HeadTarget(head) { this->Visited.insert(target); } - void Visit(cmTarget* target) + void Visit(cmTarget const* target) { if(!target || !this->Visited.insert(target).second) { @@ -4272,14 +2867,15 @@ public: private: const char* Config; std::set<cmStdString>& Languages; - cmTarget* HeadTarget; - std::set<cmTarget*> Visited; + cmTarget const* HeadTarget; + std::set<cmTarget const*> Visited; }; //---------------------------------------------------------------------------- -const char* cmTarget::GetLinkerLanguage(const char* config, cmTarget *head) +const char* cmTarget::GetLinkerLanguage(const char* config, + cmTarget const* head) const { - cmTarget *headTarget = head ? head : this; + cmTarget const* headTarget = head ? head : this; const char* lang = this->GetLinkClosure(config, headTarget) ->LinkerLanguage.c_str(); return *lang? lang : 0; @@ -4287,7 +2883,7 @@ const char* cmTarget::GetLinkerLanguage(const char* config, cmTarget *head) //---------------------------------------------------------------------------- cmTarget::LinkClosure const* cmTarget::GetLinkClosure(const char* config, - cmTarget *head) + cmTarget const* head) const { TargetConfigPair key(head, cmSystemTools::UpperCase(config ? config : "")); cmTargetInternals::LinkClosureMapType::iterator @@ -4306,12 +2902,12 @@ cmTarget::LinkClosure const* cmTarget::GetLinkClosure(const char* config, class cmTargetSelectLinker { int Preference; - cmTarget* Target; + cmTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator* GG; std::set<cmStdString> Preferred; public: - cmTargetSelectLinker(cmTarget* target): Preference(0), Target(target) + cmTargetSelectLinker(cmTarget const* target): Preference(0), Target(target) { this->Makefile = this->Target->GetMakefile(); this->GG = this->Makefile->GetLocalGenerator()->GetGlobalGenerator(); @@ -4357,7 +2953,7 @@ public: //---------------------------------------------------------------------------- void cmTarget::ComputeLinkClosure(const char* config, LinkClosure& lc, - cmTarget *head) + cmTarget const* head) const { // Get languages built in this target. std::set<cmStdString> languages; @@ -4420,7 +3016,7 @@ void cmTarget::ComputeLinkClosure(const char* config, LinkClosure& lc, } //---------------------------------------------------------------------------- -const char* cmTarget::GetSuffixVariableInternal(bool implib) +const char* cmTarget::GetSuffixVariableInternal(bool implib) const { switch(this->GetType()) { @@ -4446,7 +3042,7 @@ const char* cmTarget::GetSuffixVariableInternal(bool implib) //---------------------------------------------------------------------------- -const char* cmTarget::GetPrefixVariableInternal(bool implib) +const char* cmTarget::GetPrefixVariableInternal(bool implib) const { switch(this->GetType()) { @@ -4469,7 +3065,7 @@ const char* cmTarget::GetPrefixVariableInternal(bool implib) } //---------------------------------------------------------------------------- -std::string cmTarget::GetPDBName(const char* config) +std::string cmTarget::GetPDBName(const char* config) const { std::string prefix; std::string base; @@ -4501,7 +3097,7 @@ std::string cmTarget::GetPDBName(const char* config) } //---------------------------------------------------------------------------- -bool cmTarget::HasSOName(const char* config) +bool cmTarget::HasSOName(const char* config) const { // soname is supported only for shared libraries and modules, // and then only when the platform supports an soname flag. @@ -4513,7 +3109,7 @@ bool cmTarget::HasSOName(const char* config) } //---------------------------------------------------------------------------- -std::string cmTarget::GetSOName(const char* config) +std::string cmTarget::GetSOName(const char* config) const { if(this->IsImported()) { @@ -4555,13 +3151,17 @@ std::string cmTarget::GetSOName(const char* config) } //---------------------------------------------------------------------------- -bool cmTarget::HasMacOSXRpath(const char* config) +bool cmTarget::HasMacOSXRpathInstallNameDir(const char* config) const { bool install_name_is_rpath = false; - bool macosx_rpath = this->GetPropertyAsBool("MACOSX_RPATH"); + bool macosx_rpath = false; if(!this->IsImportedTarget) { + if(this->GetType() != cmTarget::SHARED_LIBRARY) + { + return false; + } const char* install_name = this->GetProperty("INSTALL_NAME_DIR"); bool use_install_name = this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH"); @@ -4574,6 +3174,10 @@ bool cmTarget::HasMacOSXRpath(const char* config) { return false; } + if(!install_name_is_rpath) + { + macosx_rpath = this->MacOSXRpathInstallNameDirDefault(); + } } else { @@ -4628,7 +3232,38 @@ bool cmTarget::HasMacOSXRpath(const char* config) } //---------------------------------------------------------------------------- -bool cmTarget::IsImportedSharedLibWithoutSOName(const char* config) +bool cmTarget::MacOSXRpathInstallNameDirDefault() const +{ + // we can't do rpaths when unsupported + if(!this->Makefile->IsSet("CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG")) + { + return false; + } + + const char* macosx_rpath_str = this->GetProperty("MACOSX_RPATH"); + if(macosx_rpath_str) + { + return this->GetPropertyAsBool("MACOSX_RPATH"); + } + + cmPolicies::PolicyStatus cmp0042 = this->GetPolicyStatusCMP0042(); + + if(cmp0042 == cmPolicies::WARN) + { + this->Makefile->GetLocalGenerator()->GetGlobalGenerator()-> + AddCMP0042WarnTarget(this->GetName()); + } + + if(cmp0042 == cmPolicies::NEW) + { + return true; + } + + return false; +} + +//---------------------------------------------------------------------------- +bool cmTarget::IsImportedSharedLibWithoutSOName(const char* config) const { if(this->IsImported() && this->GetType() == cmTarget::SHARED_LIBRARY) { @@ -4641,7 +3276,7 @@ bool cmTarget::IsImportedSharedLibWithoutSOName(const char* config) } //---------------------------------------------------------------------------- -std::string cmTarget::NormalGetRealName(const char* config) +std::string cmTarget::NormalGetRealName(const char* config) const { // This should not be called for imported targets. // TODO: Split cmTarget into a class hierarchy to get compile-time @@ -4679,7 +3314,7 @@ std::string cmTarget::NormalGetRealName(const char* config) } //---------------------------------------------------------------------------- -std::string cmTarget::GetFullName(const char* config, bool implib) +std::string cmTarget::GetFullName(const char* config, bool implib) const { if(this->IsImported()) { @@ -4692,7 +3327,8 @@ std::string cmTarget::GetFullName(const char* config, bool implib) } //---------------------------------------------------------------------------- -std::string cmTarget::GetFullNameImported(const char* config, bool implib) +std::string +cmTarget::GetFullNameImported(const char* config, bool implib) const { return cmSystemTools::GetFilenameName( this->ImportedGetFullPath(config, implib)); @@ -4701,14 +3337,14 @@ std::string cmTarget::GetFullNameImported(const char* config, bool implib) //---------------------------------------------------------------------------- void cmTarget::GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, const char* config, - bool implib) + bool implib) const { this->GetFullNameInternal(config, implib, prefix, base, suffix); } //---------------------------------------------------------------------------- std::string cmTarget::GetFullPath(const char* config, bool implib, - bool realname) + bool realname) const { if(this->IsImported()) { @@ -4722,7 +3358,7 @@ std::string cmTarget::GetFullPath(const char* config, bool implib, //---------------------------------------------------------------------------- std::string cmTarget::NormalGetFullPath(const char* config, bool implib, - bool realname) + bool realname) const { std::string fpath = this->GetDirectory(config, implib); fpath += "/"; @@ -4749,7 +3385,8 @@ std::string cmTarget::NormalGetFullPath(const char* config, bool implib, } //---------------------------------------------------------------------------- -std::string cmTarget::ImportedGetFullPath(const char* config, bool implib) +std::string +cmTarget::ImportedGetFullPath(const char* config, bool implib) const { std::string result; if(cmTarget::ImportInfo const* info = this->GetImportInfo(config, this)) @@ -4765,7 +3402,8 @@ std::string cmTarget::ImportedGetFullPath(const char* config, bool implib) } //---------------------------------------------------------------------------- -std::string cmTarget::GetFullNameInternal(const char* config, bool implib) +std::string +cmTarget::GetFullNameInternal(const char* config, bool implib) const { std::string prefix; std::string base; @@ -4779,7 +3417,7 @@ void cmTarget::GetFullNameInternal(const char* config, bool implib, std::string& outPrefix, std::string& outBase, - std::string& outSuffix) + std::string& outSuffix) const { // Use just the target name for non-main target types. if(this->GetType() != cmTarget::STATIC_LIBRARY && @@ -4917,7 +3555,7 @@ void cmTarget::GetLibraryNames(std::string& name, std::string& realName, std::string& impName, std::string& pdbName, - const char* config) + const char* config) const { // This should not be called for imported targets. // TODO: Split cmTarget into a class hierarchy to get compile-time @@ -4931,6 +3569,8 @@ void cmTarget::GetLibraryNames(std::string& name, return; } + assert(this->GetType() != INTERFACE_LIBRARY); + // Check for library version properties. const char* version = this->GetProperty("VERSION"); const char* soversion = this->GetProperty("SOVERSION"); @@ -5003,7 +3643,7 @@ void cmTarget::ComputeVersionedName(std::string& vName, std::string const& base, std::string const& suffix, std::string const& name, - const char* version) + const char* version) const { vName = this->IsApple? (prefix+base) : name; if(version) @@ -5019,7 +3659,7 @@ void cmTarget::GetExecutableNames(std::string& name, std::string& realName, std::string& impName, std::string& pdbName, - const char* config) + const char* config) const { // This should not be called for imported targets. // TODO: Split cmTarget into a class hierarchy to get compile-time @@ -5077,14 +3717,14 @@ void cmTarget::GetExecutableNames(std::string& name, } //---------------------------------------------------------------------------- -bool cmTarget::HasImplibGNUtoMS() +bool cmTarget::HasImplibGNUtoMS() const { return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS"); } //---------------------------------------------------------------------------- bool cmTarget::GetImplibGNUtoMS(std::string const& gnuName, - std::string& out, const char* newExt) + std::string& out, const char* newExt) const { if(this->HasImplibGNUtoMS() && gnuName.size() > 6 && gnuName.substr(gnuName.size()-6) == ".dll.a") @@ -5097,76 +3737,6 @@ bool cmTarget::GetImplibGNUtoMS(std::string const& gnuName, } //---------------------------------------------------------------------------- -void cmTarget::GenerateTargetManifest(const char* config) -{ - cmMakefile* mf = this->Makefile; - cmLocalGenerator* lg = mf->GetLocalGenerator(); - cmGlobalGenerator* gg = lg->GetGlobalGenerator(); - - // Get the names. - std::string name; - std::string soName; - std::string realName; - std::string impName; - std::string pdbName; - if(this->GetType() == cmTarget::EXECUTABLE) - { - this->GetExecutableNames(name, realName, impName, pdbName, config); - } - else if(this->GetType() == cmTarget::STATIC_LIBRARY || - this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) - { - this->GetLibraryNames(name, soName, realName, impName, pdbName, config); - } - else - { - return; - } - - // Get the directory. - std::string dir = this->GetDirectory(config, false); - - // Add each name. - std::string f; - if(!name.empty()) - { - f = dir; - f += "/"; - f += name; - gg->AddToManifest(config? config:"", f); - } - if(!soName.empty()) - { - f = dir; - f += "/"; - f += soName; - gg->AddToManifest(config? config:"", f); - } - if(!realName.empty()) - { - f = dir; - f += "/"; - f += realName; - gg->AddToManifest(config? config:"", f); - } - if(!pdbName.empty()) - { - f = this->GetPDBDirectory(config); - f += "/"; - f += pdbName; - gg->AddToManifest(config? config:"", f); - } - if(!impName.empty()) - { - f = this->GetDirectory(config, true); - f += "/"; - f += impName; - gg->AddToManifest(config? config:"", f); - } -} - -//---------------------------------------------------------------------------- void cmTarget::SetPropertyDefault(const char* property, const char* default_value) { @@ -5185,7 +3755,7 @@ void cmTarget::SetPropertyDefault(const char* property, } //---------------------------------------------------------------------------- -bool cmTarget::HaveBuildTreeRPATH(const char *config) +bool cmTarget::HaveBuildTreeRPATH(const char *config) const { if (this->GetPropertyAsBool("SKIP_BUILD_RPATH")) { @@ -5197,7 +3767,7 @@ bool cmTarget::HaveBuildTreeRPATH(const char *config) } //---------------------------------------------------------------------------- -bool cmTarget::HaveInstallTreeRPATH() +bool cmTarget::HaveInstallTreeRPATH() const { const char* install_rpath = this->GetProperty("INSTALL_RPATH"); return (install_rpath && *install_rpath) && @@ -5205,7 +3775,7 @@ bool cmTarget::HaveInstallTreeRPATH() } //---------------------------------------------------------------------------- -bool cmTarget::NeedRelinkBeforeInstall(const char* config) +bool cmTarget::NeedRelinkBeforeInstall(const char* config) const { // Only executables and shared libraries can have an rpath and may // need relinking. @@ -5268,7 +3838,7 @@ bool cmTarget::NeedRelinkBeforeInstall(const char* config) } //---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForBuildTree(const char* config) +std::string cmTarget::GetInstallNameDirForBuildTree(const char* config) const { // If building directly for installation then the build tree install_name // is the same as the install tree. @@ -5283,7 +3853,8 @@ std::string cmTarget::GetInstallNameDirForBuildTree(const char* config) !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) { std::string dir; - if(this->GetPropertyAsBool("MACOSX_RPATH")) + bool macosx_rpath = this->MacOSXRpathInstallNameDirDefault(); + if(macosx_rpath) { dir = "@rpath"; } @@ -5301,7 +3872,7 @@ std::string cmTarget::GetInstallNameDirForBuildTree(const char* config) } //---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForInstallTree() +std::string cmTarget::GetInstallNameDirForInstallTree() const { if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { @@ -5317,9 +3888,12 @@ std::string cmTarget::GetInstallNameDirForInstallTree() dir += "/"; } } - if(!install_name_dir && this->GetPropertyAsBool("MACOSX_RPATH")) + if(!install_name_dir) { - dir = "@rpath/"; + if(this->MacOSXRpathInstallNameDirDefault()) + { + dir = "@rpath/"; + } } return dir; } @@ -5330,7 +3904,7 @@ std::string cmTarget::GetInstallNameDirForInstallTree() } //---------------------------------------------------------------------------- -const char* cmTarget::GetOutputTargetType(bool implib) +const char* cmTarget::GetOutputTargetType(bool implib) const { switch(this->GetType()) { @@ -5387,7 +3961,7 @@ const char* cmTarget::GetOutputTargetType(bool implib) //---------------------------------------------------------------------------- bool cmTarget::ComputeOutputDir(const char* config, - bool implib, std::string& out) + bool implib, std::string& out) const { bool usesDefaultOutputDir = false; @@ -5467,7 +4041,7 @@ bool cmTarget::ComputeOutputDir(const char* config, } //---------------------------------------------------------------------------- -bool cmTarget::ComputePDBOutputDir(const char* config, std::string& out) +bool cmTarget::ComputePDBOutputDir(const char* config, std::string& out) const { // Look for a target property defining the target output directory // based on the target type. @@ -5526,14 +4100,14 @@ bool cmTarget::ComputePDBOutputDir(const char* config, std::string& out) } //---------------------------------------------------------------------------- -bool cmTarget::UsesDefaultOutputDir(const char* config, bool implib) +bool cmTarget::UsesDefaultOutputDir(const char* config, bool implib) const { std::string dir; return this->ComputeOutputDir(config, implib, dir); } //---------------------------------------------------------------------------- -std::string cmTarget::GetOutputName(const char* config, bool implib) +std::string cmTarget::GetOutputName(const char* config, bool implib) const { std::vector<std::string> props; std::string type = this->GetOutputTargetType(implib); @@ -5570,8 +4144,10 @@ std::string cmTarget::GetOutputName(const char* config, bool implib) } //---------------------------------------------------------------------------- -std::string cmTarget::GetFrameworkVersion() +std::string cmTarget::GetFrameworkVersion() const { + assert(this->GetType() != INTERFACE_LIBRARY); + if(const char* fversion = this->GetProperty("FRAMEWORK_VERSION")) { return fversion; @@ -5587,7 +4163,7 @@ std::string cmTarget::GetFrameworkVersion() } //---------------------------------------------------------------------------- -const char* cmTarget::GetExportMacro() +const char* cmTarget::GetExportMacro() const { // Define the symbol for targets that export symbols. if(this->GetType() == cmTarget::SHARED_LIBRARY || @@ -5613,7 +4189,7 @@ const char* cmTarget::GetExportMacro() } //---------------------------------------------------------------------------- -bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) +bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) const { return this->LinkImplicitNullProperties.find(p) != this->LinkImplicitNullProperties.end(); @@ -5621,52 +4197,257 @@ bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) //---------------------------------------------------------------------------- template<typename PropertyType> -PropertyType getTypedProperty(cmTarget *tgt, const char *prop, +PropertyType getTypedProperty(cmTarget const* tgt, const char *prop, PropertyType *); //---------------------------------------------------------------------------- template<> -bool getTypedProperty<bool>(cmTarget *tgt, const char *prop, bool *) +bool getTypedProperty<bool>(cmTarget const* tgt, const char *prop, bool *) { return tgt->GetPropertyAsBool(prop); } //---------------------------------------------------------------------------- template<> -const char *getTypedProperty<const char *>(cmTarget *tgt, const char *prop, - const char **) +const char *getTypedProperty<const char *>(cmTarget const* tgt, + const char *prop, + const char **) { return tgt->GetProperty(prop); } +enum CompatibleType +{ + BoolType, + StringType, + NumberMinType, + NumberMaxType +}; + //---------------------------------------------------------------------------- template<typename PropertyType> -bool consistentProperty(PropertyType lhs, PropertyType rhs); +std::pair<bool, PropertyType> consistentProperty(PropertyType lhs, + PropertyType rhs, + CompatibleType t); //---------------------------------------------------------------------------- template<> -bool consistentProperty(bool lhs, bool rhs) +std::pair<bool, bool> consistentProperty(bool lhs, bool rhs, CompatibleType) { - return lhs == rhs; + return std::make_pair(lhs == rhs, lhs); +} + +//---------------------------------------------------------------------------- +std::pair<bool, const char*> consistentStringProperty(const char *lhs, + const char *rhs) +{ + const bool b = strcmp(lhs, rhs) == 0; + return std::make_pair(b, b ? lhs : 0); +} + +#if defined(_MSC_VER) && _MSC_VER <= 1200 +template<typename T> const T& +cmMaximum(const T& l, const T& r) {return l > r ? l : r;} +template<typename T> const T& +cmMinimum(const T& l, const T& r) {return l < r ? l : r;} +#else +#define cmMinimum std::min +#define cmMaximum std::max +#endif + +//---------------------------------------------------------------------------- +std::pair<bool, const char*> consistentNumberProperty(const char *lhs, + const char *rhs, + CompatibleType t) +{ + char *pEnd; + +#if defined(_MSC_VER) + static const char* const null_ptr = 0; +#else +# define null_ptr 0 +#endif + + long lnum = strtol(lhs, &pEnd, 0); + if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) + { + return std::pair<bool, const char*>(false, null_ptr); + } + + long rnum = strtol(rhs, &pEnd, 0); + if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) + { + return std::pair<bool, const char*>(false, null_ptr); + } + +#if !defined(_MSC_VER) +#undef null_ptr +#endif + + if (t == NumberMaxType) + { + return std::make_pair(true, cmMaximum(lnum, rnum) == lnum ? lhs : rhs); + } + else + { + return std::make_pair(true, cmMinimum(lnum, rnum) == lnum ? lhs : rhs); + } } //---------------------------------------------------------------------------- template<> -bool consistentProperty(const char *lhs, const char *rhs) +std::pair<bool, const char*> consistentProperty(const char *lhs, + const char *rhs, + CompatibleType t) { if (!lhs && !rhs) - return true; - if (!lhs || !rhs) - return false; - return strcmp(lhs, rhs) == 0; + { + return std::make_pair(true, lhs); + } + if (!lhs) + { + return std::make_pair(true, rhs); + } + if (!rhs) + { + return std::make_pair(true, lhs); + } + +#if defined(_MSC_VER) + static const char* const null_ptr = 0; +#else +# define null_ptr 0 +#endif + + switch(t) + { + case BoolType: + assert(!"consistentProperty for strings called with BoolType"); + return std::pair<bool, const char*>(false, null_ptr); + case StringType: + return consistentStringProperty(lhs, rhs); + case NumberMinType: + case NumberMaxType: + return consistentNumberProperty(lhs, rhs, t); + } + assert(!"Unreachable!"); + return std::pair<bool, const char*>(false, null_ptr); + +#if !defined(_MSC_VER) +#undef null_ptr +#endif + +} + +template<typename PropertyType> +PropertyType impliedValue(PropertyType); +template<> +bool impliedValue<bool>(bool) +{ + return false; +} +template<> +const char* impliedValue<const char*>(const char*) +{ + return ""; +} + + +template<typename PropertyType> +std::string valueAsString(PropertyType); +template<> +std::string valueAsString<bool>(bool value) +{ + return value ? "TRUE" : "FALSE"; +} +template<> +std::string valueAsString<const char*>(const char* value) +{ + return value ? value : "(unset)"; +} + +//---------------------------------------------------------------------------- +void +cmTarget::ReportPropertyOrigin(const std::string &p, + const std::string &result, + const std::string &report, + const std::string &compatibilityType) const +{ + std::vector<std::string> debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] + && std::find(debugProperties.begin(), + debugProperties.end(), + p) + != debugProperties.end(); + + if (this->Makefile->IsGeneratingBuildSystem()) + { + this->DebugCompatiblePropertiesDone[p] = true; + } + if (!debugOrigin) + { + return; + } + + std::string areport = compatibilityType; + areport += std::string(" of property \"") + p + "\" for target \""; + areport += std::string(this->GetName()); + areport += "\" (result: \""; + areport += result; + areport += "\"):\n" + report; + + cmListFileBacktrace lfbt; + this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport, lfbt); +} + +//---------------------------------------------------------------------------- +std::string compatibilityType(CompatibleType t) +{ + switch(t) + { + case BoolType: + return "Boolean compatibility"; + case StringType: + return "String compatibility"; + case NumberMaxType: + return "Numeric maximum compatibility"; + case NumberMinType: + return "Numeric minimum compatibility"; + } + assert(!"Unreachable!"); + return ""; +} + +//---------------------------------------------------------------------------- +std::string compatibilityAgree(CompatibleType t, bool dominant) +{ + switch(t) + { + case BoolType: + case StringType: + return dominant ? "(Disagree)\n" : "(Agree)\n"; + case NumberMaxType: + case NumberMinType: + return dominant ? "(Dominant)\n" : "(Ignored)\n"; + } + assert(!"Unreachable!"); + return ""; } //---------------------------------------------------------------------------- template<typename PropertyType> -PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt, +PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, const std::string &p, const char *config, const char *defaultValue, + CompatibleType t, PropertyType *) { PropertyType propContent = getTypedProperty<PropertyType>(tgt, p.c_str(), @@ -5687,6 +4468,23 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt, const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); bool propInitialized = explicitlySet; + std::string report = " * Target \""; + report += tgt->GetName(); + if (explicitlySet) + { + report += "\" has property content \""; + report += valueAsString<PropertyType>(propContent); + report += "\"\n"; + } + else if (impliedByUse) + { + report += "\" property is implied by use.\n"; + } + else + { + report += "\" property not set.\n"; + } + for(cmComputeLinkInformation::ItemVector::const_iterator li = deps.begin(); li != deps.end(); ++li) @@ -5708,11 +4506,27 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt, PropertyType ifacePropContent = getTypedProperty<PropertyType>(li->Target, ("INTERFACE_" + p).c_str(), 0); + + std::string reportEntry; + if (ifaceIsSet) + { + reportEntry += " * Target \""; + reportEntry += li->Target->GetName(); + reportEntry += "\" property value \""; + reportEntry += valueAsString<PropertyType>(ifacePropContent); + reportEntry += "\" "; + } + if (explicitlySet) { if (ifaceIsSet) { - if (!consistentProperty(propContent, ifacePropContent)) + std::pair<bool, PropertyType> consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) { cmOStringStream e; e << "Property " << p << " on target \"" @@ -5724,7 +4538,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt, } else { - // Agree + propContent = consistent.second; continue; } } @@ -5736,9 +4550,16 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt, } else if (impliedByUse) { + propContent = impliedValue<PropertyType>(propContent); + if (ifaceIsSet) { - if (!consistentProperty(propContent, ifacePropContent)) + std::pair<bool, PropertyType> consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) { cmOStringStream e; e << "Property " << p << " on target \"" @@ -5751,7 +4572,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt, } else { - // Agree + propContent = consistent.second; continue; } } @@ -5767,7 +4588,12 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt, { if (propInitialized) { - if (!consistentProperty(propContent, ifacePropContent)) + std::pair<bool, PropertyType> consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) { cmOStringStream e; e << "The INTERFACE_" << p << " property of \"" @@ -5779,12 +4605,13 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt, } else { - // Agree. + propContent = consistent.second; continue; } } else { + report += reportEntry + "(Interface set)\n"; propContent = ifacePropContent; propInitialized = true; } @@ -5796,30 +4623,58 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt, } } } + + tgt->ReportPropertyOrigin(p, valueAsString<PropertyType>(propContent), + report, compatibilityType(t)); return propContent; } //---------------------------------------------------------------------------- bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, - const char *config) + const char *config) const { return checkInterfacePropertyCompatibility<bool>(this, p, config, "FALSE", - 0); + BoolType, 0); } //---------------------------------------------------------------------------- const char * cmTarget::GetLinkInterfaceDependentStringProperty( const std::string &p, - const char *config) + const char *config) const { return checkInterfacePropertyCompatibility<const char *>(this, p, config, - "empty", 0); + "empty", + StringType, 0); } //---------------------------------------------------------------------------- -bool isLinkDependentProperty(cmTarget *tgt, const std::string &p, +const char * cmTarget::GetLinkInterfaceDependentNumberMinProperty( + const std::string &p, + const char *config) const +{ + return checkInterfacePropertyCompatibility<const char *>(this, + p, + config, + "empty", + NumberMinType, 0); +} + +//---------------------------------------------------------------------------- +const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty( + const std::string &p, + const char *config) const +{ + return checkInterfacePropertyCompatibility<const char *>(this, + p, + config, + "empty", + NumberMaxType, 0); +} + +//---------------------------------------------------------------------------- +bool isLinkDependentProperty(cmTarget const* tgt, const std::string &p, const char *interfaceProperty, const char *config) { @@ -5863,9 +4718,10 @@ bool isLinkDependentProperty(cmTarget *tgt, const std::string &p, //---------------------------------------------------------------------------- bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p, - const char *config) + const char *config) const { - if (this->TargetTypeValue == OBJECT_LIBRARY) + if (this->TargetTypeValue == OBJECT_LIBRARY + || this->TargetTypeValue == INTERFACE_LIBRARY) { return false; } @@ -5876,13 +4732,41 @@ bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p, //---------------------------------------------------------------------------- bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p, - const char *config) + const char *config) const +{ + if (this->TargetTypeValue == OBJECT_LIBRARY + || this->TargetTypeValue == INTERFACE_LIBRARY) + { + return false; + } + return (p == "AUTOUIC_OPTIONS") || + isLinkDependentProperty(this, p, "COMPATIBLE_INTERFACE_STRING", + config); +} + +//---------------------------------------------------------------------------- +bool cmTarget::IsLinkInterfaceDependentNumberMinProperty(const std::string &p, + const char *config) const { - if (this->TargetTypeValue == OBJECT_LIBRARY) + if (this->TargetTypeValue == OBJECT_LIBRARY + || this->TargetTypeValue == INTERFACE_LIBRARY) { return false; } - return isLinkDependentProperty(this, p, "COMPATIBLE_INTERFACE_STRING", + return isLinkDependentProperty(this, p, "COMPATIBLE_INTERFACE_NUMBER_MIN", + config); +} + +//---------------------------------------------------------------------------- +bool cmTarget::IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, + const char *config) const +{ + if (this->TargetTypeValue == OBJECT_LIBRARY + || this->TargetTypeValue == INTERFACE_LIBRARY) + { + return false; + } + return isLinkDependentProperty(this, p, "COMPATIBLE_INTERFACE_NUMBER_MAX", config); } @@ -5900,7 +4784,7 @@ void cmTarget::GetLanguages(std::set<cmStdString>& languages) const } //---------------------------------------------------------------------------- -bool cmTarget::IsChrpathUsed(const char* config) +bool cmTarget::IsChrpathUsed(const char* config) const { // Only certain target types have an rpath. if(!(this->GetType() == cmTarget::SHARED_LIBRARY || @@ -5967,7 +4851,7 @@ bool cmTarget::IsChrpathUsed(const char* config) //---------------------------------------------------------------------------- cmTarget::ImportInfo const* -cmTarget::GetImportInfo(const char* config, cmTarget *headTarget) +cmTarget::GetImportInfo(const char* config, cmTarget const* headTarget) const { // There is no imported information for non-imported targets. if(!this->IsImported()) @@ -5999,6 +4883,10 @@ cmTarget::GetImportInfo(const char* config, cmTarget *headTarget) i = this->Internal->ImportInfoMap.insert(entry).first; } + if(this->GetType() == INTERFACE_LIBRARY) + { + return &i->second; + } // If the location is empty then the target is not available for // this configuration. if(i->second.Location.empty() && i->second.ImportLibrary.empty()) @@ -6013,8 +4901,17 @@ cmTarget::GetImportInfo(const char* config, cmTarget *headTarget) bool cmTarget::GetMappedConfig(std::string const& desired_config, const char** loc, const char** imp, - std::string& suffix) + std::string& suffix) const { + if (this->GetType() == INTERFACE_LIBRARY) + { + // This method attempts to find a config-specific LOCATION for the + // IMPORTED library. In the case of INTERFACE_LIBRARY, there is no + // LOCATION at all, so leaving *loc and *imp unchanged is the appropriate + // and valid response. + return true; + } + // Track the configuration-specific property suffix. suffix = "_"; suffix += desired_config; @@ -6135,7 +5032,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, //---------------------------------------------------------------------------- void cmTarget::ComputeImportInfo(std::string const& desired_config, ImportInfo& info, - cmTarget *headTarget) + cmTarget const* headTarget) const { // This method finds information about an imported target from its // properties. The "IMPORTED_" namespace is reserved for properties @@ -6152,6 +5049,49 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, return; } + // Get the link interface. + { + std::string linkProp = "INTERFACE_LINK_LIBRARIES"; + const char *propertyLibs = this->GetProperty(linkProp.c_str()); + + if (this->GetType() != INTERFACE_LIBRARY) + { + if(!propertyLibs) + { + linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; + linkProp += suffix; + propertyLibs = this->GetProperty(linkProp.c_str()); + } + + if(!propertyLibs) + { + linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; + propertyLibs = this->GetProperty(linkProp.c_str()); + } + } + if(propertyLibs) + { + cmListFileBacktrace lfbt; + cmGeneratorExpression ge(lfbt); + + cmGeneratorExpressionDAGChecker dagChecker(lfbt, + this->GetName(), + linkProp, 0, 0); + cmSystemTools::ExpandListArgument(ge.Parse(propertyLibs) + ->Evaluate(this->Makefile, + desired_config.c_str(), + false, + headTarget, + this, + &dagChecker), + info.LinkInterface.Libraries); + } + } + if(this->GetType() == INTERFACE_LIBRARY) + { + return; + } + // A provided configuration has been chosen. Load the // configuration's properties. @@ -6224,42 +5164,6 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, } } - // Get the link interface. - { - std::string linkProp = "INTERFACE_LINK_LIBRARIES"; - const char *propertyLibs = this->GetProperty(linkProp.c_str()); - - if (!propertyLibs) - { - linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; - linkProp += suffix; - propertyLibs = this->GetProperty(linkProp.c_str()); - } - - if(!propertyLibs) - { - linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; - propertyLibs = this->GetProperty(linkProp.c_str()); - } - if(propertyLibs) - { - cmListFileBacktrace lfbt; - cmGeneratorExpression ge(lfbt); - - cmGeneratorExpressionDAGChecker dagChecker(lfbt, - this->GetName(), - linkProp, 0, 0); - cmSystemTools::ExpandListArgument(ge.Parse(propertyLibs) - ->Evaluate(this->Makefile, - desired_config.c_str(), - false, - headTarget, - this, - &dagChecker), - info.LinkInterface.Libraries); - } - } - // Get the link dependencies. { std::string linkProp = "IMPORTED_LINK_DEPENDENT_LIBRARIES"; @@ -6313,7 +5217,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, //---------------------------------------------------------------------------- cmTarget::LinkInterface const* cmTarget::GetLinkInterface(const char* config, - cmTarget *head) + cmTarget const* head) const { // Imported targets have their own link interface. if(this->IsImported()) @@ -6355,8 +5259,8 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface(const char* config, //---------------------------------------------------------------------------- void cmTarget::GetTransitivePropertyLinkLibraries( const char* config, - cmTarget *headTarget, - std::vector<std::string> &libs) + cmTarget const* headTarget, + std::vector<std::string> &libs) const { cmTarget::LinkInterface const* iface = this->GetLinkInterface(config, headTarget); @@ -6396,7 +5300,7 @@ void cmTarget::GetTransitivePropertyLinkLibraries( //---------------------------------------------------------------------------- bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, - cmTarget *headTarget) + cmTarget const* headTarget) const { // Construct the property name suffix for this configuration. std::string suffix = "_"; @@ -6412,12 +5316,20 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, // An explicit list of interface libraries may be set for shared // libraries and executables that export symbols. const char* explicitLibraries = 0; - const char* newExplicitLibraries = - this->GetProperty("INTERFACE_LINK_LIBRARIES"); std::string linkIfaceProp; - if(this->GetType() == cmTarget::SHARED_LIBRARY || - this->IsExecutableWithExports()) + if(this->PolicyStatusCMP0022 != cmPolicies::OLD && + this->PolicyStatusCMP0022 != cmPolicies::WARN) + { + // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. + linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; + explicitLibraries = this->GetProperty(linkIfaceProp.c_str()); + } + else if(this->GetType() == cmTarget::SHARED_LIBRARY || + this->IsExecutableWithExports()) { + // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a + // shared lib or executable. + // Lookup the per-configuration property. linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; linkIfaceProp += suffix; @@ -6429,105 +5341,40 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; explicitLibraries = this->GetProperty(linkIfaceProp.c_str()); } - if (newExplicitLibraries - && (!explicitLibraries || - (explicitLibraries - && strcmp(newExplicitLibraries, explicitLibraries) != 0))) - { - switch(this->GetPolicyStatusCMP0022()) - { - case cmPolicies::WARN: - { - cmOStringStream w; - w << (this->Makefile->GetPolicies() - ->GetPolicyWarning(cmPolicies::CMP0022)) << "\n" - << "Target \"" << this->GetName() << "\" has a " - "INTERFACE_LINK_LIBRARIES property which differs from its " - << linkIfaceProp << " properties." - "\n" - "INTERFACE_LINK_LIBRARIES:\n " - << newExplicitLibraries - << "\n" - << linkIfaceProp << ":\n " - << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; - this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - } - // Fall through - case cmPolicies::OLD: - break; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - explicitLibraries = newExplicitLibraries; - linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; - break; - } - } } - else if(this->GetType() == cmTarget::STATIC_LIBRARY) + + if(explicitLibraries && this->PolicyStatusCMP0022 == cmPolicies::WARN && + !this->Internal->PolicyWarnedCMP0022) { - if (newExplicitLibraries) + // Compare the explicitly set old link interface properties to the + // preferred new link interface property one and warn if different. + const char* newExplicitLibraries = + this->GetProperty("INTERFACE_LINK_LIBRARIES"); + if (newExplicitLibraries + && strcmp(newExplicitLibraries, explicitLibraries) != 0) { - cmListFileBacktrace lfbt; - cmGeneratorExpression ge(lfbt); - cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(), - "INTERFACE_LINK_LIBRARIES", 0, 0); - std::vector<std::string> ifaceLibs; - cmSystemTools::ExpandListArgument( - ge.Parse(newExplicitLibraries)->Evaluate( - this->Makefile, - config, - false, - headTarget, - this, &dagChecker), ifaceLibs); - LinkImplementation const* impl = this->GetLinkImplementation(config, - headTarget); - if (ifaceLibs != impl->Libraries) - { - switch(this->GetPolicyStatusCMP0022()) - { - case cmPolicies::WARN: - { - cmOStringStream w; - w << (this->Makefile->GetPolicies() - ->GetPolicyWarning(cmPolicies::CMP0022)) << "\n" - << "Static library target \"" << this->GetName() << "\" has a " - "INTERFACE_LINK_LIBRARIES property. This should be preferred " - "as the source of the link interface for this library. " - "Ignoring the property and using the link implementation " - "as the link interface instead."; - this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - } - // Fall through - case cmPolicies::OLD: - break; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - explicitLibraries = newExplicitLibraries; - linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; - break; - } - } - else - { - iface.Libraries = impl->Libraries; - if(this->LinkLanguagePropagatesToDependents()) - { - // Targets using this archive need its language runtime libraries. - iface.Languages = impl->Languages; - } - } + cmOStringStream w; + w << + (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0022)) << "\n" + "Target \"" << this->GetName() << "\" has an " + "INTERFACE_LINK_LIBRARIES property which differs from its " << + linkIfaceProp << " properties." + "\n" + "INTERFACE_LINK_LIBRARIES:\n" + " " << newExplicitLibraries << "\n" << + linkIfaceProp << ":\n" + " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n"; + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->Internal->PolicyWarnedCMP0022 = true; } } // There is no implicit link interface for executables or modules // so if none was explicitly set then there is no link interface. - // Note that CMake versions 2.2 and below allowed linking to modules. - bool canLinkModules = this->Makefile->NeedBackwardsCompatibility(2,2); if(!explicitLibraries && (this->GetType() == cmTarget::EXECUTABLE || - (this->GetType() == cmTarget::MODULE_LIBRARY && !canLinkModules))) + (this->GetType() == cmTarget::MODULE_LIBRARY))) { return false; } @@ -6547,7 +5394,8 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, this, &dagChecker), iface.Libraries); if(this->GetType() == cmTarget::SHARED_LIBRARY - || this->GetType() == cmTarget::STATIC_LIBRARY) + || this->GetType() == cmTarget::STATIC_LIBRARY + || this->GetType() == cmTarget::INTERFACE_LIBRARY) { // Shared libraries may have runtime implementation dependencies // on other shared libraries that are not in the interface. @@ -6557,42 +5405,46 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, { emitted.insert(*li); } - LinkImplementation const* impl = this->GetLinkImplementation(config, - headTarget); - for(std::vector<std::string>::const_iterator - li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) + if (this->GetType() != cmTarget::INTERFACE_LIBRARY) { - if(emitted.insert(*li).second) + LinkImplementation const* impl = this->GetLinkImplementation(config, + headTarget); + for(std::vector<std::string>::const_iterator + li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) { - if(cmTarget* tgt = this->Makefile->FindTargetToUse(li->c_str())) + if(emitted.insert(*li).second) { - // This is a runtime dependency on another shared library. - if(tgt->GetType() == cmTarget::SHARED_LIBRARY) + if(cmTarget* tgt = this->Makefile->FindTargetToUse(li->c_str())) { - iface.SharedDeps.push_back(*li); + // This is a runtime dependency on another shared library. + if(tgt->GetType() == cmTarget::SHARED_LIBRARY) + { + iface.SharedDeps.push_back(*li); + } + } + else + { + // TODO: Recognize shared library file names. Perhaps this + // should be moved to cmComputeLinkInformation, but that creates + // a chicken-and-egg problem since this list is needed for its + // construction. } - } - else - { - // TODO: Recognize shared library file names. Perhaps this - // should be moved to cmComputeLinkInformation, but that creates - // a chicken-and-egg problem since this list is needed for its - // construction. } } - } - if(this->LinkLanguagePropagatesToDependents()) - { - // Targets using this archive need its language runtime libraries. - iface.Languages = impl->Languages; + if(this->LinkLanguagePropagatesToDependents()) + { + // Targets using this archive need its language runtime libraries. + iface.Languages = impl->Languages; + } } } } - else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN - || this->GetPolicyStatusCMP0022() == cmPolicies::OLD) - // The implementation shouldn't be the interface if CMP0022 is NEW. That - // way, the LINK_LIBRARIES property can be set directly without having to - // empty the INTERFACE_LINK_LIBRARIES + else if (this->PolicyStatusCMP0022 == cmPolicies::WARN + || this->PolicyStatusCMP0022 == cmPolicies::OLD) + // If CMP0022 is NEW then the plain tll signature sets the + // INTERFACE_LINK_LIBRARIES, so if we get here then the project + // cleared the property explicitly and we should not fall back + // to the link implementation. { // The link implementation is the default link interface. LinkImplementation const* impl = this->GetLinkImplementation(config, @@ -6605,6 +5457,70 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, // Targets using this archive need its language runtime libraries. iface.Languages = impl->Languages; } + + if(this->PolicyStatusCMP0022 == cmPolicies::WARN && + !this->Internal->PolicyWarnedCMP0022) + { + // Compare the link implementation fallback link interface to the + // preferred new link interface property and warn if different. + cmListFileBacktrace lfbt; + cmGeneratorExpression ge(lfbt); + cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(), + "INTERFACE_LINK_LIBRARIES", 0, 0); + std::vector<std::string> ifaceLibs; + const char* newExplicitLibraries = + this->GetProperty("INTERFACE_LINK_LIBRARIES"); + cmSystemTools::ExpandListArgument( + ge.Parse(newExplicitLibraries)->Evaluate(this->Makefile, + config, + false, + headTarget, + this, &dagChecker), + ifaceLibs); + if (ifaceLibs != impl->Libraries) + { + std::string oldLibraries; + std::string newLibraries; + const char *sep = ""; + for(std::vector<std::string>::const_iterator it + = impl->Libraries.begin(); it != impl->Libraries.end(); ++it) + { + oldLibraries += sep; + oldLibraries += *it; + sep = ";"; + } + sep = ""; + for(std::vector<std::string>::const_iterator it + = ifaceLibs.begin(); it != ifaceLibs.end(); ++it) + { + newLibraries += sep; + newLibraries += *it; + sep = ";"; + } + if(oldLibraries.empty()) + { oldLibraries = "(empty)"; } + if(newLibraries.empty()) + { newLibraries = "(empty)"; } + + cmOStringStream w; + w << + (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0022)) << "\n" + "Target \"" << this->GetName() << "\" has an " + "INTERFACE_LINK_LIBRARIES property. " + "This should be preferred as the source of the link interface " + "for this library but because CMP0022 is not set CMake is " + "ignoring the property and using the link implementation " + "as the link interface instead." + "\n" + "INTERFACE_LINK_LIBRARIES:\n" + " " << newLibraries << "\n" + "Link implementation:\n" + " " << oldLibraries << "\n"; + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->Internal->PolicyWarnedCMP0022 = true; + } + } } if(this->GetType() == cmTarget::STATIC_LIBRARY) @@ -6629,7 +5545,7 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, //---------------------------------------------------------------------------- cmTarget::LinkImplementation const* -cmTarget::GetLinkImplementation(const char* config, cmTarget *head) +cmTarget::GetLinkImplementation(const char* config, cmTarget const* head) const { // There is no link implementation for imported targets. if(this->IsImported()) @@ -6659,11 +5575,8 @@ cmTarget::GetLinkImplementation(const char* config, cmTarget *head) //---------------------------------------------------------------------------- void cmTarget::ComputeLinkImplementation(const char* config, LinkImplementation& impl, - cmTarget *head) + cmTarget const* head) const { - // Compute which library configuration to link. - cmTarget::LinkLibraryType linkType = this->ComputeLinkType(config); - // Collect libraries directly linked in this configuration. std::vector<std::string> llibs; this->GetDirectLinkLibraries(config, llibs, head); @@ -6674,12 +5587,89 @@ void cmTarget::ComputeLinkImplementation(const char* config, std::string item = this->CheckCMP0004(*li); if(item == this->GetName() || item.empty()) { + if(item == this->GetName()) + { + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + cmOStringStream e; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0038)) + { + case cmPolicies::WARN: + { + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0038)) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; + } + + if(!noMessage) + { + e << "Target \"" << this->GetName() << "\" links to itself."; + this->Makefile->GetCMakeInstance()->IssueMessage(messageType, + e.str(), + this->GetBacktrace()); + if (messageType == cmake::FATAL_ERROR) + { + return; + } + } + } continue; } + cmTarget *tgt = this->Makefile->FindTargetToUse(li->c_str()); + + if(!tgt && std::string(item).find("::") != std::string::npos) + { + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + cmOStringStream e; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) + { + case cmPolicies::WARN: + { + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0028)) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; + } + + if(!noMessage) + { + e << "Target \"" << this->GetName() << "\" links to target \"" << item + << "\" but the target was not found. Perhaps a find_package() " + "call is missing for an IMPORTED target, or an ALIAS target is " + "missing?"; + this->Makefile->GetCMakeInstance()->IssueMessage(messageType, + e.str(), + this->GetBacktrace()); + if (messageType == cmake::FATAL_ERROR) + { + return; + } + } + } + // The entry is meant for this configuration. impl.Libraries.push_back(item); } + cmTarget::LinkLibraryType linkType = this->ComputeLinkType(config); LinkLibraryVectorType const& oldllibs = this->GetOriginalLinkLibraries(); for(cmTarget::LinkLibraryVectorType::const_iterator li = oldllibs.begin(); li != oldllibs.end(); ++li) @@ -6701,7 +5691,8 @@ void cmTarget::ComputeLinkImplementation(const char* config, // Get languages used in our source files. this->GetLanguages(languages); // Get languages used in object library sources. - for(std::vector<std::string>::iterator i = this->ObjectLibraries.begin(); + for(std::vector<std::string>::const_iterator + i = this->ObjectLibraries.begin(); i != this->ObjectLibraries.end(); ++i) { if(cmTarget* objLib = this->Makefile->FindTargetToUse(i->c_str())) @@ -6721,7 +5712,7 @@ void cmTarget::ComputeLinkImplementation(const char* config, } //---------------------------------------------------------------------------- -std::string cmTarget::CheckCMP0004(std::string const& item) +std::string cmTarget::CheckCMP0004(std::string const& item) const { // Strip whitespace off the library names because we used to do this // in case variables were expanded at generate time. We no longer @@ -6780,34 +5771,52 @@ std::string cmTarget::CheckCMP0004(std::string const& item) } template<typename PropertyType> -PropertyType getLinkInterfaceDependentProperty(cmTarget *tgt, +PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, const std::string prop, const char *config, + CompatibleType, PropertyType *); template<> -bool getLinkInterfaceDependentProperty(cmTarget *tgt, - const std::string prop, - const char *config, bool *) +bool getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string prop, + const char *config, + CompatibleType, bool *) { return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); } template<> -const char * getLinkInterfaceDependentProperty(cmTarget *tgt, - const std::string prop, - const char *config, - const char **) +const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string prop, + const char *config, + CompatibleType t, + const char **) { - return tgt->GetLinkInterfaceDependentStringProperty(prop, config); + switch(t) + { + case BoolType: + assert(!"String compatibility check function called for boolean"); + return 0; + case StringType: + return tgt->GetLinkInterfaceDependentStringProperty(prop, config); + case NumberMinType: + return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); + case NumberMaxType: + return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + } + assert(!"Unreachable!"); + return 0; } //---------------------------------------------------------------------------- template<typename PropertyType> -void checkPropertyConsistency(cmTarget *depender, cmTarget *dependee, +void checkPropertyConsistency(cmTarget const* depender, + cmTarget const* dependee, const char *propName, std::set<cmStdString> &emitted, const char *config, + CompatibleType t, PropertyType *) { const char *prop = dependee->GetProperty(propName); @@ -6818,13 +5827,16 @@ void checkPropertyConsistency(cmTarget *depender, cmTarget *dependee, std::vector<std::string> props; cmSystemTools::ExpandListArgument(prop, props); + std::string pdir = + dependee->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT"); + pdir += "/Help/prop_tgt/"; for(std::vector<std::string>::iterator pi = props.begin(); pi != props.end(); ++pi) { - if (depender->GetMakefile()->GetCMakeInstance() - ->GetIsPropertyDefined(pi->c_str(), - cmProperty::TARGET)) + std::string pname = cmSystemTools::HelpFileName(*pi); + std::string pfile = pdir + pname + ".rst"; + if(cmSystemTools::FileExists(pfile.c_str(), true)) { cmOStringStream e; e << "Target \"" << dependee->GetName() << "\" has property \"" @@ -6837,7 +5849,7 @@ void checkPropertyConsistency(cmTarget *depender, cmTarget *dependee, if(emitted.insert(*pi).second) { getLinkInterfaceDependentProperty<PropertyType>(depender, *pi, config, - 0); + t, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -6846,14 +5858,60 @@ void checkPropertyConsistency(cmTarget *depender, cmTarget *dependee, } } +static cmStdString intersect(const std::set<cmStdString> &s1, + const std::set<cmStdString> &s2) +{ + std::set<cmStdString> intersect; + std::set_intersection(s1.begin(),s1.end(), + s2.begin(),s2.end(), + std::inserter(intersect,intersect.begin())); + if (!intersect.empty()) + { + return *intersect.begin(); + } + return ""; +} +static cmStdString intersect(const std::set<cmStdString> &s1, + const std::set<cmStdString> &s2, + const std::set<cmStdString> &s3) +{ + cmStdString result; + result = intersect(s1, s2); + if (!result.empty()) + return result; + result = intersect(s1, s3); + if (!result.empty()) + return result; + return intersect(s2, s3); +} +static cmStdString intersect(const std::set<cmStdString> &s1, + const std::set<cmStdString> &s2, + const std::set<cmStdString> &s3, + const std::set<cmStdString> &s4) +{ + cmStdString result; + result = intersect(s1, s2); + if (!result.empty()) + return result; + result = intersect(s1, s3); + if (!result.empty()) + return result; + result = intersect(s1, s4); + if (!result.empty()) + return result; + return intersect(s2, s3, s4); +} + //---------------------------------------------------------------------------- void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, - const char* config) + const char* config) const { const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); std::set<cmStdString> emittedBools; std::set<cmStdString> emittedStrings; + std::set<cmStdString> emittedMinNumbers; + std::set<cmStdString> emittedMaxNumbers; for(cmComputeLinkInformation::ItemVector::const_iterator li = deps.begin(); @@ -6866,43 +5924,93 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, checkPropertyConsistency<bool>(this, li->Target, "COMPATIBLE_INTERFACE_BOOL", - emittedBools, config, 0); + emittedBools, config, BoolType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; } checkPropertyConsistency<const char *>(this, li->Target, "COMPATIBLE_INTERFACE_STRING", - emittedStrings, config, 0); + emittedStrings, config, + StringType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency<const char *>(this, li->Target, + "COMPATIBLE_INTERFACE_NUMBER_MIN", + emittedMinNumbers, config, + NumberMinType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency<const char *>(this, li->Target, + "COMPATIBLE_INTERFACE_NUMBER_MAX", + emittedMaxNumbers, config, + NumberMaxType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; } } - for(std::set<cmStdString>::const_iterator li = emittedBools.begin(); - li != emittedBools.end(); ++li) + std::string prop = intersect(emittedBools, + emittedStrings, + emittedMinNumbers, + emittedMaxNumbers); + + if (!prop.empty()) { - const std::set<cmStdString>::const_iterator si = emittedStrings.find(*li); - if (si != emittedStrings.end()) + std::set<std::string> props; + std::set<cmStdString>::const_iterator i = emittedBools.find(prop); + if (i != emittedBools.end()) { - cmOStringStream e; - e << "Property \"" << *li << "\" appears in both the " - "COMPATIBLE_INTERFACE_BOOL and the COMPATIBLE_INTERFACE_STRING " - "property in the dependencies of target \"" << this->GetName() << - "\". This is not allowed. A property may only require compatibility " - "in a boolean interpretation or a string interpretation, but not both."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - break; + props.insert("COMPATIBLE_INTERFACE_BOOL"); + } + i = emittedStrings.find(prop); + if (i != emittedStrings.end()) + { + props.insert("COMPATIBLE_INTERFACE_STRING"); + } + i = emittedMinNumbers.find(prop); + if (i != emittedMinNumbers.end()) + { + props.insert("COMPATIBLE_INTERFACE_NUMBER_MIN"); + } + i = emittedMaxNumbers.find(prop); + if (i != emittedMaxNumbers.end()) + { + props.insert("COMPATIBLE_INTERFACE_NUMBER_MAX"); + } + + std::string propsString = *props.begin(); + props.erase(props.begin()); + while (props.size() > 1) + { + propsString += ", " + *props.begin(); + props.erase(props.begin()); } + if (props.size() == 1) + { + propsString += " and the " + *props.begin(); + } + cmOStringStream e; + e << "Property \"" << prop << "\" appears in both the " + << propsString << + " property in the dependencies of target \"" << this->GetName() << + "\". This is not allowed. A property may only require compatibility " + "in a boolean interpretation, a numeric minimum, a numeric maximum or a " + "string interpretation, but not a mixture."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); } } //---------------------------------------------------------------------------- cmComputeLinkInformation* -cmTarget::GetLinkInformation(const char* config, cmTarget *head) +cmTarget::GetLinkInformation(const char* config, cmTarget const* head) const { - cmTarget *headTarget = head ? head : this; + cmTarget const* headTarget = head ? head : this; // Lookup any existing information for this configuration. TargetConfigPair key(headTarget, cmSystemTools::UpperCase(config?config:"")); @@ -6933,7 +6041,7 @@ cmTarget::GetLinkInformation(const char* config, cmTarget *head) //---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkDirectory(const char* config, - bool rootDir) + bool rootDir) const { std::string fpath; fpath += this->GetOutputName(config, false); @@ -6948,7 +6056,7 @@ std::string cmTarget::GetFrameworkDirectory(const char* config, //---------------------------------------------------------------------------- std::string cmTarget::GetCFBundleDirectory(const char* config, - bool contentOnly) + bool contentOnly) const { std::string fpath; fpath += this->GetOutputName(config, false); @@ -6967,7 +6075,7 @@ std::string cmTarget::GetCFBundleDirectory(const char* config, //---------------------------------------------------------------------------- std::string cmTarget::GetAppBundleDirectory(const char* config, - bool contentOnly) + bool contentOnly) const { std::string fpath = this->GetFullName(config, false); fpath += ".app/Contents"; @@ -6979,7 +6087,7 @@ std::string cmTarget::GetAppBundleDirectory(const char* config, //---------------------------------------------------------------------------- std::string cmTarget::BuildMacContentDirectory(const std::string& base, const char* config, - bool contentOnly) + bool contentOnly) const { std::string fpath = base; if(this->IsAppBundleOnApple()) @@ -6999,7 +6107,7 @@ std::string cmTarget::BuildMacContentDirectory(const std::string& base, //---------------------------------------------------------------------------- std::string cmTarget::GetMacContentDirectory(const char* config, - bool implib) + bool implib) const { // Start with the output directory for the target. std::string fpath = this->GetDirectory(config, implib); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 27b74ca..ce0d812 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -25,7 +25,9 @@ F(CMP0008) \ F(CMP0020) \ F(CMP0021) \ - F(CMP0022) + F(CMP0022) \ + F(CMP0041) \ + F(CMP0042) class cmake; class cmMakefile; @@ -34,11 +36,14 @@ class cmGlobalGenerator; class cmComputeLinkInformation; class cmListFileBacktrace; class cmTarget; +class cmGeneratorTarget; +class cmTargetTraceDependencies; struct cmTargetLinkInformationMap: - public std::map<std::pair<cmTarget*, std::string>, cmComputeLinkInformation*> + public std::map<std::pair<cmTarget const* , std::string>, + cmComputeLinkInformation*> { - typedef std::map<std::pair<cmTarget*, std::string>, + typedef std::map<std::pair<cmTarget const* , std::string>, cmComputeLinkInformation*> derived; cmTargetLinkInformationMap() {} cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r); @@ -72,6 +77,7 @@ public: enum TargetType { EXECUTABLE, STATIC_LIBRARY, SHARED_LIBRARY, MODULE_LIBRARY, OBJECT_LIBRARY, UTILITY, GLOBAL_TARGET, + INTERFACE_LIBRARY, UNKNOWN_LIBRARY}; static const char* GetTargetTypeName(TargetType targetType); enum CustomCommandType { PRE_BUILD, PRE_LINK, POST_BUILD }; @@ -93,7 +99,7 @@ public: ///! Set/Get the name of the target const char* GetName() const {return this->Name.c_str();} - const char* GetExportName(); + const char* GetExportName() const; ///! Set the cmMakefile that owns this target void SetMakefile(cmMakefile *mf); @@ -110,26 +116,29 @@ public: /** * Get the list of the custom commands for this target */ - std::vector<cmCustomCommand> &GetPreBuildCommands() + std::vector<cmCustomCommand> const &GetPreBuildCommands() const {return this->PreBuildCommands;} - std::vector<cmCustomCommand> &GetPreLinkCommands() + std::vector<cmCustomCommand> const &GetPreLinkCommands() const {return this->PreLinkCommands;} - std::vector<cmCustomCommand> &GetPostBuildCommands() + std::vector<cmCustomCommand> const &GetPostBuildCommands() const {return this->PostBuildCommands;} + void AddPreBuildCommand(cmCustomCommand const &cmd) + {this->PreBuildCommands.push_back(cmd);} + void AddPreLinkCommand(cmCustomCommand const &cmd) + {this->PreLinkCommands.push_back(cmd);} + void AddPostBuildCommand(cmCustomCommand const &cmd) + {this->PostBuildCommands.push_back(cmd);} /** * Get the list of the source files used by this target */ - std::vector<cmSourceFile*> const& GetSourceFiles(); + void GetSourceFiles(std::vector<cmSourceFile*> &files) const; void AddSourceFile(cmSourceFile* sf); std::vector<std::string> const& GetObjectLibraries() const { return this->ObjectLibraries; } - /** Get sources that must be built before the given source. */ - std::vector<cmSourceFile*> const* GetSourceDepends(cmSourceFile* sf); - /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. @@ -155,7 +164,8 @@ public: /** * Get the flags for a given source file as used in this target */ - struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf); + struct SourceFileFlags + GetTargetSourceFileFlags(const cmSourceFile* sf) const; /** * Add sources to the target. @@ -175,10 +185,13 @@ public: {return this->OriginalLinkLibraries;} void GetDirectLinkLibraries(const char *config, std::vector<std::string> &, - cmTarget *head); + cmTarget const* head) const; + void GetInterfaceLinkLibraries(const char *config, + std::vector<std::string> &, + cmTarget const* head) const; /** Compute the link type to use for the given configuration. */ - LinkLibraryType ComputeLinkType(const char* config); + LinkLibraryType ComputeLinkType(const char* config) const; /** * Clear the dependency information recorded for this target, if any. @@ -186,7 +199,7 @@ public: void ClearDependencyInformation(cmMakefile& mf, const char* target); // Check to see if a library is a framework and treat it different on Mac - bool NameResolvesToFramework(const std::string& libname); + bool NameResolvesToFramework(const std::string& libname) const; void AddLinkLibrary(cmMakefile& mf, const char *target, const char* lib, LinkLibraryType llt); @@ -200,7 +213,7 @@ public: void MergeLinkLibraries( cmMakefile& mf, const char* selfname, const LinkLibraryVectorType& libs ); - const std::vector<std::string>& GetLinkDirectories(); + const std::vector<std::string>& GetLinkDirectories() const; void AddLinkDirectory(const char* d); @@ -208,30 +221,31 @@ public: * Set the path where this target should be installed. This is relative to * INSTALL_PREFIX */ - std::string GetInstallPath() {return this->InstallPath;} + std::string GetInstallPath() const {return this->InstallPath;} void SetInstallPath(const char *name) {this->InstallPath = name;} /** * Set the path where this target (if it has a runtime part) should be * installed. This is relative to INSTALL_PREFIX */ - std::string GetRuntimeInstallPath() {return this->RuntimeInstallPath;} + std::string GetRuntimeInstallPath() const {return this->RuntimeInstallPath;} void SetRuntimeInstallPath(const char *name) { this->RuntimeInstallPath = name; } /** * Get/Set whether there is an install rule for this target. */ - bool GetHaveInstallRule() { return this->HaveInstallRule; } + bool GetHaveInstallRule() const { return this->HaveInstallRule; } void SetHaveInstallRule(bool h) { this->HaveInstallRule = h; } /** Add a utility on which this project depends. A utility is an executable * name as would be specified to the ADD_EXECUTABLE or UTILITY_SOURCE * commands. It is not a full path nor does it have an extension. */ - void AddUtility(const char* u) { this->Utilities.insert(u);} + void AddUtility(const char* u, cmMakefile *makefile = 0); ///! Get the utilities used by this target std::set<cmStdString>const& GetUtilities() const { return this->Utilities; } + cmListFileBacktrace const* GetUtilityBacktrace(const char* u) const; /** Finalize the target at the end of the Configure step. */ void FinishConfigure(); @@ -239,12 +253,12 @@ public: ///! Set/Get a property of this target file void SetProperty(const char *prop, const char *value); void AppendProperty(const char* prop, const char* value,bool asString=false); - const char *GetProperty(const char *prop); - const char *GetProperty(const char *prop, cmProperty::ScopeType scope); - bool GetPropertyAsBool(const char *prop); - void CheckProperty(const char* prop, cmMakefile* context); + const char *GetProperty(const char *prop) const; + const char *GetProperty(const char *prop, cmProperty::ScopeType scope) const; + bool GetPropertyAsBool(const char *prop) const; + void CheckProperty(const char* prop, cmMakefile* context) const; - const char* GetFeature(const char* feature, const char* config); + const char* GetFeature(const char* feature, const char* config) const; bool IsImported() const {return this->IsImportedTarget;} @@ -277,10 +291,10 @@ public: /** Get the link interface for the given configuration. Returns 0 if the target cannot be linked. */ LinkInterface const* GetLinkInterface(const char* config, - cmTarget *headTarget); + cmTarget const* headTarget) const; void GetTransitivePropertyLinkLibraries(const char* config, - cmTarget *headTarget, - std::vector<std::string> &libs); + cmTarget const* headTarget, + std::vector<std::string> &libs) const; /** The link implementation specifies the direct library dependencies needed by the object files of the target. */ @@ -297,7 +311,7 @@ public: std::vector<std::string> WrongConfigLibraries; }; LinkImplementation const* GetLinkImplementation(const char* config, - cmTarget *head); + cmTarget const* head) const; /** Link information from the transitive closure of the link implementation and the interfaces of its dependencies. */ @@ -309,44 +323,40 @@ public: // Languages whose runtime libraries must be linked. std::vector<std::string> Languages; }; - LinkClosure const* GetLinkClosure(const char* config, cmTarget *head); + LinkClosure const* GetLinkClosure(const char* config, + cmTarget const* head) const; /** Strip off leading and trailing whitespace from an item named in the link dependencies of this target. */ - std::string CheckCMP0004(std::string const& item); + std::string CheckCMP0004(std::string const& item) const; /** Get the directory in which this target will be built. If the configuration name is given then the generator will add its subdirectory for that configuration. Otherwise just the canonical output directory is given. */ - std::string GetDirectory(const char* config = 0, bool implib = false); + std::string GetDirectory(const char* config = 0, bool implib = false) const; /** Get the directory in which this targets .pdb files will be placed. If the configuration name is given then the generator will add its subdirectory for that configuration. Otherwise just the canonical pdb output directory is given. */ - std::string GetPDBDirectory(const char* config = 0); + std::string GetPDBDirectory(const char* config = 0) const; /** Get the location of the target in the build tree for the given configuration. This location is suitable for use as the LOCATION target property. */ - const char* GetLocation(const char* config); + const char* GetLocation(const char* config) const; /** Get the target major and minor version numbers interpreted from the VERSION property. Version 0 is returned if the property is not set or cannot be parsed. */ - void GetTargetVersion(int& major, int& minor); + void GetTargetVersion(int& major, int& minor) const; /** Get the target major, minor, and patch version numbers interpreted from the VERSION or SOVERSION property. Version 0 is returned if the property is not set or cannot be parsed. */ - void GetTargetVersion(bool soversion, int& major, int& minor, int& patch); - - /** - * Trace through the source files in this target and add al source files - * that they depend on, used by all generators - */ - void TraceDependencies(); + void + GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; /** * Make sure the full path to all source files is known. @@ -354,101 +364,102 @@ public: bool FindSourceFiles(); ///! Return the preferred linker language for this target - const char* GetLinkerLanguage(const char* config = 0, cmTarget *head = 0); + const char* GetLinkerLanguage(const char* config = 0, + cmTarget const* head = 0) const; /** Get the full name of the target according to the settings in its makefile. */ - std::string GetFullName(const char* config=0, bool implib = false); + std::string GetFullName(const char* config=0, bool implib = false) const; void GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, - const char* config=0, bool implib = false); + const char* config=0, bool implib = false) const; /** Get the name of the pdb file for the target. */ - std::string GetPDBName(const char* config=0); + std::string GetPDBName(const char* config=0) const; /** Whether this library has soname enabled and platform supports it. */ - bool HasSOName(const char* config); + bool HasSOName(const char* config) const; /** Get the soname of the target. Allowed only for a shared library. */ - std::string GetSOName(const char* config); + std::string GetSOName(const char* config) const; - /** Whether this library has @rpath and platform supports it. */ - bool HasMacOSXRpath(const char* config); + /** Whether this library has \@rpath and platform supports it. */ + bool HasMacOSXRpathInstallNameDir(const char* config) const; + + /** Whether this library defaults to \@rpath. */ + bool MacOSXRpathInstallNameDirDefault() const; /** Test for special case of a third-party shared library that has no soname at all. */ - bool IsImportedSharedLibWithoutSOName(const char* config); + bool IsImportedSharedLibWithoutSOName(const char* config) const; /** Get the full path to the target according to the settings in its makefile and the configuration type. */ std::string GetFullPath(const char* config=0, bool implib = false, - bool realname = false); + bool realname = false) const; /** Get the names of the library needed to generate a build rule that takes into account shared library version numbers. This should be called only on a library target. */ void GetLibraryNames(std::string& name, std::string& soName, std::string& realName, std::string& impName, - std::string& pdbName, const char* config); + std::string& pdbName, const char* config) const; /** Get the names of the executable needed to generate a build rule that takes into account executable version numbers. This should be called only on an executable target. */ void GetExecutableNames(std::string& name, std::string& realName, std::string& impName, - std::string& pdbName, const char* config); + std::string& pdbName, const char* config) const; /** Does this target have a GNU implib to convert to MS format? */ - bool HasImplibGNUtoMS(); + bool HasImplibGNUtoMS() const; /** Convert the given GNU import library name (.dll.a) to a name with a new extension (.lib or ${CMAKE_IMPORT_LIBRARY_SUFFIX}). */ bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, - const char* newExt = 0); - - /** Add the target output files to the global generator manifest. */ - void GenerateTargetManifest(const char* config); + const char* newExt = 0) const; /** * Compute whether this target must be relinked before installing. */ - bool NeedRelinkBeforeInstall(const char* config); + bool NeedRelinkBeforeInstall(const char* config) const; - bool HaveBuildTreeRPATH(const char *config); - bool HaveInstallTreeRPATH(); + bool HaveBuildTreeRPATH(const char *config) const; + bool HaveInstallTreeRPATH() const; /** Return true if builtin chrpath will work for this target */ - bool IsChrpathUsed(const char* config); + bool IsChrpathUsed(const char* config) const; /** Return the install name directory for the target in the - * build tree. For example: "@rpath/", "@loader_path/", + * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ - std::string GetInstallNameDirForBuildTree(const char* config); + std::string GetInstallNameDirForBuildTree(const char* config) const; /** Return the install name directory for the target in the - * install tree. For example: "@rpath/" or "@loader_path/". */ - std::string GetInstallNameDirForInstallTree(); + * install tree. For example: "\@rpath/" or "\@loader_path/". */ + std::string GetInstallNameDirForInstallTree() const; cmComputeLinkInformation* GetLinkInformation(const char* config, - cmTarget *head = 0); + cmTarget const* head = 0) const; // Get the properties - cmPropertyMap &GetProperties() { return this->Properties; }; + cmPropertyMap &GetProperties() const { return this->Properties; }; bool GetMappedConfig(std::string const& desired_config, const char** loc, const char** imp, - std::string& suffix); + std::string& suffix) const; // Define the properties static void DefineProperties(cmake *cm); /** Get the macro to define when building sources in this target. If no macro should be defined null is returned. */ - const char* GetExportMacro(); + const char* GetExportMacro() const; void GetCompileDefinitions(std::vector<std::string> &result, - const char *config); + const char *config) const; // Compute the set of languages compiled by the target. This is // computed every time it is called because the languages can change @@ -459,34 +470,34 @@ public: /** Return whether this target is an executable with symbol exports enabled. */ - bool IsExecutableWithExports(); + bool IsExecutableWithExports() const; /** Return whether this target may be used to link another target. */ - bool IsLinkable(); + bool IsLinkable() const; /** Return whether or not the target is for a DLL platform. */ - bool IsDLLPlatform() { return this->DLLPlatform; } + bool IsDLLPlatform() const { return this->DLLPlatform; } /** Return whether or not the target has a DLL import library. */ - bool HasImportLibrary(); + bool HasImportLibrary() const; /** Return whether this target is a shared library Framework on Apple. */ - bool IsFrameworkOnApple(); + bool IsFrameworkOnApple() const; /** Return whether this target is a CFBundle (plugin) on Apple. */ - bool IsCFBundleOnApple(); + bool IsCFBundleOnApple() const; /** Return whether this target is an executable Bundle on Apple. */ - bool IsAppBundleOnApple(); + bool IsAppBundleOnApple() const; /** Return whether this target is an executable Bundle, a framework or CFBundle on Apple. */ - bool IsBundleOnApple(); + bool IsBundleOnApple() const; /** Return the framework version string. Undefined if IsFrameworkOnApple returns false. */ - std::string GetFrameworkVersion(); + std::string GetFrameworkVersion() const; /** Get a backtrace from the creation of the target. */ cmListFileBacktrace const& GetBacktrace() const; @@ -496,25 +507,26 @@ public: /** Return whether this target uses the default value for its output directory. */ - bool UsesDefaultOutputDir(const char* config, bool implib); + bool UsesDefaultOutputDir(const char* config, bool implib) const; /** @return the mac content directory for this target. */ std::string GetMacContentDirectory(const char* config, - bool implib); + bool implib) const; /** @return whether this target have a well defined output file name. */ - bool HaveWellDefinedOutputFiles(); + bool HaveWellDefinedOutputFiles() const; /** @return the Mac framework directory without the base. */ - std::string GetFrameworkDirectory(const char* config, bool rootDir); + std::string GetFrameworkDirectory(const char* config, bool rootDir) const; /** @return the Mac CFBundle directory without the base */ - std::string GetCFBundleDirectory(const char* config, bool contentOnly); + std::string GetCFBundleDirectory(const char* config, bool contentOnly) const; /** @return the Mac App directory without the base */ - std::string GetAppBundleDirectory(const char* config, bool contentOnly); + std::string GetAppBundleDirectory(const char* config, + bool contentOnly) const; - std::vector<std::string> GetIncludeDirectories(const char *config); + std::vector<std::string> GetIncludeDirectories(const char *config) const; void InsertInclude(const cmValueWithOrigin &entry, bool before = false); void InsertCompileOption(const cmValueWithOrigin &entry, @@ -525,34 +537,49 @@ public: void AppendBuildInterfaceIncludes(); void GetCompileOptions(std::vector<std::string> &result, - const char *config); + const char *config) const; + void GetAutoUicOptions(std::vector<std::string> &result, + const char *config) const; - bool IsNullImpliedByLinkLibraries(const std::string &p); + bool IsNullImpliedByLinkLibraries(const std::string &p) const; bool IsLinkInterfaceDependentBoolProperty(const std::string &p, - const char *config); + const char *config) const; bool IsLinkInterfaceDependentStringProperty(const std::string &p, - const char *config); + const char *config) const; + bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p, + const char *config) const; + bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, + const char *config) const; bool GetLinkInterfaceDependentBoolProperty(const std::string &p, - const char *config); + const char *config) const; const char *GetLinkInterfaceDependentStringProperty(const std::string &p, - const char *config); + const char *config) const; + const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p, + const char *config) const; + const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, + const char *config) const; std::string GetDebugGeneratorExpressions(const std::string &value, - cmTarget::LinkLibraryType llt); + cmTarget::LinkLibraryType llt) const; void AddSystemIncludeDirectories(const std::set<cmStdString> &incs); void AddSystemIncludeDirectories(const std::vector<std::string> &incs); std::set<cmStdString> const & GetSystemIncludeDirectories() const { return this->SystemIncludeDirectories; } - void FinalizeSystemIncludeDirectories(); - bool LinkLanguagePropagatesToDependents() const { return this->TargetTypeValue == STATIC_LIBRARY; } + void ReportPropertyOrigin(const std::string &p, + const std::string &result, + const std::string &report, + const std::string &compatibilityType) const; + private: + bool HandleLocationPropertyPolicy() const; + // The set of include directories that are marked as system include // directories. std::set<cmStdString> SystemIncludeDirectories; @@ -610,42 +637,42 @@ private: void AnalyzeLibDependencies( const cmMakefile& mf ); - const char* GetSuffixVariableInternal(bool implib); - const char* GetPrefixVariableInternal(bool implib); - std::string GetFullNameInternal(const char* config, bool implib); + const char* GetSuffixVariableInternal(bool implib) const; + const char* GetPrefixVariableInternal(bool implib) const; + std::string GetFullNameInternal(const char* config, bool implib) const; void GetFullNameInternal(const char* config, bool implib, std::string& outPrefix, std::string& outBase, - std::string& outSuffix); + std::string& outSuffix) const; // Use a makefile variable to set a default for the given property. // If the variable is not defined use the given default instead. void SetPropertyDefault(const char* property, const char* default_value); // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. - const char* GetOutputTargetType(bool implib); + const char* GetOutputTargetType(bool implib) const; // Get the target base name. - std::string GetOutputName(const char* config, bool implib); + std::string GetOutputName(const char* config, bool implib) const; - const char* ImportedGetLocation(const char* config); - const char* NormalGetLocation(const char* config); + const char* ImportedGetLocation(const char* config) const; + const char* NormalGetLocation(const char* config) const; - std::string GetFullNameImported(const char* config, bool implib); + std::string GetFullNameImported(const char* config, bool implib) const; - std::string ImportedGetFullPath(const char* config, bool implib); + std::string ImportedGetFullPath(const char* config, bool implib) const; std::string NormalGetFullPath(const char* config, bool implib, - bool realname); + bool realname) const; /** Get the real name of the target. Allowed only for non-imported targets. When a library or executable file is versioned this is the full versioned name. If the target is not versioned this is the same as GetFullName. */ - std::string NormalGetRealName(const char* config); + std::string NormalGetRealName(const char* config) const; /** Append to @a base the mac content directory and return it. */ std::string BuildMacContentDirectory(const std::string& base, const char* config, - bool contentOnly); + bool contentOnly) const; private: std::string Name; @@ -663,44 +690,48 @@ private: bool HaveInstallRule; std::string InstallPath; std::string RuntimeInstallPath; - std::string Location; - std::string ExportMacro; + mutable std::string ExportMacro; std::set<cmStdString> Utilities; + std::map<cmStdString, cmListFileBacktrace> UtilityBacktraces; bool RecordDependencies; - cmPropertyMap Properties; + mutable cmPropertyMap Properties; LinkLibraryVectorType OriginalLinkLibraries; bool DLLPlatform; bool IsApple; bool IsImportedTarget; - bool DebugIncludesDone; - bool DebugCompileOptionsDone; - bool DebugCompileDefinitionsDone; + mutable bool DebugIncludesDone; + mutable std::map<std::string, bool> DebugCompatiblePropertiesDone; + mutable bool DebugCompileOptionsDone; + mutable bool DebugCompileDefinitionsDone; mutable std::set<std::string> LinkImplicitNullProperties; bool BuildInterfaceIncludesAppended; // Cache target output paths for each configuration. struct OutputInfo; - OutputInfo const* GetOutputInfo(const char* config); - bool ComputeOutputDir(const char* config, bool implib, std::string& out); - bool ComputePDBOutputDir(const char* config, std::string& out); + OutputInfo const* GetOutputInfo(const char* config) const; + bool + ComputeOutputDir(const char* config, bool implib, std::string& out) const; + bool ComputePDBOutputDir(const char* config, std::string& out) const; // Cache import information from properties for each configuration. struct ImportInfo; ImportInfo const* GetImportInfo(const char* config, - cmTarget *workingTarget); + cmTarget const* workingTarget) const; void ComputeImportInfo(std::string const& desired_config, ImportInfo& info, - cmTarget *head); + cmTarget const* head) const; - cmTargetLinkInformationMap LinkInformation; + mutable cmTargetLinkInformationMap LinkInformation; void CheckPropertyCompatibility(cmComputeLinkInformation *info, - const char* config); + const char* config) const; bool ComputeLinkInterface(const char* config, LinkInterface& iface, - cmTarget *head); + cmTarget const* head) const; void ComputeLinkImplementation(const char* config, - LinkImplementation& impl, cmTarget *head); - void ComputeLinkClosure(const char* config, LinkClosure& lc, cmTarget *head); + LinkImplementation& impl, + cmTarget const* head) const; + void ComputeLinkClosure(const char* config, LinkClosure& lc, + cmTarget const* head) const; void ClearLinkMaps(); @@ -722,15 +753,17 @@ private: // Internal representation details. friend class cmTargetInternals; + friend class cmGeneratorTarget; + friend class cmTargetTraceDependencies; cmTargetInternalPointer Internal; - void ConstructSourceFileFlags(); + void ConstructSourceFileFlags() const; void ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, std::string const& suffix, std::string const& name, - const char* version); + const char* version) const; }; typedef std::map<cmStdString,cmTarget> cmTargets; diff --git a/Source/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx index 46c9666..b567252 100644 --- a/Source/cmTargetCompileDefinitionsCommand.cxx +++ b/Source/cmTargetCompileDefinitionsCommand.cxx @@ -44,7 +44,7 @@ std::string cmTargetCompileDefinitionsCommand for(std::vector<std::string>::const_iterator it = content.begin(); it != content.end(); ++it) { - if (strncmp(it->c_str(), "-D", 2) == 0) + if (cmHasLiteralPrefix(it->c_str(), "-D")) { defs += sep + it->substr(2); } diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h index 585485d..7405e90 100644 --- a/Source/cmTargetCompileDefinitionsCommand.h +++ b/Source/cmTargetCompileDefinitionsCommand.h @@ -38,41 +38,6 @@ public: */ virtual const char* GetName() const { return "target_compile_definitions";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return - "Add compile definitions to a target."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " target_compile_definitions(<target> " - "<INTERFACE|PUBLIC|PRIVATE> [items1...]\n" - " [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])\n" - "Specify compile definitions to use when compiling a given target. " - "The named <target> must have been created by a command such as " - "add_executable or add_library and must not be an IMPORTED target. " - "The INTERFACE, PUBLIC and PRIVATE keywords are required to specify " - "the scope of the following arguments. PRIVATE and PUBLIC items will " - "populate the COMPILE_DEFINITIONS property of <target>. PUBLIC and " - "INTERFACE items will populate the INTERFACE_COMPILE_DEFINITIONS " - "property of <target>. " - "The following arguments specify compile definitions. " - "Repeated calls for the same <target> append items in the order called." - "\n" - "Arguments to target_compile_definitions may use \"generator " - "expressions\" with the syntax \"$<...>\". " - CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS - ; - } - cmTypeMacro(cmTargetCompileDefinitionsCommand, cmTargetPropCommandBase); private: diff --git a/Source/cmTargetCompileOptionsCommand.h b/Source/cmTargetCompileOptionsCommand.h index b9afd71..3713e5a 100644 --- a/Source/cmTargetCompileOptionsCommand.h +++ b/Source/cmTargetCompileOptionsCommand.h @@ -38,43 +38,6 @@ public: */ virtual const char* GetName() const { return "target_compile_options";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return - "Add compile options to a target."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " target_compile_options(<target> [BEFORE] " - "<INTERFACE|PUBLIC|PRIVATE> [items1...]\n" - " [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])\n" - "Specify compile options to use when compiling a given target. " - "The named <target> must have been created by a command such as " - "add_executable or add_library and must not be an IMPORTED target. " - "If BEFORE is specified, the content will be prepended to the property " - "instead of being appended.\n" - "The INTERFACE, PUBLIC and PRIVATE keywords are required to specify " - "the scope of the following arguments. PRIVATE and PUBLIC items will " - "populate the COMPILE_OPTIONS property of <target>. PUBLIC and " - "INTERFACE items will populate the INTERFACE_COMPILE_OPTIONS " - "property of <target>. " - "The following arguments specify compile opitions. " - "Repeated calls for the same <target> append items in the order called." - "\n" - "Arguments to target_compile_options may use \"generator " - "expressions\" with the syntax \"$<...>\". " - CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS - ; - } - cmTypeMacro(cmTargetCompileOptionsCommand, cmTargetPropCommandBase); private: diff --git a/Source/cmTargetDepend.h b/Source/cmTargetDepend.h index 258bacd..1feb072 100644 --- a/Source/cmTargetDepend.h +++ b/Source/cmTargetDepend.h @@ -20,17 +20,17 @@ class cmTarget; It may be marked as a 'link' or 'util' edge or both. */ class cmTargetDepend { - cmTarget* Target; + cmTarget const* Target; // The set order depends only on the Target, so we use // mutable members to acheive a map with set syntax. mutable bool Link; mutable bool Util; public: - cmTargetDepend(cmTarget* t): Target(t), Link(false), Util(false) {} - operator cmTarget*() const { return this->Target; } - cmTarget* operator->() const { return this->Target; } - cmTarget& operator*() const { return *this->Target; } + cmTargetDepend(cmTarget const* t): Target(t), Link(false), Util(false) {} + operator cmTarget const*() const { return this->Target; } + cmTarget const* operator->() const { return this->Target; } + cmTarget const& operator*() const { return *this->Target; } friend bool operator < (cmTargetDepend const& l, cmTargetDepend const& r) { return l.Target < r.Target; } void SetType(bool strong) const diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index e7b906c..913bdab 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -50,7 +50,7 @@ std::string cmTargetIncludeDirectoriesCommand it != content.end(); ++it) { if (cmSystemTools::FileIsFullPath(it->c_str()) - || cmGeneratorExpression::Find(*it) != std::string::npos) + || cmGeneratorExpression::Find(*it) == 0) { dirs += sep + *it; } diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h index fcc37f0..6863ee5 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.h +++ b/Source/cmTargetIncludeDirectoriesCommand.h @@ -39,53 +39,6 @@ public: */ virtual const char* GetName() const { return "target_include_directories";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return - "Add include directories to a target."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " target_include_directories(<target> [SYSTEM] [BEFORE] " - "<INTERFACE|PUBLIC|PRIVATE> [items1...]\n" - " [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])\n" - "Specify include directories or targets to use when compiling a given " - "target. " - "The named <target> must have been created by a command such as " - "add_executable or add_library and must not be an IMPORTED target.\n" - "If BEFORE is specified, the content will be prepended to the property " - "instead of being appended.\n" - "The INTERFACE, PUBLIC and PRIVATE keywords are required to specify " - "the scope of the following arguments. PRIVATE and PUBLIC items will " - "populate the INCLUDE_DIRECTORIES property of <target>. PUBLIC and " - "INTERFACE items will populate the INTERFACE_INCLUDE_DIRECTORIES " - "property of <target>. " - "The following arguments specify include directories. Specified " - "include directories may be absolute paths or relative paths. " - "Repeated calls for the same <target> append items in the order called." - "If SYSTEM is specified, the compiler will be told the " - "directories are meant as system include directories on some " - "platforms (signalling this setting might achieve effects such as " - "the compiler skipping warnings, or these fixed-install system files " - "not being considered in dependency calculations - see compiler " - "docs). If SYSTEM is used together with PUBLIC or INTERFACE, the " - "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES target property will be " - "populated with the specified directories." - "\n" - "Arguments to target_include_directories may use \"generator " - "expressions\" with the syntax \"$<...>\". " - CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS - ; - } - cmTypeMacro(cmTargetIncludeDirectoriesCommand, cmTargetPropCommandBase); private: diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 863b391..209609d 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -101,6 +101,37 @@ bool cmTargetLinkLibrariesCommand return true; } + if (this->Target->GetType() == cmTarget::UTILITY) + { + const char *modal = 0; + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0039)) + { + case cmPolicies::WARN: + modal = "should"; + case cmPolicies::OLD: + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + modal = "must"; + messageType = cmake::FATAL_ERROR; + } + if (modal) + { + cmOStringStream e; + e << this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0039) << "\n" + "Utility target \"" << this->Target->GetName() << "\" " << modal + << " not be used as the target of a target_link_libraries call."; + this->Makefile->IssueMessage(messageType, e.str().c_str()); + if(messageType == cmake::FATAL_ERROR) + { + return false; + } + } + } + // but we might not have any libs after variable expansion if(args.size() < 2) { @@ -151,7 +182,8 @@ bool cmTargetLinkLibrariesCommand else if(args[i] == "LINK_PUBLIC") { if(i != 1 - && this->CurrentProcessingState != ProcessingPlainPrivateInterface) + && this->CurrentProcessingState != ProcessingPlainPrivateInterface + && this->CurrentProcessingState != ProcessingPlainPublicInterface) { this->Makefile->IssueMessage( cmake::FATAL_ERROR, @@ -181,7 +213,8 @@ bool cmTargetLinkLibrariesCommand else if(args[i] == "LINK_PRIVATE") { if(i != 1 - && this->CurrentProcessingState != ProcessingPlainPublicInterface) + && this->CurrentProcessingState != ProcessingPlainPublicInterface + && this->CurrentProcessingState != ProcessingPlainPrivateInterface) { this->Makefile->IssueMessage( cmake::FATAL_ERROR, @@ -322,6 +355,15 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib, cmTarget::LinkLibraryType llt) { + if(this->Target->GetType() == cmTarget::INTERFACE_LIBRARY + && this->CurrentProcessingState != ProcessingKeywordLinkInterface) + { + this->Makefile->IssueMessage(cmake::FATAL_ERROR, + "INTERFACE library can only be used with the INTERFACE keyword of " + "target_link_libraries"); + return false; + } + cmTarget::TLLSignature sig = (this->CurrentProcessingState == ProcessingPlainPrivateInterface || this->CurrentProcessingState == ProcessingPlainPublicInterface @@ -379,15 +421,26 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib, { this->Makefile ->AddLinkLibraryForTarget(this->Target->GetName(), lib, llt); - if (this->CurrentProcessingState != ProcessingKeywordPublicInterface - && this->CurrentProcessingState != ProcessingPlainPublicInterface) + if(this->CurrentProcessingState == ProcessingLinkLibraries) + { + this->Target->AppendProperty("INTERFACE_LINK_LIBRARIES", + this->Target->GetDebugGeneratorExpressions(lib, llt).c_str()); + return true; + } + else if(this->CurrentProcessingState != ProcessingKeywordPublicInterface + && this->CurrentProcessingState != ProcessingPlainPublicInterface) { if (this->Target->GetType() == cmTarget::STATIC_LIBRARY) { + std::string configLib = this->Target + ->GetDebugGeneratorExpressions(lib, llt); + if (cmGeneratorExpression::IsValidTargetName(lib) + || cmGeneratorExpression::Find(lib) != std::string::npos) + { + configLib = "$<LINK_ONLY:" + configLib + ">"; + } this->Target->AppendProperty("INTERFACE_LINK_LIBRARIES", - ("$<LINK_ONLY:" + - this->Target->GetDebugGeneratorExpressions(lib, llt) + - ">").c_str()); + configLib.c_str()); } // Not a 'public' or 'interface' library. Do not add to interface // property. @@ -407,6 +460,11 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib, return true; } + if (this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return true; + } + // Get the list of configurations considered to be DEBUG. std::vector<std::string> const& debugConfigs = this->Makefile->GetCMakeInstance()->GetDebugConfigs(); diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index f2b2543..6fbf722 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -13,7 +13,6 @@ #define cmTargetLinkLibrariesCommand_h #include "cmCommand.h" -#include "cmDocumentGeneratorExpressions.h" /** \class cmTargetLinkLibrariesCommand * \brief Specify a list of libraries to link into executables. @@ -45,151 +44,6 @@ public: */ virtual const char* GetName() const { return "target_link_libraries";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return - "Link a target to given libraries."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " target_link_libraries(<target> [item1 [item2 [...]]]\n" - " [[debug|optimized|general] <item>] ...)\n" - "Specify libraries or flags to use when linking a given target. " - "The named <target> must have been created in the current directory " - "by a command such as add_executable or add_library. " - "The remaining arguments specify library names or flags. " - "Repeated calls for the same <target> append items in the order called." - "\n" - "If a library name matches that of another target in the project " - "a dependency will automatically be added in the build system to make " - "sure the library being linked is up-to-date before the target links. " - "Item names starting with '-', but not '-l' or '-framework', are " - "treated as linker flags." - "\n" - "A \"debug\", \"optimized\", or \"general\" keyword indicates that " - "the library immediately following it is to be used only for the " - "corresponding build configuration. " - "The \"debug\" keyword corresponds to the Debug configuration " - "(or to configurations named in the DEBUG_CONFIGURATIONS global " - "property if it is set). " - "The \"optimized\" keyword corresponds to all other configurations. " - "The \"general\" keyword corresponds to all configurations, and is " - "purely optional (assumed if omitted). " - "Higher granularity may be achieved for per-configuration rules " - "by creating and linking to IMPORTED library targets. " - "See the IMPORTED mode of the add_library command for more " - "information. " - "\n" - "Library dependencies are transitive by default. " - "When this target is linked into another target then the libraries " - "linked to this target will appear on the link line for the other " - "target too. " - "See the INTERFACE_LINK_LIBRARIES target property to override the " - "set of transitive link dependencies for a target. " - "Calls to other signatures of this command may set the property " - "making any libraries linked exclusively by this signature private." - "\n" - "CMake will also propagate \"usage requirements\" from linked library " - "targets. " - "Usage requirements affect compilation of sources in the <target>. " - "They are specified by properties defined on linked targets. " - "During generation of the build system, CMake integrates " - "usage requirement property values with the corresponding " - "build properties for <target>:\n" - " INTERFACE_COMPILE_DEFINITONS: Appends to COMPILE_DEFINITONS\n" - " INTERFACE_INCLUDE_DIRECTORIES: Appends to INCLUDE_DIRECTORIES\n" - " INTERFACE_POSITION_INDEPENDENT_CODE: Sets POSITION_INDEPENDENT_CODE\n" - " or checked for consistency with existing value\n" - "\n" - "If an <item> is a library in a Mac OX framework, the Headers " - "directory of the framework will also be processed as a \"usage " - "requirement\". This has the same effect as passing the framework " - "directory as an include directory." - " target_link_libraries(<target>\n" - " <PRIVATE|PUBLIC|INTERFACE> <lib> ...\n" - " [<PRIVATE|PUBLIC|INTERFACE> <lib> ... ] ...])\n" - "The PUBLIC, PRIVATE and INTERFACE keywords can be used to specify " - "both the link dependencies and the link interface in one command. " - "Libraries and targets following PUBLIC are linked to, and are " - "made part of the link interface. Libraries and targets " - "following PRIVATE are linked to, but are not made part of the " - "link interface. Libraries following INTERFACE are appended " - "to the link interface and are not used for linking <target>." - "\n" - " target_link_libraries(<target> LINK_INTERFACE_LIBRARIES\n" - " [[debug|optimized|general] <lib>] ...)\n" - "The LINK_INTERFACE_LIBRARIES mode appends the libraries " - "to the INTERFACE_LINK_LIBRARIES target property instead of using them " - "for linking. If policy CMP0022 is not NEW, then this mode also " - "appends libraries to the LINK_INTERFACE_LIBRARIES and its " - "per-configuration equivalent. This signature " - "is for compatibility only. Prefer the INTERFACE mode instead. " - "Libraries specified as \"debug\" are wrapped in a generator " - "expression to correspond to debug builds. If policy CMP0022 is not " - "NEW, the libraries are also appended to the " - "LINK_INTERFACE_LIBRARIES_DEBUG property (or to the properties " - "corresponding to configurations listed in the DEBUG_CONFIGURATIONS " - "global property if it is set). " - "Libraries specified as \"optimized\" are appended to the " - "INTERFACE_LINK_LIBRARIES property. If policy CMP0022 is not NEW, " - "they are also appended to the LINK_INTERFACE_LIBRARIES property. " - "Libraries specified as \"general\" (or without any keyword) are " - "treated as if specified for both \"debug\" and \"optimized\"." - "\n" - " target_link_libraries(<target>\n" - " <LINK_PRIVATE|LINK_PUBLIC>\n" - " [[debug|optimized|general] <lib>] ...\n" - " [<LINK_PRIVATE|LINK_PUBLIC>\n" - " [[debug|optimized|general] <lib>] ...])\n" - "The LINK_PUBLIC and LINK_PRIVATE modes can be used to specify both " - "the link dependencies and the link interface in one command. This " - "signature is for compatibility only. Prefer the PUBLIC or PRIVATE " - "keywords instead. " - "Libraries and targets following LINK_PUBLIC are linked to, and are " - "made part of the INTERFACE_LINK_LIBRARIES. If policy CMP0022 is not " - "NEW, they are also made part of the LINK_INTERFACE_LIBRARIES. " - "Libraries and targets following LINK_PRIVATE are linked to, but are " - "not made part of the INTERFACE_LINK_LIBRARIES (or " - "LINK_INTERFACE_LIBRARIES)." - "\n" - "The library dependency graph is normally acyclic (a DAG), but in the " - "case of mutually-dependent STATIC libraries CMake allows the graph " - "to contain cycles (strongly connected components). " - "When another target links to one of the libraries CMake repeats " - "the entire connected component. " - "For example, the code\n" - " add_library(A STATIC a.c)\n" - " add_library(B STATIC b.c)\n" - " target_link_libraries(A B)\n" - " target_link_libraries(B A)\n" - " add_executable(main main.c)\n" - " target_link_libraries(main A)\n" - "links 'main' to 'A B A B'. " - "(" - "While one repetition is usually sufficient, pathological object " - "file and symbol arrangements can require more. " - "One may handle such cases by manually repeating the component in " - "the last target_link_libraries call. " - "However, if two archives are really so interdependent they should " - "probably be combined into a single archive." - ")" - "\n" - "Arguments to target_link_libraries may use \"generator expressions\" " - "with the syntax \"$<...>\". Note however, that generator expressions " - "will not be used in OLD handling of CMP0003 or CMP0004." - "\n" - CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS - ; - } - cmTypeMacro(cmTargetLinkLibrariesCommand, cmCommand); private: void LinkLibraryTypeSpecifierWarning(int left, int right); diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index 1862cb6..e7b6999 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -47,6 +47,7 @@ bool cmTargetPropCommandBase && (this->Target->GetType() != cmTarget::STATIC_LIBRARY) && (this->Target->GetType() != cmTarget::OBJECT_LIBRARY) && (this->Target->GetType() != cmTarget::MODULE_LIBRARY) + && (this->Target->GetType() != cmTarget::INTERFACE_LIBRARY) && (this->Target->GetType() != cmTarget::EXECUTABLE)) { this->SetError("called with non-compilable target type"); @@ -112,6 +113,14 @@ bool cmTargetPropCommandBase return false; } + if (this->Target->GetType() == cmTarget::INTERFACE_LIBRARY + && scope != "INTERFACE") + { + this->SetError("may only be set INTERFACE properties on INTERFACE " + "targets"); + return false; + } + ++argIndex; std::vector<std::string> content; diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h index 690582f..c402836 100644 --- a/Source/cmTargetPropCommandBase.h +++ b/Source/cmTargetPropCommandBase.h @@ -14,7 +14,6 @@ #define cmTargetPropCommandBase_h #include "cmCommand.h" -#include "cmDocumentGeneratorExpressions.h" class cmTarget; diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx index 0904431..9cda978 100644 --- a/Source/cmTest.cxx +++ b/Source/cmTest.cxx @@ -92,114 +92,3 @@ void cmTest::AppendProperty(const char* prop, const char* value, bool asString) } this->Properties.AppendProperty(prop, value, cmProperty::TEST, asString); } - -//---------------------------------------------------------------------------- -void cmTest::DefineProperties(cmake *cm) -{ - cm->DefineProperty - ("ATTACHED_FILES", cmProperty::TEST, - "Attach a list of files to a dashboard submission.", - "Set this property to a list of files that will be encoded and " - "submitted to the dashboard as an addition to the test result."); - - cm->DefineProperty - ("ATTACHED_FILES_ON_FAIL", cmProperty::TEST, - "Attach a list of files to a dashboard submission if the test fails.", - "Same as ATTACHED_FILES, but these files will only be included if the " - "test does not pass."); - - cm->DefineProperty - ("COST", cmProperty::TEST, - "Set this to a floating point value. Tests in a test set will be " - "run in descending order of cost.", "This property describes the cost " - "of a test. You can explicitly set this value; tests with higher COST " - "values will run first."); - - cm->DefineProperty - ("DEPENDS", cmProperty::TEST, - "Specifies that this test should only be run after the specified " - "list of tests.", - "Set this to a list of tests that must finish before this test is run."); - - cm->DefineProperty - ("ENVIRONMENT", cmProperty::TEST, - "Specify environment variables that should be defined for running " - "a test.", - "If set to a list of environment variables and values of the form " - "MYVAR=value those environment variables will be defined while " - "running the test. The environment is restored to its previous state " - "after the test is done."); - - cm->DefineProperty - ("FAIL_REGULAR_EXPRESSION", cmProperty::TEST, - "If the output matches this regular expression the test will fail.", - "If set, if the output matches one of " - "specified regular expressions, the test will fail." - "For example: FAIL_REGULAR_EXPRESSION \"[^a-z]Error;ERROR;Failed\""); - - cm->DefineProperty - ("LABELS", cmProperty::TEST, - "Specify a list of text labels associated with a test.", - "The list is reported in dashboard submissions."); - - cm->DefineProperty - ("RESOURCE_LOCK", cmProperty::TEST, - "Specify a list of resources that are locked by this test.", - "If multiple tests specify the same resource lock, they are guaranteed " - "not to run concurrently."); - - cm->DefineProperty - ("MEASUREMENT", cmProperty::TEST, - "Specify a CDASH measurement and value to be reported for a test.", - "If set to a name then that name will be reported to CDASH as a " - "named measurement with a value of 1. You may also specify a value " - "by setting MEASUREMENT to \"measurement=value\"."); - - cm->DefineProperty - ("PASS_REGULAR_EXPRESSION", cmProperty::TEST, - "The output must match this regular expression for the test to pass.", - "If set, the test output will be checked " - "against the specified regular expressions and at least one of the" - " regular expressions has to match, otherwise the test will fail."); - - cm->DefineProperty - ("PROCESSORS", cmProperty::TEST, - "How many process slots this test requires", - "Denotes the number of processors that this test will require. This is " - "typically used for MPI tests, and should be used in conjunction with " - "the ctest_test PARALLEL_LEVEL option."); - - cm->DefineProperty - ("REQUIRED_FILES", cmProperty::TEST, - "List of files required to run the test.", - "If set to a list of files, the test will not be run unless all of the " - "files exist."); - - cm->DefineProperty - ("RUN_SERIAL", cmProperty::TEST, - "Do not run this test in parallel with any other test.", - "Use this option in conjunction with the ctest_test PARALLEL_LEVEL " - "option to specify that this test should not be run in parallel with " - "any other tests."); - - cm->DefineProperty - ("TIMEOUT", cmProperty::TEST, - "How many seconds to allow for this test.", - "This property if set will limit a test to not take more than " - "the specified number of seconds to run. If it exceeds that the " - "test process will be killed and ctest will move to the next test. " - "This setting takes precedence over " - "CTEST_TESTING_TIMEOUT."); - - cm->DefineProperty - ("WILL_FAIL", cmProperty::TEST, - "If set to true, this will invert the pass/fail flag of the test.", - "This property can be used for tests that are expected to fail and " - "return a non zero return code."); - - cm->DefineProperty - ("WORKING_DIRECTORY", cmProperty::TEST, - "The directory from which the test executable will be called.", - "If this is not set it is called from the directory the test executable " - "is located in."); -} diff --git a/Source/cmTest.h b/Source/cmTest.h index 73ac133..1fe8fc0 100644 --- a/Source/cmTest.h +++ b/Source/cmTest.h @@ -52,9 +52,6 @@ public: bool GetPropertyAsBool(const char *prop) const; cmPropertyMap &GetProperties() { return this->Properties; }; - // Define the properties - static void DefineProperties(cmake *cm); - /** Get the cmMakefile instance that owns this test. */ cmMakefile *GetMakefile() { return this->Makefile;}; diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 42f511e..d962fb2 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -39,29 +39,8 @@ cmTestGenerator void cmTestGenerator::GenerateScriptConfigs(std::ostream& os, Indent const& indent) { - // First create the tests. + // Create the tests. this->cmScriptGenerator::GenerateScriptConfigs(os, indent); - - // Now generate the test properties. - if(this->TestGenerated) - { - cmTest* test = this->Test; - cmMakefile* mf = test->GetMakefile(); - cmLocalGenerator* lg = mf->GetLocalGenerator(); - std::ostream& fout = os; - cmPropertyMap::const_iterator pit; - cmPropertyMap* mpit = &test->GetProperties(); - if ( mpit->size() ) - { - fout << "SET_TESTS_PROPERTIES(" << test->GetName() << " PROPERTIES "; - for ( pit = mpit->begin(); pit != mpit->end(); ++ pit ) - { - fout << " " << pit->first - << " " << lg->EscapeForCMake(pit->second.GetValue()); - } - fout << ")" << std::endl; - } - } } //---------------------------------------------------------------------------- @@ -94,7 +73,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, cmGeneratorExpression ge(this->Test->GetBacktrace()); // Start the test command. - os << indent << "ADD_TEST(" << this->Test->GetName() << " "; + os << indent << "add_test(" << this->Test->GetName() << " "; // Get the test command line to be executed. std::vector<std::string> const& command = this->Test->GetCommand(); @@ -127,13 +106,29 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, // Finish the test command. os << ")\n"; + + // Output properties for the test. + cmPropertyMap& pm = this->Test->GetProperties(); + if(!pm.empty()) + { + os << indent << "set_tests_properties(" << this->Test->GetName() + << " PROPERTIES "; + for(cmPropertyMap::const_iterator i = pm.begin(); + i != pm.end(); ++i) + { + os << " " << i->first + << " " << lg->EscapeForCMake( + ge.Parse(i->second.GetValue())->Evaluate(mf, config)); + } + os << ")" << std::endl; + } } //---------------------------------------------------------------------------- void cmTestGenerator::GenerateScriptNoConfig(std::ostream& os, Indent const& indent) { - os << indent << "ADD_TEST(" << this->Test->GetName() << " NOT_AVAILABLE)\n"; + os << indent << "add_test(" << this->Test->GetName() << " NOT_AVAILABLE)\n"; } //---------------------------------------------------------------------------- @@ -157,7 +152,7 @@ void cmTestGenerator::GenerateOldStyle(std::ostream& fout, std::string exe = command[0]; cmSystemTools::ConvertToUnixSlashes(exe); fout << indent; - fout << "ADD_TEST("; + fout << "add_test("; fout << this->Test->GetName() << " \"" << exe << "\""; for(std::vector<std::string>::const_iterator argit = command.begin()+1; @@ -181,4 +176,21 @@ void cmTestGenerator::GenerateOldStyle(std::ostream& fout, fout << "\""; } fout << ")" << std::endl; + + // Output properties for the test. + cmMakefile* mf = this->Test->GetMakefile(); + cmLocalGenerator* lg = mf->GetLocalGenerator(); + cmPropertyMap& pm = this->Test->GetProperties(); + if(!pm.empty()) + { + fout << indent << "set_tests_properties(" << this->Test->GetName() + << " PROPERTIES "; + for(cmPropertyMap::const_iterator i = pm.begin(); + i != pm.end(); ++i) + { + fout << " " << i->first + << " " << lg->EscapeForCMake(i->second.GetValue()); + } + fout << ")" << std::endl; + } } diff --git a/Source/cmTryCompileCommand.h b/Source/cmTryCompileCommand.h index a20594c..8e6bbc1 100644 --- a/Source/cmTryCompileCommand.h +++ b/Source/cmTryCompileCommand.h @@ -42,81 +42,6 @@ public: */ virtual const char* GetName() const { return "try_compile";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Try building some code."; - } - - /** - * More documentation. */ - virtual const char* GetFullDocumentation() const - { - return - " try_compile(RESULT_VAR <bindir> <srcdir>\n" - " <projectName> [targetName] [CMAKE_FLAGS flags...]\n" - " [OUTPUT_VARIABLE <var>])\n" - "Try building a project. In this form, srcdir should contain a " - "complete CMake project with a CMakeLists.txt file and all sources. " - "The bindir and srcdir will not be deleted after this command is run. " - "Specify targetName to build a specific target instead of the 'all' or " - "'ALL_BUILD' target." - "\n" - " try_compile(RESULT_VAR <bindir> <srcfile|SOURCES srcfile...>\n" - " [CMAKE_FLAGS flags...]\n" - " [COMPILE_DEFINITIONS flags...]\n" - " [LINK_LIBRARIES libs...]\n" - " [OUTPUT_VARIABLE <var>]\n" - " [COPY_FILE <fileName> [COPY_FILE_ERROR <var>]])\n" - "Try building an executable from one or more source files. " - "In this form the user need only supply one or more source files " - "that include a definition for 'main'. " - "CMake will create a CMakeLists.txt file to build the source(s) " - "as an executable. " - "Specify COPY_FILE to get a copy of the linked executable at the " - "given fileName and optionally COPY_FILE_ERROR to capture any error." - "\n" - "In this version all files in bindir/CMakeFiles/CMakeTmp " - "will be cleaned automatically. For debugging, --debug-trycompile can " - "be passed to cmake to avoid this clean. However, multiple sequential " - "try_compile operations reuse this single output directory. If you " - "use --debug-trycompile, you can only debug one try_compile call at a " - "time. The recommended procedure is to configure with cmake all the " - "way through once, then delete the cache entry associated with " - "the try_compile call of interest, and then re-run cmake again with " - "--debug-trycompile." - "\n" - "Some extra flags that can be included are, " - "INCLUDE_DIRECTORIES, LINK_DIRECTORIES, and LINK_LIBRARIES. " - "COMPILE_DEFINITIONS are -Ddefinition that will be passed to the " - "compile line.\n" - "The srcfile signature also accepts a LINK_LIBRARIES argument which " - "may contain a list of libraries or IMPORTED targets which will be " - "linked to in the generated project. If LINK_LIBRARIES is specified " - "as a parameter to try_compile, then any LINK_LIBRARIES passed as " - "CMAKE_FLAGS will be ignored.\n" - "try_compile creates a CMakeList.txt " - "file on the fly that looks like this:\n" - " add_definitions( <expanded COMPILE_DEFINITIONS from calling " - "cmake>)\n" - " include_directories(${INCLUDE_DIRECTORIES})\n" - " link_directories(${LINK_DIRECTORIES})\n" - " add_executable(cmTryCompileExec sources)\n" - " target_link_libraries(cmTryCompileExec ${LINK_LIBRARIES})\n" - "In both versions of the command, " - "if OUTPUT_VARIABLE is specified, then the " - "output from the build process is stored in the given variable. " - "The success or failure of the try_compile, i.e. TRUE or FALSE " - "respectively, is returned in " - "RESULT_VAR. CMAKE_FLAGS can be used to pass -DVAR:TYPE=VALUE flags " - "to the cmake that is run during the build. " - "Set variable CMAKE_TRY_COMPILE_CONFIGURATION to choose a build " - "configuration." - ; - } - cmTypeMacro(cmTryCompileCommand, cmCoreTryCompile); }; diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index 4fc0b13..cfedaa5 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -12,6 +12,7 @@ #include "cmTryRunCommand.h" #include "cmCacheManager.h" #include "cmTryCompileCommand.h" +#include <cmsys/FStream.hxx> // cmTryRunCommand bool cmTryRunCommand @@ -302,7 +303,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, if (error) { static bool firstTryRun = true; - std::ofstream file(resultFileName.c_str(), + cmsys::ofstream file(resultFileName.c_str(), firstTryRun ? std::ios::out : std::ios::app); if ( file ) { @@ -353,13 +354,13 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, cmsys::SystemTools::ReplaceString(comment, "\n", "\n# "); file << comment << "\n\n"; - file << "SET( " << this->RunResultVariable << " \n \"" + file << "set( " << this->RunResultVariable << " \n \"" << this->Makefile->GetDefinition(this->RunResultVariable.c_str()) << "\"\n CACHE STRING \"Result from TRY_RUN\" FORCE)\n\n"; if (out!=0) { - file << "SET( " << internalRunOutputName << " \n \"" + file << "set( " << internalRunOutputName << " \n \"" << this->Makefile->GetDefinition(internalRunOutputName.c_str()) << "\"\n CACHE STRING \"Output from TRY_RUN\" FORCE)\n\n"; } diff --git a/Source/cmTryRunCommand.h b/Source/cmTryRunCommand.h index 13b9973..d0bf9ce 100644 --- a/Source/cmTryRunCommand.h +++ b/Source/cmTryRunCommand.h @@ -42,63 +42,6 @@ public: */ virtual const char* GetName() const { return "try_run";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Try compiling and then running some code."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " try_run(RUN_RESULT_VAR COMPILE_RESULT_VAR\n" - " bindir srcfile [CMAKE_FLAGS <Flags>]\n" - " [COMPILE_DEFINITIONS <flags>]\n" - " [COMPILE_OUTPUT_VARIABLE comp]\n" - " [RUN_OUTPUT_VARIABLE run]\n" - " [OUTPUT_VARIABLE var]\n" - " [ARGS <arg1> <arg2>...])\n" - "Try compiling a srcfile. Return TRUE or FALSE for success or failure " - "in COMPILE_RESULT_VAR. Then if the compile succeeded, run the " - "executable and return its exit code in RUN_RESULT_VAR. " - "If the executable was built, but failed to run, then RUN_RESULT_VAR " - "will be set to FAILED_TO_RUN. " - "COMPILE_OUTPUT_VARIABLE specifies the variable where the output from " - "the compile step goes. RUN_OUTPUT_VARIABLE specifies the variable " - "where the output from the running executable goes.\n" - "For compatibility reasons OUTPUT_VARIABLE is still supported, which " - "gives you the output from the compile and run step combined.\n" - "Cross compiling issues\n" - "When cross compiling, the executable compiled in the first step " - "usually cannot be run on the build host. try_run() checks the " - "CMAKE_CROSSCOMPILING variable to detect whether CMake is in " - "crosscompiling mode. If that's the case, it will still try to compile " - "the executable, but it will not try to run the executable. Instead it " - "will create cache variables which must be filled by the user or by " - "presetting them in some CMake script file to the values the " - "executable would have produced if it had been run on its actual " - "target platform. These variables are RUN_RESULT_VAR (explanation see " - "above) and if RUN_OUTPUT_VARIABLE (or OUTPUT_VARIABLE) was used, an " - "additional cache variable " - "RUN_RESULT_VAR__COMPILE_RESULT_VAR__TRYRUN_OUTPUT." - "This is intended to hold stdout and stderr from the executable.\n" - "In order to make cross compiling your project easier, use try_run " - "only if really required. If you use try_run, use RUN_OUTPUT_VARIABLE " - "(or OUTPUT_VARIABLE) only if really required. Using them will require " - "that when crosscompiling, the cache variables will have to be set " - "manually to the output of the executable. You can also \"guard\" the " - "calls to try_run with if(CMAKE_CROSSCOMPILING) and provide an " - "easy-to-preset alternative for this case.\n" - "Set variable CMAKE_TRY_COMPILE_CONFIGURATION to choose a build " - "configuration." - ; - } - cmTypeMacro(cmTryRunCommand, cmCoreTryCompile); private: void RunExecutable(const std::string& runArgs, diff --git a/Source/cmUnsetCommand.cxx b/Source/cmUnsetCommand.cxx index 5c0cfaa..053cdfc 100644 --- a/Source/cmUnsetCommand.cxx +++ b/Source/cmUnsetCommand.cxx @@ -24,7 +24,7 @@ bool cmUnsetCommand::InitialPass(std::vector<std::string> const& args, const char* variable = args[0].c_str(); // unset(ENV{VAR}) - if (!strncmp(variable,"ENV{",4) && strlen(variable) > 5) + if (cmHasLiteralPrefix(variable, "ENV{") && strlen(variable) > 5) { // what is the variable name char *envVarName = new char [strlen(variable)]; @@ -49,7 +49,13 @@ bool cmUnsetCommand::InitialPass(std::vector<std::string> const& args, this->Makefile->RemoveCacheDefinition(variable); return true; } - // ERROR: second argument isn't CACHE + // unset(VAR PARENT_SCOPE) + else if ((args.size() == 2) && (args[1] == "PARENT_SCOPE")) + { + this->Makefile->RaiseScope(variable, 0); + return true; + } + // ERROR: second argument isn't CACHE or PARENT_SCOPE else { this->SetError("called with an invalid second argument"); diff --git a/Source/cmUnsetCommand.h b/Source/cmUnsetCommand.h index 9cf95d9..2308139 100644 --- a/Source/cmUnsetCommand.h +++ b/Source/cmUnsetCommand.h @@ -47,30 +47,6 @@ public: */ virtual const char* GetName() const {return "unset";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Unset a variable, cache variable, or environment variable."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " unset(<variable> [CACHE])\n" - "Removes the specified variable causing it to become undefined. " - "If CACHE is present then the variable is removed from the cache " - "instead of the current scope.\n" - "<variable> can be an environment variable such as:\n" - " unset(ENV{LD_LIBRARY_PATH})\n" - "in which case the variable will be removed from the current " - "environment."; - } - cmTypeMacro(cmUnsetCommand, cmCommand); }; diff --git a/Source/cmUseMangledMesaCommand.cxx b/Source/cmUseMangledMesaCommand.cxx index 4c189e6..d4ec20f 100644 --- a/Source/cmUseMangledMesaCommand.cxx +++ b/Source/cmUseMangledMesaCommand.cxx @@ -13,11 +13,14 @@ #include "cmSystemTools.h" #include <cmsys/RegularExpression.hxx> +#include <cmsys/FStream.hxx> -// cmUseMangledMesaCommand bool cmUseMangledMesaCommand ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) { + if(this->Disallowed(cmPolicies::CMP0030, + "The use_mangled_mesa command should not be called; see CMP0030.")) + { return true; } // expected two arguments: // arguement one: the full path to gl_mangle.h // arguement two : directory for output of edited headers @@ -71,7 +74,7 @@ CopyAndFullPathMesaHeader(const char* source, outFile += file; std::string tempOutputFile = outFile; tempOutputFile += ".tmp"; - std::ofstream fout(tempOutputFile.c_str()); + cmsys::ofstream fout(tempOutputFile.c_str()); if(!fout) { cmSystemTools::Error("Could not open file for write in copy operation: ", @@ -79,7 +82,7 @@ CopyAndFullPathMesaHeader(const char* source, cmSystemTools::ReportLastSystemError(""); return; } - std::ifstream fin(source); + cmsys::ifstream fin(source); if(!fin) { cmSystemTools::Error("Could not open file for read in copy operation", diff --git a/Source/cmUseMangledMesaCommand.h b/Source/cmUseMangledMesaCommand.h index 2f52960..dca75a5 100644 --- a/Source/cmUseMangledMesaCommand.h +++ b/Source/cmUseMangledMesaCommand.h @@ -14,75 +14,19 @@ #include "cmCommand.h" -#include "cmSourceFile.h" - -/** \class cmUseMangledMesaCommand - * \brief Create Tcl Wrappers for VTK classes. - * - * cmUseMangledMesaCommand is used to define a CMake variable include - * path location by specifying a file and list of directories. - */ class cmUseMangledMesaCommand : public cmCommand { public: cmTypeMacro(cmUseMangledMesaCommand, cmCommand); - - /** - * This is a virtual constructor for the command. - */ - virtual cmCommand* Clone() - { - return new cmUseMangledMesaCommand; - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ + virtual cmCommand* Clone() { return new cmUseMangledMesaCommand; } virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); - - /** - * The name of the command as specified in CMakeList.txt. - */ virtual const char* GetName() const { return "use_mangled_mesa";} - - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Copy mesa headers for use in combination with system GL."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " use_mangled_mesa(PATH_TO_MESA OUTPUT_DIRECTORY)\n" - "The path to mesa includes, should contain gl_mangle.h. " - "The mesa headers are copied to the specified output directory. " - "This allows mangled mesa headers to override other GL headers by " - "being added to the include directory path earlier."; - } - - /** - * This determines if the command is invoked when in script mode. - */ virtual bool IsScriptable() const { return true; } - - /** This command is kept for compatibility with older CMake versions. */ - virtual bool IsDiscouraged() const - { - return true; - } - + virtual bool IsDiscouraged() const { return true; } protected: void CopyAndFullPathMesaHeader(const char* source, const char* outdir); }; - #endif diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx index 6ea3dfa..11e5108 100644 --- a/Source/cmUtilitySourceCommand.cxx +++ b/Source/cmUtilitySourceCommand.cxx @@ -15,6 +15,9 @@ bool cmUtilitySourceCommand ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) { + if(this->Disallowed(cmPolicies::CMP0034, + "The utility_source command should not be called; see CMP0034.")) + { return true; } if(args.size() < 3) { this->SetError("called with incorrect number of arguments"); diff --git a/Source/cmUtilitySourceCommand.h b/Source/cmUtilitySourceCommand.h index 195f605..83d115c 100644 --- a/Source/cmUtilitySourceCommand.h +++ b/Source/cmUtilitySourceCommand.h @@ -14,77 +14,15 @@ #include "cmCommand.h" -/** \class cmUtilitySourceCommand - * \brief A command to setup a cache entry with the location of a third-party - * utility's source. - * - * cmUtilitySourceCommand is used when a third-party utility's source is - * included in the project's source tree. It specifies the location of - * the executable's source, and any files that may be needed to confirm the - * identity of the source. - */ class cmUtilitySourceCommand : public cmCommand { public: - /** - * This is a virtual constructor for the command. - */ - virtual cmCommand* Clone() - { - return new cmUtilitySourceCommand; - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ + cmTypeMacro(cmUtilitySourceCommand, cmCommand); + virtual cmCommand* Clone() { return new cmUtilitySourceCommand; } virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); - - /** - * The name of the command as specified in CMakeList.txt. - */ virtual const char* GetName() const { return "utility_source";} - - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Specify the source tree of a third-party utility."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " utility_source(cache_entry executable_name\n" - " path_to_source [file1 file2 ...])\n" - "When a third-party utility's source is included in the distribution, " - "this command specifies its location and name. The cache entry will " - "not be set unless the path_to_source and all listed files exist. It " - "is assumed that the source tree of the utility will have been built " - "before it is needed.\n" - "When cross compiling CMake will print a warning if a utility_source() " - "command is executed, because in many cases it is used to build an " - "executable which is executed later on. This doesn't work when " - "cross compiling, since the executable can run only on their target " - "platform. So in this case the cache entry has to be adjusted manually " - "so it points to an executable which is runnable on the build host."; - } - - /** This command is kept for compatibility with older CMake versions. */ - virtual bool IsDiscouraged() const - { - return true; - } - - - cmTypeMacro(cmUtilitySourceCommand, cmCommand); + virtual bool IsDiscouraged() const { return true; } }; - - #endif diff --git a/Source/cmVariableRequiresCommand.cxx b/Source/cmVariableRequiresCommand.cxx index 747e9be..ddb4003 100644 --- a/Source/cmVariableRequiresCommand.cxx +++ b/Source/cmVariableRequiresCommand.cxx @@ -16,6 +16,9 @@ bool cmVariableRequiresCommand ::InitialPass(std::vector<std::string>const& args, cmExecutionStatus &) { + if(this->Disallowed(cmPolicies::CMP0035, + "The variable_requires command should not be called; see CMP0035.")) + { return true; } if(args.size() < 3 ) { this->SetError("called with incorrect number of arguments"); diff --git a/Source/cmVariableRequiresCommand.h b/Source/cmVariableRequiresCommand.h index c86f43d..881b149 100644 --- a/Source/cmVariableRequiresCommand.h +++ b/Source/cmVariableRequiresCommand.h @@ -14,68 +14,15 @@ #include "cmCommand.h" -/** \class cmVariableRequiresCommand - * \brief Displays a message to the user - * - */ class cmVariableRequiresCommand : public cmCommand { public: - /** - * This is a virtual constructor for the command. - */ - virtual cmCommand* Clone() - { - return new cmVariableRequiresCommand; - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ + cmTypeMacro(cmVariableRequiresCommand, cmCommand); + virtual cmCommand* Clone() { return new cmVariableRequiresCommand; } virtual bool InitialPass(std::vector<std::string> const& args, cmExecutionStatus &status); - - /** - * The name of the command as specified in CMakeList.txt. - */ virtual const char* GetName() const { return "variable_requires";} - - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Deprecated. Use the if() command instead."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - "Assert satisfaction of an option's required variables.\n" - " variable_requires(TEST_VARIABLE RESULT_VARIABLE\n" - " REQUIRED_VARIABLE1\n" - " REQUIRED_VARIABLE2 ...)\n" - "The first argument (TEST_VARIABLE) is the name of the variable to be " - "tested, if that variable is false nothing else is done. If " - "TEST_VARIABLE is true, then " - "the next argument (RESULT_VARIABLE) is a variable that is set to true " - "if all the required variables are set. " - "The rest of the arguments are variables that must be true or not " - "set to NOTFOUND to avoid an error. If any are not true, an error " - "is reported."; - } - - /** This command is kept for compatibility with older CMake versions. */ - virtual bool IsDiscouraged() const - { - return true; - } - - cmTypeMacro(cmVariableRequiresCommand, cmCommand); + virtual bool IsDiscouraged() const { return true; } }; diff --git a/Source/cmVariableWatchCommand.h b/Source/cmVariableWatchCommand.h index 545535c..fb6062c 100644 --- a/Source/cmVariableWatchCommand.h +++ b/Source/cmVariableWatchCommand.h @@ -56,27 +56,6 @@ public: */ virtual const char* GetName() const { return "variable_watch";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Watch the CMake variable for change."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " variable_watch(<variable name> [<command to execute>])\n" - "If the specified variable changes, the message will be printed about " - "the variable being changed. If the command is specified, the command " - "will be executed. The command will receive the following arguments:" - " COMMAND(<variable> <access> <value> <current list file> <stack>)"; - } - cmTypeMacro(cmVariableWatchCommand, cmCommand); protected: diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index a26b291..eee7c14 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -184,7 +184,8 @@ void cmVisualStudio10TargetGenerator::WriteString(const char* line, void cmVisualStudio10TargetGenerator::Generate() { // do not generate external ms projects - if(this->Target->GetProperty("EXTERNAL_MSPROJECT")) + if(this->Target->GetType() == cmTarget::INTERFACE_LIBRARY + || this->Target->GetProperty("EXTERNAL_MSPROJECT")) { return; } @@ -219,7 +220,8 @@ void cmVisualStudio10TargetGenerator::Generate() //get the tools version to use const std::string toolsVer(this->GlobalGenerator->GetToolsVersion()); - std::string project_defaults="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; + std::string project_defaults= + "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n"; project_defaults.append("<Project DefaultTargets=\"Build\" ToolsVersion=\""); project_defaults.append(toolsVer +"\" "); project_defaults.append( @@ -374,8 +376,8 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences() void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() { - std::vector<cmSourceFile*> const& resxObjs = - this->GeneratorTarget->ResxSources; + std::vector<cmSourceFile*> resxObjs; + this->GeneratorTarget->GetResxSources(resxObjs); if(!resxObjs.empty()) { this->WriteString("<ItemGroup>\n", 1); @@ -490,6 +492,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() break; case cmTarget::GLOBAL_TARGET: case cmTarget::UNKNOWN_LIBRARY: + case cmTarget::INTERFACE_LIBRARY: break; } configType += "</ConfigurationType>\n"; @@ -547,9 +550,11 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() void cmVisualStudio10TargetGenerator::WriteCustomCommands() { this->SourcesVisited.clear(); + std::vector<cmSourceFile*> customCommands; + this->GeneratorTarget->GetCustomCommands(customCommands); for(std::vector<cmSourceFile*>::const_iterator - si = this->GeneratorTarget->CustomCommands.begin(); - si != this->GeneratorTarget->CustomCommands.end(); ++si) + si = customCommands.begin(); + si != customCommands.end(); ++si) { this->WriteCustomCommand(*si); } @@ -561,7 +566,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomCommand(cmSourceFile* sf) if(this->SourcesVisited.insert(sf).second) { if(std::vector<cmSourceFile*> const* depends = - this->Target->GetSourceDepends(sf)) + this->GeneratorTarget->GetSourceDepends(sf)) { for(std::vector<cmSourceFile*>::const_iterator di = depends->begin(); di != depends->end(); ++di) @@ -593,7 +598,7 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, // Make sure the path exists for the file std::string path = cmSystemTools::GetFilenamePath(sourcePath); cmSystemTools::MakeDirectory(path.c_str()); - std::ofstream fout(sourcePath.c_str()); + cmsys::ofstream fout(sourcePath.c_str()); if(fout) { fout << "# generated from CMake\n"; @@ -694,7 +699,8 @@ void cmVisualStudio10TargetGenerator::WriteGroups() // collect up group information std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups(); - std::vector<cmSourceFile*> classes = this->Target->GetSourceFiles(); + std::vector<cmSourceFile*> classes; + this->Target->GetSourceFiles(classes); std::set<cmSourceGroup*> groupsUsed; for(std::vector<cmSourceFile*>::const_iterator s = classes.begin(); @@ -723,7 +729,8 @@ void cmVisualStudio10TargetGenerator::WriteGroups() //get the tools version to use const std::string toolsVer(this->GlobalGenerator->GetToolsVersion()); - std::string project_defaults="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; + std::string project_defaults= + "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n"; project_defaults.append("<Project ToolsVersion=\""); project_defaults.append(toolsVer +"\" "); project_defaults.append( @@ -736,8 +743,8 @@ void cmVisualStudio10TargetGenerator::WriteGroups() this->WriteGroupSources(ti->first.c_str(), ti->second, sourceGroups); } - std::vector<cmSourceFile*> const& resxObjs = - this->GeneratorTarget->ResxSources; + std::vector<cmSourceFile*> resxObjs; + this->GeneratorTarget->GetResxSources(resxObjs); if(!resxObjs.empty()) { this->WriteString("<ItemGroup>\n", 1); @@ -809,7 +816,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() this->WriteString("</Filter>\n", 2); } - if(!this->GeneratorTarget->ResxSources.empty()) + if(!resxObjs.empty()) { this->WriteString("<Filter Include=\"Resource Files\">\n", 2); std::string guidName = "SG_Filter_Resource Files"; @@ -992,12 +999,18 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } this->WriteString("<ItemGroup>\n", 1); - this->WriteSources("ClInclude", this->GeneratorTarget->HeaderSources); - this->WriteSources("Midl", this->GeneratorTarget->IDLSources); + std::vector<cmSourceFile*> headerSources; + this->GeneratorTarget->GetHeaderSources(headerSources); + this->WriteSources("ClInclude", headerSources); + std::vector<cmSourceFile*> idlSources; + this->GeneratorTarget->GetIDLSources(idlSources); + this->WriteSources("Midl", idlSources); + std::vector<cmSourceFile*> objectSources; + this->GeneratorTarget->GetObjectSources(objectSources); for(std::vector<cmSourceFile*>::const_iterator - si = this->GeneratorTarget->ObjectSources.begin(); - si != this->GeneratorTarget->ObjectSources.end(); ++si) + si = objectSources.begin(); + si != objectSources.end(); ++si) { const char* lang = (*si)->GetLanguage(); const char* tool = NULL; @@ -1034,26 +1047,31 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } } + std::vector<cmSourceFile*> externalObjects; + this->GeneratorTarget->GetExternalObjects(externalObjects); if(this->LocalGenerator->GetVersion() > cmLocalVisualStudioGenerator::VS10) { // For VS >= 11 we use LinkObjects to avoid linking custom command // outputs. Use Object for all external objects, generated or not. - this->WriteSources("Object", this->GeneratorTarget->ExternalObjects); + this->WriteSources("Object", externalObjects); } else { // If an object file is generated in this target, then vs10 will use // it in the build, and we have to list it as None instead of Object. for(std::vector<cmSourceFile*>::const_iterator - si = this->GeneratorTarget->ExternalObjects.begin(); - si != this->GeneratorTarget->ExternalObjects.end(); ++si) + si = externalObjects.begin(); + si != externalObjects.end(); ++si) { - std::vector<cmSourceFile*> const* d=this->Target->GetSourceDepends(*si); + std::vector<cmSourceFile*> const* d = + this->GeneratorTarget->GetSourceDepends(*si); this->WriteSource((d && !d->empty())? "None":"Object", *si); } } - this->WriteSources("None", this->GeneratorTarget->ExtraSources); + std::vector<cmSourceFile*> extraSources; + this->GeneratorTarget->GetExtraSources(extraSources); + this->WriteSources("None", extraSources); // Add object library contents as external objects. std::vector<std::string> objs; @@ -1076,10 +1094,9 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( cmSourceFile& sf = *source; std::string objectName; - if(this->GeneratorTarget->ExplicitObjectName.find(&sf) - != this->GeneratorTarget->ExplicitObjectName.end()) + if(this->GeneratorTarget->HasExplicitObjectName(&sf)) { - objectName = this->GeneratorTarget->Objects[&sf]; + objectName = this->GeneratorTarget->GetObjectName(&sf); } std::string flags; std::string defines; @@ -1420,7 +1437,9 @@ OutputIncludes(std::vector<std::string> const & includes) for(std::vector<std::string>::const_iterator i = includes.begin(); i != includes.end(); ++i) { - *this->BuildFileStream << cmVS10EscapeXML(*i) << ";"; + std::string incDir = *i; + this->ConvertToWindowsSlash(incDir); + *this->BuildFileStream << cmVS10EscapeXML(incDir) << ";"; } this->WriteString("%(AdditionalIncludeDirectories)" "</AdditionalIncludeDirectories>\n", 0); @@ -1701,7 +1720,8 @@ void cmVisualStudio10TargetGenerator::AddLibraries( libstring += sep; libstring += path; } - else + else if (!l->Target + || l->Target->GetType() != cmTarget::INTERFACE_LIBRARY) { libstring += sep; libstring += l->Value; @@ -1789,7 +1809,7 @@ cmVisualStudio10TargetGenerator::WriteEvents(std::string const& configName) void cmVisualStudio10TargetGenerator::WriteEvent( const char* name, - std::vector<cmCustomCommand> & commands, + std::vector<cmCustomCommand> const& commands, std::string const& configName) { if(commands.size() == 0) @@ -1802,10 +1822,10 @@ void cmVisualStudio10TargetGenerator::WriteEvent( std::string script; const char* pre = ""; std::string comment; - for(std::vector<cmCustomCommand>::iterator i = commands.begin(); + for(std::vector<cmCustomCommand>::const_iterator i = commands.begin(); i != commands.end(); ++i) { - cmCustomCommand& command = *i; + const cmCustomCommand& command = *i; comment += pre; comment += lg->ConstructComment(command); script += pre; @@ -1835,7 +1855,11 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences() for( OrderedTargetDependSet::const_iterator i = depends.begin(); i != depends.end(); ++i) { - cmTarget* dt = *i; + cmTarget const* dt = *i; + if(dt->GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } // skip fortran targets as they can not be processed by MSBuild // the only reference will be in the .sln file if(static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator) @@ -1872,8 +1896,10 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences() bool cmVisualStudio10TargetGenerator:: IsResxHeader(const std::string& headerFile) { - std::set<std::string>::iterator it = - this->GeneratorTarget->ExpectedResxHeaders.find(headerFile); + std::set<std::string> expectedResxHeaders; + this->GeneratorTarget->GetExpectedResxHeaders(expectedResxHeaders); - return it != this->GeneratorTarget->ExpectedResxHeaders.end(); + std::set<std::string>::const_iterator it = + expectedResxHeaders.find(headerFile); + return it != expectedResxHeaders.end(); } diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 9a480a8..d1f3d19 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -87,7 +87,8 @@ private: void AddLibraries(cmComputeLinkInformation& cli, std::string& libstring); void WriteLibOptions(std::string const& config); void WriteEvents(std::string const& configName); - void WriteEvent(const char* name, std::vector<cmCustomCommand> & commands, + void WriteEvent(const char* name, + std::vector<cmCustomCommand> const& commands, std::string const& configName); void WriteGroupSources(const char* name, ToolSources const& sources, std::vector<cmSourceGroup>& ); diff --git a/Source/cmVisualStudioSlnParser.cxx b/Source/cmVisualStudioSlnParser.cxx index bae5974..d182a75 100644 --- a/Source/cmVisualStudioSlnParser.cxx +++ b/Source/cmVisualStudioSlnParser.cxx @@ -13,6 +13,7 @@ #include "cmSystemTools.h" #include "cmVisualStudioSlnData.h" +#include <cmsys/FStream.hxx> #include <cassert> #include <stack> @@ -472,7 +473,7 @@ bool cmVisualStudioSlnParser::ParseFile(const std::string& file, this->LastResult.SetError(ResultErrorUnsupportedDataGroup, 0); return false; } - std::ifstream f(file.c_str()); + cmsys::ifstream f(file.c_str()); if (!f) { this->LastResult.SetError(ResultErrorOpeningInput, 0); diff --git a/Source/cmWhileCommand.h b/Source/cmWhileCommand.h index 1bdf27a..45badd0 100644 --- a/Source/cmWhileCommand.h +++ b/Source/cmWhileCommand.h @@ -68,32 +68,6 @@ public: */ virtual const char* GetName() const { return "while";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Evaluate a group of commands while a condition is true"; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " while(condition)\n" - " COMMAND1(ARGS ...)\n" - " COMMAND2(ARGS ...)\n" - " ...\n" - " endwhile(condition)\n" - "All commands between while and the matching endwhile are recorded " - "without being invoked. Once the endwhile is evaluated, the " - "recorded list of commands is invoked as long as the condition " - "is true. The condition is evaluated using the same logic as the " - "if command."; - } - cmTypeMacro(cmWhileCommand, cmCommand); }; diff --git a/Source/cmWin32ProcessExecution.cxx b/Source/cmWin32ProcessExecution.cxx deleted file mode 100644 index 1bdeffb..0000000 --- a/Source/cmWin32ProcessExecution.cxx +++ /dev/null @@ -1,884 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#include "cmWin32ProcessExecution.h" - -#include "cmSystemTools.h" - -#include <malloc.h> -#include <io.h> -#include <fcntl.h> -#include <sys/stat.h> -#include <windows.h> - -#if defined(__BORLANDC__) -# define STRICMP stricmp -# define TO_INTPTR(x) ((long)(x)) -#endif // Borland -#if defined(_MSC_VER) // Visual studio -# if ( _MSC_VER >= 1300 ) -# include <stddef.h> -# define TO_INTPTR(x) ((intptr_t)(x)) -# else // Visual Studio 6 -# define TO_INTPTR(x) ((long)(x)) -# endif // Visual studio .NET -# define STRICMP _stricmp -#endif // Visual Studio -#if defined(__MINGW32__) -# include <stdint.h> -# define TO_INTPTR(x) ((intptr_t)(x)) -# define STRICMP _stricmp -#endif // MinGW - -#define POPEN_1 1 -#define POPEN_2 2 -#define POPEN_3 3 -#define POPEN_4 4 - -#define cmMAX(x,y) (((x)<(y))?(y):(x)) - -void DisplayErrorMessage() -{ - LPVOID lpMsgBuf; - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL - ); - // Process any inserts in lpMsgBuf. - // ... - // Display the string. - MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION ); - // Free the buffer. - LocalFree( lpMsgBuf ); -} - -// Code from a Borland web site with the following explaination : -/* In this article, I will explain how to spawn a console application - * and redirect its standard input/output using anonymous pipes. An - * anonymous pipe is a pipe that goes only in one direction (read - * pipe, write pipe, etc.). Maybe you are asking, "why would I ever - * need to do this sort of thing?" One example would be a Windows - * telnet server, where you spawn a shell and listen on a port and - * send and receive data between the shell and the socket - * client. (Windows does not really have a built-in remote - * shell). First, we should talk about pipes. A pipe in Windows is - * simply a method of communication, often between process. The SDK - * defines a pipe as "a communication conduit with two ends; - a process - * with a handle to one end can communicate with a process having a - * handle to the other end." In our case, we are using "anonymous" - * pipes, one-way pipes that "transfer data between a parent process - * and a child process or between two child processes of the same - * parent process." It's easiest to imagine a pipe as its namesake. An - * actual pipe running between processes that can carry data. We are - * using anonymous pipes because the console app we are spawning is a - * child process. We use the CreatePipe function which will create an - * anonymous pipe and return a read handle and a write handle. We will - * create two pipes, on for stdin and one for stdout. We will then - * monitor the read end of the stdout pipe to check for display on our - * child process. Every time there is something availabe for reading, - * we will display it in our app. Consequently, we check for input in - * our app and send it off to the write end of the stdin pipe. */ - -inline bool IsWinNT() -//check if we're running NT -{ - OSVERSIONINFO osv; - osv.dwOSVersionInfoSize = sizeof(osv); - GetVersionEx(&osv); - return (osv.dwPlatformId == VER_PLATFORM_WIN32_NT); -} - -//--------------------------------------------------------------------------- -bool cmWin32ProcessExecution::BorlandRunCommand( - const char* command, const char* dir, - std::string& output, int& retVal, bool verbose, int /* timeout */, - bool hideWindows) -{ - //verbose = true; - //std::cerr << std::endl - // << "WindowsRunCommand(" << command << ")" << std::endl - // << std::flush; - const int BUFFER_SIZE = 4096; - char buf[BUFFER_SIZE]; - -//i/o buffer - STARTUPINFO si; - SECURITY_ATTRIBUTES sa; - SECURITY_DESCRIPTOR sd; - -//security information for pipes - PROCESS_INFORMATION pi; - HANDLE newstdin,newstdout,read_stdout,write_stdin; - -//pipe handles - if (IsWinNT()) -//initialize security descriptor (Windows NT) - { - InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION); - SetSecurityDescriptorDacl(&sd, true, NULL, false); - sa.lpSecurityDescriptor = &sd; - - } - else sa.lpSecurityDescriptor = NULL; - sa.nLength = sizeof(SECURITY_ATTRIBUTES); - sa.bInheritHandle = true; - -//allow inheritable handles - if (!CreatePipe(&newstdin,&write_stdin,&sa,0)) -//create stdin pipe - { - return false; - } - if (!CreatePipe(&read_stdout,&newstdout,&sa,0)) -//create stdout pipe - { - CloseHandle(newstdin); - CloseHandle(write_stdin); - return false; - - } - GetStartupInfo(&si); - -//set startupinfo for the spawned process - /* The dwFlags member tells CreateProcess how to make the - * process. STARTF_USESTDHANDLES validates the hStd* - * members. STARTF_USESHOWWINDOW validates the wShowWindow - * member. */ - - si.cb = sizeof(STARTUPINFO); - si.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW; - si.hStdOutput = newstdout; - si.hStdError = newstdout; - si.wShowWindow = SW_SHOWDEFAULT; - if(hideWindows) - { - si.wShowWindow = SW_HIDE; - } - -//set the new handles for the child process si.hStdInput = newstdin; - char* commandAndArgs = strcpy(new char[strlen(command)+1], command); - if (!CreateProcess(NULL,commandAndArgs,NULL,NULL,TRUE, - 0, // CREATE_NEW_CONSOLE, - NULL,dir,&si,&pi)) - { - std::cerr << "CreateProcess failed " << commandAndArgs << std::endl; - CloseHandle(newstdin); - CloseHandle(newstdout); - CloseHandle(read_stdout); - CloseHandle(write_stdin); - delete [] commandAndArgs; - return false; - - } - delete [] commandAndArgs; - unsigned long exit=0; - -//process exit code unsigned - unsigned long bread; - -//bytes read unsigned - unsigned long avail; - -//bytes available - memset(buf, 0, sizeof(buf)); - for(;;) -//main program loop - { - Sleep(10); -//check to see if there is any data to read from stdout - //std::cout << "Peek for data..." << std::endl; - PeekNamedPipe(read_stdout,buf,1023,&bread,&avail,NULL); - if (bread != 0) - { - memset(buf, 0, sizeof(buf)); - if (avail > 1023) - { - while (bread >= 1023) - { - //std::cout << "Read data..." << std::endl; - ReadFile(read_stdout,buf,1023,&bread,NULL); - - //read the stdout pipe - memset(buf, 0, sizeof(buf)); - output += buf; - if (verbose) - { - cmSystemTools::Stdout(buf); - } - } - } - else - { - ReadFile(read_stdout,buf,1023,&bread,NULL); - output += buf; - if(verbose) - { - cmSystemTools::Stdout(buf); - } - - } - - } - - //std::cout << "Check for process..." << std::endl; - GetExitCodeProcess(pi.hProcess,&exit); - -//while the process is running - if (exit != STILL_ACTIVE) break; - - } - WaitForSingleObject(pi.hProcess, INFINITE); - GetExitCodeProcess(pi.hProcess,&exit); - CloseHandle(pi.hThread); - CloseHandle(pi.hProcess); - CloseHandle(newstdin); - -//clean stuff up - CloseHandle(newstdout); - CloseHandle(read_stdout); - CloseHandle(write_stdin); - retVal = exit; - return true; - -} - -bool cmWin32ProcessExecution::StartProcess( - const char* cmd, const char* path, bool verbose) -{ - this->Initialize(); - this->Verbose = verbose; - return this->PrivateOpen(cmd, path, _O_RDONLY | _O_TEXT, POPEN_3); -} - -bool cmWin32ProcessExecution::Wait(int timeout) -{ - return this->PrivateClose(timeout); -} - -static BOOL RealPopenCreateProcess(const char *cmdstring, - const char *path, - const char *szConsoleSpawn, - HANDLE hStdin, - HANDLE hStdout, - HANDLE hStderr, - HANDLE *hProcess, - bool hideWindows, - std::string& output) -{ - PROCESS_INFORMATION piProcInfo; - STARTUPINFO siStartInfo; - char *s1=0,*s2=0; - const char *s3 = " /c "; - int i = GetEnvironmentVariable("COMSPEC",NULL,0); - if (i) - { - char *comshell; - - s1 = (char *)malloc(i); - int x = GetEnvironmentVariable("COMSPEC", s1, i); - if (!x) - { - free(s1); - return x; - } - - /* Explicitly check if we are using COMMAND.COM. If we are - * then use the w9xpopen hack. - */ - comshell = s1 + x; - while (comshell >= s1 && *comshell != '\\') - --comshell; - ++comshell; - - if (GetVersion() < 0x80000000 && - STRICMP(comshell, "command.com") != 0) - { - /* NT/2000 and not using command.com. */ - x = i + (int)strlen(s3) + (int)strlen(cmdstring) + 1; - s2 = (char *)malloc(x); - ZeroMemory(s2, x); - //sprintf(s2, "%s%s%s", s1, s3, cmdstring); - sprintf(s2, "%s", cmdstring); - } - else - { - /* - * Oh gag, we're on Win9x or using COMMAND.COM. Use - * the workaround listed in KB: Q150956 - */ - char modulepath[_MAX_PATH]; - struct stat statinfo; - GetModuleFileName(NULL, modulepath, sizeof(modulepath)); - for (i = x = 0; modulepath[i]; i++) - if (modulepath[i] == '\\') - x = i+1; - modulepath[x] = '\0'; - /* Create the full-name to w9xpopen, so we can test it exists */ - strncat(modulepath, - szConsoleSpawn, - (sizeof(modulepath)/sizeof(modulepath[0])) - -strlen(modulepath)); - if (stat(modulepath, &statinfo) != 0) - { - /* Eeek - file-not-found - possibly an embedding - situation - see if we can locate it in sys.prefix - */ - strncpy(modulepath, - ".", - sizeof(modulepath)/sizeof(modulepath[0])); - if (modulepath[strlen(modulepath)-1] != '\\') - strcat(modulepath, "\\"); - strncat(modulepath, - szConsoleSpawn, - (sizeof(modulepath)/sizeof(modulepath[0])) - -strlen(modulepath)); - /* No where else to look - raise an easily identifiable - error, rather than leaving Windows to report - "file not found" - as the user is probably blissfully - unaware this shim EXE is used, and it will confuse them. - (well, it confused me for a while ;-) - */ - if (stat(modulepath, &statinfo) != 0) - { - std::cout - << "Can not locate '" << modulepath - << "' which is needed " - "for popen to work with your shell " - "or platform." << std::endl; - free(s1); - free(s2); - return FALSE; - } - } - x = i + (int)strlen(s3) + (int)strlen(cmdstring) + 1 + - (int)strlen(modulepath) + - (int)strlen(szConsoleSpawn) + 1; - if(s2) - { - free(s2); - } - s2 = (char *)malloc(x); - ZeroMemory(s2, x); - sprintf( - s2, - "%s %s%s%s", - modulepath, - s1, - s3, - cmdstring); - sprintf( - s2, - "%s %s", - modulepath, - cmdstring); - } - } - - /* Could be an else here to try cmd.exe / command.com in the path - Now we'll just error out.. */ - else - { - std::cout << "Cannot locate a COMSPEC environment variable to " - << "use as the shell" << std::endl; - free(s2); - free(s1); - return FALSE; - } - - ZeroMemory(&siStartInfo, sizeof(STARTUPINFO)); - siStartInfo.cb = sizeof(STARTUPINFO); - siStartInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; - siStartInfo.hStdInput = hStdin; - siStartInfo.hStdOutput = hStdout; - siStartInfo.hStdError = hStderr; - siStartInfo.wShowWindow = SW_SHOWDEFAULT; - if(hideWindows) - { - siStartInfo.wShowWindow = SW_HIDE; - } - - //std::cout << "Create process: " << s2 << std::endl; - if (CreateProcess(NULL, - s2, - NULL, - NULL, - TRUE, - 0, //CREATE_NEW_CONSOLE, - NULL, - path, - &siStartInfo, - &piProcInfo) ) - { - /* Close the handles now so anyone waiting is woken. */ - CloseHandle(piProcInfo.hThread); - /* Return process handle */ - *hProcess = piProcInfo.hProcess; - //std::cout << "Process created..." << std::endl; - free(s2); - free(s1); - return TRUE; - } - - output += "CreateProcessError: "; - { - /* Format the error message. */ - char message[1024]; - DWORD original = GetLastError(); - DWORD length = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, 0, original, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - message, 1023, 0); - if(length < 1) - { - /* FormatMessage failed. Use a default message. */ - _snprintf(message, 1023, - "Process execution failed with error 0x%X. " - "FormatMessage failed with error 0x%X", - original, GetLastError()); - } - output += message; - } - output += "\n"; - output += "for command: "; - output += s2; - if(path) - { - output += "\nin dir: "; - output += path; - } - output += "\n"; - free(s2); - free(s1); - return FALSE; -} - -/* The following code is based off of KB: Q190351 */ - -bool cmWin32ProcessExecution::PrivateOpen(const char *cmdstring, - const char* path, - int mode, - int n) -{ - HANDLE hProcess; - - SECURITY_ATTRIBUTES saAttr; - BOOL fSuccess; - int fd1, fd2, fd3; - this->hChildStdinRd = 0; - this->hChildStdinWr = 0; - this->hChildStdoutRd = 0; - this->hChildStdoutWr = 0; - this->hChildStderrRd = 0; - this->hChildStderrWr = 0; - this->hChildStdinWrDup = 0; - this->hChildStdoutRdDup = 0; - this->hChildStderrRdDup = 0; - - saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); - saAttr.bInheritHandle = TRUE; - saAttr.lpSecurityDescriptor = NULL; - - fd1 = 0; - fd2 = 0; - fd3 = 0; - - if (!CreatePipe(&this->hChildStdinRd, &this->hChildStdinWr, &saAttr, 0)) - { - this->Output += "CreatePipeError\n"; - return false; - } - - /* Create new output read handle and the input write handle. Set - * the inheritance properties to FALSE. Otherwise, the child inherits - * these handles; resulting in non-closeable handles to the pipes - * being created. */ - fSuccess = DuplicateHandle(GetCurrentProcess(), this->hChildStdinWr, - GetCurrentProcess(), &this->hChildStdinWrDup, 0, - FALSE, - DUPLICATE_SAME_ACCESS); - if (!fSuccess) - { - this->Output += "DuplicateHandleError\n"; - return false; - } - - - /* Close the inheritable version of ChildStdin - that we're using. */ - CloseHandle(hChildStdinWr); - - if (!CreatePipe(&this->hChildStdoutRd, &this->hChildStdoutWr, &saAttr, 0)) - { - this->Output += "CreatePipeError\n"; - return false; - } - - fSuccess = DuplicateHandle(GetCurrentProcess(), this->hChildStdoutRd, - GetCurrentProcess(), &this->hChildStdoutRdDup, 0, - FALSE, DUPLICATE_SAME_ACCESS); - if (!fSuccess) - { - this->Output += "DuplicateHandleError\n"; - return false; - } - - /* Close the inheritable version of ChildStdout - that we're using. */ - CloseHandle(hChildStdoutRd); - - if (n != POPEN_4) - { - if (!CreatePipe(&this->hChildStderrRd, &this->hChildStderrWr, &saAttr, 0)) - { - this->Output += "CreatePipeError\n"; - return false; - } - fSuccess = DuplicateHandle(GetCurrentProcess(), - this->hChildStderrRd, - GetCurrentProcess(), - &this->hChildStderrRdDup, 0, - FALSE, DUPLICATE_SAME_ACCESS); - if (!fSuccess) - { - this->Output += "DuplicateHandleError\n"; - return false; - } - /* Close the inheritable version of ChildStdErr that we're using. */ - CloseHandle(hChildStderrRd); - - } - - switch (n) - { - case POPEN_1: - switch (mode & (_O_RDONLY | _O_TEXT | _O_BINARY | _O_WRONLY)) - { - case _O_WRONLY | _O_TEXT: - /* Case for writing to child Stdin in text mode. */ - fd1 = _open_osfhandle(TO_INTPTR(this->hChildStdinWrDup), mode); - /* We don't care about these pipes anymore, - so close them. */ - break; - - case _O_RDONLY | _O_TEXT: - /* Case for reading from child Stdout in text mode. */ - fd1 = _open_osfhandle(TO_INTPTR(this->hChildStdoutRdDup), mode); - /* We don't care about these pipes anymore, - so close them. */ - break; - - case _O_RDONLY | _O_BINARY: - /* Case for readinig from child Stdout in - binary mode. */ - fd1 = _open_osfhandle(TO_INTPTR(this->hChildStdoutRdDup), mode); - /* We don't care about these pipes anymore, - so close them. */ - break; - - case _O_WRONLY | _O_BINARY: - /* Case for writing to child Stdin in binary mode. */ - fd1 = _open_osfhandle(TO_INTPTR(this->hChildStdinWrDup), mode); - /* We don't care about these pipes anymore, - so close them. */ - break; - } - break; - - case POPEN_2: - case POPEN_4: - //if ( 1 ) - { - fd1 = _open_osfhandle(TO_INTPTR(this->hChildStdinWrDup), mode); - fd2 = _open_osfhandle(TO_INTPTR(this->hChildStdoutRdDup), mode); - break; - } - - case POPEN_3: - //if ( 1) - { - fd1 = _open_osfhandle(TO_INTPTR(this->hChildStdinWrDup), mode); - fd2 = _open_osfhandle(TO_INTPTR(this->hChildStdoutRdDup), mode); - fd3 = _open_osfhandle(TO_INTPTR(this->hChildStderrRdDup), mode); - break; - } - } - - if (n == POPEN_4) - { - if (!RealPopenCreateProcess(cmdstring, - path, - this->ConsoleSpawn.c_str(), - this->hChildStdinRd, - this->hChildStdoutWr, - this->hChildStdoutWr, - &hProcess, this->HideWindows, - this->Output)) - { - if(fd1 >= 0) - { - close(fd1); - } - if(fd2 >= 0) - { - close(fd2); - } - if(fd3 >= 0) - { - close(fd3); - } - return 0; - } - } - else - { - if (!RealPopenCreateProcess(cmdstring, - path, - this->ConsoleSpawn.c_str(), - this->hChildStdinRd, - this->hChildStdoutWr, - this->hChildStderrWr, - &hProcess, this->HideWindows, - this->Output)) - { - if(fd1 >= 0) - { - close(fd1); - } - if(fd2 >= 0) - { - close(fd2); - } - if(fd3 >= 0) - { - close(fd3); - } - return 0; - } - } - - /* Child is launched. Close the parents copy of those pipe - * handles that only the child should have open. You need to - * make sure that no handles to the write end of the output pipe - * are maintained in this process or else the pipe will not close - * when the child process exits and the ReadFile will hang. */ - this->ProcessHandle = hProcess; - if ( fd1 >= 0 ) - { - this->pStdIn = fd1; - } - if ( fd2 >= 0 ) - { - this->pStdOut = fd2; - } - if ( fd3 >= 0 ) - { - this->pStdErr = fd3; - } - - return true; -} - -bool cmWin32ProcessExecution::CloseHandles() -{ - if(this->pStdErr != -1 ) - { - // this will close this as well: this->hChildStderrRdDup - _close(this->pStdErr); - this->pStdErr = -1; - this->hChildStderrRdDup = 0; - } - if(this->pStdIn != -1 ) - { - // this will close this as well: this->hChildStdinWrDup - _close(this->pStdIn); - this->pStdIn = -1; - this->hChildStdinWrDup = 0; - } - if(this->pStdOut != -1 ) - { - // this will close this as well: this->hChildStdoutRdDup - _close(this->pStdOut); - this->pStdOut = -1; - this->hChildStdoutRdDup = 0; - } - - bool ret = true; - if (this->hChildStdinRd && !CloseHandle(this->hChildStdinRd)) - { - ret = false; - } - this->hChildStdinRd = 0; - // now close these two - if (this->hChildStdoutWr && !CloseHandle(this->hChildStdoutWr)) - { - ret = false; - } - this->hChildStdoutWr = 0; - if (this->hChildStderrWr && !CloseHandle(this->hChildStderrWr)) - { - ret = false; - } - this->hChildStderrWr = 0; - return ret; -} -cmWin32ProcessExecution::~cmWin32ProcessExecution() -{ - this->CloseHandles(); -} - -bool cmWin32ProcessExecution::PrivateClose(int /* timeout */) -{ - HANDLE hProcess = this->ProcessHandle; - - int result = -1; - DWORD exit_code; - - std::string output = ""; - bool done = false; - while(!done) - { - Sleep(10); - bool have_some = false; - struct _stat fsout; - struct _stat fserr; - int rout = _fstat(this->pStdOut, &fsout); - int rerr = _fstat(this->pStdErr, &fserr); - if ( rout && rerr ) - { - break; - } - if (fserr.st_size > 0) - { - char buffer[1024]; - int len = read(this->pStdErr, buffer, 1023); - buffer[len] = 0; - if ( this->Verbose ) - { - cmSystemTools::Stdout(buffer); - } - output += buffer; - have_some = true; - } - if (fsout.st_size > 0) - { - char buffer[1024]; - int len = read(this->pStdOut, buffer, 1023); - buffer[len] = 0; - if ( this->Verbose ) - { - cmSystemTools::Stdout(buffer); - } - output += buffer; - have_some = true; - } - unsigned long exitCode; - if ( ! have_some ) - { - GetExitCodeProcess(hProcess,&exitCode); - if (exitCode != STILL_ACTIVE) - { - break; - } - } - } - - - if (WaitForSingleObject(hProcess, INFINITE) != WAIT_FAILED && - GetExitCodeProcess(hProcess, &exit_code)) - { - result = exit_code; - } - else - { - /* Indicate failure - this will cause the file object - * to raise an I/O error and translate the last Win32 - * error code from errno. We do have a problem with - * last errors that overlap the normal errno table, - * but that's a consistent problem with the file object. - */ - if (result != EOF) - { - /* If the error wasn't from the fclose(), then - * set errno for the file object error handling. - */ - errno = GetLastError(); - } - result = -1; - } - - /* Free up the native handle at this point */ - CloseHandle(hProcess); - this->ExitValue = result; - this->Output += output; - bool ret = this->CloseHandles(); - if ( result < 0 || !ret) - { - return false; - } - return true; -} - -int cmWin32ProcessExecution::Windows9xHack(const char* command) -{ - BOOL bRet; - STARTUPINFO si; - PROCESS_INFORMATION pi; - DWORD exit_code=0; - - if (!command) - { - cmSystemTools::Error("Windows9xHack: Command not specified"); - return 1; - } - - /* Make child process use this app's standard files. */ - ZeroMemory(&si, sizeof si); - si.cb = sizeof si; - si.dwFlags = STARTF_USESTDHANDLES; - si.hStdInput = GetStdHandle(STD_INPUT_HANDLE); - si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); - si.hStdError = GetStdHandle(STD_ERROR_HANDLE); - - - char * app = 0; - char* cmd = new char[ strlen(command) + 1 ]; - strcpy(cmd, command); - - bRet = CreateProcess( - app, cmd, - 0, 0, - TRUE, 0, - 0, 0, - &si, &pi - ); - delete [] cmd; - - if (bRet) - { - if (WaitForSingleObject(pi.hProcess, INFINITE) != WAIT_FAILED) - { - GetExitCodeProcess(pi.hProcess, &exit_code); - } - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - return exit_code; - } - - return 1; -} diff --git a/Source/cmWin32ProcessExecution.h b/Source/cmWin32ProcessExecution.h deleted file mode 100644 index 2127ebd2..0000000 --- a/Source/cmWin32ProcessExecution.h +++ /dev/null @@ -1,169 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#ifndef cmWin32ProcessExecution_h -#define cmWin32ProcessExecution_h - -#include "cmStandardIncludes.h" -#include "windows.h" - -class cmMakefile; - -/** \class cmWin32ProcessExecution - * \brief A process executor for windows - * - * cmWin32ProcessExecution is a class that provides a "clean" way of - * executing processes on Windows. It is modified code from Python 2.1 - * distribution. - * - * Portable 'popen' replacement for Win32. - * - * Written by Bill Tutt <billtut@microsoft.com>. Minor tweaks and 2.0 - * integration by Fredrik Lundh <fredrik@pythonware.com> Return code - * handling by David Bolen <db3l@fitlinxx.com>. - * - * Modified for CMake. - * - * For more information, please check Microsoft Knowledge Base - * Articles Q190351 and Q150956. - */ -class cmWin32ProcessExecution -{ -public: - cmWin32ProcessExecution() - { - this->HideWindows = false; - this->SetConsoleSpawn("w9xpopen.exe"); - this->Initialize(); - } - ~cmWin32ProcessExecution(); - ///! If true windows will be created hidden. - void SetHideWindows(bool v) { this->HideWindows = v; } - - /** - * Initialize the process execution datastructure. Do not call while - * running the process. - */ - void Initialize() - { - this->ProcessHandle = 0; - this->ExitValue = -1; - // Comment this out. Maybe we will need it in the future. - // file IO access to the process might be cool. - //this->StdIn = 0; - //this->StdOut = 0; - //this->StdErr = 0; - this->pStdIn = -1; - this->pStdOut = -1; - this->pStdErr = -1; - } - - /** - * Start the process in the directory path. Make sure that the - * executable is either in the path or specify the full path. The - * argument verbose specifies whether or not to display output while - * it is being generated. - */ - bool StartProcess(const char*, const char* path, bool verbose); - - /** - * Wait for the process to finish. If timeout is specified, it will - * break the process after timeout expires. (Timeout code is not yet - * implemented. - */ - bool Wait(int timeout); - - /** - * Get the output of the process (mixed stdout and stderr) as - * std::string. - */ - const std::string GetOutput() const { return this->Output; } - - /** - * Get the return value of the process. If the process is still - * running, the return value is -1. - */ - int GetExitValue() const { return this->ExitValue; } - - /** - * On Windows 9x there is a bug in the process execution code which - * may result in blocking. That is why this workaround is - * used. Specify the console spawn, which should run the - * Windows9xHack code. - */ - void SetConsoleSpawn(const char* prog) { this->ConsoleSpawn = prog; } - static int Windows9xHack(const char* command); - - /** Code from a Borland web site with the following explaination : - * In this article, I will explain how to spawn a console - * application and redirect its standard input/output using - * anonymous pipes. An anonymous pipe is a pipe that goes only in - * one direction (read pipe, write pipe, etc.). Maybe you are - * asking, "why would I ever need to do this sort of thing?" One - * example would be a Windows telnet server, where you spawn a shell - * and listen on a port and send and receive data between the shell - * and the socket client. (Windows does not really have a built-in - * remote shell). First, we should talk about pipes. A pipe in - * Windows is simply a method of communication, often between - * process. The SDK defines a pipe as "a communication conduit with - * two ends; a process with a handle to one end can communicate with - * a process having a handle to the other end." In our case, we are - * using "anonymous" pipes, one-way pipes that "transfer data - * between a parent process and a child process or between two child - * processes of the same parent process." It's easiest to imagine a - * pipe as its namesake. An actual pipe running between processes - * that can carry data. We are using anonymous pipes because the - * console app we are spawning is a child process. We use the - * CreatePipe function which will create an anonymous pipe and - * return a read handle and a write handle. We will create two - * pipes, on for stdin and one for stdout. We will then monitor the - * read end of the stdout pipe to check for display on our child - * process. Every time there is something availabe for reading, we - * will display it in our app. Consequently, we check for input in - * our app and send it off to the write end of the stdin pipe. - */ - static bool BorlandRunCommand(const char* command, - const char* dir, - std::string& output, int& retVal, - bool verbose, - int timeout, bool hideWindows); - -private: - bool CloseHandles(); - bool PrivateOpen(const char*, const char*, int, int); - bool PrivateClose(int timeout); - - HANDLE ProcessHandle; - HANDLE hChildStdinRd; - HANDLE hChildStdinWr; - HANDLE hChildStdoutRd; - HANDLE hChildStdoutWr; - HANDLE hChildStderrRd; - HANDLE hChildStderrWr; - HANDLE hChildStdinWrDup; - HANDLE hChildStdoutRdDup; - HANDLE hChildStderrRdDup; - - - int pStdIn; - int pStdOut; - int pStdErr; - - int ExitValue; - - std::string Output; - std::string ConsoleSpawn; - bool Verbose; - bool HideWindows; -}; - - -#endif diff --git a/Source/cmWriteFileCommand.cxx b/Source/cmWriteFileCommand.cxx index 3642c6f..aa6b9f8 100644 --- a/Source/cmWriteFileCommand.cxx +++ b/Source/cmWriteFileCommand.cxx @@ -10,6 +10,7 @@ See the License for more information. ============================================================================*/ #include "cmWriteFileCommand.h" +#include <cmsys/FStream.hxx> #include <sys/types.h> #include <sys/stat.h> @@ -71,7 +72,7 @@ bool cmWriteFileCommand } // If GetPermissions fails, pretend like it is ok. File open will fail if // the file is not writable - std::ofstream file(fileName.c_str(), + cmsys::ofstream file(fileName.c_str(), overwrite?std::ios::out : std::ios::app); if ( !file ) { diff --git a/Source/cmWriteFileCommand.h b/Source/cmWriteFileCommand.h index 771ef5a..84a38fc 100644 --- a/Source/cmWriteFileCommand.h +++ b/Source/cmWriteFileCommand.h @@ -46,32 +46,6 @@ public: */ virtual const char* GetName() const { return "write_file";} - /** - * Succinct documentation. - */ - virtual const char* GetTerseDocumentation() const - { - return "Deprecated. Use the file(WRITE ) command instead."; - } - - /** - * More documentation. - */ - virtual const char* GetFullDocumentation() const - { - return - " write_file(filename \"message to write\"... [APPEND])\n" - "The first argument is the file name, the rest of the arguments are " - "messages to write. If the argument APPEND is specified, then " - "the message will be appended.\n" - "NOTE 1: file(WRITE ... and file(APPEND ... do exactly the same as " - "this one but add some more functionality.\n" - "NOTE 2: When using write_file the produced file cannot be used as an " - "input to CMake (CONFIGURE_FILE, source file ...) because it will " - "lead to an infinite loop. Use configure_file if you want to generate " - "input files to CMake."; - } - /** This command is kept for compatibility with older CMake versions. */ virtual bool IsDiscouraged() const { diff --git a/Source/cmXMLParser.cxx b/Source/cmXMLParser.cxx index 882fc17..0c53440 100644 --- a/Source/cmXMLParser.cxx +++ b/Source/cmXMLParser.cxx @@ -10,6 +10,7 @@ See the License for more information. ============================================================================*/ #include "cmXMLParser.h" +#include <cmsys/FStream.hxx> #include <cm_expat.h> #include <ctype.h> @@ -45,7 +46,7 @@ int cmXMLParser::ParseFile(const char* file) return 0; } - std::ifstream ifs(file); + cmsys::ifstream ifs(file); if ( !ifs ) { return 0; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 290aff0..33fb0fc 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -10,8 +10,6 @@ See the License for more information. ============================================================================*/ #include "cmake.h" -#include "cmDocumentVariables.h" -#include "time.h" #include "cmCacheManager.h" #include "cmMakefile.h" #include "cmLocalGenerator.h" @@ -19,25 +17,18 @@ #include "cmCommands.h" #include "cmCommand.h" #include "cmFileTimeComparison.h" -#include "cmGeneratedFileStream.h" -#include "cmQtAutomoc.h" #include "cmSourceFile.h" -#include "cmVersion.h" #include "cmTest.h" -#include "cmDocumentationFormatterText.h" +#include "cmDocumentationFormatter.h" #if defined(CMAKE_BUILD_WITH_CMAKE) # include "cmGraphVizWriter.h" -# include "cmDependsFortran.h" // For -E cmake_copy_f90_mod callback. # include "cmVariableWatch.h" -# include <cmsys/Terminal.h> -# include <cmsys/CommandLineArguments.hxx> #endif -#include <cmsys/Directory.hxx> -#include <cmsys/Process.h> #include <cmsys/Glob.hxx> #include <cmsys/RegularExpression.hxx> +#include <cmsys/FStream.hxx> // only build kdevelop generator on non-windows platforms // when not bootstrapping cmake @@ -74,22 +65,17 @@ # endif # include "cmGlobalMSYSMakefileGenerator.h" # include "cmGlobalMinGWMakefileGenerator.h" -# include "cmWin32ProcessExecution.h" #else #endif #include "cmGlobalUnixMakefileGenerator3.h" #include "cmGlobalNinjaGenerator.h" - - -#if defined(CMAKE_HAVE_VS_GENERATORS) -#include "cmCallVisualStudioMacro.h" -#include "cmVisualStudioWCEPlatformParser.h" -#endif +#include "cmExtraCodeLiteGenerator.h" #if !defined(CMAKE_BOOT_MINGW) # include "cmExtraCodeBlocksGenerator.h" #endif #include "cmExtraSublimeTextGenerator.h" +#include "cmExtraKateGenerator.h" #ifdef CMAKE_USE_KDEVELOP # include "cmGlobalKdevelopGenerator.h" @@ -116,30 +102,6 @@ static bool cmakeCheckStampFile(const char* stampName); static bool cmakeCheckStampList(const char* stampName); -void cmNeedBackwardsCompatibility(const std::string& variable, - int access_type, void*, const char*, const cmMakefile*) -{ -#ifdef CMAKE_BUILD_WITH_CMAKE - if (access_type == cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS) - { - std::string message = "An attempt was made to access a variable: "; - message += variable; - message += - " that has not been defined. Some variables were always defined " - "by CMake in versions prior to 1.6. To fix this you might need to set " - "the cache value of CMAKE_BACKWARDS_COMPATIBILITY to 1.4 or less. If " - "you are writing a CMakeLists file, (or have already set " - "CMAKE_BACKWARDS_COMPATIBILITY to 1.4 or less) then you probably need " - "to include a CMake module to test for the feature this variable " - "defines."; - cmSystemTools::Error(message.c_str()); - } -#else - (void)variable; - (void)access_type; -#endif -} - void cmWarnUnusedCliWarning(const std::string& variable, int, void* ctx, const char*, const cmMakefile*) { @@ -186,12 +148,6 @@ cmake::cmake() #ifdef CMAKE_BUILD_WITH_CMAKE this->VariableWatch = new cmVariableWatch; - this->VariableWatch->AddWatch("CMAKE_WORDS_BIGENDIAN", - cmNeedBackwardsCompatibility); - this->VariableWatch->AddWatch("CMAKE_SIZEOF_INT", - cmNeedBackwardsCompatibility); - this->VariableWatch->AddWatch("CMAKE_X_LIBS", - cmNeedBackwardsCompatibility); #endif this->AddDefaultGenerators(); @@ -235,12 +191,8 @@ void cmake::InitializeProperties() this->PropertyDefinitions.clear(); // initialize properties - cmCacheManager::DefineProperties(this); - cmSourceFile::DefineProperties(this); cmTarget::DefineProperties(this); cmMakefile::DefineProperties(this); - cmTest::DefineProperties(this); - cmake::DefineProperties(this); } void cmake::CleanupCommandsAndMacros() @@ -642,9 +594,10 @@ bool cmake::FindPackage(const std::vector<std::string>& args) std::string linkPath; std::string flags; std::string linkFlags; - cmGeneratorTarget gtgt(tgt); + gg->CreateGeneratorTargets(mf); + cmGeneratorTarget *gtgt = gg->GetGeneratorTarget(tgt); lg->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags, - >gt); + gtgt); linkLibs = frameworkPath + linkPath + linkLibs; printf("%s\n", linkLibs.c_str() ); @@ -983,883 +936,32 @@ void cmake::SetDirectoriesFromFile(const char* arg) // cache int cmake::AddCMakePaths() { - // Find the cmake executable - std::string cMakeSelf = cmSystemTools::GetExecutableDirectory(); - cMakeSelf = cmSystemTools::GetRealPath(cMakeSelf.c_str()); - cMakeSelf += "/cmake"; - cMakeSelf += cmSystemTools::GetExecutableExtension(); -#ifdef __APPLE__ - // on the apple this might be the gui bundle - if(!cmSystemTools::FileExists(cMakeSelf.c_str())) - { - cMakeSelf = cmSystemTools::GetExecutableDirectory(); - cMakeSelf = cmSystemTools::GetRealPath(cMakeSelf.c_str()); - cMakeSelf += "../../../.."; - cMakeSelf = cmSystemTools::GetRealPath(cMakeSelf.c_str()); - cMakeSelf = cmSystemTools::CollapseFullPath(cMakeSelf.c_str()); - cMakeSelf += "/cmake"; - std::cerr << cMakeSelf.c_str() << "\n"; - } -#endif - if(!cmSystemTools::FileExists(cMakeSelf.c_str())) - { - cmSystemTools::Error("CMake executable cannot be found at ", - cMakeSelf.c_str()); - return 0; - } // Save the value in the cache this->CacheManager->AddCacheEntry - ("CMAKE_COMMAND",cMakeSelf.c_str(), "Path to CMake executable.", - cmCacheManager::INTERNAL); - // if the edit command is not yet in the cache, - // or if CMakeEditCommand has been set on this object, - // then set the CMAKE_EDIT_COMMAND in the cache - // This will mean that the last gui to edit the cache - // will be the one that make edit_cache uses. - if(!this->GetCacheDefinition("CMAKE_EDIT_COMMAND") - || !this->CMakeEditCommand.empty()) - { - // Find and save the command to edit the cache - std::string editCacheCommand; - if(!this->CMakeEditCommand.empty()) - { - editCacheCommand = cmSystemTools::GetFilenamePath(cMakeSelf) - + std::string("/") - + this->CMakeEditCommand - + cmSystemTools::GetFilenameExtension(cMakeSelf); - } - if( !cmSystemTools::FileExists(editCacheCommand.c_str())) - { - editCacheCommand = cmSystemTools::GetFilenamePath(cMakeSelf) + - "/ccmake" + cmSystemTools::GetFilenameExtension(cMakeSelf); - } - if( !cmSystemTools::FileExists(editCacheCommand.c_str())) - { - editCacheCommand = cmSystemTools::GetFilenamePath(cMakeSelf) + - "/cmake-gui" + cmSystemTools::GetFilenameExtension(cMakeSelf); - } - if(cmSystemTools::FileExists(editCacheCommand.c_str())) - { - this->CacheManager->AddCacheEntry - ("CMAKE_EDIT_COMMAND", editCacheCommand.c_str(), - "Path to cache edit program executable.", cmCacheManager::INTERNAL); - } - } - std::string ctestCommand = cmSystemTools::GetFilenamePath(cMakeSelf) + - "/ctest" + cmSystemTools::GetFilenameExtension(cMakeSelf); - if(cmSystemTools::FileExists(ctestCommand.c_str())) - { - this->CacheManager->AddCacheEntry - ("CMAKE_CTEST_COMMAND", ctestCommand.c_str(), - "Path to ctest program executable.", cmCacheManager::INTERNAL); - } - std::string cpackCommand = cmSystemTools::GetFilenamePath(cMakeSelf) + - "/cpack" + cmSystemTools::GetFilenameExtension(cMakeSelf); - if(cmSystemTools::FileExists(cpackCommand.c_str())) - { - this->CacheManager->AddCacheEntry - ("CMAKE_CPACK_COMMAND", cpackCommand.c_str(), - "Path to cpack program executable.", cmCacheManager::INTERNAL); - } - - // do CMAKE_ROOT, look for the environment variable first - std::string cMakeRoot; - std::string modules; - if (getenv("CMAKE_ROOT")) - { - cMakeRoot = getenv("CMAKE_ROOT"); - modules = cMakeRoot + "/Modules/CMake.cmake"; - } - if(!cmSystemTools::FileExists(modules.c_str())) - { - // next try exe/.. - cMakeRoot = cmSystemTools::GetRealPath(cMakeSelf.c_str()); - cMakeRoot = cmSystemTools::GetProgramPath(cMakeRoot.c_str()); - std::string::size_type slashPos = cMakeRoot.rfind("/"); - if(slashPos != std::string::npos) - { - cMakeRoot = cMakeRoot.substr(0, slashPos); - } - // is there no Modules directory there? - modules = cMakeRoot + "/Modules/CMake.cmake"; - } - - if (!cmSystemTools::FileExists(modules.c_str())) - { - // try exe/../share/cmake - cMakeRoot += CMAKE_DATA_DIR; - modules = cMakeRoot + "/Modules/CMake.cmake"; - } -#ifdef CMAKE_ROOT_DIR - if (!cmSystemTools::FileExists(modules.c_str())) - { - // try compiled in root directory - cMakeRoot = CMAKE_ROOT_DIR; - modules = cMakeRoot + "/Modules/CMake.cmake"; - } + ("CMAKE_COMMAND", cmSystemTools::GetCMakeCommand().c_str(), + "Path to CMake executable.", cmCacheManager::INTERNAL); +#ifdef CMAKE_BUILD_WITH_CMAKE + this->CacheManager->AddCacheEntry + ("CMAKE_CTEST_COMMAND", cmSystemTools::GetCTestCommand().c_str(), + "Path to ctest program executable.", cmCacheManager::INTERNAL); + this->CacheManager->AddCacheEntry + ("CMAKE_CPACK_COMMAND", cmSystemTools::GetCPackCommand().c_str(), + "Path to cpack program executable.", cmCacheManager::INTERNAL); #endif - if (!cmSystemTools::FileExists(modules.c_str())) - { - // try - cMakeRoot = cmSystemTools::GetProgramPath(cMakeSelf.c_str()); - cMakeRoot += CMAKE_DATA_DIR; - modules = cMakeRoot + "/Modules/CMake.cmake"; - } - if(!cmSystemTools::FileExists(modules.c_str())) - { - // next try exe - cMakeRoot = cmSystemTools::GetProgramPath(cMakeSelf.c_str()); - // is there no Modules directory there? - modules = cMakeRoot + "/Modules/CMake.cmake"; - } - if (!cmSystemTools::FileExists(modules.c_str())) + if(!cmSystemTools::FileExists( + (cmSystemTools::GetCMakeRoot()+"/Modules/CMake.cmake").c_str())) { // couldn't find modules cmSystemTools::Error("Could not find CMAKE_ROOT !!!\n" "CMake has most likely not been installed correctly.\n" "Modules directory not found in\n", - cMakeRoot.c_str()); + cmSystemTools::GetCMakeRoot().c_str()); return 0; } this->CacheManager->AddCacheEntry - ("CMAKE_ROOT", cMakeRoot.c_str(), + ("CMAKE_ROOT", cmSystemTools::GetCMakeRoot().c_str(), "Path to CMake installation.", cmCacheManager::INTERNAL); -#ifdef _WIN32 - std::string comspec = "cmw9xcom.exe"; - cmSystemTools::SetWindows9xComspecSubstitute(comspec.c_str()); -#endif - return 1; -} - - - -void CMakeCommandUsage(const char* program) -{ - cmOStringStream errorStream; - -#ifdef CMAKE_BUILD_WITH_CMAKE - errorStream - << "cmake version " << cmVersion::GetCMakeVersion() << "\n"; -#else - errorStream - << "cmake bootstrap\n"; -#endif - // If you add new commands, change here, - // and in cmakemain.cxx in the options table - errorStream - << "Usage: " << program << " -E [command] [arguments ...]\n" - << "Available commands: \n" - << " chdir dir cmd [args]... - run command in a given directory\n" - << " compare_files file1 file2 - check if file1 is same as file2\n" - << " copy file destination - copy file to destination (either file " - "or directory)\n" - << " copy_directory source destination - copy directory 'source' " - "content to directory 'destination'\n" - << " copy_if_different in-file out-file - copy file if input has " - "changed\n" - << " echo [string]... - displays arguments as text\n" - << " echo_append [string]... - displays arguments as text but no new " - "line\n" - << " environment - display the current environment\n" - << " make_directory dir - create a directory\n" - << " md5sum file1 [...] - compute md5sum of files\n" - << " remove [-f] file1 file2 ... - remove the file(s), use -f to force " - "it\n" - << " remove_directory dir - remove a directory and its contents\n" - << " rename oldname newname - rename a file or directory " - "(on one volume)\n" - << " tar [cxt][vfz][cvfj] file.tar [file/dir1 file/dir2 ...]\n" - << " - create or extract a tar or zip archive\n" - << " time command [args] ... - run command and return elapsed time\n" - << " touch file - touch a file.\n" - << " touch_nocreate file - touch a file but do not create it.\n" -#if defined(_WIN32) && !defined(__CYGWIN__) - << "Available on Windows only:\n" - << " comspec - on windows 9x use this for RunCommand\n" - << " delete_regv key - delete registry value\n" - << " env_vs8_wince sdkname - displays a batch file which sets the " - "environment for the provided Windows CE SDK installed in VS2005\n" - << " env_vs9_wince sdkname - displays a batch file which sets the " - "environment for the provided Windows CE SDK installed in VS2008\n" - << " write_regv key value - write registry value\n" -#else - << "Available on UNIX only:\n" - << " create_symlink old new - create a symbolic link new -> old\n" -#endif - ; - - cmSystemTools::Error(errorStream.str().c_str()); -} - -int cmake::ExecuteCMakeCommand(std::vector<std::string>& args) -{ - // IF YOU ADD A NEW COMMAND, DOCUMENT IT ABOVE and in cmakemain.cxx - if (args.size() > 1) - { - // Copy file - if (args[1] == "copy" && args.size() == 4) - { - if(!cmSystemTools::cmCopyFile(args[2].c_str(), args[3].c_str())) - { - std::cerr << "Error copying file \"" << args[2].c_str() - << "\" to \"" << args[3].c_str() << "\".\n"; - return 1; - } - return 0; - } - - // Copy file if different. - if (args[1] == "copy_if_different" && args.size() == 4) - { - if(!cmSystemTools::CopyFileIfDifferent(args[2].c_str(), - args[3].c_str())) - { - std::cerr << "Error copying file (if different) from \"" - << args[2].c_str() << "\" to \"" << args[3].c_str() - << "\".\n"; - return 1; - } - return 0; - } - - // Copy directory content - if (args[1] == "copy_directory" && args.size() == 4) - { - if(!cmSystemTools::CopyADirectory(args[2].c_str(), args[3].c_str())) - { - std::cerr << "Error copying directory from \"" - << args[2].c_str() << "\" to \"" << args[3].c_str() - << "\".\n"; - return 1; - } - return 0; - } - - // Rename a file or directory - if (args[1] == "rename" && args.size() == 4) - { - if(!cmSystemTools::RenameFile(args[2].c_str(), args[3].c_str())) - { - std::string e = cmSystemTools::GetLastSystemError(); - std::cerr << "Error renaming from \"" - << args[2].c_str() << "\" to \"" << args[3].c_str() - << "\": " << e << "\n"; - return 1; - } - return 0; - } - - // Compare files - if (args[1] == "compare_files" && args.size() == 4) - { - if(cmSystemTools::FilesDiffer(args[2].c_str(), args[3].c_str())) - { - std::cerr << "Files \"" - << args[2].c_str() << "\" to \"" << args[3].c_str() - << "\" are different.\n"; - return 1; - } - return 0; - } - - // Echo string - else if (args[1] == "echo" ) - { - unsigned int cc; - const char* space = ""; - for ( cc = 2; cc < args.size(); cc ++ ) - { - std::cout << space << args[cc]; - space = " "; - } - std::cout << std::endl; - return 0; - } - - // Echo string no new line - else if (args[1] == "echo_append" ) - { - unsigned int cc; - const char* space = ""; - for ( cc = 2; cc < args.size(); cc ++ ) - { - std::cout << space << args[cc]; - space = " "; - } - return 0; - } - -#if defined(CMAKE_BUILD_WITH_CMAKE) - // Command to create a symbolic link. Fails on platforms not - // supporting them. - else if (args[1] == "environment" ) - { - std::vector<std::string> env = cmSystemTools::GetEnvironmentVariables(); - std::vector<std::string>::iterator it; - for ( it = env.begin(); it != env.end(); ++ it ) - { - std::cout << it->c_str() << std::endl; - } - return 0; - } -#endif - - else if (args[1] == "make_directory" && args.size() == 3) - { - if(!cmSystemTools::MakeDirectory(args[2].c_str())) - { - std::cerr << "Error making directory \"" << args[2].c_str() - << "\".\n"; - return 1; - } - return 0; - } - - else if (args[1] == "remove_directory" && args.size() == 3) - { - if(cmSystemTools::FileIsDirectory(args[2].c_str()) && - !cmSystemTools::RemoveADirectory(args[2].c_str())) - { - std::cerr << "Error removing directory \"" << args[2].c_str() - << "\".\n"; - return 1; - } - return 0; - } - - // Remove file - else if (args[1] == "remove" && args.size() > 2) - { - bool force = false; - for (std::string::size_type cc = 2; cc < args.size(); cc ++) - { - if(args[cc] == "\\-f" || args[cc] == "-f") - { - force = true; - } - else - { - // Complain if the file could not be removed, still exists, - // and the -f option was not given. - if(!cmSystemTools::RemoveFile(args[cc].c_str()) && !force && - cmSystemTools::FileExists(args[cc].c_str())) - { - return 1; - } - } - } - return 0; - } - // Touch file - else if (args[1] == "touch" && args.size() > 2) - { - for (std::string::size_type cc = 2; cc < args.size(); cc ++) - { - // Complain if the file could not be removed, still exists, - // and the -f option was not given. - if(!cmSystemTools::Touch(args[cc].c_str(), true)) - { - return 1; - } - } - return 0; - } - // Touch file - else if (args[1] == "touch_nocreate" && args.size() > 2) - { - for (std::string::size_type cc = 2; cc < args.size(); cc ++) - { - // Complain if the file could not be removed, still exists, - // and the -f option was not given. - if(!cmSystemTools::Touch(args[cc].c_str(), false)) - { - return 1; - } - } - return 0; - } - - // Clock command - else if (args[1] == "time" && args.size() > 2) - { - std::string command = args[2]; - for (std::string::size_type cc = 3; cc < args.size(); cc ++) - { - command += " "; - command += args[cc]; - } - - clock_t clock_start, clock_finish; - time_t time_start, time_finish; - - time(&time_start); - clock_start = clock(); - int ret =0; - cmSystemTools::RunSingleCommand(command.c_str(), 0, &ret); - - clock_finish = clock(); - time(&time_finish); - - double clocks_per_sec = static_cast<double>(CLOCKS_PER_SEC); - std::cout << "Elapsed time: " - << static_cast<long>(time_finish - time_start) << " s. (time)" - << ", " - << static_cast<double>(clock_finish - clock_start) / clocks_per_sec - << " s. (clock)" - << "\n"; - return ret; - } - // Command to calculate the md5sum of a file - else if (args[1] == "md5sum" && args.size() >= 3) - { - char md5out[32]; - int retval = 0; - for (std::string::size_type cc = 2; cc < args.size(); cc ++) - { - const char *filename = args[cc].c_str(); - // Cannot compute md5sum of a directory - if(cmSystemTools::FileIsDirectory(filename)) - { - std::cerr << "Error: " << filename << " is a directory" << std::endl; - retval++; - } - else if(!cmSystemTools::ComputeFileMD5(filename, md5out)) - { - // To mimic md5sum behavior in a shell: - std::cerr << filename << ": No such file or directory" << std::endl; - retval++; - } - else - { - std::cout << std::string(md5out,32) << " " << filename << std::endl; - } - } - return retval; - } - - // Command to change directory and run a program. - else if (args[1] == "chdir" && args.size() >= 4) - { - std::string directory = args[2]; - if(!cmSystemTools::FileExists(directory.c_str())) - { - cmSystemTools::Error("Directory does not exist for chdir command: ", - args[2].c_str()); - return 1; - } - - std::string command = "\""; - command += args[3]; - command += "\""; - for (std::string::size_type cc = 4; cc < args.size(); cc ++) - { - command += " \""; - command += args[cc]; - command += "\""; - } - int retval = 0; - int timeout = 0; - if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, &retval, - directory.c_str(), cmSystemTools::OUTPUT_NORMAL, timeout) ) - { - return retval; - } - - return 1; - } - - // Command to start progress for a build - else if (args[1] == "cmake_progress_start" && args.size() == 4) - { - // basically remove the directory - std::string dirName = args[2]; - dirName += "/Progress"; - cmSystemTools::RemoveADirectory(dirName.c_str()); - - // is the last argument a filename that exists? - FILE *countFile = fopen(args[3].c_str(),"r"); - int count; - if (countFile) - { - if (1!=fscanf(countFile,"%i",&count)) - { - cmSystemTools::Message("Could not read from count file."); - } - fclose(countFile); - } - else - { - count = atoi(args[3].c_str()); - } - if (count) - { - cmSystemTools::MakeDirectory(dirName.c_str()); - // write the count into the directory - std::string fName = dirName; - fName += "/count.txt"; - FILE *progFile = fopen(fName.c_str(),"w"); - if (progFile) - { - fprintf(progFile,"%i\n",count); - fclose(progFile); - } - } - return 0; - } - - // Command to report progress for a build - else if (args[1] == "cmake_progress_report" && args.size() >= 3) - { - std::string dirName = args[2]; - dirName += "/Progress"; - std::string fName; - FILE *progFile; - - // read the count - fName = dirName; - fName += "/count.txt"; - progFile = fopen(fName.c_str(),"r"); - int count = 0; - if (!progFile) - { - return 0; - } - else - { - if (1!=fscanf(progFile,"%i",&count)) - { - cmSystemTools::Message("Could not read from progress file."); - } - fclose(progFile); - } - unsigned int i; - for (i = 3; i < args.size(); ++i) - { - fName = dirName; - fName += "/"; - fName += args[i]; - progFile = fopen(fName.c_str(),"w"); - if (progFile) - { - fprintf(progFile,"empty"); - fclose(progFile); - } - } - int fileNum = static_cast<int> - (cmsys::Directory::GetNumberOfFilesInDirectory(dirName.c_str())); - if (count > 0) - { - // print the progress - fprintf(stdout,"[%3i%%] ",((fileNum-3)*100)/count); - } - return 0; - } - - // Command to create a symbolic link. Fails on platforms not - // supporting them. - else if (args[1] == "create_symlink" && args.size() == 4) - { - const char* destinationFileName = args[3].c_str(); - if ( cmSystemTools::FileExists(destinationFileName) ) - { - if ( cmSystemTools::FileIsSymlink(destinationFileName) ) - { - if ( !cmSystemTools::RemoveFile(destinationFileName) || - cmSystemTools::FileExists(destinationFileName) ) - { - return 0; - } - } - else - { - return 0; - } - } - return cmSystemTools::CreateSymlink(args[2].c_str(), - args[3].c_str())? 0:1; - } - - // Internal CMake shared library support. - else if (args[1] == "cmake_symlink_library" && args.size() == 5) - { - return cmake::SymlinkLibrary(args); - } - // Internal CMake versioned executable support. - else if (args[1] == "cmake_symlink_executable" && args.size() == 4) - { - return cmake::SymlinkExecutable(args); - } - -#if defined(CMAKE_HAVE_VS_GENERATORS) - // Internal CMake support for calling Visual Studio macros. - else if (args[1] == "cmake_call_visual_studio_macro" && args.size() >= 4) - { - // args[2] = full path to .sln file or "ALL" - // args[3] = name of Visual Studio macro to call - // args[4..args.size()-1] = [optional] args for Visual Studio macro - - std::string macroArgs; - - if (args.size() > 4) - { - macroArgs = args[4]; - - for (size_t i = 5; i < args.size(); ++i) - { - macroArgs += " "; - macroArgs += args[i]; - } - } - - return cmCallVisualStudioMacro::CallMacro(args[2], args[3], - macroArgs, true); - } -#endif - - // Internal CMake dependency scanning support. - else if (args[1] == "cmake_depends" && args.size() >= 6) - { - // Use the make system's VERBOSE environment variable to enable - // verbose output. This can be skipped by also setting CMAKE_NO_VERBOSE - // (which is set by the Eclipse and KDevelop generators). - bool verbose = ((cmSystemTools::GetEnv("VERBOSE") != 0) - && (cmSystemTools::GetEnv("CMAKE_NO_VERBOSE") == 0)); - - // Create a cmake object instance to process dependencies. - cmake cm; - std::string gen; - std::string homeDir; - std::string startDir; - std::string homeOutDir; - std::string startOutDir; - std::string depInfo; - bool color = false; - if(args.size() >= 8) - { - // Full signature: - // - // -E cmake_depends <generator> - // <home-src-dir> <start-src-dir> - // <home-out-dir> <start-out-dir> - // <dep-info> [--color=$(COLOR)] - // - // All paths are provided. - gen = args[2]; - homeDir = args[3]; - startDir = args[4]; - homeOutDir = args[5]; - startOutDir = args[6]; - depInfo = args[7]; - if(args.size() >= 9 && - args[8].length() >= 8 && - args[8].substr(0, 8) == "--color=") - { - // Enable or disable color based on the switch value. - color = (args[8].size() == 8 || - cmSystemTools::IsOn(args[8].substr(8).c_str())); - } - } - else - { - // Support older signature for existing makefiles: - // - // -E cmake_depends <generator> - // <home-out-dir> <start-out-dir> - // <dep-info> - // - // Just pretend the source directories are the same as the - // binary directories so at least scanning will work. - gen = args[2]; - homeDir = args[3]; - startDir = args[4]; - homeOutDir = args[3]; - startOutDir = args[3]; - depInfo = args[5]; - } - - // Create a local generator configured for the directory in - // which dependencies will be scanned. - homeDir = cmSystemTools::CollapseFullPath(homeDir.c_str()); - startDir = cmSystemTools::CollapseFullPath(startDir.c_str()); - homeOutDir = cmSystemTools::CollapseFullPath(homeOutDir.c_str()); - startOutDir = cmSystemTools::CollapseFullPath(startOutDir.c_str()); - cm.SetHomeDirectory(homeDir.c_str()); - cm.SetStartDirectory(startDir.c_str()); - cm.SetHomeOutputDirectory(homeOutDir.c_str()); - cm.SetStartOutputDirectory(startOutDir.c_str()); - if(cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen.c_str())) - { - cm.SetGlobalGenerator(ggd); - cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator()); - lgd->GetMakefile()->SetStartDirectory(startDir.c_str()); - lgd->GetMakefile()->SetStartOutputDirectory(startOutDir.c_str()); - lgd->GetMakefile()->MakeStartDirectoriesCurrent(); - - // Actually scan dependencies. - return lgd->UpdateDependencies(depInfo.c_str(), - verbose, color)? 0 : 2; - } - return 1; - } - - // Internal CMake link script support. - else if (args[1] == "cmake_link_script" && args.size() >= 3) - { - return cmake::ExecuteLinkScript(args); - } - - // Internal CMake unimplemented feature notification. - else if (args[1] == "cmake_unimplemented_variable") - { - std::cerr << "Feature not implemented for this platform."; - if(args.size() == 3) - { - std::cerr << " Variable " << args[2] << " is not set."; - } - std::cerr << std::endl; - return 1; - } - else if (args[1] == "vs_link_exe") - { - return cmake::VisualStudioLink(args, 1); - } - else if (args[1] == "vs_link_dll") - { - return cmake::VisualStudioLink(args, 2); - } -#ifdef CMAKE_BUILD_WITH_CMAKE - // Internal CMake color makefile support. - else if (args[1] == "cmake_echo_color") - { - return cmake::ExecuteEchoColor(args); - } - else if (args[1] == "cmake_automoc") - { - cmQtAutomoc automoc; - const char *config = args[3].empty() ? 0 : args[3].c_str(); - bool automocSuccess = automoc.Run(args[2].c_str(), config); - return automocSuccess ? 0 : 1; - } -#endif - - // Tar files - else if (args[1] == "tar" && args.size() > 3) - { - std::string flags = args[2]; - std::string outFile = args[3]; - std::vector<cmStdString> files; - for (std::string::size_type cc = 4; cc < args.size(); cc ++) - { - files.push_back(args[cc]); - } - bool gzip = false; - bool bzip2 = false; - bool verbose = false; - if ( flags.find_first_of('j') != flags.npos ) - { - bzip2 = true; - } - if ( flags.find_first_of('z') != flags.npos ) - { - gzip = true; - } - if ( flags.find_first_of('v') != flags.npos ) - { - verbose = true; - } - - if ( flags.find_first_of('t') != flags.npos ) - { - if ( !cmSystemTools::ListTar(outFile.c_str(), gzip, verbose) ) - { - cmSystemTools::Error("Problem creating tar: ", outFile.c_str()); - return 1; - } - } - else if ( flags.find_first_of('c') != flags.npos ) - { - if ( !cmSystemTools::CreateTar( - outFile.c_str(), files, gzip, bzip2, verbose) ) - { - cmSystemTools::Error("Problem creating tar: ", outFile.c_str()); - return 1; - } - } - else if ( flags.find_first_of('x') != flags.npos ) - { - if ( !cmSystemTools::ExtractTar( - outFile.c_str(), gzip, verbose) ) - { - cmSystemTools::Error("Problem extracting tar: ", outFile.c_str()); - return 1; - } -#ifdef WIN32 - // OK, on windows 7 after we untar some files, - // sometimes we can not rename the directory after - // the untar is done. This breaks the external project - // untar and rename code. So, by default we will wait - // 1/10th of a second after the untar. If CMAKE_UNTAR_DELAY - // is set in the env, its value will be used instead of 100. - int delay = 100; - const char* delayVar = cmSystemTools::GetEnv("CMAKE_UNTAR_DELAY"); - if(delayVar) - { - delay = atoi(delayVar); - } - if(delay) - { - cmSystemTools::Delay(delay); - } -#endif - } - return 0; - } - -#if defined(CMAKE_BUILD_WITH_CMAKE) - // Internal CMake Fortran module support. - else if (args[1] == "cmake_copy_f90_mod" && args.size() >= 4) - { - return cmDependsFortran::CopyModule(args)? 0 : 1; - } -#endif - -#if defined(_WIN32) && !defined(__CYGWIN__) - // Write registry value - else if (args[1] == "write_regv" && args.size() > 3) - { - return cmSystemTools::WriteRegistryValue(args[2].c_str(), - args[3].c_str()) ? 0 : 1; - } - - // Delete registry value - else if (args[1] == "delete_regv" && args.size() > 2) - { - return cmSystemTools::DeleteRegistryValue(args[2].c_str()) ? 0 : 1; - } - // Remove file - else if (args[1] == "comspec" && args.size() > 2) - { - unsigned int cc; - std::string command = args[2]; - for ( cc = 3; cc < args.size(); cc ++ ) - { - command += " " + args[cc]; - } - return cmWin32ProcessExecution::Windows9xHack(command.c_str()); - } - else if (args[1] == "env_vs8_wince" && args.size() == 3) - { - return cmake::WindowsCEEnvironment("8.0", args[2]); - } - else if (args[1] == "env_vs9_wince" && args.size() == 3) - { - return cmake::WindowsCEEnvironment("9.0", args[2]); - } -#endif - } - - ::CMakeCommandUsage(args[0].c_str()); return 1; } @@ -1891,8 +993,12 @@ void cmake::AddDefaultExtraGenerators() this->AddExtraGenerator(cmExtraCodeBlocksGenerator::GetActualName(), &cmExtraCodeBlocksGenerator::New); + this->AddExtraGenerator(cmExtraCodeLiteGenerator::GetActualName(), + &cmExtraCodeLiteGenerator::New); this->AddExtraGenerator(cmExtraSublimeTextGenerator::GetActualName(), &cmExtraSublimeTextGenerator::New); + this->AddExtraGenerator(cmExtraKateGenerator::GetActualName(), + &cmExtraKateGenerator::New); #ifdef CMAKE_USE_ECLIPSE this->AddExtraGenerator(cmExtraEclipseCDT4Generator::GetActualName(), @@ -2254,9 +1360,9 @@ int cmake::ActualConfigure() {"7.1", "Visual Studio 7 .NET 2003"}, {"8.0", "Visual Studio 8 2005"}, {"9.0", "Visual Studio 9 2008"}, - {"10.0", "Visual Studio 10"}, - {"11.0", "Visual Studio 11"}, - {"12.0", "Visual Studio 12"}, + {"10.0", "Visual Studio 10 2010"}, + {"11.0", "Visual Studio 11 2012"}, + {"12.0", "Visual Studio 12 2013"}, {0, 0}}; for(int i=0; version[i].MSVersion != 0; i++) { @@ -2295,7 +1401,7 @@ int cmake::ActualConfigure() const char* genName = this->CacheManager->GetCacheValue("CMAKE_GENERATOR"); if(genName) { - if(strcmp(this->GlobalGenerator->GetName(), genName) != 0) + if(!this->GlobalGenerator->MatchesGeneratorName(genName)) { std::string message = "Error: generator : "; message += this->GlobalGenerator->GetName(); @@ -2437,11 +1543,6 @@ int cmake::ActualConfigure() { this->CacheManager->SaveCache(this->GetHomeOutputDirectory()); } - if ( !this->GraphVizFile.empty() ) - { - std::cout << "Generate graphviz: " << this->GraphVizFile << std::endl; - this->GenerateGraphViz(this->GraphVizFile.c_str()); - } if(cmSystemTools::GetErrorOccuredFlag()) { return -1; @@ -2496,9 +1597,6 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure) return 0; } - // set the cmake command - this->CMakeCommand = args[0]; - if ( this->GetWorkingMode() == NORMAL_MODE ) { // load the cache @@ -2604,6 +1702,11 @@ int cmake::Generate() return -1; } this->GlobalGenerator->Generate(); + if ( !this->GraphVizFile.empty() ) + { + std::cout << "Generate graphviz: " << this->GraphVizFile << std::endl; + this->GenerateGraphViz(this->GraphVizFile.c_str()); + } if(this->WarnUnusedCli) { this->RunCheckForUnusedVariables(); @@ -2612,11 +1715,6 @@ int cmake::Generate() { return -1; } - if (this->GetProperty("REPORT_UNDEFINED_PROPERTIES")) - { - this->ReportUndefinedPropertyAccesses - (this->GetProperty("REPORT_UNDEFINED_PROPERTIES")); - } // Save the cache again after a successful Generate so that any internal // variables created during Generate are saved. (Specifically target GUIDs // for the Visual Studio and Xcode generators.) @@ -2716,14 +1814,6 @@ int cmake::LoadCache() } } - if (this->CMakeCommand.size() < 2) - { - cmSystemTools::Error( - "cmake command was not specified prior to loading the cache in " - "cmake.cxx"); - return -1; - } - // setup CMAKE_ROOT and CMAKE_COMMAND if(!this->AddCMakePaths()) { @@ -2747,45 +1837,6 @@ void cmake::UpdateProgress(const char *msg, float prog) } } -void cmake::GetCommandDocumentation(std::vector<cmDocumentationEntry>& v, - bool withCurrentCommands, - bool withCompatCommands) const -{ - for(RegisteredCommandsMap::const_iterator j = this->Commands.begin(); - j != this->Commands.end(); ++j) - { - if ((( withCompatCommands == false) && ( (*j).second->IsDiscouraged())) - || ((withCurrentCommands == false) && (!(*j).second->IsDiscouraged())) - || (!((*j).second->ShouldAppearInDocumentation())) - ) - { - continue; - } - - cmDocumentationEntry e((*j).second->GetName(), - (*j).second->GetTerseDocumentation(), - (*j).second->GetFullDocumentation()); - v.push_back(e); - } -} - -void cmake::GetPolicyDocumentation(std::vector<cmDocumentationEntry>& v) -{ - this->Policies->GetDocumentation(v); -} - -void cmake::GetPropertiesDocumentation(std::map<std::string, - cmDocumentationSection *>& v) -{ - // loop over the properties and put them into the doc structure - std::map<cmProperty::ScopeType, cmPropertyDefinitionMap>::iterator i; - i = this->PropertyDefinitions.begin(); - for (;i != this->PropertyDefinitions.end(); ++i) - { - i->second.GetPropertiesDocumentation(v); - } -} - void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v) { for(RegisteredGeneratorsVector::const_iterator i = @@ -2815,7 +1866,7 @@ void cmake::UpdateConversionPathTable() if(tablepath) { - std::ifstream table( tablepath ); + cmsys::ifstream table( tablepath ); if(!table) { cmSystemTools::Error("CMAKE_PATH_TRANSLATION_FILE set to ", tablepath, @@ -3068,82 +2119,6 @@ inline std::string removeQuotes(const std::string& s) return s; } -std::string cmake::FindCMakeProgram(const char* name) const -{ - std::string path; - if ((name) && (*name)) - { - const cmMakefile* mf - = this->GetGlobalGenerator()->GetLocalGenerators()[0]->GetMakefile(); -#ifdef CMAKE_BUILD_WITH_CMAKE - path = mf->GetRequiredDefinition("CMAKE_COMMAND"); - path = removeQuotes(path); - path = cmSystemTools::GetFilenamePath(path.c_str()); - path += "/"; - path += name; - path += cmSystemTools::GetExecutableExtension(); - if(!cmSystemTools::FileExists(path.c_str())) - { - path = mf->GetRequiredDefinition("CMAKE_COMMAND"); - path = cmSystemTools::GetFilenamePath(path.c_str()); - path += "/Debug/"; - path += name; - path += cmSystemTools::GetExecutableExtension(); - } - if(!cmSystemTools::FileExists(path.c_str())) - { - path = mf->GetRequiredDefinition("CMAKE_COMMAND"); - path = cmSystemTools::GetFilenamePath(path.c_str()); - path += "/Release/"; - path += name; - path += cmSystemTools::GetExecutableExtension(); - } -#else - // Only for bootstrap - path += mf->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH"); - path += "/"; - path += name; - path += cmSystemTools::GetExecutableExtension(); -#endif - } - return path; -} - -const char* cmake::GetCTestCommand() -{ - if ( this->CTestCommand.empty() ) - { - this->CTestCommand = this->FindCMakeProgram("ctest"); - } - if ( this->CTestCommand.empty() ) - { - cmSystemTools::Error("Cannot find the CTest executable"); - this->CTestCommand = "CTEST-COMMAND-NOT-FOUND"; - } - return this->CTestCommand.c_str(); -} - -const char* cmake::GetCPackCommand() -{ - if ( this->CPackCommand.empty() ) - { - this->CPackCommand = this->FindCMakeProgram("cpack"); - } - if ( this->CPackCommand.empty() ) - { - cmSystemTools::Error("Cannot find the CPack executable"); - this->CPackCommand = "CPACK-COMMAND-NOT-FOUND"; - } - return this->CPackCommand.c_str(); -} - - -const char* cmake::GetCMakeCommand() -{ - return this->CMakeCommand.c_str(); -} - - void cmake::MarkCliAsUsed(const std::string& variable) { this->UsedCliVariables[variable] = true; @@ -3169,484 +2144,16 @@ void cmake::GenerateGraphViz(const char* fileName) const #endif } - -//---------------------------------------------------------------------------- -int cmake::SymlinkLibrary(std::vector<std::string>& args) -{ - int result = 0; - std::string realName = args[2]; - std::string soName = args[3]; - std::string name = args[4]; - if(soName != realName) - { - if(!cmake::SymlinkInternal(realName, soName)) - { - cmSystemTools::ReportLastSystemError("cmake_symlink_library"); - result = 1; - } - } - if(name != soName) - { - if(!cmake::SymlinkInternal(soName, name)) - { - cmSystemTools::ReportLastSystemError("cmake_symlink_library"); - result = 1; - } - } - return result; -} - -//---------------------------------------------------------------------------- -int cmake::SymlinkExecutable(std::vector<std::string>& args) -{ - int result = 0; - std::string realName = args[2]; - std::string name = args[3]; - if(name != realName) - { - if(!cmake::SymlinkInternal(realName, name)) - { - cmSystemTools::ReportLastSystemError("cmake_symlink_executable"); - result = 1; - } - } - return result; -} - -//---------------------------------------------------------------------------- -bool cmake::SymlinkInternal(std::string const& file, std::string const& link) -{ - if(cmSystemTools::FileExists(link.c_str()) || - cmSystemTools::FileIsSymlink(link.c_str())) - { - cmSystemTools::RemoveFile(link.c_str()); - } -#if defined(_WIN32) && !defined(__CYGWIN__) - return cmSystemTools::CopyFileAlways(file.c_str(), link.c_str()); -#else - std::string linktext = cmSystemTools::GetFilenameName(file); - return cmSystemTools::CreateSymlink(linktext.c_str(), link.c_str()); -#endif -} - -//---------------------------------------------------------------------------- -#ifdef CMAKE_BUILD_WITH_CMAKE -int cmake::ExecuteEchoColor(std::vector<std::string>& args) -{ - // The arguments are - // argv[0] == <cmake-executable> - // argv[1] == cmake_echo_color - - bool enabled = true; - int color = cmsysTerminal_Color_Normal; - bool newline = true; - for(unsigned int i=2; i < args.size(); ++i) - { - if(args[i].find("--switch=") == 0) - { - // Enable or disable color based on the switch value. - std::string value = args[i].substr(9); - if(!value.empty()) - { - if(cmSystemTools::IsOn(value.c_str())) - { - enabled = true; - } - else - { - enabled = false; - } - } - } - else if(args[i] == "--normal") - { - color = cmsysTerminal_Color_Normal; - } - else if(args[i] == "--black") - { - color = cmsysTerminal_Color_ForegroundBlack; - } - else if(args[i] == "--red") - { - color = cmsysTerminal_Color_ForegroundRed; - } - else if(args[i] == "--green") - { - color = cmsysTerminal_Color_ForegroundGreen; - } - else if(args[i] == "--yellow") - { - color = cmsysTerminal_Color_ForegroundYellow; - } - else if(args[i] == "--blue") - { - color = cmsysTerminal_Color_ForegroundBlue; - } - else if(args[i] == "--magenta") - { - color = cmsysTerminal_Color_ForegroundMagenta; - } - else if(args[i] == "--cyan") - { - color = cmsysTerminal_Color_ForegroundCyan; - } - else if(args[i] == "--white") - { - color = cmsysTerminal_Color_ForegroundWhite; - } - else if(args[i] == "--bold") - { - color |= cmsysTerminal_Color_ForegroundBold; - } - else if(args[i] == "--no-newline") - { - newline = false; - } - else if(args[i] == "--newline") - { - newline = true; - } - else - { - // Color is enabled. Print with the current color. - cmSystemTools::MakefileColorEcho(color, args[i].c_str(), - newline, enabled); - } - } - - return 0; -} -#else -int cmake::ExecuteEchoColor(std::vector<std::string>&) -{ - return 1; -} -#endif - -//---------------------------------------------------------------------------- -int cmake::ExecuteLinkScript(std::vector<std::string>& args) -{ - // The arguments are - // argv[0] == <cmake-executable> - // argv[1] == cmake_link_script - // argv[2] == <link-script-name> - // argv[3] == --verbose=? - bool verbose = false; - if(args.size() >= 4) - { - if(args[3].find("--verbose=") == 0) - { - if(!cmSystemTools::IsOff(args[3].substr(10).c_str())) - { - verbose = true; - } - } - } - - // Allocate a process instance. - cmsysProcess* cp = cmsysProcess_New(); - if(!cp) - { - std::cerr << "Error allocating process instance in link script." - << std::endl; - return 1; - } - - // Children should share stdout and stderr with this process. - cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDOUT, 1); - cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDERR, 1); - - // Run the command lines verbatim. - cmsysProcess_SetOption(cp, cmsysProcess_Option_Verbatim, 1); - - // Read command lines from the script. - std::ifstream fin(args[2].c_str()); - if(!fin) - { - std::cerr << "Error opening link script \"" - << args[2] << "\"" << std::endl; - return 1; - } - - // Run one command at a time. - std::string command; - int result = 0; - while(result == 0 && cmSystemTools::GetLineFromStream(fin, command)) - { - // Skip empty command lines. - if(command.find_first_not_of(" \t") == command.npos) - { - continue; - } - - // Setup this command line. - const char* cmd[2] = {command.c_str(), 0}; - cmsysProcess_SetCommand(cp, cmd); - - // Report the command if verbose output is enabled. - if(verbose) - { - std::cout << command << std::endl; - } - - // Run the command and wait for it to exit. - cmsysProcess_Execute(cp); - cmsysProcess_WaitForExit(cp, 0); - - // Report failure if any. - switch(cmsysProcess_GetState(cp)) - { - case cmsysProcess_State_Exited: - { - int value = cmsysProcess_GetExitValue(cp); - if(value != 0) - { - result = value; - } - } - break; - case cmsysProcess_State_Exception: - std::cerr << "Error running link command: " - << cmsysProcess_GetExceptionString(cp) << std::endl; - result = 1; - break; - case cmsysProcess_State_Error: - std::cerr << "Error running link command: " - << cmsysProcess_GetErrorString(cp) << std::endl; - result = 2; - break; - default: - break; - }; - } - - // Free the process instance. - cmsysProcess_Delete(cp); - - // Return the final resulting return value. - return result; -} - -void cmake::DefineProperties(cmake *cm) -{ - cm->DefineProperty - ("REPORT_UNDEFINED_PROPERTIES", cmProperty::GLOBAL, - "If set, report any undefined properties to this file.", - "If this property is set to a filename then when CMake runs " - "it will report any properties or variables that were accessed " - "but not defined into the filename specified in this property." - ); - - cm->DefineProperty - ("TARGET_SUPPORTS_SHARED_LIBS", cmProperty::GLOBAL, - "Does the target platform support shared libraries.", - "TARGET_SUPPORTS_SHARED_LIBS is a boolean specifying whether the target " - "platform supports shared libraries. Basically all current general " - "general purpose OS do so, the exception are usually embedded systems " - "with no or special OSs."); - - cm->DefineProperty - ("TARGET_ARCHIVES_MAY_BE_SHARED_LIBS", cmProperty::GLOBAL, - "Set if shared libraries may be named like archives.", - "On AIX shared libraries may be named \"lib<name>.a\". " - "This property is set to true on such platforms."); - - cm->DefineProperty - ("FIND_LIBRARY_USE_LIB64_PATHS", cmProperty::GLOBAL, - "Whether FIND_LIBRARY should automatically search lib64 directories.", - "FIND_LIBRARY_USE_LIB64_PATHS is a boolean specifying whether the " - "FIND_LIBRARY command should automatically search the lib64 variant of " - "directories called lib in the search path when building 64-bit " - "binaries."); - cm->DefineProperty - ("FIND_LIBRARY_USE_OPENBSD_VERSIONING", cmProperty::GLOBAL, - "Whether FIND_LIBRARY should find OpenBSD-style shared libraries.", - "This property is a boolean specifying whether the FIND_LIBRARY " - "command should find shared libraries with OpenBSD-style versioned " - "extension: \".so.<major>.<minor>\". " - "The property is set to true on OpenBSD and false on other platforms."); - cm->DefineProperty - ("ENABLED_FEATURES", cmProperty::GLOBAL, - "List of features which are enabled during the CMake run.", - "List of features which are enabled during the CMake run. By default " - "it contains the names of all packages which were found. This is " - "determined using the <NAME>_FOUND variables. Packages which are " - "searched QUIET are not listed. A project can add its own features to " - "this list. " - "This property is used by the macros in FeatureSummary.cmake."); - cm->DefineProperty - ("DISABLED_FEATURES", cmProperty::GLOBAL, - "List of features which are disabled during the CMake run.", - "List of features which are disabled during the CMake run. By default " - "it contains the names of all packages which were not found. This is " - "determined using the <NAME>_FOUND variables. Packages which are " - "searched QUIET are not listed. A project can add its own features to " - "this list. " - "This property is used by the macros in FeatureSummary.cmake."); - cm->DefineProperty - ("PACKAGES_FOUND", cmProperty::GLOBAL, - "List of packages which were found during the CMake run.", - "List of packages which were found during the CMake run. Whether a " - "package has been found is determined using the <NAME>_FOUND variables."); - cm->DefineProperty - ("PACKAGES_NOT_FOUND", cmProperty::GLOBAL, - "List of packages which were not found during the CMake run.", - "List of packages which were not found during the CMake run. Whether a " - "package has been found is determined using the <NAME>_FOUND variables."); - - cm->DefineProperty( - "__CMAKE_DELETE_CACHE_CHANGE_VARS_", cmProperty::GLOBAL, - "Internal property", - "Used to detect compiler changes, Do not set."); - - cm->DefineProperty( - "DEBUG_CONFIGURATIONS", cmProperty::GLOBAL, - "Specify which configurations are for debugging.", - "The value must be a semi-colon separated list of configuration names. " - "Currently this property is used only by the target_link_libraries " - "command (see its documentation for details). " - "Additional uses may be defined in the future. " - "\n" - "This property must be set at the top level of the project and before " - "the first target_link_libraries command invocation. " - "If any entry in the list does not match a valid configuration for " - "the project the behavior is undefined."); - - cm->DefineProperty( - "GLOBAL_DEPENDS_DEBUG_MODE", cmProperty::GLOBAL, - "Enable global target dependency graph debug mode.", - "CMake automatically analyzes the global inter-target dependency graph " - "at the beginning of native build system generation. " - "This property causes it to display details of its analysis to stderr."); - - cm->DefineProperty( - "GLOBAL_DEPENDS_NO_CYCLES", cmProperty::GLOBAL, - "Disallow global target dependency graph cycles.", - "CMake automatically analyzes the global inter-target dependency graph " - "at the beginning of native build system generation. " - "It reports an error if the dependency graph contains a cycle that " - "does not consist of all STATIC library targets. " - "This property tells CMake to disallow all cycles completely, even " - "among static libraries."); - - cm->DefineProperty( - "ALLOW_DUPLICATE_CUSTOM_TARGETS", cmProperty::GLOBAL, - "Allow duplicate custom targets to be created.", - "Normally CMake requires that all targets built in a project have " - "globally unique logical names (see policy CMP0002). " - "This is necessary to generate meaningful project file names in " - "Xcode and VS IDE generators. " - "It also allows the target names to be referenced unambiguously.\n" - "Makefile generators are capable of supporting duplicate custom target " - "names. " - "For projects that care only about Makefile generators and do " - "not wish to support Xcode or VS IDE generators, one may set this " - "property to true to allow duplicate custom targets. " - "The property allows multiple add_custom_target command calls in " - "different directories to specify the same target name. " - "However, setting this property will cause non-Makefile generators " - "to produce an error and refuse to generate the project." - ); - - cm->DefineProperty - ("IN_TRY_COMPILE", cmProperty::GLOBAL, - "Read-only property that is true during a try-compile configuration.", - "True when building a project inside a TRY_COMPILE or TRY_RUN command."); - cm->DefineProperty - ("ENABLED_LANGUAGES", cmProperty::GLOBAL, - "Read-only property that contains the list of currently " - "enabled languages", - "Set to list of currently enabled languages."); - - cm->DefineProperty - ("RULE_LAUNCH_COMPILE", cmProperty::GLOBAL, - "Specify a launcher for compile rules.", - "Makefile generators prefix compiler commands with the given " - "launcher command line. " - "This is intended to allow launchers to intercept build problems " - "with high granularity. " - "Non-Makefile generators currently ignore this property."); - cm->DefineProperty - ("RULE_LAUNCH_LINK", cmProperty::GLOBAL, - "Specify a launcher for link rules.", - "Makefile generators prefix link and archive commands with the given " - "launcher command line. " - "This is intended to allow launchers to intercept build problems " - "with high granularity. " - "Non-Makefile generators currently ignore this property."); - cm->DefineProperty - ("RULE_LAUNCH_CUSTOM", cmProperty::GLOBAL, - "Specify a launcher for custom rules.", - "Makefile generators prefix custom commands with the given " - "launcher command line. " - "This is intended to allow launchers to intercept build problems " - "with high granularity. " - "Non-Makefile generators currently ignore this property."); - - cm->DefineProperty - ("RULE_MESSAGES", cmProperty::GLOBAL, - "Specify whether to report a message for each make rule.", - "This property specifies whether Makefile generators should add a " - "progress message describing what each build rule does. " - "If the property is not set the default is ON. " - "Set the property to OFF to disable granular messages and report only " - "as each target completes. " - "This is intended to allow scripted builds to avoid the build time " - "cost of detailed reports. " - "If a CMAKE_RULE_MESSAGES cache entry exists its value initializes " - "the value of this property. " - "Non-Makefile generators currently ignore this property."); - - cm->DefineProperty - ("USE_FOLDERS", cmProperty::GLOBAL, - "Use the FOLDER target property to organize targets into folders.", - "If not set, CMake treats this property as OFF by default. " - "CMake generators that are capable of organizing into a " - "hierarchy of folders use the values of the FOLDER target " - "property to name those folders. See also the documentation " - "for the FOLDER target property."); - - cm->DefineProperty - ("AUTOMOC_TARGETS_FOLDER", cmProperty::GLOBAL, - "Name of FOLDER for *_automoc targets that are added automatically by " - "CMake for targets for which AUTOMOC is enabled.", - "If not set, CMake uses the FOLDER property of the parent target as a " - "default value for this property. See also the documentation for the " - "FOLDER target property and the AUTOMOC target property."); - - cm->DefineProperty - ("PREDEFINED_TARGETS_FOLDER", cmProperty::GLOBAL, - "Name of FOLDER for targets that are added automatically by CMake.", - "If not set, CMake uses \"CMakePredefinedTargets\" as a default " - "value for this property. Targets such as INSTALL, PACKAGE and " - "RUN_TESTS will be organized into this FOLDER. See also the " - "documentation for the FOLDER target property."); - - // ================================================================ - // define variables as well - // ================================================================ - cmDocumentVariables::DefineVariables(cm); -} - - void cmake::DefineProperty(const char *name, cmProperty::ScopeType scope, const char *ShortDescription, const char *FullDescription, - bool chained, const char *docSection) + bool chained) { this->PropertyDefinitions[scope].DefineProperty(name,scope,ShortDescription, FullDescription, - docSection, chained); } -bool cmake::GetIsPropertyDefined(const char *name, - cmProperty::ScopeType scope) -{ - return this->PropertyDefinitions[scope].find(name) != - this->PropertyDefinitions[scope].end(); -} - cmPropertyDefinition *cmake ::GetPropertyDefinition(const char *name, cmProperty::ScopeType scope) @@ -3658,112 +2165,6 @@ cmPropertyDefinition *cmake return 0; } -void cmake::RecordPropertyAccess(const char *name, - cmProperty::ScopeType scope) -{ - this->AccessedProperties.insert - (std::pair<cmStdString,cmProperty::ScopeType>(name,scope)); -} - -void cmake::ReportUndefinedPropertyAccesses(const char *filename) -{ - if(!this->GlobalGenerator) - { return; } - FILE *progFile = fopen(filename,"w"); - if(!progFile) - { return; } - - // what are the enabled languages? - std::vector<std::string> enLangs; - this->GlobalGenerator->GetEnabledLanguages(enLangs); - - // Common configuration names. - // TODO: Compute current configuration(s). - std::vector<std::string> enConfigs; - enConfigs.push_back(""); - enConfigs.push_back("DEBUG"); - enConfigs.push_back("RELEASE"); - enConfigs.push_back("MINSIZEREL"); - enConfigs.push_back("RELWITHDEBINFO"); - - // take all the defined properties and add definitions for all the enabled - // languages - std::set<std::pair<cmStdString,cmProperty::ScopeType> > aliasedProperties; - std::map<cmProperty::ScopeType, cmPropertyDefinitionMap>::iterator i; - i = this->PropertyDefinitions.begin(); - for (;i != this->PropertyDefinitions.end(); ++i) - { - cmPropertyDefinitionMap::iterator j; - for (j = i->second.begin(); j != i->second.end(); ++j) - { - // TODO: What if both <LANG> and <CONFIG> appear? - if (j->first.find("<CONFIG>") != std::string::npos) - { - std::vector<std::string>::const_iterator k; - for (k = enConfigs.begin(); k != enConfigs.end(); ++k) - { - std::string tmp = j->first; - cmSystemTools::ReplaceString(tmp, "<CONFIG>", k->c_str()); - // add alias - aliasedProperties.insert - (std::pair<cmStdString,cmProperty::ScopeType>(tmp,i->first)); - } - } - if (j->first.find("<LANG>") != std::string::npos) - { - std::vector<std::string>::const_iterator k; - for (k = enLangs.begin(); k != enLangs.end(); ++k) - { - std::string tmp = j->first; - cmSystemTools::ReplaceString(tmp, "<LANG>", k->c_str()); - // add alias - aliasedProperties.insert - (std::pair<cmStdString,cmProperty::ScopeType>(tmp,i->first)); - } - } - } - } - - std::set<std::pair<cmStdString,cmProperty::ScopeType> >::const_iterator ap; - ap = this->AccessedProperties.begin(); - for (;ap != this->AccessedProperties.end(); ++ap) - { - if (!this->IsPropertyDefined(ap->first.c_str(),ap->second) && - aliasedProperties.find(std::pair<cmStdString,cmProperty::ScopeType> - (ap->first,ap->second)) == - aliasedProperties.end()) - { - const char *scopeStr = ""; - switch (ap->second) - { - case cmProperty::TARGET: - scopeStr = "TARGET"; - break; - case cmProperty::SOURCE_FILE: - scopeStr = "SOURCE_FILE"; - break; - case cmProperty::DIRECTORY: - scopeStr = "DIRECTORY"; - break; - case cmProperty::TEST: - scopeStr = "TEST"; - break; - case cmProperty::VARIABLE: - scopeStr = "VARIABLE"; - break; - case cmProperty::CACHED_VARIABLE: - scopeStr = "CACHED_VARIABLE"; - break; - default: - scopeStr = "unknown"; - break; - } - fprintf(progFile, "%s with scope %s\n", ap->first.c_str(), scopeStr); - } - } - fclose(progFile); -} - bool cmake::IsPropertyDefined(const char *name, cmProperty::ScopeType scope) { return this->PropertyDefinitions[scope].IsPropertyDefined(name); @@ -3991,7 +2392,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) // echo results to stdout if needed if (writeToStdout) { - FILE* fin = fopen(resultFile.c_str(), "r"); + FILE* fin = cmsys::SystemTools::Fopen(resultFile.c_str(), "r"); if(fin) { const int bufferSize = 4096; @@ -4025,9 +2426,9 @@ static bool cmakeCheckStampFile(const char* stampName) std::string stampDepends = stampName; stampDepends += ".depend"; #if defined(_WIN32) || defined(__CYGWIN__) - std::ifstream fin(stampDepends.c_str(), std::ios::in | std::ios::binary); + cmsys::ifstream fin(stampDepends.c_str(), std::ios::in | std::ios::binary); #else - std::ifstream fin(stampDepends.c_str(), std::ios::in); + cmsys::ifstream fin(stampDepends.c_str(), std::ios::in); #endif if(!fin) { @@ -4068,7 +2469,7 @@ static bool cmakeCheckStampFile(const char* stampName) { // TODO: Teach cmGeneratedFileStream to use a random temp file (with // multiple tries in unlikely case of conflict) and use that here. - std::ofstream stamp(stampTemp); + cmsys::ofstream stamp(stampTemp); stamp << "# CMake generation timestamp file for this directory.\n"; } if(cmSystemTools::RenameFile(stampTemp, stampName)) @@ -4098,7 +2499,7 @@ static bool cmakeCheckStampList(const char* stampList) << "is missing.\n"; return false; } - std::ifstream fin(stampList); + cmsys::ifstream fin(stampList); if(!fin) { std::cout << "CMake is re-running because generate.stamp.list " @@ -4119,356 +2520,6 @@ static bool cmakeCheckStampList(const char* stampList) } //---------------------------------------------------------------------------- -int cmake::WindowsCEEnvironment(const char* version, const std::string& name) -{ -#if defined(CMAKE_HAVE_VS_GENERATORS) - cmVisualStudioWCEPlatformParser parser(name.c_str()); - parser.ParseVersion(version); - if (parser.Found()) - { - std::cout << "@echo off" << std::endl; - std::cout << "echo Environment Selection: " << name << std::endl; - std::cout << "set PATH=" << parser.GetPathDirectories() << std::endl; - std::cout << "set INCLUDE=" << parser.GetIncludeDirectories() <<std::endl; - std::cout << "set LIB=" << parser.GetLibraryDirectories() <<std::endl; - return 0; - } -#else - (void)version; -#endif - - std::cerr << "Could not find " << name; - return -1; -} - -// For visual studio 2005 and newer manifest files need to be embedded into -// exe and dll's. This code does that in such a way that incremental linking -// still works. -int cmake::VisualStudioLink(std::vector<std::string>& args, int type) -{ - if(args.size() < 2) - { - return -1; - } - bool verbose = false; - if(cmSystemTools::GetEnv("VERBOSE")) - { - verbose = true; - } - std::vector<std::string> expandedArgs; - for(std::vector<std::string>::iterator i = args.begin(); - i != args.end(); ++i) - { - // check for nmake temporary files - if((*i)[0] == '@' && i->find("@CMakeFiles") != 0 ) - { - std::ifstream fin(i->substr(1).c_str()); - std::string line; - while(cmSystemTools::GetLineFromStream(fin, - line)) - { - cmSystemTools::ParseWindowsCommandLine(line.c_str(), expandedArgs); - } - } - else - { - expandedArgs.push_back(*i); - } - } - bool hasIncremental = false; - bool hasManifest = true; - for(std::vector<std::string>::iterator i = expandedArgs.begin(); - i != expandedArgs.end(); ++i) - { - if(cmSystemTools::Strucmp(i->c_str(), "/INCREMENTAL:YES") == 0) - { - hasIncremental = true; - } - if(cmSystemTools::Strucmp(i->c_str(), "/INCREMENTAL") == 0) - { - hasIncremental = true; - } - if(cmSystemTools::Strucmp(i->c_str(), "/MANIFEST:NO") == 0) - { - hasManifest = false; - } - } - if(hasIncremental && hasManifest) - { - if(verbose) - { - std::cout << "Visual Studio Incremental Link with embedded manifests\n"; - } - return cmake::VisualStudioLinkIncremental(expandedArgs, type, verbose); - } - if(verbose) - { - if(!hasIncremental) - { - std::cout << "Visual Studio Non-Incremental Link\n"; - } - else - { - std::cout << "Visual Studio Incremental Link without manifests\n"; - } - } - return cmake::VisualStudioLinkNonIncremental(expandedArgs, - type, hasManifest, verbose); -} - -int cmake::ParseVisualStudioLinkCommand(std::vector<std::string>& args, - std::vector<cmStdString>& command, - std::string& targetName) -{ - std::vector<std::string>::iterator i = args.begin(); - i++; // skip -E - i++; // skip vs_link_dll or vs_link_exe - command.push_back(*i); - i++; // move past link command - for(; i != args.end(); ++i) - { - command.push_back(*i); - if(i->find("/Fe") == 0) - { - targetName = i->substr(3); - } - if(i->find("/out:") == 0) - { - targetName = i->substr(5); - } - } - if(targetName.size() == 0 || command.size() == 0) - { - return -1; - } - return 0; -} - -bool cmake::RunCommand(const char* comment, - std::vector<cmStdString>& command, - bool verbose, - int* retCodeOut) -{ - if(verbose) - { - std::cout << comment << ":\n"; - for(std::vector<cmStdString>::iterator i = command.begin(); - i != command.end(); ++i) - { - std::cout << i->c_str() << " "; - } - std::cout << "\n"; - } - std::string output; - int retCode =0; - // use rc command to create .res file - cmSystemTools::RunSingleCommand(command, - &output, - &retCode, 0, cmSystemTools::OUTPUT_NONE); - // always print the output of the command, unless - // it is the dumb rc command banner, but if the command - // returned an error code then print the output anyway as - // the banner may be mixed with some other important information. - if(output.find("Resource Compiler Version") == output.npos - || retCode !=0) - { - std::cout << output; - } - // if retCodeOut is requested then always return true - // and set the retCodeOut to retCode - if(retCodeOut) - { - *retCodeOut = retCode; - return true; - } - if(retCode != 0) - { - std::cout << comment << " failed. with " << retCode << "\n"; - } - return retCode == 0; -} - -int cmake::VisualStudioLinkIncremental(std::vector<std::string>& args, - int type, bool verbose) -{ - // This follows the steps listed here: - // http://blogs.msdn.com/zakramer/archive/2006/05/22/603558.aspx - - // 1. Compiler compiles the application and generates the *.obj files. - // 2. An empty manifest file is generated if this is a clean build and if - // not the previous one is reused. - // 3. The resource compiler (rc.exe) compiles the *.manifest file to a - // *.res file. - // 4. Linker generates the binary (EXE or DLL) with the /incremental - // switch and embeds the dummy manifest file. The linker also generates - // the real manifest file based on the binaries that your binary depends - // on. - // 5. The manifest tool (mt.exe) is then used to generate the final - // manifest. - - // If the final manifest is changed, then 6 and 7 are run, if not - // they are skipped, and it is done. - - // 6. The resource compiler is invoked one more time. - // 7. Finally, the Linker does another incremental link, but since the - // only thing that has changed is the *.res file that contains the - // manifest it is a short link. - std::vector<cmStdString> linkCommand; - std::string targetName; - if(cmake::ParseVisualStudioLinkCommand(args, linkCommand, targetName) == -1) - { - return -1; - } - std::string manifestArg = "/MANIFESTFILE:"; - std::vector<cmStdString> rcCommand; - rcCommand.push_back(cmSystemTools::FindProgram("rc.exe")); - std::vector<cmStdString> mtCommand; - mtCommand.push_back(cmSystemTools::FindProgram("mt.exe")); - std::string tempManifest; - tempManifest = targetName; - tempManifest += ".intermediate.manifest"; - std::string resourceInputFile = targetName; - resourceInputFile += ".resource.txt"; - if(verbose) - { - std::cout << "Create " << resourceInputFile.c_str() << "\n"; - } - // Create input file for rc command - std::ofstream fout(resourceInputFile.c_str()); - if(!fout) - { - return -1; - } - std::string manifestFile = targetName; - manifestFile += ".embed.manifest"; - std::string fullPath= cmSystemTools::CollapseFullPath(manifestFile.c_str()); - fout << type << " /* CREATEPROCESS_MANIFEST_RESOURCE_ID " - "*/ 24 /* RT_MANIFEST */ " << "\"" << fullPath.c_str() << "\""; - fout.close(); - manifestArg += tempManifest; - // add the manifest arg to the linkCommand - linkCommand.push_back("/MANIFEST"); - linkCommand.push_back(manifestArg); - // if manifestFile is not yet created, create an - // empty one - if(!cmSystemTools::FileExists(manifestFile.c_str())) - { - if(verbose) - { - std::cout << "Create empty: " << manifestFile.c_str() << "\n"; - } - std::ofstream foutTmp(manifestFile.c_str()); - } - std::string resourceFile = manifestFile; - resourceFile += ".res"; - // add the resource file to the end of the link command - linkCommand.push_back(resourceFile); - std::string outputOpt = "/fo"; - outputOpt += resourceFile; - rcCommand.push_back(outputOpt); - rcCommand.push_back(resourceInputFile); - // Run rc command to create resource - if(!cmake::RunCommand("RC Pass 1", rcCommand, verbose)) - { - return -1; - } - // Now run the link command to link and create manifest - if(!cmake::RunCommand("LINK Pass 1", linkCommand, verbose)) - { - return -1; - } - // create mt command - std::string outArg("/out:"); - outArg+= manifestFile; - mtCommand.push_back("/nologo"); - mtCommand.push_back(outArg); - mtCommand.push_back("/notify_update"); - mtCommand.push_back("/manifest"); - mtCommand.push_back(tempManifest); - // now run mt.exe to create the final manifest file - int mtRet =0; - cmake::RunCommand("MT", mtCommand, verbose, &mtRet); - // if mt returns 0, then the manifest was not changed and - // we do not need to do another link step - if(mtRet == 0) - { - return 0; - } - // check for magic mt return value if mt returns the magic number - // 1090650113 then it means that it updated the manifest file and we need - // to do the final link. If mt has any value other than 0 or 1090650113 - // then there was some problem with the command itself and there was an - // error so return the error code back out of cmake so make can report it. - if(mtRet != 1090650113) - { - return mtRet; - } - // update the resource file with the new manifest from the mt command. - if(!cmake::RunCommand("RC Pass 2", rcCommand, verbose)) - { - return -1; - } - // Run the final incremental link that will put the new manifest resource - // into the file incrementally. - if(!cmake::RunCommand("FINAL LINK", linkCommand, verbose)) - { - return -1; - } - return 0; -} - -int cmake::VisualStudioLinkNonIncremental(std::vector<std::string>& args, - int type, - bool hasManifest, - bool verbose) -{ - std::vector<cmStdString> linkCommand; - std::string targetName; - if(cmake::ParseVisualStudioLinkCommand(args, linkCommand, targetName) == -1) - { - return -1; - } - // Run the link command as given - if (hasManifest) - { - linkCommand.push_back("/MANIFEST"); - } - if(!cmake::RunCommand("LINK", linkCommand, verbose)) - { - return -1; - } - if(!hasManifest) - { - return 0; - } - std::vector<cmStdString> mtCommand; - mtCommand.push_back(cmSystemTools::FindProgram("mt.exe")); - mtCommand.push_back("/nologo"); - mtCommand.push_back("/manifest"); - std::string manifestFile = targetName; - manifestFile += ".manifest"; - mtCommand.push_back(manifestFile); - std::string outresource = "/outputresource:"; - outresource += targetName; - outresource += ";#"; - if(type == 1) - { - outresource += "1"; - } - else if(type == 2) - { - outresource += "2"; - } - mtCommand.push_back(outresource); - // Now use the mt tool to embed the manifest into the exe or dll - if(!cmake::RunCommand("MT", mtCommand, verbose)) - { - return -1; - } - return 0; -} - -//---------------------------------------------------------------------------- void cmake::IssueMessage(cmake::MessageType t, std::string const& text, cmListFileBacktrace const& backtrace) { @@ -4489,6 +2540,15 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text, { msg << "CMake Debug Log"; } + else if(t == cmake::DEPRECATION_ERROR) + { + msg << "CMake Deprecation Error"; + isError = true; + } + else if (t == cmake::DEPRECATION_WARNING) + { + msg << "CMake Deprecation Warning"; + } else { msg << "CMake Warning"; @@ -4517,7 +2577,7 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text, // Add the message text. { msg << ":\n"; - cmDocumentationFormatterText formatter; + cmDocumentationFormatter formatter; formatter.SetIndent(" "); formatter.PrintFormatted(msg, text.c_str()); } @@ -4586,8 +2646,7 @@ int cmake::Build(const std::string& dir, const std::string& target, const std::string& config, const std::vector<std::string>& nativeOptions, - bool clean, - cmSystemTools::OutputOption outputflag) + bool clean) { if(!cmSystemTools::FileIsDirectory(dir.c_str())) { @@ -4612,25 +2671,19 @@ int cmake::Build(const std::string& dir, this->CreateGlobalGenerator(it.GetValue())); std::string output; std::string projName; - std::string makeProgram; if(!it.Find("CMAKE_PROJECT_NAME")) { std::cerr << "Error: could not find CMAKE_PROJECT_NAME in Cache\n"; return 1; } projName = it.GetValue(); - if(!it.Find("CMAKE_MAKE_PROGRAM")) - { - std::cerr << "Error: could not find CMAKE_MAKE_PROGRAM in Cache\n"; - return 1; - } - makeProgram = it.GetValue(); return gen->Build(0, dir.c_str(), projName.c_str(), target.c_str(), &output, - makeProgram.c_str(), - config.c_str(), clean, false, 0, outputflag, - 0, nativeOptions); + 0, + config.c_str(), clean, false, 0, + cmSystemTools::OUTPUT_PASSTHROUGH, + nativeOptions); } void cmake::WatchUnusedCli(const char* var) diff --git a/Source/cmake.h b/Source/cmake.h index a50c1ed..dfec55c 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -65,7 +65,9 @@ class cmake INTERNAL_ERROR, MESSAGE, WARNING, - LOG + LOG, + DEPRECATION_ERROR, + DEPRECATION_WARNING }; @@ -198,9 +200,6 @@ class cmake ///! get the cmCachemManager used by this invocation of cmake cmCacheManager *GetCacheManager() { return this->CacheManager; } - ///! set the cmake command this instance of cmake should use - void SetCMakeCommand(const char* cmd) { this->CMakeCommand = cmd; } - /** * Given a variable name, return its value (as a string). */ @@ -209,11 +208,6 @@ class cmake void AddCacheEntry(const char* key, const char* value, const char* helpString, int type); - /** - * Execute commands during the build process. Supports options such - * as echo, remove file etc. - */ - static int ExecuteCMakeCommand(std::vector<std::string>&); /** * Get the system information and write it to the file specified @@ -272,20 +266,7 @@ class cmake ///! Get the variable watch object cmVariableWatch* GetVariableWatch() { return this->VariableWatch; } - /** Get the documentation entries for the supported commands. - * If withCurrentCommands is true, the documentation for the - * recommended set of commands is included. - * If withCompatCommands is true, the documentation for discouraged - * (compatibility) commands is included. - * You probably don't want to set both to false. - */ - void GetCommandDocumentation(std::vector<cmDocumentationEntry>& entries, - bool withCurrentCommands = true, - bool withCompatCommands = true) const; - void GetPropertiesDocumentation(std::map<std::string, - cmDocumentationSection *>&); void GetGeneratorDocumentation(std::vector<cmDocumentationEntry>&); - void GetPolicyDocumentation(std::vector<cmDocumentationEntry>& entries); ///! Set/Get a property of this target file void SetProperty(const char *prop, const char *value); @@ -317,13 +298,6 @@ class cmake */ cmFileTimeComparison* GetFileComparison() { return this->FileComparison; } - /** - * Get the path to ctest - */ - const char* GetCTestCommand(); - const char* GetCPackCommand(); - const char* GetCMakeCommand(); - // Do we want debug output during the cmake run. bool GetDebugOutput() { return this->DebugOutput; } void SetDebugOutputOn(bool b) { this->DebugOutput = b;} @@ -346,10 +320,7 @@ class cmake void DefineProperty(const char *name, cmProperty::ScopeType scope, const char *ShortDescription, const char *FullDescription, - bool chain = false, - const char *variableGroup = 0); - - bool GetIsPropertyDefined(const char *name, cmProperty::ScopeType scope); + bool chain = false); // get property definition cmPropertyDefinition *GetPropertyDefinition @@ -363,17 +334,11 @@ class cmake debugging configurations.*/ std::vector<std::string> const& GetDebugConfigs(); - // record accesses of properties and variables - void RecordPropertyAccess(const char *name, cmProperty::ScopeType scope); - void ReportUndefinedPropertyAccesses(const char *filename); - - // Define the properties - static void DefineProperties(cmake *cm); + void SetCMakeEditCommand(std::string const& s) + { this->CMakeEditCommand = s; } + std::string const& GetCMakeEditCommand() const + { return this->CMakeEditCommand; } - void SetCMakeEditCommand(const char* s) - { - this->CMakeEditCommand = s; - } void SetSuppressDevWarnings(bool v) { this->SuppressDevWarnings = v; @@ -388,8 +353,7 @@ class cmake const std::string& target, const std::string& config, const std::vector<std::string>& nativeOptions, - bool clean, - cmSystemTools::OutputOption outputflag); + bool clean); void UnwatchUnusedCli(const char* var); void WatchUnusedCli(const char* var); @@ -450,33 +414,8 @@ protected: void GenerateGraphViz(const char* fileName) const; - static int SymlinkLibrary(std::vector<std::string>& args); - static int SymlinkExecutable(std::vector<std::string>& args); - static bool SymlinkInternal(std::string const& file, - std::string const& link); - static int ExecuteEchoColor(std::vector<std::string>& args); - static int ExecuteLinkScript(std::vector<std::string>& args); - static int WindowsCEEnvironment(const char* version, - const std::string& name); - static int VisualStudioLink(std::vector<std::string>& args, int type); - static int VisualStudioLinkIncremental(std::vector<std::string>& args, - int type, - bool verbose); - static int VisualStudioLinkNonIncremental(std::vector<std::string>& args, - int type, - bool hasManifest, - bool verbose); - static int ParseVisualStudioLinkCommand(std::vector<std::string>& args, - std::vector<cmStdString>& command, - std::string& targetName); - static bool RunCommand(const char* comment, - std::vector<cmStdString>& command, - bool verbose, - int* retCodeOut = 0); cmVariableWatch* VariableWatch; - ///! Find the full path to one of the cmake programs like ctest, cpack, etc. - std::string FindCMakeProgram(const char* name) const; private: cmake(const cmake&); // Not implemented. void operator=(const cmake&); // Not implemented. @@ -493,15 +432,12 @@ private: bool CheckSystemVars; std::map<cmStdString, bool> UsedCliVariables; std::string CMakeEditCommand; - std::string CMakeCommand; std::string CXXEnvironment; std::string CCEnvironment; std::string CheckBuildSystemArgument; std::string CheckStampFile; std::string CheckStampList; std::string VSSolutionFile; - std::string CTestCommand; - std::string CPackCommand; bool ClearBuildSystem; bool DebugTryCompile; cmFileTimeComparison* FileComparison; @@ -512,52 +448,12 @@ private: }; #define CMAKE_STANDARD_OPTIONS_TABLE \ - {"-C <initial-cache>", "Pre-load a script to populate the cache.", \ - "When cmake is first run in an empty build tree, it creates a " \ - "CMakeCache.txt file and populates it with customizable settings " \ - "for the project. This option may be used to specify a file from " \ - "which to load cache entries before the first pass through " \ - "the project's cmake listfiles. The loaded entries take priority " \ - "over the project's default values. The given file should be a CMake " \ - "script containing SET commands that use the CACHE option, " \ - "not a cache-format file."}, \ - {"-D <var>:<type>=<value>", "Create a cmake cache entry.", \ - "When cmake is first run in an empty build tree, it creates a " \ - "CMakeCache.txt file and populates it with customizable settings " \ - "for the project. This option may be used to specify a setting " \ - "that takes priority over the project's default value. The option " \ - "may be repeated for as many cache entries as desired."}, \ - {"-U <globbing_expr>", "Remove matching entries from CMake cache.", \ - "This option may be used to remove one or more variables from the " \ - "CMakeCache.txt file, globbing expressions using * and ? are supported. "\ - "The option may be repeated for as many cache entries as desired.\n" \ - "Use with care, you can make your CMakeCache.txt non-working."}, \ - {"-G <generator-name>", "Specify a build system generator.", \ - "CMake may support multiple native build systems on certain platforms. " \ - "A generator is responsible for generating a particular build " \ - "system. Possible generator names are specified in the Generators " \ - "section."},\ - {"-T <toolset-name>", "Specify toolset name if supported by generator.", \ - "Some CMake generators support a toolset name to be given to the " \ - "native build system to choose a compiler. " \ - "This is supported only on specific generators:\n" \ - " Visual Studio >= 10\n" \ - " Xcode >= 3.0\n" \ - "See native build system documentation for allowed toolset names."}, \ - {"-Wno-dev", "Suppress developer warnings.",\ - "Suppress warnings that are meant for the author"\ - " of the CMakeLists.txt files."},\ - {"-Wdev", "Enable developer warnings.",\ - "Enable warnings that are meant for the author"\ - " of the CMakeLists.txt files."} - - -#define CMAKE_STANDARD_INTRODUCTION \ - {0, \ - "CMake is a cross-platform build system generator. Projects " \ - "specify their build process with platform-independent CMake listfiles " \ - "included in each directory of a source tree with the name " \ - "CMakeLists.txt. " \ - "Users build a project by using CMake to generate a build system " \ - "for a native tool on their platform.", 0} + {"-C <initial-cache>", "Pre-load a script to populate the cache."}, \ + {"-D <var>:<type>=<value>", "Create a cmake cache entry."}, \ + {"-U <globbing_expr>", "Remove matching entries from CMake cache."}, \ + {"-G <generator-name>", "Specify a build system generator."},\ + {"-T <toolset-name>", "Specify toolset name if supported by generator."}, \ + {"-Wno-dev", "Suppress developer warnings."},\ + {"-Wdev", "Enable developer warnings."} + #endif diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 68d8339..fcaa127 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -17,43 +17,31 @@ #endif #include "cmake.h" +#include "cmcmd.h" #include "cmCacheManager.h" #include "cmListFileCache.h" -#include "cmakewizard.h" #include "cmSourceFile.h" #include "cmGlobalGenerator.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" +#include <cmsys/Encoding.hxx> #ifdef CMAKE_BUILD_WITH_CMAKE //---------------------------------------------------------------------------- -static const char * cmDocumentationName[][3] = +static const char * cmDocumentationName[][2] = { {0, - " cmake - Cross-Platform Makefile Generator.", 0}, - {0,0,0} + " cmake - Cross-Platform Makefile Generator."}, + {0,0} }; //---------------------------------------------------------------------------- -static const char * cmDocumentationUsage[][3] = +static const char * cmDocumentationUsage[][2] = { {0, " cmake [options] <path-to-source>\n" - " cmake [options] <path-to-existing-build>", 0}, - {0,0,0} -}; - -//---------------------------------------------------------------------------- -static const char * cmDocumentationDescription[][3] = -{ - {0, - "The \"cmake\" executable is the CMake command-line interface. It may " - "be used to configure projects in scripts. Project configuration " - "settings " - "may be specified on the command line with the -D option. The -i option " - "will cause cmake to interactively prompt for such settings.", 0}, - CMAKE_STANDARD_INTRODUCTION, - {0,0,0} + " cmake [options] <path-to-existing-build>"}, + {0,0} }; #define CMAKE_BUILD_OPTIONS \ @@ -62,209 +50,49 @@ static const char * cmDocumentationDescription[][3] = " --config <cfg> = For multi-configuration tools, choose <cfg>.\n" \ " --clean-first = Build target 'clean' first, then build.\n" \ " (To clean only, use --target 'clean'.)\n" \ - " --use-stderr = Don't merge stdout/stderr output and pass the\n" \ - " original stdout/stderr handles to the native\n" \ - " tool so it can use the capabilities of the\n" \ - " calling terminal (e.g. colored output).\n" \ + " --use-stderr = Ignored. Behavior is default in CMake >= 3.0.\n" \ " -- = Pass remaining options to the native tool.\n" //---------------------------------------------------------------------------- -static const char * cmDocumentationOptions[][3] = +static const char * cmDocumentationOptions[][2] = { CMAKE_STANDARD_OPTIONS_TABLE, - {"-E", "CMake command mode.", - "For true platform independence, CMake provides a list of commands " - "that can be used on all systems. Run with -E help for the usage " - "information. Commands available are: chdir, compare_files, copy, " - "copy_directory, copy_if_different, echo, echo_append, environment, " - "make_directory, md5sum, remove, remove_directory, rename, tar, time, " - "touch, touch_nocreate. In addition, some platform specific commands " - "are available. " - "On Windows: comspec, delete_regv, write_regv. " - "On UNIX: create_symlink."}, - {"-i", "Run in wizard mode.", - "Wizard mode runs cmake interactively without a GUI. The user is " - "prompted to answer questions about the project configuration. " - "The answers are used to set cmake cache values."}, - {"-L[A][H]", "List non-advanced cached variables.", - "List cache variables will run CMake and list all the variables from the " - "CMake cache that are not marked as INTERNAL or ADVANCED. This will " - "effectively display current CMake settings, which can then be changed " - "with -D option. Changing some of the variables may result in more " - "variables being created. If A is specified, then it will display also " - "advanced variables. If H is specified, it will also display help for " - "each variable."}, - {"--build <dir>", "Build a CMake-generated project binary tree.", - "This abstracts a native build tool's command-line interface with the " - "following options:\n" - CMAKE_BUILD_OPTIONS - "Run cmake --build with no options for quick help."}, - {"-N", "View mode only.", - "Only load the cache. Do not actually run configure and generate steps."}, - {"-P <file>", "Process script mode.", - "Process the given cmake file as a script written in the CMake language. " - "No configure or generate step is performed and the cache is not" - " modified. If variables are defined using -D, this must be done " - "before the -P argument."}, - {"--find-package", "Run in pkg-config like mode.", - "Search a package using find_package() and print the resulting flags " - "to stdout. This can be used to use cmake instead of pkg-config to find " - "installed libraries in plain Makefile-based projects or in " - "autoconf-based projects (via share/aclocal/cmake.m4)."}, + {"-E", "CMake command mode."}, + {"-L[A][H]", "List non-advanced cached variables."}, + {"--build <dir>", "Build a CMake-generated project binary tree."}, + {"-N", "View mode only."}, + {"-P <file>", "Process script mode."}, + {"--find-package", "Run in pkg-config like mode."}, {"--graphviz=[file]", "Generate graphviz of dependencies, see " - "CMakeGraphVizOptions.cmake for more.", - "Generate a graphviz input file that will contain all the library and " - "executable dependencies in the project. See the documentation for " - "CMakeGraphVizOptions.cmake for more details. "}, - {"--system-information [file]", "Dump information about this system.", - "Dump a wide range of information about the current system. If run " - "from the top of a binary tree for a CMake project it will dump " - "additional information such as the cache, log files etc."}, + "CMakeGraphVizOptions.cmake for more."}, + {"--system-information [file]", "Dump information about this system."}, {"--debug-trycompile", "Do not delete the try_compile build tree. Only " - "useful on one try_compile at a time.", - "Do not delete the files and directories created for try_compile calls. " - "This is useful in debugging failed try_compiles. It may however " - "change the results of the try-compiles as old junk from a previous " - "try-compile may cause a different test to either pass or fail " - "incorrectly. This option is best used for one try-compile at a time, " - "and only when debugging." }, - {"--debug-output", "Put cmake in a debug mode.", - "Print extra stuff during the cmake run like stack traces with " - "message(send_error ) calls."}, - {"--trace", "Put cmake in trace mode.", - "Print a trace of all calls made and from where with " - "message(send_error ) calls."}, - {"--warn-uninitialized", "Warn about uninitialized values.", - "Print a warning when an uninitialized variable is used."}, - {"--warn-unused-vars", "Warn about unused variables.", - "Find variables that are declared or set, but not used."}, - {"--no-warn-unused-cli", "Don't warn about command line options.", - "Don't find variables that are declared on the command line, but not " - "used."}, + "useful on one try_compile at a time."}, + {"--debug-output", "Put cmake in a debug mode."}, + {"--trace", "Put cmake in trace mode."}, + {"--warn-uninitialized", "Warn about uninitialized values."}, + {"--warn-unused-vars", "Warn about unused variables."}, + {"--no-warn-unused-cli", "Don't warn about command line options."}, {"--check-system-vars", "Find problems with variable usage in system " - "files.", "Normally, unused and uninitialized variables are searched for " - "only in CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR. This flag tells CMake to " - "warn about other files as well."}, - {"--help-command cmd [file]", "Print help for a single command and exit.", - "Full documentation specific to the given command is displayed. " - "If a file is specified, the documentation is written into and the output " - "format is determined depending on the filename suffix. Supported are man " - "page, HTML, DocBook and plain text."}, - {"--help-command-list [file]", "List available listfile commands and exit.", - "The list contains all commands for which help may be obtained by using " - "the --help-command argument followed by a command name. " - "If a file is specified, the documentation is written into and the output " - "format is determined depending on the filename suffix. Supported are man " - "page, HTML, DocBook and plain text."}, - {"--help-commands [file]", "Print help for all commands and exit.", - "Full documentation specific for all current commands is displayed." - "If a file is specified, the documentation is written into and the output " - "format is determined depending on the filename suffix. Supported are man " - "page, HTML, DocBook and plain text."}, - {"--help-compatcommands [file]", "Print help for compatibility commands. ", - "Full documentation specific for all compatibility commands is displayed." - "If a file is specified, the documentation is written into and the output " - "format is determined depending on the filename suffix. Supported are man " - "page, HTML, DocBook and plain text."}, - {"--help-module module [file]", "Print help for a single module and exit.", - "Full documentation specific to the given module is displayed." - "If a file is specified, the documentation is written into and the output " - "format is determined depending on the filename suffix. Supported are man " - "page, HTML, DocBook and plain text."}, - {"--help-module-list [file]", "List available modules and exit.", - "The list contains all modules for which help may be obtained by using " - "the --help-module argument followed by a module name. " - "If a file is specified, the documentation is written into and the output " - "format is determined depending on the filename suffix. Supported are man " - "page, HTML, DocBook and plain text."}, - {"--help-modules [file]", "Print help for all modules and exit.", - "Full documentation for all modules is displayed. " - "If a file is specified, the documentation is written into and the output " - "format is determined depending on the filename suffix. Supported are man " - "page, HTML, DocBook and plain text."}, - {"--help-custom-modules [file]" , "Print help for all custom modules and " - "exit.", - "Full documentation for all custom modules is displayed. " - "If a file is specified, the documentation is written into and the output " - "format is determined depending on the filename suffix. Supported are man " - "page, HTML, DocBook and plain text."}, - {"--help-policy cmp [file]", - "Print help for a single policy and exit.", - "Full documentation specific to the given policy is displayed." - "If a file is specified, the documentation is written into and the output " - "format is determined depending on the filename suffix. Supported are man " - "page, HTML, DocBook and plain text."}, - {"--help-policies [file]", "Print help for all policies and exit.", - "Full documentation for all policies is displayed." - "If a file is specified, the documentation is written into and the output " - "format is determined depending on the filename suffix. Supported are man " - "page, HTML, DocBook and plain text."}, - {"--help-property prop [file]", - "Print help for a single property and exit.", - "Full documentation specific to the given property is displayed." - "If a file is specified, the documentation is written into and the output " - "format is determined depending on the filename suffix. Supported are man " - "page, HTML, DocBook and plain text."}, - {"--help-property-list [file]", "List available properties and exit.", - "The list contains all properties for which help may be obtained by using " - "the --help-property argument followed by a property name. If a file is " - "specified, the help is written into it." - "If a file is specified, the documentation is written into and the output " - "format is determined depending on the filename suffix. Supported are man " - "page, HTML, DocBook and plain text."}, - {"--help-properties [file]", "Print help for all properties and exit.", - "Full documentation for all properties is displayed." - "If a file is specified, the documentation is written into and the output " - "format is determined depending on the filename suffix. Supported are man " - "page, HTML, DocBook and plain text."}, - {"--help-variable var [file]", - "Print help for a single variable and exit.", - "Full documentation specific to the given variable is displayed." - "If a file is specified, the documentation is written into and the output " - "format is determined depending on the filename suffix. Supported are man " - "page, HTML, DocBook and plain text."}, - {"--help-variable-list [file]", "List documented variables and exit.", - "The list contains all variables for which help may be obtained by using " - "the --help-variable argument followed by a variable name. If a file is " - "specified, the help is written into it." - "If a file is specified, the documentation is written into and the output " - "format is determined depending on the filename suffix. Supported are man " - "page, HTML, DocBook and plain text."}, - {"--help-variables [file]", "Print help for all variables and exit.", - "Full documentation for all variables is displayed." - "If a file is specified, the documentation is written into and the output " - "format is determined depending on the filename suffix. Supported are man " - "page, HTML, DocBook and plain text."}, - {0,0,0} + "files."}, + {0,0} }; -//---------------------------------------------------------------------------- -static const char * cmDocumentationSeeAlso[][3] = -{ - {0, "ccmake", 0}, - {0, "cpack", 0}, - {0, "ctest", 0}, - {0, "cmakecommands", 0}, - {0, "cmakecompat", 0}, - {0, "cmakemodules", 0}, - {0, "cmakeprops", 0}, - {0, "cmakevars", 0}, - {0, 0, 0} -}; +#endif -//---------------------------------------------------------------------------- -static const char * cmDocumentationNOTE[][3] = +static int do_command(int ac, char const* const* av) { - {0, - "CMake no longer configures a project when run with no arguments. " - "In order to configure the project in the current directory, run\n" - " cmake .", 0}, - {0,0,0} -}; -#endif + std::vector<std::string> args; + args.push_back(av[0]); + for(int i = 2; i < ac; ++i) + { + args.push_back(av[i]); + } + return cmcmd::ExecuteCMakeCommand(args); +} -int do_cmake(int ac, char** av); -static int do_build(int ac, char** av); +int do_cmake(int ac, char const* const* av); +static int do_build(int ac, char const* const* av); static cmMakefile* cmakemainGetMakefile(void *clientdata) { @@ -332,13 +160,25 @@ static void cmakemainProgressCallback(const char *m, float prog, } -int main(int ac, char** av) +int main(int ac, char const* const* av) { + cmsys::Encoding::CommandLineArguments args = + cmsys::Encoding::CommandLineArguments::Main(ac, av); + ac = args.argc(); + av = args.argv(); + cmSystemTools::EnableMSVCDebugHook(); - cmSystemTools::FindExecutableDirectory(av[0]); - if(ac > 1 && strcmp(av[1], "--build") == 0) + cmSystemTools::FindCMakeResources(av[0]); + if(ac > 1) { - return do_build(ac, av); + if(strcmp(av[1], "--build") == 0) + { + return do_build(ac, av); + } + else if(strcmp(av[1], "-E") == 0) + { + return do_command(ac, av); + } } int ret = do_cmake(ac, av); #ifdef CMAKE_BUILD_WITH_CMAKE @@ -347,7 +187,7 @@ int main(int ac, char** av) return ret; } -int do_cmake(int ac, char** av) +int do_cmake(int ac, char const* const* av) { if ( cmSystemTools::GetCurrentWorkingDirectory().size() == 0 ) { @@ -359,12 +199,11 @@ int do_cmake(int ac, char** av) #ifdef CMAKE_BUILD_WITH_CMAKE cmDocumentation doc; doc.addCMakeStandardDocSections(); - if(doc.CheckOptions(ac, av, "-E")) + if(doc.CheckOptions(ac, av)) { // Construct and print requested documentation. cmake hcm; hcm.AddCMakePaths(); - doc.SetCMakeRoot(hcm.GetCacheDefinition("CMAKE_ROOT")); // the command line args are processed here so that you can do // -DCMAKE_MODULE_PATH=/some/path and have this value accessible here @@ -374,57 +213,18 @@ int do_cmake(int ac, char** av) args.push_back(av[i]); } hcm.SetCacheArgs(args); - const char* modulePath = hcm.GetCacheDefinition("CMAKE_MODULE_PATH"); - if (modulePath) - { - doc.SetCMakeModulePath(modulePath); - } - std::vector<cmDocumentationEntry> commands; - std::vector<cmDocumentationEntry> policies; - std::vector<cmDocumentationEntry> compatCommands; std::vector<cmDocumentationEntry> generators; - std::map<std::string,cmDocumentationSection *> propDocs; - hcm.GetPolicyDocumentation(policies); - hcm.GetCommandDocumentation(commands, true, false); - hcm.GetCommandDocumentation(compatCommands, false, true); - hcm.GetPropertiesDocumentation(propDocs); hcm.GetGeneratorDocumentation(generators); doc.SetName("cmake"); doc.SetSection("Name",cmDocumentationName); doc.SetSection("Usage",cmDocumentationUsage); - doc.SetSection("Description",cmDocumentationDescription); doc.AppendSection("Generators",generators); doc.PrependSection("Options",cmDocumentationOptions); - doc.SetSection("Commands",commands); - doc.SetSection("Policies",policies); - doc.AppendSection("Compatibility Commands",compatCommands); - doc.SetSections(propDocs); - - cmDocumentationEntry e; - e.Brief = - "variables defined by cmake, that give information about the project, " - "and cmake"; - doc.PrependSection("Variables that Provide Information",e); - - doc.SetSeeAlsoList(cmDocumentationSeeAlso); - int result = doc.PrintRequestedDocumentation(std::cout)? 0:1; - - // If we were run with no arguments, but a CMakeLists.txt file - // exists, the user may have been trying to use the old behavior - // of cmake to build a project in-source. Print a message - // explaining the change to standard error and return an error - // condition in case the program is running from a script. - if((ac == 1) && cmSystemTools::FileExists("CMakeLists.txt")) - { - doc.ClearSections(); - doc.SetSection("NOTE", cmDocumentationNOTE); - doc.Print(cmDocumentation::UsageForm, 0, std::cerr); - return 1; - } - return result; + + return doc.PrintRequestedDocumentation(std::cout)? 0:1; } #else if ( ac == 1 ) @@ -436,9 +236,7 @@ int do_cmake(int ac, char** av) } #endif - bool wiz = false; bool sysinfo = false; - bool command = false; bool list_cached = false; bool list_all_cached = false; bool list_help = false; @@ -447,43 +245,41 @@ int do_cmake(int ac, char** av) std::vector<std::string> args; for(int i =0; i < ac; ++i) { - if(!command && strcmp(av[i], "-i") == 0) + if(strcmp(av[i], "-i") == 0) { - wiz = true; + std::cerr << + "The \"cmake -i\" wizard mode is no longer supported.\n" + "Use the -D option to set cache values on the command line.\n" + "Use cmake-gui or ccmake for an interactive dialog.\n"; + return 1; } - else if(!command && strcmp(av[i], "--system-information") == 0) + else if(strcmp(av[i], "--system-information") == 0) { sysinfo = true; } - // if command has already been set, then - // do not eat the -E - else if (!command && strcmp(av[i], "-E") == 0) - { - command = true; - } - else if (!command && strcmp(av[i], "-N") == 0) + else if (strcmp(av[i], "-N") == 0) { view_only = true; } - else if (!command && strcmp(av[i], "-L") == 0) + else if (strcmp(av[i], "-L") == 0) { list_cached = true; } - else if (!command && strcmp(av[i], "-LA") == 0) + else if (strcmp(av[i], "-LA") == 0) { list_all_cached = true; } - else if (!command && strcmp(av[i], "-LH") == 0) + else if (strcmp(av[i], "-LH") == 0) { list_cached = true; list_help = true; } - else if (!command && strcmp(av[i], "-LAH") == 0) + else if (strcmp(av[i], "-LAH") == 0) { list_all_cached = true; list_help = true; } - else if (!command && strncmp(av[i], "-P", strlen("-P")) == 0) + else if (cmHasLiteralPrefix(av[i], "-P")) { if ( i == ac -1 ) { @@ -497,8 +293,7 @@ int do_cmake(int ac, char** av) args.push_back(av[i]); } } - else if (!command && strncmp(av[i], "--find-package", - strlen("--find-package")) == 0) + else if (cmHasLiteralPrefix(av[i], "--find-package")) { workingMode = cmake::FIND_PACKAGE_MODE; args.push_back(av[i]); @@ -508,16 +303,6 @@ int do_cmake(int ac, char** av) args.push_back(av[i]); } } - if(command) - { - int ret = cmake::ExecuteCMakeCommand(args); - return ret; - } - if (wiz) - { - cmakewizard wizard; - return wizard.RunWizard(args); - } if (sysinfo) { cmake cm; @@ -573,7 +358,7 @@ int do_cmake(int ac, char** av) } //---------------------------------------------------------------------------- -static int do_build(int ac, char** av) +static int do_build(int ac, char const* const* av) { #ifndef CMAKE_BUILD_WITH_CMAKE std::cerr << "This cmake does not support --build\n"; @@ -584,7 +369,6 @@ static int do_build(int ac, char** av) std::string dir; std::vector<std::string> nativeOptions; bool clean = false; - cmSystemTools::OutputOption outputflag = cmSystemTools::OUTPUT_MERGE; enum Doing { DoingNone, DoingDir, DoingTarget, DoingConfig, DoingNative}; Doing doing = DoingDir; @@ -609,7 +393,7 @@ static int do_build(int ac, char** av) } else if(strcmp(av[i], "--use-stderr") == 0) { - outputflag = cmSystemTools::OUTPUT_PASSTHROUGH; + /* tolerate legacy option */ } else if(strcmp(av[i], "--") == 0) { @@ -656,6 +440,6 @@ static int do_build(int ac, char** av) } cmake cm; - return cm.Build(dir, target, config, nativeOptions, clean, outputflag); + return cm.Build(dir, target, config, nativeOptions, clean); #endif } diff --git a/Source/cmaketest.h.in b/Source/cmaketest.h.in deleted file mode 100644 index aada52d..0000000 --- a/Source/cmaketest.h.in +++ /dev/null @@ -1,16 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#define CMAKE_BINARY_DIR "${CMake_BINARY_DIR}" -#define EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}" -#define MAKEPROGRAM "${MAKEPROGRAM}" -#define CMAKE_GENERATOR "${CMAKE_GENERATOR}" -#define DART_MAKECOMMAND "${MAKECOMMAND}" diff --git a/Source/cmakewizard.cxx b/Source/cmakewizard.cxx deleted file mode 100644 index bac403a..0000000 --- a/Source/cmakewizard.cxx +++ /dev/null @@ -1,155 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#include "cmakewizard.h" -#include "cmake.h" -#include "cmCacheManager.h" - -cmakewizard::cmakewizard() -{ - this->ShowAdvanced = false; -} - - -void cmakewizard::AskUser(const char* key, - cmCacheManager::CacheIterator& iter) -{ - printf("Variable Name: %s\n", key); - const char* helpstring = iter.GetProperty("HELPSTRING"); - printf("Description: %s\n", (helpstring?helpstring:"(none)")); - printf("Current Value: %s\n", iter.GetValue()); - printf("New Value (Enter to keep current value): "); - char buffer[4096]; - if(!fgets(buffer, static_cast<int>(sizeof(buffer) - 1), stdin)) - { - buffer[0] = 0; - } - - if(strlen(buffer) > 0) - { - std::string sbuffer = buffer; - std::string::size_type pos = sbuffer.find_last_not_of(" \n\r\t"); - std::string value = ""; - if ( pos != std::string::npos ) - { - value = sbuffer.substr(0, pos+1); - } - - if ( value.size() > 0 ) - { - if(iter.GetType() == cmCacheManager::PATH || - iter.GetType() == cmCacheManager::FILEPATH) - { - cmSystemTools::ConvertToUnixSlashes(value); - } - if(iter.GetType() == cmCacheManager::BOOL) - { - if(!cmSystemTools::IsOn(value.c_str())) - { - value = "OFF"; - } - } - iter.SetValue(value.c_str()); - } - } - printf("\n"); -} - -bool cmakewizard::AskAdvanced() -{ - printf("Would you like to see advanced options? [No]:"); - char buffer[4096]; - if(!fgets(buffer, static_cast<int>(sizeof(buffer) - 1), stdin)) - { - buffer[0] = 0; - } - else if(buffer[0] == 'y' || buffer[0] == 'Y') - { - return true; - } - return false; -} - - -void cmakewizard::ShowMessage(const char* m) -{ - printf("%s\n", m); -} - - - -int cmakewizard::RunWizard(std::vector<std::string> const& args) -{ - this->ShowAdvanced = this->AskAdvanced(); - cmSystemTools::DisableRunCommandOutput(); - cmake make; - make.SetArgs(args); - make.SetCMakeCommand(args[0].c_str()); - make.LoadCache(); - make.SetCacheArgs(args); - std::map<cmStdString, cmStdString> askedCache; - bool asked = false; - // continue asking questions until no new questions are asked - do - { - asked = false; - // run cmake - this->ShowMessage( - "Please wait while cmake processes CMakeLists.txt files....\n"); - - make.Configure(); - this->ShowMessage("\n"); - // load the cache from disk - cmCacheManager *cachem = make.GetCacheManager(); - cachem->LoadCache(make.GetHomeOutputDirectory()); - cmCacheManager::CacheIterator i = cachem->NewIterator(); - // iterate over all entries in the cache - for(;!i.IsAtEnd(); i.Next()) - { - std::string key = i.GetName(); - if( i.GetType() == cmCacheManager::INTERNAL || - i.GetType() == cmCacheManager::STATIC || - i.GetType() == cmCacheManager::UNINITIALIZED ) - { - continue; - } - if(askedCache.count(key)) - { - std::string& e = askedCache.find(key)->second; - if(e != i.GetValue()) - { - if(this->ShowAdvanced || !i.GetPropertyAsBool("ADVANCED")) - { - this->AskUser(key.c_str(), i); - asked = true; - } - } - } - else - { - if(this->ShowAdvanced || !i.GetPropertyAsBool("ADVANCED")) - { - this->AskUser(key.c_str(), i); - asked = true; - } - } - askedCache[key] = i.GetValue(); - } - cachem->SaveCache(make.GetHomeOutputDirectory()); - } - while(asked); - if(make.Generate() == 0) - { - this->ShowMessage("CMake complete, run make to build project.\n"); - return 0; - } - return 1; -} diff --git a/Source/cmakewizard.h b/Source/cmakewizard.h deleted file mode 100644 index 0c8dba9..0000000 --- a/Source/cmakewizard.h +++ /dev/null @@ -1,42 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ - - -#include "cmMakefile.h" - -class cmakewizard -{ -public: - cmakewizard(); - virtual ~cmakewizard() {} - /** - * Prompt the user to see if they want to see advanced entries. - */ - virtual bool AskAdvanced(); - - /** - * Prompt the User for a new value for key, the answer is put in entry. - */ - virtual void AskUser(const char* key, cmCacheManager::CacheIterator& iter); - ///! Show a message to wait for cmake to run. - virtual void ShowMessage(const char*); - - /** - * Run cmake in wizard mode. This will coninue to ask the user questions - * until there are no more entries in the cache. - */ - int RunWizard(std::vector<std::string>const& args); - -private: - bool ShowAdvanced; -}; - diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx index 8571557..faa5fa7 100644 --- a/Source/cmcldeps.cxx +++ b/Source/cmcldeps.cxx @@ -23,6 +23,7 @@ #include <windows.h> #include <sstream> #include <cmSystemTools.h> +#include <cmsys/Encoding.hxx> // We don't want any wildcard expansion. // See http://msdn.microsoft.com/en-us/library/zay8tzh6(v=vs.85).aspx @@ -100,7 +101,7 @@ static std::string getArg(std::string& cmdline) { return ret; } -static void parseCommandLine(LPTSTR wincmdline, +static void parseCommandLine(LPWSTR wincmdline, std::string& lang, std::string& srcfile, std::string& dfile, @@ -109,7 +110,7 @@ static void parseCommandLine(LPTSTR wincmdline, std::string& clpath, std::string& binpath, std::string& rest) { - std::string cmdline(wincmdline); + std::string cmdline = cmsys::Encoding::ToNarrow(wincmdline); /* self */ getArg(cmdline); lang = getArg(cmdline); srcfile = getArg(cmdline); @@ -138,7 +139,7 @@ static void outputDepFile(const std::string& dfile, const std::string& objfile, std::sort(incs.begin(), incs.end()); incs.erase(std::unique(incs.begin(), incs.end()), incs.end()); - FILE* out = fopen(dfile.c_str(), "wb"); + FILE* out = cmsys::SystemTools::Fopen(dfile.c_str(), "wb"); // FIXME should this be fatal or not? delete obj? delete d? if (!out) @@ -247,7 +248,7 @@ int main() { // the same command line verbatim. std::string lang, srcfile, dfile, objfile, prefix, cl, binpath, rest; - parseCommandLine(GetCommandLine(), lang, srcfile, dfile, objfile, + parseCommandLine(GetCommandLineW(), lang, srcfile, dfile, objfile, prefix, cl, binpath, rest); // needed to suppress filename output of msvc tools diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx new file mode 100644 index 0000000..7891969 --- /dev/null +++ b/Source/cmcmd.cxx @@ -0,0 +1,1366 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmcmd.h" +#include "cmMakefile.h" +#include "cmLocalGenerator.h" +#include "cmGlobalGenerator.h" +#include "cmQtAutoGenerators.h" +#include "cmVersion.h" + +#if defined(CMAKE_BUILD_WITH_CMAKE) +# include "cmDependsFortran.h" // For -E cmake_copy_f90_mod callback. +# include <cmsys/Terminal.h> +#endif + +#include <cmsys/Directory.hxx> +#include <cmsys/Process.h> +#include <cmsys/FStream.hxx> + +#if defined(CMAKE_HAVE_VS_GENERATORS) +#include "cmCallVisualStudioMacro.h" +#include "cmVisualStudioWCEPlatformParser.h" +#endif + +#include <time.h> + +#include <stdlib.h> // required for atoi + +void CMakeCommandUsage(const char* program) +{ + cmOStringStream errorStream; + +#ifdef CMAKE_BUILD_WITH_CMAKE + errorStream + << "cmake version " << cmVersion::GetCMakeVersion() << "\n"; +#else + errorStream + << "cmake bootstrap\n"; +#endif + // If you add new commands, change here, + // and in cmakemain.cxx in the options table + errorStream + << "Usage: " << program << " -E [command] [arguments ...]\n" + << "Available commands: \n" + << " chdir dir cmd [args]... - run command in a given directory\n" + << " compare_files file1 file2 - check if file1 is same as file2\n" + << " copy file destination - copy file to destination (either file " + "or directory)\n" + << " copy_directory source destination - copy directory 'source' " + "content to directory 'destination'\n" + << " copy_if_different in-file out-file - copy file if input has " + "changed\n" + << " echo [string]... - displays arguments as text\n" + << " echo_append [string]... - displays arguments as text but no new " + "line\n" + << " environment - display the current environment\n" + << " make_directory dir - create a directory\n" + << " md5sum file1 [...] - compute md5sum of files\n" + << " remove [-f] file1 file2 ... - remove the file(s), use -f to force " + "it\n" + << " remove_directory dir - remove a directory and its contents\n" + << " rename oldname newname - rename a file or directory " + "(on one volume)\n" + << " tar [cxt][vfz][cvfj] file.tar [file/dir1 file/dir2 ...]\n" + << " - create or extract a tar or zip archive\n" + << " time command [args] ... - run command and return elapsed time\n" + << " touch file - touch a file.\n" + << " touch_nocreate file - touch a file but do not create it.\n" +#if defined(_WIN32) && !defined(__CYGWIN__) + << "Available on Windows only:\n" + << " delete_regv key - delete registry value\n" + << " env_vs8_wince sdkname - displays a batch file which sets the " + "environment for the provided Windows CE SDK installed in VS2005\n" + << " env_vs9_wince sdkname - displays a batch file which sets the " + "environment for the provided Windows CE SDK installed in VS2008\n" + << " write_regv key value - write registry value\n" +#else + << "Available on UNIX only:\n" + << " create_symlink old new - create a symbolic link new -> old\n" +#endif + ; + + cmSystemTools::Error(errorStream.str().c_str()); +} + +int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) +{ + // IF YOU ADD A NEW COMMAND, DOCUMENT IT ABOVE and in cmakemain.cxx + if (args.size() > 1) + { + // Copy file + if (args[1] == "copy" && args.size() == 4) + { + if(!cmSystemTools::cmCopyFile(args[2].c_str(), args[3].c_str())) + { + std::cerr << "Error copying file \"" << args[2].c_str() + << "\" to \"" << args[3].c_str() << "\".\n"; + return 1; + } + return 0; + } + + // Copy file if different. + if (args[1] == "copy_if_different" && args.size() == 4) + { + if(!cmSystemTools::CopyFileIfDifferent(args[2].c_str(), + args[3].c_str())) + { + std::cerr << "Error copying file (if different) from \"" + << args[2].c_str() << "\" to \"" << args[3].c_str() + << "\".\n"; + return 1; + } + return 0; + } + + // Copy directory content + if (args[1] == "copy_directory" && args.size() == 4) + { + if(!cmSystemTools::CopyADirectory(args[2].c_str(), args[3].c_str())) + { + std::cerr << "Error copying directory from \"" + << args[2].c_str() << "\" to \"" << args[3].c_str() + << "\".\n"; + return 1; + } + return 0; + } + + // Rename a file or directory + if (args[1] == "rename" && args.size() == 4) + { + if(!cmSystemTools::RenameFile(args[2].c_str(), args[3].c_str())) + { + std::string e = cmSystemTools::GetLastSystemError(); + std::cerr << "Error renaming from \"" + << args[2].c_str() << "\" to \"" << args[3].c_str() + << "\": " << e << "\n"; + return 1; + } + return 0; + } + + // Compare files + if (args[1] == "compare_files" && args.size() == 4) + { + if(cmSystemTools::FilesDiffer(args[2].c_str(), args[3].c_str())) + { + std::cerr << "Files \"" + << args[2].c_str() << "\" to \"" << args[3].c_str() + << "\" are different.\n"; + return 1; + } + return 0; + } + + // Echo string + else if (args[1] == "echo" ) + { + unsigned int cc; + const char* space = ""; + for ( cc = 2; cc < args.size(); cc ++ ) + { + std::cout << space << args[cc]; + space = " "; + } + std::cout << std::endl; + return 0; + } + + // Echo string no new line + else if (args[1] == "echo_append" ) + { + unsigned int cc; + const char* space = ""; + for ( cc = 2; cc < args.size(); cc ++ ) + { + std::cout << space << args[cc]; + space = " "; + } + return 0; + } + +#if defined(CMAKE_BUILD_WITH_CMAKE) + // Command to create a symbolic link. Fails on platforms not + // supporting them. + else if (args[1] == "environment" ) + { + std::vector<std::string> env = cmSystemTools::GetEnvironmentVariables(); + std::vector<std::string>::iterator it; + for ( it = env.begin(); it != env.end(); ++ it ) + { + std::cout << it->c_str() << std::endl; + } + return 0; + } +#endif + + else if (args[1] == "make_directory" && args.size() == 3) + { + if(!cmSystemTools::MakeDirectory(args[2].c_str())) + { + std::cerr << "Error making directory \"" << args[2].c_str() + << "\".\n"; + return 1; + } + return 0; + } + + else if (args[1] == "remove_directory" && args.size() == 3) + { + if(cmSystemTools::FileIsDirectory(args[2].c_str()) && + !cmSystemTools::RemoveADirectory(args[2].c_str())) + { + std::cerr << "Error removing directory \"" << args[2].c_str() + << "\".\n"; + return 1; + } + return 0; + } + + // Remove file + else if (args[1] == "remove" && args.size() > 2) + { + bool force = false; + for (std::string::size_type cc = 2; cc < args.size(); cc ++) + { + if(args[cc] == "\\-f" || args[cc] == "-f") + { + force = true; + } + else + { + // Complain if the file could not be removed, still exists, + // and the -f option was not given. + if(!cmSystemTools::RemoveFile(args[cc].c_str()) && !force && + cmSystemTools::FileExists(args[cc].c_str())) + { + return 1; + } + } + } + return 0; + } + // Touch file + else if (args[1] == "touch" && args.size() > 2) + { + for (std::string::size_type cc = 2; cc < args.size(); cc ++) + { + // Complain if the file could not be removed, still exists, + // and the -f option was not given. + if(!cmSystemTools::Touch(args[cc].c_str(), true)) + { + return 1; + } + } + return 0; + } + // Touch file + else if (args[1] == "touch_nocreate" && args.size() > 2) + { + for (std::string::size_type cc = 2; cc < args.size(); cc ++) + { + // Complain if the file could not be removed, still exists, + // and the -f option was not given. + if(!cmSystemTools::Touch(args[cc].c_str(), false)) + { + return 1; + } + } + return 0; + } + + // Clock command + else if (args[1] == "time" && args.size() > 2) + { + std::string command = args[2]; + for (std::string::size_type cc = 3; cc < args.size(); cc ++) + { + command += " "; + command += args[cc]; + } + + clock_t clock_start, clock_finish; + time_t time_start, time_finish; + + time(&time_start); + clock_start = clock(); + int ret =0; + cmSystemTools::RunSingleCommand(command.c_str(), 0, &ret); + + clock_finish = clock(); + time(&time_finish); + + double clocks_per_sec = static_cast<double>(CLOCKS_PER_SEC); + std::cout << "Elapsed time: " + << static_cast<long>(time_finish - time_start) << " s. (time)" + << ", " + << static_cast<double>(clock_finish - clock_start) / clocks_per_sec + << " s. (clock)" + << "\n"; + return ret; + } + // Command to calculate the md5sum of a file + else if (args[1] == "md5sum" && args.size() >= 3) + { + char md5out[32]; + int retval = 0; + for (std::string::size_type cc = 2; cc < args.size(); cc ++) + { + const char *filename = args[cc].c_str(); + // Cannot compute md5sum of a directory + if(cmSystemTools::FileIsDirectory(filename)) + { + std::cerr << "Error: " << filename << " is a directory" << std::endl; + retval++; + } + else if(!cmSystemTools::ComputeFileMD5(filename, md5out)) + { + // To mimic md5sum behavior in a shell: + std::cerr << filename << ": No such file or directory" << std::endl; + retval++; + } + else + { + std::cout << std::string(md5out,32) << " " << filename << std::endl; + } + } + return retval; + } + + // Command to change directory and run a program. + else if (args[1] == "chdir" && args.size() >= 4) + { + std::string directory = args[2]; + if(!cmSystemTools::FileExists(directory.c_str())) + { + cmSystemTools::Error("Directory does not exist for chdir command: ", + args[2].c_str()); + return 1; + } + + std::string command = "\""; + command += args[3]; + command += "\""; + for (std::string::size_type cc = 4; cc < args.size(); cc ++) + { + command += " \""; + command += args[cc]; + command += "\""; + } + int retval = 0; + int timeout = 0; + if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, &retval, + directory.c_str(), cmSystemTools::OUTPUT_NORMAL, timeout) ) + { + return retval; + } + + return 1; + } + + // Command to start progress for a build + else if (args[1] == "cmake_progress_start" && args.size() == 4) + { + // basically remove the directory + std::string dirName = args[2]; + dirName += "/Progress"; + cmSystemTools::RemoveADirectory(dirName.c_str()); + + // is the last argument a filename that exists? + FILE *countFile = cmsys::SystemTools::Fopen(args[3].c_str(),"r"); + int count; + if (countFile) + { + if (1!=fscanf(countFile,"%i",&count)) + { + cmSystemTools::Message("Could not read from count file."); + } + fclose(countFile); + } + else + { + count = atoi(args[3].c_str()); + } + if (count) + { + cmSystemTools::MakeDirectory(dirName.c_str()); + // write the count into the directory + std::string fName = dirName; + fName += "/count.txt"; + FILE *progFile = cmsys::SystemTools::Fopen(fName.c_str(),"w"); + if (progFile) + { + fprintf(progFile,"%i\n",count); + fclose(progFile); + } + } + return 0; + } + + // Command to report progress for a build + else if (args[1] == "cmake_progress_report" && args.size() >= 3) + { + std::string dirName = args[2]; + dirName += "/Progress"; + std::string fName; + FILE *progFile; + + // read the count + fName = dirName; + fName += "/count.txt"; + progFile = cmsys::SystemTools::Fopen(fName.c_str(),"r"); + int count = 0; + if (!progFile) + { + return 0; + } + else + { + if (1!=fscanf(progFile,"%i",&count)) + { + cmSystemTools::Message("Could not read from progress file."); + } + fclose(progFile); + } + unsigned int i; + for (i = 3; i < args.size(); ++i) + { + fName = dirName; + fName += "/"; + fName += args[i]; + progFile = cmsys::SystemTools::Fopen(fName.c_str(),"w"); + if (progFile) + { + fprintf(progFile,"empty"); + fclose(progFile); + } + } + int fileNum = static_cast<int> + (cmsys::Directory::GetNumberOfFilesInDirectory(dirName.c_str())); + if (count > 0) + { + // print the progress + fprintf(stdout,"[%3i%%] ",((fileNum-3)*100)/count); + } + return 0; + } + + // Command to create a symbolic link. Fails on platforms not + // supporting them. + else if (args[1] == "create_symlink" && args.size() == 4) + { + const char* destinationFileName = args[3].c_str(); + if ( cmSystemTools::FileExists(destinationFileName) ) + { + if ( cmSystemTools::FileIsSymlink(destinationFileName) ) + { + if ( !cmSystemTools::RemoveFile(destinationFileName) || + cmSystemTools::FileExists(destinationFileName) ) + { + return 0; + } + } + else + { + return 0; + } + } + return cmSystemTools::CreateSymlink(args[2].c_str(), + args[3].c_str())? 0:1; + } + + // Internal CMake shared library support. + else if (args[1] == "cmake_symlink_library" && args.size() == 5) + { + return cmcmd::SymlinkLibrary(args); + } + // Internal CMake versioned executable support. + else if (args[1] == "cmake_symlink_executable" && args.size() == 4) + { + return cmcmd::SymlinkExecutable(args); + } + +#if defined(CMAKE_HAVE_VS_GENERATORS) + // Internal CMake support for calling Visual Studio macros. + else if (args[1] == "cmake_call_visual_studio_macro" && args.size() >= 4) + { + // args[2] = full path to .sln file or "ALL" + // args[3] = name of Visual Studio macro to call + // args[4..args.size()-1] = [optional] args for Visual Studio macro + + std::string macroArgs; + + if (args.size() > 4) + { + macroArgs = args[4]; + + for (size_t i = 5; i < args.size(); ++i) + { + macroArgs += " "; + macroArgs += args[i]; + } + } + + return cmCallVisualStudioMacro::CallMacro(args[2], args[3], + macroArgs, true); + } +#endif + + // Internal CMake dependency scanning support. + else if (args[1] == "cmake_depends" && args.size() >= 6) + { + // Use the make system's VERBOSE environment variable to enable + // verbose output. This can be skipped by also setting CMAKE_NO_VERBOSE + // (which is set by the Eclipse and KDevelop generators). + bool verbose = ((cmSystemTools::GetEnv("VERBOSE") != 0) + && (cmSystemTools::GetEnv("CMAKE_NO_VERBOSE") == 0)); + + // Create a cmake object instance to process dependencies. + cmake cm; + std::string gen; + std::string homeDir; + std::string startDir; + std::string homeOutDir; + std::string startOutDir; + std::string depInfo; + bool color = false; + if(args.size() >= 8) + { + // Full signature: + // + // -E cmake_depends <generator> + // <home-src-dir> <start-src-dir> + // <home-out-dir> <start-out-dir> + // <dep-info> [--color=$(COLOR)] + // + // All paths are provided. + gen = args[2]; + homeDir = args[3]; + startDir = args[4]; + homeOutDir = args[5]; + startOutDir = args[6]; + depInfo = args[7]; + if(args.size() >= 9 && + args[8].length() >= 8 && + args[8].substr(0, 8) == "--color=") + { + // Enable or disable color based on the switch value. + color = (args[8].size() == 8 || + cmSystemTools::IsOn(args[8].substr(8).c_str())); + } + } + else + { + // Support older signature for existing makefiles: + // + // -E cmake_depends <generator> + // <home-out-dir> <start-out-dir> + // <dep-info> + // + // Just pretend the source directories are the same as the + // binary directories so at least scanning will work. + gen = args[2]; + homeDir = args[3]; + startDir = args[4]; + homeOutDir = args[3]; + startOutDir = args[3]; + depInfo = args[5]; + } + + // Create a local generator configured for the directory in + // which dependencies will be scanned. + homeDir = cmSystemTools::CollapseFullPath(homeDir.c_str()); + startDir = cmSystemTools::CollapseFullPath(startDir.c_str()); + homeOutDir = cmSystemTools::CollapseFullPath(homeOutDir.c_str()); + startOutDir = cmSystemTools::CollapseFullPath(startOutDir.c_str()); + cm.SetHomeDirectory(homeDir.c_str()); + cm.SetStartDirectory(startDir.c_str()); + cm.SetHomeOutputDirectory(homeOutDir.c_str()); + cm.SetStartOutputDirectory(startOutDir.c_str()); + if(cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen.c_str())) + { + cm.SetGlobalGenerator(ggd); + cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator()); + lgd->GetMakefile()->SetStartDirectory(startDir.c_str()); + lgd->GetMakefile()->SetStartOutputDirectory(startOutDir.c_str()); + lgd->GetMakefile()->MakeStartDirectoriesCurrent(); + + // Actually scan dependencies. + return lgd->UpdateDependencies(depInfo.c_str(), + verbose, color)? 0 : 2; + } + return 1; + } + + // Internal CMake link script support. + else if (args[1] == "cmake_link_script" && args.size() >= 3) + { + return cmcmd::ExecuteLinkScript(args); + } + + // Internal CMake unimplemented feature notification. + else if (args[1] == "cmake_unimplemented_variable") + { + std::cerr << "Feature not implemented for this platform."; + if(args.size() == 3) + { + std::cerr << " Variable " << args[2] << " is not set."; + } + std::cerr << std::endl; + return 1; + } + else if (args[1] == "vs_link_exe") + { + return cmcmd::VisualStudioLink(args, 1); + } + else if (args[1] == "vs_link_dll") + { + return cmcmd::VisualStudioLink(args, 2); + } +#ifdef CMAKE_BUILD_WITH_CMAKE + // Internal CMake color makefile support. + else if (args[1] == "cmake_echo_color") + { + return cmcmd::ExecuteEchoColor(args); + } + else if (args[1] == "cmake_autogen" && args.size() >= 4) + { + cmQtAutoGenerators autogen; + const char *config = args[3].empty() ? 0 : args[3].c_str(); + bool autogenSuccess = autogen.Run(args[2].c_str(), config); + return autogenSuccess ? 0 : 1; + } +#endif + + // Tar files + else if (args[1] == "tar" && args.size() > 3) + { + std::string flags = args[2]; + std::string outFile = args[3]; + std::vector<cmStdString> files; + for (std::string::size_type cc = 4; cc < args.size(); cc ++) + { + files.push_back(args[cc]); + } + bool gzip = false; + bool bzip2 = false; + bool verbose = false; + if ( flags.find_first_of('j') != flags.npos ) + { + bzip2 = true; + } + if ( flags.find_first_of('z') != flags.npos ) + { + gzip = true; + } + if ( flags.find_first_of('v') != flags.npos ) + { + verbose = true; + } + + if ( flags.find_first_of('t') != flags.npos ) + { + if ( !cmSystemTools::ListTar(outFile.c_str(), gzip, verbose) ) + { + cmSystemTools::Error("Problem creating tar: ", outFile.c_str()); + return 1; + } + } + else if ( flags.find_first_of('c') != flags.npos ) + { + if ( !cmSystemTools::CreateTar( + outFile.c_str(), files, gzip, bzip2, verbose) ) + { + cmSystemTools::Error("Problem creating tar: ", outFile.c_str()); + return 1; + } + } + else if ( flags.find_first_of('x') != flags.npos ) + { + if ( !cmSystemTools::ExtractTar( + outFile.c_str(), gzip, verbose) ) + { + cmSystemTools::Error("Problem extracting tar: ", outFile.c_str()); + return 1; + } +#ifdef WIN32 + // OK, on windows 7 after we untar some files, + // sometimes we can not rename the directory after + // the untar is done. This breaks the external project + // untar and rename code. So, by default we will wait + // 1/10th of a second after the untar. If CMAKE_UNTAR_DELAY + // is set in the env, its value will be used instead of 100. + int delay = 100; + const char* delayVar = cmSystemTools::GetEnv("CMAKE_UNTAR_DELAY"); + if(delayVar) + { + delay = atoi(delayVar); + } + if(delay) + { + cmSystemTools::Delay(delay); + } +#endif + } + return 0; + } + +#if defined(CMAKE_BUILD_WITH_CMAKE) + // Internal CMake Fortran module support. + else if (args[1] == "cmake_copy_f90_mod" && args.size() >= 4) + { + return cmDependsFortran::CopyModule(args)? 0 : 1; + } +#endif + +#if defined(_WIN32) && !defined(__CYGWIN__) + // Write registry value + else if (args[1] == "write_regv" && args.size() > 3) + { + return cmSystemTools::WriteRegistryValue(args[2].c_str(), + args[3].c_str()) ? 0 : 1; + } + + // Delete registry value + else if (args[1] == "delete_regv" && args.size() > 2) + { + return cmSystemTools::DeleteRegistryValue(args[2].c_str()) ? 0 : 1; + } + // Remove file + else if (args[1] == "comspec" && args.size() > 2) + { + std::cerr << "Win9x helper \"cmake -E comspec\" no longer supported\n"; + return 1; + } + else if (args[1] == "env_vs8_wince" && args.size() == 3) + { + return cmcmd::WindowsCEEnvironment("8.0", args[2]); + } + else if (args[1] == "env_vs9_wince" && args.size() == 3) + { + return cmcmd::WindowsCEEnvironment("9.0", args[2]); + } +#endif + } + + ::CMakeCommandUsage(args[0].c_str()); + return 1; +} + +//---------------------------------------------------------------------------- +int cmcmd::SymlinkLibrary(std::vector<std::string>& args) +{ + int result = 0; + std::string realName = args[2]; + std::string soName = args[3]; + std::string name = args[4]; + if(soName != realName) + { + if(!cmcmd::SymlinkInternal(realName, soName)) + { + cmSystemTools::ReportLastSystemError("cmake_symlink_library"); + result = 1; + } + } + if(name != soName) + { + if(!cmcmd::SymlinkInternal(soName, name)) + { + cmSystemTools::ReportLastSystemError("cmake_symlink_library"); + result = 1; + } + } + return result; +} + +//---------------------------------------------------------------------------- +int cmcmd::SymlinkExecutable(std::vector<std::string>& args) +{ + int result = 0; + std::string realName = args[2]; + std::string name = args[3]; + if(name != realName) + { + if(!cmcmd::SymlinkInternal(realName, name)) + { + cmSystemTools::ReportLastSystemError("cmake_symlink_executable"); + result = 1; + } + } + return result; +} + +//---------------------------------------------------------------------------- +bool cmcmd::SymlinkInternal(std::string const& file, std::string const& link) +{ + if(cmSystemTools::FileExists(link.c_str()) || + cmSystemTools::FileIsSymlink(link.c_str())) + { + cmSystemTools::RemoveFile(link.c_str()); + } +#if defined(_WIN32) && !defined(__CYGWIN__) + return cmSystemTools::CopyFileAlways(file.c_str(), link.c_str()); +#else + std::string linktext = cmSystemTools::GetFilenameName(file); + return cmSystemTools::CreateSymlink(linktext.c_str(), link.c_str()); +#endif +} + +//---------------------------------------------------------------------------- +#ifdef CMAKE_BUILD_WITH_CMAKE +int cmcmd::ExecuteEchoColor(std::vector<std::string>& args) +{ + // The arguments are + // argv[0] == <cmake-executable> + // argv[1] == cmake_echo_color + + bool enabled = true; + int color = cmsysTerminal_Color_Normal; + bool newline = true; + for(unsigned int i=2; i < args.size(); ++i) + { + if(args[i].find("--switch=") == 0) + { + // Enable or disable color based on the switch value. + std::string value = args[i].substr(9); + if(!value.empty()) + { + if(cmSystemTools::IsOn(value.c_str())) + { + enabled = true; + } + else + { + enabled = false; + } + } + } + else if(args[i] == "--normal") + { + color = cmsysTerminal_Color_Normal; + } + else if(args[i] == "--black") + { + color = cmsysTerminal_Color_ForegroundBlack; + } + else if(args[i] == "--red") + { + color = cmsysTerminal_Color_ForegroundRed; + } + else if(args[i] == "--green") + { + color = cmsysTerminal_Color_ForegroundGreen; + } + else if(args[i] == "--yellow") + { + color = cmsysTerminal_Color_ForegroundYellow; + } + else if(args[i] == "--blue") + { + color = cmsysTerminal_Color_ForegroundBlue; + } + else if(args[i] == "--magenta") + { + color = cmsysTerminal_Color_ForegroundMagenta; + } + else if(args[i] == "--cyan") + { + color = cmsysTerminal_Color_ForegroundCyan; + } + else if(args[i] == "--white") + { + color = cmsysTerminal_Color_ForegroundWhite; + } + else if(args[i] == "--bold") + { + color |= cmsysTerminal_Color_ForegroundBold; + } + else if(args[i] == "--no-newline") + { + newline = false; + } + else if(args[i] == "--newline") + { + newline = true; + } + else + { + // Color is enabled. Print with the current color. + cmSystemTools::MakefileColorEcho(color, args[i].c_str(), + newline, enabled); + } + } + + return 0; +} +#else +int cmcmd::ExecuteEchoColor(std::vector<std::string>&) +{ + return 1; +} +#endif + +//---------------------------------------------------------------------------- +int cmcmd::ExecuteLinkScript(std::vector<std::string>& args) +{ + // The arguments are + // argv[0] == <cmake-executable> + // argv[1] == cmake_link_script + // argv[2] == <link-script-name> + // argv[3] == --verbose=? + bool verbose = false; + if(args.size() >= 4) + { + if(args[3].find("--verbose=") == 0) + { + if(!cmSystemTools::IsOff(args[3].substr(10).c_str())) + { + verbose = true; + } + } + } + + // Allocate a process instance. + cmsysProcess* cp = cmsysProcess_New(); + if(!cp) + { + std::cerr << "Error allocating process instance in link script." + << std::endl; + return 1; + } + + // Children should share stdout and stderr with this process. + cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDOUT, 1); + cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDERR, 1); + + // Run the command lines verbatim. + cmsysProcess_SetOption(cp, cmsysProcess_Option_Verbatim, 1); + + // Read command lines from the script. + cmsys::ifstream fin(args[2].c_str()); + if(!fin) + { + std::cerr << "Error opening link script \"" + << args[2] << "\"" << std::endl; + return 1; + } + + // Run one command at a time. + std::string command; + int result = 0; + while(result == 0 && cmSystemTools::GetLineFromStream(fin, command)) + { + // Skip empty command lines. + if(command.find_first_not_of(" \t") == command.npos) + { + continue; + } + + // Setup this command line. + const char* cmd[2] = {command.c_str(), 0}; + cmsysProcess_SetCommand(cp, cmd); + + // Report the command if verbose output is enabled. + if(verbose) + { + std::cout << command << std::endl; + } + + // Run the command and wait for it to exit. + cmsysProcess_Execute(cp); + cmsysProcess_WaitForExit(cp, 0); + + // Report failure if any. + switch(cmsysProcess_GetState(cp)) + { + case cmsysProcess_State_Exited: + { + int value = cmsysProcess_GetExitValue(cp); + if(value != 0) + { + result = value; + } + } + break; + case cmsysProcess_State_Exception: + std::cerr << "Error running link command: " + << cmsysProcess_GetExceptionString(cp) << std::endl; + result = 1; + break; + case cmsysProcess_State_Error: + std::cerr << "Error running link command: " + << cmsysProcess_GetErrorString(cp) << std::endl; + result = 2; + break; + default: + break; + }; + } + + // Free the process instance. + cmsysProcess_Delete(cp); + + // Return the final resulting return value. + return result; +} + +//---------------------------------------------------------------------------- +int cmcmd::WindowsCEEnvironment(const char* version, const std::string& name) +{ +#if defined(CMAKE_HAVE_VS_GENERATORS) + cmVisualStudioWCEPlatformParser parser(name.c_str()); + parser.ParseVersion(version); + if (parser.Found()) + { + std::cout << "@echo off" << std::endl; + std::cout << "echo Environment Selection: " << name << std::endl; + std::cout << "set PATH=" << parser.GetPathDirectories() << std::endl; + std::cout << "set INCLUDE=" << parser.GetIncludeDirectories() <<std::endl; + std::cout << "set LIB=" << parser.GetLibraryDirectories() <<std::endl; + return 0; + } +#else + (void)version; +#endif + + std::cerr << "Could not find " << name; + return -1; +} + +// For visual studio 2005 and newer manifest files need to be embedded into +// exe and dll's. This code does that in such a way that incremental linking +// still works. +int cmcmd::VisualStudioLink(std::vector<std::string>& args, int type) +{ + if(args.size() < 2) + { + return -1; + } + bool verbose = false; + if(cmSystemTools::GetEnv("VERBOSE")) + { + verbose = true; + } + std::vector<std::string> expandedArgs; + for(std::vector<std::string>::iterator i = args.begin(); + i != args.end(); ++i) + { + // check for nmake temporary files + if((*i)[0] == '@' && i->find("@CMakeFiles") != 0 ) + { + cmsys::ifstream fin(i->substr(1).c_str()); + std::string line; + while(cmSystemTools::GetLineFromStream(fin, + line)) + { + cmSystemTools::ParseWindowsCommandLine(line.c_str(), expandedArgs); + } + } + else + { + expandedArgs.push_back(*i); + } + } + bool hasIncremental = false; + bool hasManifest = true; + for(std::vector<std::string>::iterator i = expandedArgs.begin(); + i != expandedArgs.end(); ++i) + { + if(cmSystemTools::Strucmp(i->c_str(), "/INCREMENTAL:YES") == 0) + { + hasIncremental = true; + } + if(cmSystemTools::Strucmp(i->c_str(), "/INCREMENTAL") == 0) + { + hasIncremental = true; + } + if(cmSystemTools::Strucmp(i->c_str(), "/MANIFEST:NO") == 0) + { + hasManifest = false; + } + } + if(hasIncremental && hasManifest) + { + if(verbose) + { + std::cout << "Visual Studio Incremental Link with embedded manifests\n"; + } + return cmcmd::VisualStudioLinkIncremental(expandedArgs, type, verbose); + } + if(verbose) + { + if(!hasIncremental) + { + std::cout << "Visual Studio Non-Incremental Link\n"; + } + else + { + std::cout << "Visual Studio Incremental Link without manifests\n"; + } + } + return cmcmd::VisualStudioLinkNonIncremental(expandedArgs, + type, hasManifest, verbose); +} + +int cmcmd::ParseVisualStudioLinkCommand(std::vector<std::string>& args, + std::vector<cmStdString>& command, + std::string& targetName) +{ + std::vector<std::string>::iterator i = args.begin(); + i++; // skip -E + i++; // skip vs_link_dll or vs_link_exe + command.push_back(*i); + i++; // move past link command + for(; i != args.end(); ++i) + { + command.push_back(*i); + if(i->find("/Fe") == 0) + { + targetName = i->substr(3); + } + if(i->find("/out:") == 0) + { + targetName = i->substr(5); + } + } + if(targetName.size() == 0 || command.size() == 0) + { + return -1; + } + return 0; +} + +bool cmcmd::RunCommand(const char* comment, + std::vector<cmStdString>& command, + bool verbose, + int* retCodeOut) +{ + if(verbose) + { + std::cout << comment << ":\n"; + for(std::vector<cmStdString>::iterator i = command.begin(); + i != command.end(); ++i) + { + std::cout << i->c_str() << " "; + } + std::cout << "\n"; + } + std::string output; + int retCode =0; + // use rc command to create .res file + cmSystemTools::RunSingleCommand(command, + &output, + &retCode, 0, cmSystemTools::OUTPUT_NONE); + // always print the output of the command, unless + // it is the dumb rc command banner, but if the command + // returned an error code then print the output anyway as + // the banner may be mixed with some other important information. + if(output.find("Resource Compiler Version") == output.npos + || retCode !=0) + { + std::cout << output; + } + // if retCodeOut is requested then always return true + // and set the retCodeOut to retCode + if(retCodeOut) + { + *retCodeOut = retCode; + return true; + } + if(retCode != 0) + { + std::cout << comment << " failed. with " << retCode << "\n"; + } + return retCode == 0; +} + +int cmcmd::VisualStudioLinkIncremental(std::vector<std::string>& args, + int type, bool verbose) +{ + // This follows the steps listed here: + // http://blogs.msdn.com/zakramer/archive/2006/05/22/603558.aspx + + // 1. Compiler compiles the application and generates the *.obj files. + // 2. An empty manifest file is generated if this is a clean build and if + // not the previous one is reused. + // 3. The resource compiler (rc.exe) compiles the *.manifest file to a + // *.res file. + // 4. Linker generates the binary (EXE or DLL) with the /incremental + // switch and embeds the dummy manifest file. The linker also generates + // the real manifest file based on the binaries that your binary depends + // on. + // 5. The manifest tool (mt.exe) is then used to generate the final + // manifest. + + // If the final manifest is changed, then 6 and 7 are run, if not + // they are skipped, and it is done. + + // 6. The resource compiler is invoked one more time. + // 7. Finally, the Linker does another incremental link, but since the + // only thing that has changed is the *.res file that contains the + // manifest it is a short link. + std::vector<cmStdString> linkCommand; + std::string targetName; + if(cmcmd::ParseVisualStudioLinkCommand(args, linkCommand, targetName) == -1) + { + return -1; + } + std::string manifestArg = "/MANIFESTFILE:"; + std::vector<cmStdString> rcCommand; + rcCommand.push_back(cmSystemTools::FindProgram("rc.exe")); + std::vector<cmStdString> mtCommand; + mtCommand.push_back(cmSystemTools::FindProgram("mt.exe")); + std::string tempManifest; + tempManifest = targetName; + tempManifest += ".intermediate.manifest"; + std::string resourceInputFile = targetName; + resourceInputFile += ".resource.txt"; + if(verbose) + { + std::cout << "Create " << resourceInputFile.c_str() << "\n"; + } + // Create input file for rc command + cmsys::ofstream fout(resourceInputFile.c_str()); + if(!fout) + { + return -1; + } + std::string manifestFile = targetName; + manifestFile += ".embed.manifest"; + std::string fullPath= cmSystemTools::CollapseFullPath(manifestFile.c_str()); + fout << type << " /* CREATEPROCESS_MANIFEST_RESOURCE_ID " + "*/ 24 /* RT_MANIFEST */ " << "\"" << fullPath.c_str() << "\""; + fout.close(); + manifestArg += tempManifest; + // add the manifest arg to the linkCommand + linkCommand.push_back("/MANIFEST"); + linkCommand.push_back(manifestArg); + // if manifestFile is not yet created, create an + // empty one + if(!cmSystemTools::FileExists(manifestFile.c_str())) + { + if(verbose) + { + std::cout << "Create empty: " << manifestFile.c_str() << "\n"; + } + cmsys::ofstream foutTmp(manifestFile.c_str()); + } + std::string resourceFile = manifestFile; + resourceFile += ".res"; + // add the resource file to the end of the link command + linkCommand.push_back(resourceFile); + std::string outputOpt = "/fo"; + outputOpt += resourceFile; + rcCommand.push_back(outputOpt); + rcCommand.push_back(resourceInputFile); + // Run rc command to create resource + if(!cmcmd::RunCommand("RC Pass 1", rcCommand, verbose)) + { + return -1; + } + // Now run the link command to link and create manifest + if(!cmcmd::RunCommand("LINK Pass 1", linkCommand, verbose)) + { + return -1; + } + // create mt command + std::string outArg("/out:"); + outArg+= manifestFile; + mtCommand.push_back("/nologo"); + mtCommand.push_back(outArg); + mtCommand.push_back("/notify_update"); + mtCommand.push_back("/manifest"); + mtCommand.push_back(tempManifest); + // now run mt.exe to create the final manifest file + int mtRet =0; + cmcmd::RunCommand("MT", mtCommand, verbose, &mtRet); + // if mt returns 0, then the manifest was not changed and + // we do not need to do another link step + if(mtRet == 0) + { + return 0; + } + // check for magic mt return value if mt returns the magic number + // 1090650113 then it means that it updated the manifest file and we need + // to do the final link. If mt has any value other than 0 or 1090650113 + // then there was some problem with the command itself and there was an + // error so return the error code back out of cmake so make can report it. + // (when hosted on a posix system the value is 187) + if(mtRet != 1090650113 && mtRet != 187) + { + return mtRet; + } + // update the resource file with the new manifest from the mt command. + if(!cmcmd::RunCommand("RC Pass 2", rcCommand, verbose)) + { + return -1; + } + // Run the final incremental link that will put the new manifest resource + // into the file incrementally. + if(!cmcmd::RunCommand("FINAL LINK", linkCommand, verbose)) + { + return -1; + } + return 0; +} + +int cmcmd::VisualStudioLinkNonIncremental(std::vector<std::string>& args, + int type, + bool hasManifest, + bool verbose) +{ + std::vector<cmStdString> linkCommand; + std::string targetName; + if(cmcmd::ParseVisualStudioLinkCommand(args, linkCommand, targetName) == -1) + { + return -1; + } + // Run the link command as given + if (hasManifest) + { + linkCommand.push_back("/MANIFEST"); + } + if(!cmcmd::RunCommand("LINK", linkCommand, verbose)) + { + return -1; + } + if(!hasManifest) + { + return 0; + } + std::vector<cmStdString> mtCommand; + mtCommand.push_back(cmSystemTools::FindProgram("mt.exe")); + mtCommand.push_back("/nologo"); + mtCommand.push_back("/manifest"); + std::string manifestFile = targetName; + manifestFile += ".manifest"; + mtCommand.push_back(manifestFile); + std::string outresource = "/outputresource:"; + outresource += targetName; + outresource += ";#"; + if(type == 1) + { + outresource += "1"; + } + else if(type == 2) + { + outresource += "2"; + } + mtCommand.push_back(outresource); + // Now use the mt tool to embed the manifest into the exe or dll + if(!cmcmd::RunCommand("MT", mtCommand, verbose)) + { + return -1; + } + return 0; +} diff --git a/Source/cmcmd.h b/Source/cmcmd.h new file mode 100644 index 0000000..4517ebf --- /dev/null +++ b/Source/cmcmd.h @@ -0,0 +1,54 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmcmd_h +#define cmcmd_h + +#include "cmStandardIncludes.h" + +class cmcmd +{ +public: + + /** + * Execute commands during the build process. Supports options such + * as echo, remove file etc. + */ + static int ExecuteCMakeCommand(std::vector<std::string>&); +protected: + + static int SymlinkLibrary(std::vector<std::string>& args); + static int SymlinkExecutable(std::vector<std::string>& args); + static bool SymlinkInternal(std::string const& file, + std::string const& link); + static int ExecuteEchoColor(std::vector<std::string>& args); + static int ExecuteLinkScript(std::vector<std::string>& args); + static int WindowsCEEnvironment(const char* version, + const std::string& name); + static int VisualStudioLink(std::vector<std::string>& args, int type); + static int VisualStudioLinkIncremental(std::vector<std::string>& args, + int type, + bool verbose); + static int VisualStudioLinkNonIncremental(std::vector<std::string>& args, + int type, + bool hasManifest, + bool verbose); + static int ParseVisualStudioLinkCommand(std::vector<std::string>& args, + std::vector<cmStdString>& command, + std::string& targetName); + static bool RunCommand(const char* comment, + std::vector<cmStdString>& command, + bool verbose, + int* retCodeOut = 0); +}; + +#endif diff --git a/Source/cmw9xcom.cxx b/Source/cmw9xcom.cxx deleted file mode 100644 index ab238d5..0000000 --- a/Source/cmw9xcom.cxx +++ /dev/null @@ -1,45 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc., Insight Software Consortium - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ -#include "cmSystemTools.h" -#include "cmWin32ProcessExecution.h" - -// this is a test driver program for cmake. -int main (int argc, char *argv[]) -{ - cmSystemTools::EnableMSVCDebugHook(); - if ( argc <= 1 ) - { - std::cerr << "Usage: " << argv[0] << " executable" << std::endl; - return 1; - } - std::string arg = argv[1]; - if ( (arg.find_first_of(" ") != arg.npos) && - (arg.find_first_of("\"") == arg.npos) ) - { - arg = "\"" + arg + "\""; - } - std::string command = arg; - int cc; - for ( cc = 2; cc < argc; cc ++ ) - { - std::string nextArg = argv[cc]; - if ( (nextArg.find_first_of(" ") != nextArg.npos) && - (nextArg.find_first_of("\"") == nextArg.npos) ) - { - nextArg = "\"" + nextArg + "\""; - } - command += " "; - command += nextArg; - } - - return cmWin32ProcessExecution::Windows9xHack(command.c_str()); -} diff --git a/Source/ctest.cxx b/Source/ctest.cxx index e767a16..3eb5551 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -18,256 +18,110 @@ #include "CTest/cmCTestScriptHandler.h" #include "CTest/cmCTestLaunch.h" +#include "cmsys/Encoding.hxx" //---------------------------------------------------------------------------- -static const char * cmDocumentationName[][3] = +static const char * cmDocumentationName[][2] = { {0, - " ctest - Testing driver provided by CMake.", 0}, - {0,0,0} + " ctest - Testing driver provided by CMake."}, + {0,0} }; //---------------------------------------------------------------------------- -static const char * cmDocumentationUsage[][3] = +static const char * cmDocumentationUsage[][2] = { {0, - " ctest [options]", 0}, - {0,0,0} + " ctest [options]"}, + {0,0} }; //---------------------------------------------------------------------------- -static const char * cmDocumentationDescription[][3] = -{ - {0, - "The \"ctest\" executable is the CMake test driver program. " - "CMake-generated build trees created for projects that use " - "the ENABLE_TESTING and ADD_TEST commands have testing support. " - "This program will run the tests and report results.", 0}, - {0,0,0} -}; - //---------------------------------------------------------------------------- -static const char * cmDocumentationOptions[][3] = +static const char * cmDocumentationOptions[][2] = { - {"-C <cfg>, --build-config <cfg>", "Choose configuration to test.", - "Some CMake-generated build trees can have multiple build configurations " - "in the same tree. This option can be used to specify which one should " - "be tested. Example configurations are \"Debug\" and \"Release\"."}, - {"-V,--verbose", "Enable verbose output from tests.", - "Test output is normally suppressed and only summary information is " - "displayed. This option will show all test output."}, - {"-VV,--extra-verbose", "Enable more verbose output from tests.", - "Test output is normally suppressed and only summary information is " - "displayed. This option will show even more test output."}, - {"--debug", "Displaying more verbose internals of CTest.", - "This feature will result in a large number of output that is mostly " - "useful for debugging dashboard problems."}, - {"--output-on-failure", "Output anything outputted by the test program " - "if the test should fail. This option can also be enabled by setting " - "the environment variable CTEST_OUTPUT_ON_FAILURE"}, - {"-F", "Enable failover.", "This option allows ctest to resume a test " - "set execution that was previously interrupted. If no interruption " - "occurred, the -F option will have no effect."}, + {"-C <cfg>, --build-config <cfg>", "Choose configuration to test."}, + {"-V,--verbose", "Enable verbose output from tests."}, + {"-VV,--extra-verbose", "Enable more verbose output from tests."}, + {"--debug", "Displaying more verbose internals of CTest."}, + {"--output-on-failure"}, + {"-F", "Enable failover."}, {"-j <jobs>, --parallel <jobs>", "Run the tests in parallel using the" - "given number of jobs.", - "This option tells ctest to run the tests in parallel using given " - "number of jobs. This option can also be set by setting " - "the environment variable CTEST_PARALLEL_LEVEL."}, - {"-Q,--quiet", "Make ctest quiet.", - "This option will suppress all the output. The output log file will " - "still be generated if the --output-log is specified. Options such " - "as --verbose, --extra-verbose, and --debug are ignored if --quiet is " - "specified."}, - {"-O <file>, --output-log <file>", "Output to log file", - "This option tells ctest to write all its output to a log file."}, - {"-N,--show-only", "Disable actual execution of tests.", - "This option tells ctest to list the tests that would be run but not " - "actually run them. Useful in conjunction with the -R and -E options."}, + "given number of jobs."}, + {"-Q,--quiet", "Make ctest quiet."}, + {"-O <file>, --output-log <file>", "Output to log file"}, + {"-N,--show-only", "Disable actual execution of tests."}, {"-L <regex>, --label-regex <regex>", "Run tests with labels matching " - "regular expression.", - "This option tells ctest to run only the tests whose labels match the " - "given regular expression."}, + "regular expression."}, {"-R <regex>, --tests-regex <regex>", "Run tests matching regular " - "expression.", - "This option tells ctest to run only the tests whose names match the " - "given regular expression."}, + "expression."}, {"-E <regex>, --exclude-regex <regex>", "Exclude tests matching regular " - "expression.", - "This option tells ctest to NOT run the tests whose names match the " - "given regular expression."}, + "expression."}, {"-LE <regex>, --label-exclude <regex>", "Exclude tests with labels " - "matching regular expression.", - "This option tells ctest to NOT run the tests whose labels match the " - "given regular expression."}, - {"-D <dashboard>, --dashboard <dashboard>", "Execute dashboard test", - "This option tells ctest to act as a Dart client and perform " - "a dashboard test. All tests are <Mode><Test>, where Mode can be " - "Experimental, Nightly, and Continuous, and Test can be Start, Update, " - "Configure, Build, Test, Coverage, and Submit."}, - {"-D <var>:<type>=<value>", "Define a variable for script mode", - "Pass in variable values on the command line. Use in " - "conjunction with -S to pass variable values to a dashboard script. " - "Parsing -D arguments as variable values is only attempted if " - "the value following -D does not match any of the known dashboard " - "types."}, - {"-M <model>, --test-model <model>", "Sets the model for a dashboard", - "This option tells ctest to act as a Dart client " - "where the TestModel can be Experimental, " - "Nightly, and Continuous. Combining -M and -T is similar to -D"}, + "matching regular expression."}, + {"-D <dashboard>, --dashboard <dashboard>", "Execute dashboard test"}, + {"-D <var>:<type>=<value>", "Define a variable for script mode"}, + {"-M <model>, --test-model <model>", "Sets the model for a dashboard"}, {"-T <action>, --test-action <action>", "Sets the dashboard action to " - "perform", - "This option tells ctest to act as a Dart client " - "and perform some action such as start, build, test etc. " - "Combining -M and -T is similar to -D"}, - {"--track <track>", "Specify the track to submit dashboard to", - "Submit dashboard to specified track instead of default one. By " - "default, the dashboard is submitted to Nightly, Experimental, or " - "Continuous track, but by specifying this option, the track can be " - "arbitrary."}, + "perform"}, + {"--track <track>", "Specify the track to submit dashboard to"}, {"-S <script>, --script <script>", "Execute a dashboard for a " - "configuration", - "This option tells ctest to load in a configuration script which sets " - "a number of parameters such as the binary and source directories. Then " - "ctest will do what is required to create and run a dashboard. This " - "option basically sets up a dashboard and then runs ctest -D with the " - "appropriate options."}, + "configuration"}, {"-SP <script>, --script-new-process <script>", "Execute a dashboard for a " - "configuration", - "This option does the same operations as -S but it will do them in a " - "separate process. This is primarily useful in cases where the script " - "may modify the environment and you do not want the modified environment " - "to impact other -S scripts."}, - {"-A <file>, --add-notes <file>", "Add a notes file with submission", - "This option tells ctest to include a notes file when submitting " - "dashboard. "}, + "configuration"}, + {"-A <file>, --add-notes <file>", "Add a notes file with submission"}, {"-I [Start,End,Stride,test#,test#|Test file], --tests-information", - "Run a specific number of tests by number.", - "This option causes ctest to run tests starting at number Start, ending " - "at number End, and incrementing by Stride. Any additional numbers after " - "Stride are considered individual test numbers. Start, End,or stride " - "can be empty. Optionally a file can be given that contains the same " - "syntax as the command line."}, - {"-U, --union", "Take the Union of -I and -R", - "When both -R and -I are specified by default the intersection of " - "tests are run. By specifying -U the union of tests is run instead."}, - {"--max-width <width>", "Set the max width for a test name to output", - "Set the maximum width for each test name to show in the output. This " - "allows the user to widen the output to avoid clipping the test name which " - "can be very annoying."}, - {"--interactive-debug-mode [0|1]", "Set the interactive mode to 0 or 1.", - "This option causes ctest to run tests in either an interactive mode or " - "a non-interactive mode. On Windows this means that in non-interactive " - "mode, all system debug pop up windows are blocked. In dashboard mode " - "(Experimental, Nightly, Continuous), the default is non-interactive. " - "When just running tests not for a dashboard the default is to allow " - "popups and interactive " - "debugging."}, - {"--no-label-summary", "Disable timing summary information for labels.", - "This option tells ctest not to print summary information for each label " - "associated with the tests run. If there are no labels on the " - "tests, nothing extra is printed."}, - {"--build-and-test", "Configure, build and run a test.", - "This option tells ctest to configure (i.e. run cmake on), build, and or " - "execute a test. The configure and test steps are optional. The arguments " - "to this command line are the source and binary directories. By default " - "this will run CMake on the Source/Bin directories specified unless " - "--build-nocmake is specified. Both --build-makeprogram and " - "--build-generator MUST be provided to use --build-and-test. If " - "--test-command is specified then that will be run after the build is " - "complete. Other options that affect this mode are --build-target " - "--build-nocmake, --build-run-dir, " - "--build-two-config, --build-exe-dir, --build-project," - "--build-noclean, --build-options"}, - {"--build-target", "Specify a specific target to build.", - "This option goes with the --build-and-test option, if left out the all " - "target is built." }, - {"--build-nocmake", "Run the build without running cmake first.", - "Skip the cmake step." }, - {"--build-run-dir", "Specify directory to run programs from.", - "Directory where programs will be after it has been compiled." }, - {"--build-two-config", "Run CMake twice", "" }, - {"--build-exe-dir", "Specify the directory for the executable.", "" }, - {"--build-generator", "Specify the generator to use.", "" }, - {"--build-generator-toolset", "Specify the generator-specific toolset.",""}, - {"--build-project", "Specify the name of the project to build.", "" }, - {"--build-makeprogram", "Specify the make program to use.", "" }, - {"--build-noclean", "Skip the make clean step.", "" }, + "Run a specific number of tests by number."}, + {"-U, --union", "Take the Union of -I and -R"}, + {"--rerun-failed", "Run only the tests that failed previously"}, + {"--max-width <width>", "Set the max width for a test name to output"}, + {"--interactive-debug-mode [0|1]", "Set the interactive mode to 0 or 1."}, + {"--no-label-summary", "Disable timing summary information for labels."}, + {"--build-and-test", "Configure, build and run a test."}, + {"--build-target", "Specify a specific target to build."}, + {"--build-nocmake", "Run the build without running cmake first."}, + {"--build-run-dir", "Specify directory to run programs from."}, + {"--build-two-config", "Run CMake twice"}, + {"--build-exe-dir", "Specify the directory for the executable."}, + {"--build-generator", "Specify the generator to use."}, + {"--build-generator-toolset", "Specify the generator-specific toolset."}, + {"--build-project", "Specify the name of the project to build."}, + {"--build-makeprogram", "Specify the make program to use."}, + {"--build-noclean", "Skip the make clean step."}, {"--build-config-sample", - "A sample executable to use to determine the configuration", - "A sample executable to use to determine the configuration that " - "should be used. e.g. Debug/Release/etc" }, - {"--build-options", "Add extra options to the build step.", - "This option must be the last option with the exception of --test-command" - }, + "A sample executable to use to determine the configuration"}, + {"--build-options", "Add extra options to the build step."}, - {"--test-command", "The test to run with the --build-and-test option.", "" - }, - {"--test-timeout", "The time limit in seconds, internal use only.", "" - }, - {"--tomorrow-tag", "Nightly or experimental starts with next day tag.", - "This is useful if the build will not finish in one day." }, + {"--test-command", "The test to run with the --build-and-test option."}, + {"--test-timeout", "The time limit in seconds, internal use only."}, + {"--tomorrow-tag", "Nightly or experimental starts with next day tag."}, {"--ctest-config", "The configuration file used to initialize CTest state " - "when submitting dashboards.", - "This option tells CTest to use different initialization file instead of " - "CTestConfiguration.tcl. This way multiple initialization files can be " - "used for example to submit to multiple dashboards." }, - {"--overwrite", "Overwrite CTest configuration option.", - "By default ctest uses configuration options from configuration file. " - "This option will overwrite the configuration option." }, - {"--extra-submit <file>[;<file>]", "Submit extra files to the dashboard.", - "This option will submit extra files to the dashboard." }, - {"--force-new-ctest-process", "Run child CTest instances as new processes", - "By default CTest will run child CTest instances within the same process. " - "If this behavior is not desired, this argument will enforce new " - "processes for child CTest processes." }, - {"--schedule-random", "Use a random order for scheduling tests", - "This option will run the tests in a random order. It is commonly used to " - "detect implicit dependencies in a test suite." }, - {"--submit-index", "Submit individual dashboard tests with specific index", - "This option allows performing the same CTest action (such as test) " - "multiple times and submit all stages to the same dashboard (Dart2 " - "required). Each execution requires different index." }, - {"--timeout <seconds>", "Set a global timeout on all tests.", - "This option will set a global timeout on all tests that do not already " - "have a timeout set on them."}, - {"--stop-time <time>", "Set a time at which all tests should stop running.", - "Set a real time of day at which all tests should timeout. Example: " - "7:00:00 -0400. Any time format understood by the curl date parser is " - "accepted. Local time is assumed if no timezone is specified."}, - {"--http1.0", "Submit using HTTP 1.0.", - "This option will force CTest to use HTTP 1.0 to submit files to the " - "dashboard, instead of HTTP 1.1."}, - {"--no-compress-output", "Do not compress test output when submitting.", - "This flag will turn off automatic compression of test output. Use this " - "to maintain compatibility with an older version of CDash which doesn't " - "support compressed test output."}, - {"--print-labels", "Print all available test labels.", - "This option will not run any tests, it will simply print the list of " - "all labels associated with the test set."}, - {"--help-command <cmd> [<file>]", "Show help for a single command and exit.", - "Prints the help for the command to stdout or to the specified file." }, - {"--help-command-list [<file>]", "List available commands and exit.", - "Prints the list of all available listfile commands to stdout or the " - "specified file." }, - {"--help-commands [<file>]", "Print help for all commands and exit.", - "Prints the help for all commands to stdout or to the specified file." }, - {0,0,0} -}; - -//---------------------------------------------------------------------------- -static const char * cmDocumentationSeeAlso[][3] = -{ - {0, "cmake", 0}, - {0, "ccmake", 0}, - {0, 0, 0} + "when submitting dashboards."}, + {"--overwrite", "Overwrite CTest configuration option."}, + {"--extra-submit <file>[;<file>]", "Submit extra files to the dashboard."}, + {"--force-new-ctest-process", "Run child CTest instances as new processes"}, + {"--schedule-random", "Use a random order for scheduling tests"}, + {"--submit-index", "Submit individual dashboard tests with specific index"}, + {"--timeout <seconds>", "Set a global timeout on all tests."}, + {"--stop-time <time>", + "Set a time at which all tests should stop running."}, + {"--http1.0", "Submit using HTTP 1.0."}, + {"--no-compress-output", "Do not compress test output when submitting."}, + {"--print-labels", "Print all available test labels."}, + {0,0} }; // this is a test driver program for cmCTest. -int main (int argc, char *argv[]) +int main (int argc, char const* const* argv) { + cmsys::Encoding::CommandLineArguments encoding_args = + cmsys::Encoding::CommandLineArguments::Main(argc, argv); + argc = encoding_args.argc(); + argv = encoding_args.argv(); + cmSystemTools::DoNotInheritStdPipes(); cmSystemTools::EnableMSVCDebugHook(); - cmSystemTools::FindExecutableDirectory(argv[0]); + cmSystemTools::FindCMakeResources(argv[0]); // Dispatch 'ctest --launch' mode directly. if(argc >= 2 && strcmp(argv[1], "--launch") == 0) @@ -301,21 +155,19 @@ int main (int argc, char *argv[]) doc.addCTestStandardDocSections(); if(doc.CheckOptions(argc, argv)) { + cmake hcm; + hcm.AddCMakePaths(); + // Construct and print requested documentation. - std::vector<cmDocumentationEntry> commands; cmCTestScriptHandler* ch = static_cast<cmCTestScriptHandler*>(inst.GetHandler("script")); ch->CreateCMake(); - ch->GetCommandDocumentation(commands); doc.SetShowGenerators(false); doc.SetName("ctest"); doc.SetSection("Name",cmDocumentationName); doc.SetSection("Usage",cmDocumentationUsage); - doc.SetSection("Description",cmDocumentationDescription); doc.PrependSection("Options",cmDocumentationOptions); - doc.SetSection("Commands",commands); - doc.SetSeeAlsoList(cmDocumentationSeeAlso); #ifdef cout # undef cout #endif @@ -324,10 +176,6 @@ int main (int argc, char *argv[]) } } -#ifdef _WIN32 - std::string comspec = "cmw9xcom.exe"; - cmSystemTools::SetWindows9xComspecSubstitute(comspec.c_str()); -#endif // copy the args to a vector std::vector<std::string> args; for(int i =0; i < argc; ++i) diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index 0f27836..24ea518 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -85,6 +85,9 @@ # written. CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR) +IF(POLICY CMP0025) + CMAKE_POLICY(SET CMP0025 NEW) +ENDIF() #----------------------------------------------------------------------------- # If a namespace is not specified, use "kwsys" and enable testing. @@ -112,6 +115,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) SET(KWSYS_USE_Base64 1) SET(KWSYS_USE_Directory 1) SET(KWSYS_USE_DynamicLoader 1) + SET(KWSYS_USE_Encoding 1) SET(KWSYS_USE_Glob 1) SET(KWSYS_USE_MD5 1) SET(KWSYS_USE_Process 1) @@ -122,6 +126,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) SET(KWSYS_USE_FundamentalType 1) SET(KWSYS_USE_Terminal 1) SET(KWSYS_USE_IOStream 1) + SET(KWSYS_USE_FStream 1) SET(KWSYS_USE_String 1) SET(KWSYS_USE_SystemInformation 1) SET(KWSYS_USE_CPU 1) @@ -130,18 +135,32 @@ ENDIF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) # Enforce component dependencies. IF(KWSYS_USE_SystemTools) SET(KWSYS_USE_Directory 1) + SET(KWSYS_USE_FStream 1) + SET(KWSYS_USE_Encoding 1) ENDIF(KWSYS_USE_SystemTools) IF(KWSYS_USE_Glob) SET(KWSYS_USE_Directory 1) SET(KWSYS_USE_SystemTools 1) SET(KWSYS_USE_RegularExpression 1) + SET(KWSYS_USE_FStream 1) + SET(KWSYS_USE_Encoding 1) ENDIF(KWSYS_USE_Glob) IF(KWSYS_USE_Process) SET(KWSYS_USE_System 1) + SET(KWSYS_USE_Encoding 1) ENDIF(KWSYS_USE_Process) IF(KWSYS_USE_SystemInformation) SET(KWSYS_USE_Process 1) ENDIF(KWSYS_USE_SystemInformation) +IF(KWSYS_USE_System) + SET(KWSYS_USE_Encoding 1) +ENDIF(KWSYS_USE_System) +IF(KWSYS_USE_Directory) + SET(KWSYS_USE_Encoding 1) +ENDIF(KWSYS_USE_Directory) +IF(KWSYS_USE_FStream) + SET(KWSYS_USE_Encoding 1) +ENDIF(KWSYS_USE_FStream) # Setup the large file support default. IF(KWSYS_LFS_DISABLE) @@ -150,6 +169,11 @@ ELSE(KWSYS_LFS_DISABLE) SET(KWSYS_LFS_REQUESTED 1) ENDIF(KWSYS_LFS_DISABLE) +# Specify default 8 bit encoding for Windows +IF(NOT KWSYS_ENCODING_DEFAULT_CODEPAGE) + SET(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_ACP) +ENDIF(NOT KWSYS_ENCODING_DEFAULT_CODEPAGE) + # Enable testing if building standalone. IF(KWSYS_STANDALONE) INCLUDE(Dart) @@ -506,6 +530,12 @@ IF(KWSYS_USE_FundamentalType) "Checking whether char is signed" DIRECT) ENDIF(KWSYS_USE_FundamentalType) +IF(KWSYS_USE_Encoding) + # Look for type size helper macros. + KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_WSTRING + "Checking whether wstring is available" DIRECT) +ENDIF(KWSYS_USE_Encoding) + IF(KWSYS_USE_IOStream) # Determine whether iostreams support long long. SET(KWSYS_PLATFORM_CXX_TEST_DEFINES @@ -861,8 +891,8 @@ SET(KWSYS_HXX_FILES Configure String # Add selected C++ classes. SET(cppclasses - Directory DynamicLoader Glob RegularExpression SystemTools - CommandLineArguments IOStream SystemInformation + Directory DynamicLoader Encoding Glob RegularExpression SystemTools + CommandLineArguments IOStream FStream SystemInformation ) FOREACH(cpp ${cppclasses}) IF(KWSYS_USE_${cpp}) @@ -878,7 +908,7 @@ ENDFOREACH(cpp) # Add selected C components. FOREACH(c - Process Base64 FundamentalType MD5 Terminal System String CPU + Process Base64 Encoding FundamentalType MD5 Terminal System String CPU ) IF(KWSYS_USE_${c}) # Use the corresponding header file. @@ -909,16 +939,24 @@ IF(KWSYS_USE_Process) ENDIF(KWSYS_USE_Process) # Add selected C sources. -FOREACH(c Base64 MD5 Terminal System String) +FOREACH(c Base64 Encoding MD5 Terminal System String) IF(KWSYS_USE_${c}) - SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ${c}.c) + IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}C.c) + LIST(APPEND KWSYS_C_SRCS ${c}C.c) + ELSE() + LIST(APPEND KWSYS_C_SRCS ${c}.c) + ENDIF() ENDIF(KWSYS_USE_${c}) ENDFOREACH(c) # Configure headers of C++ classes and construct the list of sources. FOREACH(c ${KWSYS_CLASSES}) # Add this source to the list of source files for the library. - SET(KWSYS_CXX_SRCS ${KWSYS_CXX_SRCS} ${c}.cxx) + IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}CXX.cxx) + LIST(APPEND KWSYS_CXX_SRCS ${c}CXX.cxx) + ELSEIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}.cxx) + LIST(APPEND KWSYS_CXX_SRCS ${c}.cxx) + ENDIF() # Configure the header for this class. CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/${c}.hxx.in ${KWSYS_HEADER_DIR}/${c}.hxx @@ -1044,6 +1082,12 @@ IF(KWSYS_USE_String) COMPILE_FLAGS "-DKWSYS_STRING_C") ENDIF(KWSYS_USE_String) +IF(KWSYS_USE_Encoding) + # Set default 8 bit encoding in "EndcodingC.c". + SET_PROPERTY(SOURCE EncodingC.c APPEND PROPERTY COMPILE_DEFINITIONS + KWSYS_ENCODING_DEFAULT_CODEPAGE=${KWSYS_ENCODING_DEFAULT_CODEPAGE}) +ENDIF(KWSYS_USE_Encoding) + #----------------------------------------------------------------------------- # Setup testing if not being built as part of another project. IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) @@ -1087,6 +1131,16 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) testCommandLineArguments testCommandLineArguments1 ) + IF(KWSYS_STL_HAS_WSTRING) + SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} + testEncoding + ) + ENDIF(KWSYS_STL_HAS_WSTRING) + IF(KWSYS_USE_FStream) + SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} + testFStream + ) + ENDIF(KWSYS_USE_FStream) IF(KWSYS_USE_SystemInformation) SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testSystemInformation) ENDIF(KWSYS_USE_SystemInformation) diff --git a/Source/kwsys/Configure.hxx.in b/Source/kwsys/Configure.hxx.in index 716b84f..8f5ace2 100644 --- a/Source/kwsys/Configure.hxx.in +++ b/Source/kwsys/Configure.hxx.in @@ -36,6 +36,9 @@ /* Whether STL is in std namespace. */ #define @KWSYS_NAMESPACE@_STL_HAVE_STD @KWSYS_STL_HAVE_STD@ +/* Whether wstring is available. */ +#define @KWSYS_NAMESPACE@_STL_HAS_WSTRING @KWSYS_STL_HAS_WSTRING@ + /* Whether the STL string has operator<< for ostream. */ #define @KWSYS_NAMESPACE@_STL_STRING_HAVE_OSTREAM @KWSYS_STL_STRING_HAVE_OSTREAM@ @@ -170,6 +173,7 @@ # define KWSYS_STL_HAS_ALLOCATOR_TEMPLATE @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_TEMPLATE # define KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_NONTEMPLATE # define KWSYS_STL_HAS_ALLOCATOR_OBJECTS @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_OBJECTS +# define KWSYS_STL_HAS_WSTRING @KWSYS_NAMESPACE@_STL_HAS_WSTRING #endif #endif diff --git a/Source/kwsys/Directory.cxx b/Source/kwsys/Directory.cxx index b884747..d54e607 100644 --- a/Source/kwsys/Directory.cxx +++ b/Source/kwsys/Directory.cxx @@ -14,6 +14,8 @@ #include KWSYS_HEADER(Configure.hxx) +#include KWSYS_HEADER(Encoding.hxx) + #include KWSYS_HEADER(stl/string) #include KWSYS_HEADER(stl/vector) @@ -22,6 +24,7 @@ #if 0 # include "Directory.hxx.in" # include "Configure.hxx.in" +# include "Encoding.hxx.in" # include "kwsys_stl.hxx.in" # include "kwsys_stl_string.hxx.in" # include "kwsys_stl_vector.hxx.in" @@ -120,10 +123,10 @@ bool Directory::Load(const char* name) buf = new char[n + 2 + 1]; sprintf(buf, "%s/*", name); } - struct _finddata_t data; // data of current file + struct _wfinddata_t data; // data of current file // Now put them into the file array - srchHandle = _findfirst(buf, &data); + srchHandle = _wfindfirst((wchar_t*)Encoding::ToWide(buf).c_str(), &data); delete [] buf; if ( srchHandle == -1 ) @@ -134,9 +137,9 @@ bool Directory::Load(const char* name) // Loop through names do { - this->Internal->Files.push_back(data.name); + this->Internal->Files.push_back(Encoding::ToNarrow(data.name)); } - while ( _findnext(srchHandle, &data) != -1 ); + while ( _wfindnext(srchHandle, &data) != -1 ); this->Internal->Path = name; return _findclose(srchHandle) != -1; } @@ -160,10 +163,10 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const char* name) buf = new char[n + 2 + 1]; sprintf(buf, "%s/*", name); } - struct _finddata_t data; // data of current file + struct _wfinddata_t data; // data of current file // Now put them into the file array - srchHandle = _findfirst(buf, &data); + srchHandle = _wfindfirst((wchar_t*)Encoding::ToWide(buf).c_str(), &data); delete [] buf; if ( srchHandle == -1 ) @@ -177,7 +180,7 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const char* name) { count++; } - while ( _findnext(srchHandle, &data) != -1 ); + while ( _wfindnext(srchHandle, &data) != -1 ); _findclose(srchHandle); return count; } diff --git a/Source/kwsys/DynamicLoader.cxx b/Source/kwsys/DynamicLoader.cxx index fd83752..44cf6af 100644 --- a/Source/kwsys/DynamicLoader.cxx +++ b/Source/kwsys/DynamicLoader.cxx @@ -186,13 +186,12 @@ namespace KWSYS_NAMESPACE DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname) { DynamicLoader::LibraryHandle lh; -#ifdef UNICODE - wchar_t libn[MB_CUR_MAX]; - mbstowcs(libn, libname, MB_CUR_MAX); - lh = LoadLibrary(libn); -#else - lh = LoadLibrary(libname); -#endif + int length = MultiByteToWideChar(CP_UTF8, 0, libname, -1, NULL, 0); + wchar_t* wchars = new wchar_t[length+1]; + wchars[0] = '\0'; + MultiByteToWideChar(CP_UTF8, 0, libname, -1, wchars, length); + lh = LoadLibraryW(wchars); + delete [] wchars; return lh; } @@ -238,13 +237,7 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( #else const char *rsym = sym; #endif -#ifdef UNICODE - wchar_t wsym[MB_CUR_MAX]; - mbstowcs(wsym, rsym, MB_CUR_MAX); - result = GetProcAddress(lib, wsym); -#else result = (void*)GetProcAddress(lib, rsym); -#endif #if defined(__BORLANDC__) || defined(__WATCOMC__) delete[] rsym; #endif diff --git a/Source/kwsys/Encoding.h.in b/Source/kwsys/Encoding.h.in new file mode 100644 index 0000000..591c5a8 --- /dev/null +++ b/Source/kwsys/Encoding.h.in @@ -0,0 +1,79 @@ +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef @KWSYS_NAMESPACE@_Encoding_h +#define @KWSYS_NAMESPACE@_Encoding_h + +#include <@KWSYS_NAMESPACE@/Configure.h> +#include <wchar.h> + +/* Redefine all public interface symbol names to be in the proper + namespace. These macros are used internally to kwsys only, and are + not visible to user code. Use kwsysHeaderDump.pl to reproduce + these macros after making changes to the interface. */ +#if !defined(KWSYS_NAMESPACE) +# define kwsys_ns(x) @KWSYS_NAMESPACE@##x +# define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT +#endif +#if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS +# define kwsysEncoding kwsys_ns(Encoding) +# define kwsysEncoding_mbstowcs kwsys_ns(Encoding_mbstowcs) +# define kwsysEncoding_DupToWide kwsys_ns(Encoding_DupToWide) +# define kwsysEncoding_wcstombs kwsys_ns(Encoding_wcstombs) +# define kwsysEncoding_DupToNarrow kwsys_ns(Encoding_DupToNarrow) +#endif + +#if defined(__cplusplus) +extern "C" +{ +#endif + + +/* Convert a narrow string to a wide string. + On Windows, UTF-8 is assumed, and on other platforms, + the current locale is assumed. + */ +kwsysEXPORT size_t kwsysEncoding_mbstowcs(wchar_t* dest, const char* src, size_t n); + +/* Convert a narrow string to a wide string. + This can return NULL if the conversion fails. */ +kwsysEXPORT wchar_t* kwsysEncoding_DupToWide(const char* src); + + +/* Convert a wide string to a narrow string. + On Windows, UTF-8 is assumed, and on other platforms, + the current locale is assumed. */ +kwsysEXPORT size_t kwsysEncoding_wcstombs(char* dest, const wchar_t* src, size_t n); + +/* Convert a wide string to a narrow string. + This can return NULL if the conversion fails. */ +kwsysEXPORT char* kwsysEncoding_DupToNarrow(const wchar_t* str); + + +#if defined(__cplusplus) +} /* extern "C" */ +#endif + +/* If we are building a kwsys .c or .cxx file, let it use these macros. + Otherwise, undefine them to keep the namespace clean. */ +#if !defined(KWSYS_NAMESPACE) +# undef kwsys_ns +# undef kwsysEXPORT +# if !defined(KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS +# undef kwsysEncoding +# undef kwsysEncoding_mbstowcs +# undef kwsysEncoding_DupToWide +# undef kwsysEncoding_wcstombs +# undef kwsysEncoding_DupToNarrow +# endif +#endif + +#endif diff --git a/Source/kwsys/Encoding.hxx.in b/Source/kwsys/Encoding.hxx.in new file mode 100644 index 0000000..aba4175 --- /dev/null +++ b/Source/kwsys/Encoding.hxx.in @@ -0,0 +1,87 @@ +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef @KWSYS_NAMESPACE@_Encoding_hxx +#define @KWSYS_NAMESPACE@_Encoding_hxx + +#include <@KWSYS_NAMESPACE@/Configure.hxx> +#include <@KWSYS_NAMESPACE@/stl/string> +#include <@KWSYS_NAMESPACE@/stl/vector> + +/* Define these macros temporarily to keep the code readable. */ +#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS +# define kwsys_stl @KWSYS_NAMESPACE@_stl +#endif + +namespace @KWSYS_NAMESPACE@ +{ +class @KWSYS_NAMESPACE@_EXPORT Encoding +{ +public: + + // Container class for argc/argv. + class CommandLineArguments + { + public: + // On Windows, get the program command line arguments + // in this Encoding module's 8 bit encoding. + // On other platforms the given argc/argv is used, and + // to be consistent, should be the argc/argv from main(). + static CommandLineArguments Main(int argc, char const* const* argv); + + // Construct CommandLineArguments with the given + // argc/argv. It is assumed that the string is already + // in the encoding used by this module. + CommandLineArguments(int argc, char const* const* argv); + + // Construct CommandLineArguments with the given + // argc and wide argv. This is useful if wmain() is used. + CommandLineArguments(int argc, wchar_t const* const* argv); + ~CommandLineArguments(); + CommandLineArguments(const CommandLineArguments&); + CommandLineArguments& operator=(const CommandLineArguments&); + + int argc() const; + char const* const* argv() const; + + protected: + std::vector<char*> argv_; + }; + + /** + * Convert between char and wchar_t + */ + +#if @KWSYS_NAMESPACE@_STL_HAS_WSTRING + + // Convert a narrow string to a wide string. + // On Windows, UTF-8 is assumed, and on other platforms, + // the current locale is assumed. + static kwsys_stl::wstring ToWide(const kwsys_stl::string& str); + static kwsys_stl::wstring ToWide(const char* str); + + // Convert a wide string to a narrow string. + // On Windows, UTF-8 is assumed, and on other platforms, + // the current locale is assumed. + static kwsys_stl::string ToNarrow(const kwsys_stl::wstring& str); + static kwsys_stl::string ToNarrow(const wchar_t* str); + +#endif // @KWSYS_NAMESPACE@_STL_HAS_WSTRING + +}; // class Encoding +} // namespace @KWSYS_NAMESPACE@ + +/* Undefine temporary macros. */ +#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS +# undef kwsys_stl +#endif + +#endif diff --git a/Source/kwsys/EncodingC.c b/Source/kwsys/EncodingC.c new file mode 100644 index 0000000..cda78e2 --- /dev/null +++ b/Source/kwsys/EncodingC.c @@ -0,0 +1,79 @@ +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "kwsysPrivate.h" +#include KWSYS_HEADER(Encoding.h) + +/* Work-around CMake dependency scanning limitation. This must + duplicate the above list of headers. */ +#if 0 +# include "Encoding.h.in" +#endif + +#include <stdlib.h> + +#ifdef _WIN32 +#include <windows.h> +#endif + +size_t kwsysEncoding_mbstowcs(wchar_t* dest, const char* str, size_t n) +{ + if(str == 0) + { + return (size_t)-1; + } +#ifdef _WIN32 + return MultiByteToWideChar(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, + str, -1, dest, (int)n) - 1; +#else + return mbstowcs(dest, str, n); +#endif +} + +wchar_t* kwsysEncoding_DupToWide(const char* str) +{ + wchar_t* ret = NULL; + size_t length = kwsysEncoding_mbstowcs(NULL, str, 0) + 1; + if(length > 0) + { + ret = malloc((length)*sizeof(wchar_t)); + ret[0] = 0; + kwsysEncoding_mbstowcs(ret, str, length); + } + return ret; +} + +size_t kwsysEncoding_wcstombs(char* dest, const wchar_t* str, size_t n) +{ + if(str == 0) + { + return (size_t)-1; + } +#ifdef _WIN32 + return WideCharToMultiByte(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str, -1, + dest, (int)n, NULL, NULL) - 1; +#else + return wcstombs(dest, str, n); +#endif +} + +char* kwsysEncoding_DupToNarrow(const wchar_t* str) +{ + char* ret = NULL; + size_t length = kwsysEncoding_wcstombs(0, str, 0) + 1; + if(length > 0) + { + ret = malloc(length); + ret[0] = 0; + kwsysEncoding_wcstombs(ret, str, length); + } + return ret; +} diff --git a/Source/kwsys/EncodingCXX.cxx b/Source/kwsys/EncodingCXX.cxx new file mode 100644 index 0000000..f76deb5 --- /dev/null +++ b/Source/kwsys/EncodingCXX.cxx @@ -0,0 +1,181 @@ +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifdef __osf__ +# define _OSF_SOURCE +# define _POSIX_C_SOURCE 199506L +# define _XOPEN_SOURCE_EXTENDED +#endif + +#include "kwsysPrivate.h" +#include KWSYS_HEADER(Encoding.hxx) +#include KWSYS_HEADER(Encoding.h) +#include KWSYS_HEADER(stl/vector) + +// Work-around CMake dependency scanning limitation. This must +// duplicate the above list of headers. +#if 0 +# include "Encoding.hxx.in" +# include "Encoding.h.in" +#endif + +#include <stdlib.h> +#include <string.h> + +#ifdef _MSC_VER +# pragma warning (disable: 4786) +#endif + +// Windows API. +#if defined(_WIN32) +# include <windows.h> +#endif + +namespace KWSYS_NAMESPACE +{ + +Encoding::CommandLineArguments +Encoding::CommandLineArguments::Main(int argc, char const* const* argv) +{ +#ifdef _WIN32 + (void) argc; + (void) argv; + + int ac; + LPWSTR* w_av = CommandLineToArgvW(GetCommandLineW(), &ac); + + std::vector<std::string> av1(ac); + std::vector<char const*> av2(ac); + for(int i=0; i<ac; i++) + { + av1[i] = ToNarrow(w_av[i]); + av2[i] = av1[i].c_str(); + } + LocalFree(w_av); + return CommandLineArguments(ac, &av2[0]); +#else + return CommandLineArguments(argc, argv); +#endif +} + +Encoding::CommandLineArguments::CommandLineArguments(int ac, + char const* const* av) +{ + this->argv_.resize(ac+1); + for(int i=0; i<ac; i++) + { + this->argv_[i] = strdup(av[i]); + } + this->argv_[ac] = 0; +} + +Encoding::CommandLineArguments::CommandLineArguments(int ac, + wchar_t const* const* av) +{ + this->argv_.resize(ac+1); + for(int i=0; i<ac; i++) + { + this->argv_[i] = kwsysEncoding_DupToNarrow(av[i]); + } + this->argv_[ac] = 0; +} + +Encoding::CommandLineArguments::~CommandLineArguments() +{ + for(size_t i=0; i<this->argv_.size(); i++) + { + free(argv_[i]); + } +} + +Encoding::CommandLineArguments:: + CommandLineArguments(const CommandLineArguments& other) +{ + this->argv_.resize(other.argv_.size()); + for(size_t i=0; i<this->argv_.size(); i++) + { + this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : 0; + } +} + +Encoding::CommandLineArguments& +Encoding::CommandLineArguments::operator=(const CommandLineArguments& other) +{ + size_t i; + for(i=0; i<this->argv_.size(); i++) + { + free(this->argv_[i]); + } + + this->argv_.resize(other.argv_.size()); + for(i=0; i<this->argv_.size(); i++) + { + this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : 0; + } + + return *this; +} + +int Encoding::CommandLineArguments::argc() const +{ + return static_cast<int>(this->argv_.size() - 1); +} + +char const* const* Encoding::CommandLineArguments::argv() const +{ + return &this->argv_[0]; +} + +#if KWSYS_STL_HAS_WSTRING + +kwsys_stl::wstring Encoding::ToWide(const kwsys_stl::string& str) +{ + return ToWide(str.c_str()); +} + +kwsys_stl::string Encoding::ToNarrow(const kwsys_stl::wstring& str) +{ + return ToNarrow(str.c_str()); +} + +kwsys_stl::wstring Encoding::ToWide(const char* cstr) +{ + kwsys_stl::wstring wstr; + size_t length = kwsysEncoding_mbstowcs(0, cstr, 0) + 1; + if(length > 0) + { + kwsys_stl::vector<wchar_t> wchars(length); + if(kwsysEncoding_mbstowcs(&wchars[0], cstr, length) > 0) + { + wstr = &wchars[0]; + } + } + return wstr; +} + +kwsys_stl::string Encoding::ToNarrow(const wchar_t* wcstr) +{ + kwsys_stl::string str; + size_t length = kwsysEncoding_wcstombs(0, wcstr, 0) + 1; + if(length > 0) + { + std::vector<char> chars(length); + if(kwsysEncoding_wcstombs(&chars[0], wcstr, length) > 0) + { + str = &chars[0]; + } + } + return str; +} +#endif // KWSYS_STL_HAS_WSTRING + +} // namespace KWSYS_NAMESPACE diff --git a/Source/kwsys/FStream.hxx.in b/Source/kwsys/FStream.hxx.in new file mode 100644 index 0000000..916a93e --- /dev/null +++ b/Source/kwsys/FStream.hxx.in @@ -0,0 +1,173 @@ +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef @KWSYS_NAMESPACE@_FStream_hxx +#define @KWSYS_NAMESPACE@_FStream_hxx + +#include <@KWSYS_NAMESPACE@/ios/fstream> +#include <@KWSYS_NAMESPACE@/Encoding.hxx> + +namespace @KWSYS_NAMESPACE@ +{ +#if defined(_MSC_VER) && _MSC_VER >= 1400 + template<typename CharType,typename Traits> + class basic_filebuf : public std::basic_filebuf<CharType,Traits> + { + public: + typedef std::basic_filebuf<CharType,Traits> my_base_type; + basic_filebuf *open(char const *s,std::ios_base::openmode mode) + { + return static_cast<basic_filebuf*>( + my_base_type::open(Encoding::ToWide(s).c_str(), mode) + ); + } + }; + + template<typename CharType,typename Traits = std::char_traits<CharType> > + class basic_ifstream : public std::basic_istream<CharType,Traits> + { + public: + typedef basic_filebuf<CharType,Traits> internal_buffer_type; + typedef std::basic_istream<CharType,Traits> internal_stream_type; + + basic_ifstream() : internal_stream_type(new internal_buffer_type()) + { + buf_ = static_cast<internal_buffer_type *>(internal_stream_type::rdbuf()); + } + explicit basic_ifstream(char const *file_name, + std::ios_base::openmode mode = std::ios_base::in) + : internal_stream_type(new internal_buffer_type()) + { + buf_ = static_cast<internal_buffer_type *>(internal_stream_type::rdbuf()); + open(file_name,mode); + } + void open(char const *file_name,std::ios_base::openmode mode = std::ios_base::in) + { + if(!buf_->open(file_name,mode | std::ios_base::in)) + { + this->setstate(std::ios_base::failbit); + } + else + { + this->clear(); + } + } + bool is_open() + { + return buf_->is_open(); + } + bool is_open() const + { + return buf_->is_open(); + } + void close() + { + if(!buf_->close()) + { + this->setstate(std::ios_base::failbit); + } + else + { + this->clear(); + } + } + + internal_buffer_type *rdbuf() const + { + return buf_; + } + + ~basic_ifstream() + { + buf_->close(); + delete buf_; + } + + private: + internal_buffer_type* buf_; +}; + +template<typename CharType,typename Traits = std::char_traits<CharType> > +class basic_ofstream : public std::basic_ostream<CharType,Traits> +{ + public: + typedef basic_filebuf<CharType,Traits> internal_buffer_type; + typedef std::basic_ostream<CharType,Traits> internal_stream_type; + + basic_ofstream() : internal_stream_type(new internal_buffer_type()) + { + buf_ = static_cast<internal_buffer_type *>(internal_stream_type::rdbuf()); + } + explicit basic_ofstream(char const *file_name,std::ios_base::openmode mode = std::ios_base::out) : + internal_stream_type(new internal_buffer_type()) + { + buf_ = static_cast<internal_buffer_type *>(internal_stream_type::rdbuf()); + open(file_name,mode); + } + void open(char const *file_name,std::ios_base::openmode mode = std::ios_base::out) + { + if(!buf_->open(file_name,mode | std::ios_base::out)) + { + this->setstate(std::ios_base::failbit); + } + else + { + this->clear(); + } + } + bool is_open() + { + return buf_->is_open(); + } + bool is_open() const + { + return buf_->is_open(); + } + void close() + { + if(!buf_->close()) + { + this->setstate(std::ios_base::failbit); + } + else + { + this->clear(); + } + } + + internal_buffer_type *rdbuf() const + { + return buf_.get(); + } + ~basic_ofstream() + { + buf_->close(); + delete buf_; + } + + private: + internal_buffer_type* buf_; +}; + + typedef basic_ifstream<char> ifstream; + typedef basic_ofstream<char> ofstream; + +#else + using @KWSYS_NAMESPACE@_ios_namespace::basic_filebuf; + using @KWSYS_NAMESPACE@_ios_namespace::ofstream; + using @KWSYS_NAMESPACE@_ios_namespace::ifstream; +#endif + +} + + + +#endif diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c index b9af2f1..faeb967 100644 --- a/Source/kwsys/ProcessUNIX.c +++ b/Source/kwsys/ProcessUNIX.c @@ -2449,6 +2449,7 @@ static void kwsysProcessKill(pid_t process_id) if(f) { size_t nread = fread(buffer, 1, KWSYSPE_PIPE_BUFFER_SIZE, f); + fclose(f); buffer[nread] = '\0'; if(nread > 0) { @@ -2463,7 +2464,6 @@ static void kwsysProcessKill(pid_t process_id) } } } - fclose(f); } } } diff --git a/Source/kwsys/ProcessWin32.c b/Source/kwsys/ProcessWin32.c index c836f9b..c8ec754 100644 --- a/Source/kwsys/ProcessWin32.c +++ b/Source/kwsys/ProcessWin32.c @@ -12,12 +12,14 @@ #include "kwsysPrivate.h" #include KWSYS_HEADER(Process.h) #include KWSYS_HEADER(System.h) +#include KWSYS_HEADER(Encoding.h) /* Work-around CMake dependency scanning limitation. This must duplicate the above list of headers. */ #if 0 # include "Process.h.in" # include "System.h.in" +# include "Encoding_c.h.in" #endif /* @@ -88,9 +90,10 @@ typedef LARGE_INTEGER kwsysProcessTime; typedef struct kwsysProcessCreateInformation_s { /* Windows child startup control data. */ - STARTUPINFO StartupInfo; + STARTUPINFOW StartupInfo; } kwsysProcessCreateInformation; + /*--------------------------------------------------------------------------*/ typedef struct kwsysProcessPipeData_s kwsysProcessPipeData; static DWORD WINAPI kwsysProcessPipeThreadRead(LPVOID ptd); @@ -197,14 +200,14 @@ struct kwsysProcess_s int State; /* The command lines to execute. */ - char** Commands; + wchar_t** Commands; int NumberOfCommands; /* The exit code of each command. */ DWORD* CommandExitCodes; /* The working directory for the child process. */ - char* WorkingDirectory; + wchar_t* WorkingDirectory; /* Whether to create the child as a detached process. */ int OptionDetach; @@ -299,7 +302,7 @@ struct kwsysProcess_s /* Real working directory of our own process. */ DWORD RealWorkingDirectoryLength; - char* RealWorkingDirectory; + wchar_t* RealWorkingDirectory; }; /*--------------------------------------------------------------------------*/ @@ -546,7 +549,7 @@ int kwsysProcess_SetCommand(kwsysProcess* cp, char const* const* command) int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command) { int newNumberOfCommands; - char** newCommands; + wchar_t** newCommands; /* Make sure we have a command to add. */ if(!cp || !command || !*command) @@ -554,9 +557,10 @@ int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command) return 0; } + /* Allocate a new array for command pointers. */ newNumberOfCommands = cp->NumberOfCommands + 1; - if(!(newCommands = (char**)malloc(sizeof(char*) * newNumberOfCommands))) + if(!(newCommands = (wchar_t**)malloc(sizeof(wchar_t*) * newNumberOfCommands))) { /* Out of memory. */ return 0; @@ -585,8 +589,8 @@ int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command) /* Allocate enough space for the command. We do not need an extra byte for the terminating null because we allocated a space for the first argument that we will not use. */ - newCommands[cp->NumberOfCommands] = (char*)malloc(length); - if(!newCommands[cp->NumberOfCommands]) + char* new_cmd = malloc(length); + if(!new_cmd) { /* Out of memory. */ free(newCommands); @@ -595,9 +599,13 @@ int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command) /* Construct the command line in the allocated buffer. */ kwsysProcessComputeCommandLine(cp, command, - newCommands[cp->NumberOfCommands]); + new_cmd); + + newCommands[cp->NumberOfCommands] = kwsysEncoding_DupToWide(new_cmd); + free(new_cmd); } + /* Save the new array of commands. */ free(cp->Commands); cp->Commands = newCommands; @@ -633,22 +641,26 @@ int kwsysProcess_SetWorkingDirectory(kwsysProcess* cp, const char* dir) } if(dir && dir[0]) { + wchar_t* wdir = kwsysEncoding_DupToWide(dir); /* We must convert the working directory to a full path. */ - DWORD length = GetFullPathName(dir, 0, 0, 0); + DWORD length = GetFullPathNameW(wdir, 0, 0, 0); if(length > 0) { - cp->WorkingDirectory = (char*)malloc(length); - if(!cp->WorkingDirectory) + wchar_t* work_dir = malloc(length*sizeof(wchar_t)); + if(!work_dir) { + free(wdir); return 0; } - if(!GetFullPathName(dir, length, cp->WorkingDirectory, 0)) + if(!GetFullPathNameW(wdir, length, work_dir, 0)) { - free(cp->WorkingDirectory); - cp->WorkingDirectory = 0; + free(work_dir); + free(wdir); return 0; } + cp->WorkingDirectory = work_dir; } + free(wdir); } return 1; } @@ -879,13 +891,13 @@ void kwsysProcess_Execute(kwsysProcess* cp) to make pipe file paths evaluate correctly. */ if(cp->WorkingDirectory) { - if(!GetCurrentDirectory(cp->RealWorkingDirectoryLength, + if(!GetCurrentDirectoryW(cp->RealWorkingDirectoryLength, cp->RealWorkingDirectory)) { kwsysProcessCleanup(cp, 1); return; } - SetCurrentDirectory(cp->WorkingDirectory); + SetCurrentDirectoryW(cp->WorkingDirectory); } /* Initialize startup info data. */ @@ -1003,7 +1015,7 @@ void kwsysProcess_Execute(kwsysProcess* cp) /* Restore the working directory. */ if(cp->RealWorkingDirectory) { - SetCurrentDirectory(cp->RealWorkingDirectory); + SetCurrentDirectoryW(cp->RealWorkingDirectory); free(cp->RealWorkingDirectory); cp->RealWorkingDirectory = 0; } @@ -1507,10 +1519,10 @@ int kwsysProcessInitialize(kwsysProcess* cp) /* Allocate space to save the real working directory of this process. */ if(cp->WorkingDirectory) { - cp->RealWorkingDirectoryLength = GetCurrentDirectory(0, 0); + cp->RealWorkingDirectoryLength = GetCurrentDirectoryW(0, 0); if(cp->RealWorkingDirectoryLength > 0) { - cp->RealWorkingDirectory = (char*)malloc(cp->RealWorkingDirectoryLength); + cp->RealWorkingDirectory = malloc(cp->RealWorkingDirectoryLength * sizeof(wchar_t)); if(!cp->RealWorkingDirectory) { return 0; @@ -1547,9 +1559,11 @@ int kwsysProcessCreate(kwsysProcess* cp, int index, else if(cp->PipeFileSTDIN) { /* Create a handle to read a file for stdin. */ - HANDLE fin = CreateFile(cp->PipeFileSTDIN, GENERIC_READ|GENERIC_WRITE, + wchar_t* wstdin = kwsysEncoding_DupToWide(cp->PipeFileSTDIN); + HANDLE fin = CreateFileW(wstdin, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0); + free(wstdin); if(fin == INVALID_HANDLE_VALUE) { return 0; @@ -1655,7 +1669,7 @@ int kwsysProcessCreate(kwsysProcess* cp, int index, /* Create the child in a suspended state so we can wait until all children have been created before running any one. */ - if(!CreateProcess(0, cp->Commands[index], 0, 0, TRUE, CREATE_SUSPENDED, 0, + if(!CreateProcessW(0, cp->Commands[index], 0, 0, TRUE, CREATE_SUSPENDED, 0, 0, &si->StartupInfo, &cp->ProcessInformation[index])) { return 0; @@ -1729,6 +1743,7 @@ void kwsysProcessDestroy(kwsysProcess* cp, int event) int kwsysProcessSetupOutputPipeFile(PHANDLE phandle, const char* name) { HANDLE fout; + wchar_t* wname; if(!name) { return 1; @@ -1738,8 +1753,10 @@ int kwsysProcessSetupOutputPipeFile(PHANDLE phandle, const char* name) kwsysProcessCleanupHandle(phandle); /* Create a handle to write a file for the pipe. */ - fout = CreateFile(name, GENERIC_WRITE, FILE_SHARE_READ, 0, + wname = kwsysEncoding_DupToWide(name); + fout = CreateFileW(wname, GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0); + free(wname); if(fout == INVALID_HANDLE_VALUE) { return 0; @@ -1883,10 +1900,13 @@ void kwsysProcessCleanup(kwsysProcess* cp, int error) { /* Format the error message. */ DWORD original = GetLastError(); - DWORD length = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | + wchar_t err_msg[KWSYSPE_PIPE_BUFFER_SIZE]; + DWORD length = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0, original, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - cp->ErrorMessage, KWSYSPE_PIPE_BUFFER_SIZE, 0); + err_msg, KWSYSPE_PIPE_BUFFER_SIZE, 0); + WideCharToMultiByte(CP_UTF8, 0, err_msg, -1, cp->ErrorMessage, + KWSYSPE_PIPE_BUFFER_SIZE, NULL, NULL); if(length < 1) { /* FormatMessage failed. Use a default message. */ @@ -1924,7 +1944,7 @@ void kwsysProcessCleanup(kwsysProcess* cp, int error) /* Restore the working directory. */ if(cp->RealWorkingDirectory) { - SetCurrentDirectory(cp->RealWorkingDirectory); + SetCurrentDirectoryW(cp->RealWorkingDirectory); } } @@ -2222,7 +2242,7 @@ static void kwsysProcessSetExitException(kwsysProcess* cp, int code) case STATUS_NO_MEMORY: default: cp->ExitException = kwsysProcess_Exception_Other; - sprintf(cp->ExitExceptionString, "Exit code 0x%x\n", code); + _snprintf(cp->ExitExceptionString, KWSYSPE_PIPE_BUFFER_SIZE, "Exit code 0x%x\n", code); break; } } @@ -2430,7 +2450,7 @@ static int kwsysProcess_List__New_NT4(kwsysProcess_List* self) loaded in this program. This does not actually increment the reference count to the module so we do not need to close the handle. */ - HMODULE hNT = GetModuleHandle("ntdll.dll"); + HMODULE hNT = GetModuleHandleW(L"ntdll.dll"); if(hNT) { /* Get pointers to the needed API functions. */ @@ -2534,7 +2554,7 @@ static int kwsysProcess_List__New_Snapshot(kwsysProcess_List* self) loaded in this program. This does not actually increment the reference count to the module so we do not need to close the handle. */ - HMODULE hKernel = GetModuleHandle("kernel32.dll"); + HMODULE hKernel = GetModuleHandleW(L"kernel32.dll"); if(hKernel) { self->P_CreateToolhelp32Snapshot = diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index beefd7d..5f20853 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -88,6 +88,15 @@ typedef int siginfo_t; # include <ifaddrs.h> # define KWSYS_SYSTEMINFORMATION_IMPLEMENT_FQDN # endif +# if defined(KWSYS_SYSTEMINFORMATION_HAS_BACKTRACE) +# include <execinfo.h> +# if defined(KWSYS_SYSTEMINFORMATION_HAS_CPP_DEMANGLE) +# include <cxxabi.h> +# endif +# if defined(KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP) +# include <dlfcn.h> +# endif +# endif #endif #if defined(__OpenBSD__) || defined(__NetBSD__) @@ -244,7 +253,7 @@ static bool call_cpuid(int select, int result[4]) _asm { #ifdef CPUID_AWARE_COMPILER ; we must push/pop the registers <<CPUID>> writes to, as the - ; optimiser doesn't know about <<CPUID>>, and so doesn't expect + ; optimiser does not know about <<CPUID>>, and so does not expect ; these registers to change. push eax push ebx @@ -1734,12 +1743,12 @@ int SystemInformationImplementation::GetFullyQualifiedDomainName( { char host[NI_MAXHOST]={'\0'}; - socklen_t addrlen + const size_t addrlen = (fam==AF_INET?sizeof(struct sockaddr_in):sizeof(struct sockaddr_in6)); ierr=getnameinfo( ifa->ifa_addr, - addrlen, + static_cast<socklen_t>(addrlen), host, NI_MAXHOST, NULL, @@ -2445,8 +2454,8 @@ bool SystemInformationImplementation::RetrieveCPUClockSpeed() if (!retrieved) { HKEY hKey = NULL; - LONG err = RegOpenKeyEx(HKEY_LOCAL_MACHINE, - "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", 0, + LONG err = RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", 0, KEY_READ, &hKey); if (ERROR_SUCCESS == err) @@ -2455,7 +2464,7 @@ bool SystemInformationImplementation::RetrieveCPUClockSpeed() DWORD data = 0; DWORD dwSize = sizeof(DWORD); - err = RegQueryValueEx(hKey, "~MHz", 0, + err = RegQueryValueExW(hKey, L"~MHz", 0, &dwType, (LPBYTE) &data, &dwSize); if (ERROR_SUCCESS == err) @@ -3153,8 +3162,17 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile() kwsys_stl::string cores = this->ExtractValueFromCpuInfoFile(buffer,"cpu cores"); int numberOfCoresPerCPU=atoi(cores.c_str()); - this->NumberOfPhysicalCPU=static_cast<unsigned int>( - numberOfCoresPerCPU*(maxId+1)); + if (maxId > 0) + { + this->NumberOfPhysicalCPU=static_cast<unsigned int>( + numberOfCoresPerCPU*(maxId+1)); + } + else + { + // Linux Sparc: get cpu count + this->NumberOfPhysicalCPU= + atoi(this->ExtractValueFromCpuInfoFile(buffer,"ncpus active").c_str()); + } #else // __CYGWIN__ // does not have "physical id" entries, neither "cpu cores" @@ -3176,7 +3194,19 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile() // CPU speed (checking only the first processor) kwsys_stl::string CPUSpeed = this->ExtractValueFromCpuInfoFile(buffer,"cpu MHz"); - this->CPUSpeedInMHz = static_cast<float>(atof(CPUSpeed.c_str())); + if(!CPUSpeed.empty()) + { + this->CPUSpeedInMHz = static_cast<float>(atof(CPUSpeed.c_str())); + } +#ifdef __linux + else + { + // Linux Sparc: CPU speed is in Hz and encoded in hexadecimal + CPUSpeed = this->ExtractValueFromCpuInfoFile(buffer,"Cpu0ClkTck"); + this->CPUSpeedInMHz = static_cast<float>( + strtoull(CPUSpeed.c_str(),0,16))/1000000.0f; + } +#endif // Chip family kwsys_stl::string familyStr = @@ -3836,7 +3866,8 @@ bool SystemInformationImplementation::QueryLinuxMemory() unsigned long temp; unsigned long cachedMem; unsigned long buffersMem; - char *r=fgets(buffer, sizeof(buffer), fd); // Skip "total: used:..." + // Skip "total: used:..." + char *r=fgets(buffer, static_cast<int>(sizeof(buffer)), fd); int status=0; if(r==buffer) { @@ -4981,7 +5012,12 @@ bool SystemInformationImplementation::QueryHPUXProcessor() case CPU_PA_RISC2_0: this->ChipID.Vendor = "Hewlett-Packard"; this->ChipID.Family = 0x200; +# ifdef CPU_HP_INTEL_EM_1_0 + case CPU_HP_INTEL_EM_1_0: +# endif +# ifdef CPU_IA64_ARCHREV_0 case CPU_IA64_ARCHREV_0: +# endif this->ChipID.Vendor = "GenuineIntel"; this->Features.HasIA64 = true; break; @@ -5007,19 +5043,19 @@ bool SystemInformationImplementation::QueryOSInformation() this->OSName = "Windows"; - OSVERSIONINFOEX osvi; + OSVERSIONINFOEXW osvi; BOOL bIsWindows64Bit; BOOL bOsVersionInfoEx; char operatingSystem[256]; // Try calling GetVersionEx using the OSVERSIONINFOEX structure. - ZeroMemory (&osvi, sizeof (OSVERSIONINFOEX)); - osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX); - bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi); + ZeroMemory (&osvi, sizeof (OSVERSIONINFOEXW)); + osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEXW); + bOsVersionInfoEx = GetVersionExW ((OSVERSIONINFOW*)&osvi); if (!bOsVersionInfoEx) { - osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); - if (!GetVersionEx ((OSVERSIONINFO *) &osvi)) + osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOW); + if (!GetVersionExW((OSVERSIONINFOW*)&osvi)) { return false; } @@ -5105,19 +5141,19 @@ bool SystemInformationImplementation::QueryOSInformation() #endif // VER_NT_WORKSTATION { HKEY hKey; - char szProductType[80]; + wchar_t szProductType[80]; DWORD dwBufLen; // Query the registry to retrieve information. - RegOpenKeyEx (HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\ProductOptions", 0, KEY_QUERY_VALUE, &hKey); - RegQueryValueEx (hKey, "ProductType", NULL, NULL, (LPBYTE) szProductType, &dwBufLen); + RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\ProductOptions", 0, KEY_QUERY_VALUE, &hKey); + RegQueryValueExW(hKey, L"ProductType", NULL, NULL, (LPBYTE) szProductType, &dwBufLen); RegCloseKey (hKey); - if (lstrcmpi ("WINNT", szProductType) == 0) + if (lstrcmpiW(L"WINNT", szProductType) == 0) { this->OSRelease += " Professional"; } - if (lstrcmpi ("LANMANNT", szProductType) == 0) + if (lstrcmpiW(L"LANMANNT", szProductType) == 0) { // Decide between Windows 2000 Advanced Server and Windows .NET Enterprise Server. if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) @@ -5129,7 +5165,7 @@ bool SystemInformationImplementation::QueryOSInformation() this->OSRelease += " Server"; } } - if (lstrcmpi ("SERVERNT", szProductType) == 0) + if (lstrcmpiW(L"SERVERNT", szProductType) == 0) { // Decide between Windows 2000 Advanced Server and Windows .NET Enterprise Server. if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) @@ -5162,7 +5198,7 @@ bool SystemInformationImplementation::QueryOSInformation() LPFNPROC DLLProc; // Load the Kernel32 DLL. - hKernelDLL = LoadLibrary ("kernel32"); + hKernelDLL = LoadLibraryW(L"kernel32"); if (hKernelDLL != NULL) { // Only XP and .NET Server support IsWOW64Process so... Load dynamically! DLLProc = (LPFNPROC) GetProcAddress (hKernelDLL, "IsWow64Process"); diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index e9a1fd3..f4a443f 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -20,6 +20,8 @@ #include KWSYS_HEADER(RegularExpression.hxx) #include KWSYS_HEADER(SystemTools.hxx) #include KWSYS_HEADER(Directory.hxx) +#include KWSYS_HEADER(FStream.hxx) +#include KWSYS_HEADER(Encoding.hxx) #include KWSYS_HEADER(ios/iostream) #include KWSYS_HEADER(ios/fstream) @@ -32,6 +34,8 @@ #if 0 # include "SystemTools.hxx.in" # include "Directory.hxx.in" +# include "FStream.hxx.in" +# include "Encoding.hxx.in" # include "kwsys_ios_iostream.h.in" # include "kwsys_ios_fstream.h.in" # include "kwsys_ios_sstream.h.in" @@ -75,6 +79,9 @@ // Windows API. #if defined(_WIN32) # include <windows.h> +# ifndef INVALID_FILE_ATTRIBUTES +# define INVALID_FILE_ATTRIBUTES ((DWORD)-1) +# endif #elif defined (__CYGWIN__) # include <windows.h> # undef _WIN32 @@ -152,11 +159,6 @@ public: #define _chdir chdir #endif -#if defined(__HAIKU__) -#include <os/kernel/OS.h> -#include <os/storage/Path.h> -#endif - #if defined(__BEOS__) && !defined(__ZETA__) #include <be/kernel/OS.h> #include <be/storage/Path.h> @@ -188,22 +190,25 @@ static inline char *realpath(const char *path, char *resolved_path) #if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__)) inline int Mkdir(const char* dir) { - return _mkdir(dir); + return _wmkdir(KWSYS_NAMESPACE::Encoding::ToWide(dir).c_str()); } inline int Rmdir(const char* dir) { - return _rmdir(dir); + return _wrmdir(KWSYS_NAMESPACE::Encoding::ToWide(dir).c_str()); } inline const char* Getcwd(char* buf, unsigned int len) { - if(const char* ret = _getcwd(buf, len)) + std::vector<wchar_t> w_buf(len); + if(const wchar_t* ret = _wgetcwd(&w_buf[0], len)) { // make sure the drive letter is capital - if(strlen(buf) > 1 && buf[1] == ':') + if(wcslen(&w_buf[0]) > 1 && w_buf[1] == L':') { - buf[0] = toupper(buf[0]); + w_buf[0] = towupper(w_buf[0]); } - return ret; + std::string tmp = KWSYS_NAMESPACE::Encoding::ToNarrow(&w_buf[0]); + strcpy(buf, tmp.c_str()); + return buf; } return 0; } @@ -212,16 +217,18 @@ inline int Chdir(const char* dir) #if defined(__BORLANDC__) return chdir(dir); #else - return _chdir(dir); + return _wchdir(KWSYS_NAMESPACE::Encoding::ToWide(dir).c_str()); #endif } inline void Realpath(const char *path, kwsys_stl::string & resolved_path) { - char *ptemp; - char fullpath[MAX_PATH]; - if( GetFullPathName(path, sizeof(fullpath), fullpath, &ptemp) ) + kwsys_stl::wstring tmp = KWSYS_NAMESPACE::Encoding::ToWide(path); + wchar_t *ptemp; + wchar_t fullpath[MAX_PATH]; + if( GetFullPathNameW(tmp.c_str(), sizeof(fullpath)/sizeof(fullpath[0]), + fullpath, &ptemp) ) { - resolved_path = fullpath; + resolved_path = KWSYS_NAMESPACE::Encoding::ToNarrow(fullpath); KWSYS_NAMESPACE::SystemTools::ConvertToUnixSlashes(resolved_path); } else @@ -596,6 +603,15 @@ const char* SystemTools::GetExecutableExtension() #endif } +FILE* SystemTools::Fopen(const char* file, const char* mode) +{ +#ifdef _WIN32 + return _wfopen(Encoding::ToWide(file).c_str(), + Encoding::ToWide(mode).c_str()); +#else + return fopen(file, mode); +#endif +} bool SystemTools::MakeDirectory(const char* path) { @@ -745,7 +761,7 @@ static DWORD SystemToolsMakeRegistryMode(DWORD mode, SystemTools::KeyWOW64 view) { // only add the modes when on a system that supports Wow64. - static FARPROC wow64p = GetProcAddress(GetModuleHandle("kernel32"), + static FARPROC wow64p = GetProcAddress(GetModuleHandleW(L"kernel32"), "IsWow64Process"); if(wow64p == NULL) { @@ -779,8 +795,8 @@ SystemTools::GetRegistrySubKeys(const char *key, } HKEY hKey; - if(RegOpenKeyEx(primaryKey, - second.c_str(), + if(RegOpenKeyExW(primaryKey, + Encoding::ToWide(second).c_str(), 0, SystemToolsMakeRegistryMode(KEY_READ, view), &hKey) != ERROR_SUCCESS) @@ -789,13 +805,13 @@ SystemTools::GetRegistrySubKeys(const char *key, } else { - char name[1024]; + wchar_t name[1024]; DWORD dwNameSize = sizeof(name)/sizeof(name[0]); DWORD i = 0; - while (RegEnumKey(hKey, i, name, dwNameSize) == ERROR_SUCCESS) + while (RegEnumKeyW(hKey, i, name, dwNameSize) == ERROR_SUCCESS) { - subkeys.push_back(name); + subkeys.push_back(Encoding::ToNarrow(name)); ++i; } @@ -834,8 +850,8 @@ bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value, } HKEY hKey; - if(RegOpenKeyEx(primaryKey, - second.c_str(), + if(RegOpenKeyExW(primaryKey, + Encoding::ToWide(second).c_str(), 0, SystemToolsMakeRegistryMode(KEY_READ, view), &hKey) != ERROR_SUCCESS) @@ -846,9 +862,9 @@ bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value, { DWORD dwType, dwSize; dwSize = 1023; - char data[1024]; - if(RegQueryValueEx(hKey, - (LPTSTR)valuename.c_str(), + wchar_t data[1024]; + if(RegQueryValueExW(hKey, + Encoding::ToWide(valuename).c_str(), NULL, &dwType, (BYTE *)data, @@ -856,16 +872,17 @@ bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value, { if (dwType == REG_SZ) { - value = data; + value = Encoding::ToNarrow(data); valueset = true; } else if (dwType == REG_EXPAND_SZ) { - char expanded[1024]; + wchar_t expanded[1024]; DWORD dwExpandedSize = sizeof(expanded)/sizeof(expanded[0]); - if(ExpandEnvironmentStrings(data, expanded, dwExpandedSize)) + if(ExpandEnvironmentStringsW(data, expanded, + dwExpandedSize)) { - value = expanded; + value = Encoding::ToNarrow(expanded); valueset = true; } } @@ -906,9 +923,9 @@ bool SystemTools::WriteRegistryValue(const char *key, const char *value, HKEY hKey; DWORD dwDummy; - char lpClass[] = ""; - if(RegCreateKeyEx(primaryKey, - second.c_str(), + wchar_t lpClass[] = L""; + if(RegCreateKeyExW(primaryKey, + Encoding::ToWide(second).c_str(), 0, lpClass, REG_OPTION_NON_VOLATILE, @@ -920,12 +937,13 @@ bool SystemTools::WriteRegistryValue(const char *key, const char *value, return false; } - if(RegSetValueEx(hKey, - (LPTSTR)valuename.c_str(), + std::wstring wvalue = Encoding::ToWide(value); + if(RegSetValueExW(hKey, + Encoding::ToWide(valuename).c_str(), 0, REG_SZ, - (CONST BYTE *)value, - (DWORD)(strlen(value) + 1)) == ERROR_SUCCESS) + (CONST BYTE *)wvalue.c_str(), + (DWORD)(sizeof(wchar_t) * (wvalue.size() + 1))) == ERROR_SUCCESS) { return true; } @@ -957,8 +975,8 @@ bool SystemTools::DeleteRegistryValue(const char *key, KeyWOW64 view) } HKEY hKey; - if(RegOpenKeyEx(primaryKey, - second.c_str(), + if(RegOpenKeyExW(primaryKey, + Encoding::ToWide(second).c_str(), 0, SystemToolsMakeRegistryMode(KEY_WRITE, view), &hKey) != ERROR_SUCCESS) @@ -988,7 +1006,7 @@ bool SystemTools::SameFile(const char* file1, const char* file2) #ifdef _WIN32 HANDLE hFile1, hFile2; - hFile1 = CreateFile( file1, + hFile1 = CreateFileW( Encoding::ToWide(file1).c_str(), GENERIC_READ, FILE_SHARE_READ , NULL, @@ -996,7 +1014,7 @@ bool SystemTools::SameFile(const char* file1, const char* file2) FILE_FLAG_BACKUP_SEMANTICS, NULL ); - hFile2 = CreateFile( file2, + hFile2 = CreateFileW( Encoding::ToWide(file2).c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, @@ -1045,15 +1063,6 @@ bool SystemTools::SameFile(const char* file1, const char* file2) } //---------------------------------------------------------------------------- -#if defined(_WIN32) || defined(__CYGWIN__) -static bool WindowsFileExists(const char* filename) -{ - WIN32_FILE_ATTRIBUTE_DATA fd; - return GetFileAttributesExA(filename, GetFileExInfoStandard, &fd) != 0; -} -#endif - -//---------------------------------------------------------------------------- bool SystemTools::FileExists(const char* filename) { if(!(filename && *filename)) @@ -1065,11 +1074,12 @@ bool SystemTools::FileExists(const char* filename) char winpath[MAX_PATH]; if(SystemTools::PathCygwinToWin32(filename, winpath)) { - return WindowsFileExists(winpath); + return (GetFileAttributesA(winpath) != INVALID_FILE_ATTRIBUTES); } return access(filename, R_OK) == 0; #elif defined(_WIN32) - return WindowsFileExists(filename); + return (GetFileAttributesW(Encoding::ToWide(filename).c_str()) + != INVALID_FILE_ATTRIBUTES); #else return access(filename, R_OK) == 0; #endif @@ -1112,7 +1122,7 @@ bool SystemTools::Touch(const char* filename, bool create) { if(create && !SystemTools::FileExists(filename)) { - FILE* file = fopen(filename, "a+b"); + FILE* file = Fopen(filename, "a+b"); if(file) { fclose(file); @@ -1121,7 +1131,8 @@ bool SystemTools::Touch(const char* filename, bool create) return false; } #if defined(_WIN32) && !defined(__CYGWIN__) - HANDLE h = CreateFile(filename, FILE_WRITE_ATTRIBUTES, + HANDLE h = CreateFileW(Encoding::ToWide(filename).c_str(), + FILE_WRITE_ATTRIBUTES, FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); if(!h) @@ -1225,11 +1236,13 @@ bool SystemTools::FileTimeCompare(const char* f1, const char* f2, // Windows version. Get the modification time from extended file attributes. WIN32_FILE_ATTRIBUTE_DATA f1d; WIN32_FILE_ATTRIBUTE_DATA f2d; - if(!GetFileAttributesEx(f1, GetFileExInfoStandard, &f1d)) + if(!GetFileAttributesExW(Encoding::ToWide(f1).c_str(), + GetFileExInfoStandard, &f1d)) { return false; } - if(!GetFileAttributesEx(f2, GetFileExInfoStandard, &f2d)) + if(!GetFileAttributesExW(Encoding::ToWide(f2).c_str(), + GetFileExInfoStandard, &f2d)) { return false; } @@ -1937,6 +1950,39 @@ bool SystemTools::CopyFileIfDifferent(const char* source, bool SystemTools::FilesDiffer(const char* source, const char* destination) { + +#if defined(_WIN32) + WIN32_FILE_ATTRIBUTE_DATA statSource; + if (GetFileAttributesExW(Encoding::ToWide(source).c_str(), + GetFileExInfoStandard, + &statSource) == 0) + { + return true; + } + + WIN32_FILE_ATTRIBUTE_DATA statDestination; + if (GetFileAttributesExW(Encoding::ToWide(destination).c_str(), + GetFileExInfoStandard, + &statDestination) == 0) + { + return true; + } + + if(statSource.nFileSizeHigh != statDestination.nFileSizeHigh || + statSource.nFileSizeLow != statDestination.nFileSizeLow) + { + return true; + } + + if(statSource.nFileSizeHigh == 0 && statSource.nFileSizeLow == 0) + { + return false; + } + off_t nleft = ((__int64)statSource.nFileSizeHigh << 32) + + statSource.nFileSizeLow; + +#else + struct stat statSource; if (stat(source, &statSource) != 0) { @@ -1958,15 +2004,19 @@ bool SystemTools::FilesDiffer(const char* source, { return false; } + off_t nleft = statSource.st_size; +#endif -#if defined(_WIN32) || defined(__CYGWIN__) - kwsys_ios::ifstream finSource(source, (kwsys_ios::ios::binary | - kwsys_ios::ios::in)); - kwsys_ios::ifstream finDestination(destination, (kwsys_ios::ios::binary | - kwsys_ios::ios::in)); +#if defined(_WIN32) + kwsys::ifstream finSource(source, + (kwsys_ios::ios::binary | + kwsys_ios::ios::in)); + kwsys::ifstream finDestination(destination, + (kwsys_ios::ios::binary | + kwsys_ios::ios::in)); #else - kwsys_ios::ifstream finSource(source); - kwsys_ios::ifstream finDestination(destination); + kwsys::ifstream finSource(source); + kwsys::ifstream finDestination(destination); #endif if(!finSource || !finDestination) { @@ -1976,7 +2026,6 @@ bool SystemTools::FilesDiffer(const char* source, // Compare the files a block at a time. char source_buf[KWSYS_ST_BUFFER]; char dest_buf[KWSYS_ST_BUFFER]; - off_t nleft = statSource.st_size; while(nleft > 0) { // Read a block from each file. @@ -2049,10 +2098,10 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination) // Open files #if defined(_WIN32) || defined(__CYGWIN__) - kwsys_ios::ifstream fin(source, - kwsys_ios::ios::binary | kwsys_ios::ios::in); + kwsys::ifstream fin(source, + kwsys_ios::ios::binary | kwsys_ios::ios::in); #else - kwsys_ios::ifstream fin(source); + kwsys::ifstream fin(source); #endif if(!fin) { @@ -2066,10 +2115,10 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination) SystemTools::RemoveFile(destination); #if defined(_WIN32) || defined(__CYGWIN__) - kwsys_ios::ofstream fout(destination, + kwsys::ofstream fout(destination, kwsys_ios::ios::binary | kwsys_ios::ios::out | kwsys_ios::ios::trunc); #else - kwsys_ios::ofstream fout(destination, + kwsys::ofstream fout(destination, kwsys_ios::ios::out | kwsys_ios::ios::trunc); #endif if(!fout) @@ -2349,7 +2398,11 @@ bool SystemTools::RemoveFile(const char* source) /* Win32 unlink is stupid --- it fails if the file is read-only */ SystemTools::SetPermissions(source, S_IWRITE); #endif +#ifdef _WIN32 + bool res = _wunlink(Encoding::ToWide(source).c_str()) != 0 ? false : true; +#else bool res = unlink(source) != 0 ? false : true; +#endif #ifdef _WIN32 if ( !res ) { @@ -2794,12 +2847,15 @@ bool SystemTools::FileIsDirectory(const char* name) } // Now check the file node type. +#if defined( _WIN32 ) + DWORD attr = GetFileAttributesW(Encoding::ToWide(name).c_str()); + if (attr != INVALID_FILE_ATTRIBUTES) + { + return (attr & FILE_ATTRIBUTE_DIRECTORY) != 0; +#else struct stat fs; if(stat(name, &fs) == 0) { -#if defined( _WIN32 ) && !defined(__CYGWIN__) - return ((fs.st_mode & _S_IFDIR) != 0); -#else return S_ISDIR(fs.st_mode); #endif } @@ -3284,11 +3340,12 @@ static int GetCasePathName(const kwsys_stl::string & pathIn, kwsys_stl::string test_str = casePath; test_str += path_components[idx]; - WIN32_FIND_DATA findData; - HANDLE hFind = ::FindFirstFile(test_str.c_str(), &findData); + WIN32_FIND_DATAW findData; + HANDLE hFind = ::FindFirstFileW(Encoding::ToWide(test_str).c_str(), + &findData); if (INVALID_HANDLE_VALUE != hFind) { - casePath += findData.cFileName; + casePath += Encoding::ToNarrow(findData.cFileName); ::FindClose(hFind); } else @@ -3738,8 +3795,7 @@ bool SystemTools::FileHasSignature(const char *filename, return false; } - FILE *fp; - fp = fopen(filename, "rb"); + FILE *fp = Fopen(filename, "rb"); if (!fp) { return false; @@ -3772,8 +3828,7 @@ SystemTools::DetectFileType(const char *filename, return SystemTools::FileTypeUnknown; } - FILE *fp; - fp = fopen(filename, "rb"); + FILE *fp = Fopen(filename, "rb"); if (!fp) { return SystemTools::FileTypeUnknown; @@ -3963,9 +4018,8 @@ bool SystemTools::GetShortPath(const char* path, kwsys_stl::string& shortPath) { #if defined(WIN32) && !defined(__CYGWIN__) const int size = int(strlen(path)) +1; // size of return - char *buffer = new char[size]; // create a buffer char *tempPath = new char[size]; // create a buffer - int ret; + DWORD ret; // if the path passed in has quotes around it, first remove the quotes if (path[0] == '"' && path[strlen(path)-1] == '"') @@ -3978,19 +4032,20 @@ bool SystemTools::GetShortPath(const char* path, kwsys_stl::string& shortPath) strcpy(tempPath,path); } + kwsys_stl::wstring wtempPath = Encoding::ToWide(tempPath); + kwsys_stl::vector<wchar_t> buffer(wtempPath.size()+1); buffer[0] = 0; - ret = GetShortPathName(tempPath, buffer, size); + ret = GetShortPathNameW(Encoding::ToWide(tempPath).c_str(), + &buffer[0], static_cast<DWORD>(wtempPath.size())); - if(buffer[0] == 0 || ret > size) + if(buffer[0] == 0 || ret > wtempPath.size()) { - delete [] buffer; delete [] tempPath; return false; } else { - shortPath = buffer; - delete [] buffer; + shortPath = Encoding::ToNarrow(&buffer[0]); delete [] tempPath; return true; } @@ -4217,12 +4272,45 @@ bool SystemTools::GetPermissions(const char* file, mode_t& mode) return false; } +#if defined(_WIN32) + DWORD attr = GetFileAttributesW(Encoding::ToWide(file).c_str()); + if(attr == INVALID_FILE_ATTRIBUTES) + { + return false; + } + if((attr & FILE_ATTRIBUTE_READONLY) != 0) + { + mode = (_S_IREAD | (_S_IREAD >> 3) | (_S_IREAD >> 6)); + } + else + { + mode = (_S_IWRITE | (_S_IWRITE >> 3) | (_S_IWRITE >> 6)) | + (_S_IREAD | (_S_IREAD >> 3) | (_S_IREAD >> 6)); + } + if((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) + { + mode |= S_IFDIR | (_S_IEXEC | (_S_IEXEC >> 3) | (_S_IEXEC >> 6)); + } + else + { + mode |= S_IFREG; + } + const char* ext = strrchr(file, '.'); + if(ext && (Strucmp(ext, ".exe") == 0 || + Strucmp(ext, ".com") == 0 || + Strucmp(ext, ".cmd") == 0 || + Strucmp(ext, ".bat") == 0)) + { + mode |= (_S_IEXEC | (_S_IEXEC >> 3) | (_S_IEXEC >> 6)); + } +#else struct stat st; if ( stat(file, &st) < 0 ) { return false; } mode = st.st_mode; +#endif return true; } @@ -4236,7 +4324,11 @@ bool SystemTools::SetPermissions(const char* file, mode_t mode) { return false; } +#ifdef _WIN32 + if ( _wchmod(Encoding::ToWide(file).c_str(), mode) < 0 ) +#else if ( chmod(file, mode) < 0 ) +#endif { return false; } @@ -4341,7 +4433,9 @@ void SystemTools::ConvertWindowsCommandLineToUnixArguments( (*argv)[0] = new char [1024]; #ifdef _WIN32 - ::GetModuleFileName(0, (*argv)[0], 1024); + wchar_t tmp[1024]; + ::GetModuleFileNameW(0, tmp, 1024); + strcpy((*argv)[0], Encoding::ToNarrow(tmp).c_str()); #else (*argv)[0][0] = '\0'; #endif @@ -4401,14 +4495,14 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() #ifdef _WIN32 char buffer[256]; - OSVERSIONINFOEX osvi; + OSVERSIONINFOEXA osvi; BOOL bOsVersionInfoEx; // Try calling GetVersionEx using the OSVERSIONINFOEX structure. // If that fails, try using the OSVERSIONINFO structure. - ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + ZeroMemory(&osvi, sizeof(OSVERSIONINFOEXA)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA); bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *)&osvi); if (!bOsVersionInfoEx) @@ -4551,21 +4645,21 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() { HKEY hKey; #define BUFSIZE 80 - char szProductType[BUFSIZE]; + wchar_t szProductType[BUFSIZE]; DWORD dwBufLen=BUFSIZE; LONG lRet; - lRet = RegOpenKeyEx( + lRet = RegOpenKeyExW( HKEY_LOCAL_MACHINE, - "SYSTEM\\CurrentControlSet\\Control\\ProductOptions", + L"SYSTEM\\CurrentControlSet\\Control\\ProductOptions", 0, KEY_QUERY_VALUE, &hKey); if (lRet != ERROR_SUCCESS) { return 0; } - lRet = RegQueryValueEx(hKey, "ProductType", NULL, NULL, - (LPBYTE) szProductType, &dwBufLen); + lRet = RegQueryValueExW(hKey, L"ProductType", NULL, NULL, + (LPBYTE) szProductType, &dwBufLen); if ((lRet != ERROR_SUCCESS) || (dwBufLen > BUFSIZE)) { @@ -4574,15 +4668,15 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() RegCloseKey(hKey); - if (lstrcmpi("WINNT", szProductType) == 0) + if (lstrcmpiW(L"WINNT", szProductType) == 0) { res += " Workstation"; } - if (lstrcmpi("LANMANNT", szProductType) == 0) + if (lstrcmpiW(L"LANMANNT", szProductType) == 0) { res += " Server"; } - if (lstrcmpi("SERVERNT", szProductType) == 0) + if (lstrcmpiW(L"SERVERNT", szProductType) == 0) { res += " Advanced Server"; } @@ -4598,16 +4692,16 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() // Display service pack (if any) and build number. if (osvi.dwMajorVersion == 4 && - lstrcmpi(osvi.szCSDVersion, "Service Pack 6") == 0) + lstrcmpiA(osvi.szCSDVersion, "Service Pack 6") == 0) { HKEY hKey; LONG lRet; // Test for SP6 versus SP6a. - lRet = RegOpenKeyEx( + lRet = RegOpenKeyExW( HKEY_LOCAL_MACHINE, - "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009", + L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009", 0, KEY_QUERY_VALUE, &hKey); if (lRet == ERROR_SUCCESS) diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index d6dae39..9457a4e 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -24,6 +24,8 @@ // Required for va_list #include <stdarg.h> +// Required for FILE* +#include <stdio.h> #if @KWSYS_NAMESPACE@_STL_HAVE_STD && !defined(va_list) // Some compilers move va_list into the std namespace and there is no way to // tell that this has been done. Playing with things being included before or @@ -42,10 +44,6 @@ namespace @KWSYS_NAMESPACE@ } #endif // va_list -#if defined( _MSC_VER ) -typedef unsigned short mode_t; -#endif - /* Define these macros temporarily to keep the code readable. */ #if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS # define kwsys_stl @KWSYS_NAMESPACE@_stl @@ -497,6 +495,11 @@ public: */ /** + * Open a file considering unicode. + */ + static FILE* Fopen(const char* file, const char* mode); + + /** * Make a new directory if it is not there. This function * can make a full path even if none of the directories existed * prior to calling this function. @@ -684,6 +687,10 @@ public: */ static long int CreationTime(const char* filename); + #if defined( _MSC_VER ) + typedef unsigned short mode_t; + #endif + /** * Get and set permissions of the file. */ diff --git a/Source/kwsys/Terminal.c b/Source/kwsys/Terminal.c index 25832c2..6d7ec41 100644 --- a/Source/kwsys/Terminal.c +++ b/Source/kwsys/Terminal.c @@ -155,6 +155,7 @@ static const char* kwsysTerminalVT100Names[] = "mach-color", "mlterm", "putty", + "putty-256color", "rxvt", "rxvt-256color", "rxvt-cygwin", diff --git a/Source/kwsys/kwsysPlatformTestsCXX.cxx b/Source/kwsys/kwsysPlatformTestsCXX.cxx index be7a09e..3f947f3 100644 --- a/Source/kwsys/kwsysPlatformTestsCXX.cxx +++ b/Source/kwsys/kwsysPlatformTestsCXX.cxx @@ -674,3 +674,9 @@ int main() return a; } #endif + +#ifdef TEST_KWSYS_STL_HAS_WSTRING +#include <string> +void f(std ::wstring*) {} +int main() { return 0; } +#endif diff --git a/Source/kwsys/testDynamicLoader.cxx b/Source/kwsys/testDynamicLoader.cxx index dd6d603..1bff707 100644 --- a/Source/kwsys/testDynamicLoader.cxx +++ b/Source/kwsys/testDynamicLoader.cxx @@ -15,14 +15,10 @@ #include KWSYS_HEADER(ios/iostream) #include KWSYS_HEADER(stl/string) -#if defined(__BEOS__) +#if defined(__BEOS__) || defined(__HAIKU__) #include <be/kernel/OS.h> /* disable_debugger() API. */ #endif -#if defined(__HAIKU__) -#include <os/kernel/OS.h> /* disable_debugger() API. */ -#endif - // Work-around CMake dependency scanning limitation. This must // duplicate the above list of headers. #if 0 diff --git a/Source/kwsys/testEncoding.cxx b/Source/kwsys/testEncoding.cxx new file mode 100644 index 0000000..094588c --- /dev/null +++ b/Source/kwsys/testEncoding.cxx @@ -0,0 +1,199 @@ +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "kwsysPrivate.h" + +#if defined(_MSC_VER) +# pragma warning (disable:4786) +#endif + +#include KWSYS_HEADER(Encoding.hxx) +#include KWSYS_HEADER(Encoding.h) +#include KWSYS_HEADER(ios/iostream) + +#include <locale.h> +#include <string.h> +#include <stdlib.h> + +// Work-around CMake dependency scanning limitation. This must +// duplicate the above list of headers. +#if 0 +# include "Encoding.hxx.in" +# include "Encoding.h.in" +# include "kwsys_ios_iostream.h.in" +#endif + +//---------------------------------------------------------------------------- +static const unsigned char helloWorldStrings[][32] = +{ + // English + {'H','e','l','l','o',' ','W','o','r','l','d',0}, + // Japanese + {0xE3, 0x81, 0x93, 0xE3, 0x82, 0x93, 0xE3, 0x81, 0xAB, 0xE3, + 0x81, 0xA1, 0xE3, 0x81, 0xAF, 0xE4, 0xB8, 0x96, 0xE7, 0x95, + 0x8C, 0}, + // Arabic + {0xD9, 0x85, 0xD8, 0xB1, 0xD8, 0xAD, 0xD8, 0xA8, 0xD8, 0xA7, + 0x20, 0xD8, 0xA7, 0xD9, 0x84, 0xD8, 0xB9, 0xD8, 0xA7, 0xD9, + 0x84, 0xD9, 0x85, 0}, + // Yiddish + {0xD7, 0x94, 0xD7, 0xA2, 0xD7, 0x9C, 0xD7, 0x90, 0x20, 0xD7, + 0x95, 0xD7, 0x95, 0xD7, 0xA2, 0xD7, 0x9C, 0xD7, 0x98, 0}, + // Russian + {0xD0, 0xBF, 0xD1, 0x80, 0xD0, 0xB8, 0xD0, 0xB2, 0xD0, 0xB5, + 0xD1, 0x82, 0x20, 0xD0, 0xBC, 0xD0, 0xB8, 0xD1, 0x80, 0}, + // Latin + {0x4D, 0x75, 0x6E, 0x64, 0x75, 0x73, 0x20, 0x73, 0x61, 0x6C, + 0x76, 0x65, 0}, + // Swahili + {0x68, 0x75, 0x6A, 0x61, 0x6D, 0x62, 0x6F, 0x20, 0x44, 0x75, + 0x6E, 0x69, 0x61, 0}, + // Icelandic + {0x48, 0x61, 0x6C, 0x6C, 0xC3, 0xB3, 0x20, 0x68, 0x65, 0x69, + 0x6D, 0x75, 0x72, 0}, + {0} +}; + +//---------------------------------------------------------------------------- +static int testHelloWorldEncoding() +{ + int ret = 0; + for(int i=0; helloWorldStrings[i][0] != 0; i++) + { + std::string str = reinterpret_cast<const char*>(helloWorldStrings[i]); + std::cout << str << std::endl; + std::wstring wstr = kwsys::Encoding::ToWide(str); + std::string str2 = kwsys::Encoding::ToNarrow(wstr); + wchar_t* c_wstr = kwsysEncoding_DupToWide(str.c_str()); + char* c_str2 = kwsysEncoding_DupToNarrow(c_wstr); + if(!wstr.empty() && (str != str2 || strcmp(c_str2, str.c_str()))) + { + std::cout << "converted string was different: " << str2 << std::endl; + std::cout << "converted string was different: " << c_str2 << std::endl; + ret++; + } + free(c_wstr); + free(c_str2); + } + return ret; +} + +static int testRobustEncoding() +{ + // test that the conversion functions handle invalid + // unicode correctly/gracefully + + int ret = 0; + char cstr[] = {(char)-1, 0}; + // this conversion could fail + std::wstring wstr = kwsys::Encoding::ToWide(cstr); + + wstr = kwsys::Encoding::ToWide(NULL); + if(wstr != L"") + { + const wchar_t* wcstr = wstr.c_str(); + std::cout << "ToWide(NULL) returned"; + for(size_t i=0; i<wstr.size(); i++) + { + std::cout << " " << std::hex << (int)wcstr[i]; + } + std::cout << std::endl; + ret++; + } + wstr = kwsys::Encoding::ToWide(""); + if(wstr != L"") + { + const wchar_t* wcstr = wstr.c_str(); + std::cout << "ToWide(\"\") returned"; + for(size_t i=0; i<wstr.size(); i++) + { + std::cout << " " << std::hex << (int)wcstr[i]; + } + std::cout << std::endl; + ret++; + } + +#ifdef WIN32 + // 16 bit wchar_t - we make an invalid surrogate pair + wchar_t cwstr[] = {0xD801, 0xDA00, 0}; + // this conversion could fail + std::string win_str = kwsys::Encoding::ToNarrow(cwstr); +#endif + + std::string str = kwsys::Encoding::ToNarrow(NULL); + if(str != "") + { + std::cout << "ToNarrow(NULL) returned " << str << std::endl; + ret++; + } + + str = kwsys::Encoding::ToNarrow(L""); + if(wstr != L"") + { + std::cout << "ToNarrow(\"\") returned " << str << std::endl; + ret++; + } + + return ret; +} + +static int testCommandLineArguments() +{ + int status = 0; + + char const* argv[2] = { + "./app.exe", + (char const*)helloWorldStrings[1] + }; + + kwsys::Encoding::CommandLineArguments args(2, argv); + kwsys::Encoding::CommandLineArguments arg2 = + kwsys::Encoding::CommandLineArguments(args); + + char const* const* u8_argv = args.argv(); + for(int i=0; i<args.argc(); i++) + { + char const* u8_arg = u8_argv[i]; + if(strcmp(argv[i], u8_arg) != 0) + { + std::cout << "argv[" << i << "] " << argv[i] << " != " + << u8_arg << std::endl; + status++; + } + } + + kwsys::Encoding::CommandLineArguments args3 = + kwsys::Encoding::CommandLineArguments::Main(2, argv); + + return status; +} + +//---------------------------------------------------------------------------- +int testEncoding(int, char*[]) +{ + const char* loc = setlocale(LC_ALL, ""); + if(loc) + { + std::cout << "Locale: " << loc << std::endl; + } + else + { + std::cout << "Locale: None" << std::endl; + } + + int ret = 0; + + ret |= testHelloWorldEncoding(); + ret |= testRobustEncoding(); + ret |= testCommandLineArguments(); + + return ret; +} diff --git a/Source/kwsys/testFStream.cxx b/Source/kwsys/testFStream.cxx new file mode 100644 index 0000000..8942549 --- /dev/null +++ b/Source/kwsys/testFStream.cxx @@ -0,0 +1,48 @@ +/*============================================================================ + KWSys - Kitware System Library + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "kwsysPrivate.h" + +#if defined(_MSC_VER) +# pragma warning (disable:4786) +#endif + +#include KWSYS_HEADER(FStream.hxx) + +// Work-around CMake dependency scanning limitation. This must +// duplicate the above list of headers. +#if 0 +# include "FStream.hxx.in" +#endif + + +//---------------------------------------------------------------------------- +static int testNoFile() +{ + kwsys::ifstream in_file("NoSuchFile.txt"); + if(in_file) + { + return 1; + } + + return 0; +} + + +//---------------------------------------------------------------------------- +int testFStream(int, char*[]) +{ + int ret = 0; + + ret |= testNoFile(); + + return ret; +} |