forked from ros2/mimick_vendor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
105 lines (89 loc) · 3.28 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.5)
project(mimick_vendor)
find_package(ament_cmake REQUIRED)
macro(build_mimick)
set(cmake_commands)
set(cmake_configure_args -Wno-dev)
list(APPEND cmake_configure_args -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_install)
if(WIN32)
if(DEFINED CMAKE_GENERATOR)
list(APPEND cmake_configure_args -G ${CMAKE_GENERATOR})
endif()
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "^(x86_|x86-|AMD|amd|x)64$")
list(APPEND cmake_configure_args -A x64)
endif()
endif()
if(DEFINED CMAKE_BUILD_TYPE)
if(WIN32)
build_command(_build_command CONFIGURATION ${CMAKE_BUILD_TYPE})
list(APPEND cmake_commands "BUILD_COMMAND ${_build_command}")
else()
list(APPEND cmake_configure_args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
endif()
endif()
if(DEFINED CMAKE_TOOLCHAIN_FILE)
list(APPEND cmake_configure_args "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
if(ANDROID)
if(DEFINED ANDROID_ABI)
list(APPEND cmake_configure_args "-DANDROID_ABI=${ANDROID_ABI}")
endif()
if(DEFINED ANDROID_CPP_FEATURES)
list(APPEND cmake_configure_args "-DANDROID_CPP_FEATURES=${ANDROID_CPP_FEATURES}")
endif()
if(DEFINED ANDROID_FUNCTION_LEVEL_LINKING)
list(APPEND cmake_configure_args "-DANDROID_FUNCTION_LEVEL_LINKING=${ANDROID_FUNCTION_LEVEL_LINKING}")
endif()
if(DEFINED ANDROID_NATIVE_API_LEVEL)
list(APPEND cmake_configure_args "-DANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL}")
endif()
if(DEFINED ANDROID_NDK)
list(APPEND cmake_configure_args "-DANDROID_NDK=${ANDROID_NDK}")
endif()
if(DEFINED ANDROID_STL)
list(APPEND cmake_configure_args "-DANDROID_STL=${ANDROID_STL}")
endif()
if(DEFINED ANDROID_TOOLCHAIN_NAME)
list(APPEND cmake_configure_args "-DANDROID_TOOLCHAIN_NAME=${ANDROID_TOOLCHAIN_NAME}")
endif()
endif()
else()
list(APPEND cmake_configure_args "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}")
endif()
if(DEFINED CMAKE_CXX_FLAGS)
list(APPEND cmake_configure_args "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")
endif()
if(DEFINED CMAKE_C_FLAGS)
list(APPEND cmake_configure_args "-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}")
endif()
include(ExternalProject)
set(mimick_version "de11f8377eb95f932a03707b583bf3d4ce5bd3e7")
externalproject_add(mimick-${mimick_version}
GIT_REPOSITORY https://github.com/ros2/Mimick.git
GIT_TAG ${mimick_version}
GIT_CONFIG advice.detachedHead=false
# Suppress git update due to https://gitlab.kitware.com/cmake/cmake/-/issues/16419
UPDATE_COMMAND ""
TIMEOUT 6000
${cmake_commands}
CMAKE_ARGS
${cmake_configure_args}
)
# The external project will install to the build folder, but we'll install that on make install.
install(
DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_install/
DESTINATION
${CMAKE_INSTALL_PREFIX}
USE_SOURCE_PERMISSIONS
)
endmacro()
build_mimick()
ament_export_include_directories(include)
ament_export_libraries(mimick)
ament_export_dependencies(mimick)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()
# this ensures that the package has an environment hook setting the PATH
ament_package()