build: got rid of old clang hacks and range-v3 dependency

This commit is contained in:
Mateusz Pusz
2023-09-26 18:09:06 +02:00
parent 3b6a22d2c0
commit 25fee701a0
5 changed files with 2 additions and 236 deletions

View File

@@ -93,12 +93,6 @@ class MPUnitsConan(ConanFile):
std_support = compiler == "msvc" and version >= 193 and compiler.cppstd == 23
return not std_support
@property
def _use_range_v3(self):
compiler = self.settings.compiler
version = Version(self.settings.compiler.version)
return "clang" in compiler and compiler.libcxx == "libc++" and version < 14
def set_version(self):
content = load(self, os.path.join(self.recipe_folder, "src/CMakeLists.txt"))
version = re.search(
@@ -110,8 +104,6 @@ class MPUnitsConan(ConanFile):
self.requires("gsl-lite/0.40.0")
if self._use_libfmt:
self.requires("fmt/10.1.0")
if self._use_range_v3:
self.requires("range-v3/0.11.0")
def build_requirements(self):
if self._build_all:
@@ -174,8 +166,6 @@ class MPUnitsConan(ConanFile):
self.cpp_info.components["core"].requires = ["gsl-lite::gsl-lite"]
if compiler == "msvc":
self.cpp_info.components["core"].cxxflags = ["/utf-8"]
if self._use_range_v3:
self.cpp_info.components["core"].requires.append("range-v3::range-v3")
# rest
self.cpp_info.components["core-io"].requires = ["core"]

View File

@@ -1,41 +0,0 @@
# The MIT License (MIT)
#
# Copyright (c) 2018 Mateusz Pusz
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
cmake_minimum_required(VERSION 3.15)
function(check_libcxx_in_use variable)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(CHECK_START "Checking if libc++ is being used")
list(APPEND CMAKE_MESSAGE_INDENT " ")
include(CheckCXXSymbolExists)
check_cxx_symbol_exists(_LIBCPP_VERSION "ciso646" ${variable})
set(${variable} ${${variable}} PARENT_SCOPE)
list(POP_BACK CMAKE_MESSAGE_INDENT)
if(${variable})
message(CHECK_PASS "found")
else()
message(CHECK_FAIL "not found")
endif()
endif()
endfunction()

View File

@@ -27,10 +27,6 @@ if(NOT TARGET gsl::gsl-lite)
find_package(gsl-lite CONFIG REQUIRED)
endif()
# check if libc++ is being used
include(CheckLibcxxInUse)
check_libcxx_in_use(${projectPrefix}LIBCXX)
# core library definition
add_library(
mp-units-core
@@ -78,14 +74,7 @@ target_include_directories(
$<INSTALL_INTERFACE:include>
)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(${projectPrefix}LIBCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "14")
if(NOT TARGET range-v3::range-v3)
find_package(range-v3 CONFIG REQUIRED)
endif()
target_link_libraries(mp-units-core INTERFACE range-v3::range-v3)
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(
mp-units-core
INTERFACE /utf-8 # Specifies both the source character set and the execution character set as UTF-8

View File

@@ -70,34 +70,10 @@
#define MP_UNITS_DIAGNOSTIC_IGNORE_DEPRECATED
#endif
#if _LIBCPP_VERSION
#define MP_UNITS_LIBCXX _LIBCPP_VERSION
#endif
#if MP_UNITS_LIBCXX
#if MP_UNITS_LIBCXX < 13000
#include <concepts/concepts.hpp>
#include <range/v3/algorithm/lower_bound.hpp>
#include <range/v3/algorithm/transform.hpp>
#include <range/v3/functional/comparisons.hpp>
#include <range/v3/iterator.hpp>
#include <range/v3/iterator/concepts.hpp>
#include <range/v3/range/concepts.hpp>
#elif MP_UNITS_LIBCXX < 14000
#include <range/v3/functional/comparisons.hpp>
#endif
#endif
#include <compare>
#include <concepts>
#if MP_UNITS_COMP_MSVC || (MP_UNITS_COMP_CLANG && MP_UNITS_COMP_CLANG < 16)
#if MP_UNITS_COMP_MSVC
#define MP_UNITS_TYPENAME typename
@@ -145,124 +121,6 @@ namespace std {
template<class T>
concept default_constructible = constructible_from<T>;
#elif MP_UNITS_LIBCXX
#if MP_UNITS_LIBCXX < 13000
// concepts
using concepts::common_with;
using concepts::constructible_from;
using concepts::convertible_to;
using concepts::copy_constructible;
using concepts::derived_from;
using concepts::equality_comparable;
using concepts::equality_comparable_with;
using concepts::integral;
using concepts::move_constructible;
using concepts::regular;
using concepts::three_way_comparable;
using concepts::three_way_comparable_with;
using concepts::totally_ordered;
using ranges::compare_three_way;
using ranges::input_iterator;
using ranges::iter_value_t;
using ranges::sentinel_for;
namespace ranges {
using ::ranges::begin;
using ::ranges::distance;
using ::ranges::end;
using ::ranges::input_range;
using ::ranges::range_value_t;
using ::ranges::lower_bound;
using ::ranges::transform;
} // namespace ranges
// 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 = requires(F&& f, Args&&... args) { std::invoke(std::forward<F>(f), std::forward<Args>(args)...); };
template<class F, class... Args>
concept regular_invocable = invocable<F, Args...>;
template<class T, class U>
constexpr bool cmp_equal(T t, U u) noexcept
{
using UT = std::make_unsigned_t<T>;
using UU = std::make_unsigned_t<U>;
if constexpr (std::is_signed_v<T> == std::is_signed_v<U>)
return t == u;
else if constexpr (std::is_signed_v<T>)
return t < 0 ? false : UT(t) == u;
else
return u < 0 ? false : t == UU(u);
}
template<class T, class U>
constexpr bool cmp_not_equal(T t, U u) noexcept
{
return !cmp_equal(t, u);
}
template<class T, class U>
constexpr bool cmp_less(T t, U u) noexcept
{
using UT = std::make_unsigned_t<T>;
using UU = std::make_unsigned_t<U>;
if constexpr (std::is_signed_v<T> == std::is_signed_v<U>)
return t < u;
else if constexpr (std::is_signed_v<T>)
return t < 0 ? true : UT(t) < u;
else
return u < 0 ? false : t < UU(u);
}
template<class T, class U>
constexpr bool cmp_greater(T t, U u) noexcept
{
return cmp_less(u, t);
}
template<class T, class U>
constexpr bool cmp_less_equal(T t, U u) noexcept
{
return !cmp_greater(t, u);
}
template<class T, class U>
constexpr bool cmp_greater_equal(T t, U u) noexcept
{
return !cmp_less(t, u);
}
template<class R, class T>
constexpr bool in_range(T t) noexcept
{
return std::cmp_greater_equal(t, std::numeric_limits<R>::min()) &&
std::cmp_less_equal(t, std::numeric_limits<R>::max());
}
#elif MP_UNITS_LIBCXX < 14000
using concepts::three_way_comparable;
using concepts::three_way_comparable_with;
using ::ranges::compare_three_way;
#endif
#endif
} // namespace std

View File

@@ -20,25 +20,6 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
function(__check_libcxx_in_use variable)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(CHECK_START "Checking if libc++ is being used")
list(APPEND CMAKE_MESSAGE_INDENT " ")
include(CheckCXXSymbolExists)
check_cxx_symbol_exists(_LIBCPP_VERSION "ciso646" ${variable})
set(${variable} ${${variable}} PARENT_SCOPE)
list(POP_BACK CMAKE_MESSAGE_INDENT)
if(${variable})
message(CHECK_PASS "found")
else()
message(CHECK_FAIL "not found")
endif()
endif()
endfunction()
include(CMakeFindDependencyMacro)
if(MP_UNITS_USE_LIBFMT)
@@ -47,15 +28,4 @@ endif()
find_dependency(gsl-lite)
# add range-v3 dependency only for clang + libc++
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
__check_libcxx_in_use(__units_libcxx)
if(__units_libcxx AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "14")
find_dependency(range-v3)
endif()
unset(__units_libcxx)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/mp-unitsTargets.cmake")