2025-12-07 12:00:44 -07:00
|
|
|
cmake_minimum_required(VERSION 3.20)
|
|
|
|
|
project(SCARChat VERSION 1.0.0 LANGUAGES C CXX)
|
|
|
|
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
set(CMAKE_C_STANDARD 99)
|
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
|
2025-12-07 20:12:08 -07:00
|
|
|
# Enable AddressSanitizer for debugging
|
|
|
|
|
option(ENABLE_ASAN "Enable AddressSanitizer" OFF)
|
|
|
|
|
if(ENABLE_ASAN)
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer -g")
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer -g")
|
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
|
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address")
|
|
|
|
|
message(STATUS "AddressSanitizer enabled")
|
|
|
|
|
endif()
|
|
|
|
|
|
2025-12-07 12:00:44 -07:00
|
|
|
# Options
|
|
|
|
|
option(BUILD_SERVER "Build the SCAR Chat server" ON)
|
|
|
|
|
option(BUILD_CLIENT "Build the SCAR Chat client" ON)
|
|
|
|
|
option(BUILD_TESTS "Build unit tests" OFF)
|
|
|
|
|
|
|
|
|
|
# Find required packages
|
|
|
|
|
find_package(Boost REQUIRED COMPONENTS system thread)
|
|
|
|
|
find_package(OpenSSL REQUIRED)
|
|
|
|
|
find_package(SQLite3 REQUIRED)
|
|
|
|
|
|
|
|
|
|
if(BUILD_CLIENT)
|
|
|
|
|
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets Network Sql)
|
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
|
set(CMAKE_AUTORCC ON)
|
|
|
|
|
set(CMAKE_AUTOUIC ON)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# Third-party libraries
|
|
|
|
|
add_subdirectory(third_party)
|
|
|
|
|
|
|
|
|
|
# Common/shared code
|
|
|
|
|
add_subdirectory(shared)
|
|
|
|
|
|
|
|
|
|
# Server
|
|
|
|
|
if(BUILD_SERVER)
|
|
|
|
|
add_subdirectory(server)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# Client
|
|
|
|
|
if(BUILD_CLIENT)
|
|
|
|
|
add_subdirectory(client)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# Database manager utility
|
|
|
|
|
add_subdirectory(dbmanager)
|
|
|
|
|
|
|
|
|
|
# Tests
|
|
|
|
|
if(BUILD_TESTS)
|
|
|
|
|
enable_testing()
|
|
|
|
|
add_subdirectory(tests)
|
|
|
|
|
endif()
|