Merge vk-gl-cts/vulkan-cts-1.2.8 into vk-gl-cts/master
[platform/upstream/VK-GL-CTS.git] / CMakeLists.txt
1 # dEQP cmake file
2
3 # Module FindGit requires cmake >= 2.8.2
4 cmake_minimum_required(VERSION 3.10.2)
5
6 find_package(Git)
7 find_package(PythonInterp 3)
8
9 # dEQP Target.
10 set(DEQP_TARGET "default" CACHE STRING "dEQP Target (default, android...)")
11
12 if (DEFINED DEQP_TARGET_TOOLCHAIN)
13         # \note Toolchain must be included before project() command
14         include(targets/${DEQP_TARGET}/${DEQP_TARGET_TOOLCHAIN}.cmake NO_POLICY_SCOPE)
15 endif ()
16
17 project(dEQP-Core-${DEQP_TARGET})
18
19 include(framework/delibs/cmake/Defs.cmake NO_POLICY_SCOPE)
20 include(framework/delibs/cmake/CFlags.cmake)
21
22 add_definitions(-DDE_ASSERT_FAILURE_CALLBACK)
23
24 # dEQP-specific configuration. Target file should override these.
25 set(DEQP_TARGET_NAME            "UNKNOWN")              # Target name
26
27 set(DEQP_GLES2_LIBRARIES        )                               # GLESv2 libraries. If empty, run-time linking is used
28 set(DEQP_GLES3_LIBRARIES        )                               # GLESv3 libraries. If empty, run-time linking is used
29 set(DEQP_EGL_LIBRARIES          )                               # EGL libraries
30
31 # Legacy APIs that don't use run-time loading
32 set(DEQP_SUPPORT_GLES1          OFF)                    # Is GLESv1 supported
33 set(DEQP_GLES1_LIBRARIES        )                               # GLESv1 libraries
34 set(DEQP_SUPPORT_VG                     OFF)                    # Is OpenVG supported
35 set(DEQP_VG_LIBRARIES           )                               # VG libraries
36
37 set(DEQP_SUPPORT_WGL            OFF)
38 set(DEQP_SUPPORT_GLX            OFF)                    # Is GLX supported \todo [2016-10-12 pyry] X11 specific - move to framework/platform/
39
40 set(DEQP_PLATFORM_LIBRARIES     )                               # Other platform libraries
41
42 set(DEQP_PLATFORM_COPY_LIBRARIES        )               # Libraries / binaries that need to be copied to binary directory
43
44 # Delibs include directories
45 include_directories(
46         framework/delibs/debase
47         framework/delibs/decpp
48         framework/delibs/depool
49         framework/delibs/dethread
50         framework/delibs/deutil
51         framework/delibs/destream
52         )
53
54 # Include target-specific definitions
55 include(targets/${DEQP_TARGET}/${DEQP_TARGET}.cmake)
56
57 # zlib
58 find_package(ZLIB)
59 # dEQP CMake compatibility (as for libpng)
60 set(ZLIB_INCLUDE_PATH ${ZLIB_INCLUDE_DIRS})
61 set(ZLIB_LIBRARY ${ZLIB_LIBRARIES})
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 if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external/renderdoc/src/renderdoc_app.h")
70         message(STATUS "Renderdoc header found, integration enabled")
71         set(DEQP_HAVE_RENDERDOC_HEADER 1)
72 else ()
73         message(STATUS "Renderdoc header not found, integration will not work")
74 endif ()
75
76 include_directories(${ZLIB_INCLUDE_PATH})
77
78 # libpng
79 #
80 # The FindPNG module defines PNG_INCLUDE_DIRS and PNG_LIBRARIES. But dEQP's
81 # CMake files expect the non-standard PNG_INCLUDE_PATH and PNG_LIBRARY. Set the
82 # non-standard variables here to retain compatibility with dEQP's existing
83 # CMake files.
84 find_package(PNG)
85 set(PNG_INCLUDE_PATH ${PNG_INCLUDE_DIRS})
86 set(PNG_LIBRARY ${PNG_LIBRARIES})
87
88 if (NOT PNG_INCLUDE_PATH OR NOT PNG_LIBRARY)
89         message(STATUS "System version of libpng not found, using external/libpng")
90         add_subdirectory(external/libpng)
91         # \note PNG_LIBRARY and PNG_INCLUDE_PATH are promoted from external/libpng/CMakeLists.txt
92 endif ()
93
94 # glslang
95 add_subdirectory(external/glslang)
96
97 # spirv-tools
98 add_subdirectory(external/spirv-tools)
99
100 # spirv-headers
101 set(SPIRV_INCLUDE_PATH "${PROJECT_SOURCE_DIR}/external/spirv-headers/src/include")
102 if (NOT EXISTS ${SPIRV_INCLUDE_PATH})
103         message(FATAL_ERROR "SPIR-V headers not found, please run external/fetch_sources.py")
104 endif()
105 include_directories(${SPIRV_INCLUDE_PATH})
106
107 # Amber
108 add_subdirectory(external/amber)
109 include_directories(external/amber)
110
111 # RenderDoc API
112 include_directories(external/renderdoc/src)
113
114 include_directories(${PNG_INCLUDE_PATH})
115
116 # DRM (Direct Rendering Manager) Headers
117 find_path(XF86DRM_H_PATH NAMES xf86drm.h)
118 find_path(DRM_H_PATH NAMES drm.h PATH_SUFFIXES libdrm drm)
119
120 if (XF86DRM_H_PATH AND DRM_H_PATH)
121         include_directories(${XF86DRM_H_PATH})
122         include_directories(${DRM_H_PATH})
123         set(DEQP_SUPPORT_DRM ON CACHE BOOL "Build code requiring the Linux/Unix Direct Rendering Manager")
124         mark_as_advanced(XF86DRM_H_PATH)
125         mark_as_advanced(DRM_H_PATH)
126 else ()
127         set(DEQP_SUPPORT_DRM OFF CACHE BOOL "Build code requiring the Linux/Unix Direct Rendering Manager")
128 endif ()
129
130 message(STATUS "DEQP_TARGET_NAME        = ${DEQP_TARGET_NAME}")
131 message(STATUS "DEQP_SUPPORT_GLES1      = ${DEQP_SUPPORT_GLES1}")
132 message(STATUS "DEQP_GLES1_LIBRARIES    = ${DEQP_GLES1_LIBRARIES}")
133 message(STATUS "DEQP_GLES2_LIBRARIES    = ${DEQP_GLES2_LIBRARIES}")
134 message(STATUS "DEQP_GLES3_LIBRARIES    = ${DEQP_GLES3_LIBRARIES}")
135 message(STATUS "DEQP_GLES31_LIBRARIES   = ${DEQP_GLES31_LIBRARIES}")
136 message(STATUS "DEQP_GLES32_LIBRARIES   = ${DEQP_GLES32_LIBRARIES}")
137 message(STATUS "DEQP_SUPPORT_VG         = ${DEQP_SUPPORT_VG}")
138 message(STATUS "DEQP_VG_LIBRARIES       = ${DEQP_VG_LIBRARIES}")
139 message(STATUS "DEQP_EGL_LIBRARIES      = ${DEQP_EGL_LIBRARIES}")
140 message(STATUS "DEQP_PLATFORM_LIBRARIES = ${DEQP_PLATFORM_LIBRARIES}")
141 message(STATUS "DEQP_SUPPORT_DRM        = ${DEQP_SUPPORT_DRM}")
142
143 # Defines
144 add_definitions(-DDEQP_TARGET_NAME="${DEQP_TARGET_NAME}")
145
146 # Entry points loaded directly by linking to libGL*?
147 if (DEFINED DEQP_GLES2_LIBRARIES)
148         add_definitions(-DDEQP_GLES2_DIRECT_LINK=1)
149 endif ()
150
151 if (DEFINED DEQP_GLES3_LIBRARIES)
152         add_definitions(-DDEQP_GLES3_DIRECT_LINK=1)
153 endif ()
154
155 if (DEFINED DEQP_GLES31_LIBRARIES)
156         add_definitions(-DDEQP_GLES31_DIRECT_LINK=1)
157 endif ()
158
159 if (DEFINED DEQP_GLES32_LIBRARIES)
160         add_definitions(-DDEQP_GLES32_DIRECT_LINK=1)
161 endif ()
162
163 if (DEFINED DEQP_EGL_LIBRARIES)
164         add_definitions(-DDEQP_EGL_DIRECT_LINK=1)
165 endif ()
166
167 # Legacy APIs that don't support run-time loading
168 if (DEQP_SUPPORT_GLES1)
169         add_definitions(-DDEQP_SUPPORT_GLES1=1)
170
171         if (NOT DEFINED DEQP_GLES1_LIBRARIES)
172                 message(FATAL_ERROR "Run-time loading of GLES1 is not supported (DEQP_GLES1_LIBRARIES is not set)")
173         endif ()
174 endif ()
175
176 if (DEQP_SUPPORT_VG)
177         add_definitions(-DDEQP_SUPPORT_VG=1)
178
179         if (NOT DEFINED DEQP_VG_LIBRARIES)
180                 message(FATAL_ERROR "Run-time loading of VG is not supported (DEQP_VG_LIBRARIES is not set)")
181         endif ()
182 endif ()
183
184 if (DEQP_SUPPORT_DRM)
185         add_definitions(-DDEQP_SUPPORT_DRM=1)
186 else ()
187         add_definitions(-DDEQP_SUPPORT_DRM=0)
188 endif ()
189
190 if (DE_COMPILER_IS_MSC)
191         # Don't nag about std::copy for example
192         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SCL_SECURE_NO_WARNINGS")
193 endif ()
194
195 # Precompiled header macro. Parameters are source file list and filename for pch cpp file.
196 macro(PCH SRCS PCHCPP)
197   if(MSVC AND CMAKE_GENERATOR MATCHES "^Visual Studio")
198     set(PCH_NAME "$(IntDir)\\pch.pch")
199     # make source files use/depend on PCH_NAME
200     set_source_files_properties(${${SRCS}} PROPERTIES COMPILE_FLAGS "/Yupch.h /FIpch.h /Fp${PCH_NAME}" OBJECT_DEPENDS "${PCH_NAME}")
201     # make PCHCPP file compile and generate PCH_NAME
202     set_source_files_properties(${PCHCPP} PROPERTIES COMPILE_FLAGS "/Ycpch.h /Fp${PCH_NAME}" OBJECT_OUTPUTS "${PCH_NAME}")
203     list(APPEND ${SRCS} "${PCHCPP}")
204   endif()
205 endmacro(PCH)
206
207 # delibs projects
208 add_subdirectory(framework/delibs/debase)
209 add_subdirectory(framework/delibs/depool)
210 add_subdirectory(framework/delibs/dethread)
211 add_subdirectory(framework/delibs/destream)
212 add_subdirectory(framework/delibs/deutil)
213 add_subdirectory(framework/delibs/decpp)
214
215 # ExecServer
216 add_subdirectory(execserver)
217
218 # Executor framework and tools
219 if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/executor)
220         add_subdirectory(executor)
221 endif ()
222
223 # Test framework include directories
224 include_directories(
225         framework/common
226         framework/qphelper
227         framework/opengl
228         framework/opengl/wrapper
229         framework/referencerenderer
230         framework/opengl/simplereference
231         framework/randomshaders
232         framework/egl
233         framework/egl/wrapper
234         framework/xexml
235         external/vulkancts/framework/vulkan
236         )
237
238 if (DE_OS_IS_ANDROID OR DE_OS_IS_IOS)
239         # On Android deqp modules are compiled as libraries and linked into final .so
240         set(DEQP_MODULE_LIBRARIES )
241         set(DEQP_MODULE_ENTRY_POINTS )
242 endif ()
243
244 # Macro for adding targets for copying binaries (usually target libraries) to the target destination dir
245 macro (target_copy_files target dep_name files)
246         if (NOT "${files}" STREQUAL "")
247                 set(COPY_TARGETS )
248                 foreach (SRCNAME ${files})
249                         get_filename_component(BASENAME ${SRCNAME} NAME)
250                         set(DSTNAME "${CMAKE_CURRENT_BINARY_DIR}/${BASENAME}")
251                         add_custom_command(OUTPUT ${DSTNAME}
252                                                            COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SRCNAME} ${DSTNAME})
253                         set(COPY_TARGETS ${COPY_TARGETS} ${DSTNAME})
254                 endforeach ()
255
256                 add_custom_target(${dep_name} ALL DEPENDS ${COPY_TARGETS})
257                 add_dependencies(${target} ${dep_name})
258         endif ()
259 endmacro (target_copy_files)
260
261 set(MODULE_LIB_TARGET_POSTFIX   "-package")
262 set(MODULE_DATA_TARGET_POSTFIX  "-data")
263
264 # Macro for adding dEQP module
265 # This adds 3 targets:
266 #       ${MODULE_NAME}-package:         Static library that contains all SRCS and links to LIBS
267 #       ${MODULE_NAME}-data:            Custom target that is used for data file copies
268 #       ${MODULE_NAME}:                         Executable binary (if supported by the platform)
269 macro (add_deqp_module MODULE_NAME SRCS LIBS ENTRY)
270
271         # Library target
272         add_library("${MODULE_NAME}${MODULE_LIB_TARGET_POSTFIX}" STATIC ${SRCS})
273         target_link_libraries("${MODULE_NAME}${MODULE_LIB_TARGET_POSTFIX}" ${LIBS})
274
275         set(DEQP_MODULE_LIBRARIES               ${DEQP_MODULE_LIBRARIES} "${MODULE_NAME}${MODULE_LIB_TARGET_POSTFIX}")
276         set(DEQP_MODULE_ENTRY_POINTS    ${DEQP_MODULE_ENTRY_POINTS} "${CMAKE_CURRENT_SOURCE_DIR}/${ENTRY}")
277
278         # Forward to parent scope
279         set(DEQP_MODULE_LIBRARIES               ${DEQP_MODULE_LIBRARIES} PARENT_SCOPE)
280         set(DEQP_MODULE_ENTRY_POINTS    ${DEQP_MODULE_ENTRY_POINTS} PARENT_SCOPE)
281
282         if (NOT DE_OS_IS_ANDROID AND NOT DE_OS_IS_IOS)
283                 # Executable target
284                 add_executable(${MODULE_NAME} ${PROJECT_SOURCE_DIR}/framework/platform/tcuMain.cpp ${ENTRY})
285                 target_link_libraries(${MODULE_NAME} tcutil-platform "${MODULE_NAME}${MODULE_LIB_TARGET_POSTFIX}")
286                 target_copy_files(${MODULE_NAME} platform-libs-${MODULE_NAME} "${DEQP_PLATFORM_COPY_LIBRARIES}")
287         endif ()
288
289         # Data file target
290         add_custom_target("${MODULE_NAME}${MODULE_DATA_TARGET_POSTFIX}")
291         add_dependencies("${MODULE_NAME}${MODULE_LIB_TARGET_POSTFIX}" "${MODULE_NAME}${MODULE_DATA_TARGET_POSTFIX}")
292 endmacro (add_deqp_module)
293
294 # Macro for adding data dirs to module
295 macro (add_data_dir MODULE_NAME SRC_DIR DST_DIR)
296         if (DE_OS_IS_WIN32 OR DE_OS_IS_UNIX OR DE_OS_IS_OSX OR DE_OS_IS_QNX)
297                 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})
298
299         elseif (DE_OS_IS_ANDROID)
300                 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})
301
302         elseif (DE_OS_IS_IOS)
303                 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})
304         endif ()
305 endmacro (add_data_dir)
306
307 # Macro for adding individual data files to module
308 macro (add_data_file MODULE_NAME SRC_FILE DST_FILE)
309         if (DE_OS_IS_WIN32 OR DE_OS_IS_UNIX OR DE_OS_IS_OSX OR DE_OS_IS_QNX)
310                 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})
311
312         elseif (DE_OS_IS_ANDROID)
313                 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})
314
315         elseif (DE_OS_IS_IOS)
316                 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})
317         endif ()
318 endmacro (add_data_file)
319
320 add_subdirectory(framework)
321 add_subdirectory(external/vulkancts/framework/vulkan)
322
323 if (DE_COMPILER_IS_MSC)
324         add_compile_options(/bigobj) # Required by glsBuiltinPrecisionTests.cpp
325 endif ()
326
327 add_subdirectory(modules)
328 add_subdirectory(external/vulkancts/modules/vulkan)
329 add_subdirectory(external/openglcts)
330
331 # Single-binary targets
332 if (DE_OS_IS_ANDROID)
333         include_directories(executor)
334
335         set(DEQP_SRCS
336                 framework/platform/android/tcuAndroidMain.cpp
337                 framework/platform/android/tcuAndroidJNI.cpp
338                 framework/platform/android/tcuAndroidPlatformCapabilityQueryJNI.cpp
339                 framework/platform/android/tcuTestLogParserJNI.cpp
340                 ${DEQP_MODULE_ENTRY_POINTS}
341                 )
342
343         set(DEQP_LIBS
344                 tcutil-platform
345                 xecore
346                 ${DEQP_MODULE_LIBRARIES}
347                 )
348
349         add_library(deqp SHARED ${DEQP_SRCS})
350         target_link_libraries(deqp ${DEQP_LIBS})
351
352         # Separate out the debug information because it's enormous
353         add_custom_command(TARGET deqp POST_BUILD
354                 COMMAND ${CMAKE_STRIP} --only-keep-debug -o $<TARGET_FILE:deqp>.debug $<TARGET_FILE:deqp>
355                 COMMAND ${CMAKE_STRIP} -g $<TARGET_FILE:deqp>)
356
357         # Needed by OpenGL CTS that defines its own activity but depends on
358         # common Android support code.
359         target_include_directories(deqp PRIVATE framework/platform/android)
360
361 elseif (DE_OS_IS_IOS)
362         # Code sign identity
363         set(DEQP_IOS_CODE_SIGN_IDENTITY "drawElements" CACHE STRING "Code sign identity for iOS build")
364
365         set(MACOSX_BUNDLE_PRODUCT_NAME "\${PRODUCT_NAME}")
366         set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.drawelements.\${PRODUCT_NAME:identifier}")
367
368         include_directories(framework/platform/ios)
369         set(TESTERCORE_SRC_FILES
370                 framework/platform/ios/tcuEAGLView.h
371                 framework/platform/ios/tcuEAGLView.m
372                 framework/platform/ios/tcuIOSAppDelegate.h
373                 framework/platform/ios/tcuIOSAppDelegate.m
374                 framework/platform/ios/tcuIOSViewController.h
375                 framework/platform/ios/tcuIOSViewController.m
376                 framework/platform/ios/tcuIOSMain.m
377                 )
378         set_source_files_properties(${TESTERCORE_SRC_FILES} COMPILE_FLAGS "-std=c99")
379
380         add_executable(deqp MACOSX_BUNDLE ${TESTERCORE_SRC_FILES} ${DEQP_MODULE_ENTRY_POINTS})
381         target_link_libraries(deqp tcutil-platform xscore ${DEQP_MODULE_LIBRARIES})
382         set_target_properties(deqp PROPERTIES XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2")
383         set_target_properties(deqp PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer: ${DEQP_IOS_CODE_SIGN_IDENTITY}")
384 endif ()