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)
23		set(TCUTIL_PLATFORM_SRCS
24			X11/tcuX11.cpp
25			X11/tcuX11.hpp
26			X11/tcuX11Platform.hpp
27			X11/tcuX11Platform.cpp
28			)
29		if (DEQP_SUPPORT_EGL)
30			set(TCUTIL_PLATFORM_SRCS
31				${TCUTIL_PLATFORM_SRCS}
32				X11/tcuX11EglPlatform.hpp
33				X11/tcuX11EglPlatform.cpp
34				)
35		endif()
36		if (DEQP_SUPPORT_GLX)
37			set(TCUTIL_PLATFORM_SRCS
38				${TCUTIL_PLATFORM_SRCS}
39				X11/tcuX11GlxPlatform.hpp
40				X11/tcuX11GlxPlatform.cpp
41				)
42		endif()
43		if (NOT (DEQP_SUPPORT_EGL OR DEQP_SUPPORT_GLX))
44		  message(FATAL_ERROR "At least one of EGL and GLX must be enabled for X11")
45		endif ()
46	elseif (DE_OS_IS_ANDROID)
47		set(TCUTIL_PLATFORM_SRCS
48			android/tcuAndroidExecService.cpp
49			android/tcuAndroidExecService.hpp
50			)
51
52		if (DE_ANDROID_API GREATER 8)
53			# Add NativeActivity code
54			set(TCUTIL_PLATFORM_SRCS
55				${TCUTIL_PLATFORM_SRCS}
56				android/tcuAndroidAssets.cpp
57				android/tcuAndroidAssets.hpp
58				android/tcuAndroidInternals.cpp
59				android/tcuAndroidInternals.hpp
60				android/tcuAndroidNativeActivity.cpp
61				android/tcuAndroidNativeActivity.hpp
62				android/tcuAndroidPlatform.cpp
63				android/tcuAndroidPlatform.hpp
64				android/tcuAndroidRenderActivity.cpp
65				android/tcuAndroidRenderActivity.hpp
66				android/tcuAndroidTestActivity.cpp
67				android/tcuAndroidTestActivity.hpp
68				android/tcuAndroidUtil.cpp
69				android/tcuAndroidUtil.hpp
70				android/tcuAndroidWindow.cpp
71				android/tcuAndroidWindow.hpp
72				)
73		endif ()
74
75	elseif (DE_OS_IS_IOS)
76		set(TCUTIL_PLATFORM_SRCS
77			ios/tcuIOSApp.mm
78			ios/tcuIOSApp.h
79			ios/tcuIOSPlatform.mm
80			ios/tcuIOSPlatform.hh
81			)
82
83	elseif (DE_OS_IS_OSX)
84		set(TCUTIL_PLATFORM_SRCS
85			osx/tcuOSXPlatform.cpp
86			osx/tcuOSXPlatform.hpp
87			)
88
89	else ()
90		set(TCUTIL_PLATFORM_SRCS
91			vanilla/tcuVanillaPlatform.cpp
92			)
93
94	endif ()
95endif ()
96
97add_library(tcutil-platform STATIC ${TCUTIL_PLATFORM_SRCS})
98
99# Add vkutil to the deps before tcutil so that it picks up the c++11 dependencies
100target_link_libraries(tcutil-platform vkutil)
101
102target_link_libraries(tcutil-platform tcutil ${TCUTIL_PLATFORM_LIBS})
103
104# Always link to glutil as some platforms such as Win32 always support GL
105target_link_libraries(tcutil-platform glutil)
106
107# Always link to eglutil
108target_link_libraries(tcutil-platform eglutil)
109
110# X11 libraries
111if (DEQP_USE_X11)
112	find_package(X11 REQUIRED)
113	target_link_libraries(tcutil-platform ${X11_LIBRARIES})
114	if (DEQP_SUPPORT_GLX)
115	  # GLX functions don't currently have wrappers, so link directly to libGL.
116	  target_link_libraries(tcutil-platform GL)
117	endif ()
118endif ()
119