# cmake/ThirdParty.cmake

include("${CMAKE_CURRENT_LIST_DIR}/FetchDependencies.cmake")

macro(log msg)
    message(STATUS "[ThirdParty] ${msg}")
endmacro()

set(BUILD_CONFIGS Debug Release)


# ===========================================
# 1) ZLIB (zlib131.zip → zlib-1.3.1) - без изменений
# ===========================================
set(ZLIB_SRC_DIR      "${THIRDPARTY_DIR}/zlib-1.3.1")
set(ZLIB_BUILD_DIR    "${ZLIB_SRC_DIR}/build")
set(ZLIB_INSTALL_DIR  "${ZLIB_SRC_DIR}/install")


file(MAKE_DIRECTORY "${ZLIB_BUILD_DIR}")

# проверяем, собран ли уже zlib
set(_have_zlib FALSE)
foreach(candidate
    "${ZLIB_INSTALL_DIR}/lib/zlibstatic.lib"
)
    if(EXISTS "${candidate}")
        set(_have_zlib TRUE)
        break()
    endif()
endforeach()


if(NOT _have_zlib)
    log("Configuring zlib ...")
    execute_process(
        COMMAND ${CMAKE_COMMAND}
            -G "${CMAKE_GENERATOR}"
            -S "${ZLIB_SRC_DIR}"
            -B "${ZLIB_BUILD_DIR}"
            -DCMAKE_INSTALL_PREFIX=${ZLIB_INSTALL_DIR}
        RESULT_VARIABLE _zlib_cfg_res
    )
    if(NOT _zlib_cfg_res EQUAL 0)
        message(FATAL_ERROR "zlib configure failed")
    endif()

	foreach(cfg IN LISTS BUILD_CONFIGS)
        log("Building ZLIB (${cfg}) ...")
        execute_process(
            COMMAND ${CMAKE_COMMAND}
                --build "${ZLIB_BUILD_DIR}" --config ${cfg}
            RESULT_VARIABLE _zlib_build_res
        )
        if(NOT _zlib_build_res EQUAL 0)
            message(FATAL_ERROR "ZLIB build failed for configuration ${cfg}")
        endif()

        log("Installing ZLIB (${cfg}) ...")
        execute_process(
            COMMAND ${CMAKE_COMMAND}
                --install "${ZLIB_BUILD_DIR}" --config ${cfg}
            RESULT_VARIABLE _zlib_inst_res
        )
        if(NOT _zlib_inst_res EQUAL 0)
            message(FATAL_ERROR "ZLIB install failed for configuration ${cfg}")
        endif()
    endforeach()
endif()

# ИСПРАВЛЕНИЕ: Используем свойства для конкретных конфигураций
add_library(zlib_external_lib UNKNOWN IMPORTED GLOBAL)
set_target_properties(zlib_external_lib PROPERTIES
    # Динамическая линковка (если zlib.lib - это импорт-библиотека для zlibd.dll)
    #IMPORTED_LOCATION_DEBUG   "${ZLIB_INSTALL_DIR}/lib/zlibd.lib"
    #IMPORTED_LOCATION_RELEASE "${ZLIB_INSTALL_DIR}/lib/zlib.lib"
    
    # Можно также указать статические библиотеки, если вы хотите их использовать
    IMPORTED_LOCATION_DEBUG   "${ZLIB_INSTALL_DIR}/lib/zlibstaticd.lib"
    IMPORTED_LOCATION_RELEASE "${ZLIB_INSTALL_DIR}/lib/zlibstatic.lib"

    INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INSTALL_DIR}/include"
)

# ===========================================
# 2) SDL2 (release-2.32.10.zip → SDL-release-2.32.10) - без изменений
# ===========================================
set(SDL2_SRC_DIR      "${THIRDPARTY_DIR}/SDL-release-2.32.10")
set(SDL2_BUILD_DIR    "${SDL2_SRC_DIR}/build")
set(SDL2_INSTALL_DIR  "${SDL2_SRC_DIR}/install")

file(MAKE_DIRECTORY "${SDL2_BUILD_DIR}")

set(_have_sdl2 FALSE)
foreach(candidate
    "${SDL2_INSTALL_DIR}/lib/SDL2.lib"
    "${SDL2_INSTALL_DIR}/lib/SDL2-static.lib"
    "${SDL2_INSTALL_DIR}/lib/SDL2d.lib"
)
    if(EXISTS "${candidate}")
        set(_have_sdl2 TRUE)
        break()
    endif()
endforeach()

if(NOT _have_sdl2)
    log("Configuring SDL2 ...")
    execute_process(
        COMMAND ${CMAKE_COMMAND}
            -G "${CMAKE_GENERATOR}"
            -S "${SDL2_SRC_DIR}"
            -B "${SDL2_BUILD_DIR}"
            -DCMAKE_INSTALL_PREFIX=${SDL2_INSTALL_DIR}
            -DCMAKE_PREFIX_PATH=${ZLIB_INSTALL_DIR}   # путь к zlib для SDL2
        RESULT_VARIABLE _sdl_cfg_res
    )
    if(NOT _sdl_cfg_res EQUAL 0)
        message(FATAL_ERROR "SDL2 configure failed")
    endif()

    # --- ИЗМЕНЕНИЕ: Цикл по конфигурациям Debug и Release ---
    foreach(cfg IN LISTS BUILD_CONFIGS)
        log("Building SDL2 (${cfg}) ...")
        execute_process(
            COMMAND ${CMAKE_COMMAND}
                --build "${SDL2_BUILD_DIR}" --config ${cfg}
            RESULT_VARIABLE _sdl_build_res
        )
        if(NOT _sdl_build_res EQUAL 0)
            message(FATAL_ERROR "SDL2 build failed for configuration ${cfg}")
        endif()

        log("Installing SDL2 (${cfg}) ...")
        execute_process(
            COMMAND ${CMAKE_COMMAND}
                --install "${SDL2_BUILD_DIR}" --config ${cfg}
            RESULT_VARIABLE _sdl_inst_res
        )
        if(NOT _sdl_inst_res EQUAL 0)
            message(FATAL_ERROR "SDL2 install failed for configuration ${cfg}")
        endif()
    endforeach()
    # ------------------------------------------------------
endif()


# ИСПРАВЛЕНИЕ: SDL2: Используем свойства для конкретных конфигураций
add_library(SDL2_external_lib UNKNOWN IMPORTED GLOBAL)
set_target_properties(SDL2_external_lib PROPERTIES
 # Динамическая линковка SDL2
 IMPORTED_LOCATION_DEBUG "${SDL2_INSTALL_DIR}/lib/SDL2d.lib"
 IMPORTED_LOCATION_RELEASE "${SDL2_INSTALL_DIR}/lib/SDL2.lib"
    # Оба include-пути: и include, и include/SDL2
    INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INSTALL_DIR}/include;${SDL2_INSTALL_DIR}/include/SDL2"
)

# SDL2main (обычно статическая)
add_library(SDL2main_external_lib UNKNOWN IMPORTED GLOBAL)
set_target_properties(SDL2main_external_lib PROPERTIES
    # ИСПРАВЛЕНО: Указываем пути для Debug и Release, используя
    # соглашение, что Debug имеет суффикс 'd', а Release — нет.
    IMPORTED_LOCATION_DEBUG   "${SDL2_INSTALL_DIR}/lib/SDL2maind.lib"
    IMPORTED_LOCATION_RELEASE "${SDL2_INSTALL_DIR}/lib/SDL2main.lib"
    INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INSTALL_DIR}/include"
)

log("-----${SDL2_INSTALL_DIR}/lib/SDL2maind.lib")

# ===========================================
# 3) libpng (v1.6.51.zip → libpng-1.6.51) - без изменений
# ===========================================
set(LIBPNG_SRC_DIR      "${THIRDPARTY_DIR}/libpng-1.6.51")
set(LIBPNG_BUILD_DIR    "${LIBPNG_SRC_DIR}/build")
set(LIBPNG_INSTALL_DIR  "${LIBPNG_SRC_DIR}/install")  # на будущее

file(MAKE_DIRECTORY "${LIBPNG_BUILD_DIR}")

# Проверяем, есть ли уже .lib (build/Debug или install/lib)
set(_libpng_candidates
    "${LIBPNG_BUILD_DIR}/Debug/libpng16_staticd.lib"
	"${LIBPNG_BUILD_DIR}/Release/libpng16_static.lib"
)

set(_have_png FALSE)
foreach(candidate IN LISTS _libpng_candidates)
    if(EXISTS "${candidate}")
        set(_have_png TRUE)
        break()
    endif()
endforeach()

if(NOT _have_png)
    log("Configuring libpng ...")
    execute_process(
        COMMAND ${CMAKE_COMMAND}
            -G "${CMAKE_GENERATOR}"
            -S "${LIBPNG_SRC_DIR}"
            -B "${LIBPNG_BUILD_DIR}"
            -DCMAKE_INSTALL_PREFIX=${LIBPNG_INSTALL_DIR}
            -DCMAKE_PREFIX_PATH=${ZLIB_INSTALL_DIR}
            -DZLIB_ROOT=${ZLIB_INSTALL_DIR}
        RESULT_VARIABLE _png_cfg_res
    )
    if(NOT _png_cfg_res EQUAL 0)
        message(FATAL_ERROR "libpng configure failed")
    endif()

    # --- ИЗМЕНЕНИЕ: Цикл по конфигурациям Debug и Release ---
    foreach(cfg IN LISTS BUILD_CONFIGS)
        log("Building libpng (${cfg}) ...")
        execute_process(
            COMMAND ${CMAKE_COMMAND}
                --build "${LIBPNG_BUILD_DIR}" --config ${cfg}
            RESULT_VARIABLE _png_build_res
        )
        if(NOT _png_build_res EQUAL 0)
            message(FATAL_ERROR "libpng build failed for configuration ${cfg}")
        endif()
        
        # Поскольку вы не используете "cmake --install" для libpng, 
        # здесь нет необходимости в дополнительном шаге установки.
        # Файлы .lib будут сгенерированы в подкаталоге ${LIBPNG_BUILD_DIR}/${cfg} (например, build/Debug или build/Release).
        
    endforeach()
    # ------------------------------------------------------
endif()

add_library(libpng_external_lib UNKNOWN IMPORTED GLOBAL)
set_target_properties(libpng_external_lib PROPERTIES
    # Предполагая, что libpng использует статический вариант
    IMPORTED_LOCATION_DEBUG "${LIBPNG_BUILD_DIR}/Debug/libpng16_staticd.lib" 
    IMPORTED_LOCATION_RELEASE "${LIBPNG_BUILD_DIR}/Release/libpng16_static.lib" 
    
    # png.h, pngconf.h – в SRC, pnglibconf.h – в BUILD
    INTERFACE_INCLUDE_DIRECTORIES "${LIBPNG_SRC_DIR};${LIBPNG_BUILD_DIR}"
)

# ===========================================
# 4) libzip (v1.11.4.zip → libzip-1.11.4) - НОВАЯ ЗАВИСИМОСТЬ
# ===========================================
set(LIBZIP_SRC_DIR      "${THIRDPARTY_DIR}/libzip-1.11.4")
set(LIBZIP_BUILD_DIR    "${LIBZIP_SRC_DIR}/build")
#set(LIBZIP_INSTALL_DIR  "${LIBZIP_SRC_DIR}/install")
set(LIBZIP_BASE_DIR "${LIBZIP_SRC_DIR}/install")

file(MAKE_DIRECTORY "${LIBZIP_BUILD_DIR}")

# Проверяем, собран ли уже libzip
set(_have_zip FALSE)
foreach(candidate
    "${LIBZIP_BASE_DIR}-Debug/lib/zip.lib"
    "${LIBZIP_BASE_DIR}-Release/lib/zip.lib"
)
    if(EXISTS "${candidate}")
        set(_have_zip TRUE)
        break()
    endif()
endforeach()

if(NOT _have_zip)
    foreach(cfg IN LISTS BUILD_CONFIGS)
    log("Configuring libzip (${cfg})...")
    execute_process(
        COMMAND ${CMAKE_COMMAND}
            -G "${CMAKE_GENERATOR}"
            -S "${LIBZIP_SRC_DIR}"
            -B "${LIBZIP_SRC_DIR}/build-${cfg}"
            -DCMAKE_INSTALL_PREFIX=${LIBZIP_BASE_DIR}-${cfg}
            -DCMAKE_PREFIX_PATH=${ZLIB_INSTALL_DIR}
            -DZLIB_ROOT=${ZLIB_INSTALL_DIR}
            -DENABLE_COMMONCRYPTO=OFF
            -DENABLE_GNUTLS=OFF
            -DENABLE_MBEDTLS=OFF
            -DENABLE_OPENSSL=OFF
            -DENABLE_WINDOWS_CRYPTO=OFF
            -DENABLE_FUZZ=OFF
        RESULT_VARIABLE _zip_cfg_res
    )
        if(NOT _zip_cfg_res EQUAL 0)
        message(FATAL_ERROR "libzip configure failed")
    endif()
        log("Building libzip (${cfg}) ...")
		
		
        execute_process(
            COMMAND ${CMAKE_COMMAND} --build "${LIBZIP_SRC_DIR}/build-${cfg}" --config ${cfg} -v
            RESULT_VARIABLE _zip_build_res
        )
                if(NOT _zip_build_res EQUAL 0)
            message(FATAL_ERROR "libzip build failed for configuration ${cfg}")
        endif()

        log("Installing libzip (${cfg}) ...")
		
        execute_process(
            COMMAND ${CMAKE_COMMAND} --install "${LIBZIP_SRC_DIR}/build-${cfg}" --config ${cfg} -v
            RESULT_VARIABLE _zip_inst_res
        )
		if(NOT _zip_inst_res EQUAL 0)
            message(FATAL_ERROR "libzip install failed for configuration ${cfg}")
        endif()
    endforeach()
endif()


add_library(libzip_external_lib UNKNOWN IMPORTED GLOBAL)
set_target_properties(libzip_external_lib PROPERTIES
    IMPORTED_LOCATION_DEBUG   "${LIBZIP_BASE_DIR}-Debug/lib/zip.lib" # ИСПРАВЛЕНО
    IMPORTED_LOCATION_RELEASE "${LIBZIP_BASE_DIR}-Release/lib/zip.lib" # ИСПРАВЛЕНО

    INTERFACE_INCLUDE_DIRECTORIES "$<IF:$<CONFIG:Debug>,${LIBZIP_BASE_DIR}-Debug/include,${LIBZIP_BASE_DIR}-Release/include>"
    # libzip требует zlib для линковки
    INTERFACE_LINK_LIBRARIES zlib_external_lib
)

# ===========================================
# 5) FreeType (2.14.1) - dependency for SDL_ttf
# ===========================================
set(FREETYPE_SRC_DIR   "${THIRDPARTY_DIR}/freetype-2.14.1")
set(FREETYPE_BASE_DIR  "${FREETYPE_SRC_DIR}/install")

set(_have_freetype TRUE)
foreach(cfg IN LISTS BUILD_CONFIGS)
    if(NOT EXISTS "${FREETYPE_BASE_DIR}-${cfg}/lib/freetype.lib" AND
       NOT EXISTS "${FREETYPE_BASE_DIR}-${cfg}/lib/freetyped.lib")
        set(_have_freetype FALSE)
    endif()
endforeach()

if(NOT _have_freetype)
    foreach(cfg IN LISTS BUILD_CONFIGS)
        log("Configuring FreeType (${cfg}) ...")
        execute_process(
            COMMAND ${CMAKE_COMMAND}
                -G "${CMAKE_GENERATOR}"
                -S "${FREETYPE_SRC_DIR}"
                -B "${FREETYPE_SRC_DIR}/build-${cfg}"
                -DCMAKE_INSTALL_PREFIX=${FREETYPE_BASE_DIR}-${cfg}
                -DCMAKE_PREFIX_PATH="${ZLIB_INSTALL_DIR};${LIBPNG_INSTALL_DIR}"
                -DCMAKE_DISABLE_FIND_PACKAGE_HarfBuzz=TRUE
                -DCMAKE_DISABLE_FIND_PACKAGE_BZip2=TRUE
                -DFT_DISABLE_BROTLI=ON
                -DBUILD_SHARED_LIBS=OFF
            RESULT_VARIABLE _ft_cfg_res
        )
        if(NOT _ft_cfg_res EQUAL 0)
            message(FATAL_ERROR "FreeType configure failed for ${cfg}")
        endif()

        log("Building FreeType (${cfg}) ...")
        execute_process(
            COMMAND ${CMAKE_COMMAND}
                --build "${FREETYPE_SRC_DIR}/build-${cfg}" --config ${cfg}
            RESULT_VARIABLE _ft_build_res
        )
        if(NOT _ft_build_res EQUAL 0)
            message(FATAL_ERROR "FreeType build failed for ${cfg}")
        endif()

        log("Installing FreeType (${cfg}) ...")
        execute_process(
            COMMAND ${CMAKE_COMMAND}
                --install "${FREETYPE_SRC_DIR}/build-${cfg}" --config ${cfg}
            RESULT_VARIABLE _ft_inst_res
        )
        if(NOT _ft_inst_res EQUAL 0)
            message(FATAL_ERROR "FreeType install failed for ${cfg}")
        endif()
    endforeach()
endif()

set(_ft_debug_lib "")
foreach(cand
    "${FREETYPE_BASE_DIR}-Debug/lib/freetyped.lib"
    "${FREETYPE_BASE_DIR}-Debug/lib/freetype.lib"
)
    if(EXISTS "${cand}")
        set(_ft_debug_lib "${cand}")
        break()
    endif()
endforeach()

set(_ft_release_lib "")
foreach(cand
    "${FREETYPE_BASE_DIR}-Release/lib/freetype.lib"
)
    if(EXISTS "${cand}")
        set(_ft_release_lib "${cand}")
        break()
    endif()
endforeach()

if(_ft_debug_lib STREQUAL "" OR _ft_release_lib STREQUAL "")
    message(FATAL_ERROR "FreeType libs not found in ${FREETYPE_BASE_DIR}-Debug/Release")
endif()

add_library(freetype_external_lib UNKNOWN IMPORTED GLOBAL)
set_target_properties(freetype_external_lib PROPERTIES
    IMPORTED_LOCATION_DEBUG   "${_ft_debug_lib}"
    IMPORTED_LOCATION_RELEASE "${_ft_release_lib}" 
)
target_include_directories(freetype_external_lib INTERFACE
    "$<IF:$<CONFIG:Debug>,${FREETYPE_BASE_DIR}-Debug/include/freetype2,${FREETYPE_BASE_DIR}-Release/include/freetype2>"
    "$<IF:$<CONFIG:Debug>,${FREETYPE_BASE_DIR}-Debug/include,${FREETYPE_BASE_DIR}-Release/include>"
)

# ===========================================
# 6) SDL_ttf (2.24.0)
# ===========================================
set(SDL2TTF_SRC_DIR   "${THIRDPARTY_DIR}/SDL_ttf-release-2.24.0")
set(SDL2TTF_BASE_DIR  "${SDL2TTF_SRC_DIR}/install")

set(_have_sdl2ttf TRUE)
foreach(cfg IN LISTS BUILD_CONFIGS)
    if(NOT EXISTS "${SDL2TTF_BASE_DIR}-${cfg}/lib/SDL2_ttf.lib" AND
       NOT EXISTS "${SDL2TTF_BASE_DIR}-${cfg}/lib/SDL2_ttfd.lib")
        set(_have_sdl2ttf FALSE)
    endif()
endforeach()

if(NOT _have_sdl2ttf)
    foreach(cfg IN LISTS BUILD_CONFIGS)

        if(cfg STREQUAL "Debug")
            set(_SDL2_LIB "${SDL2_INSTALL_DIR}/lib/SDL2d.lib")
        else()
            set(_SDL2_LIB "${SDL2_INSTALL_DIR}/lib/SDL2.lib")
        endif()

        set(_FT_PREFIX "${FREETYPE_BASE_DIR}-${cfg}")

        set(_FT_LIB "")
        foreach(cand
            "${_FT_PREFIX}/lib/freetyped.lib"
            "${_FT_PREFIX}/lib/freetype.lib"
        )
            if(EXISTS "${cand}")
                set(_FT_LIB "${cand}")
                break()
            endif()
        endforeach()

        if(_FT_LIB STREQUAL "")
            message(FATAL_ERROR "FreeType library not found for ${cfg}")
        endif()

        log("Configuring SDL_ttf (${cfg}) ...")
        execute_process(
            COMMAND ${CMAKE_COMMAND}
                -G "${CMAKE_GENERATOR}"
                -S "${SDL2TTF_SRC_DIR}"
                -B "${SDL2TTF_SRC_DIR}/build-${cfg}"
                -DCMAKE_INSTALL_PREFIX=${SDL2TTF_BASE_DIR}-${cfg}
                -DCMAKE_PREFIX_PATH=${_FT_PREFIX};${SDL2_INSTALL_DIR}
                -DSDL2_LIBRARY=${_SDL2_LIB}
                -DSDL2_INCLUDE_DIR=${SDL2_INSTALL_DIR}/include/SDL2
                -DFREETYPE_LIBRARY=${_FT_LIB}
                -DFREETYPE_INCLUDE_DIR=${_FT_PREFIX}/include/freetype2
                -DFREETYPE_INCLUDE_DIRS=${_FT_PREFIX}/include/freetype2
                -DSDL2TTF_VENDORED=OFF
                -DSDL2TTF_SAMPLES=OFF
            RESULT_VARIABLE _ttf_cfg_res
        )
        if(NOT _ttf_cfg_res EQUAL 0)
            message(FATAL_ERROR "SDL_ttf configure failed for ${cfg}")
        endif()

        log("Building SDL_ttf (${cfg}) ...")
        execute_process(
            COMMAND ${CMAKE_COMMAND}
                --build "${SDL2TTF_SRC_DIR}/build-${cfg}" --config ${cfg}
            RESULT_VARIABLE _ttf_build_res
        )
        if(NOT _ttf_build_res EQUAL 0)
            message(FATAL_ERROR "SDL_ttf build failed for ${cfg}")
        endif()

        log("Installing SDL_ttf (${cfg}) ...")
        execute_process(
            COMMAND ${CMAKE_COMMAND}
                --install "${SDL2TTF_SRC_DIR}/build-${cfg}" --config ${cfg}
            RESULT_VARIABLE _ttf_inst_res
        )
        if(NOT _ttf_inst_res EQUAL 0)
            message(FATAL_ERROR "SDL_ttf install failed for ${cfg}")
        endif()

    endforeach()
endif()

set(_ttf_debug_lib "")
foreach(cand
    "${SDL2TTF_BASE_DIR}-Debug/lib/SDL2_ttfd.lib"
    "${SDL2TTF_BASE_DIR}-Debug/lib/SDL2_ttf.lib"
)
    if(EXISTS "${cand}")
        set(_ttf_debug_lib "${cand}")
        break()
    endif()
endforeach()

set(_ttf_release_lib "")
foreach(cand
    "${SDL2TTF_BASE_DIR}-Release/lib/SDL2_ttf.lib"
)
    if(EXISTS "${cand}")
        set(_ttf_release_lib "${cand}")
        break()
    endif()
endforeach()

if(_ttf_debug_lib STREQUAL "" OR _ttf_release_lib STREQUAL "")
    message(FATAL_ERROR "SDL_ttf libs not found in install-Debug / install-Release")
endif()

add_library(SDL2_ttf_external_lib UNKNOWN IMPORTED GLOBAL)
set_target_properties(SDL2_ttf_external_lib PROPERTIES
    IMPORTED_LOCATION_DEBUG   "${_ttf_debug_lib}"
    IMPORTED_LOCATION_RELEASE "${_ttf_release_lib}"
    INTERFACE_INCLUDE_DIRECTORIES
        "$<IF:$<CONFIG:Debug>,${SDL2TTF_BASE_DIR}-Debug/include,${SDL2TTF_BASE_DIR}-Release/include>;$<IF:$<CONFIG:Debug>,${SDL2TTF_BASE_DIR}-Debug/include/SDL2,${SDL2TTF_BASE_DIR}-Release/include/SDL2>"
    INTERFACE_LINK_LIBRARIES
        "SDL2_external_lib;freetype_external_lib"
)

# ===========================================
# 7) Eigen (5.0.0.zip → eigen-5.0.0) - HEADER-ONLY
# ===========================================
set(EIGEN_SRC_DIR     "${THIRDPARTY_DIR}/eigen-5.0.0")

if(NOT TARGET eigen_external_lib)
    add_library(eigen_external_lib INTERFACE)
    target_include_directories(eigen_external_lib INTERFACE "${EIGEN_SRC_DIR}")
endif()

# ===========================================
# 8) Boost (1.90.0) - HEADER-ONLY
# ===========================================
set(BOOST_VERSION "1.90.0")
set(BOOST_ARCHIVE_NAME "boost_1_90_0.zip")
set(BOOST_ARCHIVE "${THIRDPARTY_DIR}/${BOOST_ARCHIVE_NAME}")
# Внутри архива папка называется boost_1_90_0
set(BOOST_SRC_DIR "${THIRDPARTY_DIR}/boost_1_90_0")

if(NOT TARGET boost_external_lib)
    add_library(boost_external_lib INTERFACE)
    # Boost заголовки находятся непосредственно в корне распакованной папки
    target_include_directories(boost_external_lib INTERFACE "${BOOST_SRC_DIR}")
endif()