-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
136 lines (112 loc) · 5.5 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
124
125
126
127
128
129
130
131
132
133
134
135
136
####################################################################################################################
## Drone Software ##
## v24.00.00 Build 001 ##
## Mars Rover Design Team ##
## Copyright 2024 - All Rights Reserved ##
####################################################################################################################
## Set CMake Minimum Version
cmake_minimum_required(VERSION 3.24.3)
## C++ Version
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CUDA_STANDARD 20)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20")
## Project Name and Software Version Number
project(Drone_Software VERSION 24.00.00 LANGUAGES CXX)
## Include Required CMake Packages
if(NOT CPack_CMake_INCLUDED)
include(CPack) # CMake Packaging Library
endif()
if(NOT CTest_CMake_INCLUDED)
include(CTest) # CMake Testing Framework
endif()
## Define Project Name and Version Number for CPack
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_VENDOR "Mars Rover Design Team")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/data/CPACK/logo.ico")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
set(CPACK_GENERATOR "STGZ")
# Configure BSThreadPool
add_compile_definitions(BS_THREAD_POOL_ENABLE_PAUSE=1)
add_compile_definitions(BS_THREAD_POOL_ENABLE_PRIORITY=1)
add_compile_definitions(BS_THREAD_POOL_ENABLE_WAIT_DEADLOCK_CHECK=1)
## Find RoveComm
include_directories(external/rovecomm/src)
add_subdirectory(external/rovecomm)
add_compile_definitions(__ROVECOMM_LIBRARY_MODE__=1)
## Determine if all variables should be listed. Nice for finding available vars when using find_package.
option(LIST_ALL_VARS "Print all CMAKE variables." OFF)
## Find Threads
find_package(Threads REQUIRED)
## Find Quill
find_package(quill REQUIRED)
## Find Google Test
find_package(GTest CONFIG REQUIRED)
include(GoogleTest)
add_library(GTest::GTest INTERFACE IMPORTED)
target_link_libraries(GTest::GTest INTERFACE gtest_main)
## Check if all variables should be listed.
if (LIST_ALL_VARS)
get_cmake_property(_variableNames VARIABLES)
list (SORT _variableNames)
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
endif()
## Enable to CTest and Google Test Frameworks
enable_testing()
## Search Project Directories for CPP Files
file(GLOB_RECURSE SRC CONFIGURE_DEPENDS "src/*.cpp")
file(GLOB_RECURSE External_SRC CONFIGURE_DEPENDS "external/src/*.cpp")
## Create Executable File
add_executable(${PROJECT_NAME} ${External_SRC}
${SRC}
)
## Set Compile Options for Drone Software.
if(MSVC) # True when compiler is Microsoft Visual C++/simulation of Visual C++ CL.
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic)
endif()
## Set Drone Libraries
set(DRONE_LIBRARIES Threads::Threads
RoveComm_CPP
quill::quill
)
## Link Libraries to Executable
target_link_libraries(${PROJECT_NAME} PRIVATE ${DRONE_LIBRARIES})
## Enable or Disble Install Mode
option(BUILD_INSTALL_MODE "Enable Install Mode" OFF)
if(BUILD_INSTALL_MODE)
## Package Executable
install(TARGETS ${PROJECT_NAME} RUNTIME_DEPENDENCIES DIRECTORIES ${DRONE_LIBRARIES} RUNTIME DESTINATION bin)
endif()
## Enable or Disble Tests Mode
option(BUILD_TESTS_MODE "Enable Tests Mode" OFF)
if(BUILD_TESTS_MODE)
## Unit/Integration Tests
file(GLOB_RECURSE UnitTests_SRC CONFIGURE_DEPENDS "tests/Unit/*.cc")
file(GLOB_RECURSE IntegrationTests_SRC CONFIGURE_DEPENDS "tests/Integration/*.cc")
file(GLOB_RECURSE Algorithms_SRC CONFIGURE_DEPENDS "src/algorithms/*.cpp")
file(GLOB Network_SRC CONFIGURE_DEPENDS "src/DroneNetworking.cpp")
file(GLOB Logging_SRC CONFIGURE_DEPENDS "src/DroneLogging.cpp")
list(LENGTH UnitTests_SRC UnitTests_LEN)
list(LENGTH IntegrationTests_SRC IntegrationTests_LEN)
if (UnitTests_LEN GREATER 0)
add_executable(${PROJECT_NAME}_UnitTests ${UnitTests_SRC} ${Algorithms_SRC} ${Network_SRC} ${Logging_SRC})
target_link_libraries(${PROJECT_NAME}_UnitTests GTest::gtest GTest::gtest_main ${DRONE_LIBRARIES})
add_test(Unit_Tests ${PROJECT_NAME}_UnitTests)
else()
message("No Unit Tests!")
endif()
if (IntegrationTests_LEN GREATER 0)
add_executable(${PROJECT_NAME}_IntegrationTests ${IntegrationTests_SRC} ${Algorithms_SRC} ${Network_SRC} ${Logging_SRC})
target_link_libraries(${PROJECT_NAME}_IntegrationTests GTest::gtest GTest::gtest_main ${DRONE_LIBRARIES})
add_test(Integration_Tests ${PROJECT_NAME}_IntegrationTests)
else()
message("No Integration Tests!")
endif()
endif()