am 887a9db1: am 8167db47: am 80fe30bf: (-s ours) am 27ad6a99: Merge "Improve calibrat...
[platform/upstream/VK-GL-CTS.git] / CMakeLists.txt
1 # dEQP cmake file
2
3 cmake_minimum_required(VERSION 2.6)
4
5 # dEQP Target.
6 set(DEQP_TARGET "default" CACHE STRING "dEQP Target (default, android...)")
7
8 project(dEQP-Core-${DEQP_TARGET})
9
10 include(framework/delibs/cmake/Defs.cmake NO_POLICY_SCOPE)
11 include(framework/delibs/cmake/CFlags.cmake)
12
13 add_definitions(-DDE_ASSERT_FAILURE_CALLBACK)
14
15 # dEQP-specific configuration. Target file should override these.
16 set(DEQP_TARGET_NAME            "UNKNOWN")              # Target name
17
18 set(DEQP_SUPPORT_GLES1          OFF)                    # Is GLESv1 supported
19 set(DEQP_GLES1_LIBRARIES        )                               # GLESv1 libraries
20
21 set(DEQP_SUPPORT_GLES2          OFF)                    # Is GLESv2 supported
22 set(DEQP_GLES2_LIBRARIES        )                               # GLESv2 libraries. If empty, run-time linking is used
23
24 set(DEQP_SUPPORT_GLES3          OFF)                    # Is GLESv3 supported
25 set(DEQP_GLES3_LIBRARIES        )                               # GLESv3 libraries. If empty, run-time linking is used
26
27 set(DEQP_SUPPORT_VG                     OFF)                    # Is VG supported
28 set(DEQP_VG_LIBRARIES           )                               # VG libraries
29
30 set(DEQP_SUPPORT_EGL            OFF)                    # Is EGL supported
31 set(DEQP_EGL_LIBRARIES          )                               # EGL libraries
32
33 set(DEQP_SUPPORT_GLX            OFF)                    # Is GLX supported
34 set(DEQP_SUPPORT_WGL            OFF)                    # Is WGL supported
35
36 set(DEQP_PLATFORM_LIBRARIES     )                               # Other platform libraries
37
38 set(DEQP_SUPPORT_OPENGL         OFF)                    # Is OpenGL supported on platform
39                                                                                         # \note OpenGL is always loaded on run-time
40
41 set(DEQP_PLATFORM_COPY_LIBRARIES        )               # Libraries / binaries that need to be copied to binary directory
42
43 # Delibs include directories
44 include_directories(
45         framework/delibs/debase
46         framework/delibs/decpp
47         framework/delibs/depool
48         framework/delibs/dethread
49         framework/delibs/deutil
50         framework/delibs/destream
51         )
52
53 # Include target-specific definitions
54 include(targets/${DEQP_TARGET}/${DEQP_TARGET}.cmake)
55
56 # zlib
57 find_path(ZLIB_INCLUDE_PATH     zlib.h)
58 find_library(ZLIB_LIBRARY       z)
59
60 if (NOT ZLIB_INCLUDE_PATH OR NOT ZLIB_LIBRARY)
61         message(STATUS "System version of zlib not found, using external/zlib")
62         add_subdirectory(external/zlib)
63         # \note ZLIB_LIBRARY and ZLIB_INCLUDE_PATH are promoted from external/zlib/CMakeLists.txt
64 endif ()
65
66 include_directories(${ZLIB_INCLUDE_PATH})
67
68 # libpng
69 find_path(PNG_INCLUDE_PATH      libpng.h)
70 find_library(PNG_LIBRARY        png)
71
72 if (NOT PNG_INCLUDE_PATH OR NOT PNG_LIBRARY)
73         message(STATUS "System version of libpng not found, using external/libpng")
74         add_subdirectory(external/libpng)
75         # \note PNG_LIBRARY and PNG_INCLUDE_PATH are promoted from external/libpng/CMakeLists.txt
76 endif ()
77
78 # glslang
79 add_subdirectory(external/glslang)
80
81 include_directories(${PNG_INCLUDE_PATH})
82
83 message(STATUS "DEQP_TARGET_NAME        = ${DEQP_TARGET_NAME}")
84 message(STATUS "DEQP_SUPPORT_GLES1      = ${DEQP_SUPPORT_GLES1}")
85 message(STATUS "DEQP_GLES1_LIBRARIES    = ${DEQP_GLES1_LIBRARIES}")
86 message(STATUS "DEQP_SUPPORT_GLES2      = ${DEQP_SUPPORT_GLES2}")
87 message(STATUS "DEQP_GLES2_LIBRARIES    = ${DEQP_GLES2_LIBRARIES}")
88 message(STATUS "DEQP_SUPPORT_GLES3      = ${DEQP_SUPPORT_GLES3}")
89 message(STATUS "DEQP_GLES3_LIBRARIES    = ${DEQP_GLES3_LIBRARIES}")
90 message(STATUS "DEQP_SUPPORT_VG         = ${DEQP_SUPPORT_VG}")
91 message(STATUS "DEQP_VG_LIBRARIES       = ${DEQP_VG_LIBRARIES}")
92 message(STATUS "DEQP_SUPPORT_EGL        = ${DEQP_SUPPORT_EGL}")
93 message(STATUS "DEQP_EGL_LIBRARIES      = ${DEQP_EGL_LIBRARIES}")
94 message(STATUS "DEQP_SUPPORT_OPENGL     = ${DEQP_SUPPORT_OPENGL}")
95 message(STATUS "DEQP_PLATFORM_LIBRARIES = ${DEQP_PLATFORM_LIBRARIES}")
96 message(STATUS "DEQP_SUPPORT_WGL        = ${DEQP_SUPPORT_WGL}")
97 message(STATUS "DEQP_SUPPORT_GLX        = ${DEQP_SUPPORT_GLX}")
98
99 # Defines
100 add_definitions(-DDEQP_TARGET_NAME="${DEQP_TARGET_NAME}")
101
102 if (DEQP_SUPPORT_GLES1)
103         add_definitions(-DDEQP_SUPPORT_GLES1=1)
104 endif ()
105
106 if (DEQP_SUPPORT_GLES2)
107         add_definitions(-DDEQP_SUPPORT_GLES2=1)
108 endif ()
109
110 if (DEQP_SUPPORT_GLES3)
111         add_definitions(-DDEQP_SUPPORT_GLES3=1)
112 endif ()
113
114 if (DEQP_SUPPORT_VG)
115         add_definitions(-DDEQP_SUPPORT_VG=1)
116 endif ()
117
118 if (DEQP_SUPPORT_EGL)
119         add_definitions(-DDEQP_SUPPORT_EGL=1)
120 endif ()
121
122 if (DEQP_SUPPORT_OPENGL)
123         add_definitions(-DDEQP_SUPPORT_OPENGL=1)
124 endif ()
125
126 if (DEQP_SUPPORT_WGL)
127         add_definitions(-DDEQP_SUPPORT_WGL=1)
128 endif ()
129
130 if (DEQP_SUPPORT_GLX)
131         add_definitions(-DDEQP_SUPPORT_GLX=1)
132 endif ()
133
134 # Check runtime linking support
135 if (DEQP_SUPPORT_GLES1 AND NOT DEFINED DEQP_GLES1_LIBRARIES)
136         message(FATAL_ERROR "Run-time loading of GLES1 is not supported (DEQP_GLES1_LIBRARIES is not set)")
137 endif ()
138
139 if (DEQP_SUPPORT_GLES2 AND NOT DEFINED DEQP_GLES2_LIBRARIES)
140         add_definitions(-DDEQP_GLES2_RUNTIME_LOAD=1)
141 endif ()
142
143 if (DEQP_SUPPORT_GLES3 AND NOT DEFINED DEQP_GLES3_LIBRARIES)
144         add_definitions(-DDEQP_GLES3_RUNTIME_LOAD=1)
145 endif ()
146
147 if (DEQP_SUPPORT_VG AND NOT DEFINED DEQP_VG_LIBRARIES)
148         message(FATAL_ERROR "Run-time loading of VG is not supported (DEQP_VG_LIBRARIES is not set)")
149 endif ()
150
151 if (DEQP_SUPPORT_EGL AND NOT DEFINED DEQP_EGL_LIBRARIES)
152         add_definitions(-DDEQP_EGL_RUNTIME_LOAD=1)
153 endif ()
154
155 # OpenGL is always loaded on run-time
156 if (DEQP_SUPPORT_OPENGL)
157         add_definitions(-DDEQP_OPENGL_RUNTIME_LOAD=1)
158 endif ()
159
160 if (DE_COMPILER_IS_MSC)
161         # Don't nag about std::copy for example
162         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SCL_SECURE_NO_WARNINGS")
163 endif ()
164
165 # delibs projects
166 add_subdirectory(framework/delibs/debase)
167 add_subdirectory(framework/delibs/depool)
168 add_subdirectory(framework/delibs/dethread)
169 add_subdirectory(framework/delibs/destream)
170 add_subdirectory(framework/delibs/deutil)
171 add_subdirectory(framework/delibs/decpp)
172
173 # ExecServer
174 add_subdirectory(execserver)
175
176 # Executor framework and tools
177 if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/executor)
178         add_subdirectory(executor)
179 endif ()
180
181 # Test framework include directories
182 include_directories(
183         framework/common
184         framework/qphelper
185         framework/opengl
186         framework/opengl/wrapper
187         framework/referencerenderer
188         framework/opengl/simplereference
189         framework/randomshaders
190         framework/egl
191         framework/egl/wrapper
192         external/vulkancts/framework/vulkan
193         )
194
195 if (DE_OS_IS_ANDROID OR DE_OS_IS_IOS)
196         # On Android deqp modules are compiled as libraries and linked into final .so
197         set(DEQP_MODULE_LIBRARIES )
198         set(DEQP_MODULE_ENTRY_POINTS )
199 endif ()
200
201 if (DE_OS_IS_WIN32)
202         include_directories(framework/platform/win32)
203 endif ()
204
205 # Macro for adding targets for copying binaries (usually target libraries) to the target destination dir
206 macro (target_copy_files target dep_name files)
207         if (NOT "${files}" STREQUAL "")
208                 set(COPY_TARGETS )
209                 foreach (SRCNAME ${files})
210                         get_filename_component(BASENAME ${SRCNAME} NAME)
211                         set(DSTNAME "${CMAKE_CURRENT_BINARY_DIR}/${BASENAME}")
212                         add_custom_command(OUTPUT ${DSTNAME}
213                                                            COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SRCNAME} ${DSTNAME})
214                         set(COPY_TARGETS ${COPY_TARGETS} ${DSTNAME})
215                 endforeach ()
216
217                 add_custom_target(${dep_name} ALL DEPENDS ${COPY_TARGETS})
218                 add_dependencies(${target} ${dep_name})
219         endif ()
220 endmacro (target_copy_files)
221
222 # Macro for adding dEQP module
223 macro (add_deqp_module MODULE_NAME SRCS LIBS ENTRY)
224         if (DE_OS_IS_ANDROID OR DE_OS_IS_IOS)
225                 # Single-binary targets
226                 add_library(${MODULE_NAME} STATIC ${SRCS})
227                 target_link_libraries(${MODULE_NAME} ${LIBS})
228
229                 set(DEQP_MODULE_LIBRARIES               ${DEQP_MODULE_LIBRARIES} ${MODULE_NAME})
230                 set(DEQP_MODULE_ENTRY_POINTS    ${DEQP_MODULE_ENTRY_POINTS} "${CMAKE_CURRENT_SOURCE_DIR}/${ENTRY}")
231
232                 # Forward to parent scope
233                 set(DEQP_MODULE_LIBRARIES               ${DEQP_MODULE_LIBRARIES} PARENT_SCOPE)
234                 set(DEQP_MODULE_ENTRY_POINTS    ${DEQP_MODULE_ENTRY_POINTS} PARENT_SCOPE)
235
236         else ()
237                 # Separate binary per target
238                 add_executable(${MODULE_NAME} ${CMAKE_SOURCE_DIR}/framework/platform/tcuMain.cpp ${ENTRY} ${SRCS})
239                 target_link_libraries(${MODULE_NAME} tcutil-platform ${LIBS})
240                 target_copy_files(${MODULE_NAME} platform-libs-${MODULE_NAME} "${DEQP_PLATFORM_COPY_LIBRARIES}")
241         endif ()
242
243         # Data file target
244         add_custom_target(${MODULE_NAME}-data)
245         add_dependencies(${MODULE_NAME} ${MODULE_NAME}-data)
246 endmacro (add_deqp_module)
247
248 # Macro for adding data dirs to module
249 macro (add_data_dir MODULE_NAME SRC_DIR DST_DIR)
250         if (DE_OS_IS_WIN32 OR DE_OS_IS_UNIX OR DE_OS_IS_OSX)
251                 add_custom_command(TARGET ${MODULE_NAME}-data POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/${SRC_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${DST_DIR})
252
253         elseif (DE_OS_IS_ANDROID)
254                 add_custom_command(TARGET ${MODULE_NAME}-data POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/${SRC_DIR} ${CMAKE_BINARY_DIR}/assets/${DST_DIR})
255
256         elseif (DE_OS_IS_IOS)
257                 add_custom_command(TARGET ${MODULE_NAME}-data POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/${SRC_DIR} ${CMAKE_BINARY_DIR}/\${CONFIGURATION}\${EFFECTIVE_PLATFORM_NAME}/deqp.app/${DST_DIR})
258         endif ()
259 endmacro (add_data_dir)
260
261 # Macro for adding individual data files to module
262 macro (add_data_file MODULE_NAME SRC_FILE DST_FILE)
263         if (DE_OS_IS_WIN32 OR DE_OS_IS_UNIX OR DE_OS_IS_OSX)
264                 add_custom_command(TARGET ${MODULE_NAME}-data POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DST_FILE})
265
266         elseif (DE_OS_IS_ANDROID)
267                 add_custom_command(TARGET ${MODULE_NAME}-data POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FILE} ${CMAKE_BINARY_DIR}/assets/${DST_FILE})
268
269         elseif (DE_OS_IS_IOS)
270                 add_custom_command(TARGET ${MODULE_NAME}-data POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FILE} ${CMAKE_BINARY_DIR}/\${CONFIGURATION}\${EFFECTIVE_PLATFORM_NAME}/deqp.app/${DST_FILE})
271         endif ()
272 endmacro (add_data_file)
273
274 add_subdirectory(framework)
275 add_subdirectory(external/vulkancts/framework/vulkan)
276
277 if (DE_COMPILER_IS_MSC)
278         add_compile_options(/bigobj) # Required by glsBuiltinPrecisionTests.cpp
279 endif ()
280
281 add_subdirectory(modules)
282 add_subdirectory(external/vulkancts/modules/vulkan)
283
284 # Single-binary targets
285 if (DE_OS_IS_ANDROID)
286         include_directories(executor)
287
288         add_library(deqp SHARED framework/platform/android/tcuAndroidMain.cpp framework/platform/android/tcuAndroidJNI.cpp framework/platform/android/tcuAndroidPlatformCapabilityQueryJNI.cpp framework/platform/android/tcuTestLogParserJNI.cpp ${DEQP_MODULE_ENTRY_POINTS})
289         target_link_libraries(deqp tcutil-platform xecore ${DEQP_MODULE_LIBRARIES})
290
291 elseif (DE_OS_IS_IOS)
292         # Code sign identity
293         set(DEQP_IOS_CODE_SIGN_IDENTITY "drawElements" CACHE STRING "Code sign identity for iOS build")
294
295         set(MACOSX_BUNDLE_PRODUCT_NAME "\${PRODUCT_NAME}")
296         set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.drawelements.\${PRODUCT_NAME:identifier}")
297
298         include_directories(framework/platform/ios)
299         set(TESTERCORE_SRC_FILES
300                 framework/platform/ios/tcuEAGLView.h
301                 framework/platform/ios/tcuEAGLView.m
302                 framework/platform/ios/tcuIOSAppDelegate.h
303                 framework/platform/ios/tcuIOSAppDelegate.m
304                 framework/platform/ios/tcuIOSViewController.h
305                 framework/platform/ios/tcuIOSViewController.m
306                 framework/platform/ios/tcuIOSMain.m
307                 )
308         set_source_files_properties(${TESTERCORE_SRC_FILES} COMPILE_FLAGS "-std=c99")
309
310         add_executable(deqp MACOSX_BUNDLE ${TESTERCORE_SRC_FILES} ${DEQP_MODULE_ENTRY_POINTS})
311         target_link_libraries(deqp tcutil-platform xscore ${DEQP_MODULE_LIBRARIES})
312         set_target_properties(deqp PROPERTIES XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2")
313         set_target_properties(deqp PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer: ${DEQP_IOS_CODE_SIGN_IDENTITY}")
314 endif ()