aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/cmake/00-Common.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/cmake/00-Common.cmake')
-rw-r--r--linden/indra/cmake/00-Common.cmake206
1 files changed, 206 insertions, 0 deletions
diff --git a/linden/indra/cmake/00-Common.cmake b/linden/indra/cmake/00-Common.cmake
new file mode 100644
index 0000000..240853a
--- /dev/null
+++ b/linden/indra/cmake/00-Common.cmake
@@ -0,0 +1,206 @@
1# -*- cmake -*-
2#
3# Compilation options shared by all Second Life components.
4
5include(Variables)
6
7
8# Portable compilation flags.
9
10set(CMAKE_CXX_FLAGS_DEBUG "-D_DEBUG -DLL_DEBUG=1")
11set(CMAKE_CXX_FLAGS_RELEASE
12 "-DLL_RELEASE=1 -DLL_RELEASE_FOR_DOWNLOAD=1 -DNDEBUG")
13set(CMAKE_CXX_FLAGS_RELWITHDEBINFO
14 "-DLL_RELEASE=1 -DNDEBUG -DLL_RELEASE_WITH_DEBUG_INFO=1")
15
16
17# Don't bother with a MinSizeRel build.
18
19set(CMAKE_CONFIGURATION_TYPES "RelWithDebInfo;Release;Debug" CACHE STRING
20 "Supported build types." FORCE)
21
22
23# Platform-specific compilation flags.
24
25if (WINDOWS)
26 # Don't build DLLs.
27 set(BUILD_SHARED_LIBS OFF)
28
29 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Od /Zi /MTd"
30 CACHE STRING "C++ compiler debug options" FORCE)
31 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO
32 "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od /Zi /MT"
33 CACHE STRING "C++ compiler release-with-debug options" FORCE)
34 set(CMAKE_CXX_FLAGS_RELEASE
35 "${CMAKE_CXX_FLAGS_RELEASE} ${LL_CXX_FLAGS} /O2 /Zi /MT"
36 CACHE STRING "C++ compiler release options" FORCE)
37
38 add_definitions(
39 /DLL_WINDOWS=1
40 /DUNICODE
41 /D_UNICODE
42 /GS
43 /TP
44 /W3
45 /c
46 /Zc:forScope
47 /nologo
48 /Oy-
49 )
50
51 if(MSVC80 OR MSVC90)
52 add_definitions(
53 /Zc:wchar_t-
54 )
55 endif (MSVC80 OR MSVC90)
56
57 # Are we using the crummy Visual Studio KDU build workaround?
58 if (NOT VS_DISABLE_FATAL_WARNINGS)
59 add_definitions(/WX)
60 endif (NOT VS_DISABLE_FATAL_WARNINGS)
61endif (WINDOWS)
62
63
64if (LINUX)
65 set(CMAKE_SKIP_RPATH TRUE)
66
67 # Here's a giant hack for Fedora 8, where we can't use
68 # _FORTIFY_SOURCE if we're using a compiler older than gcc 4.1.
69
70 find_program(GXX g++)
71 mark_as_advanced(GXX)
72
73 if (GXX)
74 execute_process(
75 COMMAND ${GXX} --version
76 COMMAND sed "s/^[gc+ ]*//"
77 COMMAND head -1
78 OUTPUT_VARIABLE GXX_VERSION
79 OUTPUT_STRIP_TRAILING_WHITESPACE
80 )
81 else (GXX)
82 set(GXX_VERSION x)
83 endif (GXX)
84
85 # The quoting hack here is necessary in case we're using distcc or
86 # ccache as our compiler. CMake doesn't pass the command line
87 # through the shell by default, so we end up trying to run "distcc"
88 # " g++" - notice the leading space. Ugh.
89
90 execute_process(
91 COMMAND sh -c "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} --version"
92 COMMAND sed "s/^[gc+ ]*//"
93 COMMAND head -1
94 OUTPUT_VARIABLE CXX_VERSION
95 OUTPUT_STRIP_TRAILING_WHITESPACE)
96
97 if (${GXX_VERSION} STREQUAL ${CXX_VERSION})
98 add_definitions(-D_FORTIFY_SOURCE=2)
99 else (${GXX_VERSION} STREQUAL ${CXX_VERSION})
100 if (NOT ${GXX_VERSION} MATCHES " 4.1.*Red Hat")
101 add_definitions(-D_FORTIFY_SOURCE=2)
102 endif (NOT ${GXX_VERSION} MATCHES " 4.1.*Red Hat")
103 endif (${GXX_VERSION} STREQUAL ${CXX_VERSION})
104
105 # GCC 4.3 introduces a pile of obnoxious new warnings, which we
106 # treat as errors due to -Werror. Quiet the most offensive and
107 # widespread of them.
108
109 if (${CXX_VERSION} MATCHES "4.3")
110 add_definitions(-Wno-deprecated -Wno-parentheses)
111 endif (${CXX_VERSION} MATCHES "4.3")
112
113 # End of hacks.
114
115 add_definitions(
116 -DLL_LINUX=1
117 -D_REENTRANT
118 -fexceptions
119 -fno-math-errno
120 -fno-strict-aliasing
121 -fsigned-char
122 -g
123 -pthread
124 )
125
126 if (SERVER)
127 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth-60")
128 if (EXISTS /etc/debian_version)
129 FILE(READ /etc/debian_version DEBIAN_VERSION)
130 else (EXISTS /etc/debian_version)
131 set(DEBIAN_VERSION "")
132 endif (EXISTS /etc/debian_version)
133
134 if (NOT DEBIAN_VERSION STREQUAL "3.1")
135 add_definitions(-DCTYPE_WORKAROUND)
136 endif (NOT DEBIAN_VERSION STREQUAL "3.1")
137
138 if (EXISTS /usr/lib/mysql4/mysql)
139 link_directories(/usr/lib/mysql4/mysql)
140 endif (EXISTS /usr/lib/mysql4/mysql)
141
142 add_definitions(
143 -msse2
144 -mfpmath=sse
145 )
146 endif (SERVER)
147
148 if (VIEWER)
149 add_definitions(-DAPPID=secondlife)
150 add_definitions(-fvisibility=hidden)
151 if (NOT STANDALONE)
152 # this stops us requiring a really recent glibc at runtime
153 add_definitions(-fno-stack-protector)
154 endif (NOT STANDALONE)
155 endif (VIEWER)
156
157 set(CMAKE_CXX_FLAGS_DEBUG "-fno-inline ${CMAKE_CXX_FLAGS_DEBUG}")
158 set(CMAKE_CXX_FLAGS_RELEASE "-O2 ${CMAKE_CXX_FLAGS_RELEASE}")
159endif (LINUX)
160
161
162if (DARWIN)
163 add_definitions(-DLL_DARWIN=1)
164 set(CMAKE_CXX_LINK_FLAGS "-Wl,-headerpad_max_install_names,-search_paths_first")
165 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS}")
166 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mlong-branch")
167 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mlong-branch")
168endif (DARWIN)
169
170
171if (LINUX OR DARWIN)
172 set(GCC_WARNINGS "-Wall -Wno-sign-compare -Wno-trigraphs")
173
174 if (NOT GCC_DISABLE_FATAL_WARNINGS)
175 set(GCC_WARNINGS "${GCC_WARNINGS} -Werror")
176 endif (NOT GCC_DISABLE_FATAL_WARNINGS)
177
178 set(GCC_CXX_WARNINGS "${GCC_WARNINGS} -Wno-reorder")
179
180 set(CMAKE_C_FLAGS "${GCC_WARNINGS} ${CMAKE_C_FLAGS}")
181 set(CMAKE_CXX_FLAGS "${GCC_CXX_WARNINGS} ${CMAKE_CXX_FLAGS}")
182endif (LINUX OR DARWIN)
183
184
185if (STANDALONE)
186 add_definitions(-DLL_STANDALONE=1)
187
188 if (LINUX AND ${ARCH} STREQUAL "i686")
189 add_definitions(-march=pentiumpro)
190 endif (LINUX AND ${ARCH} STREQUAL "i686")
191
192else (STANDALONE)
193 set(${ARCH}_linux_INCLUDES
194 ELFIO
195 atk-1.0
196 glib-2.0
197 gstreamer-0.10
198 gtk-2.0
199 llfreetype2
200 pango-1.0
201 )
202endif (STANDALONE)
203
204if(SERVER)
205 include_directories(${LIBS_PREBUILT_DIR}/include/havok)
206endif(SERVER)