diff options
| author | ilotterytea <iltsu@alright.party> | 2025-03-31 19:45:59 +0400 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-03-31 19:45:59 +0400 |
| commit | e1d3f72ac38b4dad55d1d02f945e50f086299644 (patch) | |
| tree | a0777efb4d2863e54ce1afd287c352eb3a89f868 | |
| parent | 0581549cc5f5f6b80d681c55bed4b17783f1fd48 (diff) | |
upd: separated cmake files
| -rw-r--r-- | CMakeLists.txt | 82 | ||||
| -rw-r--r-- | bot/CMakeLists.txt | 63 | ||||
| -rw-r--r-- | web/CMakeLists.txt | 40 |
3 files changed, 105 insertions, 80 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 802c0e3..b60cb18 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,4 @@ cmake_minimum_required(VERSION 3.10) -include(FetchContent) project( RedpilledBot @@ -12,90 +11,13 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -add_definitions(-DUSE_TLS=1) - -file(GLOB_RECURSE BOT_SRC_FILES "bot/src/*.cpp" "bot/src/*.h" "bot/src/*.hpp") -file(GLOB_RECURSE WEB_SRC_FILES "web/src/*.cpp" "web/src/*.h" "web/src/*.hpp") - option(BUILD_BOT "Build the bot" ON) option(BUILD_WEB "Build the web application" ON) if (BUILD_BOT) - add_executable(Bot) - - if(CMAKE_BUILD_TYPE STREQUAL "Debug") - target_compile_definitions(Bot PRIVATE DEBUG_MODE) - endif() - - set_target_properties( - Bot PROPERTIES - DESCRIPTION ${PROJECT_DESCRIPTION} - OUTPUT_NAME "redpilledbot" - ) - - target_sources(Bot PRIVATE ${BOT_SRC_FILES}) - - # Getting libraries - # json - FetchContent_Declare( - json - URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz - ) - FetchContent_MakeAvailable(json) - - # http request maker - FetchContent_Declare( - cpr - GIT_REPOSITORY https://github.com/libcpr/cpr.git - GIT_TAG 1.10.5 - ) - FetchContent_MakeAvailable(cpr) - - # postgresql - FetchContent_Declare( - pqxx - GIT_REPOSITORY https://github.com/jtv/libpqxx.git - GIT_TAG 7.9.2 - ) - FetchContent_MakeAvailable(pqxx) - - FetchContent_Declare( - ixwebsocket - GIT_REPOSITORY https://github.com/machinezone/IXWebSocket - GIT_TAG v11.4.5 - ) - FetchContent_MakeAvailable(ixwebsocket) - - target_link_libraries(Bot PRIVATE ixwebsocket::ixwebsocket pqxx nlohmann_json::nlohmann_json cpr::cpr) + add_subdirectory(bot) endif() if (BUILD_WEB) - add_executable(Web) - - set_target_properties( - Web PROPERTIES - DESCRIPTION ${PROJECT_DESCRIPTION} - OUTPUT_NAME "redpilledweb" - ) - - target_sources(Web PRIVATE ${WEB_SRC_FILES}) - - # web framework - FetchContent_Declare( - crow - GIT_REPOSITORY https://github.com/CrowCpp/Crow - GIT_TAG v1.1.0 - ) - FetchContent_MakeAvailable(crow) - - # markdown parser - FetchContent_Declare( - maddy - GIT_REPOSITORY https://github.com/progsource/maddy.git - GIT_TAG 1.3.0 - ) - FetchContent_MakeAvailable(maddy) - - target_include_directories(Web PRIVATE ${crow_SOURCE_DIR}/include) - target_link_libraries(Web PRIVATE maddy) + add_subdirectory(web) endif() diff --git a/bot/CMakeLists.txt b/bot/CMakeLists.txt new file mode 100644 index 0000000..4f02d17 --- /dev/null +++ b/bot/CMakeLists.txt @@ -0,0 +1,63 @@ +cmake_minimum_required(VERSION 3.10) +include(FetchContent) + +# Creating symbolic links +file(CREATE_LINK "${CMAKE_SOURCE_DIR}/localization" "${CMAKE_CURRENT_BINARY_DIR}/localization" SYMBOLIC) +if (EXISTS "${CMAKE_SOURCE_DIR}/.env") + file(CREATE_LINK "${CMAKE_SOURCE_DIR}/.env" "${CMAKE_CURRENT_BINARY_DIR}/.env" SYMBOLIC) +endif() + +add_executable(Bot) + +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + target_compile_definitions(Bot PRIVATE DEBUG_MODE) +endif() + +set_target_properties( + Bot PROPERTIES + DESCRIPTION ${PROJECT_DESCRIPTION} + OUTPUT_NAME "${PROJECT_NAME}-bot" +) + +# TLS for websocket connections +set(USE_TLS ON CACHE BOOL "Enable TLS support") + +file(GLOB_RECURSE SOURCE_FILES "src/*.cpp" "src/*.h" "src/*.hpp") + +target_sources(Bot PRIVATE ${SOURCE_FILES}) +target_include_directories(Bot PRIVATE src) + +# Getting libraries + +# json +FetchContent_Declare( + json + URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz +) +FetchContent_MakeAvailable(json) + +# http request maker +FetchContent_Declare( + cpr + GIT_REPOSITORY https://github.com/libcpr/cpr.git + GIT_TAG 1.10.5 +) +FetchContent_MakeAvailable(cpr) + +# postgresql +FetchContent_Declare( + pqxx + GIT_REPOSITORY https://github.com/jtv/libpqxx.git + GIT_TAG 7.9.2 +) +FetchContent_MakeAvailable(pqxx) + +FetchContent_Declare( + ixwebsocket + GIT_REPOSITORY https://github.com/machinezone/IXWebSocket + GIT_TAG v11.4.5 +) +FetchContent_MakeAvailable(ixwebsocket) + +target_link_libraries(Bot PRIVATE ixwebsocket::ixwebsocket pqxx nlohmann_json::nlohmann_json cpr::cpr) + diff --git a/web/CMakeLists.txt b/web/CMakeLists.txt new file mode 100644 index 0000000..11a11bf --- /dev/null +++ b/web/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.10) +include(FetchContent) + +# Creating symbolic links +file(CREATE_LINK "${CMAKE_SOURCE_DIR}/static" "${CMAKE_CURRENT_BINARY_DIR}/static" SYMBOLIC) +file(CREATE_LINK "${CMAKE_SOURCE_DIR}/templates" "${CMAKE_CURRENT_BINARY_DIR}/templates" SYMBOLIC) +file(CREATE_LINK "${CMAKE_SOURCE_DIR}/docs" "${CMAKE_CURRENT_BINARY_DIR}/docs" SYMBOLIC) +if (EXISTS "${CMAKE_SOURCE_DIR}/.env") + file(CREATE_LINK "${CMAKE_SOURCE_DIR}/.env" "${CMAKE_CURRENT_BINARY_DIR}/.env" SYMBOLIC) +endif() + +add_executable(Web) + +set_target_properties( + Web PROPERTIES + DESCRIPTION ${PROJECT_DESCRIPTION} + OUTPUT_NAME "${PROJECT_NAME}-web" +) + +file(GLOB_RECURSE SOURCE_FILES "src/*.cpp" "src/*.h" "src/*.hpp") +target_sources(Web PRIVATE ${SOURCE_FILES}) + +# web framework +FetchContent_Declare( + crow + GIT_REPOSITORY https://github.com/CrowCpp/Crow + GIT_TAG v1.1.0 +) +FetchContent_MakeAvailable(crow) + +# markdown parser +FetchContent_Declare( + maddy + GIT_REPOSITORY https://github.com/progsource/maddy.git + GIT_TAG 1.3.0 +) +FetchContent_MakeAvailable(maddy) + +target_include_directories(Web PRIVATE ${crow_SOURCE_DIR}/include) +target_link_libraries(Web PRIVATE maddy)
\ No newline at end of file |
