CMakeLists.txt 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. cmake_minimum_required(VERSION 3.22)
  2. cmake_policy(SET CMP0135 NEW)
  3. project(smartbotic-crm
  4. VERSION 0.1.0
  5. DESCRIPTION "SmartBotic CRM System"
  6. LANGUAGES CXX
  7. )
  8. # C++20 standard
  9. set(CMAKE_CXX_STANDARD 20)
  10. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  11. set(CMAKE_CXX_EXTENSIONS OFF)
  12. # Export compile commands for tooling
  13. set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
  14. # Build options
  15. option(ENABLE_SANITIZERS "Enable address and undefined behavior sanitizers" OFF)
  16. # Compiler warnings - applied only to project targets, not dependencies
  17. set(SMARTBOTIC_CXX_WARNINGS
  18. -Wall
  19. -Wextra
  20. -Wpedantic
  21. -Werror
  22. -Wno-unused-parameter
  23. -Wno-dangling-reference # False positive in spdlog's bundled fmt with GCC 13+
  24. )
  25. # Sanitizers for debug builds
  26. if(ENABLE_SANITIZERS)
  27. add_compile_options(-fsanitize=address,undefined)
  28. add_link_options(-fsanitize=address,undefined)
  29. endif()
  30. # ============================================================================
  31. # System Dependencies
  32. # Required packages: libspdlog-dev nlohmann-json3-dev
  33. # ============================================================================
  34. find_package(spdlog REQUIRED)
  35. find_package(nlohmann_json REQUIRED)
  36. # ============================================================================
  37. # FetchContent Dependencies (latest versions)
  38. # ============================================================================
  39. include(FetchContent)
  40. # cpp-httplib - Header-only HTTP library (always use latest)
  41. FetchContent_Declare(
  42. httplib
  43. GIT_REPOSITORY https://github.com/yhirose/cpp-httplib.git
  44. GIT_TAG v0.30.1
  45. )
  46. # jwt-cpp - Header-only JWT library (no compatible system package)
  47. FetchContent_Declare(
  48. jwt-cpp
  49. GIT_REPOSITORY https://github.com/Thalhammer/jwt-cpp.git
  50. GIT_TAG v0.7.1
  51. )
  52. message(STATUS "Fetching cpp-httplib...")
  53. set(HTTPLIB_REQUIRE_OPENSSL ON CACHE BOOL "" FORCE)
  54. set(HTTPLIB_COMPILE OFF CACHE BOOL "" FORCE) # Header-only mode
  55. FetchContent_MakeAvailable(httplib)
  56. message(STATUS "Fetching jwt-cpp...")
  57. set(JWT_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
  58. set(JWT_BUILD_TESTS OFF CACHE BOOL "" FORCE)
  59. set(JWT_EXTERNAL_PICOJSON OFF CACHE BOOL "" FORCE) # Use bundled picojson
  60. FetchContent_MakeAvailable(jwt-cpp)
  61. # ============================================================================
  62. # System gRPC and Protobuf (fast builds using system packages)
  63. # Required packages: libgrpc++-dev libprotobuf-dev protobuf-compiler-grpc
  64. # ============================================================================
  65. message(STATUS "Using system gRPC and Protobuf...")
  66. find_package(Protobuf REQUIRED)
  67. find_package(PkgConfig REQUIRED)
  68. pkg_check_modules(GRPC REQUIRED IMPORTED_TARGET grpc++)
  69. # Find reflection library (no pkg-config file in Ubuntu package)
  70. find_library(GRPC_REFLECTION_LIB grpc++_reflection REQUIRED)
  71. message(STATUS " grpc++_reflection: ${GRPC_REFLECTION_LIB}")
  72. # Create imported target for reflection library
  73. add_library(grpc_reflection SHARED IMPORTED)
  74. set_target_properties(grpc_reflection PROPERTIES
  75. IMPORTED_LOCATION ${GRPC_REFLECTION_LIB}
  76. INTERFACE_LINK_LIBRARIES PkgConfig::GRPC
  77. )
  78. # Find protoc and grpc_cpp_plugin executables
  79. find_program(PROTOC_EXECUTABLE protoc REQUIRED)
  80. find_program(GRPC_CPP_PLUGIN grpc_cpp_plugin REQUIRED)
  81. message(STATUS " protoc: ${PROTOC_EXECUTABLE}")
  82. message(STATUS " grpc_cpp_plugin: ${GRPC_CPP_PLUGIN}")
  83. # libwebsockets via pkg-config (system library)
  84. pkg_check_modules(LWS REQUIRED IMPORTED_TARGET libwebsockets)
  85. # OpenSSL for HTTPS support and crypto operations (replaces libsodium)
  86. find_package(OpenSSL REQUIRED)
  87. message(STATUS " OpenSSL version: ${OPENSSL_VERSION}")
  88. # ============================================================================
  89. # Project Subdirectories
  90. # ============================================================================
  91. add_subdirectory(common)
  92. add_subdirectory(proto)
  93. add_subdirectory(database)
  94. add_subdirectory(llm)
  95. add_subdirectory(webserver)
  96. add_subdirectory(webui)
  97. # ============================================================================
  98. # Summary
  99. # ============================================================================
  100. message(STATUS "")
  101. message(STATUS "SmartBotic CRM Configuration Summary")
  102. message(STATUS "=====================================")
  103. message(STATUS "Version: ${PROJECT_VERSION}")
  104. message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}")
  105. message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
  106. message(STATUS "Compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
  107. message(STATUS "Sanitizers: ${ENABLE_SANITIZERS}")
  108. message(STATUS "")