Merge vk-gl-cts/vulkan-cts-1.1.1 into vk-gl-cts/vulkan-cts-1.1.2
[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 2.8.2)
5
6 find_package(Git)
7 find_package(PythonInterp 2)
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_path(ZLIB_INCLUDE_PATH     zlib.h)
59 find_library(ZLIB_LIBRARY       z)
60
61 if (NOT ZLIB_INCLUDE_PATH OR NOT ZLIB_LIBRARY)
62         message(STATUS "System version of zlib not found, using external/zlib")
63         add_subdirectory(external/zlib)
64         # \note ZLIB_LIBRARY and ZLIB_INCLUDE_PATH are promoted from external/zlib/CMakeLists.txt
65 endif ()
66
67 include_directories(${ZLIB_INCLUDE_PATH})
68
69 # libpng
70 #
71 # The FindPNG module defines PNG_INCLUDE_DIRS and PNG_LIBRARIES. But dEQP's
72 # CMake files expect the non-standard PNG_INCLUDE_PATH and PNG_LIBRARY. Set the
73 # non-standard variables here to retain compatibility with dEQP's existing
74 # CMake files.
75 include(FindPNG)
76 set(PNG_INCLUDE_PATH ${PNG_INCLUDE_DIRS})
77 set(PNG_LIBRARY ${PNG_LIBRARIES})
78
79 if (NOT PNG_INCLUDE_PATH OR NOT PNG_LIBRARY)
80         message(STATUS "System version of libpng not found, using external/libpng")
81         add_subdirectory(external/libpng)
82         # \note PNG_LIBRARY and PNG_INCLUDE_PATH are promoted from external/libpng/CMakeLists.txt
83 endif ()
84
85 # glslang
86 add_subdirectory(external/glslang)
87
88 # spirv-tools
89 add_subdirectory(external/spirv-tools)
90
91 # spirv-headers
92 set(SPIRV_INCLUDE_PATH "${PROJECT_SOURCE_DIR}/external/spirv-headers/src/include")
93 if (NOT EXISTS ${SPIRV_INCLUDE_PATH})
94         message(FATAL_ERROR "SPIR-V headers not found, please run external/fetch_sources.py")
95 endif()
96 include_directories(${SPIRV_INCLUDE_PATH})
97
98 include_directories(${PNG_INCLUDE_PATH})
99
100 message(STATUS "DEQP_TARGET_NAME        = ${DEQP_TARGET_NAME}")
101 message(STATUS "DEQP_SUPPORT_GLES1      = ${DEQP_SUPPORT_GLES1}")
102 message(STATUS "DEQP_GLES1_LIBRARIES    = ${DEQP_GLES1_LIBRARIES}")
103 message(STATUS "DEQP_GLES2_LIBRARIES    = ${DEQP_GLES2_LIBRARIES}")
104 message(STATUS "DEQP_GLES3_LIBRARIES    = ${DEQP_GLES3_LIBRARIES}")
105 message(STATUS "DEQP_GLES31_LIBRARIES   = ${DEQP_GLES31_LIBRARIES}")
106 message(STATUS "DEQP_GLES32_LIBRARIES   = ${DEQP_GLES32_LIBRARIES}")
107 message(STATUS "DEQP_SUPPORT_VG         = ${DEQP_SUPPORT_VG}")
108 message(STATUS "DEQP_VG_LIBRARIES       = ${DEQP_VG_LIBRARIES}")
109 message(STATUS "DEQP_EGL_LIBRARIES      = ${DEQP_EGL_LIBRARIES}")
110 message(STATUS "DEQP_PLATFORM_LIBRARIES = ${DEQP_PLATFORM_LIBRARIES}")
111
112 # Defines
113 add_definitions(-DDEQP_TARGET_NAME="${DEQP_TARGET_NAME}")
114
115 # Entry points loaded directly by linking to libGL*?
116 if (DEFINED DEQP_GLES2_LIBRARIES)
117         add_definitions(-DDEQP_GLES2_DIRECT_LINK=1)
118 endif ()
119
120 if (DEFINED DEQP_GLES3_LIBRARIES)
121         add_definitions(-DDEQP_GLES3_DIRECT_LINK=1)
122 endif ()
123
124 if (DEFINED DEQP_GLES31_LIBRARIES)
125         add_definitions(-DDEQP_GLES31_DIRECT_LINK=1)
126 endif ()
127
128 if (DEFINED DEQP_GLES32_LIBRARIES)
129         add_definitions(-DDEQP_GLES32_DIRECT_LINK=1)
130 endif ()
131
132 if (DEFINED DEQP_EGL_LIBRARIES)
133         add_definitions(-DDEQP_EGL_DIRECT_LINK=1)
134 endif ()
135
136 # Legacy APIs that don't support run-time loading
137 if (DEQP_SUPPORT_GLES1)
138         add_definitions(-DDEQP_SUPPORT_GLES1=1)
139
140         if (NOT DEFINED DEQP_GLES1_LIBRARIES)
141                 message(FATAL_ERROR "Run-time loading of GLES1 is not supported (DEQP_GLES1_LIBRARIES is not set)")
142         endif ()
143 endif ()
144
145 if (DEQP_SUPPORT_VG)
146         add_definitions(-DDEQP_SUPPORT_VG=1)
147
148         if (NOT DEFINED DEQP_VG_LIBRARIES)
149                 message(FATAL_ERROR "Run-time loading of VG is not supported (DEQP_VG_LIBRARIES is not set)")
150         endif ()
151 endif ()
152
153 if (DE_COMPILER_IS_MSC)
154         # Don't nag about std::copy for example
155         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SCL_SECURE_NO_WARNINGS")
156 endif ()
157
158 # delibs projects
159 add_subdirectory(framework/delibs/debase)
160 add_subdirectory(framework/delibs/depool)
161 add_subdirectory(framework/delibs/dethread)
162 add_subdirectory(framework/delibs/destream)
163 add_subdirectory(framework/delibs/deutil)
164 add_subdirectory(framework/delibs/decpp)
165
166 # ExecServer
167 add_subdirectory(execserver)
168
169 # Executor framework and tools
170 if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/executor)
171         add_subdirectory(executor)
172 endif ()
173
174 # Test framework include directories
175 include_directories(
176         framework/common
177         framework/qphelper
178         framework/opengl
179         framework/opengl/wrapper
180         framework/referencerenderer
181         framework/opengl/simplereference
182         framework/randomshaders
183         framework/egl
184         framework/egl/wrapper
185         external/vulkancts/framework/vulkan
186         )
187
188 if (DE_OS_IS_ANDROID OR DE_OS_IS_IOS)
189         # On Android deqp modules are compiled as libraries and linked into final .so
190         set(DEQP_MODULE_LIBRARIES )
191         set(DEQP_MODULE_ENTRY_POINTS )
192 endif ()
193
194 # Macro for adding targets for copying binaries (usually target libraries) to the target destination dir
195 macro (target_copy_files target dep_name files)
196         if (NOT "${files}" STREQUAL "")
197                 set(COPY_TARGETS )
198                 foreach (SRCNAME ${files})
199                         get_filename_component(BASENAME ${SRCNAME} NAME)
200                         set(DSTNAME "${CMAKE_CURRENT_BINARY_DIR}/${BASENAME}")
201                         add_custom_command(OUTPUT ${DSTNAME}
202                                                            COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SRCNAME} ${DSTNAME})
203                         set(COPY_TARGETS ${COPY_TARGETS} ${DSTNAME})
204                 endforeach ()
205
206                 add_custom_target(${dep_name} ALL DEPENDS ${COPY_TARGETS})
207                 add_dependencies(${target} ${dep_name})
208         endif ()
209 endmacro (target_copy_files)
210
211 set(MODULE_LIB_TARGET_POSTFIX   "-package")
212 set(MODULE_DATA_TARGET_POSTFIX  "-data")
213
214 # Macro for adding dEQP module
215 # This adds 3 targets:
216 #       ${MODULE_NAME}-package:         Static library that contains all SRCS and links to LIBS
217 #       ${MODULE_NAME}-data:            Custom target that is used for data file copies
218 #       ${MODULE_NAME}:                         Executable binary (if supported by the platform)
219 macro (add_deqp_module MODULE_NAME SRCS LIBS ENTRY)
220
221         # Library target
222         add_library("${MODULE_NAME}${MODULE_LIB_TARGET_POSTFIX}" STATIC ${SRCS})
223         target_link_libraries("${MODULE_NAME}${MODULE_LIB_TARGET_POSTFIX}" ${LIBS})
224
225         set(DEQP_MODULE_LIBRARIES               ${DEQP_MODULE_LIBRARIES} "${MODULE_NAME}${MODULE_LIB_TARGET_POSTFIX}")
226         set(DEQP_MODULE_ENTRY_POINTS    ${DEQP_MODULE_ENTRY_POINTS} "${CMAKE_CURRENT_SOURCE_DIR}/${ENTRY}")
227
228         # Forward to parent scope
229         set(DEQP_MODULE_LIBRARIES               ${DEQP_MODULE_LIBRARIES} PARENT_SCOPE)
230         set(DEQP_MODULE_ENTRY_POINTS    ${DEQP_MODULE_ENTRY_POINTS} PARENT_SCOPE)
231
232         if (NOT DE_OS_IS_ANDROID AND NOT DE_OS_IS_IOS)
233                 # Executable target
234                 add_executable(${MODULE_NAME} ${PROJECT_SOURCE_DIR}/framework/platform/tcuMain.cpp ${ENTRY})
235                 target_link_libraries(${MODULE_NAME} tcutil-platform "${MODULE_NAME}${MODULE_LIB_TARGET_POSTFIX}")
236                 target_copy_files(${MODULE_NAME} platform-libs-${MODULE_NAME} "${DEQP_PLATFORM_COPY_LIBRARIES}")
237         endif ()
238
239         # Data file target
240         add_custom_target("${MODULE_NAME}${MODULE_DATA_TARGET_POSTFIX}")
241         add_dependencies("${MODULE_NAME}${MODULE_LIB_TARGET_POSTFIX}" "${MODULE_NAME}${MODULE_DATA_TARGET_POSTFIX}")
242 endmacro (add_deqp_module)
243
244 # Macro for adding data dirs to module
245 macro (add_data_dir MODULE_NAME SRC_DIR DST_DIR)
246         if (DE_OS_IS_WIN32 OR DE_OS_IS_UNIX OR DE_OS_IS_OSX OR DE_OS_IS_QNX)
247                 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})
248
249         elseif (DE_OS_IS_ANDROID)
250                 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})
251
252         elseif (DE_OS_IS_IOS)
253                 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})
254         endif ()
255 endmacro (add_data_dir)
256
257 # Macro for adding individual data files to module
258 macro (add_data_file MODULE_NAME SRC_FILE DST_FILE)
259         if (DE_OS_IS_WIN32 OR DE_OS_IS_UNIX OR DE_OS_IS_OSX OR DE_OS_IS_QNX)
260                 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})
261
262         elseif (DE_OS_IS_ANDROID)
263                 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})
264
265         elseif (DE_OS_IS_IOS)
266                 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})
267         endif ()
268 endmacro (add_data_file)
269
270 add_subdirectory(framework)
271 add_subdirectory(external/vulkancts/framework/vulkan)
272
273 if (DE_COMPILER_IS_MSC)
274         add_compile_options(/bigobj) # Required by glsBuiltinPrecisionTests.cpp
275 endif ()
276
277 add_subdirectory(modules)
278 add_subdirectory(external/vulkancts/modules/vulkan)
279 add_subdirectory(external/openglcts)
280
281 # Single-binary targets
282 if (DE_OS_IS_ANDROID)
283         include_directories(executor)
284
285         set(DEQP_SRCS
286                 framework/platform/android/tcuAndroidMain.cpp
287                 framework/platform/android/tcuAndroidJNI.cpp
288                 framework/platform/android/tcuAndroidPlatformCapabilityQueryJNI.cpp
289                 framework/platform/android/tcuTestLogParserJNI.cpp
290                 ${DEQP_MODULE_ENTRY_POINTS}
291                 )
292
293         set(DEQP_LIBS
294                 tcutil-platform
295                 xecore
296                 ${DEQP_MODULE_LIBRARIES}
297                 )
298
299         add_library(deqp SHARED ${DEQP_SRCS})
300         target_link_libraries(deqp ${DEQP_LIBS})
301
302         # Separate out the debug information because it's enormous
303         add_custom_command(TARGET deqp POST_BUILD
304                 COMMAND ${CMAKE_STRIP} --only-keep-debug -o $<TARGET_FILE:deqp>.debug $<TARGET_FILE:deqp>
305                 COMMAND ${CMAKE_STRIP} -g $<TARGET_FILE:deqp>)
306
307         # Needed by OpenGL CTS that defines its own activity but depends on
308         # common Android support code.
309         target_include_directories(deqp PRIVATE framework/platform/android)
310
311 elseif (DE_OS_IS_IOS)
312         # Code sign identity
313         set(DEQP_IOS_CODE_SIGN_IDENTITY "drawElements" CACHE STRING "Code sign identity for iOS build")
314
315         set(MACOSX_BUNDLE_PRODUCT_NAME "\${PRODUCT_NAME}")
316         set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.drawelements.\${PRODUCT_NAME:identifier}")
317
318         include_directories(framework/platform/ios)
319         set(TESTERCORE_SRC_FILES
320                 framework/platform/ios/tcuEAGLView.h
321                 framework/platform/ios/tcuEAGLView.m
322                 framework/platform/ios/tcuIOSAppDelegate.h
323                 framework/platform/ios/tcuIOSAppDelegate.m
324                 framework/platform/ios/tcuIOSViewController.h
325                 framework/platform/ios/tcuIOSViewController.m
326                 framework/platform/ios/tcuIOSMain.m
327                 )
328         set_source_files_properties(${TESTERCORE_SRC_FILES} COMPILE_FLAGS "-std=c99")
329
330         add_executable(deqp MACOSX_BUNDLE ${TESTERCORE_SRC_FILES} ${DEQP_MODULE_ENTRY_POINTS})
331         target_link_libraries(deqp tcutil-platform xscore ${DEQP_MODULE_LIBRARIES})
332         set_target_properties(deqp PROPERTIES XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2")
333         set_target_properties(deqp PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer: ${DEQP_IOS_CODE_SIGN_IDENTITY}")
334 endif ()