CMakeLists.txt 6.23 KB
Newer Older
1
CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
2

3
# Setup project properties
Guilhem Saurel's avatar
Guilhem Saurel committed
4
SET(PROJECT_ORG stack-of-tasks)
5
6
SET(PROJECT_NAME dynamic-graph)
SET(PROJECT_DESCRIPTION "Dynamic graph library")
Guilhem Saurel's avatar
Guilhem Saurel committed
7
SET(PROJECT_URL "http://github.com/${PROJECT_ORG}/${PROJECT_NAME}")
8
SET(PROJECT_SUFFIX "-v3")
9

Olivier Stasse's avatar
Olivier Stasse committed
10
11
# Export CMake Target
SET(PROJECT_USE_CMAKE_EXPORT TRUE)
Olivier Stasse's avatar
Olivier Stasse committed
12

Olivier Stasse's avatar
Olivier Stasse committed
13
14
15
# Make sure that every header is generated in dynamic-graph
SET(CUSTOM_HEADER_DIR ${PROJECT_NAME})

Olivier Stasse's avatar
Olivier Stasse committed
16
17
18
# Do not fail on warning
SET(CXX_DISABLE_WERROR TRUE)

19
20
INCLUDE(cmake/base.cmake)

21
# Specify the project.
22
23
COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX)
PROJECT(${PROJECT_NAME} ${PROJECT_ARGS})
24
25

# jrl-cmakemodules handling of usual modules
26
INCLUDE(cmake/pthread.cmake)
27
28
INCLUDE(cmake/boost.cmake)

29
ADD_PROJECT_DEPENDENCY(Eigen3 REQUIRED PKG_CONFIG_REQUIRES eigen3)
30
31
32
SET(BOOST_COMPONENTS serialization system unit_test_framework thread)
SEARCH_FOR_BOOST()

33
# Allows math in mathjax.
Guilhem Saurel's avatar
Guilhem Saurel committed
34
35
SET(DOXYGEN_USE_MATHJAX YES)

36
# Defines paths.
37
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
38

39
40
41
42
43
44
45
# Add configuration headers for plug-ins.
GENERATE_CONFIGURATION_HEADER(
  ${HEADER_DIR} config-tracer.hh DG_TRACER tracer_EXPORTS)
GENERATE_CONFIGURATION_HEADER(
  ${HEADER_DIR}
  config-tracer-real-time.hh DG_TRACERREALTIME tracer_real_time_EXPORTS)

Olivier Stasse's avatar
Olivier Stasse committed
46
47
48
49
set(PACKAGE_EXTRA_MACROS
  "set (DYNAMIC_GRAPH_PLUGINDIR \${CMAKE_CURRENT_LIST_DIR}/../../plugin)")

# Specific to PKG module
50
# FIXME: to be changed into lib/dynamic-graph
51
# to avoid name collision when installing dynamic-graph in /usr.
52
SET(PLUGINDIR "${CMAKE_INSTALL_FULL_LIBDIR}/plugin")
53

54
55
# Add extra keys to pkg-config file to export the location of the
# plug-in directory in a robust manner.
56
SET(PKG_CONFIG_EXTRA "plugindir=${PLUGINDIR}")
57

58
# Add dependency toward dynamic graph library in pkg-config file.
Guilhem Saurel's avatar
Guilhem Saurel committed
59
PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME})
60

61
# Search for Boost.
62
SEARCH_FOR_PTHREAD()
63

Olivier Stasse's avatar
Olivier Stasse committed
64
65
66
67
68
69
70
71
72

####################################
### Main Library
####################################
# Verbosity level
IF (NOT (\"${CMAKE_VERBOSITY_LEVEL}\" STREQUAL \"\"))
  ADD_DEFINITIONS(-DVP_DEBUG_MODE=${CMAKE_VERBOSITY_LEVEL} -DVP_DEBUG)
ENDIF (NOT (\"${CMAKE_VERBOSITY_LEVEL}\" STREQUAL \"\"))

73
SET(${PROJECT_NAME}_SOURCES
Olivier Stasse's avatar
Olivier Stasse committed
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
  src/debug/debug.cpp
  src/debug/real-time-logger.cpp
  src/debug/logger.cpp

  src/dgraph/entity.cpp
  src/dgraph/factory.cpp
  src/dgraph/pool.cpp

  src/exception/exception-abstract.cpp
  src/exception/exception-factory.cpp
  src/exception/exception-signal.cpp
  src/exception/exception-traces.cpp

  src/mt/process-list.cpp

  src/signal/signal-array.cpp
  src/signal/signal-caster.cpp
  src/signal/signal-cast-helper.cpp

  src/command/value.cpp
  src/command/command.cpp
  )

SET(${PROJECT_NAME}_HEADERS
  include/dynamic-graph/fwd.hh
  include/dynamic-graph/debug.h
  include/dynamic-graph/real-time-logger.h
101
  include/dynamic-graph/real-time-logger-def.h
Olivier Stasse's avatar
Olivier Stasse committed
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

  include/dynamic-graph/dynamic-graph-api.h

  include/dynamic-graph/entity.h
  include/dynamic-graph/factory.h
  include/dynamic-graph/pool.h

  include/dynamic-graph/exception-abstract.h
  include/dynamic-graph/exception-factory.h
  include/dynamic-graph/exception-signal.h
  include/dynamic-graph/exception-traces.h

  include/dynamic-graph/signal.h
  include/dynamic-graph/signal-array.h
  include/dynamic-graph/signal-base.h
  include/dynamic-graph/signal-ptr.h
  include/dynamic-graph/signal-time-dependent.h
  include/dynamic-graph/signal-ptr.t.cpp
  include/dynamic-graph/signal.t.cpp
  include/dynamic-graph/time-dependency.h
  include/dynamic-graph/time-dependency.t.cpp
  include/dynamic-graph/signal-caster.h
  include/dynamic-graph/signal-cast-helper.h
  include/dynamic-graph/all-signals.h
  include/dynamic-graph/signal-helper.h
  include/dynamic-graph/entity-helper.h

  include/dynamic-graph/tracer.h
  include/dynamic-graph/tracer-real-time.h

  include/dynamic-graph/command.h
  include/dynamic-graph/eigen-io.h
  include/dynamic-graph/linear-algebra.h
  include/dynamic-graph/value.h

  include/dynamic-graph/command-setter.h
  include/dynamic-graph/command-setter.t.cpp
  include/dynamic-graph/command-getter.h
  include/dynamic-graph/command-getter.t.cpp
  include/dynamic-graph/command-direct-getter.h
  include/dynamic-graph/command-direct-setter.h
  include/dynamic-graph/command-bind.h
  include/dynamic-graph/all-commands.h

  include/dynamic-graph/logger.h
Guilhem Saurel's avatar
Guilhem Saurel committed
147
  )
Olivier Stasse's avatar
Olivier Stasse committed
148

149
ADD_LIBRARY(${PROJECT_NAME}
150
151
  SHARED ${${PROJECT_NAME}_SOURCES} ${${PROJECT_NAME}_HEADERS})

Olivier Stasse's avatar
Olivier Stasse committed
152
153
154
155
SET(PUBLIC_HEADER ${${PROJECT_NAME}_HEADERS})

INSTALL(TARGETS ${PROJECT_NAME}
  EXPORT ${TARGETS_EXPORT_NAME}
156
  PUBLIC_HEADER
Olivier Stasse's avatar
Olivier Stasse committed
157
  INCLUDES DESTINATION include
158
  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
Olivier Stasse's avatar
Olivier Stasse committed
159
160
161
162
163
164
  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  )

# We need to include Eigen3 because the CMakeFile at 16.04 LTS
# is not so modern.
target_include_directories(${PROJECT_NAME}
165
166
  PUBLIC
  $<BUILD_INTERFACE:${CMAKE_BUILD_DIR}/include>
Guilhem Saurel's avatar
Guilhem Saurel committed
167
168
169
170
171
  $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
  $<BUILD_INTERFACE:${EIGEN3_INCLUDE_DIRS}>
  INTERFACE ${EIGEN3_INCLUDE_DIRS}
  $<INSTALL_INTERFACE:include>
  )
Olivier Stasse's avatar
Olivier Stasse committed
172

173
174
175
176
OPTION(SUFFIX_SO_VERSION
  "Suffix shared library name by a string depending on git status of project"
  ON)

Guilhem Saurel's avatar
Guilhem Saurel committed
177
IF (SUFFIX_SO_VERSION)
178
179
  SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION})
ENDIF ()
Olivier Stasse's avatar
Olivier Stasse committed
180
181

IF (UNIX)
182
  TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${CMAKE_DL_LIBS} pthread)
Olivier Stasse's avatar
Olivier Stasse committed
183
184
ENDIF (UNIX)

185
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${Boost_LIBRARIES})
Olivier Stasse's avatar
Olivier Stasse committed
186
187
188
189
190

####################################
### Plugins
####################################
SET(plugins_list
Guilhem Saurel's avatar
Guilhem Saurel committed
191
192
193
  src/traces/tracer
  src/traces/tracer-real-time
  )
Olivier Stasse's avatar
Olivier Stasse committed
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209

SET(tracer-real-time_dependency tracer)

FOREACH(plugin_file ${plugins_list})
  GET_FILENAME_COMPONENT(plugin ${plugin_file} NAME)
  ADD_LIBRARY(${plugin} SHARED "${plugin_file}.cpp")

  TARGET_LINK_LIBRARIES(${plugin}
    ${PROJECT_NAME} ${${plugin}_dependency}
    ${Boost_LIBRARIES})

  SET_TARGET_PROPERTIES(${plugin}
    PROPERTIES
    PREFIX ""
    )

210
211
212
  INSTALL(TARGETS ${plugin}
    EXPORT ${TARGET_NAME}
    DESTINATION ${PLUGINDIR})
Olivier Stasse's avatar
Olivier Stasse committed
213
ENDFOREACH(plugin_file)
214

Thomas Moulard's avatar
Thomas Moulard committed
215
ADD_SUBDIRECTORY(tests)
216

217
218
219
get_cmake_property(_variableNames VARIABLES)
list (SORT _variableNames)
foreach (_variableName ${_variableNames})
220
221
222
  LIST(APPEND LOGGING_WATCHED_VARIABLES
    ${_variableName}
    )
223
224
endforeach()

Guilhem Saurel's avatar
Guilhem Saurel committed
225
226
INSTALL(FILES package.xml DESTINATION share/${PROJECT_NAME})

227
MESSAGE(STATUS "dynamic_graph_VERSION=${dynamic_graph_VERSION}")