[Bug]: Compile break for chrono timepoint formatting for macOS target < 13.3 and Xcode 15.3
- Dominant language
- C++
- Stars
- 39.5k
- Forks
- 10.9k
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 1
Description
### Describe the issue
Problem:
With the latest version of Xcode 15.3 it is no longer possible to use chrono timpoints in a test assertion, if the build target is lower than macOS 13.3. With Xcode 15.0.1 (and possibly later) this worked.
The macOS SDK made the `std::to_chars` function available with macOS 13.3, which seems to be involved when formatting the timepoints for printing.
Before that, Google Test maybe used a workaround for formatting that's no longer necessary for newer targets? This workaround is still needed for older deployment targets.

### Steps to reproduce the problem
I've created an example project [here](https://github.com/wAuner/gtest_macos_build_break). The build breaks with Xcode 15.3 when the deployment target is set below 13.3, which wasn't a problem with Xcode 15.0.1.
```cmake
CMakeLists.txt
cmake_minimum_required(VERSION 3.14)
# build fails if deployment target is set below 13.3
set(CMAKE_OSX_DEPLOYMENT_TARGET "14.0")
set(CMAKE_CXX_STANDARD 20)
project(gtest_issue)
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/5197b1a8e6a1ef9f214f4aa537b0be17cbf91946.zip # latest commit
# URL https://github.com/google/googletest/archive/f8d7d77c06936315286eb55f8de22cd23c188571.zip # 1.14 release
)
FetchContent_MakeAvailable(googletest)
enable_testing()
add_executable(gtest_issue macostest.cpp)
target_link_libraries(gtest_issue gtest_main)
include(GoogleTest)
gtest_discover_tests(gtest_issue)
```
```cpp
#include
#include
TEST(ChronoTest, CompileBreakBelowMacOS133) {
auto t1 = std::chrono::system_clock::now();
ASSERT_EQ(t1, t1);
}
TEST(ChronoTest, Success) {
auto t1 = std::chrono::system_clock::now();
ASSERT_EQ(t1.time_since_epoch().count(), t1.time_since_epoch().count());
}
```
The deployment target of the mach-o can be verified via `otool -l gtest_issue | grep -A 4 LC_BUILD_VERSION `
### What version of GoogleTest are you using?
latest commit `5197b1a8e6a1ef9f214f4aa537b0be17cbf91946`
### What operating system and version are you using?
macOS 14.4.1
Xcode 15.3 (macOS SDK 14.4)
### What compiler and version are you using?
```
clang --version
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
```
### What build system are you using?
Xcode / cmake
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.