forked from OpenJVS/OpenJVS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
198 lines (166 loc) · 5.91 KB
/
Copy pathCMakeLists.txt
File metadata and controls
198 lines (166 loc) · 5.91 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
cmake_minimum_required(VERSION 3.10)
project(modernjvs
VERSION "5.18.21"
LANGUAGES "C"
DESCRIPTION "JVS I/O Emulator"
HOMEPAGE_URL "https://github.com/dazzaXx/ModernJVS"
)
find_package(Threads REQUIRED)
# libgpiod is required for GPIO character-device API
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBGPIOD REQUIRED libgpiod)
configure_file(src/version.h.in version.h)
# Source files - explicitly listed for better dependency tracking
set(SOURCES
src/modernjvs.c
src/console/cli.c
src/console/config.c
src/console/debug.c
src/console/watchdog.c
src/controller/input.c
src/controller/threading.c
src/ffb/ffb.c
src/hardware/device.c
src/jvs/io.c
src/jvs/jvs.c
)
add_executable(${PROJECT_NAME} ${SOURCES})
set_target_properties(${PROJECT_NAME} PROPERTIES
C_STANDARD 99
)
# Include directories
target_include_directories(${PROJECT_NAME} PRIVATE
${PROJECT_SOURCE_DIR}/src
${PROJECT_BINARY_DIR}
${LIBGPIOD_INCLUDE_DIRS}
)
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic)
# Link libraries
target_link_libraries(${PROJECT_NAME} PRIVATE
Threads::Threads
m
${LIBGPIOD_LIBRARIES}
)
# Detect libgpiod major version to handle API differences
string(REGEX MATCH "^([0-9]+)" LIBGPIOD_VERSION_MAJOR "${LIBGPIOD_VERSION}")
message(STATUS "Found libgpiod version: ${LIBGPIOD_VERSION} (major: ${LIBGPIOD_VERSION_MAJOR})")
if(LIBGPIOD_VERSION_MAJOR GREATER_EQUAL 2)
target_compile_definitions(${PROJECT_NAME} PRIVATE GPIOD_API_V2)
message(STATUS "Using libgpiod v2 API")
else()
message(STATUS "Using libgpiod v1 API")
endif()
# Installation rules
install(TARGETS ${PROJECT_NAME}
COMPONENT ${PROJECT_NAME}
RUNTIME DESTINATION "bin/"
LIBRARY DESTINATION "lib/"
)
install(FILES
${CMAKE_SOURCE_DIR}/docs/modernjvs.service
${CMAKE_SOURCE_DIR}/docs/modernjvs@.service
COMPONENT ${PROJECT_NAME}
DESTINATION "/etc/systemd/system/"
)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/docs/modernjvs
COMPONENT ${PROJECT_NAME}
DESTINATION "/etc/"
)
install(FILES
${CMAKE_SOURCE_DIR}/docs/wiimote.conf
COMPONENT ${PROJECT_NAME}
DESTINATION "/etc/modules-load.d/"
)
# WebUI – Python3 local-network web interface (opt-out with -DENABLE_WEBUI=OFF)
option(ENABLE_WEBUI "Include the WebUI server in the installation" ON)
if(ENABLE_WEBUI)
message(STATUS "WebUI: enabled (use -DENABLE_WEBUI=OFF to exclude)")
install(PROGRAMS
${CMAKE_SOURCE_DIR}/src/webui/modernjvs-webui.py
RENAME modernjvs-webui
COMPONENT ${PROJECT_NAME}
DESTINATION "bin/"
)
install(FILES
${CMAKE_SOURCE_DIR}/docs/modernjvs-webui.service
COMPONENT ${PROJECT_NAME}
DESTINATION "/etc/systemd/system/"
)
install(FILES
${CMAKE_SOURCE_DIR}/docs/modernjvs2.png
${CMAKE_SOURCE_DIR}/docs/Sticks4.png
COMPONENT ${PROJECT_NAME}
DESTINATION "/usr/share/modernjvs/"
)
install(FILES
${CMAKE_SOURCE_DIR}/src/webui/static/style.css
${CMAKE_SOURCE_DIR}/src/webui/static/app.js
${CMAKE_SOURCE_DIR}/src/webui/static/login.css
${CMAKE_SOURCE_DIR}/src/webui/static/login.js
COMPONENT ${PROJECT_NAME}
DESTINATION "/usr/share/modernjvs/webui/static/"
)
install(DIRECTORY
${CMAKE_SOURCE_DIR}/src/webui/static/fonts/
COMPONENT ${PROJECT_NAME}
DESTINATION "/usr/share/modernjvs/webui/static/fonts/"
)
install(FILES
${CMAKE_SOURCE_DIR}/src/webui/templates/index.html
${CMAKE_SOURCE_DIR}/src/webui/templates/login.html
COMPONENT ${PROJECT_NAME}
DESTINATION "/usr/share/modernjvs/webui/templates/"
)
else()
message(STATUS "WebUI: disabled")
endif()
# CPack configuration for DEB package generation
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "dazzaXx")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
# Include the postrm maintainer script so dpkg can clean up runtime files
# (webui-settings.json, webui-bg, webui-bg.mime) that are created after
# installation and are therefore not tracked by dpkg.
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
"${CMAKE_SOURCE_DIR}/debian/postrm"
)
include(CPack)
# ──────────────────────────────────────────────────────────────────────────────
# Test target (built separately; does not require real hardware)
# Sources exclude modernjvs.c (main) so the test runner provides its own main.
# ──────────────────────────────────────────────────────────────────────────────
option(BUILD_TESTS "Build the ModernJVS test suite" OFF)
if(BUILD_TESTS)
set(TEST_SOURCES
tests/test_modernjvs.c
src/console/cli.c
src/console/config.c
src/console/debug.c
src/console/watchdog.c
src/controller/input.c
src/controller/threading.c
src/ffb/ffb.c
src/hardware/device.c
src/jvs/io.c
src/jvs/jvs.c
)
add_executable(test_modernjvs ${TEST_SOURCES})
set_target_properties(test_modernjvs PROPERTIES C_STANDARD 99)
target_include_directories(test_modernjvs PRIVATE
${PROJECT_SOURCE_DIR}/src
${PROJECT_BINARY_DIR}
${LIBGPIOD_INCLUDE_DIRS}
)
target_compile_options(test_modernjvs PRIVATE -Wall -Wextra -Wpedantic)
# Inherit the same gpiod version flag as the main binary
if(LIBGPIOD_VERSION_MAJOR GREATER_EQUAL 2)
target_compile_definitions(test_modernjvs PRIVATE GPIOD_API_V2)
endif()
target_link_libraries(test_modernjvs PRIVATE
Threads::Threads
m
${LIBGPIOD_LIBRARIES}
)
enable_testing()
add_test(NAME modernjvs_suite COMMAND test_modernjvs)
endif()