-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
109 lines (88 loc) · 2.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
# Set the minimum required CMake version
cmake_minimum_required(VERSION 3.5)
# Set the project name
set(PROJECT_NAME as2_platform_dji_psdk)
project(${PROJECT_NAME})
# Default to C++17 if not set
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
# Set Release as default build type if not set
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# find dependencies
set(PROJECT_DEPENDENCIES
ament_cmake
rclcpp
as2_core
as2_msgs
std_msgs
psdk_interfaces
)
foreach(DEPENDENCY ${PROJECT_DEPENDENCIES})
find_package(${DEPENDENCY} REQUIRED)
endforeach()
# Include necessary directories
include_directories(
include
include/${PROJECT_NAME}
)
# Set source files
set(SOURCE_CPP_FILES
src/${PROJECT_NAME}_node.cpp
src/${PROJECT_NAME}.cpp
)
# Create the node executable
add_executable(${PROJECT_NAME}_node ${SOURCE_CPP_FILES})
ament_target_dependencies(${PROJECT_NAME}_node ${PROJECT_DEPENDENCIES})
# Create the dynamic library
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_library(${PROJECT_NAME} SHARED ${SOURCE_CPP_FILES})
ament_target_dependencies(${PROJECT_NAME} ${PROJECT_DEPENDENCIES})
# Set the public include directories for the library
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
# Install the headers
install(
DIRECTORY include/
DESTINATION include
)
# Install the node executable
install(TARGETS
${PROJECT_NAME}_node
DESTINATION lib/${PROJECT_NAME}
)
# Install the shared library
install(
TARGETS ${PROJECT_NAME}
EXPORT export_${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
# Export the libraries
ament_export_libraries(${PROJECT_NAME})
# Export the targets
ament_export_targets(export_${PROJECT_NAME})
# Export the include directories
ament_export_include_directories(include)
# Install the launch directory
install(DIRECTORY
launch
DESTINATION share/${PROJECT_NAME}
)
# Install the config directory
install(DIRECTORY
config
DESTINATION share/${PROJECT_NAME}
)
# Build tests if testing is enabled
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
add_subdirectory(tests)
endif()
# Create the ament package
ament_package()