/cmake-2.8.9-rc2/Source/cmake.cxx
C++ | 4533 lines | 4195 code | 148 blank | 190 comment | 494 complexity | 2e688e365eee01c8e03ba36b9d47bbce MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.0, Apache-2.0
Large files files are truncated, but you can click here to view the full file
- /*============================================================================
- 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 "cmake.h"
- #include "cmDocumentVariables.h"
- #include "time.h"
- #include "cmCacheManager.h"
- #include "cmMakefile.h"
- #include "cmLocalGenerator.h"
- #include "cmExternalMakefileProjectGenerator.h"
- #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"
- #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>
- // only build kdevelop generator on non-windows platforms
- // when not bootstrapping cmake
- #if !defined(_WIN32)
- # if defined(CMAKE_BUILD_WITH_CMAKE)
- # define CMAKE_USE_KDEVELOP
- # endif
- #endif
- #if defined(CMAKE_BUILD_WITH_CMAKE)
- # define CMAKE_USE_ECLIPSE
- #endif
- #if defined(__MINGW32__) && !defined(CMAKE_BUILD_WITH_CMAKE)
- # define CMAKE_BOOT_MINGW
- #endif
- // include the generator
- #if defined(_WIN32) && !defined(__CYGWIN__)
- # if !defined(CMAKE_BOOT_MINGW)
- # include "cmGlobalVisualStudio6Generator.h"
- # include "cmGlobalVisualStudio7Generator.h"
- # include "cmGlobalVisualStudio71Generator.h"
- # include "cmGlobalVisualStudio8Generator.h"
- # include "cmGlobalVisualStudio9Generator.h"
- # include "cmGlobalVisualStudio9IA64Generator.h"
- # include "cmGlobalVisualStudio9Win64Generator.h"
- # include "cmGlobalVisualStudio10Generator.h"
- # include "cmGlobalVisualStudio10IA64Generator.h"
- # include "cmGlobalVisualStudio10Win64Generator.h"
- # include "cmGlobalVisualStudio11Generator.h"
- # include "cmGlobalVisualStudio11Win64Generator.h"
- # include "cmGlobalVisualStudio11ARMGenerator.h"
- # include "cmGlobalVisualStudio8Win64Generator.h"
- # include "cmGlobalBorlandMakefileGenerator.h"
- # include "cmGlobalNMakeMakefileGenerator.h"
- # include "cmGlobalJOMMakefileGenerator.h"
- # include "cmGlobalWatcomWMakeGenerator.h"
- # define CMAKE_HAVE_VS_GENERATORS
- # endif
- # include "cmGlobalMSYSMakefileGenerator.h"
- # include "cmGlobalMinGWMakefileGenerator.h"
- # include "cmWin32ProcessExecution.h"
- #else
- #endif
- #include "cmGlobalUnixMakefileGenerator3.h"
- #ifdef CMAKE_USE_NINJA
- # include "cmGlobalNinjaGenerator.h"
- #endif
- #if defined(CMAKE_HAVE_VS_GENERATORS)
- #include "cmCallVisualStudioMacro.h"
- #endif
- #if !defined(CMAKE_BOOT_MINGW)
- # include "cmExtraCodeBlocksGenerator.h"
- #endif
- #ifdef CMAKE_USE_KDEVELOP
- # include "cmGlobalKdevelopGenerator.h"
- #endif
- #ifdef CMAKE_USE_ECLIPSE
- # include "cmExtraEclipseCDT4Generator.h"
- #endif
- #include <stdlib.h> // required for atoi
- #if defined( __APPLE__ )
- # if defined(CMAKE_BUILD_WITH_CMAKE)
- # include "cmGlobalXCodeGenerator.h"
- # define CMAKE_USE_XCODE 1
- # endif
- # include <sys/types.h>
- # include <sys/time.h>
- # include <sys/resource.h>
- #endif
- #include <sys/stat.h> // struct stat
- #include <memory> // auto_ptr
- 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_COMPATABILITY 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*)
- {
- cmake* cm = reinterpret_cast<cmake*>(ctx);
- cm->MarkCliAsUsed(variable);
- }
- cmake::cmake()
- {
- this->Trace = false;
- this->WarnUninitialized = false;
- this->WarnUnused = false;
- this->WarnUnusedCli = true;
- this->CheckSystemVars = false;
- this->SuppressDevWarnings = false;
- this->DoSuppressDevWarnings = false;
- this->DebugOutput = false;
- this->DebugTryCompile = false;
- this->ClearBuildSystem = false;
- this->FileComparison = new cmFileTimeComparison;
- this->Policies = new cmPolicies();
- this->InitializeProperties();
- #ifdef __APPLE__
- struct rlimit rlp;
- if(!getrlimit(RLIMIT_STACK, &rlp))
- {
- if(rlp.rlim_cur != rlp.rlim_max)
- {
- rlp.rlim_cur = rlp.rlim_max;
- setrlimit(RLIMIT_STACK, &rlp);
- }
- }
- #endif
- this->Verbose = false;
- this->InTryCompile = false;
- this->CacheManager = new cmCacheManager(this);
- this->GlobalGenerator = 0;
- this->ProgressCallback = 0;
- this->ProgressCallbackClientData = 0;
- this->CurrentWorkingMode = NORMAL_MODE;
- #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();
- this->AddDefaultExtraGenerators();
- this->AddDefaultCommands();
- // Make sure we can capture the build tool output.
- cmSystemTools::EnableVSConsoleOutput();
- }
- cmake::~cmake()
- {
- delete this->CacheManager;
- delete this->Policies;
- if (this->GlobalGenerator)
- {
- delete this->GlobalGenerator;
- this->GlobalGenerator = 0;
- }
- for(RegisteredCommandsMap::iterator j = this->Commands.begin();
- j != this->Commands.end(); ++j)
- {
- delete (*j).second;
- }
- #ifdef CMAKE_BUILD_WITH_CMAKE
- delete this->VariableWatch;
- #endif
- delete this->FileComparison;
- }
- void cmake::InitializeProperties()
- {
- this->Properties.clear();
- this->Properties.SetCMakeInstance(this);
- this->AccessedProperties.clear();
- 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()
- {
- this->InitializeProperties();
- std::vector<cmCommand*> commands;
- for(RegisteredCommandsMap::iterator j = this->Commands.begin();
- j != this->Commands.end(); ++j)
- {
- if ( !j->second->IsA("cmMacroHelperCommand") &&
- !j->second->IsA("cmFunctionHelperCommand"))
- {
- commands.push_back(j->second);
- }
- else
- {
- delete j->second;
- }
- }
- this->Commands.erase(this->Commands.begin(), this->Commands.end());
- std::vector<cmCommand*>::iterator it;
- for ( it = commands.begin(); it != commands.end();
- ++ it )
- {
- this->Commands[cmSystemTools::LowerCase((*it)->GetName())] = *it;
- }
- }
- bool cmake::CommandExists(const char* name) const
- {
- std::string sName = cmSystemTools::LowerCase(name);
- return (this->Commands.find(sName) != this->Commands.end());
- }
- cmCommand *cmake::GetCommand(const char *name)
- {
- cmCommand* rm = 0;
- std::string sName = cmSystemTools::LowerCase(name);
- RegisteredCommandsMap::iterator pos = this->Commands.find(sName);
- if (pos != this->Commands.end())
- {
- rm = (*pos).second;
- }
- return rm;
- }
- void cmake::RenameCommand(const char*oldName, const char* newName)
- {
- // if the command already exists, free the old one
- std::string sOldName = cmSystemTools::LowerCase(oldName);
- std::string sNewName = cmSystemTools::LowerCase(newName);
- RegisteredCommandsMap::iterator pos = this->Commands.find(sOldName);
- if ( pos == this->Commands.end() )
- {
- return;
- }
- cmCommand* cmd = pos->second;
- pos = this->Commands.find(sNewName);
- if (pos != this->Commands.end())
- {
- delete pos->second;
- this->Commands.erase(pos);
- }
- this->Commands.insert(RegisteredCommandsMap::value_type(sNewName, cmd));
- pos = this->Commands.find(sOldName);
- this->Commands.erase(pos);
- }
- void cmake::RemoveCommand(const char* name)
- {
- std::string sName = cmSystemTools::LowerCase(name);
- RegisteredCommandsMap::iterator pos = this->Commands.find(sName);
- if ( pos != this->Commands.end() )
- {
- delete pos->second;
- this->Commands.erase(pos);
- }
- }
- void cmake::AddCommand(cmCommand* wg)
- {
- std::string name = cmSystemTools::LowerCase(wg->GetName());
- // if the command already exists, free the old one
- RegisteredCommandsMap::iterator pos = this->Commands.find(name);
- if (pos != this->Commands.end())
- {
- delete pos->second;
- this->Commands.erase(pos);
- }
- this->Commands.insert( RegisteredCommandsMap::value_type(name, wg));
- }
- void cmake::RemoveUnscriptableCommands()
- {
- std::vector<std::string> unscriptableCommands;
- cmake::RegisteredCommandsMap* commands = this->GetCommands();
- for (cmake::RegisteredCommandsMap::const_iterator pos = commands->begin();
- pos != commands->end();
- ++pos)
- {
- if (!pos->second->IsScriptable())
- {
- unscriptableCommands.push_back(pos->first);
- }
- }
- for(std::vector<std::string>::const_iterator it=unscriptableCommands.begin();
- it != unscriptableCommands.end();
- ++it)
- {
- this->RemoveCommand(it->c_str());
- }
- }
- // Parse the args
- bool cmake::SetCacheArgs(const std::vector<std::string>& args)
- {
- bool findPackageMode = false;
- for(unsigned int i=1; i < args.size(); ++i)
- {
- std::string arg = args[i];
- if(arg.find("-D",0) == 0)
- {
- std::string entry = arg.substr(2);
- if(entry.size() == 0)
- {
- ++i;
- if(i < args.size())
- {
- entry = args[i];
- }
- else
- {
- cmSystemTools::Error("-D must be followed with VAR=VALUE.");
- return false;
- }
- }
- std::string var, value;
- cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED;
- if(cmCacheManager::ParseEntry(entry.c_str(), var, value, type))
- {
- this->CacheManager->AddCacheEntry(var.c_str(), value.c_str(),
- "No help, variable specified on the command line.", type);
- if(this->WarnUnusedCli)
- {
- this->WatchUnusedCli(var.c_str());
- }
- }
- else
- {
- std::cerr << "Parse error in command line argument: " << arg << "\n"
- << "Should be: VAR:type=value\n";
- cmSystemTools::Error("No cmake script provided.");
- return false;
- }
- }
- else if(arg.find("-Wno-dev",0) == 0)
- {
- this->SuppressDevWarnings = true;
- this->DoSuppressDevWarnings = true;
- }
- else if(arg.find("-Wdev",0) == 0)
- {
- this->SuppressDevWarnings = false;
- this->DoSuppressDevWarnings = true;
- }
- else if(arg.find("-U",0) == 0)
- {
- std::string entryPattern = arg.substr(2);
- if(entryPattern.size() == 0)
- {
- ++i;
- if(i < args.size())
- {
- entryPattern = args[i];
- }
- else
- {
- cmSystemTools::Error("-U must be followed with VAR.");
- return false;
- }
- }
- cmsys::RegularExpression regex(
- cmsys::Glob::PatternToRegex(entryPattern.c_str(), true, true).c_str());
- //go through all cache entries and collect the vars which will be removed
- std::vector<std::string> entriesToDelete;
- cmCacheManager::CacheIterator it =
- this->CacheManager->GetCacheIterator();
- for ( it.Begin(); !it.IsAtEnd(); it.Next() )
- {
- cmCacheManager::CacheEntryType t = it.GetType();
- if(t != cmCacheManager::STATIC)
- {
- std::string entryName = it.GetName();
- if (regex.find(entryName.c_str()))
- {
- entriesToDelete.push_back(entryName);
- }
- }
- }
- // now remove them from the cache
- for(std::vector<std::string>::const_iterator currentEntry =
- entriesToDelete.begin();
- currentEntry != entriesToDelete.end();
- ++currentEntry)
- {
- this->CacheManager->RemoveCacheEntry(currentEntry->c_str());
- }
- }
- else if(arg.find("-C",0) == 0)
- {
- std::string path = arg.substr(2);
- if ( path.size() == 0 )
- {
- ++i;
- if(i < args.size())
- {
- path = args[i];
- }
- else
- {
- cmSystemTools::Error("-C must be followed by a file name.");
- return false;
- }
- }
- std::cerr << "loading initial cache file " << path.c_str() << "\n";
- this->ReadListFile(args, path.c_str());
- }
- else if(arg.find("-P",0) == 0)
- {
- i++;
- if(i >= args.size())
- {
- cmSystemTools::Error("-P must be followed by a file name.");
- return false;
- }
- std::string path = args[i];
- if ( path.size() == 0 )
- {
- cmSystemTools::Error("No cmake script provided.");
- return false;
- }
- this->ReadListFile(args, path.c_str());
- }
- else if (arg.find("--find-package",0) == 0)
- {
- findPackageMode = true;
- }
- }
- if (findPackageMode)
- {
- return this->FindPackage(args);
- }
- return true;
- }
- void cmake::ReadListFile(const std::vector<std::string>& args,
- const char *path)
- {
- // if a generator was not yet created, temporarily create one
- cmGlobalGenerator *gg = this->GetGlobalGenerator();
- bool created = false;
- // if a generator was not specified use a generic one
- if (!gg)
- {
- gg = new cmGlobalGenerator;
- gg->SetCMakeInstance(this);
- created = true;
- }
- // read in the list file to fill the cache
- if(path)
- {
- std::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator());
- lg->GetMakefile()->SetHomeOutputDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
- lg->GetMakefile()->SetStartOutputDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
- lg->GetMakefile()->SetHomeDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
- lg->GetMakefile()->SetStartDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
- if (this->GetWorkingMode() != NORMAL_MODE)
- {
- std::string file(cmSystemTools::CollapseFullPath(path));
- cmSystemTools::ConvertToUnixSlashes(file);
- lg->GetMakefile()->SetScriptModeFile(file.c_str());
- lg->GetMakefile()->SetArgcArgv(args);
- }
- if (!lg->GetMakefile()->ReadListFile(0, path))
- {
- cmSystemTools::Error("Error processing file:", path);
- }
- }
- // free generic one if generated
- if (created)
- {
- delete gg;
- }
- }
- bool cmake::FindPackage(const std::vector<std::string>& args)
- {
- // if a generator was not yet created, temporarily create one
- cmGlobalGenerator *gg = new cmGlobalGenerator;
- gg->SetCMakeInstance(this);
- this->SetGlobalGenerator(gg);
- // read in the list file to fill the cache
- std::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator());
- cmMakefile* mf = lg->GetMakefile();
- mf->SetHomeOutputDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
- mf->SetStartOutputDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
- mf->SetHomeDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
- mf->SetStartDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
- mf->SetArgcArgv(args);
- std::string systemFile = mf->GetModulesFile("CMakeFindPackageMode.cmake");
- mf->ReadListFile(0, systemFile.c_str());
- std::string language = mf->GetSafeDefinition("LANGUAGE");
- std::string mode = mf->GetSafeDefinition("MODE");
- std::string packageName = mf->GetSafeDefinition("NAME");
- bool packageFound = mf->IsOn("PACKAGE_FOUND");
- bool quiet = mf->IsOn("PACKAGE_QUIET");
- if (!packageFound)
- {
- if (!quiet)
- {
- printf("%s not found.\n", packageName.c_str());
- }
- }
- else if (mode == "EXIST")
- {
- if (!quiet)
- {
- printf("%s found.\n", packageName.c_str());
- }
- }
- else if (mode == "COMPILE")
- {
- std::string includes = mf->GetSafeDefinition("PACKAGE_INCLUDE_DIRS");
- std::vector<std::string> includeDirs;
- cmSystemTools::ExpandListArgument(includes, includeDirs);
- std::string includeFlags = lg->GetIncludeFlags(includeDirs,
- language.c_str(), false);
- std::string definitions = mf->GetSafeDefinition("PACKAGE_DEFINITIONS");
- printf("%s %s\n", includeFlags.c_str(), definitions.c_str());
- }
- else if (mode == "LINK")
- {
- const char* targetName = "dummy";
- std::vector<std::string> srcs;
- cmTarget* tgt = mf->AddExecutable(targetName, srcs, true);
- tgt->SetProperty("LINKER_LANGUAGE", language.c_str());
- std::string libs = mf->GetSafeDefinition("PACKAGE_LIBRARIES");
- std::vector<std::string> libList;
- cmSystemTools::ExpandListArgument(libs, libList);
- for(std::vector<std::string>::const_iterator libIt=libList.begin();
- libIt != libList.end();
- ++libIt)
- {
- mf->AddLinkLibraryForTarget(targetName, libIt->c_str(),
- cmTarget::GENERAL);
- }
- std::string linkLibs;
- std::string flags;
- std::string linkFlags;
- lg->GetTargetFlags(linkLibs, flags, linkFlags, *tgt);
- printf("%s\n", linkLibs.c_str() );
- /* if ( use_win32 )
- {
- tgt->SetProperty("WIN32_EXECUTABLE", "ON");
- }
- if ( use_macbundle)
- {
- tgt->SetProperty("MACOSX_BUNDLE", "ON");
- }*/
- }
- // free generic one if generated
- // this->SetGlobalGenerator(0); // setting 0-pointer is not possible
- // delete gg; // this crashes inside the cmake instance
- return packageFound;
- }
- // Parse the args
- void cmake::SetArgs(const std::vector<std::string>& args,
- bool directoriesSetBefore)
- {
- bool directoriesSet = directoriesSetBefore;
- for(unsigned int i=1; i < args.size(); ++i)
- {
- std::string arg = args[i];
- if(arg.find("-H",0) == 0)
- {
- directoriesSet = true;
- std::string path = arg.substr(2);
- path = cmSystemTools::CollapseFullPath(path.c_str());
- cmSystemTools::ConvertToUnixSlashes(path);
- this->SetHomeDirectory(path.c_str());
- }
- else if(arg.find("-S",0) == 0)
- {
- // There is no local generate anymore. Ignore -S option.
- }
- else if(arg.find("-O",0) == 0)
- {
- // There is no local generate anymore. Ignore -O option.
- }
- else if(arg.find("-B",0) == 0)
- {
- directoriesSet = true;
- std::string path = arg.substr(2);
- path = cmSystemTools::CollapseFullPath(path.c_str());
- cmSystemTools::ConvertToUnixSlashes(path);
- this->SetHomeOutputDirectory(path.c_str());
- }
- else if((i < args.size()-1) && (arg.find("--check-build-system",0) == 0))
- {
- this->CheckBuildSystemArgument = args[++i];
- this->ClearBuildSystem = (atoi(args[++i].c_str()) > 0);
- }
- else if((i < args.size()-1) && (arg.find("--check-stamp-file",0) == 0))
- {
- this->CheckStampFile = args[++i];
- }
- else if((i < args.size()-1) && (arg.find("--check-stamp-list",0) == 0))
- {
- this->CheckStampList = args[++i];
- }
- #if defined(CMAKE_HAVE_VS_GENERATORS)
- else if((i < args.size()-1) && (arg.find("--vs-solution-file",0) == 0))
- {
- this->VSSolutionFile = args[++i];
- }
- #endif
- else if(arg.find("-V",0) == 0)
- {
- this->Verbose = true;
- }
- else if(arg.find("-D",0) == 0)
- {
- // skip for now
- }
- else if(arg.find("-U",0) == 0)
- {
- // skip for now
- }
- else if(arg.find("-C",0) == 0)
- {
- // skip for now
- }
- else if(arg.find("-P",0) == 0)
- {
- // skip for now
- i++;
- }
- else if(arg.find("--find-package",0) == 0)
- {
- // skip for now
- i++;
- }
- else if(arg.find("-Wno-dev",0) == 0)
- {
- // skip for now
- }
- else if(arg.find("-Wdev",0) == 0)
- {
- // skip for now
- }
- else if(arg.find("--graphviz=",0) == 0)
- {
- std::string path = arg.substr(strlen("--graphviz="));
- path = cmSystemTools::CollapseFullPath(path.c_str());
- cmSystemTools::ConvertToUnixSlashes(path);
- this->GraphVizFile = path;
- if ( this->GraphVizFile.empty() )
- {
- cmSystemTools::Error("No file specified for --graphviz");
- }
- }
- else if(arg.find("--debug-trycompile",0) == 0)
- {
- std::cout << "debug trycompile on\n";
- this->DebugTryCompileOn();
- }
- else if(arg.find("--debug-output",0) == 0)
- {
- std::cout << "Running with debug output on.\n";
- this->SetDebugOutputOn(true);
- }
- else if(arg.find("--trace",0) == 0)
- {
- std::cout << "Running with trace output on.\n";
- this->SetTrace(true);
- }
- else if(arg.find("--warn-uninitialized",0) == 0)
- {
- std::cout << "Warn about uninitialized values.\n";
- this->SetWarnUninitialized(true);
- }
- else if(arg.find("--warn-unused-vars",0) == 0)
- {
- std::cout << "Finding unused variables.\n";
- this->SetWarnUnused(true);
- }
- else if(arg.find("--no-warn-unused-cli",0) == 0)
- {
- std::cout << "Not searching for unused variables given on the " <<
- "command line.\n";
- this->SetWarnUnusedCli(false);
- }
- else if(arg.find("--check-system-vars",0) == 0)
- {
- std::cout << "Also check system files when warning about unused and " <<
- "uninitialized variables.\n";
- this->SetCheckSystemVars(true);
- }
- else if(arg.find("-G",0) == 0)
- {
- std::string value = arg.substr(2);
- if(value.size() == 0)
- {
- ++i;
- if(i >= args.size())
- {
- cmSystemTools::Error("No generator specified for -G");
- return;
- }
- value = args[i];
- }
- cmGlobalGenerator* gen =
- this->CreateGlobalGenerator(value.c_str());
- if(!gen)
- {
- cmSystemTools::Error("Could not create named generator ",
- value.c_str());
- }
- else
- {
- this->SetGlobalGenerator(gen);
- }
- }
- // no option assume it is the path to the source
- else
- {
- directoriesSet = true;
- this->SetDirectoriesFromFile(arg.c_str());
- }
- }
- if(!directoriesSet)
- {
- this->SetHomeOutputDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
- this->SetStartOutputDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
- this->SetHomeDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
- this->SetStartDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
- }
- this->SetStartDirectory(this->GetHomeDirectory());
- this->SetStartOutputDirectory(this->GetHomeOutputDirectory());
- }
- //----------------------------------------------------------------------------
- void cmake::SetDirectoriesFromFile(const char* arg)
- {
- // Check if the argument refers to a CMakeCache.txt or
- // CMakeLists.txt file.
- std::string listPath;
- std::string cachePath;
- bool argIsFile = false;
- if(cmSystemTools::FileIsDirectory(arg))
- {
- std::string path = cmSystemTools::CollapseFullPath(arg);
- cmSystemTools::ConvertToUnixSlashes(path);
- std::string cacheFile = path;
- cacheFile += "/CMakeCache.txt";
- std::string listFile = path;
- listFile += "/CMakeLists.txt";
- if(cmSystemTools::FileExists(cacheFile.c_str()))
- {
- cachePath = path;
- }
- if(cmSystemTools::FileExists(listFile.c_str()))
- {
- listPath = path;
- }
- }
- else if(cmSystemTools::FileExists(arg))
- {
- argIsFile = true;
- std::string fullPath = cmSystemTools::CollapseFullPath(arg);
- std::string name = cmSystemTools::GetFilenameName(fullPath.c_str());
- name = cmSystemTools::LowerCase(name);
- if(name == "cmakecache.txt")
- {
- cachePath = cmSystemTools::GetFilenamePath(fullPath.c_str());
- }
- else if(name == "cmakelists.txt")
- {
- listPath = cmSystemTools::GetFilenamePath(fullPath.c_str());
- }
- }
- else
- {
- // Specified file or directory does not exist. Try to set things
- // up to produce a meaningful error message.
- std::string fullPath = cmSystemTools::CollapseFullPath(arg);
- std::string name = cmSystemTools::GetFilenameName(fullPath.c_str());
- name = cmSystemTools::LowerCase(name);
- if(name == "cmakecache.txt" || name == "cmakelists.txt")
- {
- argIsFile = true;
- listPath = cmSystemTools::GetFilenamePath(fullPath.c_str());
- }
- else
- {
- listPath = fullPath;
- }
- }
- // If there is a CMakeCache.txt file, use its settings.
- if(cachePath.length() > 0)
- {
- cmCacheManager* cachem = this->GetCacheManager();
- cmCacheManager::CacheIterator it = cachem->NewIterator();
- if(cachem->LoadCache(cachePath.c_str()) &&
- it.Find("CMAKE_HOME_DIRECTORY"))
- {
- this->SetHomeOutputDirectory(cachePath.c_str());
- this->SetStartOutputDirectory(cachePath.c_str());
- this->SetHomeDirectory(it.GetValue());
- this->SetStartDirectory(it.GetValue());
- return;
- }
- }
- // If there is a CMakeLists.txt file, use it as the source tree.
- if(listPath.length() > 0)
- {
- this->SetHomeDirectory(listPath.c_str());
- this->SetStartDirectory(listPath.c_str());
- if(argIsFile)
- {
- // Source CMakeLists.txt file given. It was probably dropped
- // onto the executable in a GUI. Default to an in-source build.
- this->SetHomeOutputDirectory(listPath.c_str());
- this->SetStartOutputDirectory(listPath.c_str());
- }
- else
- {
- // Source directory given on command line. Use current working
- // directory as build tree.
- std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- this->SetHomeOutputDirectory(cwd.c_str());
- this->SetStartOutputDirectory(cwd.c_str());
- }
- return;
- }
- // We didn't find a CMakeLists.txt or CMakeCache.txt file from the
- // argument. Assume it is the path to the source tree, and use the
- // current working directory as the build tree.
- std::string full = cmSystemTools::CollapseFullPath(arg);
- std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- this->SetHomeDirectory(full.c_str());
- this->SetStartDirectory(full.c_str());
- this->SetHomeOutputDirectory(cwd.c_str());
- this->SetStartOutputDirectory(cwd.c_str());
- }
- // at the end of this CMAKE_ROOT and CMAKE_COMMAND should be added to the
- // cache
- int cmake::AddCMakePaths()
- {
- // Find the cmake executable
- std::string cMakeSelf = cmSystemTools::GetExecutableDirectory();
- cMakeSelf = cmSystemTools::GetRealPath(cMakeSelf.c_str());
- cMakeSelf += "/cmake";
- cMakeSelf += cmSystemTools::GetExecutableExtension();
- #if __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 direcory 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";
- }
- #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 direcory there?
- modules = cMakeRoot + "/Modules/CMake.cmake";
- }
- if (!cmSystemTools::FileExists(modules.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());
- return 0;
- }
- this->CacheManager->AddCacheEntry
- ("CMAKE_ROOT", cMakeRoot.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 ... - create a tar "
- "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"
- << " 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_MERGE, 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(…
Large files files are truncated, but you can click here to view the full file