Enable use of std::format for AppleClang / Xcode 16

Specified the minimum apple-clang version to support `std::format` to 16
for _connanfile.py_.  Xcode 16 does include the `<format>` header but
does not seem to have the __cpp_lib_format compatibility macro defined
so a similar override was needed as we had for Clang 17.

To be able to use `std::format` with Xcode 16 I had to pass
`-DMP_UNITS_API_STD_FORMAT=AUTO` when calling `cmake`.  Is this expected
or is this a sign I missed something in my changes to _CMakeLists.txt_?
This commit is contained in:
Roth Michaels
2024-12-19 11:47:00 -05:00
parent d9c39112df
commit 43729c6190
2 changed files with 10 additions and 8 deletions

View File

@ -99,7 +99,7 @@ class MPUnitsConan(ConanFile):
"compiler": { "compiler": {
"gcc": "13", "gcc": "13",
"clang": "17", "clang": "17",
"apple-clang": "", "apple-clang": "16",
"msvc": "194", "msvc": "194",
}, },
}, },

View File

@ -53,13 +53,15 @@ check_cxx_feature_supported(__cpp_explicit_this_parameter ${projectPrefix}EXPLIC
# libc++ has a basic supports for std::format but does not set __cpp_lib_format # libc++ has a basic supports for std::format but does not set __cpp_lib_format
# https://github.com/llvm/llvm-project/issues/77773 # https://github.com/llvm/llvm-project/issues/77773
if(NOT ${projectPrefix}LIB_FORMAT_SUPPORTED if(NOT ${projectPrefix}LIB_FORMAT_SUPPORTED AND ${projectPrefix}LIBCXX)
AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang" if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "17")
AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "17" message(STATUS "Clang 17+ with libc++ detected, overriding `std::format` support")
AND ${projectPrefix}LIBCXX set(${projectPrefix}LIB_FORMAT_SUPPORTED ON)
) endif()
message(STATUS "Clang 17+ with libc++ detected, overriding `std::format` support") if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "16")
set(${projectPrefix}LIB_FORMAT_SUPPORTED ON) message(STATUS "AppleClang 16+ with libc++ detected, overriding `std::format` support")
set(${projectPrefix}LIB_FORMAT_SUPPORTED ON)
endif()
endif() endif()
# clang++-18 supports explicit `this` parameter # clang++-18 supports explicit `this` parameter