cmake_minimum_required(VERSION 3.20)
project(Inject LANGUAGES CXX)

# Force x86 (32-bit) build
if(NOT CMAKE_SIZEOF_VOID_P EQUAL 4)
    message(WARNING "Inject.DLL must be built as x86 (32-bit). Use -A Win32 with Visual Studio generator.")
endif()

add_library(Inject SHARED
    Inject.cpp
    Inject.h
    Inject.def
)

target_compile_definitions(Inject PRIVATE
    WIN32
    _WINDOWS
    INJECT_EXPORTS
    _USRDLL
    UNICODE
    _UNICODE
)

target_link_libraries(Inject PRIVATE
    d3d9
    advapi32
    user32
    kernel32
    ole32
    oleaut32
)

# MSVC-specific settings
if(MSVC)
    target_compile_options(Inject PRIVATE /W3 /GR- /EHsc)
    set_target_properties(Inject PROPERTIES
        RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
        MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL"
    )
endif()

set_target_properties(Inject PROPERTIES
    OUTPUT_NAME "Inject"
    SUFFIX ".DLL"
)
