build: libc++ support added

This commit is contained in:
Mateusz Pusz
2021-03-15 21:11:26 +01:00
parent 53f0b5a4e5
commit 625f452daa
5 changed files with 91 additions and 46 deletions
+22 -7
View File
@@ -30,8 +30,21 @@ project(mp-units
set(UNITS_DOWNCAST_MODE ON CACHE STRING "Select downcasting mode")
set_property(CACHE UNITS_DOWNCAST_MODE PROPERTY STRINGS AUTO ON OFF)
# set path to custom cmake modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
# check if libc++ is being used
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
message(CHECK_START "Checking if libc++ is being used")
list(APPEND CMAKE_MESSAGE_INDENT " ")
include(CheckSymbolExists)
check_symbol_exists(_LIBCPP_VERSION "ciso646" UNITS_LIBCXX)
list(POP_BACK CMAKE_MESSAGE_INDENT)
if(UNITS_LIBCXX)
message(CHECK_PASS "found")
else()
message(CHECK_FAIL "not found")
endif()
endif()
find_package(fmt CONFIG REQUIRED)
find_package(gsl-lite CONFIG REQUIRED)
@@ -51,11 +64,13 @@ target_include_directories(mp-units
)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
find_package(range-v3)
target_link_libraries(mp-units
INTERFACE
range-v3::range-v3
)
if(UNITS_LIBCXX)
find_package(range-v3)
target_link_libraries(mp-units
INTERFACE
range-v3::range-v3
)
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(mp-units
INTERFACE
+40 -20
View File
@@ -31,15 +31,24 @@
#define COMP_MSVC _MSC_VER
#endif
#if defined(COMP_CLANG) && !defined(UNITS_LIBCXX)
#define UNITS_LIBCXX 0
#if COMP_CLANG
#include <ciso646>
#if _LIBCPP_VERSION
#define UNITS_LIBCXX _LIBCPP_VERSION
#endif
#if COMP_CLANG && UNITS_LIBCXX
#endif
#if COMP_CLANG == 12 && UNITS_LIBCXX
#include <concepts/compare.hpp>
#include <concepts/concepts.hpp>
#include <range/v3/functional/comparisons.hpp>
#include <range/v3/iterator.hpp>
#include <range/v3/range/concepts.hpp>
#include <range/v3/algorithm/lower_bound.hpp>
#include <range/v3/algorithm/transform.hpp>
#endif
@@ -67,35 +76,46 @@ concept default_constructible = constructible_from<T>;
#elif COMP_CLANG && UNITS_LIBCXX
// concepts
using concepts::three_way_comparable;
using concepts::three_way_comparable_with;
// using concepts::common_reference_with;
using concepts::common_with;
using concepts::constructible_from;
using concepts::convertible_to;
// using concepts::default_constructible;
using concepts::copy_constructible;
using concepts::derived_from;
// using concepts::equality_comparable;
using concepts::equality_comparable;
using concepts::equality_comparable_with;
// // using concepts::floating_point;
// using concepts::integral;
using concepts::integral;
using concepts::move_constructible;
using concepts::regular;
// using concepts::same_as;
// using concepts::totally_ordered;
// using concepts::totally_ordered_with;
using concepts::three_way_comparable;
using concepts::three_way_comparable_with;
using concepts::totally_ordered;
using ranges::compare_three_way;
// namespace ranges {
namespace ranges {
// using ::ranges::forward_range;
// using ::ranges::range_value_t;
using ::ranges::begin;
using ::ranges::end;
using ::ranges::distance;
// }
using ::ranges::forward_range;
using ::ranges::input_range;
using ::ranges::range_value_t;
// // missing in Range-v3
// template<class T>
// concept floating_point = std::is_floating_point_v<T>;
using ::ranges::lower_bound;
using ::ranges::transform;
}
// missing in Range-v3
template<class T>
concept floating_point = std::is_floating_point_v<T>;
template<class T>
concept default_initializable =
std::constructible_from<T> &&
requires { T{}; } &&
requires { ::new (static_cast<void*>(nullptr)) T; };
template<class F, class... Args>
concept invocable =