-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCMakeLists.txt
59 lines (48 loc) · 1.82 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Testing library
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.3.2
)
FetchContent_MakeAvailable(Catch2)
# Tests need to be added as executables first
add_executable(inputtino_tests main.cpp)
set(SRC_LIST main.cpp testCAPI.cpp)
if (UNIX AND NOT APPLE)
option(TEST_LIBINPUT "Enable libinput test" ON)
if (TEST_LIBINPUT)
find_package(PkgConfig)
pkg_check_modules(LIBINPUT REQUIRED IMPORTED_TARGET libinput)
option(SDL_CUSTOM_SRC "Use a custom SDL source location (useful to better debug)" OFF)
if (SDL_CUSTOM_SRC)
SET(SDL_TEST OFF)
SET(SDL_HIDAPI_JOYSTICK ON)
add_subdirectory(${SDL_CUSTOM_SRC} ${CMAKE_CURRENT_BINARY_DIR}/sdl EXCLUDE_FROM_ALL)
else ()
find_package(SDL2 REQUIRED CONFIG REQUIRED COMPONENTS SDL2)
endif ()
target_link_libraries(inputtino_tests PRIVATE
PkgConfig::LIBINPUT
SDL2::SDL2)
list(APPEND SRC_LIST
"testJoypads.cpp"
"testLibinput.cpp")
endif ()
endif ()
option(TEST_SERVER "Enable server test" OFF)
if (TEST_SERVER)
list(APPEND SRC_LIST "testServer.cpp")
target_link_libraries(inputtino_tests PRIVATE inputtino::server)
endif ()
target_sources(inputtino_tests PRIVATE ${SRC_LIST})
# I'm using C++17 in the test
target_compile_features(inputtino_tests PRIVATE cxx_std_17)
# Should be linked to the main library, as well as the Catch2 testing library
target_link_libraries(inputtino_tests PRIVATE
inputtino::libinputtino
Catch2::Catch2WithMain)
# See: https://github.com/catchorg/Catch2/blob/devel/docs/cmake-integration.md
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
include(CTest)
include(Catch)
catch_discover_tests(inputtino_tests)