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