1# dEQP cmake file
2
3cmake_minimum_required(VERSION 2.6)
4
5# dEQP Target.
6set(DEQP_TARGET "default" CACHE STRING "dEQP Target (default, android...)")
7
8project(dEQP-Core-${DEQP_TARGET})
9
10include(framework/delibs/cmake/Defs.cmake NO_POLICY_SCOPE)
11include(framework/delibs/cmake/CFlags.cmake)
12
13add_definitions(-DDE_ASSERT_FAILURE_CALLBACK)
14
15# dEQP-specific configuration. Target file should override these.
16set(DEQP_TARGET_NAME		"UNKNOWN")		# Target name
17
18set(DEQP_SUPPORT_GLES1		OFF)			# Is GLESv1 supported
19set(DEQP_GLES1_LIBRARIES	)				# GLESv1 libraries
20
21set(DEQP_SUPPORT_GLES2		OFF)			# Is GLESv2 supported
22set(DEQP_GLES2_LIBRARIES	)				# GLESv2 libraries. If empty, run-time linking is used
23
24set(DEQP_SUPPORT_GLES3		OFF)			# Is GLESv3 supported
25set(DEQP_GLES3_LIBRARIES	)				# GLESv3 libraries. If empty, run-time linking is used
26
27set(DEQP_SUPPORT_VG			OFF)			# Is VG supported
28set(DEQP_VG_LIBRARIES		)				# VG libraries
29
30set(DEQP_SUPPORT_EGL		OFF)			# Is EGL supported
31set(DEQP_EGL_LIBRARIES		)				# EGL libraries
32
33set(DEQP_SUPPORT_GLX		OFF)			# Is GLX supported
34set(DEQP_SUPPORT_WGL		OFF)			# Is WGL supported
35
36set(DEQP_PLATFORM_LIBRARIES	)				# Other platform libraries
37
38set(DEQP_SUPPORT_OPENGL		OFF)			# Is OpenGL supported on platform
39											# \note OpenGL is always loaded on run-time
40
41set(DEQP_PLATFORM_COPY_LIBRARIES	)		# Libraries / binaries that need to be copied to binary directory
42
43# Delibs include directories
44include_directories(
45	framework/delibs/debase
46	framework/delibs/decpp
47	framework/delibs/depool
48	framework/delibs/dethread
49	framework/delibs/deutil
50	framework/delibs/destream
51	)
52
53# Include target-specific definitions
54include(targets/${DEQP_TARGET}/${DEQP_TARGET}.cmake)
55
56# zlib
57find_path(ZLIB_INCLUDE_PATH	zlib.h)
58find_library(ZLIB_LIBRARY	z)
59
60if (NOT ZLIB_INCLUDE_PATH OR NOT ZLIB_LIBRARY)
61	message(STATUS "System version of zlib not found, using external/zlib")
62	add_subdirectory(external/zlib)
63	# \note ZLIB_LIBRARY and ZLIB_INCLUDE_PATH are promoted from external/zlib/CMakeLists.txt
64endif ()
65
66include_directories(${ZLIB_INCLUDE_PATH})
67
68# libpng
69find_path(PNG_INCLUDE_PATH	libpng.h)
70find_library(PNG_LIBRARY	png)
71
72if (NOT PNG_INCLUDE_PATH OR NOT PNG_LIBRARY)
73	message(STATUS "System version of libpng not found, using external/libpng")
74	add_subdirectory(external/libpng)
75	# \note PNG_LIBRARY and PNG_INCLUDE_PATH are promoted from external/libpng/CMakeLists.txt
76endif ()
77
78include_directories(${PNG_INCLUDE_PATH})
79
80message(STATUS "DEQP_TARGET_NAME        = ${DEQP_TARGET_NAME}")
81message(STATUS "DEQP_SUPPORT_GLES1      = ${DEQP_SUPPORT_GLES1}")
82message(STATUS "DEQP_GLES1_LIBRARIES    = ${DEQP_GLES1_LIBRARIES}")
83message(STATUS "DEQP_SUPPORT_GLES2      = ${DEQP_SUPPORT_GLES2}")
84message(STATUS "DEQP_GLES2_LIBRARIES    = ${DEQP_GLES2_LIBRARIES}")
85message(STATUS "DEQP_SUPPORT_GLES3      = ${DEQP_SUPPORT_GLES3}")
86message(STATUS "DEQP_GLES3_LIBRARIES    = ${DEQP_GLES3_LIBRARIES}")
87message(STATUS "DEQP_SUPPORT_VG         = ${DEQP_SUPPORT_VG}")
88message(STATUS "DEQP_VG_LIBRARIES       = ${DEQP_VG_LIBRARIES}")
89message(STATUS "DEQP_SUPPORT_EGL        = ${DEQP_SUPPORT_EGL}")
90message(STATUS "DEQP_EGL_LIBRARIES      = ${DEQP_EGL_LIBRARIES}")
91message(STATUS "DEQP_SUPPORT_OPENGL     = ${DEQP_SUPPORT_OPENGL}")
92message(STATUS "DEQP_PLATFORM_LIBRARIES = ${DEQP_PLATFORM_LIBRARIES}")
93message(STATUS "DEQP_SUPPORT_WGL        = ${DEQP_SUPPORT_WGL}")
94message(STATUS "DEQP_SUPPORT_GLX        = ${DEQP_SUPPORT_GLX}")
95
96# Defines
97add_definitions(-DDEQP_TARGET_NAME="${DEQP_TARGET_NAME}")
98
99if (DEQP_SUPPORT_GLES1)
100	add_definitions(-DDEQP_SUPPORT_GLES1=1)
101endif ()
102
103if (DEQP_SUPPORT_GLES2)
104	add_definitions(-DDEQP_SUPPORT_GLES2=1)
105endif ()
106
107if (DEQP_SUPPORT_GLES3)
108	add_definitions(-DDEQP_SUPPORT_GLES3=1)
109endif ()
110
111if (DEQP_SUPPORT_VG)
112	add_definitions(-DDEQP_SUPPORT_VG=1)
113endif ()
114
115if (DEQP_SUPPORT_EGL)
116	add_definitions(-DDEQP_SUPPORT_EGL=1)
117endif ()
118
119if (DEQP_SUPPORT_OPENGL)
120	add_definitions(-DDEQP_SUPPORT_OPENGL=1)
121endif ()
122
123if (DEQP_SUPPORT_WGL)
124	add_definitions(-DDEQP_SUPPORT_WGL=1)
125endif ()
126
127if (DEQP_SUPPORT_GLX)
128	add_definitions(-DDEQP_SUPPORT_GLX=1)
129endif ()
130
131# Check runtime linking support
132if (DEQP_SUPPORT_GLES1 AND NOT DEFINED DEQP_GLES1_LIBRARIES)
133	message(FATAL_ERROR "Run-time loading of GLES1 is not supported (DEQP_GLES1_LIBRARIES is not set)")
134endif ()
135
136if (DEQP_SUPPORT_GLES2 AND NOT DEFINED DEQP_GLES2_LIBRARIES)
137	add_definitions(-DDEQP_GLES2_RUNTIME_LOAD=1)
138endif ()
139
140if (DEQP_SUPPORT_GLES3 AND NOT DEFINED DEQP_GLES3_LIBRARIES)
141	add_definitions(-DDEQP_GLES3_RUNTIME_LOAD=1)
142endif ()
143
144if (DEQP_SUPPORT_VG AND NOT DEFINED DEQP_VG_LIBRARIES)
145	message(FATAL_ERROR "Run-time loading of VG is not supported (DEQP_VG_LIBRARIES is not set)")
146endif ()
147
148if (DEQP_SUPPORT_EGL AND NOT DEFINED DEQP_EGL_LIBRARIES)
149	add_definitions(-DDEQP_EGL_RUNTIME_LOAD=1)
150endif ()
151
152# OpenGL is always loaded on run-time
153if (DEQP_SUPPORT_OPENGL)
154	add_definitions(-DDEQP_OPENGL_RUNTIME_LOAD=1)
155endif ()
156
157if (DE_COMPILER_IS_MSC)
158	# Don't nag about std::copy for example
159	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SCL_SECURE_NO_WARNINGS")
160endif ()
161
162# delibs projects
163add_subdirectory(framework/delibs/debase)
164add_subdirectory(framework/delibs/depool)
165add_subdirectory(framework/delibs/dethread)
166add_subdirectory(framework/delibs/destream)
167add_subdirectory(framework/delibs/deutil)
168add_subdirectory(framework/delibs/decpp)
169
170# ExecServer
171add_subdirectory(execserver)
172
173# Executor framework and tools
174if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/executor)
175	add_subdirectory(executor)
176endif ()
177
178# Test framework include directories
179include_directories(
180	framework/common
181	framework/qphelper
182	framework/opengl
183	framework/opengl/wrapper
184	framework/referencerenderer
185	framework/opengl/simplereference
186	framework/randomshaders
187	framework/egl
188	framework/egl/wrapper
189	)
190
191if (DE_OS_IS_ANDROID OR DE_OS_IS_IOS)
192	# On Android deqp modules are compiled as libraries and linked into final .so
193	set(DEQP_MODULE_LIBRARIES )
194	set(DEQP_MODULE_ENTRY_POINTS )
195endif ()
196
197if (DE_OS_IS_WIN32)
198	include_directories(framework/platform/win32)
199endif ()
200
201# Macro for adding targets for copying binaries (usually target libraries) to the target destination dir
202macro (target_copy_files target dep_name files)
203	if (NOT "${files}" STREQUAL "")
204		set(COPY_TARGETS )
205		foreach (SRCNAME ${files})
206			get_filename_component(BASENAME ${SRCNAME} NAME)
207			set(DSTNAME "${CMAKE_CURRENT_BINARY_DIR}/${BASENAME}")
208			add_custom_command(OUTPUT ${DSTNAME}
209							   COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SRCNAME} ${DSTNAME})
210			set(COPY_TARGETS ${COPY_TARGETS} ${DSTNAME})
211		endforeach ()
212
213		add_custom_target(${dep_name} ALL DEPENDS ${COPY_TARGETS})
214		add_dependencies(${target} ${dep_name})
215	endif ()
216endmacro (target_copy_files)
217
218# Macro for adding dEQP module
219macro (add_deqp_module MODULE_NAME SRCS LIBS ENTRY)
220	if (DE_OS_IS_ANDROID OR DE_OS_IS_IOS)
221		# Single-binary targets
222		add_library(${MODULE_NAME} STATIC ${SRCS})
223		target_link_libraries(${MODULE_NAME} ${LIBS})
224
225		set(DEQP_MODULE_LIBRARIES		${DEQP_MODULE_LIBRARIES} ${MODULE_NAME})
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	else ()
233		# Separate binary per target
234		add_executable(${MODULE_NAME} ${CMAKE_SOURCE_DIR}/framework/platform/tcuMain.cpp ${ENTRY} ${SRCS})
235		target_link_libraries(${MODULE_NAME} tcutil-platform ${LIBS})
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}-data)
241	add_dependencies(${MODULE_NAME} ${MODULE_NAME}-data)
242endmacro (add_deqp_module)
243
244# Macro for adding data dirs to module
245macro (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)
247		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})
248
249	elseif (DE_OS_IS_ANDROID)
250		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})
251
252	elseif (DE_OS_IS_IOS)
253		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})
254	endif ()
255endmacro (add_data_dir)
256
257# Macro for adding individual data files to module
258macro (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)
260		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})
261
262	elseif (DE_OS_IS_ANDROID)
263		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})
264
265	elseif (DE_OS_IS_IOS)
266		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})
267	endif ()
268endmacro (add_data_file)
269
270add_subdirectory(framework)
271
272if (DE_COMPILER_IS_MSC)
273	add_compile_options(/bigobj) # Required by glsBuiltinPrecisionTests.cpp
274endif ()
275
276add_subdirectory(modules)
277
278# Single-binary targets
279if (DE_OS_IS_ANDROID)
280	include_directories(executor)
281
282	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})
283	target_link_libraries(deqp tcutil-platform xecore ${DEQP_MODULE_LIBRARIES})
284
285elseif (DE_OS_IS_IOS)
286	# Code sign identity
287	set(DEQP_IOS_CODE_SIGN_IDENTITY "drawElements" CACHE STRING "Code sign identity for iOS build")
288
289	set(MACOSX_BUNDLE_PRODUCT_NAME "\${PRODUCT_NAME}")
290	set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.drawelements.\${PRODUCT_NAME:identifier}")
291
292	include_directories(framework/platform/ios)
293	set(TESTERCORE_SRC_FILES
294		framework/platform/ios/tcuEAGLView.h
295		framework/platform/ios/tcuEAGLView.m
296		framework/platform/ios/tcuIOSAppDelegate.h
297		framework/platform/ios/tcuIOSAppDelegate.m
298		framework/platform/ios/tcuIOSViewController.h
299		framework/platform/ios/tcuIOSViewController.m
300		framework/platform/ios/tcuIOSMain.m
301		)
302	set_source_files_properties(${TESTERCORE_SRC_FILES} COMPILE_FLAGS "-std=c99")
303
304	add_executable(deqp MACOSX_BUNDLE ${TESTERCORE_SRC_FILES} ${DEQP_MODULE_ENTRY_POINTS})
305	target_link_libraries(deqp tcutil-platform xscore ${DEQP_MODULE_LIBRARIES})
306	set_target_properties(deqp PROPERTIES XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2")
307	set_target_properties(deqp PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer: ${DEQP_IOS_CODE_SIGN_IDENTITY}")
308endif ()
309