-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
184 lines (161 loc) · 6.73 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
#
# -------------------------------------------------------------------
#
# Copyright (C) 2010, 2011, Edwin van Leeuwen,
# 2011 Juan Carlos Vallejo
#
#
# This file is part of RealTimePlot.
#
# RealTimePlot 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 3 of the License, or
# (at your option) any later version.
#
# RealTimePlot 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 RealTimePlot. If not, see <http://www.gnu.org/licenses/>.
#
# -------------------------------------------------------------------
#
cmake_minimum_required(VERSION 2.6)
project(RealTimePlot)
#SET (CMAKE_CXX_FLAGS "-O2 -march=native -pipe -ffast-math -fomit-frame-pointer -Wall ${CMAKE_CXX_FLAGS}")
SET (CMAKE_CXX_FLAGS "-O3 -std=c++11 ${CMAKE_CXX_FLAGS}")
if(NO_X)
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNO_X")
endif()
#SET (CMAKE_CXX_FLAGS "-O1 -ggdb")
INCLUDE(FindPkgConfig)
pkg_check_modules(PANGOMM REQUIRED pangomm-1.4)
pkg_check_modules(CAIROMM REQUIRED cairomm-1.0)
pkg_check_modules(GLIBMM REQUIRED glibmm-2.4)
set(BOOST_LIBS thread date_time math_tr1 )
find_package(Boost COMPONENTS ${BOOST_LIBS} REQUIRED)
find_library( CPPA cppa )
if (NOT CPPA)
message( FATAL_ERROR "libcppa not found" )
endif()
SET(LIBS "${PANGOMM_LIBRARIES};${Boost_LIBRARIES};${CPPA}")
SET(SRC
"src/realtimeplot/backend.cc;src/realtimeplot/eventhandler.cc;src/realtimeplot/events.cc;src/realtimeplot/delaunay.cc;src/realtimeplot/xcbhandler.cc;src/realtimeplot/utils.cc;src/realtimeplot/plotarea.cc;src/realtimeplot/plot.cc;src/realtimeplot/adaptive.cc;src/realtimeplot/actor.cc")
if(NOT NO_X)
find_library( XCB-UTIL xcb-keysyms xcb-util )
if(NOT XCB-UTIL)
message( FATAL_ERROR "Could not find xcb-util(-keysyms) library\n You
could compile without X support by adding NO_X=1 to your cmake command
line:\ncmake . -DNO_X=1" )
endif()
SET(LIBS "${LIBS};${XCB-UTIL}")
SET(SRC "${SRC};src/cairomm/xcb_surface.cc")
endif()
# Can be used by youcompleteme to lookup compile information
SET (CMAKE_EXPORT_COMPILE_COMMANDS ON)
include_directories( ${PANGOMM_INCLUDE_DIRS} )
include_directories( ${CAIROMM_INCLUDE_DIRS} )
include_directories( ${GLIBMM_INCLUDE_DIRS} )
include_directories( "/usr/lib/x86_64-linux-gnu/glibmm-2.4/include" )
include_directories( "/usr/lib/x86_64-linux-gnu/sigc++-2.0/include" )
include_directories("include")
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY lib)
add_library( realtimeplot SHARED ${SRC} )
target_link_libraries(realtimeplot ${LIBS})
#Examples.. should be under own build target -> make examples
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY bin)
FILE(GLOB examplesRaw RELATIVE ${CMAKE_HOME_DIRECTORY} examples/*.cc)
FOREACH(example ${examplesRaw})
get_filename_component( ex ${example} NAME_WE )
add_executable(${ex} EXCLUDE_FROM_ALL ${example})
target_link_libraries(${ex} realtimeplot)
SET(examples ${examples};${ex})
ENDFOREACH()
MESSAGE( ${examples} )
add_custom_target( examples
DEPENDS ${examples}
)
# Refresh tags file after changes
FIND_PROGRAM(CTAGS ctags)
if(CTAGS)
add_custom_command (TARGET realtimeplot POST_BUILD COMMAND ${CTAGS} -R --c++-kinds=+p
--fields=+iaS --extra=+q .)
endif()
#Install the library
SET (CMAKE_INSTALL_PREFIX /usr)
install (TARGETS realtimeplot DESTINATION lib)
install (FILES include/realtimeplot/realtimeplot.h
include/realtimeplot/backend.h
include/realtimeplot/plotarea.h
include/realtimeplot/eventhandler.h
include/realtimeplot/thread_queue.h
include/realtimeplot/xcbhandler.h
include/realtimeplot/adaptive.h
include/realtimeplot/utils.h
include/realtimeplot/events.h
include/realtimeplot/delaunay.h
include/realtimeplot/actor.hh
include/realtimeplot/plot.h DESTINATION
include/realtimeplot)
#Documentation
set(DOXYFILE_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc/realtimeplot")
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
include(UseDoxygen)
# Tests
find_package(CxxTest)
if(CXXTEST_FOUND)
file(MAKE_DIRECTORY tests/tmp_plots)
include_directories(tests/include)
enable_testing()
CXXTEST_ADD_TEST(unittest_actor test_actor.cc
${CMAKE_CURRENT_SOURCE_DIR}/tests/test_actor.h)
target_link_libraries(unittest_actor realtimeplot)
CXXTEST_ADD_TEST(unittest_thread_queue test_thread_queue.cc
${CMAKE_CURRENT_SOURCE_DIR}/tests/test_thread_queue.h)
target_link_libraries(unittest_thread_queue realtimeplot)
CXXTEST_ADD_TEST(unittest_eventhandler test_eventhandler.cc
${CMAKE_CURRENT_SOURCE_DIR}/tests/test_eventhandler.h)
target_link_libraries(unittest_eventhandler realtimeplot)
CXXTEST_ADD_TEST(unittest_delaunay test_delaunay.cc
${CMAKE_CURRENT_SOURCE_DIR}/tests/test_delaunay.h)
target_link_libraries(unittest_delaunay realtimeplot) # as needed
CXXTEST_ADD_TEST(unittest_backend test_backend.cc
${CMAKE_CURRENT_SOURCE_DIR}/tests/test_backend.h)
target_link_libraries(unittest_backend realtimeplot) # as needed
CXXTEST_ADD_TEST(unittest_plotarea test_plotarea.cc
${CMAKE_CURRENT_SOURCE_DIR}/tests/test_plotarea.h)
target_link_libraries(unittest_plotarea realtimeplot cairomm-1.0)
CXXTEST_ADD_TEST(unittest_plot test_plot.cc
${CMAKE_CURRENT_SOURCE_DIR}/tests/test_plot.h)
target_link_libraries(unittest_plot realtimeplot)
CXXTEST_ADD_TEST(unittest_utils test_utils.cc
${CMAKE_CURRENT_SOURCE_DIR}/tests/test_utils.h)
target_link_libraries(unittest_utils realtimeplot)
CXXTEST_ADD_TEST(unittest_adaptive test_adaptive.cc
${CMAKE_CURRENT_SOURCE_DIR}/tests/test_adaptive.h)
target_link_libraries(unittest_adaptive realtimeplot) # as needed
if(NOT NO_X)
CXXTEST_ADD_TEST(unittest_xcbhandler test_xcbhandler.cc
${CMAKE_CURRENT_SOURCE_DIR}/tests/test_xcbhandler.h)
target_link_libraries(unittest_xcbhandler realtimeplot) # as needed
endif()
endif()
#
# Ruby library
#
#add_custom_target(rb_two_niches.so COMMAND ruby ruby/rb_two_niches.rb DEPENDS
# two_niches)
add_custom_target(ruby_install ${CMAKE_COMMAND} -E chdir ext/generated/ make
install
DEPENDS ext/generated/Makefile __install )
# Currently impossible to depend on build in command, so need to define my own
# install: http://public.kitware.com/Bug/view.php?id=8438
add_custom_target(__install ${CMAKE_COMMAND} cmake -P cmake_install.cmake)
add_custom_target(ruby DEPENDS ext/rb_realtimeplot.so)
add_custom_command( OUTPUT ext/rb_realtimeplot.so ext/generated/Makefile
COMMAND ruby ext/rb_realtimeplot.rb
COMMAND ${CMAKE_COMMAND} -E copy ext/generated/rb_realtimeplot.so ext/rb_realtimeplot.so
DEPENDS ext/rb_realtimeplot.rb realtimeplot
ext/utils/custom_from_to_ruby.h ext/utils/custom_from_to_ruby.cc)