forked from Alliance-Algorithm/UGAS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.old.txt
71 lines (59 loc) · 2.37 KB
/
CMakeLists.old.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
cmake_minimum_required(VERSION 3.12)
project(ugas VERSION 1.0 LANGUAGES C CXX)
# Set compilation flags
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# Set configure_file
set (CONFIGURE_DIR_PATH ${PROJECT_SOURCE_DIR}/build/config)
configure_file (
"${PROJECT_SOURCE_DIR}/src/config.h.in"
"${CONFIGURE_DIR_PATH}/config.h")
# Initialize custom options
option (ENABLE_DEBUG_CANVAS "Enable debug canvas to draw debug image" ON)
option (ENABLE_RECORDING "Enable recording of raw camera image" ON)
option (ENABLE_OPENVINO "Enable openvino to identify buff" ON)
option (ENABLE_ROS "Enable ROS to visualize positions" ON)
# Set the output executable file name:
# When compiling in the ROS environment, the output executable file name will be the node name.
# Otherwise, the output file name will be the project name.
if (ENABLE_ROS)
set(EXECUTABLE_NAME main)
else ()
set(EXECUTABLE_NAME ${PROJECT_NAME})
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/build)
endif()
# Find non-ros packages
find_package(OpenCV 4.5 REQUIRED)
if (ENABLE_OPENVINO)
find_package(OpenVINO REQUIRED)
set(OpenVINO_LIB openvino::runtime)
find_package(Ceres REQUIRED)
set(Ceres_LIB Ceres::ceres)
endif (ENABLE_OPENVINO)
# Include project source directory
include_directories(${PROJECT_SOURCE_DIR}/src ${CONFIGURE_DIR_PATH})
# Recursively search for all source files under the 'src' folder and store them into UGAS_SOURCE variable
# Flag 'CONFIGURE_DEPENDS' asks cmake to detect GLOB result changes so no need to rerun cmake when adding a new source file.
# file(GLOB_RECURSE UGAS_SOURCE CONFIGURE_DEPENDS
# ${PROJECT_SOURCE_DIR}/src/*.cpp
# ${PROJECT_SOURCE_DIR}/src/*.cc)
set(UGAS_SOURCE src/main.cpp)
# Find ros packages & add source files to compilation
if (ENABLE_ROS)
find_package (ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies ()
ament_auto_add_executable(${EXECUTABLE_NAME} ${UGAS_SOURCE})
else()
add_executable(${EXECUTABLE_NAME} ${UGAS_SOURCE})
endif()
# Link libraries
target_link_libraries(${EXECUTABLE_NAME} ${OpenCV_LIBS} ${OpenVINO_LIB} ${Ceres_LIB} -lpthread)
# Install package
if (ENABLE_ROS)
ament_auto_package()
endif()