1# dEQP cmake file 2 3# Module FindGit requires cmake >= 2.8.2 4cmake_minimum_required(VERSION 3.10.2) 5 6set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/framework/delibs/cmake") 7find_package(Git) 8find_package(PythonInterp 3) 9 10# dEQP Target. 11set(DEQP_TARGET "default" CACHE STRING "dEQP Target (default, android...)") 12 13if (DEFINED DEQP_TARGET_TOOLCHAIN) 14 # \note Toolchain must be included before project() command 15 include(targets/${DEQP_TARGET}/${DEQP_TARGET_TOOLCHAIN}.cmake NO_POLICY_SCOPE) 16endif () 17 18project(dEQP-Core-${DEQP_TARGET}) 19 20include(framework/delibs/cmake/Defs.cmake NO_POLICY_SCOPE) 21include(framework/delibs/cmake/CFlags.cmake) 22 23add_definitions(-DDE_ASSERT_FAILURE_CALLBACK) 24 25# dEQP-specific configuration. Target file should override these. 26set(DEQP_TARGET_NAME "UNKNOWN") # Target name 27 28set(DEQP_GLES2_LIBRARIES ) # GLESv2 libraries. If empty, run-time linking is used 29set(DEQP_GLES3_LIBRARIES ) # GLESv3 libraries. If empty, run-time linking is used 30set(DEQP_EGL_LIBRARIES ) # EGL libraries 31 32# Legacy APIs that don't use run-time loading 33set(DEQP_SUPPORT_GLES1 OFF) # Is GLESv1 supported 34set(DEQP_GLES1_LIBRARIES ) # GLESv1 libraries 35set(DEQP_SUPPORT_VG OFF) # Is OpenVG supported 36set(DEQP_VG_LIBRARIES ) # VG libraries 37 38set(DEQP_SUPPORT_WGL OFF) 39set(DEQP_SUPPORT_GLX OFF) # Is GLX supported \todo [2016-10-12 pyry] X11 specific - move to framework/platform/ 40 41set(DEQP_PLATFORM_LIBRARIES ) # Other platform libraries 42 43set(DEQP_PLATFORM_COPY_LIBRARIES ) # Libraries / binaries that need to be copied to binary directory 44 45# Delibs include directories 46include_directories( 47 framework/delibs/debase 48 framework/delibs/decpp 49 framework/delibs/depool 50 framework/delibs/dethread 51 framework/delibs/deutil 52 framework/delibs/destream 53 ) 54 55# Include target-specific definitions 56include(targets/${DEQP_TARGET}/${DEQP_TARGET}.cmake) 57 58# zlib 59find_package(ZLIB) 60# dEQP CMake compatibility (as for libpng) 61set(ZLIB_INCLUDE_PATH ${ZLIB_INCLUDE_DIRS}) 62set(ZLIB_LIBRARY ${ZLIB_LIBRARIES}) 63 64if (NOT ZLIB_INCLUDE_PATH OR NOT ZLIB_LIBRARY) 65 message(STATUS "System version of zlib not found, using external/zlib") 66 add_subdirectory(external/zlib) 67 # \note ZLIB_LIBRARY and ZLIB_INCLUDE_PATH are promoted from external/zlib/CMakeLists.txt 68endif () 69 70if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external/renderdoc/src/renderdoc_app.h") 71 message(STATUS "Renderdoc header found, integration enabled") 72 set(DEQP_HAVE_RENDERDOC_HEADER 1) 73else () 74 message(STATUS "Renderdoc header not found, integration will not work") 75endif () 76 77include_directories(${ZLIB_INCLUDE_PATH}) 78 79# libpng 80# 81# The FindPNG module defines PNG_INCLUDE_DIRS and PNG_LIBRARIES. But dEQP's 82# CMake files expect the non-standard PNG_INCLUDE_PATH and PNG_LIBRARY. Set the 83# non-standard variables here to retain compatibility with dEQP's existing 84# CMake files. 85find_package(PNG) 86set(PNG_INCLUDE_PATH ${PNG_INCLUDE_DIRS}) 87set(PNG_LIBRARY ${PNG_LIBRARIES}) 88 89if (NOT PNG_INCLUDE_PATH OR NOT PNG_LIBRARY) 90 message(STATUS "System version of libpng not found, using external/libpng") 91 add_subdirectory(external/libpng) 92 # \note PNG_LIBRARY and PNG_INCLUDE_PATH are promoted from external/libpng/CMakeLists.txt 93endif () 94 95# glslang 96add_subdirectory(external/glslang) 97 98# spirv-tools 99add_subdirectory(external/spirv-tools) 100 101# spirv-headers 102set(SPIRV_INCLUDE_PATH "${PROJECT_SOURCE_DIR}/external/spirv-headers/src/include") 103if (NOT EXISTS ${SPIRV_INCLUDE_PATH}) 104 message(FATAL_ERROR "SPIR-V headers not found, please run external/fetch_sources.py") 105endif() 106include_directories(${SPIRV_INCLUDE_PATH}) 107 108# Amber 109add_subdirectory(external/amber) 110include_directories(external/amber) 111 112# jsoncpp 113add_subdirectory(external/jsoncpp) 114include_directories(external/jsoncpp/src/include) 115 116# RenderDoc API 117include_directories(external/renderdoc/src) 118 119# FFmpeg used in vulkan video won't be part of android, fushia, or macos target 120if (DE_OS_IS_WIN32 OR DE_OS_IS_UNIX) 121 # FFmpeg 122 if (DE_OS_IS_WIN32) 123 add_subdirectory(external/ffmpeg) 124 endif() 125 include_directories(external/ffmpeg/src/include) 126endif() 127include_directories(${PNG_INCLUDE_PATH}) 128 129# DRM (Direct Rendering Manager) Headers 130find_path(XF86DRM_H_PATH NAMES xf86drm.h) 131find_path(DRM_H_PATH NAMES drm.h PATH_SUFFIXES libdrm drm) 132 133if (XF86DRM_H_PATH AND DRM_H_PATH) 134 include_directories(${XF86DRM_H_PATH}) 135 include_directories(${DRM_H_PATH}) 136 set(DEQP_SUPPORT_DRM ON CACHE BOOL "Build code requiring the Linux/Unix Direct Rendering Manager") 137 mark_as_advanced(XF86DRM_H_PATH) 138 mark_as_advanced(DRM_H_PATH) 139else () 140 set(DEQP_SUPPORT_DRM OFF CACHE BOOL "Build code requiring the Linux/Unix Direct Rendering Manager") 141endif () 142 143message(STATUS "DEQP_TARGET_NAME = ${DEQP_TARGET_NAME}") 144message(STATUS "DEQP_SUPPORT_GLES1 = ${DEQP_SUPPORT_GLES1}") 145message(STATUS "DEQP_GLES1_LIBRARIES = ${DEQP_GLES1_LIBRARIES}") 146message(STATUS "DEQP_GLES2_LIBRARIES = ${DEQP_GLES2_LIBRARIES}") 147message(STATUS "DEQP_GLES3_LIBRARIES = ${DEQP_GLES3_LIBRARIES}") 148message(STATUS "DEQP_GLES31_LIBRARIES = ${DEQP_GLES31_LIBRARIES}") 149message(STATUS "DEQP_GLES32_LIBRARIES = ${DEQP_GLES32_LIBRARIES}") 150message(STATUS "DEQP_SUPPORT_VG = ${DEQP_SUPPORT_VG}") 151message(STATUS "DEQP_VG_LIBRARIES = ${DEQP_VG_LIBRARIES}") 152message(STATUS "DEQP_EGL_LIBRARIES = ${DEQP_EGL_LIBRARIES}") 153message(STATUS "DEQP_PLATFORM_LIBRARIES = ${DEQP_PLATFORM_LIBRARIES}") 154message(STATUS "DEQP_SUPPORT_DRM = ${DEQP_SUPPORT_DRM}") 155 156# Defines 157add_definitions(-DDEQP_TARGET_NAME="${DEQP_TARGET_NAME}") 158 159# Entry points loaded directly by linking to libGL*? 160if (DEFINED DEQP_GLES2_LIBRARIES) 161 add_definitions(-DDEQP_GLES2_DIRECT_LINK=1) 162endif () 163 164if (DEFINED DEQP_GLES3_LIBRARIES) 165 add_definitions(-DDEQP_GLES3_DIRECT_LINK=1) 166endif () 167 168if (DEFINED DEQP_GLES31_LIBRARIES) 169 add_definitions(-DDEQP_GLES31_DIRECT_LINK=1) 170endif () 171 172if (DEFINED DEQP_GLES32_LIBRARIES) 173 add_definitions(-DDEQP_GLES32_DIRECT_LINK=1) 174endif () 175 176if (DEFINED DEQP_EGL_LIBRARIES) 177 add_definitions(-DDEQP_EGL_DIRECT_LINK=1) 178endif () 179 180# Legacy APIs that don't support run-time loading 181if (DEQP_SUPPORT_GLES1) 182 add_definitions(-DDEQP_SUPPORT_GLES1=1) 183 184 if (NOT DEFINED DEQP_GLES1_LIBRARIES) 185 message(FATAL_ERROR "Run-time loading of GLES1 is not supported (DEQP_GLES1_LIBRARIES is not set)") 186 endif () 187endif () 188 189if (DEQP_SUPPORT_VG) 190 add_definitions(-DDEQP_SUPPORT_VG=1) 191 192 if (NOT DEFINED DEQP_VG_LIBRARIES) 193 message(FATAL_ERROR "Run-time loading of VG is not supported (DEQP_VG_LIBRARIES is not set)") 194 endif () 195endif () 196 197if (DEQP_SUPPORT_DRM) 198 add_definitions(-DDEQP_SUPPORT_DRM=1) 199else () 200 add_definitions(-DDEQP_SUPPORT_DRM=0) 201endif () 202 203if (DE_COMPILER_IS_MSC) 204 # Don't nag about std::copy for example 205 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SCL_SECURE_NO_WARNINGS") 206endif () 207 208# Precompiled header macro. Parameters are source file list and filename for pch cpp file. 209macro(PCH SRCS PCHCPP) 210 if(MSVC AND CMAKE_GENERATOR MATCHES "^Visual Studio") 211 set(PCH_NAME "$(IntDir)\\pch.pch") 212 # make source files use/depend on PCH_NAME 213 set_source_files_properties(${${SRCS}} PROPERTIES COMPILE_FLAGS "/Yupch.h /FIpch.h /Fp${PCH_NAME}" OBJECT_DEPENDS "${PCH_NAME}") 214 # make PCHCPP file compile and generate PCH_NAME 215 set_source_files_properties(${PCHCPP} PROPERTIES COMPILE_FLAGS "/Ycpch.h /Fp${PCH_NAME}" OBJECT_OUTPUTS "${PCH_NAME}") 216 list(APPEND ${SRCS} "${PCHCPP}") 217 endif() 218endmacro(PCH) 219 220# delibs projects 221add_subdirectory(framework/delibs/debase) 222add_subdirectory(framework/delibs/depool) 223add_subdirectory(framework/delibs/dethread) 224add_subdirectory(framework/delibs/destream) 225add_subdirectory(framework/delibs/deutil) 226add_subdirectory(framework/delibs/decpp) 227 228# ExecServer 229add_subdirectory(execserver) 230 231# Executor framework and tools 232if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/executor) 233 add_subdirectory(executor) 234endif () 235 236# Test framework include directories 237include_directories( 238 framework/common 239 framework/qphelper 240 framework/opengl 241 framework/opengl/wrapper 242 framework/referencerenderer 243 framework/opengl/simplereference 244 framework/randomshaders 245 framework/egl 246 framework/egl/wrapper 247 framework/xexml 248 external/vulkancts/framework/vulkan 249 external/vulkancts/framework/vulkan/generated/vulkan 250 ) 251 252if (DE_OS_IS_ANDROID OR DE_OS_IS_IOS) 253 # On Android deqp modules are compiled as libraries and linked into final .so 254 set(DEQP_MODULE_LIBRARIES ) 255 set(DEQP_MODULE_ENTRY_POINTS ) 256endif () 257 258# Macro for adding targets for copying binaries (usually target libraries) to the target destination dir 259macro (target_copy_files target dep_name files) 260 if (NOT "${files}" STREQUAL "") 261 set(COPY_TARGETS ) 262 foreach (SRCNAME ${files}) 263 get_filename_component(BASENAME ${SRCNAME} NAME) 264 set(DSTNAME "${CMAKE_CURRENT_BINARY_DIR}/${BASENAME}") 265 add_custom_command(OUTPUT ${DSTNAME} 266 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SRCNAME} ${DSTNAME}) 267 set(COPY_TARGETS ${COPY_TARGETS} ${DSTNAME}) 268 endforeach () 269 270 add_custom_target(${dep_name} ALL DEPENDS ${COPY_TARGETS}) 271 add_dependencies(${target} ${dep_name}) 272 endif () 273endmacro (target_copy_files) 274 275set(MODULE_LIB_TARGET_POSTFIX "-package") 276set(MODULE_DATA_TARGET_POSTFIX "-data") 277 278# Macro for adding dEQP module 279# This adds 3 targets: 280# ${MODULE_NAME}-package: Static library that contains all SRCS and links to LIBS 281# ${MODULE_NAME}-data: Custom target that is used for data file copies 282# ${MODULE_NAME}: Executable binary (if supported by the platform) 283macro (add_deqp_module MODULE_NAME SRCS LIBS EXECLIBS ENTRY) 284 285 # Library target 286 add_library("${MODULE_NAME}${MODULE_LIB_TARGET_POSTFIX}" STATIC ${SRCS}) 287 target_link_libraries("${MODULE_NAME}${MODULE_LIB_TARGET_POSTFIX}" ${LIBS}) 288 289 set(DEQP_MODULE_LIBRARIES ${DEQP_MODULE_LIBRARIES} "${MODULE_NAME}${MODULE_LIB_TARGET_POSTFIX}") 290 set(DEQP_MODULE_ENTRY_POINTS ${DEQP_MODULE_ENTRY_POINTS} "${CMAKE_CURRENT_SOURCE_DIR}/${ENTRY}") 291 292 # Forward to parent scope 293 set(DEQP_MODULE_LIBRARIES ${DEQP_MODULE_LIBRARIES} PARENT_SCOPE) 294 set(DEQP_MODULE_ENTRY_POINTS ${DEQP_MODULE_ENTRY_POINTS} PARENT_SCOPE) 295 296 if (NOT DE_OS_IS_ANDROID AND NOT DE_OS_IS_IOS) 297 # Executable target 298 add_executable(${MODULE_NAME} ${PROJECT_SOURCE_DIR}/framework/platform/tcuMain.cpp ${ENTRY}) 299 target_link_libraries(${MODULE_NAME} PUBLIC "${EXECLIBS}" "${MODULE_NAME}${MODULE_LIB_TARGET_POSTFIX}") 300 target_copy_files(${MODULE_NAME} platform-libs-${MODULE_NAME} "${DEQP_PLATFORM_COPY_LIBRARIES}") 301 endif () 302 303 # Data file target 304 add_custom_target("${MODULE_NAME}${MODULE_DATA_TARGET_POSTFIX}") 305 add_dependencies("${MODULE_NAME}${MODULE_LIB_TARGET_POSTFIX}" "${MODULE_NAME}${MODULE_DATA_TARGET_POSTFIX}") 306endmacro (add_deqp_module) 307 308# Macro add_deqp_module_skip_android does not add module to DEQP_MODULE_LIBRARIES, so that it is not created on Android. 309# It's a temporary solution to disable Vulkan SC tests on Android, because later defined deqp library 310# uses both deqp-vk and deqp-vksc and this means that definitions CTS_USES_VULKAN and CTS_USES_VULKANSC 311# exist in deqp library at the same time which causes code to not compile. 312macro (add_deqp_module_skip_android MODULE_NAME SRCS LIBS EXECLIBS ENTRY) 313 314 # Library target 315 add_library("${MODULE_NAME}${MODULE_LIB_TARGET_POSTFIX}" STATIC ${SRCS}) 316 target_link_libraries("${MODULE_NAME}${MODULE_LIB_TARGET_POSTFIX}" ${LIBS}) 317 318 if (NOT DE_OS_IS_ANDROID AND NOT DE_OS_IS_IOS) 319 # Executable target 320 add_executable(${MODULE_NAME} ${PROJECT_SOURCE_DIR}/framework/platform/tcuMain.cpp ${ENTRY}) 321 target_link_libraries(${MODULE_NAME} PUBLIC "${EXECLIBS}" "${MODULE_NAME}${MODULE_LIB_TARGET_POSTFIX}") 322 target_copy_files(${MODULE_NAME} platform-libs-${MODULE_NAME} "${DEQP_PLATFORM_COPY_LIBRARIES}") 323 endif () 324 325 # Data file target 326 add_custom_target("${MODULE_NAME}${MODULE_DATA_TARGET_POSTFIX}") 327 add_dependencies("${MODULE_NAME}${MODULE_LIB_TARGET_POSTFIX}" "${MODULE_NAME}${MODULE_DATA_TARGET_POSTFIX}") 328endmacro (add_deqp_module_skip_android) 329 330# Macro for adding data dirs to module 331macro (add_data_dir MODULE_NAME SRC_DIR DST_DIR) 332 if (DE_OS_IS_WIN32 OR DE_OS_IS_UNIX OR DE_OS_IS_OSX OR DE_OS_IS_QNX) 333 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}) 334 335 elseif (DE_OS_IS_ANDROID) 336 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}) 337 338 elseif (DE_OS_IS_IOS) 339 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}) 340 endif () 341endmacro (add_data_dir) 342 343# Macro for adding individual data files to module 344macro (add_data_file MODULE_NAME SRC_FILE DST_FILE) 345 if (DE_OS_IS_WIN32 OR DE_OS_IS_UNIX OR DE_OS_IS_OSX OR DE_OS_IS_QNX) 346 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}) 347 348 elseif (DE_OS_IS_ANDROID) 349 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}) 350 351 elseif (DE_OS_IS_IOS) 352 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}) 353 endif () 354endmacro (add_data_file) 355 356add_subdirectory(framework) 357add_subdirectory(external/vulkancts/framework/vulkan) 358 359if (DE_COMPILER_IS_MSC) 360 add_compile_options(/bigobj) # Required by glsBuiltinPrecisionTests.cpp 361endif () 362 363add_subdirectory(modules) 364add_subdirectory(external/vulkancts/modules/vulkan) 365add_subdirectory(external/vulkancts/vkscserver) 366add_subdirectory(external/vulkancts/vkscpc) 367add_subdirectory(external/openglcts) 368 369# Single-binary targets 370if (DE_OS_IS_ANDROID) 371 include_directories(executor) 372 include_directories(${PROJECT_BINARY_DIR}/external/vulkancts/framework/vulkan) 373 374 set(DEQP_SRCS 375 framework/platform/android/tcuAndroidMain.cpp 376 framework/platform/android/tcuAndroidJNI.cpp 377 framework/platform/android/tcuAndroidPlatformCapabilityQueryJNI.cpp 378 framework/platform/android/tcuTestLogParserJNI.cpp 379 ${DEQP_MODULE_ENTRY_POINTS} 380 ) 381 382 set(DEQP_LIBS 383 tcutil-platform 384 xecore 385 ${DEQP_MODULE_LIBRARIES} 386 ) 387 388 add_library(deqp SHARED ${DEQP_SRCS}) 389 target_link_libraries(deqp ${DEQP_LIBS}) 390 391 # Separate out the debug information because it's enormous 392 add_custom_command(TARGET deqp POST_BUILD 393 COMMAND ${CMAKE_STRIP} --only-keep-debug -o $<TARGET_FILE:deqp>.debug $<TARGET_FILE:deqp> 394 COMMAND ${CMAKE_STRIP} -g $<TARGET_FILE:deqp>) 395 396 # Needed by OpenGL CTS that defines its own activity but depends on 397 # common Android support code. 398 target_include_directories(deqp PRIVATE framework/platform/android) 399 400elseif (DE_OS_IS_IOS) 401 # Code sign identity 402 set(DEQP_IOS_CODE_SIGN_IDENTITY "drawElements" CACHE STRING "Code sign identity for iOS build") 403 404 set(MACOSX_BUNDLE_PRODUCT_NAME "\${PRODUCT_NAME}") 405 set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.drawelements.\${PRODUCT_NAME:identifier}") 406 407 include_directories(framework/platform/ios) 408 set(TESTERCORE_SRC_FILES 409 framework/platform/ios/tcuEAGLView.h 410 framework/platform/ios/tcuEAGLView.m 411 framework/platform/ios/tcuIOSAppDelegate.h 412 framework/platform/ios/tcuIOSAppDelegate.m 413 framework/platform/ios/tcuIOSViewController.h 414 framework/platform/ios/tcuIOSViewController.m 415 framework/platform/ios/tcuIOSMain.m 416 ) 417 set_source_files_properties(${TESTERCORE_SRC_FILES} COMPILE_FLAGS "-std=c99") 418 419 add_executable(deqp MACOSX_BUNDLE ${TESTERCORE_SRC_FILES} ${DEQP_MODULE_ENTRY_POINTS}) 420 target_link_libraries(deqp tcutil-platform xscore ${DEQP_MODULE_LIBRARIES}) 421 set_target_properties(deqp PROPERTIES XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2") 422 set_target_properties(deqp PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer: ${DEQP_IOS_CODE_SIGN_IDENTITY}") 423endif () 424 425if (DE_OS_IS_FUCHSIA) 426 # The default Fuchsia stack is small, so the size needs to be increased to at 427 # least 2**20 bytes, but 2**24 is chosen for safety. 428 set_target_properties(deqp-vk PROPERTIES LINK_FLAGS "-Wl,-z,stack-size=0x1000000") 429endif () 430