-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
168 lines (142 loc) · 5.01 KB
/
CMakeLists.txt
File metadata and controls
168 lines (142 loc) · 5.01 KB
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
cmake_minimum_required(VERSION 3.24.1 FATAL_ERROR)
project(mp4writer VERSION 0.1.0)
# Configure version header
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/src/spatialmp4/version.h.in
${CMAKE_CURRENT_BINARY_DIR}/include/spatialmp4/version.h
@ONLY
)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic-functions")
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
option(BUILD_ANDROID "whether build for android" OFF)
option(BUILD_TESTING "whether build unit test" ON)
option(BUILD_PYTHON "whether build python bindings" ON)
if(BUILD_ANDROID)
message(FATAL_ERROR "Don't support android building.")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fPIC -DEIGEN_MPL2_ONLY")
set(WITH_OPENGL OFF CACHE BOOL "disable opengl" FORCE)
include(cmake/ffmpeg_local.cmake)
# include(cmake/opencv_host.cmake)
# include(cmake/spdlog.cmake)
# include(cmake/fmt.cmake)
# include(cmake/eigen.cmake)
# include(cmake/sophus.cmake)
if(BUILD_PYTHON)
include(cmake/pybind11.cmake)
endif()
set(SRC
# ./src/spatialmp4/utilities/RgbdUtils.cc
# ./src/spatialmp4/utilities/OpencvUtils.cc
# ./src/spatialmp4/utils.cc
# ./src/spatialmp4/reader.cc
./src/mp4writer/write.cc
)
add_library(${CMAKE_PROJECT_NAME}_lib STATIC ${SRC})
target_include_directories(${CMAKE_PROJECT_NAME}_lib PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}/include
)
if(EXISTS $ENV{CONDA_PREFIX}/lib)
link_directories($ENV{CONDA_PREFIX}/lib)
endif()
target_link_libraries(${CMAKE_PROJECT_NAME}_lib PUBLIC
PkgConfig::LIBAV
# PkgConfig::OpenCV
# spdlog
# fmt::fmt
# Eigen3::Eigen
# sophus
)
# On newer versions of macOS (>=10.15) and with newer compilers,
# filesystem is part of the standard library and doesn't need explicit linking
if(UNIX AND NOT APPLE)
target_link_libraries(${CMAKE_PROJECT_NAME}_lib PRIVATE stdc++fs)
endif()
# Add macOS framework linking
if(APPLE)
message(STATUS "build mac os framework linking.")
set_target_properties(${CMAKE_PROJECT_NAME}_lib PROPERTIES
INSTALL_RPATH "@loader_path"
BUILD_WITH_INSTALL_RPATH TRUE
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/python
)
# Find macOS frameworks
find_library(FOUNDATION_FRAMEWORK Foundation)
find_library(AUDIOTOOLBOX_FRAMEWORK AudioToolbox)
find_library(COREAUDIO_FRAMEWORK CoreAudio)
find_library(AVFOUNDATION_FRAMEWORK AVFoundation)
find_library(COREVIDEO_FRAMEWORK CoreVideo)
find_library(COREMEDIA_FRAMEWORK CoreMedia)
find_library(COREGRAPHICS_FRAMEWORK CoreGraphics)
find_library(OPENGL_FRAMEWORK OpenGL)
find_library(APPLICATIONSERVICES_FRAMEWORK ApplicationServices)
find_library(COREFOUNDATION_FRAMEWORK CoreFoundation)
find_library(APPKIT_FRAMEWORK AppKit)
find_library(CARBON_FRAMEWORK Carbon)
find_library(METAL_FRAMEWORK Metal)
find_library(VIDEOTOOLBOX_FRAMEWORK VideoToolbox)
find_library(COREIMAGE_FRAMEWORK CoreImage)
find_library(CORESERVICES_FRAMEWORK CoreServices)
find_library(SECURITY_FRAMEWORK Security)
if(NOT COREAUDIO_FRAMEWORK)
message(FATAL_ERROR "Foundation framework not found")
endif()
# target_link_libraries(${CMAKE_PROJECT_NAME}_lib PUBLIC
# "-framework Foundation"
# "-framework AudioToolbox"
# "-framework CoreAudio"
# "-framework AVFoundation"
# "-framework CoreVideo"
# "-framework CoreMedia"
# "-framework CoreGraphics"
# "-framework OpenGL"
# "-framework ApplicationServices"
# "-framework CoreFoundation"
# "-framework AppKit"
# "-framework Carbon"
# "-framework Metal"
# "-framework VideoToolbox"
# "-framework CoreImage"
# "-framework CoreServices"
# "-framework Security"
# )
endif()
if(BUILD_TESTING)
# include(cmake/gtest.cmake)
# add_executable(test_reader
# ${SRC}
# ./src/spatialmp4/utilities/RgbdUtils.cc
# ./src/spatialmp4/utilities/PointcloudUtils.cc
# ./src/spatialmp4/reader_test.cc
# )
# target_link_libraries(test_reader PUBLIC
# gtest
# gtest_main
# ${CMAKE_PROJECT_NAME}_lib
# )
add_executable(test_writer
./src/mp4writer/main.cc
)
target_link_libraries(test_writer PUBLIC
${CMAKE_PROJECT_NAME}_lib
)
# On newer versions of macOS (>=10.15) and with newer compilers,
# filesystem is part of the standard library and doesn't need explicit linking
if(UNIX AND NOT APPLE)
target_link_libraries(test_reader PRIVATE stdc++fs)
endif()
endif()
if(BUILD_PYTHON)
add_subdirectory(bindings)
endif()
if (APPLE)
set_target_properties(${CMAKE_PROJECT_NAME}_lib PROPERTIES INSTALL_RPATH "@loader_path")
else()
set_target_properties(${CMAKE_PROJECT_NAME}_lib PROPERTIES INSTALL_RPATH "\$ORIGIN")
endif()
install(TARGETS ${CMAKE_PROJECT_NAME}_lib DESTINATION lib)