|
@@ -0,0 +1,151 @@
|
|
|
|
|
+cmake_minimum_required(VERSION 3.22)
|
|
|
|
|
+
|
|
|
|
|
+project(smartbotic-crm
|
|
|
|
|
+ VERSION 0.1.0
|
|
|
|
|
+ DESCRIPTION "SmartBotic CRM System"
|
|
|
|
|
+ LANGUAGES CXX
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+# C++20 standard
|
|
|
|
|
+set(CMAKE_CXX_STANDARD 20)
|
|
|
|
|
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
+set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
|
+
|
|
|
|
|
+# Export compile commands for tooling
|
|
|
|
|
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
+
|
|
|
|
|
+# Build options
|
|
|
|
|
+option(BUILD_TESTING "Build tests" ON)
|
|
|
|
|
+option(ENABLE_SANITIZERS "Enable address and undefined behavior sanitizers" OFF)
|
|
|
|
|
+
|
|
|
|
|
+# Compiler warnings
|
|
|
|
|
+add_compile_options(
|
|
|
|
|
+ -Wall
|
|
|
|
|
+ -Wextra
|
|
|
|
|
+ -Wpedantic
|
|
|
|
|
+ -Werror
|
|
|
|
|
+ -Wno-unused-parameter
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+# Sanitizers for debug builds
|
|
|
|
|
+if(ENABLE_SANITIZERS)
|
|
|
|
|
+ add_compile_options(-fsanitize=address,undefined)
|
|
|
|
|
+ add_link_options(-fsanitize=address,undefined)
|
|
|
|
|
+endif()
|
|
|
|
|
+
|
|
|
|
|
+# Include FetchContent module
|
|
|
|
|
+include(FetchContent)
|
|
|
|
|
+
|
|
|
|
|
+# ============================================================================
|
|
|
|
|
+# External Dependencies via FetchContent
|
|
|
|
|
+# ============================================================================
|
|
|
|
|
+
|
|
|
|
|
+# spdlog - Fast C++ logging library
|
|
|
|
|
+FetchContent_Declare(
|
|
|
|
|
+ spdlog
|
|
|
|
|
+ GIT_REPOSITORY https://github.com/gabime/spdlog.git
|
|
|
|
|
+ GIT_TAG v1.13.0
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+# nlohmann_json - JSON for Modern C++
|
|
|
|
|
+FetchContent_Declare(
|
|
|
|
|
+ nlohmann_json
|
|
|
|
|
+ GIT_REPOSITORY https://github.com/nlohmann/json.git
|
|
|
|
|
+ GIT_TAG v3.11.3
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+# gRPC and Protobuf
|
|
|
|
|
+FetchContent_Declare(
|
|
|
|
|
+ grpc
|
|
|
|
|
+ GIT_REPOSITORY https://github.com/grpc/grpc.git
|
|
|
|
|
+ GIT_TAG v1.60.0
|
|
|
|
|
+ GIT_SHALLOW TRUE
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+# libsodium - Cryptography library
|
|
|
|
|
+FetchContent_Declare(
|
|
|
|
|
+ libsodium
|
|
|
|
|
+ GIT_REPOSITORY https://github.com/jedisct1/libsodium.git
|
|
|
|
|
+ GIT_TAG 1.0.19
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+# Make dependencies available
|
|
|
|
|
+message(STATUS "Fetching spdlog...")
|
|
|
|
|
+FetchContent_MakeAvailable(spdlog)
|
|
|
|
|
+
|
|
|
|
|
+message(STATUS "Fetching nlohmann_json...")
|
|
|
|
|
+FetchContent_MakeAvailable(nlohmann_json)
|
|
|
|
|
+
|
|
|
|
|
+message(STATUS "Fetching gRPC (this may take a while)...")
|
|
|
|
|
+set(gRPC_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
|
|
|
|
+set(gRPC_INSTALL OFF CACHE BOOL "" FORCE)
|
|
|
|
|
+set(ABSL_ENABLE_INSTALL OFF CACHE BOOL "" FORCE)
|
|
|
|
|
+set(ABSL_PROPAGATE_CXX_STD ON CACHE BOOL "" FORCE)
|
|
|
|
|
+FetchContent_MakeAvailable(grpc)
|
|
|
|
|
+
|
|
|
|
|
+# libsodium requires special handling as it uses autotools
|
|
|
|
|
+FetchContent_GetProperties(libsodium)
|
|
|
|
|
+if(NOT libsodium_POPULATED)
|
|
|
|
|
+ FetchContent_Populate(libsodium)
|
|
|
|
|
+
|
|
|
|
|
+ # Build libsodium using autotools
|
|
|
|
|
+ execute_process(
|
|
|
|
|
+ COMMAND ${libsodium_SOURCE_DIR}/configure
|
|
|
|
|
+ --prefix=${libsodium_BINARY_DIR}/install
|
|
|
|
|
+ --disable-shared
|
|
|
|
|
+ --enable-static
|
|
|
|
|
+ WORKING_DIRECTORY ${libsodium_SOURCE_DIR}
|
|
|
|
|
+ RESULT_VARIABLE SODIUM_CONFIGURE_RESULT
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ if(NOT SODIUM_CONFIGURE_RESULT EQUAL 0)
|
|
|
|
|
+ message(WARNING "libsodium configure failed, will try system libsodium")
|
|
|
|
|
+ find_package(PkgConfig REQUIRED)
|
|
|
|
|
+ pkg_check_modules(SODIUM REQUIRED libsodium)
|
|
|
|
|
+ else()
|
|
|
|
|
+ execute_process(
|
|
|
|
|
+ COMMAND make -j${CMAKE_BUILD_PARALLEL_LEVEL}
|
|
|
|
|
+ WORKING_DIRECTORY ${libsodium_SOURCE_DIR}
|
|
|
|
|
+ )
|
|
|
|
|
+ execute_process(
|
|
|
|
|
+ COMMAND make install
|
|
|
|
|
+ WORKING_DIRECTORY ${libsodium_SOURCE_DIR}
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ set(SODIUM_INCLUDE_DIRS ${libsodium_BINARY_DIR}/install/include)
|
|
|
|
|
+ set(SODIUM_LIBRARY_DIRS ${libsodium_BINARY_DIR}/install/lib)
|
|
|
|
|
+ set(SODIUM_LIBRARIES sodium)
|
|
|
|
|
+ endif()
|
|
|
|
|
+endif()
|
|
|
|
|
+
|
|
|
|
|
+# Create imported target for libsodium
|
|
|
|
|
+add_library(sodium STATIC IMPORTED GLOBAL)
|
|
|
|
|
+set_target_properties(sodium PROPERTIES
|
|
|
|
|
+ IMPORTED_LOCATION ${SODIUM_LIBRARY_DIRS}/libsodium.a
|
|
|
|
|
+ INTERFACE_INCLUDE_DIRECTORIES ${SODIUM_INCLUDE_DIRS}
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+# ============================================================================
|
|
|
|
|
+# Project Subdirectories
|
|
|
|
|
+# ============================================================================
|
|
|
|
|
+
|
|
|
|
|
+add_subdirectory(common)
|
|
|
|
|
+add_subdirectory(proto)
|
|
|
|
|
+add_subdirectory(database)
|
|
|
|
|
+add_subdirectory(webserver)
|
|
|
|
|
+add_subdirectory(webui)
|
|
|
|
|
+
|
|
|
|
|
+# ============================================================================
|
|
|
|
|
+# Summary
|
|
|
|
|
+# ============================================================================
|
|
|
|
|
+
|
|
|
|
|
+message(STATUS "")
|
|
|
|
|
+message(STATUS "SmartBotic CRM Configuration Summary")
|
|
|
|
|
+message(STATUS "=====================================")
|
|
|
|
|
+message(STATUS "Version: ${PROJECT_VERSION}")
|
|
|
|
|
+message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}")
|
|
|
|
|
+message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
|
|
|
|
|
+message(STATUS "Compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
|
|
|
|
|
+message(STATUS "Build Testing: ${BUILD_TESTING}")
|
|
|
|
|
+message(STATUS "Sanitizers: ${ENABLE_SANITIZERS}")
|
|
|
|
|
+message(STATUS "")
|