CMake/Source/cmIDEOptions.h

117 lines
3.4 KiB
C
Raw Normal View History

Simplify CMake per-source license notices Per-source copyright/license notice headers that spell out copyright holder names and years are hard to maintain and often out-of-date or plain wrong. Precise contributor information is already maintained automatically by the version control tool. Ultimately it is the receiver of a file who is responsible for determining its licensing status, and per-source notices are merely a convenience. Therefore it is simpler and more accurate for each source to have a generic notice of the license name and references to more detailed information on copyright holders and full license terms. Our `Copyright.txt` file now contains a list of Contributors whose names appeared source-level copyright notices. It also references version control history for more precise information. Therefore we no longer need to spell out the list of Contributors in each source file notice. Replace CMake per-source copyright/license notice headers with a short description of the license and links to `Copyright.txt` and online information available from "https://cmake.org/licensing". The online URL also handles cases of modules being copied out of our source into other projects, so we can drop our notices about replacing links with full license text. Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority of the replacements mechanically. Manually fix up shebang lines and trailing newlines in a few files. Manually update the notices in a few files that the script does not handle.
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. */
#ifndef cmIDEOptions_h
#define cmIDEOptions_h
#include "cmConfigure.h" // IWYU pragma: keep
2016-11-25 22:54:58 +01:00
#include <map>
#include <string>
#include <vector>
2016-11-25 22:54:58 +01:00
struct cmIDEFlagTable;
/** \class cmIDEOptions
* \brief Superclass for IDE option processing
*/
class cmIDEOptions
{
public:
cmIDEOptions();
virtual ~cmIDEOptions();
// Store definitions, includes and flags.
void AddDefine(const std::string& define);
2018-02-26 11:24:45 -05:00
void AddDefines(std::string const& defines);
void AddDefines(const std::vector<std::string>& defines);
2017-03-28 12:55:14 -04:00
std::vector<std::string> const& GetDefines() const;
void AddInclude(const std::string& includes);
2018-02-26 11:24:45 -05:00
void AddIncludes(std::string const& includes);
void AddIncludes(const std::vector<std::string>& includes);
std::vector<std::string> const& GetIncludes() const;
void AddFlag(std::string const& flag, std::string const& value);
void AddFlag(std::string const& 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);
void AppendFlagString(std::string const& flag, std::string const& value);
void RemoveFlag(std::string const& flag);
bool HasFlag(std::string const& flag) const;
const char* GetFlag(std::string const& flag) const;
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
class FlagValue : public std::vector<std::string>
{
typedef std::vector<std::string> derived;
public:
FlagValue& operator=(std::string const& r)
{
this->resize(1);
this->operator[](0) = r;
return *this;
}
FlagValue& operator=(std::vector<std::string> const& r)
{
this->derived::operator=(r);
return *this;
}
FlagValue& append_with_comma(std::string const& r)
{
return append_with_separator(r, ',');
}
FlagValue& append_with_space(std::string const& r)
{
return append_with_separator(r, ' ');
}
private:
FlagValue& append_with_separator(std::string const& r, char separator)
{
this->resize(1);
std::string& l = this->operator[](0);
if (!l.empty()) {
l += separator;
}
l += r;
return *this;
}
};
std::map<std::string, FlagValue> FlagMap;
// Preprocessor definitions.
std::vector<std::string> Defines;
// Include directories.
std::vector<std::string> Includes;
bool DoingDefine;
bool AllowDefine;
bool DoingInclude;
bool AllowInclude;
bool AllowSlash;
cmIDEFlagTable const* DoingFollowing;
enum
{
FlagTableCount = 16
};
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,
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;
};
#endif