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