diff options
author | Pierre Ossman <ossman@cendio.se> | 2023-06-21 13:58:57 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2023-06-28 15:54:12 +0200 |
commit | b0319e3e09b9d5e741a78e0591d730ef577c6ecb (patch) | |
tree | 33815f641f932d69df3d919768e0bcd9e1235fdf | |
parent | e93e2e4dffd2dde85021fc1d6f091e7d05e19e47 (diff) | |
download | tigervnc-b0319e3e09b9d5e741a78e0591d730ef577c6ecb.tar.gz tigervnc-b0319e3e09b9d5e741a78e0591d730ef577c6ecb.zip |
Move where -nodefaultlibs is specified
The previous method isn't compatible with CMake's try_compile() as it
will respect CMAKE_EXE_LINKER_FLAGS, but not CMAKE_C_LINK_EXECUTABLE and
friends. This results in the default libraries being completely missing,
and the compile test failing.
-rw-r--r-- | cmake/StaticBuild.cmake | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/cmake/StaticBuild.cmake b/cmake/StaticBuild.cmake index 1a3bdb46..495b53a1 100644 --- a/cmake/StaticBuild.cmake +++ b/cmake/StaticBuild.cmake @@ -168,8 +168,6 @@ if(BUILD_STATIC) endif() if(BUILD_STATIC_GCC) - # This ensures that we don't depend on libstdc++ or libgcc_s - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nodefaultlibs") set(STATIC_BASE_LIBRARIES "") if(ENABLE_ASAN AND NOT WIN32 AND NOT APPLE) set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -Wl,-Bstatic -lasan -Wl,-Bdynamic -ldl -lpthread") @@ -195,6 +193,7 @@ if(BUILD_STATIC_GCC) else() set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -lm -lgcc -lgcc_eh -lc") endif() - set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} ${STATIC_BASE_LIBRARIES}") - set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic ${STATIC_BASE_LIBRARIES}") + # -nodefaultlibs ensures that we don't depend on libstdc++ or libgcc_s + set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} -nodefaultlibs ${STATIC_BASE_LIBRARIES}") + set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -nodefaultlibs -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic ${STATIC_BASE_LIBRARIES}") endif() |