1# Platform port library 2 3# Target file may define TCUTIL_PLATFORM_SRCS 4if (NOT DEFINED TCUTIL_PLATFORM_SRCS) 5 if (DE_OS_IS_WIN32) 6 set(TCUTIL_PLATFORM_SRCS 7 win32/tcuWin32Platform.hpp 8 win32/tcuWin32Platform.cpp 9 win32/tcuWGLContextFactory.hpp 10 win32/tcuWGLContextFactory.cpp 11 win32/tcuWGL.hpp 12 win32/tcuWGL.cpp 13 win32/tcuWin32API.h 14 win32/tcuWin32Window.cpp 15 win32/tcuWin32Window.hpp 16 win32/tcuWin32EGLNativeDisplayFactory.hpp 17 win32/tcuWin32EGLNativeDisplayFactory.cpp 18 win32/tcuWin32VulkanPlatform.hpp 19 win32/tcuWin32VulkanPlatform.cpp 20 ) 21 22 elseif ((DE_OS_IS_UNIX OR DE_OS_IS_OSX) AND (DEQP_USE_X11 OR DEQP_USE_WAYLAND OR DEQP_USE_HEADLESS)) 23 24 set(TCUTIL_PLATFORM_SRCS 25 lnx/tcuLnx.cpp 26 lnx/tcuLnx.hpp 27 lnx/tcuLnxPlatform.cpp 28 lnx/tcuLnxPlatform.hpp 29 lnx/tcuLnxEglPlatform.hpp 30 lnx/tcuLnxEglPlatform.cpp 31 lnx/tcuLnxVulkanPlatform.hpp 32 lnx/tcuLnxVulkanPlatform.cpp 33 ) 34 35 include_directories(lnx) 36 37 if (DEQP_USE_X11) 38 add_definitions(-DDEQP_SUPPORT_X11=1) 39 include_directories(lnx/X11) 40 41 message(STATUS "DEQP_SUPPORT_GLX = ${DEQP_SUPPORT_GLX}") 42 43 if (DEQP_SUPPORT_GLX) 44 add_definitions(-DDEQP_SUPPORT_GLX=1) 45 endif () 46 47 set(TCUTIL_PLATFORM_SRCS 48 ${TCUTIL_PLATFORM_SRCS} 49 lnx/X11/tcuLnxX11.cpp 50 lnx/X11/tcuLnxX11.hpp 51 lnx/X11/tcuLnxX11EglDisplayFactory.hpp 52 lnx/X11/tcuLnxX11EglDisplayFactory.cpp 53 ) 54 55 if (DEQP_USE_XCB) 56 set(TCUTIL_PLATFORM_SRCS 57 ${TCUTIL_PLATFORM_SRCS} 58 lnx/X11/tcuLnxX11Xcb.hpp 59 lnx/X11/tcuLnxX11Xcb.cpp 60 ) 61 endif() 62 63 if (DEQP_SUPPORT_GLX) 64 set(TCUTIL_PLATFORM_SRCS 65 ${TCUTIL_PLATFORM_SRCS} 66 lnx/X11/tcuLnxX11GlxPlatform.hpp 67 lnx/X11/tcuLnxX11GlxPlatform.cpp 68 ) 69 endif() 70 endif() 71 72 if (DEQP_USE_WAYLAND) 73 add_definitions(-DDEQP_SUPPORT_WAYLAND=1) 74 include_directories(lnx/wayland) 75 76 pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir) 77 78 if (NOT WAYLAND_SCANNER) 79 pkg_get_variable(WAYLAND_SCANNER wayland-scanner wayland_scanner) 80 endif() 81 82 set(DEQP_XDG_SHELL_PROTOCOL ${WAYLAND_PROTOCOLS_DIR}/stable/xdg-shell/xdg-shell.xml) 83 set(DEQP_XDG_SHELL_GEN_OUTPUTS_DIR ${PROJECT_BINARY_DIR}/framework/platform) 84 set(DEQP_XDG_SHELL_OUTPUTS 85 ${DEQP_XDG_SHELL_GEN_OUTPUTS_DIR}/xdg-shell.c 86 ${DEQP_XDG_SHELL_GEN_OUTPUTS_DIR}/xdg-shell.h) 87 88 add_custom_command( 89 COMMAND ${WAYLAND_SCANNER} ARGS client-header ${DEQP_XDG_SHELL_PROTOCOL} xdg-shell.h 90 COMMAND ${WAYLAND_SCANNER} ARGS public-code ${DEQP_XDG_SHELL_PROTOCOL} xdg-shell.c 91 DEPENDS ${DEQP_XDG_SHELL_PROTOCOL} 92 OUTPUT ${DEQP_XDG_SHELL_OUTPUTS}) 93 94 add_custom_target( 95 deqp-xdg-shell ALL 96 DEPENDS ${DEQP_XDG_SHELL_OUTPUTS}) 97 98 set(TCUTIL_PLATFORM_SRCS 99 ${TCUTIL_PLATFORM_SRCS} 100 lnx/wayland/tcuLnxWayland.hpp 101 lnx/wayland/tcuLnxWayland.cpp 102 lnx/wayland/tcuLnxWaylandEglDisplayFactory.cpp 103 lnx/wayland/tcuLnxWaylandEglDisplayFactory.hpp 104 ${DEQP_XDG_SHELL_GEN_OUTPUTS_DIR}/xdg-shell.c 105 ${DEQP_XDG_SHELL_GEN_OUTPUTS_DIR}/xdg-shell.h 106 ) 107 include_directories(${DEQP_XDG_SHELL_GEN_OUTPUTS_DIR}) 108 include_directories(wayland) 109 endif() 110 111 if (DEQP_USE_HEADLESS) 112 add_definitions(-DDEQP_SUPPORT_HEADLESS=1) 113 endif() 114 115 elseif (DE_OS_IS_UNIX AND DEQP_USE_SURFACELESS) 116 set(TCUTIL_PLATFORM_SRCS 117 surfaceless/tcuSurfacelessPlatform.hpp 118 surfaceless/tcuSurfacelessPlatform.cpp 119 ) 120 121 elseif (DE_OS_IS_ANDROID) 122 set(TCUTIL_PLATFORM_SRCS 123 android/tcuAndroidExecService.cpp 124 android/tcuAndroidExecService.hpp 125 ) 126 127 if (DE_ANDROID_API GREATER 8) 128 # Add NativeActivity code 129 set(TCUTIL_PLATFORM_SRCS 130 ${TCUTIL_PLATFORM_SRCS} 131 android/tcuAndroidAssets.cpp 132 android/tcuAndroidAssets.hpp 133 android/tcuAndroidNativeActivity.cpp 134 android/tcuAndroidNativeActivity.hpp 135 android/tcuAndroidPlatform.cpp 136 android/tcuAndroidPlatform.hpp 137 android/tcuAndroidRenderActivity.cpp 138 android/tcuAndroidRenderActivity.hpp 139 android/tcuAndroidTestActivity.cpp 140 android/tcuAndroidTestActivity.hpp 141 android/tcuAndroidUtil.cpp 142 android/tcuAndroidUtil.hpp 143 android/tcuAndroidWindow.cpp 144 android/tcuAndroidWindow.hpp 145 ) 146 endif () 147 148 elseif (DE_OS_IS_IOS) 149 set(TCUTIL_PLATFORM_SRCS 150 ios/tcuIOSApp.mm 151 ios/tcuIOSApp.h 152 ios/tcuIOSPlatform.mm 153 ios/tcuIOSPlatform.hh 154 ) 155 156 elseif (DE_OS_IS_OSX) 157 set(TCUTIL_PLATFORM_SRCS 158 osx/tcuOSXPlatform.cpp 159 osx/tcuOSXPlatform.hpp 160 osx/tcuOSXVulkanPlatform.cpp 161 osx/tcuOSXVulkanPlatform.hpp 162 osx/tcuOSXMetalView.mm 163 osx/tcuOSXMetalView.hpp 164 ) 165 list(APPEND TCUTIL_PLATFORM_LIBS ${QUARTZCORE_LIBRARY} ${COCOA_LIBRARY}) 166 167 elseif (DE_OS_IS_FUCHSIA) 168 set(TCUTIL_PLATFORM_SRCS 169 fuchsia/tcuFuchsiaPlatform.cpp 170 ) 171 172 else () 173 set(TCUTIL_PLATFORM_SRCS 174 vanilla/tcuVanillaPlatform.cpp 175 ) 176 177 endif () 178endif () 179 180include_directories(${PROJECT_BINARY_DIR}/external/vulkancts/framework/vulkan) 181 182add_library(tcutil-platform STATIC ${TCUTIL_PLATFORM_SRCS}) 183if (DEQP_USE_WAYLAND) 184 add_dependencies(tcutil-platform deqp-xdg-shell) 185endif() 186 187# Add vkutil to the deps before tcutil so that it picks up the c++11 dependencies 188target_link_libraries(tcutil-platform vkutil) 189 190target_link_libraries(tcutil-platform tcutil ${TCUTIL_PLATFORM_LIBS}) 191 192# Always link to glutil as some platforms such as Win32 always support GL 193target_link_libraries(tcutil-platform glutil) 194 195# Always link to eglutil 196target_link_libraries(tcutil-platform eglutil) 197 198# X11 libraries 199if (DEQP_USE_X11) 200 find_package(X11 REQUIRED) 201 target_link_libraries(tcutil-platform ${X11_LIBRARIES}) 202 if (DEQP_USE_XCB) 203 find_package(XCB REQUIRED) 204 target_link_libraries(tcutil-platform ${XCB_LIBRARIES}) 205 target_compile_definitions(tcutil-platform PUBLIC DEQP_SUPPORT_XCB=1) 206 endif () 207 if (DEQP_SUPPORT_GLX) 208 # GLX functions don't currently have wrappers, so link directly to libGL. 209 target_link_libraries(tcutil-platform GL) 210 endif () 211 if (DEQP_USE_WAYLAND) 212 find_package(Wayland REQUIRED) 213 target_link_libraries(tcutil-platform ${WAYLAND_LIBRARIES}) 214 target_compile_definitions(tcutil-platform PUBLIC DEQP_SUPPORT_WAYLAND=1) 215 endif () 216endif () 217 218if (DE_OS_IS_WIN32) 219 target_link_libraries(tcutil-platform "version") 220endif() 221 222# Add similar library for Vulkan SC ( uses same code as vkutil, but with different INL files ) 223add_library(tcutil-sc-platform STATIC ${TCUTIL_PLATFORM_SRCS}) 224target_include_directories(tcutil-sc-platform BEFORE PUBLIC ${CMAKE_SOURCE_DIR}/external/vulkancts/framework/vulkan/generated/vulkansc) 225 226# Add vkscutil to the deps before tcutil so that it picks up the c++11 dependencies 227target_link_libraries(tcutil-sc-platform vkscutil) 228 229target_link_libraries(tcutil-sc-platform tcutil ${TCUTIL_PLATFORM_LIBS}) 230 231# Always link to glutil as some platforms such as Win32 always support GL 232target_link_libraries(tcutil-sc-platform glutil) 233 234# Always link to eglutil 235target_link_libraries(tcutil-sc-platform eglutil) 236 237# X11 libraries 238if (DEQP_USE_X11) 239 find_package(X11 REQUIRED) 240 target_link_libraries(tcutil-sc-platform ${X11_LIBRARIES}) 241 if (DEQP_USE_XCB) 242 find_package(XCB REQUIRED) 243 target_link_libraries(tcutil-sc-platform ${XCB_LIBRARIES}) 244 target_compile_definitions(tcutil-sc-platform PUBLIC DEQP_SUPPORT_XCB=1) 245 endif () 246 if (DEQP_SUPPORT_GLX) 247 # GLX functions don't currently have wrappers, so link directly to libGL. 248 target_link_libraries(tcutil-sc-platform GL) 249 endif () 250 if (DEQP_USE_WAYLAND) 251 find_package(Wayland REQUIRED) 252 target_link_libraries(tcutil-sc-platform ${WAYLAND_LIBRARIES}) 253 target_compile_definitions(tcutil-sc-platform PUBLIC DEQP_SUPPORT_WAYLAND=1) 254 endif () 255endif () 256 257if (DE_OS_IS_WIN32) 258 target_link_libraries(tcutil-sc-platform "version") 259endif() 260 261