[qt5] Fix linux dynamic build (#15005)

This commit is contained in:
dweckmann 2020-12-21 20:17:30 +01:00 committed by GitHub
parent d97eae3338
commit f7e746dcae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 68 additions and 10 deletions

View File

@ -1,6 +1,6 @@
Source: qt5-base
Version: 5.15.1
Port-Version: 2
Port-Version: 3
Homepage: https://www.qt.io/
Description: Qt5 Application Framework Base Module. Includes Core, GUI, Widgets, Networking, SQL, Concurrent and other essential qt components.
Build-Depends: zlib, zstd, libjpeg-turbo, libpng, freetype, pcre2, harfbuzz, sqlite3, libpq, double-conversion, openssl, angle (!windows), egl-registry, icu (!uwp), fontconfig (!windows)

View File

@ -60,7 +60,23 @@ function(install_qt)
foreach(_buildname ${BUILDTYPES})
set(_build_triplet ${TARGET_TRIPLET}-${_short_name_${_buildname}})
vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}${_path_suffix_${_buildname}}/bin")
set(_installed_prefix_ "${CURRENT_INSTALLED_DIR}${_path_suffix_${_buildname}}")
set(_installed_libpath_ "${_installed_prefix_}/lib/${VCPKG_HOST_PATH_SEPARATOR}${_installed_prefix_}/lib/manual-link/")
vcpkg_add_to_path(PREPEND "${_installed_prefix_}/bin")
vcpkg_add_to_path(PREPEND "${_installed_prefix_}/lib")
# We set LD_LIBRARY_PATH ENV variable to allow executing Qt tools (rcc,...) even with dynamic linking
if(CMAKE_HOST_UNIX)
if(DEFINED ENV{LD_LIBRARY_PATH})
set(_ld_library_path_defined_ TRUE)
set(_ld_library_path_backup_ $ENV{LD_LIBRARY_PATH})
set(ENV{LD_LIBRARY_PATH} "${_installed_libpath_}${VCPKG_HOST_PATH_SEPARATOR}${_ld_library_path_backup_}")
else()
set(_ld_library_path_defined_ FALSE)
set(ENV{LD_LIBRARY_PATH} "${_installed_libpath_}")
endif()
endif()
if(VCPKG_TARGET_IS_OSX)
# For some reason there will be an error on MacOSX without this clean!
@ -100,5 +116,14 @@ function(install_qt)
)
message(STATUS "Package ${_build_triplet} done")
set(ENV{PATH} "${_path}")
# Restore backup
if(CMAKE_HOST_UNIX)
if(_ld_library_path_defined_)
set(ENV{LD_LIBRARY_PATH} "${_ld_library_path_backup_}")
else()
unset(ENV{LD_LIBRARY_PATH})
endif()
endif()
endforeach()
endfunction()

View File

@ -120,10 +120,14 @@ find_library(LIBPNG_RELEASE NAMES png16 libpng16 PATHS "${CURRENT_INSTALLED_DIR}
find_library(LIBPNG_DEBUG NAMES png16 png16d libpng16 libpng16d PATHS "${CURRENT_INSTALLED_DIR}/debug/lib" NO_DEFAULT_PATH)
find_library(PSQL_RELEASE NAMES pq libpq PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_DEFAULT_PATH) # Depends on openssl and zlib(linux)
find_library(PSQL_DEBUG NAMES pq libpq pqd libpqd PATHS "${CURRENT_INSTALLED_DIR}/debug/lib" NO_DEFAULT_PATH)
find_library(PSQL_COMMON_RELEASE NAMES pgcommon libpgcommon PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_DEFAULT_PATH) # Depends on openssl and zlib(linux)
find_library(PSQL_COMMON_DEBUG NAMES pgcommon libpgcommon pgcommond libpgcommond PATHS "${CURRENT_INSTALLED_DIR}/debug/lib" NO_DEFAULT_PATH)
find_library(PSQL_PORT_RELEASE NAMES pgport libpgport PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_DEFAULT_PATH) # Depends on openssl and zlib(linux)
find_library(PSQL_PORT_DEBUG NAMES pgport libpgport pgportd libpgportd PATHS "${CURRENT_INSTALLED_DIR}/debug/lib" NO_DEFAULT_PATH)
if(NOT (PSQL_RELEASE MATCHES ".*\.so") AND NOT (PSQL_DEBUG MATCHES ".*\.so"))
find_library(PSQL_COMMON_RELEASE NAMES pgcommon libpgcommon PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_DEFAULT_PATH) # Depends on openssl and zlib(linux)
find_library(PSQL_COMMON_DEBUG NAMES pgcommon libpgcommon pgcommond libpgcommond PATHS "${CURRENT_INSTALLED_DIR}/debug/lib" NO_DEFAULT_PATH)
find_library(PSQL_PORT_RELEASE NAMES pgport libpgport PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_DEFAULT_PATH) # Depends on openssl and zlib(linux)
find_library(PSQL_PORT_DEBUG NAMES pgport libpgport pgportd libpgportd PATHS "${CURRENT_INSTALLED_DIR}/debug/lib" NO_DEFAULT_PATH)
endif()
find_library(PCRE2_RELEASE NAMES pcre2-16 PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_DEFAULT_PATH)
find_library(PCRE2_DEBUG NAMES pcre2-16 pcre2-16d PATHS "${CURRENT_INSTALLED_DIR}/debug/lib" NO_DEFAULT_PATH)
find_library(FREETYPE_RELEASE NAMES freetype PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_DEFAULT_PATH) #zlib, bzip2, libpng
@ -169,6 +173,8 @@ find_library(EXPAT_RELEASE NAMES expat PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_D
find_library(EXPAT_DEBUG NAMES expat PATHS "${CURRENT_INSTALLED_DIR}/debug/lib" NO_DEFAULT_PATH)
#Dependent libraries
find_library(ZSTD_RELEASE NAMES zstd zstd_static PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_DEFAULT_PATH)
find_library(ZSTD_DEBUG NAMES zstdd zstd_staticd PATHS "${CURRENT_INSTALLED_DIR}/debug/lib" NO_DEFAULT_PATH)
find_library(BZ2_RELEASE bz2 PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_DEFAULT_PATH)
find_library(BZ2_DEBUG bz2 bz2d PATHS "${CURRENT_INSTALLED_DIR}/debug/lib" NO_DEFAULT_PATH)
find_library(SSL_RELEASE ssl ssleay32 PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_DEFAULT_PATH)
@ -197,6 +203,8 @@ set(RELEASE_OPTIONS
"ICU_LIBS=${ICU_RELEASE}"
"QMAKE_LIBS_PRIVATE+=${BZ2_RELEASE}"
"QMAKE_LIBS_PRIVATE+=${LIBPNG_RELEASE}"
"QMAKE_LIBS_PRIVATE+=${ICU_RELEASE}"
"QMAKE_LIBS_PRIVATE+=${ZSTD_RELEASE}"
)
set(DEBUG_OPTIONS
"LIBJPEG_LIBS=${JPEG_DEBUG}"
@ -207,6 +215,8 @@ set(DEBUG_OPTIONS
"ICU_LIBS=${ICU_DEBUG}"
"QMAKE_LIBS_PRIVATE+=${BZ2_DEBUG}"
"QMAKE_LIBS_PRIVATE+=${LIBPNG_DEBUG}"
"QMAKE_LIBS_PRIVATE+=${ICU_DEBUG}"
"QMAKE_LIBS_PRIVATE+=${ZSTD_DEBUG}"
)

View File

@ -69,15 +69,38 @@ function(vcpkg_build_qmake)
unset(_buildname)
foreach(_buildname ${BUILDTYPES})
set(_BUILD_PREFIX "${_path_suffix_${_buildname}}")
vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}${_BUILD_PREFIX}/bin")
vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}${_BUILD_PREFIX}/lib")
set(_installed_prefix_ "${CURRENT_INSTALLED_DIR}${_path_suffix_${_buildname}}")
set(_installed_libpath_ "${_installed_prefix_}/lib/${VCPKG_HOST_PATH_SEPARATOR}${_installed_prefix_}/lib/manual-link/")
vcpkg_add_to_path(PREPEND "${_installed_prefix_}/bin")
vcpkg_add_to_path(PREPEND "${_installed_prefix_}/lib")
# We set LD_LIBRARY_PATH ENV variable to allow executing Qt tools (rcc,...) even with dynamic linking
if(CMAKE_HOST_UNIX)
if(DEFINED ENV{LD_LIBRARY_PATH})
set(_ld_library_path_defined_ TRUE)
set(_ld_library_path_backup_ $ENV{LD_LIBRARY_PATH})
set(ENV{LD_LIBRARY_PATH} "${_installed_libpath_}${VCPKG_HOST_PATH_SEPARATOR}${_ld_library_path_backup_}")
else()
set(_ld_library_path_defined_ FALSE)
set(ENV{LD_LIBRARY_PATH} "${_installed_libpath_}")
endif()
endif()
list(APPEND _csc_${_buildname}_TARGETS ${_csc_TARGETS})
if(NOT _csc_SKIP_MAKEFILES)
run_jom(qmake_all makefiles ${_short_name_${_buildname}})
endif()
run_jom("${_csc_${_buildname}_TARGETS}" ${_csc_BUILD_LOGNAME} ${_short_name_${_buildname}})
unset(_BUILD_PREFIX)
# Restore backup
if(CMAKE_HOST_UNIX)
if(_ld_library_path_defined_)
set(ENV{LD_LIBRARY_PATH} "${_ld_library_path_backup_}")
else()
unset(ENV{LD_LIBRARY_PATH})
endif()
endif()
endforeach()
# Restore the original value of ENV{PATH}