Skip to content
This repository was archived by the owner on Dec 29, 2025. It is now read-only.

Commit 5bdf0c2

Browse files
authored
Fix compile error on macOS (#116)
I was getting this error on macOS: ``` ld: library 'c++' not found clang++: error: linker command failed with exit code 1 (use -v to see invocation) ``` Took a while to track down the issue, but it turned out this warning at the end of `cmake` was key: ``` CMake Warning at src/CMakeLists.txt:40 (target_link_libraries): Target "clickhouse_fdw" requests linking to directory "/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk". Targets may link only to libraries. CMake is dropping the item. ``` This is fine, except that that CMake doesn't remove the option this directory points to. The option is stored by `pg_config`; you can see it here: ``` console pg_config --ldflags -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.5.sdk -L/opt/homebrew/opt/readline/lib -Wl,-dead_strip_dylibs ``` What we need to do is remove both the macOS SDK and `-isysroot`. So add a section to `CMakeLists.txt` that uses `REGEX REPLACE` to remove the complete option from the output of `pg_config` on macOS.
1 parent cc928fd commit 5bdf0c2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ exec_program(${PG_CONFIG} ARGS --bindir OUTPUT_VARIABLE PGSQL_BINDIR)
4444
exec_program(${PG_CONFIG} ARGS --cppflags OUTPUT_VARIABLE PGSQL_CPPFLAGS)
4545
exec_program(${PG_CONFIG} ARGS --ldflags OUTPUT_VARIABLE PGSQL_LDFLAGS)
4646
exec_program(${PG_CONFIG} ARGS --libs OUTPUT_VARIABLE PGSQL_LIBS)
47+
if(APPLE)
48+
string(REGEX REPLACE "-isysroot[ ]+[^ ]+ " "" PGSQL_LDFLAGS ${PGSQL_LDFLAGS})
49+
string(REGEX REPLACE "-isysroot[ ]+[^ ]+ " "" PGSQL_CPPFLAGS ${PGSQL_CPPFLAGS})
50+
endif(APPLE)
4751

4852
#------------------------------------------------------------------------------
4953
# tests

0 commit comments

Comments
 (0)