Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
140 lines (115 loc) · 3.6 KB
/
Copy pathCMakeLists.txt
File metadata and controls
140 lines (115 loc) · 3.6 KB
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
137
138
139
140
###############################################################################
# This is a sample CMakeLists.txt. Replace all instances of "minimalapp" with
# the name of your app.
# If necessary add your source files and libraries in the Target Definition
# section. Define files to copy to the output in the Copy Data section.
###############################################################################
cmake_minimum_required (VERSION 3.16)
project(iRC_App_API
VERSION 14.6.7
LANGUAGES C CXX
)
# Life cycle information for the SBOM
set(RELEASE_DATE "2026-05-08")
set(SUPPORT_PERIOD_END "2000-00-00") # TODO: define support period
set(END_OF_LIFE "2000-00-00") # TODO: define end of life
configure_file(src/APIVersion.h.in src/APIVersion.h)
configure_file(sbomify.json.in sbomify.json)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
option(BUILD_TESTS "Compile tests" ON)
###############################################################################
# Generating gRPC C++-Sources
###############################################################################
find_package(Protobuf REQUIRED)
find_package(gRPC REQUIRED)
include(cmake/gRPC.cmake)
file(GLOB PROTOS
"${CMAKE_CURRENT_SOURCE_DIR}/protos/*.proto"
)
set(PROTO_SRC_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated_protos")
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_SRC_DIR} ${PROTOS})
grpc_generate_cpp(GRPC_SRCS GRPC_HDRS ${PROTO_SRC_DIR} ${PROTOS})
list(APPEND INCLUDE_DIRS
${PROTO_SRC_DIR}
)
list(APPEND GRPC_SOURCES
${GRPC_SRCS}
${PROTO_SRCS}
)
###############################################################################
# Target definition - define the app source and dependencies here!
###############################################################################
file(GLOB APP_SOURCES src/*.cpp)
file(GLOB APP_SOURCES_DATATYPES src/DataTypes/*.cpp)
file(GLOB SOURCES_tests_DataTypes tests/DataTypes/*.cpp)
add_library(iRCApp
${GRPC_SOURCES}
${APP_SOURCES}
${APP_SOURCES_DATATYPES}
)
target_include_directories(iRCApp
PUBLIC
src
${PROTO_SRC_DIR}
${CMAKE_CURRENT_BINARY_DIR}/src/
)
include(CMakePrintHelpers)
cmake_print_variables(CMAKE_CURRENT_BINARY_DIR)
target_link_libraries(iRCApp
PUBLIC
protobuf::libprotobuf
gRPC::grpc++
PRIVATE
Threads::Threads
)
if(UNIX OR MINGW)
target_compile_options(iRCApp
PRIVATE
# More warnings:
-Wall -Wextra -pedantic
# More errors:
-Werror=parentheses -Werror=return-type
)
elseif(MSVC)
endif()
###############################################################################
# Unit Tests
###############################################################################
# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24:
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()
if (BUILD_TESTS)
enable_testing()
find_package(GTest REQUIRED)
# Include the GoogleTest module for gtest_discover_tests()
include(GoogleTest)
add_executable(iRCApp_Tests
${SOURCES_tests_DataTypes}
)
target_include_directories(iRCApp_Tests
PRIVATE
${INCLUDE_DIRS}
)
target_link_libraries(iRCApp_Tests
PRIVATE
iRCApp
GTest::gtest_main
GTest::gmock
)
if(UNIX OR MINGW)
target_compile_options(iRCApp_Tests
PRIVATE
# More warnings:
-Wall -Wextra -pedantic
# More errors:
-Werror=parentheses -Werror=return-type
)
elseif(MSVC)
endif()
# Detect test cases (this does not work when cross compiling as it executes the binary)
if(!CMAKE_CROSSCOMPILING)
gtest_discover_tests(iRCApp_Tests)
endif()
endif()