forked from lrodriguezlujan/neurostr
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
executable file
·331 lines (257 loc) · 9.97 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
cmake_minimum_required(VERSION 3.2.0)
if (UNIX)
find_package(PkgConfig)
endif(UNIX)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
# Workspace name
project(NeuroSTR
VERSION 0.1
LANGUAGES CXX)
#set(CMAKE_CXX_COMPILER g++-6)
# This setting is useful for providing JSON file used by CodeLite for code completion
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
set(CONFIGURATION_NAME ${CMAKE_BUILD_TYPE})
# Projects
# Top project
# Define some variables
set(PROJECT_PATH "${CMAKE_SOURCE_DIR}/")
# Set default locations
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# Copy headers and stuff
#file(COPY ./include DESTINATION ${CMAKE_BINARY_DIR}/)
#file(COPY ./bundled/ DESTINATION ${CMAKE_BINARY_DIR}/include)
# Find boost
find_package(Boost 1.62.0 REQUIRED
filesystem
program_options )
# Find eigen3
find_package( Eigen3 REQUIRED )
if(${EIGEN3_FOUND})
message( STATUS "Eigen 3 found at ${EIGEN3_INCLUDE_DIR}")
endif()
include_directories(
.
./include
./bundled
${Boost_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
)
link_directories(
${Boost_LIBRARY_DIRS}
)
# Compiler options
add_definitions(
-DBOOST_SYSTEM_NO_DEPRECATED
-DEIGEN_MPL2_ONLY
)
if(WIN32)
# Resource options
endif(WIN32)
# Library path
set(CMAKE_LDFLAGS "${CMAKE_LDFLAGS} -L. ")
# Define the library sources
set ( LIB_CXX_SRCS
${CMAKE_SOURCE_DIR}/src/core/branch.cpp
${CMAKE_SOURCE_DIR}/src/core/contour.cpp
${CMAKE_SOURCE_DIR}/src/core/geometry.cpp
${CMAKE_SOURCE_DIR}/src/core/log.cpp
${CMAKE_SOURCE_DIR}/src/core/neurite.cpp
${CMAKE_SOURCE_DIR}/src/core/neurite_type.cpp
${CMAKE_SOURCE_DIR}/src/core/neuron.cpp
${CMAKE_SOURCE_DIR}/src/core/node.cpp
${CMAKE_SOURCE_DIR}/src/core/property.cpp
${CMAKE_SOURCE_DIR}/src/io/ASCParser.cpp
${CMAKE_SOURCE_DIR}/src/io/DATParser.cpp
${CMAKE_SOURCE_DIR}/src/io/JSONParser.cpp
${CMAKE_SOURCE_DIR}/src/io/JSONWriter.cpp
${CMAKE_SOURCE_DIR}/src/io/nl_structure.cpp
${CMAKE_SOURCE_DIR}/src/io/parser_dispatcher.cpp
${CMAKE_SOURCE_DIR}/src/io/SWCParser.cpp
${CMAKE_SOURCE_DIR}/src/io/SWCWriter.cpp
${CMAKE_SOURCE_DIR}/src/methods/boxCutter.cpp
${CMAKE_SOURCE_DIR}/src/methods/branchComparison.cpp
${CMAKE_SOURCE_DIR}/src/methods/scholl.cpp
${CMAKE_SOURCE_DIR}/src/methods/triContour.cpp
${CMAKE_SOURCE_DIR}/src/validator/validator.cpp
${CMAKE_SOURCE_DIR}/src/measure/measure_operations.cpp
)
# Define the library compile flags
if( DEFINED ${CONFIGURATION_NAME} AND ${CONFIGURATION_NAME} STREQUAL "Release")
set_source_files_properties(
${LIB_CXX_SRCS} PROPERTIES COMPILE_FLAGS
" -O3 -std=c++14")
else()
set_source_files_properties(
${LIB_CXX_SRCS} PROPERTIES COMPILE_FLAGS
" -O0 -std=c++14 -Wall")
endif()
if(WIN32)
enable_language(RC)
set(CMAKE_RC_COMPILE_OBJECT
"<CMAKE_RC_COMPILER> ${RC_OPTIONS} -O coff -i <SOURCE> -o <OBJECT>")
endif(WIN32)
# Add neurostr target
add_library(neurostr ${LIB_CXX_SRCS})
target_link_libraries(neurostr -lpthread -lboost_filesystem -lboost_system)
set_property(TARGET neurostr PROPERTY CXX_STANDARD 14)
set_property(TARGET neurostr PROPERTY CXX_STANDARD_REQUIRED ON)
# Tools
# Define the library sources
set (TOOL_SRC_DIR "${CMAKE_SOURCE_DIR}/tools")
set ( TOOLS_CXX_SRCS
${TOOL_SRC_DIR}/BoxCutter.cpp
${TOOL_SRC_DIR}/BranchFeatureExtractor.cpp
${TOOL_SRC_DIR}/NodeFeatureExtractor.cpp
${TOOL_SRC_DIR}/NeuriteFeatureExtractor.cpp
${TOOL_SRC_DIR}/NeuroConverter.cpp
${TOOL_SRC_DIR}/Scholl.cpp
${TOOL_SRC_DIR}/Validator.cpp
${TOOL_SRC_DIR}/Benchmark.cpp
${TOOL_SRC_DIR}/Contour3DTagger.cpp
${TOOL_SRC_DIR}/TagFeatureExtractor.cpp
)
# Define the Tools compile flags
if( DEFINED ${CONFIGURATION_NAME} AND ${CONFIGURATION_NAME} STREQUAL "Debug")
set_source_files_properties(
${TOOLS_CXX_SRCS} PROPERTIES COMPILE_FLAGS
" -O0 -std=c++14 -Wall")
else()
set_source_files_properties(
${TOOLS_CXX_SRCS} PROPERTIES COMPILE_FLAGS
" -O3 -std=c++14")
endif()
link_directories( ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} )
add_executable(neurostr_boxcutter ${CMAKE_SOURCE_DIR}/tools/BoxCutter.cpp)
target_link_libraries(neurostr_boxcutter -lneurostr -lpthread -lboost_filesystem -lboost_program_options -lboost_system)
add_dependencies(neurostr_boxcutter neurostr)
add_executable(neurostr_branchfeatures ${CMAKE_SOURCE_DIR}/tools/BranchFeatureExtractor.cpp)
target_link_libraries(neurostr_branchfeatures -lneurostr -lpthread -lboost_filesystem -lboost_program_options -lboost_system)
add_dependencies(neurostr_branchfeatures neurostr)
add_executable(neurostr_nodefeatures ${CMAKE_SOURCE_DIR}/tools/NodeFeatureExtractor.cpp)
target_link_libraries(neurostr_nodefeatures -lneurostr -lpthread -lboost_filesystem -lboost_program_options -lboost_system)
add_dependencies(neurostr_nodefeatures neurostr)
add_executable(neurostr_neuritefeatures ${CMAKE_SOURCE_DIR}/tools/NeuriteFeatureExtractor.cpp)
target_link_libraries(neurostr_neuritefeatures -lneurostr -lpthread -lboost_filesystem -lboost_program_options -lboost_system)
add_dependencies(neurostr_neuritefeatures neurostr)
add_executable(neurostr_converter ${CMAKE_SOURCE_DIR}/tools/NeuroConverter.cpp)
target_link_libraries(neurostr_converter -lneurostr -lpthread -lboost_filesystem -lboost_program_options -lboost_system)
add_dependencies(neurostr_converter neurostr)
add_executable(neurostr_scholl ${CMAKE_SOURCE_DIR}/tools/Scholl.cpp)
target_link_libraries(neurostr_scholl -lneurostr -lpthread -lboost_filesystem -lboost_program_options -lboost_system)
add_dependencies(neurostr_scholl neurostr)
add_executable(neurostr_validator ${CMAKE_SOURCE_DIR}/tools/Validator.cpp)
target_link_libraries(neurostr_validator -lneurostr -lpthread -lboost_filesystem -lboost_program_options -lboost_system)
add_dependencies(neurostr_validator neurostr)
add_executable(neurostr_benchmark EXCLUDE_FROM_ALL ${CMAKE_SOURCE_DIR}/tools/Benchmark.cpp)
target_link_libraries(neurostr_benchmark -lneurostr -lpthread -lboost_filesystem -lboost_program_options)
add_dependencies(neurostr_benchmark neurostr)
add_executable(neurostr_contourtag ${CMAKE_SOURCE_DIR}/tools/Contour3DTagger.cpp)
target_link_libraries(neurostr_contourtag -lneurostr -lpthread -lboost_filesystem -lboost_program_options -lboost_system)
add_dependencies(neurostr_contourtag neurostr)
add_executable(neurostr_tagfeatures ${CMAKE_SOURCE_DIR}/tools/TagFeatureExtractor.cpp)
target_link_libraries(neurostr_tagfeatures -lneurostr -lpthread -lboost_filesystem -lboost_program_options -lboost_system)
add_dependencies(neurostr_tagfeatures neurostr)
add_custom_target(tools DEPENDS
neurostr_boxcutter
neurostr_branchfeatures
neurostr_neuritefeatures
neurostr_converter
neurostr_scholl
neurostr_validator
neurostr_contourtag
neurostr_tagfeatures)
## TESTS
set( TEST_SRC_DIR ${CMAKE_SOURCE_DIR}/test/src)
# Define test sources
set ( TEST_CXX_SRCS
${TEST_SRC_DIR}/core/branch_test.cpp
${TEST_SRC_DIR}/core/contour_test.cpp
${TEST_SRC_DIR}/core/geometry_test.cpp
${TEST_SRC_DIR}/core/neurite_test.cpp
${TEST_SRC_DIR}/core/neuron_test.cpp
${TEST_SRC_DIR}/core/node_test.cpp
${TEST_SRC_DIR}/core/property_test.cpp
${TEST_SRC_DIR}/core/reconstruction_test.cpp
${TEST_SRC_DIR}/io/io_asc_parser.cpp
${TEST_SRC_DIR}/io/io_swc_parser.cpp
${TEST_SRC_DIR}/io/JSONParser_test.cpp
${CMAKE_SOURCE_DIR}/test/main.cpp
)
# Define the test compile flags
if( DEFINED ${CONFIGURATION_NAME} AND ${CONFIGURATION_NAME} STREQUAL "Debug")
set_source_files_properties(
${TEST_CXX_SRCS} PROPERTIES COMPILE_FLAGS
" -O0 -std=c++14 -Wall")
else()
set_source_files_properties(
${TEST_CXX_SRCS} PROPERTIES COMPILE_FLAGS
" -O3 -std=c++14")
endif()
## Find Unittest++
#find_package( FindUnitTestcpp REQUIRED )
include(FindUnitTest++)
if( NOT ${UNITTEST++_FOUND})
message( WARNING "Unittest++ library not found - test cannot be compiled")
else()
# Add unittest paths
link_directories(
${Boost_LIBRARY_DIRS}
${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
${UNITTEST++_LIBRARY}
)
# Includes..
include_directories(
.
./include
./bundled
${Boost_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
${UNITTEST++_INCLUDE_DIR}
)
# Create test target exec
add_executable(neurostr_test EXCLUDE_FROM_ALL ${TEST_CXX_SRCS} )
target_link_libraries(neurostr_test -lneurostr -lpthread -lUnitTest++)
set_target_properties( neurostr_test PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/test)
# Create run test
# Set test data var
set(ENV{NSTR_TEST_DIR} ${CMAKE_SOURCE_DIR}/test/)
add_custom_target( run_test
COMMAND neurostr_test
DEPENDS neurostr_test
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test )
endif()
### INSTALL TARGET
# Install bundeld libs - !!!!
if(NOT NO_INSTALL_BUNDLED)
# Rapidjson
if(NOT NO_INSTALL_RAPIDJSON)
install(DIRECTORY ${PROJECT_PATH}bundled/rapidjson DESTINATION include/rapidjson )
endif()
# SPDLOG
if(NOT NO_INSTALL_SPDLOG)
install(DIRECTORY ${PROJECT_PATH}bundled/spdlog DESTINATION include/spdlog )
endif()
# tree
if(NOT NO_INSTALL_TREE)
install(FILES ${PROJECT_PATH}bundled/tree.hh DESTINATION include/ )
endif()
# basen.hpp
if(NOT NO_INSTALL_BASEN)
install(FILES ${PROJECT_PATH}bundled/basen.hpp DESTINATION include/ )
endif()
endif()
# INSTALL LIB
# Headers
install(DIRECTORY ${PROJECT_PATH}include/ DESTINATION include )
# LIB
install(TARGETS neurostr
LIBRARY DESTINATION lib/neurostr
ARCHIVE DESTINATION lib/neurostr
RUNTIME DESTINATION bin/ )
# Tools
if(NOT NO_INSTALL_TOOLS)
install(TARGETS neurostr_boxcutter neurostr_branchfeatures neurostr_neuritefeatures neurostr_converter neurostr_scholl neurostr_validator
RUNTIME DESTINATION bin/ )
endif()