forked from ros2/geometry2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
85 lines (70 loc) · 2.84 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
cmake_minimum_required(VERSION 3.5)
project(tf2_py)
# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
# GCC 8 on CentOS 7 (correctly) warns that casting
# METH_VARARGS | METH_KEYWORDS functions (with 3 PyObject * arguments) to a
# PyCFunction (with 2 PyObject * arguments) in PyMethodDef is an incompatible
# cast. This works fine since it is just a pointer, so disable that
# warning to quiet it down. Note that we do this globally rather than in a
# pragma since gcc prior to 8 ignores unknown command-line flags while it
# does *not* ignore unknown pragmas.
add_compile_options(-Wno-cast-function-type)
endif()
# Figure out Python3 debug/release before anything else can find_package it
if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
find_package(python_cmake_module REQUIRED)
find_package(PythonExtra REQUIRED)
# Force FindPython3 to use the debug interpretter where ROS 2 expects it
set(Python3_EXECUTABLE "${PYTHON_EXECUTABLE_DEBUG}")
endif()
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_python REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(tf2 REQUIRED)
ament_python_install_package(${PROJECT_NAME})
python3_add_library(_tf2_py src/tf2_py.cpp)
if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
# python3_add_library should really take care of this for us, but it doesn't
set_property(TARGET _tf2_py PROPERTY SUFFIX "_d.pyd")
endif()
# Set output directories to import module from the build directory
# Use a no-op generator expression so multi-config generators don't append an
# extra directory like Release/ or Debug/ and break the Python import.
set_target_properties(_tf2_py PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "$<1:${CMAKE_CURRENT_BINARY_DIR}/test_${PROJECT_NAME}>"
RUNTIME_OUTPUT_DIRECTORY "$<1:${CMAKE_CURRENT_BINARY_DIR}/test_${PROJECT_NAME}>"
)
target_link_libraries(_tf2_py PRIVATE
${geometry_msgs_TARGETS}
tf2::tf2
)
install(TARGETS
_tf2_py
DESTINATION ${PYTHON_INSTALL_DIR}/${PROJECT_NAME}
)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# TODO (ahcorde): disable the copyright check. Once we figure out the ament_lint situation
# https://github.com/ros2/geometry2/pull/222
list(APPEND AMENT_LINT_AUTO_EXCLUDE
ament_cmake_copyright
ament_cmake_cpplint
)
ament_lint_auto_find_test_dependencies()
find_package(ament_cmake_pytest REQUIRED)
ament_add_pytest_test(tf2_py_test test
APPEND_ENV PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}
)
# Create importable location in build directory
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_tf2_py/__init__.py" "")
endif()
ament_package()