build: Fix static build with Clang on macOS

This commit is contained in:
Heun
2022-09-05 02:19:30 +00:00
committed by Gabriel Ferreira
parent 403aec2aa3
commit 406343084b
2 changed files with 4 additions and 3 deletions

View File

@@ -204,6 +204,7 @@ set(CMAKE_CXX_STANDARD_MINIMUM 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(LIB_AS_NEEDED_PRE)
set(LIB_AS_NEEDED_POST)
set(STATIC_LINK_FLAGS -static -static-libstdc++ -static-libgcc)
if(${GCC} AND NOT APPLE)
# using GCC
set(LIB_AS_NEEDED_PRE -Wl,--no-as-needed)
@@ -216,6 +217,8 @@ endif()
if(${CLANG} AND APPLE)
# using Clang set(LIB_AS_NEEDED_PRE -all_load)
set(LIB_AS_NEEDED_POST)
set(LIB_AS_NEEDED_PRE_STATIC -Wl,-all_load)
set(STATIC_LINK_FLAGS)
endif()
macro(SUBDIRLIST result curdir)