-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
95 lines (75 loc) · 2.19 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
#
# cbox
#
cmake_minimum_required(VERSION 3.15)
#
# Building in-tree is not allowed (we take care of your craziness).
#
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "Prevented in-tree built. Please create a build directory outside of the source code and call cmake from there. Thank you.")
endif()
#
# Project configuration
#
set(CBOX_VERSION_MAJOR 0)
set(CBOX_VERSION_MINOR 1)
set(CBOX_VERSION_PATCH 0)
set(CBOX_VERSION ${CBOX_VERSION_MAJOR}.${CBOX_VERSION_MINOR}.${CBOX_VERSION_PATCH})
#
# Set install prefix
#
#set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/install" CACHE PATH "")
project(
cbox
VERSION ${CBOX_VERSION}
DESCRIPTION "Easy to use, convenient and treasure box!"
HOMEPAGE_URL "https://gitee.com/cpp-master/cbox"
LANGUAGES C
)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CBOX_BUILD_LIB_TYPE STATIC)
message("*")
message("* ${PROJECT_NAME} v${PROJECT_VERSION} (${CMAKE_BUILD_TYPE})")
message("* Copyright (c) 2020-2025 Hevake,Lucas")
message("*")
option(CBOX_ENABLE_BASE "build base" ON)
option(CBOX_ENABLE_EVENT "build event" ON)
option(CBOX_ENABLE_MQTT "build mqtt" ON)
option(CBOX_ENABLE_SAMPLES "build samples" ON)
#
# TESTS
#
option(CMAKE_ENABLE_TEST "Whether to enable unit tests" OFF)
if(CMAKE_ENABLE_TEST)
message(STATUS "Unit tests enabled")
find_package(GTest REQUIRED)
set(CBOX_ENABLE_TEST ON)
enable_testing()
endif()
#
# Compiler args
#
set(CMAKE_C_STANDARD 99)
add_compile_options(-Wall -Wextra -Werror -Wno-unused-result -Wno-missing-field-initializers)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
add_definitions(-DCBOX_VERSION_MAJOR=${CBOX_VERSION_MAJOR}
-DCBOX_VERSION_MINOR=${CBOX_VERSION_MINOR}
-DCBOX_VERSION_REVISION=${CBOX_VERSION_REVISION})
if(CBOX_ENABLE_BASE)
message(STATUS "base module enabled")
add_subdirectory(src/base)
endif()
if(CBOX_ENABLE_EVENT)
message(STATUS "event module enabled")
add_subdirectory(src/event)
endif()
if(CBOX_ENABLE_MQTT)
message(STATUS "mqtt module enabled")
add_subdirectory(src/mqtt)
endif()
if(CBOX_ENABLE_SAMPLES)
message(STATUS "samples enabled")
add_subdirectory(samples)
endif()