From af804776444337165c6f258586ac04af74b61974 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Tue, 9 May 2023 08:18:11 +0200 Subject: [PATCH] Cleanup (WIP) --- ports/libpq/Makefile | 2 +- ports/libpq/build-msvc.cmake | 104 +++++++++ ports/libpq/portfile.cmake | 305 ++++++-------------------- ports/libpq/vcpkg-cmake-wrapper.cmake | 2 +- versions/l-/libpq.json | 2 +- 5 files changed, 179 insertions(+), 236 deletions(-) create mode 100644 ports/libpq/build-msvc.cmake diff --git a/ports/libpq/Makefile b/ports/libpq/Makefile index 4a3a376cbd26b0..b610d6a8d43159 100644 --- a/ports/libpq/Makefile +++ b/ports/libpq/Makefile @@ -9,7 +9,7 @@ LIBPQ_INSTALL_LIBS = install-stlib endif ifeq ($(LIBPQ_LIBRARY_TYPE), shared) -ifeq ($(USING_MINGW), yes) +ifeq ($(LIBPQ_USING_MINGW), yes) # The import library name is the same as the static library name EXTRA_TARGET = install-lib-static endif diff --git a/ports/libpq/build-msvc.cmake b/ports/libpq/build-msvc.cmake new file mode 100644 index 00000000000000..25668744ef8c24 --- /dev/null +++ b/ports/libpq/build-msvc.cmake @@ -0,0 +1,104 @@ +function(build_msvc build_type source_path) + if(build_type STREQUAL "DEBUG") + set(label "${TARGET_TRIPLET}-dbg") + set(packages_dir "${CURRENT_PACKAGES_DIR}/debug") + else() + set(label "${TARGET_TRIPLET}-rel") + set(packages_dir "${CURRENT_PACKAGES_DIR}") + endif() + + set(build_path "${CURRENT_BUILDTREES_DIR}/${label}") + file(REMOVE_RECURSE "${build_path}") + file(COPY "${source_path}/" DESTINATION "${build_path}") + + message(STATUS "Patching ${label}") + vcpkg_apply_patches( + SOURCE_PATH "${build_path}" + PATCHES + patches/windows/Solution_${build_type}.patch + patches/windows/python3_build_${build_type}.patch + ) + vcpkg_replace_string("${build_path}/src/tools/msvc/MSBuildProject.pm" "perl" "\"${PERL}\"") + + file(COPY "${CURRENT_PORT_DIR}/config.pl" DESTINATION "${build_path}/src/tools/msvc") + configure_file("${CURRENT_PORT_DIR}/libpq.props.in" "${build_path}/libpq.props" @ONLY) + + set(config_file "${build_path}/src/tools/msvc/config.pl") + file(READ "${config_file}" _contents) + if("icu" IN_LIST FEATURES) + string(REPLACE "icu => undef" "icu => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}") + endif() + if("lz4" IN_LIST FEATURES) + string(REPLACE "lz4 => undef" "lz4 => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}") + endif() + if("nls" IN_LIST FEATURES) + string(REPLACE "nls => undef" "nls => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}") + vcpkg_acquire_msys(MSYS_ROOT PACKAGES gettext) + vcpkg_add_to_path("${MSYS_ROOT}/usr/bin") + endif() + if("openssl" IN_LIST FEATURES) + string(REPLACE "openssl => undef" "openssl => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}") + endif() + if("python" IN_LIST FEATURES) + #vcpkg_find_acquire_program(PYTHON3) + #get_filename_component(PYTHON3_EXE_PATH ${PYTHON3} DIRECTORY) + #vcpkg_add_to_path("${PYTHON3_EXE_PATH}") + string(REPLACE "python => undef" "python => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}") + endif() + if("tcl" IN_LIST FEATURES) + string(REPLACE "tcl => undef" "tcl => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}") + endif() + if("xml" IN_LIST FEATURES) + string(REPLACE "xml => undef" "xml => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}") + string(REPLACE "iconv => undef" "iconv => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}") + endif() + if("xslt" IN_LIST FEATURES) + string(REPLACE "xslt => undef" "xslt => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}") + endif() + if("zlib" IN_LIST FEATURES) + string(REPLACE "zlib => undef" "zlib => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}") + endif() + if("zstd" IN_LIST FEATURES) + string(REPLACE "zstd => undef" "zstd => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}") + endif() + file(WRITE "${config_file}" "${_contents}") + + vcpkg_get_windows_sdk(VCPKG_TARGET_PLATFORM_VERSION) + set(ENV{MSBFLAGS}"/p:PlatformToolset=${VCPKG_PLATFORM_TOOLSET} + /p:VCPkgLocalAppDataDisabled=true + /p:UseIntelMKL=No + /p:WindowsTargetPlatformVersion=${VCPKG_TARGET_PLATFORM_VERSION} + /m + /p:ForceImportBeforeCppTargets=\"${SCRIPTS}/buildsystems/msbuild/vcpkg.targets\" + /p:ForceImportAfterCppTargets=\"${build_path}/libpq.props\" + /p:VcpkgTriplet=${TARGET_TRIPLET} + /p:VcpkgCurrentInstalledDir=\"${CURRENT_INSTALLED_DIR}\"" + ) + if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") + set(ENV{MSBFLAGS} "$ENV{MSBFLAGS} /p:Platform=Win32") + endif() + + message(STATUS "Building ${label}") + if(HAS_TOOLS) + vcpkg_execute_required_process( + COMMAND "${PERL}" build.pl ${build_type} + WORKING_DIRECTORY "${build_path}/src/tools/msvc" + LOGNAME "build-${label}" + ) + else() + foreach(lib IN ITEMS libpq libecpg_compat) + vcpkg_execute_required_process( + COMMAND "${PERL}" build.pl ${build_type} ${lib} + WORKING_DIRECTORY "${build_path}/src/tools/msvc" + LOGNAME "build-${lib}-${label}" + ) + endforeach() + endif() + + message(STATUS "Installing ${label}") + vcpkg_execute_required_process( + COMMAND "${PERL}" install.pl "${packages_dir}" client + WORKING_DIRECTORY "${build_path}/src/tools/msvc" + LOGNAME "install-${label}" + ) +endfunction() diff --git a/ports/libpq/portfile.cmake b/ports/libpq/portfile.cmake index 06e64693851652..83bb1b8e03ee9a 100644 --- a/ports/libpq/portfile.cmake +++ b/ports/libpq/portfile.cmake @@ -1,26 +1,23 @@ -set(PORT_VERSION ${VERSION}) # NOTE: the python patches must be regenerated on version update - -## Download and extract sources vcpkg_download_distfile(ARCHIVE - URLS "https://ftp.postgresql.org/pub/source/v${PORT_VERSION}/postgresql-${PORT_VERSION}.tar.bz2" - FILENAME "postgresql-${PORT_VERSION}.tar.bz2" + URLS "https://ftp.postgresql.org/pub/source/v${VERSION}/postgresql-${VERSION}.tar.bz2" + FILENAME "postgresql-${VERSION}.tar.bz2" SHA512 115a8a4234791bba4e6dcc4617e9dd77abedcf767894ce9472c59cce9d5d4ef2d4e1746f3a0c7a99de4fc4385fb716652b70dce9f48be45a9db5a682517db7e8 ) set(PATCHES - patches/windows/install.patch - patches/windows/win_bison_flex.patch - patches/windows/openssl-version.patch - patches/windows/Solution.patch - patches/windows/MSBuildProject_fix_gendef_perl.patch - patches/windows/msgfmt.patch - patches/windows/python_lib.patch - patches/windows/fix-compile-flag-Zi.patch - patches/windows/tcl_version.patch - patches/windows/macro-def.patch - patches/fix-configure.patch - patches/no-server-tools.patch + patches/windows/install.patch + patches/windows/win_bison_flex.patch + patches/windows/openssl-version.patch + patches/windows/Solution.patch + patches/windows/MSBuildProject_fix_gendef_perl.patch + patches/windows/msgfmt.patch + patches/windows/python_lib.patch + patches/windows/fix-compile-flag-Zi.patch + patches/windows/tcl_version.patch + patches/windows/macro-def.patch + patches/fix-configure.patch + patches/no-server-tools.patch ) if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") list(APPEND PATCHES patches/windows/MSBuildProject-static-lib.patch) @@ -43,51 +40,25 @@ vcpkg_extract_source_archive( ARCHIVE "${ARCHIVE}" PATCHES ${PATCHES} ) -unset(buildenv_contents) -# Get paths to required programs -set(REQUIRED_PROGRAMS PERL) + +set(buildenv_contents "") +set(required_programs PERL) if(VCPKG_TARGET_IS_WINDOWS) - list(APPEND REQUIRED_PROGRAMS BISON FLEX) + list(APPEND required_programs BISON FLEX) endif() -foreach(program_name ${REQUIRED_PROGRAMS}) +foreach(program_name IN LISTS required_programs) # Need to rename win_bison and win_flex to just bison and flex vcpkg_find_acquire_program(${program_name}) - get_filename_component(${program_name}_EXE_PATH ${${program_name}} DIRECTORY) - vcpkg_add_to_path(PREPEND "${${program_name}_EXE_PATH}") - set(buildenv_contents "${buildenv_contents}\n\$ENV{'PATH'}=\$ENV{'PATH'} . ';${${program_name}_EXE_PATH}';") + get_filename_component(program_dir ${${program_name}} DIRECTORY) + vcpkg_add_to_path(PREPEND "${program_dir}") + string(APPEND buildenv_contents "\$ENV{'PATH'}=\$ENV{'PATH'} . ';${program_dir}';") endforeach() -## Setup build types -if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE MATCHES "[Rr][Ee][Ll][Ee][Aa][Ss][Ee]") - set(_buildtype RELEASE) - set(_short rel) - list(APPEND port_config_list ${_buildtype}) - set(INSTALL_PATH_SUFFIX_${_buildtype} "") - set(BUILDPATH_${_buildtype} "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${_short}") - file(REMOVE_RECURSE "${BUILDPATH_${_buildtype}}") #Clean old builds - set(PACKAGE_DIR_${_buildtype} ${CURRENT_PACKAGES_DIR}) - unset(_short) - unset(_buildtype) -endif() -if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]") - set(_buildtype DEBUG) - set(_short dbg) - list(APPEND port_config_list ${_buildtype}) - set(INSTALL_PATH_SUFFIX_${_buildtype} "/debug") - set(BUILDPATH_${_buildtype} "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${_short}") - file(REMOVE_RECURSE "${BUILDPATH_${_buildtype}}") #Clean old builds - set(PACKAGE_DIR_${_buildtype} "${CURRENT_PACKAGES_DIR}${INSTALL_PATH_SUFFIX_${_buildtype}}") - unset(_short) - unset(_buildtype) -endif() - -file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/share/${PORT}") - -## Do the build -if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) - vcpkg_cmake_get_vars(vars_file) - include("${vars_file}") +vcpkg_cmake_get_vars(cmake_vars_file) +include("${cmake_vars_file}") +if(VCPKG_DETECTED_MSVC) + file(WRITE "${SOURCE_PATH}/src/tools/msvc/buildenv.pl" "${buildenv_contents}") if("openssl" IN_LIST FEATURES) file(STRINGS "${CURRENT_INSTALLED_DIR}/lib/pkgconfig/openssl.pc" OPENSSL_VERSION REGEX "Version:") if(OPENSSL_VERSION) @@ -95,157 +66,34 @@ if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) endif() endif() - file(GLOB SOURCE_FILES ${SOURCE_PATH}/*) - foreach(_buildtype ${port_config_list}) - # Copy libpq sources. - message(STATUS "Copying libpq source files to ${BUILDPATH_${_buildtype}}...") - foreach(SOURCE_FILE ${SOURCE_FILES}) - file(COPY ${SOURCE_FILE} DESTINATION "${BUILDPATH_${_buildtype}}") - endforeach() - message(STATUS "Copying libpq source files... done") - - vcpkg_apply_patches( - SOURCE_PATH "${BUILDPATH_${_buildtype}}" - PATCHES patches/windows/Solution_${_buildtype}.patch - patches/windows/python3_build_${_buildtype}.patch - ) - message(STATUS "Patches applied!") - file(COPY "${CURRENT_PORT_DIR}/config.pl" DESTINATION "${BUILDPATH_${_buildtype}}/src/tools/msvc") - - set(MSPROJ_PERL "${BUILDPATH_${_buildtype}}/src/tools/msvc/MSBuildProject.pm") - file(READ "${MSPROJ_PERL}" _contents) - string(REPLACE "perl" "\"${PERL}\"" _contents "${_contents}") - file(WRITE "${MSPROJ_PERL}" "${_contents}") - - set(CONFIG_FILE "${BUILDPATH_${_buildtype}}/src/tools/msvc/config.pl") - file(READ "${CONFIG_FILE}" _contents) - - ## ldap => undef, # --with-ldap - ## extraver => undef, # --with-extra-version= - ## gss => undef, # --with-gssapi= - ## icu => undef, # --with-icu= ##done - ## nls => undef, # --enable-nls= ##done - ## tap_tests => undef, # --enable-tap-tests - ## tcl => undef, # --with-tcl= #done - ## perl => undef, # --with-perl - ## python => undef, # --with-python= ##done - ## openssl => undef, # --with-openssl= ##done - ## uuid => undef, # --with-ossp-uuid - ## xml => undef, # --with-libxml= ##done - ## xslt => undef, # --with-libxslt= ##done - ## iconv => undef, # (not in configure, path to iconv) ##done (needed by xml) - ## zlib => undef # --with-zlib= ##done - - ## Setup external dependencies - ##"-DFEATURES=core;openssl;zlib" "-DALL_FEATURES=openssl;zlib;readline;libedit;python;tcl;nls;systemd;llvm;icu;bonjour;uuid;xml;xslt;" - if("${FEATURES}" MATCHES "icu") - string(REPLACE "icu => undef" "icu => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}") - endif() - if("${FEATURES}" MATCHES "nls") - string(REPLACE "nls => undef" "nls => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}") - vcpkg_acquire_msys(MSYS_ROOT PACKAGES gettext) - vcpkg_add_to_path("${MSYS_ROOT}/usr/bin") - endif() - if("${FEATURES}" MATCHES "openssl") - string(REPLACE "openssl => undef" "openssl => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}") - endif() - if("${FEATURES}" MATCHES "python") - #vcpkg_find_acquire_program(PYTHON3) - #get_filename_component(PYTHON3_EXE_PATH ${PYTHON3} DIRECTORY) - #vcpkg_add_to_path("${PYTHON3_EXE_PATH}") - string(REPLACE "python => undef" "python => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}") - endif() - if("${FEATURES}" MATCHES "tcl") - string(REPLACE "tcl => undef" "tcl => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}") - endif() - if("${FEATURES}" MATCHES "xml") - string(REPLACE "xml => undef" "xml => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}") - string(REPLACE "iconv => undef" "iconv => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}") - endif() - if("${FEATURES}" MATCHES "xslt") - string(REPLACE "xslt => undef" "xslt => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}") - endif() - if("${FEATURES}" MATCHES "zlib") - string(REPLACE "zlib => undef" "zlib => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}") - endif() - if("${FEATURES}" MATCHES "lz4") - string(REPLACE "lz4 => undef" "lz4 => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}") - endif() - if("${FEATURES}" MATCHES "zstd") - string(REPLACE "zstd => undef" "zstd => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}") - endif() - - file(WRITE "${CONFIG_FILE}" "${_contents}") - file(WRITE "${BUILDPATH_${_buildtype}}/src/tools/msvc/buildenv.pl" "${buildenv_contents}") - configure_file("${CURRENT_PORT_DIR}/libpq.props.in" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}/libpq.props" @ONLY) - vcpkg_get_windows_sdk(VCPKG_TARGET_PLATFORM_VERSION) - set(ENV{MSBFLAGS} "/p:PlatformToolset=${VCPKG_PLATFORM_TOOLSET} - /p:VCPkgLocalAppDataDisabled=true - /p:UseIntelMKL=No - /p:WindowsTargetPlatformVersion=${VCPKG_TARGET_PLATFORM_VERSION} - /m - /p:ForceImportBeforeCppTargets=\"${SCRIPTS}/buildsystems/msbuild/vcpkg.targets\" - /p:ForceImportAfterCppTargets=\"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}/libpq.props\" - /p:VcpkgTriplet=${TARGET_TRIPLET} - /p:VcpkgCurrentInstalledDir=\"${CURRENT_INSTALLED_DIR}\"" - ) - if(HAS_TOOLS) - if(VCPKG_TARGET_ARCHITECTURE STREQUAL x86) - set(ENV{MSBFLAGS} "$ENV{MSBFLAGS} /p:Platform=Win32") - endif() - message(STATUS "Building libpq ${TARGET_TRIPLET}-${_buildtype}...") - vcpkg_execute_required_process( - COMMAND ${PERL} build.pl ${_buildtype} - WORKING_DIRECTORY "${BUILDPATH_${_buildtype}}/src/tools/msvc" - LOGNAME "build-${TARGET_TRIPLET}-${_buildtype}" - ) - message(STATUS "Building libpq ${TARGET_TRIPLET}-${_buildtype}... done") - else() - set(build_libs libpq libecpg_compat) - foreach(build_lib ${build_libs}) - message(STATUS "Building ${build_lib} ${TARGET_TRIPLET}-${_buildtype}...") - vcpkg_execute_required_process( - COMMAND ${PERL} build.pl ${_buildtype} ${build_lib} - WORKING_DIRECTORY "${BUILDPATH_${_buildtype}}/src/tools/msvc" - LOGNAME "build-${build_lib}-${TARGET_TRIPLET}-${_buildtype}" - ) - message(STATUS "Building ${build_lib} ${TARGET_TRIPLET}-${_buildtype}... done") - endforeach() - endif() - - message(STATUS "Installing libpq ${TARGET_TRIPLET}-${_buildtype}...") - vcpkg_execute_required_process( - COMMAND ${PERL} install.pl "${CURRENT_PACKAGES_DIR}${INSTALL_PATH_SUFFIX_${_buildtype}}" client - WORKING_DIRECTORY "${BUILDPATH_${_buildtype}}/src/tools/msvc" - LOGNAME "install-${TARGET_TRIPLET}-${_buildtype}" - ) - message(STATUS "Installing libpq ${TARGET_TRIPLET}-${_buildtype}... done") - endforeach() - - message(STATUS "Cleanup libpq ${TARGET_TRIPLET}...") - #Cleanup - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/doc") - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/tools") - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/symbols") - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/symbols") + include("${CMAKE_CURRENT_LIST_DIR}/build-msvc.cmake") + if(NOT VCPKG_BUILD_TYPE) + build_msvc(DEBUG "${SOURCE_PATH}") + endif() + build_msvc(RELEASE "${SOURCE_PATH}") if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") endif() - if(NOT HAS_TOOLS) - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/tools") - else() + if(HAS_TOOLS) vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/${PORT}") + else() + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/tools") endif() - - message(STATUS "Cleanup libpq ${TARGET_TRIPLET}... - done") - set(USE_DL OFF) else() file(COPY "${CMAKE_CURRENT_LIST_DIR}/Makefile" DESTINATION "${SOURCE_PATH}") + if("icu" IN_LIST FEATURES) + list(APPEND BUILD_OPTS --with-icu) + else() + list(APPEND BUILD_OPTS --without-icu) + endif() + if("lz4" IN_LIST FEATURES) + list(APPEND BUILD_OPTS --with-lz4) + else() + list(APPEND BUILD_OPTS --without-lz4) + endif() if("nls" IN_LIST FEATURES) list(APPEND BUILD_OPTS --enable-nls) set(ENV{MSGFMT} "${CURRENT_HOST_INSTALLED_DIR}/tools/gettext/bin/msgfmt${VCPKG_HOST_EXECUTABLE_SUFFIX}") @@ -257,25 +105,10 @@ else() else() list(APPEND BUILD_OPTS --without-openssl) endif() - if("zlib" IN_LIST FEATURES) - list(APPEND BUILD_OPTS --with-zlib) - else() - list(APPEND BUILD_OPTS --without-zlib) - endif() - if("zstd" IN_LIST FEATURES) - list(APPEND BUILD_OPTS --with-zstd) - else() - list(APPEND BUILD_OPTS --without-zstd) - endif() - if("icu" IN_LIST FEATURES) - list(APPEND BUILD_OPTS --with-icu) - else() - list(APPEND BUILD_OPTS --without-icu) - endif() - if("lz4" IN_LIST FEATURES) - list(APPEND BUILD_OPTS --with-lz4) + if("python" IN_LIST FEATURES) + list(APPEND BUILD_OPTS --with-python) else() - list(APPEND BUILD_OPTS --without-lz4) + list(APPEND BUILD_OPTS --without-python) endif() if("readline" IN_LIST FEATURES) list(APPEND BUILD_OPTS --with-readline) @@ -292,16 +125,19 @@ else() else() list(APPEND BUILD_OPTS --without-libxslt) endif() - if("python" IN_LIST FEATURES) - list(APPEND BUILD_OPTS --with-python) + if("zlib" IN_LIST FEATURES) + list(APPEND BUILD_OPTS --with-zlib) else() - list(APPEND BUILD_OPTS --without-python) + list(APPEND BUILD_OPTS --without-zlib) + endif() + if("zstd" IN_LIST FEATURES) + list(APPEND BUILD_OPTS --with-zstd) + else() + list(APPEND BUILD_OPTS --without-zstd) endif() if(VCPKG_TARGET_IS_ANDROID) # AND CMAKE_SYSTEM_VERSION LESS 26) list(APPEND BUILD_OPTS ac_cv_header_langinfo_h=no) endif() - vcpkg_cmake_get_vars(cmake_vars_file) - include("${cmake_vars_file}") if(VCPKG_DETECTED_CMAKE_OSX_SYSROOT) list(APPEND BUILD_OPTS "PG_SYSROOT=${VCPKG_DETECTED_CMAKE_OSX_SYSROOT}") endif() @@ -321,12 +157,12 @@ else() ) if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") - set(ENV{LIBPQ_LIBRARY_TYPE} shared) + set(ENV{LIBPQ_LIBRARY_TYPE} shared) else() - set(ENV{LIBPQ_LIBRARY_TYPE} static) + set(ENV{LIBPQ_LIBRARY_TYPE} static) endif() if(VCPKG_TARGET_IS_MINGW) - set(ENV{USING_MINGW} yes) + set(ENV{LIBPQ_USING_MINGW} yes) endif() if(HAS_TOOLS) set(ENV{LIBPQ_ENABLE_TOOLS} yes) @@ -336,11 +172,8 @@ else() file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/bin") file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") - if(NOT HAS_TOOLS) + if(HAS_TOOLS) file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin") - else() - vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin") - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug") endif() if(VCPKG_TARGET_IS_MINGW AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") @@ -354,17 +187,23 @@ else() file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/libpq.dll" "${CURRENT_PACKAGES_DIR}/debug/bin/libpq.dll") endif() endif() - if(VCPKG_TARGET_IS_MINGW) - set(USE_DL OFF) - else() - set(USE_DL ON) - endif() vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/postgresql/server/pg_config.h" "#define CONFIGURE_ARGS" "// #define CONFIGURE_ARGS") vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/pg_config.h" "#define CONFIGURE_ARGS" "// #define CONFIGURE_ARGS") endif() +vcpkg_fixup_pkgconfig() configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" "${CURRENT_PACKAGES_DIR}/share/postgresql/vcpkg-cmake-wrapper.cmake" @ONLY) + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/doc" + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" + "${CURRENT_PACKAGES_DIR}/debug/symbols" + "${CURRENT_PACKAGES_DIR}/debug/tools" + "${CURRENT_PACKAGES_DIR}/symbols" + "${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug" +) + file(INSTALL "${CURRENT_PORT_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") -file(INSTALL "${SOURCE_PATH}/COPYRIGHT" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) -vcpkg_fixup_pkgconfig() +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYRIGHT") \ No newline at end of file diff --git a/ports/libpq/vcpkg-cmake-wrapper.cmake b/ports/libpq/vcpkg-cmake-wrapper.cmake index 311f3bb9d53c8f..6f1432570cdd23 100644 --- a/ports/libpq/vcpkg-cmake-wrapper.cmake +++ b/ports/libpq/vcpkg-cmake-wrapper.cmake @@ -6,7 +6,7 @@ PATHS NO_DEFAULT_PATH ) _find_package(${ARGS}) -if(PostgreSQL_FOUND AND @USE_DL@) +if(PostgreSQL_FOUND AND NOT "@VCPKG_TARGET_IS_WINDOWS@") find_library(PostgreSQL_DL_LIBRARY NAMES dl) if(PostgreSQL_DL_LIBRARY) list(APPEND PostgreSQL_LIBRARIES "dl") diff --git a/versions/l-/libpq.json b/versions/l-/libpq.json index 9ad7b7faeb79e5..c2d8d54efa2c3f 100644 --- a/versions/l-/libpq.json +++ b/versions/l-/libpq.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "c3335f31812e4623c46d3563f325cedfb2a815c0", + "git-tree": "8086a8d881a387c31eb421ca49b18695fec87026", "version": "15.2", "port-version": 4 },