-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
83 lines (68 loc) · 2.61 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
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
# Project
project(pycluon LANGUAGES CXX)
# Fetch CPM
set(CPM_DOWNLOAD_VERSION 0.32.0)
set(CPM_DOWNLOAD_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(STATUS "Downloading CPM.cmake v${CPM_DOWNLOAD_VERSION}")
file(DOWNLOAD https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake ${CPM_DOWNLOAD_LOCATION})
endif()
include(${CPM_DOWNLOAD_LOCATION})
# Add dependencies
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
CPMAddPackage(
NAME cluon
GITHUB_REPOSITORY chrberger/libcluon
VERSION 0.0.145
SOURCE_SUBDIR libcluon
EXCLUDE_FROM_ALL YES
GIT_SHALLOW YES
SKIP_TESTS 1
)
CPMAddPackage(
NAME pybind11
GITHUB_REPOSITORY pybind/pybind11
GIT_TAG v2.10.4
)
# Create executable
pybind11_add_module(${PROJECT_NAME} src/pycluon.cpp)
target_include_directories(${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
# cluon specific inludes
${cluon_SOURCE_DIR}/libcluon/include
${cluon_SOURCE_DIR}/libcluon/thirdparty
${cluon_SOURCE_DIR}/libcluon/tools
${CMAKE_CURRENT_BINARY_DIR}/include # libcluon "built-in" message specifications
)
target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads cluon-static)
if(UNIX)
if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
target_link_libraries(${PROJECT_NAME} PRIVATE rt)
endif()
endif()
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME _pycluon)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED true)
add_dependencies(${PROJECT_NAME} cluon-msc)
add_dependencies(${PROJECT_NAME} cluon-OD4toStdout)
add_dependencies(${PROJECT_NAME} cluon-OD4toJSON)
add_dependencies(${PROJECT_NAME} cluon-LCMtoJSON)
add_dependencies(${PROJECT_NAME} cluon-filter)
add_dependencies(${PROJECT_NAME} cluon-livefeed)
add_dependencies(${PROJECT_NAME} cluon-rec2csv)
add_dependencies(${PROJECT_NAME} cluon-replay)
install(TARGETS ${PROJECT_NAME} DESTINATION pycluon)
install(TARGETS cluon-msc DESTINATION pycluon/bin)
install(TARGETS cluon-OD4toStdout DESTINATION pycluon/bin)
install(TARGETS cluon-OD4toJSON DESTINATION pycluon/bin)
install(TARGETS cluon-LCMtoJSON DESTINATION pycluon/bin)
install(TARGETS cluon-filter DESTINATION pycluon/bin)
install(TARGETS cluon-livefeed DESTINATION pycluon/bin)
install(TARGETS cluon-rec2csv DESTINATION pycluon/bin)
install(TARGETS cluon-replay DESTINATION pycluon/bin)
install(
FILES ${cluon_SOURCE_DIR}/libcluon/resources/cluonDataStructures.odvd
RENAME cluon_data_structures.odvd
DESTINATION pycluon/resources)