# CMake: Add support for ensuring time\_t is Y2038-safe

**URL:** https://discourse.cmake.org/t/cmake-add-support-for-ensuring-time-t-is-y2038-safe/13754
**Category:** Development
**Created:** [March 15, 2025, 4:50pm UTC](https://discourse.cmake.org/t/cmake-add-support-for-ensuring-time-t-is-y2038-safe/13754 "2025-03-15T16:50:30Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Francois-Xavier\_Le\_B](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/f/278dde/32.png) [@Francois-Xavier\_Le\_B](https://discourse.cmake.org/u/Francois-Xavier_Le_B)
#### Post date: [March 15, 2025, 4:50pm UTC](https://discourse.cmake.org/t/cmake-add-support-for-ensuring-time-t-is-y2038-safe/13754/1 "2025-03-15T16:50:30Z")

</div>

Hello Kitware Team,

The Year 2038 problem threatens 32-bit systems using a 32-bit time\_t, which overflows in January 2038.  
Autoconf 2.72 addresses this problem with its AC\_SYS\_YEAR2038\_RECOMMENDED macro, introduced in 2023 [1].  
This macro automatically checks for 64-bit time\_t support, enables it via \_TIME\_BITS=64 on compatible systems  
(e.g., glibc 2.34+ [2]), and enforces compliance, ensuring many software remains future-proof.

Could CMake offered a CMAKE\_YEAR2038\_RECOMMENDED option or module?  
e.g.:  
$ cmake -DCMAME\_YEAR2038\_RECOMMENDED=ON

Behavior could be like:

1. Checks if sizeof(time\_t) \>= 8 natively.

2. If not, tests \_TIME\_BITS=64 with a small program.

3. Defines necessary macros (e.g. “#define \_TIME\_BITS 64”, “#define \_FILE\_OFFSET\_BITS 64”) in config.h if the  
result is successful.

4. Errors out with a message if unsupported.

What do you think about it?

[1] [autoconf-2.72 released [stable]](https://lists.gnu.org/archive/html/autotools-announce/2023-12/msg00003.html)  
[2] [The GNU C Library version 2.34 is now available](https://lists.gnu.org/archive/html/info-gnu/2021-08/msg00001.html)

Salutations,

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 20, 2025, 2:34am UTC](https://discourse.cmake.org/t/cmake-add-support-for-ensuring-time-t-is-y2038-safe/13754/2 "2025-07-20T02:34:23Z")

</div>

A CMake module that does this could be developed independently. If that works out well, upstreaming it could be considered.
