generated from simonthorell/cpp-cmake-googletest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
54 lines (46 loc) · 1.62 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
#================== CMake Configuration ===================#
cmake_minimum_required(VERSION 3.28.2)
project(cpp-mqtt-sqlite) # Project name
#=================== Set C++ Standard ====================#
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
#================= Set Build Configuration ================#
# Debug configuration
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message("Debug build")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/debug)
add_compile_options(
-g # Debug information
-Werror # Treat warnings as errors
-Wall # Enable all warnings
-Wextra # Enable extra warnings
-pedantic # Ensure standards-compliant code
)
# Release configuration
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
message("Release build")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/release)
add_compile_options(
-O2 # Optimization level 2
)
# Other configurations (if needed)
else()
message("Other build configuration")
endif()
#================= Find Installed Packages ================#
find_library(MOSQUITTO_LIB NAMES mosquitto)
find_package(OpenSSL REQUIRED)
find_package(SQLite3 REQUIRED)
#==================== Fetch Libraries =====================#
# Fetch external libraries
include(FetchContent)
# Fetch the JSON library as it's a header-only library
FetchContent_Declare(
json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.11.3
)
FetchContent_MakeAvailable(json)
#=================== Add Subdirectories ===================#
add_subdirectory(src)
add_subdirectory(tests)