-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
75 lines (62 loc) · 2.8 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
cmake_minimum_required(VERSION 3.0)
project(mrta_cpp)
# option(CXX "enable C++ compilation" ON)
# Enforce C++-standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Force Release build if nothing was specified
if((NOT CMAKE_BUILD_TYPE) OR (CMAKE_BUILD_TYPE STREQUAL ""))
set(CMAKE_BUILD_TYPE
"Release" CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel ..."
FORCE)
endif((NOT CMAKE_BUILD_TYPE) OR (CMAKE_BUILD_TYPE STREQUAL ""))
# Special behavior if debug builds were chosen
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
# Enable Asan by default
set(ASAN_COMPILER_FLAGS " -fsanitize=address -fno-optimize-sibling-calls -fno-omit-frame-pointer")
set(ASAN_LINKER_FLAGS " -fsanitize=address")
string(APPEND CMAKE_C_FLAGS_DEBUG ${ASAN_COMPILER_FLAGS})
string(APPEND CMAKE_CXX_FLAGS_DEBUG ${ASAN_COMPILER_FLAGS})
string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO ${ASAN_COMPILER_FLAGS})
string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO ${ASAN_COMPILER_FLAGS})
set(CMAKE_EXE_LINKER_FLAGS_DEBUG ${ASAN_LINKER_FLAGS})
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG ${ASAN_LINKER_FLAGS})
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG ${ASAN_LINKER_FLAGS})
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO ${ASAN_LINKER_FLAGS})
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO ${ASAN_LINKER_FLAGS})
set(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO ${ASAN_LINKER_FLAGS})
endif(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
# Standard include directory
include_directories(${CMAKE_SOURCE_DIR})
find_package (nlohmann_json REQUIRED NO_MODULE)
# (Should be Optional)
find_package (Eigen3 REQUIRED)
include_directories(${EIGEN_INCLUDE_DIR})
# (Should be Optional)
# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# find_package(GUROBI REQUIRED)
# include_directories(${GUROBI_INCLUDE_DIRS})
# link_libraries(${GUROBI_CXX_LIBRARY} ${GUROBI_LIBRARY})
include_directories(
utilities/include
interface/include
solvers/include
${catkin_INCLUDE_DIRS}
)
# Compile the code
add_subdirectory(utilities)
add_subdirectory(interface)
add_subdirectory(solvers)
add_subdirectory(usage_example)
install(TARGETS mrta_utilities mrta_interface mrta_solvers
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
# Specify the headers to be installed
install(DIRECTORY utilities/include/ DESTINATION include)
install(DIRECTORY interface/include/ DESTINATION include)
install(DIRECTORY solvers/include/ DESTINATION include)
install(FILES ${CMAKE_CURRENT_LIST_DIR}/cmake/mrta_cppConfig.cmake DESTINATION share/mrta_cpp/cmake)