forked from mpusz/mp-units
build: libc++ support added
This commit is contained in:
@@ -103,7 +103,7 @@ class UnitsConan(ConanFile):
|
|||||||
# del self.options.build_docs
|
# del self.options.build_docs
|
||||||
|
|
||||||
def requirements(self):
|
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")
|
self.requires("range-v3/0.11.0")
|
||||||
|
|
||||||
def build_requirements(self):
|
def build_requirements(self):
|
||||||
|
@@ -43,20 +43,20 @@ add_example(avg_speed)
|
|||||||
add_example(hello_units)
|
add_example(hello_units)
|
||||||
add_example(total_energy)
|
add_example(total_energy)
|
||||||
|
|
||||||
add_executable(glide_computer
|
if(NOT UNITS_LIBCXX)
|
||||||
geographic.cpp geographic.h
|
add_executable(glide_computer
|
||||||
glide_computer.cpp glide_computer.h
|
geographic.cpp geographic.h
|
||||||
glide_computer_example.cpp
|
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)
|
||||||
find_package(linear_algebra CONFIG REQUIRED)
|
target_link_libraries(linear_algebra
|
||||||
add_example(linear_algebra)
|
PRIVATE
|
||||||
target_link_libraries(linear_algebra
|
linear_algebra::linear_algebra
|
||||||
PRIVATE
|
)
|
||||||
linear_algebra::linear_algebra
|
endif()
|
||||||
)
|
|
||||||
|
|
||||||
add_subdirectory(alternative_namespaces)
|
add_subdirectory(alternative_namespaces)
|
||||||
|
@@ -30,8 +30,21 @@ project(mp-units
|
|||||||
set(UNITS_DOWNCAST_MODE ON CACHE STRING "Select downcasting mode")
|
set(UNITS_DOWNCAST_MODE ON CACHE STRING "Select downcasting mode")
|
||||||
set_property(CACHE UNITS_DOWNCAST_MODE PROPERTY STRINGS AUTO ON OFF)
|
set_property(CACHE UNITS_DOWNCAST_MODE PROPERTY STRINGS AUTO ON OFF)
|
||||||
|
|
||||||
# set path to custom cmake modules
|
# check if libc++ is being used
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
|
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(fmt CONFIG REQUIRED)
|
||||||
find_package(gsl-lite 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(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
find_package(range-v3)
|
if(UNITS_LIBCXX)
|
||||||
target_link_libraries(mp-units
|
find_package(range-v3)
|
||||||
INTERFACE
|
target_link_libraries(mp-units
|
||||||
range-v3::range-v3
|
INTERFACE
|
||||||
)
|
range-v3::range-v3
|
||||||
|
)
|
||||||
|
endif()
|
||||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
target_compile_options(mp-units
|
target_compile_options(mp-units
|
||||||
INTERFACE
|
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
|
#define COMP_MSVC _MSC_VER
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(COMP_CLANG) && !defined(UNITS_LIBCXX)
|
#if COMP_CLANG
|
||||||
#define UNITS_LIBCXX 0
|
|
||||||
|
#include <ciso646>
|
||||||
|
#if _LIBCPP_VERSION
|
||||||
|
#define UNITS_LIBCXX _LIBCPP_VERSION
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if COMP_CLANG && UNITS_LIBCXX
|
#endif
|
||||||
|
|
||||||
|
#if COMP_CLANG == 12 && UNITS_LIBCXX
|
||||||
|
|
||||||
#include <concepts/compare.hpp>
|
#include <concepts/compare.hpp>
|
||||||
#include <concepts/concepts.hpp>
|
#include <concepts/concepts.hpp>
|
||||||
#include <range/v3/functional/comparisons.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
|
#endif
|
||||||
|
|
||||||
@@ -67,35 +76,46 @@ concept default_constructible = constructible_from<T>;
|
|||||||
#elif COMP_CLANG && UNITS_LIBCXX
|
#elif COMP_CLANG && UNITS_LIBCXX
|
||||||
|
|
||||||
// concepts
|
// concepts
|
||||||
using concepts::three_way_comparable;
|
|
||||||
using concepts::three_way_comparable_with;
|
|
||||||
// using concepts::common_reference_with;
|
|
||||||
using concepts::common_with;
|
using concepts::common_with;
|
||||||
using concepts::constructible_from;
|
using concepts::constructible_from;
|
||||||
using concepts::convertible_to;
|
using concepts::convertible_to;
|
||||||
// using concepts::default_constructible;
|
using concepts::copy_constructible;
|
||||||
using concepts::derived_from;
|
using concepts::derived_from;
|
||||||
// using concepts::equality_comparable;
|
using concepts::equality_comparable;
|
||||||
using concepts::equality_comparable_with;
|
using concepts::equality_comparable_with;
|
||||||
// // using concepts::floating_point;
|
using concepts::integral;
|
||||||
// using concepts::integral;
|
using concepts::move_constructible;
|
||||||
using concepts::regular;
|
using concepts::regular;
|
||||||
// using concepts::same_as;
|
using concepts::three_way_comparable;
|
||||||
// using concepts::totally_ordered;
|
using concepts::three_way_comparable_with;
|
||||||
// using concepts::totally_ordered_with;
|
using concepts::totally_ordered;
|
||||||
|
|
||||||
using ranges::compare_three_way;
|
using ranges::compare_three_way;
|
||||||
|
|
||||||
// namespace ranges {
|
namespace ranges {
|
||||||
|
|
||||||
// using ::ranges::forward_range;
|
using ::ranges::begin;
|
||||||
// using ::ranges::range_value_t;
|
using ::ranges::end;
|
||||||
|
using ::ranges::distance;
|
||||||
|
|
||||||
// }
|
using ::ranges::forward_range;
|
||||||
|
using ::ranges::input_range;
|
||||||
|
using ::ranges::range_value_t;
|
||||||
|
|
||||||
// // missing in Range-v3
|
using ::ranges::lower_bound;
|
||||||
// template<class T>
|
using ::ranges::transform;
|
||||||
// concept floating_point = std::is_floating_point_v<T>;
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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>
|
template<class F, class... Args>
|
||||||
concept invocable =
|
concept invocable =
|
||||||
|
@@ -24,9 +24,13 @@ cmake_minimum_required(VERSION 3.2)
|
|||||||
|
|
||||||
add_library(unit_tests_static_truncating
|
add_library(unit_tests_static_truncating
|
||||||
quantity_test.cpp
|
quantity_test.cpp
|
||||||
quantity_kind_test.cpp
|
|
||||||
quantity_point_kind_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
|
target_link_libraries(unit_tests_static_truncating
|
||||||
PRIVATE
|
PRIVATE
|
||||||
mp-units::mp-units
|
mp-units::mp-units
|
||||||
@@ -41,7 +45,6 @@ add_library(unit_tests_static
|
|||||||
chrono_test.cpp
|
chrono_test.cpp
|
||||||
concepts_test.cpp
|
concepts_test.cpp
|
||||||
custom_rep_test_min_expl.cpp
|
custom_rep_test_min_expl.cpp
|
||||||
custom_rep_test_min_impl.cpp
|
|
||||||
custom_unit_test.cpp
|
custom_unit_test.cpp
|
||||||
data_test.cpp
|
data_test.cpp
|
||||||
dimension_op_test.cpp
|
dimension_op_test.cpp
|
||||||
@@ -50,7 +53,6 @@ add_library(unit_tests_static
|
|||||||
fps_test.cpp
|
fps_test.cpp
|
||||||
kind_test.cpp
|
kind_test.cpp
|
||||||
math_test.cpp
|
math_test.cpp
|
||||||
quantity_point_test.cpp
|
|
||||||
ratio_test.cpp
|
ratio_test.cpp
|
||||||
si_test.cpp
|
si_test.cpp
|
||||||
si_cgs_test.cpp
|
si_cgs_test.cpp
|
||||||
@@ -61,6 +63,14 @@ add_library(unit_tests_static
|
|||||||
unit_test.cpp
|
unit_test.cpp
|
||||||
us_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
|
target_link_libraries(unit_tests_static
|
||||||
PRIVATE
|
PRIVATE
|
||||||
unit_tests_static_truncating
|
unit_tests_static_truncating
|
||||||
|
Reference in New Issue
Block a user