-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
86 lines (72 loc) · 3.09 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
# Works with 3.11 and tested through 3.19
cmake_minimum_required(VERSION 3.11...3.19)
set(CMAKE_BUILD_TYPE Release)
#set(CMAKE_BUILD_TYPE Debug)
# Project name and a few useful settings. Other commands can pick up the results
project(
AMoD2
DESCRIPTION "An agent-based modeling platform for mobility-on-demand simulations"
LANGUAGES CXX)
########################################################################
# Find External Packages
########################################################################
if (CMAKE_HOST_APPLE)
set(MACOS 1)
elseif (CMAKE_HOST_UNIX)
set(LINUX 1)
endif ()
# Define the path to cmake files
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# Define the path to gurobi library
# if Gurobi directory/version is different, manually change the directory to Gurobi in set(GUROBI_DIR ...) (line 30/33)
# and term "gurobi91" in target_link_libraries(mod-abm-lib ... gurobi91) (line 53).
if (MACOS)
MESSAGE(STATUS "operation system is MacOs (${CMAKE_SYSTEM})")
set(GUROBI_DIR /Library/gurobi912/mac64)
elseif (LINUX)
MESSAGE(STATUS "operation system is Linux (${CMAKE_SYSTEM})")
set(GUROBI_DIR /Library/gurobi912/linux64)
endif ()
# path to: "gurobi_c++.h"
include_directories(${GUROBI_DIR}/include)
# path to: the Gurobi C++ library "libgurobi_c++.a"
# and the Gurobi C library "libgurobi91.dylib(Mac OS) / libgurobi91.so(Linux)"
link_directories(${GUROBI_DIR}/lib)
# Find all required libraries
find_package(Boost 1.52.0 COMPONENTS filesystem system thread iostreams chrono date_time regex REQUIRED)
########################################################################
# Define Libraries and Executable
########################################################################
include_directories(SYSTEM src)
# The libraries
add_library(mod-abm-lib src/simulator/config.cpp src/simulator/demand_generator.cpp src/simulator/router.cpp
src/simulator/vehicle.cpp src/utility/utility_functions.cpp src/dispatcher/scheduling.cpp
src/dispatcher/ilp_assign.cpp)
target_link_libraries(mod-abm-lib yaml-cpp fmt::fmt gurobi_c++ gurobi91)
target_compile_features(mod-abm-lib PRIVATE cxx_std_17)
# The executable
add_executable(main src/main.cpp)
target_link_libraries(main mod-abm-lib)
target_compile_features(main PRIVATE cxx_std_17)
add_executable(test src/test.cpp)
target_link_libraries(test mod-abm-lib)
target_compile_features(test PRIVATE cxx_std_17)
########################################################################
# Fetch Other Third-Party Libraries
########################################################################
# Third-party libraries
include(FetchContent)
include(ExternalProject)
# Add fmt::fmt
FetchContent_Declare(
fmtlib
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 5.3.0)
FetchContent_MakeAvailable(fmtlib)
# At least cmake 3.11.0 (sometimes the error message says 3.14.5) is needed to support CMake command "FetchContent_MakeAvailable".
# Add YAML
FetchContent_Declare(
yaml-cpp
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
GIT_TAG yaml-cpp-0.6.3)
FetchContent_MakeAvailable(yaml-cpp)