-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
72 lines (55 loc) · 1.86 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
cmake_minimum_required(VERSION 3.5)
project(pybind11_opencv)
# Specify C++ Standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED on)
# pybind11 needs to be first, otherwise other packages which also search for
# Python can cause an 'Unknown CMake command "python3_add_library"' error.
# Probably related to how Python is found, see
# https://github.com/pybind/pybind11/issues/3996
find_package(pybind11 REQUIRED)
find_package(ament_cmake REQUIRED)
find_package(mpi_cmake_modules REQUIRED)
find_package(OpenCV REQUIRED)
###########
## Build ##
###########
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
${OpenCV_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME} INTERFACE
${OpenCV_LIBRARIES}
pybind11::pybind11
)
#############
## Install ##
#############
ament_export_interfaces(export_${PROJECT_NAME} HAS_LIBRARY_TARGET)
# Mark cpp header files for installation
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION include/${PROJECT_NAME})
install(
TARGETS ${PROJECT_NAME}
EXPORT export_${PROJECT_NAME}
LIBRARY DESTINATION lib
)
#############
## Testing ##
#############
if (BUILD_TESTING)
find_package(ament_cmake_nose REQUIRED)
# Need to install a dummy package with __init__.py, otherwise the package
# will not be added to PYTHONPATH in the setup.bash and the pybind11 module
# installed below will not be found.
ament_python_install_package(${PROJECT_NAME} PACKAGE_DIR test/dummy_pkg/${PROJECT_NAME})
add_pybind11_module(cvbind_test srcpy/cvbind_test.cpp
LINK_LIBRARIES ${PROJECT_NAME}
)
ament_add_nose_test(test_cvbind test/test_cvbind.py)
endif()
ament_export_include_directories(include)
ament_export_dependencies(pybind11 OpenCV)
ament_package()