summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmake/StaticBuild.cmake8
1 files changed, 7 insertions, 1 deletions
diff --git a/cmake/StaticBuild.cmake b/cmake/StaticBuild.cmake
index 25c10777..5a3d9987 100644
--- a/cmake/StaticBuild.cmake
+++ b/cmake/StaticBuild.cmake
@@ -10,9 +10,14 @@
option(BUILD_STATIC
"Link statically against most libraries, if possible" OFF)
+option(BUILD_STATIC_GCC
+ "Link statically against only libgcc and libstdc++" OFF)
+
if(BUILD_STATIC)
message(STATUS "Attempting to link static binaries...")
+ set(BUILD_STATIC_GCC 1)
+
set(JPEG_LIBRARIES "-Wl,-Bstatic -ljpeg -Wl,-Bdynamic")
if(WIN32)
@@ -105,7 +110,9 @@ if(BUILD_STATIC)
set(X11_Xdamage_LIB "-Wl,-Bstatic -lXdamage -Wl,-Bdynamic")
endif()
endif()
+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 "-Wl,-Bstatic -lstdc++ -Wl,-Bdynamic")
@@ -122,5 +129,4 @@ if(BUILD_STATIC)
set(STATIC_BASE_LIBRARIES "${STATIC_BASE_LIBRARIES} -lgcc -lgcc_eh -lc")
endif()
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} ${STATIC_BASE_LIBRARIES}")
-
endif()