diff options
Diffstat (limited to 'Source')
163 files changed, 3591 insertions, 1682 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index f9405b3..7705683 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -473,7 +473,7 @@ set(SRCS ${SRCS} cmNinjaUtilityTargetGenerator.cxx cmNinjaUtilityTargetGenerator.h ) -if(WIN32 AND NOT CYGWIN AND NOT BORLAND) +if(WIN32 AND NOT CYGWIN) set_source_files_properties(cmcldeps.cxx PROPERTIES COMPILE_DEFINITIONS _WIN32_WINNT=0x0501) add_executable(cmcldeps cmcldeps.cxx) target_link_libraries(cmcldeps CMakeLib) @@ -522,8 +522,10 @@ set(CTEST_SRCS cmCTest.cxx CTest/cmParseCacheCoverage.cxx CTest/cmParseGTMCoverage.cxx CTest/cmParseJacocoCoverage.cxx + CTest/cmParseBlanketJSCoverage.cxx CTest/cmParsePHPCoverage.cxx CTest/cmParseCoberturaCoverage.cxx + CTest/cmParseDelphiCoverage.cxx CTest/cmCTestEmptyBinaryDirectoryCommand.cxx CTest/cmCTestGenericHandler.cxx CTest/cmCTestHandlerCommand.cxx diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index e1b62e9..c8c6a5b 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 1) -set(CMake_VERSION_PATCH 0) -set(CMake_VERSION_RC 2) +set(CMake_VERSION_PATCH 20141201) +#set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index 6e7b8d7..e2437b5 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -56,7 +56,7 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(cmArchiveWrite& archive, localToplevel += "/"+ component->Name; std::string dir = cmSystemTools::GetCurrentWorkingDirectory(); // Change to local toplevel - cmSystemTools::ChangeDirectory(localToplevel.c_str()); + cmSystemTools::ChangeDirectory(localToplevel); std::string filePrefix; if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) { @@ -80,7 +80,7 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(cmArchiveWrite& archive, } } // Go back to previous dir - cmSystemTools::ChangeDirectory(dir.c_str()); + cmSystemTools::ChangeDirectory(dir); return 1; } @@ -270,7 +270,7 @@ int cmCPackArchiveGenerator::PackageFiles() DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0],archive); std::vector<std::string>::const_iterator fileIt; std::string dir = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(toplevel.c_str()); + cmSystemTools::ChangeDirectory(toplevel); for ( fileIt = files.begin(); fileIt != files.end(); ++ fileIt ) { // Get the relative path to the file @@ -288,7 +288,7 @@ int cmCPackArchiveGenerator::PackageFiles() return 0; } } - cmSystemTools::ChangeDirectory(dir.c_str()); + cmSystemTools::ChangeDirectory(dir); // The destructor of cmArchiveWrite will close and finish the write return 1; } diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx index 6c994f1..fbd1d21 100644 --- a/Source/CPack/cmCPackBundleGenerator.cxx +++ b/Source/CPack/cmCPackBundleGenerator.cxx @@ -39,6 +39,21 @@ int cmCPackBundleGenerator::InitializeInternal() return 0; } + if(this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP")) + { + const std::string codesign_path = cmSystemTools::FindProgram("codesign", + std::vector<std::string>(), false); + + if(codesign_path.empty()) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot locate codesign command" + << std::endl); + return 0; + } + this->SetOptionIfNotSet("CPACK_COMMAND_CODESIGN", codesign_path.c_str()); + } + return this->Superclass::InitializeInternal(); } @@ -53,7 +68,7 @@ const char* cmCPackBundleGenerator::GetPackagingInstallPrefix() } //---------------------------------------------------------------------- -int cmCPackBundleGenerator::PackageFiles() +int cmCPackBundleGenerator::ConstructBundle() { // Get required arguments ... @@ -165,6 +180,22 @@ int cmCPackBundleGenerator::PackageFiles() cmSystemTools::SetPermissions(command_target.str().c_str(), 0777); } + return 1; +} + +//---------------------------------------------------------------------- +int cmCPackBundleGenerator::PackageFiles() +{ + if(!this->ConstructBundle()) + { + return 0; + } + + if(!this->SignBundle(toplevel)) + { + return 0; + } + return this->CreateDMG(toplevel, packageFileNames[0]); } @@ -172,3 +203,96 @@ bool cmCPackBundleGenerator::SupportsComponentInstallation() const { return false; } + + +int cmCPackBundleGenerator::SignBundle(const std::string& src_dir) +{ + const std::string cpack_apple_cert_app = + this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP") + ? this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP") : ""; + + // codesign the application. + if(!cpack_apple_cert_app.empty()) + { + std::string bundle_path; + bundle_path = src_dir + "/"; + bundle_path += this->GetOption("CPACK_BUNDLE_NAME"); + bundle_path += ".app"; + + // A list of additional files to sign, ie. frameworks and plugins. + const std::string sign_files = + this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES") + ? this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES") : ""; + + std::vector<std::string> relFiles; + cmSystemTools::ExpandListArgument(sign_files, relFiles); + + // sign the files supplied by the user, ie. frameworks. + for(std::vector<std::string>::iterator it = relFiles.begin(); + it != relFiles.end(); ++it) + { + cmOStringStream temp_sign_file_cmd; + temp_sign_file_cmd << this->GetOption("CPACK_COMMAND_CODESIGN"); + temp_sign_file_cmd << " --deep -f -s \"" << cpack_apple_cert_app; + temp_sign_file_cmd << "\" -i "; + temp_sign_file_cmd << this->GetOption("CPACK_APPLE_BUNDLE_ID"); + temp_sign_file_cmd << " \""; + temp_sign_file_cmd << bundle_path; + temp_sign_file_cmd << it->c_str() << "\""; + + if(!this->RunCommand(temp_sign_file_cmd)) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error signing file:" + << bundle_path << it->c_str() << std::endl); + + return 0; + } + } + + // sign main binary + cmOStringStream temp_sign_binary_cmd; + temp_sign_binary_cmd << this->GetOption("CPACK_COMMAND_CODESIGN"); + temp_sign_binary_cmd << " --deep -f -s \"" << cpack_apple_cert_app; + temp_sign_binary_cmd << "\" \"" << bundle_path << "\""; + + if(!this->RunCommand(temp_sign_binary_cmd)) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error signing the application binary." + << std::endl); + + return 0; + } + + // sign app bundle + cmOStringStream temp_codesign_cmd; + temp_codesign_cmd << this->GetOption("CPACK_COMMAND_CODESIGN"); + temp_codesign_cmd << " --deep -f -s \"" << cpack_apple_cert_app << "\""; + if(this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS")) + { + temp_codesign_cmd << " --entitlements "; + temp_codesign_cmd << this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS"); + } + temp_codesign_cmd << " \"" << bundle_path << "\""; + + if(!this->RunCommand(temp_codesign_cmd)) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error signing the application package." + << std::endl); + + return 0; + } + + cmCPackLogger(cmCPackLog::LOG_OUTPUT, + "- Application has been codesigned" + << std::endl); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + (this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS") + ? "with entitlement sandboxing" : "without entitlement sandboxing") + << std::endl); + } + + return 1; +} diff --git a/Source/CPack/cmCPackBundleGenerator.h b/Source/CPack/cmCPackBundleGenerator.h index ed0187d..9cb2f0a 100644 --- a/Source/CPack/cmCPackBundleGenerator.h +++ b/Source/CPack/cmCPackBundleGenerator.h @@ -31,6 +31,8 @@ public: protected: virtual int InitializeInternal(); virtual const char* GetPackagingInstallPrefix(); + int ConstructBundle(); + int SignBundle(const std::string& src_dir); int PackageFiles(); bool SupportsComponentInstallation() const; diff --git a/Source/CPack/cmCPackComponentGroup.cxx b/Source/CPack/cmCPackComponentGroup.cxx index 77f11cb..fd20e9b 100644 --- a/Source/CPack/cmCPackComponentGroup.cxx +++ b/Source/CPack/cmCPackComponentGroup.cxx @@ -30,7 +30,7 @@ unsigned long cmCPackComponent::GetInstalledSize( std::string path = installDir; path += '/'; path += *fileIt; - this->TotalSize += cmSystemTools::FileLength(path.c_str()); + this->TotalSize += cmSystemTools::FileLength(path); } return this->TotalSize; diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 936942b..0a64bd5 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -58,7 +58,7 @@ int cmCPackDebGenerator::PackageOnePack(std::string initialTopLevel, // Begin the archive for this pack std::string localToplevel(initialTopLevel); std::string packageFileName( - cmSystemTools::GetParentDirectory(toplevel.c_str()) + cmSystemTools::GetParentDirectory(toplevel) ); std::string outputFileName( std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) @@ -186,7 +186,7 @@ int cmCPackDebGenerator::PackageComponentsAllInOne() // The ALL GROUPS in ONE package case std::string localToplevel(initialTopLevel); std::string packageFileName( - cmSystemTools::GetParentDirectory(toplevel.c_str()) + cmSystemTools::GetParentDirectory(toplevel) ); std::string outputFileName( std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) @@ -390,7 +390,7 @@ int cmCPackDebGenerator::createDeb() packageFiles.begin(); fileIt != packageFiles.end(); ++ fileIt ) { - totalSize += cmSystemTools::FileLength(fileIt->c_str()); + totalSize += cmSystemTools::FileLength(*fileIt); } } out << "Installed-Size: " << (totalSize + 1023) / 1024 << "\n"; @@ -540,7 +540,7 @@ int cmCPackDebGenerator::createDeb() localcopy += filenamename; // if we can copy the file, it means it does exist, let's add it: if( cmsys::SystemTools::CopyFileIfDifferent( - i->c_str(), localcopy.c_str()) ) + *i, localcopy) ) { // debian is picky and need relative to ./ path in the tar.* cmd += " ./"; diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 1461bb1..e78f161 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -217,7 +217,7 @@ int cmCPackGenerator::InstallProject() { std::string destDir = "DESTDIR="; destDir += tempInstallDirectory; - cmSystemTools::PutEnv(destDir.c_str()); + cmSystemTools::PutEnv(destDir); } else { @@ -277,7 +277,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( { std::string tempInstallDirectoryEnv = "CMAKE_INSTALL_PREFIX="; tempInstallDirectoryEnv += tempInstallDirectory; - cmSystemTools::PutEnv(tempInstallDirectoryEnv.c_str()); + cmSystemTools::PutEnv(tempInstallDirectoryEnv); std::vector<std::string> installCommandsVector; cmSystemTools::ExpandListArgument(installCommands,installCommandsVector); std::vector<std::string>::iterator it; @@ -399,12 +399,12 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: " << inFile << " -> " << filePath << std::endl); /* If the file is a symlink we will have to re-create it */ - if ( cmSystemTools::FileIsSymlink(inFile.c_str())) + if ( cmSystemTools::FileIsSymlink(inFile)) { std::string targetFile; std::string inFileRelative = cmSystemTools::RelativePath(top.c_str(),inFile.c_str()); - cmSystemTools::ReadSymlink(inFile.c_str(),targetFile); + cmSystemTools::ReadSymlink(inFile,targetFile); symlinkedFiles.push_back(std::pair<std::string, std::string>(targetFile,inFileRelative)); } @@ -429,7 +429,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( goToDir += "/"+subdir; cmCPackLogger(cmCPackLog::LOG_DEBUG, "Change dir to: " << goToDir <<std::endl); - cmSystemTools::ChangeDirectory(goToDir.c_str()); + cmSystemTools::ChangeDirectory(goToDir); for (symlinkedIt=symlinkedFiles.begin(); symlinkedIt != symlinkedFiles.end(); ++symlinkedIt) @@ -437,8 +437,8 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( cmCPackLogger(cmCPackLog::LOG_DEBUG, "Will create a symlink: " << symlinkedIt->second << "--> " << symlinkedIt->first << std::endl); - if (!cmSystemTools::CreateSymlink((symlinkedIt->first).c_str(), - (symlinkedIt->second).c_str())) + if (!cmSystemTools::CreateSymlink(symlinkedIt->first, + symlinkedIt->second)) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create symlink: " << symlinkedIt->second << "--> " @@ -448,7 +448,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( } cmCPackLogger(cmCPackLog::LOG_DEBUG, "Going back to: " << curDir <<std::endl); - cmSystemTools::ChangeDirectory(curDir.c_str()); + cmSystemTools::ChangeDirectory(curDir); } } } @@ -787,7 +787,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( * in order to put things in subdirs... */ cmSystemTools::PutEnv( - (std::string("DESTDIR=")+tempInstallDirectory).c_str() + std::string("DESTDIR=")+tempInstallDirectory ); cmCPackLogger(cmCPackLog::LOG_DEBUG, "- Creating directory: '" << dir << "'" << std::endl); diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index c8737f4..94ca536 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -47,9 +47,6 @@ #include "cmCPackLog.h" -#if defined(__BORLANDC__) -# pragma warn -8008 /* condition is always true */ -#endif //---------------------------------------------------------------------- cmCPackGeneratorFactory::cmCPackGeneratorFactory() diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index a5eee6b..b506b06 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -657,8 +657,8 @@ bool cmCPackNSISGenerator::GetListOfSubdirectories(const char* topdir, cmsys_stl::string fullPath = topdir; fullPath += "/"; fullPath += dir.GetFile(static_cast<unsigned long>(fileNum)); - if(cmsys::SystemTools::FileIsDirectory(fullPath.c_str()) && - !cmsys::SystemTools::FileIsSymlink(fullPath.c_str())) + if(cmsys::SystemTools::FileIsDirectory(fullPath) && + !cmsys::SystemTools::FileIsSymlink(fullPath)) { if (!this->GetListOfSubdirectories(fullPath.c_str(), dirs)) { @@ -771,7 +771,7 @@ CreateComponentDescription(cmCPackComponent *component, << archiveFile << std::endl); if (cmSystemTools::FileExists(archiveFile.c_str(), true)) { - if (!cmSystemTools::RemoveFile(archiveFile.c_str())) + if (!cmSystemTools::RemoveFile(archiveFile)) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Unable to remove archive file " << archiveFile @@ -825,7 +825,7 @@ CreateComponentDescription(cmCPackComponent *component, } out << std::endl; - totalSize += cmSystemTools::FileLength((dirName + *fileIt).c_str()); + totalSize += cmSystemTools::FileLength(dirName + *fileIt); } } diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index c6171dc..71ab3a0 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -57,7 +57,7 @@ int cmCPackRPMGenerator::PackageOnePack(std::string initialToplevel, // Begin the archive for this pack std::string localToplevel(initialToplevel); std::string packageFileName( - cmSystemTools::GetParentDirectory(toplevel.c_str()) + cmSystemTools::GetParentDirectory(toplevel) ); std::string outputFileName( GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"), @@ -166,7 +166,7 @@ int cmCPackRPMGenerator::PackageComponentsAllInOne() // The ALL GROUPS in ONE package case std::string localToplevel(initialTopLevel); std::string packageFileName( - cmSystemTools::GetParentDirectory(toplevel.c_str()) + cmSystemTools::GetParentDirectory(toplevel) ); std::string outputFileName( std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index 6c1d201..e5da5cf 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -71,8 +71,6 @@ int cmCPackSTGZGenerator::PackageFiles() retval &= cmSystemTools::SetPermissions((*it).c_str(), #if defined( _MSC_VER ) || defined( __MINGW32__ ) S_IREAD | S_IWRITE | S_IEXEC -#elif defined( __BORLANDC__ ) - S_IRUSR | S_IWUSR | S_IXUSR #else S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index c57028d..26bf607 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -267,7 +267,7 @@ int main (int argc, char const* const* argv) if ( cmSystemTools::FileExists(cpackConfigFile.c_str()) ) { cpackConfigFile = - cmSystemTools::CollapseFullPath(cpackConfigFile.c_str()); + cmSystemTools::CollapseFullPath(cpackConfigFile); cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Read CPack configuration file: " << cpackConfigFile << std::endl); diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index 41db042..a101e39 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -109,7 +109,7 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, out << "Error: cmake execution failed\n"; out << cmakeOutString << "\n"; // return to the original directory - cmSystemTools::ChangeDirectory(cwd.c_str()); + cmSystemTools::ChangeDirectory(cwd); if(outstring) { *outstring = out.str(); @@ -128,7 +128,7 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, out << "Error: cmake execution failed\n"; out << cmakeOutString << "\n"; // return to the original directory - cmSystemTools::ChangeDirectory(cwd.c_str()); + cmSystemTools::ChangeDirectory(cwd); if(outstring) { *outstring = out.str(); @@ -241,11 +241,11 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); out << "Internal cmake changing into directory: " << this->BinaryDir << std::endl; - if (!cmSystemTools::FileIsDirectory(this->BinaryDir.c_str())) + if (!cmSystemTools::FileIsDirectory(this->BinaryDir)) { cmSystemTools::MakeDirectory(this->BinaryDir.c_str()); } - cmSystemTools::ChangeDirectory(this->BinaryDir.c_str()); + cmSystemTools::ChangeDirectory(this->BinaryDir); if(this->BuildNoCMake) { @@ -374,7 +374,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) cmCTestLog(this->CTest, ERROR_MESSAGE, out.str()); } // return to the original directory - cmSystemTools::ChangeDirectory(cwd.c_str()); + cmSystemTools::ChangeDirectory(cwd); return 1; } @@ -391,7 +391,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) if(this->BuildRunDir.size()) { out << "Run test in directory: " << this->BuildRunDir << "\n"; - cmSystemTools::ChangeDirectory(this->BuildRunDir.c_str()); + cmSystemTools::ChangeDirectory(this->BuildRunDir); } out << "Running test command: \"" << fullPath << "\""; for(size_t k=0; k < this->TestCommandArgs.size(); ++k) @@ -453,9 +453,9 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments( // dir must exist before CollapseFullPath is called cmSystemTools::MakeDirectory(this->BinaryDir.c_str()); this->BinaryDir - = cmSystemTools::CollapseFullPath(this->BinaryDir.c_str()); + = cmSystemTools::CollapseFullPath(this->BinaryDir); this->SourceDir - = cmSystemTools::CollapseFullPath(this->SourceDir.c_str()); + = cmSystemTools::CollapseFullPath(this->SourceDir); } else { diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 2ec1365..d226a6c 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -36,9 +36,6 @@ #include <math.h> #include <float.h> -#if defined(__BORLANDC__) -# pragma warn -8060 /* possibly incorrect assignment */ -#endif static const char* cmCTestErrorMatches[] = { "^[Bb]us [Ee]rror", @@ -610,7 +607,7 @@ void cmCTestBuildHandler::GenerateXMLLaunched(std::ostream& os) int numWarningsAllowed = this->MaxWarnings; // Identify fragments on disk. cmsys::Directory launchDir; - launchDir.Load(this->CTestLaunchDir.c_str()); + launchDir.Load(this->CTestLaunchDir); unsigned long n = launchDir.GetNumberOfFiles(); for(unsigned long i=0; i < n; ++i) { @@ -649,7 +646,7 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(std::ostream& os) std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory"); // make sure the source dir is in the correct case on windows // via a call to collapse full path. - srcdir = cmSystemTools::CollapseFullPath(srcdir.c_str()); + srcdir = cmSystemTools::CollapseFullPath(srcdir); srcdir += "/"; for ( it = ew.begin(); it != ew.end() && (numErrorsAllowed || numWarningsAllowed); it++ ) @@ -695,7 +692,7 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(std::ostream& os) { // make sure it is a full path with the correct case cm->SourceFile = cmSystemTools::CollapseFullPath( - cm->SourceFile.c_str()); + cm->SourceFile); cmSystemTools::ReplaceString( cm->SourceFile, srcdir.c_str(), ""); } @@ -822,7 +819,7 @@ cmCTestBuildHandler::LaunchHelper::LaunchHelper(cmCTestBuildHandler* handler): launchDir += "/Build"; // Clean out any existing launcher fragments. - cmSystemTools::RemoveADirectory(launchDir.c_str()); + cmSystemTools::RemoveADirectory(launchDir); if(this->Handler->UseCTestLaunch) { @@ -831,7 +828,7 @@ cmCTestBuildHandler::LaunchHelper::LaunchHelper(cmCTestBuildHandler* handler): this->WriteLauncherConfig(); std::string launchEnv = "CTEST_LAUNCH_LOGS="; launchEnv += launchDir; - cmSystemTools::PutEnv(launchEnv.c_str()); + cmSystemTools::PutEnv(launchEnv); } } diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 76f6584..e782886 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -15,6 +15,8 @@ #include "cmParseGTMCoverage.h" #include "cmParseCacheCoverage.h" #include "cmParseJacocoCoverage.h" +#include "cmParseDelphiCoverage.h" +#include "cmParseBlanketJSCoverage.h" #include "cmCTest.h" #include "cmake.h" #include "cmMakefile.h" @@ -164,7 +166,7 @@ void cmCTestCoverageHandler::CleanCoverageLogFiles(std::ostream& log) fi != files.end(); ++fi) { log << "Removing old coverage log: " << *fi << "\n"; - cmSystemTools::RemoveFile(fi->c_str()); + cmSystemTools::RemoveFile(*fi); } } @@ -237,10 +239,10 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, std::string fSrcDir = cmSystemTools::CollapseFullPath(srcDir); std::string fBinDir = cmSystemTools::CollapseFullPath(binDir); std::string fFile = cmSystemTools::CollapseFullPath(file); - bool sourceSubDir = cmSystemTools::IsSubDirectory(fFile.c_str(), - fSrcDir.c_str()); - bool buildSubDir = cmSystemTools::IsSubDirectory(fFile.c_str(), - fBinDir.c_str()); + bool sourceSubDir = cmSystemTools::IsSubDirectory(fFile, + fSrcDir); + bool buildSubDir = cmSystemTools::IsSubDirectory(fFile, + fBinDir); // Always check parent directory of the file. std::string fileDir = cmSystemTools::GetFilenamePath(fFile); std::string checkDir; @@ -423,6 +425,19 @@ int cmCTestCoverageHandler::ProcessHandler() return error; } + file_count += this->HandleBlanketJSCoverage(&cont); + error = cont.Error; + if ( file_count < 0 ) + { + return error; + } + + file_count += this->HandleDelphiCoverage(&cont); + error = cont.Error; + if ( file_count < 0 ) + { + return error; + } std::set<std::string> uncovered = this->FindUncoveredFiles(&cont); if ( file_count == 0 ) @@ -758,8 +773,8 @@ void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile *mf) //---------------------------------------------------------------------- bool IsFileInDir(const std::string &infile, const std::string &indir) { - std::string file = cmSystemTools::CollapseFullPath(infile.c_str()); - std::string dir = cmSystemTools::CollapseFullPath(indir.c_str()); + std::string file = cmSystemTools::CollapseFullPath(infile); + std::string dir = cmSystemTools::CollapseFullPath(indir); if ( file.size() > dir.size() && @@ -779,7 +794,7 @@ int cmCTestCoverageHandler::HandlePHPCoverage( { cmParsePHPCoverage cov(*cont, this->CTest); std::string coverageDir = this->CTest->GetBinaryDir() + "/xdebugCoverage"; - if(cmSystemTools::FileIsDirectory(coverageDir.c_str())) + if(cmSystemTools::FileIsDirectory(coverageDir)) { cov.ReadPHPCoverageDirectory(coverageDir.c_str()); } @@ -869,7 +884,7 @@ struct cmCTestCoverageHandlerLocale { if(!lc_all.empty()) { - cmSystemTools::PutEnv(("LC_ALL=" + lc_all).c_str()); + cmSystemTools::PutEnv("LC_ALL=" + lc_all); } else { @@ -910,7 +925,68 @@ int cmCTestCoverageHandler::HandleJacocoCoverage( return static_cast<int>(cont->TotalCoverage.size()); } +//---------------------------------------------------------------------- +int cmCTestCoverageHandler::HandleDelphiCoverage( + cmCTestCoverageHandlerContainer* cont) +{ + cmParseDelphiCoverage cov = + cmParseDelphiCoverage(*cont, this->CTest); + cmsys::Glob g; + std::vector<std::string> files; + g.SetRecurse(true); + + + std::string BinDir + = this->CTest->GetBinaryDir(); + std::string coverageFile = BinDir+ "/*.html"; + + g.FindFiles(coverageFile); + files=g.GetFiles(); + if (files.size() > 0) + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Found Delphi HTML Files, Performing Coverage" << std::endl); + cov.LoadCoverageData(files); + } + else + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " Cannot find Delphi coverage files: " << coverageFile + << std::endl); + } + return static_cast<int>(cont->TotalCoverage.size()); +} + +//---------------------------------------------------------------------- +int cmCTestCoverageHandler::HandleBlanketJSCoverage( + cmCTestCoverageHandlerContainer* cont) + { + cmParseBlanketJSCoverage cov = + cmParseBlanketJSCoverage(*cont, this->CTest); + std::string SourceDir + = this->CTest->GetCTestConfiguration("SourceDirectory"); + + //Look for something other than output.json, still JSON extension. + std::string coverageFile = SourceDir+ "/*.json"; + cmsys::Glob g; + std::vector<std::string> files; + g.FindFiles(coverageFile); + files=g.GetFiles(); + if (files.size() > 0) + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Found BlanketJS output JSON, Performing Coverage" << std::endl); + cov.LoadCoverageData(files); + } + else + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " Cannot find BlanketJS coverage files: " << coverageFile + << std::endl); + } + return static_cast<int>(cont->TotalCoverage.size()); + } //---------------------------------------------------------------------- int cmCTestCoverageHandler::HandleGCovCoverage( cmCTestCoverageHandlerContainer* cont) @@ -974,7 +1050,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( std::string tempDir = testingDir + "/CoverageInfo"; std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory(); cmSystemTools::MakeDirectory(tempDir.c_str()); - cmSystemTools::ChangeDirectory(tempDir.c_str()); + cmSystemTools::ChangeDirectory(tempDir); int gcovStyle = 0; @@ -1295,7 +1371,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( *cont->OFS << " produced in source dir: " << sourceFile << std::endl; actualSourceFile - = cmSystemTools::CollapseFullPath(sourceFile.c_str()); + = cmSystemTools::CollapseFullPath(sourceFile); } else if ( IsFileInDir(sourceFile, cont->BinaryDir) ) { @@ -1304,7 +1380,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( *cont->OFS << " produced in binary dir: " << sourceFile << std::endl; actualSourceFile - = cmSystemTools::CollapseFullPath(sourceFile.c_str()); + = cmSystemTools::CollapseFullPath(sourceFile); } if ( actualSourceFile.empty() ) @@ -1345,7 +1421,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( } } - cmSystemTools::ChangeDirectory(currentDirectory.c_str()); + cmSystemTools::ChangeDirectory(currentDirectory); return file_count; } @@ -1409,30 +1485,30 @@ int cmCTestCoverageHandler::HandleLCovCoverage( for ( it = files.begin(); it != files.end(); ++ it ) { cmCTestLog(this->CTest, HANDLER_OUTPUT, "." << std::flush); - std::string fileDir = cmSystemTools::GetFilenamePath(it->c_str()); - cmSystemTools::ChangeDirectory(fileDir.c_str()); + std::string fileDir = cmSystemTools::GetFilenamePath(*it); + cmSystemTools::ChangeDirectory(fileDir); std::string command = "\"" + lcovCommand + "\" " + lcovExtraFlags + " "; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Current coverage dir: " - << fileDir.c_str() << std::endl); + << fileDir << std::endl); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, command.c_str() << std::endl); std::string output = ""; std::string errors = ""; int retVal = 0; - *cont->OFS << "* Run coverage for: " << fileDir.c_str() << std::endl; - *cont->OFS << " Command: " << command.c_str() << std::endl; + *cont->OFS << "* Run coverage for: " << fileDir << std::endl; + *cont->OFS << " Command: " << command << std::endl; int res = this->CTest->RunCommand(command.c_str(), &output, &errors, &retVal, fileDir.c_str(), 0 /*this->TimeOut*/); - *cont->OFS << " Output: " << output.c_str() << std::endl; - *cont->OFS << " Errors: " << errors.c_str() << std::endl; + *cont->OFS << " Output: " << output << std::endl; + *cont->OFS << " Errors: " << errors << std::endl; if ( ! res ) { cmCTestLog(this->CTest, ERROR_MESSAGE, - "Problem running coverage on file: " << it->c_str() << std::endl); + "Problem running coverage on file: " << *it << std::endl); cmCTestLog(this->CTest, ERROR_MESSAGE, "Command produced error: " << errors << std::endl); cont->Error ++; @@ -1441,7 +1517,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage( if ( retVal != 0 ) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Coverage command returned: " - << retVal << " while processing: " << it->c_str() << std::endl); + << retVal << " while processing: " << *it << std::endl); cmCTestLog(this->CTest, ERROR_MESSAGE, "Command produced error: " << cont->Error << std::endl); } @@ -1609,7 +1685,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage( } } - cmSystemTools::ChangeDirectory(currentDirectory.c_str()); + cmSystemTools::ChangeDirectory(currentDirectory); return file_count; } @@ -1653,7 +1729,7 @@ void cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files) gl.RecurseThroughSymlinksOff(); std::string prevBinaryDir; cmSystemTools::ChangeDirectory( - this->CTest->GetCTestConfiguration("BuildDirectory").c_str()); + this->CTest->GetCTestConfiguration("BuildDirectory")); // Run profmerge to merge all *.dyn files into dpi files cmSystemTools::RunSingleCommand("profmerge"); @@ -1696,9 +1772,9 @@ int cmCTestCoverageHandler::HandleTracePyCoverage( std::string tempDir = testingDir + "/CoverageInfo"; std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory(); cmSystemTools::MakeDirectory(tempDir.c_str()); - cmSystemTools::ChangeDirectory(tempDir.c_str()); + cmSystemTools::ChangeDirectory(tempDir); - cmSystemTools::ChangeDirectory(currentDirectory.c_str()); + cmSystemTools::ChangeDirectory(currentDirectory); std::vector<std::string>::iterator fileIt; int file_count = 0; @@ -1714,7 +1790,7 @@ int cmCTestCoverageHandler::HandleTracePyCoverage( } std::string actualSourceFile - = cmSystemTools::CollapseFullPath(fileName.c_str()); + = cmSystemTools::CollapseFullPath(fileName); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Check coverage for file: " << actualSourceFile << std::endl); @@ -1802,7 +1878,7 @@ int cmCTestCoverageHandler::HandleTracePyCoverage( } ++ file_count; } - cmSystemTools::ChangeDirectory(currentDirectory.c_str()); + cmSystemTools::ChangeDirectory(currentDirectory); return file_count; } @@ -2132,7 +2208,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary( file += "/"; file += sourceFile; } - file = cmSystemTools::CollapseFullPath(file.c_str()); + file = cmSystemTools::CollapseFullPath(file); bool shouldIDoCoverage = this->ShouldIDoCoverage(file.c_str(), cont->SourceDir.c_str(), diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h index d0f274c..4aec795 100644 --- a/Source/CTest/cmCTestCoverageHandler.h +++ b/Source/CTest/cmCTestCoverageHandler.h @@ -84,6 +84,12 @@ private: //! Handle coverage for Jacoco int HandleJacocoCoverage(cmCTestCoverageHandlerContainer* cont); + //! Handle coverage for Delphi (Pascal) + int HandleDelphiCoverage(cmCTestCoverageHandlerContainer* cont); + + //! Handle coverage for Jacoco + int HandleBlanketJSCoverage(cmCTestCoverageHandlerContainer* cont); + //! Handle coverage using Bullseye int HandleBullseyeCoverage(cmCTestCoverageHandlerContainer* cont); int RunBullseyeSourceSummary(cmCTestCoverageHandlerContainer* cont); diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index aaa01b2..98bc9d7 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -158,7 +158,7 @@ std::string cmCTestGIT::FindTopDir() { top_dir += "/"; top_dir += cdup; - top_dir = cmSystemTools::CollapseFullPath(top_dir.c_str()); + top_dir = cmSystemTools::CollapseFullPath(top_dir); } return top_dir; } diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx index 0e29160..5b525dd 100644 --- a/Source/CTest/cmCTestHandlerCommand.cxx +++ b/Source/CTest/cmCTestHandlerCommand.cxx @@ -137,7 +137,7 @@ bool cmCTestHandlerCommand } std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory(); cmSystemTools::ChangeDirectory( - this->CTest->GetCTestConfiguration("BuildDirectory").c_str()); + this->CTest->GetCTestConfiguration("BuildDirectory")); int res = handler->ProcessHandler(); if ( this->Values[ct_RETURN_VALUE] && *this->Values[ct_RETURN_VALUE]) { @@ -146,7 +146,7 @@ bool cmCTestHandlerCommand this->Makefile->AddDefinition( this->Values[ct_RETURN_VALUE], str.str().c_str()); } - cmSystemTools::ChangeDirectory(current_dir.c_str()); + cmSystemTools::ChangeDirectory(current_dir); return true; } diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index 10a5199..b65d23b 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -48,8 +48,8 @@ cmCTestLaunch::~cmCTestLaunch() cmsysProcess_Delete(this->Process); if(!this->Passthru) { - cmSystemTools::RemoveFile(this->LogOut.c_str()); - cmSystemTools::RemoveFile(this->LogErr.c_str()); + cmSystemTools::RemoveFile(this->LogOut); + cmSystemTools::RemoveFile(this->LogErr); } } @@ -434,8 +434,8 @@ void cmCTestLaunch::WriteXMLAction(std::ostream& fxml) // If file is in source tree use its relative location. if(cmSystemTools::FileIsFullPath(this->SourceDir.c_str()) && cmSystemTools::FileIsFullPath(source.c_str()) && - cmSystemTools::IsSubDirectory(source.c_str(), - this->SourceDir.c_str())) + cmSystemTools::IsSubDirectory(source, + this->SourceDir)) { source = cmSystemTools::RelativePath(this->SourceDir.c_str(), source.c_str()); diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 4835010..089e84b 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -1221,10 +1221,10 @@ cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res, } } cmSystemTools::Delay(1000); - cmSystemTools::RemoveFile(this->BoundsCheckerDPBDFile.c_str()); + cmSystemTools::RemoveFile(this->BoundsCheckerDPBDFile); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: " << this->BoundsCheckerDPBDFile << std::endl); - cmSystemTools::RemoveFile(this->BoundsCheckerXMLFile.c_str()); + cmSystemTools::RemoveFile(this->BoundsCheckerXMLFile); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: " << this->BoundsCheckerXMLFile << std::endl); } @@ -1255,7 +1255,7 @@ cmCTestMemCheckHandler::AppendMemTesterOutput(cmCTestTestResult& res, } if(this->LogWithPID) { - cmSystemTools::RemoveFile(ofile.c_str()); + cmSystemTools::RemoveFile(ofile); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: "<< ofile <<"\n"); } } diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 7ba434c..4c89caa 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -123,7 +123,7 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test) testRun->SetTestProperties(this->Properties[test]); std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(this->Properties[test]->Directory.c_str()); + cmSystemTools::ChangeDirectory(this->Properties[test]->Directory); // Lock the resources we'll be using this->LockResources(test); @@ -156,7 +156,7 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test) this->Failed->push_back(this->Properties[test]->Name); delete testRun; } - cmSystemTools::ChangeDirectory(current_dir.c_str()); + cmSystemTools::ChangeDirectory(current_dir); } //--------------------------------------------------------- @@ -334,7 +334,7 @@ void cmCTestMultiProcessHandler::UpdateCostData() { if(line == "---") break; std::vector<cmsys::String> parts = - cmSystemTools::SplitString(line.c_str(), ' '); + cmSystemTools::SplitString(line, ' '); //Format: <name> <previous_runs> <avg_cost> if(parts.size() < 3) break; @@ -357,7 +357,7 @@ void cmCTestMultiProcessHandler::UpdateCostData() } } fin.close(); - cmSystemTools::RemoveFile(fname.c_str()); + cmSystemTools::RemoveFile(fname); } // Add all tests not previously listed in the file @@ -393,7 +393,7 @@ void cmCTestMultiProcessHandler::ReadCostData() if(line == "---") break; std::vector<cmsys::String> parts = - cmSystemTools::SplitString(line.c_str(), ' '); + cmSystemTools::SplitString(line, ' '); // Probably an older version of the file, will be fixed next run if(parts.size() < 3) @@ -621,7 +621,7 @@ void cmCTestMultiProcessHandler::MarkFinished() { std::string fname = this->CTest->GetBinaryDir() + "/Testing/Temporary/CTestCheckpoint.txt"; - cmSystemTools::RemoveFile(fname.c_str()); + cmSystemTools::RemoveFile(fname); } //--------------------------------------------------------- @@ -639,7 +639,7 @@ void cmCTestMultiProcessHandler::PrintTestList() //push working dir std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(p.Directory.c_str()); + cmSystemTools::ChangeDirectory(p.Directory); cmCTestRunTest testRun(this->TestHandler); testRun.SetIndex(p.Index); @@ -676,7 +676,7 @@ void cmCTestMultiProcessHandler::PrintTestList() cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); cmCTestLog(this->CTest, HANDLER_OUTPUT, p.Name.c_str() << std::endl); //pop working dir - cmSystemTools::ChangeDirectory(current_dir.c_str()); + cmSystemTools::ChangeDirectory(current_dir); } cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl << "Total Tests: " @@ -735,7 +735,7 @@ void cmCTestMultiProcessHandler::CheckResume() } else if(cmSystemTools::FileExists(fname.c_str(), true)) { - cmSystemTools::RemoveFile(fname.c_str()); + cmSystemTools::RemoveFile(fname); } } diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index bdd8c02..9e3c9fc 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -280,12 +280,12 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) // Set the working directory to the tests directory std::string oldpath = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(this->TestProperties->Directory.c_str()); + cmSystemTools::ChangeDirectory(this->TestProperties->Directory); this->DartProcessing(); // restore working directory - cmSystemTools::ChangeDirectory(oldpath.c_str()); + cmSystemTools::ChangeDirectory(oldpath); // if this is doing MemCheck then all the output needs to be put into diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index f050148..749eb58 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -184,7 +184,7 @@ int cmCTestScriptHandler::ProcessHandler() { // for each script run it res += this->RunConfigurationScript - (cmSystemTools::CollapseFullPath(this->ConfigurationScripts[i].c_str()), + (cmSystemTools::CollapseFullPath(this->ConfigurationScripts[i]), this->ScriptProcessScope[i]); } if ( res ) @@ -482,8 +482,8 @@ int cmCTestScriptHandler::ExtractVariables() = this->Makefile->GetSafeDefinition("CTEST_BINARY_DIRECTORY"); // add in translations for src and bin - cmSystemTools::AddKeepPath(this->SourceDir.c_str()); - cmSystemTools::AddKeepPath(this->BinaryDir.c_str()); + cmSystemTools::AddKeepPath(this->SourceDir); + cmSystemTools::AddKeepPath(this->BinaryDir); this->CTestCmd = this->Makefile->GetSafeDefinition("CTEST_COMMAND"); @@ -743,11 +743,11 @@ int cmCTestScriptHandler::BackupDirectories() // if for some reason those directories exist then first delete them if (cmSystemTools::FileExists(this->BackupSourceDir.c_str())) { - cmSystemTools::RemoveADirectory(this->BackupSourceDir.c_str()); + cmSystemTools::RemoveADirectory(this->BackupSourceDir); } if (cmSystemTools::FileExists(this->BackupBinaryDir.c_str())) { - cmSystemTools::RemoveADirectory(this->BackupBinaryDir.c_str()); + cmSystemTools::RemoveADirectory(this->BackupBinaryDir); } // first rename the src and binary directories @@ -991,8 +991,8 @@ int cmCTestScriptHandler::RunConfigurationDashboard() // if all was succesful, delete the backup dirs to free up disk space if (this->Backup) { - cmSystemTools::RemoveADirectory(this->BackupSourceDir.c_str()); - cmSystemTools::RemoveADirectory(this->BackupBinaryDir.c_str()); + cmSystemTools::RemoveADirectory(this->BackupSourceDir); + cmSystemTools::RemoveADirectory(this->BackupBinaryDir); } return 0; @@ -1033,11 +1033,11 @@ void cmCTestScriptHandler::RestoreBackupDirectories() // if for some reason those directories exist then first delete them if (cmSystemTools::FileExists(this->SourceDir.c_str())) { - cmSystemTools::RemoveADirectory(this->SourceDir.c_str()); + cmSystemTools::RemoveADirectory(this->SourceDir); } if (cmSystemTools::FileExists(this->BinaryDir.c_str())) { - cmSystemTools::RemoveADirectory(this->BinaryDir.c_str()); + cmSystemTools::RemoveADirectory(this->BinaryDir); } // rename the src and binary directories rename(this->BackupSourceDir.c_str(), this->SourceDir.c_str()); @@ -1100,7 +1100,7 @@ bool cmCTestScriptHandler::TryToRemoveBinaryDirectoryOnce( const std::string& directoryPath) { cmsys::Directory directory; - directory.Load(directoryPath.c_str()); + directory.Load(directoryPath); for(unsigned long i = 0; i < directory.GetNumberOfFiles(); ++i) { @@ -1113,26 +1113,26 @@ bool cmCTestScriptHandler::TryToRemoveBinaryDirectoryOnce( std::string fullPath = directoryPath + std::string("/") + path; - bool isDirectory = cmSystemTools::FileIsDirectory(fullPath.c_str()) && - !cmSystemTools::FileIsSymlink(fullPath.c_str()); + bool isDirectory = cmSystemTools::FileIsDirectory(fullPath) && + !cmSystemTools::FileIsSymlink(fullPath); if(isDirectory) { - if(!cmSystemTools::RemoveADirectory(fullPath.c_str())) + if(!cmSystemTools::RemoveADirectory(fullPath)) { return false; } } else { - if(!cmSystemTools::RemoveFile(fullPath.c_str())) + if(!cmSystemTools::RemoveFile(fullPath)) { return false; } } } - return cmSystemTools::RemoveADirectory(directoryPath.c_str()); + return cmSystemTools::RemoveADirectory(directoryPath); } //------------------------------------------------------------------------- diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx index da46f4a..1a39a8a 100644 --- a/Source/CTest/cmCTestStartCommand.cxx +++ b/Source/CTest/cmCTestStartCommand.cxx @@ -124,7 +124,7 @@ bool cmCTestStartCommand { return false; } - if(!cmSystemTools::FileIsDirectory(sourceDir.c_str())) + if(!cmSystemTools::FileIsDirectory(sourceDir)) { cmOStringStream e; e << "given source path\n" diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 06fcb75..6aa1c2b 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -234,9 +234,9 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix, ::curl_global_cleanup(); return false; } - unsigned long filelen = cmSystemTools::FileLength(local_file.c_str()); + unsigned long filelen = cmSystemTools::FileLength(local_file); - ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb"); + ftpfile = cmsys::SystemTools::Fopen(local_file, "rb"); *this->LogFile << "\tUpload file: " << local_file << " to " << upload_as << std::endl; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " @@ -475,9 +475,9 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, ::curl_global_cleanup(); return false; } - unsigned long filelen = cmSystemTools::FileLength(local_file.c_str()); + unsigned long filelen = cmSystemTools::FileLength(local_file); - ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb"); + ftpfile = cmsys::SystemTools::Fopen(local_file, "rb"); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: " << local_file << " to " << upload_as << " Size: " << filelen << std::endl); @@ -567,7 +567,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix, << count << std::endl); ::fclose(ftpfile); - ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb"); + ftpfile = cmsys::SystemTools::Fopen(local_file, "rb"); ::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile); chunk.clear(); @@ -931,13 +931,13 @@ bool cmCTestSubmitHandler::SubmitUsingCP( cmSystemTools::ConvertToUnixSlashes(lfname); lfname += "/" + *file; std::string rfname = destination + "/" + remoteprefix + *file; - cmSystemTools::CopyFileAlways(lfname.c_str(), rfname.c_str()); + cmSystemTools::CopyFileAlways(lfname, rfname); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Copy file: " << lfname << " to " << rfname << std::endl); } std::string tagDoneFile = destination + "/" + remoteprefix + "DONE"; - cmSystemTools::Touch(tagDoneFile.c_str(), true); + cmSystemTools::Touch(tagDoneFile, true); if ( problems ) { return false; @@ -1418,20 +1418,20 @@ int cmCTestSubmitHandler::ProcessHandler() // change to the build directory so that we can uses a relative path // on windows since scp dosn't support "c:" a drive in the path oldWorkingDirectory = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(buildDirectory.c_str()); + cmSystemTools::ChangeDirectory(buildDirectory); if ( !this->SubmitUsingSCP( this->CTest->GetCTestConfiguration("ScpCommand"), "Testing/"+this->CTest->GetCurrentTag(), files, prefix, url) ) { - cmSystemTools::ChangeDirectory(oldWorkingDirectory.c_str()); + cmSystemTools::ChangeDirectory(oldWorkingDirectory); cmCTestLog(this->CTest, ERROR_MESSAGE, " Problems when submitting via SCP" << std::endl); ofs << " Problems when submitting via SCP" << std::endl; return -1; } - cmSystemTools::ChangeDirectory(oldWorkingDirectory.c_str()); + cmSystemTools::ChangeDirectory(oldWorkingDirectory); cmCTestLog(this->CTest, HANDLER_OUTPUT, " Submission successful" << std::endl); ofs << " Submission successful" << std::endl; @@ -1447,7 +1447,7 @@ int cmCTestSubmitHandler::ProcessHandler() // on windows since scp dosn't support "c:" a drive in the path std::string oldWorkingDirectory = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(buildDirectory.c_str()); + cmSystemTools::ChangeDirectory(buildDirectory); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Change directory: " << buildDirectory << std::endl); @@ -1457,14 +1457,14 @@ int cmCTestSubmitHandler::ProcessHandler() prefix, location) ) { - cmSystemTools::ChangeDirectory(oldWorkingDirectory.c_str()); + cmSystemTools::ChangeDirectory(oldWorkingDirectory); cmCTestLog(this->CTest, ERROR_MESSAGE, " Problems when submitting via CP" << std::endl); ofs << " Problems when submitting via cp" << std::endl; return -1; } - cmSystemTools::ChangeDirectory(oldWorkingDirectory.c_str()); + cmSystemTools::ChangeDirectory(oldWorkingDirectory); cmCTestLog(this->CTest, HANDLER_OUTPUT, " Submission successful" << std::endl); ofs << " Submission successful" << std::endl; diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index f21d166..f330e58 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -93,12 +93,12 @@ bool cmCTestSubdirCommand fname += *it; } - if ( !cmSystemTools::FileIsDirectory(fname.c_str()) ) + if ( !cmSystemTools::FileIsDirectory(fname) ) { // No subdirectory? So what... continue; } - cmSystemTools::ChangeDirectory(fname.c_str()); + cmSystemTools::ChangeDirectory(fname); const char* testFilename; if( cmSystemTools::FileExists("CTestTestfile.cmake") ) { @@ -120,7 +120,7 @@ bool cmCTestSubdirCommand bool readit = this->Makefile->ReadListFile(this->Makefile->GetCurrentListFile(), fname.c_str()); - cmSystemTools::ChangeDirectory(cwd.c_str()); + cmSystemTools::ChangeDirectory(cwd); if(!readit) { std::string m = "Could not find include file: "; @@ -129,7 +129,7 @@ bool cmCTestSubdirCommand return false; } } - cmSystemTools::ChangeDirectory(cwd.c_str()); + cmSystemTools::ChangeDirectory(cwd); return true; } @@ -175,7 +175,7 @@ bool cmCTestAddSubdirectoryCommand } std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(cwd.c_str()); + cmSystemTools::ChangeDirectory(cwd); std::string fname = cwd; fname += "/"; fname += args[1]; @@ -185,7 +185,7 @@ bool cmCTestAddSubdirectoryCommand // No subdirectory? So what... return true; } - cmSystemTools::ChangeDirectory(fname.c_str()); + cmSystemTools::ChangeDirectory(fname); const char* testFilename; if( cmSystemTools::FileExists("CTestTestfile.cmake") ) { @@ -200,7 +200,7 @@ bool cmCTestAddSubdirectoryCommand else { // No CTestTestfile? Who cares... - cmSystemTools::ChangeDirectory(cwd.c_str()); + cmSystemTools::ChangeDirectory(cwd); return true; } fname += "/"; @@ -208,7 +208,7 @@ bool cmCTestAddSubdirectoryCommand bool readit = this->Makefile->ReadListFile(this->Makefile->GetCurrentListFile(), fname.c_str()); - cmSystemTools::ChangeDirectory(cwd.c_str()); + cmSystemTools::ChangeDirectory(cwd); if(!readit) { std::string m = "Could not find include file: "; @@ -1498,9 +1498,9 @@ std::string cmCTestTestHandler { // first check without exe extension if(cmSystemTools::FileExists(attempted[ai].c_str()) - && !cmSystemTools::FileIsDirectory(attempted[ai].c_str())) + && !cmSystemTools::FileIsDirectory(attempted[ai])) { - fullPath = cmSystemTools::CollapseFullPath(attempted[ai].c_str()); + fullPath = cmSystemTools::CollapseFullPath(attempted[ai]); resultingConfig = attemptedConfigs[ai]; } // then try with the exe extension @@ -1510,9 +1510,9 @@ std::string cmCTestTestHandler tempPath = attempted[ai]; tempPath += cmSystemTools::GetExecutableExtension(); if(cmSystemTools::FileExists(tempPath.c_str()) - && !cmSystemTools::FileIsDirectory(tempPath.c_str())) + && !cmSystemTools::FileIsDirectory(tempPath)) { - fullPath = cmSystemTools::CollapseFullPath(tempPath.c_str()); + fullPath = cmSystemTools::CollapseFullPath(tempPath); resultingConfig = attemptedConfigs[ai]; } else @@ -1746,7 +1746,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed() std::string dirName = this->CTest->GetBinaryDir() + "/Testing/Temporary"; cmsys::Directory directory; - if (directory.Load(dirName.c_str()) == 0) + if (directory.Load(dirName) == 0) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to read the contents of " << dirName << std::endl); @@ -1754,7 +1754,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed() } int numFiles = static_cast<int> - (cmsys::Directory::GetNumberOfFilesInDirectory(dirName.c_str())); + (cmsys::Directory::GetNumberOfFilesInDirectory(dirName)); std::string pattern = "LastTestsFailed"; std::string logName = ""; @@ -1777,7 +1777,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed() // if multiple matching logs were found we use the most recently // modified one. int res; - cmSystemTools::FileTimeCompare(logName.c_str(), fileName.c_str(), &res); + cmSystemTools::FileTimeCompare(logName, fileName, &res); if (res == -1) { logName = fileName; @@ -1939,7 +1939,7 @@ std::string cmCTestTestHandler::GenerateRegressionImages( cmCTest::CleanString(measurementfile.match(5)); if ( cmSystemTools::FileExists(filename.c_str()) ) { - long len = cmSystemTools::FileLength(filename.c_str()); + long len = cmSystemTools::FileLength(filename); if ( len == 0 ) { std::string k1 = measurementfile.match(1); diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx index 68f5fe1..7206914 100644 --- a/Source/CTest/cmCTestUpdateHandler.cxx +++ b/Source/CTest/cmCTestUpdateHandler.cxx @@ -98,7 +98,7 @@ cmCTestUpdateHandlerLocale::~cmCTestUpdateHandlerLocale() { std::string put = "LC_MESSAGES="; put += saveLCMessages; - cmSystemTools::PutEnv(put.c_str()); + cmSystemTools::PutEnv(put); } else { diff --git a/Source/CTest/cmParseBlanketJSCoverage.cxx b/Source/CTest/cmParseBlanketJSCoverage.cxx new file mode 100644 index 0000000..fc90bc1 --- /dev/null +++ b/Source/CTest/cmParseBlanketJSCoverage.cxx @@ -0,0 +1,166 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmStandardIncludes.h" +#include <stdio.h> +#include <stdlib.h> +#include "cmSystemTools.h" +#include "cmParseBlanketJSCoverage.h" +#include <cmsys/Directory.hxx> +#include <cmsys/Glob.hxx> +#include <cmsys/FStream.hxx> + + +class cmParseBlanketJSCoverage::JSONParser + { +public: + typedef cmCTestCoverageHandlerContainer:: + SingleFileCoverageVector FileLinesType; + JSONParser(cmCTestCoverageHandlerContainer& cont) + : Coverage(cont) + { + } + + virtual ~JSONParser() + { + } + + std::string getValue(std::string line, int type) + { + size_t begIndex; + size_t endIndex; + endIndex = line.rfind(','); + begIndex = line.find_first_of(':'); + if(type == 0) + { + // A unique substring to remove the extra characters + // around the files name in the JSON (extra " and ,) + std::string foundFileName = + line.substr(begIndex+3,endIndex-(begIndex+4)); + return foundFileName; + } + else + { + return line.substr(begIndex,line.npos); + } + } + bool ParseFile(std::string file) + { + FileLinesType localCoverageVector; + std::string filename; + bool foundFile = false; + bool inSource = false; + std::string covResult; + std::string line; + + cmsys::ifstream in(file.c_str()); + if(!in) + { + return false; + } + while( cmSystemTools::GetLineFromStream(in, line)) + { + if(line.find("filename") != line.npos) + { + if(foundFile) + { + /* + * Upon finding a second file name, generate a + * vector within the total coverage to capture the + * information in the local vector + */ + FileLinesType& CoverageVector = + this->Coverage.TotalCoverage[filename]; + CoverageVector = localCoverageVector; + localCoverageVector.clear(); + foundFile=false; + } + foundFile= true; + inSource = false; + filename = getValue(line,0).c_str(); + } + else if((line.find("coverage") != line.npos) && foundFile && inSource ) + { + /* + * two types of "coverage" in the JSON structure + * + * The coverage result over the file or set of files + * and the coverage for each individual line + * + * FoundFile and foundSource ensure that + * only the value of the line coverage is captured + */ + std::string result = getValue(line,1); + result = result.substr(2,result.npos); + if(result == "\"\"") + { + // Empty quotation marks indicate that the + // line is not executable + localCoverageVector.push_back(-1); + } + else + { + // Else, it contains the number of time executed + localCoverageVector.push_back(atoi(result.c_str())); + } + } + else if(line.find("source") != line.npos) + { + inSource=true; + } + } + + // On exit, capture end of last file covered. + FileLinesType& CoverageVector = + this->Coverage.TotalCoverage[filename]; + CoverageVector = localCoverageVector; + foundFile=false; + localCoverageVector.clear(); + return true; + } +private: + cmCTestCoverageHandlerContainer& Coverage; +}; + +cmParseBlanketJSCoverage::cmParseBlanketJSCoverage( + cmCTestCoverageHandlerContainer& cont, cmCTest* ctest) + :Coverage(cont), CTest(ctest) + { + } + +bool cmParseBlanketJSCoverage::LoadCoverageData(std::vector<std::string> files) + { + size_t i=0; + std::string path; + cmCTestLog(this->CTest,HANDLER_VERBOSE_OUTPUT, + "Found " << files.size() <<" Files" << std::endl); + for(i=0;i<files.size();i++) + { + cmCTestLog(this->CTest,HANDLER_VERBOSE_OUTPUT, + "Reading JSON File " << files[i] << std::endl); + + if(!this->ReadJSONFile(files[i])) + { + return false; + } + } + return true; + } + +bool cmParseBlanketJSCoverage::ReadJSONFile(std::string file) + { + cmParseBlanketJSCoverage::JSONParser parser + (this->Coverage); + cmCTestLog(this->CTest,HANDLER_VERBOSE_OUTPUT, + "Parsing " << file << std::endl); + parser.ParseFile(file); + return true; + } diff --git a/Source/CTest/cmParseBlanketJSCoverage.h b/Source/CTest/cmParseBlanketJSCoverage.h new file mode 100644 index 0000000..fc1d477 --- /dev/null +++ b/Source/CTest/cmParseBlanketJSCoverage.h @@ -0,0 +1,48 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmParseBlanketJSCoverage_h +#define cmParseBlanketJSCoverage_h + +#include "cmStandardIncludes.h" +#include "cmCTestCoverageHandler.h" + + +/** \class cmParseBlanketJSCoverage + * \brief Parse BlanketJS coverage information + * + * This class is used to parse BlanketJS(Pascal) coverage information + * generated by the Blanket.js library when used in conjunction with the + * test runner mocha.js, which is used to write out the JSON format. + * + * Blanket.js: + * http://blanketjs.org/ + * + * Mocha.js + * http://visionmedia.github.io/mocha/ + */ +class cmParseBlanketJSCoverage +{ +public: + cmParseBlanketJSCoverage(cmCTestCoverageHandlerContainer& cont, + cmCTest* ctest); + bool LoadCoverageData(std::vector<std::string> files); + // Read the JSON output + bool ReadJSONFile(std::string file); + +protected: + + class JSONParser; + cmCTestCoverageHandlerContainer& Coverage; + cmCTest* CTest; +}; +#endif diff --git a/Source/CTest/cmParseCacheCoverage.cxx b/Source/CTest/cmParseCacheCoverage.cxx index d17f169..97454a8 100644 --- a/Source/CTest/cmParseCacheCoverage.cxx +++ b/Source/CTest/cmParseCacheCoverage.cxx @@ -31,7 +31,7 @@ bool cmParseCacheCoverage::LoadCoverageData(const char* d) { std::string file = dir.GetFile(i); if(file != "." && file != ".." - && !cmSystemTools::FileIsDirectory(file.c_str())) + && !cmSystemTools::FileIsDirectory(file)) { std::string path = d; path += "/"; diff --git a/Source/CTest/cmParseDelphiCoverage.cxx b/Source/CTest/cmParseDelphiCoverage.cxx new file mode 100644 index 0000000..ad71c85 --- /dev/null +++ b/Source/CTest/cmParseDelphiCoverage.cxx @@ -0,0 +1,253 @@ +#include "cmStandardIncludes.h" +#include <stdio.h> +#include <stdlib.h> +#include "cmSystemTools.h" +#include "cmXMLParser.h" +#include "cmParseDelphiCoverage.h" +#include <cmsys/Directory.hxx> +#include <cmsys/Glob.hxx> +#include <cmsys/FStream.hxx> + + +class cmParseDelphiCoverage::HTMLParser +{ +public: + typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector + FileLinesType; + HTMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont) + : CTest(ctest), Coverage(cont) + { + } + + virtual ~HTMLParser() + { + } + + bool initializeDelphiFile(const std::string filename, + cmParseDelphiCoverage::HTMLParser::FileLinesType &coverageVector) + { + std::string line; + size_t comPos; + size_t semiPos; + bool blockComFlag= false; + bool lineComFlag= false; + std::vector<std::string> beginSet; + cmsys::ifstream in(filename.c_str()); + if(!in) + { + return false; + } + while(cmSystemTools::GetLineFromStream(in, line)) + { + lineComFlag=false; + // Unique cases found in lines. + size_t beginPos = line.find("begin"); + + //Check that the begin is the first non-space string on the line + if( (beginPos == line.find_first_not_of(' ')) && beginPos != line.npos ) + { + beginSet.push_back("begin"); + coverageVector.push_back(-1); + continue; + } + else if(line.find('{') != line.npos) + { + blockComFlag=true; + } + else if(line.find('}') != line.npos) + { + blockComFlag=false; + coverageVector.push_back(-1); + continue; + } + else if((line.find("end;") != line.npos) + && (beginSet.size() > 0)) + { + beginSet.pop_back(); + coverageVector.push_back(-1); + continue; + } + + // This checks for comments after lines of code, finding the + // comment symbol after the ending semicolon. + comPos = line.find("//"); + if(comPos != line.npos) + { + semiPos= line.find(';'); + if(comPos < semiPos) + { + lineComFlag=true; + } + } + //Based up what was found, add a line to the coverageVector + if((beginSet.size() > 0) && line != "" && !blockComFlag + && !lineComFlag) + { + coverageVector.push_back(0); + } + else + { + coverageVector.push_back(-1); + } + } + return true; + } + bool ParseFile(const char* file) + { + std::string line=file; + std::string lineresult; + std::string lastroutine; + std::string filename; + std::string filelineoffset; + size_t afterLineNum = 0; + size_t lastoffset = 0; + size_t endcovpos = 0; + size_t endnamepos = 0; + size_t pos = 0; + + /* + * This first 'while' section goes through the found HTML + * file name and attempts to capture the source file name + * which is set as part of the HTML file name: the name of + * the file is found in parenthesis '()' + * + * See test HTML file name: UTCovTest(UTCovTest.pas).html. + * + * Find the text inside each pair of parenthesis and check + * to see if it ends in '.pas'. If it can't be found, + * exit the function. + */ + while(true) + { + lastoffset = line.find('(',pos); + if(lastoffset==line.npos) + { + cmCTestLog(this->CTest,HANDLER_VERBOSE_OUTPUT, + endnamepos << "File not found " << lastoffset << std::endl); + return false; + } + endnamepos = line.find(')',lastoffset); + filename = line.substr(lastoffset+1, + (endnamepos-1)-lastoffset); + if(filename.find(".pas") != filename.npos) + { + cmCTestLog(this->CTest,HANDLER_VERBOSE_OUTPUT, + "Coverage found for file: " << filename << std::endl); + break; + } + pos = lastoffset+1; + endnamepos = 0; + lastoffset =0; + } + /* + * Glob through the source directory for the + * file found above + */ + cmsys::Glob gl; + gl.RecurseOn(); + gl.RecurseThroughSymlinksOff(); + std::string glob = Coverage.SourceDir + "*/" + filename; + gl.FindFiles(glob); + std::vector<std::string> const& files = gl.GetFiles(); + if(files.size() == 0) + { + /* + * If that doesn't find any matching files + * return a failure. + */ + cmCTestLog(this->CTest,HANDLER_VERBOSE_OUTPUT, + "Unable to find file matching" << glob << std::endl); + return false; + } + FileLinesType& coverageVector = + this->Coverage.TotalCoverage[files[0]]; + + /* + * Initialize the file to have all code between 'begin' and + * 'end' tags marked as executable + */ + + this->initializeDelphiFile(files[0],coverageVector); + + cmsys::ifstream in(file); + if(!in) + { + return false; + } + + /* + * Now read the HTML file, looking for the lines that have an + * "inline" in it. Then parse out the "class" value of that + * line to determine if the line is executed or not. + * + * Sample HTML line: + * + * <tr class="covered"><td>47</td><td><pre style="display:inline;"> + * CheckEquals(1,2-1);</pre></td></tr> + * + */ + + while( cmSystemTools::GetLineFromStream(in, line)) + { + if(line.find("inline") == line.npos) + { + continue; + } + + lastoffset = line.find("class="); + endcovpos = line.find(">",lastoffset); + lineresult = line.substr(lastoffset+7,(endcovpos-8)-lastoffset); + + if(lineresult == "covered") + { + afterLineNum = line.find('<',endcovpos+5); + filelineoffset= line.substr(endcovpos+5, + afterLineNum-(endcovpos+5)); + coverageVector[atoi(filelineoffset.c_str())-1] = 1; + } + } + return true; + } + + + private: + cmCTest* CTest; + cmCTestCoverageHandlerContainer& Coverage; +}; + +cmParseDelphiCoverage::cmParseDelphiCoverage( + cmCTestCoverageHandlerContainer& cont, cmCTest* ctest) + :Coverage(cont), CTest(ctest) + { + } + +bool cmParseDelphiCoverage::LoadCoverageData( + const std::vector<std::string> files) + { + size_t i; + std::string path; + size_t numf = files.size(); + for (i = 0; i < numf; i++) + { + path = files[i]; + + cmCTestLog(this->CTest,HANDLER_VERBOSE_OUTPUT, + "Reading HTML File " << path << std::endl); + if(cmSystemTools::GetFilenameLastExtension(path) == ".html") + { + if(!this->ReadDelphiHTML(path.c_str())) + { + return false; + } + } + } + return true; + }; + +bool cmParseDelphiCoverage::ReadDelphiHTML(const char* file) + { + cmParseDelphiCoverage::HTMLParser + parser(this->CTest, this->Coverage); + parser.ParseFile(file); + return true; + }; diff --git a/Source/CTest/cmParseDelphiCoverage.h b/Source/CTest/cmParseDelphiCoverage.h new file mode 100644 index 0000000..018340b --- /dev/null +++ b/Source/CTest/cmParseDelphiCoverage.h @@ -0,0 +1,46 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmParseDelphiCoverage_h +#define cmParseDelphiCoverage_h + +#include "cmStandardIncludes.h" +#include "cmCTestCoverageHandler.h" + + +/** \class cmParseDelphiCoverage + * \brief Parse Delphi coverage information + * + * This class is used to parse Delphi(Pascal) coverage information + * generated by the Delphi-Code-Coverage tool + * + * https://code.google.com/p/delphi-code-coverage/ + */ + +class cmParseDelphiCoverage + { + public: + cmParseDelphiCoverage(cmCTestCoverageHandlerContainer& cont, + cmCTest* ctest); + bool LoadCoverageData(const std::vector<std::string> files); + bool ReadDelphiHTML(const char* file); + // Read a single HTML file from output + bool ReadHTMLFile(const char* f); + + + protected: + + class HTMLParser; + cmCTestCoverageHandlerContainer& Coverage; + cmCTest* CTest; + }; +#endif diff --git a/Source/CTest/cmParseGTMCoverage.cxx b/Source/CTest/cmParseGTMCoverage.cxx index be10c2e..d77244a 100644 --- a/Source/CTest/cmParseGTMCoverage.cxx +++ b/Source/CTest/cmParseGTMCoverage.cxx @@ -30,7 +30,7 @@ bool cmParseGTMCoverage::LoadCoverageData(const char* d) { std::string file = dir.GetFile(i); if(file != "." && file != ".." - && !cmSystemTools::FileIsDirectory(file.c_str())) + && !cmSystemTools::FileIsDirectory(file)) { std::string path = d; path += "/"; diff --git a/Source/CTest/cmParsePHPCoverage.cxx b/Source/CTest/cmParsePHPCoverage.cxx index 3b7f968..c7f5a68 100644 --- a/Source/CTest/cmParsePHPCoverage.cxx +++ b/Source/CTest/cmParsePHPCoverage.cxx @@ -239,7 +239,7 @@ bool cmParsePHPCoverage::ReadPHPCoverageDirectory(const char* d) { std::string file = dir.GetFile(i); if(file != "." && file != ".." - && !cmSystemTools::FileIsDirectory(file.c_str())) + && !cmSystemTools::FileIsDirectory(file)) { std::string path = d; path += "/"; diff --git a/Source/CursesDialog/CMakeLists.txt b/Source/CursesDialog/CMakeLists.txt index 548f5a5..7d4e88c 100644 --- a/Source/CursesDialog/CMakeLists.txt +++ b/Source/CursesDialog/CMakeLists.txt @@ -26,13 +26,25 @@ set( CURSES_SRCS CursesDialog/ccmake ) -include_directories(${CMake_SOURCE_DIR}/Source/CursesDialog/form - ${CMake_BINARY_DIR}/Source/CursesDialog/form) +if( NOT CMAKE_USE_SYSTEM_FORM ) + include_directories(${CMake_SOURCE_DIR}/Source/CursesDialog/form + ${CMake_BINARY_DIR}/Source/CursesDialog/form) +endif() include_directories(${CURSES_INCLUDE_PATH}) add_executable(ccmake ${CURSES_SRCS} ) target_link_libraries(ccmake CMakeLib) -target_link_libraries(ccmake cmForm) +if(CMAKE_USE_SYSTEM_FORM) + target_link_libraries(ccmake + ${CURSES_FORM_LIBRARY} + ${CURSES_LIBRARY} + ) + if(CURSES_EXTRA_LIBRARY) + target_link_libraries(ccmake ${CURSES_EXTRA_LIBRARY}) + endif() +else() + target_link_libraries(ccmake cmForm) +endif() install(TARGETS ccmake DESTINATION bin) diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 0734927..4200e9e 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -47,7 +47,7 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> const& args, cmSystemTools::GetCMakeCursesCommand()); // create the arguments for the cmake object - std::string whereCMake = cmSystemTools::GetProgramPath(this->Args[0].c_str()); + std::string whereCMake = cmSystemTools::GetProgramPath(this->Args[0]); whereCMake += "/cmake"; this->Args[0] = whereCMake; this->CMakeInstance->SetArgs(this->Args); diff --git a/Source/CursesDialog/cmCursesPathWidget.cxx b/Source/CursesDialog/cmCursesPathWidget.cxx index cd93bc3..89e2238 100644 --- a/Source/CursesDialog/cmCursesPathWidget.cxx +++ b/Source/CursesDialog/cmCursesPathWidget.cxx @@ -69,7 +69,7 @@ void cmCursesPathWidget::OnTab(cmCursesMainForm* fm, WINDOW* w) cstr = cstr.substr(0, cstr.size()-1); } - if ( cmSystemTools::FileIsDirectory(cstr.c_str()) ) + if ( cmSystemTools::FileIsDirectory(cstr) ) { cstr += "/"; } diff --git a/Source/CursesDialog/cmCursesStandardIncludes.h b/Source/CursesDialog/cmCursesStandardIncludes.h index b157a28..791ac9b 100644 --- a/Source/CursesDialog/cmCursesStandardIncludes.h +++ b/Source/CursesDialog/cmCursesStandardIncludes.h @@ -15,30 +15,13 @@ #define _MSE_INT_H #endif -#include <cmFormConfigure.h> - #if defined(__hpux) # define _BOOL_DEFINED # include <sys/time.h> -# define _XOPEN_SOURCE_EXTENDED -# include <curses.h> -# include <form.h> -# undef _XOPEN_SOURCE_EXTENDED -#else -/* figure out which curses.h to include */ -# if defined(CURSES_HAVE_NCURSES_H) -# include <ncurses.h> -# elif defined(CURSES_HAVE_NCURSES_NCURSES_H) -# include <ncurses/ncurses.h> -# elif defined(CURSES_HAVE_NCURSES_CURSES_H) -# include <ncurses/curses.h> -# else -# include <curses.h> -# endif - -# include <form.h> #endif +#include <form.h> + // This is a hack to prevent warnings about these functions being // declared but not referenced. #if defined(__sgi) && !defined(__GNUC__) @@ -57,10 +40,6 @@ public: }; #endif -#ifndef getmaxyx - #define getmaxyx(w,y,x) ((y) = getmaxy(w), (x) = getmaxx(w)) -#endif - // on some machines move erase and clear conflict with stl // so remove them from the namespace diff --git a/Source/CursesDialog/form/fld_attr.c b/Source/CursesDialog/form/fld_attr.c index 8619588..35ea903 100644 --- a/Source/CursesDialog/form/fld_attr.c +++ b/Source/CursesDialog/form/fld_attr.c @@ -29,13 +29,7 @@ /**************************************************************************** * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 * ****************************************************************************/ -#if defined(__hpux) - #define _XOPEN_SOURCE_EXTENDED -#endif - #include "form.priv.h" -#if defined(__hpux) - #undef _XOPEN_SOURCE_EXTENDED -#endif +#include "form.priv.h" MODULE_ID("$Id$") /*---------------------------------------------------------------------------- diff --git a/Source/CursesDialog/form/form.h b/Source/CursesDialog/form/form.h index 94f05af..1219cb5 100644 --- a/Source/CursesDialog/form/form.h +++ b/Source/CursesDialog/form/form.h @@ -47,7 +47,17 @@ # elif defined(CURSES_HAVE_NCURSES_CURSES_H) # include <ncurses/curses.h> # else +# if defined(__hpux) +# if defined(_XOPEN_SOURCE_EXTENDED) +# define HAVE__XOPEN_SOURCE_EXTENDED +# else +# define _XOPEN_SOURCE_EXTENDED +# endif +# endif # include <curses.h> +# if defined(__hpux) && !defined(HAVE__XOPEN_SOURCE_EXTENDED) +# undef _XOPEN_SOURCE_EXTENDED +# endif # endif #include <eti.h> diff --git a/Source/CursesDialog/form/form.priv.h b/Source/CursesDialog/form/form.priv.h index 3691f2f..8516a6f 100644 --- a/Source/CursesDialog/form/form.priv.h +++ b/Source/CursesDialog/form/form.priv.h @@ -33,12 +33,6 @@ #include "mf_common.h" #include "form.h" -/* get around odd bug on aCC and itanium */ -#if defined(__hpux) && defined(__ia64) -#define getmaxx __getmaxx -#define getmaxy __getmaxy -#endif - /* form status values */ #define _OVLMODE (0x04) /* Form is in overlay mode */ #define _WINDOW_MODIFIED (0x10) /* Current field window has been modified */ diff --git a/Source/CursesDialog/form/frm_driver.c b/Source/CursesDialog/form/frm_driver.c index b9611bf..26f580e 100644 --- a/Source/CursesDialog/form/frm_driver.c +++ b/Source/CursesDialog/form/frm_driver.c @@ -29,13 +29,7 @@ /**************************************************************************** * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 * ****************************************************************************/ -#if defined(__hpux) - #define _XOPEN_SOURCE_EXTENDED -#endif #include "form.priv.h" -#if defined(__hpux) - #undef _XOPEN_SOURCE_EXTENDED -#endif /* AIX seems to define this */ #undef lines @@ -357,12 +351,7 @@ static void Buffer_To_Window(const FIELD * field, WINDOW * win) assert(win && field); -#if defined(__LSB_VERSION__) getmaxyx(win, height, width); -#else - width = getmaxx(win); - height = getmaxy(win); -#endif for(row=0, pBuffer=field->buf; row < height; @@ -394,17 +383,13 @@ static void Window_To_Buffer(WINDOW * win, FIELD * field) int pad; int len = 0; char *p; - int row, height; + int row, height, width; assert(win && field && field->buf ); pad = field->pad; p = field->buf; -#if defined(__LSB_VERSION__) - { int width; getmaxyx(win, height, width); } -#else - height = getmaxy(win); -#endif + getmaxyx(win, height, width); for(row=0; (row < height) && (row < field->drows); row++ ) { diff --git a/Source/CursesDialog/form/frm_post.c b/Source/CursesDialog/form/frm_post.c index 3c63de7..924fe6a 100644 --- a/Source/CursesDialog/form/frm_post.c +++ b/Source/CursesDialog/form/frm_post.c @@ -63,12 +63,7 @@ int post_form(FORM * form) RETURN(E_NOT_CONNECTED); formwin = Get_Form_Window(form); -#if defined(__LSB_VERSION__) getmaxyx(formwin, height, width); -#else - width = getmaxx(formwin); - height = getmaxy(formwin); -#endif if ((form->cols > width) || (form->rows > height)) RETURN(E_NO_ROOM); diff --git a/Source/CursesDialog/form/frm_req_name.c b/Source/CursesDialog/form/frm_req_name.c index b108dab..6fb9183 100644 --- a/Source/CursesDialog/form/frm_req_name.c +++ b/Source/CursesDialog/form/frm_req_name.c @@ -35,13 +35,7 @@ * Routines to handle external names of menu requests * ***************************************************************************/ -#if defined(__hpux) - #define _XOPEN_SOURCE_EXTENDED -#endif #include "form.priv.h" -#if defined(__hpux) - #undef _XOPEN_SOURCE_EXTENDED -#endif MODULE_ID("$Id$") diff --git a/Source/QtDialog/CMake.desktop b/Source/QtDialog/CMake.desktop index 7be495f..842091f 100644 --- a/Source/QtDialog/CMake.desktop +++ b/Source/QtDialog/CMake.desktop @@ -3,7 +3,7 @@ Version=1.0 Name=CMake Comment=Cross-platform buildsystem Exec=cmake-gui %f -Icon=CMakeSetup32 +Icon=CMakeSetup Terminal=false X-MultipleArgs=false Type=Application diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 03c2fb4..b59af94 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -171,11 +171,17 @@ set(CMAKE_INSTALL_DESTINATION_ARGS install(TARGETS cmake-gui RUNTIME DESTINATION bin ${CMAKE_INSTALL_DESTINATION_ARGS}) -if(UNIX) +if(UNIX AND NOT APPLE) + foreach (size IN ITEMS 32 128) + install( + FILES "${CMAKE_CURRENT_SOURCE_DIR}/CMakeSetup${size}.png" + DESTINATION "share/icons/hicolor/${size}x${size}/apps" + RENAME "CMakeSetup.png") + endforeach () + # install a desktop file so CMake appears in the application start menu # with an icon install(FILES CMake.desktop DESTINATION share/applications ) - install(FILES CMakeSetup32.png DESTINATION share/pixmaps ) install(FILES cmakecache.xml DESTINATION share/mime/packages ) endif() diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index 6a95550..818b910 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -32,9 +32,10 @@ bool cmAddCustomCommandCommand std::string source, target, main_dependency, working; std::string comment_buffer; const char* comment = 0; - std::vector<std::string> depends, outputs, output; + std::vector<std::string> depends, outputs, output, byproducts; bool verbatim = false; bool append = false; + bool uses_terminal = false; std::string implicit_depends_lang; cmCustomCommand::ImplicitDependsList implicit_depends; @@ -56,6 +57,7 @@ bool cmAddCustomCommandCommand doing_main_dependency, doing_output, doing_outputs, + doing_byproducts, doing_comment, doing_working_directory, doing_nothing @@ -102,6 +104,10 @@ bool cmAddCustomCommandCommand { append = true; } + else if(copy == "USES_TERMINAL") + { + uses_terminal = true; + } else if(copy == "TARGET") { doing = doing_target; @@ -122,6 +128,10 @@ bool cmAddCustomCommandCommand { doing = doing_output; } + else if (copy == "BYPRODUCTS") + { + doing = doing_byproducts; + } else if (copy == "WORKING_DIRECTORY") { doing = doing_working_directory; @@ -145,6 +155,7 @@ bool cmAddCustomCommandCommand { case doing_output: case doing_outputs: + case doing_byproducts: if (!cmSystemTools::FileIsFullPath(copy.c_str())) { // This is an output to be generated, so it should be @@ -228,6 +239,9 @@ bool cmAddCustomCommandCommand case doing_outputs: outputs.push_back(filename); break; + case doing_byproducts: + byproducts.push_back(filename); + break; case doing_comment: comment_buffer = copy; comment = comment_buffer.c_str(); @@ -267,7 +281,9 @@ bool cmAddCustomCommandCommand } // Make sure the output names and locations are safe. - if(!this->CheckOutputs(output) || !this->CheckOutputs(outputs)) + if(!this->CheckOutputs(output) || + !this->CheckOutputs(outputs) || + !this->CheckOutputs(byproducts)) { return false; } @@ -300,7 +316,7 @@ bool cmAddCustomCommandCommand if(!working.empty()) { const char* build_dir = this->Makefile->GetCurrentOutputDirectory(); - working = cmSystemTools::CollapseFullPath(working.c_str(), build_dir); + working = cmSystemTools::CollapseFullPath(working, build_dir); } // Choose which mode of the command to use. @@ -309,19 +325,19 @@ bool cmAddCustomCommandCommand { // Source is empty, use the target. std::vector<std::string> no_depends; - this->Makefile->AddCustomCommandToTarget(target, no_depends, + this->Makefile->AddCustomCommandToTarget(target, byproducts, no_depends, commandLines, cctype, comment, working.c_str(), - escapeOldStyle); + escapeOldStyle, uses_terminal); } else if(target.empty()) { // Target is empty, use the output. - this->Makefile->AddCustomCommandToOutput(output, depends, - main_dependency, + this->Makefile->AddCustomCommandToOutput(output, byproducts, + depends, main_dependency, commandLines, comment, working.c_str(), false, - escapeOldStyle); + escapeOldStyle, uses_terminal); // Add implicit dependency scanning requests if any were given. if(!implicit_depends.empty()) @@ -346,6 +362,16 @@ bool cmAddCustomCommandCommand } } } + else if (!byproducts.empty()) + { + this->SetError("BYPRODUCTS may not be specified with SOURCE signatures"); + return false; + } + else if (uses_terminal) + { + this->SetError("USES_TERMINAL may not be used with SOURCE signatures"); + return false; + } else { bool issueMessage = true; diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx index 2fb0eb3..09c8af5 100644 --- a/Source/cmAddCustomTargetCommand.cxx +++ b/Source/cmAddCustomTargetCommand.cxx @@ -45,9 +45,10 @@ bool cmAddCustomTargetCommand cmCustomCommandLines commandLines; // Accumulate dependencies. - std::vector<std::string> depends; + std::vector<std::string> depends, byproducts; std::string working_directory; bool verbatim = false; + bool uses_terminal = false; std::string comment_buffer; const char* comment = 0; std::vector<std::string> sources; @@ -56,10 +57,11 @@ bool cmAddCustomTargetCommand enum tdoing { doing_command, doing_depends, + doing_byproducts, doing_working_directory, doing_comment, doing_source, - doing_verbatim + doing_nothing }; tdoing doing = doing_command; @@ -84,15 +86,24 @@ bool cmAddCustomTargetCommand { doing = doing_depends; } + else if(copy == "BYPRODUCTS") + { + doing = doing_byproducts; + } else if(copy == "WORKING_DIRECTORY") { doing = doing_working_directory; } else if(copy == "VERBATIM") { - doing = doing_verbatim; + doing = doing_nothing; verbatim = true; } + else if(copy == "USES_TERMINAL") + { + doing = doing_nothing; + uses_terminal = true; + } else if (copy == "COMMENT") { doing = doing_comment; @@ -122,6 +133,19 @@ bool cmAddCustomTargetCommand case doing_command: currentLine.push_back(copy); break; + case doing_byproducts: + { + std::string filename; + if (!cmSystemTools::FileIsFullPath(copy.c_str())) + { + filename = this->Makefile->GetCurrentOutputDirectory(); + filename += "/"; + } + filename += copy; + cmSystemTools::ConvertToUnixSlashes(filename); + byproducts.push_back(filename); + } + break; case doing_depends: { std::string dep = copy; @@ -218,15 +242,30 @@ bool cmAddCustomTargetCommand { const char* build_dir = this->Makefile->GetCurrentOutputDirectory(); working_directory = - cmSystemTools::CollapseFullPath(working_directory.c_str(), build_dir); + cmSystemTools::CollapseFullPath(working_directory, build_dir); + } + + if (commandLines.empty() && !byproducts.empty()) + { + this->Makefile->IssueMessage(cmake::FATAL_ERROR, + "BYPRODUCTS may not be specified without any COMMAND"); + return true; + } + if (commandLines.empty() && uses_terminal) + { + this->Makefile->IssueMessage(cmake::FATAL_ERROR, + "USES_TERMINAL may not be specified without any COMMAND"); + return true; } // Add the utility target to the makefile. bool escapeOldStyle = !verbatim; cmTarget* target = this->Makefile->AddUtilityCommand(targetName, excludeFromAll, - working_directory.c_str(), depends, - commandLines, escapeOldStyle, comment); + working_directory.c_str(), + byproducts, depends, + commandLines, escapeOldStyle, comment, + uses_terminal); // Add additional user-specified source files to the target. target->AddSources(sources); diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx index 4ea2524..477a3d9 100644 --- a/Source/cmAddSubDirectoryCommand.cxx +++ b/Source/cmAddSubDirectoryCommand.cxx @@ -61,7 +61,7 @@ bool cmAddSubDirectoryCommand::InitialPass srcPath += "/"; srcPath += srcArg; } - if(!cmSystemTools::FileIsDirectory(srcPath.c_str())) + if(!cmSystemTools::FileIsDirectory(srcPath)) { std::string error = "given source \""; error += srcArg; @@ -69,7 +69,7 @@ bool cmAddSubDirectoryCommand::InitialPass this->SetError(error); return false; } - srcPath = cmSystemTools::CollapseFullPath(srcPath.c_str()); + srcPath = cmSystemTools::CollapseFullPath(srcPath); // Compute the full path to the binary directory. std::string binPath; @@ -78,7 +78,7 @@ bool cmAddSubDirectoryCommand::InitialPass // No binary directory was specified. If the source directory is // not a subdirectory of the current directory then it is an // error. - if(!cmSystemTools::IsSubDirectory(srcPath.c_str(), + if(!cmSystemTools::IsSubDirectory(srcPath, this->Makefile->GetCurrentDirectory())) { cmOStringStream e; @@ -118,7 +118,7 @@ bool cmAddSubDirectoryCommand::InitialPass binPath += binArg; } } - binPath = cmSystemTools::CollapseFullPath(binPath.c_str()); + binPath = cmSystemTools::CollapseFullPath(binPath); // Add the subdirectory using the computed full paths. this->Makefile->AddSubDirectory(srcPath, binPath, diff --git a/Source/cmBootstrapCommands1.cxx b/Source/cmBootstrapCommands1.cxx index 9093579..5502609 100644 --- a/Source/cmBootstrapCommands1.cxx +++ b/Source/cmBootstrapCommands1.cxx @@ -52,6 +52,8 @@ #include "cmFindProgramCommand.cxx" #include "cmForEachCommand.cxx" #include "cmFunctionCommand.cxx" +#include "cmPathLabel.cxx" +#include "cmSearchPath.cxx" void GetBootstrapCommands1(std::list<cmCommand*>& commands) { diff --git a/Source/cmBreakCommand.cxx b/Source/cmBreakCommand.cxx index b70e400..ff527db 100644 --- a/Source/cmBreakCommand.cxx +++ b/Source/cmBreakCommand.cxx @@ -12,10 +12,76 @@ #include "cmBreakCommand.h" // cmBreakCommand -bool cmBreakCommand::InitialPass(std::vector<std::string> const&, +bool cmBreakCommand::InitialPass(std::vector<std::string> const &args, cmExecutionStatus &status) { + if(!this->Makefile->IsLoopBlock()) + { + bool issueMessage = true; + cmOStringStream e; + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0055)) + { + case cmPolicies::WARN: + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0055)) << "\n"; + break; + case cmPolicies::OLD: + issueMessage = false; + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + messageType = cmake::FATAL_ERROR; + break; + } + + if(issueMessage) + { + e << "A BREAK command was found outside of a proper " + "FOREACH or WHILE loop scope."; + this->Makefile->IssueMessage(messageType, e.str()); + if(messageType == cmake::FATAL_ERROR) + { + return false; + } + } + } + status.SetBreakInvoked(true); + + if(!args.empty()) + { + bool issueMessage = true; + cmOStringStream e; + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0055)) + { + case cmPolicies::WARN: + e << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0055)) << "\n"; + break; + case cmPolicies::OLD: + issueMessage = false; + break; + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::NEW: + messageType = cmake::FATAL_ERROR; + break; + } + + if(issueMessage) + { + e << "The BREAK command does not accept any arguments."; + this->Makefile->IssueMessage(messageType, e.str()); + if(messageType == cmake::FATAL_ERROR) + { + return false; + } + } + } + return true; } diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index dd2a1b8..b304f28 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -353,10 +353,11 @@ void CCONV cmAddCustomCommandToTarget(void *arg, const char* target, } // Pass the call to the makefile instance. + std::vector<std::string> no_byproducts; std::vector<std::string> no_depends; const char* no_comment = 0; const char* no_working_dir = 0; - mf->AddCustomCommandToTarget(target, no_depends, commandLines, + mf->AddCustomCommandToTarget(target, no_byproducts, no_depends, commandLines, cctype, no_comment, no_working_dir); } diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index a7905a4..2bf7b77 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -208,7 +208,7 @@ int cmCTest::HTTPRequest(std::string url, HTTPMethod method, return -1; } ::curl_easy_setopt(curl, CURLOPT_PUT, 1); - file = cmsys::SystemTools::Fopen(putFile.c_str(), "rb"); + file = cmsys::SystemTools::Fopen(putFile, "rb"); ::curl_easy_setopt(curl, CURLOPT_INFILE, file); //fall through to append GET fields case cmCTest::HTTP_GET: @@ -524,7 +524,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) std::string testingDir = this->BinaryDir + "/Testing"; if ( cmSystemTools::FileExists(testingDir.c_str()) ) { - if ( !cmSystemTools::FileIsDirectory(testingDir.c_str()) ) + if ( !cmSystemTools::FileIsDirectory(testingDir) ) { cmCTestLog(this, ERROR_MESSAGE, "File " << testingDir << " is in the place of the testing directory" << std::endl); @@ -809,7 +809,7 @@ bool cmCTest::UpdateCTestConfiguration() if ( !this->GetCTestConfiguration("BuildDirectory").empty() ) { this->BinaryDir = this->GetCTestConfiguration("BuildDirectory"); - cmSystemTools::ChangeDirectory(this->BinaryDir.c_str()); + cmSystemTools::ChangeDirectory(this->BinaryDir); } this->TimeOut = atoi(this->GetCTestConfiguration("TimeOut").c_str()); if ( this->ProduceXML ) @@ -884,7 +884,7 @@ bool cmCTest::OpenOutputFile(const std::string& path, } if ( cmSystemTools::FileExists(testingDir.c_str()) ) { - if ( !cmSystemTools::FileIsDirectory(testingDir.c_str()) ) + if ( !cmSystemTools::FileIsDirectory(testingDir) ) { cmCTestLog(this, ERROR_MESSAGE, "File " << testingDir << " is in the place of the testing directory" @@ -1061,17 +1061,17 @@ int cmCTest::ProcessTests() if ( !notest ) { std::string notes_dir = this->BinaryDir + "/Testing/Notes"; - if ( cmSystemTools::FileIsDirectory(notes_dir.c_str()) ) + if ( cmSystemTools::FileIsDirectory(notes_dir) ) { cmsys::Directory d; - d.Load(notes_dir.c_str()); + d.Load(notes_dir); unsigned long kk; for ( kk = 0; kk < d.GetNumberOfFiles(); kk ++ ) { const char* file = d.GetFile(kk); std::string fullname = notes_dir + "/" + file; if ( cmSystemTools::FileExists(fullname.c_str()) && - !cmSystemTools::FileIsDirectory(fullname.c_str()) ) + !cmSystemTools::FileIsDirectory(fullname) ) { if ( this->NotesFiles.size() > 0 ) { @@ -1294,7 +1294,7 @@ int cmCTest::RunTest(std::vector<const char*> argv, cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Test timeout computed to be: " << timeout << "\n"); if(cmSystemTools::SameFile( - argv[0], cmSystemTools::GetCTestCommand().c_str()) && + argv[0], cmSystemTools::GetCTestCommand()) && !this->ForceNewCTestProcess) { cmCTest inst; @@ -1342,7 +1342,7 @@ int cmCTest::RunTest(std::vector<const char*> argv, { *log << *output; } - cmSystemTools::ChangeDirectory(oldpath.c_str()); + cmSystemTools::ChangeDirectory(oldpath); cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Internal cmCTest object used to run test." << std::endl @@ -1681,14 +1681,14 @@ std::string cmCTest::Base64GzipEncodeFile(std::string file) return ""; } std::string base64 = this->Base64EncodeFile(tarFile); - cmSystemTools::RemoveFile(tarFile.c_str()); + cmSystemTools::RemoveFile(tarFile); return base64; } //---------------------------------------------------------------------- std::string cmCTest::Base64EncodeFile(std::string file) { - long len = cmSystemTools::FileLength(file.c_str()); + long len = cmSystemTools::FileLength(file); cmsys::ifstream ifs(file.c_str(), std::ios::in #ifdef _WIN32 | std::ios::binary @@ -2628,10 +2628,10 @@ std::string cmCTest::GetShortPathToFile(const char* cfname) { const std::string& sourceDir = cmSystemTools::CollapseFullPath( - this->GetCTestConfiguration("SourceDirectory").c_str()); + this->GetCTestConfiguration("SourceDirectory")); const std::string& buildDir = cmSystemTools::CollapseFullPath( - this->GetCTestConfiguration("BuildDirectory").c_str()); + this->GetCTestConfiguration("BuildDirectory")); std::string fname = cmSystemTools::CollapseFullPath(cfname); // Find relative paths to both directories @@ -2860,7 +2860,7 @@ void cmCTest::SetConfigType(const char* ct) cmSystemTools::ReplaceString(this->ConfigType, ".\\", ""); std::string confTypeEnv = "CMAKE_CONFIG_TYPE=" + this->ConfigType; - cmSystemTools::PutEnv(confTypeEnv.c_str()); + cmSystemTools::PutEnv(confTypeEnv); } //---------------------------------------------------------------------- diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index d6b84a0..6a47ea7 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -139,7 +139,7 @@ bool cmCacheManager::ParseEntry(const std::string& entry, { // input line is: key:type=value static cmsys::RegularExpression reg( - "^([^:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); + "^([^=:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); // input line is: "key":type=value static cmsys::RegularExpression regQuoted( "^\"([^\"]*)\":([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); @@ -189,7 +189,7 @@ void cmCacheManager::CleanCMakeFiles(const std::string& path) for(std::vector<std::string>::iterator i = files.begin(); i != files.end(); ++i) { - cmSystemTools::RemoveFile(i->c_str()); + cmSystemTools::RemoveFile(*i); } } @@ -336,7 +336,7 @@ bool cmCacheManager::LoadCache(const std::string& path, cmSystemTools::ConvertToUnixSlashes(currentcwd); currentcwd += "/CMakeCache.txt"; oldcwd += "/CMakeCache.txt"; - if(!cmSystemTools::SameFile(oldcwd.c_str(), currentcwd.c_str())) + if(!cmSystemTools::SameFile(oldcwd, currentcwd)) { std::string message = std::string("The current CMakeCache.txt directory ") + @@ -586,13 +586,13 @@ bool cmCacheManager::DeleteCache(const std::string& path) cacheFile += "/CMakeCache.txt"; if(cmSystemTools::FileExists(cacheFile.c_str())) { - cmSystemTools::RemoveFile(cacheFile.c_str()); + cmSystemTools::RemoveFile(cacheFile); // now remove the files in the CMakeFiles directory // this cleans up language cache files cmakeFiles += cmake::GetCMakeFilesDirectory(); - if(cmSystemTools::FileIsDirectory(cmakeFiles.c_str())) + if(cmSystemTools::FileIsDirectory(cmakeFiles)) { - cmSystemTools::RemoveADirectory(cmakeFiles.c_str()); + cmSystemTools::RemoveADirectory(cmakeFiles); } } return true; diff --git a/Source/cmCallVisualStudioMacro.cxx b/Source/cmCallVisualStudioMacro.cxx index 0c15477..c211111 100644 --- a/Source/cmCallVisualStudioMacro.cxx +++ b/Source/cmCallVisualStudioMacro.cxx @@ -34,8 +34,6 @@ static bool LogErrorsAsMessages; // Copied from a correct comdef.h to avoid problems with deficient versions // of comdef.h that exist in the wild... Fixes issue #7533. // -#if ( _MSC_VER >= 1300 ) -// VS7 and later: #ifdef _NATIVE_WCHAR_T_DEFINED # ifdef _DEBUG # pragma comment(lib, "comsuppwd.lib") @@ -49,10 +47,6 @@ static bool LogErrorsAsMessages; # pragma comment(lib, "comsupp.lib") # endif #endif -#else -// VS6 only had comsupp.lib: -# pragma comment(lib, "comsupp.lib") -#endif //---------------------------------------------------------------------------- @@ -63,12 +57,13 @@ static bool LogErrorsAsMessages; { \ if (LogErrorsAsMessages) \ { \ - std::ostringstream oss; \ - oss.flags(std::ios::hex); \ - oss << context << " failed HRESULT, hr = 0x" << hr << std::endl; \ - oss.flags(std::ios::dec); \ - oss << __FILE__ << "(" << __LINE__ << ")"; \ - cmSystemTools::Message(oss.str().c_str()); \ + std::ostringstream _hresult_oss; \ + _hresult_oss.flags(std::ios::hex); \ + _hresult_oss << context << " failed HRESULT, hr = 0x" \ + << hr << std::endl; \ + _hresult_oss.flags(std::ios::dec); \ + _hresult_oss << __FILE__ << "(" << __LINE__ << ")"; \ + cmSystemTools::Message(_hresult_oss.str().c_str()); \ } \ } diff --git a/Source/cmCommandArgumentParser.cxx b/Source/cmCommandArgumentParser.cxx index c5146c5..9f8a4de 100644 --- a/Source/cmCommandArgumentParser.cxx +++ b/Source/cmCommandArgumentParser.cxx @@ -183,12 +183,6 @@ static void cmCommandArgumentError(yyscan_t yyscanner, const char* message); #define YYINITDEPTH 10000 /* Disable some warnings in the generated code. */ -#ifdef __BORLANDC__ -# pragma warn -8004 /* Variable assigned a value that is not used. */ -# pragma warn -8008 /* condition always returns true */ -# pragma warn -8060 /* possibly incorrect assignment */ -# pragma warn -8066 /* unreachable code */ -#endif #ifdef _MSC_VER # pragma warning (disable: 4102) /* Unused goto label. */ # pragma warning (disable: 4065) /* Switch statement contains default but no diff --git a/Source/cmCommandArgumentParser.y b/Source/cmCommandArgumentParser.y index 48f5c8e..b1d53f6 100644 --- a/Source/cmCommandArgumentParser.y +++ b/Source/cmCommandArgumentParser.y @@ -64,12 +64,6 @@ static void cmCommandArgumentError(yyscan_t yyscanner, const char* message); #define YYINITDEPTH 10000 /* Disable some warnings in the generated code. */ -#ifdef __BORLANDC__ -# pragma warn -8004 /* Variable assigned a value that is not used. */ -# pragma warn -8008 /* condition always returns true */ -# pragma warn -8060 /* possibly incorrect assignment */ -# pragma warn -8066 /* unreachable code */ -#endif #ifdef _MSC_VER # pragma warning (disable: 4102) /* Unused goto label. */ # pragma warning (disable: 4065) /* Switch statement contains default but no diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index e1852a3..f4fa5c6 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -675,7 +675,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, // This is not a CMake target. Use the name given. if(cmSystemTools::FileIsFullPath(item.c_str())) { - if(cmSystemTools::FileIsDirectory(item.c_str())) + if(cmSystemTools::FileIsDirectory(item)) { // This is a directory. this->AddDirectoryItem(item); @@ -1937,10 +1937,10 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, // Do not add any path inside the source or build tree. const char* topSourceDir = this->Makefile->GetHomeDirectory(); const char* topBinaryDir = this->Makefile->GetHomeOutputDirectory(); - if(!cmSystemTools::ComparePath(ri->c_str(), topSourceDir) && - !cmSystemTools::ComparePath(ri->c_str(), topBinaryDir) && - !cmSystemTools::IsSubDirectory(ri->c_str(), topSourceDir) && - !cmSystemTools::IsSubDirectory(ri->c_str(), topBinaryDir)) + if(!cmSystemTools::ComparePath(*ri, topSourceDir) && + !cmSystemTools::ComparePath(*ri, topBinaryDir) && + !cmSystemTools::IsSubDirectory(*ri, topSourceDir) && + !cmSystemTools::IsSubDirectory(*ri, topBinaryDir)) { std::string d = *ri; if (!rootPath.empty() && d.find(rootPath) == 0) diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index aba26de..6065b8a 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -11,6 +11,7 @@ ============================================================================*/ #include "cmConditionEvaluator.h" +#include "cmStringCommand.h" cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile): Makefile(makefile), @@ -555,7 +556,7 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList &newArgs, { def = this->GetVariableOrString(*arg); const char* rex = argP2->c_str(); - this->Makefile.ClearMatches(); + cmStringCommand::ClearMatches(&this->Makefile); cmsys::RegularExpression regEntry; if ( !regEntry.compile(rex) ) { @@ -567,7 +568,7 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList &newArgs, } if (regEntry.find(def)) { - this->Makefile.StoreMatches(regEntry); + cmStringCommand::StoreMatches(&this->Makefile, regEntry); *arg = cmExpandedCommandArgument("1", true); } else diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx index 395e6c8..cc6cf5f 100644 --- a/Source/cmConfigureFileCommand.cxx +++ b/Source/cmConfigureFileCommand.cxx @@ -32,7 +32,7 @@ bool cmConfigureFileCommand this->InputFile += inFile; // If the input location is a directory, error out. - if(cmSystemTools::FileIsDirectory(this->InputFile.c_str())) + if(cmSystemTools::FileIsDirectory(this->InputFile)) { cmOStringStream e; e << "input location\n" @@ -51,7 +51,7 @@ bool cmConfigureFileCommand this->OutputFile += outFile; // If the output location is already a directory put the file in it. - if(cmSystemTools::FileIsDirectory(this->OutputFile.c_str())) + if(cmSystemTools::FileIsDirectory(this->OutputFile)) { this->OutputFile += "/"; this->OutputFile += cmSystemTools::GetFilenameName(inFile); @@ -74,6 +74,7 @@ bool cmConfigureFileCommand this->CopyOnly = false; this->EscapeQuotes = false; + std::string unknown_args; this->AtOnly = false; for(unsigned int i=2;i < args.size();++i) { @@ -99,6 +100,18 @@ bool cmConfigureFileCommand { /* Ignore legacy option. */ } + else + { + unknown_args += " "; + unknown_args += args[i]; + unknown_args += "\n"; + } + } + if (!unknown_args.empty()) + { + std::string msg = "configure_file called with unknown argument(s):\n"; + msg += unknown_args; + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, msg); } if ( !this->ConfigureFile() ) diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index bc5708d..512f5cf 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -233,7 +233,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) { // remove any CMakeCache.txt files so we will have a clean test std::string ccFile = this->BinaryDirectory + "/CMakeCache.txt"; - cmSystemTools::RemoveFile(ccFile.c_str()); + cmSystemTools::RemoveFile(ccFile); // Choose sources. if(!useSources) @@ -279,7 +279,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 = cmsys::SystemTools::Fopen(outFileName.c_str(),"w"); + FILE *fout = cmsys::SystemTools::Fopen(outFileName,"w"); if (!fout) { cmOStringStream e; @@ -514,8 +514,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) if ((res==0) && (copyFile.size())) { if(this->OutputFile.empty() || - !cmSystemTools::CopyFileAlways(this->OutputFile.c_str(), - copyFile.c_str())) + !cmSystemTools::CopyFileAlways(this->OutputFile, + copyFile)) { cmOStringStream emsg; emsg << "Cannot copy output executable\n" @@ -580,10 +580,10 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir) std::string fullPath = binDir; fullPath += "/"; fullPath += dir.GetFile(static_cast<unsigned long>(fileNum)); - if(cmSystemTools::FileIsDirectory(fullPath.c_str())) + if(cmSystemTools::FileIsDirectory(fullPath)) { this->CleanupFiles(fullPath.c_str()); - cmSystemTools::RemoveADirectory(fullPath.c_str()); + cmSystemTools::RemoveADirectory(fullPath); } else { @@ -599,7 +599,7 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir) } if(retry.Count == 0) #else - if(!cmSystemTools::RemoveFile(fullPath.c_str())) + if(!cmSystemTools::RemoveFile(fullPath)) #endif { std::string m = "Remove failed on file: " + fullPath; @@ -649,7 +649,7 @@ void cmCoreTryCompile::FindOutputFile(const std::string& targetName) command += tmpOutputFile; if(cmSystemTools::FileExists(command.c_str())) { - tmpOutputFile = cmSystemTools::CollapseFullPath(command.c_str()); + tmpOutputFile = cmSystemTools::CollapseFullPath(command); this->OutputFile = tmpOutputFile; return; } diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx index c161eb6..2afb029 100644 --- a/Source/cmCustomCommand.cxx +++ b/Source/cmCustomCommand.cxx @@ -22,11 +22,13 @@ cmCustomCommand::cmCustomCommand() this->HaveComment = false; this->EscapeOldStyle = true; this->EscapeAllowMakeVars = false; + this->UsesTerminal = false; } //---------------------------------------------------------------------------- cmCustomCommand::cmCustomCommand(const cmCustomCommand& r): Outputs(r.Outputs), + Byproducts(r.Byproducts), Depends(r.Depends), CommandLines(r.CommandLines), HaveComment(r.HaveComment), @@ -34,7 +36,8 @@ cmCustomCommand::cmCustomCommand(const cmCustomCommand& r): WorkingDirectory(r.WorkingDirectory), EscapeAllowMakeVars(r.EscapeAllowMakeVars), EscapeOldStyle(r.EscapeOldStyle), - Backtrace(r.Backtrace) + Backtrace(r.Backtrace), + UsesTerminal(r.UsesTerminal) { } @@ -47,6 +50,7 @@ cmCustomCommand& cmCustomCommand::operator=(cmCustomCommand const& r) } this->Outputs = r.Outputs; + this->Byproducts= r.Byproducts; this->Depends = r.Depends; this->CommandLines = r.CommandLines; this->HaveComment = r.HaveComment; @@ -56,6 +60,7 @@ cmCustomCommand& cmCustomCommand::operator=(cmCustomCommand const& r) this->EscapeOldStyle = r.EscapeOldStyle; this->ImplicitDepends = r.ImplicitDepends; this->Backtrace = r.Backtrace; + this->UsesTerminal = r.UsesTerminal; return *this; } @@ -63,11 +68,13 @@ cmCustomCommand& cmCustomCommand::operator=(cmCustomCommand const& r) //---------------------------------------------------------------------------- cmCustomCommand::cmCustomCommand(cmMakefile const* mf, const std::vector<std::string>& outputs, + const std::vector<std::string>& byproducts, const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, const char* comment, const char* workingDirectory): Outputs(outputs), + Byproducts(byproducts), Depends(depends), CommandLines(commandLines), HaveComment(comment?true:false), @@ -97,6 +104,12 @@ const std::vector<std::string>& cmCustomCommand::GetOutputs() const } //---------------------------------------------------------------------------- +const std::vector<std::string>& cmCustomCommand::GetByproducts() const +{ + return this->Byproducts; +} + +//---------------------------------------------------------------------------- const std::vector<std::string>& cmCustomCommand::GetDepends() const { return this->Depends; @@ -184,3 +197,15 @@ void cmCustomCommand::AppendImplicitDepends(ImplicitDependsList const& l) this->ImplicitDepends.insert(this->ImplicitDepends.end(), l.begin(), l.end()); } + +//---------------------------------------------------------------------------- +bool cmCustomCommand::GetUsesTerminal() const +{ + return this->UsesTerminal; +} + +//---------------------------------------------------------------------------- +void cmCustomCommand::SetUsesTerminal(bool b) +{ + this->UsesTerminal = b; +} diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h index 21dbefb..0bfaef2 100644 --- a/Source/cmCustomCommand.h +++ b/Source/cmCustomCommand.h @@ -32,6 +32,7 @@ public: /** Main constructor specifies all information for the command. */ cmCustomCommand(cmMakefile const* mf, const std::vector<std::string>& outputs, + const std::vector<std::string>& byproducts, const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, const char* comment, @@ -42,6 +43,9 @@ public: /** Get the output file produced by the command. */ const std::vector<std::string>& GetOutputs() const; + /** Get the extra files produced by the command. */ + const std::vector<std::string>& GetByproducts() const; + /** Get the vector that holds the list of dependencies. */ const std::vector<std::string>& GetDepends() const; @@ -79,8 +83,14 @@ public: void AppendImplicitDepends(ImplicitDependsList const&); ImplicitDependsList const& GetImplicitDepends() const; + /** Set/Get whether this custom command should be given access to the + real console (if possible). */ + bool GetUsesTerminal() const; + void SetUsesTerminal(bool b); + private: std::vector<std::string> Outputs; + std::vector<std::string> Byproducts; std::vector<std::string> Depends; cmCustomCommandLines CommandLines; bool HaveComment; @@ -90,6 +100,7 @@ private: bool EscapeOldStyle; cmListFileBacktrace Backtrace; ImplicitDependsList ImplicitDepends; + bool UsesTerminal; }; #endif diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 1bca6e6..162d7a1 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -91,6 +91,12 @@ std::vector<std::string> const& cmCustomCommandGenerator::GetOutputs() const } //---------------------------------------------------------------------------- +std::vector<std::string> const& cmCustomCommandGenerator::GetByproducts() const +{ + return this->CC.GetByproducts(); +} + +//---------------------------------------------------------------------------- std::vector<std::string> const& cmCustomCommandGenerator::GetDepends() const { if (!this->DependsDone) diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h index 0d8a0a4..b4ae014 100644 --- a/Source/cmCustomCommandGenerator.h +++ b/Source/cmCustomCommandGenerator.h @@ -42,6 +42,7 @@ public: const char* GetComment() const; std::string GetWorkingDirectory() const; std::vector<std::string> const& GetOutputs() const; + std::vector<std::string> const& GetByproducts() const; std::vector<std::string> const& GetDepends() const; }; diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx index 134f45b..947db82 100644 --- a/Source/cmDepends.cxx +++ b/Source/cmDepends.cxx @@ -94,7 +94,7 @@ bool cmDepends::Check(const char *makeFile, const char *internalFile, // Get the CWD but do not call CollapseFullPath because // we only need it to cd back, and the form does not matter oldcwd = cmSystemTools::GetCurrentWorkingDirectory(false); - cmSystemTools::ChangeDirectory(this->CompileDirectory.c_str()); + cmSystemTools::ChangeDirectory(this->CompileDirectory); } // Check whether dependencies must be regenerated. @@ -111,7 +111,7 @@ bool cmDepends::Check(const char *makeFile, const char *internalFile, // Restore working directory. if(oldcwd != ".") { - cmSystemTools::ChangeDirectory(oldcwd.c_str()); + cmSystemTools::ChangeDirectory(oldcwd); } return okay; diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index 8fc8347..4082d24 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -668,7 +668,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args) if(cmDependsFortran::ModulesDiffer(mod_upper.c_str(), stamp.c_str(), compilerId.c_str())) { - if(!cmSystemTools::CopyFileAlways(mod_upper.c_str(), stamp.c_str())) + if(!cmSystemTools::CopyFileAlways(mod_upper, stamp)) { std::cerr << "Error copying Fortran module from \"" << mod_upper << "\" to \"" << stamp @@ -683,7 +683,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args) if(cmDependsFortran::ModulesDiffer(mod_lower.c_str(), stamp.c_str(), compilerId.c_str())) { - if(!cmSystemTools::CopyFileAlways(mod_lower.c_str(), stamp.c_str())) + if(!cmSystemTools::CopyFileAlways(mod_lower, stamp)) { std::cerr << "Error copying Fortran module from \"" << mod_lower << "\" to \"" << stamp diff --git a/Source/cmDependsFortranParser.cxx b/Source/cmDependsFortranParser.cxx index 7b49a9c..9d51025 100644 --- a/Source/cmDependsFortranParser.cxx +++ b/Source/cmDependsFortranParser.cxx @@ -144,12 +144,6 @@ static bool cmDependsFortranParserIsKeyword(const char* word, } /* Disable some warnings in the generated code. */ -#ifdef __BORLANDC__ -# pragma warn -8004 /* Variable assigned a value that is not used. */ -# pragma warn -8008 /* condition always returns true */ -# pragma warn -8060 /* possibly incorrect assignment */ -# pragma warn -8066 /* unreachable code */ -#endif #ifdef _MSC_VER # pragma warning (disable: 4102) /* Unused goto label. */ # pragma warning (disable: 4065) /* Switch contains default but no case. */ diff --git a/Source/cmDependsFortranParser.y b/Source/cmDependsFortranParser.y index d814f30..a987c13 100644 --- a/Source/cmDependsFortranParser.y +++ b/Source/cmDependsFortranParser.y @@ -68,12 +68,6 @@ static bool cmDependsFortranParserIsKeyword(const char* word, } /* Disable some warnings in the generated code. */ -#ifdef __BORLANDC__ -# pragma warn -8004 /* Variable assigned a value that is not used. */ -# pragma warn -8008 /* condition always returns true */ -# pragma warn -8060 /* possibly incorrect assignment */ -# pragma warn -8066 /* unreachable code */ -#endif #ifdef _MSC_VER # pragma warning (disable: 4102) /* Unused goto label. */ # pragma warning (disable: 4065) /* Switch contains default but no case. */ diff --git a/Source/cmDependsJavaParser.cxx b/Source/cmDependsJavaParser.cxx index 586c0de..899f4d2 100644 --- a/Source/cmDependsJavaParser.cxx +++ b/Source/cmDependsJavaParser.cxx @@ -336,12 +336,6 @@ static void cmDependsJavaError(yyscan_t yyscanner, const char* message); #define jpStoreClass(str) \ yyGetParser->AddClassFound(str); yyGetParser->DeallocateParserType(&(str)) /* Disable some warnings in the generated code. */ -#ifdef __BORLANDC__ -# pragma warn -8004 /* Variable assigned a value that is not used. */ -# pragma warn -8008 /* condition always returns true */ -# pragma warn -8060 /* possibly incorrect assignment */ -# pragma warn -8066 /* unreachable code */ -#endif #ifdef _MSC_VER # pragma warning (disable: 4102) /* Unused goto label. */ # pragma warning (disable: 4065) /* Switch statement contains default but diff --git a/Source/cmDependsJavaParser.y b/Source/cmDependsJavaParser.y index 944d4b5..b66dc6d 100644 --- a/Source/cmDependsJavaParser.y +++ b/Source/cmDependsJavaParser.y @@ -52,12 +52,6 @@ static void cmDependsJavaError(yyscan_t yyscanner, const char* message); #define jpElementStart(cnt) yyGetParser->PrepareElement(&yyval) #define jpStoreClass(str) yyGetParser->AddClassFound(str); yyGetParser->DeallocateParserType(&(str)) /* Disable some warnings in the generated code. */ -#ifdef __BORLANDC__ -# pragma warn -8004 /* Variable assigned a value that is not used. */ -# pragma warn -8008 /* condition always returns true */ -# pragma warn -8060 /* possibly incorrect assignment */ -# pragma warn -8066 /* unreachable code */ -#endif #ifdef _MSC_VER # pragma warning (disable: 4102) /* Unused goto label. */ # pragma warning (disable: 4065) /* Switch statement contains default but no case. */ diff --git a/Source/cmExprParser.cxx b/Source/cmExprParser.cxx index 77880c0..c12b42e 100644 --- a/Source/cmExprParser.cxx +++ b/Source/cmExprParser.cxx @@ -157,12 +157,6 @@ static void cmExprError(yyscan_t yyscanner, const char* message); /* Disable some warnings in the generated code. */ -#ifdef __BORLANDC__ -# pragma warn -8004 /* Variable assigned a value that is not used. */ -# pragma warn -8008 /* condition always returns true */ -# pragma warn -8060 /* possibly incorrect assignment */ -# pragma warn -8066 /* unreachable code */ -#endif #ifdef _MSC_VER # pragma warning (disable: 4102) /* Unused goto label. */ # pragma warning (disable: 4065) /* Switch statement contains default but diff --git a/Source/cmExprParser.y b/Source/cmExprParser.y index 12c2e48..f2c85d0 100644 --- a/Source/cmExprParser.y +++ b/Source/cmExprParser.y @@ -52,12 +52,6 @@ static void cmExprError(yyscan_t yyscanner, const char* message); /* Disable some warnings in the generated code. */ -#ifdef __BORLANDC__ -# pragma warn -8004 /* Variable assigned a value that is not used. */ -# pragma warn -8008 /* condition always returns true */ -# pragma warn -8060 /* possibly incorrect assignment */ -# pragma warn -8066 /* unreachable code */ -#endif #ifdef _MSC_VER # pragma warning (disable: 4102) /* Unused goto label. */ # pragma warning (disable: 4065) /* Switch statement contains default but no case. */ diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 56a6edb..79d7bcaff 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -276,7 +276,7 @@ void cmExtraCodeBlocksGenerator it->second[0]->GetMakefile()->GetHomeDirectory(), jt->c_str()); std::vector<std::string> splitted; - cmSystemTools::SplitPath(relative.c_str(), splitted, false); + cmSystemTools::SplitPath(relative, splitted, false); // Split filename from path std::string fileName = *(splitted.end()-1); splitted.erase(splitted.end() - 1, splitted.end()); diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 1beb3fd..2f69882 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -124,8 +124,8 @@ void cmExtraEclipseCDT4Generator::Generate() "Enable CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT instead."); } - if (cmSystemTools::IsSubDirectory(this->HomeOutputDirectory.c_str(), - this->HomeDirectory.c_str())) + if (cmSystemTools::IsSubDirectory(this->HomeOutputDirectory, + this->HomeDirectory)) { mf->IssueMessage(cmake::WARNING, "The build directory is a subdirectory " "of the source directory.\n" @@ -495,8 +495,8 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() std::string linkSourceDirectory = this->GetEclipsePath( mf->GetStartDirectory()); // .project dir can't be subdir of a linked resource dir - if (!cmSystemTools::IsSubDirectory(this->HomeOutputDirectory.c_str(), - linkSourceDirectory.c_str())) + if (!cmSystemTools::IsSubDirectory(this->HomeOutputDirectory, + linkSourceDirectory)) { this->AppendLinkedResource(fout, sourceLinkedResourceName, this->GetEclipsePath(linkSourceDirectory), @@ -590,7 +590,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets( ++fileIt) { std::string fullPath = (*fileIt)->GetFullPath(); - if (!cmSystemTools::FileIsDirectory(fullPath.c_str())) + if (!cmSystemTools::FileIsDirectory(fullPath)) { std::string linkName4 = linkName3; linkName4 += "/"; @@ -635,8 +635,8 @@ void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects( // a linked resource must not point to a parent directory of .project or // .project itself if ((baseDir != linkSourceDirectory) && - !cmSystemTools::IsSubDirectory(baseDir.c_str(), - linkSourceDirectory.c_str())) + !cmSystemTools::IsSubDirectory(baseDir, + linkSourceDirectory)) { std::string linkName = "[Subprojects]/"; linkName += it->first; @@ -663,7 +663,7 @@ void cmExtraEclipseCDT4Generator::AppendIncludeDirectories( { if (!inc->empty()) { - std::string dir = cmSystemTools::CollapseFullPath(inc->c_str()); + std::string dir = cmSystemTools::CollapseFullPath(*inc); // handle framework include dirs on OSX, the remainder after the // Frameworks/ part has to be stripped @@ -819,7 +819,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const // exlude source directory from output search path // - only if not named the same as an output directory if (!cmSystemTools::FileIsDirectory( - std::string(this->HomeOutputDirectory + "/" + *it).c_str())) + std::string(this->HomeOutputDirectory + "/" + *it))) { excludeFromOut += this->EscapeForXML(*it) + "/|"; } diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 1325cec..aa4c95b 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -33,6 +33,7 @@ #include <cmsys/Glob.hxx> #include <cmsys/RegularExpression.hxx> #include <cmsys/FStream.hxx> +#include <cmsys/Encoding.hxx> // Table of permissions flags. #if defined(_WIN32) && !defined(__CYGWIN__) @@ -61,6 +62,35 @@ static mode_t mode_setuid = S_ISUID; static mode_t mode_setgid = S_ISGID; #endif +#if defined(WIN32) && defined(CMAKE_ENCODING_UTF8) +// libcurl doesn't support file:// urls for unicode filenames on Windows. +// Convert string from UTF-8 to ACP if this is a file:// URL. +static std::string fix_file_url_windows(const std::string& url) +{ + std::string ret = url; + if(strncmp(url.c_str(), "file://", 7) == 0) + { + cmsys_stl::wstring wurl = cmsys::Encoding::ToWide(url); + if(!wurl.empty()) + { + int mblen = WideCharToMultiByte(CP_ACP, 0, wurl.c_str(), -1, + NULL, 0, NULL, NULL); + if(mblen > 0) + { + std::vector<char> chars(mblen); + mblen = WideCharToMultiByte(CP_ACP, 0, wurl.c_str(), -1, + &chars[0], mblen, NULL, NULL); + if(mblen > 0) + { + ret = &chars[0]; + } + } + } + } + return ret; +} +#endif + // cmLibraryCommand bool cmFileCommand ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) @@ -220,8 +250,6 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args, cmSystemTools::SetPermissions(fileName.c_str(), #if defined( _MSC_VER ) || defined( __MINGW32__ ) mode | S_IWRITE -#elif defined( __BORLANDC__ ) - mode | S_IWUSR #else mode | S_IWUSR | S_IWGRP #endif @@ -1504,7 +1532,7 @@ bool cmFileCopier::Run(std::vector<std::string> const& args) { // Split the input file into its directory and name components. std::vector<std::string> fromPathComponents; - cmSystemTools::SplitPath(files[i].c_str(), fromPathComponents); + cmSystemTools::SplitPath(files[i], fromPathComponents); std::string fromName = *(fromPathComponents.end()-1); std::string fromDir = cmSystemTools::JoinPath(fromPathComponents.begin(), fromPathComponents.end()-1); @@ -1612,7 +1640,7 @@ bool cmFileCopier::InstallSymlink(const char* fromFile, const char* toFile) cmSystemTools::RemoveFile(toFile); // Create the symlink. - if(!cmSystemTools::CreateSymlink(symlinkTarget.c_str(), toFile)) + if(!cmSystemTools::CreateSymlink(symlinkTarget, toFile)) { cmOStringStream e; e << this->Name << " cannot duplicate symlink \"" << fromFile @@ -2203,7 +2231,7 @@ bool cmFileInstaller::HandleInstallDestination() return false; } } - if ( !cmSystemTools::FileIsDirectory(destination.c_str()) ) + if ( !cmSystemTools::FileIsDirectory(destination) ) { std::string errstring = "INSTALL destination: " + destination + " is not a directory."; @@ -2553,14 +2581,14 @@ bool cmFileCommand::HandleRemove(std::vector<std::string> const& args, fileName += "/" + *i; } - if(cmSystemTools::FileIsDirectory(fileName.c_str()) && - !cmSystemTools::FileIsSymlink(fileName.c_str()) && recurse) + if(cmSystemTools::FileIsDirectory(fileName) && + !cmSystemTools::FileIsSymlink(fileName) && recurse) { - cmSystemTools::RemoveADirectory(fileName.c_str()); + cmSystemTools::RemoveADirectory(fileName); } else { - cmSystemTools::RemoveFile(fileName.c_str()); + cmSystemTools::RemoveFile(fileName); } } return true; @@ -2584,7 +2612,7 @@ bool cmFileCommand::HandleCMakePathCommand(std::vector<std::string> #else char pathSep = ':'; #endif - std::vector<cmsys::String> path = cmSystemTools::SplitString(i->c_str(), + std::vector<cmsys::String> path = cmSystemTools::SplitString(*i, pathSep); i++; const char* var = i->c_str(); @@ -2990,6 +3018,10 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) return false; } +#if defined(WIN32) && defined(CMAKE_ENCODING_UTF8) + url = fix_file_url_windows(url); +#endif + ::CURL *curl; ::curl_global_init(CURL_GLOBAL_DEFAULT); curl = ::curl_easy_init(); @@ -3241,7 +3273,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args) // Open file for reading: // - FILE *fin = cmsys::SystemTools::Fopen(filename.c_str(), "rb"); + FILE *fin = cmsys::SystemTools::Fopen(filename, "rb"); if(!fin) { std::string errStr = "UPLOAD cannot open file '"; @@ -3250,7 +3282,11 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args) return false; } - unsigned long file_size = cmsys::SystemTools::FileLength(filename.c_str()); + unsigned long file_size = cmsys::SystemTools::FileLength(filename); + +#if defined(WIN32) && defined(CMAKE_ENCODING_UTF8) + url = fix_file_url_windows(url); +#endif ::CURL *curl; ::curl_global_init(CURL_GLOBAL_DEFAULT); diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index e4e819a..beb6dde 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -140,11 +140,11 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) } else if(doing == DoingPaths) { - this->AddUserPath(args[j], this->UserPaths); + this->UserGuessArgs.push_back(args[j]); } else if(doing == DoingHints) { - this->AddUserPath(args[j], this->UserHints); + this->UserHintsArgs.push_back(args[j]); } else if(doing == DoingPathSuffixes) { @@ -186,16 +186,11 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) this->Names.push_back(shortArgs[0]); for(unsigned int j = 1; j < shortArgs.size(); ++j) { - this->AddUserPath(shortArgs[j], this->UserPaths); + this->UserGuessArgs.push_back(shortArgs[j]); } } this->ExpandPaths(); - // Filter out ignored paths from the prefix list - std::set<std::string> ignored; - this->GetIgnoredPaths(ignored); - this->FilterPaths(this->SearchPaths, ignored); - this->ComputeFinalPaths(); return true; @@ -203,226 +198,142 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) void cmFindBase::ExpandPaths() { - this->AddCMakeVariablePath(); - this->AddCMakeEnvironmentPath(); - this->AddUserHintsPath(); - this->AddSystemEnvironmentPath(); - this->AddCMakeSystemVariablePath(); - this->AddUserGuessPath(); - - // Add suffixes and clean up paths. - this->AddPathSuffixes(); -} - -//---------------------------------------------------------------------------- -void cmFindBase::AddPrefixPaths(std::vector<std::string> const& in_paths, - PathType pathType) -{ - // default for programs - std::string subdir = "bin"; - - if (this->CMakePathName == "INCLUDE") - { - subdir = "include"; - } - else if (this->CMakePathName == "LIBRARY") + if(!this->NoDefaultPath) { - subdir = "lib"; - } - else if (this->CMakePathName == "FRAMEWORK") - { - subdir = ""; // ? what to do for frameworks ? - } - - for(std::vector<std::string>::const_iterator it = in_paths.begin(); - it != in_paths.end(); ++it) - { - std::string dir = *it; - if(!subdir.empty() && !dir.empty() && dir[dir.size()-1] != '/') - { - dir += "/"; - } - if(subdir == "include" || subdir == "lib") + if(!this->NoCMakePath) { - const char* arch = - this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE"); - if(arch && *arch) - { - this->AddPathInternal(dir+subdir+"/"+arch, pathType); - } + this->FillCMakeVariablePath(); } - std::string add = dir + subdir; - if(add != "/") + if(!this->NoCMakeEnvironmentPath) { - this->AddPathInternal(add, pathType); + this->FillCMakeEnvironmentPath(); } - if (subdir == "bin") + if(!this->NoSystemEnvironmentPath) { - this->AddPathInternal(dir+"sbin", pathType); + this->FillSystemEnvironmentPath(); } - if(!subdir.empty() && *it != "/") + if(!this->NoCMakeSystemPath) { - this->AddPathInternal(*it, pathType); + this->FillCMakeSystemVariablePath(); } } -} -//---------------------------------------------------------------------------- -void cmFindBase::AddCMakePrefixPath(const std::string& variable) -{ - // Get a path from a CMake variable. - if(const char* varPath = this->Makefile->GetDefinition(variable)) - { - std::vector<std::string> tmp; - cmSystemTools::ExpandListArgument(varPath, tmp); - this->AddPrefixPaths(tmp, CMakePath); - } + this->FillUserHintsPath(); + this->FillUserGuessPath(); } //---------------------------------------------------------------------------- -void cmFindBase::AddEnvPrefixPath(const std::string& variable) +void cmFindBase::FillCMakeEnvironmentPath() { - // Get a path from the environment. - std::vector<std::string> tmp; - cmSystemTools::GetPath(tmp, variable.c_str()); - this->AddPrefixPaths(tmp, EnvPath); -} + cmSearchPath &paths = this->LabeledPaths[PathLabel::CMakeEnvironment]; -//---------------------------------------------------------------------------- -void cmFindBase::AddCMakeEnvironmentPath() -{ - if(!this->NoCMakeEnvironmentPath && !this->NoDefaultPath) - { - // Add CMAKE_*_PATH environment variables - std::string var = "CMAKE_"; - var += this->CMakePathName; - var += "_PATH"; - this->AddEnvPrefixPath("CMAKE_PREFIX_PATH"); - this->AddEnvPath(var.c_str()); + // Add CMAKE_*_PATH environment variables + std::string var = "CMAKE_"; + var += this->CMakePathName; + var += "_PATH"; + paths.AddEnvPrefixPath("CMAKE_PREFIX_PATH"); + paths.AddEnvPath(var); - if(this->CMakePathName == "PROGRAM") - { - this->AddEnvPath("CMAKE_APPBUNDLE_PATH"); - } - else - { - this->AddEnvPath("CMAKE_FRAMEWORK_PATH"); - } + if(this->CMakePathName == "PROGRAM") + { + paths.AddEnvPath("CMAKE_APPBUNDLE_PATH"); } + else + { + paths.AddEnvPath("CMAKE_FRAMEWORK_PATH"); + } + paths.AddSuffixes(this->SearchPathSuffixes); } //---------------------------------------------------------------------------- -void cmFindBase::AddCMakeVariablePath() +void cmFindBase::FillCMakeVariablePath() { - if(!this->NoCMakePath && !this->NoDefaultPath) + cmSearchPath &paths = this->LabeledPaths[PathLabel::CMake]; + + // Add CMake varibles of the same name as the previous environment + // varibles CMAKE_*_PATH to be used most of the time with -D + // command line options + std::string var = "CMAKE_"; + var += this->CMakePathName; + var += "_PATH"; + paths.AddCMakePrefixPath("CMAKE_PREFIX_PATH"); + paths.AddCMakePath(var); + + if(this->CMakePathName == "PROGRAM") { - // Add CMake varibles of the same name as the previous environment - // varibles CMAKE_*_PATH to be used most of the time with -D - // command line options - std::string var = "CMAKE_"; - var += this->CMakePathName; - var += "_PATH"; - this->AddCMakePrefixPath("CMAKE_PREFIX_PATH"); - this->AddCMakePath(var); - - if(this->CMakePathName == "PROGRAM") - { - this->AddCMakePath("CMAKE_APPBUNDLE_PATH"); - } - else - { - this->AddCMakePath("CMAKE_FRAMEWORK_PATH"); - } + paths.AddCMakePath("CMAKE_APPBUNDLE_PATH"); + } + else + { + paths.AddCMakePath("CMAKE_FRAMEWORK_PATH"); } + paths.AddSuffixes(this->SearchPathSuffixes); } //---------------------------------------------------------------------------- -void cmFindBase::AddSystemEnvironmentPath() +void cmFindBase::FillSystemEnvironmentPath() { - if(!this->NoSystemEnvironmentPath && !this->NoDefaultPath) + cmSearchPath &paths = this->LabeledPaths[PathLabel::SystemEnvironment]; + + // Add LIB or INCLUDE + if(!this->EnvironmentPath.empty()) { - // Add LIB or INCLUDE - if(!this->EnvironmentPath.empty()) - { - this->AddEnvPath(this->EnvironmentPath.c_str()); - } - // Add PATH - this->AddEnvPath(0); + paths.AddEnvPath(this->EnvironmentPath); } + // Add PATH + paths.AddEnvPath("PATH"); + paths.AddSuffixes(this->SearchPathSuffixes); } //---------------------------------------------------------------------------- -void cmFindBase::AddCMakeSystemVariablePath() +void cmFindBase::FillCMakeSystemVariablePath() { - if(!this->NoCMakeSystemPath && !this->NoDefaultPath) - { - std::string var = "CMAKE_SYSTEM_"; - var += this->CMakePathName; - var += "_PATH"; - this->AddCMakePrefixPath("CMAKE_SYSTEM_PREFIX_PATH"); - this->AddCMakePath(var); + cmSearchPath &paths = this->LabeledPaths[PathLabel::CMakeSystem]; - if(this->CMakePathName == "PROGRAM") - { - this->AddCMakePath("CMAKE_SYSTEM_APPBUNDLE_PATH"); - } - else - { - this->AddCMakePath("CMAKE_SYSTEM_FRAMEWORK_PATH"); - } + std::string var = "CMAKE_SYSTEM_"; + var += this->CMakePathName; + var += "_PATH"; + paths.AddCMakePrefixPath("CMAKE_SYSTEM_PREFIX_PATH"); + paths.AddCMakePath(var); + + if(this->CMakePathName == "PROGRAM") + { + paths.AddCMakePath("CMAKE_SYSTEM_APPBUNDLE_PATH"); + } + else + { + paths.AddCMakePath("CMAKE_SYSTEM_FRAMEWORK_PATH"); } + paths.AddSuffixes(this->SearchPathSuffixes); } //---------------------------------------------------------------------------- -void cmFindBase::AddUserHintsPath() +void cmFindBase::FillUserHintsPath() { - this->AddPathsInternal(this->UserHints, CMakePath); -} + cmSearchPath &paths = this->LabeledPaths[PathLabel::Hints]; -//---------------------------------------------------------------------------- -void cmFindBase::AddUserGuessPath() -{ - this->AddPathsInternal(this->UserPaths, CMakePath); + for(std::vector<std::string>::const_iterator p = this->UserHintsArgs.begin(); + p != this->UserHintsArgs.end(); ++p) + { + paths.AddUserPath(*p); + } + paths.AddSuffixes(this->SearchPathSuffixes); } //---------------------------------------------------------------------------- -void cmFindBase::AddPathSuffixes() +void cmFindBase::FillUserGuessPath() { - std::vector<std::string>& paths = this->SearchPaths; - std::vector<std::string> finalPath = paths; - std::vector<std::string>::iterator i; - // clear the path - paths.clear(); - // convert all paths to unix slashes and add search path suffixes - // if there are any - for(i = finalPath.begin(); - i != finalPath.end(); ++i) + cmSearchPath &paths = this->LabeledPaths[PathLabel::Guess]; + + for(std::vector<std::string>::const_iterator p = this->UserGuessArgs.begin(); + p != this->UserGuessArgs.end(); ++p) { - cmSystemTools::ConvertToUnixSlashes(*i); - // copy each finalPath combined with SearchPathSuffixes - // to the SearchPaths ivar - for(std::vector<std::string>::iterator j = - this->SearchPathSuffixes.begin(); - j != this->SearchPathSuffixes.end(); ++j) - { - // if *i is only / then do not add a // - // this will get incorrectly considered a network - // path on windows and cause huge delays. - std::string p = *i; - if(p.size() && p[p.size()-1] != '/') - { - p += std::string("/"); - } - p += *j; - // add to all paths because the search path may be modified - // later with lib being replaced for lib64 which may exist - paths.push_back(p); - } - // now put the path without the path suffixes in the SearchPaths - paths.push_back(*i); + paths.AddUserPath(*p); } + paths.AddSuffixes(this->SearchPathSuffixes); } +//---------------------------------------------------------------------------- void cmFindBase::PrintFindStuff() { std::cerr << "SearchFrameworkLast: " << this->SearchFrameworkLast << "\n"; @@ -457,9 +368,10 @@ void cmFindBase::PrintFindStuff() } std::cerr << "\n"; std::cerr << "SearchPaths\n"; - for(unsigned int i =0; i < this->SearchPaths.size(); ++i) + for(std::vector<std::string>::const_iterator i = this->SearchPaths.begin(); + i != this->SearchPaths.end(); ++i) { - std::cerr << "[" << this->SearchPaths[i] << "]\n"; + std::cerr << "[" << *i << "]\n"; } } diff --git a/Source/cmFindBase.h b/Source/cmFindBase.h index 42d9bc1..8ca311d 100644 --- a/Source/cmFindBase.h +++ b/Source/cmFindBase.h @@ -34,7 +34,6 @@ public: protected: void PrintFindStuff(); void ExpandPaths(); - void AddPathSuffixes(); // see if the VariableName is already set in the cache, // also copy the documentation from the cache to VariableDocumentation @@ -55,18 +54,12 @@ protected: bool AlreadyInCacheWithoutMetaInfo; private: // Add pieces of the search. - void AddCMakeEnvironmentPath(); - void AddCMakeVariablePath(); - void AddSystemEnvironmentPath(); - void AddCMakeSystemVariablePath(); - void AddUserHintsPath(); - void AddUserGuessPath(); - - // Helpers. - void AddCMakePrefixPath(const std::string& variable); - void AddEnvPrefixPath(const std::string& variable); - void AddPrefixPaths(std::vector<std::string> const& in_paths, - PathType pathType); + void FillCMakeVariablePath(); + void FillCMakeEnvironmentPath(); + void FillUserHintsPath(); + void FillSystemEnvironmentPath(); + void FillCMakeSystemVariablePath(); + void FillUserGuessPath(); }; diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index 10241f2..913985f 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -10,6 +10,19 @@ See the License for more information. ============================================================================*/ #include "cmFindCommon.h" +#include <functional> +#include <algorithm> + +//---------------------------------------------------------------------------- +cmFindCommon::PathGroup cmFindCommon::PathGroup::All("ALL"); +cmFindCommon::PathLabel cmFindCommon::PathLabel::CMake("CMAKE"); +cmFindCommon::PathLabel + cmFindCommon::PathLabel::CMakeEnvironment("CMAKE_ENVIRONMENT"); +cmFindCommon::PathLabel cmFindCommon::PathLabel::Hints("HINTS"); +cmFindCommon::PathLabel + cmFindCommon::PathLabel::SystemEnvironment("SYSTM_ENVIRONMENT"); +cmFindCommon::PathLabel cmFindCommon::PathLabel::CMakeSystem("CMAKE_SYSTEM"); +cmFindCommon::PathLabel cmFindCommon::PathLabel::Guess("GUESS"); //---------------------------------------------------------------------------- cmFindCommon::cmFindCommon() @@ -34,6 +47,8 @@ cmFindCommon::cmFindCommon() this->SearchFrameworkLast = false; this->SearchAppBundleOnly = false; this->SearchAppBundleLast = false; + + this->InitializeSearchPathGroups(); } //---------------------------------------------------------------------------- @@ -42,11 +57,42 @@ cmFindCommon::~cmFindCommon() } //---------------------------------------------------------------------------- -void cmFindCommon::SelectDefaultRootPathMode() +void cmFindCommon::InitializeSearchPathGroups() { - // Use both by default. - this->FindRootPathMode = RootPathModeBoth; + std::vector<PathLabel>* labels; + + // Define the varoius different groups of path types + + // All search paths + labels = &this->PathGroupLabelMap[PathGroup::All]; + labels->push_back(PathLabel::CMake); + labels->push_back(PathLabel::CMakeEnvironment); + labels->push_back(PathLabel::Hints); + labels->push_back(PathLabel::SystemEnvironment); + labels->push_back(PathLabel::CMakeSystem); + labels->push_back(PathLabel::Guess); + + // Define the search group order + this->PathGroupOrder.push_back(PathGroup::All); + + // Create the idividual labeld search paths + this->LabeledPaths.insert(std::make_pair(PathLabel::CMake, + cmSearchPath(this))); + this->LabeledPaths.insert(std::make_pair(PathLabel::CMakeEnvironment, + cmSearchPath(this))); + this->LabeledPaths.insert(std::make_pair(PathLabel::Hints, + cmSearchPath(this))); + this->LabeledPaths.insert(std::make_pair(PathLabel::SystemEnvironment, + cmSearchPath(this))); + this->LabeledPaths.insert(std::make_pair(PathLabel::CMakeSystem, + cmSearchPath(this))); + this->LabeledPaths.insert(std::make_pair(PathLabel::Guess, + cmSearchPath(this))); +} +//---------------------------------------------------------------------------- +void cmFindCommon::SelectDefaultRootPathMode() +{ // Check the policy variable for this find command type. std::string findRootPathVar = "CMAKE_FIND_ROOT_PATH_MODE_"; findRootPathVar += this->CMakePathName; @@ -54,11 +100,11 @@ void cmFindCommon::SelectDefaultRootPathMode() this->Makefile->GetSafeDefinition(findRootPathVar); if (rootPathMode=="NEVER") { - this->FindRootPathMode = RootPathModeNoRootPath; + this->FindRootPathMode = RootPathModeNever; } else if (rootPathMode=="ONLY") { - this->FindRootPathMode = RootPathModeOnlyRootPath; + this->FindRootPathMode = RootPathModeOnly; } else if (rootPathMode=="BOTH") { @@ -132,12 +178,12 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) fprintf(stderr, "[%s]\n", i->c_str()); } #endif - // Short-circuit if there is nothing to do. - if(this->FindRootPathMode == RootPathModeNoRootPath) + if(this->FindRootPathMode == RootPathModeNever) { return; } + const char* sysroot = this->Makefile->GetDefinition("CMAKE_SYSROOT"); const char* rootPath = @@ -182,9 +228,9 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) // already inside. Skip the unrooted path if it is relative to // a user home directory or is empty. std::string rootedDir; - if(cmSystemTools::IsSubDirectory(ui->c_str(), ri->c_str()) + if(cmSystemTools::IsSubDirectory(*ui, *ri) || (stagePrefix - && cmSystemTools::IsSubDirectory(ui->c_str(), stagePrefix))) + && cmSystemTools::IsSubDirectory(*ui, stagePrefix))) { rootedDir = *ui; } @@ -195,7 +241,7 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) rootedDir += "/"; // Append the original path with its old root removed. - rootedDir += cmSystemTools::SplitPathRootComponent(ui->c_str()); + rootedDir += cmSystemTools::SplitPathRootComponent(*ui); } // Store the new path. @@ -212,24 +258,20 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) } //---------------------------------------------------------------------------- -void cmFindCommon::FilterPaths(std::vector<std::string>& paths, - const std::set<std::string>& ignore) +void cmFindCommon::FilterPaths(const std::vector<std::string>& inPaths, + const std::set<std::string>& ignore, + std::vector<std::string>& outPaths) { - // Now filter out anything that's in the ignore set. - std::vector<std::string> unfiltered; - unfiltered.swap(paths); - - for(std::vector<std::string>::iterator pi = unfiltered.begin(); - pi != unfiltered.end(); ++pi) + for(std::vector<std::string>::const_iterator i = inPaths.begin(); + i != inPaths.end(); ++i) { - if (ignore.count(*pi) == 0) + if(ignore.count(*i) == 0) { - paths.push_back(*pi); + outPaths.push_back(*i); } } } - //---------------------------------------------------------------------------- void cmFindCommon::GetIgnoredPaths(std::vector<std::string>& ignore) { @@ -266,8 +308,6 @@ void cmFindCommon::GetIgnoredPaths(std::set<std::string>& ignore) ignore.insert(ignoreVec.begin(), ignoreVec.end()); } - - //---------------------------------------------------------------------------- bool cmFindCommon::CheckCommonArgument(std::string const& arg) { @@ -291,13 +331,13 @@ bool cmFindCommon::CheckCommonArgument(std::string const& arg) { this->NoCMakeSystemPath = true; } - else if(arg == "NO_CMAKE_FIND_ROOT_PATH") + else if(arg == "NO_CMAKE_FIND_ROOT_PATH") { - this->FindRootPathMode = RootPathModeNoRootPath; + this->FindRootPathMode = RootPathModeNever; } else if(arg == "ONLY_CMAKE_FIND_ROOT_PATH") { - this->FindRootPathMode = RootPathModeOnlyRootPath; + this->FindRootPathMode = RootPathModeOnly; } else if(arg == "CMAKE_FIND_ROOT_PATH_BOTH") { @@ -345,116 +385,34 @@ void cmFindCommon::AddPathSuffix(std::string const& arg) } //---------------------------------------------------------------------------- -void cmFindCommon::AddUserPath(std::string const& p, - std::vector<std::string>& paths) -{ - // We should view the registry as the target application would view - // it. - cmSystemTools::KeyWOW64 view = cmSystemTools::KeyWOW64_32; - cmSystemTools::KeyWOW64 other_view = cmSystemTools::KeyWOW64_64; - if(this->Makefile->PlatformIs64Bit()) - { - view = cmSystemTools::KeyWOW64_64; - other_view = cmSystemTools::KeyWOW64_32; - } - - // Expand using the view of the target application. - std::string expanded = p; - cmSystemTools::ExpandRegistryValues(expanded, view); - cmSystemTools::GlobDirs(expanded, paths); - - // Executables can be either 32-bit or 64-bit, so expand using the - // alternative view. - if(expanded != p && this->CMakePathName == "PROGRAM") - { - expanded = p; - cmSystemTools::ExpandRegistryValues(expanded, other_view); - cmSystemTools::GlobDirs(expanded, paths); - } -} - -//---------------------------------------------------------------------------- -void cmFindCommon::AddCMakePath(const std::string& variable) -{ - // Get a path from a CMake variable. - if(const char* varPath = this->Makefile->GetDefinition(variable)) - { - std::vector<std::string> tmp; - cmSystemTools::ExpandListArgument(varPath, tmp); - - // Relative paths are interpreted with respect to the current - // source directory. - this->AddPathsInternal(tmp, CMakePath); - } -} - -//---------------------------------------------------------------------------- -void cmFindCommon::AddEnvPath(const char* variable) -{ - // Get a path from the environment. - std::vector<std::string> tmp; - cmSystemTools::GetPath(tmp, variable); - // Relative paths are interpreted with respect to the current - // working directory. - this->AddPathsInternal(tmp, EnvPath); -} - -//---------------------------------------------------------------------------- -void cmFindCommon::AddPathsInternal(std::vector<std::string> const& in_paths, - PathType pathType) +void AddTrailingSlash(std::string& s) { - for(std::vector<std::string>::const_iterator i = in_paths.begin(); - i != in_paths.end(); ++i) + if(!s.empty() && *s.rbegin() != '/') { - this->AddPathInternal(*i, pathType); + s += '/'; } } - -//---------------------------------------------------------------------------- -void cmFindCommon::AddPathInternal(std::string const& in_path, - PathType pathType) +void cmFindCommon::ComputeFinalPaths() { - if(in_path.empty()) - { - return; - } + // Filter out ignored paths from the prefix list + std::set<std::string> ignored; + this->GetIgnoredPaths(ignored); - // Select the base path with which to interpret relative paths. - const char* relbase = 0; - if(pathType == CMakePath) + // Combine the seperate path types, filtering out ignores + this->SearchPaths.clear(); + std::vector<PathLabel>& allLabels = this->PathGroupLabelMap[PathGroup::All]; + for(std::vector<PathLabel>::const_iterator l = allLabels.begin(); + l != allLabels.end(); ++l) { - relbase = this->Makefile->GetCurrentDirectory(); + this->LabeledPaths[*l].ExtractWithout(ignored, this->SearchPaths); } - // Convert to clean full path. - std::string fullPath = - cmSystemTools::CollapseFullPath(in_path.c_str(), relbase); - - // Insert the path if has not already been emitted. - if(this->SearchPathsEmitted.insert(fullPath).second) - { - this->SearchPaths.push_back(fullPath); - } -} - -//---------------------------------------------------------------------------- -void cmFindCommon::ComputeFinalPaths() -{ - std::vector<std::string>& paths = this->SearchPaths; - // Expand list of paths inside all search roots. - this->RerootPaths(paths); + this->RerootPaths(this->SearchPaths); // Add a trailing slash to all paths to aid the search process. - for(std::vector<std::string>::iterator i = paths.begin(); - i != paths.end(); ++i) - { - std::string& p = *i; - if(!p.empty() && p[p.size()-1] != '/') - { - p += "/"; - } - } + std::for_each(this->SearchPaths.begin(), this->SearchPaths.end(), + &AddTrailingSlash); } //---------------------------------------------------------------------------- diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h index 5a905cd..3fefc8d 100644 --- a/Source/cmFindCommon.h +++ b/Source/cmFindCommon.h @@ -13,6 +13,8 @@ #define cmFindCommon_h #include "cmCommand.h" +#include "cmSearchPath.h" +#include "cmPathLabel.h" /** \class cmFindCommon * \brief Base class for FIND_XXX implementations. @@ -29,12 +31,39 @@ public: cmTypeMacro(cmFindCommon, cmCommand); protected: - - enum RootPathMode { RootPathModeBoth, - RootPathModeOnlyRootPath, - RootPathModeNoRootPath }; - - enum PathType { FullPath, CMakePath, EnvPath }; + friend class cmSearchPath; + + /** Used to define groups of path labels */ + class PathGroup : public cmPathLabel + { + protected: + PathGroup(); + public: + PathGroup(const std::string& label) : cmPathLabel(label) { } + static PathGroup All; + }; + + /* Individual path types */ + class PathLabel : public cmPathLabel + { + protected: + PathLabel(); + public: + PathLabel(const std::string& label) : cmPathLabel(label) { } + static PathLabel CMake; + static PathLabel CMakeEnvironment; + static PathLabel Hints; + static PathLabel SystemEnvironment; + static PathLabel CMakeSystem; + static PathLabel Guess; + }; + + enum RootPathMode { RootPathModeNever, + RootPathModeOnly, + RootPathModeBoth }; + + /** Construct the various path groups and labels */ + void InitializeSearchPathGroups(); /** Place a set of search paths under the search roots. */ void RerootPaths(std::vector<std::string>& paths); @@ -44,8 +73,9 @@ protected: void GetIgnoredPaths(std::set<std::string>& ignore); /** Remove paths in the ignore set from the supplied vector. */ - void FilterPaths(std::vector<std::string>& paths, - const std::set<std::string>& ignore); + void FilterPaths(const std::vector<std::string>& inPaths, + const std::set<std::string>& ignore, + std::vector<std::string>& outPaths); /** Compute final search path list (reroot + trailing slash). */ void ComputeFinalPaths(); @@ -56,19 +86,15 @@ protected: /** Compute the current default bundle/framework search policy. */ void SelectDefaultMacMode(); + // Path arguments prior to path manipulation routines + std::vector<std::string> UserHintsArgs; + std::vector<std::string> UserGuessArgs; + std::string CMakePathName; RootPathMode FindRootPathMode; bool CheckCommonArgument(std::string const& arg); void AddPathSuffix(std::string const& arg); - void AddUserPath(std::string const& p, - std::vector<std::string>& paths); - void AddCMakePath(const std::string& variable); - void AddEnvPath(const char* variable); - void AddPathsInternal(std::vector<std::string> const& in_paths, - PathType pathType); - void AddPathInternal(std::string const& in_path, PathType pathType); - void SetMakefile(cmMakefile* makefile); bool NoDefaultPath; @@ -78,8 +104,12 @@ protected: bool NoCMakeSystemPath; std::vector<std::string> SearchPathSuffixes; - std::vector<std::string> UserPaths; - std::vector<std::string> UserHints; + + std::map<PathGroup, std::vector<PathLabel> > PathGroupLabelMap; + std::vector<PathGroup> PathGroupOrder; + std::map<std::string, PathLabel> PathLabelStringMap; + std::map<PathLabel, cmSearchPath> LabeledPaths; + std::vector<std::string> SearchPaths; std::set<std::string> SearchPathsEmitted; diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index fe5e45f..78f0e9e 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -88,7 +88,7 @@ void cmFindLibraryCommand::AddArchitecturePaths(const char* suffix) { std::vector<std::string> original; original.swap(this->SearchPaths); - for(std::vector<std::string>::iterator i = original.begin(); + for(std::vector<std::string>::const_iterator i = original.begin(); i != original.end(); ++i) { this->AddArchitecturePath(*i, 0, suffix); @@ -107,7 +107,7 @@ void cmFindLibraryCommand::AddArchitecturePath( // Follow "lib<suffix>". std::string next_dir = cur_dir + suffix; - if(cmSystemTools::FileIsDirectory(next_dir.c_str())) + if(cmSystemTools::FileIsDirectory(next_dir)) { next_dir += dir.substr(pos+3); std::string::size_type next_pos = pos+3+strlen(suffix)+1; @@ -115,7 +115,7 @@ void cmFindLibraryCommand::AddArchitecturePath( } // Follow "lib". - if(cmSystemTools::FileIsDirectory(cur_dir.c_str())) + if(cmSystemTools::FileIsDirectory(cur_dir)) { this->AddArchitecturePath(dir, pos+3+1, suffix, false); } @@ -124,13 +124,13 @@ void cmFindLibraryCommand::AddArchitecturePath( { // Check for <dir><suffix>/. std::string cur_dir = dir + suffix + "/"; - if(cmSystemTools::FileIsDirectory(cur_dir.c_str())) + if(cmSystemTools::FileIsDirectory(cur_dir)) { this->SearchPaths.push_back(cur_dir); } // Now add the original unchanged path - if(cmSystemTools::FileIsDirectory(dir.c_str())) + if(cmSystemTools::FileIsDirectory(dir)) { this->SearchPaths.push_back(dir); } @@ -353,7 +353,7 @@ bool cmFindLibraryHelper::CheckDirectoryForName(std::string const& path, if(cmSystemTools::FileExists(this->TestPath.c_str(), true)) { this->BestPath = - cmSystemTools::CollapseFullPath(this->TestPath.c_str()); + cmSystemTools::CollapseFullPath(this->TestPath); cmSystemTools::ConvertToUnixSlashes(this->BestPath); return true; } @@ -382,7 +382,7 @@ bool cmFindLibraryHelper::CheckDirectoryForName(std::string const& path, { this->TestPath = path; this->TestPath += origName; - if(!cmSystemTools::FileIsDirectory(this->TestPath.c_str())) + if(!cmSystemTools::FileIsDirectory(this->TestPath)) { // This is a matching file. Check if it is better than the // best name found so far. Earlier prefixes are preferred, @@ -506,9 +506,9 @@ std::string cmFindLibraryCommand::FindFrameworkLibraryNamesPerDir() fwPath = *di; fwPath += *ni; fwPath += ".framework"; - if(cmSystemTools::FileIsDirectory(fwPath.c_str())) + if(cmSystemTools::FileIsDirectory(fwPath)) { - return cmSystemTools::CollapseFullPath(fwPath.c_str()); + return cmSystemTools::CollapseFullPath(fwPath); } } } @@ -532,9 +532,9 @@ std::string cmFindLibraryCommand::FindFrameworkLibraryDirsPerName() fwPath = *di; fwPath += *ni; fwPath += ".framework"; - if(cmSystemTools::FileIsDirectory(fwPath.c_str())) + if(cmSystemTools::FileIsDirectory(fwPath)) { - return cmSystemTools::CollapseFullPath(fwPath.c_str()); + return cmSystemTools::CollapseFullPath(fwPath); } } } diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 55a61f5..0130006 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -26,6 +26,14 @@ #endif //---------------------------------------------------------------------------- +cmFindPackageCommand::PathLabel + cmFindPackageCommand::PathLabel::UserRegistry("PACKAGE_REGISTRY"); +cmFindPackageCommand::PathLabel + cmFindPackageCommand::PathLabel::Builds("BUILDS"); +cmFindPackageCommand::PathLabel + cmFindPackageCommand::PathLabel::SystemRegistry("SYSTEM_PACKAGE_REGISTRY"); + +//---------------------------------------------------------------------------- cmFindPackageCommand::cmFindPackageCommand() { this->CMakePathName = "PACKAGE"; @@ -51,6 +59,33 @@ cmFindPackageCommand::cmFindPackageCommand() this->VersionFoundTweak = 0; this->VersionFoundCount = 0; this->RequiredCMakeVersion = 0; + + this->AppendSearchPathGroups(); +} + +//---------------------------------------------------------------------------- +void cmFindPackageCommand::AppendSearchPathGroups() +{ + std::vector<cmFindCommon::PathLabel>* labels; + + // Update the All group with new paths + labels = &this->PathGroupLabelMap[PathGroup::All]; + labels->insert(std::find(labels->begin(), labels->end(), + PathLabel::CMakeSystem), + PathLabel::UserRegistry); + labels->insert(std::find(labels->begin(), labels->end(), + PathLabel::CMakeSystem), + PathLabel::Builds); + labels->insert(std::find(labels->begin(), labels->end(), PathLabel::Guess), + PathLabel::SystemRegistry); + + // Create the new path objects + this->LabeledPaths.insert(std::make_pair(PathLabel::UserRegistry, + cmSearchPath(this))); + this->LabeledPaths.insert(std::make_pair(PathLabel::Builds, + cmSearchPath(this))); + this->LabeledPaths.insert(std::make_pair(PathLabel::SystemRegistry, + cmSearchPath(this))); } //---------------------------------------------------------------------------- @@ -248,11 +283,11 @@ bool cmFindPackageCommand } else if(doing == DoingPaths) { - this->AddUserPath(args[i], this->UserPaths); + this->UserGuessArgs.push_back(args[i]); } else if(doing == DoingHints) { - this->AddUserPath(args[i], this->UserHints); + this->UserHintsArgs.push_back(args[i]); } else if(doing == DoingPathSuffixes) { @@ -1111,86 +1146,97 @@ void cmFindPackageCommand::AppendSuccessInformation() //---------------------------------------------------------------------------- void cmFindPackageCommand::ComputePrefixes() { - this->AddPrefixesCMakeVariable(); - this->AddPrefixesCMakeEnvironment(); - this->AddPrefixesUserHints(); - this->AddPrefixesSystemEnvironment(); - this->AddPrefixesUserRegistry(); - this->AddPrefixesBuilds(); - this->AddPrefixesCMakeSystemVariable(); - this->AddPrefixesSystemRegistry(); - this->AddPrefixesUserGuess(); + if(!this->NoDefaultPath) + { + if(!this->NoCMakePath) + { + this->FillPrefixesCMakeVariable(); + } + if(!this->NoCMakeEnvironmentPath) + { + this->FillPrefixesCMakeEnvironment(); + } + if(!this->NoSystemEnvironmentPath) + { + this->FillPrefixesSystemEnvironment(); + } + if(!this->NoUserRegistry) + { + this->FillPrefixesUserRegistry(); + } + if(!this->NoBuilds) + { + this->FillPrefixesBuilds(); + } + if(!this->NoCMakeSystemPath) + { + this->FillPrefixesCMakeSystemVariable(); + } + if(!this->NoSystemRegistry) + { + this->FillPrefixesSystemRegistry(); + } + } + this->FillPrefixesUserHints(); + this->FillPrefixesUserGuess(); + this->ComputeFinalPaths(); } //---------------------------------------------------------------------------- -void cmFindPackageCommand::AddPrefixesCMakeEnvironment() +void cmFindPackageCommand::FillPrefixesCMakeEnvironment() { - if(!this->NoCMakeEnvironmentPath && !this->NoDefaultPath) - { - // Check the environment variable with the same name as the cache - // entry. - std::string env; - if(cmSystemTools::GetEnv(this->Variable.c_str(), env) && env.length() > 0) - { - cmSystemTools::ConvertToUnixSlashes(env); - this->AddPathInternal(env, EnvPath); - } + cmSearchPath &paths = this->LabeledPaths[PathLabel::CMakeEnvironment]; - this->AddEnvPath("CMAKE_PREFIX_PATH"); - this->AddEnvPath("CMAKE_FRAMEWORK_PATH"); - this->AddEnvPath("CMAKE_APPBUNDLE_PATH"); - } + // Check the environment variable with the same name as the cache + // entry. + paths.AddEnvPath(this->Variable); + + // And now the general CMake environment variables + paths.AddEnvPath("CMAKE_PREFIX_PATH"); + paths.AddEnvPath("CMAKE_FRAMEWORK_PATH"); + paths.AddEnvPath("CMAKE_APPBUNDLE_PATH"); } //---------------------------------------------------------------------------- -void cmFindPackageCommand::AddPrefixesCMakeVariable() +void cmFindPackageCommand::FillPrefixesCMakeVariable() { - if(!this->NoCMakePath && !this->NoDefaultPath) - { - this->AddCMakePath("CMAKE_PREFIX_PATH"); - this->AddCMakePath("CMAKE_FRAMEWORK_PATH"); - this->AddCMakePath("CMAKE_APPBUNDLE_PATH"); - } + cmSearchPath &paths = this->LabeledPaths[PathLabel::CMake]; + + paths.AddCMakePath("CMAKE_PREFIX_PATH"); + paths.AddCMakePath("CMAKE_FRAMEWORK_PATH"); + paths.AddCMakePath("CMAKE_APPBUNDLE_PATH"); } //---------------------------------------------------------------------------- -void cmFindPackageCommand::AddPrefixesSystemEnvironment() +void cmFindPackageCommand::FillPrefixesSystemEnvironment() { - if(!this->NoSystemEnvironmentPath && !this->NoDefaultPath) + cmSearchPath &paths = this->LabeledPaths[PathLabel::SystemEnvironment]; + + // Use the system search path to generate prefixes. + // Relative paths are interpreted with respect to the current + // working directory. + std::vector<std::string> tmp; + cmSystemTools::GetPath(tmp); + for(std::vector<std::string>::iterator i = tmp.begin(); + i != tmp.end(); ++i) { - // Use the system search path to generate prefixes. - // Relative paths are interpreted with respect to the current - // working directory. - std::vector<std::string> tmp; - cmSystemTools::GetPath(tmp); - for(std::vector<std::string>::iterator i = tmp.begin(); - i != tmp.end(); ++i) + // If the path is a PREFIX/bin case then add its parent instead. + if((cmHasLiteralSuffix(*i, "/bin")) || + (cmHasLiteralSuffix(*i, "/sbin"))) { - std::string const& d = *i; - - // If the path is a PREFIX/bin case then add its parent instead. - if((cmHasLiteralSuffix(d, "/bin")) || - (cmHasLiteralSuffix(d, "/sbin"))) - { - this->AddPathInternal(cmSystemTools::GetFilenamePath(d), EnvPath); - } - else - { - this->AddPathInternal(d, EnvPath); - } + paths.AddPath(cmSystemTools::GetFilenamePath(*i)); + } + else + { + paths.AddPath(*i); } } } //---------------------------------------------------------------------------- -void cmFindPackageCommand::AddPrefixesUserRegistry() +void cmFindPackageCommand::FillPrefixesUserRegistry() { - if(this->NoUserRegistry || this->NoDefaultPath) - { - return; - } - #if defined(_WIN32) && !defined(__CYGWIN__) this->LoadPackageRegistryWinUser(); #elif defined(__HAIKU__) @@ -1201,7 +1247,8 @@ void cmFindPackageCommand::AddPrefixesUserRegistry() std::string fname = dir; fname += "/cmake/packages/"; fname += Name; - this->LoadPackageRegistryDir(fname); + this->LoadPackageRegistryDir(fname, + this->LabeledPaths[PathLabel::UserRegistry]); } #else if(const char* home = cmSystemTools::GetEnv("HOME")) @@ -1209,13 +1256,14 @@ void cmFindPackageCommand::AddPrefixesUserRegistry() std::string dir = home; dir += "/.cmake/packages/"; dir += this->Name; - this->LoadPackageRegistryDir(dir); + this->LoadPackageRegistryDir(dir, + this->LabeledPaths[PathLabel::UserRegistry]); } #endif } //---------------------------------------------------------------------------- -void cmFindPackageCommand::AddPrefixesSystemRegistry() +void cmFindPackageCommand::FillPrefixesSystemRegistry() { if(this->NoSystemRegistry || this->NoDefaultPath) { @@ -1241,29 +1289,32 @@ void cmFindPackageCommand::AddPrefixesSystemRegistry() void cmFindPackageCommand::LoadPackageRegistryWinUser() { // HKEY_CURRENT_USER\\Software shares 32-bit and 64-bit views. - this->LoadPackageRegistryWin(true, 0); + this->LoadPackageRegistryWin(true, 0, + this->LabeledPaths[PathLabel::UserRegistry]); } //---------------------------------------------------------------------------- void cmFindPackageCommand::LoadPackageRegistryWinSystem() { + cmSearchPath &paths = this->LabeledPaths[PathLabel::SystemRegistry]; + // HKEY_LOCAL_MACHINE\\SOFTWARE has separate 32-bit and 64-bit views. // Prefer the target platform view first. if(this->Makefile->PlatformIs64Bit()) { - this->LoadPackageRegistryWin(false, KEY_WOW64_64KEY); - this->LoadPackageRegistryWin(false, KEY_WOW64_32KEY); + this->LoadPackageRegistryWin(false, KEY_WOW64_64KEY, paths); + this->LoadPackageRegistryWin(false, KEY_WOW64_32KEY, paths); } else { - this->LoadPackageRegistryWin(false, KEY_WOW64_32KEY); - this->LoadPackageRegistryWin(false, KEY_WOW64_64KEY); + this->LoadPackageRegistryWin(false, KEY_WOW64_32KEY, paths); + this->LoadPackageRegistryWin(false, KEY_WOW64_64KEY, paths); } } //---------------------------------------------------------------------------- -void cmFindPackageCommand::LoadPackageRegistryWin(bool user, - unsigned int view) +void cmFindPackageCommand::LoadPackageRegistryWin(bool user, unsigned int view, + cmSearchPath& outPaths) { std::wstring key = L"Software\\Kitware\\CMake\\Packages\\"; key += cmsys::Encoding::ToWide(this->Name); @@ -1289,8 +1340,8 @@ void cmFindPackageCommand::LoadPackageRegistryWin(bool user, if(valueType == REG_SZ) { data[dataSize] = 0; - cmsys_ios::stringstream ss(cmsys::Encoding::ToNarrow(&data[0])); - if(!this->CheckPackageRegistryEntry(ss)) + if(!this->CheckPackageRegistryEntry( + cmsys::Encoding::ToNarrow(&data[0]), outPaths)) { // The entry is invalid. bad.insert(name); @@ -1332,10 +1383,11 @@ public: }; //---------------------------------------------------------------------------- -void cmFindPackageCommand::LoadPackageRegistryDir(std::string const& dir) +void cmFindPackageCommand::LoadPackageRegistryDir(std::string const& dir, + cmSearchPath& outPaths) { cmsys::Directory files; - if(!files.Load(dir.c_str())) + if(!files.Load(dir)) { return; } @@ -1347,14 +1399,16 @@ void cmFindPackageCommand::LoadPackageRegistryDir(std::string const& dir) fname += "/"; fname += files.GetFile(i); - if(!cmSystemTools::FileIsDirectory(fname.c_str())) + if(!cmSystemTools::FileIsDirectory(fname)) { // Hold this file hostage until it behaves. cmFindPackageCommandHoldFile holdFile(fname.c_str()); // Load the file. cmsys::ifstream fin(fname.c_str(), std::ios::in | cmsys_ios_binary); - if(fin && this->CheckPackageRegistryEntry(fin)) + std::string fentry; + if(fin && cmSystemTools::GetLineFromStream(fin, fentry) && + this->CheckPackageRegistryEntry(fentry, outPaths)) { // The file references an existing package, so release it. holdFile.Release(); @@ -1367,23 +1421,25 @@ void cmFindPackageCommand::LoadPackageRegistryDir(std::string const& dir) #endif //---------------------------------------------------------------------------- -bool cmFindPackageCommand::CheckPackageRegistryEntry(std::istream& is) +bool cmFindPackageCommand::CheckPackageRegistryEntry(const std::string& fname, + cmSearchPath& outPaths) { // Parse the content of one package registry entry. - std::string fname; - if(cmSystemTools::GetLineFromStream(is, fname) && - cmSystemTools::FileIsFullPath(fname.c_str())) + if(cmSystemTools::FileIsFullPath(fname.c_str())) { // The first line in the stream is the full path to a file or // directory containing the package. if(cmSystemTools::FileExists(fname.c_str())) { // The path exists. Look for the package here. - if(!cmSystemTools::FileIsDirectory(fname.c_str())) + if(!cmSystemTools::FileIsDirectory(fname)) + { + outPaths.AddPath(cmSystemTools::GetFilenamePath(fname)); + } + else { - fname = cmSystemTools::GetFilenamePath(fname); + outPaths.AddPath(fname); } - this->AddPathInternal(fname, FullPath); return true; } else @@ -1404,52 +1460,60 @@ bool cmFindPackageCommand::CheckPackageRegistryEntry(std::istream& is) } //---------------------------------------------------------------------------- -void cmFindPackageCommand::AddPrefixesBuilds() +void cmFindPackageCommand::FillPrefixesBuilds() { - if(!this->NoBuilds && !this->NoDefaultPath) - { - // It is likely that CMake will have recently built the project. - for(int i=0; i <= 10; ++i) - { - cmOStringStream r; - r << - "[HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\" - "Settings\\StartPath;WhereBuild" << i << "]"; - std::string f = r.str(); - cmSystemTools::ExpandRegistryValues(f); - cmSystemTools::ConvertToUnixSlashes(f); - if(cmSystemTools::FileIsFullPath(f.c_str()) && - cmSystemTools::FileIsDirectory(f.c_str())) - { - this->AddPathInternal(f, FullPath); - } + cmSearchPath &paths = this->LabeledPaths[PathLabel::Builds]; + + // It is likely that CMake will have recently built the project. + for(int i=0; i <= 10; ++i) + { + cmOStringStream r; + r << + "[HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\" + "Settings\\StartPath;WhereBuild" << i << "]"; + std::string f = r.str(); + cmSystemTools::ExpandRegistryValues(f); + cmSystemTools::ConvertToUnixSlashes(f); + if(cmSystemTools::FileIsFullPath(f.c_str()) && + cmSystemTools::FileIsDirectory(f)) + { + paths.AddPath(f); } } } //---------------------------------------------------------------------------- -void cmFindPackageCommand::AddPrefixesCMakeSystemVariable() +void cmFindPackageCommand::FillPrefixesCMakeSystemVariable() { - if(!this->NoCMakeSystemPath && !this->NoDefaultPath) - { - this->AddCMakePath("CMAKE_SYSTEM_PREFIX_PATH"); - this->AddCMakePath("CMAKE_SYSTEM_FRAMEWORK_PATH"); - this->AddCMakePath("CMAKE_SYSTEM_APPBUNDLE_PATH"); - } + cmSearchPath &paths = this->LabeledPaths[PathLabel::CMakeSystem]; + + paths.AddCMakePath("CMAKE_SYSTEM_PREFIX_PATH"); + paths.AddCMakePath("CMAKE_SYSTEM_FRAMEWORK_PATH"); + paths.AddCMakePath("CMAKE_SYSTEM_APPBUNDLE_PATH"); } //---------------------------------------------------------------------------- -void cmFindPackageCommand::AddPrefixesUserGuess() +void cmFindPackageCommand::FillPrefixesUserGuess() { - // Add guesses specified by the caller. - this->AddPathsInternal(this->UserPaths, CMakePath); + cmSearchPath &paths = this->LabeledPaths[PathLabel::Guess]; + + for(std::vector<std::string>::const_iterator p = this->UserGuessArgs.begin(); + p != this->UserGuessArgs.end(); ++p) + { + paths.AddUserPath(*p); + } } //---------------------------------------------------------------------------- -void cmFindPackageCommand::AddPrefixesUserHints() +void cmFindPackageCommand::FillPrefixesUserHints() { - // Add hints specified by the caller. - this->AddPathsInternal(this->UserHints, CMakePath); + cmSearchPath &paths = this->LabeledPaths[PathLabel::Hints]; + + for(std::vector<std::string>::const_iterator p = this->UserHintsArgs.begin(); + p != this->UserHintsArgs.end(); ++p) + { + paths.AddUserPath(*p); + } } //---------------------------------------------------------------------------- @@ -1847,7 +1911,7 @@ private: // Construct a list of matches. std::vector<std::string> matches; cmsys::Directory d; - d.Load(parent.c_str()); + d.Load(parent); for(unsigned long i=0; i < d.GetNumberOfFiles(); ++i) { const char* fname = d.GetFile(i); @@ -1901,7 +1965,7 @@ private: // Construct a list of matches. std::vector<std::string> matches; cmsys::Directory d; - d.Load(parent.c_str()); + d.Load(parent); for(unsigned long i=0; i < d.GetNumberOfFiles(); ++i) { const char* fname = d.GetFile(i); @@ -1955,7 +2019,7 @@ private: // Look for matching files. std::vector<std::string> matches; cmsys::Directory d; - d.Load(parent.c_str()); + d.Load(parent); for(unsigned long i=0; i < d.GetNumberOfFiles(); ++i) { const char* fname = d.GetFile(i); @@ -2007,7 +2071,7 @@ private: for(std::vector<std::string>::const_iterator fi = files.begin(); fi != files.end(); ++fi) { - if(cmSystemTools::FileIsDirectory(fi->c_str())) + if(cmSystemTools::FileIsDirectory(*fi)) { if(this->Consider(*fi, lister)) { @@ -2035,7 +2099,7 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) } // Skip this if the prefix does not exist. - if(!cmSystemTools::FileIsDirectory(prefix_in.c_str())) + if(!cmSystemTools::FileIsDirectory(prefix_in)) { return false; } diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index 2249459..949dcb1 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -53,6 +53,21 @@ public: cmTypeMacro(cmFindPackageCommand, cmFindCommon); private: + class PathLabel : public cmFindCommon::PathLabel + { + protected: + PathLabel(); + public: + PathLabel(const std::string& label) : cmFindCommon::PathLabel(label) { } + static PathLabel UserRegistry; + static PathLabel Builds; + static PathLabel SystemRegistry; + }; + + // Add additional search path labels and groups not present in the + // parent class + void AppendSearchPathGroups(); + void AppendSuccessInformation(); void AppendToFoundProperty(bool found); void SetModuleVariables(const std::string& components); @@ -69,20 +84,22 @@ private: void StoreVersionFound(); void ComputePrefixes(); - void AddPrefixesCMakeEnvironment(); - void AddPrefixesCMakeVariable(); - void AddPrefixesSystemEnvironment(); - void AddPrefixesUserRegistry(); - void AddPrefixesSystemRegistry(); - void AddPrefixesBuilds(); - void AddPrefixesCMakeSystemVariable(); - void AddPrefixesUserGuess(); - void AddPrefixesUserHints(); - void LoadPackageRegistryDir(std::string const& dir); + void FillPrefixesCMakeEnvironment(); + void FillPrefixesCMakeVariable(); + void FillPrefixesSystemEnvironment(); + void FillPrefixesUserRegistry(); + void FillPrefixesSystemRegistry(); + void FillPrefixesBuilds(); + void FillPrefixesCMakeSystemVariable(); + void FillPrefixesUserGuess(); + void FillPrefixesUserHints(); + void LoadPackageRegistryDir(std::string const& dir, cmSearchPath& outPaths); void LoadPackageRegistryWinUser(); void LoadPackageRegistryWinSystem(); - void LoadPackageRegistryWin(bool user, unsigned int view); - bool CheckPackageRegistryEntry(std::istream& is); + void LoadPackageRegistryWin(bool user, unsigned int view, + cmSearchPath& outPaths); + bool CheckPackageRegistryEntry(const std::string& fname, + cmSearchPath& outPaths); bool SearchDirectory(std::string const& dir); bool CheckDirectory(std::string const& dir); bool FindConfigFile(std::string const& dir, std::string& file); diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx index 5531cdf..f4cc4c2 100644 --- a/Source/cmFindPathCommand.cxx +++ b/Source/cmFindPathCommand.cxx @@ -136,7 +136,7 @@ cmFindPathCommand::FindHeaderInFramework(std::string const& file, std::vector<std::string> files = globIt.GetFiles(); if(files.size()) { - std::string fheader = cmSystemTools::CollapseFullPath(files[0].c_str()); + std::string fheader = cmSystemTools::CollapseFullPath(files[0]); if(this->IncludeFileInPath) { return fheader; diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx index f6e37f6..4ee419c 100644 --- a/Source/cmFindProgramCommand.cxx +++ b/Source/cmFindProgramCommand.cxx @@ -88,7 +88,7 @@ std::string cmFindProgramCommand { std::string appName = *name + std::string(".app"); - std::string appPath = cmSystemTools::FindDirectory(appName.c_str(), + std::string appPath = cmSystemTools::FindDirectory(appName, this->SearchPaths, true); @@ -97,7 +97,7 @@ std::string cmFindProgramCommand std::string executable = GetBundleExecutable(appPath); if (!executable.empty()) { - return cmSystemTools::CollapseFullPath(executable.c_str()); + return cmSystemTools::CollapseFullPath(executable); } } } diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index e3f66c1..dec5157 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -27,6 +27,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, // if this is the endofreach for this statement if (!this->Depth) { + cmMakefile::LoopBlockPop loopBlockPop(&mf); + // Remove the function blocker for this scope or bail. cmsys::auto_ptr<cmFunctionBlocker> fb(mf.RemoveFunctionBlocker(this, lff)); @@ -73,6 +75,7 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, } } } + // restore the variable to its prior value mf.AddDefinition(this->Args[0],oldDef.c_str()); return true; @@ -199,6 +202,8 @@ bool cmForEachCommand } this->Makefile->AddFunctionBlocker(f); + this->Makefile->PushLoopBlock(); + return true; } @@ -242,5 +247,8 @@ bool cmForEachCommand::HandleInMode(std::vector<std::string> const& args) } this->Makefile->AddFunctionBlocker(f.release()); // TODO: pass auto_ptr + + this->Makefile->PushLoopBlock(); + return true; } diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index 78ad4b2..600b793 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -152,7 +152,7 @@ void cmGeneratedFileStreamBase::Open(const char* name) #endif // Make sure the temporary file that will be used is not present. - cmSystemTools::RemoveFile(this->TempName.c_str()); + cmSystemTools::RemoveFile(this->TempName); std::string dir = cmSystemTools::GetFilenamePath(this->TempName); cmSystemTools::MakeDirectory(dir.c_str()); @@ -174,7 +174,7 @@ bool cmGeneratedFileStreamBase::Close() if(!this->Name.empty() && this->Okay && (!this->CopyIfDifferent || - cmSystemTools::FilesDiffer(this->TempName.c_str(), resname.c_str()))) + cmSystemTools::FilesDiffer(this->TempName, resname))) { // The destination is to be replaced. Rename the temporary to the // destination atomically. @@ -185,7 +185,7 @@ bool cmGeneratedFileStreamBase::Close() { this->RenameFile(gzname.c_str(), resname.c_str()); } - cmSystemTools::RemoveFile(gzname.c_str()); + cmSystemTools::RemoveFile(gzname); } else { @@ -198,7 +198,7 @@ bool cmGeneratedFileStreamBase::Close() // Else, the destination was not replaced. // // Always delete the temporary file. We never want it to stay around. - cmSystemTools::RemoveFile(this->TempName.c_str()); + cmSystemTools::RemoveFile(this->TempName); return replaced; } diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 7fc1464..bff6f5f 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -33,18 +33,10 @@ cmGeneratorExpression::cmGeneratorExpression( cmsys::auto_ptr<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse(std::string const& input) { -#if !defined(__BORLANDC__) return cmsys::auto_ptr<cmCompiledGeneratorExpression>( new cmCompiledGeneratorExpression( this->Backtrace ? *this->Backtrace : cmListFileBacktrace(NULL), input)); -#else - cmListFileBacktrace emptyBacktrace(NULL); - return cmsys::auto_ptr<cmCompiledGeneratorExpression>( - new cmCompiledGeneratorExpression( - this->Backtrace ? *this->Backtrace : emptyBacktrace, - input)); -#endif } //---------------------------------------------------------------------------- @@ -98,6 +90,7 @@ const char *cmCompiledGeneratorExpression::Evaluate( context.HadError = false; context.HadContextSensitiveCondition = false; context.HadHeadSensitiveCondition = false; + context.SourceSensitiveTargets.clear(); context.HeadTarget = headTarget; context.EvaluateForBuildsystem = this->EvaluateForBuildsystem; context.CurrentTarget = currentTarget ? currentTarget : headTarget; @@ -126,6 +119,7 @@ const char *cmCompiledGeneratorExpression::Evaluate( { this->HadContextSensitiveCondition = context.HadContextSensitiveCondition; this->HadHeadSensitiveCondition = context.HadHeadSensitiveCondition; + this->SourceSensitiveTargets = context.SourceSensitiveTargets; } this->DependTargets = context.DependTargets; diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index b952520..57f78c5 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -115,6 +115,10 @@ public: { return this->HadHeadSensitiveCondition; } + std::set<cmTarget const*> GetSourceSensitiveTargets() const + { + return this->SourceSensitiveTargets; + } void SetEvaluateForBuildsystem(bool eval) { @@ -146,6 +150,7 @@ private: mutable std::string Output; mutable bool HadContextSensitiveCondition; mutable bool HadHeadSensitiveCondition; + mutable std::set<cmTarget const*> SourceSensitiveTargets; bool EvaluateForBuildsystem; }; diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index f9067cf..03d0bc6 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -13,6 +13,9 @@ #include "cmGeneratorExpressionEvaluationFile.h" #include "cmMakefile.h" +#include "cmLocalGenerator.h" +#include "cmGlobalGenerator.h" +#include "cmSourceFile.h" #include "cmGeneratedFileStream.h" #include <cmsys/FStream.hxx> @@ -36,7 +39,7 @@ cmGeneratorExpressionEvaluationFile::cmGeneratorExpressionEvaluationFile( //---------------------------------------------------------------------------- void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config, cmCompiledGeneratorExpression* inputExpression, - std::map<std::string, std::string> &outputFiles) + std::map<std::string, std::string> &outputFiles, mode_t perm) { std::string rawCondition = this->Condition->GetInput(); if (!rawCondition.empty()) @@ -77,17 +80,37 @@ void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config, return; } + this->Makefile->AddCMakeOutputFile(outputFileName.c_str()); this->Files.push_back(outputFileName); outputFiles[outputFileName] = outputContent; cmGeneratedFileStream fout(outputFileName.c_str()); fout.SetCopyIfDifferent(true); fout << outputContent; + if (fout.Close() && perm) + { + cmSystemTools::SetPermissions(outputFileName.c_str(), perm); + } +} + +//---------------------------------------------------------------------------- +void cmGeneratorExpressionEvaluationFile::CreateOutputFile( + std::string const& config) +{ + std::string name = this->OutputFileExpr->Evaluate(this->Makefile, config); + cmSourceFile* sf = this->Makefile->GetOrCreateSource(name); + sf->SetProperty("GENERATED", "1"); + + cmGlobalGenerator *gg + = this->Makefile->GetLocalGenerator()->GetGlobalGenerator(); + gg->SetFilenameTargetDepends(sf, + this->OutputFileExpr->GetSourceSensitiveTargets()); } //---------------------------------------------------------------------------- void cmGeneratorExpressionEvaluationFile::Generate() { + mode_t perm = 0; std::string inputContent; if (this->InputIsContent) { @@ -95,6 +118,8 @@ void cmGeneratorExpressionEvaluationFile::Generate() } else { + this->Makefile->AddCMakeDependFile(this->Input.c_str()); + cmSystemTools::GetPermissions(this->Input.c_str(), perm); cmsys::ifstream fin(this->Input.c_str()); if(!fin) { @@ -131,7 +156,7 @@ void cmGeneratorExpressionEvaluationFile::Generate() for(std::vector<std::string>::const_iterator li = allConfigs.begin(); li != allConfigs.end(); ++li) { - this->Generate(*li, inputExpression.get(), outputFiles); + this->Generate(*li, inputExpression.get(), outputFiles, perm); if(cmSystemTools::GetFatalErrorOccured()) { return; diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h index f939916..3394ade 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.h +++ b/Source/cmGeneratorExpressionEvaluationFile.h @@ -31,10 +31,12 @@ public: std::vector<std::string> GetFiles() const { return this->Files; } + void CreateOutputFile(std::string const& config); + private: void Generate(const std::string& config, cmCompiledGeneratorExpression* inputExpression, - std::map<std::string, std::string> &outputFiles); + std::map<std::string, std::string> &outputFiles, mode_t perm); private: const std::string Input; diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 67a1a6d..b0258f6 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -329,7 +329,7 @@ static const struct MakeCIdentifierNode : public cmGeneratorExpressionNode const GeneratorExpressionContent *, cmGeneratorExpressionDAGChecker *) const { - return cmSystemTools::MakeCidentifier(parameters.front().c_str()); + return cmSystemTools::MakeCidentifier(parameters.front()); } } makeCIdentifierNode; @@ -939,7 +939,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode reportError(context, content->GetOriginalExpression(), e.str()); return std::string(); } - context->AllTargets.insert(target); + context->AllTargets.insert(target); } if (target == context->HeadTarget) @@ -950,6 +950,10 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode // value for all evaluations. context->SeenTargetProperties.insert(propertyName); } + if (propertyName == "SOURCES") + { + context->SourceSensitiveTargets.insert(target); + } if (propertyName.empty()) { @@ -1253,7 +1257,7 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode std::string tgtName = parameters.front(); cmGeneratorTarget* gt = - context->Makefile->FindGeneratorTargetToUse(tgtName.c_str()); + context->Makefile->FindGeneratorTargetToUse(tgtName); if (!gt) { cmOStringStream e; diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h index 8a529e8..0bf1797 100644 --- a/Source/cmGeneratorExpressionEvaluator.h +++ b/Source/cmGeneratorExpressionEvaluator.h @@ -31,6 +31,7 @@ struct cmGeneratorExpressionContext std::set<cmTarget*> DependTargets; std::set<cmTarget const*> AllTargets; std::set<std::string> SeenTargetProperties; + std::set<cmTarget const*> SourceSensitiveTargets; std::map<cmTarget const*, std::map<std::string, std::string> > MaxLanguageStandard; cmMakefile *Makefile; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 14b5a92..2b531e2 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -56,7 +56,6 @@ struct ModuleDefinitionFileTag {}; struct AppManifestTag{}; struct CertificatesTag{}; -#if !defined(_MSC_VER) || _MSC_VER >= 1310 template<typename Tag, typename OtherTag> struct IsSameTag { @@ -72,25 +71,6 @@ struct IsSameTag<Tag, Tag> Result = true }; }; -#else -struct IsSameTagBase -{ - typedef char (&no_type)[1]; - typedef char (&yes_type)[2]; - template<typename T> struct Check; - template<typename T> static yes_type check(Check<T>*, Check<T>*); - static no_type check(...); -}; -template<typename Tag1, typename Tag2> -struct IsSameTag: public IsSameTagBase -{ - enum { - Result = (sizeof(check(static_cast< Check<Tag1>* >(0), - static_cast< Check<Tag2>* >(0))) == - sizeof(yes_type)) - }; -}; -#endif template<bool> struct DoAccept @@ -646,6 +626,17 @@ cmTargetTraceDependencies si != sources.end(); ++si) { cmSourceFile* sf = *si; + const std::set<cmTarget const*> tgts = + this->GlobalGenerator->GetFilenameTargetDepends(sf); + if (tgts.find(this->Target) != tgts.end()) + { + cmOStringStream e; + e << "Evaluation output file\n \"" << sf->GetFullPath() + << "\"\ndepends on the sources of a target it is used in. This " + "is a dependency loop and is not allowed."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; + } if(emitted.insert(sf).second && this->SourcesQueued.insert(sf).second) { this->SourceQueue.push(sf); @@ -772,8 +763,8 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep) std::string tLocation = t->GetLocationForBuild(); tLocation = cmSystemTools::GetFilenamePath(tLocation); std::string depLocation = cmSystemTools::GetFilenamePath(dep); - depLocation = cmSystemTools::CollapseFullPath(depLocation.c_str()); - tLocation = cmSystemTools::CollapseFullPath(tLocation.c_str()); + depLocation = cmSystemTools::CollapseFullPath(depLocation); + tLocation = cmSystemTools::CollapseFullPath(tLocation); if(depLocation == tLocation) { this->Target->AddUtility(util); diff --git a/Source/cmGetDirectoryPropertyCommand.cxx b/Source/cmGetDirectoryPropertyCommand.cxx index fcc3da1..8fb2fa1 100644 --- a/Source/cmGetDirectoryPropertyCommand.cxx +++ b/Source/cmGetDirectoryPropertyCommand.cxx @@ -49,7 +49,7 @@ bool cmGetDirectoryPropertyCommand } // The local generators are associated with collapsed paths. - sd = cmSystemTools::CollapseFullPath(sd.c_str()); + sd = cmSystemTools::CollapseFullPath(sd); // lookup the makefile from the directory name cmLocalGenerator *lg = diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx index 10406d2..e7d2857 100644 --- a/Source/cmGetFilenameComponentCommand.cxx +++ b/Source/cmGetFilenameComponentCommand.cxx @@ -79,7 +79,7 @@ bool cmGetFilenameComponentCommand } } } - cmSystemTools::SplitProgramFromArgs(filename.c_str(), + cmSystemTools::SplitProgramFromArgs(filename, result, programArgs); } else if (args[2] == "EXT") @@ -97,11 +97,11 @@ bool cmGetFilenameComponentCommand // If the path given is relative evaluate it relative to the // current source directory. result = cmSystemTools::CollapseFullPath( - filename.c_str(), this->Makefile->GetCurrentDirectory()); + filename, this->Makefile->GetCurrentDirectory()); if(args[2] == "REALPATH") { // Resolve symlinks if possible - result = cmSystemTools::GetRealPath(result.c_str()); + result = cmSystemTools::GetRealPath(result); } } else diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index 9a88191..3c59c25 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -259,7 +259,7 @@ bool cmGetPropertyCommand::HandleDirectoryMode() } // The local generators are associated with collapsed paths. - dir = cmSystemTools::CollapseFullPath(dir.c_str()); + dir = cmSystemTools::CollapseFullPath(dir); // Lookup the generator. if(cmLocalGenerator* lg = diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 2f4d9bb..29ab7d0 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -11,6 +11,9 @@ ============================================================================*/ #if defined(_WIN32) && !defined(__CYGWIN__) #include "windows.h" // this must be first to define GetCurrentDirectory +#if defined(_MSC_VER) && _MSC_VER >= 1800 +# define KWSYS_WINDOWS_DEPRECATED_GetVersionEx +#endif #endif #include "cmGlobalGenerator.h" @@ -297,11 +300,11 @@ void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf) { std::string dir; std::string file; - cmSystemTools::SplitProgramPath(makeProgram.c_str(), + cmSystemTools::SplitProgramPath(makeProgram, dir, file); std::string saveFile = file; - cmSystemTools::GetShortPath(makeProgram.c_str(), makeProgram); - cmSystemTools::SplitProgramPath(makeProgram.c_str(), + cmSystemTools::GetShortPath(makeProgram, makeProgram); + cmSystemTools::SplitProgramPath(makeProgram, dir, file); makeProgram = dir; makeProgram += "/"; @@ -456,7 +459,14 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, OSVERSIONINFO osvi; ZeroMemory(&osvi, sizeof(osvi)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); +#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx +# pragma warning (push) +# pragma warning (disable:4996) +#endif GetVersionEx (&osvi); +#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx +# pragma warning (pop) +#endif cmOStringStream windowsVersionString; windowsVersionString << osvi.dwMajorVersion << "." << osvi.dwMinorVersion; windowsVersionString.str(); @@ -597,7 +607,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, std::string env = envVar; env += "="; env += envVarValue; - cmSystemTools::PutEnv(env.c_str()); + cmSystemTools::PutEnv(env); } // if determineLanguage was called then load the file it @@ -691,7 +701,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, compilerLangFile += "/CMake"; compilerLangFile += lang; compilerLangFile += "Compiler.cmake"; - cmSystemTools::RemoveFile(compilerLangFile.c_str()); + cmSystemTools::RemoveFile(compilerLangFile); if(!this->CMakeInstance->GetIsInTryCompile()) { this->PrintCompilerAdvice(noCompiler, lang, @@ -758,7 +768,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, compilerLangFile += "/CMake"; compilerLangFile += lang; compilerLangFile += "Compiler.cmake"; - cmSystemTools::RemoveFile(compilerLangFile.c_str()); + cmSystemTools::RemoveFile(compilerLangFile); } } // end if in try compile } // end need test language @@ -1253,8 +1263,6 @@ void cmGlobalGenerator::Generate() // Create per-target generator information. this->CreateGeneratorTargets(); - this->ForceLinkerLanguages(); - #ifdef CMAKE_BUILD_WITH_CMAKE for (AutogensType::iterator it = autogens.begin(); it != autogens.end(); ++it) @@ -1270,6 +1278,8 @@ void cmGlobalGenerator::Generate() this->LocalGenerators[i]->TraceDependencies(); } + this->ForceLinkerLanguages(); + // Compute the manifest of main targets generated. for (i = 0; i < this->LocalGenerators.size(); ++i) { @@ -1735,7 +1745,7 @@ int cmGlobalGenerator::Build( * Run an executable command and put the stdout in output. */ std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(bindir.c_str()); + cmSystemTools::ChangeDirectory(bindir); output += "Change Dir: "; output += bindir; output += "\n"; @@ -1765,7 +1775,7 @@ int cmGlobalGenerator::Build( output += "\nGenerator: execution of make clean failed.\n"; // return to the original directory - cmSystemTools::ChangeDirectory(cwd.c_str()); + cmSystemTools::ChangeDirectory(cwd); return 1; } output += *outputPtr; @@ -1792,7 +1802,7 @@ int cmGlobalGenerator::Build( + makeCommandStr + "\n"; // return to the original directory - cmSystemTools::ChangeDirectory(cwd.c_str()); + cmSystemTools::ChangeDirectory(cwd); return 1; } output += *outputPtr; @@ -1806,7 +1816,7 @@ int cmGlobalGenerator::Build( retVal = 1; } - cmSystemTools::ChangeDirectory(cwd.c_str()); + cmSystemTools::ChangeDirectory(cwd); return retVal; } @@ -2197,7 +2207,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) = this->CreateGlobalTarget(this->GetPackageTargetName(), "Run CPack packaging tool...", &cpackCommandLines, depends, - workingDir.c_str()); + workingDir.c_str(), /*uses_terminal*/false); } // CPack source const char* packageSourceTargetName = this->GetPackageSourceTargetName(); @@ -2221,8 +2231,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) = this->CreateGlobalTarget(packageSourceTargetName, "Run CPack packaging tool for source...", &cpackCommandLines, depends, - workingDir.c_str() - ); + workingDir.c_str(), /*uses_terminal*/false); } } @@ -2247,7 +2256,8 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) cpackCommandLines.push_back(singleLine); (*targets)[this->GetTestTargetName()] = this->CreateGlobalTarget(this->GetTestTargetName(), - "Running tests...", &cpackCommandLines, depends, 0); + "Running tests...", &cpackCommandLines, depends, 0, + /*uses_terminal*/false); } //Edit Cache @@ -2270,7 +2280,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) (*targets)[editCacheTargetName] = this->CreateGlobalTarget( editCacheTargetName, "Running CMake cache editor...", - &cpackCommandLines, depends, 0); + &cpackCommandLines, depends, 0, /*uses_terminal*/true); } else { @@ -2283,7 +2293,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) this->CreateGlobalTarget( editCacheTargetName, "No interactive CMake dialog available...", - &cpackCommandLines, depends, 0); + &cpackCommandLines, depends, 0, /*uses_terminal*/false); } } @@ -2302,7 +2312,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) (*targets)[rebuildCacheTargetName] = this->CreateGlobalTarget( rebuildCacheTargetName, "Running CMake to regenerate build system...", - &cpackCommandLines, depends, 0); + &cpackCommandLines, depends, 0, /*uses_terminal*/false); } //Install @@ -2342,7 +2352,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) (*targets)["list_install_components"] = this->CreateGlobalTarget("list_install_components", ostr.str().c_str(), - &cpackCommandLines, depends, 0); + &cpackCommandLines, depends, 0, /*uses_terminal*/false); } std::string cmd = cmakeCommand; cpackCommandLines.erase(cpackCommandLines.begin(), @@ -2383,7 +2393,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) (*targets)[this->GetInstallTargetName()] = this->CreateGlobalTarget( this->GetInstallTargetName(), "Install the project...", - &cpackCommandLines, depends, 0); + &cpackCommandLines, depends, 0, /*uses_terminal*/false); // install_local if(const char* install_local = this->GetInstallLocalTargetName()) @@ -2399,7 +2409,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) (*targets)[install_local] = this->CreateGlobalTarget( install_local, "Installing only the local directory...", - &cpackCommandLines, depends, 0); + &cpackCommandLines, depends, 0, /*uses_terminal*/false); } // install_strip @@ -2416,7 +2426,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) (*targets)[install_strip] = this->CreateGlobalTarget( install_strip, "Installing the project stripped...", - &cpackCommandLines, depends, 0); + &cpackCommandLines, depends, 0, /*uses_terminal*/false); } } } @@ -2459,7 +2469,7 @@ void cmGlobalGenerator::EnableMinGWLanguage(cmMakefile *mf) this->FindMakeProgram(mf); std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); std::vector<std::string> locations; - locations.push_back(cmSystemTools::GetProgramPath(makeProgram.c_str())); + locations.push_back(cmSystemTools::GetProgramPath(makeProgram)); locations.push_back("/mingw/bin"); locations.push_back("c:/mingw/bin"); std::string tgcc = cmSystemTools::FindProgram("gcc", locations); @@ -2490,7 +2500,8 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget( const std::string& name, const char* message, const cmCustomCommandLines* commandLines, std::vector<std::string> depends, - const char* workingDirectory) + const char* workingDirectory, + bool uses_terminal) { // Package cmTarget target; @@ -2499,10 +2510,12 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget( target.SetProperty("EXCLUDE_FROM_ALL","TRUE"); std::vector<std::string> no_outputs; + std::vector<std::string> no_byproducts; std::vector<std::string> no_depends; // Store the custom command in the target. - cmCustomCommand cc(0, no_outputs, no_depends, *commandLines, 0, - workingDirectory); + cmCustomCommand cc(0, no_outputs, no_byproducts, no_depends, + *commandLines, 0, workingDirectory); + cc.SetUsesTerminal(uses_terminal); target.AddPostBuildCommand(cc); target.SetProperty("EchoString", message); std::vector<std::string>::iterator dit; @@ -2724,7 +2737,7 @@ cmGlobalGenerator::GetDirectoryContent(std::string const& dir, bool needDisk) { // Load the directory content from disk. cmsys::Directory d; - if(d.Load(dir.c_str())) + if(d.Load(dir)) { unsigned long n = d.GetNumberOfFiles(); for(unsigned long i = 0; i < n; ++i) @@ -2831,8 +2844,8 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile, { // The rule has changed. Delete the output so it will be // built again. - fname = cmSystemTools::CollapseFullPath(fname.c_str(), home.c_str()); - cmSystemTools::RemoveFile(fname.c_str()); + fname = cmSystemTools::CollapseFullPath(fname, home.c_str()); + cmSystemTools::RemoveFile(fname); } } else @@ -2844,7 +2857,7 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile, // that if the feature is turned back on and the rule has // changed the file is still rebuilt. std::string fpath = - cmSystemTools::CollapseFullPath(fname.c_str(), home.c_str()); + cmSystemTools::CollapseFullPath(fname, home.c_str()); if(cmSystemTools::FileExists(fpath.c_str())) { RuleHash hash; @@ -2861,7 +2874,7 @@ void cmGlobalGenerator::WriteRuleHashes(std::string const& pfile) // Now generate a new persistence file with the current hashes. if(this->RuleHashes.empty()) { - cmSystemTools::RemoveFile(pfile.c_str()); + cmSystemTools::RemoveFile(pfile); } else { @@ -2966,7 +2979,7 @@ void cmGlobalGenerator::WriteSummary(cmTarget* target) } else { - cmSystemTools::RemoveFile(file.c_str()); + cmSystemTools::RemoveFile(file); } } @@ -2984,6 +2997,32 @@ std::string cmGlobalGenerator::EscapeJSON(const std::string& s) { } //---------------------------------------------------------------------------- +void cmGlobalGenerator::SetFilenameTargetDepends(cmSourceFile* sf, + std::set<cmTarget const*> tgts) +{ + this->FilenameTargetDepends[sf] = tgts; +} + +//---------------------------------------------------------------------------- +std::set<cmTarget const*> const& +cmGlobalGenerator::GetFilenameTargetDepends(cmSourceFile* sf) const { + return this->FilenameTargetDepends[sf]; +} + +//---------------------------------------------------------------------------- +void cmGlobalGenerator::CreateEvaluationSourceFiles( + std::string const& config) const +{ + for(std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator + li = this->EvaluationFiles.begin(); + li != this->EvaluationFiles.end(); + ++li) + { + (*li)->CreateOutputFile(config); + } +} + +//---------------------------------------------------------------------------- void cmGlobalGenerator::AddEvaluationFile(const std::string &inputFile, cmsys::auto_ptr<cmCompiledGeneratorExpression> outputExpr, cmMakefile *makefile, diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index ddd7e91..926efe7 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -341,6 +341,13 @@ public: bool GenerateCPackPropertiesFile(); + void CreateEvaluationSourceFiles(std::string const& config) const; + + void SetFilenameTargetDepends(cmSourceFile* sf, + std::set<cmTarget const*> tgts); + std::set<cmTarget const*> const& + GetFilenameTargetDepends(cmSourceFile* sf) const; + protected: virtual void Generate(); @@ -378,7 +385,8 @@ protected: void CreateDefaultGlobalTargets(cmTargets* targets); cmTarget CreateGlobalTarget(const std::string& name, const char* message, const cmCustomCommandLines* commandLines, - std::vector<std::string> depends, const char* workingDir); + std::vector<std::string> depends, const char* workingDir, + bool uses_terminal); bool NeedSymbolicMark; bool UseLinkScript; @@ -488,6 +496,9 @@ private: // track targets to issue CMP0042 warning for. std::set<std::string> CMP0042WarnTargets; + + mutable std::map<cmSourceFile*, std::set<cmTarget const*> > + FilenameTargetDepends; }; #endif diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index 89d25c4..ee0c583 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -222,7 +222,7 @@ bool cmGlobalKdevelopGenerator it!=files.end(); it++) { // get the full path to the file - tmp=cmSystemTools::CollapseFullPath(it->c_str(), projectDir.c_str()); + tmp=cmSystemTools::CollapseFullPath(*it, projectDir.c_str()); // just select the first source file if (fileToOpen.empty()) { @@ -274,7 +274,7 @@ void cmGlobalKdevelopGenerator // kdevelop blacklist so they are not monitored for added or removed files // since this is handled by adding files to the cmake files cmsys::Directory d; - if (d.Load(projectDir.c_str())) + if (d.Load(projectDir)) { size_t numf = d.GetNumberOfFiles(); for (unsigned int i = 0; i < numf; i++) @@ -285,7 +285,7 @@ void cmGlobalKdevelopGenerator std::string tmp = projectDir; tmp += "/"; tmp += nextFile; - if (cmSystemTools::FileIsDirectory(tmp.c_str())) + if (cmSystemTools::FileIsDirectory(tmp)) { tmp += "/CMakeCache.txt"; if ((nextFile == "CMakeFiles") diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 6e7b06b..6f0586b 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -242,7 +242,7 @@ void cmGlobalNinjaGenerator::AddCustomCommandRule() /*deptype*/ "", /*rspfile*/ "", /*rspcontent*/ "", - /*restat*/ true, + /*restat*/ "1", /*generator*/ false); } @@ -250,6 +250,7 @@ void cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command, const std::string& description, const std::string& comment, + bool uses_terminal, const cmNinjaDeps& outputs, const cmNinjaDeps& deps, const cmNinjaDeps& orderOnly) @@ -266,6 +267,10 @@ cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command, cmNinjaVars vars; vars["COMMAND"] = cmd; vars["DESC"] = EncodeLiteral(description); + if (uses_terminal && SupportsConsolePool()) + { + vars["pool"] = "console"; + } this->WriteBuild(*this->BuildFileStream, comment, @@ -304,7 +309,7 @@ cmGlobalNinjaGenerator::AddMacOSXContentRule() /*deptype*/ "", /*rspfile*/ "", /*rspcontent*/ "", - /*restat*/ false, + /*restat*/ "", /*generator*/ false); } @@ -339,7 +344,7 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os, const std::string& deptype, const std::string& rspfile, const std::string& rspcontent, - bool restat, + const std::string& restat, bool generator) { // Make sure the rule has a name. @@ -403,10 +408,10 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os, os << "rspfile_content = " << rspcontent << "\n"; } - if(restat) + if(!restat.empty()) { cmGlobalNinjaGenerator::Indent(os, 1); - os << "restat = 1\n"; + os << "restat = " << restat << "\n"; } if(generator) @@ -602,7 +607,7 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name, const std::string& deptype, const std::string& rspfile, const std::string& rspcontent, - bool restat, + const std::string& restat, bool generator) { // Do not add the same rule twice. @@ -771,7 +776,7 @@ void cmGlobalNinjaGenerator::AddCXXCompileCommand( if (!cmSystemTools::FileIsFullPath(sourceFileName.c_str())) { sourceFileName = cmSystemTools::CollapseFullPath( - sourceFileName.c_str(), + sourceFileName, this->GetCMakeInstance()->GetHomeOutputDirectory()); } @@ -826,6 +831,7 @@ void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies() std::copy(i->second.begin(), i->second.end(), std::back_inserter(deps)); WriteCustomCommandBuild(/*command=*/"", /*description=*/"", "Assume dependencies for generated source file.", + /*uses_terminal*/false, cmNinjaDeps(1, i->first), deps); } } @@ -851,7 +857,7 @@ cmGlobalNinjaGenerator case cmTarget::STATIC_LIBRARY: case cmTarget::MODULE_LIBRARY: outputs.push_back(ng->ConvertToNinjaPath( - target->GetFullPath(configName, false, realname).c_str())); + target->GetFullPath(configName, false, realname))); break; case cmTarget::OBJECT_LIBRARY: @@ -970,7 +976,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) typedef std::vector<std::string>::const_iterator vect_it; for(vect_it j = files.begin(); j != files.end(); ++j) { - knownDependencies.insert( ng->ConvertToNinjaPath( j->c_str() ) ); + knownDependencies.insert( ng->ConvertToNinjaPath( *j ) ); } //get list files which are implicit dependencies as well and will be phony //for rebuild manifest @@ -978,7 +984,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) typedef std::vector<std::string>::const_iterator vect_it; for(vect_it j = lf.begin(); j != lf.end(); ++j) { - knownDependencies.insert( ng->ConvertToNinjaPath( j->c_str() ) ); + knownDependencies.insert( ng->ConvertToNinjaPath( *j ) ); } } knownDependencies.insert( "CMakeCache.txt" ); @@ -994,7 +1000,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) typedef std::vector<std::string>::const_iterator vect_it; for(vect_it j = files.begin(); j != files.end(); ++j) { - knownDependencies.insert( ng->ConvertToNinjaPath( j->c_str() ) ); + knownDependencies.insert( ng->ConvertToNinjaPath( *j ) ); } } @@ -1002,7 +1008,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) i != this->TargetAliases.end(); ++i) { - knownDependencies.insert( ng->ConvertToNinjaPath(i->first.c_str()) ); + knownDependencies.insert( ng->ConvertToNinjaPath(i->first) ); } //remove all source files we know will exist. @@ -1011,7 +1017,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) i != this->AssumedSourceDependencies.end(); ++i) { - knownDependencies.insert( ng->ConvertToNinjaPath(i->first.c_str()) ); + knownDependencies.insert( ng->ConvertToNinjaPath(i->first) ); } //insert outputs from all WirteBuild commands @@ -1051,9 +1057,9 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) { //verify the file is in the build directory std::string const absDepPath = cmSystemTools::CollapseFullPath( - i->c_str(), rootBuildDirectory.c_str()); - bool const inBuildDir = cmSystemTools::IsSubDirectory(absDepPath.c_str(), - rootBuildDirectory.c_str()); + *i, rootBuildDirectory.c_str()); + bool const inBuildDir = cmSystemTools::IsSubDirectory(absDepPath, + rootBuildDirectory); if(inBuildDir) { cmNinjaDeps deps(1,*i); @@ -1116,7 +1122,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) /*deptype=*/ "", /*rspfile=*/ "", /*rspcontent*/ "", - /*restat=*/ false, + /*restat=*/ "", /*generator=*/ true); cmLocalNinjaGenerator *ng = static_cast<cmLocalNinjaGenerator *>(lg); @@ -1129,7 +1135,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) for(std::vector<std::string>::const_iterator fi = lf.begin(); fi != lf.end(); ++fi) { - implicitDeps.push_back(ng->ConvertToNinjaPath(fi->c_str())); + implicitDeps.push_back(ng->ConvertToNinjaPath(*fi)); } } implicitDeps.push_back("CMakeCache.txt"); @@ -1141,9 +1147,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) cmNinjaVars variables; // Use 'console' pool to get non buffered output of the CMake re-run call // Available since Ninja 1.5 - if(cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, - ninjaVersion().c_str(), - "1.5") == false) + if(SupportsConsolePool()) { variables["pool"] = "console"; } @@ -1185,6 +1189,12 @@ std::string cmGlobalNinjaGenerator::ninjaVersion() const return version; } +bool cmGlobalNinjaGenerator::SupportsConsolePool() const +{ + return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, + ninjaVersion().c_str(), "1.5") == false; +} + void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) { WriteRule(*this->RulesFileStream, @@ -1196,7 +1206,7 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) /*deptype=*/ "", /*rspfile=*/ "", /*rspcontent*/ "", - /*restat=*/ false, + /*restat=*/ "", /*generator=*/ false); WriteBuild(os, "Clean all the built files.", @@ -1219,7 +1229,7 @@ void cmGlobalNinjaGenerator::WriteTargetHelp(std::ostream& os) /*deptype=*/ "", /*rspfile=*/ "", /*rspcontent*/ "", - /*restat=*/ false, + /*restat=*/ "", /*generator=*/ false); WriteBuild(os, "Print all primary targets available.", diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index f666ee3..3d443d8 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -103,6 +103,7 @@ public: void WriteCustomCommandBuild(const std::string& command, const std::string& description, const std::string& comment, + bool uses_terminal, const cmNinjaDeps& outputs, const cmNinjaDeps& deps = cmNinjaDeps(), const cmNinjaDeps& orderOnly = cmNinjaDeps()); @@ -124,7 +125,7 @@ public: const std::string& deptype, const std::string& rspfile, const std::string& rspcontent, - bool restat, + const std::string& restat, bool generator); /** @@ -244,7 +245,7 @@ public: const std::string& deptype, const std::string& rspfile, const std::string& rspcontent, - bool restat, + const std::string& restat, bool generator); bool HasRule(const std::string& name); @@ -299,6 +300,9 @@ public: virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; std::string ninjaVersion() const; + + bool SupportsConsolePool() const; + protected: /// Overloaded methods. @see cmGlobalGenerator::Generate() diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 745515b..e6ce45d 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -341,9 +341,10 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() // overwritten by the CreateVCProjBuildRule. // (this could be avoided with per-target source files) std::string no_main_dependency = ""; + std::vector<std::string> no_byproducts; if(cmSourceFile* file = mf->AddCustomCommandToOutput( - stamps, listFiles, + stamps, no_byproducts, listFiles, no_main_dependency, commandLines, "Checking Build System", no_working_directory, true)) { diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 13e6988..b9f64e2 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -477,7 +477,9 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, this->PostBuildMakeTarget(target.GetName(), "$(CONFIGURATION)"); cmCustomCommandLines commandLines; commandLines.push_back(makeHelper); + std::vector<std::string> no_byproducts; lg->GetMakefile()->AddCustomCommandToTarget(target.GetName(), + no_byproducts, no_depends, commandLines, cmTarget::POST_BUILD, @@ -1368,6 +1370,7 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, cmCustomCommand command(this->CurrentMakefile, std::vector<std::string>(), std::vector<std::string>(), + std::vector<std::string>(), cmd, "Creating symlinks", ""); @@ -2314,6 +2317,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, group->AddObject(this->CreateString("-Wmost")); group->AddObject(this->CreateString("-Wno-four-char-constants")); group->AddObject(this->CreateString("-Wno-unknown-pragmas")); + group->AddObject(this->CreateString("$(inherited)")); buildSettings->AddAttribute("WARNING_CFLAGS", group); } else diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx index 0a4f5c9..0a1d280 100644 --- a/Source/cmIncludeCommand.cxx +++ b/Source/cmIncludeCommand.cxx @@ -90,7 +90,7 @@ bool cmIncludeCommand } std::string fname_abs = - cmSystemTools::CollapseFullPath(fname.c_str(), + cmSystemTools::CollapseFullPath(fname, this->Makefile->GetStartDirectory()); cmGlobalGenerator *gg = this->Makefile->GetLocalGenerator() diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index ec500d9..c3c9c55 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -167,7 +167,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args) script += "/"; script += args[i]; } - if(cmSystemTools::FileIsDirectory(script.c_str())) + if(cmSystemTools::FileIsDirectory(script)) { this->SetError("given a directory as value of SCRIPT argument."); return false; @@ -1111,7 +1111,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args) // Make sure the name is a directory. if(cmSystemTools::FileExists(dir.c_str()) && - !cmSystemTools::FileIsDirectory(dir.c_str())) + !cmSystemTools::FileIsDirectory(dir)) { cmOStringStream e; e << args[0] << " given non-directory \"" @@ -1393,7 +1393,7 @@ bool cmInstallCommand::MakeFilesFullPath(const char* modeName, } // Make sure the file is not a directory. - if(gpos == file.npos && cmSystemTools::FileIsDirectory(file.c_str())) + if(gpos == file.npos && cmSystemTools::FileIsDirectory(file)) { cmOStringStream e; e << modeName << " given directory \"" << (*fileIt) << "\" to install."; diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 3fc5b69..1c39563 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -19,9 +19,6 @@ #include <cmsys/RegularExpression.hxx> -#ifdef __BORLANDC__ -# pragma warn -8060 /* possibly incorrect assignment */ -#endif //---------------------------------------------------------------------------- struct cmListFileParser diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 50e279b..3fb1e1e 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -221,19 +221,19 @@ void cmLocalGenerator::SetupPathConversions() std::string outdir; outdir = cmSystemTools::CollapseFullPath(this->Makefile->GetHomeDirectory()); - cmSystemTools::SplitPath(outdir.c_str(), this->HomeDirectoryComponents); + cmSystemTools::SplitPath(outdir, this->HomeDirectoryComponents); outdir = cmSystemTools::CollapseFullPath(this->Makefile->GetStartDirectory()); - cmSystemTools::SplitPath(outdir.c_str(), this->StartDirectoryComponents); + cmSystemTools::SplitPath(outdir, this->StartDirectoryComponents); outdir = cmSystemTools::CollapseFullPath (this->Makefile->GetHomeOutputDirectory()); - cmSystemTools::SplitPath(outdir.c_str(), + cmSystemTools::SplitPath(outdir, this->HomeOutputDirectoryComponents); outdir = cmSystemTools::CollapseFullPath (this->Makefile->GetStartOutputDirectory()); - cmSystemTools::SplitPath(outdir.c_str(), + cmSystemTools::SplitPath(outdir, this->StartOutputDirectoryComponents); } @@ -259,6 +259,17 @@ void cmLocalGenerator::ConfigureFinalPass() void cmLocalGenerator::TraceDependencies() { + std::vector<std::string> configs; + this->Makefile->GetConfigurations(configs); + if (configs.empty()) + { + configs.push_back(""); + } + for(std::vector<std::string>::const_iterator ci = configs.begin(); + ci != configs.end(); ++ci) + { + this->GlobalGenerator->CreateEvaluationSourceFiles(*ci); + } // Generate the rule files for each target. cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); for(cmGeneratorTargetsType::iterator t = targets.begin(); @@ -1247,7 +1258,7 @@ cmLocalGenerator::ConvertToOutputForExistingCommon(const std::string& remote, cmSystemTools::FileExists(remote.c_str())) { std::string tmp; - if(cmSystemTools::GetShortPath(remote.c_str(), tmp)) + if(cmSystemTools::GetShortPath(remote, tmp)) { return this->Convert(tmp, NONE, format, true); } @@ -1371,7 +1382,7 @@ std::string cmLocalGenerator::GetIncludeFlags( { std::string frameworkDir = *i; frameworkDir += "/../"; - frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str()); + frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir); if(emitted.insert(frameworkDir).second) { if (sysFwSearchFlag && target && @@ -1613,10 +1624,10 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, { // Emit this directory only if it is a subdirectory of the // top-level source or binary tree. - if(cmSystemTools::ComparePath(i->c_str(), topSourceDir) || - cmSystemTools::ComparePath(i->c_str(), topBinaryDir) || - cmSystemTools::IsSubDirectory(i->c_str(), topSourceDir) || - cmSystemTools::IsSubDirectory(i->c_str(), topBinaryDir)) + if(cmSystemTools::ComparePath(*i, topSourceDir) || + cmSystemTools::ComparePath(*i, topBinaryDir) || + cmSystemTools::IsSubDirectory(*i, topSourceDir) || + cmSystemTools::IsSubDirectory(*i, topBinaryDir)) { if(emitted.insert(*i).second) { @@ -2109,11 +2120,11 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName, { tLocation = target->GetLocation(config); tLocation = cmSystemTools::GetFilenamePath(tLocation); - tLocation = cmSystemTools::CollapseFullPath(tLocation.c_str()); + tLocation = cmSystemTools::CollapseFullPath(tLocation); } std::string depLocation = cmSystemTools::GetFilenamePath( std::string(inName)); - depLocation = cmSystemTools::CollapseFullPath(depLocation.c_str()); + depLocation = cmSystemTools::CollapseFullPath(depLocation); if(depLocation != tLocation) { // it is a full path to a depend that has the same name @@ -2743,7 +2754,7 @@ std::string cmLocalGenerator::Convert(const std::string& source, result); break; case FULL: - result = cmSystemTools::CollapseFullPath(result.c_str()); + result = cmSystemTools::CollapseFullPath(result); break; case NONE: break; @@ -2807,7 +2818,7 @@ std::string cmLocalGenerator::Convert(RelativeRoot remote, if(!local.empty() && (!optional || this->UseRelativePaths)) { std::vector<std::string> components; - cmSystemTools::SplitPath(local.c_str(), components); + cmSystemTools::SplitPath(local, components); std::string result = this->ConvertToRelativePath(components, remotePath); return this->ConvertToOutputFormat(result, output); } @@ -2827,7 +2838,7 @@ std::string cmLocalGenerator::FindRelativePathTopSource() { std::string parentTop = parent->FindRelativePathTopSource(); if(cmSystemTools::IsSubDirectory( - this->Makefile->GetStartDirectory(), parentTop.c_str())) + this->Makefile->GetStartDirectory(), parentTop)) { return parentTop; } @@ -2847,7 +2858,7 @@ std::string cmLocalGenerator::FindRelativePathTopBinary() { std::string parentTop = parent->FindRelativePathTopBinary(); if(cmSystemTools::IsSubDirectory( - this->Makefile->GetStartOutputDirectory(), parentTop.c_str())) + this->Makefile->GetStartOutputDirectory(), parentTop)) { return parentTop; } @@ -2933,12 +2944,12 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local, // Identify the longest shared path component between the remote // path and the local path. std::vector<std::string> remote; - cmSystemTools::SplitPath(in_remote.c_str(), remote); + cmSystemTools::SplitPath(in_remote, remote); unsigned int common=0; while(common < remote.size() && common < local.size() && - cmSystemTools::ComparePath(remote[common].c_str(), - local[common].c_str())) + cmSystemTools::ComparePath(remote[common], + local[common])) { ++common; } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 398b55a..0b0d971 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -352,7 +352,7 @@ void cmLocalNinjaGenerator::AppendCustomCommandDeps( i != deps.end(); ++i) { std::string dep; if (this->GetRealDependency(*i, this->GetConfigName(), dep)) - ninjaDeps.push_back(ConvertToNinjaPath(dep.c_str())); + ninjaDeps.push_back(ConvertToNinjaPath(dep)); } } @@ -440,10 +440,18 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement( cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile); const std::vector<std::string> &outputs = ccg.GetOutputs(); - cmNinjaDeps ninjaOutputs(outputs.size()), ninjaDeps; + const std::vector<std::string> &byproducts = ccg.GetByproducts(); + cmNinjaDeps ninjaOutputs(outputs.size()+byproducts.size()), ninjaDeps; +#if 0 +#error TODO: Once CC in an ExternalProject target must provide the \ + file of each imported target that has an add_dependencies pointing \ + at us. How to know which ExternalProject step actually provides it? +#endif std::transform(outputs.begin(), outputs.end(), ninjaOutputs.begin(), MapToNinjaPath()); + std::transform(byproducts.begin(), byproducts.end(), + ninjaOutputs.begin() + outputs.size(), MapToNinjaPath()); this->AppendCustomCommandDeps(ccg, ninjaDeps); for (cmNinjaDeps::iterator i = ninjaOutputs.begin(); i != ninjaOutputs.end(); @@ -468,6 +476,7 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement( this->BuildCommandLine(cmdLines), this->ConstructComment(ccg), "Custom command for " + ninjaOutputs[0], + cc->GetUsesTerminal(), ninjaOutputs, ninjaDeps, orderOnlyDeps); diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 1d27224..01e16df 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -74,7 +74,7 @@ public: map_to_ninja_path(cmLocalNinjaGenerator *LocalGen) : LocalGenerator(LocalGen) {} std::string operator()(const std::string &path) { - return LocalGenerator->ConvertToNinjaPath(path.c_str()); + return LocalGenerator->ConvertToNinjaPath(path); } }; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 23513fa..ff8ba8b 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -315,36 +315,43 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() // Check whether preprocessing and assembly rules make sense. // They make sense only for C and C++ sources. - bool lang_is_c_or_cxx = false; + bool lang_has_preprocessor = false; + bool lang_has_assembly = false; + for(std::vector<LocalObjectEntry>::const_iterator ei = lo->second.begin(); ei != lo->second.end(); ++ei) { - if(ei->Language == "C" || ei->Language == "CXX") + if(ei->Language == "C" || + ei->Language == "CXX" || + ei->Language == "Fortran") { - lang_is_c_or_cxx = true; + // Right now, C, C++ and Fortran have both a preprocessor and the + // ability to generate assembly code + lang_has_preprocessor = true; + lang_has_assembly = true; break; } } // Add convenience rules for preprocessed and assembly files. - if(lang_is_c_or_cxx && (do_preprocess_rules || do_assembly_rules)) + if(lang_has_preprocessor && do_preprocess_rules) { std::string::size_type dot_pos = lo->first.rfind("."); std::string base = lo->first.substr(0, dot_pos); - if(do_preprocess_rules) - { - this->WriteObjectConvenienceRule( - ruleFileStream, "target to preprocess a source file", - (base + ".i").c_str(), lo->second); - lo->second.HasPreprocessRule = true; - } - if(do_assembly_rules) - { - this->WriteObjectConvenienceRule( - ruleFileStream, "target to generate assembly for a file", - (base + ".s").c_str(), lo->second); - lo->second.HasAssembleRule = true; - } + this->WriteObjectConvenienceRule( + ruleFileStream, "target to preprocess a source file", + (base + ".i").c_str(), lo->second); + lo->second.HasPreprocessRule = true; + } + + if(lang_has_assembly && do_assembly_rules) + { + std::string::size_type dot_pos = lo->first.rfind("."); + std::string base = lo->first.substr(0, dot_pos); + this->WriteObjectConvenienceRule( + ruleFileStream, "target to generate assembly for a file", + (base + ".s").c_str(), lo->second); + lo->second.HasAssembleRule = true; } } @@ -700,7 +707,7 @@ cmLocalUnixMakefileGenerator3 // name. This is needed to avoid funny quoting problems on // lines with shell redirection operators. std::string scmd; - if(cmSystemTools::GetShortPath(cmd.c_str(), scmd)) + if(cmSystemTools::GetShortPath(cmd, scmd)) { return this->Convert(scmd, NONE, SHELL); } @@ -1733,7 +1740,7 @@ void cmLocalUnixMakefileGenerator3::CheckMultipleOutputs(bool verbose) << depender << "\" does not exist." << std::endl; cmSystemTools::Stdout(msg.str().c_str()); } - cmSystemTools::RemoveFile(dependee.c_str()); + cmSystemTools::RemoveFile(dependee); } } } @@ -1988,7 +1995,7 @@ void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf, // Remove the internal dependency check file to force // regeneration. std::string internalDependFile = dir + "/depend.internal"; - cmSystemTools::RemoveFile(internalDependFile.c_str()); + cmSystemTools::RemoveFile(internalDependFile); } } diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index c14fb2b..b9a5074 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -821,10 +821,12 @@ cmLocalVisualStudio6Generator::MaybeCreateOutputDir(cmTarget& target, command.push_back("make_directory"); command.push_back(outDir); std::vector<std::string> no_output; + std::vector<std::string> no_byproducts; std::vector<std::string> no_depends; cmCustomCommandLines commands; commands.push_back(command); - pcc.reset(new cmCustomCommand(0, no_output, no_depends, commands, 0, 0)); + pcc.reset(new cmCustomCommand(0, no_output, no_byproducts, + no_depends, commands, 0, 0)); pcc->SetEscapeOldStyle(false); pcc->SetEscapeAllowMakeVars(true); return pcc; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index eb45423..0e66764 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -592,6 +592,15 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorLinkFlagTable[] = {0,0,0,0,0} }; +cmVS7FlagTable cmLocalVisualStudio7GeneratorFortranLinkFlagTable[] = +{ + {"LinkIncremental", "INCREMENTAL:NO", "link incremental", + "linkIncrementalNo", 0}, + {"LinkIncremental", "INCREMENTAL:YES", "link incremental", + "linkIncrementalYes", 0}, + {0,0,0,0,0} +}; + //---------------------------------------------------------------------------- // Helper class to write build event <Tool .../> elements. class cmLocalVisualStudio7Generator::EventWriter @@ -1056,8 +1065,13 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, extraLinkOptions += " "; extraLinkOptions += targetLinkFlags; } - Options linkOptions(this, Options::Linker, - cmLocalVisualStudio7GeneratorLinkFlagTable); + Options linkOptions(this, Options::Linker); + if(this->FortranProject) + { + linkOptions.AddTable(cmLocalVisualStudio7GeneratorFortranLinkFlagTable); + } + linkOptions.AddTable(cmLocalVisualStudio7GeneratorLinkFlagTable); + linkOptions.Parse(extraLinkOptions.c_str()); if(!this->ModuleDefinitionFile.empty()) { diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 9680d43..f01aa6b 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -95,10 +95,12 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmTarget& target, command.push_back("make_directory"); command.push_back(impDir); std::vector<std::string> no_output; + std::vector<std::string> no_byproducts; std::vector<std::string> no_depends; cmCustomCommandLines commands; commands.push_back(command); - pcc.reset(new cmCustomCommand(0, no_output, no_depends, commands, 0, 0)); + pcc.reset(new cmCustomCommand(0, no_output, no_byproducts, + no_depends, commands, 0, 0)); pcc->SetEscapeOldStyle(false); pcc->SetEscapeAllowMakeVars(true); return pcc; diff --git a/Source/cmMakeDepend.cxx b/Source/cmMakeDepend.cxx index 52832db..1499e57 100644 --- a/Source/cmMakeDepend.cxx +++ b/Source/cmMakeDepend.cxx @@ -329,9 +329,9 @@ std::string cmMakeDepend::FullPath(const char* fname, const char *extraPath) } path = path + fname; if(cmSystemTools::FileExists(path.c_str(), true) - && !cmSystemTools::FileIsDirectory(path.c_str())) + && !cmSystemTools::FileIsDirectory(path)) { - std::string fp = cmSystemTools::CollapseFullPath(path.c_str()); + std::string fp = cmSystemTools::CollapseFullPath(path); this->DirectoryToFileToPathMap[extraPath? extraPath: ""][fname] = fp; return fp; } @@ -346,9 +346,9 @@ std::string cmMakeDepend::FullPath(const char* fname, const char *extraPath) } path = path + fname; if(cmSystemTools::FileExists(path.c_str(), true) - && !cmSystemTools::FileIsDirectory(path.c_str())) + && !cmSystemTools::FileIsDirectory(path)) { - std::string fp = cmSystemTools::CollapseFullPath(path.c_str()); + std::string fp = cmSystemTools::CollapseFullPath(path); this->DirectoryToFileToPathMap[extraPath][fname] = fp; return fp; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 0bd1624..53fd56f 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -102,7 +102,6 @@ cmMakefile::cmMakefile(): Internal(new Internals) this->PreOrder = false; this->GeneratingBuildSystem = false; - this->NumLastMatches = 0; this->SuppressWatches = false; } @@ -153,7 +152,6 @@ cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals) this->ListFileStack = mf.ListFileStack; this->OutputToSource = mf.OutputToSource; - this->NumLastMatches = mf.NumLastMatches; this->SuppressWatches = mf.SuppressWatches; } @@ -171,6 +169,9 @@ void cmMakefile::Initialize() // Protect the directory-level policies. this->PushPolicyBarrier(); + // push empty loop block + this->PushLoopBlockBarrier(); + // By default the check is not done. It is enabled by // cmListFileCache in the top level if necessary. this->CheckCMP0000 = false; @@ -880,12 +881,14 @@ void cmMakefile::ConfigureFinalPass() //---------------------------------------------------------------------------- void cmMakefile::AddCustomCommandToTarget(const std::string& target, + const std::vector<std::string>& byproducts, const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type, const char* comment, const char* workingDir, - bool escapeOldStyle) const + bool escapeOldStyle, + bool uses_terminal) { // Find the target to which to add the custom command. cmTargets::iterator ti = this->Targets.find(target); @@ -935,12 +938,24 @@ cmMakefile::AddCustomCommandToTarget(const std::string& target, this->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } + + // Always create the byproduct sources and mark them generated. + for(std::vector<std::string>::const_iterator o = byproducts.begin(); + o != byproducts.end(); ++o) + { + if(cmSourceFile* out = this->GetOrCreateSource(*o, true)) + { + out->SetProperty("GENERATED", "1"); + } + } + // Add the command to the appropriate build step for the target. std::vector<std::string> no_output; - cmCustomCommand cc(this, no_output, depends, + cmCustomCommand cc(this, no_output, byproducts, depends, commandLines, comment, workingDir); cc.SetEscapeOldStyle(escapeOldStyle); cc.SetEscapeAllowMakeVars(true); + cc.SetUsesTerminal(uses_terminal); switch(type) { case cmTarget::PRE_BUILD: @@ -958,13 +973,15 @@ cmMakefile::AddCustomCommandToTarget(const std::string& target, //---------------------------------------------------------------------------- cmSourceFile* cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs, + const std::vector<std::string>& byproducts, const std::vector<std::string>& depends, const std::string& main_dependency, const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace, - bool escapeOldStyle) + bool escapeOldStyle, + bool uses_terminal) { // Make sure there is at least one output. if(outputs.empty()) @@ -1055,6 +1072,14 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs, out->SetProperty("GENERATED", "1"); } } + for(std::vector<std::string>::const_iterator o = byproducts.begin(); + o != byproducts.end(); ++o) + { + if(cmSourceFile* out = this->GetOrCreateSource(*o, true)) + { + out->SetProperty("GENERATED", "1"); + } + } // Attach the custom command to the file. if(file) @@ -1067,10 +1092,11 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs, } cmCustomCommand* cc = - new cmCustomCommand(this, outputs, depends2, commandLines, - comment, workingDir); + new cmCustomCommand(this, outputs, byproducts, depends2, + commandLines, comment, workingDir); cc->SetEscapeOldStyle(escapeOldStyle); cc->SetEscapeAllowMakeVars(true); + cc->SetUsesTerminal(uses_terminal); file->SetCustomCommand(cc); this->UpdateOutputToSourceMap(outputs, file); } @@ -1119,13 +1145,17 @@ cmMakefile::AddCustomCommandToOutput(const std::string& output, const char* comment, const char* workingDir, bool replace, - bool escapeOldStyle) + bool escapeOldStyle, + bool uses_terminal) { std::vector<std::string> outputs; outputs.push_back(output); - return this->AddCustomCommandToOutput(outputs, depends, main_dependency, + std::vector<std::string> no_byproducts; + return this->AddCustomCommandToOutput(outputs, no_byproducts, + depends, main_dependency, commandLines, comment, workingDir, - replace, escapeOldStyle); + replace, escapeOldStyle, + uses_terminal); } //---------------------------------------------------------------------------- @@ -1144,7 +1174,9 @@ cmMakefile::AddCustomCommandOldStyle(const std::string& target, // In the old-style signature if the source and target were the // same then it added a post-build rule to the target. Preserve // this behavior. - this->AddCustomCommandToTarget(target, depends, commandLines, + std::vector<std::string> no_byproducts; + this->AddCustomCommandToTarget(target, no_byproducts, + depends, commandLines, cmTarget::POST_BUILD, comment, 0); return; } @@ -1242,7 +1274,25 @@ cmMakefile::AddUtilityCommand(const std::string& utilityName, const char* workingDirectory, const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, - bool escapeOldStyle, const char* comment) + bool escapeOldStyle, const char* comment, + bool uses_terminal) +{ + std::vector<std::string> no_byproducts; + return this->AddUtilityCommand(utilityName, excludeFromAll, workingDirectory, + no_byproducts, depends, commandLines, + escapeOldStyle, comment, uses_terminal); +} + +//---------------------------------------------------------------------------- +cmTarget* +cmMakefile::AddUtilityCommand(const std::string& utilityName, + bool excludeFromAll, + const char* workingDirectory, + const std::vector<std::string>& byproducts, + const std::vector<std::string>& depends, + const cmCustomCommandLines& commandLines, + bool escapeOldStyle, const char* comment, + bool uses_terminal) { // Create a target instance for this utility. cmTarget* target = this->AddNewTarget(cmTarget::UTILITY, utilityName); @@ -1263,13 +1313,15 @@ cmMakefile::AddUtilityCommand(const std::string& utilityName, force += cmake::GetCMakeFilesDirectory(); force += "/"; force += utilityName; + std::vector<std::string> forced; + forced.push_back(force); std::string no_main_dependency = ""; bool no_replace = false; - this->AddCustomCommandToOutput(force, depends, - no_main_dependency, + this->AddCustomCommandToOutput(forced, byproducts, + depends, no_main_dependency, commandLines, comment, workingDirectory, no_replace, - escapeOldStyle); + escapeOldStyle, uses_terminal); cmSourceFile* sf = target->AddSourceCMP0049(force); // The output is not actually created so mark it symbolic. @@ -1282,6 +1334,16 @@ cmMakefile::AddUtilityCommand(const std::string& utilityName, cmSystemTools::Error("Could not get source file entry for ", force.c_str()); } + + // Always create the byproduct sources and mark them generated. + for(std::vector<std::string>::const_iterator o = byproducts.begin(); + o != byproducts.end(); ++o) + { + if(cmSourceFile* out = this->GetOrCreateSource(*o, true)) + { + out->SetProperty("GENERATED", "1"); + } + } } return target; } @@ -1832,7 +1894,7 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, { if(!cmSystemTools::IsOff(files[cc].c_str())) { - files[cc] = cmSystemTools::CollapseFullPath(files[cc].c_str()); + files[cc] = cmSystemTools::CollapseFullPath(files[cc]); } if ( cc > 0 ) { @@ -1937,11 +1999,11 @@ void cmMakefile::CheckForUnused(const char* reason, bt.push_back(lfc); } if (this->CheckSystemVars || - cmSystemTools::IsSubDirectory(path.c_str(), + cmSystemTools::IsSubDirectory(path, this->GetHomeDirectory()) || - (cmSystemTools::IsSubDirectory(path.c_str(), + (cmSystemTools::IsSubDirectory(path, this->GetHomeOutputDirectory()) && - !cmSystemTools::IsSubDirectory(path.c_str(), + !cmSystemTools::IsSubDirectory(path, cmake::GetCMakeFilesDirectory()))) { cmOStringStream msg; @@ -2878,7 +2940,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew( bt.push_back(lfc); msg << "uninitialized variable \'" << lookup << "\'"; this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, - msg.str().c_str(), bt); + msg.str(), bt); } } } @@ -3293,6 +3355,38 @@ void cmMakefile::PopFunctionBlockerBarrier(bool reportError) } //---------------------------------------------------------------------------- +void cmMakefile::PushLoopBlock() +{ + assert(!this->LoopBlockCounter.empty()); + this->LoopBlockCounter.top()++; +} + +void cmMakefile::PopLoopBlock() +{ + assert(!this->LoopBlockCounter.empty()); + assert(this->LoopBlockCounter.top() > 0); + this->LoopBlockCounter.top()--; +} + +void cmMakefile::PushLoopBlockBarrier() +{ + this->LoopBlockCounter.push(0); +} + +void cmMakefile::PopLoopBlockBarrier() +{ + assert(!this->LoopBlockCounter.empty()); + assert(this->LoopBlockCounter.top() == 0); + this->LoopBlockCounter.pop(); +} + +bool cmMakefile::IsLoopBlock() const +{ + assert(!this->LoopBlockCounter.empty()); + return !this->LoopBlockCounter.empty() && this->LoopBlockCounter.top() > 0; +} + +//---------------------------------------------------------------------------- bool cmMakefile::ExpandArguments( std::vector<cmListFileArgument> const& inArgs, std::vector<std::string>& outArgs) const @@ -3556,7 +3650,7 @@ int cmMakefile::TryCompile(const std::string& srcdir, { this->Internal->IsSourceFileTryCompile = fast; // does the binary directory exist ? If not create it... - if (!cmSystemTools::FileIsDirectory(bindir.c_str())) + if (!cmSystemTools::FileIsDirectory(bindir)) { cmSystemTools::MakeDirectory(bindir.c_str()); } @@ -3564,7 +3658,7 @@ int cmMakefile::TryCompile(const std::string& srcdir, // change to the tests directory and run cmake // use the cmake object instead of calling cmake std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(bindir.c_str()); + cmSystemTools::ChangeDirectory(bindir); // make sure the same generator is used // use this program as the cmake to be run, it should not @@ -3579,7 +3673,7 @@ int cmMakefile::TryCompile(const std::string& srcdir, cmSystemTools::Error( "Internal CMake error, TryCompile bad GlobalGenerator"); // return to the original directory - cmSystemTools::ChangeDirectory(cwd.c_str()); + cmSystemTools::ChangeDirectory(cwd); this->Internal->IsSourceFileTryCompile = false; return 1; } @@ -3653,7 +3747,7 @@ int cmMakefile::TryCompile(const std::string& srcdir, cmSystemTools::Error( "Internal CMake error, TryCompile configure of cmake failed"); // return to the original directory - cmSystemTools::ChangeDirectory(cwd.c_str()); + cmSystemTools::ChangeDirectory(cwd); this->Internal->IsSourceFileTryCompile = false; return 1; } @@ -3663,7 +3757,7 @@ int cmMakefile::TryCompile(const std::string& srcdir, cmSystemTools::Error( "Internal CMake error, TryCompile generation of cmake failed"); // return to the original directory - cmSystemTools::ChangeDirectory(cwd.c_str()); + cmSystemTools::ChangeDirectory(cwd); this->Internal->IsSourceFileTryCompile = false; return 1; } @@ -3677,7 +3771,7 @@ int cmMakefile::TryCompile(const std::string& srcdir, output, this); - cmSystemTools::ChangeDirectory(cwd.c_str()); + cmSystemTools::ChangeDirectory(cwd); this->Internal->IsSourceFileTryCompile = false; return ret; } @@ -4036,7 +4130,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, { cmSystemTools::SetPermissions(soutfile.c_str(), perm); } - cmSystemTools::RemoveFile(tempOutputFile.c_str()); + cmSystemTools::RemoveFile(tempOutputFile); } return res; } @@ -4426,10 +4520,14 @@ void cmMakefile::PushScope() this->Internal->VarStack.push(cmDefinitions(parent)); this->Internal->VarInitStack.push(init); this->Internal->VarUsageStack.push(usage); + + this->PushLoopBlockBarrier(); } void cmMakefile::PopScope() { + this->PopLoopBlockBarrier(); + cmDefinitions* current = &this->Internal->VarStack.top(); std::set<std::string> init = this->Internal->VarInitStack.top(); std::set<std::string> usage = this->Internal->VarUsageStack.top(); @@ -4743,51 +4841,6 @@ std::vector<cmSourceFile*> cmMakefile::GetQtUiFilesWithOptions() const return this->QtUiFilesWithOptions; } -static std::string matchVariables[] = { - "CMAKE_MATCH_0", - "CMAKE_MATCH_1", - "CMAKE_MATCH_2", - "CMAKE_MATCH_3", - "CMAKE_MATCH_4", - "CMAKE_MATCH_5", - "CMAKE_MATCH_6", - "CMAKE_MATCH_7", - "CMAKE_MATCH_8", - "CMAKE_MATCH_9" -}; - -//---------------------------------------------------------------------------- -void cmMakefile::ClearMatches() -{ - for (unsigned int i=0; i<this->NumLastMatches; i++) - { - std::string const& var = matchVariables[i]; - std::string const& s = this->GetSafeDefinition(var); - if(!s.empty()) - { - this->AddDefinition(var, ""); - this->MarkVariableAsUsed(var); - } - } - this->NumLastMatches = 0; -} - -//---------------------------------------------------------------------------- -void cmMakefile::StoreMatches(cmsys::RegularExpression& re) -{ - for (unsigned int i=0; i<10; i++) - { - std::string const& m = re.match(i); - if(!m.empty()) - { - std::string const& var = matchVariables[i]; - this->AddDefinition(var, m.c_str()); - this->MarkVariableAsUsed(var); - this->NumLastMatches = i + 1; - } - } -} - //---------------------------------------------------------------------------- cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const @@ -5208,7 +5261,7 @@ HaveCFeatureAvailable(cmTarget const* target, const std::string& feature) const cmOStringStream e; e << "The C_STANDARD property on target \"" << target->GetName() << "\" contained an invalid value: \"" << existingCStandard << "\"."; - this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->IssueMessage(cmake::FATAL_ERROR, e.str()); return false; } @@ -5459,7 +5512,7 @@ AddRequiredTargetCFeature(cmTarget *target, const std::string& feature) const cmOStringStream e; e << "The C_STANDARD property on target \"" << target->GetName() << "\" contained an invalid value: \"" << existingCStandard << "\"."; - this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + this->IssueMessage(cmake::FATAL_ERROR, e.str()); return false; } } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 164290a..05b7a37 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -34,6 +34,8 @@ # include <cmsys/hash_map.hxx> #endif +#include <stack> + class cmFunctionBlocker; class cmCommand; class cmInstallGenerator; @@ -123,6 +125,15 @@ public: }; friend class LexicalPushPop; + class LoopBlockPop + { + public: + LoopBlockPop(cmMakefile* mf) { this->Makefile = mf; } + ~LoopBlockPop() { this->Makefile->PopLoopBlock(); } + private: + cmMakefile* Makefile; + }; + /** * Try running cmake and building a file. This is used for dynalically * loaded commands, not as part of the usual build process. @@ -170,19 +181,23 @@ public: /** Add a custom command to the build. */ void AddCustomCommandToTarget(const std::string& target, + const std::vector<std::string>& byproducts, const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type, const char* comment, const char* workingDir, - bool escapeOldStyle = true) const; + bool escapeOldStyle = true, + bool uses_terminal = false); cmSourceFile* AddCustomCommandToOutput( const std::vector<std::string>& outputs, + const std::vector<std::string>& byproducts, const std::vector<std::string>& depends, const std::string& main_dependency, const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace = false, - bool escapeOldStyle = true); + bool escapeOldStyle = true, + bool uses_terminal = false); cmSourceFile* AddCustomCommandToOutput( const std::string& output, const std::vector<std::string>& depends, @@ -190,7 +205,8 @@ public: const cmCustomCommandLines& commandLines, const char* comment, const char* workingDir, bool replace = false, - bool escapeOldStyle = true); + bool escapeOldStyle = true, + bool uses_terminal = false); void AddCustomCommandOldStyle(const std::string& target, const std::vector<std::string>& outputs, const std::vector<std::string>& depends, @@ -237,7 +253,17 @@ public: const std::vector<std::string>& depends, const cmCustomCommandLines& commandLines, bool escapeOldStyle = true, - const char* comment = 0); + const char* comment = 0, + bool uses_terminal = false); + cmTarget* AddUtilityCommand(const std::string& utilityName, + bool excludeFromAll, + const char* workingDirectory, + const std::vector<std::string>& byproducts, + const std::vector<std::string>& depends, + const cmCustomCommandLines& commandLines, + bool escapeOldStyle = true, + const char* comment = 0, + bool uses_terminal = false); /** * Add a link library to the build. @@ -466,7 +492,7 @@ public: this->cmStartDirectory = dir; cmSystemTools::ConvertToUnixSlashes(this->cmStartDirectory); this->cmStartDirectory = - cmSystemTools::CollapseFullPath(this->cmStartDirectory.c_str()); + cmSystemTools::CollapseFullPath(this->cmStartDirectory); this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", this->cmStartDirectory.c_str()); } @@ -479,7 +505,7 @@ public: this->StartOutputDirectory = lib; cmSystemTools::ConvertToUnixSlashes(this->StartOutputDirectory); this->StartOutputDirectory = - cmSystemTools::CollapseFullPath(this->StartOutputDirectory.c_str()); + cmSystemTools::CollapseFullPath(this->StartOutputDirectory); cmSystemTools::MakeDirectory(this->StartOutputDirectory.c_str()); this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", this->StartOutputDirectory.c_str()); @@ -885,6 +911,10 @@ public: void PopScope(); void RaiseScope(const std::string& var, const char *value); + // push and pop loop scopes + void PushLoopBlockBarrier(); + void PopLoopBlockBarrier(); + /** Helper class to push and pop scopes automatically. */ class ScopePushPop { @@ -942,8 +972,9 @@ public: std::string const& lhs, std::string const& rhs); - void ClearMatches(); - void StoreMatches(cmsys::RegularExpression& re); + void PushLoopBlock(); + void PopLoopBlock(); + bool IsLoopBlock() const; protected: // add link libraries and directories to the target @@ -1039,6 +1070,8 @@ private: void PushFunctionBlockerBarrier(); void PopFunctionBlockerBarrier(bool reportError = true); + std::stack<int> LoopBlockCounter; + typedef std::map<std::string, std::string> StringStringMap; StringStringMap MacrosMap; @@ -1150,8 +1183,6 @@ private: std::vector<cmSourceFile*> QtUiFilesWithOptions; - unsigned int NumLastMatches; - bool AddRequiredTargetCFeature(cmTarget *target, const std::string& feature) const; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 1f8f686..1e01f11 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -702,7 +702,14 @@ cmMakefileTargetGenerator vars.Defines = definesString.c_str(); - bool lang_is_c_or_cxx = ((lang == "C") || (lang == "CXX")); + // At the moment, it is assumed that C, C++, and Fortran have both + // assembly and preprocessor capabilities. The same is true for the + // ability to export compile commands + bool lang_has_preprocessor = ((lang == "C") || + (lang == "CXX") || + (lang == "Fortran")); + bool const lang_has_assembly = lang_has_preprocessor; + bool const lang_can_export_cmds = lang_has_preprocessor; // Construct the compile rules. { @@ -715,7 +722,7 @@ cmMakefileTargetGenerator cmSystemTools::ExpandListArgument(compileRule, compileCommands); if (this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS") && - lang_is_c_or_cxx && compileCommands.size() == 1) + lang_can_export_cmds && compileCommands.size() == 1) { std::string compileCommand = compileCommands[0]; this->LocalGenerator->ExpandRuleVariables(compileCommand, vars); @@ -771,9 +778,9 @@ cmMakefileTargetGenerator } } - bool do_preprocess_rules = lang_is_c_or_cxx && + bool do_preprocess_rules = lang_has_preprocessor && this->LocalGenerator->GetCreatePreprocessedSourceRules(); - bool do_assembly_rules = lang_is_c_or_cxx && + bool do_assembly_rules = lang_has_assembly && this->LocalGenerator->GetCreateAssemblySourceRules(); if(do_preprocess_rules || do_assembly_rules) { @@ -1577,7 +1584,7 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags(std::string const& l) { std::string frameworkDir = *i; frameworkDir += "/../"; - frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str()); + frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir); emitted.insert(frameworkDir); } } diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index e344df4..25931f3 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -194,12 +194,7 @@ cmNinjaNormalTargetGenerator vars.ObjectDir = "$OBJECT_DIR"; - // TODO: - // Makefile generator expands <TARGET> to the plain target name - // with suffix. $out expands to a relative path. This difference - // could make trouble when switching to Ninja generator. Maybe - // using TARGET_NAME and RuleVariables::TargetName is a fix. - vars.Target = "$out"; + vars.Target = "$TARGET_FILE"; vars.SONameFlag = "$SONAME_FLAG"; vars.TargetSOName = "$SONAME"; @@ -252,7 +247,7 @@ cmNinjaNormalTargetGenerator << this->GetVisibleTypeName() << "."; cmOStringStream description; description << "Linking " << this->TargetLinkLanguage << " " - << this->GetVisibleTypeName() << " $out"; + << this->GetVisibleTypeName() << " $TARGET_FILE"; this->GetGlobalGenerator()->AddRule(ruleName, linkCmd, description.str(), @@ -261,7 +256,7 @@ cmNinjaNormalTargetGenerator /*deptype*/ "", rspfile, rspcontent, - /*restat*/ false, + /*restat*/ "$RESTAT", /*generator*/ false); } @@ -283,7 +278,7 @@ cmNinjaNormalTargetGenerator /*deptype*/ "", /*rspfile*/ "", /*rspcontent*/ "", - /*restat*/ false, + /*restat*/ "", /*generator*/ false); else this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_LIBRARY", @@ -297,7 +292,7 @@ cmNinjaNormalTargetGenerator /*deptype*/ "", /*rspfile*/ "", /*rspcontent*/ "", - /*restat*/ false, + /*restat*/ "", /*generator*/ false); } } @@ -326,7 +321,7 @@ cmNinjaNormalTargetGenerator this->GetLocalGenerator()->ConvertToOutputFormat( mf->GetRequiredDefinition("CMAKE_COMMAND"), cmLocalGenerator::SHELL); - linkCmds.push_back(cmakeCommand + " -E remove $out"); + linkCmds.push_back(cmakeCommand + " -E remove $TARGET_FILE"); } // TODO: Use ARCHIVE_APPEND for archives over a certain size. { @@ -375,14 +370,14 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() cmTarget& target = *this->GetTarget(); const std::string cfgName = this->GetConfigName(); std::string targetOutput = ConvertToNinjaPath( - target.GetFullPath(cfgName).c_str()); + target.GetFullPath(cfgName)); std::string targetOutputReal = ConvertToNinjaPath( target.GetFullPath(cfgName, /*implib=*/false, - /*realpath=*/true).c_str()); + /*realpath=*/true)); std::string targetOutputImplib = ConvertToNinjaPath( target.GetFullPath(cfgName, - /*implib=*/true).c_str()); + /*implib=*/true)); if (target.IsAppBundleOnApple()) { @@ -394,11 +389,11 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() targetOutput = outpath; targetOutput += "/"; targetOutput += this->TargetNameOut; - targetOutput = this->ConvertToNinjaPath(targetOutput.c_str()); + targetOutput = this->ConvertToNinjaPath(targetOutput); targetOutputReal = outpath; targetOutputReal += "/"; targetOutputReal += this->TargetNameReal; - targetOutputReal = this->ConvertToNinjaPath(targetOutputReal.c_str()); + targetOutputReal = this->ConvertToNinjaPath(targetOutputReal); } else if (target.IsFrameworkOnApple()) { @@ -450,6 +445,10 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() this->GetConfigName()); bool useWatcomQuote = mf->IsOn(createRule+"_USE_WATCOM_QUOTE"); cmLocalNinjaGenerator& localGen = *this->GetLocalGenerator(); + + vars["TARGET_FILE"] = + localGen.ConvertToOutputFormat(targetOutputReal, cmLocalGenerator::SHELL); + localGen.GetTargetFlags(vars["LINK_LIBRARIES"], vars["FLAGS"], vars["LINK_FLAGS"], @@ -509,6 +508,10 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() cmLocalGenerator::SHELL); vars["TARGET_IMPLIB"] = impLibPath; EnsureParentDirectoryExists(impLibPath); + if(target.HasImportLibrary()) + { + outputs.push_back(targetOutputImplib); + } } if (!this->SetMsvcTargetPdbVariable(vars)) @@ -531,7 +534,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() if (mf->IsOn("CMAKE_COMPILER_IS_MINGW")) { const std::string objPath = GetTarget()->GetSupportDirectory(); - vars["OBJECT_DIR"] = ConvertToNinjaPath(objPath.c_str()); + vars["OBJECT_DIR"] = ConvertToNinjaPath(objPath); EnsureDirectoryExists(objPath); // ar.exe can't handle backslashes in rsp files (implicitly used by gcc) std::string& linkLibraries = vars["LINK_LIBRARIES"]; @@ -553,6 +556,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() &postBuildCmdLines }; + cmNinjaDeps byproducts; for (unsigned i = 0; i != 3; ++i) { for (std::vector<cmCustomCommand>::const_iterator @@ -561,6 +565,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() { cmCustomCommandGenerator ccg(*ci, cfgName, mf); localGen.AppendCustomCommandLines(ccg, *cmdLineLists[i]); + std::vector<std::string> const& ccByproducts = ccg.GetByproducts(); + std::transform(ccByproducts.begin(), ccByproducts.end(), + std::back_inserter(byproducts), MapToNinjaPath()); } } @@ -608,6 +615,17 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() this->GetLocalGenerator()->AppendTargetDepends(this->GetTarget(), orderOnlyDeps); + // Ninja should restat after linking if and only if there are byproducts. + vars["RESTAT"] = byproducts.empty()? "" : "1"; + + for (cmNinjaDeps::const_iterator oi = byproducts.begin(), + oe = byproducts.end(); + oi != oe; ++oi) + { + this->GetGlobalGenerator()->SeenCustomCommandOutput(*oi); + outputs.push_back(*oi); + } + // Write the build statement for this target. globalGen.WriteBuild(this->GetBuildFileStream(), comment.str(), @@ -659,16 +677,6 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } } - if (!this->TargetNameImport.empty()) - { - // Since using multiple outputs would mess up the $out variable, use an - // alias for the import library. - globalGen.WritePhonyBuild(this->GetBuildFileStream(), - "Alias for import library.", - cmNinjaDeps(1, targetOutputImplib), - cmNinjaDeps(1, targetOutputReal)); - } - // Add aliases for the file name and the target name. globalGen.AddTargetAlias(this->TargetNameOut, &target); globalGen.AddTargetAlias(this->GetTargetName(), &target); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 816e6d8..7967762 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -277,7 +277,7 @@ std::string cmNinjaTargetGenerator ::GetSourceFilePath(cmSourceFile const* source) const { - return ConvertToNinjaPath(source->GetFullPath().c_str()); + return ConvertToNinjaPath(source->GetFullPath()); } std::string @@ -298,7 +298,7 @@ cmNinjaTargetGenerator std::string cmNinjaTargetGenerator::GetTargetOutputDir() const { std::string dir = this->Target->GetDirectory(this->GetConfigName()); - return ConvertToNinjaPath(dir.c_str()); + return ConvertToNinjaPath(dir); } std::string @@ -346,11 +346,11 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const } vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat( - ConvertToNinjaPath(pdbPath.c_str()), + ConvertToNinjaPath(pdbPath), cmLocalGenerator::SHELL); vars["TARGET_COMPILE_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat( - ConvertToNinjaPath(compilePdbPath.c_str()), + ConvertToNinjaPath(compilePdbPath), cmLocalGenerator::SHELL); EnsureParentDirectoryExists(pdbPath); @@ -477,7 +477,7 @@ cmNinjaTargetGenerator deptype, /*rspfile*/ "", /*rspcontent*/ "", - /*restat*/ false, + /*restat*/ "", /*generator*/ false); } @@ -538,8 +538,11 @@ cmNinjaTargetGenerator cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->GetMakefile()); const std::vector<std::string>& ccoutputs = ccg.GetOutputs(); + const std::vector<std::string>& ccbyproducts= ccg.GetByproducts(); std::transform(ccoutputs.begin(), ccoutputs.end(), std::back_inserter(orderOnlyDeps), MapToNinjaPath()); + std::transform(ccbyproducts.begin(), ccbyproducts.end(), + std::back_inserter(orderOnlyDeps), MapToNinjaPath()); } if (!orderOnlyDeps.empty()) @@ -564,7 +567,7 @@ cmNinjaTargetGenerator std::string def = this->GeneratorTarget->GetModuleDefinitionFile(config); if(!def.empty()) { - this->ModuleDefinitionFile = this->ConvertToNinjaPath(def.c_str()); + this->ModuleDefinitionFile = this->ConvertToNinjaPath(def); } this->GetBuildFileStream() << "\n"; @@ -628,11 +631,11 @@ cmNinjaTargetGenerator std::string objectDir = this->Target->GetSupportDirectory(); vars["OBJECT_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat( - ConvertToNinjaPath(objectDir.c_str()), + ConvertToNinjaPath(objectDir), cmLocalGenerator::SHELL); std::string objectFileDir = cmSystemTools::GetFilenamePath(objectFileName); vars["OBJECT_FILE_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat( - ConvertToNinjaPath(objectFileDir.c_str()), + ConvertToNinjaPath(objectFileDir), cmLocalGenerator::SHELL); this->addPoolNinjaVariable("JOB_POOL_COMPILE", this->GetTarget(), vars); @@ -650,7 +653,7 @@ cmNinjaTargetGenerator if (!cmSystemTools::FileIsFullPath(sourceFileName.c_str())) { escapedSourceFileName = cmSystemTools::CollapseFullPath( - escapedSourceFileName.c_str(), + escapedSourceFileName, this->GetGlobalGenerator()->GetCMakeInstance()-> GetHomeOutputDirectory()); } @@ -754,7 +757,7 @@ void cmNinjaTargetGenerator ::EnsureParentDirectoryExists(const std::string& path) const { - EnsureDirectoryExists(cmSystemTools::GetParentDirectory(path.c_str())); + EnsureDirectoryExists(cmSystemTools::GetParentDirectory(path)); } @@ -775,14 +778,14 @@ cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()( // Get the input file location. std::string input = source.GetFullPath(); input = - this->Generator->GetLocalGenerator()->ConvertToNinjaPath(input.c_str()); + this->Generator->GetLocalGenerator()->ConvertToNinjaPath(input); // Get the output file location. std::string output = macdir; output += "/"; output += cmSystemTools::GetFilenameName(input); output = - this->Generator->GetLocalGenerator()->ConvertToNinjaPath(output.c_str()); + this->Generator->GetLocalGenerator()->ConvertToNinjaPath(output); // Write a build statement to copy the content into the bundle. this->Generator->GetGlobalGenerator()->WriteMacOSXContentBuild(input, diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 40a15a3..17cf517 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -116,7 +116,6 @@ protected: void WriteObjectBuildStatements(); void WriteObjectBuildStatement(cmSourceFile const* source, bool writeOrderDependsTargetForTarget); - void WriteCustomCommandBuildStatement(cmCustomCommand *cc); cmNinjaDeps GetObjects() const { return this->Objects; } diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index f5d18dc..42d6b46 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -27,14 +27,19 @@ cmNinjaUtilityTargetGenerator::~cmNinjaUtilityTargetGenerator() {} void cmNinjaUtilityTargetGenerator::Generate() { + std::string utilCommandName = cmake::GetCMakeFilesDirectoryPostSlash(); + utilCommandName += this->GetTargetName() + ".util"; + std::vector<std::string> commands; - cmNinjaDeps deps, outputs; + cmNinjaDeps deps, outputs, util_outputs(1, utilCommandName); const std::vector<cmCustomCommand> *cmdLists[2] = { &this->GetTarget()->GetPreBuildCommands(), &this->GetTarget()->GetPostBuildCommands() }; + bool uses_terminal = false; + for (unsigned i = 0; i != 2; ++i) { for (std::vector<cmCustomCommand>::const_iterator ci = cmdLists[i]->begin(); ci != cmdLists[i]->end(); ++ci) { @@ -42,6 +47,11 @@ void cmNinjaUtilityTargetGenerator::Generate() this->GetMakefile()); this->GetLocalGenerator()->AppendCustomCommandDeps(ccg, deps); this->GetLocalGenerator()->AppendCustomCommandLines(ccg, commands); + std::vector<std::string> const& ccByproducts = ccg.GetByproducts(); + std::transform(ccByproducts.begin(), ccByproducts.end(), + std::back_inserter(util_outputs), MapToNinjaPath()); + if (ci->GetUsesTerminal()) + uses_terminal = true; } } @@ -60,8 +70,11 @@ void cmNinjaUtilityTargetGenerator::Generate() // Depend on all custom command outputs. const std::vector<std::string>& ccOutputs = ccg.GetOutputs(); + const std::vector<std::string>& ccByproducts = ccg.GetByproducts(); std::transform(ccOutputs.begin(), ccOutputs.end(), std::back_inserter(deps), MapToNinjaPath()); + std::transform(ccByproducts.begin(), ccByproducts.end(), + std::back_inserter(deps), MapToNinjaPath()); } } @@ -103,14 +116,19 @@ void cmNinjaUtilityTargetGenerator::Generate() if (command.find('$') != std::string::npos) return; - std::string utilCommandName = cmake::GetCMakeFilesDirectoryPostSlash(); - utilCommandName += this->GetTargetName() + ".util"; + for (cmNinjaDeps::const_iterator + oi = util_outputs.begin(), oe = util_outputs.end(); + oi != oe; ++oi) + { + this->GetGlobalGenerator()->SeenCustomCommandOutput(*oi); + } this->GetGlobalGenerator()->WriteCustomCommandBuild( command, desc, "Utility command for " + this->GetTargetName(), - cmNinjaDeps(1, utilCommandName), + uses_terminal, + util_outputs, deps); this->GetGlobalGenerator()->WritePhonyBuild(this->GetBuildFileStream(), diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 786e6e2..55e20ab 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -112,8 +112,8 @@ void cmOSXBundleGenerator::CreateFramework( oldName = frameworkVersion; newName = versions; newName += "/Current"; - cmSystemTools::RemoveFile(newName.c_str()); - cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str()); + cmSystemTools::RemoveFile(newName); + cmSystemTools::CreateSymlink(oldName, newName); this->Makefile->AddCMakeOutputFile(newName); // foo -> Versions/Current/foo @@ -121,8 +121,8 @@ void cmOSXBundleGenerator::CreateFramework( oldName += name; newName = contentdir; newName += name; - cmSystemTools::RemoveFile(newName.c_str()); - cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str()); + cmSystemTools::RemoveFile(newName); + cmSystemTools::CreateSymlink(oldName, newName); this->Makefile->AddCMakeOutputFile(newName); // Resources -> Versions/Current/Resources @@ -132,8 +132,8 @@ void cmOSXBundleGenerator::CreateFramework( oldName = "Versions/Current/Resources"; newName = contentdir; newName += "Resources"; - cmSystemTools::RemoveFile(newName.c_str()); - cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str()); + cmSystemTools::RemoveFile(newName); + cmSystemTools::CreateSymlink(oldName, newName); this->Makefile->AddCMakeOutputFile(newName); } @@ -144,8 +144,8 @@ void cmOSXBundleGenerator::CreateFramework( oldName = "Versions/Current/Headers"; newName = contentdir; newName += "Headers"; - cmSystemTools::RemoveFile(newName.c_str()); - cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str()); + cmSystemTools::RemoveFile(newName); + cmSystemTools::CreateSymlink(oldName, newName); this->Makefile->AddCMakeOutputFile(newName); } @@ -156,8 +156,8 @@ void cmOSXBundleGenerator::CreateFramework( oldName = "Versions/Current/PrivateHeaders"; newName = contentdir; newName += "PrivateHeaders"; - cmSystemTools::RemoveFile(newName.c_str()); - cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str()); + cmSystemTools::RemoveFile(newName); + cmSystemTools::CreateSymlink(oldName, newName); this->Makefile->AddCMakeOutputFile(newName); } } diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index 007364c..3cdd2f6 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -140,7 +140,7 @@ bool cmOrderDirectoriesConstraint::FileMayConflict(std::string const& dir, { // The file conflicts only if it is not the same as the original // file due to a symlink or hardlink. - return !cmSystemTools::SameFile(this->FullPath.c_str(), file.c_str()); + return !cmSystemTools::SameFile(this->FullPath, file); } // Check if the file will be built by cmake. diff --git a/Source/cmPathLabel.cxx b/Source/cmPathLabel.cxx new file mode 100644 index 0000000..67d56e1 --- /dev/null +++ b/Source/cmPathLabel.cxx @@ -0,0 +1,41 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#include "cmPathLabel.h" + +//---------------------------------------------------------------------------- +cmPathLabel::cmPathLabel(const std::string& label) +: Label(label), Hash(0) +{ + // Use a Jenkins one-at-a-time hash with under/over-flow protection + for(size_t i = 0; i < this->Label.size(); ++i) + { + this->Hash += this->Label[i]; + this->Hash += ((this->Hash & 0x003FFFFF) << 10); + this->Hash ^= ((this->Hash & 0xFFFFFFC0) >> 6); + } + this->Hash += ((this->Hash & 0x1FFFFFFF) << 3); + this->Hash ^= ((this->Hash & 0xFFFFF800) >> 11); + this->Hash += ((this->Hash & 0x0001FFFF) << 15); +} + +//---------------------------------------------------------------------------- +bool cmPathLabel::operator < (const cmPathLabel& l) const +{ + return this->Hash < l.Hash; +} + +//---------------------------------------------------------------------------- +bool cmPathLabel::operator == (const cmPathLabel& l) const +{ + return this->Hash == l.Hash; +} diff --git a/Source/cmPathLabel.h b/Source/cmPathLabel.h new file mode 100644 index 0000000..02d5261 --- /dev/null +++ b/Source/cmPathLabel.h @@ -0,0 +1,44 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmPathLabel_h +#define cmPathLabel_h + +#include "cmStandardIncludes.h" + +/** \class cmPathLabel + * \brief Helper class for text based labels + * + * cmPathLabel is extended in different classes to act as an inheritable + * enum. Comparisons are done on a precomputed Jenkins hash of the string + * label for indexing and searchig. + */ +class cmPathLabel +{ +public: + cmPathLabel(const std::string& label); + + // The comparison operators are only for quick sorting and searching and + // in no way imply any lexicographical order of the label + bool operator < (const cmPathLabel& l) const; + bool operator == (const cmPathLabel& l) const; + + const std::string& GetLabel() const { return this->Label; } + const unsigned int& GetHash() const { return this->Hash; } + +protected: + cmPathLabel(); + + std::string Label; + unsigned int Hash; +}; + +#endif diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index a420f59..64b87b7 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -364,6 +364,11 @@ cmPolicies::cmPolicies() CMP0054, "CMP0054", "Only interpret if() arguments as variables or keywords when unquoted.", 3,1,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0055, "CMP0055", + "Strict checking for break() command.", + 3,2,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 7c73da8..46ecc22 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -111,6 +111,7 @@ public: CMP0053, ///< Simplify variable reference and escape sequence evaluation CMP0054, ///< Only interpret if() arguments as variables /// or keywords when unquoted. + CMP0055, ///< Strict checking for break() command. /** \brief Always the last entry. * diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 93ebde6..0c38366 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -166,6 +166,112 @@ static std::string getAutogenTargetDir(cmTarget const* target) return targetDir; } +std::string cmQtAutoGenerators::ListQt5RccInputs(cmSourceFile* sf, + cmTarget const* target, + std::vector<std::string>& depends) +{ + std::string rccCommand = this->GetRccExecutable(target); + std::vector<std::string> qrcEntries; + + std::vector<std::string> command; + command.push_back(rccCommand); + command.push_back("--list"); + + std::string absFile = cmsys::SystemTools::GetRealPath( + sf->GetFullPath()); + + command.push_back(absFile); + + std::string output; + int retVal = 0; + bool result = cmSystemTools::RunSingleCommand(command, &output, + &retVal, 0, + cmSystemTools::OUTPUT_NONE); + if (!result || retVal) + { + std::cerr << "AUTOGEN: error: Rcc list process for " << sf->GetFullPath() + << " failed:\n" << output << std::endl; + return std::string(); + } + + std::istringstream ostr(output); + std::string oline; + while(std::getline(ostr, oline)) + { + if (oline.empty()) + { + // The output of rcc --list contains many empty lines. + continue; + } + if (cmHasLiteralPrefix(oline, "RCC: Error in")) + { + static std::string searchString = "Cannot find file '"; + + std::string::size_type pos = oline.find(searchString); + if (pos == std::string::npos) + { + std::cerr << "AUTOGEN: error: Rcc lists unparsable output " + << oline << std::endl; + return std::string(); + } + pos += searchString.length(); + std::string::size_type sz = oline.size() - pos - 1; + qrcEntries.push_back(oline.substr(pos, sz)); + } + else + { + qrcEntries.push_back(oline); + } + } + depends.insert(depends.end(), qrcEntries.begin(), qrcEntries.end()); + std::string entriesList; + const char* sep = ""; + for(std::vector<std::string>::const_iterator it = qrcEntries.begin(); + it != qrcEntries.end(); ++it) + { + entriesList += sep; + entriesList += *it; + sep = "@list_sep@"; + } + return entriesList; +} + +std::string cmQtAutoGenerators::ListQt4RccInputs(cmSourceFile* sf, + std::vector<std::string>& depends) +{ + const std::string qrcContents = ReadAll(sf->GetFullPath()); + + cmsys::RegularExpression fileMatchRegex("(<file[^<]+)"); + + std::string entriesList; + const char* sep = ""; + + size_t offset = 0; + while (fileMatchRegex.find(qrcContents.c_str() + offset)) + { + std::string qrcEntry = fileMatchRegex.match(1); + + offset += qrcEntry.size(); + + cmsys::RegularExpression fileReplaceRegex("(^<file[^>]*>)"); + fileReplaceRegex.find(qrcEntry); + std::string tag = fileReplaceRegex.match(1); + + qrcEntry = qrcEntry.substr(tag.size()); + + if (!cmSystemTools::FileIsFullPath(qrcEntry.c_str())) + { + qrcEntry = sf->GetLocation().GetDirectory() + "/" + qrcEntry; + } + + entriesList += sep; + entriesList += qrcEntry; + sep = "@list_sep@"; + depends.push_back(qrcEntry); + } + return entriesList; +} + bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) { cmMakefile* makefile = target->GetMakefile(); @@ -271,13 +377,69 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) } } } +#endif + + std::vector<std::string> rcc_output; + if(makefile->GetLocalGenerator()->GetGlobalGenerator()->GetName() == "Ninja" +#if defined(_WIN32) && !defined(__CYGWIN__) + || usePRE_BUILD +#endif + ) + { + std::vector<cmSourceFile*> srcFiles; + target->GetConfigCommonSourceFiles(srcFiles); + for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); + fileIt != srcFiles.end(); + ++fileIt) + { + cmSourceFile* sf = *fileIt; + std::string absFile = cmsys::SystemTools::GetRealPath( + sf->GetFullPath()); + + std::string ext = sf->GetExtension(); + + if (target->GetPropertyAsBool("AUTORCC")) + { + if (ext == "qrc" + && !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC"))) + { + std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(absFile); + + std::string rcc_output_dir = target->GetSupportDirectory(); + cmSystemTools::MakeDirectory(rcc_output_dir.c_str()); + std::string rcc_output_file = rcc_output_dir; + rcc_output_file += "/qrc_" + basename + ".cpp"; + rcc_output.push_back(rcc_output_file); + + if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) + { + if (qtMajorVersion == "5") + { + this->ListQt5RccInputs(sf, target, depends); + } + else + { + this->ListQt4RccInputs(sf, depends); + } +#if defined(_WIN32) && !defined(__CYGWIN__) + usePRE_BUILD = false; +#endif + } + } + } + } + } + +#if defined(_WIN32) && !defined(__CYGWIN__) if(usePRE_BUILD) { // Add the pre-build command directly to bypass the OBJECT_LIBRARY // rejection in cmMakefile::AddCustomCommandToTarget because we know // PRE_BUILD will work for an OBJECT_LIBRARY in this specific case. std::vector<std::string> no_output; - cmCustomCommand cc(makefile, no_output, depends, + std::vector<std::string> no_byproducts; + cmCustomCommand cc(makefile, no_output, no_byproducts, depends, commandLines, autogenComment.c_str(), workingDirectory.c_str()); cc.SetEscapeOldStyle(false); @@ -287,10 +449,31 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) else #endif { - cmTarget* autogenTarget = makefile->AddUtilityCommand( + cmTarget* autogenTarget = 0; + if (!rcc_output.empty()) + { + std::vector<std::string> no_byproducts; + makefile->AddCustomCommandToOutput(rcc_output, no_byproducts, + depends, "", + commandLines, 0, + workingDirectory.c_str(), + false, false); + + cmCustomCommandLines no_commands; + autogenTarget = makefile->AddUtilityCommand( + autogenTargetName, true, + workingDirectory.c_str(), rcc_output, + no_commands, false, autogenComment.c_str()); + + } + else + { + autogenTarget = makefile->AddUtilityCommand( autogenTargetName, true, workingDirectory.c_str(), depends, commandLines, false, autogenComment.c_str()); + } + // Set target folder const char* autogenFolder = makefile->GetCMakeInstance()->GetProperty( "AUTOMOC_TARGETS_FOLDER"); @@ -418,6 +601,8 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) inputFile += "/Modules/AutogenInfo.cmake.in"; std::string outputFile = targetDir; outputFile += "/AutogenInfo.cmake"; + makefile->AddDefinition("_qt_rcc_inputs", + makefile->GetDefinition("_qt_rcc_inputs_" + target->GetName())); makefile->ConfigureFile(inputFile.c_str(), outputFile.c_str(), false, true, false); @@ -488,7 +673,7 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target) { cmSourceFile* sf = *fileIt; std::string absFile = cmsys::SystemTools::GetRealPath( - sf->GetFullPath().c_str()); + sf->GetFullPath()); bool skipMoc = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC")); bool generated = cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED")); @@ -766,7 +951,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, { cmSourceFile* sf = *fileIt; std::string absFile = cmsys::SystemTools::GetRealPath( - sf->GetFullPath().c_str()); + sf->GetFullPath()); if (!skipped.insert(absFile).second) { @@ -869,9 +1054,12 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) std::vector<cmSourceFile*> srcFiles; target->GetConfigCommonSourceFiles(srcFiles); + std::string qrcInputs; + const char* qrcInputsSep = ""; + std::string rccFileFiles; std::string rccFileOptions; - const char *sep = ""; + const char *optionSep = ""; const char *qtVersion = makefile->GetDefinition("_target_qt_version"); @@ -880,6 +1068,11 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) { cmSystemTools::ExpandListArgument(opts, rccOptions); } + std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); + if (qtMajorVersion == "") + { + qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR"); + } for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); @@ -890,7 +1083,7 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) if (ext == "qrc") { std::string absFile = cmsys::SystemTools::GetRealPath( - sf->GetFullPath().c_str()); + sf->GetFullPath()); bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")); if (!skip) @@ -909,9 +1102,9 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) if (!rccOptions.empty()) { - rccFileFiles += sep; + rccFileFiles += optionSep; rccFileFiles += absFile; - rccFileOptions += sep; + rccFileOptions += optionSep; } const char *listSep = ""; for(std::vector<std::string>::const_iterator it = rccOptions.begin(); @@ -922,10 +1115,34 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) rccFileOptions += *it; listSep = "@list_sep@"; } - sep = ";"; + optionSep = ";"; + + std::vector<std::string> depends; + + std::string entriesList; + if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) + { + if (qtMajorVersion == "5") + { + entriesList = this->ListQt5RccInputs(sf, target, depends); + } + else + { + entriesList = this->ListQt4RccInputs(sf, depends); + } + if (entriesList.empty()) + { + return; + } + } + qrcInputs += qrcInputsSep; + qrcInputs += entriesList; + qrcInputsSep = ";"; } } } + makefile->AddDefinition("_qt_rcc_inputs_" + target->GetName(), + cmLocalGenerator::EscapeForCMake(qrcInputs).c_str()); makefile->AddDefinition("_rcc_files", cmLocalGenerator::EscapeForCMake(_rcc_files).c_str()); @@ -935,6 +1152,29 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) makefile->AddDefinition("_qt_rcc_options_options", cmLocalGenerator::EscapeForCMake(rccFileOptions).c_str()); + makefile->AddDefinition("_qt_rcc_executable", + this->GetRccExecutable(target).c_str()); +} + +std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target) +{ + cmMakefile *makefile = target->GetMakefile(); + const char *qtVersion = makefile->GetDefinition("_target_qt_version"); + if (!qtVersion) + { + qtVersion = makefile->GetDefinition("Qt5Core_VERSION_MAJOR"); + if (!qtVersion) + { + qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); + } + if (const char *targetQtVersion = + target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", + "")) + { + qtVersion = targetQtVersion; + } + } + std::string targetName = target->GetName(); if (strcmp(qtVersion, "5") == 0) { @@ -943,9 +1183,9 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) { cmSystemTools::Error("Qt5::rcc target not found ", targetName.c_str()); - return; + return std::string(); } - makefile->AddDefinition("_qt_rcc_executable", qt5Rcc->GetLocation("")); + return qt5Rcc->GetLocation(""); } else if (strcmp(qtVersion, "4") == 0) { @@ -954,15 +1194,14 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) { cmSystemTools::Error("Qt4::rcc target not found ", targetName.c_str()); - return; + return std::string(); } - makefile->AddDefinition("_qt_rcc_executable", qt4Rcc->GetLocation("")); - } - else - { - cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and " - "Qt 5 ", targetName.c_str()); + return qt4Rcc->GetLocation(""); } + + cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and " + "Qt 5 ", targetName.c_str()); + return std::string(); } static cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, @@ -1013,7 +1252,7 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, const std::string& config) { std::string filename( - cmSystemTools::CollapseFullPath(targetDirectory.c_str())); + cmSystemTools::CollapseFullPath(targetDirectory)); cmSystemTools::ConvertToUnixSlashes(filename); filename += "/AutogenInfo.cmake"; @@ -1030,7 +1269,10 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, "AM_Qt5Core_VERSION_MAJOR"); } this->Sources = makefile->GetSafeDefinition("AM_SOURCES"); - this->RccSources = makefile->GetSafeDefinition("AM_RCC_SOURCES"); + { + std::string rccSources = makefile->GetSafeDefinition("AM_RCC_SOURCES"); + cmSystemTools::ExpandListArgument(rccSources, this->RccSources); + } this->SkipMoc = makefile->GetSafeDefinition("AM_SKIP_MOC"); this->SkipUic = makefile->GetSafeDefinition("AM_SKIP_UIC"); this->Headers = makefile->GetSafeDefinition("AM_HEADERS"); @@ -1128,6 +1370,28 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, cmSystemTools::ReplaceString(*optionIt, "@list_sep@", ";"); this->RccOptions[*fileIt] = *optionIt; } + + const char *rccInputs = makefile->GetSafeDefinition("AM_RCC_INPUTS"); + std::vector<std::string> rccInputLists; + cmSystemTools::ExpandListArgument(rccInputs, rccInputLists); + + if (this->RccSources.size() != rccInputLists.size()) + { + cmSystemTools::Error("Error processing file: ", filename.c_str()); + return false; + } + + for (std::vector<std::string>::iterator fileIt = this->RccSources.begin(), + inputIt = rccInputLists.begin(); + fileIt != this->RccSources.end(); + ++fileIt, ++inputIt) + { + cmSystemTools::ReplaceString(*inputIt, "@list_sep@", ";"); + std::vector<std::string> rccInputFiles; + cmSystemTools::ExpandListArgument(*inputIt, rccInputFiles); + + this->RccInputs[*fileIt] = rccInputFiles; + } } this->CurrentCompileSettingsStr = this->MakeCompileSettingsString(makefile); @@ -1158,7 +1422,7 @@ bool cmQtAutoGenerators::ReadOldMocDefinitionsFile(cmMakefile* makefile, const std::string& targetDirectory) { std::string filename( - cmSystemTools::CollapseFullPath(targetDirectory.c_str())); + cmSystemTools::CollapseFullPath(targetDirectory)); cmSystemTools::ConvertToUnixSlashes(filename); filename += "/AutomocOldMocDefinitions.cmake"; @@ -1176,7 +1440,7 @@ cmQtAutoGenerators::WriteOldMocDefinitionsFile( const std::string& targetDirectory) { std::string filename( - cmSystemTools::CollapseFullPath(targetDirectory.c_str())); + cmSystemTools::CollapseFullPath(targetDirectory)); cmSystemTools::ConvertToUnixSlashes(filename); filename += "/AutomocOldMocDefinitions.cmake"; @@ -1218,11 +1482,11 @@ void cmQtAutoGenerators::Init() { const std::string &path = *it; this->MocIncludes.push_back("-I" + path); - if (this->EndsWith(path, ".framework/Headers")) + if (cmHasLiteralSuffix(path, ".framework/Headers")) { // Go up twice to get to the framework root std::vector<std::string> pathComponents; - cmsys::SystemTools::SplitPath(path.c_str(), pathComponents); + cmsys::SystemTools::SplitPath(path, pathComponents); std::string frameworkPath =cmsys::SystemTools::JoinPath( pathComponents.begin(), pathComponents.end() - 2); frameworkPaths.insert(frameworkPath); @@ -1239,7 +1503,7 @@ void cmQtAutoGenerators::Init() if (this->IncludeProjectDirsBefore) { - const std::string &binDir = "-I" + this->ProjectBinaryDir; + const std::string binDir = "-I" + this->ProjectBinaryDir; const std::string srcDir = "-I" + this->ProjectSourceDir; @@ -1484,7 +1748,7 @@ void cmQtAutoGenerators::ParseCppFile(const std::string& absFilename, } const std::string absPath = cmsys::SystemTools::GetFilenamePath( - cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/'; + cmsys::SystemTools::GetRealPath(absFilename)) + '/'; const std::string scannedFileBasename = cmsys::SystemTools:: GetFilenameWithoutLastExtension(absFilename); std::string macroName; @@ -1510,7 +1774,7 @@ void cmQtAutoGenerators::ParseCppFile(const std::string& absFilename, std::string basename = cmsys::SystemTools:: GetFilenameWithoutLastExtension(currentMoc); - const bool moc_style = this->StartsWith(basename, "moc_"); + const bool moc_style = cmHasLiteralPrefix(basename, "moc_"); // If the moc include is of the moc_foo.cpp style we expect // the Q_OBJECT class declaration in a header file. @@ -1672,7 +1936,7 @@ void cmQtAutoGenerators::StrictParseCppFile(const std::string& absFilename, } const std::string absPath = cmsys::SystemTools::GetFilenamePath( - cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/'; + cmsys::SystemTools::GetRealPath(absFilename)) + '/'; const std::string scannedFileBasename = cmsys::SystemTools:: GetFilenameWithoutLastExtension(absFilename); @@ -1692,7 +1956,7 @@ void cmQtAutoGenerators::StrictParseCppFile(const std::string& absFilename, std::string basename = cmsys::SystemTools:: GetFilenameWithoutLastExtension(currentMoc); - const bool mocUnderscoreStyle = this->StartsWith(basename, "moc_"); + const bool mocUnderscoreStyle = cmHasLiteralPrefix(basename, "moc_"); // If the moc include is of the moc_foo.cpp style we expect // the Q_OBJECT class declaration in a header file. @@ -1802,7 +2066,7 @@ void cmQtAutoGenerators::ParseForUic(const std::string& absFilename, std::string::size_type matchOffset = 0; const std::string realName = - cmsys::SystemTools::GetRealPath(absFilename.c_str()); + cmsys::SystemTools::GetRealPath(absFilename); matchOffset = 0; if ((strstr(contentsString.c_str(), "ui_") != NULL) @@ -1836,7 +2100,7 @@ cmQtAutoGenerators::SearchHeadersForCppFile(const std::string& absFilename, const std::string basename = cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename); const std::string absPath = cmsys::SystemTools::GetFilenamePath( - cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/'; + cmsys::SystemTools::GetRealPath(absFilename)) + '/'; for(std::vector<std::string>::const_iterator ext = headerExtensions.begin(); ext != headerExtensions.end(); @@ -1904,8 +2168,8 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile, { const std::string mocFilePath = this->Builddir + mocFileName; int sourceNewerThanMoc = 0; - bool success = cmsys::SystemTools::FileTimeCompare(sourceFile.c_str(), - mocFilePath.c_str(), + bool success = cmsys::SystemTools::FileTimeCompare(sourceFile, + mocFilePath, &sourceNewerThanMoc); if (this->GenerateAll || !success || sourceNewerThanMoc >= 0) { @@ -1968,7 +2232,7 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile, std::cerr << "AUTOGEN: error: process for " << mocFilePath <<" failed:\n" << output << std::endl; this->RunMocFailed = true; - cmSystemTools::RemoveFile(mocFilePath.c_str()); + cmSystemTools::RemoveFile(mocFilePath); } return true; } @@ -1984,14 +2248,14 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName, } const std::string path = cmsys::SystemTools::GetFilenamePath( - realName.c_str()) + '/'; + realName) + '/'; std::string ui_output_file = "ui_" + uiFileName + ".h"; std::string ui_input_file = path + uiFileName + ".ui"; int sourceNewerThanUi = 0; - bool success = cmsys::SystemTools::FileTimeCompare(ui_input_file.c_str(), - (this->Builddir + ui_output_file).c_str(), + bool success = cmsys::SystemTools::FileTimeCompare(ui_input_file, + this->Builddir + ui_output_file, &sourceNewerThanUi); if (this->GenerateAll || !success || sourceNewerThanUi >= 0) { @@ -2042,7 +2306,7 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName, std::cerr << "AUTOUIC: error: process for " << ui_output_file << " failed:\n" << output << std::endl; this->RunUicFailed = true; - cmSystemTools::RemoveFile(ui_output_file.c_str()); + cmSystemTools::RemoveFile(ui_output_file); return false; } return true; @@ -2050,13 +2314,29 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName, return false; } -bool cmQtAutoGenerators::GenerateQrc() +bool cmQtAutoGenerators::InputFilesNewerThanQrc(const std::string& qrcFile, + const std::string& rccOutput) { - std::vector<std::string> sourceFiles; - cmSystemTools::ExpandListArgument(this->RccSources, sourceFiles); + std::vector<std::string> const& files = this->RccInputs[qrcFile]; + for (std::vector<std::string>::const_iterator it = files.begin(); + it != files.end(); ++it) + { + int inputNewerThanQrc = 0; + bool success = cmsys::SystemTools::FileTimeCompare(*it, + rccOutput, + &inputNewerThanQrc); + if (!success || inputNewerThanQrc >= 0) + { + return true; + } + } + return false; +} - for(std::vector<std::string>::const_iterator si = sourceFiles.begin(); - si != sourceFiles.end(); ++si) +bool cmQtAutoGenerators::GenerateQrc() +{ + for(std::vector<std::string>::const_iterator si = this->RccSources.begin(); + si != this->RccSources.end(); ++si) { std::string ext = cmsys::SystemTools::GetFilenameLastExtension(*si); @@ -2075,10 +2355,14 @@ bool cmQtAutoGenerators::GenerateQrc() + ".dir/qrc_" + basename + ".cpp"; int sourceNewerThanQrc = 0; - bool success = cmsys::SystemTools::FileTimeCompare(si->c_str(), - rcc_output_file.c_str(), + bool generateQrc = !cmsys::SystemTools::FileTimeCompare(*si, + rcc_output_file, &sourceNewerThanQrc); - if (this->GenerateAll || !success || sourceNewerThanQrc >= 0) + generateQrc = generateQrc || (sourceNewerThanQrc >= 0); + generateQrc = generateQrc || this->InputFilesNewerThanQrc(*si, + rcc_output_file); + + if (this->GenerateAll || generateQrc) { std::map<std::string, std::string>::const_iterator optionIt = this->RccOptions.find(*si); @@ -2118,7 +2402,7 @@ bool cmQtAutoGenerators::GenerateQrc() std::cerr << "AUTORCC: error: process for " << rcc_output_file << " failed:\n" << output << std::endl; this->RunRccFailed = true; - cmSystemTools::RemoveFile(rcc_output_file.c_str()); + cmSystemTools::RemoveFile(rcc_output_file); return false; } } diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index c298f5d..79fa5df 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -86,9 +86,20 @@ private: void MergeRccOptions(std::vector<std::string> &opts, const std::vector<std::string> &fileOpts, bool isQt5); + std::string GetRccExecutable(cmTarget const* target); + + std::string ListQt5RccInputs(cmSourceFile* sf, cmTarget const* target, + std::vector<std::string>& depends); + + std::string ListQt4RccInputs(cmSourceFile* sf, + std::vector<std::string>& depends); + + bool InputFilesNewerThanQrc(const std::string& qrcFile, + const std::string& rccOutput); + std::string QtMajorVersion; std::string Sources; - std::string RccSources; + std::vector<std::string> RccSources; std::string SkipMoc; std::string SkipUic; std::string Headers; @@ -116,6 +127,7 @@ private: std::vector<std::string> UicTargetOptions; std::map<std::string, std::string> UicOptions; std::map<std::string, std::string> RccOptions; + std::map<std::string, std::vector<std::string> > RccInputs; bool Verbose; bool ColorOutput; diff --git a/Source/cmSearchPath.cxx b/Source/cmSearchPath.cxx new file mode 100644 index 0000000..861dbf1 --- /dev/null +++ b/Source/cmSearchPath.cxx @@ -0,0 +1,251 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#include "cmSearchPath.h" +#include "cmFindCommon.h" + +//---------------------------------------------------------------------------- +cmSearchPath::cmSearchPath(cmFindCommon* findCmd) +: FC(findCmd) +{ +} + +//---------------------------------------------------------------------------- +cmSearchPath::~cmSearchPath() +{ +} + +//---------------------------------------------------------------------------- + +void cmSearchPath::ExtractWithout(const std::set<std::string>& ignore, + std::vector<std::string>& outPaths, + bool clear) const +{ + if(clear) + { + outPaths.clear(); + } + for(std::vector<std::string>::const_iterator p = this->Paths.begin(); + p != this->Paths.end(); ++p) + { + if(ignore.count(*p) == 0) + { + outPaths.push_back(*p); + } + } +} + +//---------------------------------------------------------------------------- +void cmSearchPath::AddPath(const std::string& path) +{ + this->AddPathInternal(path); +} + +//---------------------------------------------------------------------------- +void cmSearchPath::AddUserPath(const std::string& path) +{ + assert(this->FC != NULL); + + std::vector<std::string> outPaths; + + // We should view the registry as the target application would view + // it. + cmSystemTools::KeyWOW64 view = cmSystemTools::KeyWOW64_32; + cmSystemTools::KeyWOW64 other_view = cmSystemTools::KeyWOW64_64; + if(this->FC->Makefile->PlatformIs64Bit()) + { + view = cmSystemTools::KeyWOW64_64; + other_view = cmSystemTools::KeyWOW64_32; + } + + // Expand using the view of the target application. + std::string expanded = path; + cmSystemTools::ExpandRegistryValues(expanded, view); + cmSystemTools::GlobDirs(expanded, outPaths); + + // Executables can be either 32-bit or 64-bit, so expand using the + // alternative view. + if(expanded != path && this->FC->CMakePathName == "PROGRAM") + { + expanded = path; + cmSystemTools::ExpandRegistryValues(expanded, other_view); + cmSystemTools::GlobDirs(expanded, outPaths); + } + + // Process them all from the current directory + for(std::vector<std::string>::const_iterator p = outPaths.begin(); + p != outPaths.end(); ++p) + { + this->AddPathInternal(*p, this->FC->Makefile->GetCurrentDirectory()); + } +} + +//---------------------------------------------------------------------------- +void cmSearchPath::AddCMakePath(const std::string& variable) +{ + assert(this->FC != NULL); + + // Get a path from a CMake variable. + if(const char* value = this->FC->Makefile->GetDefinition(variable)) + { + std::vector<std::string> expanded; + cmSystemTools::ExpandListArgument(value, expanded); + + for(std::vector<std::string>::const_iterator p = expanded.begin(); + p!= expanded.end(); ++p) + { + this->AddPathInternal(*p, this->FC->Makefile->GetCurrentDirectory()); + } + } +} + +//---------------------------------------------------------------------------- +void cmSearchPath::AddEnvPath(const std::string& variable) +{ + std::vector<std::string> expanded; + cmSystemTools::GetPath(expanded, variable.c_str()); + for(std::vector<std::string>::const_iterator p = expanded.begin(); + p!= expanded.end(); ++p) + { + this->AddPathInternal(*p); + } +} + +//---------------------------------------------------------------------------- +void cmSearchPath::AddCMakePrefixPath(const std::string& variable) +{ + assert(this->FC != NULL); + + // Get a path from a CMake variable. + if(const char* value = this->FC->Makefile->GetDefinition(variable)) + { + std::vector<std::string> expanded; + cmSystemTools::ExpandListArgument(value, expanded); + + this->AddPrefixPaths(expanded, this->FC->Makefile->GetCurrentDirectory()); + } +} + +//---------------------------------------------------------------------------- +void cmSearchPath::AddEnvPrefixPath(const std::string& variable) +{ + std::vector<std::string> expanded; + cmSystemTools::GetPath(expanded, variable.c_str()); + this->AddPrefixPaths(expanded); +} + +//---------------------------------------------------------------------------- +void cmSearchPath::AddSuffixes(const std::vector<std::string>& suffixes) +{ + std::vector<std::string> inPaths; + inPaths.swap(this->Paths); + this->Paths.reserve(inPaths.size()*(suffixes.size()+1)); + + for(std::vector<std::string>::iterator ip = inPaths.begin(); + ip != inPaths.end(); ++ip) + { + cmSystemTools::ConvertToUnixSlashes(*ip); + + // if *i is only / then do not add a // + // this will get incorrectly considered a network + // path on windows and cause huge delays. + std::string p = *ip; + if(!p.empty() && *p.rbegin() != '/') + { + p += "/"; + } + + // Combine with all the suffixes + for(std::vector<std::string>::const_iterator s = suffixes.begin(); + s != suffixes.end(); ++s) + { + this->Paths.push_back(p+*s); + } + + // And now the original w/o any suffix + this->Paths.push_back(*ip); + } +} + +//---------------------------------------------------------------------------- +void cmSearchPath::AddPrefixPaths(const std::vector<std::string>& paths, + const char *base) +{ + assert(this->FC != NULL); + + // default for programs + std::string subdir = "bin"; + + if (this->FC->CMakePathName == "INCLUDE") + { + subdir = "include"; + } + else if (this->FC->CMakePathName == "LIBRARY") + { + subdir = "lib"; + } + else if (this->FC->CMakePathName == "FRAMEWORK") + { + subdir = ""; // ? what to do for frameworks ? + } + + for(std::vector<std::string>::const_iterator p = paths.begin(); + p != paths.end(); ++p) + { + std::string dir = *p; + if(!subdir.empty() && !dir.empty() && *dir.rbegin() != '/') + { + dir += "/"; + } + if(subdir == "include" || subdir == "lib") + { + const char* arch = + this->FC->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE"); + if(arch && *arch) + { + this->AddPathInternal(dir+subdir+"/"+arch, base); + } + } + std::string add = dir + subdir; + if(add != "/") + { + this->AddPathInternal(add, base); + } + if (subdir == "bin") + { + this->AddPathInternal(dir+"sbin", base); + } + if(!subdir.empty() && *p != "/") + { + this->AddPathInternal(*p, base); + } + } +} + +//---------------------------------------------------------------------------- +void cmSearchPath::AddPathInternal(const std::string& path, const char *base) +{ + assert(this->FC != NULL); + + std::string collapsed = cmSystemTools::CollapseFullPath(path, base); + + if(collapsed.empty()) + { + return; + } + + // Insert the path if has not already been emitted. + if(this->FC->SearchPathsEmitted.insert(collapsed).second) + { + this->Paths.push_back(collapsed); + } +} diff --git a/Source/cmSearchPath.h b/Source/cmSearchPath.h new file mode 100644 index 0000000..51a6149 --- /dev/null +++ b/Source/cmSearchPath.h @@ -0,0 +1,57 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmSearchPath_h +#define cmSearchPath_h + +#include "cmStandardIncludes.h" + +class cmFindCommon; + +/** \class cmSearchPath + * \brief Container for encapsulating a set of search paths + * + * cmSearchPath is a container that encapsulates search path construction and + * management + */ +class cmSearchPath +{ +public: + // cmSearchPath must be initialized from a valid pointer. The only reason + // for teh default is to allow it to be easily used in stl containers. + // Attempting to initialize with a NULL value will fail an assertion + cmSearchPath(cmFindCommon* findCmd = 0); + ~cmSearchPath(); + + const std::vector<std::string>& GetPaths() const { return this->Paths; } + + void ExtractWithout(const std::set<std::string>& ignore, + std::vector<std::string>& outPaths, + bool clear = false) const; + + void AddPath(const std::string& path); + void AddUserPath(const std::string& path); + void AddCMakePath(const std::string& variable); + void AddEnvPath(const std::string& variable); + void AddCMakePrefixPath(const std::string& variable); + void AddEnvPrefixPath(const std::string& variable); + void AddSuffixes(const std::vector<std::string>& suffixes); + +protected: + void AddPrefixPaths(const std::vector<std::string>& paths, + const char *base = 0); + void AddPathInternal(const std::string& path, const char *base = 0); + + cmFindCommon *FC; + std::vector<std::string> Paths; +}; + +#endif diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index 0ca36eb..176a08d 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -43,7 +43,7 @@ bool cmSetCommand if (!currValue || strcmp(currValue,args[1].c_str())) { putEnvArg += args[1]; - cmSystemTools::PutEnv(putEnvArg.c_str()); + cmSystemTools::PutEnv(putEnvArg); } return true; } @@ -51,7 +51,7 @@ bool cmSetCommand // if it will be cleared, then clear it if it isn;t already clear if (currValue) { - cmSystemTools::PutEnv(putEnvArg.c_str()); + cmSystemTools::PutEnv(putEnvArg); } return true; } diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index c624d17..653d764 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -204,7 +204,7 @@ bool cmSetPropertyCommand::HandleDirectoryMode() } // The local generators are associated with collapsed paths. - dir = cmSystemTools::CollapseFullPath(dir.c_str()); + dir = cmSystemTools::CollapseFullPath(dir); // Lookup the generator. if(cmLocalGenerator* lg = diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index b833d3f..6fe5c62 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -179,7 +179,7 @@ bool cmSourceFile::FindFullPath(std::string* error) tryPath += "/"; } tryPath += this->Location.GetName(); - tryPath = cmSystemTools::CollapseFullPath(tryPath.c_str(), *di); + tryPath = cmSystemTools::CollapseFullPath(tryPath, *di); if(this->TryFullPath(tryPath, "")) { return true; diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx index 004fd1f..b81951d 100644 --- a/Source/cmSourceFileLocation.cxx +++ b/Source/cmSourceFileLocation.cxx @@ -63,7 +63,7 @@ cmSourceFileLocation if (cmSystemTools::FileIsFullPath(this->Directory.c_str())) { this->Directory - = cmSystemTools::CollapseFullPath(this->Directory.c_str()); + = cmSystemTools::CollapseFullPath(this->Directory); } this->Name = cmSystemTools::GetFilenameName(name); this->UpdateExtension(name); @@ -92,7 +92,7 @@ void cmSourceFileLocation::DirectoryUseSource() { this->Directory = cmSystemTools::CollapseFullPath( - this->Directory.c_str(), this->Makefile->GetCurrentDirectory()); + this->Directory, this->Makefile->GetCurrentDirectory()); this->AmbiguousDirectory = false; } } @@ -105,7 +105,7 @@ void cmSourceFileLocation::DirectoryUseBinary() { this->Directory = cmSystemTools::CollapseFullPath( - this->Directory.c_str(), this->Makefile->GetCurrentOutputDirectory()); + this->Directory, this->Makefile->GetCurrentOutputDirectory()); this->AmbiguousDirectory = false; } } @@ -281,10 +281,10 @@ bool cmSourceFileLocation::Matches(cmSourceFileLocation const& loc) // Compare possible directory combinations. std::string const& srcDir = cmSystemTools::CollapseFullPath( - this->Directory.c_str(), this->Makefile->GetCurrentDirectory()); + this->Directory, this->Makefile->GetCurrentDirectory()); std::string const& binDir = cmSystemTools::CollapseFullPath( - this->Directory.c_str(), this->Makefile->GetCurrentOutputDirectory()); + this->Directory, this->Makefile->GetCurrentOutputDirectory()); if(srcDir != loc.Directory && binDir != loc.Directory) { @@ -296,10 +296,10 @@ bool cmSourceFileLocation::Matches(cmSourceFileLocation const& loc) // Compare possible directory combinations. std::string const& srcDir = cmSystemTools::CollapseFullPath( - loc.Directory.c_str(), loc.Makefile->GetCurrentDirectory()); + loc.Directory, loc.Makefile->GetCurrentDirectory()); std::string const& binDir = cmSystemTools::CollapseFullPath( - loc.Directory.c_str(), loc.Makefile->GetCurrentOutputDirectory()); + loc.Directory, loc.Makefile->GetCurrentOutputDirectory()); if(srcDir != this->Directory && binDir != this->Directory) { diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index 8baf7b3..6b85634 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -28,12 +28,6 @@ #define CMAKE_NO_ANSI_FOR_SCOPE #endif -#ifdef __BORLANDC__ -# pragma warn -8030 /* Temporary used for parameter */ -# pragma warn -8027 /* 'for' not inlined. */ -# pragma warn -8026 /* 'exception' not inlined. */ -# pragma warn -8004 /* value never used */ -#endif #ifdef __ICL #pragma warning ( disable : 985 ) @@ -78,10 +72,6 @@ public: #if defined(_MSC_VER) # pragma warning (push,1) #endif -#if defined(__BORLANDC__) -# pragma warn -8008 /* condition is always false (RESET BELOW!) */ -# pragma warn -8066 /* unreachable code (RESET BELOW!) */ -#endif #ifndef CMAKE_NO_ANSI_STREAM_HEADERS # include <fstream> @@ -112,10 +102,6 @@ public: #include <set> #include <deque> -#if defined(__BORLANDC__) -# pragma warn .8008 /* condition is always false (disabled above) */ -# pragma warn .8066 /* unreachable code (disabled above) */ -#endif #if defined(_MSC_VER) # pragma warning(pop) #endif @@ -134,10 +120,6 @@ public: // include blockers are put in place that prevent including the // C-style versions from ever including the sub-headers. Therefore we // have to include the sub-headers here to get the using declarations. -#if defined(__BORLANDC__) -# include <mem.h> /* mem... functions from string.h */ -# include <search.h> /* search functions from stdlib.h */ -#endif #if !defined(_WIN32) && defined(__COMO__) @@ -411,9 +393,7 @@ inline bool cmHasLiteralSuffixImpl(const char* str1, return len >= N && strcmp(str1 + len - N, str2) == 0; } -#if defined(_MSC_VER) && _MSC_VER < 1300 \ - || defined(__GNUC__) && __GNUC__ < 3 \ - || defined(__BORLANDC__) +#if defined(__GNUC__) && __GNUC__ < 3 #define cmArrayBegin(a) a #define cmArraySize(a) (sizeof(a)/sizeof(*a)) diff --git a/Source/cmStandardLexer.h b/Source/cmStandardLexer.h index acd636c..981e03e 100644 --- a/Source/cmStandardLexer.h +++ b/Source/cmStandardLexer.h @@ -25,25 +25,6 @@ # pragma warning ( disable : 4786 ) #endif -#if defined(__BORLANDC__) -# pragma warn -8008 /* condition always returns true */ -# pragma warn -8066 /* unreachable code */ -#endif - -/* Borland system header defines these macros without first undef-ing them. */ -#if defined(__BORLANDC__) && __BORLANDC__ >= 0x580 -# undef INT8_MIN -# undef INT16_MIN -# undef INT32_MIN -# undef INT8_MAX -# undef INT16_MAX -# undef INT32_MAX -# undef UINT8_MAX -# undef UINT16_MAX -# undef UINT32_MAX -# include <stdint.h> -#endif - /* Make sure SGI termios does not define ECHO differently. */ #if defined(__sgi) && !defined(__GNUC__) # include <sys/termios.h> diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 90a8f85..9827c62 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -310,7 +310,7 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args) input += args[i]; } - this->Makefile->ClearMatches(); + this->ClearMatches(this->Makefile); // Compile the regular expression. cmsys::RegularExpression re; if(!re.compile(regex.c_str())) @@ -325,7 +325,7 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args) std::string output; if(re.find(input.c_str())) { - this->Makefile->StoreMatches(re); + this->StoreMatches(this->Makefile, re); std::string::size_type l = re.start(); std::string::size_type r = re.end(); if(r-l == 0) @@ -359,7 +359,7 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args) input += args[i]; } - this->Makefile->ClearMatches(); + this->ClearMatches(this->Makefile); // Compile the regular expression. cmsys::RegularExpression re; if(!re.compile(regex.c_str())) @@ -376,7 +376,7 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args) const char* p = input.c_str(); while(re.find(p)) { - this->Makefile->StoreMatches(re); + this->StoreMatches(this->Makefile, re); std::string::size_type l = re.start(); std::string::size_type r = re.end(); if(r-l == 0) @@ -463,7 +463,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args) input += args[i]; } - this->Makefile->ClearMatches(); + this->ClearMatches(this->Makefile); // Compile the regular expression. cmsys::RegularExpression re; if(!re.compile(regex.c_str())) @@ -480,7 +480,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args) std::string::size_type base = 0; while(re.find(input.c_str()+base)) { - this->Makefile->StoreMatches(re); + this->StoreMatches(this->Makefile, re); std::string::size_type l2 = re.start(); std::string::size_type r = re.end(); @@ -541,6 +541,38 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args) } //---------------------------------------------------------------------------- +void cmStringCommand::ClearMatches(cmMakefile* mf) +{ + for (unsigned int i=0; i<10; i++) + { + char name[128]; + sprintf(name, "CMAKE_MATCH_%d", i); + const char* s = mf->GetDefinition(name); + if(s && *s != 0) + { + mf->AddDefinition(name, ""); + mf->MarkVariableAsUsed(name); + } + } +} + +//---------------------------------------------------------------------------- +void cmStringCommand::StoreMatches(cmMakefile* mf,cmsys::RegularExpression& re) +{ + for (unsigned int i=0; i<10; i++) + { + std::string m = re.match(i); + if(m.size() > 0) + { + char name[128]; + sprintf(name, "CMAKE_MATCH_%d", i); + mf->AddDefinition(name, re.match(i).c_str()); + mf->MarkVariableAsUsed(name); + } + } +} + +//---------------------------------------------------------------------------- bool cmStringCommand::HandleFindCommand(std::vector<std::string> const& args) { @@ -711,12 +743,10 @@ bool cmStringCommand::HandleSubstringCommand(std::vector<std::string> const& this->SetError(ostr.str()); return false; } - int leftOverLength = intStringLength - begin; - if ( end < -1 || end > leftOverLength ) + if ( end < -1 ) { cmOStringStream ostr; - ostr << "end index: " << end << " is out of range -1 - " - << leftOverLength; + ostr << "end index: " << end << " should be -1 or greater"; this->SetError(ostr.str()); return false; } @@ -782,7 +812,7 @@ bool cmStringCommand const std::string& variableName = args[2]; this->Makefile->AddDefinition(variableName, - cmSystemTools::MakeCidentifier(input.c_str()).c_str()); + cmSystemTools::MakeCidentifier(input).c_str()); return true; } diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h index 9c75095..a5fe893 100644 --- a/Source/cmStringCommand.h +++ b/Source/cmStringCommand.h @@ -53,6 +53,8 @@ public: virtual std::string GetName() const { return "string";} cmTypeMacro(cmStringCommand, cmCommand); + static void ClearMatches(cmMakefile* mf); + static void StoreMatches(cmMakefile* mf, cmsys::RegularExpression& re); protected: bool HandleConfigureCommand(std::vector<std::string> const& args); bool HandleAsciiCommand(std::vector<std::string> const& args); diff --git a/Source/cmSubdirCommand.cxx b/Source/cmSubdirCommand.cxx index cdde916..93ad4f3 100644 --- a/Source/cmSubdirCommand.cxx +++ b/Source/cmSubdirCommand.cxx @@ -42,7 +42,7 @@ bool cmSubdirCommand std::string srcPath = std::string(this->Makefile->GetCurrentDirectory()) + "/" + i->c_str(); - if (cmSystemTools::FileIsDirectory(srcPath.c_str())) + if (cmSystemTools::FileIsDirectory(srcPath)) { std::string binPath = std::string(this->Makefile->GetCurrentOutputDirectory()) + @@ -51,7 +51,7 @@ bool cmSubdirCommand excludeFromAll, preorder, false); } // otherwise it is a full path - else if ( cmSystemTools::FileIsDirectory(i->c_str()) ) + else if ( cmSystemTools::FileIsDirectory(*i) ) { // we must compute the binPath from the srcPath, we just take the last // element from the source path and use that diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index fbb4416..baac7b8 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -9,9 +9,7 @@ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more information. ============================================================================*/ -#if defined(_MSC_VER) && _MSC_VER < 1300 -# define _WIN32_WINNT 0x0400 /* for wincrypt.h */ -#endif + #include "cmSystemTools.h" #include <ctype.h> #include <errno.h> @@ -52,8 +50,7 @@ #include <sys/stat.h> #if defined(_WIN32) && \ - (defined(_MSC_VER) || defined(__WATCOMC__) || \ - defined(__BORLANDC__) || defined(__MINGW32__)) + (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__MINGW32__)) # include <io.h> #endif @@ -97,7 +94,7 @@ cm_archive_entry_pathname(struct archive_entry *entry) { #if cmsys_STL_HAS_WSTRING return cmsys::Encoding::ToNarrow( - archive_entry_pathname_w(entry)).c_str(); + archive_entry_pathname_w(entry)); #else return archive_entry_pathname(entry); #endif @@ -881,7 +878,7 @@ std::string cmSystemTools::FileExistsInParentDirectories(const char* fname, break; } prevDir = dir; - dir = cmSystemTools::GetParentDirectory(dir.c_str()); + dir = cmSystemTools::GetParentDirectory(dir); } return ""; } @@ -1014,7 +1011,7 @@ void cmSystemTools::Glob(const std::string& directory, cmsys::Directory d; cmsys::RegularExpression reg(regexp.c_str()); - if (d.Load(directory.c_str())) + if (d.Load(directory)) { size_t numf; unsigned int i; @@ -1044,7 +1041,7 @@ void cmSystemTools::GlobDirs(const std::string& path, std::string finishPath = path.substr(pos+2); cmsys::Directory d; - if (d.Load(startPath.c_str())) + if (d.Load(startPath)) { for (unsigned int i = 0; i < d.GetNumberOfFiles(); ++i) { @@ -1054,7 +1051,7 @@ void cmSystemTools::GlobDirs(const std::string& path, std::string fname = startPath; fname +="/"; fname += d.GetFile(i); - if(cmSystemTools::FileIsDirectory(fname.c_str())) + if(cmSystemTools::FileIsDirectory(fname)) { fname += finishPath; cmSystemTools::GlobDirs(fname, files); @@ -1168,7 +1165,7 @@ bool cmSystemTools::SimpleGlob(const std::string& glob, bool res = false; cmsys::Directory d; - if (d.Load(path.c_str())) + if (d.Load(path)) { for (unsigned int i = 0; i < d.GetNumberOfFiles(); ++i) { @@ -1182,11 +1179,11 @@ bool cmSystemTools::SimpleGlob(const std::string& glob, } fname += d.GetFile(i); std::string sfname = d.GetFile(i); - if ( type > 0 && cmSystemTools::FileIsDirectory(fname.c_str()) ) + if ( type > 0 && cmSystemTools::FileIsDirectory(fname) ) { continue; } - if ( type < 0 && !cmSystemTools::FileIsDirectory(fname.c_str()) ) + if ( type < 0 && !cmSystemTools::FileIsDirectory(fname) ) { continue; } @@ -1354,8 +1351,8 @@ std::string cmSystemTools::CollapseCombinedPath(std::string const& dir, std::vector<std::string> dirComponents; std::vector<std::string> fileComponents; - cmSystemTools::SplitPath(dir.c_str(), dirComponents); - cmSystemTools::SplitPath(file.c_str(), fileComponents); + cmSystemTools::SplitPath(dir, dirComponents); + cmSystemTools::SplitPath(file, fileComponents); if(fileComponents.empty()) { @@ -1410,7 +1407,7 @@ void cmSystemTools::AppendEnv(std::vector<std::string> const& env) for(std::vector<std::string>::const_iterator eit = env.begin(); eit != env.end(); ++eit) { - cmSystemTools::PutEnv(eit->c_str()); + cmSystemTools::PutEnv(*eit); } } @@ -1649,9 +1646,6 @@ namespace{ fprintf(out, " -> %s", archive_entry_symlink(entry)); } } -#ifdef __BORLANDC__ -# pragma warn -8066 /* unreachable code */ -#endif long copy_data(struct archive *ar, struct archive *aw) { @@ -2176,7 +2170,7 @@ void cmSystemTools::FindCMakeResources(const char* argv0) if(cmSystemTools::FindProgramPath(argv0, exe, errorMsg)) { // remove symlinks - exe = cmSystemTools::GetRealPath(exe.c_str()); + exe = cmSystemTools::GetRealPath(exe); exe_dir = cmSystemTools::GetFilenamePath(exe); } @@ -2227,7 +2221,7 @@ void cmSystemTools::FindCMakeResources(const char* argv0) 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())) + cmSystemTools::FileIsDirectory(src_dir)) { cmSystemToolsCMakeRoot = src_dir; } @@ -2237,7 +2231,7 @@ void cmSystemTools::FindCMakeResources(const char* argv0) src_dir_txt = dir + "/CMakeFiles/CMakeSourceDir.txt"; cmsys::ifstream fin2(src_dir_txt.c_str()); if(fin2 && cmSystemTools::GetLineFromStream(fin2, src_dir) && - cmSystemTools::FileIsDirectory(src_dir.c_str())) + cmSystemTools::FileIsDirectory(src_dir)) { cmSystemToolsCMakeRoot = src_dir; } @@ -2333,11 +2327,11 @@ bool cmSystemTools::GuessLibrarySOName(std::string const& fullPath, #endif // If the file is not a symlink we have no guess for its soname. - if(!cmSystemTools::FileIsSymlink(fullPath.c_str())) + if(!cmSystemTools::FileIsSymlink(fullPath)) { return false; } - if(!cmSystemTools::ReadSymlink(fullPath.c_str(), soname)) + if(!cmSystemTools::ReadSymlink(fullPath, soname)) { return false; } @@ -2638,29 +2632,37 @@ bool cmSystemTools::ChangeRPath(std::string const& file, bool cmSystemTools::VersionCompare(cmSystemTools::CompareOp op, const char* lhss, const char* rhss) { - // Parse out up to 8 components. - unsigned int lhs[8] = {0,0,0,0,0,0,0,0}; - unsigned int rhs[8] = {0,0,0,0,0,0,0,0}; - sscanf(lhss, "%u.%u.%u.%u.%u.%u.%u.%u", - &lhs[0], &lhs[1], &lhs[2], &lhs[3], - &lhs[4], &lhs[5], &lhs[6], &lhs[7]); - sscanf(rhss, "%u.%u.%u.%u.%u.%u.%u.%u", - &rhs[0], &rhs[1], &rhs[2], &rhs[3], - &rhs[4], &rhs[5], &rhs[6], &rhs[7]); + const char *endl = lhss; + const char *endr = rhss; + unsigned long lhs, rhs; - // Do component-wise comparison. - for(unsigned int i=0; i < 8; ++i) + while (((*endl >= '0') && (*endl <= '9')) || + ((*endr >= '0') && (*endr <= '9'))) { - if(lhs[i] < rhs[i]) + // Do component-wise comparison. + lhs = strtoul(endl, const_cast<char**>(&endl), 10); + rhs = strtoul(endr, const_cast<char**>(&endr), 10); + + if(lhs < rhs) { // lhs < rhs, so true if operation is LESS return op == cmSystemTools::OP_LESS; } - else if(lhs[i] > rhs[i]) + else if(lhs > rhs) { // lhs > rhs, so true if operation is GREATER return op == cmSystemTools::OP_GREATER; } + + if (*endr == '.') + { + endr++; + } + + if (*endl == '.') + { + endl++; + } } // lhs == rhs, so true if operation is EQUAL return op == cmSystemTools::OP_EQUAL; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b476a27..edae18f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2171,7 +2171,7 @@ cmTarget::GetIncludeDirectories(const std::string& config) const it = impl->Libraries.begin(); it != impl->Libraries.end(); ++it) { - std::string libDir = cmSystemTools::CollapseFullPath(it->c_str()); + std::string libDir = cmSystemTools::CollapseFullPath(*it); static cmsys::RegularExpression frameworkCheck("(.*\\.framework)(/Versions/[^/]+)?/[^/]+$"); @@ -4555,7 +4555,7 @@ bool cmTarget::ComputeOutputDir(const std::string& config, // specified as a relative path. Treat a relative path as // relative to the current output directory for this makefile. out = (cmSystemTools::CollapseFullPath - (out.c_str(), this->Makefile->GetStartOutputDirectory())); + (out, this->Makefile->GetStartOutputDirectory())); // The generator may add the configuration's subdirectory. if(!conf.empty()) @@ -4621,7 +4621,7 @@ bool cmTarget::ComputePDBOutputDir(const std::string& kind, // specified as a relative path. Treat a relative path as // relative to the current output directory for this makefile. out = (cmSystemTools::CollapseFullPath - (out.c_str(), this->Makefile->GetStartOutputDirectory())); + (out, this->Makefile->GetStartOutputDirectory())); // The generator may add the configuration's subdirectory. if(!conf.empty()) @@ -4713,7 +4713,7 @@ const char* cmTarget::GetExportMacro() const { std::string in = this->GetName(); in += "_EXPORTS"; - this->ExportMacro = cmSystemTools::MakeCindentifier(in.c_str()); + this->ExportMacro = cmSystemTools::MakeCindentifier(in); } return this->ExportMacro.c_str(); } @@ -4781,16 +4781,6 @@ std::pair<bool, const char*> consistentStringProperty(const char *lhs, return std::make_pair(b, b ? lhs : 0); } -#if defined(_MSC_VER) && _MSC_VER <= 1200 -template<typename T> const T& -cmMaximum(const T& l, const T& r) {return l > r ? l : r;} -template<typename T> const T& -cmMinimum(const T& l, const T& r) {return l < r ? l : r;} -#else -#define cmMinimum std::min -#define cmMaximum std::max -#endif - //---------------------------------------------------------------------------- std::pair<bool, const char*> consistentNumberProperty(const char *lhs, const char *rhs, @@ -4798,11 +4788,7 @@ std::pair<bool, const char*> consistentNumberProperty(const char *lhs, { char *pEnd; -#if defined(_MSC_VER) - static const char* const null_ptr = 0; -#else -# define null_ptr 0 -#endif + const char* const null_ptr = 0; long lnum = strtol(lhs, &pEnd, 0); if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) @@ -4816,17 +4802,13 @@ std::pair<bool, const char*> consistentNumberProperty(const char *lhs, return std::pair<bool, const char*>(false, null_ptr); } -#if !defined(_MSC_VER) -#undef null_ptr -#endif - if (t == NumberMaxType) { - return std::make_pair(true, cmMaximum(lnum, rnum) == lnum ? lhs : rhs); + return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); } else { - return std::make_pair(true, cmMinimum(lnum, rnum) == lnum ? lhs : rhs); + return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs); } } @@ -4849,11 +4831,7 @@ std::pair<bool, const char*> consistentProperty(const char *lhs, return std::make_pair(true, lhs); } -#if defined(_MSC_VER) - static const char* const null_ptr = 0; -#else -# define null_ptr 0 -#endif + const char* const null_ptr = 0; switch(t) { @@ -4868,11 +4846,6 @@ std::pair<bool, const char*> consistentProperty(const char *lhs, } assert(!"Unreachable!"); return std::pair<bool, const char*>(false, null_ptr); - -#if !defined(_MSC_VER) -#undef null_ptr -#endif - } template<typename PropertyType> @@ -5286,7 +5259,7 @@ cmTarget::GetObjectLibrariesCMP0026(std::vector<cmTarget*>& objlibs) const { continue; } - cmTarget *objLib = this->Makefile->FindTargetToUse(objLibName.c_str()); + cmTarget *objLib = this->Makefile->FindTargetToUse(objLibName); if(objLib) { objlibs.push_back(objLib); diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index cc6e139..8f2deeb 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -239,7 +239,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, copyDest += "-"; copyDest += this->RunResultVariable; copyDest += cmSystemTools::GetFilenameExtension(this->OutputFile); - cmSystemTools::CopyFileAlways(this->OutputFile.c_str(), copyDest.c_str()); + cmSystemTools::CopyFileAlways(this->OutputFile, copyDest); std::string resultFileName = this->Makefile->GetHomeOutputDirectory(); resultFileName += "/TryRunResults.cmake"; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 1ac13cf..f591fc8 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -307,7 +307,7 @@ void cmVisualStudio10TargetGenerator::Generate() this->BuildFileStream->SetCopyIfDifferent(true); // Write the encoding header into the file - char magic[] = {0xEF,0xBB, 0xBF}; + char magic[] = {char(0xEF), char(0xBB), char(0xBF)}; this->BuildFileStream->write(magic, 3); //get the tools version to use @@ -937,7 +937,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() path += ".vcxproj.filters"; cmGeneratedFileStream fout(path.c_str()); fout.SetCopyIfDifferent(true); - char magic[] = {0xEF,0xBB, 0xBF}; + char magic[] = {char(0xEF), char(0xBB), char(0xBF)}; fout.write(magic, 3); cmGeneratedFileStream* save = this->BuildFileStream; this->BuildFileStream = & fout; diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index cdc8879..00386f6 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -28,6 +28,26 @@ std::string cmVisualStudioGeneratorOptionsEscapeForXML(std::string ret) cmVisualStudioGeneratorOptions ::cmVisualStudioGeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool, + cmVisualStudio10TargetGenerator* g): + cmIDEOptions(), + LocalGenerator(lg), Version(lg->GetVersion()), CurrentTool(tool), + TargetGenerator(g) +{ + // Preprocessor definitions are not allowed for linker tools. + this->AllowDefine = (tool != Linker); + + // Slash options are allowed for VS. + this->AllowSlash = true; + + this->FortranRuntimeDebug = false; + this->FortranRuntimeDLL = false; + this->FortranRuntimeMT = false; +} + +//---------------------------------------------------------------------------- +cmVisualStudioGeneratorOptions +::cmVisualStudioGeneratorOptions(cmLocalVisualStudioGenerator* lg, + Tool tool, cmVS7FlagTable const* table, cmVS7FlagTable const* extraTable, cmVisualStudio10TargetGenerator* g): @@ -36,9 +56,8 @@ cmVisualStudioGeneratorOptions TargetGenerator(g) { // Store the given flag tables. - cmIDEFlagTable const** ft = this->FlagTable; - if(table) { *ft++ = table; } - if(extraTable) { *ft++ = extraTable; } + this->AddTable(table); + this->AddTable(extraTable); // Preprocessor definitions are not allowed for linker tools. this->AllowDefine = (tool != Linker); @@ -52,6 +71,22 @@ cmVisualStudioGeneratorOptions } //---------------------------------------------------------------------------- +void cmVisualStudioGeneratorOptions::AddTable(cmVS7FlagTable const* table) +{ + if(table) + { + for(int i=0; i < FlagTableCount; ++i) + { + if (!this->FlagTable[i]) + { + this->FlagTable[i] = table; + break; + } + } + } +} + +//---------------------------------------------------------------------------- void cmVisualStudioGeneratorOptions::FixExceptionHandlingDefault() { // Exception handling is on by default because the platform file has diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h index 9951033..5490a43 100644 --- a/Source/cmVisualStudioGeneratorOptions.h +++ b/Source/cmVisualStudioGeneratorOptions.h @@ -38,6 +38,13 @@ public: cmVS7FlagTable const* extraTable = 0, cmVisualStudio10TargetGenerator* g = 0); + cmVisualStudioGeneratorOptions(cmLocalVisualStudioGenerator* lg, + Tool tool, + cmVisualStudio10TargetGenerator* g = 0); + + // Add a table of flags. + void AddTable(cmVS7FlagTable const* table); + // Store options from command line flags. void Parse(const char* flags); void ParseFinish(); diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 851c4cb..d36095e 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -27,6 +27,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, // if this is the endwhile for this while loop then execute if (!this->Depth) { + cmMakefile::LoopBlockPop loopBlockPop(&mf); + // Remove the function blocker for this scope or bail. cmsys::auto_ptr<cmFunctionBlocker> fb(mf.RemoveFunctionBlocker(this, lff)); @@ -138,6 +140,8 @@ bool cmWhileCommand f->Args = args; this->Makefile->AddFunctionBlocker(f); + this->Makefile->PushLoopBlock(); + return true; } diff --git a/Source/cmWriteFileCommand.cxx b/Source/cmWriteFileCommand.cxx index af955ec..cc9f220 100644 --- a/Source/cmWriteFileCommand.cxx +++ b/Source/cmWriteFileCommand.cxx @@ -63,8 +63,6 @@ bool cmWriteFileCommand cmSystemTools::SetPermissions(fileName.c_str(), #if defined( _MSC_VER ) || defined( __MINGW32__ ) mode | S_IWRITE -#elif defined( __BORLANDC__ ) - mode | S_IWUSR #else mode | S_IWUSR | S_IWGRP #endif diff --git a/Source/cm_sha2.c b/Source/cm_sha2.c index 24de2b2..4738920 100644 --- a/Source/cm_sha2.c +++ b/Source/cm_sha2.c @@ -103,9 +103,6 @@ typedef cm_sha2_uint32_t sha_word32; /* Exactly 4 bytes */ typedef cm_sha2_uint64_t sha_word64; /* Exactly 8 bytes */ #define SHA_UINT32_C(x) cmIML_INT_UINT32_C(x) #define SHA_UINT64_C(x) cmIML_INT_UINT64_C(x) -#if defined(__BORLANDC__) -# pragma warn -8004 /* variable assigned value that is never used */ -#endif #if defined(__clang__) # pragma clang diagnostic ignored "-Wcast-align" #endif diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 36a0645..bbd3fe4 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -647,7 +647,7 @@ void cmake::SetArgs(const std::vector<std::string>& args, { directoriesSet = true; std::string path = arg.substr(2); - path = cmSystemTools::CollapseFullPath(path.c_str()); + path = cmSystemTools::CollapseFullPath(path); cmSystemTools::ConvertToUnixSlashes(path); this->SetHomeDirectory(path); } @@ -663,7 +663,7 @@ void cmake::SetArgs(const std::vector<std::string>& args, { directoriesSet = true; std::string path = arg.substr(2); - path = cmSystemTools::CollapseFullPath(path.c_str()); + path = cmSystemTools::CollapseFullPath(path); cmSystemTools::ConvertToUnixSlashes(path); this->SetHomeOutputDirectory(path); } @@ -723,7 +723,7 @@ void cmake::SetArgs(const std::vector<std::string>& args, else if(arg.find("--graphviz=",0) == 0) { std::string path = arg.substr(strlen("--graphviz=")); - path = cmSystemTools::CollapseFullPath(path.c_str()); + path = cmSystemTools::CollapseFullPath(path); cmSystemTools::ConvertToUnixSlashes(path); this->GraphVizFile = path; if ( this->GraphVizFile.empty() ) @@ -1135,13 +1135,13 @@ void cmake::SetGlobalGenerator(cmGlobalGenerator *gg) { env += this->CCEnvironment; } - cmSystemTools::PutEnv(env.c_str()); + cmSystemTools::PutEnv(env); env = "CXX="; if(this->CXXEnvironment.size()) { env += this->CXXEnvironment; } - cmSystemTools::PutEnv(env.c_str()); + cmSystemTools::PutEnv(env); } // set the new @@ -1212,7 +1212,7 @@ int cmake::DoPreConfigureChecks() cacheStart += "/CMakeLists.txt"; std::string currentStart = this->GetHomeDirectory(); currentStart += "/CMakeLists.txt"; - if(!cmSystemTools::SameFile(cacheStart.c_str(), currentStart.c_str())) + if(!cmSystemTools::SameFile(cacheStart, currentStart)) { std::string message = "The source \""; message += currentStart; @@ -1377,9 +1377,7 @@ int cmake::ActualConfigure() } else { -#if defined(__BORLANDC__) && defined(_WIN32) - this->SetGlobalGenerator(new cmGlobalBorlandMakefileGenerator); -#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW) +#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW) std::string installedCompiler; // Try to find the newest VS installed on the computer and // use that as a default if -G is not specified @@ -1948,7 +1946,7 @@ void cmake::UpdateConversionPathTable() { // two entries per line table >> a; table >> b; - cmSystemTools::AddTranslationPath( a.c_str(), b.c_str()); + cmSystemTools::AddTranslationPath( a, b); } } } @@ -2043,7 +2041,7 @@ int cmake::CheckBuildSystem() pi != products.end(); ++pi) { if(!(cmSystemTools::FileExists(pi->c_str()) || - cmSystemTools::FileIsSymlink(pi->c_str()))) + cmSystemTools::FileIsSymlink(*pi))) { if(verbose) { @@ -2166,7 +2164,7 @@ void cmake::TruncateOutputLog(const char* fname) } if ( !this->CacheManager->GetCacheValue("CMAKE_CACHEFILE_DIR") ) { - cmSystemTools::RemoveFile(fullPath.c_str()); + cmSystemTools::RemoveFile(fullPath); return; } off_t fsize = st.st_size; @@ -2392,7 +2390,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) std::string resultFile; std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); std::string destPath = cwd + "/__cmake_systeminformation"; - cmSystemTools::RemoveADirectory(destPath.c_str()); + cmSystemTools::RemoveADirectory(destPath); if (!cmSystemTools::MakeDirectory(destPath.c_str())) { std::cerr << "Error: --system-information must be run from a " @@ -2474,7 +2472,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) } // now run cmake on the CMakeLists file - cmSystemTools::ChangeDirectory(destPath.c_str()); + cmSystemTools::ChangeDirectory(destPath); std::vector<std::string> args2; args2.push_back(args[0]); args2.push_back(destPath); @@ -2490,12 +2488,12 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) } // change back to the original directory - cmSystemTools::ChangeDirectory(cwd.c_str()); + cmSystemTools::ChangeDirectory(cwd); // echo results to stdout if needed if (writeToStdout) { - FILE* fin = cmsys::SystemTools::Fopen(resultFile.c_str(), "r"); + FILE* fin = cmsys::SystemTools::Fopen(resultFile, "r"); if(fin) { const int bufferSize = 4096; @@ -2514,7 +2512,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) } // clean up the directory - cmSystemTools::RemoveADirectory(destPath.c_str()); + cmSystemTools::RemoveADirectory(destPath); return 0; } @@ -2770,7 +2768,7 @@ int cmake::Build(const std::string& dir, const std::vector<std::string>& nativeOptions, bool clean) { - if(!cmSystemTools::FileIsDirectory(dir.c_str())) + if(!cmSystemTools::FileIsDirectory(dir)) { std::cerr << "Error: " << dir << " is not a directory\n"; return 1; diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index a0c67e0..a97444d 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -128,7 +128,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Copy directory content if (args[1] == "copy_directory" && args.size() == 4) { - if(!cmSystemTools::CopyADirectory(args[2].c_str(), args[3].c_str())) + if(!cmSystemTools::CopyADirectory(args[2], args[3])) { std::cerr << "Error copying directory from \"" << args[2] << "\" to \"" << args[3] @@ -155,7 +155,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Compare files if (args[1] == "compare_files" && args.size() == 4) { - if(cmSystemTools::FilesDiffer(args[2].c_str(), args[3].c_str())) + if(cmSystemTools::FilesDiffer(args[2], args[3])) { std::cerr << "Files \"" << args[2] << "\" to \"" << args[3] @@ -215,7 +215,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) else if(a.find("=") != a.npos) { // Set environment variable. - cmSystemTools::PutEnv(a.c_str()); + cmSystemTools::PutEnv(a); } else { @@ -269,8 +269,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) else if (args[1] == "remove_directory" && args.size() == 3) { - if(cmSystemTools::FileIsDirectory(args[2].c_str()) && - !cmSystemTools::RemoveADirectory(args[2].c_str())) + if(cmSystemTools::FileIsDirectory(args[2]) && + !cmSystemTools::RemoveADirectory(args[2])) { std::cerr << "Error removing directory \"" << args[2] << "\".\n"; @@ -293,7 +293,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) { // Complain if the file could not be removed, still exists, // and the -f option was not given. - if(!cmSystemTools::RemoveFile(args[cc].c_str()) && !force && + if(!cmSystemTools::RemoveFile(args[cc]) && !force && cmSystemTools::FileExists(args[cc].c_str())) { return 1; @@ -309,7 +309,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) { // Complain if the file could not be removed, still exists, // and the -f option was not given. - if(!cmSystemTools::Touch(args[cc].c_str(), true)) + if(!cmSystemTools::Touch(args[cc], true)) { return 1; } @@ -323,7 +323,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) { // Complain if the file could not be removed, still exists, // and the -f option was not given. - if(!cmSystemTools::Touch(args[cc].c_str(), false)) + if(!cmSystemTools::Touch(args[cc], false)) { return 1; } @@ -453,10 +453,10 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // basically remove the directory std::string dirName = args[2]; dirName += "/Progress"; - cmSystemTools::RemoveADirectory(dirName.c_str()); + cmSystemTools::RemoveADirectory(dirName); // is the last argument a filename that exists? - FILE *countFile = cmsys::SystemTools::Fopen(args[3].c_str(),"r"); + FILE *countFile = cmsys::SystemTools::Fopen(args[3],"r"); int count; if (countFile) { @@ -476,7 +476,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // write the count into the directory std::string fName = dirName; fName += "/count.txt"; - FILE *progFile = cmsys::SystemTools::Fopen(fName.c_str(),"w"); + FILE *progFile = cmsys::SystemTools::Fopen(fName,"w"); if (progFile) { fprintf(progFile,"%i\n",count); @@ -497,7 +497,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // read the count fName = dirName; fName += "/count.txt"; - progFile = cmsys::SystemTools::Fopen(fName.c_str(),"r"); + progFile = cmsys::SystemTools::Fopen(fName,"r"); int count = 0; if (!progFile) { @@ -517,7 +517,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) fName = dirName; fName += "/"; fName += args[i]; - progFile = cmsys::SystemTools::Fopen(fName.c_str(),"w"); + progFile = cmsys::SystemTools::Fopen(fName,"w"); if (progFile) { fprintf(progFile,"empty"); @@ -525,7 +525,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) } } int fileNum = static_cast<int> - (cmsys::Directory::GetNumberOfFilesInDirectory(dirName.c_str())); + (cmsys::Directory::GetNumberOfFilesInDirectory(dirName)); if (count > 0) { // print the progress @@ -549,7 +549,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) "' because existing path cannot be removed: " << emsg << "\n"; return 1; } - if(!cmSystemTools::CreateSymlink(args[2].c_str(), args[3].c_str())) + if(!cmSystemTools::CreateSymlink(args[2], args[3])) { std::string emsg = cmSystemTools::GetLastSystemError(); std::cerr << @@ -660,10 +660,10 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Create a local generator configured for the directory in // which dependencies will be scanned. - homeDir = cmSystemTools::CollapseFullPath(homeDir.c_str()); - startDir = cmSystemTools::CollapseFullPath(startDir.c_str()); - homeOutDir = cmSystemTools::CollapseFullPath(homeOutDir.c_str()); - startOutDir = cmSystemTools::CollapseFullPath(startOutDir.c_str()); + homeDir = cmSystemTools::CollapseFullPath(homeDir); + startDir = cmSystemTools::CollapseFullPath(startDir); + homeOutDir = cmSystemTools::CollapseFullPath(homeOutDir); + startOutDir = cmSystemTools::CollapseFullPath(startOutDir); cm.SetHomeDirectory(homeDir); cm.SetStartDirectory(startDir); cm.SetHomeOutputDirectory(homeOutDir); @@ -885,15 +885,15 @@ int cmcmd::SymlinkExecutable(std::vector<std::string>& args) bool cmcmd::SymlinkInternal(std::string const& file, std::string const& link) { if(cmSystemTools::FileExists(link.c_str()) || - cmSystemTools::FileIsSymlink(link.c_str())) + cmSystemTools::FileIsSymlink(link)) { - cmSystemTools::RemoveFile(link.c_str()); + cmSystemTools::RemoveFile(link); } #if defined(_WIN32) && !defined(__CYGWIN__) return cmSystemTools::CopyFileAlways(file.c_str(), link.c_str()); #else std::string linktext = cmSystemTools::GetFilenameName(file); - return cmSystemTools::CreateSymlink(linktext.c_str(), link.c_str()); + return cmSystemTools::CreateSymlink(linktext, link); #endif } @@ -1318,7 +1318,7 @@ int cmcmd::VisualStudioLinkIncremental(std::vector<std::string>& args, } std::string manifestFile = targetName; manifestFile += ".embed.manifest"; - std::string fullPath= cmSystemTools::CollapseFullPath(manifestFile.c_str()); + std::string fullPath= cmSystemTools::CollapseFullPath(manifestFile); fout << type << " /* CREATEPROCESS_MANIFEST_RESOURCE_ID " "*/ 24 /* RT_MANIFEST */ " << "\"" << fullPath << "\""; fout.close(); diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index 2067690..8069ee2 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -96,7 +96,7 @@ ENDIF() IF(NOT KWSYS_NAMESPACE) SET(KWSYS_NAMESPACE "kwsys") SET(KWSYS_STANDALONE 1) -ENDIF(NOT KWSYS_NAMESPACE) +ENDIF() #----------------------------------------------------------------------------- # The project name is that of the specified namespace. @@ -130,49 +130,49 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) SET(KWSYS_USE_String 1) SET(KWSYS_USE_SystemInformation 1) SET(KWSYS_USE_CPU 1) -ENDIF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) +ENDIF() # Enforce component dependencies. IF(KWSYS_USE_SystemTools) SET(KWSYS_USE_Directory 1) SET(KWSYS_USE_FStream 1) SET(KWSYS_USE_Encoding 1) -ENDIF(KWSYS_USE_SystemTools) +ENDIF() IF(KWSYS_USE_Glob) SET(KWSYS_USE_Directory 1) SET(KWSYS_USE_SystemTools 1) SET(KWSYS_USE_RegularExpression 1) SET(KWSYS_USE_FStream 1) SET(KWSYS_USE_Encoding 1) -ENDIF(KWSYS_USE_Glob) +ENDIF() IF(KWSYS_USE_Process) SET(KWSYS_USE_System 1) SET(KWSYS_USE_Encoding 1) -ENDIF(KWSYS_USE_Process) +ENDIF() IF(KWSYS_USE_SystemInformation) SET(KWSYS_USE_Process 1) -ENDIF(KWSYS_USE_SystemInformation) +ENDIF() IF(KWSYS_USE_System) SET(KWSYS_USE_Encoding 1) -ENDIF(KWSYS_USE_System) +ENDIF() IF(KWSYS_USE_Directory) SET(KWSYS_USE_Encoding 1) -ENDIF(KWSYS_USE_Directory) +ENDIF() IF(KWSYS_USE_FStream) SET(KWSYS_USE_Encoding 1) -ENDIF(KWSYS_USE_FStream) +ENDIF() # Setup the large file support default. IF(KWSYS_LFS_DISABLE) SET(KWSYS_LFS_REQUESTED 0) -ELSE(KWSYS_LFS_DISABLE) +ELSE() SET(KWSYS_LFS_REQUESTED 1) -ENDIF(KWSYS_LFS_DISABLE) +ENDIF() # Specify default 8 bit encoding for Windows IF(NOT KWSYS_ENCODING_DEFAULT_CODEPAGE) SET(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_ACP) -ENDIF(NOT KWSYS_ENCODING_DEFAULT_CODEPAGE) +ENDIF() # Enable testing if building standalone. IF(KWSYS_STANDALONE) @@ -180,8 +180,8 @@ IF(KWSYS_STANDALONE) MARK_AS_ADVANCED(BUILD_TESTING DART_ROOT TCL_TCLSH) IF(BUILD_TESTING) ENABLE_TESTING() - ENDIF(BUILD_TESTING) -ENDIF(KWSYS_STANDALONE) + ENDIF() +ENDIF() # Include helper macros. INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/kwsysPlatformTests.cmake) @@ -197,15 +197,15 @@ INCLUDE_REGULAR_EXPRESSION("^.*$") IF(NOT KWSYS_INSTALL_INCLUDE_DIR) STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_INCLUDE_DIR "${KWSYS_HEADER_INSTALL_DIR}") -ENDIF(NOT KWSYS_INSTALL_INCLUDE_DIR) +ENDIF() IF(NOT KWSYS_INSTALL_LIB_DIR) STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_LIB_DIR "${KWSYS_LIBRARY_INSTALL_DIR}") -ENDIF(NOT KWSYS_INSTALL_LIB_DIR) +ENDIF() IF(NOT KWSYS_INSTALL_BIN_DIR) STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_BIN_DIR "${KWSYS_LIBRARY_INSTALL_DIR}") -ENDIF(NOT KWSYS_INSTALL_BIN_DIR) +ENDIF() # Setup header install rules. SET(KWSYS_INSTALL_INCLUDE_OPTIONS) @@ -213,7 +213,7 @@ IF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT) SET(KWSYS_INSTALL_INCLUDE_OPTIONS ${KWSYS_INSTALL_INCLUDE_OPTIONS} COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT} ) -ENDIF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT) +ENDIF() # Setup library install rules. SET(KWSYS_INSTALL_LIBRARY_RULE) @@ -230,7 +230,7 @@ IF(KWSYS_INSTALL_LIB_DIR) SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME} ) - ENDIF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME) + ENDIF() # Install the archive to the lib directory. SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} @@ -241,8 +241,8 @@ IF(KWSYS_INSTALL_LIB_DIR) SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT} ) - ENDIF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT) -ENDIF(KWSYS_INSTALL_LIB_DIR) + ENDIF() +ENDIF() IF(KWSYS_INSTALL_BIN_DIR) # Install the runtime library to the bin directory. SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} @@ -253,8 +253,8 @@ IF(KWSYS_INSTALL_BIN_DIR) SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME} ) - ENDIF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME) -ENDIF(KWSYS_INSTALL_BIN_DIR) + ENDIF() +ENDIF() # Do not support old KWSYS_*a_INSTALL_DIR variable names. SET(KWSYS_HEADER_INSTALL_DIR) @@ -266,7 +266,7 @@ STRING(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}" IF(NOT KWSYS_IN_SOURCE_BUILD) CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsysPrivate.h ${PROJECT_BINARY_DIR}/kwsysPrivate.h COPYONLY IMMEDIATE) -ENDIF(NOT KWSYS_IN_SOURCE_BUILD) +ENDIF() # Select plugin module file name convention. IF(NOT KWSYS_DynamicLoader_PREFIX) @@ -280,7 +280,7 @@ ENDIF() # We require ANSI support from the C compiler. Add any needed flags. IF(CMAKE_ANSI_CFLAGS) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}") -ENDIF(CMAKE_ANSI_CFLAGS) +ENDIF() #----------------------------------------------------------------------------- # Adjust compiler flags for some platforms. @@ -292,11 +292,11 @@ IF(NOT CMAKE_COMPILER_IS_GNUCXX) KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE "${CMAKE_CXX_FLAGS}") IF(NOT KWSYS_CXX_FLAGS_HAVE_IMPLICIT_LOCAL) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local") - ENDIF(NOT KWSYS_CXX_FLAGS_HAVE_IMPLICIT_LOCAL) + ENDIF() IF(NOT KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no_implicit_include") - ENDIF(NOT KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE) - ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V.*") + ENDIF() + ENDIF() IF(CMAKE_SYSTEM MATCHES "HP-UX") SET(KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS "+p") IF(CMAKE_CXX_COMPILER_ID MATCHES "HP") @@ -306,8 +306,8 @@ IF(NOT CMAKE_COMPILER_IS_GNUCXX) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA +hpxstd98") ENDIF() ENDIF() - ENDIF(CMAKE_SYSTEM MATCHES "HP-UX") -ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX) + ENDIF() +ENDIF() #----------------------------------------------------------------------------- # Configure Large File Support. @@ -327,11 +327,11 @@ IF(KWSYS_LFS_REQUESTED) IF(KWSYS_LFS_WORKS) SET(KWSYS_LFS_AVAILABLE 1) - ENDIF(KWSYS_LFS_WORKS) -ELSE(KWSYS_LFS_REQUESTED) + ENDIF() +ELSE() # Large File Support is not requested. SET(KWSYS_LFS_REQUESTED 0) -ENDIF(KWSYS_LFS_REQUESTED) +ENDIF() #----------------------------------------------------------------------------- # Configure the standard library header wrappers based on compiler's @@ -343,34 +343,34 @@ KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAVE_STD IF(KWSYS_IOS_FORCE_OLD) SET(KWSYS_IOS_USE_ANSI 0) -ELSE(KWSYS_IOS_FORCE_OLD) +ELSE() KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_ANSI "Checking whether ANSI stream headers are available" DIRECT) -ENDIF(KWSYS_IOS_FORCE_OLD) +ENDIF() IF(KWSYS_IOS_USE_ANSI) KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAVE_STD "Checking whether ANSI streams are in std namespace" DIRECT) KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_SSTREAM "Checking whether ANSI string stream is available" DIRECT) -ELSE(KWSYS_IOS_USE_ANSI) +ELSE() SET(KWSYS_IOS_HAVE_STD 0) SET(KWSYS_IOS_USE_SSTREAM 0) -ENDIF(KWSYS_IOS_USE_ANSI) +ENDIF() IF(KWSYS_IOS_USE_SSTREAM) SET(KWSYS_IOS_USE_STRSTREAM_H 0) SET(KWSYS_IOS_USE_STRSTREA_H 0) -ELSE(KWSYS_IOS_USE_SSTREAM) +ELSE() KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_STRSTREAM_H "Checking whether strstream.h is available" DIRECT) IF(KWSYS_IOS_USE_STRSTREAM_H) SET(KWSYS_IOS_USE_STRSTREA_H 0) - ELSE(KWSYS_IOS_USE_STRSTREAM_H) + ELSE() KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_STRSTREA_H "Checking whether strstrea.h is available" DIRECT) - ENDIF(KWSYS_IOS_USE_STRSTREAM_H) -ENDIF(KWSYS_IOS_USE_SSTREAM) + ENDIF() +ENDIF() KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_CSTDDEF "Checking whether header cstddef is available" DIRECT) @@ -384,16 +384,16 @@ KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ITERATOR_TRAITS IF(KWSYS_STL_HAS_ITERATOR_TRAITS) SET(KWSYS_STL_HAS_ITERATOR_CATEGORY 0) SET(KWSYS_STL_HAS___ITERATOR_CATEGORY 0) -ELSE(KWSYS_STL_HAS_ITERATOR_TRAITS) +ELSE() KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ITERATOR_CATEGORY "Checking whether stl has old iterator_category" DIRECT) IF(KWSYS_STL_HAS_ITERATOR_CATEGORY) SET(KWSYS_STL_HAS___ITERATOR_CATEGORY 0) - ELSE(KWSYS_STL_HAS_ITERATOR_CATEGORY) + ELSE() KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS___ITERATOR_CATEGORY "Checking whether stl has internal __iterator_category" DIRECT) - ENDIF(KWSYS_STL_HAS_ITERATOR_CATEGORY) -ENDIF(KWSYS_STL_HAS_ITERATOR_TRAITS) + ENDIF() +ENDIF() KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE "Checking whether stl has standard template allocator" DIRECT) IF(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE) @@ -402,25 +402,25 @@ IF(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE) "Checking for rebind member of stl allocator" DIRECT) KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT "Checking for non-standard argument to stl allocator<>::max_size" DIRECT) -ELSE(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE) +ELSE() KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE "Checking whether stl has old non-template allocator" DIRECT) SET(KWSYS_STL_HAS_ALLOCATOR_REBIND 0) SET(KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT 0) -ENDIF(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE) +ENDIF() KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_OBJECTS "Checking whether stl containers support allocator objects." DIRECT) IF(KWSYS_IOS_USE_ANSI AND NOT WATCOM) # ANSI streams always have string operators. SET(KWSYS_STL_STRING_HAVE_OSTREAM 1) SET(KWSYS_STL_STRING_HAVE_ISTREAM 1) -ELSE(KWSYS_IOS_USE_ANSI AND NOT WATCOM) +ELSE() # There may not be string operators for old streams. KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_STRING_HAVE_OSTREAM "Checking whether stl string has ostream operator<<" DIRECT) KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_STRING_HAVE_ISTREAM "Checking whether stl string has istream operator>>" DIRECT) -ENDIF(KWSYS_IOS_USE_ANSI AND NOT WATCOM) +ENDIF() SET(KWSYS_PLATFORM_CXX_TEST_DEFINES -DKWSYS_IOS_USE_ANSI=${KWSYS_IOS_USE_ANSI} -DKWSYS_IOS_HAVE_STD=${KWSYS_IOS_HAVE_STD}) @@ -440,7 +440,7 @@ KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP IF(UNIX) KWSYS_PLATFORM_CXX_TEST(KWSYS_STAT_HAS_ST_MTIM "Checking whether struct stat has st_mtim member" DIRECT) -ENDIF(UNIX) +ENDIF() # Check existence and uniqueness of long long and __int64. KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_LONG_LONG @@ -528,20 +528,20 @@ IF(KWSYS_USE_FundamentalType) IF(KWSYS_USE___INT64) KWSYS_PLATFORM_CXX_TEST(KWSYS_CAN_CONVERT_UI64_TO_DOUBLE "Checking whether unsigned __int64 can convert to double" DIRECT) - ELSE(KWSYS_USE___INT64) + ELSE() SET(KWSYS_CAN_CONVERT_UI64_TO_DOUBLE 1) - ENDIF(KWSYS_USE___INT64) + ENDIF() # Check signedness of "char" type. KWSYS_PLATFORM_CXX_TEST_RUN(KWSYS_CHAR_IS_SIGNED "Checking whether char is signed" DIRECT) -ENDIF(KWSYS_USE_FundamentalType) +ENDIF() IF(KWSYS_USE_Encoding) # Look for type size helper macros. KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_WSTRING "Checking whether wstring is available" DIRECT) -ENDIF(KWSYS_USE_Encoding) +ENDIF() IF(KWSYS_USE_IOStream) # Determine whether iostreams support long long. @@ -567,26 +567,26 @@ IF(KWSYS_USE_IOStream) SET(KWSYS_IOS_HAS_OSTREAM___INT64 0) ENDIF() SET(KWSYS_PLATFORM_CXX_TEST_DEFINES) -ENDIF(KWSYS_USE_IOStream) +ENDIF() IF(KWSYS_NAMESPACE MATCHES "^kwsys$") SET(KWSYS_NAME_IS_KWSYS 1) -ELSE(KWSYS_NAMESPACE MATCHES "^kwsys$") +ELSE() SET(KWSYS_NAME_IS_KWSYS 0) -ENDIF(KWSYS_NAMESPACE MATCHES "^kwsys$") +ENDIF() # Choose default shared/static build if not specified. IF(KWSYS_BUILD_SHARED MATCHES "^KWSYS_BUILD_SHARED$") SET(KWSYS_BUILD_SHARED ${BUILD_SHARED_LIBS}) -ENDIF(KWSYS_BUILD_SHARED MATCHES "^KWSYS_BUILD_SHARED$") +ENDIF() IF(KWSYS_BUILD_SHARED) SET(KWSYS_BUILD_SHARED 1) SET(KWSYS_LIBRARY_TYPE SHARED) -ELSE(KWSYS_BUILD_SHARED) +ELSE() SET(KWSYS_BUILD_SHARED 0) SET(KWSYS_LIBRARY_TYPE STATIC) -ENDIF(KWSYS_BUILD_SHARED) +ENDIF() #----------------------------------------------------------------------------- # Configure some implementation details. @@ -789,7 +789,7 @@ ENDIF() # Choose a directory for the generated headers. IF(NOT KWSYS_HEADER_ROOT) SET(KWSYS_HEADER_ROOT "${PROJECT_BINARY_DIR}") -ENDIF(NOT KWSYS_HEADER_ROOT) +ENDIF() SET(KWSYS_HEADER_DIR "${KWSYS_HEADER_ROOT}/${KWSYS_NAMESPACE}") INCLUDE_DIRECTORIES(${KWSYS_HEADER_ROOT}) @@ -801,13 +801,13 @@ IF(KWSYS_INSTALL_DOC_DIR) SET(KWSYS_INSTALL_LICENSE_OPTIONS ${KWSYS_INSTALL_LICENSE_OPTIONS} COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME} ) - ENDIF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME) + ENDIF() # Install the license under the documentation directory. INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt DESTINATION ${KWSYS_INSTALL_DOC_DIR}/${KWSYS_NAMESPACE} ${KWSYS_INSTALL_LICENSE_OPTIONS}) -ENDIF(KWSYS_INSTALL_DOC_DIR) +ENDIF() #----------------------------------------------------------------------------- # Create STL header wrappers to block warnings in the STL headers and @@ -844,10 +844,10 @@ FOREACH(header INSTALL(FILES ${KWSYS_HEADER_DIR}/stl/${header}.hxx DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}/stl ${KWSYS_INSTALL_INCLUDE_OPTIONS}) - ENDIF(KWSYS_INSTALL_INCLUDE_DIR) - ELSE(KWSYS_STL_HEADER_EXTRA_${header}) + ENDIF() + ELSE() SET(KWSYS_STL_HEADER_EXTRA "") - ENDIF(KWSYS_STL_HEADER_EXTRA_${header}) + ENDIF() CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_stl.hxx.in ${KWSYS_HEADER_DIR}/stl/${header} @ONLY IMMEDIATE) @@ -857,8 +857,8 @@ FOREACH(header INSTALL(FILES ${KWSYS_HEADER_DIR}/stl/${header} DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}/stl ${KWSYS_INSTALL_INCLUDE_OPTIONS}) - ENDIF(KWSYS_INSTALL_INCLUDE_DIR) -ENDFOREACH(header) + ENDIF() +ENDFOREACH() # Provide cstddef header. CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_cstddef.hxx.in @@ -868,7 +868,7 @@ IF(KWSYS_INSTALL_INCLUDE_DIR) INSTALL(FILES ${KWSYS_HEADER_DIR}/cstddef DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE} ${KWSYS_INSTALL_INCLUDE_OPTIONS}) -ENDIF(KWSYS_INSTALL_INCLUDE_DIR) +ENDIF() #----------------------------------------------------------------------------- # Create streams header wrappers to give standard names by which they @@ -884,8 +884,8 @@ FOREACH(header iostream fstream sstream iosfwd) INSTALL(FILES ${KWSYS_HEADER_DIR}/ios/${header} DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}/ios ${KWSYS_INSTALL_INCLUDE_OPTIONS}) - ENDIF(KWSYS_INSTALL_INCLUDE_DIR) -ENDFOREACH(header) + ENDIF() +ENDFOREACH() #----------------------------------------------------------------------------- # Build a list of classes and headers we need to implement the @@ -910,9 +910,9 @@ FOREACH(cpp ${cppclasses}) # Load component-specific CMake code. IF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake) INCLUDE(${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake) - ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake) - ENDIF(KWSYS_USE_${cpp}) -ENDFOREACH(cpp) + ENDIF() + ENDIF() +ENDFOREACH() # Add selected C components. FOREACH(c @@ -925,9 +925,9 @@ FOREACH(c # Load component-specific CMake code. IF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${c}.cmake) INCLUDE(${PROJECT_SOURCE_DIR}/kwsys${c}.cmake) - ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${c}.cmake) - ENDIF(KWSYS_USE_${c}) -ENDFOREACH(c) + ENDIF() + ENDIF() +ENDFOREACH() #----------------------------------------------------------------------------- # Build a list of sources for the library based on components that are @@ -940,11 +940,11 @@ IF(KWSYS_USE_Process) IF(NOT UNIX) # Use the Windows implementation. SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessWin32.c) - ELSE(NOT UNIX) + ELSE() # Use the UNIX implementation. SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessUNIX.c) - ENDIF(NOT UNIX) -ENDIF(KWSYS_USE_Process) + ENDIF() +ENDIF() # Add selected C sources. FOREACH(c Base64 Encoding MD5 Terminal System String) @@ -954,8 +954,8 @@ FOREACH(c Base64 Encoding MD5 Terminal System String) ELSE() LIST(APPEND KWSYS_C_SRCS ${c}.c) ENDIF() - ENDIF(KWSYS_USE_${c}) -ENDFOREACH(c) + ENDIF() +ENDFOREACH() # Configure headers of C++ classes and construct the list of sources. FOREACH(c ${KWSYS_CLASSES}) @@ -976,8 +976,8 @@ FOREACH(c ${KWSYS_CLASSES}) INSTALL(FILES ${KWSYS_HEADER_DIR}/${c}.hxx DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE} ${KWSYS_INSTALL_INCLUDE_OPTIONS}) - ENDIF(KWSYS_INSTALL_INCLUDE_DIR) -ENDFOREACH(c) + ENDIF() +ENDFOREACH() # Configure C headers. FOREACH(h ${KWSYS_H_FILES}) @@ -991,8 +991,8 @@ FOREACH(h ${KWSYS_H_FILES}) INSTALL(FILES ${KWSYS_HEADER_DIR}/${h}.h DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE} ${KWSYS_INSTALL_INCLUDE_OPTIONS}) - ENDIF(KWSYS_INSTALL_INCLUDE_DIR) -ENDFOREACH(h) + ENDIF() +ENDFOREACH() # Configure other C++ headers. FOREACH(h ${KWSYS_HXX_FILES}) @@ -1006,8 +1006,8 @@ FOREACH(h ${KWSYS_HXX_FILES}) INSTALL(FILES ${KWSYS_HEADER_DIR}/${h}.hxx DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE} ${KWSYS_INSTALL_INCLUDE_OPTIONS}) - ENDIF(KWSYS_INSTALL_INCLUDE_DIR) -ENDFOREACH(h) + ENDIF() +ENDFOREACH() #----------------------------------------------------------------------------- # Add the library with the configured name and list of sources. @@ -1018,8 +1018,8 @@ IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS) IF(KWSYS_USE_DynamicLoader) IF(UNIX) TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ${CMAKE_DL_LIBS}) - ENDIF(UNIX) - ENDIF(KWSYS_USE_DynamicLoader) + ENDIF() + ENDIF() IF(KWSYS_USE_SystemInformation) IF(WIN32) @@ -1044,13 +1044,13 @@ IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS) SET_TARGET_PROPERTIES(${KWSYS_NAMESPACE} PROPERTIES ${KWSYS_PROPERTIES_CXX} ) - ENDIF(KWSYS_PROPERTIES_CXX) + ENDIF() # Create an install target for the library. IF(KWSYS_INSTALL_LIBRARY_RULE) INSTALL(TARGETS ${KWSYS_NAMESPACE} ${KWSYS_INSTALL_LIBRARY_RULE}) - ENDIF(KWSYS_INSTALL_LIBRARY_RULE) -ENDIF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS) + ENDIF() +ENDIF() # Add a C-only library if requested. IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS) @@ -1062,20 +1062,20 @@ IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS) SET_TARGET_PROPERTIES(${KWSYS_NAMESPACE} PROPERTIES ${KWSYS_PROPERTIES_C} ) - ENDIF(KWSYS_PROPERTIES_C) + ENDIF() # Create an install target for the library. IF(KWSYS_INSTALL_LIBRARY_RULE) INSTALL(TARGETS ${KWSYS_NAMESPACE}_c ${KWSYS_INSTALL_LIBRARY_RULE}) - ENDIF(KWSYS_INSTALL_LIBRARY_RULE) -ENDIF(KWSYS_ENABLE_C AND KWSYS_C_SRCS) + ENDIF() +ENDIF() # For building kwsys itself, we use a macro defined on the command # line to configure the namespace in the C and C++ source files. ADD_DEFINITIONS("-DKWSYS_NAMESPACE=${KWSYS_NAMESPACE}") # Disable deprecation warnings for standard C functions. -IF(MSVC OR (WIN32 AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$")) +IF(MSVC OR (WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "Intel")) ADD_DEFINITIONS( -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE @@ -1093,13 +1093,13 @@ IF(KWSYS_USE_String) # Activate code in "String.c". See the comment in the source. SET_SOURCE_FILES_PROPERTIES(String.c PROPERTIES COMPILE_FLAGS "-DKWSYS_STRING_C") -ENDIF(KWSYS_USE_String) +ENDIF() IF(KWSYS_USE_Encoding) # Set default 8 bit encoding in "EndcodingC.c". SET_PROPERTY(SOURCE EncodingC.c APPEND PROPERTY COMPILE_DEFINITIONS KWSYS_ENCODING_DEFAULT_CODEPAGE=${KWSYS_ENCODING_DEFAULT_CODEPAGE}) -ENDIF(KWSYS_USE_Encoding) +ENDIF() #----------------------------------------------------------------------------- # Setup testing if not being built as part of another project. @@ -1109,7 +1109,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) SET(EXEC_DIR "${CMAKE_CURRENT_BINARY_DIR}") IF(EXECUTABLE_OUTPUT_PATH) SET(EXEC_DIR "${EXECUTABLE_OUTPUT_PATH}") - ENDIF(EXECUTABLE_OUTPUT_PATH) + ENDIF() # C tests SET(KWSYS_C_TESTS @@ -1129,7 +1129,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) FOREACH(test ${KWSYS_C_TESTS}) ADD_TEST(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsC ${test} ${KWSYS_TEST_ARGS_${test}}) SET_PROPERTY(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST}) - ENDFOREACH(test) + ENDFOREACH() # C++ tests IF(NOT WATCOM) @@ -1137,7 +1137,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) testAutoPtr testHashSTL ) - ENDIF(NOT WATCOM) + ENDIF() SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testIOS testSystemTools @@ -1148,22 +1148,22 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testEncoding ) - ENDIF(KWSYS_STL_HAS_WSTRING) + ENDIF() IF(KWSYS_USE_FStream) SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testFStream ) - ENDIF(KWSYS_USE_FStream) + ENDIF() IF(KWSYS_USE_SystemInformation) SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testSystemInformation) - ENDIF(KWSYS_USE_SystemInformation) + ENDIF() IF(KWSYS_USE_DynamicLoader) SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testDynamicLoader) # If kwsys contains the DynamicLoader, need extra library ADD_LIBRARY(${KWSYS_NAMESPACE}TestDynload MODULE testDynload.c) SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestDynload PROPERTY LABELS ${KWSYS_LABELS_LIB}) ADD_DEPENDENCIES(${KWSYS_NAMESPACE}TestDynload ${KWSYS_NAMESPACE}) - ENDIF(KWSYS_USE_DynamicLoader) + ENDIF() CREATE_TEST_SOURCELIST( KWSYS_CXX_TEST_SRCS ${KWSYS_NAMESPACE}TestsCxx.cxx ${KWSYS_CXX_TESTS} @@ -1183,7 +1183,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ExtraTest.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/ExtraTest.cmake") SET_DIRECTORY_PROPERTIES(PROPERTIES TEST_INCLUDE_FILE "${CMAKE_CURRENT_BINARY_DIR}/ExtraTest.cmake") - ENDIF(CTEST_TEST_KWSYS) + ENDIF() SET(KWSYS_TEST_ARGS_testCommandLineArguments --another-bool-variable @@ -1216,7 +1216,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) FOREACH(test ${KWSYS_CXX_TESTS}) ADD_TEST(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsCxx ${test} ${KWSYS_TEST_ARGS_${test}}) SET_PROPERTY(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST}) - ENDFOREACH(test) + ENDFOREACH() # Process tests. ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestProcess testProcess.c) @@ -1224,15 +1224,15 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestProcess ${KWSYS_NAMESPACE}_c) IF(NOT CYGWIN) SET(KWSYS_TEST_PROCESS_7 7) - ENDIF(NOT CYGWIN) + ENDIF() FOREACH(n 1 2 3 4 5 6 ${KWSYS_TEST_PROCESS_7}) ADD_TEST(kwsys.testProcess-${n} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestProcess ${n}) SET_PROPERTY(TEST kwsys.testProcess-${n} PROPERTY LABELS ${KWSYS_LABELS_TEST}) SET_TESTS_PROPERTIES(kwsys.testProcess-${n} PROPERTIES TIMEOUT 120) - ENDFOREACH(n) + ENDFOREACH() # Some Apple compilers produce bad optimizations in this source. - IF(APPLE AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU|LLVM)$") + IF(APPLE AND CMAKE_C_COMPILER_ID MATCHES "^(GNU|LLVM)$") SET_SOURCE_FILES_PROPERTIES(testProcess.c PROPERTIES COMPILE_FLAGS -O0) ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "XL") # Tell IBM XL not to warn about our test infinite loop @@ -1263,5 +1263,5 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) SET_TESTS_PROPERTIES(${KWSYS_TEST_BOGUS_FAILURES} PROPERTIES WILL_FAIL ON) ENDIF() - ENDIF(BUILD_TESTING) -ENDIF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) + ENDIF() +ENDIF() diff --git a/Source/kwsys/Directory.hxx.in b/Source/kwsys/Directory.hxx.in index 0acb191..1bcf90e 100644 --- a/Source/kwsys/Directory.hxx.in +++ b/Source/kwsys/Directory.hxx.in @@ -18,7 +18,6 @@ /* Define these macros temporarily to keep the code readable. */ #if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS # define kwsys_stl @KWSYS_NAMESPACE@_stl -# define kwsys_ios @KWSYS_NAMESPACE@_ios #endif namespace @KWSYS_NAMESPACE@ @@ -87,7 +86,6 @@ private: /* Undefine temporary macros. */ #if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS # undef kwsys_stl -# undef kwsys_ios #endif #endif diff --git a/Source/kwsys/DynamicLoader.cxx b/Source/kwsys/DynamicLoader.cxx index 44cf6af..66c7d57 100644 --- a/Source/kwsys/DynamicLoader.cxx +++ b/Source/kwsys/DynamicLoader.cxx @@ -40,9 +40,9 @@ namespace KWSYS_NAMESPACE { //---------------------------------------------------------------------------- -DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname ) +DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const kwsys_stl::string& libname ) { - return shl_load(libname, BIND_DEFERRED | DYNAMIC_PATH, 0L); + return shl_load(libname.c_str(), BIND_DEFERRED | DYNAMIC_PATH, 0L); } //---------------------------------------------------------------------------- @@ -53,7 +53,7 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib) //---------------------------------------------------------------------------- DynamicLoader::SymbolPointer -DynamicLoader::GetSymbolAddress(DynamicLoader::LibraryHandle lib, const char* sym) +DynamicLoader::GetSymbolAddress(DynamicLoader::LibraryHandle lib, const kwsys_stl::string& sym) { void* addr; int status; @@ -62,7 +62,7 @@ DynamicLoader::GetSymbolAddress(DynamicLoader::LibraryHandle lib, const char* sy * TYPE_DATA Look for a symbol in the data segment (for example, variables). * TYPE_UNDEFINED Look for any symbol. */ - status = shl_findsym (&lib, sym, TYPE_UNDEFINED, &addr); + status = shl_findsym (&lib, sym.c_str(), TYPE_UNDEFINED, &addr); void* result = (status < 0) ? (void*)0 : addr; // Hack to cast pointer-to-data to pointer-to-function. @@ -111,18 +111,18 @@ namespace KWSYS_NAMESPACE { //---------------------------------------------------------------------------- -DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname ) +DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const kwsys_stl::string& libname ) { NSObjectFileImageReturnCode rc; NSObjectFileImage image = 0; - rc = NSCreateObjectFileImageFromFile(libname, &image); + rc = NSCreateObjectFileImageFromFile(libname.c_str(), &image); // rc == NSObjectFileImageInappropriateFile when trying to load a dylib file if( rc != NSObjectFileImageSuccess ) { return 0; } - NSModule handle = NSLinkModule(image, libname, + NSModule handle = NSLinkModule(image, libname.c_str(), NSLINKMODULE_OPTION_BINDNOW|NSLINKMODULE_OPTION_RETURN_ON_ERROR); NSDestroyObjectFileImage(image); return handle; @@ -142,14 +142,14 @@ int DynamicLoader::CloseLibrary( DynamicLoader::LibraryHandle lib) //---------------------------------------------------------------------------- DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( - DynamicLoader::LibraryHandle lib, const char* sym) + DynamicLoader::LibraryHandle lib, const kwsys_stl::string& sym) { void *result=0; // Need to prepend symbols with '_' on Apple-gcc compilers - size_t len = strlen(sym); + size_t len = sym.size(); char *rsym = new char[len + 1 + 1]; strcpy(rsym, "_"); - strcat(rsym+1, sym); + strcat(rsym+1, sym.c_str()); NSSymbol symbol = NSLookupSymbolInModule(lib, rsym); if(symbol) @@ -183,13 +183,13 @@ namespace KWSYS_NAMESPACE { //---------------------------------------------------------------------------- -DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname) +DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const kwsys_stl::string& libname) { DynamicLoader::LibraryHandle lh; - int length = MultiByteToWideChar(CP_UTF8, 0, libname, -1, NULL, 0); + int length = MultiByteToWideChar(CP_UTF8, 0, libname.c_str(), -1, NULL, 0); wchar_t* wchars = new wchar_t[length+1]; wchars[0] = '\0'; - MultiByteToWideChar(CP_UTF8, 0, libname, -1, wchars, length); + MultiByteToWideChar(CP_UTF8, 0, libname.c_str(), -1, wchars, length); lh = LoadLibraryW(wchars); delete [] wchars; return lh; @@ -203,7 +203,7 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib) //---------------------------------------------------------------------------- DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( - DynamicLoader::LibraryHandle lib, const char* sym) + DynamicLoader::LibraryHandle lib, const kwsys_stl::string& sym) { // TODO: The calling convention affects the name of the symbol. We // should have a tool to help get the symbol with the desired @@ -230,12 +230,12 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( void *result; #if defined(__BORLANDC__) || defined(__WATCOMC__) // Need to prepend symbols with '_' - size_t len = strlen(sym); + size_t len = sym.size(); char *rsym = new char[len + 1 + 1]; strcpy(rsym, "_"); - strcat(rsym, sym); + strcat(rsym, sym.c_str()); #else - const char *rsym = sym; + const char *rsym = sym.c_str(); #endif result = (void*)GetProcAddress(lib, rsym); #if defined(__BORLANDC__) || defined(__WATCOMC__) @@ -298,11 +298,11 @@ namespace KWSYS_NAMESPACE static image_id last_dynamic_err = B_OK; //---------------------------------------------------------------------------- -DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname ) +DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const kwsys_stl::string& libname ) { // image_id's are integers, errors are negative. Add one just in case we // get a valid image_id of zero (is that even possible?). - image_id rc = load_add_on(libname); + image_id rc = load_add_on(libname.c_str()); if (rc < 0) { last_dynamic_err = rc; @@ -336,7 +336,7 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib) //---------------------------------------------------------------------------- DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( - DynamicLoader::LibraryHandle lib, const char* sym) + DynamicLoader::LibraryHandle lib, const kwsys_stl::string& sym) { // Hack to cast pointer-to-data to pointer-to-function. union @@ -356,7 +356,7 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( // !!! FIXME: BeOS can do function-only lookups...does this ever // !!! FIXME: actually _want_ a data symbol lookup, or was this union // !!! FIXME: a leftover of dlsym()? (s/ANY/TEXT for functions only). - status_t rc = get_image_symbol(lib-1,sym,B_SYMBOL_TYPE_ANY,&result.pvoid); + status_t rc = get_image_symbol(lib-1,sym.c_str(),B_SYMBOL_TYPE_ANY,&result.pvoid); if (rc != B_OK) { last_dynamic_err = rc; @@ -389,7 +389,7 @@ namespace KWSYS_NAMESPACE { //---------------------------------------------------------------------------- -DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname ) +DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const kwsys_stl::string& libname ) { return 0; } @@ -407,7 +407,7 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib) //---------------------------------------------------------------------------- DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( - DynamicLoader::LibraryHandle lib, const char* sym) + DynamicLoader::LibraryHandle lib, const kwsys_stl::string& sym) { return 0; } @@ -433,12 +433,12 @@ namespace KWSYS_NAMESPACE { //---------------------------------------------------------------------------- -DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname ) +DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const kwsys_stl::string& libname ) { - char *name = (char *)calloc(1, strlen(libname) + 1); + char *name = (char *)calloc(1, libname.size() + 1); dld_init(program_invocation_name); - strncpy(name, libname, strlen(libname)); - dld_link(libname); + strncpy(name, libname.c_str(), libname.size()); + dld_link(libname.c_str()); return (void *)name; } @@ -452,7 +452,7 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib) //---------------------------------------------------------------------------- DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( - DynamicLoader::LibraryHandle lib, const char* sym) + DynamicLoader::LibraryHandle lib, const kwsys_stl::string& sym) { // Hack to cast pointer-to-data to pointer-to-function. union @@ -460,7 +460,7 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( void* pvoid; DynamicLoader::SymbolPointer psym; } result; - result.pvoid = dld_get_symbol(sym); + result.pvoid = dld_get_symbol(sym.c_str()); return result.psym; } @@ -485,9 +485,9 @@ namespace KWSYS_NAMESPACE { //---------------------------------------------------------------------------- -DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname ) +DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const kwsys_stl::string& libname ) { - return dlopen(libname, RTLD_LAZY); + return dlopen(libname.c_str(), RTLD_LAZY); } //---------------------------------------------------------------------------- @@ -504,7 +504,7 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib) //---------------------------------------------------------------------------- DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( - DynamicLoader::LibraryHandle lib, const char* sym) + DynamicLoader::LibraryHandle lib, const kwsys_stl::string& sym) { // Hack to cast pointer-to-data to pointer-to-function. union @@ -512,7 +512,7 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress( void* pvoid; DynamicLoader::SymbolPointer psym; } result; - result.pvoid = dlsym(lib, sym); + result.pvoid = dlsym(lib, sym.c_str()); return result.psym; } diff --git a/Source/kwsys/DynamicLoader.hxx.in b/Source/kwsys/DynamicLoader.hxx.in index 64468ec..75811ab 100644 --- a/Source/kwsys/DynamicLoader.hxx.in +++ b/Source/kwsys/DynamicLoader.hxx.in @@ -13,6 +13,7 @@ #define @KWSYS_NAMESPACE@_DynamicLoader_hxx #include <@KWSYS_NAMESPACE@/Configure.h> +#include <@KWSYS_NAMESPACE@/stl/string> #if defined(__hpux) #include <dl.h> @@ -27,6 +28,11 @@ #include <be/kernel/image.h> #endif +/* Define these macros temporarily to keep the code readable. */ +#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS +# define kwsys_stl @KWSYS_NAMESPACE@_stl +#endif + namespace @KWSYS_NAMESPACE@ { /** \class DynamicLoader @@ -77,14 +83,14 @@ public: /** Load a dynamic library into the current process. * The returned LibraryHandle can be used to access the symbols in the * library. */ - static LibraryHandle OpenLibrary(const char*); + static LibraryHandle OpenLibrary(const kwsys_stl::string&); /** Attempt to detach a dynamic library from the * process. A value of true is returned if it is sucessful. */ static int CloseLibrary(LibraryHandle); /** Find the address of the symbol in the given library. */ - static SymbolPointer GetSymbolAddress(LibraryHandle, const char*); + static SymbolPointer GetSymbolAddress(LibraryHandle, const kwsys_stl::string&); /** Return the default module prefix for the current platform. */ static const char* LibPrefix() { return "@KWSYS_DynamicLoader_PREFIX@"; } @@ -98,4 +104,9 @@ public: } // namespace @KWSYS_NAMESPACE@ +/* Undefine temporary macros. */ +#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS +# undef kwsys_stl +#endif + #endif diff --git a/Source/kwsys/Glob.cxx b/Source/kwsys/Glob.cxx index 0916d2e..5a96aed 100644 --- a/Source/kwsys/Glob.cxx +++ b/Source/kwsys/Glob.cxx @@ -501,7 +501,7 @@ void Glob::AddFile(kwsys_stl::vector<kwsys_stl::string>& files, const kwsys_stl: { if ( !this->Relative.empty() ) { - files.push_back(kwsys::SystemTools::RelativePath(this->Relative.c_str(), file.c_str())); + files.push_back(kwsys::SystemTools::RelativePath(this->Relative, file)); } else { diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index c4aeb47..3e1a1ab 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -5156,7 +5156,7 @@ bool SystemInformationImplementation::QueryOSInformation() } } - sprintf (operatingSystem, "%s (Build %ld)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF); + sprintf (operatingSystem, "%ls (Build %ld)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF); this->OSVersion = operatingSystem; } else @@ -5205,7 +5205,7 @@ bool SystemInformationImplementation::QueryOSInformation() if (osvi.dwMajorVersion <= 4) { // NB: NT 4.0 and earlier. - sprintf (operatingSystem, "version %ld.%ld %s (Build %ld)", + sprintf (operatingSystem, "version %ld.%ld %ls (Build %ld)", osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.szCSDVersion, @@ -5236,7 +5236,7 @@ bool SystemInformationImplementation::QueryOSInformation() else { // Windows 2000 and everything else. - sprintf (operatingSystem,"%s (Build %ld)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF); + sprintf (operatingSystem,"%ls (Build %ld)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF); this->OSVersion = operatingSystem; } break; diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index b1221e3..e4c82d8 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -222,7 +222,7 @@ inline int Rmdir(const kwsys_stl::string& dir) inline const char* Getcwd(char* buf, unsigned int len) { std::vector<wchar_t> w_buf(len); - if(const wchar_t* ret = _wgetcwd(&w_buf[0], len)) + if(_wgetcwd(&w_buf[0], len)) { // make sure the drive letter is capital if(wcslen(&w_buf[0]) > 1 && w_buf[1] == L':') @@ -385,6 +385,11 @@ const char* SystemTools::GetEnv(const char* key) return getenv(key); } +const char* SystemTools::GetEnv(const kwsys_stl::string& key) +{ + return SystemTools::GetEnv(key.c_str()); +} + bool SystemTools::GetEnv(const char* key, kwsys_stl::string& result) { const char* v = getenv(key); @@ -399,6 +404,11 @@ bool SystemTools::GetEnv(const char* key, kwsys_stl::string& result) } } +bool SystemTools::GetEnv(const kwsys_stl::string& key, kwsys_stl::string& result) +{ + return SystemTools::GetEnv(key.c_str(), result); +} + //---------------------------------------------------------------------------- #if defined(__CYGWIN__) || defined(__GLIBC__) @@ -410,27 +420,28 @@ bool SystemTools::GetEnv(const char* key, kwsys_stl::string& result) #if KWSYS_CXX_HAS_UNSETENV /* unsetenv("A") removes A from the environment. On older platforms it returns void instead of int. */ -static int kwsysUnPutEnv(const char* env) +static int kwsysUnPutEnv(const kwsys_stl::string& env) { - if(const char* eq = strchr(env, '=')) + size_t pos = env.find('='); + if(pos != env.npos) { - std::string name(env, eq-env); + std::string name = env.substr(0, pos); unsetenv(name.c_str()); } else { - unsetenv(env); + unsetenv(env.c_str()); } return 0; } #elif defined(KWSYS_PUTENV_EMPTY) || defined(KWSYS_PUTENV_NAME) /* putenv("A=") or putenv("A") removes A from the environment. */ -static int kwsysUnPutEnv(const char* env) +static int kwsysUnPutEnv(const kwsys_stl::string& env) { int err = 0; - const char* eq = strchr(env, '='); - size_t const len = eq? (size_t)(eq-env) : strlen(env); + size_t pos = env.find('='); + size_t const len = pos == env.npos ? env.size() : pos; # ifdef KWSYS_PUTENV_EMPTY size_t const sz = len + 2; # else @@ -442,7 +453,7 @@ static int kwsysUnPutEnv(const char* env) { return -1; } - strncpy(buf, env, len); + strncpy(buf, env.c_str(), len); # ifdef KWSYS_PUTENV_EMPTY buf[len] = '='; buf[len+1] = 0; @@ -471,17 +482,17 @@ static int kwsysUnPutEnv(const char* env) #else /* Manipulate the "environ" global directly. */ -static int kwsysUnPutEnv(const char* env) +static int kwsysUnPutEnv(const kwsys_stl::string& env) { - const char* eq = strchr(env, '='); - size_t const len = eq? (size_t)(eq-env) : strlen(env); + size_t pos = env.find('='); + size_t const len = pos == env.npos ? env.size() : pos; int in = 0; int out = 0; while(environ[in]) { if(strlen(environ[in]) > len && environ[in][len] == '=' && - strncmp(env, environ[in], len) == 0) + strncmp(env.c_str(), environ[in], len) == 0) { ++in; } @@ -504,12 +515,13 @@ static int kwsysUnPutEnv(const char* env) /* setenv("A", "B", 1) will set A=B in the environment and makes its own copies of the strings. */ -bool SystemTools::PutEnv(const char* env) +bool SystemTools::PutEnv(const kwsys_stl::string& env) { - if(const char* eq = strchr(env, '=')) + size_t pos = env.find('='); + if(pos != env.npos) { - std::string name(env, eq-env); - return setenv(name.c_str(), eq+1, 1) == 0; + std::string name = env.substr(0, pos); + return setenv(name.c_str(), env.c_str() + pos + 1, 1) == 0; } else { @@ -517,7 +529,7 @@ bool SystemTools::PutEnv(const char* env) } } -bool SystemTools::UnPutEnv(const char* env) +bool SystemTools::UnPutEnv(const kwsys_stl::string& env) { return kwsysUnPutEnv(env) == 0; } @@ -603,14 +615,14 @@ public: static kwsysEnv kwsysEnvInstance; -bool SystemTools::PutEnv(const char* env) +bool SystemTools::PutEnv(const kwsys_stl::string& env) { - return kwsysEnvInstance.Put(env); + return kwsysEnvInstance.Put(env.c_str()); } -bool SystemTools::UnPutEnv(const char* env) +bool SystemTools::UnPutEnv(const kwsys_stl::string& env) { - return kwsysEnvInstance.UnPut(env); + return kwsysEnvInstance.UnPut(env.c_str()); } #endif @@ -689,8 +701,35 @@ bool SystemTools::MakeDirectory(const kwsys_stl::string& path) // replace replace with with as many times as it shows up in source. // write the result into source. void SystemTools::ReplaceString(kwsys_stl::string& source, - const char* replace, - const char* with) + const kwsys_stl::string& replace, + const kwsys_stl::string& with) +{ + // do while hangs if replaceSize is 0 + if (replace.empty()) + { + return; + } + + SystemTools::ReplaceString(source, replace.c_str(), replace.size(), with); +} + +void SystemTools::ReplaceString(kwsys_stl::string& source, + const char* replace, + const char* with) +{ + // do while hangs if replaceSize is 0 + if (!*replace) + { + return; + } + + SystemTools::ReplaceString(source, replace, strlen(replace), with ? with : ""); +} + +void SystemTools::ReplaceString(kwsys_stl::string& source, + const char* replace, + size_t replaceSize, + const kwsys_stl::string& with) { const char *src = source.c_str(); char *searchPos = const_cast<char *>(strstr(src,replace)); @@ -702,12 +741,6 @@ void SystemTools::ReplaceString(kwsys_stl::string& source, } // perform replacements until done - size_t replaceSize = strlen(replace); - // do while hangs if replaceSize is 0 - if(replaceSize == 0) - { - return; - } char *orig = strdup(src); char *currentPos = orig; searchPos = searchPos - src + orig; @@ -739,20 +772,20 @@ void SystemTools::ReplaceString(kwsys_stl::string& source, #endif #if defined(_WIN32) && !defined(__CYGWIN__) -static bool SystemToolsParseRegistryKey(const char* key, +static bool SystemToolsParseRegistryKey(const kwsys_stl::string& key, HKEY& primaryKey, kwsys_stl::string& second, kwsys_stl::string& valuename) { kwsys_stl::string primary = key; - size_t start = primary.find("\\"); + size_t start = primary.find('\\'); if (start == kwsys_stl::string::npos) { return false; } - size_t valuenamepos = primary.find(";"); + size_t valuenamepos = primary.find(';'); if (valuenamepos != kwsys_stl::string::npos) { valuename = primary.substr(valuenamepos+1); @@ -810,7 +843,7 @@ static DWORD SystemToolsMakeRegistryMode(DWORD mode, #if defined(_WIN32) && !defined(__CYGWIN__) bool -SystemTools::GetRegistrySubKeys(const char *key, +SystemTools::GetRegistrySubKeys(const kwsys_stl::string& key, kwsys_stl::vector<kwsys_stl::string>& subkeys, KeyWOW64 view) { @@ -849,7 +882,7 @@ SystemTools::GetRegistrySubKeys(const char *key, return true; } #else -bool SystemTools::GetRegistrySubKeys(const char *, +bool SystemTools::GetRegistrySubKeys(const kwsys_stl::string&, kwsys_stl::vector<kwsys_stl::string>&, KeyWOW64) { @@ -865,7 +898,7 @@ bool SystemTools::GetRegistrySubKeys(const char *, // => will return the data of the "Root" value of the key #if defined(_WIN32) && !defined(__CYGWIN__) -bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value, +bool SystemTools::ReadRegistryValue(const kwsys_stl::string& key, kwsys_stl::string &value, KeyWOW64 view) { bool valueset = false; @@ -922,7 +955,7 @@ bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value, return valueset; } #else -bool SystemTools::ReadRegistryValue(const char *, kwsys_stl::string &, +bool SystemTools::ReadRegistryValue(const kwsys_stl::string&, kwsys_stl::string &, KeyWOW64) { return false; @@ -938,7 +971,8 @@ bool SystemTools::ReadRegistryValue(const char *, kwsys_stl::string &, // => will set the data of the "Root" value of the key #if defined(_WIN32) && !defined(__CYGWIN__) -bool SystemTools::WriteRegistryValue(const char *key, const char *value, +bool SystemTools::WriteRegistryValue(const kwsys_stl::string& key, + const kwsys_stl::string& value, KeyWOW64 view) { HKEY primaryKey = HKEY_CURRENT_USER; @@ -978,7 +1012,7 @@ bool SystemTools::WriteRegistryValue(const char *key, const char *value, return false; } #else -bool SystemTools::WriteRegistryValue(const char *, const char *, KeyWOW64) +bool SystemTools::WriteRegistryValue(const kwsys_stl::string&, const kwsys_stl::string&, KeyWOW64) { return false; } @@ -992,7 +1026,7 @@ bool SystemTools::WriteRegistryValue(const char *, const char *, KeyWOW64) // => will delete the data of the "Root" value of the key #if defined(_WIN32) && !defined(__CYGWIN__) -bool SystemTools::DeleteRegistryValue(const char *key, KeyWOW64 view) +bool SystemTools::DeleteRegistryValue(const kwsys_stl::string& key, KeyWOW64 view) { HKEY primaryKey = HKEY_CURRENT_USER; kwsys_stl::string second; @@ -1023,7 +1057,7 @@ bool SystemTools::DeleteRegistryValue(const char *key, KeyWOW64 view) return false; } #else -bool SystemTools::DeleteRegistryValue(const char *, KeyWOW64) +bool SystemTools::DeleteRegistryValue(const kwsys_stl::string&, KeyWOW64) { return false; } @@ -2245,12 +2279,13 @@ bool SystemTools::CopyFileAlways(const kwsys_stl::string& source, const kwsys_st SystemTools::MakeDirectory(destination_dir); // Open files - -#if defined(_WIN32) || defined(__CYGWIN__) - kwsys::ifstream fin(source.c_str(), - kwsys_ios::ios::binary | kwsys_ios::ios::in); +#if defined(_WIN32) + kwsys::ifstream fin(Encoding::ToNarrow( + SystemTools::ConvertToWindowsExtendedPath(source)).c_str(), + kwsys_ios::ios::in | kwsys_ios_binary); #else - kwsys::ifstream fin(source.c_str()); + kwsys::ifstream fin(source.c_str(), + kwsys_ios::ios::in | kwsys_ios_binary); #endif if(!fin) { @@ -2263,12 +2298,13 @@ bool SystemTools::CopyFileAlways(const kwsys_stl::string& source, const kwsys_st // that do not allow file removal can be modified. SystemTools::RemoveFile(real_destination); -#if defined(_WIN32) || defined(__CYGWIN__) - kwsys::ofstream fout(real_destination.c_str(), - kwsys_ios::ios::binary | kwsys_ios::ios::out | kwsys_ios::ios::trunc); +#if defined(_WIN32) + kwsys::ofstream fout(Encoding::ToNarrow( + SystemTools::ConvertToWindowsExtendedPath(real_destination)).c_str(), + kwsys_ios::ios::out | kwsys_ios::ios::trunc | kwsys_ios_binary); #else kwsys::ofstream fout(real_destination.c_str(), - kwsys_ios::ios::out | kwsys_ios::ios::trunc); + kwsys_ios::ios::out | kwsys_ios::ios::trunc | kwsys_ios_binary); #endif if(!fout) { @@ -2379,7 +2415,7 @@ bool SystemTools::CopyADirectory(const kwsys_stl::string& source, const kwsys_st // return size of file; also returns zero if no file exists -unsigned long SystemTools::FileLength(const char* filename) +unsigned long SystemTools::FileLength(const kwsys_stl::string& filename) { unsigned long length = 0; #ifdef _WIN32 @@ -2397,7 +2433,7 @@ unsigned long SystemTools::FileLength(const char* filename) } #else struct stat fs; - if (stat(filename, &fs) == 0) + if (stat(filename.c_str(), &fs) == 0) { length = static_cast<unsigned long>(fs.st_size); } @@ -2663,7 +2699,7 @@ size_t SystemTools::GetMaximumFilePathLength() * found. Otherwise, the empty string is returned. */ kwsys_stl::string SystemTools -::FindName(const char* name, +::FindName(const kwsys_stl::string& name, const kwsys_stl::vector<kwsys_stl::string>& userPaths, bool no_system_path) { @@ -2716,7 +2752,7 @@ kwsys_stl::string SystemTools * found. Otherwise, the empty string is returned. */ kwsys_stl::string SystemTools -::FindFile(const char* name, +::FindFile(const kwsys_stl::string& name, const kwsys_stl::vector<kwsys_stl::string>& userPaths, bool no_system_path) { @@ -2735,7 +2771,7 @@ kwsys_stl::string SystemTools * found. Otherwise, the empty string is returned. */ kwsys_stl::string SystemTools -::FindDirectory(const char* name, +::FindDirectory(const kwsys_stl::string& name, const kwsys_stl::vector<kwsys_stl::string>& userPaths, bool no_system_path) { @@ -3078,29 +3114,29 @@ bool SystemTools::FileIsSymlink(const kwsys_stl::string& name) } #if defined(_WIN32) && !defined(__CYGWIN__) -bool SystemTools::CreateSymlink(const char*, const char*) +bool SystemTools::CreateSymlink(const kwsys_stl::string&, const kwsys_stl::string&) { return false; } #else -bool SystemTools::CreateSymlink(const char* origName, const char* newName) +bool SystemTools::CreateSymlink(const kwsys_stl::string& origName, const kwsys_stl::string& newName) { - return symlink(origName, newName) >= 0; + return symlink(origName.c_str(), newName.c_str()) >= 0; } #endif #if defined(_WIN32) && !defined(__CYGWIN__) -bool SystemTools::ReadSymlink(const char*, kwsys_stl::string&) +bool SystemTools::ReadSymlink(const kwsys_stl::string&, kwsys_stl::string&) { return false; } #else -bool SystemTools::ReadSymlink(const char* newName, +bool SystemTools::ReadSymlink(const kwsys_stl::string& newName, kwsys_stl::string& origName) { char buf[KWSYS_SYSTEMTOOLS_MAXPATH+1]; int count = - static_cast<int>(readlink(newName, buf, KWSYS_SYSTEMTOOLS_MAXPATH)); + static_cast<int>(readlink(newName.c_str(), buf, KWSYS_SYSTEMTOOLS_MAXPATH)); if(count >= 0) { // Add null-terminator. @@ -3136,14 +3172,14 @@ kwsys_stl::string SystemTools::GetCurrentWorkingDirectory(bool collapse) return path; } -kwsys_stl::string SystemTools::GetProgramPath(const char* in_name) +kwsys_stl::string SystemTools::GetProgramPath(const kwsys_stl::string& in_name) { kwsys_stl::string dir, file; SystemTools::SplitProgramPath(in_name, dir, file); return dir; } -bool SystemTools::SplitProgramPath(const char* in_name, +bool SystemTools::SplitProgramPath(const kwsys_stl::string& in_name, kwsys_stl::string& dir, kwsys_stl::string& file, bool) @@ -3409,7 +3445,62 @@ kwsys_stl::string SystemTools::CollapseFullPath(const kwsys_stl::string& in_path SystemTools::CheckTranslationPath(newPath); #ifdef _WIN32 - newPath = SystemTools::GetActualCaseForPath(newPath.c_str()); + newPath = SystemTools::GetActualCaseForPath(newPath); + SystemTools::ConvertToUnixSlashes(newPath); +#endif + // Return the reconstructed path. + return newPath; +} + +kwsys_stl::string SystemTools::CollapseFullPath(const kwsys_stl::string& in_path, + const kwsys_stl::string& in_base) +{ + // Collect the output path components. + kwsys_stl::vector<kwsys_stl::string> out_components; + + // Split the input path components. + kwsys_stl::vector<kwsys_stl::string> path_components; + SystemTools::SplitPath(in_path, path_components); + + // If the input path is relative, start with a base path. + if(path_components[0].length() == 0) + { + kwsys_stl::vector<kwsys_stl::string> base_components; + // Use the given base path. + SystemTools::SplitPath(in_base, base_components); + + // Append base path components to the output path. + out_components.push_back(base_components[0]); + SystemToolsAppendComponents(out_components, + base_components.begin()+1, + base_components.end()); + } + + // Append input path components to the output path. + SystemToolsAppendComponents(out_components, + path_components.begin(), + path_components.end()); + + // Transform the path back to a string. + kwsys_stl::string newPath = SystemTools::JoinPath(out_components); + + // Update the translation table with this potentially new path. I am not + // sure why this line is here, it seems really questionable, but yet I + // would put good money that if I remove it something will break, basically + // from what I can see it created a mapping from the collapsed path, to be + // replaced by the input path, which almost completely does the opposite of + // this function, the only thing preventing this from happening a lot is + // that if the in_path has a .. in it, then it is not added to the + // translation table. So for most calls this either does nothing due to the + // .. or it adds a translation between identical paths as nothing was + // collapsed, so I am going to try to comment it out, and see what hits the + // fan, hopefully quickly. + // Commented out line below: + //SystemTools::AddTranslationPath(newPath, in_path); + + SystemTools::CheckTranslationPath(newPath); +#ifdef _WIN32 + newPath = SystemTools::GetActualCaseForPath(newPath); SystemTools::ConvertToUnixSlashes(newPath); #endif // Return the reconstructed path. @@ -3569,7 +3660,7 @@ static int GetCasePathName(const kwsys_stl::string & pathIn, //---------------------------------------------------------------------------- -kwsys_stl::string SystemTools::GetActualCaseForPath(const char* p) +kwsys_stl::string SystemTools::GetActualCaseForPath(const kwsys_stl::string& p) { #ifndef _WIN32 return p; @@ -3930,7 +4021,7 @@ kwsys_stl::string SystemTools::GetFilenameName(const kwsys_stl::string& filename kwsys_stl::string SystemTools::GetFilenameExtension(const kwsys_stl::string& filename) { kwsys_stl::string name = SystemTools::GetFilenameName(filename); - kwsys_stl::string::size_type dot_pos = name.find("."); + kwsys_stl::string::size_type dot_pos = name.find('.'); if(dot_pos != kwsys_stl::string::npos) { return name.substr(dot_pos); @@ -3948,7 +4039,7 @@ kwsys_stl::string SystemTools::GetFilenameExtension(const kwsys_stl::string& fil kwsys_stl::string SystemTools::GetFilenameLastExtension(const kwsys_stl::string& filename) { kwsys_stl::string name = SystemTools::GetFilenameName(filename); - kwsys_stl::string::size_type dot_pos = name.rfind("."); + kwsys_stl::string::size_type dot_pos = name.rfind('.'); if(dot_pos != kwsys_stl::string::npos) { return name.substr(dot_pos); @@ -3966,7 +4057,7 @@ kwsys_stl::string SystemTools::GetFilenameLastExtension(const kwsys_stl::string& kwsys_stl::string SystemTools::GetFilenameWithoutExtension(const kwsys_stl::string& filename) { kwsys_stl::string name = SystemTools::GetFilenameName(filename); - kwsys_stl::string::size_type dot_pos = name.find("."); + kwsys_stl::string::size_type dot_pos = name.find('.'); if(dot_pos != kwsys_stl::string::npos) { return name.substr(0, dot_pos); @@ -3987,7 +4078,7 @@ kwsys_stl::string SystemTools::GetFilenameWithoutLastExtension(const kwsys_stl::string& filename) { kwsys_stl::string name = SystemTools::GetFilenameName(filename); - kwsys_stl::string::size_type dot_pos = name.rfind("."); + kwsys_stl::string::size_type dot_pos = name.rfind('.'); if(dot_pos != kwsys_stl::string::npos) { return name.substr(0, dot_pos); @@ -4276,7 +4367,7 @@ bool SystemTools::GetShortPath(const kwsys_stl::string& path, kwsys_stl::string& #endif } -void SystemTools::SplitProgramFromArgs(const char* path, +void SystemTools::SplitProgramFromArgs(const kwsys_stl::string& path, kwsys_stl::string& program, kwsys_stl::string& args) { // see if this is a full path to a program @@ -4352,7 +4443,7 @@ kwsys_stl::string SystemTools::GetCurrentDateTime(const char* format) return kwsys_stl::string(buf); } -kwsys_stl::string SystemTools::MakeCidentifier(const char* s) +kwsys_stl::string SystemTools::MakeCidentifier(const kwsys_stl::string& s) { kwsys_stl::string str(s); if (str.find_first_of("0123456789") == 0) diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index e88bc8f..beb2a7e 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -89,9 +89,9 @@ public: * then an underscore is prepended. Note that this can produce * identifiers that the standard reserves (_[A-Z].* and __.*). */ - static kwsys_stl::string MakeCidentifier(const char* s); + static kwsys_stl::string MakeCidentifier(const kwsys_stl::string& s); - static kwsys_stl::string MakeCindentifier(const char* s) + static kwsys_stl::string MakeCindentifier(const kwsys_stl::string& s) { return MakeCidentifier(s); } @@ -102,6 +102,9 @@ public: static void ReplaceString(kwsys_stl::string& source, const char* replace, const char* with); + static void ReplaceString(kwsys_stl::string& source, + const kwsys_stl::string& replace, + const kwsys_stl::string& with); /** * Return a capitalized string (i.e the first letter is uppercased, @@ -306,7 +309,7 @@ public: /** * Return file length */ - static unsigned long FileLength(const char *filename); + static unsigned long FileLength(const kwsys_stl::string& filename); /** Change the modification time or create a file @@ -335,15 +338,15 @@ public: * does not exist path is returned unchanged. This does nothing * on unix but return path. */ - static kwsys_stl::string GetActualCaseForPath(const char* path); + static kwsys_stl::string GetActualCaseForPath(const kwsys_stl::string& path); /** * Given the path to a program executable, get the directory part of * the path with the file stripped off. If there is no directory * part, the empty string is returned. */ - static kwsys_stl::string GetProgramPath(const char*); - static bool SplitProgramPath(const char* in_name, + static kwsys_stl::string GetProgramPath(const kwsys_stl::string&); + static bool SplitProgramPath(const kwsys_stl::string& in_name, kwsys_stl::string& dir, kwsys_stl::string& file, bool errorReport = true); @@ -376,6 +379,8 @@ public: static kwsys_stl::string CollapseFullPath(const kwsys_stl::string& in_relative); static kwsys_stl::string CollapseFullPath(const kwsys_stl::string& in_relative, const char* in_base); + static kwsys_stl::string CollapseFullPath(const kwsys_stl::string& in_relative, + const kwsys_stl::string& in_base); /** * Get the real path for a given path, removing all symlinks. In @@ -446,7 +451,7 @@ public: * Split a program from its arguments and handle spaces in the paths */ static void SplitProgramFromArgs( - const char* path, + const kwsys_stl::string& path, kwsys_stl::string& program, kwsys_stl::string& args); /** @@ -582,7 +587,7 @@ public: * Find a file in the system PATH, with optional extra paths */ static kwsys_stl::string FindFile( - const char* name, + const kwsys_stl::string& name, const kwsys_stl::vector<kwsys_stl::string>& path = kwsys_stl::vector<kwsys_stl::string>(), bool no_system_path = false); @@ -591,7 +596,7 @@ public: * Find a directory in the system PATH, with optional extra paths */ static kwsys_stl::string FindDirectory( - const char* name, + const kwsys_stl::string& name, const kwsys_stl::vector<kwsys_stl::string>& path = kwsys_stl::vector<kwsys_stl::string>(), bool no_system_path = false); @@ -662,13 +667,13 @@ public: * Create a symbolic link if the platform supports it. Returns whether * creation succeded. */ - static bool CreateSymlink(const char* origName, const char* newName); + static bool CreateSymlink(const kwsys_stl::string& origName, const kwsys_stl::string& newName); /** * Read the contents of a symbolic link. Returns whether reading * succeded. */ - static bool ReadSymlink(const char* newName, kwsys_stl::string& origName); + static bool ReadSymlink(const kwsys_stl::string& newName, kwsys_stl::string& origName); /** * Try to locate the file 'filename' in the directory 'dir'. @@ -750,26 +755,26 @@ public: /** * Get a list of subkeys. */ - static bool GetRegistrySubKeys(const char *key, + static bool GetRegistrySubKeys(const kwsys_stl::string& key, kwsys_stl::vector<kwsys_stl::string>& subkeys, KeyWOW64 view = KeyWOW64_Default); /** * Read a registry value */ - static bool ReadRegistryValue(const char *key, kwsys_stl::string &value, + static bool ReadRegistryValue(const kwsys_stl::string& key, kwsys_stl::string &value, KeyWOW64 view = KeyWOW64_Default); /** * Write a registry value */ - static bool WriteRegistryValue(const char *key, const char *value, + static bool WriteRegistryValue(const kwsys_stl::string& key, const kwsys_stl::string& value, KeyWOW64 view = KeyWOW64_Default); /** * Delete a registry value */ - static bool DeleteRegistryValue(const char *key, + static bool DeleteRegistryValue(const kwsys_stl::string& key, KeyWOW64 view = KeyWOW64_Default); /** ----------------------------------------------------------------- @@ -789,15 +794,17 @@ public: * Read an environment variable */ static const char* GetEnv(const char* key); + static const char* GetEnv(const kwsys_stl::string& key); static bool GetEnv(const char* key, kwsys_stl::string& result); + static bool GetEnv(const kwsys_stl::string& key, kwsys_stl::string& result); /** Put a string into the environment of the form var=value */ - static bool PutEnv(const char* env); + static bool PutEnv(const kwsys_stl::string& env); /** Remove a string from the environment. Input is of the form "var" or "var=value" (value is ignored). */ - static bool UnPutEnv(const char* env); + static bool UnPutEnv(const kwsys_stl::string& env); /** * Get current working directory CWD @@ -906,6 +913,14 @@ private: } /** + * Actual implementation of ReplaceString. + */ + static void ReplaceString(kwsys_stl::string& source, + const char* replace, + size_t replaceSize, + const kwsys_stl::string& with); + + /** * Actual implementation of FileIsFullPath. */ static bool FileIsFullPath(const char*, size_t); @@ -915,7 +930,7 @@ private: * optional extra paths. */ static kwsys_stl::string FindName( - const char* name, + const kwsys_stl::string& name, const kwsys_stl::vector<kwsys_stl::string>& path = kwsys_stl::vector<kwsys_stl::string>(), bool no_system_path = false); diff --git a/Source/kwsys/kwsysPlatformTests.cmake b/Source/kwsys/kwsysPlatformTests.cmake index 16bc969..0da0f63 100644 --- a/Source/kwsys/kwsysPlatformTests.cmake +++ b/Source/kwsys/kwsysPlatformTests.cmake @@ -25,39 +25,39 @@ MACRO(KWSYS_PLATFORM_TEST lang var description invert) FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "${description} compiled with the following output:\n${OUTPUT}\n\n") - ELSE(${var}_COMPILED) + ELSE() FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "${description} failed to compile with the following output:\n${OUTPUT}\n\n") - ENDIF(${var}_COMPILED) + ENDIF() IF(${invert} MATCHES INVERT) IF(${var}_COMPILED) MESSAGE(STATUS "${description} - no") - ELSE(${var}_COMPILED) + ELSE() MESSAGE(STATUS "${description} - yes") - ENDIF(${var}_COMPILED) - ELSE(${invert} MATCHES INVERT) + ENDIF() + ELSE() IF(${var}_COMPILED) MESSAGE(STATUS "${description} - yes") - ELSE(${var}_COMPILED) + ELSE() MESSAGE(STATUS "${description} - no") - ENDIF(${var}_COMPILED) - ENDIF(${invert} MATCHES INVERT) + ENDIF() + ENDIF() ENDIF() IF(${invert} MATCHES INVERT) IF(${var}_COMPILED) SET(${var} 0) - ELSE(${var}_COMPILED) + ELSE() SET(${var} 1) - ENDIF(${var}_COMPILED) - ELSE(${invert} MATCHES INVERT) + ENDIF() + ELSE() IF(${var}_COMPILED) SET(${var} 1) - ELSE(${var}_COMPILED) + ELSE() SET(${var} 0) - ENDIF(${var}_COMPILED) - ENDIF(${invert} MATCHES INVERT) -ENDMACRO(KWSYS_PLATFORM_TEST) + ENDIF() + ENDIF() +ENDMACRO() MACRO(KWSYS_PLATFORM_TEST_RUN lang var description invert) IF(NOT DEFINED ${var}) @@ -74,63 +74,63 @@ MACRO(KWSYS_PLATFORM_TEST_RUN lang var description invert) FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "${description} compiled but failed to run with the following output:\n${OUTPUT}\n\n") - ELSE(${var}) + ELSE() FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "${description} compiled and ran with the following output:\n${OUTPUT}\n\n") - ENDIF(${var}) - ELSE(${var}_COMPILED) + ENDIF() + ELSE() FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "${description} failed to compile with the following output:\n${OUTPUT}\n\n") SET(${var} -1 CACHE INTERNAL "${description} failed to compile.") - ENDIF(${var}_COMPILED) + ENDIF() IF(${invert} MATCHES INVERT) IF(${var}_COMPILED) IF(${var}) MESSAGE(STATUS "${description} - yes") - ELSE(${var}) + ELSE() MESSAGE(STATUS "${description} - no") - ENDIF(${var}) - ELSE(${var}_COMPILED) + ENDIF() + ELSE() MESSAGE(STATUS "${description} - failed to compile") - ENDIF(${var}_COMPILED) - ELSE(${invert} MATCHES INVERT) + ENDIF() + ELSE() IF(${var}_COMPILED) IF(${var}) MESSAGE(STATUS "${description} - no") - ELSE(${var}) + ELSE() MESSAGE(STATUS "${description} - yes") - ENDIF(${var}) - ELSE(${var}_COMPILED) + ENDIF() + ELSE() MESSAGE(STATUS "${description} - failed to compile") - ENDIF(${var}_COMPILED) - ENDIF(${invert} MATCHES INVERT) + ENDIF() + ENDIF() ENDIF() IF(${invert} MATCHES INVERT) IF(${var}_COMPILED) IF(${var}) SET(${var} 1) - ELSE(${var}) + ELSE() SET(${var} 0) - ENDIF(${var}) - ELSE(${var}_COMPILED) + ENDIF() + ELSE() SET(${var} 1) - ENDIF(${var}_COMPILED) - ELSE(${invert} MATCHES INVERT) + ENDIF() + ELSE() IF(${var}_COMPILED) IF(${var}) SET(${var} 0) - ELSE(${var}) + ELSE() SET(${var} 1) - ENDIF(${var}) - ELSE(${var}_COMPILED) + ENDIF() + ELSE() SET(${var} 0) - ENDIF(${var}_COMPILED) - ENDIF(${invert} MATCHES INVERT) -ENDMACRO(KWSYS_PLATFORM_TEST_RUN) + ENDIF() + ENDIF() +ENDMACRO() MACRO(KWSYS_PLATFORM_C_TEST var description invert) SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_C_TEST_DEFINES}) @@ -138,7 +138,7 @@ MACRO(KWSYS_PLATFORM_C_TEST var description invert) KWSYS_PLATFORM_TEST(C "${var}" "${description}" "${invert}") SET(KWSYS_PLATFORM_TEST_DEFINES) SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS) -ENDMACRO(KWSYS_PLATFORM_C_TEST) +ENDMACRO() MACRO(KWSYS_PLATFORM_C_TEST_RUN var description invert) SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_C_TEST_DEFINES}) @@ -146,7 +146,7 @@ MACRO(KWSYS_PLATFORM_C_TEST_RUN var description invert) KWSYS_PLATFORM_TEST_RUN(C "${var}" "${description}" "${invert}") SET(KWSYS_PLATFORM_TEST_DEFINES) SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS) -ENDMACRO(KWSYS_PLATFORM_C_TEST_RUN) +ENDMACRO() MACRO(KWSYS_PLATFORM_CXX_TEST var description invert) SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES}) @@ -156,7 +156,7 @@ MACRO(KWSYS_PLATFORM_CXX_TEST var description invert) SET(KWSYS_PLATFORM_TEST_DEFINES) SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS) SET(KWSYS_PLATFORM_TEST_LINK_LIBRARIES) -ENDMACRO(KWSYS_PLATFORM_CXX_TEST) +ENDMACRO() MACRO(KWSYS_PLATFORM_CXX_TEST_RUN var description invert) SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES}) @@ -164,7 +164,7 @@ MACRO(KWSYS_PLATFORM_CXX_TEST_RUN var description invert) KWSYS_PLATFORM_TEST_RUN(CXX "${var}" "${description}" "${invert}") SET(KWSYS_PLATFORM_TEST_DEFINES) SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS) -ENDMACRO(KWSYS_PLATFORM_CXX_TEST_RUN) +ENDMACRO() #----------------------------------------------------------------------------- # KWSYS_PLATFORM_INFO_TEST(lang var description) diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx index b41532b..42b6249 100644 --- a/Source/kwsys/testSystemTools.cxx +++ b/Source/kwsys/testSystemTools.cxx @@ -124,7 +124,7 @@ static bool CheckFileOperations() res = false; } - if (kwsys::SystemTools::FileLength(testBinFile.c_str()) != 766) + if (kwsys::SystemTools::FileLength(testBinFile) != 766) { kwsys_ios::cerr << "Problem with FileLength - incorrect length for: " @@ -512,7 +512,7 @@ static bool CheckStringOperations() //---------------------------------------------------------------------------- -static bool CheckPutEnv(const char* env, const char* name, const char* value) +static bool CheckPutEnv(const kwsys_stl::string& env, const char* name, const char* value) { if(!kwsys::SystemTools::PutEnv(env)) { |