cmake_minimum_required(VERSION 3.20)
project(warfactory-map-module)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 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()

# Include and source directories
include_directories(include)
include_directories(../../core/include)

# Headers only (header-only library)
file(GLOB_RECURSE HEADERS "include/*.h")

# Create header-only interface library
add_library(warfactory-map-module INTERFACE)

# Set include directories for interface library
target_include_directories(warfactory-map-module INTERFACE
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
    $<INSTALL_INTERFACE:include>
)

# Link nlohmann_json as interface dependency
target_link_libraries(warfactory-map-module INTERFACE nlohmann_json::nlohmann_json)

# Install headers for other modules to use
install(DIRECTORY include/
        DESTINATION include/warfactory/map
        FILES_MATCHING PATTERN "*.h")