Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
222 lines (201 loc) · 7.06 KB
/
Copy pathCMakeLists.txt
File metadata and controls
222 lines (201 loc) · 7.06 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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# LGProtocol - Looking Glass Communication Protocol
# Copyright © 2017-2026 Geoffrey McRae <geoff@hostfission.com>
# https://github.com/gnif/LGProtocol
# SPDX-License-Identifier: GPL-2.0-or-later
#
# 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 2 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, write to the Free Software Foundation, Inc., 59
# Temple Place, Suite 330, Boston, MA 02111-1307 USA
cmake_minimum_required(VERSION 3.16)
project(LGProtocol VERSION 1.4.0 LANGUAGES C CXX)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
add_library(LGProtocol INTERFACE)
add_library(LGProtocol::LGProtocol ALIAS LGProtocol)
add_library(LGProtocolNetwork STATIC
src/network/auth.c
src/network/crc32c.c
src/network/packet.c
src/network/protocol.c
src/network/reassembly.c
src/network/route.c
src/network/sequence.c
src/network/services.c
src/network/stream.c
src/network/wire.c
)
add_library(LGProtocol::Network ALIAS LGProtocolNetwork)
target_compile_features(LGProtocol INTERFACE c_std_11 cxx_std_11)
target_include_directories(LGProtocol INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_compile_features(LGProtocolNetwork PUBLIC c_std_11)
target_link_libraries(LGProtocolNetwork PUBLIC LGProtocol::LGProtocol)
set_target_properties(LGProtocolNetwork PROPERTIES
EXPORT_NAME Network
OUTPUT_NAME LGProtocolNetwork
POSITION_INDEPENDENT_CODE ON
)
if(MSVC OR CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
target_compile_options(LGProtocolNetwork PRIVATE /W4 /WX)
elseif(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(LGProtocolNetwork PRIVATE
-Wall
-Wextra
-Werror
)
endif()
install(TARGETS
LGProtocol
LGProtocolNetwork
EXPORT LGProtocolTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(FILES
include/LGProtocol/KVMFR.h
include/LGProtocol/KVMFRAudio.h
include/LGProtocol/KVMFRClipboard.h
include/LGProtocol/KVMFRInput.h
include/LGProtocol/KVMFRRecovery.h
include/LGProtocol/KVMFRStream.h
include/LGProtocol/KVMFRTypes.h
include/LGProtocol/LGMPConfig.h
include/LGProtocol/NetworkAuth.h
include/LGProtocol/NetworkClipboard.h
include/LGProtocol/NetworkCRC32C.h
include/LGProtocol/NetworkIdentity.h
include/LGProtocol/NetworkPacket.h
include/LGProtocol/NetworkProtocol.h
include/LGProtocol/NetworkReassembly.h
include/LGProtocol/NetworkRoute.h
include/LGProtocol/NetworkSequence.h
include/LGProtocol/NetworkServices.h
include/LGProtocol/NetworkStream.h
include/LGProtocol/NetworkWire.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/LGProtocol
)
install(EXPORT LGProtocolTargets
FILE LGProtocolTargets.cmake
NAMESPACE LGProtocol::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LGProtocol
)
configure_package_config_file(
cmake/LGProtocolConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/LGProtocolConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LGProtocol
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/LGProtocolConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/LGProtocolConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/LGProtocolConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LGProtocol
)
include(CTest)
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
set(LGPROTOCOL_BUILD_TESTS_DEFAULT ${BUILD_TESTING})
else()
set(LGPROTOCOL_BUILD_TESTS_DEFAULT OFF)
endif()
option(LGPROTOCOL_BUILD_TESTS
"Build LGProtocol validation tests"
${LGPROTOCOL_BUILD_TESTS_DEFAULT}
)
unset(LGPROTOCOL_BUILD_TESTS_DEFAULT)
if(BUILD_TESTING AND LGPROTOCOL_BUILD_TESTS)
function(lgprotocol_enable_test_warnings target)
if(MSVC)
target_compile_options(${target} PRIVATE /W4 /WX)
elseif(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang" OR
CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(${target} PRIVATE -Wall -Wextra -Werror)
endif()
endfunction()
set(LGPROTOCOL_COMMON_HEADERS
KVMFR
KVMFRAudio
KVMFRClipboard
KVMFRInput
KVMFRRecovery
KVMFRStream
LGMPConfig
KVMFRTypes
NetworkWire
NetworkProtocol
NetworkServices
NetworkIdentity
)
set(header_id 0)
foreach(header IN LISTS LGPROTOCOL_COMMON_HEADERS)
math(EXPR header_id "${header_id} + 1")
set(c_target lgprotocol_header_c_${header})
add_executable(${c_target} tests/headers_c.c)
target_compile_definitions(${c_target} PRIVATE
LGPROTOCOL_HEADER_ID=${header_id}
)
target_link_libraries(${c_target} PRIVATE LGProtocol::LGProtocol)
set_target_properties(${c_target} PROPERTIES
C_STANDARD 11
C_STANDARD_REQUIRED YES
C_EXTENSIONS NO
)
lgprotocol_enable_test_warnings(${c_target})
add_test(NAME header_c_${header} COMMAND ${c_target})
set(cxx_target lgprotocol_header_cxx_${header})
add_executable(${cxx_target} tests/headers_cxx.cpp)
target_compile_definitions(${cxx_target} PRIVATE
LGPROTOCOL_HEADER_ID=${header_id}
)
target_link_libraries(${cxx_target} PRIVATE LGProtocol::LGProtocol)
set_target_properties(${cxx_target} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS YES
)
lgprotocol_enable_test_warnings(${cxx_target})
add_test(NAME header_cxx_${header} COMMAND ${cxx_target})
endforeach()
add_executable(lgprotocol_abi_c tests/abi_common.c)
target_link_libraries(lgprotocol_abi_c PRIVATE LGProtocol::LGProtocol)
set_target_properties(lgprotocol_abi_c PROPERTIES
C_STANDARD 11
C_STANDARD_REQUIRED YES
C_EXTENSIONS NO
)
lgprotocol_enable_test_warnings(lgprotocol_abi_c)
add_test(NAME abi_common_c COMMAND lgprotocol_abi_c)
add_executable(lgprotocol_abi_cxx tests/abi_common.cpp)
target_link_libraries(lgprotocol_abi_cxx PRIVATE LGProtocol::LGProtocol)
set_target_properties(lgprotocol_abi_cxx PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS YES
)
lgprotocol_enable_test_warnings(lgprotocol_abi_cxx)
add_test(NAME abi_common_cxx COMMAND lgprotocol_abi_cxx)
add_test(NAME package_consumer
COMMAND ${CMAKE_COMMAND}
-DLGPROTOCOL_BINARY_DIR=${CMAKE_BINARY_DIR}
-DLGPROTOCOL_SOURCE_DIR=${CMAKE_SOURCE_DIR}
-DLGPROTOCOL_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR}
-DLGPROTOCOL_TEST_COMPILER=${CMAKE_C_COMPILER}
-DLGPROTOCOL_TEST_CONFIG=$<CONFIG>
-P ${CMAKE_SOURCE_DIR}/tests/package-consumer/run.cmake
)
endif()