-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
153 lines (131 loc) · 5.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
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
cmake_minimum_required(VERSION 3.10)
include(GNUInstallDirs)
#project setting
project(cyber)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-I")
set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-I" CACHE STRING "" FORCE )
#set(CMAKE_INCLUDE_SYSTEM_FLAG_CUDA "-I" CACHE STRING "" FORCE )
set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O0 -Wall")
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fPIC -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fPIC -std=c++11")
enable_language(ASM)
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "core2-64")
set(SWAP_SRCS "${PROJECT_SOURCE_DIR}/cyber/croutine/detail/swap_x86_64.S")
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
set(SWAP_SRCS "${PROJECT_SOURCE_DIR}/cyber/croutine/detail/swap_aarch64.S")
else()
message(FATAL_ERROR "Can not set swap source file, your processor is: " ${CMAKE_SYSTEM_PROCESSOR})
return()
endif()
#include dependencies
include(cmake/Dependencies.cmake)
#build proto files
# add_subdirectory(cyber/proto)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/generate_proto.sh ${CMAKE_CURRENT_SOURCE_DIR}/cyber/proto)
execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/generate_proto.sh ${CMAKE_CURRENT_SOURCE_DIR}/cyber/examples/proto)
#collect source files
file(GLOB CYBER_SRCS
"${PROJECT_SOURCE_DIR}/cyber/base/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/blocker/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/class_loader/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/class_loader/*/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/common/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/component/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/croutine/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/croutine/*/*.cc"
"${SWAP_SRCS}"
"${PROJECT_SOURCE_DIR}/cyber/data/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/event/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/event/*.h"
"${PROJECT_SOURCE_DIR}/cyber/io/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/logger/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/message/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/node/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/parameter/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/record/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/record/*/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/scheduler/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/scheduler/*/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/service/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/service_discovery/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/service_discovery/*/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/task/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/time/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/timer/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/transport/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/transport/*/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/sysmo/*.cc"
"${PROJECT_SOURCE_DIR}/cyber/proto/*.cc"
)
set(CYBER_TEST_SRCS ${CYBER_SRCS})
list(FILTER CYBER_TEST_SRCS INCLUDE REGEX .*test[.]cc )
list(FILTER CYBER_SRCS EXCLUDE REGEX .*test[.]cc )
#include_directories
include_directories(${PROJECT_BINARY_DIR})
#build cyber library
add_library(cyber SHARED ${CYBER_SRCS})
#target_link_libraries(cyber cyber_proto atomic fastrtps fastcdr dl rt tinyxml2 glog gflags PocoFoundation uuid pthread)
target_link_libraries(cyber protobuf atomic fastrtps fastcdr dl rt tinyxml2 glog gflags PocoFoundation uuid pthread)
#build mainboard
file(GLOB CYBER_MAINBOARD_SRCS "${PROJECT_SOURCE_DIR}/cyber/mainboard/*.cc")
add_executable(mainboard ${CYBER_MAINBOARD_SRCS})
target_link_libraries(mainboard cyber)
target_compile_options(mainboard PRIVATE -Og)
#build examples
add_subdirectory(cyber/examples)
#TODO:to solve py_wrapper compile error
#build python wrapper
add_subdirectory(cyber/python)
#build tools
add_subdirectory(cyber/tools)
# proto path
# include_directories(${PROJECT_SOURCE_DIR}/models/common/proto)
# include_directories(${PROJECT_SOURCE_DIR}/modules/proto)
# include_directories(${PROJECT_SOURCE_DIR}/modules/common/proto)
# ADD_CUSTOM_COMMAND(
# OUTPUT "${proto_file_name}.pb.h" "${proto_file_name}.pb.cc"
# COMMAND protoc --proto_path=${PROJECT_SOURCE_DIR}
# --cpp_out=${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/models/common/proto/*.proto
# )
# ADD_CUSTOM_COMMAND(
# OUTPUT "${proto_file_name}.pb.h" "${proto_file_name}.pb.cc"
# COMMAND protoc --proto_path=${PROJECT_SOURCE_DIR}
# --cpp_out=${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/models/proto/*.proto
# )
# ADD_CUSTOM_COMMAND(
# OUTPUT "${proto_file_name}.pb.h" "${proto_file_name}.pb.cc"
# COMMAND protoc --proto_path=${PROJECT_SOURCE_DIR}
# --cpp_out=${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/models/proto/*.proto
# )
# add_subdirectory(modules)
add_subdirectory(modules/common)
# add_subdirectory(modules/map)
# add_subdirectory(modules/perception)
#build tests
# FOREACH(TEST_FILE ${CYBER_TEST_SRCS})
# string( REGEX MATCH "[A-Za-z0-9_]*[.]cc" FILE_NAME ${TEST_FILE} )
# string( REGEX MATCH "[A-Za-z0-9_]*" TARGET_NAME ${FILE_NAME})
# list(APPEND TEST_TARGETS ${TARGET_NAME})
# add_executable(${TARGET_NAME} ${TEST_FILE})
# target_link_libraries(${TARGET_NAME} cyber gflags glog gmock_main gmock gtest)
# target_compile_options(${TARGET_NAME} PRIVATE -Og)
# ENDFOREACH(TEST_FILE)
#install
install(TARGETS cyber mainboard
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
#install(TARGETS ${TEST_TARGETS} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}/cyber/test)
install(DIRECTORY cyber DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${PROJECT_BINARY_DIR}/cyber DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h")
install(DIRECTORY cyber/conf DESTINATION ${CMAKE_INSTALL_BINDIR}/cyber)
install(FILES cyber/setup.bash DESTINATION ${CMAKE_INSTALL_BINDIR}/cyber)
install(DIRECTORY cyber/python DESTINATION ${CMAKE_INSTALL_BINDIR}/cyber)