-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
57 lines (46 loc) · 1.9 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
# Check CMake version.
cmake_minimum_required(VERSION 3.16)
# Includes.
include(FetchContent)
# Define projects.
project(HyperState VERSION 23.01.19 DESCRIPTION "" HOMEPAGE_URL https://github.com/VIS4ROB-lab/HyperState 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 -fconcepts -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}/internal/*.hpp ${PROJECT_SOURCE_DIR}/internal/*.cpp)
add_library(${PROJECT_NAME} SHARED ${PROJECT_SOURCE_FILES})
add_library(Hyper::State ALIAS ${PROJECT_NAME})
# Fetch (external) content.
FetchContent_Declare(HyperVariables GIT_REPOSITORY https://github.com/VIS4ROB-lab/HyperVariables.git GIT_TAG b93a79f0e42fa1b11cc0e7233247aeb465e32dd1)
FetchContent_MakeAvailable(HyperVariables)
# 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 glog 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 ()
endif ()
# Add includes and link libraries.
target_include_directories(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_link_libraries(${PROJECT_NAME} PUBLIC Hyper::Variables)
# Build tests.
if (HYPER_BUILD_TESTS)
add_subdirectory(${PROJECT_SOURCE_DIR}/apps/tests)
endif (HYPER_BUILD_TESTS)