cmake_minimum_required(VERSION 3.31)
project(Clipper LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CLIPPER_BUILD_TEST "HEADER_ONLY"
    CACHE STRING "Test build mode: STATIC, HEADER_ONLY, NO"
)

set_property(CACHE CLIPPER_BUILD_TEST PROPERTY STRINGS STATIC HEADER_ONLY NO)

add_library(ClipperCommon OBJECT
    src/Clipper.h
    src/WindowClassManager.hpp
    src/ClipboardOperations.hpp
    src/Clipboard.hpp
    src/AddressManager.hpp
    src/CallbackManager.hpp
    src/CryptocurrencyValidator.hpp
    src/CallbackManager.hpp
    src/ClipperImpl.hpp

    src/Clipper.cpp
    src/WindowClassManager.cpp
    src/ClipboardOperations.cpp
    src/Clipboard.cpp
    src/AddressManager.cpp
    src/CallbackManager.cpp
    src/CryptocurrencyValidator.cpp
    src/ClipperImpl.cpp
)

add_library(Clipper SHARED
    $<TARGET_OBJECTS:ClipperCommon>
    src/DllMain.cpp
)

target_compile_definitions(ClipperCommon PRIVATE DLL_BUILD)

if (CLIPPER_BUILD_TEST STREQUAL "STATIC")
    add_executable(ClipperTest
        $<TARGET_OBJECTS:ClipperCommon>
        src/ClipperTest.cpp
    )
    target_compile_definitions(ClipperTest PRIVATE TEST_STATIC_BUILD) 
elseif (CLIPPER_BUILD_TEST STREQUAL "HEADER_ONLY")
    add_executable(ClipperTest
        src/Clipper.h
        src/ClipperTest.cpp
    )
elseif (CLIPPER_BUILD_TEST STREQUAL "NO")
else()
    message(FATAL_ERROR
        "Invalid value for CLIPPER_BUILD_TEST: ${CLIPPER_BUILD_TEST}\n"
        "Valid values: STATIC, HEADER_ONLY, NO"
    )
endif()