cmake_minimum_required(VERSION 3.25) project(DevPlaceApp VERSION 0.1.0 LANGUAGES C CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE RelWithDebInfo) endif() option(DEVPLACE_WERROR "Treat warnings as errors" OFF) # aiohttpcpp: installed prefix first, sibling source tree second (read-only use, never modified). list(APPEND CMAKE_PREFIX_PATH "$ENV{HOME}/.local" "$ENV{AIOHTTPCPP_PREFIX}") find_package(aiohttpcpp CONFIG QUIET) if(NOT aiohttpcpp_FOUND) if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../aiohttpcpp/CMakeLists.txt") set(AIOHTTPCPP_BUILD_TESTS OFF CACHE BOOL "" FORCE) add_subdirectory(../aiohttpcpp aiohttpcpp-build EXCLUDE_FROM_ALL) else() message(FATAL_ERROR "aiohttpcpp not found: install it (make install PREFIX=$HOME/.local) or place it at ../aiohttpcpp") endif() endif() find_package(SDL3 CONFIG REQUIRED) find_package(SDL3_ttf CONFIG REQUIRED) file(GLOB_RECURSE CORE_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp") list(FILTER CORE_SOURCES EXCLUDE REGEX "src/app/main\\.cpp$") list(FILTER CORE_SOURCES EXCLUDE REGEX "src/ui/ThirdPartyImpl\\.cpp$") add_library(app_vendor STATIC src/ui/ThirdPartyImpl.cpp) target_include_directories(app_vendor PUBLIC third_party) target_compile_options(app_vendor PRIVATE -w) add_library(app_core STATIC ${CORE_SOURCES}) target_include_directories(app_core PUBLIC src ${CMAKE_CURRENT_SOURCE_DIR} third_party) target_compile_options(app_core PRIVATE -Wall -Wextra $<$:-Werror>) target_compile_definitions(app_core PUBLIC DEVPLACE_ASSET_DIR="${CMAKE_CURRENT_SOURCE_DIR}/assets") target_link_libraries(app_core PUBLIC aiohttpcpp::aiohttpcpp SDL3::SDL3 SDL3_ttf::SDL3_ttf app_vendor) add_executable(app src/app/main.cpp) set_target_properties(app PROPERTIES OUTPUT_NAME devplaceapp) target_compile_options(app PRIVATE -Wall -Wextra $<$:-Werror>) target_link_libraries(app PRIVATE app_core) enable_testing() file(GLOB_RECURSE TEST_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/tests/*.cpp") if(TEST_SOURCES) add_executable(app_tests ${TEST_SOURCES}) target_include_directories(app_tests PRIVATE tests) target_compile_options(app_tests PRIVATE -Wall -Wextra $<$:-Werror>) target_link_libraries(app_tests PRIVATE app_core) add_test(NAME app_tests COMMAND app_tests) endif()