|
| 1 | +# Copyright (c) 2017-2025 Intel Corporation |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +cmake_minimum_required(VERSION 3.0.2) |
| 16 | +project(movidius_ncs_lib) |
| 17 | + |
| 18 | +# Find required packages |
| 19 | +find_package(catkin REQUIRED COMPONENTS |
| 20 | + roscpp |
| 21 | + std_msgs |
| 22 | +) |
| 23 | + |
| 24 | +# Find OpenCV (required for image processing) |
| 25 | +find_package(OpenCV REQUIRED) |
| 26 | + |
| 27 | +# Find Intel Movidius NCS SDK |
| 28 | +find_path(MVNC_INCLUDE_DIR mvnc.h |
| 29 | + HINTS /opt/movidius/nc-sdk/include |
| 30 | + PATHS /usr/include /usr/local/include |
| 31 | +) |
| 32 | + |
| 33 | +find_library(MVNC_LIBRARY mvnc |
| 34 | + HINTS /opt/movidius/nc-sdk/lib |
| 35 | + PATHS /usr/lib /usr/local/lib |
| 36 | +) |
| 37 | + |
| 38 | +if(NOT MVNC_INCLUDE_DIR OR NOT MVNC_LIBRARY) |
| 39 | + message(WARNING "Intel Movidius NCS SDK not found. Please install it for full functionality.") |
| 40 | +endif() |
| 41 | + |
| 42 | +# Catkin package configuration |
| 43 | +catkin_package( |
| 44 | + INCLUDE_DIRS include |
| 45 | + LIBRARIES ${PROJECT_NAME} |
| 46 | + CATKIN_DEPENDS roscpp std_msgs |
| 47 | + DEPENDS OpenCV |
| 48 | +) |
| 49 | + |
| 50 | +# Include directories |
| 51 | +include_directories( |
| 52 | + include |
| 53 | + ${catkin_INCLUDE_DIRS} |
| 54 | + ${OpenCV_INCLUDE_DIRS} |
| 55 | + ${MVNC_INCLUDE_DIR} |
| 56 | +) |
| 57 | + |
| 58 | +# Source files |
| 59 | +set(SOURCES |
| 60 | + ../src cpp/device.cpp |
| 61 | + ../src cpp/exception.cpp |
| 62 | + ../src cpp/exception_util.cpp |
| 63 | + ../src cpp/graph.cpp |
| 64 | + ../src cpp/ncs.cpp |
| 65 | + ../src cpp/ncs_manager.cpp |
| 66 | + ../src cpp/result.cpp |
| 67 | + ../src cpp/tensor.cpp |
| 68 | +) |
| 69 | + |
| 70 | +# Header files |
| 71 | +set(HEADERS |
| 72 | + include/lib/device.h |
| 73 | + include/lib/exception.h |
| 74 | + include/lib/exception_util.h |
| 75 | + include/lib/graph.h |
| 76 | + include/lib/mvnc_cpp.h |
| 77 | + include/lib/ncs.h |
| 78 | + include/lib/ncs_manager.h |
| 79 | + include/lib/result.h |
| 80 | + include/lib/tensor.h |
| 81 | +) |
| 82 | + |
| 83 | +# Create library |
| 84 | +add_library(${PROJECT_NAME} ${SOURCES}) |
| 85 | + |
| 86 | +# Link libraries |
| 87 | +target_link_libraries(${PROJECT_NAME} |
| 88 | + ${catkin_LIBRARIES} |
| 89 | + ${OpenCV_LIBRARIES} |
| 90 | + ${MVNC_LIBRARY} |
| 91 | +) |
| 92 | + |
| 93 | +# Set compiler flags |
| 94 | +set_target_properties(${PROJECT_NAME} PROPERTIES |
| 95 | + CXX_STANDARD 14 |
| 96 | + CXX_STANDARD_REQUIRED ON |
| 97 | +) |
| 98 | + |
| 99 | +# Install headers |
| 100 | +install(DIRECTORY include/${PROJECT_NAME}/ |
| 101 | + DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} |
| 102 | +) |
| 103 | + |
| 104 | +# Install library |
| 105 | +install(TARGETS ${PROJECT_NAME} |
| 106 | + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} |
| 107 | + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} |
| 108 | + RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} |
| 109 | +) |
| 110 | + |
| 111 | +# Export library for other packages to use |
| 112 | +export(TARGETS ${PROJECT_NAME} |
| 113 | + FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake" |
| 114 | +) |
| 115 | + |
| 116 | +# Generate package configuration files |
| 117 | +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME}-config.cmake.in" |
| 118 | + "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" @ONLY) |
| 119 | + |
| 120 | +install(FILES |
| 121 | + "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" |
| 122 | + DESTINATION "${CATKIN_PACKAGE_SHARE_DESTINATION}/cmake" |
| 123 | +) |
0 commit comments