2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2001-05-18 23:25:08 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2001-05-18 23:25:08 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
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.
|
|
|
|
============================================================================*/
|
2001-05-18 23:25:08 +04:00
|
|
|
#include "cmake.h"
|
2016-04-29 16:40:20 +03:00
|
|
|
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmAlgorithms.h"
|
2002-09-11 00:51:29 +04:00
|
|
|
#include "cmCommand.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmCommands.h"
|
|
|
|
#include "cmDocumentationFormatter.h"
|
|
|
|
#include "cmExternalMakefileProjectGenerator.h"
|
2005-10-12 21:51:15 +04:00
|
|
|
#include "cmFileTimeComparison.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmLocalGenerator.h"
|
|
|
|
#include "cmMakefile.h"
|
2006-12-07 17:45:32 +03:00
|
|
|
#include "cmSourceFile.h"
|
2015-04-04 22:20:12 +03:00
|
|
|
#include "cmState.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmTest.h"
|
2016-07-08 00:54:05 +03:00
|
|
|
#include "cmUtils.hxx"
|
2016-06-30 16:38:44 +03:00
|
|
|
#include "cmVersionMacros.h"
|
2001-05-18 23:25:08 +04:00
|
|
|
|
2004-10-27 18:47:14 +04:00
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
2016-05-16 17:34:04 +03:00
|
|
|
#include "cmGraphVizWriter.h"
|
|
|
|
#include "cmVariableWatch.h"
|
|
|
|
#include <cmsys/SystemInformation.hxx>
|
2016-06-30 16:38:44 +03:00
|
|
|
|
|
|
|
#include "cm_jsoncpp_value.h"
|
|
|
|
#include "cm_jsoncpp_writer.h"
|
2004-10-27 18:47:14 +04:00
|
|
|
#endif
|
2004-10-26 20:55:20 +04:00
|
|
|
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <cmsys/FStream.hxx>
|
2007-06-04 21:48:11 +04:00
|
|
|
#include <cmsys/Glob.hxx>
|
|
|
|
#include <cmsys/RegularExpression.hxx>
|
2006-05-23 17:11:46 +04:00
|
|
|
|
2004-10-12 17:50:36 +04:00
|
|
|
// only build kdevelop generator on non-windows platforms
|
|
|
|
// when not bootstrapping cmake
|
|
|
|
#if !defined(_WIN32)
|
2016-05-16 17:34:04 +03:00
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
|
|
|
#define CMAKE_USE_KDEVELOP
|
|
|
|
#endif
|
2004-10-12 17:50:36 +04:00
|
|
|
#endif
|
|
|
|
|
2007-08-01 17:18:50 +04:00
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
2016-05-16 17:34:04 +03:00
|
|
|
#define CMAKE_USE_ECLIPSE
|
2007-08-01 17:18:50 +04:00
|
|
|
#endif
|
|
|
|
|
2006-02-01 02:50:16 +03:00
|
|
|
#if defined(__MINGW32__) && !defined(CMAKE_BUILD_WITH_CMAKE)
|
2016-05-16 17:34:04 +03:00
|
|
|
#define CMAKE_BOOT_MINGW
|
2006-02-01 02:50:16 +03:00
|
|
|
#endif
|
|
|
|
|
2001-05-18 23:25:08 +04:00
|
|
|
// include the generator
|
|
|
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
2016-05-16 17:34:04 +03:00
|
|
|
#if !defined(CMAKE_BOOT_MINGW)
|
|
|
|
#include "cmGlobalBorlandMakefileGenerator.h"
|
|
|
|
#include "cmGlobalGhsMultiGenerator.h"
|
|
|
|
#include "cmGlobalJOMMakefileGenerator.h"
|
|
|
|
#include "cmGlobalNMakeMakefileGenerator.h"
|
|
|
|
#include "cmGlobalVisualStudio10Generator.h"
|
|
|
|
#include "cmGlobalVisualStudio11Generator.h"
|
|
|
|
#include "cmGlobalVisualStudio12Generator.h"
|
|
|
|
#include "cmGlobalVisualStudio14Generator.h"
|
|
|
|
#include "cmGlobalVisualStudio71Generator.h"
|
|
|
|
#include "cmGlobalVisualStudio8Generator.h"
|
|
|
|
#include "cmGlobalVisualStudio9Generator.h"
|
|
|
|
#define CMAKE_HAVE_VS_GENERATORS
|
|
|
|
#endif
|
|
|
|
#include "cmGlobalMSYSMakefileGenerator.h"
|
|
|
|
#include "cmGlobalMinGWMakefileGenerator.h"
|
2001-05-18 23:25:08 +04:00
|
|
|
#else
|
2001-05-21 17:50:24 +04:00
|
|
|
#endif
|
2014-03-17 22:30:38 +04:00
|
|
|
#if defined(CMAKE_USE_WMAKE)
|
2016-05-16 17:34:04 +03:00
|
|
|
#include "cmGlobalWatcomWMakeGenerator.h"
|
2014-03-17 22:30:38 +04:00
|
|
|
#endif
|
2005-05-12 18:49:56 +04:00
|
|
|
#include "cmGlobalUnixMakefileGenerator3.h"
|
2015-08-10 20:26:52 +03:00
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
2016-05-16 17:34:04 +03:00
|
|
|
#include "cmGlobalNinjaGenerator.h"
|
2015-08-10 20:26:52 +03:00
|
|
|
#endif
|
2014-01-10 11:20:11 +04:00
|
|
|
#include "cmExtraCodeLiteGenerator.h"
|
2004-10-12 17:50:36 +04:00
|
|
|
|
2010-01-13 20:58:08 +03:00
|
|
|
#if !defined(CMAKE_BOOT_MINGW)
|
2016-05-16 17:34:04 +03:00
|
|
|
#include "cmExtraCodeBlocksGenerator.h"
|
2007-07-18 18:19:33 +04:00
|
|
|
#endif
|
2013-11-16 18:41:32 +04:00
|
|
|
#include "cmExtraKateGenerator.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmExtraSublimeTextGenerator.h"
|
2007-07-18 18:19:33 +04:00
|
|
|
|
2004-10-12 17:50:36 +04:00
|
|
|
#ifdef CMAKE_USE_KDEVELOP
|
2016-05-16 17:34:04 +03:00
|
|
|
#include "cmGlobalKdevelopGenerator.h"
|
2004-10-12 17:50:36 +04:00
|
|
|
#endif
|
2001-05-21 17:50:24 +04:00
|
|
|
|
2007-08-01 17:18:50 +04:00
|
|
|
#ifdef CMAKE_USE_ECLIPSE
|
2016-05-16 17:34:04 +03:00
|
|
|
#include "cmExtraEclipseCDT4Generator.h"
|
2007-08-01 17:18:50 +04:00
|
|
|
#endif
|
|
|
|
|
2003-05-24 00:40:55 +04:00
|
|
|
#include <stdlib.h> // required for atoi
|
2002-09-11 01:24:25 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
#if defined(__APPLE__)
|
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
|
|
|
#include "cmGlobalXCodeGenerator.h"
|
|
|
|
#define CMAKE_USE_XCODE 1
|
|
|
|
#endif
|
|
|
|
#include <sys/resource.h>
|
|
|
|
#include <sys/time.h>
|
2003-04-16 23:40:24 +04:00
|
|
|
#endif
|
2002-10-24 23:39:25 +04:00
|
|
|
|
2016-05-02 22:03:45 +03:00
|
|
|
#include <sys/types.h>
|
|
|
|
// include sys/stat.h after sys/types.h
|
2005-07-03 06:25:43 +04:00
|
|
|
#include <sys/stat.h> // struct stat
|
|
|
|
|
2015-01-12 23:17:55 +03:00
|
|
|
#include <list>
|
|
|
|
|
2016-06-30 16:38:44 +03:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
|
|
|
#ifdef CMake_HAVE_CXX_UNORDERED_MAP
|
|
|
|
typedef std::unordered_map<std::string, Json::Value> JsonValueMapType;
|
|
|
|
#else
|
|
|
|
typedef cmsys::hash_map<std::string, Json::Value> JsonValueMapType;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2007-11-10 16:15:13 +03:00
|
|
|
static bool cmakeCheckStampFile(const char* stampName);
|
2008-03-12 00:25:49 +03:00
|
|
|
static bool cmakeCheckStampList(const char* stampName);
|
2007-11-10 16:15:13 +03:00
|
|
|
|
2016-08-17 02:49:57 +03:00
|
|
|
void cmWarnUnusedCliWarning(const std::string& variable, int /*unused*/,
|
|
|
|
void* ctx, const char* /*unused*/,
|
|
|
|
const cmMakefile* /*unused*/)
|
2010-09-01 18:22:08 +04:00
|
|
|
{
|
|
|
|
cmake* cm = reinterpret_cast<cmake*>(ctx);
|
|
|
|
cm->MarkCliAsUsed(variable);
|
|
|
|
}
|
|
|
|
|
2001-09-07 01:28:24 +04:00
|
|
|
cmake::cmake()
|
|
|
|
{
|
2008-07-31 18:33:25 +04:00
|
|
|
this->Trace = false;
|
2015-07-22 00:18:53 +03:00
|
|
|
this->TraceExpand = false;
|
2010-08-25 20:35:40 +04:00
|
|
|
this->WarnUninitialized = false;
|
2010-08-25 20:36:21 +04:00
|
|
|
this->WarnUnused = false;
|
2010-09-01 18:22:08 +04:00
|
|
|
this->WarnUnusedCli = true;
|
2010-09-01 19:24:20 +04:00
|
|
|
this->CheckSystemVars = false;
|
2006-10-06 19:11:59 +04:00
|
|
|
this->DebugOutput = false;
|
2006-03-15 19:02:08 +03:00
|
|
|
this->DebugTryCompile = false;
|
|
|
|
this->ClearBuildSystem = false;
|
|
|
|
this->FileComparison = new cmFileTimeComparison;
|
2006-03-10 21:06:26 +03:00
|
|
|
|
2015-10-10 16:42:02 +03:00
|
|
|
this->State = new cmState;
|
2015-05-31 01:18:33 +03:00
|
|
|
this->CurrentSnapshot = this->State->CreateBaseSnapshot();
|
2015-04-04 22:20:12 +03:00
|
|
|
|
2002-10-24 23:39:25 +04:00
|
|
|
#ifdef __APPLE__
|
|
|
|
struct rlimit rlp;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!getrlimit(RLIMIT_STACK, &rlp)) {
|
|
|
|
if (rlp.rlim_cur != rlp.rlim_max) {
|
|
|
|
rlp.rlim_cur = rlp.rlim_max;
|
|
|
|
setrlimit(RLIMIT_STACK, &rlp);
|
2002-10-24 23:39:25 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-10-24 23:39:25 +04:00
|
|
|
#endif
|
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
this->GlobalGenerator = CM_NULLPTR;
|
|
|
|
this->ProgressCallback = CM_NULLPTR;
|
|
|
|
this->ProgressCallbackClientData = CM_NULLPTR;
|
2011-07-13 20:59:51 +04:00
|
|
|
this->CurrentWorkingMode = NORMAL_MODE;
|
2010-10-31 16:46:09 +03:00
|
|
|
|
2004-10-27 18:47:14 +04:00
|
|
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
2006-03-15 19:02:08 +03:00
|
|
|
this->VariableWatch = new cmVariableWatch;
|
2004-10-27 18:47:14 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
this->AddDefaultGenerators();
|
2007-06-08 19:57:16 +04:00
|
|
|
this->AddDefaultExtraGenerators();
|
2004-10-27 18:47:14 +04:00
|
|
|
this->AddDefaultCommands();
|
|
|
|
|
2006-02-15 18:22:55 +03:00
|
|
|
// Make sure we can capture the build tool output.
|
|
|
|
cmSystemTools::EnableVSConsoleOutput();
|
2015-10-24 15:58:23 +03:00
|
|
|
|
|
|
|
// Set up a list of source and header extensions
|
|
|
|
// these are used to find files when the extension
|
|
|
|
// is not given
|
|
|
|
// The "c" extension MUST precede the "C" extension.
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SourceFileExtensions.push_back("c");
|
|
|
|
this->SourceFileExtensions.push_back("C");
|
|
|
|
|
|
|
|
this->SourceFileExtensions.push_back("c++");
|
|
|
|
this->SourceFileExtensions.push_back("cc");
|
|
|
|
this->SourceFileExtensions.push_back("cpp");
|
|
|
|
this->SourceFileExtensions.push_back("cxx");
|
|
|
|
this->SourceFileExtensions.push_back("m");
|
|
|
|
this->SourceFileExtensions.push_back("M");
|
|
|
|
this->SourceFileExtensions.push_back("mm");
|
|
|
|
|
|
|
|
this->HeaderFileExtensions.push_back("h");
|
|
|
|
this->HeaderFileExtensions.push_back("hh");
|
|
|
|
this->HeaderFileExtensions.push_back("h++");
|
|
|
|
this->HeaderFileExtensions.push_back("hm");
|
|
|
|
this->HeaderFileExtensions.push_back("hpp");
|
|
|
|
this->HeaderFileExtensions.push_back("hxx");
|
|
|
|
this->HeaderFileExtensions.push_back("in");
|
|
|
|
this->HeaderFileExtensions.push_back("txx");
|
2001-09-07 01:28:24 +04:00
|
|
|
}
|
|
|
|
|
2002-08-23 21:46:32 +04:00
|
|
|
cmake::~cmake()
|
|
|
|
{
|
2015-04-04 22:20:12 +03:00
|
|
|
delete this->State;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GlobalGenerator) {
|
2006-03-15 19:02:08 +03:00
|
|
|
delete this->GlobalGenerator;
|
2016-06-27 23:44:16 +03:00
|
|
|
this->GlobalGenerator = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-01-04 15:33:16 +03:00
|
|
|
cmDeleteAll(this->Generators);
|
2004-10-27 18:47:14 +04:00
|
|
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
2006-03-15 19:02:08 +03:00
|
|
|
delete this->VariableWatch;
|
2004-10-27 18:47:14 +04:00
|
|
|
#endif
|
2006-03-15 19:02:08 +03:00
|
|
|
delete this->FileComparison;
|
2002-09-11 00:51:29 +04:00
|
|
|
}
|
|
|
|
|
2016-06-30 16:38:44 +03:00
|
|
|
std::string cmake::ReportCapabilities() const
|
|
|
|
{
|
|
|
|
std::string result;
|
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
|
|
|
Json::Value obj = Json::objectValue;
|
|
|
|
// Version information:
|
|
|
|
Json::Value version = Json::objectValue;
|
|
|
|
version["string"] = CMake_VERSION;
|
|
|
|
version["major"] = CMake_VERSION_MAJOR;
|
|
|
|
version["minor"] = CMake_VERSION_MINOR;
|
|
|
|
version["suffix"] = CMake_VERSION_SUFFIX;
|
|
|
|
version["isDirty"] = (CMake_VERSION_IS_DIRTY == 1);
|
|
|
|
version["patch"] = CMake_VERSION_PATCH;
|
|
|
|
|
|
|
|
obj["version"] = version;
|
|
|
|
|
|
|
|
// Generators:
|
|
|
|
std::vector<cmake::GeneratorInfo> generatorInfoList;
|
|
|
|
this->GetRegisteredGenerators(generatorInfoList);
|
|
|
|
|
|
|
|
JsonValueMapType generatorMap;
|
|
|
|
for (std::vector<cmake::GeneratorInfo>::const_iterator i =
|
|
|
|
generatorInfoList.begin();
|
|
|
|
i != generatorInfoList.end(); ++i) {
|
|
|
|
if (i->isAlias) { // skip aliases, they are there for compatibility reasons
|
|
|
|
// only
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i->extraName.empty()) {
|
|
|
|
Json::Value gen = Json::objectValue;
|
|
|
|
gen["name"] = i->name;
|
|
|
|
gen["toolsetSupport"] = i->supportsToolset;
|
|
|
|
gen["platformSupport"] = i->supportsPlatform;
|
|
|
|
gen["extraGenerators"] = Json::arrayValue;
|
|
|
|
generatorMap[i->name] = gen;
|
|
|
|
} else {
|
|
|
|
Json::Value& gen = generatorMap[i->baseName];
|
|
|
|
gen["extraGenerators"].append(i->extraName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Json::Value generators = Json::arrayValue;
|
|
|
|
for (JsonValueMapType::const_iterator i = generatorMap.begin();
|
|
|
|
i != generatorMap.end(); ++i) {
|
|
|
|
generators.append(i->second);
|
|
|
|
}
|
|
|
|
obj["generators"] = generators;
|
|
|
|
|
|
|
|
#if defined(HAVE_SERVER_MODE) && HAVE_SERVER_MODE
|
|
|
|
obj["serverMode"] = true;
|
|
|
|
#else
|
|
|
|
obj["serverMode"] = false;
|
|
|
|
#endif
|
|
|
|
Json::FastWriter writer;
|
|
|
|
result = writer.write(obj);
|
|
|
|
#else
|
|
|
|
result = "Not supported";
|
|
|
|
#endif
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2005-06-16 22:56:15 +04:00
|
|
|
void cmake::CleanupCommandsAndMacros()
|
|
|
|
{
|
2015-06-14 02:08:34 +03:00
|
|
|
this->CurrentSnapshot = this->State->Reset();
|
2015-04-11 13:30:26 +03:00
|
|
|
this->State->RemoveUserDefinedCommands();
|
2015-10-13 22:48:46 +03:00
|
|
|
this->CurrentSnapshot.SetDefaultDefinitions();
|
2005-06-16 22:56:15 +04:00
|
|
|
}
|
|
|
|
|
2001-11-21 01:51:03 +03:00
|
|
|
// Parse the args
|
2003-10-29 17:45:26 +03:00
|
|
|
bool cmake::SetCacheArgs(const std::vector<std::string>& args)
|
2006-03-10 21:06:26 +03:00
|
|
|
{
|
2011-07-02 19:50:05 +04:00
|
|
|
bool findPackageMode = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (unsigned int i = 1; i < args.size(); ++i) {
|
2001-11-21 01:51:03 +03:00
|
|
|
std::string arg = args[i];
|
2016-05-16 17:34:04 +03:00
|
|
|
if (arg.find("-D", 0) == 0) {
|
2001-11-21 01:51:03 +03:00
|
|
|
std::string entry = arg.substr(2);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (entry.empty()) {
|
2006-05-19 07:24:00 +04:00
|
|
|
++i;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i < args.size()) {
|
2006-05-19 07:24:00 +04:00
|
|
|
entry = args[i];
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2007-06-04 21:50:34 +04:00
|
|
|
cmSystemTools::Error("-D must be followed with VAR=VALUE.");
|
2006-05-19 07:24:00 +04:00
|
|
|
return false;
|
2005-07-20 01:16:23 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-21 01:51:03 +03:00
|
|
|
std::string var, value;
|
2015-04-07 23:45:54 +03:00
|
|
|
cmState::CacheEntryType type = cmState::UNINITIALIZED;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmState::ParseCacheEntry(entry, var, value, type)) {
|
2013-05-16 23:51:45 +04:00
|
|
|
// The value is transformed if it is a filepath for example, so
|
|
|
|
// we can't compare whether the value is already in the cache until
|
|
|
|
// after we call AddCacheEntry.
|
2014-06-12 17:46:54 +04:00
|
|
|
bool haveValue = false;
|
|
|
|
std::string cachedValue;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->WarnUnusedCli) {
|
|
|
|
if (const char* v = this->State->GetInitializedCacheValue(var)) {
|
2014-06-12 17:46:54 +04:00
|
|
|
haveValue = true;
|
|
|
|
cachedValue = v;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-05-16 23:51:45 +04:00
|
|
|
|
2015-10-10 15:53:24 +03:00
|
|
|
this->AddCacheEntry(var, value.c_str(),
|
2016-05-16 17:34:04 +03:00
|
|
|
"No help, variable specified on the command line.",
|
|
|
|
type);
|
2014-06-12 17:46:54 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->WarnUnusedCli) {
|
2014-06-12 17:46:54 +04:00
|
|
|
if (!haveValue ||
|
2016-05-16 17:34:04 +03:00
|
|
|
cachedValue != this->State->GetInitializedCacheValue(var)) {
|
2014-03-11 03:04:11 +04:00
|
|
|
this->WatchUnusedCli(var);
|
2010-09-01 18:22:08 +04:00
|
|
|
}
|
2001-11-21 01:51:03 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2001-11-21 01:51:03 +03:00
|
|
|
std::cerr << "Parse error in command line argument: " << arg << "\n"
|
|
|
|
<< "Should be: VAR:type=value\n";
|
2009-08-01 00:11:28 +04:00
|
|
|
cmSystemTools::Error("No cmake script provided.");
|
2003-10-29 17:45:26 +03:00
|
|
|
return false;
|
2001-11-21 01:51:03 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (cmHasLiteralPrefix(arg, "-W")) {
|
2015-11-29 15:39:03 +03:00
|
|
|
std::string entry = arg.substr(2);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (entry.empty()) {
|
2015-11-29 15:39:03 +03:00
|
|
|
++i;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i < args.size()) {
|
2015-11-29 15:39:03 +03:00
|
|
|
entry = args[i];
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-11-29 15:39:03 +03:00
|
|
|
cmSystemTools::Error("-W must be followed with [no-]<name>.");
|
|
|
|
return false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-11-29 15:39:03 +03:00
|
|
|
|
|
|
|
std::string name;
|
|
|
|
bool foundNo = false;
|
2015-12-22 00:39:27 +03:00
|
|
|
bool foundError = false;
|
2015-11-29 15:39:03 +03:00
|
|
|
unsigned int nameStartPosition = 0;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (entry.find("no-", nameStartPosition) == 0) {
|
2015-11-29 15:39:03 +03:00
|
|
|
foundNo = true;
|
|
|
|
nameStartPosition += 3;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-11-29 15:39:03 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (entry.find("error=", nameStartPosition) == 0) {
|
2015-12-22 00:39:27 +03:00
|
|
|
foundError = true;
|
|
|
|
nameStartPosition += 6;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-12-22 00:39:27 +03:00
|
|
|
|
2015-11-29 15:39:03 +03:00
|
|
|
name = entry.substr(nameStartPosition);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (name.empty()) {
|
2015-11-29 15:39:03 +03:00
|
|
|
cmSystemTools::Error("No warning name provided.");
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-11-29 15:39:03 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!foundNo && !foundError) {
|
2015-11-29 15:39:03 +03:00
|
|
|
// -W<name>
|
2016-05-16 17:34:04 +03:00
|
|
|
this->DiagLevels[name] = std::max(this->DiagLevels[name], DIAG_WARN);
|
|
|
|
} else if (foundNo && !foundError) {
|
|
|
|
// -Wno<name>
|
|
|
|
this->DiagLevels[name] = DIAG_IGNORE;
|
|
|
|
} else if (!foundNo && foundError) {
|
2015-12-22 00:39:27 +03:00
|
|
|
// -Werror=<name>
|
|
|
|
this->DiagLevels[name] = DIAG_ERROR;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-12-22 00:39:27 +03:00
|
|
|
// -Wno-error=<name>
|
2016-05-16 17:34:04 +03:00
|
|
|
this->DiagLevels[name] = std::min(this->DiagLevels[name], DIAG_WARN);
|
2008-03-11 22:17:58 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (arg.find("-U", 0) == 0) {
|
2007-06-01 22:16:46 +04:00
|
|
|
std::string entryPattern = arg.substr(2);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (entryPattern.empty()) {
|
2007-06-01 22:16:46 +04:00
|
|
|
++i;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i < args.size()) {
|
2007-06-01 22:16:46 +04:00
|
|
|
entryPattern = args[i];
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2007-06-01 22:16:46 +04:00
|
|
|
cmSystemTools::Error("-U must be followed with VAR.");
|
|
|
|
return false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-04 21:48:11 +04:00
|
|
|
cmsys::RegularExpression regex(
|
2014-03-11 03:04:11 +04:00
|
|
|
cmsys::Glob::PatternToRegex(entryPattern, true, true).c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
// go through all cache entries and collect the vars which will be
|
|
|
|
// removed
|
2007-06-01 22:16:46 +04:00
|
|
|
std::vector<std::string> entriesToDelete;
|
2015-04-06 11:52:45 +03:00
|
|
|
std::vector<std::string> cacheKeys = this->State->GetCacheEntryKeys();
|
2015-04-05 11:48:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
it != cacheKeys.end(); ++it) {
|
2015-04-07 23:45:54 +03:00
|
|
|
cmState::CacheEntryType t = this->State->GetCacheEntryType(*it);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (t != cmState::STATIC) {
|
|
|
|
if (regex.find(it->c_str())) {
|
2015-04-05 11:48:04 +03:00
|
|
|
entriesToDelete.push_back(*it);
|
2007-06-01 22:16:46 +04:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-01 22:16:46 +04:00
|
|
|
|
|
|
|
// now remove them from the cache
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator currentEntry =
|
|
|
|
entriesToDelete.begin();
|
|
|
|
currentEntry != entriesToDelete.end(); ++currentEntry) {
|
2015-04-06 11:52:45 +03:00
|
|
|
this->State->RemoveCacheEntry(*currentEntry);
|
2007-06-01 22:16:46 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (arg.find("-C", 0) == 0) {
|
2001-12-04 01:00:43 +03:00
|
|
|
std::string path = arg.substr(2);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (path.empty()) {
|
2006-05-19 07:24:00 +04:00
|
|
|
++i;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i < args.size()) {
|
2006-05-19 07:24:00 +04:00
|
|
|
path = args[i];
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2006-05-19 07:24:00 +04:00
|
|
|
cmSystemTools::Error("-C must be followed by a file name.");
|
|
|
|
return false;
|
2003-10-29 17:45:26 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-01-25 04:15:28 +03:00
|
|
|
std::cout << "loading initial cache file " << path << "\n";
|
2011-02-03 05:17:23 +03:00
|
|
|
this->ReadListFile(args, path.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (arg.find("-P", 0) == 0) {
|
2004-02-20 22:46:33 +03:00
|
|
|
i++;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i >= args.size()) {
|
2006-05-19 07:24:00 +04:00
|
|
|
cmSystemTools::Error("-P must be followed by a file name.");
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-02-20 22:46:33 +03:00
|
|
|
std::string path = args[i];
|
2016-05-16 17:34:04 +03:00
|
|
|
if (path.empty()) {
|
2005-09-23 20:50:09 +04:00
|
|
|
cmSystemTools::Error("No cmake script provided.");
|
2003-10-29 17:45:26 +03:00
|
|
|
return false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
this->ReadListFile(args, path.c_str());
|
|
|
|
} else if (arg.find("--find-package", 0) == 0) {
|
2011-07-02 19:50:05 +04:00
|
|
|
findPackageMode = true;
|
2002-09-06 21:06:23 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-07-02 19:50:05 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (findPackageMode) {
|
2011-07-02 19:50:05 +04:00
|
|
|
return this->FindPackage(args);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-07-02 19:50:05 +04:00
|
|
|
|
2003-10-29 17:45:26 +03:00
|
|
|
return true;
|
2002-09-06 21:06:23 +04:00
|
|
|
}
|
|
|
|
|
2011-02-04 18:38:22 +03:00
|
|
|
void cmake::ReadListFile(const std::vector<std::string>& args,
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* path)
|
2002-09-06 21:06:23 +04:00
|
|
|
{
|
|
|
|
// if a generator was not yet created, temporarily create one
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGlobalGenerator* gg = this->GetGlobalGenerator();
|
2002-09-08 18:17:03 +04:00
|
|
|
bool created = false;
|
2006-03-10 21:06:26 +03:00
|
|
|
|
2002-09-06 21:06:23 +04:00
|
|
|
// if a generator was not specified use a generic one
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!gg) {
|
2015-05-24 12:31:14 +03:00
|
|
|
gg = new cmGlobalGenerator(this);
|
2002-09-06 21:06:23 +04:00
|
|
|
created = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-09-06 21:06:23 +04:00
|
|
|
|
|
|
|
// read in the list file to fill the cache
|
2016-05-16 17:34:04 +03:00
|
|
|
if (path) {
|
2015-06-14 02:08:34 +03:00
|
|
|
this->CurrentSnapshot = this->State->Reset();
|
2015-04-26 18:18:27 +03:00
|
|
|
std::string homeDir = this->GetHomeDirectory();
|
|
|
|
std::string homeOutputDir = this->GetHomeOutputDirectory();
|
|
|
|
this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
|
|
|
|
this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory());
|
2015-05-31 02:43:31 +03:00
|
|
|
cmState::Snapshot snapshot = this->GetCurrentSnapshot();
|
2016-05-16 17:34:04 +03:00
|
|
|
snapshot.GetDirectory().SetCurrentBinary(
|
|
|
|
cmSystemTools::GetCurrentWorkingDirectory());
|
|
|
|
snapshot.GetDirectory().SetCurrentSource(
|
|
|
|
cmSystemTools::GetCurrentWorkingDirectory());
|
2015-10-13 22:48:46 +03:00
|
|
|
snapshot.SetDefaultDefinitions();
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(gg, snapshot));
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetWorkingMode() != NORMAL_MODE) {
|
2011-02-03 02:18:14 +03:00
|
|
|
std::string file(cmSystemTools::CollapseFullPath(path));
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(file);
|
2015-10-05 21:52:26 +03:00
|
|
|
mf->SetScriptModeFile(file.c_str());
|
2011-02-03 05:17:23 +03:00
|
|
|
|
2015-10-05 21:52:26 +03:00
|
|
|
mf->SetArgcArgv(args);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!mf->ReadListFile(path)) {
|
2013-06-21 15:51:58 +04:00
|
|
|
cmSystemTools::Error("Error processing file: ", path);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-26 18:18:27 +03:00
|
|
|
this->SetHomeDirectory(homeDir);
|
|
|
|
this->SetHomeOutputDirectory(homeOutputDir);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-10 21:06:26 +03:00
|
|
|
|
2002-09-06 21:06:23 +04:00
|
|
|
// free generic one if generated
|
2016-05-16 17:34:04 +03:00
|
|
|
if (created) {
|
2002-09-06 21:06:23 +04:00
|
|
|
delete gg;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-21 01:51:03 +03:00
|
|
|
}
|
|
|
|
|
2011-07-02 19:50:05 +04:00
|
|
|
bool cmake::FindPackage(const std::vector<std::string>& args)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
|
|
|
|
this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory());
|
2015-04-16 22:09:16 +03:00
|
|
|
|
2011-07-03 01:14:28 +04:00
|
|
|
// if a generator was not yet created, temporarily create one
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGlobalGenerator* gg = new cmGlobalGenerator(this);
|
2011-07-03 01:14:28 +04:00
|
|
|
this->SetGlobalGenerator(gg);
|
|
|
|
|
2015-05-31 02:43:31 +03:00
|
|
|
cmState::Snapshot snapshot = this->GetCurrentSnapshot();
|
2016-05-16 17:34:04 +03:00
|
|
|
snapshot.GetDirectory().SetCurrentBinary(
|
|
|
|
cmSystemTools::GetCurrentWorkingDirectory());
|
|
|
|
snapshot.GetDirectory().SetCurrentSource(
|
|
|
|
cmSystemTools::GetCurrentWorkingDirectory());
|
2011-07-03 01:14:28 +04:00
|
|
|
// read in the list file to fill the cache
|
2015-10-13 22:48:46 +03:00
|
|
|
snapshot.SetDefaultDefinitions();
|
2015-10-25 16:17:56 +03:00
|
|
|
cmMakefile* mf = new cmMakefile(gg, snapshot);
|
|
|
|
gg->AddMakefile(mf);
|
2011-07-03 01:14:28 +04:00
|
|
|
|
|
|
|
mf->SetArgcArgv(args);
|
|
|
|
|
|
|
|
std::string systemFile = mf->GetModulesFile("CMakeFindPackageMode.cmake");
|
2015-04-18 15:50:37 +03:00
|
|
|
mf->ReadListFile(systemFile.c_str());
|
2011-07-03 01:14:28 +04:00
|
|
|
|
|
|
|
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");
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!packageFound) {
|
|
|
|
if (!quiet) {
|
2011-07-03 01:14:28 +04:00
|
|
|
printf("%s not found.\n", packageName.c_str());
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (mode == "EXIST") {
|
|
|
|
if (!quiet) {
|
2011-07-03 01:14:28 +04:00
|
|
|
printf("%s found.\n", packageName.c_str());
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (mode == "COMPILE") {
|
2011-07-03 01:14:28 +04:00
|
|
|
std::string includes = mf->GetSafeDefinition("PACKAGE_INCLUDE_DIRS");
|
|
|
|
std::vector<std::string> includeDirs;
|
|
|
|
cmSystemTools::ExpandListArgument(includes, includeDirs);
|
|
|
|
|
2015-10-25 16:17:56 +03:00
|
|
|
gg->CreateGenerationObjects();
|
|
|
|
cmLocalGenerator* lg = gg->LocalGenerators[0];
|
2016-06-27 23:44:16 +03:00
|
|
|
std::string includeFlags =
|
|
|
|
lg->GetIncludeFlags(includeDirs, CM_NULLPTR, language);
|
2011-12-04 19:36:48 +04:00
|
|
|
|
2011-07-03 01:14:28 +04:00
|
|
|
std::string definitions = mf->GetSafeDefinition("PACKAGE_DEFINITIONS");
|
|
|
|
printf("%s %s\n", includeFlags.c_str(), definitions.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (mode == "LINK") {
|
2011-07-03 01:14:28 +04:00
|
|
|
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);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator libIt = libList.begin();
|
|
|
|
libIt != libList.end(); ++libIt) {
|
|
|
|
mf->AddLinkLibraryForTarget(targetName, *libIt, GENERAL_LibraryType);
|
|
|
|
}
|
2011-07-03 01:14:28 +04:00
|
|
|
|
2016-06-07 17:30:58 +03:00
|
|
|
std::string buildType = mf->GetSafeDefinition("CMAKE_BUILD_TYPE");
|
|
|
|
buildType = cmSystemTools::UpperCase(buildType);
|
|
|
|
|
2011-07-03 01:14:28 +04:00
|
|
|
std::string linkLibs;
|
2012-09-26 16:38:15 +04:00
|
|
|
std::string frameworkPath;
|
|
|
|
std::string linkPath;
|
2011-07-03 01:14:28 +04:00
|
|
|
std::string flags;
|
|
|
|
std::string linkFlags;
|
2015-10-25 16:17:56 +03:00
|
|
|
gg->CreateGenerationObjects();
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGeneratorTarget* gtgt = gg->FindGeneratorTarget(tgt->GetName());
|
2015-10-25 16:17:56 +03:00
|
|
|
cmLocalGenerator* lg = gtgt->GetLocalGenerator();
|
2016-06-07 17:30:58 +03:00
|
|
|
lg->GetTargetFlags(buildType, linkLibs, frameworkPath, linkPath, flags,
|
|
|
|
linkFlags, gtgt, false);
|
2012-09-26 16:38:15 +04:00
|
|
|
linkLibs = frameworkPath + linkPath + linkLibs;
|
2011-07-03 01:14:28 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
printf("%s\n", linkLibs.c_str());
|
2011-07-03 01:14:28 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
/* if ( use_win32 )
|
|
|
|
{
|
|
|
|
tgt->SetProperty("WIN32_EXECUTABLE", "ON");
|
|
|
|
}
|
|
|
|
if ( use_macbundle)
|
|
|
|
{
|
|
|
|
tgt->SetProperty("MACOSX_BUNDLE", "ON");
|
|
|
|
}*/
|
|
|
|
}
|
2011-07-03 01:14:28 +04:00
|
|
|
|
|
|
|
// free generic one if generated
|
2016-05-16 17:34:04 +03:00
|
|
|
// this->SetGlobalGenerator(0); // setting 0-pointer is not possible
|
|
|
|
// delete gg; // this crashes inside the cmake instance
|
2011-07-03 01:14:28 +04:00
|
|
|
|
|
|
|
return packageFound;
|
2011-07-02 19:50:05 +04:00
|
|
|
}
|
|
|
|
|
2001-05-18 23:25:08 +04:00
|
|
|
// Parse the args
|
2010-10-06 23:00:52 +04:00
|
|
|
void cmake::SetArgs(const std::vector<std::string>& args,
|
|
|
|
bool directoriesSetBefore)
|
2001-05-18 23:25:08 +04:00
|
|
|
{
|
2010-10-05 21:44:28 +04:00
|
|
|
bool directoriesSet = directoriesSetBefore;
|
2012-12-10 19:42:33 +04:00
|
|
|
bool haveToolset = false;
|
2014-09-12 17:55:06 +04:00
|
|
|
bool havePlatform = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (unsigned int i = 1; i < args.size(); ++i) {
|
2001-05-30 23:28:55 +04:00
|
|
|
std::string arg = args[i];
|
2016-05-16 17:34:04 +03:00
|
|
|
if (arg.find("-H", 0) == 0) {
|
2001-09-07 01:28:24 +04:00
|
|
|
directoriesSet = true;
|
2001-05-18 23:25:08 +04:00
|
|
|
std::string path = arg.substr(2);
|
2014-10-15 16:54:05 +04:00
|
|
|
path = cmSystemTools::CollapseFullPath(path);
|
2003-12-22 20:24:26 +03:00
|
|
|
cmSystemTools::ConvertToUnixSlashes(path);
|
2014-03-11 03:04:11 +04:00
|
|
|
this->SetHomeDirectory(path);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (arg.find("-S", 0) == 0) {
|
2005-03-01 20:26:25 +03:00
|
|
|
// There is no local generate anymore. Ignore -S option.
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (arg.find("-O", 0) == 0) {
|
2005-03-01 20:26:25 +03:00
|
|
|
// There is no local generate anymore. Ignore -O option.
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (arg.find("-B", 0) == 0) {
|
2001-09-07 01:28:24 +04:00
|
|
|
directoriesSet = true;
|
2001-05-18 23:25:08 +04:00
|
|
|
std::string path = arg.substr(2);
|
2014-10-15 16:54:05 +04:00
|
|
|
path = cmSystemTools::CollapseFullPath(path);
|
2003-12-22 20:24:26 +03:00
|
|
|
cmSystemTools::ConvertToUnixSlashes(path);
|
2014-03-11 03:04:11 +04:00
|
|
|
this->SetHomeOutputDirectory(path);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if ((i < args.size() - 2) &&
|
|
|
|
(arg.find("--check-build-system", 0) == 0)) {
|
2006-03-15 19:02:08 +03:00
|
|
|
this->CheckBuildSystemArgument = args[++i];
|
|
|
|
this->ClearBuildSystem = (atoi(args[++i].c_str()) > 0);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if ((i < args.size() - 1) &&
|
|
|
|
(arg.find("--check-stamp-file", 0) == 0)) {
|
2007-11-10 16:15:13 +03:00
|
|
|
this->CheckStampFile = args[++i];
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if ((i < args.size() - 1) &&
|
|
|
|
(arg.find("--check-stamp-list", 0) == 0)) {
|
2008-03-12 00:25:49 +03:00
|
|
|
this->CheckStampList = args[++i];
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-19 22:22:38 +03:00
|
|
|
#if defined(CMAKE_HAVE_VS_GENERATORS)
|
2016-05-16 17:34:04 +03:00
|
|
|
else if ((i < args.size() - 1) &&
|
|
|
|
(arg.find("--vs-solution-file", 0) == 0)) {
|
2007-11-19 21:45:16 +03:00
|
|
|
this->VSSolutionFile = args[++i];
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-19 22:22:38 +03:00
|
|
|
#endif
|
2016-06-08 16:18:28 +03:00
|
|
|
else if (arg.find("-D", 0) == 0) {
|
2001-11-21 16:47:37 +03:00
|
|
|
// skip for now
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (arg.find("-U", 0) == 0) {
|
2007-06-01 22:16:46 +04:00
|
|
|
// skip for now
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (arg.find("-C", 0) == 0) {
|
2001-12-04 01:00:43 +03:00
|
|
|
// skip for now
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (arg.find("-P", 0) == 0) {
|
2003-10-29 17:45:26 +03:00
|
|
|
// skip for now
|
2005-01-28 21:00:36 +03:00
|
|
|
i++;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (arg.find("--find-package", 0) == 0) {
|
2011-07-02 19:50:05 +04:00
|
|
|
// skip for now
|
|
|
|
i++;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (arg.find("-W", 0) == 0) {
|
2008-03-13 22:06:35 +03:00
|
|
|
// skip for now
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (arg.find("--graphviz=", 0) == 0) {
|
2006-03-03 22:24:31 +03:00
|
|
|
std::string path = arg.substr(strlen("--graphviz="));
|
2014-10-15 16:54:05 +04:00
|
|
|
path = cmSystemTools::CollapseFullPath(path);
|
2006-03-03 22:24:31 +03:00
|
|
|
cmSystemTools::ConvertToUnixSlashes(path);
|
2006-03-15 19:02:08 +03:00
|
|
|
this->GraphVizFile = path;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GraphVizFile.empty()) {
|
2006-03-03 22:24:31 +03:00
|
|
|
cmSystemTools::Error("No file specified for --graphviz");
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (arg.find("--debug-trycompile", 0) == 0) {
|
2003-12-23 23:01:10 +03:00
|
|
|
std::cout << "debug trycompile on\n";
|
|
|
|
this->DebugTryCompileOn();
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (arg.find("--debug-output", 0) == 0) {
|
2006-10-06 19:11:59 +04:00
|
|
|
std::cout << "Running with debug output on.\n";
|
2008-04-03 01:29:25 +04:00
|
|
|
this->SetDebugOutputOn(true);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (arg.find("--trace-expand", 0) == 0) {
|
2015-07-22 00:18:53 +03:00
|
|
|
std::cout << "Running with expanded trace output on.\n";
|
|
|
|
this->SetTrace(true);
|
|
|
|
this->SetTraceExpand(true);
|
2016-06-13 22:27:58 +03:00
|
|
|
} else if (arg.find("--trace-source=", 0) == 0) {
|
|
|
|
std::string file = arg.substr(strlen("--trace-source="));
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(file);
|
|
|
|
this->AddTraceSource(file);
|
|
|
|
this->SetTrace(true);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (arg.find("--trace", 0) == 0) {
|
2008-07-31 18:33:25 +04:00
|
|
|
std::cout << "Running with trace output on.\n";
|
|
|
|
this->SetTrace(true);
|
2015-07-22 00:18:53 +03:00
|
|
|
this->SetTraceExpand(false);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (arg.find("--warn-uninitialized", 0) == 0) {
|
2010-08-25 20:35:40 +04:00
|
|
|
std::cout << "Warn about uninitialized values.\n";
|
|
|
|
this->SetWarnUninitialized(true);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (arg.find("--warn-unused-vars", 0) == 0) {
|
2010-09-01 18:22:08 +04:00
|
|
|
std::cout << "Finding unused variables.\n";
|
2010-08-25 20:36:21 +04:00
|
|
|
this->SetWarnUnused(true);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (arg.find("--no-warn-unused-cli", 0) == 0) {
|
|
|
|
std::cout << "Not searching for unused variables given on the "
|
|
|
|
<< "command line.\n";
|
2010-09-02 19:38:00 +04:00
|
|
|
this->SetWarnUnusedCli(false);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (arg.find("--check-system-vars", 0) == 0) {
|
|
|
|
std::cout << "Also check system files when warning about unused and "
|
|
|
|
<< "uninitialized variables.\n";
|
2010-09-01 19:24:20 +04:00
|
|
|
this->SetCheckSystemVars(true);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (arg.find("-A", 0) == 0) {
|
2014-09-12 17:55:06 +04:00
|
|
|
std::string value = arg.substr(2);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (value.empty()) {
|
2014-09-12 17:55:06 +04:00
|
|
|
++i;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i >= args.size()) {
|
2014-09-12 17:55:06 +04:00
|
|
|
cmSystemTools::Error("No platform specified for -A");
|
|
|
|
return;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
value = args[i];
|
|
|
|
}
|
|
|
|
if (havePlatform) {
|
2014-09-12 17:55:06 +04:00
|
|
|
cmSystemTools::Error("Multiple -A options not allowed");
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-09-12 17:55:06 +04:00
|
|
|
this->GeneratorPlatform = value;
|
|
|
|
havePlatform = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (arg.find("-T", 0) == 0) {
|
2012-12-10 19:42:33 +04:00
|
|
|
std::string value = arg.substr(2);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (value.empty()) {
|
2012-12-10 19:42:33 +04:00
|
|
|
++i;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i >= args.size()) {
|
2012-12-10 19:42:33 +04:00
|
|
|
cmSystemTools::Error("No toolset specified for -T");
|
|
|
|
return;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
value = args[i];
|
|
|
|
}
|
|
|
|
if (haveToolset) {
|
2012-12-10 19:42:33 +04:00
|
|
|
cmSystemTools::Error("Multiple -T options not allowed");
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-12-10 19:42:33 +04:00
|
|
|
this->GeneratorToolset = value;
|
|
|
|
haveToolset = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (arg.find("-G", 0) == 0) {
|
2001-09-07 01:28:24 +04:00
|
|
|
std::string value = arg.substr(2);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (value.empty()) {
|
2006-05-19 07:24:00 +04:00
|
|
|
++i;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i >= args.size()) {
|
2006-05-19 07:24:00 +04:00
|
|
|
cmSystemTools::Error("No generator specified for -G");
|
2015-03-29 21:28:30 +03:00
|
|
|
this->PrintGeneratorList();
|
2006-05-19 07:24:00 +04:00
|
|
|
return;
|
2005-07-20 01:16:23 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
value = args[i];
|
|
|
|
}
|
|
|
|
cmGlobalGenerator* gen = this->CreateGlobalGenerator(value);
|
|
|
|
if (!gen) {
|
2001-09-07 01:28:24 +04:00
|
|
|
cmSystemTools::Error("Could not create named generator ",
|
|
|
|
value.c_str());
|
2015-03-29 21:28:30 +03:00
|
|
|
this->PrintGeneratorList();
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2002-09-06 21:06:23 +04:00
|
|
|
this->SetGlobalGenerator(gen);
|
2001-09-07 01:28:24 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-01-07 23:49:07 +03:00
|
|
|
// no option assume it is the path to the source
|
2016-05-16 17:34:04 +03:00
|
|
|
else {
|
2002-01-07 23:49:07 +03:00
|
|
|
directoriesSet = true;
|
2003-08-06 00:36:15 +04:00
|
|
|
this->SetDirectoriesFromFile(arg.c_str());
|
2001-05-18 23:25:08 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!directoriesSet) {
|
|
|
|
this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory());
|
|
|
|
this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
|
|
|
|
}
|
2001-05-18 23:25:08 +04:00
|
|
|
}
|
|
|
|
|
2003-08-06 00:36:15 +04:00
|
|
|
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;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileIsDirectory(arg)) {
|
2003-08-06 00:36:15 +04:00
|
|
|
std::string path = cmSystemTools::CollapseFullPath(arg);
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(path);
|
|
|
|
std::string cacheFile = path;
|
|
|
|
cacheFile += "/CMakeCache.txt";
|
|
|
|
std::string listFile = path;
|
|
|
|
listFile += "/CMakeLists.txt";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileExists(cacheFile.c_str())) {
|
2003-08-06 00:36:15 +04:00
|
|
|
cachePath = path;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (cmSystemTools::FileExists(listFile.c_str())) {
|
2003-08-06 00:36:15 +04:00
|
|
|
listPath = path;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (cmSystemTools::FileExists(arg)) {
|
2003-08-06 00:36:15 +04:00
|
|
|
argIsFile = true;
|
|
|
|
std::string fullPath = cmSystemTools::CollapseFullPath(arg);
|
2014-03-11 03:04:11 +04:00
|
|
|
std::string name = cmSystemTools::GetFilenameName(fullPath);
|
2003-08-06 00:36:15 +04:00
|
|
|
name = cmSystemTools::LowerCase(name);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (name == "cmakecache.txt") {
|
2014-03-11 03:04:11 +04:00
|
|
|
cachePath = cmSystemTools::GetFilenamePath(fullPath);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (name == "cmakelists.txt") {
|
2014-03-11 03:04:11 +04:00
|
|
|
listPath = cmSystemTools::GetFilenamePath(fullPath);
|
2003-08-06 00:36:15 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2003-12-08 19:31:16 +03:00
|
|
|
// Specified file or directory does not exist. Try to set things
|
|
|
|
// up to produce a meaningful error message.
|
|
|
|
std::string fullPath = cmSystemTools::CollapseFullPath(arg);
|
2014-03-11 03:04:11 +04:00
|
|
|
std::string name = cmSystemTools::GetFilenameName(fullPath);
|
2003-12-08 19:31:16 +03:00
|
|
|
name = cmSystemTools::LowerCase(name);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (name == "cmakecache.txt" || name == "cmakelists.txt") {
|
2003-12-08 19:31:16 +03:00
|
|
|
argIsFile = true;
|
2014-03-11 03:04:11 +04:00
|
|
|
listPath = cmSystemTools::GetFilenamePath(fullPath);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2003-12-08 19:31:16 +03:00
|
|
|
listPath = fullPath;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2003-12-08 19:31:16 +03:00
|
|
|
|
2003-08-06 00:36:15 +04:00
|
|
|
// If there is a CMakeCache.txt file, use its settings.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cachePath.empty()) {
|
|
|
|
if (this->LoadCache(cachePath)) {
|
2015-04-05 11:48:04 +03:00
|
|
|
const char* existingValue =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->State->GetCacheEntryValue("CMAKE_HOME_DIRECTORY");
|
|
|
|
if (existingValue) {
|
2015-04-05 11:48:04 +03:00
|
|
|
this->SetHomeOutputDirectory(cachePath);
|
|
|
|
this->SetHomeDirectory(existingValue);
|
|
|
|
return;
|
2003-08-06 00:36:15 +04:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-10 21:06:26 +03:00
|
|
|
|
2003-08-06 00:36:15 +04:00
|
|
|
// If there is a CMakeLists.txt file, use it as the source tree.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!listPath.empty()) {
|
2014-03-11 03:04:11 +04:00
|
|
|
this->SetHomeDirectory(listPath);
|
2006-03-10 21:06:26 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (argIsFile) {
|
2003-08-06 00:36:15 +04:00
|
|
|
// Source CMakeLists.txt file given. It was probably dropped
|
|
|
|
// onto the executable in a GUI. Default to an in-source build.
|
2014-03-11 03:04:11 +04:00
|
|
|
this->SetHomeOutputDirectory(listPath);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2003-08-06 00:36:15 +04:00
|
|
|
// Source directory given on command line. Use current working
|
|
|
|
// directory as build tree.
|
|
|
|
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
|
2014-03-11 03:04:11 +04:00
|
|
|
this->SetHomeOutputDirectory(cwd);
|
2003-08-06 00:36:15 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return;
|
|
|
|
}
|
2006-03-10 21:06:26 +03:00
|
|
|
|
2003-08-06 00:36:15 +04:00
|
|
|
// 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();
|
2014-03-11 03:04:11 +04:00
|
|
|
this->SetHomeDirectory(full);
|
|
|
|
this->SetHomeOutputDirectory(cwd);
|
2003-08-06 00:36:15 +04:00
|
|
|
}
|
|
|
|
|
2006-03-10 21:06:26 +03:00
|
|
|
// at the end of this CMAKE_ROOT and CMAKE_COMMAND should be added to the
|
|
|
|
// cache
|
2007-12-14 01:56:50 +03:00
|
|
|
int cmake::AddCMakePaths()
|
2001-05-18 23:25:08 +04:00
|
|
|
{
|
2001-06-22 01:20:03 +04:00
|
|
|
// Save the value in the cache
|
2016-05-16 17:34:04 +03:00
|
|
|
this->AddCacheEntry("CMAKE_COMMAND",
|
|
|
|
cmSystemTools::GetCMakeCommand().c_str(),
|
|
|
|
"Path to CMake executable.", cmState::INTERNAL);
|
2013-11-08 00:30:59 +04:00
|
|
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
2016-05-16 17:34:04 +03:00
|
|
|
this->AddCacheEntry("CMAKE_CTEST_COMMAND",
|
|
|
|
cmSystemTools::GetCTestCommand().c_str(),
|
|
|
|
"Path to ctest program executable.", cmState::INTERNAL);
|
|
|
|
this->AddCacheEntry("CMAKE_CPACK_COMMAND",
|
|
|
|
cmSystemTools::GetCPackCommand().c_str(),
|
|
|
|
"Path to cpack program executable.", cmState::INTERNAL);
|
2013-11-08 00:30:59 +04:00
|
|
|
#endif
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileExists(
|
|
|
|
(cmSystemTools::GetCMakeRoot() + "/Modules/CMake.cmake").c_str())) {
|
2001-06-22 01:20:03 +04:00
|
|
|
// couldn't find modules
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::Error(
|
|
|
|
"Could not find CMAKE_ROOT !!!\n"
|
2006-03-10 21:06:26 +03:00
|
|
|
"CMake has most likely not been installed correctly.\n"
|
|
|
|
"Modules directory not found in\n",
|
2013-11-08 00:30:59 +04:00
|
|
|
cmSystemTools::GetCMakeRoot().c_str());
|
2002-06-27 17:35:21 +04:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
this->AddCacheEntry("CMAKE_ROOT", cmSystemTools::GetCMakeRoot().c_str(),
|
|
|
|
"Path to CMake installation.", cmState::INTERNAL);
|
2002-09-28 01:28:15 +04:00
|
|
|
|
2002-06-03 21:08:52 +04:00
|
|
|
return 1;
|
|
|
|
}
|
2002-08-28 22:51:10 +04:00
|
|
|
|
2007-06-08 19:57:16 +04:00
|
|
|
void cmake::AddDefaultExtraGenerators()
|
|
|
|
{
|
2007-07-18 18:19:33 +04:00
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
2016-07-20 19:28:39 +03:00
|
|
|
this->ExtraGenerators.push_back(cmExtraCodeBlocksGenerator::GetFactory());
|
|
|
|
this->ExtraGenerators.push_back(cmExtraCodeLiteGenerator::GetFactory());
|
|
|
|
this->ExtraGenerators.push_back(cmExtraSublimeTextGenerator::GetFactory());
|
|
|
|
this->ExtraGenerators.push_back(cmExtraKateGenerator::GetFactory());
|
2007-07-18 18:19:33 +04:00
|
|
|
|
2007-08-01 17:18:50 +04:00
|
|
|
#ifdef CMAKE_USE_ECLIPSE
|
2016-07-20 19:28:39 +03:00
|
|
|
this->ExtraGenerators.push_back(cmExtraEclipseCDT4Generator::GetFactory());
|
2007-08-01 17:18:50 +04:00
|
|
|
#endif
|
|
|
|
|
2007-07-18 18:19:33 +04:00
|
|
|
#ifdef CMAKE_USE_KDEVELOP
|
2016-07-20 19:28:39 +03:00
|
|
|
this->ExtraGenerators.push_back(cmGlobalKdevelopGenerator::GetFactory());
|
2007-06-08 19:57:16 +04:00
|
|
|
#endif
|
2007-07-18 18:19:33 +04:00
|
|
|
#endif
|
2007-06-08 19:57:16 +04:00
|
|
|
}
|
|
|
|
|
2016-08-16 20:36:54 +03:00
|
|
|
void cmake::GetRegisteredGenerators(
|
|
|
|
std::vector<GeneratorInfo>& generators) const
|
2002-08-28 22:51:10 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
for (RegisteredGeneratorsVector::const_iterator i = this->Generators.begin(),
|
|
|
|
e = this->Generators.end();
|
|
|
|
i != e; ++i) {
|
2015-02-15 22:17:54 +03:00
|
|
|
std::vector<std::string> names;
|
2012-11-19 19:13:54 +04:00
|
|
|
(*i)->GetGenerators(names);
|
2015-02-15 22:17:54 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (size_t j = 0; j < names.size(); ++j) {
|
2015-02-15 22:17:54 +03:00
|
|
|
GeneratorInfo info;
|
|
|
|
info.supportsToolset = (*i)->SupportsToolset();
|
2016-07-11 16:44:37 +03:00
|
|
|
info.supportsPlatform = (*i)->SupportsPlatform();
|
2015-02-15 22:17:54 +03:00
|
|
|
info.name = names[j];
|
2016-07-21 14:24:11 +03:00
|
|
|
info.baseName = names[j];
|
2016-07-20 19:28:39 +03:00
|
|
|
info.isAlias = false;
|
2015-02-15 22:17:54 +03:00
|
|
|
generators.push_back(info);
|
2003-07-08 05:52:10 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-02-15 22:17:54 +03:00
|
|
|
|
2016-07-20 19:28:39 +03:00
|
|
|
for (RegisteredExtraGeneratorsVector::const_iterator
|
2016-05-16 17:34:04 +03:00
|
|
|
i = this->ExtraGenerators.begin(),
|
|
|
|
e = this->ExtraGenerators.end();
|
|
|
|
i != e; ++i) {
|
2016-07-20 19:28:39 +03:00
|
|
|
const std::vector<std::string> genList =
|
|
|
|
(*i)->GetSupportedGlobalGenerators();
|
|
|
|
for (std::vector<std::string>::const_iterator gen = genList.begin();
|
|
|
|
gen != genList.end(); ++gen) {
|
|
|
|
GeneratorInfo info;
|
|
|
|
info.name = cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
|
|
|
|
(*i)->GetName(), *gen);
|
2016-07-21 14:24:11 +03:00
|
|
|
info.baseName = *gen;
|
|
|
|
info.extraName = (*i)->GetName();
|
2016-07-20 19:28:39 +03:00
|
|
|
info.supportsPlatform = false;
|
|
|
|
info.supportsToolset = false;
|
|
|
|
info.isAlias = false;
|
|
|
|
generators.push_back(info);
|
|
|
|
}
|
|
|
|
for (std::vector<std::string>::const_iterator a = (*i)->Aliases.begin();
|
|
|
|
a != (*i)->Aliases.end(); ++a) {
|
|
|
|
GeneratorInfo info;
|
|
|
|
info.name = *a;
|
2016-07-21 14:24:11 +03:00
|
|
|
if (!genList.empty()) {
|
|
|
|
info.baseName = genList.at(0);
|
|
|
|
}
|
|
|
|
info.extraName = (*i)->GetName();
|
2016-07-20 19:28:39 +03:00
|
|
|
info.supportsPlatform = false;
|
|
|
|
info.supportsToolset = false;
|
|
|
|
info.isAlias = true;
|
|
|
|
generators.push_back(info);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-09-06 21:06:23 +04:00
|
|
|
}
|
|
|
|
|
2016-07-20 19:28:39 +03:00
|
|
|
static std::pair<cmExternalMakefileProjectGenerator*, std::string>
|
|
|
|
createExtraGenerator(
|
|
|
|
const std::vector<cmExternalMakefileProjectGeneratorFactory*>& in,
|
|
|
|
const std::string& name)
|
2002-09-06 21:06:23 +04:00
|
|
|
{
|
2016-07-20 19:28:39 +03:00
|
|
|
for (std::vector<cmExternalMakefileProjectGeneratorFactory*>::const_iterator
|
|
|
|
i = in.begin();
|
|
|
|
i != in.end(); ++i) {
|
|
|
|
const std::vector<std::string> generators =
|
|
|
|
(*i)->GetSupportedGlobalGenerators();
|
|
|
|
if ((*i)->GetName() == name) { // Match aliases
|
|
|
|
return std::make_pair((*i)->CreateExternalMakefileProjectGenerator(),
|
|
|
|
generators.at(0));
|
|
|
|
}
|
|
|
|
for (std::vector<std::string>::const_iterator g = generators.begin();
|
|
|
|
g != generators.end(); ++g) {
|
|
|
|
const std::string fullName =
|
|
|
|
cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
|
|
|
|
*g, (*i)->GetName());
|
|
|
|
if (fullName == name) {
|
|
|
|
return std::make_pair((*i)->CreateExternalMakefileProjectGenerator(),
|
|
|
|
*g);
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-07-20 19:28:39 +03:00
|
|
|
return std::make_pair(
|
|
|
|
static_cast<cmExternalMakefileProjectGenerator*>(CM_NULLPTR), name);
|
|
|
|
}
|
|
|
|
|
|
|
|
cmGlobalGenerator* cmake::CreateGlobalGenerator(const std::string& gname)
|
|
|
|
{
|
|
|
|
std::pair<cmExternalMakefileProjectGenerator*, std::string> extra =
|
|
|
|
createExtraGenerator(this->ExtraGenerators, gname);
|
|
|
|
cmExternalMakefileProjectGenerator* extraGenerator = extra.first;
|
|
|
|
const std::string name = extra.second;
|
2012-11-19 18:56:31 +04:00
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
cmGlobalGenerator* generator = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (RegisteredGeneratorsVector::const_iterator i = this->Generators.begin();
|
|
|
|
i != this->Generators.end(); ++i) {
|
2015-05-24 12:31:14 +03:00
|
|
|
generator = (*i)->CreateGlobalGenerator(name, this);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (generator) {
|
2012-11-19 19:13:54 +04:00
|
|
|
break;
|
2012-11-19 18:56:31 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-11-19 18:56:31 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (generator) {
|
2012-11-19 18:56:31 +04:00
|
|
|
generator->SetExternalMakefileProjectGenerator(extraGenerator);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2012-11-19 18:56:31 +04:00
|
|
|
delete extraGenerator;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-08 19:57:16 +04:00
|
|
|
|
|
|
|
return generator;
|
2002-08-28 22:51:10 +04:00
|
|
|
}
|
|
|
|
|
2014-02-08 00:24:15 +04:00
|
|
|
void cmake::SetHomeDirectory(const std::string& dir)
|
2002-09-06 21:06:23 +04:00
|
|
|
{
|
2015-04-12 16:26:54 +03:00
|
|
|
this->State->SetSourceDirectory(dir);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CurrentSnapshot.IsValid()) {
|
2015-10-13 22:52:33 +03:00
|
|
|
this->CurrentSnapshot.SetDefinition("CMAKE_SOURCE_DIR", dir);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-09-06 21:06:23 +04:00
|
|
|
}
|
2002-08-28 22:51:10 +04:00
|
|
|
|
2015-04-12 21:10:40 +03:00
|
|
|
const char* cmake::GetHomeDirectory() const
|
2002-08-28 22:51:10 +04:00
|
|
|
{
|
2015-04-12 16:26:54 +03:00
|
|
|
return this->State->GetSourceDirectory();
|
2015-04-12 21:10:40 +03:00
|
|
|
}
|
|
|
|
|
2015-04-12 20:32:48 +03:00
|
|
|
void cmake::SetHomeOutputDirectory(const std::string& dir)
|
2002-08-28 22:51:10 +04:00
|
|
|
{
|
2015-04-12 16:26:54 +03:00
|
|
|
this->State->SetBinaryDirectory(dir);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CurrentSnapshot.IsValid()) {
|
2015-10-13 22:52:33 +03:00
|
|
|
this->CurrentSnapshot.SetDefinition("CMAKE_BINARY_DIR", dir);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-09-06 21:06:23 +04:00
|
|
|
}
|
|
|
|
|
2015-04-12 21:10:40 +03:00
|
|
|
const char* cmake::GetHomeOutputDirectory() const
|
|
|
|
{
|
2015-04-12 16:26:54 +03:00
|
|
|
return this->State->GetBinaryDirectory();
|
2015-04-12 21:10:40 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmake::SetGlobalGenerator(cmGlobalGenerator* gg)
|
2002-09-06 21:06:23 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!gg) {
|
2006-10-03 19:55:55 +04:00
|
|
|
cmSystemTools::Error("Error SetGlobalGenerator called with null");
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-09-06 21:06:23 +04:00
|
|
|
// delete the old generator
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GlobalGenerator) {
|
2006-03-15 19:02:08 +03:00
|
|
|
delete this->GlobalGenerator;
|
2003-01-09 20:18:22 +03:00
|
|
|
// restore the original environment variables CXX and CC
|
2012-02-26 22:44:20 +04:00
|
|
|
// Restore CC
|
2003-01-09 20:18:22 +03:00
|
|
|
std::string env = "CC=";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->CCEnvironment.empty()) {
|
2006-03-15 19:02:08 +03:00
|
|
|
env += this->CCEnvironment;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-11-23 13:05:50 +03:00
|
|
|
cmSystemTools::PutEnv(env);
|
2003-01-09 20:18:22 +03:00
|
|
|
env = "CXX=";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->CXXEnvironment.empty()) {
|
2006-03-15 19:02:08 +03:00
|
|
|
env += this->CXXEnvironment;
|
2002-08-28 22:51:10 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::PutEnv(env);
|
|
|
|
}
|
2003-01-09 20:18:22 +03:00
|
|
|
|
2002-09-06 21:06:23 +04:00
|
|
|
// set the new
|
2006-03-15 19:02:08 +03:00
|
|
|
this->GlobalGenerator = gg;
|
2006-05-12 22:36:39 +04:00
|
|
|
|
|
|
|
// set the global flag for unix style paths on cmSystemTools as soon as
|
|
|
|
// the generator is set. This allows gmake to be used on windows.
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::SetForceUnixPaths(this->GlobalGenerator->GetForceUnixPaths());
|
2006-05-12 22:36:39 +04:00
|
|
|
|
2003-01-09 20:18:22 +03:00
|
|
|
// Save the environment variables CXX and CC
|
2016-07-08 00:54:05 +03:00
|
|
|
if (!cmSystemTools::GetEnv("CXX", this->CXXEnvironment)) {
|
2006-03-15 19:02:08 +03:00
|
|
|
this->CXXEnvironment = "";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-07-08 00:54:05 +03:00
|
|
|
if (!cmSystemTools::GetEnv("CC", this->CCEnvironment)) {
|
2006-03-15 19:02:08 +03:00
|
|
|
this->CCEnvironment = "";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-08-28 22:51:10 +04:00
|
|
|
}
|
|
|
|
|
2003-05-29 19:14:05 +04:00
|
|
|
int cmake::DoPreConfigureChecks()
|
2002-08-28 22:51:10 +04:00
|
|
|
{
|
2015-04-16 01:52:20 +03:00
|
|
|
// Make sure the Source directory contains a CMakeLists.txt file.
|
2003-06-13 22:15:17 +04:00
|
|
|
std::string srcList = this->GetHomeDirectory();
|
|
|
|
srcList += "/CMakeLists.txt";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileExists(srcList.c_str())) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream err;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileIsDirectory(this->GetHomeDirectory())) {
|
2003-12-08 19:31:16 +03:00
|
|
|
err << "The source directory \"" << this->GetHomeDirectory()
|
|
|
|
<< "\" does not appear to contain CMakeLists.txt.\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (cmSystemTools::FileExists(this->GetHomeDirectory())) {
|
2003-12-08 19:31:16 +03:00
|
|
|
err << "The source directory \"" << this->GetHomeDirectory()
|
|
|
|
<< "\" is a file, not a directory.\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2003-12-08 19:31:16 +03:00
|
|
|
err << "The source directory \"" << this->GetHomeDirectory()
|
|
|
|
<< "\" does not exist.\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-10 21:06:26 +03:00
|
|
|
err << "Specify --help for usage, or press the help button on the CMake "
|
2016-05-16 17:34:04 +03:00
|
|
|
"GUI.";
|
2003-10-31 00:12:09 +03:00
|
|
|
cmSystemTools::Error(err.str().c_str());
|
2003-06-13 22:15:17 +04:00
|
|
|
return -2;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-10 21:06:26 +03:00
|
|
|
|
2002-09-13 18:41:20 +04:00
|
|
|
// do a sanity check on some values
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->State->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY")) {
|
2010-10-31 16:46:09 +03:00
|
|
|
std::string cacheStart =
|
2015-10-10 15:42:36 +03:00
|
|
|
this->State->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY");
|
2002-09-06 21:06:23 +04:00
|
|
|
cacheStart += "/CMakeLists.txt";
|
|
|
|
std::string currentStart = this->GetHomeDirectory();
|
|
|
|
currentStart += "/CMakeLists.txt";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::SameFile(cacheStart, currentStart)) {
|
2003-08-06 00:51:00 +04:00
|
|
|
std::string message = "The source \"";
|
2002-09-06 21:06:23 +04:00
|
|
|
message += currentStart;
|
2003-08-06 00:51:00 +04:00
|
|
|
message += "\" does not match the source \"";
|
2002-09-06 21:06:23 +04:00
|
|
|
message += cacheStart;
|
2003-08-06 00:51:00 +04:00
|
|
|
message += "\" used to generate cache. ";
|
|
|
|
message += "Re-run cmake with a different source directory.";
|
2002-09-06 21:06:23 +04:00
|
|
|
cmSystemTools::Error(message.c_str());
|
|
|
|
return -2;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2003-05-29 19:14:05 +04:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2003-05-29 19:14:05 +04:00
|
|
|
return 1;
|
|
|
|
}
|
2007-12-13 23:54:29 +03:00
|
|
|
struct SaveCacheEntry
|
|
|
|
{
|
|
|
|
std::string key;
|
|
|
|
std::string value;
|
|
|
|
std::string help;
|
2015-04-07 23:45:54 +03:00
|
|
|
cmState::CacheEntryType type;
|
2007-12-13 23:54:29 +03:00
|
|
|
};
|
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
int cmake::HandleDeleteCacheVariables(const std::string& var)
|
2007-12-13 23:54:29 +03:00
|
|
|
{
|
|
|
|
std::vector<std::string> argsSplit;
|
2013-02-09 01:33:52 +04:00
|
|
|
cmSystemTools::ExpandListArgument(std::string(var), argsSplit, true);
|
2007-12-13 23:54:29 +03:00
|
|
|
// erase the property to avoid infinite recursion
|
2016-05-16 17:34:04 +03:00
|
|
|
this->State->SetGlobalProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_", "");
|
|
|
|
if (this->State->GetIsInTryCompile()) {
|
2008-08-19 21:31:21 +04:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-12-13 23:54:29 +03:00
|
|
|
std::vector<SaveCacheEntry> saved;
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream warning;
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2010-10-31 16:46:09 +03:00
|
|
|
warning
|
2007-12-13 23:54:29 +03:00
|
|
|
<< "You have changed variables that require your cache to be deleted.\n"
|
|
|
|
<< "Configure will be re-run and you may have to reset some variables.\n"
|
|
|
|
<< "The following variables have changed:\n";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::iterator i = argsSplit.begin();
|
|
|
|
i != argsSplit.end(); ++i) {
|
2007-12-13 23:54:29 +03:00
|
|
|
SaveCacheEntry save;
|
|
|
|
save.key = *i;
|
|
|
|
warning << *i << "= ";
|
|
|
|
i++;
|
|
|
|
save.value = *i;
|
|
|
|
warning << *i << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* existingValue = this->State->GetCacheEntryValue(save.key);
|
|
|
|
if (existingValue) {
|
2015-10-10 15:42:36 +03:00
|
|
|
save.type = this->State->GetCacheEntryType(save.key);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* help =
|
|
|
|
this->State->GetCacheEntryProperty(save.key, "HELPSTRING")) {
|
2014-05-28 00:03:51 +04:00
|
|
|
save.help = help;
|
2007-12-13 23:54:29 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
saved.push_back(save);
|
|
|
|
}
|
2010-10-31 16:46:09 +03:00
|
|
|
|
2007-12-13 23:54:29 +03:00
|
|
|
// remove the cache
|
2015-10-10 15:42:36 +03:00
|
|
|
this->DeleteCache(this->GetHomeOutputDirectory());
|
2007-12-13 23:54:29 +03:00
|
|
|
// load the empty cache
|
|
|
|
this->LoadCache();
|
|
|
|
// restore the changed compilers
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<SaveCacheEntry>::iterator i = saved.begin();
|
|
|
|
i != saved.end(); ++i) {
|
|
|
|
this->AddCacheEntry(i->key, i->value.c_str(), i->help.c_str(), i->type);
|
|
|
|
}
|
2007-12-13 23:54:29 +03:00
|
|
|
cmSystemTools::Message(warning.str().c_str());
|
|
|
|
// avoid reconfigure if there were errors
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::GetErrorOccuredFlag()) {
|
2007-12-13 23:54:29 +03:00
|
|
|
// re-run configure
|
|
|
|
return this->Configure();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-12-14 02:30:53 +03:00
|
|
|
return 0;
|
2007-12-13 23:54:29 +03:00
|
|
|
}
|
2003-05-29 19:14:05 +04:00
|
|
|
|
|
|
|
int cmake::Configure()
|
2007-12-13 23:54:29 +03:00
|
|
|
{
|
2015-11-29 15:39:03 +03:00
|
|
|
DiagLevel diagLevel;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->DiagLevels.count("deprecated") == 1) {
|
2015-11-09 02:06:33 +03:00
|
|
|
|
|
|
|
diagLevel = this->DiagLevels["deprecated"];
|
2016-05-16 17:34:04 +03:00
|
|
|
if (diagLevel == DIAG_IGNORE) {
|
2015-12-06 15:58:24 +03:00
|
|
|
this->SetSuppressDeprecatedWarnings(true);
|
2015-12-22 00:39:27 +03:00
|
|
|
this->SetDeprecatedWarningsAsErrors(false);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (diagLevel == DIAG_WARN) {
|
2015-12-06 15:58:24 +03:00
|
|
|
this->SetSuppressDeprecatedWarnings(false);
|
2015-12-22 00:39:27 +03:00
|
|
|
this->SetDeprecatedWarningsAsErrors(false);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (diagLevel == DIAG_ERROR) {
|
2015-12-22 00:39:27 +03:00
|
|
|
this->SetSuppressDeprecatedWarnings(false);
|
|
|
|
this->SetDeprecatedWarningsAsErrors(true);
|
2015-11-09 02:06:33 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-11-09 02:06:33 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->DiagLevels.count("dev") == 1) {
|
2015-11-09 02:34:59 +03:00
|
|
|
bool setDeprecatedVariables = false;
|
|
|
|
|
|
|
|
const char* cachedWarnDeprecated =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->State->GetCacheEntryValue("CMAKE_WARN_DEPRECATED");
|
2015-12-22 00:39:27 +03:00
|
|
|
const char* cachedErrorDeprecated =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->State->GetCacheEntryValue("CMAKE_ERROR_DEPRECATED");
|
2015-11-09 02:34:59 +03:00
|
|
|
|
|
|
|
// don't overwrite deprecated warning setting from a previous invocation
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cachedWarnDeprecated && !cachedErrorDeprecated) {
|
2015-11-09 02:34:59 +03:00
|
|
|
setDeprecatedVariables = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-11-29 15:39:03 +03:00
|
|
|
|
|
|
|
diagLevel = this->DiagLevels["dev"];
|
2016-05-16 17:34:04 +03:00
|
|
|
if (diagLevel == DIAG_IGNORE) {
|
2015-12-06 15:58:24 +03:00
|
|
|
this->SetSuppressDevWarnings(true);
|
2015-12-22 00:39:27 +03:00
|
|
|
this->SetDevWarningsAsErrors(false);
|
2015-11-09 02:34:59 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (setDeprecatedVariables) {
|
2015-12-06 15:58:24 +03:00
|
|
|
this->SetSuppressDeprecatedWarnings(true);
|
2015-12-22 00:39:27 +03:00
|
|
|
this->SetDeprecatedWarningsAsErrors(false);
|
2008-03-22 17:24:06 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (diagLevel == DIAG_WARN) {
|
2015-12-06 15:58:24 +03:00
|
|
|
this->SetSuppressDevWarnings(false);
|
2015-12-22 00:39:27 +03:00
|
|
|
this->SetDevWarningsAsErrors(false);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (setDeprecatedVariables) {
|
2015-12-22 00:39:27 +03:00
|
|
|
this->SetSuppressDeprecatedWarnings(false);
|
|
|
|
this->SetDeprecatedWarningsAsErrors(false);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (diagLevel == DIAG_ERROR) {
|
2015-12-22 00:39:27 +03:00
|
|
|
this->SetSuppressDevWarnings(false);
|
|
|
|
this->SetDevWarningsAsErrors(true);
|
2015-11-09 02:34:59 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (setDeprecatedVariables) {
|
2015-12-06 15:58:24 +03:00
|
|
|
this->SetSuppressDeprecatedWarnings(false);
|
2015-12-22 00:39:27 +03:00
|
|
|
this->SetDeprecatedWarningsAsErrors(true);
|
2008-03-22 17:24:06 +03:00
|
|
|
}
|
2008-03-12 05:50:35 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-11-29 15:39:03 +03:00
|
|
|
|
2007-12-13 23:54:29 +03:00
|
|
|
int ret = this->ActualConfigure();
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* delCacheVars =
|
|
|
|
this->State->GetGlobalProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_");
|
|
|
|
if (delCacheVars && delCacheVars[0] != 0) {
|
2007-12-13 23:54:29 +03:00
|
|
|
return this->HandleDeleteCacheVariables(delCacheVars);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-12-13 23:54:29 +03:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int cmake::ActualConfigure()
|
2003-05-29 19:14:05 +04:00
|
|
|
{
|
2004-10-04 20:31:09 +04:00
|
|
|
// Construct right now our path conversion table before it's too late:
|
|
|
|
this->UpdateConversionPathTable();
|
2005-06-16 22:56:15 +04:00
|
|
|
this->CleanupCommandsAndMacros();
|
2004-10-04 20:31:09 +04:00
|
|
|
|
2003-10-29 17:45:26 +03:00
|
|
|
int res = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetWorkingMode() == NORMAL_MODE) {
|
2003-10-29 17:45:26 +03:00
|
|
|
res = this->DoPreConfigureChecks();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (res < 0) {
|
2003-05-29 19:14:05 +04:00
|
|
|
return -2;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!res) {
|
|
|
|
this->AddCacheEntry(
|
|
|
|
"CMAKE_HOME_DIRECTORY", this->GetHomeDirectory(),
|
|
|
|
"Source directory with the top level CMakeLists.txt file for this "
|
|
|
|
"project",
|
|
|
|
cmState::INTERNAL);
|
|
|
|
}
|
2006-03-10 21:06:26 +03:00
|
|
|
|
2002-09-06 21:06:23 +04:00
|
|
|
// no generator specified on the command line
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->GlobalGenerator) {
|
2010-10-31 16:46:09 +03:00
|
|
|
const char* genName =
|
2015-10-10 15:42:36 +03:00
|
|
|
this->State->GetInitializedCacheValue("CMAKE_GENERATOR");
|
2010-10-31 16:46:09 +03:00
|
|
|
const char* extraGenName =
|
2015-10-10 15:42:36 +03:00
|
|
|
this->State->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (genName) {
|
|
|
|
std::string fullName =
|
|
|
|
cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
|
|
|
|
genName, extraGenName ? extraGenName : "");
|
2014-03-11 03:04:11 +04:00
|
|
|
this->GlobalGenerator = this->CreateGlobalGenerator(fullName);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (this->GlobalGenerator) {
|
2006-03-10 21:06:26 +03:00
|
|
|
// set the global flag for unix style paths on cmSystemTools as
|
2003-08-22 00:22:23 +04:00
|
|
|
// soon as the generator is set. This allows gmake to be used
|
|
|
|
// on windows.
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::SetForceUnixPaths(
|
|
|
|
this->GlobalGenerator->GetForceUnixPaths());
|
|
|
|
} else {
|
2014-08-06 17:20:24 +04:00
|
|
|
#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW)
|
2004-07-27 21:40:47 +04:00
|
|
|
std::string installedCompiler;
|
2010-10-31 16:46:09 +03:00
|
|
|
// Try to find the newest VS installed on the computer and
|
2009-09-15 06:16:43 +04:00
|
|
|
// use that as a default if -G is not specified
|
2012-01-28 16:59:19 +04:00
|
|
|
const std::string vsregBase =
|
|
|
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\";
|
|
|
|
std::vector<std::string> vsVerions;
|
|
|
|
vsVerions.push_back("VisualStudio\\");
|
|
|
|
vsVerions.push_back("VCExpress\\");
|
2012-09-16 02:01:32 +04:00
|
|
|
vsVerions.push_back("WDExpress\\");
|
2009-09-15 06:16:43 +04:00
|
|
|
struct VSRegistryEntryName
|
|
|
|
{
|
|
|
|
const char* MSVersion;
|
|
|
|
const char* GeneratorName;
|
|
|
|
};
|
|
|
|
VSRegistryEntryName version[] = {
|
2016-05-06 22:21:30 +03:00
|
|
|
/* clang-format needs this comment to break after the opening brace */
|
2016-05-16 17:34:04 +03:00
|
|
|
{ "7.1", "Visual Studio 7 .NET 2003" },
|
|
|
|
{ "8.0", "Visual Studio 8 2005" },
|
|
|
|
{ "9.0", "Visual Studio 9 2008" },
|
|
|
|
{ "10.0", "Visual Studio 10 2010" },
|
|
|
|
{ "11.0", "Visual Studio 11 2012" },
|
|
|
|
{ "12.0", "Visual Studio 12 2013" },
|
|
|
|
{ "14.0", "Visual Studio 14 2015" },
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
for (int i = 0; version[i].MSVersion != 0; i++) {
|
|
|
|
for (size_t b = 0; b < vsVerions.size(); b++) {
|
2012-01-28 16:59:19 +04:00
|
|
|
std::string reg = vsregBase + vsVerions[b] + version[i].MSVersion;
|
|
|
|
reg += ";InstallDir]";
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ExpandRegistryValues(reg, cmSystemTools::KeyWOW64_32);
|
|
|
|
if (!(reg == "/registry")) {
|
2012-01-28 16:59:19 +04:00
|
|
|
installedCompiler = version[i].GeneratorName;
|
2012-09-16 02:01:32 +04:00
|
|
|
break;
|
2004-07-27 21:40:47 +04:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
cmGlobalGenerator* gen =
|
|
|
|
this->CreateGlobalGenerator(installedCompiler.c_str());
|
|
|
|
if (!gen) {
|
2015-05-24 12:31:14 +03:00
|
|
|
gen = new cmGlobalNMakeMakefileGenerator(this);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-07-27 21:40:47 +04:00
|
|
|
this->SetGlobalGenerator(gen);
|
2009-09-15 06:16:43 +04:00
|
|
|
std::cout << "-- Building for: " << gen->GetName() << "\n";
|
2002-09-06 21:06:23 +04:00
|
|
|
#else
|
2015-05-24 12:31:14 +03:00
|
|
|
this->SetGlobalGenerator(new cmGlobalUnixMakefileGenerator3(this));
|
2002-09-06 21:06:23 +04:00
|
|
|
#endif
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!this->GlobalGenerator) {
|
2002-09-06 21:06:23 +04:00
|
|
|
cmSystemTools::Error("Could not create generator");
|
|
|
|
return -1;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-09-06 21:06:23 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* genName =
|
|
|
|
this->State->GetInitializedCacheValue("CMAKE_GENERATOR");
|
|
|
|
if (genName) {
|
|
|
|
if (!this->GlobalGenerator->MatchesGeneratorName(genName)) {
|
2002-09-06 21:06:23 +04:00
|
|
|
std::string message = "Error: generator : ";
|
2006-03-15 19:02:08 +03:00
|
|
|
message += this->GlobalGenerator->GetName();
|
2002-09-06 21:06:23 +04:00
|
|
|
message += "\nDoes not match the generator used previously: ";
|
|
|
|
message += genName;
|
2016-05-16 17:34:04 +03:00
|
|
|
message += "\nEither remove the CMakeCache.txt file and CMakeFiles "
|
|
|
|
"directory or choose a different binary directory.";
|
2002-09-06 21:06:23 +04:00
|
|
|
cmSystemTools::Error(message.c_str());
|
|
|
|
return -2;
|
2002-08-28 22:51:10 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!this->State->GetInitializedCacheValue("CMAKE_GENERATOR")) {
|
2015-10-10 15:53:24 +03:00
|
|
|
this->AddCacheEntry("CMAKE_GENERATOR",
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GlobalGenerator->GetName().c_str(),
|
|
|
|
"Name of generator.", cmState::INTERNAL);
|
2015-10-10 15:53:24 +03:00
|
|
|
this->AddCacheEntry("CMAKE_EXTRA_GENERATOR",
|
2014-02-25 02:36:27 +04:00
|
|
|
this->GlobalGenerator->GetExtraGeneratorName().c_str(),
|
|
|
|
"Name of external makefile project generator.",
|
2015-04-07 23:45:54 +03:00
|
|
|
cmState::INTERNAL);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-09-06 21:06:23 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* platformName =
|
|
|
|
this->State->GetInitializedCacheValue("CMAKE_GENERATOR_PLATFORM")) {
|
|
|
|
if (this->GeneratorPlatform.empty()) {
|
2014-09-05 22:25:27 +04:00
|
|
|
this->GeneratorPlatform = platformName;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (this->GeneratorPlatform != platformName) {
|
2014-09-05 22:25:27 +04:00
|
|
|
std::string message = "Error: generator platform: ";
|
|
|
|
message += this->GeneratorPlatform;
|
|
|
|
message += "\nDoes not match the platform used previously: ";
|
|
|
|
message += platformName;
|
2016-05-16 17:34:04 +03:00
|
|
|
message += "\nEither remove the CMakeCache.txt file and CMakeFiles "
|
|
|
|
"directory or choose a different binary directory.";
|
2014-09-05 22:25:27 +04:00
|
|
|
cmSystemTools::Error(message.c_str());
|
|
|
|
return -2;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-10-10 15:53:24 +03:00
|
|
|
this->AddCacheEntry("CMAKE_GENERATOR_PLATFORM",
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GeneratorPlatform.c_str(),
|
|
|
|
"Name of generator platform.", cmState::INTERNAL);
|
|
|
|
}
|
2014-09-05 22:25:27 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* tsName =
|
|
|
|
this->State->GetInitializedCacheValue("CMAKE_GENERATOR_TOOLSET")) {
|
|
|
|
if (this->GeneratorToolset.empty()) {
|
2012-12-10 19:42:33 +04:00
|
|
|
this->GeneratorToolset = tsName;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (this->GeneratorToolset != tsName) {
|
2012-12-10 19:42:33 +04:00
|
|
|
std::string message = "Error: generator toolset: ";
|
|
|
|
message += this->GeneratorToolset;
|
|
|
|
message += "\nDoes not match the toolset used previously: ";
|
|
|
|
message += tsName;
|
2016-05-16 17:34:04 +03:00
|
|
|
message += "\nEither remove the CMakeCache.txt file and CMakeFiles "
|
|
|
|
"directory or choose a different binary directory.";
|
2012-12-10 19:42:33 +04:00
|
|
|
cmSystemTools::Error(message.c_str());
|
|
|
|
return -2;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-10-10 15:53:24 +03:00
|
|
|
this->AddCacheEntry("CMAKE_GENERATOR_TOOLSET",
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GeneratorToolset.c_str(),
|
|
|
|
"Name of generator toolset.", cmState::INTERNAL);
|
|
|
|
}
|
2012-12-10 19:42:33 +04:00
|
|
|
|
2002-09-13 18:41:20 +04:00
|
|
|
// reset any system configuration information, except for when we are
|
|
|
|
// InTryCompile. With TryCompile the system info is taken from the parent's
|
|
|
|
// info to save time
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->State->GetIsInTryCompile()) {
|
2006-03-15 19:02:08 +03:00
|
|
|
this->GlobalGenerator->ClearEnabledLanguages();
|
2006-03-10 21:06:26 +03:00
|
|
|
|
2005-07-03 20:06:40 +04:00
|
|
|
this->TruncateOutputLog("CMakeOutput.log");
|
|
|
|
this->TruncateOutputLog("CMakeError.log");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-07-03 20:06:40 +04:00
|
|
|
|
2002-09-06 21:06:23 +04:00
|
|
|
// actually do the configure
|
2006-03-15 19:02:08 +03:00
|
|
|
this->GlobalGenerator->Configure();
|
2002-09-06 21:06:23 +04:00
|
|
|
// Before saving the cache
|
|
|
|
// if the project did not define one of the entries below, add them now
|
|
|
|
// so users can edit the values in the cache:
|
2008-07-03 21:55:33 +04:00
|
|
|
|
|
|
|
// We used to always present LIBRARY_OUTPUT_PATH and
|
|
|
|
// EXECUTABLE_OUTPUT_PATH. They are now documented as old-style and
|
|
|
|
// should no longer be used. Therefore we present them only if the
|
|
|
|
// project requires compatibility with CMake 2.4. We detect this
|
2012-11-07 20:13:09 +04:00
|
|
|
// here by looking for the old CMAKE_BACKWARDS_COMPATIBILITY
|
2008-07-03 21:55:33 +04:00
|
|
|
// variable created when CMP0001 is not set to NEW.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->State->GetInitializedCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")) {
|
|
|
|
if (!this->State->GetInitializedCacheValue("LIBRARY_OUTPUT_PATH")) {
|
|
|
|
this->AddCacheEntry(
|
|
|
|
"LIBRARY_OUTPUT_PATH", "",
|
|
|
|
"Single output directory for building all libraries.", cmState::PATH);
|
|
|
|
}
|
|
|
|
if (!this->State->GetInitializedCacheValue("EXECUTABLE_OUTPUT_PATH")) {
|
|
|
|
this->AddCacheEntry(
|
|
|
|
"EXECUTABLE_OUTPUT_PATH", "",
|
|
|
|
"Single output directory for building all executables.",
|
|
|
|
cmState::PATH);
|
2008-07-03 21:55:33 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-10 21:06:26 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmMakefile* mf = this->GlobalGenerator->GetMakefiles()[0];
|
|
|
|
if (mf->IsOn("CTEST_USE_LAUNCHERS") &&
|
|
|
|
!this->State->GetGlobalProperty("RULE_LAUNCH_COMPILE")) {
|
|
|
|
cmSystemTools::Error(
|
|
|
|
"CTEST_USE_LAUNCHERS is enabled, but the "
|
|
|
|
"RULE_LAUNCH_COMPILE global property is not defined.\n"
|
|
|
|
"Did you forget to include(CTest) in the toplevel "
|
|
|
|
"CMakeLists.txt ?");
|
|
|
|
}
|
2012-08-21 01:19:44 +04:00
|
|
|
|
2006-02-15 06:03:16 +03:00
|
|
|
// only save the cache if there were no fatal errors
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetWorkingMode() == NORMAL_MODE) {
|
2015-10-10 15:42:36 +03:00
|
|
|
this->SaveCache(this->GetHomeOutputDirectory());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (cmSystemTools::GetErrorOccuredFlag()) {
|
2002-09-06 21:06:23 +04:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-08-28 22:51:10 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-08-17 23:36:08 +04:00
|
|
|
void cmake::PreLoadCMakeFiles()
|
|
|
|
{
|
2011-02-03 05:17:23 +03:00
|
|
|
std::vector<std::string> args;
|
2004-08-17 23:36:08 +04:00
|
|
|
std::string pre_load = this->GetHomeDirectory();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!pre_load.empty()) {
|
2004-08-23 22:33:22 +04:00
|
|
|
pre_load += "/PreLoad.cmake";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileExists(pre_load.c_str())) {
|
2011-02-03 05:17:23 +03:00
|
|
|
this->ReadListFile(args, pre_load.c_str());
|
2004-08-17 23:36:08 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-08-17 23:36:08 +04:00
|
|
|
pre_load = this->GetHomeOutputDirectory();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!pre_load.empty()) {
|
2004-08-23 22:33:22 +04:00
|
|
|
pre_load += "/PreLoad.cmake";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileExists(pre_load.c_str())) {
|
2011-02-03 05:17:23 +03:00
|
|
|
this->ReadListFile(args, pre_load.c_str());
|
2004-08-17 23:36:08 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-08-17 23:36:08 +04:00
|
|
|
}
|
|
|
|
|
2002-09-06 21:06:23 +04:00
|
|
|
// handle a command line invocation
|
2003-04-29 18:04:05 +04:00
|
|
|
int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
|
2002-09-06 21:06:23 +04:00
|
|
|
{
|
|
|
|
// Process the arguments
|
|
|
|
this->SetArgs(args);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::GetErrorOccuredFlag()) {
|
2005-04-05 19:23:08 +04:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-10 21:06:26 +03:00
|
|
|
|
2008-03-12 00:25:49 +03:00
|
|
|
// If we are given a stamp list file check if it is really out of date.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->CheckStampList.empty() &&
|
|
|
|
cmakeCheckStampList(this->CheckStampList.c_str())) {
|
2008-03-12 00:25:49 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-03-12 00:25:49 +03:00
|
|
|
|
2007-11-10 16:15:13 +03:00
|
|
|
// If we are given a stamp file check if it is really out of date.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->CheckStampFile.empty() &&
|
|
|
|
cmakeCheckStampFile(this->CheckStampFile.c_str())) {
|
2007-11-10 16:15:13 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-10 16:15:13 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetWorkingMode() == NORMAL_MODE) {
|
2003-10-29 17:45:26 +03:00
|
|
|
// load the cache
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->LoadCache() < 0) {
|
2006-03-10 21:06:26 +03:00
|
|
|
cmSystemTools::Error("Error executing cmake::LoadCache(). Aborting.\n");
|
2003-10-29 17:45:26 +03:00
|
|
|
return -1;
|
2003-01-22 18:33:34 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2007-12-14 01:56:50 +03:00
|
|
|
this->AddCMakePaths();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-11-08 15:59:27 +03:00
|
|
|
|
2002-09-17 21:59:58 +04:00
|
|
|
// Add any cache args
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->SetCacheArgs(args)) {
|
2003-10-29 17:45:26 +03:00
|
|
|
cmSystemTools::Error("Problem processing arguments. Aborting.\n");
|
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-04-28 18:52:20 +04:00
|
|
|
|
2005-02-22 17:08:02 +03:00
|
|
|
// In script mode we terminate after running the script.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetWorkingMode() != NORMAL_MODE) {
|
|
|
|
if (cmSystemTools::GetErrorOccuredFlag()) {
|
2005-08-08 17:37:29 +04:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2005-08-08 17:37:29 +04:00
|
|
|
return 0;
|
2005-02-22 17:08:02 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-02-22 17:08:02 +03:00
|
|
|
|
2010-06-21 18:50:11 +04:00
|
|
|
// If MAKEFLAGS are given in the environment, remove the environment
|
|
|
|
// variable. This will prevent try-compile from succeeding when it
|
|
|
|
// should fail (if "-i" is an option). We cannot simply test
|
|
|
|
// whether "-i" is given and remove it because some make programs
|
|
|
|
// encode the MAKEFLAGS variable in a strange way.
|
2016-07-08 00:54:05 +03:00
|
|
|
if (cmSystemTools::HasEnv("MAKEFLAGS")) {
|
2010-06-21 18:50:11 +04:00
|
|
|
cmSystemTools::PutEnv("MAKEFLAGS=");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-06-21 18:50:11 +04:00
|
|
|
|
2004-08-17 23:36:08 +04:00
|
|
|
this->PreLoadCMakeFiles();
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (noconfigure) {
|
2003-04-29 18:04:05 +04:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2003-04-29 18:04:05 +04:00
|
|
|
|
2005-03-10 21:39:38 +03:00
|
|
|
// now run the global generate
|
|
|
|
// Check the state of the build system to see if we need to regenerate.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->CheckBuildSystem()) {
|
2005-03-10 21:39:38 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-10 21:06:26 +03:00
|
|
|
|
2005-03-11 16:38:15 +03:00
|
|
|
int ret = this->Configure();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (ret || this->GetWorkingMode() != NORMAL_MODE) {
|
2007-11-19 22:22:38 +03:00
|
|
|
#if defined(CMAKE_HAVE_VS_GENERATORS)
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->VSSolutionFile.empty() && this->GlobalGenerator) {
|
2007-11-19 21:45:16 +03:00
|
|
|
// CMake is running to regenerate a Visual Studio build tree
|
|
|
|
// during a build from the VS IDE. The build files cannot be
|
|
|
|
// regenerated, so we should stop the build.
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::Message("CMake Configure step failed. "
|
|
|
|
"Build files cannot be regenerated correctly. "
|
|
|
|
"Attempting to stop IDE build.");
|
2007-11-19 21:45:16 +03:00
|
|
|
cmGlobalVisualStudioGenerator* gg =
|
|
|
|
static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator);
|
|
|
|
gg->CallVisualStudioMacro(cmGlobalVisualStudioGenerator::MacroStop,
|
|
|
|
this->VSSolutionFile.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-19 22:22:38 +03:00
|
|
|
#endif
|
2005-03-10 21:39:38 +03:00
|
|
|
return ret;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-03-10 21:39:38 +03:00
|
|
|
ret = this->Generate();
|
|
|
|
std::string message = "Build files have been written to: ";
|
|
|
|
message += this->GetHomeOutputDirectory();
|
|
|
|
this->UpdateProgress(message.c_str(), -1);
|
2002-11-13 23:20:20 +03:00
|
|
|
return ret;
|
2002-09-06 21:06:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int cmake::Generate()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->GlobalGenerator) {
|
2003-08-26 23:06:52 +04:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!this->GlobalGenerator->Compute()) {
|
2015-07-25 19:44:58 +03:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-25 19:43:28 +03:00
|
|
|
this->GlobalGenerator->Generate();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->GraphVizFile.empty()) {
|
2012-10-07 15:10:24 +04:00
|
|
|
std::cout << "Generate graphviz: " << this->GraphVizFile << std::endl;
|
|
|
|
this->GenerateGraphViz(this->GraphVizFile.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (this->WarnUnusedCli) {
|
2011-03-24 16:24:27 +03:00
|
|
|
this->RunCheckForUnusedVariables();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (cmSystemTools::GetErrorOccuredFlag()) {
|
2002-09-06 21:06:23 +04:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-09-01 16:49:00 +04:00
|
|
|
// 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.)
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->GetWorkingMode() == NORMAL_MODE) {
|
2015-10-10 15:42:36 +03:00
|
|
|
this->SaveCache(this->GetHomeOutputDirectory());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-09-06 21:06:23 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
void cmake::AddCacheEntry(const std::string& key, const char* value,
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* helpString, int type)
|
2002-12-04 18:57:22 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
this->State->AddCacheEntry(key, value, helpString,
|
|
|
|
cmState::CacheEntryType(type));
|
2015-10-10 15:31:06 +03:00
|
|
|
this->UnwatchUnusedCli(key);
|
2002-12-04 18:57:22 +03:00
|
|
|
}
|
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
const char* cmake::GetCacheDefinition(const std::string& name) const
|
2002-09-06 21:06:23 +04:00
|
|
|
{
|
2015-10-10 15:42:36 +03:00
|
|
|
return this->State->GetInitializedCacheValue(name);
|
2002-09-06 21:06:23 +04:00
|
|
|
}
|
2002-09-11 00:51:29 +04:00
|
|
|
|
|
|
|
void cmake::AddDefaultCommands()
|
|
|
|
{
|
2015-04-12 03:44:41 +03:00
|
|
|
std::vector<cmCommand*> commands;
|
2013-06-14 16:35:52 +04:00
|
|
|
GetBootstrapCommands1(commands);
|
|
|
|
GetBootstrapCommands2(commands);
|
2002-09-11 00:51:29 +04:00
|
|
|
GetPredefinedCommands(commands);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<cmCommand*>::iterator i = commands.begin();
|
|
|
|
i != commands.end(); ++i) {
|
2015-04-11 13:52:14 +03:00
|
|
|
this->State->AddCommand(*i);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-09-11 00:51:29 +04:00
|
|
|
}
|
|
|
|
|
2003-07-08 05:52:10 +04:00
|
|
|
void cmake::AddDefaultGenerators()
|
|
|
|
{
|
|
|
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
2016-05-16 17:34:04 +03:00
|
|
|
#if !defined(CMAKE_BOOT_MINGW)
|
|
|
|
this->Generators.push_back(cmGlobalVisualStudio14Generator::NewFactory());
|
|
|
|
this->Generators.push_back(cmGlobalVisualStudio12Generator::NewFactory());
|
|
|
|
this->Generators.push_back(cmGlobalVisualStudio11Generator::NewFactory());
|
|
|
|
this->Generators.push_back(cmGlobalVisualStudio10Generator::NewFactory());
|
|
|
|
this->Generators.push_back(cmGlobalVisualStudio9Generator::NewFactory());
|
|
|
|
this->Generators.push_back(cmGlobalVisualStudio8Generator::NewFactory());
|
|
|
|
this->Generators.push_back(cmGlobalVisualStudio71Generator::NewFactory());
|
|
|
|
this->Generators.push_back(cmGlobalBorlandMakefileGenerator::NewFactory());
|
|
|
|
this->Generators.push_back(cmGlobalNMakeMakefileGenerator::NewFactory());
|
|
|
|
this->Generators.push_back(cmGlobalJOMMakefileGenerator::NewFactory());
|
|
|
|
this->Generators.push_back(cmGlobalGhsMultiGenerator::NewFactory());
|
|
|
|
#endif
|
|
|
|
this->Generators.push_back(cmGlobalMSYSMakefileGenerator::NewFactory());
|
|
|
|
this->Generators.push_back(cmGlobalMinGWMakefileGenerator::NewFactory());
|
2003-08-22 00:22:23 +04:00
|
|
|
#endif
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Generators.push_back(cmGlobalUnixMakefileGenerator3::NewFactory());
|
2015-08-10 20:26:52 +03:00
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Generators.push_back(cmGlobalNinjaGenerator::NewFactory());
|
2015-08-10 20:26:52 +03:00
|
|
|
#endif
|
2014-03-17 22:30:38 +04:00
|
|
|
#if defined(CMAKE_USE_WMAKE)
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Generators.push_back(cmGlobalWatcomWMakeGenerator::NewFactory());
|
2014-03-17 22:30:38 +04:00
|
|
|
#endif
|
2005-03-14 21:23:14 +03:00
|
|
|
#ifdef CMAKE_USE_XCODE
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Generators.push_back(cmGlobalXCodeGenerator::NewFactory());
|
2005-03-14 21:23:14 +03:00
|
|
|
#endif
|
2003-07-08 05:52:10 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmake::ParseCacheEntry(const std::string& entry, std::string& var,
|
|
|
|
std::string& value, cmState::CacheEntryType& type)
|
2015-04-05 01:07:04 +03:00
|
|
|
{
|
2015-10-10 16:08:15 +03:00
|
|
|
return cmState::ParseCacheEntry(entry, var, value, type);
|
2015-04-05 01:07:04 +03:00
|
|
|
}
|
|
|
|
|
2002-11-07 17:04:20 +03:00
|
|
|
int cmake::LoadCache()
|
2002-09-17 21:59:58 +04:00
|
|
|
{
|
2005-08-11 21:20:23 +04:00
|
|
|
// could we not read the cache
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->LoadCache(this->GetHomeOutputDirectory())) {
|
2012-02-26 22:44:20 +04:00
|
|
|
// if it does exist, but isn't readable then warn the user
|
2005-08-11 21:20:23 +04:00
|
|
|
std::string cacheFile = this->GetHomeOutputDirectory();
|
|
|
|
cacheFile += "/CMakeCache.txt";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileExists(cacheFile.c_str())) {
|
2006-03-10 21:06:26 +03:00
|
|
|
cmSystemTools::Error(
|
|
|
|
"There is a CMakeCache.txt file for the current binary tree but "
|
|
|
|
"cmake does not have permission to read it. Please check the "
|
|
|
|
"permissions of the directory you are trying to run CMake on.");
|
2005-08-11 21:20:23 +04:00
|
|
|
return -1;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-09-17 21:59:58 +04:00
|
|
|
|
|
|
|
// setup CMAKE_ROOT and CMAKE_COMMAND
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->AddCMakePaths()) {
|
2002-09-17 21:59:58 +04:00
|
|
|
return -3;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-09-17 21:59:58 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-04-05 01:07:04 +03:00
|
|
|
bool cmake::LoadCache(const std::string& path)
|
|
|
|
{
|
2015-10-10 16:13:08 +03:00
|
|
|
std::set<std::string> emptySet;
|
|
|
|
return this->LoadCache(path, true, emptySet, emptySet);
|
2015-04-05 01:07:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmake::LoadCache(const std::string& path, bool internal,
|
2016-05-16 17:34:04 +03:00
|
|
|
std::set<std::string>& excludes,
|
|
|
|
std::set<std::string>& includes)
|
2015-04-05 01:07:04 +03:00
|
|
|
{
|
2015-10-10 15:26:56 +03:00
|
|
|
bool result = this->State->LoadCache(path, internal, excludes, includes);
|
2016-05-16 17:34:04 +03:00
|
|
|
static const char* entries[] = { "CMAKE_CACHE_MAJOR_VERSION",
|
|
|
|
"CMAKE_CACHE_MINOR_VERSION" };
|
2015-10-10 15:26:56 +03:00
|
|
|
for (const char* const* nameIt = cmArrayBegin(entries);
|
2016-05-16 17:34:04 +03:00
|
|
|
nameIt != cmArrayEnd(entries); ++nameIt) {
|
2015-10-10 15:26:56 +03:00
|
|
|
this->UnwatchUnusedCli(*nameIt);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-10 15:26:56 +03:00
|
|
|
return result;
|
2015-04-05 01:07:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmake::SaveCache(const std::string& path)
|
|
|
|
{
|
2015-10-10 15:26:56 +03:00
|
|
|
bool result = this->State->SaveCache(path);
|
2016-05-16 17:34:04 +03:00
|
|
|
static const char* entries[] = { "CMAKE_CACHE_MAJOR_VERSION",
|
|
|
|
"CMAKE_CACHE_MINOR_VERSION",
|
|
|
|
"CMAKE_CACHE_PATCH_VERSION",
|
|
|
|
"CMAKE_CACHEFILE_DIR" };
|
2015-10-10 15:26:56 +03:00
|
|
|
for (const char* const* nameIt = cmArrayBegin(entries);
|
2016-05-16 17:34:04 +03:00
|
|
|
nameIt != cmArrayEnd(entries); ++nameIt) {
|
2015-10-10 15:26:56 +03:00
|
|
|
this->UnwatchUnusedCli(*nameIt);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-10-10 15:26:56 +03:00
|
|
|
return result;
|
2015-04-05 01:07:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cmake::DeleteCache(const std::string& path)
|
|
|
|
{
|
2015-10-10 16:21:41 +03:00
|
|
|
return this->State->DeleteCache(path);
|
2015-04-05 01:07:04 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmake::SetProgressCallback(ProgressCallbackType f, void* cd)
|
2002-09-26 23:14:20 +04:00
|
|
|
{
|
2006-03-15 19:02:08 +03:00
|
|
|
this->ProgressCallback = f;
|
|
|
|
this->ProgressCallbackClientData = cd;
|
2002-09-26 23:14:20 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmake::UpdateProgress(const char* msg, float prog)
|
2002-09-26 23:14:20 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->ProgressCallback && !this->State->GetIsInTryCompile()) {
|
2006-03-15 19:02:08 +03:00
|
|
|
(*this->ProgressCallback)(msg, prog, this->ProgressCallbackClientData);
|
2002-09-26 23:14:20 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2002-09-26 23:14:20 +04:00
|
|
|
}
|
2003-02-14 18:53:37 +03:00
|
|
|
|
2015-04-11 13:12:14 +03:00
|
|
|
bool cmake::GetIsInTryCompile() const
|
|
|
|
{
|
2015-04-11 13:16:54 +03:00
|
|
|
return this->State->GetIsInTryCompile();
|
2015-04-11 13:12:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmake::SetIsInTryCompile(bool b)
|
|
|
|
{
|
2015-04-11 13:16:54 +03:00
|
|
|
this->State->SetIsInTryCompile(b);
|
2015-04-11 13:12:14 +03:00
|
|
|
}
|
|
|
|
|
2003-07-08 05:52:10 +04:00
|
|
|
void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
for (RegisteredGeneratorsVector::const_iterator i = this->Generators.begin();
|
|
|
|
i != this->Generators.end(); ++i) {
|
2003-07-08 05:52:10 +04:00
|
|
|
cmDocumentationEntry e;
|
2012-11-19 19:13:54 +04:00
|
|
|
(*i)->GetDocumentation(e);
|
2003-07-08 05:52:10 +04:00
|
|
|
v.push_back(e);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-07-20 19:28:39 +03:00
|
|
|
for (RegisteredExtraGeneratorsVector::const_iterator i =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->ExtraGenerators.begin();
|
|
|
|
i != this->ExtraGenerators.end(); ++i) {
|
2016-07-20 19:28:39 +03:00
|
|
|
const std::string doc = (*i)->GetDocumentation();
|
|
|
|
const std::string name = (*i)->GetName();
|
|
|
|
|
|
|
|
// Aliases:
|
|
|
|
for (std::vector<std::string>::const_iterator a = (*i)->Aliases.begin();
|
|
|
|
a != (*i)->Aliases.end(); ++a) {
|
|
|
|
cmDocumentationEntry e;
|
|
|
|
e.Name = *a;
|
|
|
|
e.Brief = doc;
|
|
|
|
v.push_back(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Full names:
|
|
|
|
const std::vector<std::string> generators =
|
|
|
|
(*i)->GetSupportedGlobalGenerators();
|
|
|
|
for (std::vector<std::string>::const_iterator g = generators.begin();
|
|
|
|
g != generators.end(); ++g) {
|
|
|
|
cmDocumentationEntry e;
|
|
|
|
e.Name =
|
|
|
|
cmExternalMakefileProjectGenerator::CreateFullGeneratorName(*g, name);
|
|
|
|
e.Brief = doc;
|
|
|
|
v.push_back(e);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2003-07-08 05:52:10 +04:00
|
|
|
}
|
2004-04-18 22:41:46 +04:00
|
|
|
|
2015-03-29 21:28:30 +03:00
|
|
|
void cmake::PrintGeneratorList()
|
|
|
|
{
|
|
|
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
|
|
|
cmDocumentation doc;
|
|
|
|
std::vector<cmDocumentationEntry> generators;
|
|
|
|
this->GetGeneratorDocumentation(generators);
|
2016-05-16 17:34:04 +03:00
|
|
|
doc.AppendSection("Generators", generators);
|
2015-03-29 21:28:30 +03:00
|
|
|
std::cerr << "\n";
|
|
|
|
doc.PrintDocumentation(cmDocumentation::ListGenerators, std::cerr);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2004-10-04 20:31:09 +04:00
|
|
|
void cmake::UpdateConversionPathTable()
|
|
|
|
{
|
|
|
|
// Update the path conversion table with any specified file:
|
2010-10-31 16:46:09 +03:00
|
|
|
const char* tablepath =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->State->GetInitializedCacheValue("CMAKE_PATH_TRANSLATION_FILE");
|
2004-10-04 20:31:09 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (tablepath) {
|
|
|
|
cmsys::ifstream table(tablepath);
|
|
|
|
if (!table) {
|
2006-03-10 21:06:26 +03:00
|
|
|
cmSystemTools::Error("CMAKE_PATH_TRANSLATION_FILE set to ", tablepath,
|
2016-05-16 17:34:04 +03:00
|
|
|
". CMake can not open file.");
|
2004-10-05 19:37:03 +04:00
|
|
|
cmSystemTools::ReportLastSystemError("CMake can not open file.");
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2004-10-05 19:37:03 +04:00
|
|
|
std::string a, b;
|
2016-05-16 17:34:04 +03:00
|
|
|
while (!table.eof()) {
|
2004-10-04 20:31:09 +04:00
|
|
|
// two entries per line
|
2016-05-16 17:34:04 +03:00
|
|
|
table >> a;
|
|
|
|
table >> b;
|
|
|
|
cmSystemTools::AddTranslationPath(a, b);
|
2004-10-04 20:31:09 +04:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-10-04 20:31:09 +04:00
|
|
|
}
|
2004-10-15 17:24:44 +04:00
|
|
|
|
2004-10-30 00:50:46 +04:00
|
|
|
int cmake::CheckBuildSystem()
|
2004-10-15 17:24:44 +04:00
|
|
|
{
|
2016-07-08 00:54:05 +03:00
|
|
|
// We do not need to rerun CMake. Check dependency integrity.
|
|
|
|
const bool verbose = isCMakeVerbose();
|
2009-12-23 21:51:46 +03:00
|
|
|
|
2004-10-30 00:50:46 +04:00
|
|
|
// This method will check the integrity of the build system if the
|
|
|
|
// option was given on the command line. It reads the given file to
|
2006-06-15 17:45:02 +04:00
|
|
|
// determine whether CMake should rerun.
|
2004-10-30 00:50:46 +04:00
|
|
|
|
2004-10-15 17:24:44 +04:00
|
|
|
// If no file is provided for the check, we have to rerun.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CheckBuildSystemArgument.empty()) {
|
|
|
|
if (verbose) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream msg;
|
2006-04-12 06:39:34 +04:00
|
|
|
msg << "Re-run cmake no build system arguments\n";
|
|
|
|
cmSystemTools::Stdout(msg.str().c_str());
|
2004-10-15 17:24:44 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return 1;
|
|
|
|
}
|
2004-10-15 17:24:44 +04:00
|
|
|
|
|
|
|
// If the file provided does not exist, we have to rerun.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileExists(this->CheckBuildSystemArgument.c_str())) {
|
|
|
|
if (verbose) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream msg;
|
2016-05-16 17:34:04 +03:00
|
|
|
msg << "Re-run cmake missing file: " << this->CheckBuildSystemArgument
|
|
|
|
<< "\n";
|
2006-04-12 06:39:34 +04:00
|
|
|
cmSystemTools::Stdout(msg.str().c_str());
|
2004-10-15 17:24:44 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return 1;
|
|
|
|
}
|
2004-10-15 17:24:44 +04:00
|
|
|
|
|
|
|
// Read the rerun check file and use it to decide whether to do the
|
|
|
|
// global generate.
|
|
|
|
cmake cm;
|
2015-05-05 00:01:29 +03:00
|
|
|
cm.SetHomeDirectory("");
|
|
|
|
cm.SetHomeOutputDirectory("");
|
2015-10-13 22:48:46 +03:00
|
|
|
cm.GetCurrentSnapshot().SetDefaultDefinitions();
|
2015-05-24 12:31:14 +03:00
|
|
|
cmGlobalGenerator gg(&cm);
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!mf->ReadListFile(this->CheckBuildSystemArgument.c_str()) ||
|
|
|
|
cmSystemTools::GetErrorOccuredFlag()) {
|
|
|
|
if (verbose) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream msg;
|
2016-05-16 17:34:04 +03:00
|
|
|
msg << "Re-run cmake error reading : " << this->CheckBuildSystemArgument
|
|
|
|
<< "\n";
|
2006-04-12 06:39:34 +04:00
|
|
|
cmSystemTools::Stdout(msg.str().c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-10-15 17:24:44 +04:00
|
|
|
// There was an error reading the file. Just rerun.
|
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-10-15 17:24:44 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->ClearBuildSystem) {
|
2007-12-21 20:22:12 +03:00
|
|
|
// Get the generator used for this build system.
|
|
|
|
const char* genName = mf->GetDefinition("CMAKE_DEPENDS_GENERATOR");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!genName || genName[0] == '\0') {
|
2007-12-21 20:22:12 +03:00
|
|
|
genName = "Unix Makefiles";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-12-20 00:36:30 +03:00
|
|
|
|
2007-12-21 20:22:12 +03:00
|
|
|
// Create the generator and use it to clear the dependencies.
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmGlobalGenerator> ggd(this->CreateGlobalGenerator(genName));
|
2016-05-16 17:34:04 +03:00
|
|
|
if (ggd.get()) {
|
2015-10-13 22:48:46 +03:00
|
|
|
cm.GetCurrentSnapshot().SetDefaultDefinitions();
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmMakefile> mfd(
|
2016-05-16 17:34:04 +03:00
|
|
|
new cmMakefile(ggd.get(), cm.GetCurrentSnapshot()));
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmLocalGenerator> lgd(ggd->CreateLocalGenerator(mfd.get()));
|
2015-08-02 12:41:51 +03:00
|
|
|
lgd->ClearDependencies(mfd.get(), verbose);
|
2006-06-15 17:45:02 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-06-15 17:45:02 +04:00
|
|
|
|
2009-02-06 19:18:56 +03:00
|
|
|
// If any byproduct of makefile generation is missing we must re-run.
|
|
|
|
std::vector<std::string> products;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* productStr = mf->GetDefinition("CMAKE_MAKEFILE_PRODUCTS")) {
|
2009-02-06 19:18:56 +03:00
|
|
|
cmSystemTools::ExpandListArgument(productStr, products);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
for (std::vector<std::string>::const_iterator pi = products.begin();
|
|
|
|
pi != products.end(); ++pi) {
|
|
|
|
if (!(cmSystemTools::FileExists(pi->c_str()) ||
|
|
|
|
cmSystemTools::FileIsSymlink(*pi))) {
|
|
|
|
if (verbose) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream msg;
|
2009-02-06 19:18:56 +03:00
|
|
|
msg << "Re-run cmake, missing byproduct: " << *pi << "\n";
|
|
|
|
cmSystemTools::Stdout(msg.str().c_str());
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return 1;
|
2009-02-06 19:18:56 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-02-06 19:18:56 +03:00
|
|
|
|
2004-10-15 17:24:44 +04:00
|
|
|
// Get the set of dependencies and outputs.
|
2007-12-19 19:51:30 +03:00
|
|
|
std::vector<std::string> depends;
|
|
|
|
std::vector<std::string> outputs;
|
2004-10-15 17:24:44 +04:00
|
|
|
const char* dependsStr = mf->GetDefinition("CMAKE_MAKEFILE_DEPENDS");
|
|
|
|
const char* outputsStr = mf->GetDefinition("CMAKE_MAKEFILE_OUTPUTS");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (dependsStr && outputsStr) {
|
2007-12-19 19:51:30 +03:00
|
|
|
cmSystemTools::ExpandListArgument(dependsStr, depends);
|
|
|
|
cmSystemTools::ExpandListArgument(outputsStr, outputs);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (depends.empty() || outputs.empty()) {
|
2004-10-15 17:24:44 +04:00
|
|
|
// Not enough information was provided to do the test. Just rerun.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (verbose) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream msg;
|
2006-04-12 06:39:34 +04:00
|
|
|
msg << "Re-run cmake no CMAKE_MAKEFILE_DEPENDS "
|
2016-05-16 17:34:04 +03:00
|
|
|
"or CMAKE_MAKEFILE_OUTPUTS :\n";
|
2006-04-12 06:39:34 +04:00
|
|
|
cmSystemTools::Stdout(msg.str().c_str());
|
2004-10-15 17:24:44 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return 1;
|
|
|
|
}
|
2004-10-15 17:24:44 +04:00
|
|
|
|
2011-03-19 13:41:00 +03:00
|
|
|
// Find the newest dependency.
|
2007-12-19 19:51:30 +03:00
|
|
|
std::vector<std::string>::iterator dep = depends.begin();
|
|
|
|
std::string dep_newest = *dep++;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (; dep != depends.end(); ++dep) {
|
2007-12-19 19:51:30 +03:00
|
|
|
int result = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->FileComparison->FileTimeCompare(dep_newest.c_str(), dep->c_str(),
|
|
|
|
&result)) {
|
|
|
|
if (result < 0) {
|
2007-12-19 19:51:30 +03:00
|
|
|
dep_newest = *dep;
|
2004-10-15 17:24:44 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
if (verbose) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream msg;
|
2007-12-19 19:51:30 +03:00
|
|
|
msg << "Re-run cmake: build system dependency is missing\n";
|
|
|
|
cmSystemTools::Stdout(msg.str().c_str());
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return 1;
|
2004-10-15 17:24:44 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-10-15 17:24:44 +04:00
|
|
|
|
2011-03-19 13:41:00 +03:00
|
|
|
// Find the oldest output.
|
2007-12-19 19:51:30 +03:00
|
|
|
std::vector<std::string>::iterator out = outputs.begin();
|
|
|
|
std::string out_oldest = *out++;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (; out != outputs.end(); ++out) {
|
2007-12-19 19:51:30 +03:00
|
|
|
int result = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->FileComparison->FileTimeCompare(out_oldest.c_str(), out->c_str(),
|
|
|
|
&result)) {
|
|
|
|
if (result > 0) {
|
2007-12-19 19:51:30 +03:00
|
|
|
out_oldest = *out;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
if (verbose) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream msg;
|
2007-12-19 19:51:30 +03:00
|
|
|
msg << "Re-run cmake: build system output is missing\n";
|
|
|
|
cmSystemTools::Stdout(msg.str().c_str());
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return 1;
|
2007-12-19 19:51:30 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-12-19 19:51:30 +03:00
|
|
|
|
|
|
|
// If any output is older than any dependency then rerun.
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
int result = 0;
|
|
|
|
if (!this->FileComparison->FileTimeCompare(out_oldest.c_str(),
|
|
|
|
dep_newest.c_str(), &result) ||
|
|
|
|
result < 0) {
|
|
|
|
if (verbose) {
|
|
|
|
std::ostringstream msg;
|
|
|
|
msg << "Re-run cmake file: " << out_oldest
|
|
|
|
<< " older than: " << dep_newest << "\n";
|
|
|
|
cmSystemTools::Stdout(msg.str().c_str());
|
2007-12-19 19:51:30 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return 1;
|
2007-12-19 19:51:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-15 17:24:44 +04:00
|
|
|
// No need to rerun.
|
|
|
|
return 0;
|
|
|
|
}
|
2005-07-03 06:25:43 +04:00
|
|
|
|
|
|
|
void cmake::TruncateOutputLog(const char* fname)
|
|
|
|
{
|
|
|
|
std::string fullPath = this->GetHomeOutputDirectory();
|
|
|
|
fullPath += "/";
|
|
|
|
fullPath += fname;
|
|
|
|
struct stat st;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (::stat(fullPath.c_str(), &st)) {
|
2005-07-03 06:25:43 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!this->State->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR")) {
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::RemoveFile(fullPath);
|
2005-07-03 06:25:43 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-05 22:34:36 +03:00
|
|
|
off_t fsize = st.st_size;
|
|
|
|
const off_t maxFileSize = 50 * 1024;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (fsize < maxFileSize) {
|
|
|
|
// TODO: truncate file
|
2005-07-03 06:25:43 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-07-03 06:25:43 +04:00
|
|
|
}
|
|
|
|
|
2006-02-23 18:00:44 +03:00
|
|
|
inline std::string removeQuotes(const std::string& s)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (s[0] == '\"' && s[s.size() - 1] == '\"') {
|
|
|
|
return s.substr(1, s.size() - 2);
|
|
|
|
}
|
2006-02-23 18:00:44 +03:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2010-09-01 18:22:08 +04:00
|
|
|
void cmake::MarkCliAsUsed(const std::string& variable)
|
|
|
|
{
|
|
|
|
this->UsedCliVariables[variable] = true;
|
|
|
|
}
|
|
|
|
|
2007-06-15 18:10:24 +04:00
|
|
|
void cmake::GenerateGraphViz(const char* fileName) const
|
2006-03-03 22:24:31 +03:00
|
|
|
{
|
2010-11-09 23:37:51 +03:00
|
|
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmGraphVizWriter> gvWriter(
|
2016-05-16 17:34:04 +03:00
|
|
|
new cmGraphVizWriter(this->GetGlobalGenerator()->GetLocalGenerators()));
|
2006-03-03 22:24:31 +03:00
|
|
|
|
2010-11-09 23:37:51 +03:00
|
|
|
std::string settingsFile = this->GetHomeOutputDirectory();
|
|
|
|
settingsFile += "/CMakeGraphVizOptions.cmake";
|
|
|
|
std::string fallbackSettingsFile = this->GetHomeDirectory();
|
|
|
|
fallbackSettingsFile += "/CMakeGraphVizOptions.cmake";
|
2006-03-03 22:24:31 +03:00
|
|
|
|
2010-11-09 23:37:51 +03:00
|
|
|
gvWriter->ReadSettings(settingsFile.c_str(), fallbackSettingsFile.c_str());
|
2006-03-03 22:24:31 +03:00
|
|
|
|
2010-11-09 23:37:51 +03:00
|
|
|
gvWriter->WritePerTargetFiles(fileName);
|
2011-02-06 20:34:48 +03:00
|
|
|
gvWriter->WriteTargetDependersFiles(fileName);
|
2010-11-09 23:37:51 +03:00
|
|
|
gvWriter->WriteGlobalFile(fileName);
|
2006-03-03 22:24:31 +03:00
|
|
|
|
2010-11-09 23:37:51 +03:00
|
|
|
#endif
|
2006-03-03 22:24:31 +03:00
|
|
|
}
|
2007-06-26 21:05:27 +04:00
|
|
|
|
2013-09-03 00:27:32 +04:00
|
|
|
void cmake::SetProperty(const std::string& prop, const char* value)
|
2006-12-07 17:45:32 +03:00
|
|
|
{
|
2015-04-11 15:17:46 +03:00
|
|
|
this->State->SetGlobalProperty(prop, value);
|
2006-12-07 17:45:32 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmake::AppendProperty(const std::string& prop, const char* value,
|
|
|
|
bool asString)
|
2008-01-18 02:13:55 +03:00
|
|
|
{
|
2015-04-11 15:17:46 +03:00
|
|
|
this->State->AppendGlobalProperty(prop, value, asString);
|
2008-01-18 02:13:55 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cmake::GetProperty(const std::string& prop)
|
2006-12-07 17:45:32 +03:00
|
|
|
{
|
2015-04-11 15:17:46 +03:00
|
|
|
return this->State->GetGlobalProperty(prop);
|
2006-12-07 17:45:32 +03:00
|
|
|
}
|
|
|
|
|
2013-09-03 00:27:32 +04:00
|
|
|
bool cmake::GetPropertyAsBool(const std::string& prop)
|
2006-12-07 17:45:32 +03:00
|
|
|
{
|
2015-04-11 15:15:55 +03:00
|
|
|
return this->State->GetGlobalPropertyAsBool(prop);
|
2006-12-07 17:45:32 +03:00
|
|
|
}
|
2007-02-27 18:10:10 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmInstalledFile* cmake::GetOrCreateInstalledFile(cmMakefile* mf,
|
|
|
|
const std::string& name)
|
2014-05-15 21:12:40 +04:00
|
|
|
{
|
|
|
|
std::map<std::string, cmInstalledFile>::iterator i =
|
|
|
|
this->InstalledFiles.find(name);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i != this->InstalledFiles.end()) {
|
|
|
|
cmInstalledFile& file = i->second;
|
2014-05-15 21:12:40 +04:00
|
|
|
return &file;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
cmInstalledFile& file = this->InstalledFiles[name];
|
2014-05-15 21:12:40 +04:00
|
|
|
file.SetName(mf, name);
|
|
|
|
return &file;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-05-15 21:12:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
cmInstalledFile const* cmake::GetInstalledFile(const std::string& name) const
|
|
|
|
{
|
|
|
|
std::map<std::string, cmInstalledFile>::const_iterator i =
|
|
|
|
this->InstalledFiles.find(name);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i != this->InstalledFiles.end()) {
|
2014-05-15 21:12:40 +04:00
|
|
|
cmInstalledFile const& file = i->second;
|
|
|
|
return &file;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2016-06-27 23:44:16 +03:00
|
|
|
return CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-05-15 21:12:40 +04:00
|
|
|
}
|
|
|
|
|
2007-02-27 18:10:10 +03:00
|
|
|
int cmake::GetSystemInformation(std::vector<std::string>& args)
|
|
|
|
{
|
|
|
|
// so create the directory
|
2007-02-28 20:25:19 +03:00
|
|
|
std::string resultFile;
|
2007-02-27 18:10:10 +03:00
|
|
|
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
|
|
|
|
std::string destPath = cwd + "/__cmake_systeminformation";
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::RemoveADirectory(destPath);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::MakeDirectory(destPath.c_str())) {
|
2007-02-27 18:10:10 +03:00
|
|
|
std::cerr << "Error: --system-information must be run from a "
|
2016-05-16 17:34:04 +03:00
|
|
|
"writable directory!\n";
|
2007-02-27 18:10:10 +03:00
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-02-28 20:25:19 +03:00
|
|
|
|
|
|
|
// process the arguments
|
2007-03-01 18:53:09 +03:00
|
|
|
bool writeToStdout = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (unsigned int i = 1; i < args.size(); ++i) {
|
2007-02-28 20:25:19 +03:00
|
|
|
std::string arg = args[i];
|
2016-06-08 16:18:28 +03:00
|
|
|
if (arg.find("-G", 0) == 0) {
|
2007-02-28 20:25:19 +03:00
|
|
|
std::string value = arg.substr(2);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (value.empty()) {
|
2007-02-28 20:25:19 +03:00
|
|
|
++i;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i >= args.size()) {
|
2007-02-28 20:25:19 +03:00
|
|
|
cmSystemTools::Error("No generator specified for -G");
|
2015-03-29 21:28:30 +03:00
|
|
|
this->PrintGeneratorList();
|
2007-02-28 20:25:19 +03:00
|
|
|
return -1;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
value = args[i];
|
|
|
|
}
|
|
|
|
cmGlobalGenerator* gen = this->CreateGlobalGenerator(value);
|
|
|
|
if (!gen) {
|
2007-02-28 20:25:19 +03:00
|
|
|
cmSystemTools::Error("Could not create named generator ",
|
|
|
|
value.c_str());
|
2015-03-29 21:28:30 +03:00
|
|
|
this->PrintGeneratorList();
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2007-02-28 20:25:19 +03:00
|
|
|
this->SetGlobalGenerator(gen);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-02-28 20:25:19 +03:00
|
|
|
// no option assume it is the output file
|
2016-05-16 17:34:04 +03:00
|
|
|
else {
|
|
|
|
if (!cmSystemTools::FileIsFullPath(arg.c_str())) {
|
2007-03-01 18:53:09 +03:00
|
|
|
resultFile = cwd;
|
2007-02-28 20:25:19 +03:00
|
|
|
resultFile += "/";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-03-01 18:53:09 +03:00
|
|
|
resultFile += arg;
|
|
|
|
writeToStdout = false;
|
2007-02-28 20:25:19 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-02-28 20:25:19 +03:00
|
|
|
|
2007-02-27 18:10:10 +03:00
|
|
|
// we have to find the module directory, so we can copy the files
|
2007-12-14 01:56:50 +03:00
|
|
|
this->AddCMakePaths();
|
2016-03-14 17:38:19 +03:00
|
|
|
std::string modulesPath = cmSystemTools::GetCMakeRoot();
|
2007-02-27 18:10:10 +03:00
|
|
|
modulesPath += "/Modules";
|
|
|
|
std::string inFile = modulesPath;
|
|
|
|
inFile += "/SystemInformation.cmake";
|
|
|
|
std::string outFile = destPath;
|
|
|
|
outFile += "/CMakeLists.txt";
|
2010-10-31 16:46:09 +03:00
|
|
|
|
2007-02-27 18:10:10 +03:00
|
|
|
// Copy file
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::cmCopyFile(inFile.c_str(), outFile.c_str())) {
|
|
|
|
std::cerr << "Error copying file \"" << inFile << "\" to \"" << outFile
|
|
|
|
<< "\".\n";
|
2007-02-27 18:10:10 +03:00
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-10-31 16:46:09 +03:00
|
|
|
|
2007-02-27 18:10:10 +03:00
|
|
|
// do we write to a file or to stdout?
|
2016-05-16 17:34:04 +03:00
|
|
|
if (resultFile.empty()) {
|
2007-02-27 18:10:10 +03:00
|
|
|
resultFile = cwd;
|
2007-02-28 00:41:43 +03:00
|
|
|
resultFile += "/__cmake_systeminformation/results.txt";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-02-27 18:10:10 +03:00
|
|
|
|
|
|
|
// now run cmake on the CMakeLists file
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::ChangeDirectory(destPath);
|
2007-02-27 18:10:10 +03:00
|
|
|
std::vector<std::string> args2;
|
|
|
|
args2.push_back(args[0]);
|
|
|
|
args2.push_back(destPath);
|
|
|
|
std::string resultArg = "-DRESULT_FILE=";
|
|
|
|
resultArg += resultFile;
|
|
|
|
args2.push_back(resultArg);
|
2007-03-01 18:53:09 +03:00
|
|
|
int res = this->Run(args2, false);
|
2007-02-27 20:47:14 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (res != 0) {
|
2007-02-27 20:47:14 +03:00
|
|
|
std::cerr << "Error: --system-information failed on internal CMake!\n";
|
|
|
|
return res;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-02-27 20:47:14 +03:00
|
|
|
|
2007-02-27 18:10:10 +03:00
|
|
|
// change back to the original directory
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::ChangeDirectory(cwd);
|
2010-10-31 16:46:09 +03:00
|
|
|
|
2007-02-27 18:10:10 +03:00
|
|
|
// echo results to stdout if needed
|
2016-05-16 17:34:04 +03:00
|
|
|
if (writeToStdout) {
|
2014-10-15 16:54:05 +04:00
|
|
|
FILE* fin = cmsys::SystemTools::Fopen(resultFile, "r");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (fin) {
|
2007-02-27 18:10:10 +03:00
|
|
|
const int bufferSize = 4096;
|
|
|
|
char buffer[bufferSize];
|
2007-03-02 18:49:32 +03:00
|
|
|
size_t n;
|
2016-05-16 17:34:04 +03:00
|
|
|
while ((n = fread(buffer, 1, bufferSize, fin)) > 0) {
|
|
|
|
for (char* c = buffer; c < buffer + n; ++c) {
|
2007-02-27 18:10:10 +03:00
|
|
|
putc(*c, stdout);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
fflush(stdout);
|
2007-02-27 18:10:10 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
fclose(fin);
|
2007-02-27 18:10:10 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-10-31 16:46:09 +03:00
|
|
|
|
2007-02-27 18:10:10 +03:00
|
|
|
// clean up the directory
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::RemoveADirectory(destPath);
|
2007-02-27 18:10:10 +03:00
|
|
|
return 0;
|
|
|
|
}
|
2007-11-10 16:15:13 +03:00
|
|
|
|
|
|
|
static bool cmakeCheckStampFile(const char* stampName)
|
|
|
|
{
|
|
|
|
// The stamp file does not exist. Use the stamp dependencies to
|
|
|
|
// determine whether it is really out of date. This works in
|
|
|
|
// conjunction with cmLocalVisualStudio7Generator to avoid
|
|
|
|
// repeatedly re-running CMake when the user rebuilds the entire
|
|
|
|
// solution.
|
|
|
|
std::string stampDepends = stampName;
|
|
|
|
stampDepends += ".depend";
|
|
|
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
2014-01-04 09:47:13 +04:00
|
|
|
cmsys::ifstream fin(stampDepends.c_str(), std::ios::in | std::ios::binary);
|
2007-11-10 16:15:13 +03:00
|
|
|
#else
|
2016-06-13 23:56:48 +03:00
|
|
|
cmsys::ifstream fin(stampDepends.c_str());
|
2007-11-10 16:15:13 +03:00
|
|
|
#endif
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!fin) {
|
2007-11-10 16:15:13 +03:00
|
|
|
// The stamp dependencies file cannot be read. Just assume the
|
|
|
|
// build system is really out of date.
|
2008-06-08 19:41:24 +04:00
|
|
|
std::cout << "CMake is re-running because " << stampName
|
|
|
|
<< " dependency file is missing.\n";
|
2007-11-10 16:15:13 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-10 16:15:13 +03:00
|
|
|
|
|
|
|
// Compare the stamp dependencies against the dependency file itself.
|
|
|
|
cmFileTimeComparison ftc;
|
|
|
|
std::string dep;
|
2016-05-16 17:34:04 +03:00
|
|
|
while (cmSystemTools::GetLineFromStream(fin, dep)) {
|
2007-11-10 16:15:13 +03:00
|
|
|
int result;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!dep.empty() && dep[0] != '#' &&
|
|
|
|
(!ftc.FileTimeCompare(stampDepends.c_str(), dep.c_str(), &result) ||
|
|
|
|
result < 0)) {
|
2007-11-10 16:15:13 +03:00
|
|
|
// The stamp depends file is older than this dependency. The
|
|
|
|
// build system is really out of date.
|
2008-06-08 19:41:24 +04:00
|
|
|
std::cout << "CMake is re-running because " << stampName
|
|
|
|
<< " is out-of-date.\n";
|
2010-06-21 19:47:16 +04:00
|
|
|
std::cout << " the file '" << dep << "'\n";
|
|
|
|
std::cout << " is newer than '" << stampDepends << "'\n";
|
|
|
|
std::cout << " result='" << result << "'\n";
|
2007-11-10 16:15:13 +03:00
|
|
|
return false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-10 16:15:13 +03:00
|
|
|
|
|
|
|
// The build system is up to date. The stamp file has been removed
|
2013-02-12 19:46:22 +04:00
|
|
|
// by the VS IDE due to a "rebuild" request. Restore it atomically.
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream stampTempStream;
|
2013-02-12 19:46:22 +04:00
|
|
|
stampTempStream << stampName << ".tmp" << cmSystemTools::RandomSeed();
|
|
|
|
std::string stampTempString = stampTempStream.str();
|
|
|
|
const char* stampTemp = stampTempString.c_str();
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
// TODO: Teach cmGeneratedFileStream to use a random temp file (with
|
|
|
|
// multiple tries in unlikely case of conflict) and use that here.
|
|
|
|
cmsys::ofstream stamp(stampTemp);
|
|
|
|
stamp << "# CMake generation timestamp file for this directory.\n";
|
2013-02-12 19:46:22 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::RenameFile(stampTemp, stampName)) {
|
2007-11-10 16:15:13 +03:00
|
|
|
// Notify the user why CMake is not re-running. It is safe to
|
|
|
|
// just print to stdout here because this code is only reachable
|
|
|
|
// through an undocumented flag used by the VS generator.
|
2016-05-16 17:34:04 +03:00
|
|
|
std::cout << "CMake does not need to re-run because " << stampName
|
|
|
|
<< " is up-to-date.\n";
|
2007-11-10 16:15:13 +03:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2013-02-12 19:46:22 +04:00
|
|
|
cmSystemTools::RemoveFile(stampTemp);
|
2007-11-10 16:15:13 +03:00
|
|
|
cmSystemTools::Error("Cannot restore timestamp ", stampName);
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-11-10 16:15:13 +03:00
|
|
|
}
|
2008-01-01 23:13:41 +03:00
|
|
|
|
2008-03-12 00:25:49 +03:00
|
|
|
static bool cmakeCheckStampList(const char* stampList)
|
|
|
|
{
|
|
|
|
// If the stamp list does not exist CMake must rerun to generate it.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileExists(stampList)) {
|
2008-03-12 00:25:49 +03:00
|
|
|
std::cout << "CMake is re-running because generate.stamp.list "
|
|
|
|
<< "is missing.\n";
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-01-04 09:47:13 +04:00
|
|
|
cmsys::ifstream fin(stampList);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!fin) {
|
2008-03-12 00:25:49 +03:00
|
|
|
std::cout << "CMake is re-running because generate.stamp.list "
|
|
|
|
<< "could not be read.\n";
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-03-12 00:25:49 +03:00
|
|
|
|
|
|
|
// Check each stamp.
|
|
|
|
std::string stampName;
|
2016-05-16 17:34:04 +03:00
|
|
|
while (cmSystemTools::GetLineFromStream(fin, stampName)) {
|
|
|
|
if (!cmakeCheckStampFile(stampName.c_str())) {
|
2008-03-12 00:25:49 +03:00
|
|
|
return false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-03-12 00:25:49 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-01-29 00:10:23 +03:00
|
|
|
cmake::MessageType cmake::ConvertMessageType(cmake::MessageType t) const
|
2015-12-22 00:39:27 +03:00
|
|
|
{
|
|
|
|
bool warningsAsErrors;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (t == cmake::AUTHOR_WARNING || t == cmake::AUTHOR_ERROR) {
|
2015-12-22 00:39:27 +03:00
|
|
|
warningsAsErrors = this->GetDevWarningsAsErrors();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (warningsAsErrors && t == cmake::AUTHOR_WARNING) {
|
2015-12-22 00:39:27 +03:00
|
|
|
t = cmake::AUTHOR_ERROR;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (!warningsAsErrors && t == cmake::AUTHOR_ERROR) {
|
2015-12-22 00:39:27 +03:00
|
|
|
t = cmake::AUTHOR_WARNING;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (t == cmake::DEPRECATION_WARNING ||
|
|
|
|
t == cmake::DEPRECATION_ERROR) {
|
2015-12-22 00:39:27 +03:00
|
|
|
warningsAsErrors = this->GetDeprecatedWarningsAsErrors();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (warningsAsErrors && t == cmake::DEPRECATION_WARNING) {
|
2015-12-22 00:39:27 +03:00
|
|
|
t = cmake::DEPRECATION_ERROR;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (!warningsAsErrors && t == cmake::DEPRECATION_ERROR) {
|
2015-12-22 00:39:27 +03:00
|
|
|
t = cmake::DEPRECATION_WARNING;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-12-22 00:39:27 +03:00
|
|
|
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2016-01-29 00:10:23 +03:00
|
|
|
bool cmake::IsMessageTypeVisible(cmake::MessageType t) const
|
2015-11-08 15:20:47 +03:00
|
|
|
{
|
|
|
|
bool isVisible = true;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (t == cmake::DEPRECATION_ERROR) {
|
|
|
|
if (!this->GetDeprecatedWarningsAsErrors()) {
|
2015-11-08 15:20:47 +03:00
|
|
|
isVisible = false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (t == cmake::DEPRECATION_WARNING) {
|
|
|
|
if (this->GetSuppressDeprecatedWarnings()) {
|
2015-11-08 15:20:47 +03:00
|
|
|
isVisible = false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (t == cmake::AUTHOR_ERROR) {
|
|
|
|
if (!this->GetDevWarningsAsErrors()) {
|
2015-12-22 00:39:27 +03:00
|
|
|
isVisible = false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (t == cmake::AUTHOR_WARNING) {
|
|
|
|
if (this->GetSuppressDevWarnings()) {
|
2015-11-08 15:20:47 +03:00
|
|
|
isVisible = false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-11-08 15:20:47 +03:00
|
|
|
|
|
|
|
return isVisible;
|
|
|
|
}
|
|
|
|
|
2016-01-29 00:10:25 +03:00
|
|
|
static bool printMessagePreamble(cmake::MessageType t, std::ostream& msg)
|
2008-03-13 20:48:57 +03:00
|
|
|
{
|
|
|
|
// Construct the message header.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (t == cmake::FATAL_ERROR) {
|
2008-03-13 20:48:57 +03:00
|
|
|
msg << "CMake Error";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (t == cmake::INTERNAL_ERROR) {
|
2008-03-13 20:48:57 +03:00
|
|
|
msg << "CMake Internal Error (please report a bug)";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (t == cmake::LOG) {
|
2013-01-20 16:07:31 +04:00
|
|
|
msg << "CMake Debug Log";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (t == cmake::DEPRECATION_ERROR) {
|
2013-09-17 20:54:34 +04:00
|
|
|
msg << "CMake Deprecation Error";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (t == cmake::DEPRECATION_WARNING) {
|
2013-09-17 20:54:34 +04:00
|
|
|
msg << "CMake Deprecation Warning";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (t == cmake::AUTHOR_WARNING) {
|
2015-11-08 15:20:47 +03:00
|
|
|
msg << "CMake Warning (dev)";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (t == cmake::AUTHOR_ERROR) {
|
2015-12-22 00:39:27 +03:00
|
|
|
msg << "CMake Error (dev)";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2008-03-13 20:48:57 +03:00
|
|
|
msg << "CMake Warning";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-22 01:31:52 +03:00
|
|
|
return true;
|
|
|
|
}
|
2008-03-13 20:48:57 +03:00
|
|
|
|
2015-05-22 01:33:45 +03:00
|
|
|
void printMessageText(std::ostream& msg, std::string const& text)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
msg << ":\n";
|
|
|
|
cmDocumentationFormatter formatter;
|
|
|
|
formatter.SetIndent(" ");
|
|
|
|
formatter.PrintFormatted(msg, text.c_str());
|
2015-05-22 01:33:45 +03:00
|
|
|
}
|
2008-03-13 20:48:57 +03:00
|
|
|
|
2015-05-22 01:35:21 +03:00
|
|
|
void displayMessage(cmake::MessageType t, std::ostringstream& msg)
|
2015-05-22 01:31:52 +03:00
|
|
|
{
|
2008-03-13 20:48:57 +03:00
|
|
|
|
2008-03-13 22:06:35 +03:00
|
|
|
// Add a note about warning suppression.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (t == cmake::AUTHOR_WARNING) {
|
|
|
|
msg << "This warning is for project developers. Use -Wno-dev to suppress "
|
|
|
|
"it.";
|
|
|
|
} else if (t == cmake::AUTHOR_ERROR) {
|
|
|
|
msg << "This error is for project developers. Use -Wno-error=dev to "
|
|
|
|
"suppress "
|
|
|
|
"it.";
|
|
|
|
}
|
2008-03-13 22:06:35 +03:00
|
|
|
|
2008-03-13 20:48:57 +03:00
|
|
|
// Add a terminating blank line.
|
|
|
|
msg << "\n";
|
|
|
|
|
2014-04-17 19:20:13 +04:00
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
|
|
|
// Add a C++ stack trace to internal errors.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (t == cmake::INTERNAL_ERROR) {
|
|
|
|
std::string stack = cmsys::SystemInformation::GetProgramStack(0, 0);
|
|
|
|
if (!stack.empty()) {
|
|
|
|
if (cmHasLiteralPrefix(stack, "WARNING:")) {
|
2014-04-17 19:20:13 +04:00
|
|
|
stack = "Note:" + stack.substr(8);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
msg << stack << "\n";
|
2014-04-17 19:20:13 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-04-17 19:20:13 +04:00
|
|
|
#endif
|
|
|
|
|
2008-03-13 20:48:57 +03:00
|
|
|
// Output the message.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (t == cmake::FATAL_ERROR || t == cmake::INTERNAL_ERROR ||
|
|
|
|
t == cmake::DEPRECATION_ERROR || t == cmake::AUTHOR_ERROR) {
|
2008-03-13 20:48:57 +03:00
|
|
|
cmSystemTools::SetErrorOccured();
|
|
|
|
cmSystemTools::Message(msg.str().c_str(), "Error");
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2008-03-13 20:48:57 +03:00
|
|
|
cmSystemTools::Message(msg.str().c_str(), "Warning");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-03-13 20:48:57 +03:00
|
|
|
}
|
2008-09-05 01:34:25 +04:00
|
|
|
|
2015-05-22 01:35:21 +03:00
|
|
|
void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
|
2016-06-09 10:57:47 +03:00
|
|
|
cmListFileBacktrace const& backtrace) const
|
2015-05-22 01:35:21 +03:00
|
|
|
{
|
2016-06-09 10:57:47 +03:00
|
|
|
bool force = false;
|
|
|
|
// override the message type, if needed, for warnings and errors
|
|
|
|
cmake::MessageType override = this->ConvertMessageType(t);
|
|
|
|
if (override != t) {
|
|
|
|
t = override;
|
|
|
|
force = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-12-22 00:39:27 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!force && !this->IsMessageTypeVisible(t)) {
|
2015-11-08 15:20:47 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-11-08 15:20:47 +03:00
|
|
|
|
2016-06-12 23:06:01 +03:00
|
|
|
this->DisplayMessage(t, text, backtrace);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmake::DisplayMessage(cmake::MessageType t, std::string const& text,
|
|
|
|
cmListFileBacktrace const& backtrace) const
|
|
|
|
{
|
2015-05-22 01:35:21 +03:00
|
|
|
std::ostringstream msg;
|
2016-01-29 00:10:25 +03:00
|
|
|
if (!printMessagePreamble(t, msg)) {
|
2015-05-22 01:35:21 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-05-22 01:35:21 +03:00
|
|
|
|
|
|
|
// Add the immediate context.
|
|
|
|
backtrace.PrintTitle(msg);
|
|
|
|
|
|
|
|
printMessageText(msg, text);
|
|
|
|
|
|
|
|
// Add the rest of the context.
|
|
|
|
backtrace.PrintCallStack(msg);
|
|
|
|
|
|
|
|
displayMessage(t, msg);
|
|
|
|
}
|
|
|
|
|
2015-04-11 13:04:05 +03:00
|
|
|
std::vector<std::string> cmake::GetDebugConfigs()
|
2008-09-05 01:34:25 +04:00
|
|
|
{
|
2015-04-11 13:04:05 +03:00
|
|
|
std::vector<std::string> configs;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* config_list =
|
|
|
|
this->State->GetGlobalProperty("DEBUG_CONFIGURATIONS")) {
|
2015-04-11 13:04:05 +03:00
|
|
|
// Expand the specified list and convert to upper-case.
|
|
|
|
cmSystemTools::ExpandListArgument(config_list, configs);
|
2016-05-16 17:34:04 +03:00
|
|
|
std::transform(configs.begin(), configs.end(), configs.begin(),
|
2015-04-11 13:04:05 +03:00
|
|
|
cmSystemTools::UpperCase);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-11 13:04:05 +03:00
|
|
|
// If no configurations were specified, use a default list.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (configs.empty()) {
|
2015-04-11 13:04:05 +03:00
|
|
|
configs.push_back("DEBUG");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-11 13:04:05 +03:00
|
|
|
return configs;
|
2008-09-05 01:34:25 +04:00
|
|
|
}
|
2008-10-15 21:56:07 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
int cmake::Build(const std::string& dir, const std::string& target,
|
2008-10-15 21:56:07 +04:00
|
|
|
const std::string& config,
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::vector<std::string>& nativeOptions, bool clean)
|
2009-12-28 21:44:38 +03:00
|
|
|
{
|
2015-05-05 00:01:29 +03:00
|
|
|
|
|
|
|
this->SetHomeDirectory("");
|
|
|
|
this->SetHomeOutputDirectory("");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileIsDirectory(dir)) {
|
2008-10-15 21:56:07 +04:00
|
|
|
std::cerr << "Error: " << dir << " is not a directory\n";
|
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-10-15 21:56:07 +04:00
|
|
|
std::string cachePath = dir;
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(cachePath);
|
2015-08-15 07:45:53 +03:00
|
|
|
std::string cacheFile = cachePath;
|
|
|
|
cacheFile += "/CMakeCache.txt";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileExists(cacheFile.c_str())) {
|
2015-08-15 07:45:53 +03:00
|
|
|
// search in parent directories for cache
|
|
|
|
std::string cmakeFiles = cachePath;
|
|
|
|
cmakeFiles += "/CMakeFiles";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileExists(cmakeFiles.c_str())) {
|
2015-08-15 07:45:53 +03:00
|
|
|
std::string cachePathFound =
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::FileExistsInParentDirectories("CMakeCache.txt",
|
|
|
|
cachePath.c_str(), "/");
|
|
|
|
if (!cachePathFound.empty()) {
|
2015-08-15 07:45:53 +03:00
|
|
|
cachePath = cmSystemTools::GetFilenamePath(cachePathFound);
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-08-15 07:45:53 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->LoadCache(cachePath)) {
|
2008-10-15 21:56:07 +04:00
|
|
|
std::cerr << "Error: could not load cache\n";
|
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-05 11:48:04 +03:00
|
|
|
const char* cachedGenerator =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->State->GetCacheEntryValue("CMAKE_GENERATOR");
|
|
|
|
if (!cachedGenerator) {
|
2014-06-03 19:36:25 +04:00
|
|
|
std::cerr << "Error: could not find CMAKE_GENERATOR in Cache\n";
|
2008-10-15 21:56:07 +04:00
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2016-06-28 17:17:52 +03:00
|
|
|
CM_AUTO_PTR<cmGlobalGenerator> gen(
|
2015-04-05 11:48:04 +03:00
|
|
|
this->CreateGlobalGenerator(cachedGenerator));
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!gen.get()) {
|
|
|
|
std::cerr << "Error: could create CMAKE_GENERATOR \"" << cachedGenerator
|
|
|
|
<< "\"\n";
|
2014-06-03 19:36:25 +04:00
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-10-15 21:56:07 +04:00
|
|
|
std::string output;
|
|
|
|
std::string projName;
|
2015-04-05 11:48:04 +03:00
|
|
|
const char* cachedProjectName =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->State->GetCacheEntryValue("CMAKE_PROJECT_NAME");
|
|
|
|
if (!cachedProjectName) {
|
2008-10-15 21:56:07 +04:00
|
|
|
std::cerr << "Error: could not find CMAKE_PROJECT_NAME in Cache\n";
|
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-05 11:48:04 +03:00
|
|
|
projName = cachedProjectName;
|
2015-02-26 13:32:26 +03:00
|
|
|
bool verbose = false;
|
2015-04-05 11:48:04 +03:00
|
|
|
const char* cachedVerbose =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->State->GetCacheEntryValue("CMAKE_VERBOSE_MAKEFILE");
|
|
|
|
if (cachedVerbose) {
|
2015-04-05 11:48:04 +03:00
|
|
|
verbose = cmSystemTools::IsOn(cachedVerbose);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
return gen->Build("", dir, projName, target, output, "", config, clean,
|
|
|
|
false, verbose, 0, cmSystemTools::OUTPUT_PASSTHROUGH,
|
2013-11-15 22:33:32 +04:00
|
|
|
nativeOptions);
|
2008-10-15 21:56:07 +04:00
|
|
|
}
|
2010-09-02 19:29:05 +04:00
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
void cmake::WatchUnusedCli(const std::string& var)
|
2010-09-22 20:42:49 +04:00
|
|
|
{
|
|
|
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
|
|
|
this->VariableWatch->AddWatch(var, cmWarnUnusedCliWarning, this);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->UsedCliVariables.find(var) == this->UsedCliVariables.end()) {
|
2011-03-24 16:44:23 +03:00
|
|
|
this->UsedCliVariables[var] = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-09-22 20:42:49 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
void cmake::UnwatchUnusedCli(const std::string& var)
|
2011-01-14 01:58:04 +03:00
|
|
|
{
|
|
|
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
|
|
|
this->VariableWatch->RemoveWatch(var, cmWarnUnusedCliWarning);
|
2011-03-24 16:44:23 +03:00
|
|
|
this->UsedCliVariables.erase(var);
|
2011-01-14 01:58:04 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-03-24 16:24:27 +03:00
|
|
|
void cmake::RunCheckForUnusedVariables()
|
2010-09-02 19:29:05 +04:00
|
|
|
{
|
|
|
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
2011-03-24 16:24:27 +03:00
|
|
|
bool haveUnused = false;
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream msg;
|
2011-03-24 16:24:27 +03:00
|
|
|
msg << "Manually-specified variables were not used by the project:";
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::map<std::string, bool>::const_iterator it =
|
|
|
|
this->UsedCliVariables.begin();
|
|
|
|
it != this->UsedCliVariables.end(); ++it) {
|
|
|
|
if (!it->second) {
|
2011-03-24 16:24:27 +03:00
|
|
|
haveUnused = true;
|
|
|
|
msg << "\n " << it->first;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (haveUnused) {
|
2014-05-23 22:54:42 +04:00
|
|
|
this->IssueMessage(cmake::WARNING, msg.str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-09-02 19:29:05 +04:00
|
|
|
#endif
|
|
|
|
}
|
2015-11-08 15:59:27 +03:00
|
|
|
|
2016-06-12 19:38:33 +03:00
|
|
|
bool cmake::GetSuppressDevWarnings() const
|
|
|
|
{
|
|
|
|
const char* cacheEntryValue =
|
|
|
|
this->State->GetCacheEntryValue("CMAKE_SUPPRESS_DEVELOPER_WARNINGS");
|
|
|
|
return cmSystemTools::IsOn(cacheEntryValue);
|
2015-12-06 15:58:24 +03:00
|
|
|
}
|
|
|
|
|
2015-11-29 15:39:03 +03:00
|
|
|
void cmake::SetSuppressDevWarnings(bool b)
|
|
|
|
{
|
2015-12-06 15:33:13 +03:00
|
|
|
std::string value;
|
|
|
|
|
2015-11-29 15:39:03 +03:00
|
|
|
// equivalent to -Wno-dev
|
2016-05-16 17:34:04 +03:00
|
|
|
if (b) {
|
2015-12-06 15:33:13 +03:00
|
|
|
value = "TRUE";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-11-29 15:39:03 +03:00
|
|
|
// equivalent to -Wdev
|
2016-05-16 17:34:04 +03:00
|
|
|
else {
|
2015-12-06 15:33:13 +03:00
|
|
|
value = "FALSE";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-12-06 15:33:13 +03:00
|
|
|
|
|
|
|
this->AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", value.c_str(),
|
|
|
|
"Suppress Warnings that are meant for"
|
|
|
|
" the author of the CMakeLists.txt files.",
|
|
|
|
cmState::INTERNAL);
|
2015-11-29 15:39:03 +03:00
|
|
|
}
|
|
|
|
|
2016-06-12 19:38:33 +03:00
|
|
|
bool cmake::GetSuppressDeprecatedWarnings() const
|
2015-11-29 16:34:07 +03:00
|
|
|
{
|
2016-06-12 19:38:33 +03:00
|
|
|
const char* cacheEntryValue =
|
|
|
|
this->State->GetCacheEntryValue("CMAKE_WARN_DEPRECATED");
|
|
|
|
return cacheEntryValue && cmSystemTools::IsOff(cacheEntryValue);
|
2015-11-29 16:34:07 +03:00
|
|
|
}
|
2015-12-06 15:33:13 +03:00
|
|
|
|
|
|
|
void cmake::SetSuppressDeprecatedWarnings(bool b)
|
|
|
|
{
|
|
|
|
std::string value;
|
|
|
|
|
|
|
|
// equivalent to -Wno-deprecated
|
2016-05-16 17:34:04 +03:00
|
|
|
if (b) {
|
2015-12-06 15:33:13 +03:00
|
|
|
value = "FALSE";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-12-06 15:33:13 +03:00
|
|
|
// equivalent to -Wdeprecated
|
2016-05-16 17:34:04 +03:00
|
|
|
else {
|
2015-12-06 15:33:13 +03:00
|
|
|
value = "TRUE";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-12-06 15:33:13 +03:00
|
|
|
|
|
|
|
this->AddCacheEntry("CMAKE_WARN_DEPRECATED", value.c_str(),
|
|
|
|
"Whether to issue warnings for deprecated "
|
|
|
|
"functionality.",
|
|
|
|
cmState::INTERNAL);
|
|
|
|
}
|
2015-12-22 00:39:27 +03:00
|
|
|
|
2016-06-12 19:38:33 +03:00
|
|
|
bool cmake::GetDevWarningsAsErrors() const
|
2015-12-22 00:39:27 +03:00
|
|
|
{
|
2016-06-12 19:38:33 +03:00
|
|
|
const char* cacheEntryValue =
|
|
|
|
this->State->GetCacheEntryValue("CMAKE_SUPPRESS_DEVELOPER_ERRORS");
|
|
|
|
return cacheEntryValue && cmSystemTools::IsOff(cacheEntryValue);
|
2015-12-22 00:39:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmake::SetDevWarningsAsErrors(bool b)
|
|
|
|
{
|
|
|
|
std::string value;
|
|
|
|
|
|
|
|
// equivalent to -Werror=dev
|
2016-05-16 17:34:04 +03:00
|
|
|
if (b) {
|
2015-12-22 00:39:27 +03:00
|
|
|
value = "FALSE";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-12-22 00:39:27 +03:00
|
|
|
// equivalent to -Wno-error=dev
|
2016-05-16 17:34:04 +03:00
|
|
|
else {
|
2015-12-22 00:39:27 +03:00
|
|
|
value = "TRUE";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-12-22 00:39:27 +03:00
|
|
|
|
|
|
|
this->AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_ERRORS", value.c_str(),
|
|
|
|
"Suppress errors that are meant for"
|
|
|
|
" the author of the CMakeLists.txt files.",
|
|
|
|
cmState::INTERNAL);
|
|
|
|
}
|
|
|
|
|
2016-06-12 19:38:33 +03:00
|
|
|
bool cmake::GetDeprecatedWarningsAsErrors() const
|
2015-12-22 00:39:27 +03:00
|
|
|
{
|
2016-06-12 19:38:33 +03:00
|
|
|
const char* cacheEntryValue =
|
|
|
|
this->State->GetCacheEntryValue("CMAKE_ERROR_DEPRECATED");
|
|
|
|
return cmSystemTools::IsOn(cacheEntryValue);
|
2015-12-22 00:39:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmake::SetDeprecatedWarningsAsErrors(bool b)
|
|
|
|
{
|
|
|
|
std::string value;
|
|
|
|
|
|
|
|
// equivalent to -Werror=deprecated
|
2016-05-16 17:34:04 +03:00
|
|
|
if (b) {
|
2015-12-22 00:39:27 +03:00
|
|
|
value = "TRUE";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-12-22 00:39:27 +03:00
|
|
|
// equivalent to -Wno-error=deprecated
|
2016-05-16 17:34:04 +03:00
|
|
|
else {
|
2015-12-22 00:39:27 +03:00
|
|
|
value = "FALSE";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-12-22 00:39:27 +03:00
|
|
|
|
|
|
|
this->AddCacheEntry("CMAKE_ERROR_DEPRECATED", value.c_str(),
|
|
|
|
"Whether to issue deprecation errors for macros"
|
|
|
|
" and functions.",
|
|
|
|
cmState::INTERNAL);
|
|
|
|
}
|