-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
115 lines (87 loc) · 3.74 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
cmake_minimum_required(VERSION 3.29)
# Set the C++ standard to C++20
set(CMAKE_CXX_STANDARD 20)
#------------------------------- PROJECT SETUP -------------------------------
# Define project name
project(fusion_vision)
# Find necessary packages
find_package(OpenCV REQUIRED) # OpenCV for computer vision functionalities
find_package(Boost 1.86.0 REQUIRED)
# Add include directories (for headers and external libraries)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include # Custom include directory
${CMAKE_CURRENT_SOURCE_DIR}/lib # Custom libraries directory
${OpenCV_INCLUDE_DIRS} # OpenCV include directories
${Boost_INCLUDE_DIRS}
)
#------------------------------- FILE GLOBBING -------------------------------
# Recursively gather all source, header, and test files
file(GLOB_RECURSE HEADER_SOURCE "include/**/*.h") # Header files in include/
file(GLOB_RECURSE MAIN_SOURCE "src/**/*.cpp") # Source files in src/
file(GLOB_RECURSE TEST_SOURCE "test/*.cpp") # Test files in tests/
file(GLOB_RECURSE LIB_SOURCE "lib/**/*.h") # Library headers in lib/
# Main application entry point
set(MAIN_FILE src/main.cpp)
# Output status messages for debugging
message(STATUS "Source files: ${MAIN_SOURCE}")
message(STATUS "Test files: ${TEST_SOURCE}")
message(STATUS "Header files: ${HEADER_SOURCE}")
message(STATUS "OpenCV files: ${OpenCV_INCLUDE_DIRS}")
message(STATUS "Boost files: ${Boost_INCLUDE_DIRS}")
# Ensure that source, header, and library files are present
if (NOT MAIN_SOURCE OR NOT LIB_SOURCE OR NOT HEADER_SOURCE)
message(FATAL_ERROR "Source files not found!")
endif()
if(NOT Boost_FOUND)
message(FATAL_ERROR "Boost not found !")
endif ()
#------------------------------- MAIN EXECUTABLE -------------------------------
# Define the main application executable
add_executable(fusion_vision
${MAIN_FILE} # Entry point
${MAIN_SOURCE} # All source files
${HEADER_SOURCE} # All header files
${LIB_SOURCE} # All library headers
)
# Find the Freenect2 library (for Kinect2 sensor)
find_library(FREENECT2_LIB freenect2 PATHS ${CMAKE_CURRENT_SOURCE_DIR}/lib)
# Link the libraries to the main executable
target_link_libraries(fusion_vision
${FREENECT2_LIB} # Kinect2 support
${OpenCV_LIBS} # OpenCV libraries
${Boost_LIBRARIES}
)
add_test(NAME Main COMMAND fusion_vision)
#------------------------------- BUILD CONFIGURATION -------------------------------
#------------------------------- UNIT TEST SETUP -------------------------------
# Fetch and include GoogleTest for unit testing
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/refs/tags/release-1.11.0.zip
)
# Ensure shared CRT for cross-library compatibility
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
# Download and make GoogleTest available
FetchContent_MakeAvailable(googletest)
# Define the main test file entry point
set(MAIN_TEST_FILE test/device/device_manager_test.cpp)
# Define the test executable
add_executable(unit_test
${MAIN_TEST_FILE} # Main test file
${MAIN_SOURCE} # All source files
${HEADER_SOURCE} # All header files
${LIB_SOURCE} # All library headers
)
# Link GoogleTest and other necessary libraries to the test executable
target_link_libraries(unit_test
PRIVATE
GTest::gtest_main # GoogleTest main function
${OpenCV_LIBS} # OpenCV libraries
${FREENECT2_LIB} # Kinect2 support
)
# Enable testing support in CMake
enable_testing()
# Define a general test case
add_test(NAME GeneralTest COMMAND unit_test)
#------------------------------- UNIT TEST SETUP -------------------------------