Skip to content

Commit f4516b6

Browse files
fix build on osx 15.4 with command line tools 16.3
1 parent 979a47d commit f4516b6

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

contrib/postgres-cmake/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,25 @@ if (OS_DARWIN OR OS_FREEBSD OR USE_MUSL)
7979
target_compile_definitions(_libpq PRIVATE -DSTRERROR_R_INT=1)
8080
endif()
8181

82+
# Mac 15.4 / Xcode 16.3 started defining srtchrnul
83+
# Could be cleaned up after resolved in upstream https://www.postgresql.org/message-id/flat/385134.1743523038%40sss.pgh.pa.us
84+
if (OS_DARWIN AND NOT USE_MUSL)
85+
execute_process(
86+
COMMAND xcrun --sdk macosx --show-sdk-version
87+
OUTPUT_VARIABLE XCRUN
88+
OUTPUT_STRIP_TRAILING_WHITESPACE
89+
)
90+
91+
string(REGEX MATCH "([0-9]+)\\.([0-9]+)" _ ${XCRUN})
92+
set(SDK_VERSION_MAJOR "${CMAKE_MATCH_1}")
93+
set(SDK_VERSION_MINOR "${CMAKE_MATCH_2}")
94+
95+
message(STATUS "Detected SDK Version: ${SDK_VERSION_MAJOR}.${SDK_VERSION_MINOR}")
96+
if(SDK_VERSION_MAJOR GREATER 15 OR (SDK_VERSION_MAJOR EQUAL 15 AND SDK_VERSION_MINOR GREATER_EQUAL 4))
97+
target_compile_definitions(_libpq PRIVATE -DHAVE_STRCHRNUL)
98+
endif()
99+
endif()
100+
82101
target_link_libraries (_libpq PRIVATE OpenSSL::SSL)
83102

84103
add_library(ch_contrib::libpq ALIAS _libpq)

0 commit comments

Comments
 (0)