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