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