-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
123 lines (100 loc) · 3.39 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
PROJECT(nnstreamer-ros C CXX)
OPTION(TIZEN "Enable Tizen build mode" OFF)
OPTION(ENABLE_TEST "Enable tests" ON)
OPTION(ENABLE_COV "Enable code instrumentation for coverage analysis" OFF)
SET(ROS_DISTROS "kinetic" "melodic" "noextic" )
SET(ROS2_DISTROS "eloquent" "foxy")
SET(NNS_VERSION "1.6.0")
ADD_DEFINITIONS(-DNNS_VERSION="${NNS_VERSION}")
IF(NOT ROS_VERSION)
SET(ROS_VERSION "melodic")
ENDIF (NOT ROS_VERSION)
LIST(FIND ROS_DISTROS ${ROS_VERSION} ROS_DISTRO_IDX)
LIST(FIND ROS2_DISTROS ${ROS_VERSION} ROS2_DISTRO_IDX)
IF(${ROS_DISTRO_IDX} GREATER -1)
SET(WITH_ROS1 TRUE)
SET(WITH_ROS2 FALSE)
ADD_DEFINITIONS(-DWITH_ROS1)
ELSEIF(${ROS2_DISTRO_IDX} GREATER -1)
SET(WITH_ROS1 FALSE)
SET(WITH_ROS2 TRUE)
ADD_DEFINITIONS(-DWITH_ROS2)
ELSE()
message(FATAL_ERROR "Invalid or Not Supported ROS_DISTRO: ${ROS_VERSION}")
ENDIF(${ROS_DISTRO_IDX} GREATER -1)
IF(NOT ROS_BASE_PREFIX)
SET(ROS_BASE_PREFIX "/opt/ros/${ROS_VERSION}")
ENDIF(NOT ROS_BASE_PREFIX)
IF(NOT ROS_INSTALL_PREFIX)
SET(ROS_INSTALL_PREFIX ${ROS_BASE_PREFIX})
ENDIF(NOT ROS_INSTALL_PREFIX)
## Configure ROS-related path
SET(ROS_ROOT "${CMAKE_PREFIX_PATH}/ros")
SET(ROS_INSTALL_LIBDIR "lib")
SET(ROS_INSTALL_BINDIR "bin")
SET(ROS_INSTALL_INCLUDEDIR "include")
SET(ROS_INSTALL_DATAROOTDIR "share")
## Override CMake Variables
SET(CMAKE_PREFIX_PATH "${ROS_BASE_PREFIX}")
STRING(FIND ${CMAKE_INSTALL_PREFIX} ${CMAKE_CURRENT_SOURCE_DIR} BUILD_IN_WORKSPACE)
IF(BUILD_IN_WORKSPACE EQUAL -1)
SET(CMAKE_INSTALL_PREFIX ${ROS_INSTALL_PREFIX})
ENDIF(BUILD_IN_WORKSPACE EQUAL -1)
SET(CMAKE_INSTALL_LIBDIR "${ROS_INSTALL_LIBDIR}")
SET(CMAKE_INSTALL_BINDIR "${ROS_INSTALL_BINDIR}")
SET(CMAKE_INSTALL_INCLUDEDIR "${ROS_INSTALL_INCLUDEDIR}")
SET(CMAKE_INSTALL_DATAROOTDIR "${ROS_INSTALL_DATAROOTDIR}")
## Configure variables to use in build
SET(ENV{LD_LIBRARY_PATH} "${CMAKE_PREFIX_PATH}/lib:$ENV{LD_LIBRARY_PATH}")
SET(ROS_BASE_INCLUDE_DIR "${CMAKE_PREFIX_PATH}/include")
## Set the directory where the NNS plugins will be placed
SET(NNS_INSTALL_GSTDIR "${ROS_INSTALL_LIBDIR}/gstreamer-1.0")
FIND_PACKAGE(PkgConfig REQUIRED)
SET(PKG_COMMON_MODULES
glib-2.0
gstreamer-1.0
gstreamer-base-1.0
nnstreamer
)
IF(TIZEN)
# Enable dlog of Tizen.
SET(PKG_COMMON_MODULES ${PKG_COMMON_MODULES} dlog)
ENDIF(TIZEN)
PKG_CHECK_MODULES(PKGS_COMMON REQUIRED ${PKG_COMMON_MODULES})
INCLUDE_DIRECTORIES(
${PROJECT_SOURCE_DIR}/include
${PKGS_COMMON_INCLUDE_DIRS}
${ROS_BASE_INCLUDE_DIR}
)
# Default to C99
IF(NOT CMAKE_C_STANDARD)
SET(CMAKE_C_STANDARD 99)
ENDIF()
# Default to C++14
IF(NOT CMAKE_CXX_STANDARD)
SET(CMAKE_CXX_STANDARD 14)
ENDIF()
SET(NNS_ROS_COMMON_DIR ${PROJECT_SOURCE_DIR}/common)
SET(EXTRA_CFLAGS -Wall -Werror -fPIC -g)
SET(EXTRA_CXXFLAGS -Wall -Werror -fPIC -g)
IF(ENABLE_COV)
SET(CMAKE_BUILD_TYPE Debug)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb -fprofile-arcs -ftest-coverage")
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -lgcov")
ENDIF(ENABLE_COV)
ADD_COMPILE_OPTIONS(
"$<$<COMPILE_LANGUAGE:C>:${EXTRA_CFLAGS}>"
"$<$<COMPILE_LANGUAGE:CXX>:${EXTRA_CXXFLAGS}>"
)
IF(WITH_ROS1)
ADD_SUBDIRECTORY(ros)
ELSEIF(WITH_ROS2)
ADD_SUBDIRECTORY(ros2)
ENDIF()
ADD_SUBDIRECTORY(gst)
IF(ENABLE_TEST)
ENABLE_TESTING()
ADD_SUBDIRECTORY(tests)
ENDIF(ENABLE_TEST)