diff options
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r-- | Source/cmake.cxx | 2057 |
1 files changed, 55 insertions, 2002 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 290aff0..33fb0fc 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -10,8 +10,6 @@ See the License for more information. ============================================================================*/ #include "cmake.h" -#include "cmDocumentVariables.h" -#include "time.h" #include "cmCacheManager.h" #include "cmMakefile.h" #include "cmLocalGenerator.h" @@ -19,25 +17,18 @@ #include "cmCommands.h" #include "cmCommand.h" #include "cmFileTimeComparison.h" -#include "cmGeneratedFileStream.h" -#include "cmQtAutomoc.h" #include "cmSourceFile.h" -#include "cmVersion.h" #include "cmTest.h" -#include "cmDocumentationFormatterText.h" +#include "cmDocumentationFormatter.h" #if defined(CMAKE_BUILD_WITH_CMAKE) # include "cmGraphVizWriter.h" -# include "cmDependsFortran.h" // For -E cmake_copy_f90_mod callback. # include "cmVariableWatch.h" -# include <cmsys/Terminal.h> -# include <cmsys/CommandLineArguments.hxx> #endif -#include <cmsys/Directory.hxx> -#include <cmsys/Process.h> #include <cmsys/Glob.hxx> #include <cmsys/RegularExpression.hxx> +#include <cmsys/FStream.hxx> // only build kdevelop generator on non-windows platforms // when not bootstrapping cmake @@ -74,22 +65,17 @@ # endif # include "cmGlobalMSYSMakefileGenerator.h" # include "cmGlobalMinGWMakefileGenerator.h" -# include "cmWin32ProcessExecution.h" #else #endif #include "cmGlobalUnixMakefileGenerator3.h" #include "cmGlobalNinjaGenerator.h" - - -#if defined(CMAKE_HAVE_VS_GENERATORS) -#include "cmCallVisualStudioMacro.h" -#include "cmVisualStudioWCEPlatformParser.h" -#endif +#include "cmExtraCodeLiteGenerator.h" #if !defined(CMAKE_BOOT_MINGW) # include "cmExtraCodeBlocksGenerator.h" #endif #include "cmExtraSublimeTextGenerator.h" +#include "cmExtraKateGenerator.h" #ifdef CMAKE_USE_KDEVELOP # include "cmGlobalKdevelopGenerator.h" @@ -116,30 +102,6 @@ static bool cmakeCheckStampFile(const char* stampName); static bool cmakeCheckStampList(const char* stampName); -void cmNeedBackwardsCompatibility(const std::string& variable, - int access_type, void*, const char*, const cmMakefile*) -{ -#ifdef CMAKE_BUILD_WITH_CMAKE - if (access_type == cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS) - { - std::string message = "An attempt was made to access a variable: "; - message += variable; - message += - " that has not been defined. Some variables were always defined " - "by CMake in versions prior to 1.6. To fix this you might need to set " - "the cache value of CMAKE_BACKWARDS_COMPATIBILITY to 1.4 or less. If " - "you are writing a CMakeLists file, (or have already set " - "CMAKE_BACKWARDS_COMPATIBILITY to 1.4 or less) then you probably need " - "to include a CMake module to test for the feature this variable " - "defines."; - cmSystemTools::Error(message.c_str()); - } -#else - (void)variable; - (void)access_type; -#endif -} - void cmWarnUnusedCliWarning(const std::string& variable, int, void* ctx, const char*, const cmMakefile*) { @@ -186,12 +148,6 @@ cmake::cmake() #ifdef CMAKE_BUILD_WITH_CMAKE this->VariableWatch = new cmVariableWatch; - this->VariableWatch->AddWatch("CMAKE_WORDS_BIGENDIAN", - cmNeedBackwardsCompatibility); - this->VariableWatch->AddWatch("CMAKE_SIZEOF_INT", - cmNeedBackwardsCompatibility); - this->VariableWatch->AddWatch("CMAKE_X_LIBS", - cmNeedBackwardsCompatibility); #endif this->AddDefaultGenerators(); @@ -235,12 +191,8 @@ void cmake::InitializeProperties() this->PropertyDefinitions.clear(); // initialize properties - cmCacheManager::DefineProperties(this); - cmSourceFile::DefineProperties(this); cmTarget::DefineProperties(this); cmMakefile::DefineProperties(this); - cmTest::DefineProperties(this); - cmake::DefineProperties(this); } void cmake::CleanupCommandsAndMacros() @@ -642,9 +594,10 @@ bool cmake::FindPackage(const std::vector<std::string>& args) std::string linkPath; std::string flags; std::string linkFlags; - cmGeneratorTarget gtgt(tgt); + gg->CreateGeneratorTargets(mf); + cmGeneratorTarget *gtgt = gg->GetGeneratorTarget(tgt); lg->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags, - >gt); + gtgt); linkLibs = frameworkPath + linkPath + linkLibs; printf("%s\n", linkLibs.c_str() ); @@ -983,883 +936,32 @@ void cmake::SetDirectoriesFromFile(const char* arg) // cache int cmake::AddCMakePaths() { - // Find the cmake executable - std::string cMakeSelf = cmSystemTools::GetExecutableDirectory(); - cMakeSelf = cmSystemTools::GetRealPath(cMakeSelf.c_str()); - cMakeSelf += "/cmake"; - cMakeSelf += cmSystemTools::GetExecutableExtension(); -#ifdef __APPLE__ - // on the apple this might be the gui bundle - if(!cmSystemTools::FileExists(cMakeSelf.c_str())) - { - cMakeSelf = cmSystemTools::GetExecutableDirectory(); - cMakeSelf = cmSystemTools::GetRealPath(cMakeSelf.c_str()); - cMakeSelf += "../../../.."; - cMakeSelf = cmSystemTools::GetRealPath(cMakeSelf.c_str()); - cMakeSelf = cmSystemTools::CollapseFullPath(cMakeSelf.c_str()); - cMakeSelf += "/cmake"; - std::cerr << cMakeSelf.c_str() << "\n"; - } -#endif - if(!cmSystemTools::FileExists(cMakeSelf.c_str())) - { - cmSystemTools::Error("CMake executable cannot be found at ", - cMakeSelf.c_str()); - return 0; - } // Save the value in the cache this->CacheManager->AddCacheEntry - ("CMAKE_COMMAND",cMakeSelf.c_str(), "Path to CMake executable.", - cmCacheManager::INTERNAL); - // if the edit command is not yet in the cache, - // or if CMakeEditCommand has been set on this object, - // then set the CMAKE_EDIT_COMMAND in the cache - // This will mean that the last gui to edit the cache - // will be the one that make edit_cache uses. - if(!this->GetCacheDefinition("CMAKE_EDIT_COMMAND") - || !this->CMakeEditCommand.empty()) - { - // Find and save the command to edit the cache - std::string editCacheCommand; - if(!this->CMakeEditCommand.empty()) - { - editCacheCommand = cmSystemTools::GetFilenamePath(cMakeSelf) - + std::string("/") - + this->CMakeEditCommand - + cmSystemTools::GetFilenameExtension(cMakeSelf); - } - if( !cmSystemTools::FileExists(editCacheCommand.c_str())) - { - editCacheCommand = cmSystemTools::GetFilenamePath(cMakeSelf) + - "/ccmake" + cmSystemTools::GetFilenameExtension(cMakeSelf); - } - if( !cmSystemTools::FileExists(editCacheCommand.c_str())) - { - editCacheCommand = cmSystemTools::GetFilenamePath(cMakeSelf) + - "/cmake-gui" + cmSystemTools::GetFilenameExtension(cMakeSelf); - } - if(cmSystemTools::FileExists(editCacheCommand.c_str())) - { - this->CacheManager->AddCacheEntry - ("CMAKE_EDIT_COMMAND", editCacheCommand.c_str(), - "Path to cache edit program executable.", cmCacheManager::INTERNAL); - } - } - std::string ctestCommand = cmSystemTools::GetFilenamePath(cMakeSelf) + - "/ctest" + cmSystemTools::GetFilenameExtension(cMakeSelf); - if(cmSystemTools::FileExists(ctestCommand.c_str())) - { - this->CacheManager->AddCacheEntry - ("CMAKE_CTEST_COMMAND", ctestCommand.c_str(), - "Path to ctest program executable.", cmCacheManager::INTERNAL); - } - std::string cpackCommand = cmSystemTools::GetFilenamePath(cMakeSelf) + - "/cpack" + cmSystemTools::GetFilenameExtension(cMakeSelf); - if(cmSystemTools::FileExists(cpackCommand.c_str())) - { - this->CacheManager->AddCacheEntry - ("CMAKE_CPACK_COMMAND", cpackCommand.c_str(), - "Path to cpack program executable.", cmCacheManager::INTERNAL); - } - - // do CMAKE_ROOT, look for the environment variable first - std::string cMakeRoot; - std::string modules; - if (getenv("CMAKE_ROOT")) - { - cMakeRoot = getenv("CMAKE_ROOT"); - modules = cMakeRoot + "/Modules/CMake.cmake"; - } - if(!cmSystemTools::FileExists(modules.c_str())) - { - // next try exe/.. - cMakeRoot = cmSystemTools::GetRealPath(cMakeSelf.c_str()); - cMakeRoot = cmSystemTools::GetProgramPath(cMakeRoot.c_str()); - std::string::size_type slashPos = cMakeRoot.rfind("/"); - if(slashPos != std::string::npos) - { - cMakeRoot = cMakeRoot.substr(0, slashPos); - } - // is there no Modules directory there? - modules = cMakeRoot + "/Modules/CMake.cmake"; - } - - if (!cmSystemTools::FileExists(modules.c_str())) - { - // try exe/../share/cmake - cMakeRoot += CMAKE_DATA_DIR; - modules = cMakeRoot + "/Modules/CMake.cmake"; - } -#ifdef CMAKE_ROOT_DIR - if (!cmSystemTools::FileExists(modules.c_str())) - { - // try compiled in root directory - cMakeRoot = CMAKE_ROOT_DIR; - modules = cMakeRoot + "/Modules/CMake.cmake"; - } + ("CMAKE_COMMAND", cmSystemTools::GetCMakeCommand().c_str(), + "Path to CMake executable.", cmCacheManager::INTERNAL); +#ifdef CMAKE_BUILD_WITH_CMAKE + this->CacheManager->AddCacheEntry + ("CMAKE_CTEST_COMMAND", cmSystemTools::GetCTestCommand().c_str(), + "Path to ctest program executable.", cmCacheManager::INTERNAL); + this->CacheManager->AddCacheEntry + ("CMAKE_CPACK_COMMAND", cmSystemTools::GetCPackCommand().c_str(), + "Path to cpack program executable.", cmCacheManager::INTERNAL); #endif - if (!cmSystemTools::FileExists(modules.c_str())) - { - // try - cMakeRoot = cmSystemTools::GetProgramPath(cMakeSelf.c_str()); - cMakeRoot += CMAKE_DATA_DIR; - modules = cMakeRoot + "/Modules/CMake.cmake"; - } - if(!cmSystemTools::FileExists(modules.c_str())) - { - // next try exe - cMakeRoot = cmSystemTools::GetProgramPath(cMakeSelf.c_str()); - // is there no Modules directory there? - modules = cMakeRoot + "/Modules/CMake.cmake"; - } - if (!cmSystemTools::FileExists(modules.c_str())) + if(!cmSystemTools::FileExists( + (cmSystemTools::GetCMakeRoot()+"/Modules/CMake.cmake").c_str())) { // couldn't find modules cmSystemTools::Error("Could not find CMAKE_ROOT !!!\n" "CMake has most likely not been installed correctly.\n" "Modules directory not found in\n", - cMakeRoot.c_str()); + cmSystemTools::GetCMakeRoot().c_str()); return 0; } this->CacheManager->AddCacheEntry - ("CMAKE_ROOT", cMakeRoot.c_str(), + ("CMAKE_ROOT", cmSystemTools::GetCMakeRoot().c_str(), "Path to CMake installation.", cmCacheManager::INTERNAL); -#ifdef _WIN32 - std::string comspec = "cmw9xcom.exe"; - cmSystemTools::SetWindows9xComspecSubstitute(comspec.c_str()); -#endif - return 1; -} - - - -void CMakeCommandUsage(const char* program) -{ - cmOStringStream errorStream; - -#ifdef CMAKE_BUILD_WITH_CMAKE - errorStream - << "cmake version " << cmVersion::GetCMakeVersion() << "\n"; -#else - errorStream - << "cmake bootstrap\n"; -#endif - // If you add new commands, change here, - // and in cmakemain.cxx in the options table - errorStream - << "Usage: " << program << " -E [command] [arguments ...]\n" - << "Available commands: \n" - << " chdir dir cmd [args]... - run command in a given directory\n" - << " compare_files file1 file2 - check if file1 is same as file2\n" - << " copy file destination - copy file to destination (either file " - "or directory)\n" - << " copy_directory source destination - copy directory 'source' " - "content to directory 'destination'\n" - << " copy_if_different in-file out-file - copy file if input has " - "changed\n" - << " echo [string]... - displays arguments as text\n" - << " echo_append [string]... - displays arguments as text but no new " - "line\n" - << " environment - display the current environment\n" - << " make_directory dir - create a directory\n" - << " md5sum file1 [...] - compute md5sum of files\n" - << " remove [-f] file1 file2 ... - remove the file(s), use -f to force " - "it\n" - << " remove_directory dir - remove a directory and its contents\n" - << " rename oldname newname - rename a file or directory " - "(on one volume)\n" - << " tar [cxt][vfz][cvfj] file.tar [file/dir1 file/dir2 ...]\n" - << " - create or extract a tar or zip archive\n" - << " time command [args] ... - run command and return elapsed time\n" - << " touch file - touch a file.\n" - << " touch_nocreate file - touch a file but do not create it.\n" -#if defined(_WIN32) && !defined(__CYGWIN__) - << "Available on Windows only:\n" - << " comspec - on windows 9x use this for RunCommand\n" - << " delete_regv key - delete registry value\n" - << " env_vs8_wince sdkname - displays a batch file which sets the " - "environment for the provided Windows CE SDK installed in VS2005\n" - << " env_vs9_wince sdkname - displays a batch file which sets the " - "environment for the provided Windows CE SDK installed in VS2008\n" - << " write_regv key value - write registry value\n" -#else - << "Available on UNIX only:\n" - << " create_symlink old new - create a symbolic link new -> old\n" -#endif - ; - - cmSystemTools::Error(errorStream.str().c_str()); -} - -int cmake::ExecuteCMakeCommand(std::vector<std::string>& args) -{ - // IF YOU ADD A NEW COMMAND, DOCUMENT IT ABOVE and in cmakemain.cxx - if (args.size() > 1) - { - // Copy file - if (args[1] == "copy" && args.size() == 4) - { - if(!cmSystemTools::cmCopyFile(args[2].c_str(), args[3].c_str())) - { - std::cerr << "Error copying file \"" << args[2].c_str() - << "\" to \"" << args[3].c_str() << "\".\n"; - return 1; - } - return 0; - } - - // Copy file if different. - if (args[1] == "copy_if_different" && args.size() == 4) - { - if(!cmSystemTools::CopyFileIfDifferent(args[2].c_str(), - args[3].c_str())) - { - std::cerr << "Error copying file (if different) from \"" - << args[2].c_str() << "\" to \"" << args[3].c_str() - << "\".\n"; - return 1; - } - return 0; - } - - // Copy directory content - if (args[1] == "copy_directory" && args.size() == 4) - { - if(!cmSystemTools::CopyADirectory(args[2].c_str(), args[3].c_str())) - { - std::cerr << "Error copying directory from \"" - << args[2].c_str() << "\" to \"" << args[3].c_str() - << "\".\n"; - return 1; - } - return 0; - } - - // Rename a file or directory - if (args[1] == "rename" && args.size() == 4) - { - if(!cmSystemTools::RenameFile(args[2].c_str(), args[3].c_str())) - { - std::string e = cmSystemTools::GetLastSystemError(); - std::cerr << "Error renaming from \"" - << args[2].c_str() << "\" to \"" << args[3].c_str() - << "\": " << e << "\n"; - return 1; - } - return 0; - } - - // Compare files - if (args[1] == "compare_files" && args.size() == 4) - { - if(cmSystemTools::FilesDiffer(args[2].c_str(), args[3].c_str())) - { - std::cerr << "Files \"" - << args[2].c_str() << "\" to \"" << args[3].c_str() - << "\" are different.\n"; - return 1; - } - return 0; - } - - // Echo string - else if (args[1] == "echo" ) - { - unsigned int cc; - const char* space = ""; - for ( cc = 2; cc < args.size(); cc ++ ) - { - std::cout << space << args[cc]; - space = " "; - } - std::cout << std::endl; - return 0; - } - - // Echo string no new line - else if (args[1] == "echo_append" ) - { - unsigned int cc; - const char* space = ""; - for ( cc = 2; cc < args.size(); cc ++ ) - { - std::cout << space << args[cc]; - space = " "; - } - return 0; - } - -#if defined(CMAKE_BUILD_WITH_CMAKE) - // Command to create a symbolic link. Fails on platforms not - // supporting them. - else if (args[1] == "environment" ) - { - std::vector<std::string> env = cmSystemTools::GetEnvironmentVariables(); - std::vector<std::string>::iterator it; - for ( it = env.begin(); it != env.end(); ++ it ) - { - std::cout << it->c_str() << std::endl; - } - return 0; - } -#endif - - else if (args[1] == "make_directory" && args.size() == 3) - { - if(!cmSystemTools::MakeDirectory(args[2].c_str())) - { - std::cerr << "Error making directory \"" << args[2].c_str() - << "\".\n"; - return 1; - } - return 0; - } - - else if (args[1] == "remove_directory" && args.size() == 3) - { - if(cmSystemTools::FileIsDirectory(args[2].c_str()) && - !cmSystemTools::RemoveADirectory(args[2].c_str())) - { - std::cerr << "Error removing directory \"" << args[2].c_str() - << "\".\n"; - return 1; - } - return 0; - } - - // Remove file - else if (args[1] == "remove" && args.size() > 2) - { - bool force = false; - for (std::string::size_type cc = 2; cc < args.size(); cc ++) - { - if(args[cc] == "\\-f" || args[cc] == "-f") - { - force = true; - } - else - { - // Complain if the file could not be removed, still exists, - // and the -f option was not given. - if(!cmSystemTools::RemoveFile(args[cc].c_str()) && !force && - cmSystemTools::FileExists(args[cc].c_str())) - { - return 1; - } - } - } - return 0; - } - // Touch file - else if (args[1] == "touch" && args.size() > 2) - { - for (std::string::size_type cc = 2; cc < args.size(); cc ++) - { - // Complain if the file could not be removed, still exists, - // and the -f option was not given. - if(!cmSystemTools::Touch(args[cc].c_str(), true)) - { - return 1; - } - } - return 0; - } - // Touch file - else if (args[1] == "touch_nocreate" && args.size() > 2) - { - for (std::string::size_type cc = 2; cc < args.size(); cc ++) - { - // Complain if the file could not be removed, still exists, - // and the -f option was not given. - if(!cmSystemTools::Touch(args[cc].c_str(), false)) - { - return 1; - } - } - return 0; - } - - // Clock command - else if (args[1] == "time" && args.size() > 2) - { - std::string command = args[2]; - for (std::string::size_type cc = 3; cc < args.size(); cc ++) - { - command += " "; - command += args[cc]; - } - - clock_t clock_start, clock_finish; - time_t time_start, time_finish; - - time(&time_start); - clock_start = clock(); - int ret =0; - cmSystemTools::RunSingleCommand(command.c_str(), 0, &ret); - - clock_finish = clock(); - time(&time_finish); - - double clocks_per_sec = static_cast<double>(CLOCKS_PER_SEC); - std::cout << "Elapsed time: " - << static_cast<long>(time_finish - time_start) << " s. (time)" - << ", " - << static_cast<double>(clock_finish - clock_start) / clocks_per_sec - << " s. (clock)" - << "\n"; - return ret; - } - // Command to calculate the md5sum of a file - else if (args[1] == "md5sum" && args.size() >= 3) - { - char md5out[32]; - int retval = 0; - for (std::string::size_type cc = 2; cc < args.size(); cc ++) - { - const char *filename = args[cc].c_str(); - // Cannot compute md5sum of a directory - if(cmSystemTools::FileIsDirectory(filename)) - { - std::cerr << "Error: " << filename << " is a directory" << std::endl; - retval++; - } - else if(!cmSystemTools::ComputeFileMD5(filename, md5out)) - { - // To mimic md5sum behavior in a shell: - std::cerr << filename << ": No such file or directory" << std::endl; - retval++; - } - else - { - std::cout << std::string(md5out,32) << " " << filename << std::endl; - } - } - return retval; - } - - // Command to change directory and run a program. - else if (args[1] == "chdir" && args.size() >= 4) - { - std::string directory = args[2]; - if(!cmSystemTools::FileExists(directory.c_str())) - { - cmSystemTools::Error("Directory does not exist for chdir command: ", - args[2].c_str()); - return 1; - } - - std::string command = "\""; - command += args[3]; - command += "\""; - for (std::string::size_type cc = 4; cc < args.size(); cc ++) - { - command += " \""; - command += args[cc]; - command += "\""; - } - int retval = 0; - int timeout = 0; - if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, &retval, - directory.c_str(), cmSystemTools::OUTPUT_NORMAL, timeout) ) - { - return retval; - } - - return 1; - } - - // Command to start progress for a build - else if (args[1] == "cmake_progress_start" && args.size() == 4) - { - // basically remove the directory - std::string dirName = args[2]; - dirName += "/Progress"; - cmSystemTools::RemoveADirectory(dirName.c_str()); - - // is the last argument a filename that exists? - FILE *countFile = fopen(args[3].c_str(),"r"); - int count; - if (countFile) - { - if (1!=fscanf(countFile,"%i",&count)) - { - cmSystemTools::Message("Could not read from count file."); - } - fclose(countFile); - } - else - { - count = atoi(args[3].c_str()); - } - if (count) - { - cmSystemTools::MakeDirectory(dirName.c_str()); - // write the count into the directory - std::string fName = dirName; - fName += "/count.txt"; - FILE *progFile = fopen(fName.c_str(),"w"); - if (progFile) - { - fprintf(progFile,"%i\n",count); - fclose(progFile); - } - } - return 0; - } - - // Command to report progress for a build - else if (args[1] == "cmake_progress_report" && args.size() >= 3) - { - std::string dirName = args[2]; - dirName += "/Progress"; - std::string fName; - FILE *progFile; - - // read the count - fName = dirName; - fName += "/count.txt"; - progFile = fopen(fName.c_str(),"r"); - int count = 0; - if (!progFile) - { - return 0; - } - else - { - if (1!=fscanf(progFile,"%i",&count)) - { - cmSystemTools::Message("Could not read from progress file."); - } - fclose(progFile); - } - unsigned int i; - for (i = 3; i < args.size(); ++i) - { - fName = dirName; - fName += "/"; - fName += args[i]; - progFile = fopen(fName.c_str(),"w"); - if (progFile) - { - fprintf(progFile,"empty"); - fclose(progFile); - } - } - int fileNum = static_cast<int> - (cmsys::Directory::GetNumberOfFilesInDirectory(dirName.c_str())); - if (count > 0) - { - // print the progress - fprintf(stdout,"[%3i%%] ",((fileNum-3)*100)/count); - } - return 0; - } - - // Command to create a symbolic link. Fails on platforms not - // supporting them. - else if (args[1] == "create_symlink" && args.size() == 4) - { - const char* destinationFileName = args[3].c_str(); - if ( cmSystemTools::FileExists(destinationFileName) ) - { - if ( cmSystemTools::FileIsSymlink(destinationFileName) ) - { - if ( !cmSystemTools::RemoveFile(destinationFileName) || - cmSystemTools::FileExists(destinationFileName) ) - { - return 0; - } - } - else - { - return 0; - } - } - return cmSystemTools::CreateSymlink(args[2].c_str(), - args[3].c_str())? 0:1; - } - - // Internal CMake shared library support. - else if (args[1] == "cmake_symlink_library" && args.size() == 5) - { - return cmake::SymlinkLibrary(args); - } - // Internal CMake versioned executable support. - else if (args[1] == "cmake_symlink_executable" && args.size() == 4) - { - return cmake::SymlinkExecutable(args); - } - -#if defined(CMAKE_HAVE_VS_GENERATORS) - // Internal CMake support for calling Visual Studio macros. - else if (args[1] == "cmake_call_visual_studio_macro" && args.size() >= 4) - { - // args[2] = full path to .sln file or "ALL" - // args[3] = name of Visual Studio macro to call - // args[4..args.size()-1] = [optional] args for Visual Studio macro - - std::string macroArgs; - - if (args.size() > 4) - { - macroArgs = args[4]; - - for (size_t i = 5; i < args.size(); ++i) - { - macroArgs += " "; - macroArgs += args[i]; - } - } - - return cmCallVisualStudioMacro::CallMacro(args[2], args[3], - macroArgs, true); - } -#endif - - // Internal CMake dependency scanning support. - else if (args[1] == "cmake_depends" && args.size() >= 6) - { - // Use the make system's VERBOSE environment variable to enable - // verbose output. This can be skipped by also setting CMAKE_NO_VERBOSE - // (which is set by the Eclipse and KDevelop generators). - bool verbose = ((cmSystemTools::GetEnv("VERBOSE") != 0) - && (cmSystemTools::GetEnv("CMAKE_NO_VERBOSE") == 0)); - - // Create a cmake object instance to process dependencies. - cmake cm; - std::string gen; - std::string homeDir; - std::string startDir; - std::string homeOutDir; - std::string startOutDir; - std::string depInfo; - bool color = false; - if(args.size() >= 8) - { - // Full signature: - // - // -E cmake_depends <generator> - // <home-src-dir> <start-src-dir> - // <home-out-dir> <start-out-dir> - // <dep-info> [--color=$(COLOR)] - // - // All paths are provided. - gen = args[2]; - homeDir = args[3]; - startDir = args[4]; - homeOutDir = args[5]; - startOutDir = args[6]; - depInfo = args[7]; - if(args.size() >= 9 && - args[8].length() >= 8 && - args[8].substr(0, 8) == "--color=") - { - // Enable or disable color based on the switch value. - color = (args[8].size() == 8 || - cmSystemTools::IsOn(args[8].substr(8).c_str())); - } - } - else - { - // Support older signature for existing makefiles: - // - // -E cmake_depends <generator> - // <home-out-dir> <start-out-dir> - // <dep-info> - // - // Just pretend the source directories are the same as the - // binary directories so at least scanning will work. - gen = args[2]; - homeDir = args[3]; - startDir = args[4]; - homeOutDir = args[3]; - startOutDir = args[3]; - depInfo = args[5]; - } - - // Create a local generator configured for the directory in - // which dependencies will be scanned. - homeDir = cmSystemTools::CollapseFullPath(homeDir.c_str()); - startDir = cmSystemTools::CollapseFullPath(startDir.c_str()); - homeOutDir = cmSystemTools::CollapseFullPath(homeOutDir.c_str()); - startOutDir = cmSystemTools::CollapseFullPath(startOutDir.c_str()); - cm.SetHomeDirectory(homeDir.c_str()); - cm.SetStartDirectory(startDir.c_str()); - cm.SetHomeOutputDirectory(homeOutDir.c_str()); - cm.SetStartOutputDirectory(startOutDir.c_str()); - if(cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen.c_str())) - { - cm.SetGlobalGenerator(ggd); - cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator()); - lgd->GetMakefile()->SetStartDirectory(startDir.c_str()); - lgd->GetMakefile()->SetStartOutputDirectory(startOutDir.c_str()); - lgd->GetMakefile()->MakeStartDirectoriesCurrent(); - - // Actually scan dependencies. - return lgd->UpdateDependencies(depInfo.c_str(), - verbose, color)? 0 : 2; - } - return 1; - } - - // Internal CMake link script support. - else if (args[1] == "cmake_link_script" && args.size() >= 3) - { - return cmake::ExecuteLinkScript(args); - } - - // Internal CMake unimplemented feature notification. - else if (args[1] == "cmake_unimplemented_variable") - { - std::cerr << "Feature not implemented for this platform."; - if(args.size() == 3) - { - std::cerr << " Variable " << args[2] << " is not set."; - } - std::cerr << std::endl; - return 1; - } - else if (args[1] == "vs_link_exe") - { - return cmake::VisualStudioLink(args, 1); - } - else if (args[1] == "vs_link_dll") - { - return cmake::VisualStudioLink(args, 2); - } -#ifdef CMAKE_BUILD_WITH_CMAKE - // Internal CMake color makefile support. - else if (args[1] == "cmake_echo_color") - { - return cmake::ExecuteEchoColor(args); - } - else if (args[1] == "cmake_automoc") - { - cmQtAutomoc automoc; - const char *config = args[3].empty() ? 0 : args[3].c_str(); - bool automocSuccess = automoc.Run(args[2].c_str(), config); - return automocSuccess ? 0 : 1; - } -#endif - - // Tar files - else if (args[1] == "tar" && args.size() > 3) - { - std::string flags = args[2]; - std::string outFile = args[3]; - std::vector<cmStdString> files; - for (std::string::size_type cc = 4; cc < args.size(); cc ++) - { - files.push_back(args[cc]); - } - bool gzip = false; - bool bzip2 = false; - bool verbose = false; - if ( flags.find_first_of('j') != flags.npos ) - { - bzip2 = true; - } - if ( flags.find_first_of('z') != flags.npos ) - { - gzip = true; - } - if ( flags.find_first_of('v') != flags.npos ) - { - verbose = true; - } - - if ( flags.find_first_of('t') != flags.npos ) - { - if ( !cmSystemTools::ListTar(outFile.c_str(), gzip, verbose) ) - { - cmSystemTools::Error("Problem creating tar: ", outFile.c_str()); - return 1; - } - } - else if ( flags.find_first_of('c') != flags.npos ) - { - if ( !cmSystemTools::CreateTar( - outFile.c_str(), files, gzip, bzip2, verbose) ) - { - cmSystemTools::Error("Problem creating tar: ", outFile.c_str()); - return 1; - } - } - else if ( flags.find_first_of('x') != flags.npos ) - { - if ( !cmSystemTools::ExtractTar( - outFile.c_str(), gzip, verbose) ) - { - cmSystemTools::Error("Problem extracting tar: ", outFile.c_str()); - return 1; - } -#ifdef WIN32 - // OK, on windows 7 after we untar some files, - // sometimes we can not rename the directory after - // the untar is done. This breaks the external project - // untar and rename code. So, by default we will wait - // 1/10th of a second after the untar. If CMAKE_UNTAR_DELAY - // is set in the env, its value will be used instead of 100. - int delay = 100; - const char* delayVar = cmSystemTools::GetEnv("CMAKE_UNTAR_DELAY"); - if(delayVar) - { - delay = atoi(delayVar); - } - if(delay) - { - cmSystemTools::Delay(delay); - } -#endif - } - return 0; - } - -#if defined(CMAKE_BUILD_WITH_CMAKE) - // Internal CMake Fortran module support. - else if (args[1] == "cmake_copy_f90_mod" && args.size() >= 4) - { - return cmDependsFortran::CopyModule(args)? 0 : 1; - } -#endif - -#if defined(_WIN32) && !defined(__CYGWIN__) - // Write registry value - else if (args[1] == "write_regv" && args.size() > 3) - { - return cmSystemTools::WriteRegistryValue(args[2].c_str(), - args[3].c_str()) ? 0 : 1; - } - - // Delete registry value - else if (args[1] == "delete_regv" && args.size() > 2) - { - return cmSystemTools::DeleteRegistryValue(args[2].c_str()) ? 0 : 1; - } - // Remove file - else if (args[1] == "comspec" && args.size() > 2) - { - unsigned int cc; - std::string command = args[2]; - for ( cc = 3; cc < args.size(); cc ++ ) - { - command += " " + args[cc]; - } - return cmWin32ProcessExecution::Windows9xHack(command.c_str()); - } - else if (args[1] == "env_vs8_wince" && args.size() == 3) - { - return cmake::WindowsCEEnvironment("8.0", args[2]); - } - else if (args[1] == "env_vs9_wince" && args.size() == 3) - { - return cmake::WindowsCEEnvironment("9.0", args[2]); - } -#endif - } - - ::CMakeCommandUsage(args[0].c_str()); return 1; } @@ -1891,8 +993,12 @@ void cmake::AddDefaultExtraGenerators() this->AddExtraGenerator(cmExtraCodeBlocksGenerator::GetActualName(), &cmExtraCodeBlocksGenerator::New); + this->AddExtraGenerator(cmExtraCodeLiteGenerator::GetActualName(), + &cmExtraCodeLiteGenerator::New); this->AddExtraGenerator(cmExtraSublimeTextGenerator::GetActualName(), &cmExtraSublimeTextGenerator::New); + this->AddExtraGenerator(cmExtraKateGenerator::GetActualName(), + &cmExtraKateGenerator::New); #ifdef CMAKE_USE_ECLIPSE this->AddExtraGenerator(cmExtraEclipseCDT4Generator::GetActualName(), @@ -2254,9 +1360,9 @@ int cmake::ActualConfigure() {"7.1", "Visual Studio 7 .NET 2003"}, {"8.0", "Visual Studio 8 2005"}, {"9.0", "Visual Studio 9 2008"}, - {"10.0", "Visual Studio 10"}, - {"11.0", "Visual Studio 11"}, - {"12.0", "Visual Studio 12"}, + {"10.0", "Visual Studio 10 2010"}, + {"11.0", "Visual Studio 11 2012"}, + {"12.0", "Visual Studio 12 2013"}, {0, 0}}; for(int i=0; version[i].MSVersion != 0; i++) { @@ -2295,7 +1401,7 @@ int cmake::ActualConfigure() const char* genName = this->CacheManager->GetCacheValue("CMAKE_GENERATOR"); if(genName) { - if(strcmp(this->GlobalGenerator->GetName(), genName) != 0) + if(!this->GlobalGenerator->MatchesGeneratorName(genName)) { std::string message = "Error: generator : "; message += this->GlobalGenerator->GetName(); @@ -2437,11 +1543,6 @@ int cmake::ActualConfigure() { this->CacheManager->SaveCache(this->GetHomeOutputDirectory()); } - if ( !this->GraphVizFile.empty() ) - { - std::cout << "Generate graphviz: " << this->GraphVizFile << std::endl; - this->GenerateGraphViz(this->GraphVizFile.c_str()); - } if(cmSystemTools::GetErrorOccuredFlag()) { return -1; @@ -2496,9 +1597,6 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure) return 0; } - // set the cmake command - this->CMakeCommand = args[0]; - if ( this->GetWorkingMode() == NORMAL_MODE ) { // load the cache @@ -2604,6 +1702,11 @@ int cmake::Generate() return -1; } this->GlobalGenerator->Generate(); + if ( !this->GraphVizFile.empty() ) + { + std::cout << "Generate graphviz: " << this->GraphVizFile << std::endl; + this->GenerateGraphViz(this->GraphVizFile.c_str()); + } if(this->WarnUnusedCli) { this->RunCheckForUnusedVariables(); @@ -2612,11 +1715,6 @@ int cmake::Generate() { return -1; } - if (this->GetProperty("REPORT_UNDEFINED_PROPERTIES")) - { - this->ReportUndefinedPropertyAccesses - (this->GetProperty("REPORT_UNDEFINED_PROPERTIES")); - } // Save the cache again after a successful Generate so that any internal // variables created during Generate are saved. (Specifically target GUIDs // for the Visual Studio and Xcode generators.) @@ -2716,14 +1814,6 @@ int cmake::LoadCache() } } - if (this->CMakeCommand.size() < 2) - { - cmSystemTools::Error( - "cmake command was not specified prior to loading the cache in " - "cmake.cxx"); - return -1; - } - // setup CMAKE_ROOT and CMAKE_COMMAND if(!this->AddCMakePaths()) { @@ -2747,45 +1837,6 @@ void cmake::UpdateProgress(const char *msg, float prog) } } -void cmake::GetCommandDocumentation(std::vector<cmDocumentationEntry>& v, - bool withCurrentCommands, - bool withCompatCommands) const -{ - for(RegisteredCommandsMap::const_iterator j = this->Commands.begin(); - j != this->Commands.end(); ++j) - { - if ((( withCompatCommands == false) && ( (*j).second->IsDiscouraged())) - || ((withCurrentCommands == false) && (!(*j).second->IsDiscouraged())) - || (!((*j).second->ShouldAppearInDocumentation())) - ) - { - continue; - } - - cmDocumentationEntry e((*j).second->GetName(), - (*j).second->GetTerseDocumentation(), - (*j).second->GetFullDocumentation()); - v.push_back(e); - } -} - -void cmake::GetPolicyDocumentation(std::vector<cmDocumentationEntry>& v) -{ - this->Policies->GetDocumentation(v); -} - -void cmake::GetPropertiesDocumentation(std::map<std::string, - cmDocumentationSection *>& v) -{ - // loop over the properties and put them into the doc structure - std::map<cmProperty::ScopeType, cmPropertyDefinitionMap>::iterator i; - i = this->PropertyDefinitions.begin(); - for (;i != this->PropertyDefinitions.end(); ++i) - { - i->second.GetPropertiesDocumentation(v); - } -} - void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v) { for(RegisteredGeneratorsVector::const_iterator i = @@ -2815,7 +1866,7 @@ void cmake::UpdateConversionPathTable() if(tablepath) { - std::ifstream table( tablepath ); + cmsys::ifstream table( tablepath ); if(!table) { cmSystemTools::Error("CMAKE_PATH_TRANSLATION_FILE set to ", tablepath, @@ -3068,82 +2119,6 @@ inline std::string removeQuotes(const std::string& s) return s; } -std::string cmake::FindCMakeProgram(const char* name) const -{ - std::string path; - if ((name) && (*name)) - { - const cmMakefile* mf - = this->GetGlobalGenerator()->GetLocalGenerators()[0]->GetMakefile(); -#ifdef CMAKE_BUILD_WITH_CMAKE - path = mf->GetRequiredDefinition("CMAKE_COMMAND"); - path = removeQuotes(path); - path = cmSystemTools::GetFilenamePath(path.c_str()); - path += "/"; - path += name; - path += cmSystemTools::GetExecutableExtension(); - if(!cmSystemTools::FileExists(path.c_str())) - { - path = mf->GetRequiredDefinition("CMAKE_COMMAND"); - path = cmSystemTools::GetFilenamePath(path.c_str()); - path += "/Debug/"; - path += name; - path += cmSystemTools::GetExecutableExtension(); - } - if(!cmSystemTools::FileExists(path.c_str())) - { - path = mf->GetRequiredDefinition("CMAKE_COMMAND"); - path = cmSystemTools::GetFilenamePath(path.c_str()); - path += "/Release/"; - path += name; - path += cmSystemTools::GetExecutableExtension(); - } -#else - // Only for bootstrap - path += mf->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH"); - path += "/"; - path += name; - path += cmSystemTools::GetExecutableExtension(); -#endif - } - return path; -} - -const char* cmake::GetCTestCommand() -{ - if ( this->CTestCommand.empty() ) - { - this->CTestCommand = this->FindCMakeProgram("ctest"); - } - if ( this->CTestCommand.empty() ) - { - cmSystemTools::Error("Cannot find the CTest executable"); - this->CTestCommand = "CTEST-COMMAND-NOT-FOUND"; - } - return this->CTestCommand.c_str(); -} - -const char* cmake::GetCPackCommand() -{ - if ( this->CPackCommand.empty() ) - { - this->CPackCommand = this->FindCMakeProgram("cpack"); - } - if ( this->CPackCommand.empty() ) - { - cmSystemTools::Error("Cannot find the CPack executable"); - this->CPackCommand = "CPACK-COMMAND-NOT-FOUND"; - } - return this->CPackCommand.c_str(); -} - - -const char* cmake::GetCMakeCommand() -{ - return this->CMakeCommand.c_str(); -} - - void cmake::MarkCliAsUsed(const std::string& variable) { this->UsedCliVariables[variable] = true; @@ -3169,484 +2144,16 @@ void cmake::GenerateGraphViz(const char* fileName) const #endif } - -//---------------------------------------------------------------------------- -int cmake::SymlinkLibrary(std::vector<std::string>& args) -{ - int result = 0; - std::string realName = args[2]; - std::string soName = args[3]; - std::string name = args[4]; - if(soName != realName) - { - if(!cmake::SymlinkInternal(realName, soName)) - { - cmSystemTools::ReportLastSystemError("cmake_symlink_library"); - result = 1; - } - } - if(name != soName) - { - if(!cmake::SymlinkInternal(soName, name)) - { - cmSystemTools::ReportLastSystemError("cmake_symlink_library"); - result = 1; - } - } - return result; -} - -//---------------------------------------------------------------------------- -int cmake::SymlinkExecutable(std::vector<std::string>& args) -{ - int result = 0; - std::string realName = args[2]; - std::string name = args[3]; - if(name != realName) - { - if(!cmake::SymlinkInternal(realName, name)) - { - cmSystemTools::ReportLastSystemError("cmake_symlink_executable"); - result = 1; - } - } - return result; -} - -//---------------------------------------------------------------------------- -bool cmake::SymlinkInternal(std::string const& file, std::string const& link) -{ - if(cmSystemTools::FileExists(link.c_str()) || - cmSystemTools::FileIsSymlink(link.c_str())) - { - cmSystemTools::RemoveFile(link.c_str()); - } -#if defined(_WIN32) && !defined(__CYGWIN__) - return cmSystemTools::CopyFileAlways(file.c_str(), link.c_str()); -#else - std::string linktext = cmSystemTools::GetFilenameName(file); - return cmSystemTools::CreateSymlink(linktext.c_str(), link.c_str()); -#endif -} - -//---------------------------------------------------------------------------- -#ifdef CMAKE_BUILD_WITH_CMAKE -int cmake::ExecuteEchoColor(std::vector<std::string>& args) -{ - // The arguments are - // argv[0] == <cmake-executable> - // argv[1] == cmake_echo_color - - bool enabled = true; - int color = cmsysTerminal_Color_Normal; - bool newline = true; - for(unsigned int i=2; i < args.size(); ++i) - { - if(args[i].find("--switch=") == 0) - { - // Enable or disable color based on the switch value. - std::string value = args[i].substr(9); - if(!value.empty()) - { - if(cmSystemTools::IsOn(value.c_str())) - { - enabled = true; - } - else - { - enabled = false; - } - } - } - else if(args[i] == "--normal") - { - color = cmsysTerminal_Color_Normal; - } - else if(args[i] == "--black") - { - color = cmsysTerminal_Color_ForegroundBlack; - } - else if(args[i] == "--red") - { - color = cmsysTerminal_Color_ForegroundRed; - } - else if(args[i] == "--green") - { - color = cmsysTerminal_Color_ForegroundGreen; - } - else if(args[i] == "--yellow") - { - color = cmsysTerminal_Color_ForegroundYellow; - } - else if(args[i] == "--blue") - { - color = cmsysTerminal_Color_ForegroundBlue; - } - else if(args[i] == "--magenta") - { - color = cmsysTerminal_Color_ForegroundMagenta; - } - else if(args[i] == "--cyan") - { - color = cmsysTerminal_Color_ForegroundCyan; - } - else if(args[i] == "--white") - { - color = cmsysTerminal_Color_ForegroundWhite; - } - else if(args[i] == "--bold") - { - color |= cmsysTerminal_Color_ForegroundBold; - } - else if(args[i] == "--no-newline") - { - newline = false; - } - else if(args[i] == "--newline") - { - newline = true; - } - else - { - // Color is enabled. Print with the current color. - cmSystemTools::MakefileColorEcho(color, args[i].c_str(), - newline, enabled); - } - } - - return 0; -} -#else -int cmake::ExecuteEchoColor(std::vector<std::string>&) -{ - return 1; -} -#endif - -//---------------------------------------------------------------------------- -int cmake::ExecuteLinkScript(std::vector<std::string>& args) -{ - // The arguments are - // argv[0] == <cmake-executable> - // argv[1] == cmake_link_script - // argv[2] == <link-script-name> - // argv[3] == --verbose=? - bool verbose = false; - if(args.size() >= 4) - { - if(args[3].find("--verbose=") == 0) - { - if(!cmSystemTools::IsOff(args[3].substr(10).c_str())) - { - verbose = true; - } - } - } - - // Allocate a process instance. - cmsysProcess* cp = cmsysProcess_New(); - if(!cp) - { - std::cerr << "Error allocating process instance in link script." - << std::endl; - return 1; - } - - // Children should share stdout and stderr with this process. - cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDOUT, 1); - cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDERR, 1); - - // Run the command lines verbatim. - cmsysProcess_SetOption(cp, cmsysProcess_Option_Verbatim, 1); - - // Read command lines from the script. - std::ifstream fin(args[2].c_str()); - if(!fin) - { - std::cerr << "Error opening link script \"" - << args[2] << "\"" << std::endl; - return 1; - } - - // Run one command at a time. - std::string command; - int result = 0; - while(result == 0 && cmSystemTools::GetLineFromStream(fin, command)) - { - // Skip empty command lines. - if(command.find_first_not_of(" \t") == command.npos) - { - continue; - } - - // Setup this command line. - const char* cmd[2] = {command.c_str(), 0}; - cmsysProcess_SetCommand(cp, cmd); - - // Report the command if verbose output is enabled. - if(verbose) - { - std::cout << command << std::endl; - } - - // Run the command and wait for it to exit. - cmsysProcess_Execute(cp); - cmsysProcess_WaitForExit(cp, 0); - - // Report failure if any. - switch(cmsysProcess_GetState(cp)) - { - case cmsysProcess_State_Exited: - { - int value = cmsysProcess_GetExitValue(cp); - if(value != 0) - { - result = value; - } - } - break; - case cmsysProcess_State_Exception: - std::cerr << "Error running link command: " - << cmsysProcess_GetExceptionString(cp) << std::endl; - result = 1; - break; - case cmsysProcess_State_Error: - std::cerr << "Error running link command: " - << cmsysProcess_GetErrorString(cp) << std::endl; - result = 2; - break; - default: - break; - }; - } - - // Free the process instance. - cmsysProcess_Delete(cp); - - // Return the final resulting return value. - return result; -} - -void cmake::DefineProperties(cmake *cm) -{ - cm->DefineProperty - ("REPORT_UNDEFINED_PROPERTIES", cmProperty::GLOBAL, - "If set, report any undefined properties to this file.", - "If this property is set to a filename then when CMake runs " - "it will report any properties or variables that were accessed " - "but not defined into the filename specified in this property." - ); - - cm->DefineProperty - ("TARGET_SUPPORTS_SHARED_LIBS", cmProperty::GLOBAL, - "Does the target platform support shared libraries.", - "TARGET_SUPPORTS_SHARED_LIBS is a boolean specifying whether the target " - "platform supports shared libraries. Basically all current general " - "general purpose OS do so, the exception are usually embedded systems " - "with no or special OSs."); - - cm->DefineProperty - ("TARGET_ARCHIVES_MAY_BE_SHARED_LIBS", cmProperty::GLOBAL, - "Set if shared libraries may be named like archives.", - "On AIX shared libraries may be named \"lib<name>.a\". " - "This property is set to true on such platforms."); - - cm->DefineProperty - ("FIND_LIBRARY_USE_LIB64_PATHS", cmProperty::GLOBAL, - "Whether FIND_LIBRARY should automatically search lib64 directories.", - "FIND_LIBRARY_USE_LIB64_PATHS is a boolean specifying whether the " - "FIND_LIBRARY command should automatically search the lib64 variant of " - "directories called lib in the search path when building 64-bit " - "binaries."); - cm->DefineProperty - ("FIND_LIBRARY_USE_OPENBSD_VERSIONING", cmProperty::GLOBAL, - "Whether FIND_LIBRARY should find OpenBSD-style shared libraries.", - "This property is a boolean specifying whether the FIND_LIBRARY " - "command should find shared libraries with OpenBSD-style versioned " - "extension: \".so.<major>.<minor>\". " - "The property is set to true on OpenBSD and false on other platforms."); - cm->DefineProperty - ("ENABLED_FEATURES", cmProperty::GLOBAL, - "List of features which are enabled during the CMake run.", - "List of features which are enabled during the CMake run. By default " - "it contains the names of all packages which were found. This is " - "determined using the <NAME>_FOUND variables. Packages which are " - "searched QUIET are not listed. A project can add its own features to " - "this list. " - "This property is used by the macros in FeatureSummary.cmake."); - cm->DefineProperty - ("DISABLED_FEATURES", cmProperty::GLOBAL, - "List of features which are disabled during the CMake run.", - "List of features which are disabled during the CMake run. By default " - "it contains the names of all packages which were not found. This is " - "determined using the <NAME>_FOUND variables. Packages which are " - "searched QUIET are not listed. A project can add its own features to " - "this list. " - "This property is used by the macros in FeatureSummary.cmake."); - cm->DefineProperty - ("PACKAGES_FOUND", cmProperty::GLOBAL, - "List of packages which were found during the CMake run.", - "List of packages which were found during the CMake run. Whether a " - "package has been found is determined using the <NAME>_FOUND variables."); - cm->DefineProperty - ("PACKAGES_NOT_FOUND", cmProperty::GLOBAL, - "List of packages which were not found during the CMake run.", - "List of packages which were not found during the CMake run. Whether a " - "package has been found is determined using the <NAME>_FOUND variables."); - - cm->DefineProperty( - "__CMAKE_DELETE_CACHE_CHANGE_VARS_", cmProperty::GLOBAL, - "Internal property", - "Used to detect compiler changes, Do not set."); - - cm->DefineProperty( - "DEBUG_CONFIGURATIONS", cmProperty::GLOBAL, - "Specify which configurations are for debugging.", - "The value must be a semi-colon separated list of configuration names. " - "Currently this property is used only by the target_link_libraries " - "command (see its documentation for details). " - "Additional uses may be defined in the future. " - "\n" - "This property must be set at the top level of the project and before " - "the first target_link_libraries command invocation. " - "If any entry in the list does not match a valid configuration for " - "the project the behavior is undefined."); - - cm->DefineProperty( - "GLOBAL_DEPENDS_DEBUG_MODE", cmProperty::GLOBAL, - "Enable global target dependency graph debug mode.", - "CMake automatically analyzes the global inter-target dependency graph " - "at the beginning of native build system generation. " - "This property causes it to display details of its analysis to stderr."); - - cm->DefineProperty( - "GLOBAL_DEPENDS_NO_CYCLES", cmProperty::GLOBAL, - "Disallow global target dependency graph cycles.", - "CMake automatically analyzes the global inter-target dependency graph " - "at the beginning of native build system generation. " - "It reports an error if the dependency graph contains a cycle that " - "does not consist of all STATIC library targets. " - "This property tells CMake to disallow all cycles completely, even " - "among static libraries."); - - cm->DefineProperty( - "ALLOW_DUPLICATE_CUSTOM_TARGETS", cmProperty::GLOBAL, - "Allow duplicate custom targets to be created.", - "Normally CMake requires that all targets built in a project have " - "globally unique logical names (see policy CMP0002). " - "This is necessary to generate meaningful project file names in " - "Xcode and VS IDE generators. " - "It also allows the target names to be referenced unambiguously.\n" - "Makefile generators are capable of supporting duplicate custom target " - "names. " - "For projects that care only about Makefile generators and do " - "not wish to support Xcode or VS IDE generators, one may set this " - "property to true to allow duplicate custom targets. " - "The property allows multiple add_custom_target command calls in " - "different directories to specify the same target name. " - "However, setting this property will cause non-Makefile generators " - "to produce an error and refuse to generate the project." - ); - - cm->DefineProperty - ("IN_TRY_COMPILE", cmProperty::GLOBAL, - "Read-only property that is true during a try-compile configuration.", - "True when building a project inside a TRY_COMPILE or TRY_RUN command."); - cm->DefineProperty - ("ENABLED_LANGUAGES", cmProperty::GLOBAL, - "Read-only property that contains the list of currently " - "enabled languages", - "Set to list of currently enabled languages."); - - cm->DefineProperty - ("RULE_LAUNCH_COMPILE", cmProperty::GLOBAL, - "Specify a launcher for compile rules.", - "Makefile generators prefix compiler commands with the given " - "launcher command line. " - "This is intended to allow launchers to intercept build problems " - "with high granularity. " - "Non-Makefile generators currently ignore this property."); - cm->DefineProperty - ("RULE_LAUNCH_LINK", cmProperty::GLOBAL, - "Specify a launcher for link rules.", - "Makefile generators prefix link and archive commands with the given " - "launcher command line. " - "This is intended to allow launchers to intercept build problems " - "with high granularity. " - "Non-Makefile generators currently ignore this property."); - cm->DefineProperty - ("RULE_LAUNCH_CUSTOM", cmProperty::GLOBAL, - "Specify a launcher for custom rules.", - "Makefile generators prefix custom commands with the given " - "launcher command line. " - "This is intended to allow launchers to intercept build problems " - "with high granularity. " - "Non-Makefile generators currently ignore this property."); - - cm->DefineProperty - ("RULE_MESSAGES", cmProperty::GLOBAL, - "Specify whether to report a message for each make rule.", - "This property specifies whether Makefile generators should add a " - "progress message describing what each build rule does. " - "If the property is not set the default is ON. " - "Set the property to OFF to disable granular messages and report only " - "as each target completes. " - "This is intended to allow scripted builds to avoid the build time " - "cost of detailed reports. " - "If a CMAKE_RULE_MESSAGES cache entry exists its value initializes " - "the value of this property. " - "Non-Makefile generators currently ignore this property."); - - cm->DefineProperty - ("USE_FOLDERS", cmProperty::GLOBAL, - "Use the FOLDER target property to organize targets into folders.", - "If not set, CMake treats this property as OFF by default. " - "CMake generators that are capable of organizing into a " - "hierarchy of folders use the values of the FOLDER target " - "property to name those folders. See also the documentation " - "for the FOLDER target property."); - - cm->DefineProperty - ("AUTOMOC_TARGETS_FOLDER", cmProperty::GLOBAL, - "Name of FOLDER for *_automoc targets that are added automatically by " - "CMake for targets for which AUTOMOC is enabled.", - "If not set, CMake uses the FOLDER property of the parent target as a " - "default value for this property. See also the documentation for the " - "FOLDER target property and the AUTOMOC target property."); - - cm->DefineProperty - ("PREDEFINED_TARGETS_FOLDER", cmProperty::GLOBAL, - "Name of FOLDER for targets that are added automatically by CMake.", - "If not set, CMake uses \"CMakePredefinedTargets\" as a default " - "value for this property. Targets such as INSTALL, PACKAGE and " - "RUN_TESTS will be organized into this FOLDER. See also the " - "documentation for the FOLDER target property."); - - // ================================================================ - // define variables as well - // ================================================================ - cmDocumentVariables::DefineVariables(cm); -} - - void cmake::DefineProperty(const char *name, cmProperty::ScopeType scope, const char *ShortDescription, const char *FullDescription, - bool chained, const char *docSection) + bool chained) { this->PropertyDefinitions[scope].DefineProperty(name,scope,ShortDescription, FullDescription, - docSection, chained); } -bool cmake::GetIsPropertyDefined(const char *name, - cmProperty::ScopeType scope) -{ - return this->PropertyDefinitions[scope].find(name) != - this->PropertyDefinitions[scope].end(); -} - cmPropertyDefinition *cmake ::GetPropertyDefinition(const char *name, cmProperty::ScopeType scope) @@ -3658,112 +2165,6 @@ cmPropertyDefinition *cmake return 0; } -void cmake::RecordPropertyAccess(const char *name, - cmProperty::ScopeType scope) -{ - this->AccessedProperties.insert - (std::pair<cmStdString,cmProperty::ScopeType>(name,scope)); -} - -void cmake::ReportUndefinedPropertyAccesses(const char *filename) -{ - if(!this->GlobalGenerator) - { return; } - FILE *progFile = fopen(filename,"w"); - if(!progFile) - { return; } - - // what are the enabled languages? - std::vector<std::string> enLangs; - this->GlobalGenerator->GetEnabledLanguages(enLangs); - - // Common configuration names. - // TODO: Compute current configuration(s). - std::vector<std::string> enConfigs; - enConfigs.push_back(""); - enConfigs.push_back("DEBUG"); - enConfigs.push_back("RELEASE"); - enConfigs.push_back("MINSIZEREL"); - enConfigs.push_back("RELWITHDEBINFO"); - - // take all the defined properties and add definitions for all the enabled - // languages - std::set<std::pair<cmStdString,cmProperty::ScopeType> > aliasedProperties; - std::map<cmProperty::ScopeType, cmPropertyDefinitionMap>::iterator i; - i = this->PropertyDefinitions.begin(); - for (;i != this->PropertyDefinitions.end(); ++i) - { - cmPropertyDefinitionMap::iterator j; - for (j = i->second.begin(); j != i->second.end(); ++j) - { - // TODO: What if both <LANG> and <CONFIG> appear? - if (j->first.find("<CONFIG>") != std::string::npos) - { - std::vector<std::string>::const_iterator k; - for (k = enConfigs.begin(); k != enConfigs.end(); ++k) - { - std::string tmp = j->first; - cmSystemTools::ReplaceString(tmp, "<CONFIG>", k->c_str()); - // add alias - aliasedProperties.insert - (std::pair<cmStdString,cmProperty::ScopeType>(tmp,i->first)); - } - } - if (j->first.find("<LANG>") != std::string::npos) - { - std::vector<std::string>::const_iterator k; - for (k = enLangs.begin(); k != enLangs.end(); ++k) - { - std::string tmp = j->first; - cmSystemTools::ReplaceString(tmp, "<LANG>", k->c_str()); - // add alias - aliasedProperties.insert - (std::pair<cmStdString,cmProperty::ScopeType>(tmp,i->first)); - } - } - } - } - - std::set<std::pair<cmStdString,cmProperty::ScopeType> >::const_iterator ap; - ap = this->AccessedProperties.begin(); - for (;ap != this->AccessedProperties.end(); ++ap) - { - if (!this->IsPropertyDefined(ap->first.c_str(),ap->second) && - aliasedProperties.find(std::pair<cmStdString,cmProperty::ScopeType> - (ap->first,ap->second)) == - aliasedProperties.end()) - { - const char *scopeStr = ""; - switch (ap->second) - { - case cmProperty::TARGET: - scopeStr = "TARGET"; - break; - case cmProperty::SOURCE_FILE: - scopeStr = "SOURCE_FILE"; - break; - case cmProperty::DIRECTORY: - scopeStr = "DIRECTORY"; - break; - case cmProperty::TEST: - scopeStr = "TEST"; - break; - case cmProperty::VARIABLE: - scopeStr = "VARIABLE"; - break; - case cmProperty::CACHED_VARIABLE: - scopeStr = "CACHED_VARIABLE"; - break; - default: - scopeStr = "unknown"; - break; - } - fprintf(progFile, "%s with scope %s\n", ap->first.c_str(), scopeStr); - } - } - fclose(progFile); -} - bool cmake::IsPropertyDefined(const char *name, cmProperty::ScopeType scope) { return this->PropertyDefinitions[scope].IsPropertyDefined(name); @@ -3991,7 +2392,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args) // echo results to stdout if needed if (writeToStdout) { - FILE* fin = fopen(resultFile.c_str(), "r"); + FILE* fin = cmsys::SystemTools::Fopen(resultFile.c_str(), "r"); if(fin) { const int bufferSize = 4096; @@ -4025,9 +2426,9 @@ static bool cmakeCheckStampFile(const char* stampName) std::string stampDepends = stampName; stampDepends += ".depend"; #if defined(_WIN32) || defined(__CYGWIN__) - std::ifstream fin(stampDepends.c_str(), std::ios::in | std::ios::binary); + cmsys::ifstream fin(stampDepends.c_str(), std::ios::in | std::ios::binary); #else - std::ifstream fin(stampDepends.c_str(), std::ios::in); + cmsys::ifstream fin(stampDepends.c_str(), std::ios::in); #endif if(!fin) { @@ -4068,7 +2469,7 @@ static bool cmakeCheckStampFile(const char* stampName) { // TODO: Teach cmGeneratedFileStream to use a random temp file (with // multiple tries in unlikely case of conflict) and use that here. - std::ofstream stamp(stampTemp); + cmsys::ofstream stamp(stampTemp); stamp << "# CMake generation timestamp file for this directory.\n"; } if(cmSystemTools::RenameFile(stampTemp, stampName)) @@ -4098,7 +2499,7 @@ static bool cmakeCheckStampList(const char* stampList) << "is missing.\n"; return false; } - std::ifstream fin(stampList); + cmsys::ifstream fin(stampList); if(!fin) { std::cout << "CMake is re-running because generate.stamp.list " @@ -4119,356 +2520,6 @@ static bool cmakeCheckStampList(const char* stampList) } //---------------------------------------------------------------------------- -int cmake::WindowsCEEnvironment(const char* version, const std::string& name) -{ -#if defined(CMAKE_HAVE_VS_GENERATORS) - cmVisualStudioWCEPlatformParser parser(name.c_str()); - parser.ParseVersion(version); - if (parser.Found()) - { - std::cout << "@echo off" << std::endl; - std::cout << "echo Environment Selection: " << name << std::endl; - std::cout << "set PATH=" << parser.GetPathDirectories() << std::endl; - std::cout << "set INCLUDE=" << parser.GetIncludeDirectories() <<std::endl; - std::cout << "set LIB=" << parser.GetLibraryDirectories() <<std::endl; - return 0; - } -#else - (void)version; -#endif - - std::cerr << "Could not find " << name; - return -1; -} - -// For visual studio 2005 and newer manifest files need to be embedded into -// exe and dll's. This code does that in such a way that incremental linking -// still works. -int cmake::VisualStudioLink(std::vector<std::string>& args, int type) -{ - if(args.size() < 2) - { - return -1; - } - bool verbose = false; - if(cmSystemTools::GetEnv("VERBOSE")) - { - verbose = true; - } - std::vector<std::string> expandedArgs; - for(std::vector<std::string>::iterator i = args.begin(); - i != args.end(); ++i) - { - // check for nmake temporary files - if((*i)[0] == '@' && i->find("@CMakeFiles") != 0 ) - { - std::ifstream fin(i->substr(1).c_str()); - std::string line; - while(cmSystemTools::GetLineFromStream(fin, - line)) - { - cmSystemTools::ParseWindowsCommandLine(line.c_str(), expandedArgs); - } - } - else - { - expandedArgs.push_back(*i); - } - } - bool hasIncremental = false; - bool hasManifest = true; - for(std::vector<std::string>::iterator i = expandedArgs.begin(); - i != expandedArgs.end(); ++i) - { - if(cmSystemTools::Strucmp(i->c_str(), "/INCREMENTAL:YES") == 0) - { - hasIncremental = true; - } - if(cmSystemTools::Strucmp(i->c_str(), "/INCREMENTAL") == 0) - { - hasIncremental = true; - } - if(cmSystemTools::Strucmp(i->c_str(), "/MANIFEST:NO") == 0) - { - hasManifest = false; - } - } - if(hasIncremental && hasManifest) - { - if(verbose) - { - std::cout << "Visual Studio Incremental Link with embedded manifests\n"; - } - return cmake::VisualStudioLinkIncremental(expandedArgs, type, verbose); - } - if(verbose) - { - if(!hasIncremental) - { - std::cout << "Visual Studio Non-Incremental Link\n"; - } - else - { - std::cout << "Visual Studio Incremental Link without manifests\n"; - } - } - return cmake::VisualStudioLinkNonIncremental(expandedArgs, - type, hasManifest, verbose); -} - -int cmake::ParseVisualStudioLinkCommand(std::vector<std::string>& args, - std::vector<cmStdString>& command, - std::string& targetName) -{ - std::vector<std::string>::iterator i = args.begin(); - i++; // skip -E - i++; // skip vs_link_dll or vs_link_exe - command.push_back(*i); - i++; // move past link command - for(; i != args.end(); ++i) - { - command.push_back(*i); - if(i->find("/Fe") == 0) - { - targetName = i->substr(3); - } - if(i->find("/out:") == 0) - { - targetName = i->substr(5); - } - } - if(targetName.size() == 0 || command.size() == 0) - { - return -1; - } - return 0; -} - -bool cmake::RunCommand(const char* comment, - std::vector<cmStdString>& command, - bool verbose, - int* retCodeOut) -{ - if(verbose) - { - std::cout << comment << ":\n"; - for(std::vector<cmStdString>::iterator i = command.begin(); - i != command.end(); ++i) - { - std::cout << i->c_str() << " "; - } - std::cout << "\n"; - } - std::string output; - int retCode =0; - // use rc command to create .res file - cmSystemTools::RunSingleCommand(command, - &output, - &retCode, 0, cmSystemTools::OUTPUT_NONE); - // always print the output of the command, unless - // it is the dumb rc command banner, but if the command - // returned an error code then print the output anyway as - // the banner may be mixed with some other important information. - if(output.find("Resource Compiler Version") == output.npos - || retCode !=0) - { - std::cout << output; - } - // if retCodeOut is requested then always return true - // and set the retCodeOut to retCode - if(retCodeOut) - { - *retCodeOut = retCode; - return true; - } - if(retCode != 0) - { - std::cout << comment << " failed. with " << retCode << "\n"; - } - return retCode == 0; -} - -int cmake::VisualStudioLinkIncremental(std::vector<std::string>& args, - int type, bool verbose) -{ - // This follows the steps listed here: - // http://blogs.msdn.com/zakramer/archive/2006/05/22/603558.aspx - - // 1. Compiler compiles the application and generates the *.obj files. - // 2. An empty manifest file is generated if this is a clean build and if - // not the previous one is reused. - // 3. The resource compiler (rc.exe) compiles the *.manifest file to a - // *.res file. - // 4. Linker generates the binary (EXE or DLL) with the /incremental - // switch and embeds the dummy manifest file. The linker also generates - // the real manifest file based on the binaries that your binary depends - // on. - // 5. The manifest tool (mt.exe) is then used to generate the final - // manifest. - - // If the final manifest is changed, then 6 and 7 are run, if not - // they are skipped, and it is done. - - // 6. The resource compiler is invoked one more time. - // 7. Finally, the Linker does another incremental link, but since the - // only thing that has changed is the *.res file that contains the - // manifest it is a short link. - std::vector<cmStdString> linkCommand; - std::string targetName; - if(cmake::ParseVisualStudioLinkCommand(args, linkCommand, targetName) == -1) - { - return -1; - } - std::string manifestArg = "/MANIFESTFILE:"; - std::vector<cmStdString> rcCommand; - rcCommand.push_back(cmSystemTools::FindProgram("rc.exe")); - std::vector<cmStdString> mtCommand; - mtCommand.push_back(cmSystemTools::FindProgram("mt.exe")); - std::string tempManifest; - tempManifest = targetName; - tempManifest += ".intermediate.manifest"; - std::string resourceInputFile = targetName; - resourceInputFile += ".resource.txt"; - if(verbose) - { - std::cout << "Create " << resourceInputFile.c_str() << "\n"; - } - // Create input file for rc command - std::ofstream fout(resourceInputFile.c_str()); - if(!fout) - { - return -1; - } - std::string manifestFile = targetName; - manifestFile += ".embed.manifest"; - std::string fullPath= cmSystemTools::CollapseFullPath(manifestFile.c_str()); - fout << type << " /* CREATEPROCESS_MANIFEST_RESOURCE_ID " - "*/ 24 /* RT_MANIFEST */ " << "\"" << fullPath.c_str() << "\""; - fout.close(); - manifestArg += tempManifest; - // add the manifest arg to the linkCommand - linkCommand.push_back("/MANIFEST"); - linkCommand.push_back(manifestArg); - // if manifestFile is not yet created, create an - // empty one - if(!cmSystemTools::FileExists(manifestFile.c_str())) - { - if(verbose) - { - std::cout << "Create empty: " << manifestFile.c_str() << "\n"; - } - std::ofstream foutTmp(manifestFile.c_str()); - } - std::string resourceFile = manifestFile; - resourceFile += ".res"; - // add the resource file to the end of the link command - linkCommand.push_back(resourceFile); - std::string outputOpt = "/fo"; - outputOpt += resourceFile; - rcCommand.push_back(outputOpt); - rcCommand.push_back(resourceInputFile); - // Run rc command to create resource - if(!cmake::RunCommand("RC Pass 1", rcCommand, verbose)) - { - return -1; - } - // Now run the link command to link and create manifest - if(!cmake::RunCommand("LINK Pass 1", linkCommand, verbose)) - { - return -1; - } - // create mt command - std::string outArg("/out:"); - outArg+= manifestFile; - mtCommand.push_back("/nologo"); - mtCommand.push_back(outArg); - mtCommand.push_back("/notify_update"); - mtCommand.push_back("/manifest"); - mtCommand.push_back(tempManifest); - // now run mt.exe to create the final manifest file - int mtRet =0; - cmake::RunCommand("MT", mtCommand, verbose, &mtRet); - // if mt returns 0, then the manifest was not changed and - // we do not need to do another link step - if(mtRet == 0) - { - return 0; - } - // check for magic mt return value if mt returns the magic number - // 1090650113 then it means that it updated the manifest file and we need - // to do the final link. If mt has any value other than 0 or 1090650113 - // then there was some problem with the command itself and there was an - // error so return the error code back out of cmake so make can report it. - if(mtRet != 1090650113) - { - return mtRet; - } - // update the resource file with the new manifest from the mt command. - if(!cmake::RunCommand("RC Pass 2", rcCommand, verbose)) - { - return -1; - } - // Run the final incremental link that will put the new manifest resource - // into the file incrementally. - if(!cmake::RunCommand("FINAL LINK", linkCommand, verbose)) - { - return -1; - } - return 0; -} - -int cmake::VisualStudioLinkNonIncremental(std::vector<std::string>& args, - int type, - bool hasManifest, - bool verbose) -{ - std::vector<cmStdString> linkCommand; - std::string targetName; - if(cmake::ParseVisualStudioLinkCommand(args, linkCommand, targetName) == -1) - { - return -1; - } - // Run the link command as given - if (hasManifest) - { - linkCommand.push_back("/MANIFEST"); - } - if(!cmake::RunCommand("LINK", linkCommand, verbose)) - { - return -1; - } - if(!hasManifest) - { - return 0; - } - std::vector<cmStdString> mtCommand; - mtCommand.push_back(cmSystemTools::FindProgram("mt.exe")); - mtCommand.push_back("/nologo"); - mtCommand.push_back("/manifest"); - std::string manifestFile = targetName; - manifestFile += ".manifest"; - mtCommand.push_back(manifestFile); - std::string outresource = "/outputresource:"; - outresource += targetName; - outresource += ";#"; - if(type == 1) - { - outresource += "1"; - } - else if(type == 2) - { - outresource += "2"; - } - mtCommand.push_back(outresource); - // Now use the mt tool to embed the manifest into the exe or dll - if(!cmake::RunCommand("MT", mtCommand, verbose)) - { - return -1; - } - return 0; -} - -//---------------------------------------------------------------------------- void cmake::IssueMessage(cmake::MessageType t, std::string const& text, cmListFileBacktrace const& backtrace) { @@ -4489,6 +2540,15 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text, { msg << "CMake Debug Log"; } + else if(t == cmake::DEPRECATION_ERROR) + { + msg << "CMake Deprecation Error"; + isError = true; + } + else if (t == cmake::DEPRECATION_WARNING) + { + msg << "CMake Deprecation Warning"; + } else { msg << "CMake Warning"; @@ -4517,7 +2577,7 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text, // Add the message text. { msg << ":\n"; - cmDocumentationFormatterText formatter; + cmDocumentationFormatter formatter; formatter.SetIndent(" "); formatter.PrintFormatted(msg, text.c_str()); } @@ -4586,8 +2646,7 @@ int cmake::Build(const std::string& dir, const std::string& target, const std::string& config, const std::vector<std::string>& nativeOptions, - bool clean, - cmSystemTools::OutputOption outputflag) + bool clean) { if(!cmSystemTools::FileIsDirectory(dir.c_str())) { @@ -4612,25 +2671,19 @@ int cmake::Build(const std::string& dir, this->CreateGlobalGenerator(it.GetValue())); std::string output; std::string projName; - std::string makeProgram; if(!it.Find("CMAKE_PROJECT_NAME")) { std::cerr << "Error: could not find CMAKE_PROJECT_NAME in Cache\n"; return 1; } projName = it.GetValue(); - if(!it.Find("CMAKE_MAKE_PROGRAM")) - { - std::cerr << "Error: could not find CMAKE_MAKE_PROGRAM in Cache\n"; - return 1; - } - makeProgram = it.GetValue(); return gen->Build(0, dir.c_str(), projName.c_str(), target.c_str(), &output, - makeProgram.c_str(), - config.c_str(), clean, false, 0, outputflag, - 0, nativeOptions); + 0, + config.c_str(), clean, false, 0, + cmSystemTools::OUTPUT_PASSTHROUGH, + nativeOptions); } void cmake::WatchUnusedCli(const char* var) |