1 #-------------------------------------------------------------------------
2 # drawElements CMake utilities
3 # ----------------------------
5 # Copyright 2014 The Android Open Source Project
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
11 # http://www.apache.org/licenses/LICENSE-2.0
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.
19 #-------------------------------------------------------------------------
21 # \note Always include this file in main project file, with NO_POLICY_SCOPE
22 # AFTER project(name) statement.
25 # include(delibs/cmake/Defs.cmake NO_POLICY_SCOPE)
27 cmake_policy(VERSION 2.6)
29 # \todo [pyry] More intelligent detection, perhaps use some script?
31 # cmake files can use DE_DEFS variable to check that this file has been included
34 macro (DE_MAKE_ENV_BOOL BASE VALUE)
35 if (${BASE} STREQUAL ${BASE}_${VALUE})
36 set(${BASE}_IS_${VALUE} 1)
38 set(${BASE}_IS_${VALUE} 0)
43 if (NOT DEFINED DE_OS)
45 set(DE_OS "DE_OS_WIN32")
47 set(DE_OS "DE_OS_OSX")
49 set(DE_OS "DE_OS_UNIX")
51 set(DE_OS "DE_OS_VANILLA")
55 # DE_OS_IS_{PLATFORM} definitions
56 DE_MAKE_ENV_BOOL("DE_OS" "VANILLA")
57 DE_MAKE_ENV_BOOL("DE_OS" "WIN32")
58 DE_MAKE_ENV_BOOL("DE_OS" "UNIX")
59 DE_MAKE_ENV_BOOL("DE_OS" "WINCE")
60 DE_MAKE_ENV_BOOL("DE_OS" "OSX")
61 DE_MAKE_ENV_BOOL("DE_OS" "ANDROID")
62 DE_MAKE_ENV_BOOL("DE_OS" "IOS")
65 if (NOT DEFINED DE_COMPILER)
66 # \note " x" postfix is to work around bug in CMake that causes
67 # "MSVC" to translate to something completely different
68 if (("${CMAKE_C_COMPILER_ID} x" MATCHES "MSVC") OR MSVC)
69 set(DE_COMPILER "DE_COMPILER_MSC")
70 elseif ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU")
71 set(DE_COMPILER "DE_COMPILER_GCC")
72 elseif ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
73 set(DE_COMPILER "DE_COMPILER_CLANG")
76 elseif (DE_OS_IS_WIN32)
77 set(DE_COMPILER "DE_COMPILER_MSC")
78 elseif (DE_OS_IS_UNIX OR DE_OS_IS_ANDROID)
79 set(DE_COMPILER "DE_COMPILER_GCC")
80 elseif (DE_OS_IS_OSX OR DE_OS_IS_IOS)
81 set(DE_COMPILER "DE_COMPILER_CLANG")
84 set(DE_COMPILER "DE_COMPILER_VANILLA")
88 # DE_COMPILER_IS_{COMPILER} definitions
89 DE_MAKE_ENV_BOOL("DE_COMPILER" "VANILLA")
90 DE_MAKE_ENV_BOOL("DE_COMPILER" "MSC")
91 DE_MAKE_ENV_BOOL("DE_COMPILER" "GCC")
92 DE_MAKE_ENV_BOOL("DE_COMPILER" "CLANG")
94 # Pointer size detection
95 if (NOT DEFINED DE_PTR_SIZE)
96 if (DEFINED CMAKE_SIZEOF_VOID_P)
97 set(DE_PTR_SIZE ${CMAKE_SIZEOF_VOID_P})
104 if (NOT DEFINED DE_CPU)
105 if (DE_PTR_SIZE EQUAL 8)
106 set(DE_CPU "DE_CPU_X86_64")
108 set(DE_CPU "DE_CPU_X86")
112 # DE_CPU_IS_{CPU} definitions
113 DE_MAKE_ENV_BOOL("DE_CPU" "VANILLA")
114 DE_MAKE_ENV_BOOL("DE_CPU" "X86")
115 DE_MAKE_ENV_BOOL("DE_CPU" "ARM")
116 DE_MAKE_ENV_BOOL("DE_CPU" "ARM_64")
118 # \note [petri] Re-wrote in this ugly manner, because CMake 2.6 seems to
119 # barf about the parenthesis in the previous way. Ugh.
120 #if (NOT ((DE_PTR_SIZE EQUAL 4) OR (DE_PTR_SIZE EQUAL 8)))
121 if (DE_PTR_SIZE EQUAL 4)
122 elseif (DE_PTR_SIZE EQUAL 8)
124 message(FATAL_ERROR "DE_PTR_SIZE (${DE_PTR_SIZE}) is invalid")
128 if (NOT DEFINED DE_DEBUG)
129 if (CMAKE_BUILD_TYPE STREQUAL "Debug")
136 # Android API version
137 if (DE_OS_IS_ANDROID AND NOT DEFINED DE_ANDROID_API)
138 set(DE_ANDROID_API 5)
141 message(STATUS "DE_OS = ${DE_OS}")
142 message(STATUS "DE_COMPILER = ${DE_COMPILER}")
143 message(STATUS "DE_CPU = ${DE_CPU}")
144 message(STATUS "DE_PTR_SIZE = ${DE_PTR_SIZE}")
145 message(STATUS "DE_DEBUG = ${DE_DEBUG}")
146 if (DE_OS_IS_ANDROID)
147 message(STATUS "DE_ANDROID_API = ${DE_ANDROID_API}")
152 add_definitions(-DDE_DEBUG)
155 add_definitions("-DDE_OS=${DE_OS}")
156 add_definitions("-DDE_COMPILER=${DE_COMPILER}")
157 add_definitions("-DDE_CPU=${DE_CPU}")
158 add_definitions("-DDE_PTR_SIZE=${DE_PTR_SIZE}")
160 if (DE_OS_IS_ANDROID)
161 add_definitions("-DDE_ANDROID_API=${DE_ANDROID_API}")