Remove libfmt, fix instantiating templates for fast_float usage

This commit is contained in:
Maarten L. Hekkelman
2025-10-30 09:08:44 +01:00
parent 4e128885d6
commit e51f31dc4c
4 changed files with 10 additions and 26 deletions

View File

@@ -168,16 +168,6 @@ if(MSVC)
endforeach()
endif()
# First check if <format> is available
find_file(FMT NAME format)
if(FMT EQUAL "FMT-NOTFOUND")
if(NOT (fmt_FOUND OR TARGET fmt))
find_package(fmt REQUIRED)
message(FATAL_ERROR "cifpp: <format> not found and neither was libfmt, compiler too old, you're out of luck")
endif()
endif()
# Using fast_float for float parsing, but only if needed
try_compile(STD_CHARCONV_COMPILING
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/test-charconv.cpp)
@@ -359,10 +349,6 @@ if(NOT STD_CHARCONV_COMPILING)
target_link_libraries(cifpp PUBLIC FastFloat::fast_float)
endif()
if(fmt_FOUND)
target_link_libraries(cifpp PUBLIC fmt)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
target_link_options(cifpp PRIVATE -undefined dynamic_lookup)
endif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
@@ -499,7 +485,6 @@ if(CIFPP_DATA_DIR AND CIFPP_DOWNLOAD_CCD)
endif()
set(CONFIG_TEMPLATE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cifpp-config.cmake.in)
set(REQUIRE_FMT ${fmt_FOUND})
configure_package_config_file(
${CONFIG_TEMPLATE_FILE} ${CMAKE_CURRENT_BINARY_DIR}/cifpp/cifpp-config.cmake

View File

@@ -8,8 +8,5 @@ include(CMakeFindDependencyMacro)
find_dependency(Threads)
find_dependency(ZLIB REQUIRED)
if(@REQUIRE_FMT@)
find_dependency(fmt REQUIRED)
endif()
check_required_components(cifpp)

View File

@@ -30,6 +30,7 @@
#include <initializer_list>
#include <random> // for uniform_real_distribution, normal_distri...
#include <stdexcept>
namespace cif
{
@@ -517,6 +518,7 @@ bool point_in_circle(point p, std::vector<point> c)
default:
assert(false);
throw std::runtime_error("Error finding smallest sphere");
}
}
@@ -570,6 +572,7 @@ std::tuple<point, float> smallest_sphere_around_points(std::vector<point> pts)
return smallest_sphere_around_points(pts[cix[0]], pts[cix[1]], pts[cix[2]], pts[cix[3]]);
default:
assert(false);
throw std::runtime_error("Error finding smallest sphere");
}
}

View File

@@ -34,7 +34,6 @@
#include "fast_float/fast_float.h"
#endif
namespace cif
{
@@ -527,21 +526,21 @@ std::from_chars_result ff_charconv<T, typename std::enable_if_t<std::is_floating
return { r.ptr, r.ec };
}
template<> struct ff_charconv<float>;
template<> struct ff_charconv<double>;
template<> struct ff_charconv<long double>;
template struct ff_charconv<float>;
template struct ff_charconv<double>;
// template struct ff_charconv<long double>;
#ifdef __STDCPP_FLOAT64_T__
template<> struct ff_charconv<std::float64_t>;
template struct ff_charconv<std::float64_t>;
#endif
#ifdef __STDCPP_FLOAT32_T__
template<> struct ff_charconv<std::float32_t>;
template struct ff_charconv<std::float32_t>;
#endif
#ifdef __STDCPP_FLOAT16_T__
template<> struct ff_charconv<std::float16_t>;
template struct ff_charconv<std::float16_t>;
#endif
#ifdef __STDCPP_BFLOAT16_T__
template<> struct ff_charconv<std::bfloat16_t>;
template struct ff_charconv<std::bfloat16_t>;
#endif
#endif