• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#-------------------------------------------------------------------------
2# drawElements CMake utilities
3# ----------------------------
4#
5# Copyright 2014 The Android Open Source Project
6#
7# Licensed under the Apache License, Version 2.0 (the "License");
8# you may not use this file except in compliance with the License.
9# You may obtain a copy of the License at
10#
11#      http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18#
19#-------------------------------------------------------------------------
20
21set(DE_COVERAGE_BUILD "OFF" CACHE STRING "Build with coverage instrumentation with GCC (ON/OFF)")
22
23if (NOT DE_DEFS)
24	message(FATAL_ERROR "Defs.cmake is not included")
25endif ()
26
27if (DE_OS_IS_ANDROID)
28	set(GCC_COMMON_FLAGS		"-Wall -Wextra -Wshadow -Wundef -Wno-long-long")
29
30	# For 3rd party sw disable all warnings
31	set(DE_3RD_PARTY_C_FLAGS	"${CMAKE_C_FLAGS} -w")
32	set(DE_3RD_PARTY_CXX_FLAGS	"${CMAKE_CXX_FLAGS} -w")
33
34	set(CMAKE_C_FLAGS			"${CMAKE_C_FLAGS} ${GCC_COMMON_FLAGS} -ansi -pedantic")
35	set(CMAKE_CXX_FLAGS			"${CMAKE_CXX_FLAGS} ${GCC_COMMON_FLAGS}") # Don't warn about va_list
36
37elseif (DE_OS_IS_SYMBIAN)
38	# \todo [kalle] Add our warning flags.
39	# \todo [kalle] Soft-float WTF?
40	# \todo [kalle] Emulator build
41	set(WARNING_FLAGS           "-Wall -Wno-unknown-pragmas -Wno-parentheses -Wno-comment")
42
43	if (DE_DEBUG)
44		set(OPTIMIZATION_FLAGS "-g")
45	else (DE_DEBUG)
46		set(OPTIMIZATION_FLAGS "-O3")
47	endif (DE_DEBUG)
48
49    set(GCC_COMMON_FLAGS        "-march=armv5t -mapcs -pipe -nostdinc -msoft-float ${OPTIMIZATION_FLAGS} -include ${SYMBIAN_EPOCROOT}/include/gcce/gcce.h")
50
51	# Should these be embedded directly into the flags? Is it possible that these lists get cleared?
52	add_definitions("-D_UNICODE")
53	add_definitions("-D__GCCE__ -D__MARM__ -D__MARM_ARMV5__ -D__EABI__")
54	add_definitions("-D__SYMBIAN32__ -D__EPOC32__ -D__SERIES60_30__ -D__SERIES60_3X__")
55	add_definitions("-D__EXE__")
56	add_definitions("-D__PRODUCT_INLUDE__=${SYMBIAN_EPOCROOT}/include/variant/Symbian_OS.hrh")
57	add_definitions("-DSYMBIAN_ENABLE_SPLIT_HEADERS")
58	add_definitions("-D_POSIX_C_SOURCE=200112") # Value taken from epoc32/release/armv5/udeb/libcrt0.lib
59
60	# \review [2011-08-31 pyry] CMake should set this automatically, right?
61	if (DE_DEBUG)
62		add_definitions("-D_DEBUG")
63	endif (DE_DEBUG)
64
65	include_directories(
66		${SYMBIAN_EPOCROOT}/include/stdapis
67		${SYMBIAN_EPOCROOT}/include/stdapis/stlportv5
68		${SYMBIAN_EPOCROOT}/include/variant
69		${SYMBIAN_EPOCROOT}/include
70		${SYMBIAN_EPOCROOT}/include/platform
71		${SYMBIAN_EPOCROOT}/include/esdl
72		${SYMBIAN_EPOCROOT}/include/mw
73		${SYMBIAN_EPOCROOT}/include/platform/mw
74		${SYMBIAN_EPOCROOT}/include/libc
75		${COMPILER_INCLUDE_DIR}
76	)
77
78	# -Wno-psabi == Don't warn about va_list
79	# \note _STLP_USE_MALLOC=1 enables stlport malloc based allocator => our code needs to implement static function void* __malloc_alloc::allocate(size_t& __n)
80	set(GCC_CXX_FLAGS           "${GCC_COMMON_FLAGS} -Wno-psabi -Wno-ctor-dtor-privacy -D__SUPPORT_CPP_EXCEPTIONS__ -D__SYMBIAN_STDCPP_SUPPORT__ -D__LEAVE_EQUALS_THROW__ -D_STLP_USE_MALLOC=1")
81	# \todo [kalle] -ansi -pedantic
82	set(CMAKE_C_FLAGS			"${CMAKE_C_FLAGS} ${WARNING_FLAGS} ${GCC_COMMON_FLAGS}")
83	set(CMAKE_CXX_FLAGS			"${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} ${GCC_CXX_FLAGS}")
84
85	set(DE_3RD_PARTY_C_FLAGS	"${CMAKE_C_FLAGS} -w ${GCC_COMMON_FLAGS}")
86	set(DE_3RD_PARTY_CXX_FLAGS	"${CMAKE_CXX_FLAGS} -w ${GCC_CXX_FLAGS}")
87
88	# \todo [kalle] Add map file using TARGET_BASE variable?
89	if (DE_DEBUG)
90		set(SYMBIAN_PLATFORM_LINK_DIR "${SYMBIAN_EPOCROOT}/RELEASE/ARMV5/UDEB")
91	else (DE_DEBUG)
92		set(SYMBIAN_PLATFORM_LINK_DIR "${SYMBIAN_EPOCROOT}/RELEASE/ARMV5/UREL")
93	endif (DE_DEBUG)
94	set(CMAKE_C_LINK_FLAGS     "-Ttext 0x8000 -Tdata 0x400000 -Xlinker --target1-abs -Xlinker --no-undefined -Xlinker --default-symver -nostdlib -shared --entry _E32Startup -u _E32Startup ${SYMBIAN_LIB_DIR}/libc.dso ${SYMBIAN_LIB_DIR}/libm.dso ${SYMBIAN_LIB_DIR}/drtaeabi.dso ${SYMBIAN_LIB_DIR}/dfpaeabi.dso")
95
96	set(CMAKE_CXX_LINK_FLAGS   "${CMAKE_C_LINK_FLAGS} ${SYMBIAN_LIB_DIR}/stdnew.dso ${SYMBIAN_LIB_DIR}/libstdcppv5.dso")
97	set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SYMBIAN_PLATFORM_LINK_DIR}/eexe.lib ${SYMBIAN_LIB_DIR}/euser.dso")
98	link_directories(${COMPILER_LIB_DIR})
99
100elseif (DE_COMPILER_IS_GCC)
101	# Compiler flags for gcc
102
103	# \note Add -Wconversion and -Wundef for more warnings
104	set(GCC_COMMON_FLAGS "-Wall -Wextra -Wno-long-long -Wshadow -Wundef")
105
106	if (DE_CPU_IS_X86)
107		set(GCC_MACHINE_FLAGS "-m32")
108	elseif (DE_CPU_IS_X86_64)
109		set(GCC_MACHINE_FLAGS "-m64")
110	endif ()
111
112	if (DE_COVERAGE_BUILD)
113		add_definitions("-DDE_COVERAGE_BUILD")
114		set(GCC_MACHINE_FLAGS "${GCC_MACHINE_FLAGS} -fprofile-arcs -ftest-coverage")
115		set(LINK_FLAGS "${LINK_FLAGS} -lgcov")
116	endif ()
117
118	# For 3rd party sw disable all warnings
119	set(DE_3RD_PARTY_C_FLAGS   "${CMAKE_C_FLAGS} -w ${GCC_MACHINE_FLAGS}")
120	set(DE_3RD_PARTY_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w ${GCC_MACHINE_FLAGS}")
121
122	set(CMAKE_C_FLAGS	       "${CMAKE_C_FLAGS} ${GCC_COMMON_FLAGS} ${GCC_MACHINE_FLAGS} -ansi -pedantic ")
123	set(CMAKE_CXX_FLAGS	       "${CMAKE_CXX_FLAGS} ${GCC_COMMON_FLAGS} ${GCC_MACHINE_FLAGS}")
124
125elseif (DE_COMPILER_IS_MSC)
126	# Compiler flags for msc
127
128	# \note Following unnecessary nagging warnings are disabled:
129	# 4820: automatic padding added after data
130	# 4255: no function prototype given (from system headers)
131	# 4668: undefined identifier in preprocessor expression (from system headers)
132	# 4738: storing 32-bit float result in memory
133	# 4711: automatic inline expansion
134	set(MSC_BASE_FLAGS "/DWIN32 /D_WINDOWS /D_CRT_SECURE_NO_WARNINGS")
135	set(MSC_WARNING_FLAGS "/W3 /wd4820 /wd4255 /wd4668 /wd4738 /wd4711")
136
137	# For 3rd party sw disable all warnings
138	set(DE_3RD_PARTY_C_FLAGS    "${CMAKE_C_FLAGS} ${MSC_BASE_FLAGS} /W0")
139	set(DE_3RD_PARTY_CXX_FLAGS  "${CMAKE_CXX_FLAGS} ${MSC_BASE_FLAGS} /W0")
140
141	set(CMAKE_C_FLAGS	         "${CMAKE_C_FLAGS} ${MSC_BASE_FLAGS} ${MSC_WARNING_FLAGS}")
142	set(CMAKE_CXX_FLAGS	         "${CMAKE_CXX_FLAGS} ${MSC_BASE_FLAGS} ${MSC_WARNING_FLAGS}")
143
144elseif (DE_COMPILER_IS_CLANG)
145	# Compiler flags for clang
146
147	# \note Add -Wconversion and -Wundef for more warnings
148	set(CLANG_COMMON_FLAGS "-Wall -Wextra -Wno-long-long -Wshadow -Wundef")
149
150	if (DE_CPU_IS_X86)
151		set(CLANG_MACHINE_FLAGS "-m32")
152	elseif (DE_CPU_IS_X86_64)
153		set(CLANG_MACHINE_FLAGS "-m64")
154	endif ()
155
156	# For 3rd party sw disable all warnings
157	set(DE_3RD_PARTY_C_FLAGS   "${CMAKE_C_FLAGS} -w ${CLANG_MACHINE_FLAGS}")
158	set(DE_3RD_PARTY_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w ${CLANG_MACHINE_FLAGS} -frtti -fexceptions")
159
160	set(CMAKE_C_FLAGS	       "${CMAKE_C_FLAGS} ${CLANG_COMMON_FLAGS} ${CLANG_MACHINE_FLAGS} -ansi -pedantic ")
161	set(CMAKE_CXX_FLAGS	       "${CMAKE_CXX_FLAGS} ${CLANG_COMMON_FLAGS} ${CLANG_MACHINE_FLAGS} -frtti -fexceptions")
162
163else ()
164	message(FATAL_ERROR "DE_COMPILER is not valid")
165endif ()
166