-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
134 lines (109 loc) · 4.73 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
cmake_minimum_required(VERSION 3.8)
project(sensei)
##################################
# Build information #
##################################
option(WITH_UNIT_TESTS "Build and run unittests" ON)
# Get the latest commit hash of the working branch
execute_process(
COMMAND git log -1 --format=%H
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(TIMESTAMP BUILD_TIMESTAMP "%Y-%m-%d %H:%M")
configure_file(
${CMAKE_SOURCE_DIR}/include/version.h.in
${CMAKE_BINARY_DIR}/generated/version.h
)
# Enable
option(WITH_GPIO_LOGIC "Perform gpio logic instead of a micro controller" OFF)
############################
# Main executable target #
############################
set(COMPILATION_UNITS src/config_backend/json_configuration.cpp
src/mapping/sensor_mappers.cpp
src/mapping/mapping_processor.cpp
src/event_handler.cpp
src/output_backend/std_stream_backend.cpp
src/output_backend/osc_backend.cpp
src/hardware_frontend/hw_frontend.cpp
src/hardware_frontend/message_tracker.cpp
src/hardware_frontend/gpio_command_creator.cpp
src/hardware_backend/gpio_hw_socket.cpp
src/main.cpp
src/logging.cpp
src/user_frontend/user_frontend.cpp src/user_frontend/osc_user_frontend.cpp)
# Enumerate all the headers separately so that CLion can index them
set(EXTRA_CLION_SOURCES src/config_backend/base_configuration.h
src/config_backend/json_configuration.h
src/message/base_message.h
src/message/base_value.h
src/message/base_command.h
src/message/base_error.h
src/message/error_defs.h
src/message/command_defs.h
src/message/value_defs.h
src/message/message_factory.h
src/mapping/mapping_processor.h
src/mapping/sensor_mappers.h
src/output_backend/output_backend.h
src/output_backend/std_stream_backend.h
src/output_backend/osc_backend.h
src/hardware_frontend/base_hw_frontend.h
src/hardware_frontend/message_tracker.h
src/hardware_frontend/hw_frontend.h
src/hardware_frontend/gpio_command_creator.h
src/hardware_backend/base_hw_backend.h
src/hardware_backend/gpio_hw_socket.h
src/locked_queue.h
src/synchronized_queue.h
src/event_handler.h
src/utils.h
src/logging.h
src/user_frontend/user_frontend.h
src/user_frontend/osc_user_frontend.h)
set(SOURCE_FILES "${COMPILATION_UNITS}" "${EXTRA_CLION_SOURCES}")
add_executable(sensei ${SOURCE_FILES})
#########################
# Include Directories #
#########################
set(INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src"
"${PROJECT_SOURCE_DIR}/include"
"${PROJECT_SOURCE_DIR}/shiftregister_gpio/include"
"${CMAKE_BINARY_DIR}"
"${PROJECT_SOURCE_DIR}/third-party/optionparser/"
"${PROJECT_SOURCE_DIR}/third-party/spdlog/include")
# /usr/local doesn't get added by default in Mac OS X
if (APPLE)
set(INCLUDE_DIRS "${INCLUDE_DIRS}" /usr/local/include)
endif()
target_include_directories(sensei PRIVATE ${INCLUDE_DIRS})
if (APPLE)
target_include_directories(sensei PRIVATE /usr/local/lib)
endif()
####################################
# Compiler Flags and definitions #
####################################
target_compile_features(sensei PRIVATE cxx_std_17)
target_compile_options(sensei PRIVATE -Wall -Wextra -Wno-psabi -fno-rtti -ffast-math)
if (APPLE)
set_target_properties(sensei LINK_FLAGS -framework IOKit -framework CoreFoundation)
endif()
#################################
# Statically linked libraries #
#################################
add_subdirectory(elk-gpio-protocol)
add_subdirectory(shiftregister_gpio)
set(LINK_LIBRARIES gpio_protocol shiftreg_gpio pthread jsoncpp lo)
target_link_libraries(sensei PRIVATE ${LINK_LIBRARIES})
####################
# Add unit tests #
####################
if (${WITH_UNIT_TESTS})
add_subdirectory(test)
endif()
###########
# Tools #
###########
add_subdirectory(test/tools/socket_example EXCLUDE_FROM_ALL)