-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
92 lines (74 loc) · 3.05 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
cmake_minimum_required(VERSION 3.16)
set(PROJECT_DESCRIPTION "An unofficial serial (UART) protocol library implementation to control JURA coffee makers.")
project("Jutta Protocol Library"
VERSION 0.0.0
DESCRIPTION "${PROJECT_DESCRIPTION}"
HOMEPAGE_URL "https://github.com/Jutta-Proto/protocol-cpp")
set(VERSION_NAME "dev")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
macro(jutta_proto_option OPTION_NAME OPTION_TEXT OPTION_DEFAULT)
option(${OPTION_NAME} ${OPTION_TEXT} ${OPTION_DEFAULT})
if(DEFINED ENV{${OPTION_NAME}})
# Allow setting the option through an environment variable
set(${OPTION_NAME} $ENV{${OPTION_NAME}})
endif()
if(${OPTION_NAME})
add_definitions(-D${OPTION_NAME})
endif()
message(STATUS " ${OPTION_NAME}: ${${OPTION_NAME}}")
endmacro()
message(STATUS "C++ Jutta Protocol Library Options")
message(STATUS "=======================================================")
jutta_proto_option(JUTTA_PROTO_BUILD_TESTS "Set to ON to build tests." ON)
jutta_proto_option(JUTTA_PROTO_STATIC_ANALYZE "Set to ON to enable the GCC 10 static analysis." OFF)
jutta_proto_option(JUTTA_PROTO_ENABLE_LINTING "Set to ON to enable clang linting." OFF)
jutta_proto_option(JUTTA_PROTO_BUILD_TEST_EXEC "Build test executables." OFF)
message(STATUS "=======================================================")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})
include(GNUInstallDirs)
include(sanitizer)
include(gcc_analyze)
if (${JUTTA_PROTO_ENABLE_LINTING})
message(STATUS "Enabling linting")
include(clang-tidy)
else()
message(STATUS "Linting is disabled")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/0.18.1/conan.cmake"
"${CMAKE_BINARY_DIR}/conan.cmake"
TLS_VERIFY ON)
endif()
include(${CMAKE_BINARY_DIR}/conan.cmake)
set(CONAN_CONFIGS"Release;Debug;RelWithDebInfo")
if(NOT CMAKE_BUILD_TYPE IN_LIST CONAN_CONFIGS)
set(CONAN_BUILD_TYPE "Debug")
else()
set(CONAN_BUILD_TYPE ${CMAKE_BUILD_TYPE})
endif()
conan_cmake_configure(REQUIRES catch2/2.13.8
spdlog/1.10.0
GENERATORS cmake_find_package
BUILD missing)
conan_cmake_autodetect(settings)
conan_cmake_install(PATH_OR_REFERENCE .
BUILD missing
REMOTE conancenter
SETTINGS ${settings})
find_package(spdlog REQUIRED)
include_directories(${CMAKE_SOURCE_DIR}/src)
add_subdirectory(src)
# Testing
if(${JUTTA_PROTO_BUILD_TESTS})
message(STATUS "Testing is enabled")
enable_testing()
add_subdirectory(tests)
else()
message(STATUS "Testing is disabled")
endif()