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))
23
24		set(TCUTIL_PLATFORM_SRCS
25			lnx/tcuLnx.cpp
26			lnx/tcuLnx.cpp
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			set(TCUTIL_PLATFORM_SRCS
77				${TCUTIL_PLATFORM_SRCS}
78				lnx/wayland/tcuLnxWayland.hpp
79				lnx/wayland/tcuLnxWayland.cpp
80				lnx/wayland/tcuLnxWaylandEglDisplayFactory.cpp
81				lnx/wayland/tcuLnxWaylandEglDisplayFactory.hpp
82				)
83			include_directories(wayland)
84		endif()
85
86	elseif (DE_OS_IS_UNIX AND DEQP_USE_SURFACELESS)
87		set(TCUTIL_PLATFORM_SRCS
88			surfaceless/tcuSurfacelessPlatform.hpp
89			surfaceless/tcuSurfacelessPlatform.cpp
90			)
91
92	elseif (DE_OS_IS_ANDROID)
93		set(TCUTIL_PLATFORM_SRCS
94			android/tcuAndroidExecService.cpp
95			android/tcuAndroidExecService.hpp
96			)
97
98		if (DE_ANDROID_API GREATER 8)
99			# Add NativeActivity code
100			set(TCUTIL_PLATFORM_SRCS
101				${TCUTIL_PLATFORM_SRCS}
102				android/tcuAndroidAssets.cpp
103				android/tcuAndroidAssets.hpp
104				android/tcuAndroidInternals.cpp
105				android/tcuAndroidInternals.hpp
106				android/tcuAndroidNativeActivity.cpp
107				android/tcuAndroidNativeActivity.hpp
108				android/tcuAndroidPlatform.cpp
109				android/tcuAndroidPlatform.hpp
110				android/tcuAndroidRenderActivity.cpp
111				android/tcuAndroidRenderActivity.hpp
112				android/tcuAndroidTestActivity.cpp
113				android/tcuAndroidTestActivity.hpp
114				android/tcuAndroidUtil.cpp
115				android/tcuAndroidUtil.hpp
116				android/tcuAndroidWindow.cpp
117				android/tcuAndroidWindow.hpp
118				)
119		endif ()
120
121	elseif (DE_OS_IS_IOS)
122		set(TCUTIL_PLATFORM_SRCS
123			ios/tcuIOSApp.mm
124			ios/tcuIOSApp.h
125			ios/tcuIOSPlatform.mm
126			ios/tcuIOSPlatform.hh
127			)
128
129	elseif (DE_OS_IS_OSX)
130		set(TCUTIL_PLATFORM_SRCS
131			osx/tcuOSXPlatform.cpp
132			osx/tcuOSXPlatform.hpp
133			osx/tcuOSXVulkanPlatform.cpp
134			osx/tcuOSXVulkanPlatform.hpp
135			osx/tcuOSXMetalView.mm
136			osx/tcuOSXMetalView.hpp
137			)
138
139	else ()
140		set(TCUTIL_PLATFORM_SRCS
141			vanilla/tcuVanillaPlatform.cpp
142			)
143
144	endif ()
145endif ()
146
147add_library(tcutil-platform STATIC ${TCUTIL_PLATFORM_SRCS})
148
149# Add vkutil to the deps before tcutil so that it picks up the c++11 dependencies
150target_link_libraries(tcutil-platform vkutil)
151
152target_link_libraries(tcutil-platform tcutil ${TCUTIL_PLATFORM_LIBS})
153
154# Always link to glutil as some platforms such as Win32 always support GL
155target_link_libraries(tcutil-platform glutil)
156
157# Always link to eglutil
158target_link_libraries(tcutil-platform eglutil)
159
160# X11 libraries
161if (DEQP_USE_X11)
162	find_package(X11 REQUIRED)
163	target_link_libraries(tcutil-platform ${X11_LIBRARIES})
164	if (DEQP_USE_XCB)
165		find_package(XCB REQUIRED)
166		target_link_libraries(tcutil-platform ${XCB_LIBRARIES})
167		add_definitions(-DDEQP_SUPPORT_XCB=1)
168	endif ()
169	if (DEQP_SUPPORT_GLX)
170	  # GLX functions don't currently have wrappers, so link directly to libGL.
171	  target_link_libraries(tcutil-platform GL)
172	endif ()
173	if (DEQP_USE_WAYLAND)
174		find_package(Wayland REQUIRED)
175		target_link_libraries(tcutil-platform ${WAYLAND_LIBRARIES})
176		add_definitions(-DDEQP_SUPPORT_WAYLAND=1)
177	endif ()
178endif ()
179