mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-22 17:22:15 +09:00
136 lines
5.0 KiB
CMake
136 lines
5.0 KiB
CMake
# MobileGL - MobileGL/MG_Test/CMakeLists.txt
|
|
# Copyright (c) 2025-2026 MobileGL-Dev
|
|
# Licensed under the GNU Lesser General Public License v3.0:
|
|
# https://www.gnu.org/licenses/gpl-3.0.txt
|
|
# https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
# SPDX-License-Identifier: LGPL-3.0-only
|
|
# End of Source File Header
|
|
|
|
cmake_minimum_required(VERSION 3.24)
|
|
project(MobileGLTest)
|
|
|
|
message(STATUS "Generating build files for MobileGL Test...")
|
|
|
|
set(CMAKE_CXX_STANDARD 23)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(MGL_ROOT ${CMAKE_CURRENT_LIST_DIR}/../..)
|
|
|
|
# # Add the directory containing our custom Find modules
|
|
# list(APPEND CMAKE_MODULE_PATH "${MGL_ROOT}/buildsystem/cmake")
|
|
|
|
include(FetchContent)
|
|
FetchContent_Declare(
|
|
googletest
|
|
GIT_REPOSITORY https://github.com/google/googletest.git
|
|
GIT_TAG v1.17.0
|
|
)
|
|
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
|
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
|
FetchContent_MakeAvailable(googletest)
|
|
|
|
# The main() of every test binary: gtest's, then the shader compile workers stop before main
|
|
# returns (see TestMain.cpp).
|
|
add_library(MobileGLTestMain STATIC TestMain.cpp)
|
|
target_link_libraries(MobileGLTestMain PUBLIC GTest::gtest MobileGL_s)
|
|
target_include_directories(MobileGLTestMain PRIVATE ${MGL_ROOT}/include ${MGL_ROOT}/MobileGL)
|
|
|
|
enable_testing()
|
|
|
|
# # Find the required libraries using our custom Find modules
|
|
# find_package(glslang REQUIRED)
|
|
# find_package(SPIRVCross REQUIRED)
|
|
# find_package(SPIRVTools)
|
|
|
|
add_executable(
|
|
SanityTest
|
|
SanityTest.cpp
|
|
)
|
|
target_link_libraries(
|
|
SanityTest
|
|
MobileGLTestMain
|
|
MobileGL_s
|
|
)
|
|
|
|
target_include_directories(SanityTest PRIVATE
|
|
${MGL_ROOT}/include
|
|
${MGL_ROOT}/MobileGL
|
|
)
|
|
|
|
# message(STATUS "glslang_LIBRARIES: ${glslang_LIBRARIES}")
|
|
# message(STATUS "SPIRVTools_LIBRARIES: ${SPIRVTools_LIBRARIES}")
|
|
# message(STATUS "SPIRVCross_LIBRARIES: ${SPIRVCross_LIBRARIES}")
|
|
|
|
# # Set the libraries to link against
|
|
# set(LINK_LIBRARIES
|
|
# ${glslang_LIBRARIES}
|
|
# ${SPIRVCross_LIBRARIES}
|
|
# )
|
|
|
|
# if (SPIRVTools_FOUND)
|
|
# list(APPEND LINK_LIBRARIES ${SPIRVTools_LIBRARIES})
|
|
# endif()
|
|
|
|
set(LINK_LIBRARIES
|
|
MobileGL_s
|
|
)
|
|
|
|
include(GoogleTest)
|
|
gtest_discover_tests(SanityTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
|
|
|
|
if (MSVC)
|
|
# The GL headers declare gl* as dllimport on Windows, so any test that pulls
|
|
# GetProcAddress.cpp out of the static library references __imp_gl*, which only
|
|
# resolves when the in-library entry-point definitions are part of the link.
|
|
# Applies to every test executable below, the way the DirectVulkan and
|
|
# integration test targets already do it for themselves.
|
|
add_link_options(/WHOLEARCHIVE:MobileGL_s)
|
|
endif()
|
|
|
|
add_subdirectory(BackendLoader)
|
|
add_subdirectory(Buffer)
|
|
# The heap-address-is-not-an-identity invariant the backends' per-object memos
|
|
# rest on. No GL context, no driver: it only needs the allocator.
|
|
add_subdirectory(State)
|
|
add_subdirectory(EGLState)
|
|
add_subdirectory(Framebuffer)
|
|
add_subdirectory(Texture)
|
|
add_subdirectory(VertexArray)
|
|
add_subdirectory(Program)
|
|
add_subdirectory(Query)
|
|
add_subdirectory(Pipeline)
|
|
# The MGPipe catalog arithmetic: no GL context and no driver, just the .def, the seven
|
|
# generated files and the payload layouts.
|
|
add_subdirectory(Pipe)
|
|
# The P0.5 interface-purity gate: a python walk of #include lines, so it registers with no
|
|
# MobileGL build, no GL context and no submodules (scripts/check_include_closure.py).
|
|
add_subdirectory(Purity)
|
|
add_subdirectory(Swapchain)
|
|
add_subdirectory(ShaderTranspiler)
|
|
add_subdirectory(Util)
|
|
add_subdirectory(SelfTest)
|
|
# The DirectGLES post-transpile ESSL passes are pure String -> String, so unlike the
|
|
# DirectVulkan suite below this one needs no device and always builds.
|
|
add_subdirectory(Backend/DirectGLES)
|
|
# Which session's submission stops the GPU (MG_Backend/GpuHangWatch.h): no device, no driver.
|
|
add_executable(GpuHangWatchTest Backend/GpuHangWatchTest.cpp)
|
|
target_include_directories(GpuHangWatchTest PRIVATE ${MGL_ROOT}/include ${MGL_ROOT}/MobileGL)
|
|
target_link_libraries(GpuHangWatchTest PRIVATE MobileGLTestMain ${LINK_LIBRARIES})
|
|
gtest_discover_tests(GpuHangWatchTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
|
|
# The base class's EGL surface and current-context bookkeeping driven through a test double: no
|
|
# device, no EGL driver, no window.
|
|
add_executable(BackendObjectEglStateTest Backend/BackendObjectEglStateTest.cpp)
|
|
target_include_directories(BackendObjectEglStateTest PRIVATE ${MGL_ROOT}/include ${MGL_ROOT}/MobileGL)
|
|
target_link_libraries(BackendObjectEglStateTest PRIVATE MobileGLTestMain ${LINK_LIBRARIES})
|
|
gtest_discover_tests(BackendObjectEglStateTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
|
|
if (ENABLE_INTEGRATION_TESTS)
|
|
add_subdirectory(Backend/DirectVulkan)
|
|
endif()
|
|
# The wire layer only exists in the disaggregated configuration, so its suite
|
|
# is only registered there. Nothing under MG_Remote is compiled otherwise.
|
|
if (MOBILEGL_BUILD_DISAGGREGATED)
|
|
add_subdirectory(Wire)
|
|
# The GBM backend glamor uses (Xwayland on MobileGL), through the system's loader.
|
|
add_subdirectory(Gbm)
|
|
endif()
|