forked from Grumbel/sdl-jstest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
117 lines (90 loc) · 3.58 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# sdl-jstest - Joystick Test Program for SDL
# Copyright (C) 2015 Ingo Ruhnke <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.5)
project(sdl-jstest)
set(TINYCMMC_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/external/tinycmmc/modules/")
find_package(tinycmmc CONFIG)
message(STATUS "tinycmmc module path: ${TINYCMMC_MODULE_PATH}")
list(APPEND CMAKE_MODULE_PATH ${TINYCMMC_MODULE_PATH})
option(WARNINGS "Switch on extra warnings" OFF)
option(WERROR "Turn warnings into errors" OFF)
option(BUILD_TESTS "Build test cases" OFF)
option(BUILD_NETWORK_TESTS "Build test cases using the network" OFF)
option(BUILD_SDL_JSTEST "Build sdl-jstest" ON)
option(BUILD_SDL2_JSTEST "Build sdl2-jstest" ON)
include(GetProjectVersion)
include(GNUInstallDirs)
add_definitions(-DSDL_JSTEST_VERSION="${PROJECT_VERSION}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
find_package(PkgConfig REQUIRED)
pkg_search_module(NCURSES REQUIRED ncursesw ncurses IMPORTED_TARGET)
if(WARNINGS)
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} -pedantic -Wall -Wextra -Wshadow -Wcast-qual -Wconversion -Wmissing-prototypes -Wno-unused-parameter")
endif()
if(WERROR)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
endif()
if(BUILD_TESTS)
# add 'make test' target, use 'make test ARGS="-V"' or 'ctest -V' for verbose
enable_testing()
endif(BUILD_TESTS)
if(NOT BUILD_NETWORK_TESTS)
set(APPSTREAM_UTIL_FLAGS --nonet)
endif()
if(BUILD_SDL_JSTEST)
find_package(SDL REQUIRED)
add_executable(sdl-jstest src/sdl-jstest.c)
target_link_libraries(sdl-jstest
SDL::SDL
PkgConfig::NCURSES
)
file(COPY sdl-jstest.1
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/sdl-jstest.1
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
install(TARGETS sdl-jstest
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES
sdl-jstest.svg
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps)
endif()
if(BUILD_SDL2_JSTEST)
# not using find_package() as that includes some invalid include
# directories that make cmake fail
pkg_search_module(SDL2 REQUIRED sdl2 IMPORTED_TARGET)
link_directories(${SDL2_LIBRARY_DIRS})
add_executable(sdl2-jstest src/sdl2-jstest.c)
target_link_libraries(sdl2-jstest
PkgConfig::SDL2
PkgConfig::NCURSES
)
target_compile_definitions(sdl2-jstest PUBLIC SDL2_JSTEST_DATADIR=\"${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}\")
file(COPY sdl2-jstest.1
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY external/sdl_gamecontrollerdb/gamecontrollerdb.txt
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gamecontrollerdb.txt
DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/sdl2-jstest.1
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
install(TARGETS sdl2-jstest
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES
sdl2-jstest.svg
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps)
endif()
# EOF #