-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
56 lines (47 loc) · 2.3 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
# Check CMake version.
cmake_minimum_required(VERSION 3.16)
# Define projects.
project(HyperVariables VERSION 23.01.19 DESCRIPTION "" HOMEPAGE_URL https://github.com/VIS4ROB-lab/HyperVariables LANGUAGES CXX)
# Set properties.
if (PROJECT_IS_TOP_LEVEL)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -march=native -Wall -Wextra -Wnon-virtual-dtor -pedantic")
option(HYPER_BUILD_WITH_CERES "Build with Ceres." FALSE)
option(HYPER_BUILD_TESTS "Build tests." TRUE)
endif ()
# Define libraries and aliases.
file(GLOB_RECURSE PROJECT_SOURCE_FILES CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/include/*.hpp ${PROJECT_SOURCE_DIR}/internal/*.cpp)
add_library(${PROJECT_NAME} SHARED ${PROJECT_SOURCE_FILES})
add_library(Hyper::Variables ALIAS ${PROJECT_NAME})
# Find Eigen target if not present.
if (NOT TARGET Eigen3::Eigen)
find_package(Eigen3 REQUIRED NO_MODULE)
endif ()
# Find GTest target if not present.
if (NOT TARGET GTest::GTest)
find_package(GTest REQUIRED)
endif ()
# Find GTest target if not present.
if (NOT TARGET glog::glog)
find_package(glog REQUIRED)
endif ()
if (HYPER_BUILD_WITH_CERES)
# Find Ceres target if not present.
if (NOT TARGET Ceres::ceres)
find_package(Ceres REQUIRED)
endif ()
# Add includes and link libraries.
target_compile_definitions(${PROJECT_NAME} PUBLIC HYPER_COMPILE_WITH_CERES EIGEN_MATRIXBASE_PLUGIN="${PROJECT_SOURCE_DIR}/plugins/matrix_base_plugin.hpp")
target_include_directories(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_link_libraries(${PROJECT_NAME} PUBLIC Ceres::ceres PUBLIC Eigen3::Eigen PUBLIC glog::glog PUBLIC GTest::GTest)
else ()
# Add includes and link libraries.
target_compile_definitions(${PROJECT_NAME} PUBLIC EIGEN_MATRIXBASE_PLUGIN="${PROJECT_SOURCE_DIR}/plugins/matrix_base_plugin.hpp")
target_include_directories(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_link_libraries(${PROJECT_NAME} PUBLIC Eigen3::Eigen PUBLIC glog::glog PUBLIC GTest::GTest)
endif ()
# Build tests.
if (HYPER_BUILD_TESTS)
add_subdirectory(${PROJECT_SOURCE_DIR}/apps/tests)
endif (HYPER_BUILD_TESTS)