From c7fd7605bdd17924ad88aa344529a91b3c32131c Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Sat, 22 Jun 2024 12:08:29 +0200 Subject: [PATCH 1/4] [gdal] Fix build on *-osx-dynamic --- ports/gdal/portfile.cmake | 36 ++++++++++++++++++++++++++++-------- ports/gdal/vcpkg.json | 1 + 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/ports/gdal/portfile.cmake b/ports/gdal/portfile.cmake index 966d34c..46e5999 100644 --- a/ports/gdal/portfile.cmake +++ b/ports/gdal/portfile.cmake @@ -169,17 +169,37 @@ if(NOT bin_files) endif() if("python" IN_LIST FEATURES) + if(VCPKG_TARGET_IS_WINDOWS) + set(PY_LIB_DIR "Lib") + set(PY_SCRIPTS_DIR "Scripts") + else() + set(PY_LIB_DIR ${PYTHON3_VERSION_MAJOR}.${PYTHON3_VERSION_MINOR}) + set(PY_SCRIPTS_DIR "bin") + endif() + file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/debug/Lib" - "${CURRENT_PACKAGES_DIR}/debug/Scripts" + "${CURRENT_PACKAGES_DIR}/debug/${PY_LIB_DIR}" + "${CURRENT_PACKAGES_DIR}/debug/${PY_SCRIPTS_DIR}" ) - file(COPY "${CURRENT_PACKAGES_DIR}/Lib/site-packages/" DESTINATION "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}") - # TODO: Generalize for non windows - file(COPY "${CURRENT_PACKAGES_DIR}/Scripts" DESTINATION "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}/../../Scripts") - file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/Lib/site-packages" - "${CURRENT_PACKAGES_DIR}/Scripts" + if(VCPKG_TARGET_IS_WINDOWS) + file(COPY "${CURRENT_PACKAGES_DIR}/${PY_LIB_DIR}/site-packages/" DESTINATION "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}") + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/${PY_LIB_DIR}/site-packages") + file(COPY "${CURRENT_PACKAGES_DIR}/Scripts" DESTINATION "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}/../../Scripts") + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/Scripts") + endif() + if(VCPKG_TARGET_IS_OSX) + file(GLOB_RECURSE macho_files LIST_DIRECTORIES FALSE "${CURRENT_PACKAGES_DIR}/${PY_LIB_DIR}/*") + list(FILTER macho_files INCLUDE REGEX "\.so$") + foreach(macho_file IN LISTS macho_files) + # Required for testing, as it needs to be able load shared libs from the package (not yet installed) path + # Will be overwritten by z_vcpkg_fixup_rpath_macho + execute_process( + COMMAND install_name_tool -add_rpath "${CURRENT_PACKAGES_DIR}/lib" "${macho_file}" + OUTPUT_QUIET + ERROR_VARIABLE set_rpath_error ) + endforeach() + endif() vcpkg_python_test_import(MODULE "osgeo.gdal") endif() diff --git a/ports/gdal/vcpkg.json b/ports/gdal/vcpkg.json index 0ec788a..5e67202 100644 --- a/ports/gdal/vcpkg.json +++ b/ports/gdal/vcpkg.json @@ -1,6 +1,7 @@ { "name": "gdal", "version-semver": "3.8.4", + "port-version": 1, "description": "The Geographic Data Abstraction Library for reading and writing geospatial raster and vector data", "homepage": "https://gdal.org", "license": null, From 3295248bd050e277ff93411a1da39e00d00cb9fe Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Fri, 28 Jun 2024 18:13:13 +0200 Subject: [PATCH 2/4] Fixes for osx --- ports/gdal/portfile.cmake | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/ports/gdal/portfile.cmake b/ports/gdal/portfile.cmake index 46e5999..c4e7bc9 100644 --- a/ports/gdal/portfile.cmake +++ b/ports/gdal/portfile.cmake @@ -99,6 +99,7 @@ vcpkg_cmake_configure( "-DQHULL_LIBRARY=${qhull_target}" "-DSWIG_DIR=${CURRENT_HOST_INSTALLED_DIR}/tools/swig" "-DSWIG_EXECUTABLE=${CURRENT_HOST_INSTALLED_DIR}/tools/swig/swig${VCPKG_HOST_EXECUTABLE_SUFFIX}" + -DONLY_GENERATE_FOR_NON_DEBUG=ON # Python bindings only for release "-DCMAKE_PROJECT_INCLUDE=${CMAKE_CURRENT_LIST_DIR}/cmake-project-include.cmake" OPTIONS_DEBUG -DBUILD_APPS=OFF @@ -170,25 +171,16 @@ endif() if("python" IN_LIST FEATURES) if(VCPKG_TARGET_IS_WINDOWS) - set(PY_LIB_DIR "Lib") - set(PY_SCRIPTS_DIR "Scripts") - else() - set(PY_LIB_DIR ${PYTHON3_VERSION_MAJOR}.${PYTHON3_VERSION_MINOR}) - set(PY_SCRIPTS_DIR "bin") - endif() - - file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/debug/${PY_LIB_DIR}" - "${CURRENT_PACKAGES_DIR}/debug/${PY_SCRIPTS_DIR}" - ) - if(VCPKG_TARGET_IS_WINDOWS) - file(COPY "${CURRENT_PACKAGES_DIR}/${PY_LIB_DIR}/site-packages/" DESTINATION "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}") - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/${PY_LIB_DIR}/site-packages") + # to be checked ... can this be replaced with -DGDAL_PYTHON_INSTALL_PREFIX:PATH="${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}" ? + file(COPY "${CURRENT_PACKAGES_DIR}/Lib/site-packages/" DESTINATION "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}") file(COPY "${CURRENT_PACKAGES_DIR}/Scripts" DESTINATION "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}/../../Scripts") - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/Scripts") + file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/Lib/site-packages" + "${CURRENT_PACKAGES_DIR}/Scripts" + ) endif() if(VCPKG_TARGET_IS_OSX) - file(GLOB_RECURSE macho_files LIST_DIRECTORIES FALSE "${CURRENT_PACKAGES_DIR}/${PY_LIB_DIR}/*") + file(GLOB_RECURSE macho_files LIST_DIRECTORIES FALSE "${CURRENT_PACKAGES_DIR}/*") list(FILTER macho_files INCLUDE REGEX "\.so$") foreach(macho_file IN LISTS macho_files) # Required for testing, as it needs to be able load shared libs from the package (not yet installed) path From c49e489f76b5c9812fc0680584f6daea9087e0a4 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Fri, 28 Jun 2024 18:44:08 +0200 Subject: [PATCH 3/4] Use gdal install prefix --- ports/gdal/portfile.cmake | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/ports/gdal/portfile.cmake b/ports/gdal/portfile.cmake index c4e7bc9..d4d492c 100644 --- a/ports/gdal/portfile.cmake +++ b/ports/gdal/portfile.cmake @@ -99,6 +99,7 @@ vcpkg_cmake_configure( "-DQHULL_LIBRARY=${qhull_target}" "-DSWIG_DIR=${CURRENT_HOST_INSTALLED_DIR}/tools/swig" "-DSWIG_EXECUTABLE=${CURRENT_HOST_INSTALLED_DIR}/tools/swig/swig${VCPKG_HOST_EXECUTABLE_SUFFIX}" + "-DGDAL_PYTHON_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}/../../../" -DONLY_GENERATE_FOR_NON_DEBUG=ON # Python bindings only for release "-DCMAKE_PROJECT_INCLUDE=${CMAKE_CURRENT_LIST_DIR}/cmake-project-include.cmake" OPTIONS_DEBUG @@ -170,15 +171,6 @@ if(NOT bin_files) endif() if("python" IN_LIST FEATURES) - if(VCPKG_TARGET_IS_WINDOWS) - # to be checked ... can this be replaced with -DGDAL_PYTHON_INSTALL_PREFIX:PATH="${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}" ? - file(COPY "${CURRENT_PACKAGES_DIR}/Lib/site-packages/" DESTINATION "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}") - file(COPY "${CURRENT_PACKAGES_DIR}/Scripts" DESTINATION "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}/../../Scripts") - file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/Lib/site-packages" - "${CURRENT_PACKAGES_DIR}/Scripts" - ) - endif() if(VCPKG_TARGET_IS_OSX) file(GLOB_RECURSE macho_files LIST_DIRECTORIES FALSE "${CURRENT_PACKAGES_DIR}/*") list(FILTER macho_files INCLUDE REGEX "\.so$") From 313200ddd36fe2b523eb613319362ec5076f5062 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Fri, 28 Jun 2024 19:11:28 +0200 Subject: [PATCH 4/4] oh windows, oh windows --- ports/gdal/portfile.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ports/gdal/portfile.cmake b/ports/gdal/portfile.cmake index d4d492c..70bec2b 100644 --- a/ports/gdal/portfile.cmake +++ b/ports/gdal/portfile.cmake @@ -72,6 +72,11 @@ endif() string(REPLACE "dynamic" "" qhull_target "Qhull::qhull${VCPKG_LIBRARY_LINKAGE}_r") +if(VCPKG_TARGET_IS_WINDOWS) + set(GDAL_PYTHON_INSTALL_PREFIX "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}/../../") +else() + set(GDAL_PYTHON_INSTALL_PREFIX "${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}/../../../") +endif() vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" OPTIONS @@ -99,7 +104,7 @@ vcpkg_cmake_configure( "-DQHULL_LIBRARY=${qhull_target}" "-DSWIG_DIR=${CURRENT_HOST_INSTALLED_DIR}/tools/swig" "-DSWIG_EXECUTABLE=${CURRENT_HOST_INSTALLED_DIR}/tools/swig/swig${VCPKG_HOST_EXECUTABLE_SUFFIX}" - "-DGDAL_PYTHON_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}/${PYTHON3_SITE}/../../../" + "-DGDAL_PYTHON_INSTALL_PREFIX=${GDAL_PYTHON_INSTALL_PREFIX}" -DONLY_GENERATE_FOR_NON_DEBUG=ON # Python bindings only for release "-DCMAKE_PROJECT_INCLUDE=${CMAKE_CURRENT_LIST_DIR}/cmake-project-include.cmake" OPTIONS_DEBUG