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