forked from houmain/keymapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
128 lines (114 loc) · 3.39 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
118
119
120
121
122
123
124
125
126
127
128
cmake_minimum_required(VERSION 3.12.0)
project(keymapper LANGUAGES CXX)
set(GIT_COMMIT_LAST_TAG "unknown")
find_package(Git)
if(GIT_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_LAST_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
configure_file("src/version.h.in" "${CMAKE_SOURCE_DIR}/src/_version.h")
set(CMAKE_CXX_STANDARD 17)
include_directories(src)
set(SOURCES_CONFIG
src/config/Config.h
src/config/ParseConfig.cpp
src/config/ParseConfig.h
src/config/ParseKeySequence.cpp
src/config/ParseKeySequence.h
src/config/Key.cpp
src/config/Key.h
src/config/string_iteration.h
)
set(SOURCES_RUNTIME
src/runtime/KeyEvent.h
src/runtime/MatchKeySequence.cpp
src/runtime/MatchKeySequence.h
src/runtime/Stage.cpp
src/runtime/Stage.h
)
if(NOT WIN32)
add_executable(keymapper
${SOURCES_CONFIG}
src/linux/client/ConfigFile.cpp
src/linux/client/ConfigFile.h
src/linux/client/FocusedWindow.cpp
src/linux/client/FocusedWindow.h
src/linux/client/Settings.cpp
src/linux/client/Settings.h
src/linux/client/ServerPort.cpp
src/linux/client/ServerPort.h
src/linux/client/main.cpp
src/linux/common.cpp
src/linux/common.h
)
option(ENABLE_X11 "Enable X11 context awareness" TRUE)
if(ENABLE_X11)
add_compile_definitions(ENABLE_X11)
target_link_libraries(keymapper X11)
endif()
add_executable(keymapperd
${SOURCES_RUNTIME}
src/linux/server/ClientPort.cpp
src/linux/server/ClientPort.h
src/linux/server/GrabbedKeyboards.cpp
src/linux/server/GrabbedKeyboards.h
src/linux/server/main.cpp
src/linux/server/uinput_keyboard.cpp
src/linux/server/uinput_keyboard.h
src/linux/server/Settings.cpp
src/linux/server/Settings.h
src/linux/common.cpp
src/linux/common.h
)
target_link_libraries(keymapperd usb-1.0 udev)
else() # WIN32
option(ENABLE_INTERCEPTION "Enable Interception" TRUE)
if(ENABLE_INTERCEPTION)
add_compile_definitions(ENABLE_INTERCEPTION)
endif(ENABLE_INTERCEPTION)
string(REPLACE "." "," GIT_COMMIT_FILEVERSION "${GIT_COMMIT_LAST_TAG}")
string(REGEX REPLACE "-.*" "" GIT_COMMIT_FILEVERSION "${GIT_COMMIT_FILEVERSION}")
configure_file("src/win32/resource.rc.in" "${CMAKE_SOURCE_DIR}/src/win32/_resource.rc")
add_executable(keymapper WIN32
${SOURCES_CONFIG}
${SOURCES_RUNTIME}
src/win32/_resource.rc
src/win32/ConfigFile.cpp
src/win32/ConfigFile.h
src/win32/FocusedWindow.cpp
src/win32/FocusedWindow.h
src/win32/LimitSingleInstance.h
src/win32/Settings.cpp
src/win32/Settings.h
src/win32/common.h
src/win32/interception.h
src/win32/main.cpp
src/win32/run_hook.cpp
src/win32/run_interception.cpp
src/win32/win.h
)
target_link_libraries(keymapper wtsapi32.lib)
endif()
option(ENABLE_TEST "Enable tests")
if(ENABLE_TEST)
add_executable(test-keymapper
${SOURCES_CONFIG}
${SOURCES_RUNTIME}
src/test/catch.hpp
src/test/test.cpp
src/test/test.h
src/test/test0_ParseKeySequence.cpp
src/test/test1_ParseConfig.cpp
src/test/test2_MatchKeySequence.cpp
src/test/test3_Stage.cpp
src/test/test4_Fuzz.cpp
)
endif()
if(NOT WIN32)
install(TARGETS keymapper DESTINATION "bin")
install(TARGETS keymapperd DESTINATION "bin")
else()
install(TARGETS keymapper DESTINATION .)
endif()