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