-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
653 lines (499 loc) · 22.4 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
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
# Copyright 2014, Max Planck Society.
# Distributed under the BSD 3-Clause license.
# (See accompanying file LICENSE.txt or copy at
# http://opensource.org/licenses/BSD-3-Clause)
cmake_minimum_required(VERSION 3.5)
project(GrassmannAveragesPCA)
# build type, by default to release (with optimisations)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_MACOSX_RPATH ON)
if(NOT WITHOUT_TESTS)
# ctest sets BUILD_TESTING automatically, but does not seem to serve its purpose.
include(CTest)
enable_testing()
endif()
##############################################################################################
# Thirdparties and tools
#
find_package(Doxygen)
# Boost, uBlas and some other libraries are needed in any case.
if(NOT DEFINED Boost_ADDITIONAL_VERSIONS)
set(Boost_ADDITIONAL_VERSIONS "1.59" "1.59.0" "1.60" "1.60.0")
endif()
# disable auto link
add_definitions(-DBOOST_ALL_NO_LIB)
if(NOT DEFINED Boost_USE_STATIC_LIBS)
if(UNIX)
set(Boost_USE_STATIC_LIBS ON) # because of the Matlab.mex dependencies relocation not handled here
else()
set(Boost_USE_STATIC_LIBS OFF)
endif()
endif()
if(NOT Boost_USE_STATIC_LIBS)
# link against dynamic libraries
add_definitions(-DBOOST_ALL_DYN_LINK)
endif()
set(Boost_REALPATH ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_DEBUG ON)
set(Boost_DETAILED_FAILURE_MSG ON)
if(DEFINED BOOST_ROOT)
set(Boost_NO_SYSTEM_PATHS ON)
else()
set(Boost_NO_SYSTEM_PATHS OFF)
endif()
set(Boost_NO_BOOST_CMAKE ON)
if(NOT WITHOUT_TESTS)
find_package(Boost COMPONENTS system thread chrono date_time program_options unit_test_framework)
else()
find_package(Boost COMPONENTS system thread chrono date_time program_options)
endif()
if(NOT ${Boost_FOUND})
message(FATAL_ERROR "[BOOST] Boost not found. Please set BOOST_ROOT in your command line.")
endif()
# Matlab bindings
if(NOT WITHOUT_MATLAB)
set(MATLAB_FIND_DEBUG TRUE)
find_package(Matlab 8.1 REQUIRED COMPONENTS MX_LIBRARY MAIN_PROGRAM)
# the following lines should not be needed
if(NOT ${Matlab_FOUND})
message(FATAL_ERROR "Unable to find Matlab include directory")
else()
set(MATLAB_RELEASE_NAME)
matlab_get_release_name_from_version(${Matlab_VERSION_STRING} MATLAB_RELEASE_NAME)
message(STATUS "[MATLAB] - version ${Matlab_VERSION_STRING}")
message(STATUS "[MATLAB] - release ${MATLAB_RELEASE_NAME}")
message(STATUS "[MATLAB] - include directory ${Matlab_INCLUDE_DIRS}")
message(STATUS "[MATLAB] - mex library ${Matlab_MEX_LIBRARY}")
message(STATUS "[MATLAB] - mex extension ${Matlab_MEX_EXTENSION}")
message(STATUS "[MATLAB] - mx library ${Matlab_MX_LIBRARY}")
message(STATUS "[MATLAB] - matlab ${Matlab_MAIN_PROGRAM}")
endif()
endif()
# openCV for videos reading applications
# openCV should be installed somewhere defined on the command line. If this is not the case, an error message is printed and
# the build is aborted.
set(OpenCV_LIB_COMPONENTS opencv_core)
if(NOT OpenCVRoot)
set(OpenCV_CUDA OFF)
set(OpenCV_STATIC OFF)
find_package(OpenCV)
if(OpenCV_INCLUDE_DIRS)
set(OPENCV_AVAILABLE TRUE CACHE INTERNAL "Setting the availability of opencv")
message(STATUS "[OPENCV] Open CV found at location ${OpenCV_INCLUDE_DIRS}")
else()
set(OPENCV_AVAILABLE FALSE CACHE INTERNAL "Setting the availability of opencv")
message(WARNING "[OPENCV] OpenCVRoot is not defined. OpenCVRoot should be defined with the option -DOpenCVRoot=<root-to-opencv>
in order to benefit from the video applications")
endif()
else()
set(opencv_root ${OpenCVRoot})
if(EXISTS ${opencv_root}/opencv)
set(opencv_root ${opencv_root}/opencv)
endif()
if(NOT EXISTS ${opencv_root}/include)
message(FATAL_ERROR "[OPENCV] Cannot find the header directory of open cv. Please ensure you have decompressed the version for windows")
endif()
# apparently this is the way cmake works... did not know, the OpenCVConfig.cmake file is enough for the configuration
set(OpenCV_DIR ${opencv_root}/ CACHE PATH "Location of the OpenCV configuration directory")
set(OpenCV_SHARED ON)
set(OpenCV_STATIC OFF)
set(OpenCV_CUDA OFF)
#set(BUILD_SHARED_LIBS OFF)
find_package(OpenCV REQUIRED)
if(NOT OpenCV_INCLUDE_DIRS)
message(FATAL_ERROR "[OPENCV] Cannot add the OpenCV include directories")
endif()
list(REMOVE_DUPLICATES OpenCV_LIB_DIR)
list(LENGTH OpenCV_LIB_DIR list_lenght)
if(${list_lenght} GREATER 1)
list(GET OpenCV_LIB_DIR 0 OpenCV_LIB_DIR)
endif()
set(OpenCV_BIN_DIR ${OpenCV_LIB_DIR}/../bin)
get_filename_component(OpenCV_BIN_DIR ${OpenCV_BIN_DIR} ABSOLUTE)
set(OPENCV_AVAILABLE TRUE CACHE INTERNAL "Setting the availability of opencv")
endif()
#
# general defines and compilation options
if(WIN32)
add_definitions(-D_WIN32_WINNT=0x0501)
else()
# this is mainly because of Boost to which the mex file is linked.
# Basically, it will change the rpath of the produced .mex file to point to either $ORIGIN (ldd variants)
# or @loader_path (otool variants). Then dependant .so/.dylib will be found relatively to the .mex file, which
# is in this case the current directory.
# The SONAME of the dependencies should be changed as well after the installation. The alternative is to use
# static libraries of Boost for the UNIX like platforms. Those should be compiled with -fPIC.
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
if(NOT APPLE)
set(CMAKE_INSTALL_RPATH "$ORIGIN/.")
elseif(UNIX) # APPLE is Unix
set(CMAKE_INSTALL_RPATH "@loader_path/.")
endif()
endif()
# compilation options
include(CheckCXXCompilerFlag)
include(CheckIncludeFileCXX)
set(HAS_AVX FALSE)
check_include_file_cxx(smmintrin.h HAS_SSE41_INSTRINSICS)
# this variable contains the libraries to which the tests should be linked against. In case
# we are using the static libraries of boost, its content will be expanded.
set(BOOST_ADDITIONAL_LIBRARIES_FOR_TESTS ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ${Boost_CHRONO_LIBRARY})
if(NOT MSVC)
# c++11 options
check_cxx_compiler_flag(-std=c++11 HAS_CXX11_FLAG)
check_cxx_compiler_flag(-std=c++0x HAS_CXX0X_FLAG)
check_cxx_compiler_flag(-pthread HAS_PTHREAD_FLAG)
if(HAS_CXX11_FLAG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(HAS_CXX0X_FLAG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
endif()
if(HAS_PTHREAD_FLAG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
endif()
if(Boost_USE_STATIC_LIBS)
# update to include rt library (from chrono)
if(NOT APPLE)
set(BOOST_ADDITIONAL_LIBRARIES_FOR_TESTS ${BOOST_ADDITIONAL_LIBRARIES_FOR_TESTS} rt)
endif()
endif()
else()
check_cxx_compiler_flag(/AVX HAS_AVX)
endif()
if(MSVC)
add_definitions(-D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS)
set(MSVC_Additional_flags "/fp:fast /GF /Oy /GT /Ox /Ob2 /Oi /Os")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${MSVC_Additional_flags}")
if(HAS_SSE41_INSTRINSICS AND HAS_AVX)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /arch:AVX ")
add_definitions(-DGRASSMANNPCA_INNER_PROD_INTRINSICS_AVX)
endif()
endif()
#
# the project starts here
#
# BEFORE and SYSTEM are needed in case there are problems generated by OpenCV; example:
# - boost and opencv installed with homebrew
# - BOOST_ROOT set to sthg
# - FindOpenCV brings /usr/local/include at the top of the includes, which favors the brew boost and hides
# the chosen one from BOOST_ROOT
include_directories(BEFORE ${Boost_INCLUDE_DIRS} SYSTEM)
##############################################################################################
# Main library
# This library is header only in fact, but we add an empty cpp file for convenience with CMake.
set(${PROJECT_NAME}_LIB
include/grassmann_pca.hpp
include/grassmann_pca_with_trimming.hpp
include/private/utilities.hpp
include/private/em_pca.hpp
include/private/boost_ublas_external_storage.hpp
include/private/boost_ublas_row_iterator.hpp
src/grassmann_pca.cpp)
add_library(grassmann_averages ${${PROJECT_NAME}_LIB})
target_include_directories(grassmann_averages
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(grassmann_averages ${Boost_SYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_DATE_TIME_LIBRARY})
install(
DIRECTORY include
DESTINATION "."
PATTERN "*bak" EXCLUDE)
# examples, checks the compilation only
set(${PROJECT_NAME}Examples_LIB
test/example_grassmannpca.cpp)
add_library(grassmann_averages_examples ${${PROJECT_NAME}Examples_LIB})
target_link_libraries(grassmann_averages_examples grassmann_averages)
##############################################################################################
# Applications
if(OPENCV_AVAILABLE)
# not linking against everything in opencv
set(opencv_core_library "opencv_core" "opencv_highgui")
set(${PROJECT_NAME}_ga_movie_runner_SRC
applications/video_processing_grassmann_pca.cpp)
add_executable(${PROJECT_NAME}_ga_movie_runner ${${PROJECT_NAME}_ga_movie_runner_SRC})
target_link_libraries(${PROJECT_NAME}_ga_movie_runner grassmann_averages ${opencv_core_library} ${Boost_PROGRAM_OPTIONS_LIBRARY})
target_include_directories(${PROJECT_NAME}_ga_movie_runner PRIVATE ${OpenCV_INCLUDE_DIRS})
set_target_properties(${PROJECT_NAME}_ga_movie_runner PROPERTIES FOLDER "Applications")
# Reads a full movie and runs the Trimmed Grassman PCA on it
set(${PROJECT_NAME}_trimmed_ga_movie_runner_SRC
applications/video_processing_trimmed_grassmann_pca.cpp)
add_executable(${PROJECT_NAME}_trimmed_ga_movie_runner ${${PROJECT_NAME}_trimmed_ga_movie_runner_SRC})
target_link_libraries(${PROJECT_NAME}_trimmed_ga_movie_runner grassmann_averages ${opencv_core_library} ${Boost_PROGRAM_OPTIONS_LIBRARY})
target_include_directories(${PROJECT_NAME}_trimmed_ga_movie_runner PRIVATE ${OpenCV_INCLUDE_DIRS})
set_target_properties(${PROJECT_NAME}_trimmed_ga_movie_runner PROPERTIES FOLDER "Applications")
# Reads a full movie and runs the EM PCA on it
set(${PROJECT_NAME}_empca_movie_runner_SRC
applications/video_processing_empca.cpp)
add_executable(${PROJECT_NAME}_empca_movie_runner ${${PROJECT_NAME}_empca_movie_runner_SRC})
target_link_libraries(${PROJECT_NAME}_empca_movie_runner grassmann_averages ${opencv_core_library} ${Boost_PROGRAM_OPTIONS_LIBRARY})
target_include_directories(${PROJECT_NAME}_empca_movie_runner PRIVATE ${OpenCV_INCLUDE_DIRS})
set_target_properties(${PROJECT_NAME}_empca_movie_runner PROPERTIES FOLDER "Applications")
endif()
##############################################################################################
# Documentation
# documentation of the main doxygen page
# part of the doxygen configuration includes variables that are expanded by cmake.
set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/documentation)
configure_file(doc/Doxyfile ${DOXYGEN_OUTPUT_DIRECTORY}/DoxyfileConfigured)
set(doxygen_sources
doc/main.md
doc/Doxyfile
${DOXYGEN_OUTPUT_DIRECTORY}/DoxyfileConfigured
)
if(DOXYGEN_FOUND)
# generation and "installation" of the doxygen documentation
add_custom_target(
doxygen_documentation
ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUTPUT_DIRECTORY}/DoxyfileConfigured
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/doc
COMMENT "Generating Doxygen documentation"
SOURCES ${doxygen_sources}
)
install(
DIRECTORY ${CMAKE_BINARY_DIR}/documentation/html/
DESTINATION documentation
PATTERN "html/*")
#set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} documentation;documentation/index.html)
else()
add_custom_target(
doxygen_documentation
SOURCES ${doxygen_sources}
)
endif()
set_target_properties(doxygen_documentation PROPERTIES FOLDER "Documentation")
# the readme file
add_custom_target(
readme
SOURCES
README.md
LICENSE.txt
)
set_target_properties(readme PROPERTIES FOLDER "Documentation")
install(
FILES README.md LICENSE.txt
DESTINATION ".")
#set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} readme.txt;readme.txt)
##############################################################################################
# Tests
# Unit tests using boost
if(NOT WITHOUT_TESTS)
# avoiding boost.test autolink
add_definitions(-DBOOST_TEST_NO_LIB)
# introducing specific invocation in boost 1.60
set(boost_test_custom_command_invocation "")
if(${Boost_VERSION} VERSION_GREATER "1.60")
set(boost_test_custom_command_invocation "--")
endif()
if(WIN32)
set(TEST_DYNAMIC_LIBRARY_PATH_CMD "PATH")
elseif(APPLE)
set(TEST_DYNAMIC_LIBRARY_PATH_CMD "DYLD_LIBRARY_PATH")
else()
set(TEST_DYNAMIC_LIBRARY_PATH_CMD "LD_LIBRARY_PATH")
endif()
# basically, we cannot concatenate PATH with something else. I tried different configuration, and the spaces and ; in PATH do
# not play well with the command itself. Even the PATH=%PATH%;blablabla with space does not seem to work.
list(LENGTH Boost_LIBRARY_DIRS _boost_lib_length)
if(${_boost_lib_length} GREATER 1)
list(GET Boost_LIBRARY_DIRS 0 _boost_lib_env)
else()
list(GET Boost_LIBRARY_DIRS 0 _boost_lib_env)
endif()
set(${PROJECT_NAME}_tests
test/test_main.hpp
test/test_main.cpp
test/test_grassmannpca.cpp
test/test_grassmannpca_trimming.cpp
test/test_simplepca.cpp
test/test_row_proxy.cpp)
# this file is used for some internal tests related to ordering
if(${Boost_VERSION} VERSION_GREATER "1.48")
set(${PROJECT_NAME}_tests ${${PROJECT_NAME}_tests} test/test_k_first.cpp)
endif()
add_executable(${PROJECT_NAME}_test ${${PROJECT_NAME}_tests})
target_link_libraries(${PROJECT_NAME}_test grassmann_averages ${BOOST_ADDITIONAL_LIBRARIES_FOR_TESTS})
# the link is with dynamic
if(NOT Boost_USE_STATIC_LIBS)
set_target_properties(${PROJECT_NAME}_test PROPERTIES COMPILE_DEFINITIONS "BOOST_TEST_DYN_LINK")
endif()
set_target_properties(${PROJECT_NAME}_test PROPERTIES FOLDER "UnitTests")
add_test(
NAME ${PROJECT_NAME}_test-1
COMMAND ${PROJECT_NAME}_test)
if(NOT Boost_USE_STATIC_LIBS)
set_tests_properties(
${PROJECT_NAME}_test-1
PROPERTIES ENVIRONMENT ${TEST_DYNAMIC_LIBRARY_PATH_CMD}=${_boost_lib_env})
endif()
# second test based on files
add_executable(${PROJECT_NAME}_test_with_files test/test_grassmannpca_trimming_from_file.cpp)
target_link_libraries(${PROJECT_NAME}_test_with_files grassmann_averages ${BOOST_ADDITIONAL_LIBRARIES_FOR_TESTS})
if(NOT Boost_USE_STATIC_LIBS)
set_target_properties(${PROJECT_NAME}_test_with_files PROPERTIES COMPILE_DEFINITIONS "BOOST_TEST_DYN_LINK")
endif()
set_target_properties(${PROJECT_NAME}_test_with_files PROPERTIES FOLDER "UnitTests")
add_test(
NAME ${PROJECT_NAME}_test-2
CONFIGURATIONS Release
COMMAND ${PROJECT_NAME}_test_with_files
${boost_test_custom_command_invocation}
--data ${CMAKE_SOURCE_DIR}/test/mat_test.csv
--basis_vectors ${CMAKE_SOURCE_DIR}/test/mat_test_init_vectors.csv
--expected_result ${CMAKE_SOURCE_DIR}/test/mat_test_desired_output.csv)
if(NOT Boost_USE_STATIC_LIBS)
set_tests_properties(
${PROJECT_NAME}_test-2
PROPERTIES ENVIRONMENT ${TEST_DYNAMIC_LIBRARY_PATH_CMD}=${_boost_lib_env})
endif()
endif()
##############################################################################################
# Matlab extensions
# adding the matlab MEX extensions
if(NOT WITHOUT_MATLAB)
if(WIN32)
set(MATLAB_INSTALL_DIRECTORY lib/${MATLAB_RELEASE_NAME})
else()
set(MATLAB_INSTALL_DIRECTORY lib)
endif()
#
# the MEX file project
#
set(GAPCA_MEX_Project ${PROJECT_NAME}_mex)
matlab_add_mex(
NAME ${GAPCA_MEX_Project}
OUTPUT_NAME ${PROJECT_NAME}
SRC extensions/matlab.cpp
DOCUMENTATION ${${GAPCA_MEX_Project}_help_file}
LINK_TO grassmann_averages
)
set_target_properties(${GAPCA_MEX_Project} PROPERTIES FOLDER "Matlab")
if(UNIX AND NOT APPLE AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU"))
# this is needed to hide the symbols of eg. Boost as those may clash with the ones loaded from Matlab
# this does not work for the libC++ though, and a LD_PRELOAD is often necessary.
set_target_properties(${GAPCA_MEX_Project}
PROPERTIES LINK_FLAGS "-Wl,--exclude-libs,ALL -Wl,--version-script=${CMAKE_SOURCE_DIR}/extensions/MatlabLinuxVisibility.map"
)
endif()
install(TARGETS ${GAPCA_MEX_Project}
DESTINATION ${MATLAB_INSTALL_DIRECTORY})
install(FILES ${${GAPCA_MEX_Project}_help_file}
DESTINATION ${MATLAB_INSTALL_DIRECTORY}
RENAME ${${GAPCA_MEX_Project}_name}.m)
#
# copies the dependency files into the target output directory
#
macro(copy_dependency_with_config target_name dependency_name)
set(dependency_name_debug ${${dependency_name}_DEBUG})
set(dependency_name_non_debug ${${dependency_name}_RELEASE})
# check to see if the function GetPrerequisites can do the job
if(WIN32)
# on windows, the dependencies are .lib but we should copy .dll files
get_filename_component(dependency_name_debug1 ${dependency_name_debug} NAME_WE)
get_filename_component(dependency_name_debug_dir ${dependency_name_debug} DIRECTORY)
set(dependency_name_debug ${dependency_name_debug_dir}/${dependency_name_debug1}${CMAKE_SHARED_LIBRARY_SUFFIX})
get_filename_component(dependency_name_non_debug1 ${dependency_name_non_debug} NAME_WE)
get_filename_component(dependency_name_non_debug_dir ${dependency_name_non_debug} DIRECTORY)
set(dependency_name_non_debug ${dependency_name_non_debug_dir}/${dependency_name_non_debug1}${CMAKE_SHARED_LIBRARY_SUFFIX})
unset(dependency_name_non_debug1)
unset(dependency_name_non_debug_dir)
unset(dependency_name_debug1)
unset(dependency_name_debug_dir)
endif()
add_custom_command(
TARGET ${target_name}
PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E echo Copy ${dependency_name}
$<$<CONFIG:Debug>:${dependency_name_debug}>
$<$<NOT:$<CONFIG:Debug>>:${dependency_name_non_debug}>
into
$<TARGET_FILE_DIR:${target_name}>/.
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<$<CONFIG:Debug>:${dependency_name_debug}>
$<$<NOT:$<CONFIG:Debug>>:${dependency_name_non_debug}>
$<TARGET_FILE_DIR:${target_name}>/.
COMMENT "Copy ${target_name} dependencies into the output folder"
)
install( FILES ${dependency_name_debug}
DESTINATION ${MATLAB_INSTALL_DIRECTORY}
CONFIGURATIONS Debug)
install( FILES ${dependency_name_non_debug}
DESTINATION ${MATLAB_INSTALL_DIRECTORY}
CONFIGURATIONS Release)
unset(dependency_name_debug)
unset(dependency_name_non_debug)
endmacro(copy_dependency_with_config)
# copying the boost dependencies
if(NOT Boost_USE_STATIC_LIBS)
copy_dependency_with_config(${GAPCA_MEX_Project} Boost_SYSTEM_LIBRARY)
copy_dependency_with_config(${GAPCA_MEX_Project} Boost_THREAD_LIBRARY)
copy_dependency_with_config(${GAPCA_MEX_Project} Boost_CHRONO_LIBRARY)
copy_dependency_with_config(${GAPCA_MEX_Project} Boost_DATE_TIME_LIBRARY)
copy_dependency_with_config(${GAPCA_MEX_Project} Boost_PROGRAM_OPTIONS_LIBRARY)
endif()
endif()
##############################################################################################
# Matlab unit tests
# adding the matlab unit tests
if(NOT WITHOUT_MATLAB AND NOT WITHOUT_TESTS)
set(GAPCA_MEXUnitTest_Project ${GAPCA_MEX_Project}_matlab_unittest_scripts)
add_custom_target(
${GAPCA_MEXUnitTest_Project}
SOURCES
test/grassmannpca_matlab_unit_tests.m
test/grassmannpca_matlab_performance_unit_tests.m)
set_target_properties(${GAPCA_MEXUnitTest_Project} PROPERTIES FOLDER "UnitTests")
add_dependencies(${GAPCA_MEXUnitTest_Project} ${GAPCA_MEX_Project})
matlab_add_unit_test(
NAME ${PROJECT_NAME}_matlabtest-1
TIMEOUT 180
UNITTEST_FILE ${CMAKE_SOURCE_DIR}/test/grassmannpca_matlab_unit_tests.m
ADDITIONAL_PATH $<TARGET_FILE_DIR:${GAPCA_MEX_Project}>
)
matlab_add_unit_test(
NAME ${PROJECT_NAME}_matlabtest-2
TIMEOUT 600
UNITTEST_FILE ${CMAKE_SOURCE_DIR}/test/grassmannpca_matlab_performance_unit_tests.m
ADDITIONAL_PATH $<TARGET_FILE_DIR:${GAPCA_MEX_Project}>
TEST_ARGS CONFIGURATIONS Release
)
if(UNIX AND NOT APPLE)
# dirty hack to load the system libc++ first, as this one may supersede the one coming w. Matlab
set_tests_properties(
${PROJECT_NAME}_matlabtest-1
${PROJECT_NAME}_matlabtest-2
PROPERTIES
ENVIRONMENT "LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6"
)
endif()
endif()
##############################################################################################
# Installation rules
# CPack rules
set(CPACK_PACKAGE_VENDOR "Max Planck Institute for Intelligent Systems")
set(CPACK_PACKAGE_VERSION_MAJOR 1)
set(CPACK_PACKAGE_VERSION_MINOR 2)
set(CPACK_PACKAGE_VERSION_PATCH 0)
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Grassmann Averages for computing a scalable and robust PCA, Matlab extensions")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.txt")
set(CPACK_STRIP_FILES TRUE)
set(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_SOURCE_DIR}/extensions/installer_welcome.txt")
if(WIN32)
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
set(CPACK_NSIS_URL_INFO_ABOUT http://ps.is.tuebingen.mpg.de/project/Robust_PCA)
set(CPACK_NSIS_MENU_LINKS
"documentation/index.html" "C++ library documentation"
"README.md" "README.md"
"http://ps.is.tuebingen.mpg.de/project/Robust_PCA" "Grassmann Averages Web Site")
else()
set(CPACK_GENERATOR TBZ2)
endif()
include(CPack)