-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
120 lines (105 loc) · 3.57 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
cmake_minimum_required(VERSION 3.13)
project(self_organizing_gmm
VERSION 0.0.0
DESCRIPTION
"PRI Mapping"
LANGUAGES CXX C)
# configuration
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_CXX_FLAGS "-std=c++17 -stdlib=libc++ -march=native")
else()
set(CMAKE_CXX_FLAGS "-std=c++17 -march=native -fopenmp -lstdc++fs")
endif()
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
set(FILE_SYS_LIB "stdc++fs")
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp /usr/local/lib/libomp.dylib -I/usr/local/include")
set(OpenMP_CXX_LIB_NAMES "libomp")
set(OpenMP_C_FLAGS "-Xpreprocessor -fopenmp /usr/local/lib/libomp.dylib -I/usr/local/include")
set(OpenMP_C_LIB_NAMES="libomp")
set(OpenMP_libomp_LIBRARY "/usr/local/lib/libomp.dylib")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(FILE_SYS_LIB "")
endif()
# find dependencies
find_package(OpenMP REQUIRED)
find_package(pybind11 REQUIRED)
find_package(Eigen3 3.4 REQUIRED)
find_package(nanoflann REQUIRED)
include(FetchContent)
FetchContent_Declare(
EigenRand
GIT_REPOSITORY https://github.com/bab2min/EigenRand.git
GIT_TAG main
)
FetchContent_MakeAvailable(EigenRand)
# Setup pybind modules
pybind11_add_module(time_profiler_py src/pybind/time_profiler_py.cpp)
target_include_directories(time_profiler_py
PRIVATE
include
)
target_link_libraries(
time_profiler_py
PRIVATE stdc++fs
)
set_target_properties(time_profiler_py PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_INSTALL_PREFIX})
pybind11_add_module(mean_shift_py src/pybind/mean_shift_py.cpp)
target_include_directories(mean_shift_py PRIVATE include)
target_link_libraries(
mean_shift_py
PRIVATE ${FILE_SYS_LIB}
PRIVATE Eigen3::Eigen
PRIVATE nanoflann::nanoflann
)
set_target_properties(mean_shift_py PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_INSTALL_PREFIX})
pybind11_add_module(camera_model_py src/pybind/camera_model_py.cpp)
target_include_directories(camera_model_py PRIVATE include)
target_link_libraries(
camera_model_py
PRIVATE ${FILE_SYS_LIB}
PRIVATE Eigen3::Eigen
)
set_target_properties(camera_model_py PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_INSTALL_PREFIX})
pybind11_add_module(gmm_py src/pybind/gmm_py.cpp)
target_include_directories(gmm_py PRIVATE include ${EigenRand_SOURCE_DIR})
target_link_libraries(
gmm_py
PRIVATE ${FILE_SYS_LIB}
PRIVATE Eigen3::Eigen
PRIVATE ${OpenMP_libomp_LIBRARY}
)
set_target_properties(gmm_py PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_INSTALL_PREFIX})
pybind11_add_module(kinit_py src/pybind/kinit_py.cpp)
target_include_directories(kinit_py PRIVATE include)
target_link_libraries(
kinit_py
PRIVATE ${FILE_SYS_LIB}
PRIVATE Eigen3::Eigen
PRIVATE ${OpenMP_libomp_LIBRARY}
)
set_target_properties(kinit_py PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_INSTALL_PREFIX})
pybind11_add_module(sogmm_cpu src/pybind/sogmm_cpu.cpp)
target_include_directories(sogmm_cpu PRIVATE include ${EigenRand_SOURCE_DIR})
target_link_libraries(
sogmm_cpu
PRIVATE ${FILE_SYS_LIB}
PRIVATE Eigen3::Eigen
PRIVATE ${OpenMP_libomp_LIBRARY}
PRIVATE nanoflann::nanoflann
)
set_target_properties(sogmm_cpu PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_INSTALL_PREFIX})
# Install
install(TARGETS DESTINATION ${CMAKE_INSTALL_PREFIX})
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION "include/${PROJECT_NAME}"
FILES_MATCHING PATTERN "*.h"
)
install(DIRECTORY cmake/
DESTINATION "share/${PROJECT_NAME}"
FILES_MATCHING PATTERN "*.cmake"
)