blob: 9aac0372d4f891bfabac7ea3c63a4931979ff0ae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
>From 7a15d1c9a908afe429c1aba1c27516d18bdea299 Mon Sep 17 00:00:00 2001
From: DRC <information@virtualgl.org>
Date: Tue, 26 Feb 2013 03:37:12 -0600
Subject: [PATCH 1/4] Add BUILD_STATIC feature from TigerVNC to (optionally)
prevent FLTK from depending on libgcc and libstdc++
---
CMakeLists.txt | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a1ee285..7d9d94b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -150,6 +150,49 @@ mark_as_advanced(LIB_CAIRO LIB_fontconfig LIB_freetype)
mark_as_advanced(LIB_GL LIB_MesaGL)
mark_as_advanced(LIB_jpeg LIB_png LIB_zlib)
+# This ensures that we don't depend on libstdc++ or libgcc
+if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE AND NOT CYGWIN)
+ option(BUILD_STATIC
+ "Link statically against libgcc and libstdc++, if possible" OFF)
+ if(BUILD_STATIC)
+ # For some reason, simply passing ${CMAKE_CXX_FLAGS} to the compiler in
+ # execute_process() doesn't work. Grrr...
+ if(CMAKE_SIZEOF_VOID_P MATCHES 8)
+ execute_process(COMMAND ${CMAKE_CXX_COMPILER} -m64
+ --print-file-name=libstdc++.a OUTPUT_VARIABLE LIBSTDCPLUSPLUS
+ RESULT_VARIABLE RESULT)
+ else()
+ execute_process(COMMAND ${CMAKE_CXX_COMPILER} -m32
+ --print-file-name=libstdc++.a OUTPUT_VARIABLE LIBSTDCPLUSPLUS
+ RESULT_VARIABLE RESULT)
+ endif()
+ string(REGEX REPLACE "\n" "" LIBSTDCPLUSPLUS ${LIBSTDCPLUSPLUS})
+ if(RESULT MATCHES 0 AND LIBSTDCPLUSPLUS)
+ message(STATUS "Linking with static libstdc++:\n ${LIBSTDCPLUSPLUS}")
+ file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/staticlib)
+ execute_process(COMMAND ${CMAKE_COMMAND} -E remove
+ ${CMAKE_BINARY_DIR}/staticlib/libstdc++.a)
+ if(MINGW)
+ execute_process(COMMAND ${CMAKE_COMMAND} -E copy
+ ${LIBSTDCPLUSPLUS} ${CMAKE_BINARY_DIR}/staticlib/libstdc++.a)
+ else()
+ execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
+ ${LIBSTDCPLUSPLUS} ${CMAKE_BINARY_DIR}/staticlib/libstdc++.a)
+ endif()
+ set(CMAKE_EXE_LINKER_FLAGS
+ "${CMAKE_EXE_LINKER_FLAGS} -L${CMAKE_BINARY_DIR}/staticlib")
+ set(CMAKE_SHARED_LINKER_FLAGS
+ "${CMAKE_SHARED_LINKER_FLAGS} -L${CMAKE_BINARY_DIR}/staticlib")
+ else()
+ message(WARNING Cannot find static libstdc++. TigerVNC will depend on dynamic libstdc++.)
+ endif()
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc")
+ set(CMAKE_SHARED_LINKER_FLAGS
+ "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc")
+ endif()
+endif()
+
#######################################################################
# functions
include(CheckFunctionExists)
--
1.8.1.3
|