Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vcpkg][gdal] Switch build method to vcpkg_*_nmake(win)/vcpkg_*_make(unix) #9100

Closed
wants to merge 16 commits into from

Conversation

JackBoosY
Copy link
Contributor

@JackBoosY JackBoosY commented Nov 26, 2019

This PR will:

  • Update to 3.1.2
  • Add new option BUILD_TARGET to vcpkg_*_nmake to select target.
  • Add new option MAKEFILE to vcpkg_build_make to select the makefile.
  • Add new vcpkg function vcpkg_use_system_ports to use configure's option to handle vcpkg installed ports.
  • Switch gdal build method to vcpkg_*_nmake (Windows) / vcpkg_*_make (UNIX).
  • Fix linux build.

Related: #9068.

…nt `all`

[gdal]Switch build method to vcpkg_*_nmake(win)/vcpkg_*_make(unix)
@JackBoosY JackBoosY added the info:internal This PR or Issue was filed by the vcpkg team. label Nov 26, 2019
@JackBoosY
Copy link
Contributor Author

@Neumann-A This PR should fix your issue. Can you review it?

Thanks.

@grdowns grdowns self-assigned this Nov 26, 2019
@JackBoosY
Copy link
Contributor Author

@Neumann-A You are right, I found that almost all features were broken. Mostly because the dependent libraries were not added to the test case.

@Neumann-A
Copy link
Contributor

@JackBoosY You should probably ask @lakinwecker to check this PR.
I'm not using gdal. I was just trying to solve a problem which was discussed in the slack channel and then discovered that gdal on linux is totally broken and made an issue out of it.

@JackBoosY
Copy link
Contributor Author

@Neumann-A In the end, I found that the order of ports in gdal configure/configure.ac is incorrect. We can only solve these configuration problems by adding -l$ {lib}.

@JackBoosY
Copy link
Contributor Author

Current status:

  Installation directory:    /home/usr/work/9100/vcpkg/packages/gdal_x64-linux/debug
  C compiler:                gcc -DHAVE_AVX_AT_COMPILE_TIME -DHAVE_SSSE3_AT_COMPILE_TIME -DHAVE_SSE_AT_COMPILE_TIME  -g -DDEBUG -ftrapv
  C++ compiler:              g++ -DHAVE_AVX_AT_COMPILE_TIME -DHAVE_SSSE3_AT_COMPILE_TIME -DHAVE_SSE_AT_COMPILE_TIME  -g -DDEBUG -ftrapv
  C++14 support:             no

  LIBTOOL support:           yes

  LIBZ support:              external
  LIBLZMA support:           yes
  ZSTD support:              yes
  cryptopp support:          no
  crypto/openssl support:    yes
  GRASS support:             no
  CFITSIO support:           no
  PCRaster support:          internal
  LIBPNG support:            external
  DDS support:               no
  GTA support:               no
  LIBTIFF support:           external (BigTIFF=no)
  LIBGEOTIFF support:        internal
  LIBJPEG support:           internal
  12 bit JPEG:               no
  12 bit JPEG-in-TIFF:       no
  LIBGIF support:            external
  JPEG-Lossless/CharLS:      no
  OGDI support:              no
  HDF4 support:              no
  HDF5 support:              yes
  Kea support:               no
  NetCDF support:            yes
  NetCDF has netcdf_mem.h:   yes
  Kakadu support:            no
  JasPer support:            no
  OpenJPEG support:          yes
  ECW support:               no
  MrSID support:             no
  MrSID/MG4 Lidar support:   no
  JP2Lura support:           no
  MSG support:               no
  GRIB support:              yes
  EPSILON support:           no
  WebP support:              yes
  cURL support (wms/wcs/...):yes
  PostgreSQL support:        no
  MRF support:               yes
  LERC support:              yes
  MySQL support:             yes
  Ingres support:            no
  Xerces-C support:          yes
  NAS support:               yes
  Expat support:             yes
  libxml2 support:           yes
  Google libkml support:     no
  ODBC support:              yes
  PGeo support:              yes
  FGDB support:              no
  MDB support:               no
  PCIDSK support:            internal
  OCI support:               no
  GEORASTER support:         no
  SDE support:               no
  Rasdaman support:          no
  DODS support:              no
  SQLite support:            yes
  PCRE support:              yes
  SpatiaLite support:        yes
  RasterLite2 support:       no
  Teigha (DWG and DGNv8):    no
  INFORMIX DataBlade support:no
  GEOS support:              yes
  SFCGAL support:            no
  QHull support:             internal
  Poppler support:           no
  Podofo support:            no
  PDFium support:            no
  OpenCL support:            no
  Armadillo support:         no
  FreeXL support:            no
  SOSI support:              no
  MongoDB support:           no
  HDFS support:              no
  userfaultfd support:       yes


  SWIG Bindings:             no

  Statically link PROJ:      yes
  enable GNM building:       yes
  enable pthread support:    yes
  enable POSIX iconv support:yes
  hide internal symbols:     no

@JackBoosY JackBoosY marked this pull request as ready for review November 29, 2019 08:27
@JackBoosY
Copy link
Contributor Author

The CI system did not really test gdal, we need to fix it before merging this PR.

@Neumann-A
Copy link
Contributor

  LIBGEOTIFF support:        internal
  LIBJPEG support:           internal
  QHull support:             internal

shouldn't those be external? (If I understand external correctly)
It also looks like some of those dependencies could potentially screw up CI results (if there is a port depending on gdal)
like

  Armadillo support:         no
  MongoDB support:           no
  PostgreSQL support:        no

@JackBoosY
Copy link
Contributor Author

@Neumann-A Because these 6 ports are not added as functions. This PR only fixes existing features.

@vicroms
Copy link
Member

vicroms commented Dec 2, 2019

liblzma and libjpeg-turbo are failing for Linux, that causes tiff and gdal to be skipped by CI.

@grdowns
Copy link
Contributor

grdowns commented Dec 2, 2019

Hey @JackBoosY. We like vcpkg_use_system_port, but @vicroms and I are thinking about whether it can be merged into vcpkg_check_features with a flag. We'll take this on and ping you when we've got something for you to see!

@ras0219-msft
Copy link
Contributor

Explanation of common autoconf-style arguments: https://autotools.io/autoconf/arguments.html

It looks like "enable" is typically paired with "disable" and "with" is paired with "without".

@JackBoosY
Copy link
Contributor Author

@ras0219-msft According to the documentation, with should be paired with without, but in general, the judgment in configure.ac is:

elif test "$with_libgrass" = "no" ; then

or

if test "$with_pcidsk" != "no" ; then

@janholt
Copy link
Contributor

janholt commented Dec 3, 2019

@JackBoosY gdal[core] (commit cb7d59e Add feature options) works for me on x64-windows and x64-linux with small changes:

diff --git a/ports/gdal/portfile.cmake b/ports/gdal/portfile.cmake
index 34af0075b..1b938ffd7 100644
--- a/ports/gdal/portfile.cmake
+++ b/ports/gdal/portfile.cmake
@@ -119,6 +119,7 @@ if (VCPKG_TARGET_IS_WINDOWS)
         HTMLDIR=${NATIVE_HTML_DIR}
         GEOS_DIR=${COMMON_INCLUDE_DIR}
         "GEOS_CFLAGS=-I${COMMON_INCLUDE_DIR} -DHAVE_GEOS"
+        "PROJ_FLAGS=-DPROJ_STATIC -DPROJ_VERSION=5"
         PROJ_INCLUDE=-I${COMMON_INCLUDE_DIR}
         EXPAT_DIR=${COMMON_INCLUDE_DIR}
         EXPAT_INCLUDE=-I${COMMON_INCLUDE_DIR}
@@ -188,7 +189,7 @@ if (VCPKG_TARGET_IS_WINDOWS)
         OPTIONS_RELEASE ${NMAKE_OPTIONS_REL}
     )
     
-    if (CMAKE_BUILD_TYPE STREQUAL debug)
+    if (VCPKG_BUILD_TYPE STREQUAL debug)
         set(GDAL_OBJ_DIR ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
     else()
         set(GDAL_OBJ_DIR ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel)
@@ -281,7 +282,12 @@ else()
         SOURCE_PATH ${SOURCE_PATH}
         AUTOCONFIG
         OPTIONS ${EXTRA_OPTIONS}
+            --with-jpeg=${CURRENT_INSTALLED_DIR}
+            --with-qhull=no
             --with-proj5-api=yes
+            --with-hide-internal-symbols=yes
+            --with-rename-internal-libgeotiff-symbols=yes
+            --with-rename-internal-shapelib-symbols=yes
             --enable-shared=${BUILD_DYNAMIC}
             --enable-static=${BUILD_STATIC}
         OPTIONS_DEBUG
@@ -303,11 +309,14 @@ else()
     
     file(GLOB GDAL_TOOLS ${CURRENT_PACKAGES_DIR}/bin/*)
     foreach (GDAL_TOOL ${GDAL_TOOLS})
-        file(INSTALL ${GDAL_TOOL} DESTINATION ${CURRENT_PACKAGES_DIR}/tools/gdal)
+        file(INSTALL ${GDAL_TOOL} DESTINATION ${CURRENT_PACKAGES_DIR}/tools/gdal
+                PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ)
         file(REMOVE ${GDAL_TOOL})
     endforeach()
     file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin)
 endif()
 
+configure_file(${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake ${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake @ONLY)
+
 # Handle copyright

and help in vcpkg-cmake-wrapper.cmake for static linking:

_find_package(${ARGS})

if(TARGET GDAL::GDAL AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static")
	find_package(PROJ4 REQUIRED)
	find_package(PNG REQUIRED)
	find_library(GDAL_GEOS_LIB NAMES geos)
	find_library(GDAL_GEOSC_LIB NAMES geos_c)
	message(STATUS "GDAL_GEOS: ${GDAL_GEOS_LIB} ${GDAL_GEOSC_LIB}")
	find_package(WebP REQUIRED)
	find_package(sqlite3 CONFIG REQUIRED)
	find_package(EXPAT REQUIRED)
	find_package(OpenJPEG CONFIG REQUIRED)
	find_package(netCDF REQUIRED)
	find_package(HDF5 CONFIG REQUIRED)
	find_package(SZIP REQUIRED)
	find_package(JPEG REQUIRED)
	find_package(TIFF REQUIRED)
	find_package(Threads)
	find_package(CURL CONFIG REQUIRED)
	find_package(OpenSSL REQUIRED)
	find_package(LibXml2 REQUIRED)
	find_package(ZLIB REQUIRED)
	find_package(LibLZMA CONFIG REQUIRED)

	set_property(TARGET GDAL::GDAL APPEND PROPERTY INTERFACE_LINK_LIBRARIES
		PROJ4::proj
		PNG::PNG
		${GDAL_GEOS_LIB} ${GDAL_GEOSC_LIB}
		WebP::webp
		sqlite3
		EXPAT::EXPAT
		openjp2
		netcdf
		hdf5::hdf5_hl-static hdf5::hdf5-static 
		szip-static
		JPEG::JPEG
		TIFF::TIFF
		Threads::Threads
		${CMAKE_DL_LIBS}
		CURL::libcurl
		OpenSSL::SSL OpenSSL::Crypto
		LibXml2::LibXml2
		ZLIB::ZLIB
		LibLZMA::LibLZMA
	)
endif()

Here additional features omitted, libgeotiff - internal renamed, jpeg - external, qhull - disabled (all just for quick test).
Also I have a pretty clean Linux, with minimum -dev packages. I think it is a problem that configure can pick up "system" libraries, so maybe it is preferable to have exhaustive options list for configure that mimics configure --help (all would be explicit and easy to check that nothing is missing). For example gdal has -with-kea=ARG Include kealib (ARG=path to kea-config) [default=yes], so now you can easily end up with misterious kea.

@janholt
Copy link
Contributor

janholt commented Dec 7, 2019

@JackBoosY small typo fix

diff --git a/ports/gdal/portfile.cmake b/ports/gdal/portfile.cmake
index 1b938ffd7..c101cd235 100644
--- a/ports/gdal/portfile.cmake
+++ b/ports/gdal/portfile.cmake
@@ -27,8 +27,8 @@ vcpkg_extract_source_archive_ex(
 )
 
 if (VCPKG_TARGET_IS_WINDOWS)
-    set(NATIVE_PACKAGES_DIR_DBG "${CURRENT_PACKAGES_DIR}")
-    set(NATIVE_PACKAGES_DIR_REL "${CURRENT_PACKAGES_DIR}/debug")
+    set(NATIVE_PACKAGES_DIR_REL "${CURRENT_PACKAGES_DIR}")
+    set(NATIVE_PACKAGES_DIR_DBG "${CURRENT_PACKAGES_DIR}/debug")
     # We can't pass in the normal absolute path because the "xcopy" command needs to use the windows path.
     # We also can't pass in the windows path because it is used as an argument after the "\" will be used as an escape character and cannot be resolved using double quotes.
     # Use relative path here to install manually below

@JackBoosY
Copy link
Contributor Author

/azp run

@PhoebeHui PhoebeHui changed the title [gdal] Switch build method to vcpkg_*_nmake(win)/vcpkg_*_make(unix) [vcpkg][gdal] Switch build method to vcpkg_*_nmake(win)/vcpkg_*_make(unix) Apr 7, 2020

-if test "$with_liblzma" = "yes" ; then
+if test "$with_liblzma" != "no" ; then
AC_CHECK_LIB(lzma,lzma_code,LIBLZMA_SETTING=yes,LIBLZMA_SETTING=no,)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use AC_CHECK_LIB due to possible debug suffixes. Instead use AC_SEARCH_LIBS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are too many AC_CHECK_LIB in the source, so I think we should keep it as it is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean you can also set the autotool variable by hand and pass it to configure if you feel like it but it general all those check libs calls need to be replaced with search lib calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Neumann-A As my knowledge of configure is limited, can you help me do this?


- if test "$LIBLZMA_SETTING" = "yes" -a "$ac_cv_header_lzma_h" = "yes" ; then
+ if test "$LIBLZMA_SETTING" = "yes" ; then
LIBS="-llzma $LIBS"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't link by name. Use $ac_cv_search_(function) (in this case $ac_cv_search_lzma_code). Requires a check if $ac_cv_search_(function) is not equal to none required. Compare with the libwandio changes in 2e711ae

Comment on lines +45 to +49
AC_CHECK_LIB(hdf5,H5Fopen,HAVE_HDF5=yes,HAVE_HDF5=no,)

if test "$HAVE_HDF5" = "yes" ; then
- LIBS="-lhdf5 $LIBS"
+ LIBS="-lhdf5_hl -lhdf5 -lszip $LIBS"
Copy link
Contributor

@Neumann-A Neumann-A Apr 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above
I won't comment on all the AC_CHECK_LIB and named links below but those should be changed as described above.

Comment on lines +25 to +42
if test "$TIFF_SETTING" = "external" ; then
- LIBS="-ltiff $LIBS"
+ LIBS="-ltiff -llzma $LIBS"
AC_MSG_RESULT([using pre-installed libtiff.])
else
AC_MSG_RESULT([using internal TIFF code.])
@@ -1667,10 +1666,10 @@ else

TIFF_SETTING=external
if test -r "$with_libtiff/tiff.h" ; then
- LIBS="-L$with_libtiff -ltiff $LIBS"
+ LIBS="-L$with_libtiff -ltiff -llzma $LIBS"
EXTRA_INCLUDES="-I$with_libtiff $EXTRA_INCLUDES"
else
- LIBS="-L$with_libtiff/lib -ltiff $LIBS"
+ LIBS="-L$with_libtiff/lib -ltiff -llzma $LIBS"
EXTRA_INCLUDES="-I$with_libtiff/include $EXTRA_INCLUDES"
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a search for tiff, Why is lzma linked in again? It should already be a part of LIBS

elif test "$with_netcdf" = "yes" -o "$with_netcdf" = "" ; then

- AC_CHECK_LIB([netcdf], [nc_open], [NETCDF_SETTING=yes], [NETCDF_SETTING=no],)
+ AC_CHECK_LIB([netcdf], [nc_open], [NETCDF_SETTING=yes], [NETCDF_SETTING=no], -lcurl -lssl -lcrypto)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curl has a debug suffix so this won't work in debug builds. Better do a search for CURL.

@PhoebeHui PhoebeHui marked this pull request as draft July 14, 2020 02:52
@JackBoosY JackBoosY mentioned this pull request Jul 30, 2020
@JackBoosY JackBoosY added category:port-bug The issue is with a library, which is something the port should already support category:port-update The issue is with a library, which is requesting update new revision labels Jul 31, 2020
@JackBoosY
Copy link
Contributor Author

This is too hard for me, close it temporary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:port-bug The issue is with a library, which is something the port should already support category:port-update The issue is with a library, which is requesting update new revision info:internal This PR or Issue was filed by the vcpkg team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants