-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
130 lines (114 loc) · 3.25 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
# Copyright 2023 ICUBE Laboratory, University of Strasbourg
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Author: Thibault Poignonec ([email protected])
cmake_minimum_required(VERSION 3.11)
project(fd_sdk_vendor)
set(FD_SDK_VERSION "3.16.1")
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17) # Default to C++17
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
find_package(PkgConfig REQUIRED)
pkg_check_modules(libusb REQUIRED libusb-1.0)
find_package(ament_cmake REQUIRED)
include(FetchContent)
# Downdload SDK binaries
#------------------------
fetchcontent_declare(
fd_sdk_binaries
URL https://downloads.forcedimension.com/sdk/sdk-${FD_SDK_VERSION}-linux-x86_64-gcc.tar.gz
)
fetchcontent_makeavailable(fd_sdk_binaries)
# Set DHD and DRD library paths
#-------------------------------
string(REPLACE "." ";" VERSION_SDK_LIST ${FD_SDK_VERSION})
list(GET VERSION_SDK_LIST 0 VERSION_SDK_MAJOR)
set(
dhd_LIBS
${fd_sdk_binaries_SOURCE_DIR}/lib/release/lin-x86_64-gcc/libdhd.so.${FD_SDK_VERSION}
)
set(
drd_LIBS
${fd_sdk_binaries_SOURCE_DIR}/lib/release/lin-x86_64-gcc/libdrd.so.${FD_SDK_VERSION}
)
# Setup vendor library
#----------------------
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${fd_sdk_binaries_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(
${PROJECT_NAME} INTERFACE
${CMAKE_INSTALL_PREFIX}/lib/libdhd.so.${VERSION_SDK_MAJOR}
${CMAKE_INSTALL_PREFIX}/lib/libdrd.so.${VERSION_SDK_MAJOR}
${libusb-1.0_LIBRARIES}
)
# Testing
#----------
if(BUILD_TESTING)
find_package(ament_cmake_test REQUIRED)
find_package(ament_lint_auto REQUIRED)
set(ament_cmake_copyright_FOUND TRUE)
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
find_package(ament_cmake_gtest REQUIRED)
ament_add_gtest(
test_dhd
test/test_dhd.cpp
test/test_drd.cpp
)
target_include_directories(
test_dhd
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${fd_sdk_binaries_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(test_dhd
${dhd_LIBS}
${drd_LIBS}
${libusb-1.0_LIBRARIES}
)
endif()
# Install
#----------
install(
DIRECTORY ${fd_sdk_binaries_SOURCE_DIR}/include
DESTINATION .
)
install(
DIRECTORY include/${PROJECT_NAME}
DESTINATION include
)
install(
FILES ${dhd_LIBS}
DESTINATION lib
RENAME libdhd.so.${VERSION_SDK_MAJOR}
)
install(
FILES ${drd_LIBS}
DESTINATION lib
RENAME libdrd.so.${VERSION_SDK_MAJOR}
)
install(
TARGETS ${PROJECT_NAME}
EXPORT export_${PROJECT_NAME}
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
)
ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET)
ament_package()