-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
170 lines (142 loc) · 4.81 KB
/
CMakeLists.txt
File metadata and controls
170 lines (142 loc) · 4.81 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
cmake_minimum_required(VERSION 3.20)
project(OpenLock
VERSION 0.1.0
DESCRIPTION "Open-source Linux lockdown exam browser"
LANGUAGES CXX
)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
# Build options
option(OPENLOCK_BUILD_TESTS "Build unit tests" ON)
option(OPENLOCK_ENABLE_WAYLAND "Enable Wayland/Cage kiosk support" ON)
option(OPENLOCK_ENABLE_VM_DETECTION "Enable VM detection (can be disabled for dev)" ON)
# Find Qt6
find_package(Qt6 REQUIRED COMPONENTS
Core
Gui
Widgets
WebEngineWidgets
WebEngineCore
Network
)
# Find system libraries
find_package(PkgConfig REQUIRED)
find_package(OpenSSL REQUIRED)
pkg_check_modules(X11 IMPORTED_TARGET x11)
pkg_check_modules(XRANDR IMPORTED_TARGET xrandr)
pkg_check_modules(XCB IMPORTED_TARGET xcb xcb-keysyms xcb-xfixes xcb-randr)
pkg_check_modules(XKBCOMMON IMPORTED_TARGET xkbcommon)
# Core library (shared between main app and tests)
add_library(openlock_core STATIC
# Core
src/core/LockdownEngine.cpp
src/core/Config.cpp
# Kiosk
src/kiosk/PlatformKiosk.cpp
src/kiosk/KioskShell.cpp
src/kiosk/X11Kiosk.cpp
src/kiosk/WaylandKiosk.cpp
# Guard
src/guard/ProcessGuard.cpp
src/guard/ProcessBlocklist.cpp
src/guard/CGroupIsolator.cpp
# Input
src/input/InputLockdown.cpp
src/input/ClipboardGuard.cpp
src/input/ShortcutBlocker.cpp
src/input/PrintBlocker.cpp
# Integrity
src/integrity/SystemIntegrity.cpp
src/integrity/VMDetector.cpp
src/integrity/DebugDetector.cpp
src/integrity/SelfVerifier.cpp
# Browser
src/browser/SecureBrowser.cpp
src/browser/NavigationFilter.cpp
src/browser/DownloadBlocker.cpp
src/browser/DevToolsBlocker.cpp
# Protocol
src/protocol/SEBProtocol.cpp
src/protocol/SEBConfigParser.cpp
src/protocol/BrowserExamKey.cpp
src/protocol/ConfigKeyGenerator.cpp
src/protocol/SEBRequestInterceptor.cpp
# LMS
src/lms/MoodleAdapter.cpp
src/lms/CanvasAdapter.cpp
src/lms/BlackboardAdapter.cpp
)
target_include_directories(openlock_core PUBLIC
${CMAKE_SOURCE_DIR}/src
)
target_link_libraries(openlock_core PUBLIC
Qt6::Core
Qt6::Gui
Qt6::Widgets
Qt6::WebEngineWidgets
Qt6::WebEngineCore
Qt6::Network
OpenSSL::SSL
OpenSSL::Crypto
)
if(X11_FOUND)
target_link_libraries(openlock_core PUBLIC PkgConfig::X11)
target_compile_definitions(openlock_core PUBLIC OPENLOCK_HAS_X11)
endif()
if(XRANDR_FOUND)
target_link_libraries(openlock_core PUBLIC PkgConfig::XRANDR)
endif()
if(XCB_FOUND)
target_link_libraries(openlock_core PUBLIC PkgConfig::XCB)
target_compile_definitions(openlock_core PUBLIC OPENLOCK_HAS_XCB)
endif()
if(XKBCOMMON_FOUND)
target_link_libraries(openlock_core PUBLIC PkgConfig::XKBCOMMON)
endif()
if(OPENLOCK_ENABLE_VM_DETECTION)
target_compile_definitions(openlock_core PUBLIC OPENLOCK_VM_DETECTION)
endif()
if(OPENLOCK_ENABLE_WAYLAND)
target_compile_definitions(openlock_core PUBLIC OPENLOCK_WAYLAND)
endif()
# Main executable
add_executable(openlock src/main.cpp)
target_link_libraries(openlock PRIVATE openlock_core)
# Copy data files to build directory for development runs
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/share/openlock)
configure_file(config/blocklist.json ${CMAKE_BINARY_DIR}/share/openlock/blocklist.json COPYONLY)
configure_file(config/default.openlock ${CMAKE_BINARY_DIR}/share/openlock/default.openlock COPYONLY)
# Install
install(TARGETS openlock RUNTIME DESTINATION bin)
install(FILES config/default.openlock DESTINATION share/openlock)
install(FILES config/blocklist.json DESTINATION share/openlock)
# Tests
if(OPENLOCK_BUILD_TESTS)
enable_testing()
find_package(GTest)
if(GTest_FOUND)
function(openlock_add_test TEST_NAME TEST_SOURCE)
add_executable(${TEST_NAME} ${TEST_SOURCE})
target_link_libraries(${TEST_NAME} PRIVATE openlock_core GTest::gtest GTest::gtest_main)
add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME})
endfunction()
openlock_add_test(test_process_guard tests/unit/test_process_guard.cpp)
openlock_add_test(test_vm_detector tests/unit/test_vm_detector.cpp)
openlock_add_test(test_seb_config tests/unit/test_seb_config.cpp)
openlock_add_test(test_navigation_filter tests/unit/test_navigation_filter.cpp)
else()
message(WARNING "GTest not found, tests will not be built")
endif()
endif()
# CPack for packaging
set(CPACK_PACKAGE_NAME "openlock")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Open-source Linux lockdown exam browser")
set(CPACK_PACKAGE_CONTACT "OpenLock Contributors")
set(CPACK_PACKAGE_LICENSE "MPL-2.0")
set(CPACK_GENERATOR "DEB;RPM")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "qt6-webengine (>= 6.2)")
include(CPack)