-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
75 lines (59 loc) · 2.06 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
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR)
set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/mbed-os CACHE INTERNAL "")
set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "")
set(APP_TARGET micro_ros_mbed)
include(${MBED_PATH}/tools/cmake/app.cmake)
add_subdirectory(${MBED_PATH})
add_executable(${APP_TARGET})
mbed_configure_app_target(${APP_TARGET})
include(ExternalProject)
externalproject_add(libmicroros_project
PREFIX ${CMAKE_BINARY_DIR}/libmicroros-prefix
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}
CONFIGURE_COMMAND ""
BUILD_COMMAND
make -f ${CMAKE_CURRENT_SOURCE_DIR}/libmicroros.mk
X_CC=${CMAKE_C_COMPILER}
X_AR=${CMAKE_AR}
X_STRIP=${CMAKE_STRIP}
X_CFLAGS=${CMAKE_C_FLAGS}
X_CXX=${CMAKE_CXX_COMPILER}
X_CXXFLAGS=${CMAKE_CXX_FLAGS}
BUILD_DIR=${CMAKE_BINARY_DIR}
EXTENSIONS_DIR=${CMAKE_CURRENT_SOURCE_DIR}
INSTALL_COMMAND ""
BUILD_BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/libmicroros.a
)
project(${APP_TARGET})
target_sources(${APP_TARGET}
PRIVATE
main.cpp
transports.cpp
)
add_dependencies(${APP_TARGET} libmicroros_project)
target_include_directories(${APP_TARGET} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
execute_process(
COMMAND
make -f ${CMAKE_CURRENT_SOURCE_DIR}/libmicroros.mk get_package_names
WORKING_DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE
INCLUDE_ROS2_PACKAGES
OUTPUT_STRIP_TRAILING_WHITESPACE
)
foreach(pkg ${INCLUDE_ROS2_PACKAGES})
target_include_directories(${APP_TARGET} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/${pkg})
endforeach()
target_link_libraries(${APP_TARGET}
PRIVATE
mbed-os
${CMAKE_CURRENT_SOURCE_DIR}/libmicroros.a
)
mbed_set_post_build(${APP_TARGET})
option(VERBOSE_BUILD "Have a verbose build process")
if(VERBOSE_BUILD)
set(CMAKE_VERBOSE_MAKEFILE ON)
endif()