-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
87 lines (69 loc) · 2.54 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
cmake_minimum_required(VERSION 3.20)
project(optim)
# Include FetchContent functionality to get repos from git and set it to verbose
# This simplifies manual downloading and setting paths to GIT_REPOSITORY
include(FetchContent)
set(FETCHCONTENT_QUIET FALSE)
##########################################
# Threads are found automagically
find_package(Threads REQUIRED)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Eigen3 QUIET)
################################################################
# Fetch libraries
#FetchContent_Declare(gflags
# GIT_REPOSITORY https://github.com/gflags/gflags.git
# GIT_TAG v2.2.2
# GIT_PROGRESS TRUE
#)
set(WITH_GFLAGS FALSE)
set(WITH_GMOCK FALSE)
set(BUILD_EXAMPLES FALSE)
set(MINIGLOG TRUE)
#FetchContent_Declare(google-glog
# GIT_REPOSITORY https://github.com/google/glog.git
# GIT_TAG v0.7.0
## GIT_PROGRESS TRUE
#)
#FetchContent_GetProperties(glog)
#if (NOT glog_POPULATED)
# FetchContent_Populate(glog)
# set(WITH_GFLAGS OFF CACHE BOOL "we don't use gflags")
# add_subdirectory(${glog_SOURCE_DIR} ${glog_BINARY_DIR})
#endif ()
# Depends on google-glog
FetchContent_Declare(ceres
GIT_REPOSITORY https://ceres-solver.googlesource.com/ceres-solver
GIT_TAG 2.2.0
GIT_PROGRESS TRUE
)
#FetchContent_MakeAvailable(gflags)
#FetchContent_MakeAvailable(google-glog)
#add_subdirectory(${glog_SOURCE_DIR} ${CMAKE_BINARY_DIR}/glog-build)
FetchContent_MakeAvailable(ceres)
################################################################
### SET C++17 STANDARD
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
### SET WARNINGS
if (MSVC)
# Enable all, but warning C4127: conditional expression is constant
# (https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-4-c4127?view=msvc-160)
add_compile_options(/W4 /wd4127)
else()
add_compile_options(-Wall -Wextra -pedantic)
endif()
add_executable(ceres_example_1 source/example1/main.cpp)
target_link_libraries(ceres_example_1 PRIVATE ceres)
add_executable(ceres_example_2 source/example2/main.cpp)
target_link_libraries(ceres_example_2 PRIVATE ceres)
add_executable(ceres_example_3 source/example3/main.cpp)
target_link_libraries(ceres_example_3 PRIVATE ceres)
add_executable(simplex_example_4 source/example4/main.cpp)
target_include_directories(simplex_example_4 PRIVATE include)
if (Eigen3_FOUND)
add_executable(example_5_eigen source/example5/main.cpp)
target_link_libraries(example_5_eigen PRIVATE Eigen3::Eigen)
else()
message(STATUS "Eigen not found. Skipping Eigen-dependent examples.")
endif()