-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
84 lines (68 loc) · 2.35 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
cmake_minimum_required(VERSION 3.7)
project(UTBM_LO41_DroneDeliverySystem C)
# Don't allow to build in sources otherwise a makefile not generated by CMake can be overridden
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
# Place generated binaries in build/bin
set(
CMAKE_RUNTIME_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/build/bin
)
# Place generated libs in build/lib
set(
CMAKE_LIBRARY_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/build/lib
)
set(
CMAKE_ARCHIVE_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/build/lib
)
# By default build in Release mode
if( NOT CMAKE_BUILD_TYPE )
set(CMAKE_BUILD_TYPE "Release")
endif()
if(CMAKE_COMPILER_IS_GNUCC)
include(cmake/gcc-settings.cmake)
endif()
# Disable compiler specific extensions
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_POSIX_C_SOURCE=200112L")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLOGGER_ENABLED")
message(STATUS "Debug mode: Logger enabled (LOGGER_ENABLED macro defined)")
endif()
# Add dependencies subdirectories
add_subdirectory(ConsoleControl)
# Set include directories
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/ConsoleControl/ConsoleControl/include/
${CMAKE_CURRENT_SOURCE_DIR}/ConsoleControl/Logger/include/
${CMAKE_CURRENT_SOURCE_DIR}/DroneDeliverySystem/include/
)
# Set libraries directories
link_directories(
${CMAKE_BINARY_DIR}/build/lib/
)
# Use static linking for the libraries
set(CMAKE_EXE_LINKER_FLAGS " -static")
#target_link_libraries(UTBM_LO41_DroneDeliverySystem -static-libgcc -static-libstdc++)
# Set sources
message(STATUS "Sources preparation")
file(GLOB_RECURSE SOURCE_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/DroneDeliverySystem/src/*.c"
)
message(" -> Sources prepared")
# Add executable
add_executable(
UTBM_LO41_DroneDeliverySystem
${SOURCE_FILES}
)
add_dependencies(UTBM_LO41_DroneDeliverySystem ConsoleControl)
target_link_libraries(UTBM_LO41_DroneDeliverySystem ConsoleControl)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(UTBM_LO41_DroneDeliverySystem Threads::Threads)
target_link_libraries(UTBM_LO41_DroneDeliverySystem rt)
set_property(TARGET UTBM_LO41_DroneDeliverySystem PROPERTY C_STANDARD 11)
set_property(TARGET UTBM_LO41_DroneDeliverySystem PROPERTY C_STANDARD_REQUIRED ON)
message(STATUS "UTBM_LO41_DroneDeliverySystem set standard to use: c11")