cmake/Source/cmIDEOptions.h

96 lines
2.7 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2009-10-04 10:30:41 +03:00
#ifndef cmIDEOptions_h
#define cmIDEOptions_h
2017-07-20 19:35:53 +02:00
#include "cmConfigure.h"
2016-10-30 18:24:19 +01:00
2017-04-14 19:02:05 +02:00
#include <map>
#include <string>
#include <vector>
2016-07-09 11:21:54 +02:00
2017-04-14 19:02:05 +02:00
struct cmIDEFlagTable;
2009-10-04 10:30:41 +03:00
/** \class cmIDEOptions
* \brief Superclass for IDE option processing
*/
class cmIDEOptions
{
public:
cmIDEOptions();
virtual ~cmIDEOptions();
// Store definitions and flags.
void AddDefine(const std::string& define);
void AddDefines(const char* defines);
2016-07-09 11:21:54 +02:00
void AddDefines(const std::vector<std::string>& defines);
2017-04-14 19:02:05 +02:00
std::vector<std::string> const& GetDefines() const;
2009-10-04 10:30:41 +03:00
void AddFlag(const char* flag, const char* value);
2015-04-27 22:25:09 +02:00
void AddFlag(const char* flag, std::vector<std::string> const& value);
void AppendFlag(std::string const& flag, std::string const& value);
void AppendFlag(std::string const& flag,
std::vector<std::string> const& value);
2017-07-20 19:35:53 +02:00
void AppendFlagString(std::string const& flag, std::string const& value);
2011-06-19 15:41:06 +03:00
void RemoveFlag(const char* flag);
2015-04-27 22:25:09 +02:00
bool HasFlag(std::string const& flag) const;
2013-03-16 19:13:01 +02:00
const char* GetFlag(const char* flag);
2009-10-04 10:30:41 +03:00
protected:
// create a map of xml tags to the values they should have in the output
// for example, "BufferSecurityCheck" = "TRUE"
// first fill this table with the values for the configuration
// Debug, Release, etc,
// Then parse the command line flags specified in CMAKE_CXX_FLAGS
// and CMAKE_C_FLAGS
// and overwrite or add new values to this map
2016-07-09 11:21:54 +02:00
class FlagValue : public std::vector<std::string>
2015-04-27 22:25:09 +02:00
{
typedef std::vector<std::string> derived;
2016-07-09 11:21:54 +02:00
2015-04-27 22:25:09 +02:00
public:
FlagValue& operator=(std::string const& r)
2016-07-09 11:21:54 +02:00
{
2015-04-27 22:25:09 +02:00
this->resize(1);
this->operator[](0) = r;
return *this;
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
FlagValue& operator=(std::vector<std::string> const& r)
2016-07-09 11:21:54 +02:00
{
2015-04-27 22:25:09 +02:00
this->derived::operator=(r);
return *this;
2016-07-09 11:21:54 +02:00
}
2017-07-20 19:35:53 +02:00
FlagValue& append_with_space(std::string const& r)
{
this->resize(1);
std::string& l = this->operator[](0);
if (!l.empty()) {
l += " ";
}
l += r;
return *this;
}
2015-04-27 22:25:09 +02:00
};
2016-07-09 11:21:54 +02:00
std::map<std::string, FlagValue> FlagMap;
2009-10-04 10:30:41 +03:00
// Preprocessor definitions.
std::vector<std::string> Defines;
bool DoingDefine;
bool AllowDefine;
bool AllowSlash;
2015-04-27 22:25:09 +02:00
cmIDEFlagTable const* DoingFollowing;
2016-07-09 11:21:54 +02:00
enum
{
FlagTableCount = 16
};
2009-10-04 10:30:41 +03:00
cmIDEFlagTable const* FlagTable[FlagTableCount];
void HandleFlag(const char* flag);
bool CheckFlagTable(cmIDEFlagTable const* table, const char* flag,
bool& flag_handled);
2015-04-27 22:25:09 +02:00
void FlagMapUpdate(cmIDEFlagTable const* entry, const char* new_value);
2009-10-04 10:30:41 +03:00
virtual void StoreUnknownFlag(const char* flag) = 0;
};
#endif