cmake_minimum_required(VERSION 3.20) project(kbot-cli VERSION 0.1.0 DESCRIPTION "KBot C++ CLI" LANGUAGES CXX C ) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/dist") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/dist") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/dist") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_SOURCE_DIR}/dist") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_SOURCE_DIR}/dist") # ── C++ standard ───────────────────────────────────────────────────────────── set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) # ── Dependencies ───────────────────────────────────────────────────────────── include(FetchContent) FetchContent_Declare( cli11 GIT_REPOSITORY https://github.com/CLIUtils/CLI11.git GIT_TAG v2.4.2 GIT_SHALLOW TRUE ) FetchContent_Declare( tomlplusplus GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git GIT_TAG v3.4.0 GIT_SHALLOW TRUE ) FetchContent_Declare( Catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_TAG v3.7.1 GIT_SHALLOW TRUE ) FetchContent_Declare( asio GIT_REPOSITORY https://github.com/chriskohlhoff/asio.git GIT_TAG asio-1-28-0 GIT_SHALLOW TRUE ) FetchContent_Declare( concurrentqueue GIT_REPOSITORY https://github.com/cameron314/concurrentqueue.git GIT_TAG v1.0.4 GIT_SHALLOW TRUE ) FetchContent_Declare( taskflow GIT_REPOSITORY https://github.com/taskflow/taskflow.git GIT_TAG v3.6.0 GIT_SHALLOW TRUE ) FetchContent_Declare( nlohmann_json GIT_REPOSITORY https://github.com/nlohmann/json.git GIT_TAG v3.11.3 GIT_SHALLOW TRUE ) FetchContent_Declare( liboai GIT_REPOSITORY https://github.com/jasonduncan/liboai.git GIT_TAG main GIT_SHALLOW TRUE SOURCE_SUBDIR liboai ) # p-ranav/glob — Unix-style glob / rglob (C++17); avoid upstream CMake (CPM + gtest). FetchContent_Declare( pranav_glob GIT_REPOSITORY https://github.com/p-ranav/glob.git GIT_TAG master GIT_SHALLOW TRUE ) FetchContent_GetProperties(pranav_glob) if(NOT pranav_glob_POPULATED) FetchContent_Populate(pranav_glob) endif() add_library(pranav_glob STATIC ${pranav_glob_SOURCE_DIR}/source/glob.cpp) target_include_directories(pranav_glob PUBLIC ${pranav_glob_SOURCE_DIR}/include) target_compile_features(pranav_glob PUBLIC cxx_std_17) if(MSVC) target_compile_options(pranav_glob PRIVATE /permissive-) endif() # laserpants/dotenv-cpp — load .env into the process environment (header-only). FetchContent_Declare( laserpants_dotenv GIT_REPOSITORY https://github.com/laserpants/dotenv-cpp.git GIT_TAG master GIT_SHALLOW TRUE ) FetchContent_GetProperties(laserpants_dotenv) if(NOT laserpants_dotenv_POPULATED) FetchContent_Populate(laserpants_dotenv) endif() add_library(laserpants_dotenv INTERFACE) target_include_directories(laserpants_dotenv INTERFACE ${laserpants_dotenv_SOURCE_DIR}/include) add_library(laserpants::dotenv ALIAS laserpants_dotenv) set(TF_BUILD_TESTS OFF CACHE BOOL "" FORCE) set(TF_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) set(JSON_BuildTests OFF CACHE BOOL "" FORCE) FetchContent_MakeAvailable(cli11 tomlplusplus Catch2 asio concurrentqueue taskflow nlohmann_json) # ── Packages ───────────────────────────────────────────────────────────────── add_subdirectory(packages/logger) add_subdirectory(packages/html) add_subdirectory(packages/postgres) add_subdirectory(packages/http) add_subdirectory(packages/json) add_subdirectory(packages/polymech) add_subdirectory(packages/ipc) add_subdirectory(packages/liboai/liboai) add_subdirectory(packages/kbot) # ── Sources ────────────────────────────────────────────────────────────────── add_executable(${PROJECT_NAME} src/main.cpp src/cmd_kbot.cpp src/cmd_kbot_uds.cpp src/sys_metrics.cpp ) # Output file name is kbot.exe / kbot (not kbot-cli) set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "kbot") target_link_libraries(${PROJECT_NAME} PRIVATE CLI11::CLI11 tomlplusplus::tomlplusplus logger html postgres http json polymech ipc kbot laserpants::dotenv) target_include_directories(${PROJECT_NAME} PRIVATE ${asio_SOURCE_DIR}/asio/include ${taskflow_SOURCE_DIR} ${concurrentqueue_SOURCE_DIR} ) # Define standalone ASIO (since it's not boost) if(WIN32) # Enable math constants like M_PI add_compile_definitions(_USE_MATH_DEFINES) add_compile_definitions(NOMINMAX) endif() target_compile_definitions(${PROJECT_NAME} PRIVATE ASIO_STANDALONE=1 ASIO_NO_DEPRECATED=1) # ── Compiler warnings ─────────────────────────────────────────────────────── if(MSVC) target_compile_options(${PROJECT_NAME} PRIVATE /W4 /permissive-) else() target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic) endif() # ── Install ────────────────────────────────────────────────────────────────── # Library + headers: see packages/kbot/CMakeLists.txt and packages/ipc/CMakeLists.txt # Optional DLL/so: configure with -DIPC_BUILD_SHARED=ON -DPOLYMECH_KBOT_SHARED=ON install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin ) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/cmd_kbot.h DESTINATION include/polymech ) # ── Tests ──────────────────────────────────────────────────────────────────── enable_testing() add_subdirectory(tests)