-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
121 lines (104 loc) · 4.63 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
cmake_minimum_required(VERSION 3.16...3.27)
set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
set(TARGET_NAME rerun_vrs_example)
project(${TARGET_NAME} LANGUAGES CXX)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
# Rerun:
include(FetchContent)
FetchContent_Declare(rerun_sdk URL https://github.com/rerun-io/rerun/releases/download/0.23.0/rerun_cpp_sdk.zip)
FetchContent_MakeAvailable(rerun_sdk)
# VRS:
include(FetchContent)
set(BUILD_TOOLS OFF) # VRS tools
set(BUILD_SAMPLES OFF) # VRS sample code and sample apps
FetchContent_Declare(vrslib URL https://github.com/facebookresearch/vrs/archive/refs/tags/v1.1.0.zip)
FetchContent_MakeAvailable(vrslib)
find_package(fmt REQUIRED)
add_executable(${TARGET_NAME} src/main.cpp src/frame_player.cpp src/imu_player.cpp)
target_link_libraries(${TARGET_NAME} rerun_sdk vrslib vrs_utils fmt)
target_include_directories(${TARGET_NAME} PRIVATE src)
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${rerun_sdk_SOURCE_DIR}) # Ignore warnings in Rerun SDK headers
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${vrslib_SOURCE_DIR}) # Ignore warnings in VRS headers
if(MSVC)
# TODO(andreas): Try to enable /Wall
target_compile_options(${TARGET_NAME} PRIVATE /W4)
target_compile_options(${TARGET_NAME} PRIVATE /we4996) # Using deprecated functions is an error
if(BUILD_SHARED_LIBS)
# If we are building as shared libs, we are going to have to disable the C4251
# warning, as it would trigger for any datatype derived from a STL class
# See also https://github.com/protocolbuffers/protobuf/blob/v26.1/cmake/README.md#notes-on-compiler-warnings
# We need also to make it public, otherwise downstream code will be flooded by c4251 warnings
target_compile_options(${TARGET_NAME} PUBLIC /wd4251)
endif()
# CMAKE_COMPILE_WARNING_AS_ERROR is only directly supported starting in CMake `3.24`
# https://cmake.org/cmake/help/latest/prop_tgt/COMPILE_WARNING_AS_ERROR.html
if(CMAKE_COMPILE_WARNING_AS_ERROR)
target_compile_options(${TARGET_NAME} PRIVATE /WX
/w15038 # Initialization order. https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5038
)
endif()
else()
# Enabled warnings.
target_compile_options(${TARGET_NAME} PRIVATE
-Wall
-Wcast-align
-Wcast-qual
-Wdeprecated
-Wdeprecated-declarations
-Wextra
-Wformat=2
-Wmissing-include-dirs
-Wnull-dereference
-Wold-style-cast
-Wpedantic
-Wpointer-arith
-Wshadow
-Wswitch-enum
-Wunreachable-code
-Wvla
)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") # match both "Clang" and "AppleClang"
# TODO(emilk): enable some hardening flags from https://best.openssf.org/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.html
target_compile_options(${TARGET_NAME} PRIVATE
-Wc++17-compat-pedantic
-Wc++20-compat-pedantic
-Wc99-extensions
-Weverything
-Wgnu
-Wnon-gcc
-Wpre-c2x-compat-pedantic
-Wshadow-all
# Turn off some warning that -Weverything turns on:
-Wno-c++98-compat
-Wno-c++98-compat-pedantic
-Wno-covered-switch-default # We often add a `default:` case out of paranoia
-Wno-ctad-maybe-unsupported
-Wno-disabled-macro-expansion
-Wno-documentation
-Wno-documentation-unknown-command
-Wno-double-promotion # float->double is nothing to whine about
-Wno-exit-time-destructors
-Wno-float-equal # comparing floats is fine
-Wno-global-constructors
-Wno-missing-prototypes
-Wno-padded
-Wno-reserved-id-macro
-Wno-reserved-identifier
-Wno-unused-macros
-Wno-unsafe-buffer-usage # Not sure why we need this, but we do.
-Wno-unknown-warning-option # Otherwise older clang will complain about `-Wno-unsafe-buffer-usage`
)
endif()
# CMAKE_COMPILE_WARNING_AS_ERROR is only directly supported starting in CMake `3.24`
# https://cmake.org/cmake/help/latest/prop_tgt/COMPILE_WARNING_AS_ERROR.html
if(CMAKE_COMPILE_WARNING_AS_ERROR)
target_compile_options(${TARGET_NAME} PRIVATE -Werror)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
# Improve stack traces:
target_compile_options(${TARGET_NAME} PRIVATE -g -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-optimize-sibling-calls)
endif()
endif()