From 0de236a7c1ef37663d0b37f656bedb6fc202ca6f Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 11 Dec 2023 16:21:30 +0000 Subject: [PATCH] cmake: auto-detect `strtonum` Notice that just like in autotools, this detection also doesn't take into account the targeted OS version. Meaning it detects `strtonum` even if targeting e.g. macOS older than release v11 Big Sur (which introduced this funcitions), if the SDK declares it. Wrong detection will either cause a binary broken on older macOS and/or trigger compiler warnings. Ref: https://github.com/libressl/portable/issues/928#issuecomment-1850178282 Ref: https://github.com/libressl/portable/issues/928#issuecomment-1850276298 Prerequisite: https://github.com/libressl/portable/issues/928#issuecomment-1850356408 --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 605cfde3de..ac3e5a0e6d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -234,6 +234,11 @@ if(HAVE_STRSEP) add_definitions(-DHAVE_STRSEP) endif() +check_function_exists(strtonum HAVE_STRTONUM) +if(HAVE_STRTONUM) + add_definitions(-DHAVE_STRTONUM) +endif() + check_function_exists(timegm HAVE_TIMEGM) if(HAVE_TIMEGM) add_definitions(-DHAVE_TIMEGM)