-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
202 lines (152 loc) · 6.09 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
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
cmake_minimum_required(VERSION 3.5)
# Project
project(DCPLib VERSION 0.1)
# use c++11 features, requires cmake > 3.1
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
option(BUILD_ALL "Build all parts of the DCPLib" ON)
option(BUILD_ETHERNET "Build neccessary parts to use UDP driver." OFF)
option(BUILD_BLUETOOTH "Build neccessary parts to use the Bluetooth RFCOMM driver." OFF)
option(BUILD_SLAVE "Build neccessary parts to implement an DCP slave." OFF)
option(BUILD_MASTER "Build neccessary parts to implement an DCP master." OFF)
option(BUILD_XML "Build neccessary parts for handling slave description XML files" OFF)
option(BUILD_ZIP "Build neccessary parts for handling slave zip files" OFF)
add_definitions(-DDEBUG)
##dcplib core
add_library(Core INTERFACE)
add_library(DCPLib::Core ALIAS Core)
target_include_directories(Core INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/core>
$<INSTALL_INTERFACE:include/DCPLib/core>
)
install(TARGETS Core
EXPORT DCPLib-targets
COMPONENT Core
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/core DESTINATION include/DCPLib)
if(BUILD_ALL OR BUILD_ETHERNET)
find_package(Threads REQUIRED)
find_package(ASIO REQUIRED )
##dcplib ethernet
add_library(Ethernet INTERFACE)
add_library(DCPLib::Ethernet ALIAS Ethernet)
target_link_libraries(Ethernet INTERFACE Threads::Threads ASIO::ASIO)
target_link_libraries(Ethernet INTERFACE DCPLib::Core)
if(WIN32)
target_link_libraries(Ethernet INTERFACE wsock32 ws2_32)
endif()
target_include_directories(Ethernet INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/ethernet>
$<INSTALL_INTERFACE:include/DCPLib/ethernet>
)
install(TARGETS Ethernet
EXPORT DCPLib-targets
COMPONENT Ethernet
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ethernet DESTINATION include/DCPLib)
endif(BUILD_ALL OR BUILD_ETHERNET)
if(BUILD_ALL OR BUILD_BLUETOOTH)
##dcplib bluetooth
add_library(Bluetooth INTERFACE)
add_library(DCPLib::Bluetooth ALIAS Bluetooth)
target_link_libraries(Bluetooth INTERFACE DCPLib::Core)
target_include_directories(Bluetooth INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/bluetooth>
$<INSTALL_INTERFACE:include/DCPLib/bluetooth>
)
install(TARGETS Bluetooth
EXPORT DCPLib-targets
COMPONENT Bluetooth
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/bluetooth DESTINATION include/DCPLib)
endif(BUILD_ALL OR BUILD_BLUETOOTH)
if(BUILD_ALL OR BUILD_MASTER)
##dcplib master
add_library(Master INTERFACE)
add_library(DCPLib::Master ALIAS Master)
target_link_libraries(Master INTERFACE DCPLib::Core)
if(WIN32)
target_link_libraries(Master INTERFACE wsock32 ws2_32)
endif()
target_include_directories(Master INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/master>
$<INSTALL_INTERFACE:include/DCPLib/master>
)
install(TARGETS Master
EXPORT DCPLib-targets
COMPONENT Master
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/master DESTINATION include/DCPLib)
endif(BUILD_ALL OR BUILD_MASTER)
if(BUILD_ALL OR BUILD_SLAVE)
##dcplib slave
add_library(Slave INTERFACE)
add_library(DCPLib::Slave ALIAS Slave)
target_link_libraries(Slave INTERFACE DCPLib::Core)
if(WIN32)
target_link_libraries(Slave INTERFACE wsock32 ws2_32)
endif()
target_include_directories(Slave INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/slave>
$<INSTALL_INTERFACE:include/DCPLib/slave>
)
install(TARGETS Slave
EXPORT DCPLib-targets
COMPONENT Slave
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/slave DESTINATION include/DCPLib)
endif(BUILD_ALL OR BUILD_SLAVE)
if(BUILD_ALL OR BUILD_XML)
find_package(XercesC REQUIRED)
add_library(Xml INTERFACE)
add_library(DCPLib::Xml ALIAS Xml)
target_link_libraries(Xml INTERFACE DCPLib::Core)
target_link_libraries(Xml INTERFACE XercesC::XercesC)
target_include_directories(Xml INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/xml>
$<INSTALL_INTERFACE:include/DCPLib/xml>
)
install(TARGETS Xml
EXPORT DCPLib-targets
COMPONENT Xml
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/xml DESTINATION include/DCPLib)
endif(BUILD_ALL OR BUILD_XML)
if(BUILD_ALL OR BUILD_ZIP)
find_package(Zip REQUIRED)
add_library(Zip INTERFACE)
add_library(DCPLib::Zip ALIAS Zip)
target_link_libraries(Zip INTERFACE DCPLib::Xml ZIP::ZIP)
target_include_directories(Zip INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/zip>
$<INSTALL_INTERFACE:include/DCPLib/zip>
)
install(TARGETS Zip
EXPORT DCPLib-targets
COMPONENT Zip
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/zip DESTINATION include/DCPLib)
endif(BUILD_ALL OR BUILD_ZIP)
install(EXPORT DCPLib-targets
FILE
DCPLibConfig.cmake
NAMESPACE
DCPLib::
DESTINATION
lib/DCPLib)
add_executable(mytest src/test/BasicChecks.cpp)
target_link_libraries(mytest DCPLib::Ethernet DCPLib::Bluetooth DCPLib::Master DCPLib::Slave DCPLib::Xml DCPLib::Zip)