mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-03 12:24:26 +02:00
Preeliminary clang support added
This commit is contained in:
12
conanfile.py
12
conanfile.py
@@ -59,10 +59,12 @@ class UnitsConan(ConanFile):
|
||||
return tools.get_env("CONAN_RUN_TESTS", False)
|
||||
|
||||
def configure(self):
|
||||
if self.settings.compiler != "gcc":
|
||||
raise ConanInvalidConfiguration("Library works only with gcc")
|
||||
if Version(self.settings.compiler.version) < "9":
|
||||
raise ConanInvalidConfiguration("Library requires at least gcc-9")
|
||||
if self.settings.compiler != "gcc": # and self.settings.compiler != "clang":
|
||||
raise ConanInvalidConfiguration("Library works only with gcc") # and clang")
|
||||
if self.settings.compiler == "gcc" and Version(self.settings.compiler.version) < "9":
|
||||
raise ConanInvalidConfiguration("Library requires at least g++-9")
|
||||
if self.settings.compiler == "clang" and Version(self.settings.compiler.version) < "11":
|
||||
raise ConanInvalidConfiguration("Library requires at least clang++-11")
|
||||
if self.settings.compiler.cppstd not in ["20", "gnu20"]:
|
||||
raise ConanInvalidConfiguration("Library requires at least C++20 support")
|
||||
|
||||
@@ -75,7 +77,7 @@ class UnitsConan(ConanFile):
|
||||
return cmake
|
||||
|
||||
def requirements(self):
|
||||
if Version(self.settings.compiler.version) < "10":
|
||||
if self.settings.compiler == "clang" or Version(self.settings.compiler.version) < "10":
|
||||
self.requires("range-v3/0.10.0@ericniebler/stable")
|
||||
|
||||
def build(self):
|
||||
|
@@ -60,12 +60,18 @@ target_include_directories(units
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
||||
target_compile_options(units
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
target_link_libraries(units
|
||||
INTERFACE
|
||||
-Wno-literal-suffix
|
||||
-Wno-non-template-friend
|
||||
CONAN_PKG::range-v3
|
||||
)
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
target_compile_options(units
|
||||
INTERFACE
|
||||
-Wno-literal-suffix
|
||||
-Wno-non-template-friend
|
||||
)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0)
|
||||
target_compile_options(units
|
||||
INTERFACE
|
||||
@@ -77,6 +83,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_library(mp::units ALIAS units)
|
||||
|
||||
# installation info
|
||||
|
37
src/include/units/bits/external/hacks.h
vendored
37
src/include/units/bits/external/hacks.h
vendored
@@ -24,6 +24,13 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
#if __clang__
|
||||
#define COMP_CLANG __clang_major__
|
||||
#elif __GNUC__
|
||||
#define COMP_GCC __GNUC__
|
||||
#define COMP_GCC_MINOR __GNUC_MINOR__
|
||||
#endif
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define Expects(cond) (void)(cond);
|
||||
#else
|
||||
@@ -31,23 +38,36 @@
|
||||
#define Expects(cond) assert(cond);
|
||||
#endif
|
||||
|
||||
#if __GNUC__ < 10
|
||||
#if COMP_GCC >= 10 || COMP_CLANG >= 11
|
||||
|
||||
#include <concepts/concepts.hpp>
|
||||
#define AUTO
|
||||
#define SAME_AS(T) T
|
||||
#include <concepts>
|
||||
|
||||
#else
|
||||
|
||||
#include <concepts>
|
||||
#include <concepts/concepts.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
#if COMP_GCC >= 10 || COMP_CLANG >= 11
|
||||
|
||||
#define AUTO auto
|
||||
#define SAME_AS(T) std::same_as<T>
|
||||
|
||||
#else
|
||||
|
||||
#define AUTO
|
||||
#define SAME_AS(T) T
|
||||
|
||||
#endif
|
||||
|
||||
namespace std {
|
||||
|
||||
#if __GNUC__ < 10
|
||||
#if COMP_GCC >= 10
|
||||
|
||||
template<class T>
|
||||
concept default_constructible = constructible_from<T>;
|
||||
|
||||
#else
|
||||
|
||||
// concepts
|
||||
using concepts::common_reference_with;
|
||||
@@ -71,11 +91,6 @@ namespace std {
|
||||
template<class F, class... Args>
|
||||
concept regular_invocable = invocable<F, Args...>;
|
||||
|
||||
#else
|
||||
|
||||
template<class T>
|
||||
concept default_constructible = constructible_from<T>;
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace std
|
||||
|
Reference in New Issue
Block a user