Skip to content

Commit 0e1a0a5

Browse files
authored
Merge pull request ClickHouse#79220 from ClickHouse/pg-osx
fix build on osx with command line tool 16.3
2 parents f513493 + e5c8bcb commit 0e1a0a5

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

cmake/darwin/default_libs.cmake

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,18 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15)
1515
set(THREADS_PREFER_PTHREAD_FLAG ON)
1616
find_package(Threads REQUIRED)
1717

18+
if(NOT CMAKE_CROSSCOMPILING)
19+
execute_process(
20+
COMMAND xcrun --sdk macosx --show-sdk-version
21+
OUTPUT_VARIABLE OS_DARWIN_SDK_VERSION
22+
OUTPUT_STRIP_TRAILING_WHITESPACE
23+
)
24+
if(${OS_DARWIN_SDK_VERSION} MATCHES "^[0-9]+\\.[0-9]+")
25+
message(STATUS "Detected OSX SDK Version: ${OS_DARWIN_SDK_VERSION}")
26+
else ()
27+
message(WARNING "Unexpected OSX SDK Version: ${OS_DARWIN_SDK_VERSION}")
28+
endif()
29+
endif()
30+
1831
include (cmake/unwind.cmake)
19-
include (cmake/cxx.cmake)
32+
include (cmake/cxx.cmake)

contrib/postgres-cmake/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ 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 if properly resolved in upstream
84+
# https://www.postgresql.org/message-id/flat/385134.1743523038%40sss.pgh.pa.us
85+
if (OS_DARWIN AND OS_DARWIN_SDK_VERSION AND OS_DARWIN_SDK_VERSION VERSION_GREATER_EQUAL 15.4)
86+
target_compile_definitions(_libpq PRIVATE -DHAVE_STRCHRNUL)
87+
endif()
88+
8289
target_link_libraries (_libpq PRIVATE OpenSSL::SSL)
8390

8491
add_library(ch_contrib::libpq ALIAS _libpq)

0 commit comments

Comments
 (0)