Skip to content

Instantly share code, notes, and snippets.

@maz-1
Last active March 15, 2022 12:12
Show Gist options
  • Save maz-1/42a776308f65010eb60e89eb4e777728 to your computer and use it in GitHub Desktop.
Save maz-1/42a776308f65010eb60e89eb4e777728 to your computer and use it in GitHub Desktop.
gdal portfile
set(GDAL_VERSION_SEMVER 3.4.2)
set(GDAL_REF "v${GDAL_VERSION_SEMVER}")
#...
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO OSGeo/gdal
REF ${GDAL_REF}
SHA512 <VALUE>
HEAD_REF master
PATCHES ${GDAL_PATCHES}
)
#...
if (VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
#...
# pkgconfig support is ignored by makefile.vc, manually configure it
file(READ "${SOURCE_PATH}/gdal/gdal.pc.in" GDAL_PC_FILEDATA)
string(REGEX REPLACE "\\$\\{(CONFIG_[A-Za-z0-9_]+)\\}" "@\\1@" GDAL_PC_FILEDATA "${GDAL_PC_FILEDATA}")
file(WRITE "${SOURCE_PATH}/gdal.pc.win.in" "${GDAL_PC_FILEDATA}")
set(CONFIG_INST_PREFIX "${CURRENT_PACKAGES_DIR}")
set(CONFIG_INST_DATA "${CURRENT_PACKAGES_DIR}/share/gdal")
set(CONFIG_VERSION "${GDAL_VERSION_SEMVER}")
set(CONFIG_INST_CFLAGS "-I${CURRENT_PACKAGES_DIR}/include")
if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
set(CONFIG_INST_LIBS "-L${CURRENT_PACKAGES_DIR}/lib -lgdal_i")
configure_file("${SOURCE_PATH}/gdal.pc.win.in" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/gdal.pc" @ONLY)
vcpkg_fixup_pkgconfig()
endif()
if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
set(CONFIG_INST_LIBS "-L${CURRENT_PACKAGES_DIR}/lib -lgdal_i_d")
set(pc_file_debug "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/gdal.pc")
configure_file("${SOURCE_PATH}/gdal.pc.win.in" "${pc_file_debug}" @ONLY)
vcpkg_fixup_pkgconfig()
vcpkg_replace_string("${pc_file_debug}" "\${prefix}/../../include" "\${prefix}/../include")
vcpkg_replace_string("${pc_file_debug}" "\${exec_prefix}/include" "\${prefix}/../include")
endif()
else()
#...
endif()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment