In case it helps others, here are the steps I took to use MrSID and ECW through GDAL:
(1a) Download the 32 bit Visual Studio 2022 DSDK from https://www.extensis.com/support/developers. Unzip it to C:\Users\michael.katz\Documents\vcpkg\sdk\MrSID_DSDK-9.5.5.5244-win32-vc17.
(1b) Go to https://supportsi.hexagon.com/help/s/article/ERDAS-ECW-JP2-SDK-Read-Only-Redistributable-download and download the appropriate SDK in the top-right corner. Unzip the download to C:\Users\michael.katz\Documents\vcpkg\sdk\ecw\Hexagon\ERDAS_ECW_JPEG_2000_SDK_5.5.0\Desktop_Read-Only.
(2) Edit C:\Users\michael.katz\Documents\vcpkg\triplets\x86-windows.cmake. (You can see the meaning of the flags at https://gdal.org/development/building_from_source.html.)
set(VCPKG_TARGET_ARCHITECTURE x86)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_BUILD_TYPE release)
set(ENV{CMAKE_WINDOWS_KITS_10_DIR} "C:\\Program Files (x86)\\Windows Kits\\10")
set(VCPKG_CMAKE_CONFIGURE_OPTIONS "-DCMAKE_WINDOWS_KITS_10_DIR=C:/Program Files (x86)/Windows Kits/10\"")
set(VCPKG_ENV_PASSTHROUGH CMAKE_WINDOWS_KITS_10_DIR)
# CMAKE_CURRENT_LIST_DIR is the triplets directory
# such as C:/Users/michael.katz/Documents/vcpkg/triplets
message( STATUS "\n\n-----------------------CMAKE_CURRENT_LIST_DIR = ${CMAKE_CURRENT_LIST_DIR}\n\n" )
if (PORT MATCHES "gdal")
string(
CONCAT x
" \"-DMRSID_INCLUDE_DIR=${CMAKE_CURRENT_LIST_DIR}/../sdk/MrSID_DSDK-9.5.5.5244-win32-vc17/Raster_DSDK/include\""
" \"-DMRSID_LIBRARY=${CMAKE_CURRENT_LIST_DIR}/../sdk/MrSID_DSDK-9.5.5.5244-win32-vc17/Raster_DSDK/lib/lti_dsdk.lib\""
" \"-DGDAL_USE_MRSID=ON\""
" \"-DECW_INCLUDE_DIR=${CMAKE_CURRENT_LIST_DIR}/../sdk/ecw/Hexagon/ERDAS_ECW_JPEG_2000_SDK_5.5.0/Desktop_Read-Only/include\""
" \"-DECW_LIBRARY=${CMAKE_CURRENT_LIST_DIR}/../sdk/ecw/Hexagon/ERDAS_ECW_JPEG_2000_SDK_5.5.0/Desktop_Read-Only/lib/vc141/Win32/NCSEcw.lib\""
" \"-DGDAL_USE_ECW=ON"
)
set(VCPKG_CMAKE_CONFIGURE_OPTIONS "${VCPKG_CMAKE_CONFIGURE_OPTIONS} ${x}" )
endif()
message( STATUS "\n\n-----------------------VCPKG_CMAKE_CONFIGURE_OPTIONS = ${VCPKG_CMAKE_CONFIGURE_OPTIONS}\n\n" )
message( STATUS "\n\n-----------------------FEATURES = ${FEATURES}\n\n" )
# message( STATUS "\n\n-----------------------VCPKG_CXX_FLAGS = ${VCPKG_CXX_FLAGS}\n\n" )
(3) Build gdal, but first remove the old gdal:
PS C:\Users\michael.katz\Documents\vcpkg> rmdir C:\Users\michael.katz.la\AppData\Local\vcpkg\archives
PS C:\Users\michael.katz\Documents\vcpkg> .\vcpkg.exe remove gdal
PS C:\Users\michael.katz\Documents\vcpkg> rm C:\Users\michael.katz\Documents\vcpkg\buildtrees\gdal\x86-windows-rel\CMakeCache.txt
PS C:\Users\michael.katz\Documents\vcpkg> .\vcpkg.exe install gdal
(4a) Add ...MrSID_DSDK-9.5.5.5244-win32-vc17\Raster_DSDK\lib\lti_dsdk.lib
as a linker input for your project.
(4b) Add ...Desktop_Read-Only\lib\vc141\Win32\NCSEcw.lib
as a linker input for your project.
(5a) Copy ...MrSID_DSDK-9.5.5.5244-win32-vc17\Raster_DSDK\lib\lti_dsdk_9.5.dll
to the Release directory of your project, so it's a sibling to your app.exe
.
(5b) Copy ...Desktop_Read-Only\redistributable\vc141\Win32\NCSEcw.dll
to the Release directory of your project, so it's a sibling to your app.exe
.
(6) Rebuild your project.