am f9ccead6: Remove invalid atomic image compare swap tests from mustpass.
[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 # zlib
60 find_path(ZLIB_INCLUDE_PATH     zlib.h)
61 find_library(ZLIB_LIBRARY       z)
62
63 if (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
67 endif ()
68
69 include_directories(${ZLIB_INCLUDE_PATH})
70
71 # libpng
72 find_path(PNG_INCLUDE_PATH      libpng.h)
73 find_library(PNG_LIBRARY        png)
74
75 if (NOT PNG_INCLUDE_PATH OR NOT PNG_LIBRARY)
76         message(STATUS "System version of libpng not found, using external/libpng")
77         add_subdirectory(external/libpng)
78         # \note PNG_LIBRARY and PNG_INCLUDE_PATH are promoted from external/libpng/CMakeLists.txt
79 endif ()
80
81 include_directories(${PNG_INCLUDE_PATH})
82
83 # \todo [2013-04-14 pyry] Remove once we've got dynamic loading of GL libraries figured out
84 if (DEQP_RUNTIME_LINK)
85         include_directories(wrappers/dynlib/inc)
86
87         if (DEQP_SUPPORT_GLES3)
88                 set(DEQP_GLES2_LIBRARIES GLESv3)
89                 set(DEQP_GLES3_LIBRARIES GLESv3)
90         else ()
91                 set(DEQP_GLES2_LIBRARIES GLESv2)
92         endif ()
93
94         set(DEQP_EGL_LIBRARIES EGL)
95         add_definitions(-DKHRONOS_STATIC_LIB)
96 endif ()
97
98 message(STATUS "DEQP_TARGET_NAME        = ${DEQP_TARGET_NAME}")
99 message(STATUS "DEQP_SUPPORT_GLES1      = ${DEQP_SUPPORT_GLES1}")
100 message(STATUS "DEQP_GLES1_LIBRARIES    = ${DEQP_GLES1_LIBRARIES}")
101 message(STATUS "DEQP_SUPPORT_GLES2      = ${DEQP_SUPPORT_GLES2}")
102 message(STATUS "DEQP_GLES2_LIBRARIES    = ${DEQP_GLES2_LIBRARIES}")
103 message(STATUS "DEQP_SUPPORT_GLES3      = ${DEQP_SUPPORT_GLES3}")
104 message(STATUS "DEQP_GLES3_LIBRARIES    = ${DEQP_GLES3_LIBRARIES}")
105 message(STATUS "DEQP_SUPPORT_VG         = ${DEQP_SUPPORT_VG}")
106 message(STATUS "DEQP_VG_LIBRARIES       = ${DEQP_VG_LIBRARIES}")
107 message(STATUS "DEQP_SUPPORT_EGL        = ${DEQP_SUPPORT_EGL}")
108 message(STATUS "DEQP_EGL_LIBRARIES      = ${DEQP_EGL_LIBRARIES}")
109 message(STATUS "DEQP_SUPPORT_OPENCL     = ${DEQP_SUPPORT_OPENCL}")
110 message(STATUS "DEQP_OPENCL_LIBRARIES   = ${DEQP_OPENCL_LIBRARIES}")
111 message(STATUS "DEQP_SUPPORT_OPENGL     = ${DEQP_SUPPORT_OPENGL}")
112 message(STATUS "DEQP_PLATFORM_LIBRARIES = ${DEQP_PLATFORM_LIBRARIES}")
113
114 # Defines
115 add_definitions(-DDEQP_TARGET_NAME="${DEQP_TARGET_NAME}")
116
117 if (DEQP_SUPPORT_GLES1)
118         add_definitions(-DDEQP_SUPPORT_GLES1=1)
119 endif ()
120
121 if (DEQP_SUPPORT_GLES2)
122         add_definitions(-DDEQP_SUPPORT_GLES2=1)
123 endif ()
124
125 if (DEQP_SUPPORT_GLES3)
126         add_definitions(-DDEQP_SUPPORT_GLES3=1)
127 endif ()
128
129 if (DEQP_SUPPORT_VG)
130         add_definitions(-DDEQP_SUPPORT_VG=1)
131 endif ()
132
133 if (DEQP_SUPPORT_EGL)
134         add_definitions(-DDEQP_SUPPORT_EGL=1)
135 endif ()
136
137 if (DEQP_SUPPORT_OPENCL)
138         add_definitions(-DDEQP_SUPPORT_OPENCL=1)
139 endif ()
140
141 if (DEQP_SUPPORT_OPENGL)
142         add_definitions(-DDEQP_SUPPORT_OPENGL=1)
143 endif ()
144
145 if (DEQP_SUPPORT_WGL)
146         add_definitions(-DDEQP_SUPPORT_WGL=1)
147 endif ()
148
149 if (DEQP_SUPPORT_GLX)
150         add_definitions(-DDEQP_SUPPORT_GLX=1)
151 endif ()
152
153 # Check runtime linking support
154 if (DEQP_SUPPORT_GLES1 AND NOT DEFINED DEQP_GLES1_LIBRARIES)
155         message(FATAL_ERROR "Run-time loading of GLES1 is not supported (DEQP_GLES1_LIBRARIES is not set)")
156 endif ()
157
158 if (DEQP_SUPPORT_GLES2 AND NOT DEFINED DEQP_GLES2_LIBRARIES)
159         add_definitions(-DDEQP_GLES2_RUNTIME_LOAD=1)
160 endif ()
161
162 if (DEQP_SUPPORT_GLES3 AND NOT DEFINED DEQP_GLES3_LIBRARIES)
163         add_definitions(-DDEQP_GLES3_RUNTIME_LOAD=1)
164 endif ()
165
166 if (DEQP_SUPPORT_VG AND NOT DEFINED DEQP_VG_LIBRARIES)
167         message(FATAL_ERROR "Run-time loading of VG is not supported (DEQP_VG_LIBRARIES is not set)")
168 endif ()
169
170 if (DEQP_SUPPORT_EGL AND NOT DEFINED DEQP_EGL_LIBRARIES)
171         message(FATAL_ERROR "Run-time loading of EGL is not supported (DEQP_EGL_LIBRARIES is not set)")
172 endif ()
173
174 if (DEQP_SUPPORT_OPENCL AND NOT DEFINED DEQP_OPENCL_LIBRARIES)
175         message(FATAL_ERROR "Run-time loading of OpenCL is not supported (DEQP_OPENCL_LIBRARIES is not set)")
176 endif ()
177
178 # OpenGL is always loaded on run-time
179 if (DEQP_SUPPORT_OPENGL)
180         add_definitions(-DDEQP_OPENGL_RUNTIME_LOAD=1)
181 endif ()
182
183 if (DE_COMPILER_IS_MSC)
184         # Don't nag about std::copy for example
185         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SCL_SECURE_NO_WARNINGS")
186 endif ()
187
188 # delibs projects
189 add_subdirectory(${DELIBS_DIR}/debase           debase)
190 add_subdirectory(${DELIBS_DIR}/depool           depool)
191 add_subdirectory(${DELIBS_DIR}/dethread         dethread)
192 add_subdirectory(${DELIBS_DIR}/destream         destream)
193 add_subdirectory(${DELIBS_DIR}/deutil           deutil)
194 add_subdirectory(${DELIBS_DIR}/decpp            decpp)
195
196 # \todo [2013-04-14 pyry] Remove once we've got dynamic loading of GL libraries figured out
197 if (DEQP_RUNTIME_LINK)
198         add_subdirectory(wrappers/dynlib)
199 endif ()
200
201 # ExecServer
202 add_subdirectory(execserver)
203
204 # Executor framework and tools
205 if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/executor)
206         add_subdirectory(executor)
207 endif ()
208
209 if (DEQP_SUPPORT_OPENCL)
210         # We need to support all older CL1.x versions
211         add_definitions(-DCL_USE_DEPRECATED_OPENCL_1_0_APIS)
212         add_definitions(-DCL_USE_DEPRECATED_OPENCL_1_1_APIS)
213 endif ()
214
215 # Test framework include directories
216 include_directories(
217         framework/common
218         framework/qphelper
219         framework/opengl
220         framework/opengl/wrapper
221         framework/referencerenderer
222         framework/opengl/simplereference
223         framework/randomshaders
224         )
225
226 if (DEQP_SUPPORT_EGL)
227         include_directories(framework/egl)
228 endif ()
229
230 if (DE_OS_IS_ANDROID OR DE_OS_IS_IOS)
231         # On Android deqp modules are compiled as libraries and linked into final .so
232         set(DEQP_MODULE_LIBRARIES )
233         set(DEQP_MODULE_ENTRY_POINTS )
234 endif ()
235
236 if (DE_OS_IS_WIN32)
237         include_directories(framework/platform/win32)
238 endif ()
239
240 # Macro for adding targets for copying binaries (usually target libraries) to the target destination dir
241 macro (target_copy_files target dep_name files)
242         if (NOT "${files}" STREQUAL "")
243                 set(COPY_TARGETS )
244                 foreach (SRCNAME ${files})
245                         get_filename_component(BASENAME ${SRCNAME} NAME)
246                         set(DSTNAME "${CMAKE_CURRENT_BINARY_DIR}/${BASENAME}")
247                         add_custom_command(OUTPUT ${DSTNAME}
248                                                            COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SRCNAME} ${DSTNAME})
249                         set(COPY_TARGETS ${COPY_TARGETS} ${DSTNAME})
250                 endforeach ()
251
252                 add_custom_target(${dep_name} ALL DEPENDS ${COPY_TARGETS})
253                 add_dependencies(${target} ${dep_name})
254         endif ()
255 endmacro (target_copy_files)
256
257 # Macro for adding dEQP module
258 macro (add_deqp_module MODULE_NAME SRCS LIBS ENTRY)
259         if (DE_OS_IS_ANDROID OR DE_OS_IS_IOS)
260                 # Single-binary targets
261                 add_library(${MODULE_NAME} STATIC ${SRCS})
262                 target_link_libraries(${MODULE_NAME} ${LIBS})
263
264                 set(DEQP_MODULE_LIBRARIES               ${DEQP_MODULE_LIBRARIES} ${MODULE_NAME})
265                 set(DEQP_MODULE_ENTRY_POINTS    ${DEQP_MODULE_ENTRY_POINTS} "${CMAKE_CURRENT_SOURCE_DIR}/${ENTRY}")
266
267                 # Forward to parent scope
268                 set(DEQP_MODULE_LIBRARIES               ${DEQP_MODULE_LIBRARIES} PARENT_SCOPE)
269                 set(DEQP_MODULE_ENTRY_POINTS    ${DEQP_MODULE_ENTRY_POINTS} PARENT_SCOPE)
270
271         else ()
272                 # Separate binary per target
273                 add_executable(${MODULE_NAME} ${CMAKE_SOURCE_DIR}/framework/platform/tcuMain.cpp ${ENTRY} ${SRCS})
274                 target_link_libraries(${MODULE_NAME} tcutil-platform ${LIBS})
275                 target_copy_files(${MODULE_NAME} platform-libs-${MODULE_NAME} "${DEQP_PLATFORM_COPY_LIBRARIES}")
276         endif ()
277
278         # Data file target
279         add_custom_target(${MODULE_NAME}-data)
280         add_dependencies(${MODULE_NAME} ${MODULE_NAME}-data)
281 endmacro (add_deqp_module)
282
283 # Macro for adding data dirs to module
284 macro (add_data_dir MODULE_NAME SRC_DIR DST_DIR)
285         if (DE_OS_IS_WIN32 OR DE_OS_IS_UNIX OR DE_OS_IS_OSX)
286                 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})
287
288         elseif (DE_OS_IS_ANDROID)
289                 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})
290
291         elseif (DE_OS_IS_IOS)
292                 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})
293         endif ()
294 endmacro (add_data_dir)
295
296 # Macro for adding individual data files to module
297 macro (add_data_file MODULE_NAME SRC_FILE DST_FILE)
298         if (DE_OS_IS_WIN32 OR DE_OS_IS_UNIX OR DE_OS_IS_OSX)
299                 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})
300
301         elseif (DE_OS_IS_ANDROID)
302                 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})
303
304         elseif (DE_OS_IS_IOS)
305                 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})
306         endif ()
307 endmacro (add_data_file)
308
309 add_subdirectory(framework)
310
311 if (DE_COMPILER_IS_MSC)
312         add_compile_options(/bigobj) # Required by glsBuiltinPrecisionTests.cpp
313 endif ()
314
315 add_subdirectory(modules)
316
317 # Single-binary targets
318 if (DE_OS_IS_ANDROID)
319         # CTS activities require headers from Android port directory
320         include_directories(framework/platform/android)
321         include_directories(executor)
322
323         add_library(deqp SHARED framework/platform/android/tcuAndroidMain.cpp framework/platform/android/tcuAndroidJNI.cpp framework/platform/android/tcuTestLogParserJNI.cpp ${DEQP_MODULE_ENTRY_POINTS})
324         target_link_libraries(deqp tcutil-platform xecore ${DEQP_MODULE_LIBRARIES})
325
326 elseif (DE_OS_IS_IOS)
327         # Code sign identity
328         set(DEQP_IOS_CODE_SIGN_IDENTITY "drawElements" CACHE STRING "Code sign identity for iOS build")
329
330         set(MACOSX_BUNDLE_PRODUCT_NAME "\${PRODUCT_NAME}")
331         set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.drawelements.\${PRODUCT_NAME:identifier}")
332
333         include_directories(framework/platform/ios)
334         set(TESTERCORE_SRC_FILES
335                 framework/platform/ios/tcuEAGLView.h
336                 framework/platform/ios/tcuEAGLView.m
337                 framework/platform/ios/tcuIOSAppDelegate.h
338                 framework/platform/ios/tcuIOSAppDelegate.m
339                 framework/platform/ios/tcuIOSViewController.h
340                 framework/platform/ios/tcuIOSViewController.m
341                 framework/platform/ios/tcuIOSMain.m
342                 )
343         set_source_files_properties(${TESTERCORE_SRC_FILES} COMPILE_FLAGS "-std=c99")
344
345         add_executable(deqp MACOSX_BUNDLE ${TESTERCORE_SRC_FILES} ${DEQP_MODULE_ENTRY_POINTS})
346         target_link_libraries(deqp tcutil-platform xscore ${DEQP_MODULE_LIBRARIES})
347         set_target_properties(deqp PROPERTIES XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2")
348         set_target_properties(deqp PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer: ${DEQP_IOS_CODE_SIGN_IDENTITY}")
349 endif ()