-
Notifications
You must be signed in to change notification settings - Fork 14
/
CMakeLists.txt
98 lines (80 loc) · 2.91 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
cmake_minimum_required(VERSION 3.18)
project(ga_nmpc_tuning
VERSION 0.0.1
LANGUAGES CXX
)
set(PROJECT_ALIAS "gnt")
option(BUILD_TESTS "Build the tests" ON)
option(BUILD_BENCHMARK "Build benchmark binaries" OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_compile_options(-w -fPIC)
if(NOT BUILD_BENCHMARK)
add_compile_definitions(NBENCHMARK)
endif()
# ---------------------------------------------------------------------------------------
# Set default build to release
# ---------------------------------------------------------------------------------------
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose Release or Debug" FORCE)
endif()
message(STATUS "Generating with build type: ${CMAKE_BUILD_TYPE}")
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/data)
# ---------------------------------------------------------------------------------------
# Requirements
# ---------------------------------------------------------------------------------------
find_package(PkgConfig REQUIRED)
pkg_check_modules(CPPAD REQUIRED cppad)
pkg_check_modules(IPOPT REQUIRED ipopt)
add_subdirectory(third_party/jsoncpp)
add_subdirectory(third_party/yaml-cpp)
add_subdirectory(third_party/googletest)
add_subdirectory(third_party/google-benchmark)
include_directories(
third_party/Eigen-3.3
include
)
link_libraries(
${IPOPT_LIBRARIES}
${CPPAD_LIBRARIES}
yaml-cpp
jsoncpp_lib
)
# Library source files
set(SOURCE_FILES
include/utils/config_handler.hpp
include/utils/json_logger.hpp
include/utils/progress_bar.hpp
src/mpc_lib/mpc.cpp
src/model/differential_drive.cpp
src/model/base_organism.cpp
src/genetic_algorithm/core.cpp
src/genetic_algorithm/operators.cpp
src/genetic_algorithm/organism.cpp
src/genetic_algorithm/fitness.cpp
src/genetic_algorithm/population.cpp
)
# Project library
add_library(${PROJECT_ALIAS} STATIC ${SOURCE_FILES})
# ---------------------------------------------------------------------------------------
# Project targets
# ---------------------------------------------------------------------------------------
macro(project_add_target TARGETNAME)
add_executable(${TARGETNAME} ${ARGN})
target_link_libraries(${TARGETNAME} ${PROJECT_ALIAS})
endmacro(project_add_target)
project_add_target(mpc_mono src/mpc_mono.cpp)
project_add_target(hone_weights src/hone_weights.cpp)
# ---------------------------------------------------------------------------------------
# Testing
# ---------------------------------------------------------------------------------------
if(BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
# ---------------------------------------------------------------------------------------
# Benchmarking
# ---------------------------------------------------------------------------------------
if(BUILD_BENCHMARK)
add_subdirectory(benchmark)
endif()