mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-05 21:24:27 +02:00
build: libc++ support added
This commit is contained in:
@@ -103,7 +103,7 @@ class UnitsConan(ConanFile):
|
||||
# del self.options.build_docs
|
||||
|
||||
def requirements(self):
|
||||
if self.settings.compiler == "clang":
|
||||
if self.settings.compiler == "clang" and self.settings.compiler.libcxx == "libc++":
|
||||
self.requires("range-v3/0.11.0")
|
||||
|
||||
def build_requirements(self):
|
||||
|
@@ -43,20 +43,20 @@ add_example(avg_speed)
|
||||
add_example(hello_units)
|
||||
add_example(total_energy)
|
||||
|
||||
add_executable(glide_computer
|
||||
if(NOT UNITS_LIBCXX)
|
||||
add_executable(glide_computer
|
||||
geographic.cpp geographic.h
|
||||
glide_computer.cpp glide_computer.h
|
||||
glide_computer_example.cpp
|
||||
)
|
||||
target_link_libraries(glide_computer PRIVATE mp-units::mp-units)
|
||||
)
|
||||
target_link_libraries(glide_computer PRIVATE mp-units::mp-units)
|
||||
|
||||
# TODO "atomic constraint should be a constant expression" error in std::invocable
|
||||
|
||||
find_package(linear_algebra CONFIG REQUIRED)
|
||||
add_example(linear_algebra)
|
||||
target_link_libraries(linear_algebra
|
||||
find_package(linear_algebra CONFIG REQUIRED)
|
||||
add_example(linear_algebra)
|
||||
target_link_libraries(linear_algebra
|
||||
PRIVATE
|
||||
linear_algebra::linear_algebra
|
||||
)
|
||||
)
|
||||
endif()
|
||||
|
||||
add_subdirectory(alternative_namespaces)
|
||||
|
@@ -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")
|
||||
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
|
||||
|
60
src/include/units/bits/external/hacks.h
vendored
60
src/include/units/bits/external/hacks.h
vendored
@@ -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 =
|
||||
|
@@ -24,9 +24,13 @@ cmake_minimum_required(VERSION 3.2)
|
||||
|
||||
add_library(unit_tests_static_truncating
|
||||
quantity_test.cpp
|
||||
)
|
||||
if(NOT UNITS_LIBCXX)
|
||||
target_sources(unit_tests_static_truncating PRIVATE
|
||||
quantity_kind_test.cpp
|
||||
quantity_point_kind_test.cpp
|
||||
)
|
||||
)
|
||||
endif()
|
||||
target_link_libraries(unit_tests_static_truncating
|
||||
PRIVATE
|
||||
mp-units::mp-units
|
||||
@@ -41,7 +45,6 @@ add_library(unit_tests_static
|
||||
chrono_test.cpp
|
||||
concepts_test.cpp
|
||||
custom_rep_test_min_expl.cpp
|
||||
custom_rep_test_min_impl.cpp
|
||||
custom_unit_test.cpp
|
||||
data_test.cpp
|
||||
dimension_op_test.cpp
|
||||
@@ -50,7 +53,6 @@ add_library(unit_tests_static
|
||||
fps_test.cpp
|
||||
kind_test.cpp
|
||||
math_test.cpp
|
||||
quantity_point_test.cpp
|
||||
ratio_test.cpp
|
||||
si_test.cpp
|
||||
si_cgs_test.cpp
|
||||
@@ -61,6 +63,14 @@ add_library(unit_tests_static
|
||||
unit_test.cpp
|
||||
us_test.cpp
|
||||
)
|
||||
|
||||
if(NOT UNITS_LIBCXX)
|
||||
target_sources(unit_tests_static PRIVATE
|
||||
custom_rep_test_min_impl.cpp
|
||||
quantity_point_test.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(unit_tests_static
|
||||
PRIVATE
|
||||
unit_tests_static_truncating
|
||||
|
Reference in New Issue
Block a user