build: support clang-cl
This commit is contained in:
parent
f916fe3c6a
commit
d763b2e336
|
|
@ -1,4 +1,4 @@
|
|||
cmake_minimum_required (VERSION 3.0)
|
||||
cmake_minimum_required (VERSION 3.14)
|
||||
cmake_policy(SET CMP0028 NEW)
|
||||
|
||||
project (ericw-tools)
|
||||
|
|
@ -14,6 +14,11 @@ execute_process(
|
|||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
|
||||
add_compile_options(/EHsc)
|
||||
message(STATUS "working around exceptions not being enabled by default on clang-cl")
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
"${CMAKE_SOURCE_DIR}/include"
|
||||
"${CMAKE_SOURCE_DIR}/3rdparty/glm")
|
||||
|
|
@ -75,10 +80,6 @@ if (ERICWTOOLS_ASAN)
|
|||
add_link_options(-fsanitize=address)
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
|
||||
add_compile_options(/EHsc)
|
||||
endif()
|
||||
|
||||
# 10.9: minimum version that supports unordered_map
|
||||
# 10.14: required by tbb 2021.3.0 (due to use of alignas)
|
||||
# 10.15: required by std::filesytstem
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm> // for std::min
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
|
@ -765,7 +766,7 @@ protected:
|
|||
return traits_type::eof();
|
||||
}
|
||||
|
||||
ptrdiff_t free_space = epptr() - pptr();
|
||||
std::streamsize free_space = epptr() - pptr();
|
||||
std::streamsize num_write = std::min(free_space, n);
|
||||
|
||||
memcpy(pptr(), s, n);
|
||||
|
|
@ -783,7 +784,7 @@ protected:
|
|||
return traits_type::eof();
|
||||
}
|
||||
|
||||
ptrdiff_t free_space = egptr() - gptr();
|
||||
std::streamsize free_space = egptr() - gptr();
|
||||
std::streamsize num_read = std::min(free_space, n);
|
||||
|
||||
memcpy(s, gptr(), n);
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ inline void print(const char *fmt, const Args &...args)
|
|||
|
||||
// TODO: C++20 source_location
|
||||
#ifdef _MSC_VER
|
||||
#define funcprint(fmt, ...) print(__FUNCTION__ ": " fmt, ##__VA_ARGS__)
|
||||
#define funcprint(fmt, ...) print("{}: " fmt, __FUNCTION__, ##__VA_ARGS__)
|
||||
#else
|
||||
#define funcprint(fmt, ...) print("{}: " fmt, __func__, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -393,29 +393,28 @@ protected:
|
|||
virtual void setValueInternal(T f, source newsource) override
|
||||
{
|
||||
if (f < _min) {
|
||||
logging::print("WARNING: '{}': {} is less than minimum value {}.\n", primaryName(), f, _min);
|
||||
logging::print("WARNING: '{}': {} is less than minimum value {}.\n", this->primaryName(), f, _min);
|
||||
f = _min;
|
||||
}
|
||||
if (f > _max) {
|
||||
logging::print("WARNING: '{}': {} is greater than maximum value {}.\n", primaryName(), f, _max);
|
||||
logging::print("WARNING: '{}': {} is greater than maximum value {}.\n", this->primaryName(), f, _max);
|
||||
f = _max;
|
||||
}
|
||||
|
||||
setting_value::setValueInternal(f, newsource);
|
||||
this->setting_value<T>::setValueInternal(f, newsource);
|
||||
}
|
||||
|
||||
public:
|
||||
inline setting_numeric(setting_container *dictionary, const nameset &names, T v, T minval, T maxval,
|
||||
const setting_group *group = nullptr, const char *description = "")
|
||||
: setting_value(dictionary, names, v, group, description), _min(minval), _max(maxval)
|
||||
: setting_value<T>(dictionary, names, v, group, description), _min(minval), _max(maxval)
|
||||
{
|
||||
// check the default value is valid
|
||||
Q_assert(_min < _max);
|
||||
Q_assert(_value >= _min);
|
||||
Q_assert(_value <= _max);
|
||||
Q_assert(this->_value >= _min);
|
||||
Q_assert(this->_value <= _max);
|
||||
}
|
||||
|
||||
template<typename = std::enable_if_t<!std::is_enum_v<T>>>
|
||||
inline setting_numeric(setting_container *dictionary, const nameset &names, T v,
|
||||
const setting_group *group = nullptr, const char *description = "")
|
||||
: setting_numeric(
|
||||
|
|
@ -423,10 +422,9 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
template<typename = std::enable_if_t<!std::is_enum_v<T>>>
|
||||
inline bool boolValue() const
|
||||
{
|
||||
return _value > 0;
|
||||
return this->_value > 0;
|
||||
}
|
||||
|
||||
virtual bool parse(const std::string &settingName, parser_base_t &parser, bool locked = false) override
|
||||
|
|
@ -444,7 +442,7 @@ public:
|
|||
f = static_cast<T>(std::stoull(parser.token));
|
||||
}
|
||||
|
||||
setValueFromParse(f, locked);
|
||||
this->setValueFromParse(f, locked);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -453,7 +451,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual std::string stringValue() const override { return std::to_string(_value); }
|
||||
virtual std::string stringValue() const override { return std::to_string(this->_value); }
|
||||
|
||||
virtual std::string format() const override { return "n"; }
|
||||
};
|
||||
|
|
@ -471,7 +469,7 @@ public:
|
|||
inline setting_enum(setting_container *dictionary, const nameset &names, T v,
|
||||
const std::initializer_list<std::pair<const char *, T>> &enumValues, const setting_group *group = nullptr,
|
||||
const char *description = "")
|
||||
: setting_value(dictionary, names, v, group, description), _values(enumValues.begin(), enumValues.end())
|
||||
: setting_value<T>(dictionary, names, v, group, description), _values(enumValues.begin(), enumValues.end())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -690,7 +688,8 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
setting->parse(name, parser_t{value}, locked);
|
||||
parser_t p{value};
|
||||
setting->parse(name, p, locked);
|
||||
}
|
||||
|
||||
inline void setSettings(const entdict_t &epairs, bool locked)
|
||||
|
|
@ -747,7 +746,10 @@ public:
|
|||
// before the parsing routine; set up options, members, etc
|
||||
virtual void preinitialize(int argc, const char **argv) { setParameters(argc, argv); }
|
||||
// do the actual parsing
|
||||
virtual void initialize(int argc, const char **argv) { parse(token_parser_t(argc, argv)); }
|
||||
virtual void initialize(int argc, const char **argv) {
|
||||
token_parser_t p(argc, argv);
|
||||
parse(p);
|
||||
}
|
||||
// after parsing has concluded, handle the side effects
|
||||
virtual void postinitialize(int argc, const char **argv);
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public:
|
|||
settings::setting_numeric<light_formula_t> formula{this, "delay", LF_LINEAR, LF_LINEAR, LF_INVERSE2A};
|
||||
settings::setting_scalar spotangle{this, "angle", 40.0};
|
||||
settings::setting_scalar spotangle2{this, "softangle", 0.0};
|
||||
settings::setting_numeric<int32_t> style{this, "style", 0.0, 0, 254};
|
||||
settings::setting_numeric<int32_t> style{this, "style", 0, 0, 254};
|
||||
settings::setting_scalar anglescale{this, {"anglesense", "anglescale"}, -1.0}; // fallback to worldspawn
|
||||
settings::setting_scalar dirtscale{this, "dirtscale", 0.0};
|
||||
settings::setting_scalar dirtgain{this, "dirtgain", 0};
|
||||
|
|
|
|||
|
|
@ -119,5 +119,5 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
constexpr reference operator[](const size_t &index) { return {bits, index >> shift, 1ULL << (index & mask)}; }
|
||||
constexpr reference operator[](const size_t &index) { return {bits, index >> shift, 1u << (index & mask)}; }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -103,7 +103,8 @@ setting_group experimental_group{"Experimental options", 60};
|
|||
|
||||
void light_settings::initialize(int argc, const char **argv)
|
||||
{
|
||||
auto remainder = parse(token_parser_t(argc - 1, argv + 1));
|
||||
token_parser_t p(argc - 1, argv + 1);
|
||||
auto remainder = parse(p);
|
||||
|
||||
if (remainder.size() <= 0 || remainder.size() > 1) {
|
||||
printHelp();
|
||||
|
|
|
|||
|
|
@ -56,12 +56,14 @@ void qbsp_settings::initialize(int argc, const char **argv)
|
|||
{
|
||||
if (auto file = fs::load("qbsp.ini")) {
|
||||
logging::print("Loading options from qbsp.ini\n");
|
||||
parse(parser_t(file->data(), file->size()));
|
||||
parser_t p(file->data(), file->size());
|
||||
parse(p);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
auto remainder = parse(token_parser_t(argc - 1, argv + 1));
|
||||
token_parser_t p(argc - 1, argv + 1);
|
||||
auto remainder = parse(p);
|
||||
|
||||
if (remainder.size() <= 0 || remainder.size() > 2) {
|
||||
printHelp();
|
||||
|
|
|
|||
|
|
@ -50,7 +50,8 @@ setting_group advanced_group{"Advanced", 300};
|
|||
|
||||
void vis_settings::initialize(int argc, const char **argv)
|
||||
{
|
||||
auto remainder = parse(token_parser_t(argc - 1, argv + 1));
|
||||
token_parser_t p(argc - 1, argv + 1);
|
||||
auto remainder = parse(p);
|
||||
|
||||
if (remainder.size() <= 0 || remainder.size() > 1) {
|
||||
printHelp();
|
||||
|
|
|
|||
Loading…
Reference in New Issue