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_COMPILER_IS_GCC OR DE_COMPILER_IS_CLANG) 28 # Compiler flags for GCC/Clang 29 30 set(TARGET_FLAGS "") 31 32 if (DE_COVERAGE_BUILD) 33 if (not DE_COMPILER_IS_GCC) 34 message(FATAL_ERROR "Coverage build requires GCC") 35 endif () 36 37 add_definitions("-DDE_COVERAGE_BUILD") 38 set(TARGET_FLAGS "-fprofile-arcs -ftest-coverage") 39 set(LINK_FLAGS "${LINK_FLAGS} -lgcov") 40 endif () 41 42 # For 3rd party sw disable all warnings 43 set(DE_3RD_PARTY_C_FLAGS "${CMAKE_C_FLAGS} ${TARGET_FLAGS} -w") 44 set(DE_3RD_PARTY_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TARGET_FLAGS} -w") 45 46 # \note Add -Wconversion for more warnings 47 set(WARNING_FLAGS "-Wall -Wextra -Wno-long-long -Wshadow -Wundef") 48 49 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TARGET_FLAGS} ${WARNING_FLAGS} -ansi -pedantic ") 50 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TARGET_FLAGS} ${WARNING_FLAGS}") 51 52elseif (DE_COMPILER_IS_MSC) 53 # Compiler flags for msc 54 55 # \note Following unnecessary nagging warnings are disabled: 56 # 4820: automatic padding added after data 57 # 4255: no function prototype given (from system headers) 58 # 4668: undefined identifier in preprocessor expression (from system headers) 59 # 4738: storing 32-bit float result in memory 60 # 4711: automatic inline expansion 61 set(MSC_BASE_FLAGS "/DWIN32 /D_WINDOWS /D_CRT_SECURE_NO_WARNINGS") 62 set(MSC_WARNING_FLAGS "/W3 /wd4820 /wd4255 /wd4668 /wd4738 /wd4711") 63 64 # For 3rd party sw disable all warnings 65 set(DE_3RD_PARTY_C_FLAGS "${CMAKE_C_FLAGS} ${MSC_BASE_FLAGS} /W0") 66 set(DE_3RD_PARTY_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MSC_BASE_FLAGS} /W0") 67 68 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MSC_BASE_FLAGS} ${MSC_WARNING_FLAGS}") 69 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MSC_BASE_FLAGS} ${MSC_WARNING_FLAGS}") 70 71else () 72 message(FATAL_ERROR "DE_COMPILER is not valid") 73endif () 74