# pdfengine — the C++23 PDF SDK core.
#
# Phase 0 scope: a minimal-but-real static library that compiles, links against
# its vcpkg dependencies, and exposes version/build introspection. Feature
# modules (parser, render, text, core) are filled in from Phase 1 onward.

# Generate the version header from the project version.
configure_file(
    "${CMAKE_CURRENT_SOURCE_DIR}/include/pdfengine/version.hpp.in"
    "${CMAKE_CURRENT_BINARY_DIR}/generated/pdfengine/version.hpp"
    @ONLY)

add_library(pdfengine STATIC
    src/core/engine_info.cpp
    src/parser/pdfium_loader.cpp
)
add_library(pdfengine::pdfengine ALIAS pdfengine)

target_include_directories(pdfengine
    PUBLIC
        "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
        "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated>"
    PRIVATE
        "${CMAKE_CURRENT_SOURCE_DIR}/src"
)

# Dependencies resolved by vcpkg.
#   spdlog            - logging, used now (engine blueprint §13.1).
#   freetype/harfbuzz - linked now to prove the vcpkg toolchain end to end;
#                       actually exercised by Dev 3 from Phase 1 onward.
target_link_libraries(pdfengine
    PUBLIC
        spdlog::spdlog
    PRIVATE
        freetype
        harfbuzz::harfbuzz
)

# PDFium is optional in Phase 0 (built from source separately). When enabled,
# only this target gets the macro + link — and only src/parser/ uses it (R2).
if(PDFENGINE_WITH_PDFIUM)
    target_link_libraries(pdfengine PRIVATE pdfium::pdfium)
    target_compile_definitions(pdfengine PRIVATE PDFENGINE_WITH_PDFIUM)
endif()

pdfengine_set_warnings(pdfengine)
pdfengine_enable_sanitizers(pdfengine)

if(PDFENGINE_BUILD_TESTS)
    add_subdirectory(tests)
endif()
