Merge topic 'cmake-internal-info'

4db08807 CMake: Report whether generators support platforms
43a68a6d cmGlobalGeneratorFactory: Use CM_OVERRIDE for all derived classes
af0e1cd4 Make CMake version dirty state available to code
6a077b5d Make CMake version suffix available to code
This commit is contained in:
Brad King 2016-07-15 09:04:24 -04:00 committed by CMake Topic Stage
commit c59ec2b7c8
17 changed files with 92 additions and 40 deletions

View File

@ -3,6 +3,7 @@ include(${CMake_SOURCE_DIR}/Source/CMakeVersion.cmake)
# Releases define a small patch level.
if("${CMake_VERSION_PATCH}" VERSION_LESS 20000000)
set(CMake_VERSION_IS_DIRTY 0)
set(CMake_VERSION_IS_RELEASE 1)
set(CMake_VERSION_SOURCE "")
else()
@ -12,9 +13,16 @@ endif()
# Compute the full version string.
set(CMake_VERSION ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH})
if(CMake_VERSION_RC)
set(CMake_VERSION ${CMake_VERSION}-rc${CMake_VERSION_RC})
endif()
if(CMake_VERSION_SOURCE)
set(CMake_VERSION ${CMake_VERSION}-${CMake_VERSION_SOURCE})
set(CMake_VERSION_SUFFIX "${CMake_VERSION_SOURCE}")
elseif(CMake_VERSION_RC)
set(CMake_VERSION_SUFFIX "rc${CMake_VERSION_RC}")
else()
set(CMake_VERSION_SUFFIX "")
endif()
if(CMake_VERSION_SUFFIX)
set(CMake_VERSION ${CMake_VERSION}-${CMake_VERSION_SUFFIX})
endif()
if(CMake_VERSION_IS_DIRTY)
set(CMake_VERSION ${CMake_VERSION}-dirty)
endif()

View File

@ -23,7 +23,9 @@ if(EXISTS ${CMake_SOURCE_DIR}/.git/HEAD)
WORKING_DIRECTORY ${CMake_SOURCE_DIR}
)
if(dirty)
set(CMake_VERSION_SOURCE "${CMake_VERSION_SOURCE}-dirty")
set(CMake_VERSION_IS_DIRTY 1)
else()
set(CMake_VERSION_IS_DIRTY 0)
endif()
endif()
endif()

View File

@ -41,6 +41,9 @@ public:
/** Determine whether or not this generator supports toolsets */
virtual bool SupportsToolset() const = 0;
/** Determine whether or not this generator supports platforms */
virtual bool SupportsPlatform() const = 0;
};
template <class T>
@ -71,6 +74,9 @@ public:
/** Determine whether or not this generator supports toolsets */
bool SupportsToolset() const CM_OVERRIDE { return T::SupportsToolset(); }
/** Determine whether or not this generator supports platforms */
bool SupportsPlatform() const CM_OVERRIDE { return T::SupportsPlatform(); }
};
#endif

View File

@ -51,6 +51,12 @@ public:
*/
static bool SupportsToolset() { return false; }
/**
* Utilized by the generator factory to determine if this generator
* supports platforms.
*/
static bool SupportsPlatform() { return false; }
/**
* Try to determine system information such as shared library
* extension, pthreads, byte order etc.

View File

@ -80,6 +80,12 @@ public:
*/
static bool SupportsToolset() { return false; }
/**
* Utilized by the generator factory to determine if this generator
* supports platforms.
*/
static bool SupportsPlatform() { return false; }
/**
* Write a build statement to @a os with the @a comment using
* the @a rule the list of @a outputs files and inputs.

View File

@ -75,6 +75,12 @@ public:
*/
static bool SupportsToolset() { return false; }
/**
* Utilized by the generator factory to determine if this generator
* supports platforms.
*/
static bool SupportsPlatform() { return false; }
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);

View File

@ -42,8 +42,8 @@ class cmGlobalVisualStudio10Generator::Factory
: public cmGlobalGeneratorFactory
{
public:
virtual cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
cmake* cm) const
cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
cmake* cm) const CM_OVERRIDE
{
std::string genName;
const char* p = cmVS10GenName(name, genName);
@ -65,21 +65,22 @@ public:
return 0;
}
virtual void GetDocumentation(cmDocumentationEntry& entry) const
void GetDocumentation(cmDocumentationEntry& entry) const CM_OVERRIDE
{
entry.Name = std::string(vs10generatorName) + " [arch]";
entry.Brief = "Generates Visual Studio 2010 project files. "
"Optional [arch] can be \"Win64\" or \"IA64\".";
}
virtual void GetGenerators(std::vector<std::string>& names) const
void GetGenerators(std::vector<std::string>& names) const CM_OVERRIDE
{
names.push_back(vs10generatorName);
names.push_back(vs10generatorName + std::string(" IA64"));
names.push_back(vs10generatorName + std::string(" Win64"));
}
virtual bool SupportsToolset() const { return true; }
bool SupportsToolset() const CM_OVERRIDE { return true; }
bool SupportsPlatform() const CM_OVERRIDE { return true; }
};
cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory()

View File

@ -36,8 +36,8 @@ class cmGlobalVisualStudio11Generator::Factory
: public cmGlobalGeneratorFactory
{
public:
virtual cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
cmake* cm) const
cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
cmake* cm) const CM_OVERRIDE
{
std::string genName;
const char* p = cmVS11GenName(name, genName);
@ -70,14 +70,14 @@ public:
return ret;
}
virtual void GetDocumentation(cmDocumentationEntry& entry) const
void GetDocumentation(cmDocumentationEntry& entry) const CM_OVERRIDE
{
entry.Name = std::string(vs11generatorName) + " [arch]";
entry.Brief = "Generates Visual Studio 2012 project files. "
"Optional [arch] can be \"Win64\" or \"ARM\".";
}
virtual void GetGenerators(std::vector<std::string>& names) const
void GetGenerators(std::vector<std::string>& names) const CM_OVERRIDE
{
names.push_back(vs11generatorName);
names.push_back(vs11generatorName + std::string(" ARM"));
@ -91,7 +91,8 @@ public:
}
}
virtual bool SupportsToolset() const { return true; }
bool SupportsToolset() const CM_OVERRIDE { return true; }
bool SupportsPlatform() const CM_OVERRIDE { return true; }
};
cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory()

View File

@ -36,8 +36,8 @@ class cmGlobalVisualStudio12Generator::Factory
: public cmGlobalGeneratorFactory
{
public:
virtual cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
cmake* cm) const
cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
cmake* cm) const CM_OVERRIDE
{
std::string genName;
const char* p = cmVS12GenName(name, genName);
@ -59,21 +59,22 @@ public:
return 0;
}
virtual void GetDocumentation(cmDocumentationEntry& entry) const
void GetDocumentation(cmDocumentationEntry& entry) const CM_OVERRIDE
{
entry.Name = std::string(vs12generatorName) + " [arch]";
entry.Brief = "Generates Visual Studio 2013 project files. "
"Optional [arch] can be \"Win64\" or \"ARM\".";
}
virtual void GetGenerators(std::vector<std::string>& names) const
void GetGenerators(std::vector<std::string>& names) const CM_OVERRIDE
{
names.push_back(vs12generatorName);
names.push_back(vs12generatorName + std::string(" ARM"));
names.push_back(vs12generatorName + std::string(" Win64"));
}
virtual bool SupportsToolset() const { return true; }
bool SupportsToolset() const CM_OVERRIDE { return true; }
bool SupportsPlatform() const CM_OVERRIDE { return true; }
};
cmGlobalGeneratorFactory* cmGlobalVisualStudio12Generator::NewFactory()

View File

@ -36,8 +36,8 @@ class cmGlobalVisualStudio14Generator::Factory
: public cmGlobalGeneratorFactory
{
public:
virtual cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
cmake* cm) const
cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
cmake* cm) const CM_OVERRIDE
{
std::string genName;
const char* p = cmVS14GenName(name, genName);
@ -59,21 +59,22 @@ public:
return 0;
}
virtual void GetDocumentation(cmDocumentationEntry& entry) const
void GetDocumentation(cmDocumentationEntry& entry) const CM_OVERRIDE
{
entry.Name = std::string(vs14generatorName) + " [arch]";
entry.Brief = "Generates Visual Studio 2015 project files. "
"Optional [arch] can be \"Win64\" or \"ARM\".";
}
virtual void GetGenerators(std::vector<std::string>& names) const
void GetGenerators(std::vector<std::string>& names) const CM_OVERRIDE
{
names.push_back(vs14generatorName);
names.push_back(vs14generatorName + std::string(" ARM"));
names.push_back(vs14generatorName + std::string(" Win64"));
}
virtual bool SupportsToolset() const { return true; }
bool SupportsToolset() const CM_OVERRIDE { return true; }
bool SupportsPlatform() const CM_OVERRIDE { return true; }
};
cmGlobalGeneratorFactory* cmGlobalVisualStudio14Generator::NewFactory()

View File

@ -47,6 +47,12 @@ public:
*/
static bool SupportsToolset() { return false; }
/**
* Utilized by the generator factory to determine if this generator
* supports platforms.
*/
static bool SupportsPlatform() { return false; }
/**
* Try to determine system information such as shared library
* extension, pthreads, byte order etc.

View File

@ -25,8 +25,8 @@ static const char vs8generatorName[] = "Visual Studio 8 2005";
class cmGlobalVisualStudio8Generator::Factory : public cmGlobalGeneratorFactory
{
public:
virtual cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
cmake* cm) const
cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
cmake* cm) const CM_OVERRIDE
{
if (strncmp(name.c_str(), vs8generatorName,
sizeof(vs8generatorName) - 1) != 0) {
@ -60,14 +60,14 @@ public:
return ret;
}
virtual void GetDocumentation(cmDocumentationEntry& entry) const
void GetDocumentation(cmDocumentationEntry& entry) const CM_OVERRIDE
{
entry.Name = std::string(vs8generatorName) + " [arch]";
entry.Brief = "Generates Visual Studio 2005 project files. "
"Optional [arch] can be \"Win64\".";
}
virtual void GetGenerators(std::vector<std::string>& names) const
void GetGenerators(std::vector<std::string>& names) const CM_OVERRIDE
{
names.push_back(vs8generatorName);
names.push_back(vs8generatorName + std::string(" Win64"));
@ -82,7 +82,8 @@ public:
}
}
virtual bool SupportsToolset() const { return false; }
bool SupportsToolset() const CM_OVERRIDE { return false; }
bool SupportsPlatform() const CM_OVERRIDE { return true; }
};
cmGlobalGeneratorFactory* cmGlobalVisualStudio8Generator::NewFactory()

View File

@ -23,8 +23,8 @@ static const char vs9generatorName[] = "Visual Studio 9 2008";
class cmGlobalVisualStudio9Generator::Factory : public cmGlobalGeneratorFactory
{
public:
virtual cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
cmake* cm) const
cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
cmake* cm) const CM_OVERRIDE
{
if (strncmp(name.c_str(), vs9generatorName,
sizeof(vs9generatorName) - 1) != 0) {
@ -62,14 +62,14 @@ public:
return ret;
}
virtual void GetDocumentation(cmDocumentationEntry& entry) const
void GetDocumentation(cmDocumentationEntry& entry) const CM_OVERRIDE
{
entry.Name = std::string(vs9generatorName) + " [arch]";
entry.Brief = "Generates Visual Studio 2008 project files. "
"Optional [arch] can be \"Win64\" or \"IA64\".";
}
virtual void GetGenerators(std::vector<std::string>& names) const
void GetGenerators(std::vector<std::string>& names) const CM_OVERRIDE
{
names.push_back(vs9generatorName);
names.push_back(vs9generatorName + std::string(" Win64"));
@ -85,7 +85,8 @@ public:
}
}
virtual bool SupportsToolset() const { return false; }
bool SupportsToolset() const CM_OVERRIDE { return false; }
bool SupportsPlatform() const CM_OVERRIDE { return true; }
};
cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory()

View File

@ -108,20 +108,21 @@ public:
class cmGlobalXCodeGenerator::Factory : public cmGlobalGeneratorFactory
{
public:
virtual cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
cmake* cm) const;
cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
cmake* cm) const CM_OVERRIDE;
virtual void GetDocumentation(cmDocumentationEntry& entry) const
void GetDocumentation(cmDocumentationEntry& entry) const CM_OVERRIDE
{
cmGlobalXCodeGenerator::GetDocumentation(entry);
}
virtual void GetGenerators(std::vector<std::string>& names) const
void GetGenerators(std::vector<std::string>& names) const CM_OVERRIDE
{
names.push_back(cmGlobalXCodeGenerator::GetActualName());
}
virtual bool SupportsToolset() const { return true; }
bool SupportsToolset() const CM_OVERRIDE { return true; }
bool SupportsPlatform() const CM_OVERRIDE { return false; }
};
cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(cmake* cm,

View File

@ -12,4 +12,6 @@
#define CMake_VERSION_MAJOR @CMake_VERSION_MAJOR@
#define CMake_VERSION_MINOR @CMake_VERSION_MINOR@
#define CMake_VERSION_PATCH @CMake_VERSION_PATCH@
#define CMake_VERSION_SUFFIX "@CMake_VERSION_SUFFIX@"
#define CMake_VERSION_IS_DIRTY @CMake_VERSION_IS_DIRTY@
#define CMake_VERSION "@CMake_VERSION@"

View File

@ -853,6 +853,7 @@ void cmake::GetRegisteredGenerators(std::vector<GeneratorInfo>& generators)
for (size_t j = 0; j < names.size(); ++j) {
GeneratorInfo info;
info.supportsToolset = (*i)->SupportsToolset();
info.supportsPlatform = (*i)->SupportsPlatform();
info.name = names[j];
generators.push_back(info);
}
@ -865,6 +866,7 @@ void cmake::GetRegisteredGenerators(std::vector<GeneratorInfo>& generators)
GeneratorInfo info;
info.name = i->first;
info.supportsToolset = false;
info.supportsPlatform = false;
generators.push_back(info);
}
}

View File

@ -104,6 +104,7 @@ public:
{
std::string name;
bool supportsToolset;
bool supportsPlatform;
};
typedef std::map<std::string, cmInstalledFile> InstalledFilesMap;