Commit 334d0501 authored by Ryan Pavlik's avatar Ryan Pavlik
Browse files

build: Improve test building.

Uses the FindLibcheck and friends at the top level to control
BUILD_TESTING (which CTest uses).

Adds the test to the project so CTest can see it too.

PROJECT_SOURCE_DIR instead of CMAKE_SOURCE_DIR
so it doesn't break in case this is a subproject somewhere.
parent 353572c8
...@@ -24,7 +24,8 @@ find_package(Vulkan REQUIRED) ...@@ -24,7 +24,8 @@ find_package(Vulkan REQUIRED)
find_package(OpenGL REQUIRED COMPONENTS GLX) find_package(OpenGL REQUIRED COMPONENTS GLX)
find_package(HIDAPI) find_package(HIDAPI)
find_package(OpenHMD) find_package(OpenHMD)
find_package(Libcheck)
find_package(glfw3)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux") if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_package(X11) find_package(X11)
...@@ -37,6 +38,7 @@ cmake_dependent_option(BUILD_WITH_HIDAPI "Enable HIDAPI-based OSVR HDK driver" O ...@@ -37,6 +38,7 @@ cmake_dependent_option(BUILD_WITH_HIDAPI "Enable HIDAPI-based OSVR HDK driver" O
cmake_dependent_option(BUILD_WITH_WAYLAND "Enable Wayland support" ON "WAYLAND_FOUND" OFF) cmake_dependent_option(BUILD_WITH_WAYLAND "Enable Wayland support" ON "WAYLAND_FOUND" OFF)
cmake_dependent_option(BUILD_WITH_XLIB "Enable xlib support" ON "X11_FOUND" OFF) cmake_dependent_option(BUILD_WITH_XLIB "Enable xlib support" ON "X11_FOUND" OFF)
cmake_dependent_option(BUILD_WITH_OPENGL "Enable OpenGL Graphics API support?" ON "OPENGL_FOUND" OFF) cmake_dependent_option(BUILD_WITH_OPENGL "Enable OpenGL Graphics API support?" ON "OPENGL_FOUND" OFF)
cmake_dependent_option(BUILD_TESTING "Enable building of the test suite?" ON "LIBCHECK_FOUND AND glfw3_FOUND AND OPENGL_FOUND" OFF)
if(NOT BUILD_WITH_OPENHMD AND NOT BUILD_WITH_HIDAPI) if(NOT BUILD_WITH_OPENHMD AND NOT BUILD_WITH_HIDAPI)
message(FATAL_ERROR "You must enable at least one driver: either provide OpenHMD and enable BUILD_WITH_OPENHMD (for a variety of devices via OpenHMD), or provide HIDAPI and enable BUILD_WITH_HIDAPI (for the HDK driver)") message(FATAL_ERROR "You must enable at least one driver: either provide OpenHMD and enable BUILD_WITH_OPENHMD (for a variety of devices via OpenHMD), or provide HIDAPI and enable BUILD_WITH_HIDAPI (for the HDK driver)")
...@@ -58,4 +60,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter") ...@@ -58,4 +60,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter")
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(doc) add_subdirectory(doc)
add_subdirectory(tests) if(BUILD_TESTING)
include(CTest)
add_subdirectory(tests)
endif()
# Copyright 2018-2019, Collabora, Ltd.
find_package(Libcheck REQUIRED) # SPDX-License-Identifier: BSL-1.0
add_executable(tests add_executable(tests
tests_common.c tests_common.c
...@@ -7,15 +7,15 @@ add_executable(tests ...@@ -7,15 +7,15 @@ add_executable(tests
tests_unit.c tests_unit.c
tests_system.c) tests_system.c)
target_include_directories(tests PRIVATE "${CMAKE_SOURCE_DIR}/src") target_include_directories(tests PRIVATE
target_include_directories(tests PRIVATE "${CMAKE_SOURCE_DIR}/src/external") "${PROJECT_SOURCE_DIR}/src"
target_include_directories(tests PRIVATE "${CMAKE_SOURCE_DIR}/src/xrt/include") "${PROJECT_SOURCE_DIR}/src/external"
target_include_directories(tests PRIVATE "${CMAKE_SOURCE_DIR}/src/xrt/state_trackers") "${PROJECT_SOURCE_DIR}/src/xrt/include"
target_include_directories(tests PRIVATE "${CMAKE_SOURCE_DIR}/src/xrt/auxiliary") "${PROJECT_SOURCE_DIR}/src/xrt/state_trackers"
"${PROJECT_SOURCE_DIR}/src/xrt/auxiliary"
find_package(glfw3 3.2 REQUIRED) )
find_package(OpenGL REQUIRED)
target_include_directories(tests PRIVATE ${OPENGL_INCLUDE_DIR})
target_link_libraries(tests ${RUNTIME_TARGET} libcheck::check ${OPENGL_gl_LIBRARY} glfw X11) target_link_libraries(tests ${RUNTIME_TARGET} libcheck::check OpenGL::GL glfw X11)
# TODO: adjust the runner so we can individually run test cases here.
add_test(NAME monado_tests COMMAND tests)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment