2016-09-27 15:01:08 -04:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2009-07-29 11:29:08 -04:00
|
|
|
#ifndef cmIDEOptions_h
|
|
|
|
#define cmIDEOptions_h
|
|
|
|
|
2017-08-25 20:39:02 +02:00
|
|
|
#include "cmConfigure.h" // IWYU pragma: keep
|
2016-09-01 20:05:48 +02:00
|
|
|
|
2016-11-25 22:54:58 +01:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2016-04-29 09:40:20 -04:00
|
|
|
|
2016-11-25 22:54:58 +01:00
|
|
|
struct cmIDEFlagTable;
|
2009-07-29 11:29:08 -04:00
|
|
|
|
|
|
|
/** \class cmIDEOptions
|
|
|
|
* \brief Superclass for IDE option processing
|
|
|
|
*/
|
|
|
|
class cmIDEOptions
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cmIDEOptions();
|
|
|
|
virtual ~cmIDEOptions();
|
|
|
|
|
2017-12-19 16:03:41 +01:00
|
|
|
// Store definitions, includes and flags.
|
2009-07-29 11:29:08 -04:00
|
|
|
void AddDefine(const std::string& define);
|
2018-02-26 11:24:45 -05:00
|
|
|
void AddDefines(std::string const& defines);
|
2016-05-16 10:34:04 -04:00
|
|
|
void AddDefines(const std::vector<std::string>& defines);
|
2017-03-28 12:55:14 -04:00
|
|
|
std::vector<std::string> const& GetDefines() const;
|
|
|
|
|
2017-12-19 16:03:41 +01:00
|
|
|
void AddInclude(const std::string& includes);
|
2018-02-26 11:24:45 -05:00
|
|
|
void AddIncludes(std::string const& includes);
|
2017-12-19 16:03:41 +01:00
|
|
|
void AddIncludes(const std::vector<std::string>& includes);
|
|
|
|
std::vector<std::string> const& GetIncludes() const;
|
|
|
|
|
2017-12-08 22:30:16 -05:00
|
|
|
void AddFlag(std::string const& flag, std::string const& value);
|
|
|
|
void AddFlag(std::string const& flag, std::vector<std::string> const& value);
|
2014-07-31 14:02:03 -04:00
|
|
|
void AppendFlag(std::string const& flag, std::string const& value);
|
2014-08-13 13:39:35 -04:00
|
|
|
void AppendFlag(std::string const& flag,
|
|
|
|
std::vector<std::string> const& value);
|
2017-02-15 09:35:36 -05:00
|
|
|
void AppendFlagString(std::string const& flag, std::string const& value);
|
2017-12-08 22:30:16 -05:00
|
|
|
void RemoveFlag(std::string const& flag);
|
2014-08-13 14:07:07 -04:00
|
|
|
bool HasFlag(std::string const& flag) const;
|
2017-12-08 22:30:16 -05:00
|
|
|
const char* GetFlag(std::string const& flag) const;
|
2009-07-29 11:29:08 -04: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-05-16 10:34:04 -04:00
|
|
|
class FlagValue : public std::vector<std::string>
|
2014-07-23 11:13:13 -04:00
|
|
|
{
|
|
|
|
typedef std::vector<std::string> derived;
|
2016-05-16 10:34:04 -04:00
|
|
|
|
2014-07-23 11:13:13 -04:00
|
|
|
public:
|
|
|
|
FlagValue& operator=(std::string const& r)
|
2016-05-16 10:34:04 -04:00
|
|
|
{
|
2014-07-23 11:13:13 -04:00
|
|
|
this->resize(1);
|
|
|
|
this->operator[](0) = r;
|
|
|
|
return *this;
|
2016-05-16 10:34:04 -04:00
|
|
|
}
|
2014-07-23 11:13:13 -04:00
|
|
|
FlagValue& operator=(std::vector<std::string> const& r)
|
2016-05-16 10:34:04 -04:00
|
|
|
{
|
2014-07-23 11:13:13 -04:00
|
|
|
this->derived::operator=(r);
|
|
|
|
return *this;
|
2016-05-16 10:34:04 -04:00
|
|
|
}
|
2019-02-05 15:12:38 -08:00
|
|
|
FlagValue& append_with_comma(std::string const& r)
|
|
|
|
{
|
|
|
|
return append_with_separator(r, ',');
|
|
|
|
}
|
2017-02-15 09:35:36 -05:00
|
|
|
FlagValue& append_with_space(std::string const& r)
|
2019-02-05 15:12:38 -08:00
|
|
|
{
|
|
|
|
return append_with_separator(r, ' ');
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
FlagValue& append_with_separator(std::string const& r, char separator)
|
2017-02-15 09:35:36 -05:00
|
|
|
{
|
|
|
|
this->resize(1);
|
|
|
|
std::string& l = this->operator[](0);
|
|
|
|
if (!l.empty()) {
|
2019-02-05 15:12:38 -08:00
|
|
|
l += separator;
|
2017-02-15 09:35:36 -05:00
|
|
|
}
|
|
|
|
l += r;
|
|
|
|
return *this;
|
|
|
|
}
|
2014-07-23 11:13:13 -04:00
|
|
|
};
|
2016-05-16 10:34:04 -04:00
|
|
|
std::map<std::string, FlagValue> FlagMap;
|
2009-07-29 11:29:08 -04:00
|
|
|
|
|
|
|
// Preprocessor definitions.
|
|
|
|
std::vector<std::string> Defines;
|
|
|
|
|
2017-12-19 16:03:41 +01:00
|
|
|
// Include directories.
|
|
|
|
std::vector<std::string> Includes;
|
|
|
|
|
2009-07-29 11:29:08 -04:00
|
|
|
bool DoingDefine;
|
|
|
|
bool AllowDefine;
|
2017-12-19 16:03:41 +01:00
|
|
|
bool DoingInclude;
|
|
|
|
bool AllowInclude;
|
2009-07-29 11:29:08 -04:00
|
|
|
bool AllowSlash;
|
2014-04-01 14:56:08 -04:00
|
|
|
cmIDEFlagTable const* DoingFollowing;
|
2016-05-16 10:34:04 -04:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
FlagTableCount = 16
|
|
|
|
};
|
2009-07-29 11:29:08 -04:00
|
|
|
cmIDEFlagTable const* FlagTable[FlagTableCount];
|
2018-02-26 11:24:45 -05:00
|
|
|
void HandleFlag(std::string const& flag);
|
|
|
|
bool CheckFlagTable(cmIDEFlagTable const* table, std::string const& flag,
|
2009-07-29 11:29:08 -04:00
|
|
|
bool& flag_handled);
|
2018-02-26 11:24:45 -05:00
|
|
|
void FlagMapUpdate(cmIDEFlagTable const* entry,
|
|
|
|
std::string const& new_value);
|
|
|
|
virtual void StoreUnknownFlag(std::string const& flag) = 0;
|
2009-07-29 11:29:08 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|