am 949be649: am 1029ba1f: Fix srgb_unsigned_byte RBO test regression with NV_sRGB_for...
[platform/upstream/VK-GL-CTS.git] / framework / delibs / cmake / Defs.cmake
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
21 # \note Always include this file in main project file, with NO_POLICY_SCOPE
22 #       AFTER project(name) statement.
23 #
24 # project(deproject)
25 # include(delibs/cmake/Defs.cmake NO_POLICY_SCOPE)
26
27 cmake_policy(VERSION 2.6)
28
29 # \todo [pyry] More intelligent detection, perhaps use some script?
30
31 # cmake files can use DE_DEFS variable to check that this file has been included
32 set(DE_DEFS 1)
33
34 macro (DE_MAKE_ENV_BOOL BASE VALUE)
35         if (${BASE} STREQUAL ${BASE}_${VALUE})
36                 set(${BASE}_IS_${VALUE} 1)
37         else ()
38                 set(${BASE}_IS_${VALUE} 0)
39         endif ()
40 endmacro ()
41
42 # Os detection
43 if (NOT DEFINED DE_OS)
44         if (WIN32)
45                 set(DE_OS "DE_OS_WIN32")
46         elseif (APPLE)
47                 set(DE_OS "DE_OS_OSX")
48         elseif (UNIX)
49                 set(DE_OS "DE_OS_UNIX")
50         else ()
51                 set(DE_OS "DE_OS_VANILLA")
52         endif ()
53 endif ()
54
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")
63
64 # Compiler detection
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")
74
75         # Guess based on OS
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")
82
83         else ()
84                 set(DE_COMPILER "DE_COMPILER_VANILLA")
85         endif ()
86 endif ()
87
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")
93
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})
98         else ()
99                 set(DE_PTR_SIZE 4)
100         endif ()
101 endif ()
102
103 # CPU detection
104 if (NOT DEFINED DE_CPU)
105         if (DE_PTR_SIZE EQUAL 8)
106                 set(DE_CPU "DE_CPU_X86_64")
107         else ()
108                 set(DE_CPU "DE_CPU_X86")
109         endif ()
110 endif ()
111
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")
117
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)
123 else ()
124         message(FATAL_ERROR "DE_PTR_SIZE (${DE_PTR_SIZE}) is invalid")
125 endif ()
126
127 # Debug definitions
128 if (NOT DEFINED DE_DEBUG)
129         if (CMAKE_BUILD_TYPE STREQUAL "Debug")
130                 set(DE_DEBUG 1)
131         else ()
132                 set(DE_DEBUG 0)
133         endif ()
134 endif ()
135
136 # Android API version
137 if (DE_OS_IS_ANDROID AND NOT DEFINED DE_ANDROID_API)
138         set(DE_ANDROID_API 5)
139 endif ()
140
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}")
148 endif ()
149
150 # Expose definitions
151 if (DE_DEBUG)
152         add_definitions(-DDE_DEBUG)
153 endif ()
154
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}")
159
160 if (DE_OS_IS_ANDROID)
161         add_definitions("-DDE_ANDROID_API=${DE_ANDROID_API}")
162 endif ()