-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
118 lines (84 loc) · 2.14 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
cmake_minimum_required(VERSION 3.10)
project(CALIB)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
option(BUILD_SHARED "Build shared library" ON)
find_library(BLITZ_LIB libblitz.a PATHS ./lib)
find_library(FFTW3_LIB libfftw3.a PATHS ./lib)
if (NOT BLITZ_LIB)
message(FATAL_ERROR "File 'libblitz.a' not found! Blitz library must be installed!")
endif()
if (NOT FFTW3_LIB)
message(FATAL_ERROR "File 'libfftw3.a' not found! FFTW3 library must be installed!")
endif()
file(GLOB CALIB_SRC "./src/calib/*.cpp")
file(GLOB DEMO_SRC "./src/demo/*.cpp")
file(GLOB TEST_SRC "./src/test/*.cpp")
#Add target library
if (BUILD_SHARED)
add_library(calib SHARED ${CALIB_SRC})
else ()
add_library(calib ${CALIB_SRC})
endif()
target_include_directories(calib PRIVATE ./inc)
target_link_libraries(
calib
${BLITZ_LIB} ${FFTW3_LIB}
)
#Add demo examples
set(DEMO)
foreach(demo_src ${DEMO_SRC})
get_filename_component(demo_bin ${demo_src} NAME)
string(REPLACE ".cpp" "" demo_bin ${demo_bin})
set(DEMO ${DEMO} ${demo_bin})
add_executable(${demo_bin} ${demo_src})
set_target_properties(
${demo_bin}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/bin/demo
)
target_include_directories(
${demo_bin} PRIVATE ./inc
)
target_link_libraries(
${demo_bin} calib
)
endforeach()
add_custom_target(
demo DEPENDS
${DEMO}
)
#Add unit-tests
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost COMPONENTS unit_test_framework)
if (Boost_FOUND)
set(TEST)
foreach(test_src ${TEST_SRC})
get_filename_component(test_bin ${test_src} NAME)
string(REPLACE ".cpp" "" test_bin ${test_bin})
set(TEST ${TEST} ${test_bin})
add_executable(${test_bin} ${test_src})
set_target_properties(
${test_bin}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/bin/test
)
target_include_directories(
${test_bin} PRIVATE ./inc
)
target_link_libraries(
${test_bin}
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
)
target_link_libraries(
${test_bin} calib
)
endforeach()
add_custom_target(
test DEPENDS
${TEST}
)
endif()