project(ANSCustomWeaponDetection LANGUAGES CXX)

# ---------- sources ----------
set(SOURCES
    ANSCustomCodeWeaponDetection.cpp
    dllmain.cpp
    pch.cpp
)

set(HEADERS
    ANSCustomCodeWeaponDetection.h
    framework.h
    pch.h
)

# ---------- shared library (DLL) ----------
add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS})

# ---------- preprocessor definitions ----------
target_compile_definitions(${PROJECT_NAME} PRIVATE
    ANSCUSTOMCODE_EXPORTS
    _WINDOWS
    _USRDLL
    WIN32_LEAN_AND_MEAN
    NOMINMAX
    $<$<CONFIG:Debug>:_DEBUG>
    $<$<CONFIG:Release>:NDEBUG>
)

# ---------- include directories ----------
target_include_directories(${PROJECT_NAME} PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}
    C:/ProgramData/ANSCENTER/Shared              # ANSLIB.h + ANSLIB.lib from same location
    C:/ANSLibs/opencv/include
)

# ---------- library directories & linking ----------
target_link_directories(${PROJECT_NAME} PRIVATE
    C:/ProgramData/ANSCENTER/Shared
    C:/ANSLibs/opencv/x64/vc17/lib
)

target_link_libraries(${PROJECT_NAME} PRIVATE
    ANSLIB
    opencv_world4130
)

# ---------- compiler options (MSVC) ----------
if(MSVC)
    target_compile_options(${PROJECT_NAME} PRIVATE
        /W3          # Warning level 3
        /sdl         # SDL checks
        /permissive- # Conformance mode
        /Zi          # Generate full debug info (PDB) in all configs
        $<$<CONFIG:Release>:/O2 /Oi>  # Optimize + intrinsics (no /GL — incompatible with debugging)
    )

    target_link_options(${PROJECT_NAME} PRIVATE
        /DEBUG       # Emit PDB for debugger in all configs
        $<$<CONFIG:Release>:/OPT:REF /OPT:ICF>  # Optimize refs, COMDAT folding (no /LTCG — incompatible with debugging)
    )
endif()
