cmake_minimum_required(VERSION 3.20) project(EconomyModule LANGUAGES CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -DDEBUG") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) endif() # Find nlohmann_json find_package(nlohmann_json QUIET) # Minimal FetchContent for missing deps if(NOT nlohmann_json_FOUND) include(FetchContent) FetchContent_Declare(nlohmann_json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz URL_HASH SHA256=d6c65aca6b1ed68e7a182f4757257b107ae403032760ed6ef121c9d55e81757d ) FetchContent_MakeAvailable(nlohmann_json) endif() set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build) include_directories(shared) # Economy module as shared library (.so) add_library(economy-module SHARED src/EconomyModule.cpp ) set_target_properties(economy-module PROPERTIES PREFIX "" SUFFIX ".so" OUTPUT_NAME "economy" ) # Test executable add_executable(economy-test src/EconomyModule.cpp tests/EconomyTest.cpp ) # Standalone executable add_executable(economy-standalone src/EconomyModule.cpp src/main.cpp ) # Link nlohmann_json to all targets target_link_libraries(economy-module PRIVATE nlohmann_json::nlohmann_json) target_link_libraries(economy-test PRIVATE nlohmann_json::nlohmann_json) target_link_libraries(economy-standalone PRIVATE nlohmann_json::nlohmann_json) add_custom_target(build-economy DEPENDS economy-module COMMENT "Building economy.so module" ) add_custom_target(test-economy DEPENDS economy-test COMMAND ./build/economy-test COMMENT "Running economy module tests" ) add_custom_target(clean-economy COMMAND ${CMAKE_COMMAND} -E remove_directory build COMMAND ${CMAKE_COMMAND} -E make_directory build COMMENT "Cleaning economy module build" ) message(STATUS "💰 Economy Module configured:") message(STATUS " cmake . : Configure") message(STATUS " make economy-module : Build economy.so") message(STATUS " make test-economy : Run tests") message(STATUS " make clean-economy : Clean build")