-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
105 lines (79 loc) · 3.07 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
cmake_minimum_required(VERSION 3.7)
project(open_simulation_interface)
# read the version number from the file "VERSION"
file(STRINGS "VERSION" VERSION_CONTENTS)
foreach(LINE ${VERSION_CONTENTS})
string(REGEX REPLACE " |\t" "" LINE ${LINE})
string(REGEX MATCH "^[^=]+" VERSION_NAME ${LINE})
string(REPLACE "${VERSION_NAME}=" "" VERSION_VALUE ${LINE})
set(${VERSION_NAME} "${VERSION_VALUE}")
endforeach()
configure_file(osi_version.proto.in ${CMAKE_CURRENT_SOURCE_DIR}/osi_version.proto)
find_package(Protobuf 2.6.1 REQUIRED)
set(OSI_PROTO_FILES
osi_version.proto
osi_common.proto
osi_datarecording.proto
osi_detectedlandmark.proto
osi_detectedlane.proto
osi_detectedobject.proto
osi_detectedoccupant.proto
osi_environment.proto
osi_groundtruth.proto
osi_landmark.proto
osi_lane.proto
osi_lowleveldata.proto
osi_modelinternal.proto
osi_object.proto
osi_occupant.proto
osi_sensordata.proto
osi_sensorspecific.proto
)
protobuf_generate_cpp(PROTO_SRCS PROTO_HEADERS ${OSI_PROTO_FILES})
add_library(${PROJECT_NAME}_static STATIC ${PROTO_SRCS} ${PROTO_HEADERS})
target_include_directories(${PROJECT_NAME}_static
PUBLIC
${PROTOBUF_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(${PROJECT_NAME}_static PUBLIC ${PROTOBUF_LIBRARY})
add_library(${PROJECT_NAME}_obj OBJECT ${PROTO_SRCS} ${PROTO_HEADERS})
target_include_directories(${PROJECT_NAME}_obj
PUBLIC
${PROTOBUF_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
set_property(TARGET ${PROJECT_NAME}_obj PROPERTY POSITION_INDEPENDENT_CODE ON)
add_library(${PROJECT_NAME}_pic STATIC $<TARGET_OBJECTS:${PROJECT_NAME}_obj>)
target_include_directories(${PROJECT_NAME}_pic
PUBLIC
${PROTOBUF_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(${PROJECT_NAME}_pic PUBLIC ${PROTOBUF_LIBRARY})
set_property(TARGET ${PROJECT_NAME}_pic PROPERTY POSITION_INDEPENDENT_CODE ON)
add_library(${PROJECT_NAME} SHARED $<TARGET_OBJECTS:${PROJECT_NAME}_obj>)
target_include_directories(${PROJECT_NAME}
PUBLIC
${PROTOBUF_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(${PROJECT_NAME} PUBLIC ${PROTOBUF_LIBRARY})
# add a target to generate API documentation with Doxygen
# Dependencies: Doxygen and proto2cpp.py
FIND_PACKAGE(Doxygen)
set(FILTER_PROTO2CPP_PY_PATH CACHE PATH "directory to the filter proto2cpp.py")
if(NOT DOXYGEN_FOUND)
message(WARNING "Doxygen could not be found.")
else()
if(NOT EXISTS ${FILTER_PROTO2CPP_PY_PATH}/proto2cpp.py)
message(WARNING "${FILTER_PROTO2CPP_PY_PATH}/proto2cpp.py could not be found.")
else()
set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/doxygen_config.cmake.in)
set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
configure_file(${doxyfile_in} ${doxyfile} @ONLY)
ADD_CUSTOM_TARGET(api_doc ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif(NOT EXISTS ${FILTER_PROTO2CPP_PY_PATH}/proto2cpp.py)
endif(NOT DOXYGEN_FOUND)