summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: 9760d723eaf21033acd7360c720fe8f2b489691b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# dEQP cmake file

cmake_minimum_required(VERSION 2.6)

# dEQP Target.
set(DEQP_TARGET "default" CACHE STRING "dEQP Target (default, android...)")

project(dEQP-Core-${DEQP_TARGET})

include(framework/delibs/cmake/Defs.cmake NO_POLICY_SCOPE)
include(framework/delibs/cmake/CFlags.cmake)

add_definitions(-DDE_ASSERT_FAILURE_CALLBACK)

# dEQP-specific configuration. Target file should override these.
set(DEQP_TARGET_NAME		"UNKNOWN")		# Target name

set(DEQP_SUPPORT_GLES1		OFF)			# Is GLESv1 supported
set(DEQP_GLES1_LIBRARIES	)				# GLESv1 libraries

set(DEQP_SUPPORT_GLES2		OFF)			# Is GLESv2 supported
set(DEQP_GLES2_LIBRARIES	)				# GLESv2 libraries. If empty, run-time linking is used

set(DEQP_SUPPORT_GLES3		OFF)			# Is GLESv3 supported
set(DEQP_GLES3_LIBRARIES	)				# GLESv3 libraries. If empty, run-time linking is used

set(DEQP_SUPPORT_VG			OFF)			# Is VG supported
set(DEQP_VG_LIBRARIES		)				# VG libraries

set(DEQP_SUPPORT_EGL		OFF)			# Is EGL supported
set(DEQP_EGL_LIBRARIES		)				# EGL libraries

set(DEQP_SUPPORT_GLX		OFF)			# Is GLX supported
set(DEQP_SUPPORT_WGL		OFF)			# Is WGL supported

set(DEQP_PLATFORM_LIBRARIES	)				# Other platform libraries

set(DEQP_SUPPORT_OPENGL		OFF)			# Is OpenGL supported on platform
											# \note OpenGL is always loaded on run-time

set(DEQP_PLATFORM_COPY_LIBRARIES	)		# Libraries / binaries that need to be copied to binary directory

# Delibs include directories
include_directories(
	framework/delibs/debase
	framework/delibs/decpp
	framework/delibs/depool
	framework/delibs/dethread
	framework/delibs/deutil
	framework/delibs/destream
	)

# Include target-specific definitions
include(targets/${DEQP_TARGET}/${DEQP_TARGET}.cmake)

# zlib
find_path(ZLIB_INCLUDE_PATH	zlib.h)
find_library(ZLIB_LIBRARY	z)

if (NOT ZLIB_INCLUDE_PATH OR NOT ZLIB_LIBRARY)
	message(STATUS "System version of zlib not found, using external/zlib")
	add_subdirectory(external/zlib)
	# \note ZLIB_LIBRARY and ZLIB_INCLUDE_PATH are promoted from external/zlib/CMakeLists.txt
endif ()

include_directories(${ZLIB_INCLUDE_PATH})

# libpng
find_path(PNG_INCLUDE_PATH	libpng.h)
find_library(PNG_LIBRARY	png)

if (NOT PNG_INCLUDE_PATH OR NOT PNG_LIBRARY)
	message(STATUS "System version of libpng not found, using external/libpng")
	add_subdirectory(external/libpng)
	# \note PNG_LIBRARY and PNG_INCLUDE_PATH are promoted from external/libpng/CMakeLists.txt
endif ()

include_directories(${PNG_INCLUDE_PATH})

message(STATUS "DEQP_TARGET_NAME        = ${DEQP_TARGET_NAME}")
message(STATUS "DEQP_SUPPORT_GLES1      = ${DEQP_SUPPORT_GLES1}")
message(STATUS "DEQP_GLES1_LIBRARIES    = ${DEQP_GLES1_LIBRARIES}")
message(STATUS "DEQP_SUPPORT_GLES2      = ${DEQP_SUPPORT_GLES2}")
message(STATUS "DEQP_GLES2_LIBRARIES    = ${DEQP_GLES2_LIBRARIES}")
message(STATUS "DEQP_SUPPORT_GLES3      = ${DEQP_SUPPORT_GLES3}")
message(STATUS "DEQP_GLES3_LIBRARIES    = ${DEQP_GLES3_LIBRARIES}")
message(STATUS "DEQP_SUPPORT_VG         = ${DEQP_SUPPORT_VG}")
message(STATUS "DEQP_VG_LIBRARIES       = ${DEQP_VG_LIBRARIES}")
message(STATUS "DEQP_SUPPORT_EGL        = ${DEQP_SUPPORT_EGL}")
message(STATUS "DEQP_EGL_LIBRARIES      = ${DEQP_EGL_LIBRARIES}")
message(STATUS "DEQP_SUPPORT_OPENGL     = ${DEQP_SUPPORT_OPENGL}")
message(STATUS "DEQP_PLATFORM_LIBRARIES = ${DEQP_PLATFORM_LIBRARIES}")
message(STATUS "DEQP_SUPPORT_WGL        = ${DEQP_SUPPORT_WGL}")
message(STATUS "DEQP_SUPPORT_GLX        = ${DEQP_SUPPORT_GLX}")

# Defines
add_definitions(-DDEQP_TARGET_NAME="${DEQP_TARGET_NAME}")

if (DEQP_SUPPORT_GLES1)
	add_definitions(-DDEQP_SUPPORT_GLES1=1)
endif ()

if (DEQP_SUPPORT_GLES2)
	add_definitions(-DDEQP_SUPPORT_GLES2=1)
endif ()

if (DEQP_SUPPORT_GLES3)
	add_definitions(-DDEQP_SUPPORT_GLES3=1)
endif ()

if (DEQP_SUPPORT_VG)
	add_definitions(-DDEQP_SUPPORT_VG=1)
endif ()

if (DEQP_SUPPORT_EGL)
	add_definitions(-DDEQP_SUPPORT_EGL=1)
endif ()

if (DEQP_SUPPORT_OPENGL)
	add_definitions(-DDEQP_SUPPORT_OPENGL=1)
endif ()

if (DEQP_SUPPORT_WGL)
	add_definitions(-DDEQP_SUPPORT_WGL=1)
endif ()

if (DEQP_SUPPORT_GLX)
	add_definitions(-DDEQP_SUPPORT_GLX=1)
endif ()

# Check runtime linking support
if (DEQP_SUPPORT_GLES1 AND NOT DEFINED DEQP_GLES1_LIBRARIES)
	message(FATAL_ERROR "Run-time loading of GLES1 is not supported (DEQP_GLES1_LIBRARIES is not set)")
endif ()

if (DEQP_SUPPORT_GLES2 AND NOT DEFINED DEQP_GLES2_LIBRARIES)
	add_definitions(-DDEQP_GLES2_RUNTIME_LOAD=1)
endif ()

if (DEQP_SUPPORT_GLES3 AND NOT DEFINED DEQP_GLES3_LIBRARIES)
	add_definitions(-DDEQP_GLES3_RUNTIME_LOAD=1)
endif ()

if (DEQP_SUPPORT_VG AND NOT DEFINED DEQP_VG_LIBRARIES)
	message(FATAL_ERROR "Run-time loading of VG is not supported (DEQP_VG_LIBRARIES is not set)")
endif ()

if (DEQP_SUPPORT_EGL AND NOT DEFINED DEQP_EGL_LIBRARIES)
	add_definitions(-DDEQP_EGL_RUNTIME_LOAD=1)
endif ()

# OpenGL is always loaded on run-time
if (DEQP_SUPPORT_OPENGL)
	add_definitions(-DDEQP_OPENGL_RUNTIME_LOAD=1)
endif ()

if (DE_COMPILER_IS_MSC)
	# Don't nag about std::copy for example
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SCL_SECURE_NO_WARNINGS")
endif ()

# delibs projects
add_subdirectory(framework/delibs/debase)
add_subdirectory(framework/delibs/depool)
add_subdirectory(framework/delibs/dethread)
add_subdirectory(framework/delibs/destream)
add_subdirectory(framework/delibs/deutil)
add_subdirectory(framework/delibs/decpp)

# ExecServer
add_subdirectory(execserver)

# Executor framework and tools
if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/executor)
	add_subdirectory(executor)
endif ()

# Test framework include directories
include_directories(
	framework/common
	framework/qphelper
	framework/opengl
	framework/opengl/wrapper
	framework/referencerenderer
	framework/opengl/simplereference
	framework/randomshaders
	framework/egl
	framework/egl/wrapper
	)

if (DE_OS_IS_ANDROID OR DE_OS_IS_IOS)
	# On Android deqp modules are compiled as libraries and linked into final .so
	set(DEQP_MODULE_LIBRARIES )
	set(DEQP_MODULE_ENTRY_POINTS )
endif ()

if (DE_OS_IS_WIN32)
	include_directories(framework/platform/win32)
endif ()

# Macro for adding targets for copying binaries (usually target libraries) to the target destination dir
macro (target_copy_files target dep_name files)
	if (NOT "${files}" STREQUAL "")
		set(COPY_TARGETS )
		foreach (SRCNAME ${files})
			get_filename_component(BASENAME ${SRCNAME} NAME)
			set(DSTNAME "${CMAKE_CURRENT_BINARY_DIR}/${BASENAME}")
			add_custom_command(OUTPUT ${DSTNAME}
							   COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SRCNAME} ${DSTNAME})
			set(COPY_TARGETS ${COPY_TARGETS} ${DSTNAME})
		endforeach ()

		add_custom_target(${dep_name} ALL DEPENDS ${COPY_TARGETS})
		add_dependencies(${target} ${dep_name})
	endif ()
endmacro (target_copy_files)

# Macro for adding dEQP module
macro (add_deqp_module MODULE_NAME SRCS LIBS ENTRY)
	if (DE_OS_IS_ANDROID OR DE_OS_IS_IOS)
		# Single-binary targets
		add_library(${MODULE_NAME} STATIC ${SRCS})
		target_link_libraries(${MODULE_NAME} ${LIBS})

		set(DEQP_MODULE_LIBRARIES		${DEQP_MODULE_LIBRARIES} ${MODULE_NAME})
		set(DEQP_MODULE_ENTRY_POINTS	${DEQP_MODULE_ENTRY_POINTS} "${CMAKE_CURRENT_SOURCE_DIR}/${ENTRY}")

		# Forward to parent scope
		set(DEQP_MODULE_LIBRARIES		${DEQP_MODULE_LIBRARIES} PARENT_SCOPE)
		set(DEQP_MODULE_ENTRY_POINTS	${DEQP_MODULE_ENTRY_POINTS} PARENT_SCOPE)

	else ()
		# Separate binary per target
		add_executable(${MODULE_NAME} ${CMAKE_SOURCE_DIR}/framework/platform/tcuMain.cpp ${ENTRY} ${SRCS})
		target_link_libraries(${MODULE_NAME} tcutil-platform ${LIBS})
		target_copy_files(${MODULE_NAME} platform-libs-${MODULE_NAME} "${DEQP_PLATFORM_COPY_LIBRARIES}")
	endif ()

	# Data file target
	add_custom_target(${MODULE_NAME}-data)
	add_dependencies(${MODULE_NAME} ${MODULE_NAME}-data)
endmacro (add_deqp_module)

# Macro for adding data dirs to module
macro (add_data_dir MODULE_NAME SRC_DIR DST_DIR)
	if (DE_OS_IS_WIN32 OR DE_OS_IS_UNIX OR DE_OS_IS_OSX)
		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})

	elseif (DE_OS_IS_ANDROID)
		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})

	elseif (DE_OS_IS_IOS)
		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})
	endif ()
endmacro (add_data_dir)

# Macro for adding individual data files to module
macro (add_data_file MODULE_NAME SRC_FILE DST_FILE)
	if (DE_OS_IS_WIN32 OR DE_OS_IS_UNIX OR DE_OS_IS_OSX)
		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})

	elseif (DE_OS_IS_ANDROID)
		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})

	elseif (DE_OS_IS_IOS)
		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})
	endif ()
endmacro (add_data_file)

add_subdirectory(framework)

if (DE_COMPILER_IS_MSC)
	add_compile_options(/bigobj) # Required by glsBuiltinPrecisionTests.cpp
endif ()

add_subdirectory(modules)

# Single-binary targets
if (DE_OS_IS_ANDROID)
	include_directories(executor)

	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})
	target_link_libraries(deqp tcutil-platform xecore ${DEQP_MODULE_LIBRARIES})

elseif (DE_OS_IS_IOS)
	# Code sign identity
	set(DEQP_IOS_CODE_SIGN_IDENTITY "drawElements" CACHE STRING "Code sign identity for iOS build")

	set(MACOSX_BUNDLE_PRODUCT_NAME "\${PRODUCT_NAME}")
	set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.drawelements.\${PRODUCT_NAME:identifier}")

	include_directories(framework/platform/ios)
	set(TESTERCORE_SRC_FILES
		framework/platform/ios/tcuEAGLView.h
		framework/platform/ios/tcuEAGLView.m
		framework/platform/ios/tcuIOSAppDelegate.h
		framework/platform/ios/tcuIOSAppDelegate.m
		framework/platform/ios/tcuIOSViewController.h
		framework/platform/ios/tcuIOSViewController.m
		framework/platform/ios/tcuIOSMain.m
		)
	set_source_files_properties(${TESTERCORE_SRC_FILES} COMPILE_FLAGS "-std=c99")

	add_executable(deqp MACOSX_BUNDLE ${TESTERCORE_SRC_FILES} ${DEQP_MODULE_ENTRY_POINTS})
	target_link_libraries(deqp tcutil-platform xscore ${DEQP_MODULE_LIBRARIES})
	set_target_properties(deqp PROPERTIES XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2")
	set_target_properties(deqp PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer: ${DEQP_IOS_CODE_SIGN_IDENTITY}")
endif ()