forked from knowrob/knowrob
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
executable file
·388 lines (337 loc) · 10.3 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
cmake_minimum_required(VERSION 3.5.0)
set (CMAKE_CXX_FLAGS "-Wswitch -std=c++0x -O2 -pthread ${CMAKE_CXX_FLAGS} -Wno-undef")
set (CMAKE_CXX_STANDARD 17)
project(knowrob)
IF( NOT WIN32 )
INCLUDE( FindPkgConfig )
ENDIF()
set(SOMA_VERSION "current")
# include additional CMake macros
include("cmake/ontologies.cmake")
find_package(Eigen3 REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(spdlog REQUIRED)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.50 REQUIRED COMPONENTS program_options serialization)
enable_testing()
find_package(GTest REQUIRED)
pkg_check_modules(SWIPL REQUIRED swipl)
link_directories(${SWIPL_LIBRARY_DIRS})
pkg_check_modules(RAPTOR REQUIRED raptor2)
include_directories(include ${RAPTOR_INCLUDE_DIRS})
# install additional Prolog code
# FIXME: is added by rosprolog
#install_prolog_pack(list_util
# URL "https://github.com/mndrix/list_util/archive/v0.13.0.zip")
#install_prolog_pack(delay
# URL "https://github.com/mndrix/delay/archive/v0.3.3.zip")
# install ontologies hosted on http servers.
# copy them into the workspace such the we can load them
# from a local source at runtime.
# TODO: there is a similar macros called FetchContent_* shipped with CMake.
# Have a look if install_ontology can use it or be replaced with it.
install_ontology(
URL "http://www.ease-crc.org/ont/DUL.owl"
VERSION "3.34")
install_ontology(
URL "https://ease-crc.github.io/soma/owl/${SOMA_VERSION}/SOMA.owl"
VERSION "${SOMA_VERSION}")
install_ontology(
URL "https://ease-crc.github.io/soma/owl/${SOMA_VERSION}/SOMA-HOME.owl"
VERSION "${SOMA_VERSION}")
set(CMAKE_CXX_FLAGS "-std=c++0x -pthread ${CMAKE_CXX_FLAGS}")
include_directories(include
${SWIPL_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
${Boost_INCLUDE_DIRS})
# define some constants for the compilation of source files that
# are used to load project-relative files.
# TODO: needs to be defined differently when catkin is used?
add_definitions(-DKNOWROB_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\")
add_definitions(-DKNOWROB_SOURCE_DIR=\"${CMAKE_SOURCE_DIR}\")
##############
########## ROS1 block
##############
# NOTE: seems catkin_package must be called *before* any library is build.
find_package(catkin QUIET COMPONENTS
roscpp roslib tests/urdf message_generation
geometry_msgs message_generation json_prolog_msgs actionlib actionlib_msgs)
if (catkin_FOUND)
message(STATUS "Building with ROS1 support.")
add_definitions(-DKNOWROB_SOURCE_DIR=\"${PROJECT_SOURCE_DIR}\")
include_directories(${catkin_INCLUDE_DIRS})
catkin_python_setup()
# build messages
add_action_files(
DIRECTORY action
FILES
askall.action
askone.action
askincremental.action
tell.action
)
add_message_files(
FILES
KeyValuePair.msg
GraphQueryMessage.msg
GraphAnswerMessage.msg
EventToken.msg
)
generate_messages(DEPENDENCIES
std_msgs
geometry_msgs
actionlib_msgs)
catkin_package(
INCLUDE_DIRS include
LIBRARIES knowrob-ros-cli
CATKIN_DEPENDS roscpp roslib
CFG_EXTRAS ontologies.cmake
)
else()
message(STATUS "Building without ROS1 support.")
endif()
##############
#### MONGO DB
##############
pkg_check_modules(MONGOC REQUIRED libmongoc-1.0)
# find_package(libmongoc-1.0 1.7 REQUIRED)
include_directories(${MONGOC_INCLUDE_DIRS})
link_directories(${MONGOC_LIBRARY_DIRS})
#add_library(mongo_kb SHARED
# src/mongodb/mongo_kb.cpp
# src/mongodb/bson_pl.cpp
# src/mongodb/MongoException.cpp
# src/mongodb/MongoInterface.cpp
# src/mongodb/MongoDatabase.cpp
# src/mongodb/MongoCollection.cpp
# src/mongodb/MongoCursor.cpp
# src/mongodb/MongoWatch.cpp)
#target_link_libraries(mongo_kb
# ${SWIPL_LIBRARIES}
# ${MONGOC_LIBRARIES})
##############
#### QUERY ANSWERING
##############
add_library(knowrob_qa SHARED
src/knowrob.cpp
src/ThreadPool.cpp
src/Logger.cpp
src/KnowledgeBase.cpp
src/DataSource.cpp
src/URI.cpp
src/modalities/ConfidenceValue.cpp
src/modalities/ConfidenceInterval.cpp
src/modalities/Timepoint.cpp
src/modalities/TimeInterval.cpp
src/modalities/BeliefModality.cpp
src/modalities/KnowledgeModality.cpp
src/modalities/PastModality.cpp
src/modalities/ModalOperator.cpp
src/modalities/EpistemicModality.cpp
src/modalities/TemporalModality.cpp
src/terms/Term.cpp
src/terms/Variable.cpp
src/terms/ListTerm.cpp
src/terms/OptionList.cpp
src/terms/Substitution.cpp
src/terms/Unifier.cpp
src/terms/Constant.cpp
src/formulas/Formula.cpp
src/formulas/CompoundFormula.cpp
src/formulas/Conjunction.cpp
src/formulas/Disjunction.cpp
src/formulas/Implication.cpp
src/formulas/Negation.cpp
src/formulas/Predicate.cpp
src/formulas/Bottom.cpp
src/formulas/Top.cpp
src/formulas/ModalFormula.cpp
src/formulas/Literal.cpp
src/queries/ModalQuery.cpp
src/queries/QueryError.cpp
src/queries/Answer.cpp
src/queries/AnswerStream.cpp
src/queries/AnswerQueue.cpp
src/queries/AnswerCombiner.cpp
src/queries/AnswerBroadcaster.cpp
src/queries/DependencyGraph.cpp
src/queries/QueryParser.cpp
src/queries/QueryTree.cpp
src/queries/AnswerBuffer.cpp
src/queries/GraphQuery.cpp
src/queries/Query.cpp
src/queries/RedundantAnswerFilter.cpp
src/semweb/PrefixRegistry.cpp
src/semweb/PrefixProbe.cpp
src/semweb/xsd.cpp
src/semweb/Vocabulary.cpp
src/semweb/owl.cpp
src/semweb/rdfs.cpp
src/semweb/rdf.cpp
src/semweb/Property.cpp
src/semweb/Class.cpp
src/semweb/RDFLiteral.cpp
src/semweb/ImportHierarchy.cpp
src/reasoner/DefinedPredicate.cpp
src/reasoner/ReasonerPlugin.cpp
src/reasoner/Reasoner.cpp
src/reasoner/ReasonerManager.cpp
src/reasoner/ReasonerConfiguration.cpp
src/reasoner/ReasonerAttention.cpp
src/reasoner/prolog/PrologQuery.cpp
src/reasoner/prolog/PrologQueryRunner.cpp
src/reasoner/prolog/PrologThreadPool.cpp
src/reasoner/prolog/PrologReasoner.cpp
src/reasoner/prolog/PrologTests.cpp
src/reasoner/prolog/logging.cpp
src/reasoner/prolog/algebra.cpp
src/reasoner/prolog/blackboard.cpp
src/reasoner/mongolog/MongologReasoner.cpp
src/reasoner/mongolog/mongo_kb.cpp
src/reasoner/mongolog/bson_pl.cpp
src/reasoner/swrl/SWRLReasoner.cpp
src/reasoner/esg/ESGReasoner.cpp
src/mongodb/MongoInterface.cpp
src/mongodb/Database.cpp
src/mongodb/Collection.cpp
src/mongodb/ChangeStream.cpp
src/mongodb/Cursor.cpp
src/mongodb/QueryWatch.cpp
src/mongodb/MongoKnowledgeGraph.cpp
src/mongodb/BulkOperation.cpp
src/mongodb/TripleLoader.cpp
src/mongodb/aggregation/graph.cpp
src/mongodb/Pipeline.cpp
src/mongodb/TripleCursor.cpp
src/mongodb/AnswerCursor.cpp
src/mongodb/aggregation/terms.cpp
src/mongodb/aggregation/triples.cpp
src/mongodb/Connection.cpp
src/modalities/ModalityLabel.cpp
src/semweb/KnowledgeGraph.cpp
src/semweb/KnowledgeGraphManager.cpp
src/semweb/KnowledgeGraphPlugin.cpp
src/queries/EDBStage.cpp
src/queries/QueryStage.cpp
src/queries/IDBStage.cpp
src/queries/QueryPipeline.cpp)
target_link_libraries(knowrob_qa
${SWIPL_LIBRARIES}
${MONGOC_LIBRARIES}
${RAPTOR_LIBRARIES}
spdlog::spdlog
${GTEST_LIBRARIES})
add_executable(knowrob-terminal src/terminal.cpp)
target_link_libraries(knowrob-terminal
Boost::program_options
Boost::serialization
knowrob_qa)
install(TARGETS knowrob-terminal RUNTIME DESTINATION bin)
##############
########## ROS1 block
##############
if (catkin_FOUND)
# install into ROS workspace
#add_dependencies(mongo_kb ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
add_dependencies(knowrob_qa ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
add_dependencies(knowrob-terminal ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
# ### TF messages ###
# add_library(tf_knowrob SHARED
# src/ros/tf/tf.cpp
# src/ros/tf/memory.cpp
# src/ros/tf/logger.cpp
# src/ros/tf/publisher.cpp
# src/ros/tf/republisher.cpp)
# target_link_libraries(tf_knowrob
# ${SWIPL_LIBRARIES}
# ${MONGOC_LIBRARIES}
# ${catkin_LIBRARIES})
# #mongo_kb
# add_dependencies(tf_knowrob
# ${${PROJECT_NAME}_EXPORTED_TARGETS}
# ${catkin_EXPORTED_TARGETS})
#
# ## RViz marker ###
# add_library(marker_knowrob SHARED src/ros/marker/publisher.cpp)
# target_link_libraries(marker_knowrob
# ${SWIPL_LIBRARIES} ${catkin_LIBRARIES})
# add_dependencies(marker_knowrob
# ${${PROJECT_NAME}_EXPORTED_TARGETS}
# ${catkin_EXPORTED_TARGETS})
#
# ## URDf ###
# add_library(urdf_parser SHARED src/ros/urdf/parser.cpp)
# target_link_libraries(urdf_parser ${SWIPL_LIBRARIES} ${catkin_LIBRARIES})
# add_dependencies(urdf_parser
# ${${PROJECT_NAME}_EXPORTED_TARGETS}
# ${catkin_EXPORTED_TARGETS})
## ROS Interface ###
add_executable(knowrob-ros
src/ros/ROSInterface.cpp
)
add_dependencies(knowrob-ros
${catkin_EXPORTED_TARGETS})
target_link_libraries(knowrob-ros
Boost::program_options
knowrob_qa
${catkin_LIBRARIES})
install(TARGETS knowrob-ros RUNTIME DESTINATION bin)
## ROS Client Interface
add_library(
knowrob-ros-cli
include/knowrob/ros_client/cpp/knowrob_client.hpp
src/ros_client/knowrob_client.cpp
)
add_dependencies(
knowrob-ros-cli
${catkin_EXPORTED_TARGETS}
)
target_link_libraries(
knowrob-ros-cli
${catkin_LIBRARIES}
)
install(
TARGETS knowrob-ros-cli
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
)
## Test node for the client library
add_executable(
client-node
src/ros_client/client_node.cpp
)
add_dependencies(
client-node
${catkin_EXPORTED_TARGETS}
)
target_link_libraries(
client-node
knowrob-ros-cli
${catkin_LIBRARIES}
)
endif()
##############
########## Unit Testing
##############
# add an executable target for GTest.
# but the testing code is actually in the *knowrob_qa* library
# where gtest won't find them without using the "--no-as-needed"
# flag for the linker.
add_executable(all_gtests
tests/gtests.cpp
src/neems/test.cpp)
target_link_libraries(all_gtests
-Wl,--whole-archive,--no-as-needed
knowrob_qa
-Wl,--no-whole-archive
${GTEST_MAIN_LIBRARIES})
##############
##############
# TODO: look into installation
#install(DIRECTORY owl/
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/owl)
#install(DIRECTORY prolog/
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/prolog)
install(DIRECTORY src/reasoner/prolog DESTINATION share
PATTERN ".cpp" EXCLUDE)