Skip to content

Commit

Permalink
build: overriding of std::format support for clang-17+ with libc++ …
Browse files Browse the repository at this point in the history
…added
  • Loading branch information
mpusz committed Jun 14, 2024
1 parent 05fc1e2 commit d746817
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,15 @@ check_cxx_feature_supported(__cpp_lib_format ${projectPrefix}LIB_FORMAT_SUPPORTE
check_cxx_feature_supported("__cpp_constexpr >= 202211L" ${projectPrefix}STATIC_CONSTEXPR_VARS_IN_CONSTEXPR_FUNCTIONS)
check_cxx_feature_supported(__cpp_explicit_this_parameter ${projectPrefix}EXPLICIT_THIS_PARAMETER_SUPPORTED)

# libc++ has a basic supports for std::format but does not set __cpp_lib_format
# https://github.com/llvm/llvm-project/issues/77773
if(NOT ${projectPrefix}LIB_FORMAT_SUPPORTED AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "17" AND ${projectPrefix}LIBCXX)
message(STATUS "Clang 17+ with libc++ detected, overriding `std::format` support")
set(${projectPrefix}LIB_FORMAT_SUPPORTED 1)
endif()

# validate settings
if(NOT ${projectPrefix}API_FREESTANDING
AND "${projectPrefix}API_STD_FORMAT"
AND NOT
(${projectPrefix}LIB_FORMAT_SUPPORTED
# libc++ has a basic supports for std::format but does not set __cpp_lib_format
# https://github.com/llvm/llvm-project/issues/77773
OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "17"
AND ${projectPrefix}LIBCXX))
)
if(NOT ${projectPrefix}API_FREESTANDING AND "${projectPrefix}API_STD_FORMAT" AND NOT ${projectPrefix}LIB_FORMAT_SUPPORTED)
message(FATAL_ERROR "`std::format` enabled but not supported")
endif()

Expand Down

0 comments on commit d746817

Please sign in to comment.