]> source.dussan.org Git - tigervnc.git/commitdiff
Move where -nodefaultlibs is specified
authorPierre Ossman <ossman@cendio.se>
Wed, 21 Jun 2023 11:58:57 +0000 (13:58 +0200)
committerPierre Ossman <ossman@cendio.se>
Wed, 28 Jun 2023 13:54:12 +0000 (15:54 +0200)
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.

cmake/StaticBuild.cmake

index 1a3bdb46202b557be8be0e12c5fd6e704b5efd42..495b53a1c5ece2e622fe800652c0c67f42b28ff9 100644 (file)
@@ -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()