diff options
Diffstat (limited to 'Source')
137 files changed, 1832 insertions, 640 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 3c944fb..dbb922d 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -186,6 +186,8 @@ set(SRCS cmExportSetMap.cxx cmExtraCodeBlocksGenerator.cxx cmExtraCodeBlocksGenerator.h + cmExtraCodeLiteGenerator.cxx + cmExtraCodeLiteGenerator.h cmExtraEclipseCDT4Generator.cxx cmExtraEclipseCDT4Generator.h cmExtraKateGenerator.cxx diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index b512a0a..ff35331 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 12) -set(CMake_VERSION_TWEAK 20140106) +set(CMake_VERSION_TWEAK 20140120) #set(CMake_VERSION_RC 1) 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 78e7339..998b5f1 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -24,6 +24,7 @@ #include <cmsys/SystemTools.hxx> #include <cmsys/Directory.hxx> #include <cmsys/Encoding.hxx> +#include <cmsys/FStream.hxx> #include <rpc.h> // for GUID generation @@ -56,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(); @@ -436,7 +437,15 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() featureDefinitions.AddAttribute("Level", "1"); - CreateFeatureHierarchy(featureDefinitions); + if(!CreateCMakePackageRegistryEntry(featureDefinitions)) + { + return false; + } + + if(!CreateFeatureHierarchy(featureDefinitions)) + { + return false; + } featureDefinitions.EndElement("Feature"); @@ -563,6 +572,39 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() 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) { @@ -838,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)) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h index 0a85ae2..1f4facf 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.h +++ b/Source/CPack/WiX/cmCPackWIXGenerator.h @@ -81,6 +81,9 @@ private: bool CreateWiXSourceFiles(); + bool CreateCMakePackageRegistryEntry( + cmWIXSourceWriter& featureDefinitions); + bool CreateFeatureHierarchy( cmWIXSourceWriter& featureDefinitions); diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h index 38e40b0..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 @@ -46,7 +46,7 @@ private: void EmitInvalidCodepoint(int c); - std::ofstream File; + cmsys::ofstream File; }; #endif diff --git a/Source/CPack/WiX/cmWIXSourceWriter.h b/Source/CPack/WiX/cmWIXSourceWriter.h index f291d25..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> @@ -60,7 +60,7 @@ private: cmCPackLog* Logger; - std::ofstream File; + cmsys::ofstream File; State State; 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/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index dfb2f15..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()) { diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index cd2fcc7..96491aa 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -23,6 +23,7 @@ #include <cmsys/SystemTools.hxx> #include <cmsys/Glob.hxx> +#include <cmsys/FStream.hxx> #include <algorithm> #if defined(__HAIKU__) @@ -152,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, 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 438b16d..a19b778 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -25,6 +25,7 @@ #include <cmsys/CommandLineArguments.hxx> #include <cmsys/SystemTools.hxx> +#include <cmsys/Encoding.hxx> //---------------------------------------------------------------------------- static const char * cmDocumentationName[][2] = @@ -97,8 +98,13 @@ 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) { + cmsys::Encoding::CommandLineArguments args = + cmsys::Encoding::CommandLineArguments::Main(argc, argv); + argc = args.argc(); + argv = args.argv(); + cmSystemTools::FindCMakeResources(argv[0]); cmCPackLog log; diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index e480fff..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)) { @@ -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/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 33b084e..3c65c55 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -26,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> @@ -511,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; @@ -600,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; @@ -1158,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: " @@ -1370,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: " @@ -1530,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, @@ -1743,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, @@ -2012,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)) { @@ -2026,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; @@ -2080,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 3506928..660f501 100644 --- a/Source/CTest/cmCTestCoverageHandler.h +++ b/Source/CTest/cmCTestCoverageHandler.h @@ -132,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/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 725f613..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"; diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index 8e5fd78..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) @@ -171,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)) { @@ -241,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. @@ -330,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; @@ -579,7 +580,7 @@ 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 = ""; @@ -652,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)) @@ -671,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/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 729f14a..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 { @@ -325,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; @@ -384,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)) @@ -721,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/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/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/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index da24ae4..3a04b33 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -21,6 +21,7 @@ #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" @@ -931,7 +932,7 @@ void cmCTestTestHandler::UpdateMaxTestNameWidth() bool cmCTestTestHandler::GetValue(const char* tag, int& value, - std::ifstream& fin) + std::istream& fin) { std::string line; bool ret = true; @@ -953,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); @@ -975,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); @@ -1007,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); @@ -1029,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); @@ -1798,7 +1799,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed() } // parse the list of tests to rerun from LastTestsFailed.log - std::ifstream ifs(lastTestsFailedLog.c_str()); + cmsys::ifstream ifs(lastTestsFailedLog.c_str()); if ( ifs ) { std::string line; @@ -1964,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 @@ -2054,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); @@ -2228,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; @@ -2363,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 398f052..63f9c93 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -109,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; @@ -227,19 +229,19 @@ private: 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 */ 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 index a086f13..38a770a 100644 --- a/Source/CTest/cmParsePythonCoverage.cxx +++ b/Source/CTest/cmParsePythonCoverage.cxx @@ -3,7 +3,7 @@ #include "cmXMLParser.h" #include "cmParsePythonCoverage.h" #include <cmsys/Directory.hxx> - +#include <cmsys/FStream.hxx> //---------------------------------------------------------------------------- class cmParsePythonCoverage::XMLParser: public cmXMLParser @@ -35,7 +35,7 @@ protected: atts[tagCount+1]; FileLinesType& curFileLines = this->Coverage.TotalCoverage[this->CurFileName]; - std::ifstream fin(this->CurFileName.c_str()); + cmsys::ifstream fin(this->CurFileName.c_str()); if(!fin) { cmCTestLog(this->CTest, ERROR_MESSAGE, diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index ce50845..2d1ef5c 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -19,6 +19,7 @@ #include "cmCursesMainForm.h" #include "cmCursesStandardIncludes.h" +#include <cmsys/Encoding.hxx> #include <form.h> @@ -78,8 +79,13 @@ 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) { + 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(); 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/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/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index 408bb4c..821121e 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -21,6 +21,7 @@ #include "cmVersion.h" #include <cmsys/CommandLineArguments.hxx> #include <cmsys/SystemTools.hxx> +#include <cmsys/Encoding.hxx> //---------------------------------------------------------------------------- static const char * cmDocumentationName[][2] = @@ -48,12 +49,17 @@ static const char * cmDocumentationOptions[][2] = int main(int argc, char** argv) { - cmSystemTools::FindCMakeResources(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; @@ -80,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(); @@ -116,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 1903c02..f62afd6 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -70,8 +70,10 @@ CMakeSetupDialog::CMakeSetupDialog() 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); @@ -1049,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); @@ -1064,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); } } } 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/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx index 87bfb3c..b55334f 100644 --- a/Source/cmAddDependenciesCommand.cxx +++ b/Source/cmAddDependenciesCommand.cxx @@ -24,14 +24,14 @@ bool cmAddDependenciesCommand } std::string target_name = args[0]; - if(this->Makefile->IsAlias(target_name.c_str())) + if(this->Makefile->IsAlias(target_name)) { cmOStringStream e; e << "Cannot add target-level dependencies to alias target \"" << target_name << "\".\n"; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); } - if(cmTarget* target = this->Makefile->FindTargetToUse(target_name.c_str())) + if(cmTarget* target = this->Makefile->FindTargetToUse(target_name)) { if (target->GetType() == cmTarget::INTERFACE_LIBRARY) { @@ -46,7 +46,7 @@ bool cmAddDependenciesCommand ++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/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index a352be0..62b6667 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -201,7 +201,7 @@ bool cmAddExecutableCommand if(importTarget) { // Make sure the target does not already exist. - if(this->Makefile->FindTargetToUse(exename.c_str())) + if(this->Makefile->FindTargetToUse(exename)) { cmOStringStream e; e << "cannot create imported target \"" << exename diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index 2627445..a29f784 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -363,7 +363,7 @@ bool cmAddLibraryCommand } // Make sure the target does not already exist. - if(this->Makefile->FindTargetToUse(libName.c_str())) + if(this->Makefile->FindTargetToUse(libName)) { cmOStringStream e; e << "cannot create imported target \"" << libName 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/cmCTest.cxx b/Source/cmCTest.cxx index 125a3bf..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" @@ -207,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: @@ -549,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) @@ -604,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; @@ -763,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) { @@ -1149,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); @@ -1611,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; @@ -1692,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 diff --git a/Source/cmCTest.h b/Source/cmCTest.h index c0a06c5..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 diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index a2baa80..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. ", diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index cf227fb..9776f55 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -63,7 +63,7 @@ private: cmTarget const* HeadTarget; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; - cmGlobalGenerator* GlobalGenerator; + cmGlobalGenerator const* GlobalGenerator; cmake* CMakeInstance; bool DebugMode; diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 73a8e27..6511510 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -343,6 +343,45 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, 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. @@ -372,7 +411,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, i != utils.end(); ++i) { if(cmTarget const* transitive_dependee = - dependee->GetMakefile()->FindTargetToUse(i->c_str())) + dependee->GetMakefile()->FindTargetToUse(*i)) { this->AddTargetDepend(depender_index, transitive_dependee, false); } diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index bbfc427..bbdb3a1 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -93,7 +93,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) else if(doing == DoingLinkLibraries) { libsToLink += "\"" + cmSystemTools::TrimWhitespace(argv[i]) + "\" "; - if(cmTarget *tgt = this->Makefile->FindTargetToUse(argv[i].c_str())) + if(cmTarget *tgt = this->Makefile->FindTargetToUse(argv[i])) { switch(tgt->GetType()) { @@ -278,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; 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/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index f2f77ee..f24dfa2 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -41,7 +41,7 @@ unsigned int cmCustomCommandGenerator::GetNumberOfCommands() const std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const { std::string const& argv0 = this->CC.GetCommandLines()[c][0]; - cmTarget* target = this->Makefile->FindTargetToUse(argv0.c_str()); + cmTarget* target = this->Makefile->FindTargetToUse(argv0); if(target && target->GetType() == cmTarget::EXECUTABLE && (target->IsImported() || !this->Makefile->IsOn("CMAKE_CROSSCOMPILING"))) { 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/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/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 8576bf2..9c27fc1 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -17,6 +17,7 @@ #include <cmsys/Directory.hxx> #include <cmsys/Glob.hxx> +#include <cmsys/FStream.hxx> #include <ctype.h> @@ -137,6 +138,8 @@ bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os) return this->PrintHelpListPolicies(os); case cmDocumentation::Version: return this->PrintVersion(os); + case cmDocumentation::OldCustomModules: + return this->PrintOldCustomModules(os); default: return false; } } @@ -156,11 +159,11 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os) 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; 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; @@ -335,7 +338,15 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv, GET_OPT_ARGUMENT(help.Filename); cmSystemTools::Message( "Warning: --help-custom-modules no longer supported"); - return true; + 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) { @@ -631,7 +642,7 @@ void cmDocumentation::PrintNames(std::ostream& os, i != files.end(); ++i) { std::string line; - std::ifstream fin(i->c_str()); + cmsys::ifstream fin(i->c_str()); while(fin && cmSystemTools::GetLineFromStream(fin, line)) { if(!line.empty() && (isalnum(line[0]) || line[0] == '<')) @@ -863,3 +874,48 @@ bool cmDocumentation::IsOption(const char* arg) const return ((arg[0] == '-') || (strcmp(arg, "/V") == 0) || (strcmp(arg, "/?") == 0)); } + +//---------------------------------------------------------------------------- +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 + { + os << name << "\n\n" << summary << "\n" << detail; + } + return true; +} diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h index 05c0442..d5a7dd5 100644 --- a/Source/cmDocumentation.h +++ b/Source/cmDocumentation.h @@ -115,6 +115,7 @@ private: bool PrintHelpListVariables(std::ostream& os); bool PrintHelpListPolicies(std::ostream& os); bool PrintDocumentationUsage(std::ostream& os); + bool PrintOldCustomModules(std::ostream& os); const char* GetNameString() const; bool IsOption(const char* arg) const; diff --git a/Source/cmDocumentationFormatter.h b/Source/cmDocumentationFormatter.h index c7da52c..118f03d 100644 --- a/Source/cmDocumentationFormatter.h +++ b/Source/cmDocumentationFormatter.h @@ -28,7 +28,8 @@ public: { None, Version, Usage, ListManuals, ListCommands, ListModules, ListProperties, ListVariables, ListPolicies, - OneManual, OneCommand, OneModule, OneProperty, OneVariable, OnePolicy + OneManual, OneCommand, OneModule, OneProperty, OneVariable, OnePolicy, + OldCustomModules }; }; 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/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index b669cd1..858f76c 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -35,7 +35,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) tei = targets.begin(); tei != targets.end(); ++tei) { - cmTarget *te = this->Makefile->FindTargetToUse(tei->c_str()); + cmTarget *te = this->Makefile->FindTargetToUse(*tei); expectedTargets += sep + this->Namespace + te->GetExportName(); sep = " "; if(this->ExportedTargets.insert(te).second) diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index 7c97d8d..db56aaf 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -159,7 +159,7 @@ bool cmExportCommand currentTarget != this->Targets.GetVector().end(); ++currentTarget) { - if (this->Makefile->IsAlias(currentTarget->c_str())) + if (this->Makefile->IsAlias(*currentTarget)) { cmOStringStream e; e << "given ALIAS target \"" << *currentTarget diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 4543f79..4a161ee 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> //---------------------------------------------------------------------------- @@ -61,12 +62,12 @@ const char* cmExportFileGenerator::GetMainExportFileName() const 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 @@ -533,7 +534,7 @@ cmExportFileGenerator::AddTargetNamespace(std::string &input, { cmMakefile *mf = target->GetMakefile(); - cmTarget *tgt = mf->FindTargetToUse(input.c_str()); + cmTarget *tgt = mf->FindTargetToUse(input); if (!tgt) { return false; diff --git a/Source/cmExportLibraryDependencies.cxx b/Source/cmExportLibraryDependencies.cxx index 064ffa3..4624e92 100644 --- a/Source/cmExportLibraryDependencies.cxx +++ b/Source/cmExportLibraryDependencies.cxx @@ -55,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 diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 8d37b62..a8a91d6 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -109,7 +109,7 @@ cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target, for(std::vector<std::string>::const_iterator li = depends.begin(); li != depends.end(); ++li) { - cmTarget *tgt = target->GetMakefile()->FindTargetToUse(li->c_str()); + cmTarget *tgt = target->GetMakefile()->FindTargetToUse(*li); if(tgt && emitted.insert(tgt).second) { this->Exports.push_back(tgt); diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index fce1284..548c88b 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -398,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++) { @@ -760,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 c93187e..3e9b786 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -559,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++) diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 9cbdd7c..52411e8 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -237,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..4dd81be 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -120,7 +120,7 @@ void cmFLTKWrapUICommand::FinalPass() // people should add the srcs to the target themselves, but the old command // didn't support that, so check and see if they added the files in and if // they didn;t then print a warning and add then anyhow - cmTarget* target = this->Makefile->FindTarget(this->Target.c_str()); + cmTarget* target = this->Makefile->FindTarget(this->Target); if(!target) { std::string msg = @@ -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/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/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 55c20d6..c59aafd 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -1151,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); } @@ -1334,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/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/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index c2c4e20..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 () || @@ -61,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) { @@ -125,7 +125,7 @@ void cmGeneratorExpressionDAGChecker::reportError( //---------------------------------------------------------------------------- cmGeneratorExpressionDAGChecker::Result -cmGeneratorExpressionDAGChecker::checkGraph() const +cmGeneratorExpressionDAGChecker::CheckGraph() const { const cmGeneratorExpressionDAGChecker *parent = this->Parent; while (parent) @@ -179,44 +179,37 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(const char *tgt) || 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, "SYSTEM_INCLUDE_DIRECTORIES") == 0 - || 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 - || cmHasLiteralPrefix(prop, "COMPILE_DEFINITIONS_")); + 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); \ } -//---------------------------------------------------------------------------- -bool cmGeneratorExpressionDAGChecker::EvaluatingAutoUicOptions() const -{ - const char *prop = this->Property.c_str(); - return (strcmp(prop, "AUTOUIC_OPTIONS") == 0 - || strcmp(prop, "INTERFACE_AUTOUIC_OPTIONS") == 0 ); -} +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 98ffd36..b6effa1 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -16,19 +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) \ - F(EvaluatingAutoUicOptions) + CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, CM_SELECT_FIRST) #define CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(F) \ - F(INCLUDE_DIRECTORIES) \ - F(SYSTEM_INCLUDE_DIRECTORIES) \ - F(COMPILE_DEFINITIONS) \ - F(COMPILE_OPTIONS) \ - F(AUTOUIC_OPTIONS) + CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, CM_SELECT_SECOND) //---------------------------------------------------------------------------- struct cmGeneratorExpressionDAGChecker @@ -46,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); @@ -65,7 +71,7 @@ struct cmGeneratorExpressionDAGChecker { 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 f0e40ea..7036992 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -215,18 +215,18 @@ static const struct EqualNode : public cmGeneratorExpressionNode bool flipSign = false; const char *lhs = parameters[0].c_str(); - if (cmHasLiteralPrefix(lhs, "0b")) + if (cmHasLiteralPrefix(lhs, "0b") || cmHasLiteralPrefix(lhs, "0B")) { base = 2; lhs += 2; } - if (cmHasLiteralPrefix(lhs, "-0b")) + if (cmHasLiteralPrefix(lhs, "-0b") || cmHasLiteralPrefix(lhs, "-0B")) { base = 2; lhs += 3; flipSign = true; } - if (cmHasLiteralPrefix(lhs, "+0b")) + if (cmHasLiteralPrefix(lhs, "+0b") || cmHasLiteralPrefix(lhs, "+0B")) { base = 2; lhs += 3; @@ -249,18 +249,18 @@ static const struct EqualNode : public cmGeneratorExpressionNode flipSign = false; const char *rhs = parameters[1].c_str(); - if (cmHasLiteralPrefix(rhs, "0b")) + if (cmHasLiteralPrefix(rhs, "0b") || cmHasLiteralPrefix(rhs, "0B")) { base = 2; rhs += 2; } - if (cmHasLiteralPrefix(rhs, "-0b")) + if (cmHasLiteralPrefix(rhs, "-0b") || cmHasLiteralPrefix(rhs, "-0B")) { base = 2; rhs += 3; flipSign = true; } - if (cmHasLiteralPrefix(rhs, "+0b")) + if (cmHasLiteralPrefix(rhs, "+0b") || cmHasLiteralPrefix(rhs, "+0B")) { base = 2; rhs += 3; @@ -412,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"; } }; @@ -676,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())) @@ -796,7 +822,7 @@ std::string getLinkedTargetsContent(const std::vector<std::string> &libraries, // self-referencing loop. continue; } - if (context->Makefile->FindTargetToUse(it->c_str())) + if (context->Makefile->FindTargetToUse(*it)) { depString += sep + "$<TARGET_PROPERTY:" + *it + "," + interfacePropertyName + ">"; @@ -886,18 +912,16 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } if(propertyName == "ALIASED_TARGET") { - if(context->Makefile->IsAlias(targetName.c_str())) + if(context->Makefile->IsAlias(targetName)) { - if(cmTarget* tgt = - context->Makefile->FindTargetToUse(targetName.c_str())) + if(cmTarget* tgt = context->Makefile->FindTargetToUse(targetName)) { return tgt->GetName(); } } return ""; } - target = context->Makefile->FindTargetToUse( - targetName.c_str()); + target = context->Makefile->FindTargetToUse(targetName); if (!target) { @@ -957,10 +981,10 @@ 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. @@ -1020,7 +1044,12 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode /* else */ if (cmHasLiteralPrefix(propertyName.c_str(), "COMPILE_DEFINITIONS_")) { - interfacePropertyName = "INTERFACE_COMPILE_DEFINITIONS"; + cmPolicies::PolicyStatus polSt = + context->Makefile->GetPolicyStatus(cmPolicies::CMP0043); + if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD) + { + interfacePropertyName = "INTERFACE_COMPILE_DEFINITIONS"; + } } #undef POPULATE_INTERFACE_PROPERTY_NAME @@ -1445,7 +1474,7 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode "Expression syntax not recognized."); return std::string(); } - cmTarget* target = context->Makefile->FindTargetToUse(name.c_str()); + cmTarget* target = context->Makefile->FindTargetToUse(name); if(!target) { ::reportError(context, content->GetOriginalExpression(), @@ -1801,7 +1830,7 @@ std::string GeneratorExpressionContent::EvaluateParameters( + "> expression requires at least one parameter."); } if (numExpected == cmGeneratorExpressionNode::OneOrZeroParameters - && parameters.size() > 2) + && parameters.size() > 1) { reportError(context, this->GetOriginalExpression(), "$<" + identifier + "> expression requires one or zero parameters."); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6894cfc..2573c85 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -65,9 +65,10 @@ cmGeneratorTarget::GetSourceDepends(cmSourceFile* sf) const static void handleSystemIncludesDep(cmMakefile *mf, const std::string &name, const char *config, cmTarget *headTarget, cmGeneratorExpressionDAGChecker *dagChecker, - std::vector<std::string>& result) + std::vector<std::string>& result, + bool excludeImported) { - cmTarget* depTgt = mf->FindTargetToUse(name.c_str()); + cmTarget* depTgt = mf->FindTargetToUse(name); if (!depTgt) { @@ -85,7 +86,7 @@ static void handleSystemIncludesDep(cmMakefile *mf, const std::string &name, config, false, headTarget, depTgt, dagChecker), result); } - if (!depTgt->IsImported()) + if (!depTgt->IsImported() || excludeImported) { return; } @@ -102,6 +103,84 @@ static void handleSystemIncludesDep(cmMakefile *mf, const std::string &name, } //---------------------------------------------------------------------------- +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 { @@ -130,6 +209,9 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, 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(); @@ -148,7 +230,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, { if (uniqueDeps.insert(*li).second) { - cmTarget* tgt = this->Makefile->FindTargetToUse(li->c_str()); + cmTarget* tgt = this->Makefile->FindTargetToUse(*li); if (!tgt) { @@ -156,7 +238,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, } handleSystemIncludesDep(this->Makefile, *li, config, this->Target, - &dagChecker, result); + &dagChecker, result, excludeImported); std::vector<std::string> deps; tgt->GetTransitivePropertyLinkLibraries(config, this->Target, deps); @@ -167,7 +249,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, if (uniqueDeps.insert(*di).second) { handleSystemIncludesDep(this->Makefile, *di, config, this->Target, - &dagChecker, result); + &dagChecker, result, excludeImported); } } } @@ -202,9 +284,9 @@ bool cmGeneratorTarget::GetPropertyAsBool(const char *prop) const } //---------------------------------------------------------------------------- -std::vector<cmSourceFile*> const& cmGeneratorTarget::GetSourceFiles() const +void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*> &files) const { - return this->Target->GetSourceFiles(); + this->Target->GetSourceFiles(files); } //---------------------------------------------------------------------------- @@ -216,7 +298,8 @@ void cmGeneratorTarget::ClassifySources() 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) { @@ -311,7 +394,7 @@ void cmGeneratorTarget::LookupObjectLibraries() oli != objLibs.end(); ++oli) { std::string const& objLibName = *oli; - if(cmTarget* objLib = this->Makefile->FindTargetToUse(objLibName.c_str())) + if(cmTarget* objLib = this->Makefile->FindTargetToUse(objLibName)) { if(objLib->GetType() == cmTarget::OBJECT_LIBRARY) { @@ -386,7 +469,7 @@ private: cmTarget* Target; cmGeneratorTarget* GeneratorTarget; cmMakefile* Makefile; - cmGlobalGenerator* GlobalGenerator; + cmGlobalGenerator const* GlobalGenerator; typedef cmGeneratorTarget::SourceEntry SourceEntry; SourceEntry* CurrentEntry; std::queue<cmSourceFile*> SourceQueue; @@ -414,7 +497,8 @@ cmTargetTraceDependencies this->CurrentEntry = 0; // Queue all the source files already specified for the target. - 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) { @@ -523,7 +607,7 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep) } // Check for a target with this name. - if(cmTarget* t = this->Makefile->FindTargetToUse(util.c_str())) + if(cmTarget* t = this->Makefile->FindTargetToUse(util)) { // 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 @@ -577,7 +661,7 @@ cmTargetTraceDependencies { std::string const& command = *cit->begin(); // Check for a target with this name. - if(cmTarget* t = this->Makefile->FindTargetToUse(command.c_str())) + if(cmTarget* t = this->Makefile->FindTargetToUse(command)) { if(t->GetType() == cmTarget::EXECUTABLE) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8b760f1..a4caba1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -30,36 +30,35 @@ public: const char *GetName() const; const char *GetProperty(const char *prop) const; bool GetPropertyAsBool(const char *prop) const; - std::vector<cmSourceFile*> const& GetSourceFiles() 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) const; void GetAppleArchs(const char* config, @@ -89,11 +88,23 @@ public: /** 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; -private: + 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&); diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index a1454a3..33c43ca 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -290,17 +290,17 @@ bool cmGetPropertyCommand::HandleTargetMode() if(this->PropertyName == "ALIASED_TARGET") { - if(this->Makefile->IsAlias(this->Name.c_str())) + if(this->Makefile->IsAlias(this->Name)) { if(cmTarget* target = - this->Makefile->FindTargetToUse(this->Name.c_str())) + this->Makefile->FindTargetToUse(this->Name)) { return this->StoreResult(target->GetName()); } } return this->StoreResult((this->Variable + "-NOTFOUND").c_str()); } - if(cmTarget* target = this->Makefile->FindTargetToUse(this->Name.c_str())) + if(cmTarget* target = this->Makefile->FindTargetToUse(this->Name)) { return this->StoreResult(target->GetProperty(this->PropertyName.c_str())); } diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx index 02f00a5..4aa49fe 100644 --- a/Source/cmGetTargetPropertyCommand.cxx +++ b/Source/cmGetTargetPropertyCommand.cxx @@ -21,7 +21,7 @@ bool cmGetTargetPropertyCommand return false; } std::string var = args[0].c_str(); - const char* targetName = args[1].c_str(); + const std::string& targetName = args[1]; const char *prop = 0; if(args[2] == "ALIASED_TARGET") @@ -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/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index eef8d6d..8a7eee4 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -30,6 +30,7 @@ #include "cmExportBuildFileGenerator.h" #include <cmsys/Directory.hxx> +#include <cmsys/FStream.hxx> #if defined(CMAKE_BUILD_WITH_CMAKE) # include <cmsys/MD5.h> @@ -89,7 +90,7 @@ bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts) } std::string cmGlobalGenerator::SelectMakeProgram(const char* makeProgram, - std::string makeDefault) + std::string makeDefault) const { if(cmSystemTools::IsOff(makeProgram)) { @@ -110,7 +111,7 @@ std::string cmGlobalGenerator::SelectMakeProgram(const char* makeProgram, void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang, cmMakefile *mf, - bool optional) + bool optional) const { std::string langComp = "CMAKE_"; langComp += lang; @@ -722,7 +723,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, //---------------------------------------------------------------------------- void cmGlobalGenerator::PrintCompilerAdvice(std::ostream& os, std::string lang, - const char* envVar) + const char* envVar) const { // Subclasses override this method if they do not support this advice. os << @@ -743,7 +744,7 @@ void cmGlobalGenerator::PrintCompilerAdvice(std::ostream& os, //---------------------------------------------------------------------------- void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf, - std::string lang) + std::string lang) const { std::string compilerIdVar = "CMAKE_" + lang + "_COMPILER_ID"; const char* compilerId = mf->GetDefinition(compilerIdVar.c_str()); @@ -781,13 +782,16 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf, //---------------------------------------------------------------------------- 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 @@ -808,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 @@ -816,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; } @@ -942,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)) { @@ -965,15 +971,22 @@ bool cmGlobalGenerator::IsDependedOn(const char* project, 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)) { @@ -1063,7 +1076,7 @@ void cmGlobalGenerator::AddCMP0042WarnTarget(const std::string& target) this->CMP0042WarnTargets.insert(target); } -bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() +bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const { // If the property is not enabled then okay. if(!this->CMakeInstance @@ -1182,7 +1195,11 @@ void cmGlobalGenerator::Generate() 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)/ @@ -1329,9 +1346,6 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo() 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) @@ -1352,48 +1366,58 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo() 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())); + } } } } } //---------------------------------------------------------------------------- +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); +} + +//---------------------------------------------------------------------------- void cmGlobalGenerator::CreateGeneratorTargets() { // Construct per-target generator information. for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) { - cmGeneratorTargetsType generatorTargets; - - cmMakefile *mf = this->LocalGenerators[i]->GetMakefile(); - - 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); + this->CreateGeneratorTargets(this->LocalGenerators[i]->GetMakefile()); } } @@ -1887,7 +1911,7 @@ void cmGlobalGenerator::SetConfiguredFilesPath(cmGlobalGenerator* gen) } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmLocalGenerator* gen) + cmLocalGenerator* gen) const { if(!gen || gen == root) { @@ -1907,7 +1931,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmTarget& target) + cmTarget const& target) const { if(target.GetType() == cmTarget::INTERFACE_LIBRARY || target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) @@ -1923,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); @@ -1978,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. @@ -2010,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; @@ -2270,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] == '.') { @@ -2494,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 ""; } @@ -2629,7 +2664,7 @@ 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); @@ -2749,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) { @@ -2883,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 fc5cab9..ebc2db5 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -80,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. @@ -93,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 @@ -182,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 "."; } @@ -220,7 +220,7 @@ public: target in the project */ 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 @@ -293,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; @@ -325,7 +325,7 @@ protected: virtual void GetTargetSets(TargetDependSet& projectTargets, TargetDependSet& originalTargets, cmLocalGenerator* root, GeneratorVector const&); - virtual bool IsRootOnlyTarget(cmTarget* target); + bool IsRootOnlyTarget(cmTarget* target) const; void AddTargetDepends(cmTarget const* target, TargetDependSet& projectTargets); void SetLanguageEnabledFlag(const char* l, cmMakefile* mf); @@ -334,7 +334,7 @@ protected: virtual bool ComputeTargetDepends(); - virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS(); + virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const; bool CheckTargets(); typedef std::vector<std::pair<cmQtAutoGenerators, @@ -342,14 +342,14 @@ protected: void CreateQtAutoGeneratorsTargets(AutogensType& autogens); std::string SelectMakeProgram(const char* makeProgram, - std::string makeDefault = ""); + 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, @@ -418,8 +418,8 @@ private: void FinalizeTargetCompileInfo(); virtual void PrintCompilerAdvice(std::ostream& os, std::string lang, - const char* envVar); - void CheckCompilerIdCompatibility(cmMakefile* mf, std::string lang); + const char* envVar) const; + void CheckCompilerIdCompatibility(cmMakefile* mf, std::string lang) const; cmExternalMakefileProjectGenerator* ExtraGenerator; @@ -432,6 +432,8 @@ private: // Per-target generator information. cmGeneratorTargetsType GeneratorTargets; + friend class cmake; + void CreateGeneratorTargets(cmMakefile* mf); void CreateGeneratorTargets(); void ComputeGeneratorTargetObjects(); virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const; diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index ab7db51..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 @@ -137,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++) { @@ -189,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)) @@ -310,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, diff --git a/Source/cmGlobalMSYSMakefileGenerator.cxx b/Source/cmGlobalMSYSMakefileGenerator.cxx index 539d2af..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; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 4b92058..5e1f1ed 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -644,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); } } @@ -1113,9 +1115,6 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) this->LocalGenerators.begin(); i != this->LocalGenerators.end(); ++i) { const std::vector<std::string>& lf = (*i)->GetMakefile()->GetListFiles(); implicitDeps.insert(implicitDeps.end(), lf.begin(), lf.end()); - - const std::vector<std::string>& of = (*i)->GetMakefile()->GetOutputFiles(); - implicitDeps.insert(implicitDeps.end(), of.begin(), of.end()); } std::sort(implicitDeps.begin(), implicitDeps.end()); implicitDeps.erase(std::unique(implicitDeps.begin(), implicitDeps.end()), diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index de38923..0d5fb44 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -304,7 +304,7 @@ 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: diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 622a7c5..0b37a07 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -120,17 +120,19 @@ 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); } } diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 00a86eb..9173751 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -161,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 diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 38c47ef..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: @@ -244,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: ", diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 93a597c..42492e6 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -129,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( @@ -143,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 = @@ -152,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(); diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 54e3c28..eab613d 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -110,7 +110,7 @@ protected: private: virtual std::string GetVSMakeProgram() = 0; - void PrintCompilerAdvice(std::ostream&, std::string, const char*) {} + void PrintCompilerAdvice(std::ostream&, std::string, const char*) const {} void ComputeTargetObjects(cmGeneratorTarget* gt) const; void FollowLinkDepends(cmTarget const* target, diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 381c1f5..41961ed 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -753,7 +753,8 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, //---------------------------------------------------------------------------- std::string GetSourcecodeValueFromFileExtension(const std::string& _ext, - const std::string& lang) + const std::string& lang, + bool& keepLastKnownFileType) { std::string ext = cmSystemTools::LowerCase(_ext); std::string sourcecode = "sourcecode"; @@ -764,10 +765,12 @@ GetSourcecodeValueFromFileExtension(const std::string& _ext, } else if(ext == "xib") { + keepLastKnownFileType = true; sourcecode = "file.xib"; } else if(ext == "storyboard") { + keepLastKnownFileType = true; sourcecode = "file.storyboard"; } else if(ext == "mm") @@ -778,10 +781,6 @@ GetSourcecodeValueFromFileExtension(const std::string& _ext, { sourcecode += ".c.objc"; } - else if(ext == "xib") - { - sourcecode += ".file.xib"; - } else if(ext == "plist") { sourcecode += ".text.plist"; @@ -797,6 +796,7 @@ GetSourcecodeValueFromFileExtension(const std::string& _ext, } else if(ext == "png" || ext == "gif" || ext == "jpg") { + keepLastKnownFileType = true; sourcecode = "image"; } else if(ext == "txt") @@ -875,8 +875,13 @@ cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath( } else { - std::string sourcecode = GetSourcecodeValueFromFileExtension(ext, lang); - fileRef->AddAttribute("explicitFileType", + bool keepLastKnownFileType = false; + std::string sourcecode = GetSourcecodeValueFromFileExtension(ext, + lang, keepLastKnownFileType); + const char* attribute = keepLastKnownFileType ? + "lastKnownFileType" : + "explicitFileType"; + fileRef->AddAttribute(attribute, this->CreateString(sourcecode.c_str())); } @@ -988,7 +993,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; @@ -1357,7 +1363,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(); @@ -2439,7 +2446,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) { @@ -2942,7 +2950,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(); @@ -3922,9 +3931,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 = @@ -3938,7 +3949,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 6281c3b..ae7f07e 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -212,7 +212,7 @@ protected: std::vector<cmXCodeObject*> XCodeObjects; cmXCodeObject* RootObject; private: - void PrintCompilerAdvice(std::ostream&, std::string, const char*) {} + void PrintCompilerAdvice(std::ostream&, std::string, const char*) const {} void ComputeTargetObjects(cmGeneratorTarget* gt) const; std::string GetObjectsNormalDirectory( 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.cxx b/Source/cmIfCommand.cxx index 57cec5b..ee95c05 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -543,7 +543,7 @@ namespace if (*arg == "TARGET" && argP1 != newArgs.end()) { HandlePredicate( - makefile->FindTargetToUse((argP1)->c_str())? true:false, + makefile->FindTargetToUse(*argP1)?true:false, reducible, arg, newArgs, argP1, argP2); } // is a variable defined diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 10578f2..6f2dd65 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -363,7 +363,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) ++targetIt) { - if (this->Makefile->IsAlias(targetIt->c_str())) + if (this->Makefile->IsAlias(*targetIt)) { cmOStringStream e; e << "TARGETS given target \"" << (*targetIt) @@ -372,7 +372,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) return false; } // Lookup this target in the current directory. - if(cmTarget* target=this->Makefile->FindTarget(targetIt->c_str())) + if(cmTarget* target=this->Makefile->FindTarget(*targetIt)) { // Found the target. Check its type. if(target->GetType() != cmTarget::EXECUTABLE && diff --git a/Source/cmListFileLexer.c b/Source/cmListFileLexer.c index be27884..bfa388e 100644 --- a/Source/cmListFileLexer.c +++ b/Source/cmListFileLexer.c @@ -569,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* @@ -612,7 +615,7 @@ static void cmListFileLexerDestroy(cmListFileLexer* lexer); -#line 618 "cmListFileLexer.c" +#line 621 "cmListFileLexer.c" #define INITIAL 0 #define STRING 1 @@ -844,10 +847,10 @@ YY_DECL int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; -#line 88 "cmListFileLexer.in.l" +#line 91 "cmListFileLexer.in.l" -#line 855 "cmListFileLexer.c" +#line 858 "cmListFileLexer.c" if ( !yyg->yy_init ) { @@ -945,7 +948,7 @@ do_action: /* This label is used only to access EOF actions. */ case 1: /* rule 1 can match eol */ YY_RULE_SETUP -#line 90 "cmListFileLexer.in.l" +#line 93 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_Newline; cmListFileLexerSetToken(lexer, yytext, yyleng); @@ -957,7 +960,7 @@ YY_RULE_SETUP case 2: /* rule 2 can match eol */ YY_RULE_SETUP -#line 99 "cmListFileLexer.in.l" +#line 102 "cmListFileLexer.in.l" { const char* bracket = yytext; lexer->comment = yytext[0] == '#'; @@ -986,7 +989,7 @@ YY_RULE_SETUP YY_BREAK case 3: YY_RULE_SETUP -#line 125 "cmListFileLexer.in.l" +#line 128 "cmListFileLexer.in.l" { lexer->column += yyleng; BEGIN(COMMENT); @@ -994,14 +997,14 @@ YY_RULE_SETUP YY_BREAK case 4: YY_RULE_SETUP -#line 130 "cmListFileLexer.in.l" +#line 133 "cmListFileLexer.in.l" { lexer->column += yyleng; } YY_BREAK case 5: YY_RULE_SETUP -#line 134 "cmListFileLexer.in.l" +#line 137 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_ParenLeft; cmListFileLexerSetToken(lexer, yytext, yyleng); @@ -1010,7 +1013,7 @@ YY_RULE_SETUP } case 6: YY_RULE_SETUP -#line 141 "cmListFileLexer.in.l" +#line 144 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_ParenRight; cmListFileLexerSetToken(lexer, yytext, yyleng); @@ -1019,7 +1022,7 @@ YY_RULE_SETUP } case 7: YY_RULE_SETUP -#line 148 "cmListFileLexer.in.l" +#line 151 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_Identifier; cmListFileLexerSetToken(lexer, yytext, yyleng); @@ -1028,7 +1031,7 @@ YY_RULE_SETUP } case 8: YY_RULE_SETUP -#line 155 "cmListFileLexer.in.l" +#line 158 "cmListFileLexer.in.l" { /* Handle ]]====]=======]*/ cmListFileLexerAppend(lexer, yytext, yyleng); @@ -1041,7 +1044,7 @@ YY_RULE_SETUP YY_BREAK case 9: YY_RULE_SETUP -#line 165 "cmListFileLexer.in.l" +#line 168 "cmListFileLexer.in.l" { lexer->column += yyleng; /* Erase the partial bracket from the token. */ @@ -1052,7 +1055,7 @@ YY_RULE_SETUP } case 10: YY_RULE_SETUP -#line 174 "cmListFileLexer.in.l" +#line 177 "cmListFileLexer.in.l" { cmListFileLexerAppend(lexer, yytext, yyleng); lexer->column += yyleng; @@ -1061,7 +1064,7 @@ YY_RULE_SETUP case 11: /* rule 11 can match eol */ YY_RULE_SETUP -#line 179 "cmListFileLexer.in.l" +#line 182 "cmListFileLexer.in.l" { cmListFileLexerAppend(lexer, yytext, yyleng); ++lexer->line; @@ -1071,7 +1074,7 @@ YY_RULE_SETUP YY_BREAK case 12: YY_RULE_SETUP -#line 186 "cmListFileLexer.in.l" +#line 189 "cmListFileLexer.in.l" { cmListFileLexerAppend(lexer, yytext, yyleng); lexer->column += yyleng; @@ -1080,7 +1083,7 @@ YY_RULE_SETUP YY_BREAK case YY_STATE_EOF(BRACKET): case YY_STATE_EOF(BRACKETEND): -#line 192 "cmListFileLexer.in.l" +#line 195 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_BadBracket; BEGIN(INITIAL); @@ -1088,7 +1091,7 @@ case YY_STATE_EOF(BRACKETEND): } case 13: YY_RULE_SETUP -#line 198 "cmListFileLexer.in.l" +#line 201 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted; cmListFileLexerSetToken(lexer, yytext, yyleng); @@ -1097,7 +1100,7 @@ YY_RULE_SETUP } case 14: YY_RULE_SETUP -#line 205 "cmListFileLexer.in.l" +#line 208 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted; cmListFileLexerSetToken(lexer, yytext, yyleng); @@ -1106,7 +1109,7 @@ YY_RULE_SETUP } case 15: YY_RULE_SETUP -#line 212 "cmListFileLexer.in.l" +#line 215 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_ArgumentQuoted; cmListFileLexerSetToken(lexer, "", 0); @@ -1116,7 +1119,7 @@ YY_RULE_SETUP YY_BREAK case 16: YY_RULE_SETUP -#line 219 "cmListFileLexer.in.l" +#line 222 "cmListFileLexer.in.l" { cmListFileLexerAppend(lexer, yytext, yyleng); lexer->column += yyleng; @@ -1125,7 +1128,7 @@ YY_RULE_SETUP case 17: /* rule 17 can match eol */ YY_RULE_SETUP -#line 224 "cmListFileLexer.in.l" +#line 227 "cmListFileLexer.in.l" { /* Continuation: text is not part of string */ ++lexer->line; @@ -1135,7 +1138,7 @@ YY_RULE_SETUP case 18: /* rule 18 can match eol */ YY_RULE_SETUP -#line 230 "cmListFileLexer.in.l" +#line 233 "cmListFileLexer.in.l" { cmListFileLexerAppend(lexer, yytext, yyleng); ++lexer->line; @@ -1144,7 +1147,7 @@ YY_RULE_SETUP YY_BREAK case 19: YY_RULE_SETUP -#line 236 "cmListFileLexer.in.l" +#line 239 "cmListFileLexer.in.l" { lexer->column += yyleng; BEGIN(INITIAL); @@ -1152,14 +1155,14 @@ YY_RULE_SETUP } case 20: YY_RULE_SETUP -#line 242 "cmListFileLexer.in.l" +#line 245 "cmListFileLexer.in.l" { cmListFileLexerAppend(lexer, yytext, yyleng); lexer->column += yyleng; } YY_BREAK case YY_STATE_EOF(STRING): -#line 247 "cmListFileLexer.in.l" +#line 250 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_BadString; BEGIN(INITIAL); @@ -1167,7 +1170,7 @@ case YY_STATE_EOF(STRING): } case 21: YY_RULE_SETUP -#line 253 "cmListFileLexer.in.l" +#line 256 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_Space; cmListFileLexerSetToken(lexer, yytext, yyleng); @@ -1176,7 +1179,7 @@ YY_RULE_SETUP } case 22: YY_RULE_SETUP -#line 260 "cmListFileLexer.in.l" +#line 263 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_BadCharacter; cmListFileLexerSetToken(lexer, yytext, yyleng); @@ -1185,7 +1188,7 @@ YY_RULE_SETUP } case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(COMMENT): -#line 267 "cmListFileLexer.in.l" +#line 270 "cmListFileLexer.in.l" { lexer->token.type = cmListFileLexer_Token_None; cmListFileLexerSetToken(lexer, 0, 0); @@ -1193,10 +1196,10 @@ case YY_STATE_EOF(COMMENT): } case 23: YY_RULE_SETUP -#line 273 "cmListFileLexer.in.l" +#line 276 "cmListFileLexer.in.l" ECHO; YY_BREAK -#line 1217 "cmListFileLexer.c" +#line 1220 "cmListFileLexer.c" case YY_END_OF_BUFFER: { @@ -2317,7 +2320,7 @@ void cmListFileLexer_yyfree (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 273 "cmListFileLexer.in.l" +#line 276 "cmListFileLexer.in.l" @@ -2542,7 +2545,13 @@ int cmListFileLexer_SetFileName(cmListFileLexer* lexer, const char* name, cmListFileLexerDestroy(lexer); if(name) { +#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) diff --git a/Source/cmListFileLexer.in.l b/Source/cmListFileLexer.in.l index d45a8ea..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* @@ -493,7 +496,13 @@ int cmListFileLexer_SetFileName(cmListFileLexer* lexer, const char* name, cmListFileLexerDestroy(lexer); if(name) { +#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) 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/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 455f542..bd910e2 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -657,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) { @@ -1631,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) { @@ -2019,7 +2021,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName, } // Look for a CMake target with the given name. - if(cmTarget* target = this->Makefile->FindTargetToUse(name.c_str())) + if(cmTarget* target = this->Makefile->FindTargetToUse(name)) { // make sure it is not just a coincidence that the target name // found is part of the inName diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 20e8eea..93722d1 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1172,7 +1172,7 @@ cmLocalUnixMakefileGenerator3 } cleanfile += ".cmake"; std::string cleanfilePath = this->Convert(cleanfile.c_str(), FULL); - std::ofstream fout(cleanfilePath.c_str()); + cmsys::ofstream fout(cleanfilePath.c_str()); if(!fout) { cmSystemTools::Error("Could not create ", cleanfilePath.c_str()); diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index a665b93..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) @@ -200,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()); @@ -313,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 @@ -336,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) @@ -400,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. @@ -758,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) @@ -1452,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()); @@ -1785,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 ", diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 14832e5..57a4880 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -205,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 @@ -216,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(); @@ -1381,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++) { @@ -1468,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. @@ -1826,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); 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/cmMakefile.cxx b/Source/cmMakefile.cxx index 6883f57..222cdb6 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -34,7 +34,7 @@ #include <stdlib.h> // required for atoi #include <cmsys/RegularExpression.hxx> - +#include <cmsys/FStream.hxx> #include <cmsys/auto_ptr.hxx> #include <stack> @@ -1601,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; @@ -3499,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( @@ -3508,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 ", @@ -3857,7 +3859,8 @@ const char* cmMakefile::GetFeature(const char* feature, const char* config) return 0; } -cmTarget* cmMakefile::FindTarget(const char* name, bool excludeAliases) const +cmTarget* cmMakefile::FindTarget(const std::string& name, + bool excludeAliases) const { if (!excludeAliases) { @@ -4061,7 +4064,8 @@ cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type, } //---------------------------------------------------------------------------- -cmTarget* cmMakefile::FindTargetToUse(const char* name, bool excludeAliases) +cmTarget* cmMakefile::FindTargetToUse(const std::string& name, + bool excludeAliases) { // Look for an imported target. These take priority because they // are more local in scope and do not have to be globally unique. @@ -4079,16 +4083,18 @@ cmTarget* cmMakefile::FindTargetToUse(const char* name, bool excludeAliases) } // Look for a target built in this project. - return this->LocalGenerator->GetGlobalGenerator()->FindTarget(0, name, + return this->LocalGenerator->GetGlobalGenerator()->FindTarget(0, + name.c_str(), excludeAliases); } //---------------------------------------------------------------------------- -bool cmMakefile::IsAlias(const char *name) +bool cmMakefile::IsAlias(const std::string& name) { if (this->AliasTargets.find(name) != this->AliasTargets.end()) return true; - return this->GetLocalGenerator()->GetGlobalGenerator()->IsAlias(name); + return this->GetLocalGenerator()->GetGlobalGenerator()->IsAlias( + name.c_str()); } //---------------------------------------------------------------------------- @@ -4105,7 +4111,7 @@ cmGeneratorTarget* cmMakefile::FindGeneratorTargetToUse(const char* name) bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, bool isCustom) { - if(this->IsAlias(name.c_str())) + if(this->IsAlias(name)) { cmOStringStream e; e << "cannot create target \"" << name @@ -4113,7 +4119,7 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, msg = e.str(); return false; } - if(cmTarget* existing = this->FindTargetToUse(name.c_str())) + if(cmTarget* existing = this->FindTargetToUse(name)) { // The name given conflicts with an existing target. Produce an // error in a compatible way. diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 44aaa66..0232ffe 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -533,12 +533,14 @@ public: this->GeneratorTargets = targets; } - cmTarget* FindTarget(const char* name, bool excludeAliases = false) const; + cmTarget* FindTarget(const std::string& 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. */ - cmTarget* FindTargetToUse(const char* name, bool excludeAliases = false); - bool IsAlias(const char *name); + cmTarget* FindTargetToUse(const std::string& name, + bool excludeAliases = false); + bool IsAlias(const std::string& name); cmGeneratorTarget* FindGeneratorTargetToUse(const char* name); /** @@ -957,7 +959,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 diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index f82b808..7f90078 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -151,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); @@ -170,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); @@ -421,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; @@ -1142,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) { diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index c8b03e1..82f8d1b 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -276,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; @@ -458,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); } @@ -539,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(); diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index 8556565..1a7b445 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -42,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/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index 5de36ed..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()); @@ -196,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/cmPolicies.cxx b/Source/cmPolicies.cxx index 987c663..020a782 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -316,6 +316,26 @@ cmPolicies::cmPolicies() 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() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 66eaf87..38f47f1 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -96,6 +96,10 @@ public: /// 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. * diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index abf20cb..da22ab5 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -23,6 +23,7 @@ #include <cmsys/Terminal.h> #include <cmsys/ios/sstream> +#include <cmsys/FStream.hxx> #include <assert.h> #include <string.h> @@ -396,7 +397,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) || !configIncludes.empty() || !configUicOptions.empty()) { - std::ofstream infoFile(outputFile.c_str(), std::ios::app); + cmsys::ofstream infoFile(outputFile.c_str(), std::ios::app); if ( !infoFile ) { std::string error = "Internal CMake error when trying to open file: "; @@ -450,7 +451,8 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, 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 = ""; @@ -642,7 +644,8 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, const char *qtUic = makefile->GetSafeDefinition("QT_UIC_EXECUTABLE"); makefile->AddDefinition("_qt_uic_executable", qtUic); - const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles(); + std::vector<cmSourceFile*> srcFiles; + target->GetSourceFiles(srcFiles); std::string skip_uic; const char *sep = ""; @@ -808,7 +811,8 @@ void cmQtAutoGenerators::InitializeAutoRccTarget(cmTarget* target) { cmMakefile *makefile = target->GetMakefile(); - const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles(); + std::vector<cmSourceFile*> srcFiles; + target->GetSourceFiles(srcFiles); std::vector<cmSourceFile*> newFiles; @@ -854,7 +858,8 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) const char* sepRccFiles = ""; cmMakefile *makefile = target->GetMakefile(); - const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles(); + std::vector<cmSourceFile*> srcFiles; + target->GetSourceFiles(srcFiles); std::string rccFileFiles; std::string rccFileOptions; @@ -2111,7 +2116,7 @@ bool cmQtAutoGenerators::EndsWith(const std::string& str, 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/cmRST.cxx b/Source/cmRST.cxx index 3aa8e1b..11a9913 100644 --- a/Source/cmRST.cxx +++ b/Source/cmRST.cxx @@ -13,7 +13,7 @@ #include "cmSystemTools.h" #include "cmVersion.h" - +#include <cmsys/FStream.hxx> #include <ctype.h> //---------------------------------------------------------------------------- @@ -52,7 +52,7 @@ cmRST::cmRST(std::ostream& os, std::string const& docroot): //---------------------------------------------------------------------------- bool cmRST::ProcessFile(std::string const& fname, bool isModule) { - std::ifstream fin(fname.c_str()); + cmsys::ifstream fin(fname.c_str()); if(fin) { this->DocDir = cmSystemTools::GetFilenamePath(fname); diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index 4207860..1a6f1d6 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -244,12 +244,12 @@ bool cmSetPropertyCommand::HandleTargetMode() for(std::set<cmStdString>::const_iterator ni = this->Names.begin(); ni != this->Names.end(); ++ni) { - if (this->Makefile->IsAlias(ni->c_str())) + if (this->Makefile->IsAlias(*ni)) { this->SetError("can not be used on an ALIAS target."); return false; } - if(cmTarget* target = this->Makefile->FindTargetToUse(ni->c_str())) + if(cmTarget* target = this->Makefile->FindTargetToUse(*ni)) { // Handle the current target. if(!this->HandleTarget(target)) diff --git a/Source/cmSetTargetPropertiesCommand.cxx b/Source/cmSetTargetPropertiesCommand.cxx index 78ef393..dab4180 100644 --- a/Source/cmSetTargetPropertiesCommand.cxx +++ b/Source/cmSetTargetPropertiesCommand.cxx @@ -72,7 +72,7 @@ bool cmSetTargetPropertiesCommand int i; for(i = 0; i < numFiles; ++i) { - if (this->Makefile->IsAlias(args[i].c_str())) + if (this->Makefile->IsAlias(args[i])) { this->SetError("can not be used on an ALIAS target."); return false; diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index eb6e52f..ebfa8f9 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -391,6 +391,22 @@ inline bool cmHasLiteralPrefixImpl(const char* str1, 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__) @@ -402,6 +418,9 @@ inline bool cmHasLiteralPrefixImpl(const char* str1, #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> @@ -417,6 +436,12 @@ 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 { diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index b8163c8..41c7509 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -32,6 +32,7 @@ # include <cmsys/Terminal.h> #endif #include <cmsys/stl/algorithm> +#include <cmsys/FStream.hxx> #if defined(_WIN32) # include <windows.h> @@ -359,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) + if(strcmp(val, "NOTFOUND") == 0) { - return false; - } - if(len == lenNotFound-1) - { - return ( strcmp(val, "NOTFOUND") == 0); + return true; } - return ((strncmp((val + (len - lenNotFound)), notfound, lenNotFound) == 0)); + return cmHasLiteralSuffix(val, "-NOTFOUND"); } @@ -1432,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 \""; @@ -2037,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)) { @@ -2160,7 +2154,7 @@ void cmSystemTools::FindCMakeResources(const char* argv0) // Build tree has "<build>/bin[/<config>]/cmake" and // "<build>/CMakeFiles/CMakeSourceDir.txt". std::string src_dir_txt = dir + "/CMakeFiles/CMakeSourceDir.txt"; - std::ifstream fin(src_dir_txt.c_str()); + 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())) @@ -2171,7 +2165,7 @@ void cmSystemTools::FindCMakeResources(const char* argv0) { dir = cmSystemTools::GetFilenamePath(dir); src_dir_txt = dir + "/CMakeFiles/CMakeSourceDir.txt"; - std::ifstream fin2(src_dir_txt.c_str()); + cmsys::ifstream fin2(src_dir_txt.c_str()); if(fin2 && cmSystemTools::GetLineFromStream(fin2, src_dir) && cmSystemTools::FileIsDirectory(src_dir.c_str())) { @@ -2506,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) { @@ -2704,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/cmTarget.cxx b/Source/cmTarget.cxx index b06480b..21f8d4c 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -402,6 +402,26 @@ void cmTarget::SetMakefile(cmMakefile* mf) } //---------------------------------------------------------------------------- +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; +} + +//---------------------------------------------------------------------------- void cmTarget::FinishConfigure() { // Erase any cached link information that might have been comptued @@ -530,9 +550,9 @@ bool cmTarget::FindSourceFiles() } //---------------------------------------------------------------------------- -std::vector<cmSourceFile*> const& cmTarget::GetSourceFiles() const +void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files) const { - return this->SourceFiles; + files = this->SourceFiles; } //---------------------------------------------------------------------------- @@ -673,7 +693,8 @@ void cmTarget::ConstructSourceFileFlags() const // 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) { @@ -1660,14 +1681,14 @@ static void processIncludeDirectories(cmTarget const* tgt, evaluatedTargetName = cge->Evaluate(mf, config, false, tgt, 0, 0); } - cmTarget *dependentTarget = mf->FindTargetToUse(targetName.c_str()); + cmTarget *dependentTarget = mf->FindTargetToUse(targetName); const bool fromImported = dependentTarget && dependentTarget->IsImported(); cmTarget *evaluatedDependentTarget = (targetName != evaluatedTargetName) - ? mf->FindTargetToUse(evaluatedTargetName.c_str()) + ? mf->FindTargetToUse(evaluatedTargetName) : 0; targetName = evaluatedTargetName; @@ -1839,7 +1860,7 @@ cmTarget::GetIncludeDirectories(const char *config) const ge.Parse(it->Value); std::string result = cge->Evaluate(this->Makefile, config, false, this, 0, 0); - if (!this->Makefile->FindTargetToUse(result.c_str())) + if (!this->Makefile->FindTargetToUse(result)) { continue; } @@ -2068,7 +2089,7 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result, ge.Parse(it->Value); std::string targetResult = cge->Evaluate(this->Makefile, config, false, this, 0, 0); - if (!this->Makefile->FindTargetToUse(targetResult.c_str())) + if (!this->Makefile->FindTargetToUse(targetResult)) { continue; } @@ -2181,7 +2202,7 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, ge.Parse(it->Value); std::string targetResult = cge->Evaluate(this->Makefile, config, false, this, 0, 0); - if (!this->Makefile->FindTargetToUse(targetResult.c_str())) + if (!this->Makefile->FindTargetToUse(targetResult)) { continue; } @@ -2209,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; + } + } } } @@ -2820,7 +2861,7 @@ public: for(std::vector<std::string>::const_iterator li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) { - this->Visit(mf->FindTargetToUse(li->c_str())); + this->Visit(mf->FindTargetToUse(*li)); } } private: @@ -2928,7 +2969,7 @@ void cmTarget::ComputeLinkClosure(const char* config, LinkClosure& lc, for(std::vector<std::string>::const_iterator li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) { - cll.Visit(this->Makefile->FindTargetToUse(li->c_str())); + cll.Visit(this->Makefile->FindTargetToUse(*li)); } // Store the transitive closure of languages. @@ -5373,7 +5414,7 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, { if(emitted.insert(*li).second) { - if(cmTarget* tgt = this->Makefile->FindTargetToUse(li->c_str())) + if(cmTarget* tgt = this->Makefile->FindTargetToUse(*li)) { // This is a runtime dependency on another shared library. if(tgt->GetType() == cmTarget::SHARED_LIBRARY) @@ -5583,7 +5624,7 @@ void cmTarget::ComputeLinkImplementation(const char* config, } continue; } - cmTarget *tgt = this->Makefile->FindTargetToUse(li->c_str()); + cmTarget *tgt = this->Makefile->FindTargetToUse(*li); if(!tgt && std::string(item).find("::") != std::string::npos) { @@ -5654,7 +5695,7 @@ void cmTarget::ComputeLinkImplementation(const char* config, i = this->ObjectLibraries.begin(); i != this->ObjectLibraries.end(); ++i) { - if(cmTarget* objLib = this->Makefile->FindTargetToUse(i->c_str())) + if(cmTarget* objLib = this->Makefile->FindTargetToUse(*i)) { if(objLib->GetType() == cmTarget::OBJECT_LIBRARY) { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 4916648..ce0d812 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -132,7 +132,7 @@ public: /** * Get the list of the source files used by this target */ - std::vector<cmSourceFile*> const& GetSourceFiles() const; + void GetSourceFiles(std::vector<cmSourceFile*> &files) const; void AddSourceFile(cmSourceFile* sf); std::vector<std::string> const& GetObjectLibraries() const { @@ -242,9 +242,10 @@ public: * 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(); @@ -691,6 +692,7 @@ private: std::string RuntimeInstallPath; mutable std::string ExportMacro; std::set<cmStdString> Utilities; + std::map<cmStdString, cmListFileBacktrace> UtilityBacktraces; bool RecordDependencies; mutable cmPropertyMap Properties; LinkLibraryVectorType OriginalLinkLibraries; diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 209609d..02da933 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -31,7 +31,7 @@ bool cmTargetLinkLibrariesCommand return false; } - if (this->Makefile->IsAlias(args[0].c_str())) + if (this->Makefile->IsAlias(args[0])) { this->SetError("can not be used on an ALIAS target."); return false; diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index e7b6999..195690e 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -26,7 +26,7 @@ bool cmTargetPropCommandBase } // Lookup the target for which libraries are specified. - if (this->Makefile->IsAlias(args[0].c_str())) + if (this->Makefile->IsAlias(args[0])) { this->SetError("can not be used on an ALIAS target."); return false; @@ -36,7 +36,7 @@ bool cmTargetPropCommandBase ->GetGlobalGenerator()->FindTarget(0, args[0].c_str()); if(!this->Target) { - this->Target = this->Makefile->FindTargetToUse(args[0].c_str()); + this->Target = this->Makefile->FindTargetToUse(args[0]); } if(!this->Target) { diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index d962fb2..5dc3e60 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -82,7 +82,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, // be translated. std::string exe = command[0]; cmMakefile* mf = this->Test->GetMakefile(); - cmTarget* target = mf->FindTargetToUse(exe.c_str()); + cmTarget* target = mf->FindTargetToUse(exe); if(target && target->GetType() == cmTarget::EXECUTABLE) { // Use the target file on disk. diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index 879d4fd..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 ) { diff --git a/Source/cmUseMangledMesaCommand.cxx b/Source/cmUseMangledMesaCommand.cxx index 1bd579d..d4ec20f 100644 --- a/Source/cmUseMangledMesaCommand.cxx +++ b/Source/cmUseMangledMesaCommand.cxx @@ -13,6 +13,7 @@ #include "cmSystemTools.h" #include <cmsys/RegularExpression.hxx> +#include <cmsys/FStream.hxx> bool cmUseMangledMesaCommand ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) @@ -73,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: ", @@ -81,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/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index b9ae701..eee7c14 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -376,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); @@ -550,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); } @@ -596,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"; @@ -697,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(); @@ -740,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); @@ -813,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"; @@ -996,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; @@ -1038,19 +1047,21 @@ 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->GeneratorTarget->GetSourceDepends(*si); @@ -1058,7 +1069,9 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } } - 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; @@ -1081,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; @@ -1425,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); @@ -1882,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/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/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/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 741e263..33fb0fc 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -28,6 +28,7 @@ #include <cmsys/Glob.hxx> #include <cmsys/RegularExpression.hxx> +#include <cmsys/FStream.hxx> // only build kdevelop generator on non-windows platforms // when not bootstrapping cmake @@ -68,6 +69,7 @@ #endif #include "cmGlobalUnixMakefileGenerator3.h" #include "cmGlobalNinjaGenerator.h" +#include "cmExtraCodeLiteGenerator.h" #if !defined(CMAKE_BOOT_MINGW) # include "cmExtraCodeBlocksGenerator.h" @@ -592,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() ); @@ -990,6 +993,8 @@ 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(), @@ -1861,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, @@ -2387,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; @@ -2421,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) { @@ -2464,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)) @@ -2494,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 " diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 882b072..fcaa127 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -24,6 +24,7 @@ #include "cmGlobalGenerator.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" +#include <cmsys/Encoding.hxx> #ifdef CMAKE_BUILD_WITH_CMAKE //---------------------------------------------------------------------------- @@ -79,7 +80,7 @@ static const char * cmDocumentationOptions[][2] = #endif -static int do_command(int ac, char** av) +static int do_command(int ac, char const* const* av) { std::vector<std::string> args; args.push_back(av[0]); @@ -90,8 +91,8 @@ static int do_command(int ac, char** av) 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) { @@ -159,8 +160,13 @@ 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::FindCMakeResources(av[0]); if(ac > 1) @@ -181,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 ) { @@ -352,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"; diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx index 0675470..faa5fa7 100644 --- a/Source/cmcldeps.cxx +++ b/Source/cmcldeps.cxx @@ -139,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) diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index d3b7b5f..7891969 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -23,6 +23,7 @@ #include <cmsys/Directory.hxx> #include <cmsys/Process.h> +#include <cmsys/FStream.hxx> #if defined(CMAKE_HAVE_VS_GENERATORS) #include "cmCallVisualStudioMacro.h" @@ -376,7 +377,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) cmSystemTools::RemoveADirectory(dirName.c_str()); // is the last argument a filename that exists? - FILE *countFile = fopen(args[3].c_str(),"r"); + FILE *countFile = cmsys::SystemTools::Fopen(args[3].c_str(),"r"); int count; if (countFile) { @@ -396,7 +397,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // write the count into the directory std::string fName = dirName; fName += "/count.txt"; - FILE *progFile = fopen(fName.c_str(),"w"); + FILE *progFile = cmsys::SystemTools::Fopen(fName.c_str(),"w"); if (progFile) { fprintf(progFile,"%i\n",count); @@ -417,7 +418,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // read the count fName = dirName; fName += "/count.txt"; - progFile = fopen(fName.c_str(),"r"); + progFile = cmsys::SystemTools::Fopen(fName.c_str(),"r"); int count = 0; if (!progFile) { @@ -437,7 +438,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) fName = dirName; fName += "/"; fName += args[i]; - progFile = fopen(fName.c_str(),"w"); + progFile = cmsys::SystemTools::Fopen(fName.c_str(),"w"); if (progFile) { fprintf(progFile,"empty"); @@ -946,7 +947,7 @@ int cmcmd::ExecuteLinkScript(std::vector<std::string>& args) cmsysProcess_SetOption(cp, cmsysProcess_Option_Verbatim, 1); // Read command lines from the script. - std::ifstream fin(args[2].c_str()); + cmsys::ifstream fin(args[2].c_str()); if(!fin) { std::cerr << "Error opening link script \"" @@ -1057,7 +1058,7 @@ int cmcmd::VisualStudioLink(std::vector<std::string>& args, int type) // check for nmake temporary files if((*i)[0] == '@' && i->find("@CMakeFiles") != 0 ) { - std::ifstream fin(i->substr(1).c_str()); + cmsys::ifstream fin(i->substr(1).c_str()); std::string line; while(cmSystemTools::GetLineFromStream(fin, line)) @@ -1229,7 +1230,7 @@ int cmcmd::VisualStudioLinkIncremental(std::vector<std::string>& args, std::cout << "Create " << resourceInputFile.c_str() << "\n"; } // Create input file for rc command - std::ofstream fout(resourceInputFile.c_str()); + cmsys::ofstream fout(resourceInputFile.c_str()); if(!fout) { return -1; @@ -1252,7 +1253,7 @@ int cmcmd::VisualStudioLinkIncremental(std::vector<std::string>& args, { std::cout << "Create empty: " << manifestFile.c_str() << "\n"; } - std::ofstream foutTmp(manifestFile.c_str()); + cmsys::ofstream foutTmp(manifestFile.c_str()); } std::string resourceFile = manifestFile; resourceFile += ".res"; diff --git a/Source/ctest.cxx b/Source/ctest.cxx index de07458..3eb5551 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -18,6 +18,7 @@ #include "CTest/cmCTestScriptHandler.h" #include "CTest/cmCTestLaunch.h" +#include "cmsys/Encoding.hxx" //---------------------------------------------------------------------------- static const char * cmDocumentationName[][2] = @@ -111,8 +112,13 @@ static const char * cmDocumentationOptions[][2] = }; // 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::FindCMakeResources(argv[0]); |