-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
232 lines (200 loc) · 7.51 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
cmake_minimum_required(VERSION 3.1)
project (pyesmini)
include(ExternalProject)
include(FetchContent)
############## esmini ##############
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/esmini")
FetchContent_Declare(
esmini
GIT_REPOSITORY https://github.com/esmini/esmini.git
GIT_TAG a75bb2b52bdb6ddd8a033be8ba1eb94bed044c3e # master
)
FetchContent_GetProperties(esmini)
if(NOT esmini_POPULATED)
FetchContent_Populate(esmini)
endif()
message(STATUS "esmini-python: esmini downloaded")
add_subdirectory(${esmini_SOURCE_DIR})
else()
add_subdirectory(esmini)
endif()
message(STATUS "SCENARIOENGINE_INCLUDE_DIRS: ${SCENARIOENGINE_INCLUDE_DIRS}")
message(STATUS "ROADMANAGER_INCLUDE_DIR: ${ROADMANAGER_INCLUDE_DIR}")
message(STATUS "VIEWER_BASE_INCLUDE_DIR: ${VIEWER_BASE_INCLUDE_DIR}")
message(STATUS "PLAYER_BASE_INCLUDE_DIR: ${PLAYER_BASE_INCLUDE_DIR}")
message(STATUS "CONTROLLERS_INCLUDE_DIR: ${CONTROLLERS_INCLUDE_DIR}")
message(STATUS "OSG_INCLUDE_DIR: ${OSG_INCLUDE_DIR}")
message(STATUS "SUMO_INCLUDE_DIR: ${SUMO_INCLUDE_DIR}")
message(STATUS "COMMON_MINI_INCLUDE_DIR: ${COMMON_MINI_INCLUDE_DIR}")
message(STATUS "OSI_INCLUDE_DIR: ${OSI_INCLUDE_DIR}")
message(STATUS "TIME_LIB: ${TIME_LIB}")
message(STATUS "SOCK_LIB: ${SOCK_LIB}")
message(STATUS "OSG_LIBRARIES_PATH: ${OSG_LIBRARIES_PATH}")
message(STATUS "OSI_LIBRARIES_PATH: ${OSI_LIBRARIES_PATH}")
message(STATUS "SUMO_LIBRARIES_PATH: ${SUMO_LIBRARIES_PATH}")
message(STATUS "GTEST_LIBRARIES_PATH: ${GTEST_LIBRARIES_PATH}")
message(STATUS "OSG_LIBRARIES: ${OSG_LIBRARIES}")
message(STATUS "OSI_LIBRARIES: ${OSI_LIBRARIES}")
message(STATUS "SUMO_LIBRARIES: ${SUMO_LIBRARIES}")
message(STATUS "GTEST_LIBRARIES: ${GTEST_LIBRARIES}")
message(STATUS "SCENARIOENGINE_DLL_INCLUDE_DIR: ${SCENARIOENGINE_DLL_INCLUDE_DIR}")
message(STATUS "ROADMANAGER_DLL_INCLUDE_DIR: ${ROADMANAGER_DLL_INCLUDE_DIR}")
message(STATUS "OSI_BASE_DIR: ${OSI_BASE_DIR}")
message(STATUS "PUGIXML_INCLUDE_DIR: ${PUGIXML_INCLUDE_DIR}")
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
############## pybind11 ##############
FetchContent_Declare(
pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG 70a58c577eaf067748c2ec31bfd0b0a614cffba6
)
FetchContent_GetProperties(pybind11)
if(NOT pybind11_POPULATED)
FetchContent_Populate(pybind11)
add_subdirectory(${pybind11_SOURCE_DIR})
message(STATUS "esmini-python: pybind11")
endif()
set(CMAKE_BUILD_TYPE "Release") # https://github.com/microsoft/vcpkg/issues/20237?amp=1
link_directories(${OSG_LIBRARIES_PATH} ${OSI_LIBRARIES_PATH} ${SUMO_LIBRARIES_PATH} ${GTEST_LIBRARIES_PATH} )
include(CheckCXXCompilerFlag)
# Check for standard to use
check_cxx_compiler_flag(-std=c++14 HAVE_FLAG_STD_CXX14)
if(HAVE_FLAG_STD_CXX14)
SET(CXX_STD_FLAG "-std=c++14")
else()
check_cxx_compiler_flag(-std=c++1y HAVE_FLAG_STD_CXX1Y)
if(HAVE_FLAG_STD_CXX1Y)
SET(CXX_STD_FLAG "-std=c++1y")
else()
message ("Need compiler support for c++14 \(or 1y as the beta was called\)")
endif()
endif()
set (CMAKE_C_FLAGS "-std=c11 ${CMAKE_C_FLAGS}")
if(CMAKE_BUILD_TYPE STREQUAL "Release")
SET(CMAKE_CXX_FLAGS "${CXX_STD_FLAG} -pthread -fPIC -Wl,-strip-all")
elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
SET(CMAKE_CXX_FLAGS "${CXX_STD_FLAG} -march=native -O0 -pthread -fPIC")
else()
SET(CMAKE_CXX_FLAGS "${CXX_STD_FLAG} -pthread -fPIC -Wl,-strip-all")
endif()
project(pyesmini)
set(CMAKE_BUILD_TYPE "Release") # https://github.com/microsoft/vcpkg/issues/20237?amp=1
#################### pyplayerbase ####################
pybind11_add_module(pyplayerbase MODULE "${CMAKE_CURRENT_SOURCE_DIR}/src/playerbase/pyplayerbase.cpp")
include_directories(
${SCENARIOENGINE_INCLUDE_DIRS}
${SCENARIOENGINE_INCLUDE_DIR}
${ROADMANAGER_INCLUDE_DIR}
${VIEWER_BASE_INCLUDE_DIR}
${PLAYER_BASE_INCLUDE_DIR}
${CONTROLLERS_INCLUDE_DIR}
${OSG_INCLUDE_DIR}
${SUMO_INCLUDE_DIR}
${COMMON_MINI_INCLUDE_DIR}
${OSI_INCLUDE_DIR}
)
# EXAMPLE_VERSION_INFO is defined by setup.py and passed into the C++ code as a
# define (VERSION_INFO) here.
target_link_libraries(pyplayerbase PRIVATE
ViewerBase
PlayerBase
ScenarioEngine
Controllers
RoadManager
CommonMini
${OSG_LIBRARIES}
${SUMO_LIBRARIES}
${OSI_LIBRARIES}
${viewer_libs}
${osi_libs}
${sumo_libs}
${TIME_LIB}
${SOCK_LIB}
)
target_compile_definitions(pyplayerbase PRIVATE VERSION_INFO=${EXAMPLE_VERSION_INFO})
#################### pyroadmanager ####################
pybind11_add_module(pyroadmanager MODULE "${CMAKE_CURRENT_SOURCE_DIR}/src/roadmanager/pyroadmanager.cpp" ${SCENARIOENGINE_DLL_INCLUDE_DIR}/esminiLib.hpp ${ROADMANAGER_INCLUDE_DIR}/odrSpiral.cpp ${COMMON_MINI_INCLUDE_DIR}/CommonMini.cpp ${COMMON_MINI_INCLUDE_DIR}/buildnr.cpp ${COMMON_MINI_INCLUDE_DIR}/version.cpp ${PUGIXML_INCLUDE_DIR}/pugixml.cpp )
include_directories(${PLAYER_BASE_INCLUDE_DIR} ${SCENARIOENGINE_INCLUDE_DIRS} ${SCENARIOENGINE_INCLUDE_DIR} ${SCENARIOENGINE_DLL_INCLUDE_DIR}/ ${OSI_INCLUDE_DIR} ${OSG_INCLUDE_DIR} ${COMMON_MINI_INCLUDE_DIR} ${ROADMANAGER_INCLUDE_DIR} ${CONTROLLERS_INCLUDE_DIR} ${VIEWER_BASE_INCLUDE_DIR} ${PUGIXML_INCLUDE_DIR})
target_link_libraries(pyroadmanager PRIVATE
ViewerBase
PlayerBase
ScenarioEngine
Controllers
RoadManager
CommonMini
${OSG_LIBRARIES}
${SUMO_LIBRARIES}
${OSI_LIBRARIES}
${viewer_libs}
${osi_libs}
${sumo_libs}
${TIME_LIB}
${SOCK_LIB}
)
target_compile_definitions(pyroadmanager PRIVATE VERSION_INFO=${EXAMPLE_VERSION_INFO})
#################### pyscenarioengine ####################
pybind11_add_module(pyscenarioengine MODULE "${CMAKE_CURRENT_SOURCE_DIR}/src/scenarioengine/pyscenarioengine.cpp"
${SCENARIO_SRCS}
${ROADMANAGER_INCLUDE_DIR}/RoadManager.cpp
${ROADMANAGER_INCLUDE_DIR}/odrSpiral.cpp
${COMMON_MINI_INCLUDE_DIR}/CommonMini.cpp
${COMMON_MINI_INCLUDE_DIR}/buildnr.cpp
${COMMON_MINI_INCLUDE_DIR}/version.cpp
${PUGIXML_INCLUDE_DIR}/pugixml.cpp
)
include_directories(
${SCENARIOENGINE_INCLUDE_DIRS}
${SCENARIOENGINE_INCLUDE_DIR}
${ROADMANAGER_INCLUDE_DIR}
${VIEWER_BASE_INCLUDE_DIR}
${PLAYER_BASE_INCLUDE_DIR}
${CONTROLLERS_INCLUDE_DIR}
${OSG_INCLUDE_DIR}
${SUMO_INCLUDE_DIR}
${COMMON_MINI_INCLUDE_DIR}
${OSI_INCLUDE_DIR}
)
target_link_libraries(pyscenarioengine PRIVATE
ViewerBase
PlayerBase
ScenarioEngine
Controllers
RoadManager
CommonMini
${OSG_LIBRARIES}
${SUMO_LIBRARIES}
${OSI_LIBRARIES}
${viewer_libs}
${osi_libs}
${sumo_libs}
${TIME_LIB}
${SOCK_LIB}
)
target_compile_definitions(pyscenarioengine PRIVATE VERSION_INFO=${EXAMPLE_VERSION_INFO})
#################### pyviewerbase ####################
pybind11_add_module(pyviewerbase MODULE "${CMAKE_CURRENT_SOURCE_DIR}/src/viewerbase/pyviewerbase.cpp"
${ROADMANAGER_INCLUDE_DIR}/RoadManager.cpp
${ROADMANAGER_INCLUDE_DIR}/odrSpiral.cpp
${COMMON_MINI_INCLUDE_DIR}/buildnr.cpp
${COMMON_MINI_INCLUDE_DIR}/version.cpp
${PUGIXML_INCLUDE_DIR}/pugixml.cpp
)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-DOSG_LIBRARY_STATIC ) # -D_SCENARIO_VIEWER
target_link_libraries(pyviewerbase PRIVATE
ViewerBase
PlayerBase
ScenarioEngine
Controllers
RoadManager
CommonMini
${OSG_LIBRARIES}
${SUMO_LIBRARIES}
${OSI_LIBRARIES}
${viewer_libs}
${osi_libs}
${sumo_libs}
${TIME_LIB}
${SOCK_LIB}
)
target_compile_definitions(pyviewerbase PRIVATE VERSION_INFO=${EXAMPLE_VERSION_INFO})