From 41f6126182054f9b37cd2cdb56d13136cc020db2 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Sat, 2 Mar 2024 10:03:42 +0100 Subject: [PATCH] Add pyqt5 --- ports/py-pyqt5-sip/portfile.cmake | 16 ++ ports/py-pyqt5-sip/vcpkg.json | 18 ++ ports/py-pyqt5/portfile.cmake | 49 +++++ ports/py-pyqt5/vcpkg.json | 32 ++++ ports/vcpkg-qmake-qt5/portfile.cmake | 10 + ports/vcpkg-qmake-qt5/vcpkg-port-config.cmake | 7 + ports/vcpkg-qmake-qt5/vcpkg.json | 18 ++ ports/vcpkg-qmake-qt5/vcpkg_qmake_build.cmake | 72 +++++++ .../vcpkg_qmake_configure.cmake | 175 ++++++++++++++++++ .../vcpkg-qmake-qt5/vcpkg_qmake_install.cmake | 46 +++++ .../z_vcpkg_qmake_fix_makefiles.cmake | 35 ++++ 11 files changed, 478 insertions(+) create mode 100644 ports/py-pyqt5-sip/portfile.cmake create mode 100644 ports/py-pyqt5-sip/vcpkg.json create mode 100644 ports/py-pyqt5/portfile.cmake create mode 100644 ports/py-pyqt5/vcpkg.json create mode 100644 ports/vcpkg-qmake-qt5/portfile.cmake create mode 100644 ports/vcpkg-qmake-qt5/vcpkg-port-config.cmake create mode 100644 ports/vcpkg-qmake-qt5/vcpkg.json create mode 100644 ports/vcpkg-qmake-qt5/vcpkg_qmake_build.cmake create mode 100644 ports/vcpkg-qmake-qt5/vcpkg_qmake_configure.cmake create mode 100644 ports/vcpkg-qmake-qt5/vcpkg_qmake_install.cmake create mode 100644 ports/vcpkg-qmake-qt5/z_vcpkg_qmake_fix_makefiles.cmake diff --git a/ports/py-pyqt5-sip/portfile.cmake b/ports/py-pyqt5-sip/portfile.cmake new file mode 100644 index 0000000..e44feec --- /dev/null +++ b/ports/py-pyqt5-sip/portfile.cmake @@ -0,0 +1,16 @@ +set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) + +vcpkg_from_pythonhosted( + OUT_SOURCE_PATH SOURCE_PATH + PACKAGE_NAME PyQt5_sip + VERSION ${VERSION} + SHA512 ef363b21899f6d089fbc6d5adf700dc6c8838501343070ed1cf0826e05dd860343eba608d5aee5d8bece39b8ddca1f37866bb56aa07db18384ac0a372ca3532f +) + +vcpkg_python_build_and_install_wheel(SOURCE_PATH "${SOURCE_PATH}") + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") + +vcpkg_python_test_import(MODULE "PyQt5.sip") + +set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) \ No newline at end of file diff --git a/ports/py-pyqt5-sip/vcpkg.json b/ports/py-pyqt5-sip/vcpkg.json new file mode 100644 index 0000000..cd99b16 --- /dev/null +++ b/ports/py-pyqt5-sip/vcpkg.json @@ -0,0 +1,18 @@ +{ + "name": "py-pyqt5-sip", + "version": "12.13.0", + "description": "Python bindings for the Qt cross platform application toolkit", + "homepage": "https://www.riverbankcomputing.com/software/pyqt/", + "dependencies": [ + "python3", + "py-sip", + { + "name": "py-setuptools", + "host": true + }, + { + "name": "vcpkg-python-scripts", + "host": true + } + ] +} diff --git a/ports/py-pyqt5/portfile.cmake b/ports/py-pyqt5/portfile.cmake new file mode 100644 index 0000000..8c264c9 --- /dev/null +++ b/ports/py-pyqt5/portfile.cmake @@ -0,0 +1,49 @@ +set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled) +set(VCPKG_BUILD_TYPE release) + +vcpkg_from_pythonhosted( + OUT_SOURCE_PATH SOURCE_PATH + PACKAGE_NAME PyQt5 + VERSION ${VERSION} + SHA512 e62debe112210b68993377264448199b66a43fc5db13c583a25e210759f5cd945bd1056c1c19fb86bcf005c6904358dfb89e005d27167a349f1d55987a63013e +) + +# https://www.riverbankcomputing.com/static/Docs/PyQt5/installation.html +# sipbuild repo: /project.py +set(SIPBUILD_ARGS + "--confirm-license" + "--qmake" "${CURRENT_INSTALLED_DIR}/tools/qt5/bin/qmake${VCPKG_HOST_EXECUTABLE_SUFFIX}" + "--api-dir" "${CURRENT_PACKAGES_DIR}/share/qt5/qsci/api/python" + "--verbose" + "--qt-shared" + "--no-make" + "--disable" "QtDesigner" + "--pep484-pyi" + "--build-dir" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" + "--target-dir" "${PYTHON3_SITEPACKAGES}" +) + +vcpkg_backup_env_variables(VARS PATH) + +vcpkg_add_to_path(PREPEND "${CURRENT_HOST_INSTALLED_DIR}/tools/python3/Scripts/" "${CURRENT_HOST_INSTALLED_DIR}/tools/qt5/bin/" "${CURRENT_HOST_INSTALLED_DIR}/bin") + +message(STATUS "Running sipbuild...") +#vcpkg_execute_required_process( +# COMMAND "${PYTHON3}" "-m" "sipbuild.tools.build" ${SIPBUILD_ARGS} +# WORKING_DIRECTORY "${SOURCE_PATH}" +# LOGNAME "sipbuild-${TARGET_TRIPLET}" +#) +message(STATUS "Running sipbuild...finished.") + +# inventory.txt is consumed by the distinfo tool which is run during make and should be run against the package directory +file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}" NATIVE_INSTALLED_DIR) +vcpkg_replace_string("${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/inventory.txt" + "${CURRENT_INSTALLED_DIR}" + "${CURRENT_PACKAGES_DIR}") + vcpkg_replace_string("${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/inventory.txt" + "${NATIVE_INSTALLED_DIR}" + "${CURRENT_PACKAGES_DIR}") + +vcpkg_qmake_build(BUILD_LOGNAME "install" TARGETS "install") + +vcpkg_python_test_import(MODULE "PyQt5.QtCore") diff --git a/ports/py-pyqt5/vcpkg.json b/ports/py-pyqt5/vcpkg.json new file mode 100644 index 0000000..69841e4 --- /dev/null +++ b/ports/py-pyqt5/vcpkg.json @@ -0,0 +1,32 @@ +{ + "name": "py-pyqt5", + "version": "5.15.10", + "description": "Python bindings for the Qt cross platform application toolkit", + "homepage": "https://www.riverbankcomputing.com/software/pyqt/", + "dependencies": [ + "python3", + "py-sip", + "py-pyqt5-sip", + "py-pyqt-builder", + "py-ply", + "py-packaging", + { + "name": "qt5-activeqt", + "platform": "windows" + }, + "qt5-base", + "qt5-multimedia", + "qt5-sensors", + "qt5-svg", + "qt5-webchannel", + "qt5-websockets", + { + "name": "vcpkg-python-scripts", + "host": true + }, + { + "name": "vcpkg-qmake-qt5", + "host": true + } + ] +} diff --git a/ports/vcpkg-qmake-qt5/portfile.cmake b/ports/vcpkg-qmake-qt5/portfile.cmake new file mode 100644 index 0000000..24e9eb1 --- /dev/null +++ b/ports/vcpkg-qmake-qt5/portfile.cmake @@ -0,0 +1,10 @@ +file(INSTALL + "${CMAKE_CURRENT_LIST_DIR}/vcpkg_qmake_configure.cmake" + "${CMAKE_CURRENT_LIST_DIR}/vcpkg_qmake_build.cmake" + "${CMAKE_CURRENT_LIST_DIR}/vcpkg_qmake_install.cmake" + "${CMAKE_CURRENT_LIST_DIR}/z_vcpkg_qmake_fix_makefiles.cmake" + "${CMAKE_CURRENT_LIST_DIR}/vcpkg-port-config.cmake" + DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") + +file(INSTALL "${VCPKG_ROOT_DIR}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) +set(VCPKG_POLICY_CMAKE_HELPER_PORT enabled) diff --git a/ports/vcpkg-qmake-qt5/vcpkg-port-config.cmake b/ports/vcpkg-qmake-qt5/vcpkg-port-config.cmake new file mode 100644 index 0000000..b95854c --- /dev/null +++ b/ports/vcpkg-qmake-qt5/vcpkg-port-config.cmake @@ -0,0 +1,7 @@ +include_guard(GLOBAL) +include("${CMAKE_CURRENT_LIST_DIR}/../vcpkg-cmake-get-vars/vcpkg-port-config.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/z_vcpkg_qmake_fix_makefiles.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_qmake_configure.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_qmake_build.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_qmake_install.cmake") + diff --git a/ports/vcpkg-qmake-qt5/vcpkg.json b/ports/vcpkg-qmake-qt5/vcpkg.json new file mode 100644 index 0000000..38295d9 --- /dev/null +++ b/ports/vcpkg-qmake-qt5/vcpkg.json @@ -0,0 +1,18 @@ +{ + "name": "vcpkg-qmake-qt5", + "version-date": "2024-02-29", + "documentation": "https://vcpkg.io/en/docs/README.html", + "license": "MIT", + "supports": "native", + "dependencies": [ + "pkgconf", + { + "name": "qt5-base", + "default-features": false + }, + { + "name": "vcpkg-cmake-get-vars", + "host": true + } + ] +} diff --git a/ports/vcpkg-qmake-qt5/vcpkg_qmake_build.cmake b/ports/vcpkg-qmake-qt5/vcpkg_qmake_build.cmake new file mode 100644 index 0000000..1f269cf --- /dev/null +++ b/ports/vcpkg-qmake-qt5/vcpkg_qmake_build.cmake @@ -0,0 +1,72 @@ +include_guard(GLOBAL) + +function(z_run_jom_build invoke_command targets log_prefix log_suffix) + message(STATUS "Package ${log_prefix}-${TARGET_TRIPLET}-${log_suffix}") + vcpkg_execute_build_process( + COMMAND "${invoke_command}" -j ${VCPKG_CONCURRENCY} ${targets} + NO_PARALLEL_COMMAND "${invoke_command}" -j 1 ${targets} + WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${log_suffix}" + LOGNAME "package-${log_prefix}-${TARGET_TRIPLET}-${log_suffix}" + ) +endfunction() + +function(vcpkg_qmake_build) + # parse parameters such that semicolons in options arguments to COMMAND don't get erased + cmake_parse_arguments(PARSE_ARGV 0 arg + "SKIP_MAKEFILES" + "BUILD_LOGNAME" + "TARGETS;RELEASE_TARGETS;DEBUG_TARGETS" + ) + + # Make sure that the linker finds the libraries used + vcpkg_backup_env_variables(VARS PATH LD_LIBRARY_PATH) + + if(CMAKE_HOST_WIN32) + if (VCPKG_QMAKE_USE_NMAKE) + find_program(NMAKE nmake) + set(invoke_command "${NMAKE}") + get_filename_component(nmake_exe_path "${NMAKE}" DIRECTORY) + vcpkg_host_path_list(APPEND ENV{PATH} "${nmake_exe_path}") + else() + vcpkg_find_acquire_program(JOM) + set(invoke_command "${JOM}") + endif() + else() + find_program(MAKE make) + set(invoke_command "${MAKE}") + endif() + + file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}" NATIVE_INSTALLED_DIR) + + if(NOT DEFINED arg_BUILD_LOGNAME) + set(arg_BUILD_LOGNAME build) + endif() + + set(short_name_debug "dbg") + set(path_suffix_debug "/debug") + set(targets_debug "${arg_DEBUG_TARGETS}") + + set(short_name_release "rel") + set(path_suffix_release "") + set(targets_release "${arg_RELEASE_TARGETS}") + + if(NOT DEFINED VCPKG_BUILD_TYPE) + set(items debug release) + else() + set(items release) + endif() + foreach(build_type IN ITEMS ${items}) + set(current_installed_prefix "${CURRENT_INSTALLED_DIR}${path_suffix_${build_type}}") + + vcpkg_add_to_path(PREPEND "${current_installed_prefix}/lib" "${current_installed_prefix}/bin") + + vcpkg_list(SET targets ${targets_${build_type}} ${arg_TARGETS}) + if(NOT arg_SKIP_MAKEFILES) + z_run_jom_build("${invoke_command}" qmake_all makefiles "${short_name_${build_type}}") + z_vcpkg_qmake_fix_makefiles("${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${short_name_${build_type}}") + endif() + z_run_jom_build("${invoke_command}" "${targets}" "${arg_BUILD_LOGNAME}" "${short_name_${build_type}}") + + vcpkg_restore_env_variables(VARS PATH LD_LIBRARY_PATH) + endforeach() +endfunction() diff --git a/ports/vcpkg-qmake-qt5/vcpkg_qmake_configure.cmake b/ports/vcpkg-qmake-qt5/vcpkg_qmake_configure.cmake new file mode 100644 index 0000000..289f41f --- /dev/null +++ b/ports/vcpkg-qmake-qt5/vcpkg_qmake_configure.cmake @@ -0,0 +1,175 @@ +include_guard(GLOBAL) + +function(vcpkg_qmake_configure) + cmake_parse_arguments(PARSE_ARGV 0 arg "" "SOURCE_PATH" "QMAKE_OPTIONS;QMAKE_OPTIONS_RELEASE;QMAKE_OPTIONS_DEBUG;OPTIONS;OPTIONS_RELEASE;OPTIONS_DEBUG") + + vcpkg_cmake_get_vars(detected_file) + include("${detected_file}") + + if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + vcpkg_list(APPEND arg_QMAKE_OPTIONS "CONFIG-=shared") + vcpkg_list(APPEND arg_QMAKE_OPTIONS "CONFIG*=static") + else() + vcpkg_list(APPEND arg_QMAKE_OPTIONS "CONFIG-=static") + vcpkg_list(APPEND arg_QMAKE_OPTIONS "CONFIG*=shared") + vcpkg_list(APPEND arg_QMAKE_OPTIONS_DEBUG "CONFIG*=separate_debug_info") + endif() + if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_CRT_LINKAGE STREQUAL "static") + vcpkg_list(APPEND arg_QMAKE_OPTIONS "CONFIG*=static-runtime") + endif() + + set(ENV{PKG_CONFIG} "${CURRENT_HOST_INSTALLED_DIR}/tools/pkgconf/pkgconf${VCPKG_HOST_EXECUTABLE_SUFFIX}") + get_filename_component(PKGCONFIG_PATH "${PKGCONFIG}" DIRECTORY) + vcpkg_add_to_path("${PKGCONFIG_PATH}") + + set(buildtypes "") + if(NOT VCPKG_BUILD_TYPE OR "${VCPKG_BUILD_TYPE}" STREQUAL "debug") + list(APPEND buildtypes "DEBUG") # Using uppercase to also access the detected cmake variables with it + set(path_suffix_DEBUG "debug/") + set(short_name_DEBUG "dbg") + set(qmake_config_DEBUG CONFIG+=debug CONFIG-=release) + endif() + if(NOT VCPKG_BUILD_TYPE OR "${VCPKG_BUILD_TYPE}" STREQUAL "release") + list(APPEND buildtypes "RELEASE") + set(path_suffix_RELEASE "") + set(short_name_RELEASE "rel") + set(qmake_config_RELEASE CONFIG-=debug CONFIG+=release) + endif() + + function(qmake_append_program var qmake_var value) + get_filename_component(prog "${value}" NAME) + # QMake assumes everything is on PATH? + vcpkg_list(APPEND ${var} "${qmake_var}=${prog}") + find_program(${qmake_var} NAMES "${prog}") + cmake_path(COMPARE "${${qmake_var}}" EQUAL "${value}" correct_prog_on_path) + if(NOT correct_prog_on_path AND NOT "${value}" MATCHES "|:") + message(FATAL_ERROR "Detect path mismatch for '${qmake_var}'. '${value}' is not the same as '${${qmake_var}}'. Please correct your PATH!") + endif() + unset(${qmake_var}) + unset(${qmake_var} CACHE) + set(${var} "${${var}}" PARENT_SCOPE) # Is this correct? Or is there a vcpkg_list command for that? + endfunction() + # Setup Build tools + if(NOT VCPKG_QMAKE_COMMAND) + set(VCPKG_QMAKE_COMMAND "${CURRENT_HOST_INSTALLED_DIR}/tools/qt5/bin/qmake${VCPKG_HOST_EXECUTABLE_SUFFIX}") + endif() + + if(VCPKG_TARGET_IS_OSX) + # Get Qt version + execute_process( + COMMAND ${VCPKG_QMAKE_COMMAND} -query QT_VERSION + OUTPUT_VARIABLE QT_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + if(DEFINED VCPKG_OSX_DEPLOYMENT_TARGET) + vcpkg_list(APPEND arg_QMAKE_OPTIONS "QMAKE_MACOSX_DEPLOYMENT_TARGET=${VCPKG_OSX_DEPLOYMENT_TARGET}") + elseif(${QT_VERSION} VERSION_GREATER_EQUAL 6) + # https://doc.qt.io/qt-6/macos.html + vcpkg_list(APPEND arg_QMAKE_OPTIONS "QMAKE_MACOSX_DEPLOYMENT_TARGET=10.15") + else() # Qt5 + # https://doc.qt.io/qt-5/macos.html + vcpkg_list(APPEND arg_QMAKE_OPTIONS "QMAKE_MACOSX_DEPLOYMENT_TARGET=10.13") + endif() + endif() + + set(qmake_build_tools "") + qmake_append_program(qmake_build_tools "QMAKE_CC" "${VCPKG_DETECTED_CMAKE_C_COMPILER}") + qmake_append_program(qmake_build_tools "QMAKE_CXX" "${VCPKG_DETECTED_CMAKE_CXX_COMPILER}") + qmake_append_program(qmake_build_tools "QMAKE_AR" "${VCPKG_DETECTED_CMAKE_AR}") + qmake_append_program(qmake_build_tools "QMAKE_RANLIB" "${VCPKG_DETECTED_CMAKE_RANLIB}") + qmake_append_program(qmake_build_tools "QMAKE_STRIP" "${VCPKG_DETECTED_CMAKE_STRIP}") + qmake_append_program(qmake_build_tools "QMAKE_NM" "${VCPKG_DETECTED_CMAKE_NM}") + qmake_append_program(qmake_build_tools "QMAKE_RC" "${VCPKG_DETECTED_CMAKE_RC_COMPILER}") + qmake_append_program(qmake_build_tools "QMAKE_MT" "${VCPKG_DETECTED_CMAKE_MT}") + + if(NOT VCPKG_TARGET_IS_WINDOWS OR VCPKG_DETECTED_CMAKE_AR MATCHES "ar$") + vcpkg_list(APPEND qmake_build_tools "QMAKE_AR+=qc") + endif() + + if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) + qmake_append_program(qmake_build_tools "QMAKE_LIB" "${VCPKG_DETECTED_CMAKE_AR}") + qmake_append_program(qmake_build_tools "QMAKE_LINK" "${VCPKG_DETECTED_CMAKE_LINKER}") + else() + qmake_append_program(qmake_build_tools "QMAKE_LINK" "${VCPKG_DETECTED_CMAKE_CXX_COMPILER}") + qmake_append_program(qmake_build_tools "QMAKE_LINK_SHLIB" "${VCPKG_DETECTED_CMAKE_CXX_COMPILER}") + qmake_append_program(qmake_build_tools "QMAKE_LINK_C" "${VCPKG_DETECTED_CMAKE_C_COMPILER}") + qmake_append_program(qmake_build_tools "QMAKE_LINK_C_SHLIB" "${VCPKG_DETECTED_CMAKE_C_COMPILER}") + endif() + + if(DEFINED VCPKG_QT_TARGET_MKSPEC) + vcpkg_list(APPEND arg_QMAKE_OPTIONS "-spec" "${VCPKG_QT_TARGET_MKSPEC}") + endif() + + foreach(buildtype IN LISTS buildtypes) + set(short "${short_name_${buildtype}}") + string(TOLOWER "${buildtype}" lowerbuildtype) + set(prefix "${CURRENT_INSTALLED_DIR}${path_suffix_${buildtype}}") + set(prefix_package "${CURRENT_PACKAGES_DIR}${path_suffix_${buildtype}}") + set(config_triplet "${TARGET_TRIPLET}-${short}") + # Cleanup build directories + file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${config_triplet}") + + set(qmake_comp_flags "") + macro(qmake_add_flags qmake_var operation flags) + string(STRIP "${flags}" striped_flags) + if(striped_flags) + vcpkg_list(APPEND qmake_comp_flags "${qmake_var}${operation}${striped_flags}") + endif() + endmacro() + + qmake_add_flags("QMAKE_LIBS" "+=" "${VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES}") + qmake_add_flags("QMAKE_RC" "+=" "${VCPKG_COMBINED_RC_FLAGS_${buildtype}}") # not exported by vcpkg_cmake_get_vars yet + qmake_add_flags("QMAKE_CFLAGS_${buildtype}" "+=" "${VCPKG_COMBINED_C_FLAGS_${buildtype}}") + qmake_add_flags("QMAKE_CXXFLAGS_${buildtype}" "+=" "${VCPKG_COMBINED_CXX_FLAGS_${buildtype}}") + qmake_add_flags("QMAKE_LFLAGS" "+=" "${VCPKG_COMBINED_STATIC_LINKER_FLAGS_${buildtype}}") + qmake_add_flags("QMAKE_LFLAGS_SHLIB" "+=" "${VCPKG_COMBINED_SHARED_LINKER_FLAGS_${buildtype}}") + qmake_add_flags("QMAKE_LFLAGS_PLUGIN" "+=" "${VCPKG_COMBINED_MODULE_LINKER_FLAGS_${buildtype}}") + qmake_add_flags("QMAKE_LIBFLAGS" "+=" "${VCPKG_COMBINED_STATIC_LINKER_FLAGS_${buildtype}}") + qmake_add_flags("QMAKE_LIBFLAGS_${buildtype}" "+=" "${VCPKG_COMBINED_STATIC_LINKER_FLAGS_${buildtype}}") + vcpkg_list(APPEND qmake_build_tools "QMAKE_AR+=${VCPKG_COMBINED_STATIC_LINKER_FLAGS_${buildtype}}") + + # QMAKE_CXXFLAGS_SHLIB + + # Setup qt.conf + if(NOT VCPKG_QT_CONF_${buildtype}) + set(VCPKG_QT_CONF_${buildtype} "${CURRENT_INSTALLED_DIR}/tools/qt5/qt_${lowerbuildtype}.conf") + else() + # Let a supplied qt.conf override everything. + # The file will still be configured so users might use the variables within this scope. + set(qmake_build_tools "") + set(qmake_comp_flags "") + endif() + configure_file("${VCPKG_QT_CONF_${buildtype}}" "${CURRENT_BUILDTREES_DIR}/${config_triplet}/qt.conf") + + vcpkg_backup_env_variables(VARS PKG_CONFIG_PATH) + vcpkg_host_path_list(PREPEND PKG_CONFIG_PATH "${prefix}/lib/pkgconfig" "${CURRENT_INSTALLED_DIR}/share/pkgconfig") + + message(STATUS "Configuring ${config_triplet}") + file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${config_triplet}") + if(DEFINED arg_OPTIONS OR DEFINED arg_OPTIONS_${buildtype}) + set(options -- ${arg_OPTIONS} ${arg_OPTIONS_${buildtype}}) + endif() + # Options might need to go into a response file? I am a bit concerned about cmd line length. + vcpkg_execute_required_process( + COMMAND ${VCPKG_QMAKE_COMMAND} ${qmake_config_${buildtype}} + ${arg_QMAKE_OPTIONS} ${arg_QMAKE_OPTIONS_${buildtype}} + ${VCPKG_QMAKE_OPTIONS} ${VCPKG_QMAKE_OPTIONS_${buildtype}} # Advanced users need a way to inject QMAKE variables via the triplet. + ${qmake_build_tools} ${qmake_comp_flags} + "${arg_SOURCE_PATH}" + -qtconf "${CURRENT_BUILDTREES_DIR}/${config_triplet}/qt.conf" + ${options} + WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${config_triplet}" + LOGNAME config-${config_triplet} + SAVE_LOG_FILES config.log + ) + z_vcpkg_qmake_fix_makefiles("${CURRENT_BUILDTREES_DIR}/${config_triplet}") + message(STATUS "Configuring ${config_triplet} done") + + vcpkg_restore_env_variables(VARS PKG_CONFIG_PATH) + if(EXISTS "${CURRENT_BUILDTREES_DIR}/${config_triplet}/config.log") + file(REMOVE "${CURRENT_BUILDTREES_DIR}/internal-config-${config_triplet}.log") + file(RENAME "${CURRENT_BUILDTREES_DIR}/${config_triplet}/config.log" "${CURRENT_BUILDTREES_DIR}/internal-config-${config_triplet}.log") + endif() + endforeach() +endfunction() \ No newline at end of file diff --git a/ports/vcpkg-qmake-qt5/vcpkg_qmake_install.cmake b/ports/vcpkg-qmake-qt5/vcpkg_qmake_install.cmake new file mode 100644 index 0000000..1aee0aa --- /dev/null +++ b/ports/vcpkg-qmake-qt5/vcpkg_qmake_install.cmake @@ -0,0 +1,46 @@ +#[===[.md: +# vcpkg_qmake_install + +Build and install a qmake project. + +## Usage: +```cmake +vcpkg_qmake_install(...) +``` + +## Parameters: +See [`vcpkg_qmake_build()`](vcpkg_qmake_build.md). + +## Notes: +This command transparently forwards to [`vcpkg_qmake_build()`](vcpkg_qmake_build.md). +and appends the 'install' target + +#]===] + +function(z_vcpkg_qmake_fix_prl PACKAGE_DIR PRL_FILES) + file(TO_CMAKE_PATH "${PACKAGE_DIR}/lib" CMAKE_LIB_PATH) + file(TO_CMAKE_PATH "${PACKAGE_DIR}/include/qt5" CMAKE_INCLUDE_PATH_QT5) + file(TO_CMAKE_PATH "${PACKAGE_DIR}/include" CMAKE_INCLUDE_PATH) + file(TO_CMAKE_PATH "${CURRENT_INSTALLED_DIR}" CMAKE_INSTALLED_PREFIX) + foreach(PRL_FILE IN LISTS PRL_FILES) + file(READ "${PRL_FILE}" _contents) + string(REPLACE "${CMAKE_LIB_PATH}" "\$\$[QT_INSTALL_LIBS]" _contents "${_contents}") + string(REPLACE "${CMAKE_INCLUDE_PATH_QT5}" "\$\$[QT_INSTALL_HEADERS]" _contents "${_contents}") + string(REPLACE "${CMAKE_INCLUDE_PATH}" "\$\$[QT_INSTALL_HEADERS]/../" _contents "${_contents}") + string(REPLACE "${CMAKE_INSTALLED_PREFIX}" "\$\$[QT_INSTALL_PREFIX]" _contents "${_contents}") + string(REGEX REPLACE "QMAKE_PRL_BUILD_DIR[^\\\n]+" "QMAKE_PRL_BUILD_DIR =" _contents "${_contents}") + #Note: This only works without an extra if case since QT_INSTALL_PREFIX is the same for debug and release + file(WRITE "${PRL_FILE}" "${_contents}") + endforeach() +endfunction() + +function(vcpkg_qmake_install) + z_vcpkg_function_arguments(args) + vcpkg_qmake_build(${args}) + vcpkg_qmake_build(SKIP_MAKEFILES BUILD_LOGNAME "install" TARGETS "install") + + # Fix absolute paths in prl files + file(GLOB_RECURSE prl_files "${CURRENT_PACKAGES_DIR}/**.prl") + debug_message(STATUS "prl_files:${prl_files}") + z_vcpkg_qmake_fix_prl("${CURRENT_PACKAGES_DIR}" "${prl_files}") +endfunction() diff --git a/ports/vcpkg-qmake-qt5/z_vcpkg_qmake_fix_makefiles.cmake b/ports/vcpkg-qmake-qt5/z_vcpkg_qmake_fix_makefiles.cmake new file mode 100644 index 0000000..c82c0fb --- /dev/null +++ b/ports/vcpkg-qmake-qt5/z_vcpkg_qmake_fix_makefiles.cmake @@ -0,0 +1,35 @@ +include_guard(GLOBAL) +function(z_vcpkg_qmake_fix_makefiles BUILD_DIR) + #Fix the installation location + file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}" NATIVE_INSTALLED_DIR) + file(TO_NATIVE_PATH "${CURRENT_PACKAGES_DIR}" NATIVE_PACKAGES_DIR) + + if(WIN32) + string(SUBSTRING "${CURRENT_INSTALLED_DIR}" 2 -1 INSTALLED_DIR_WITHOUT_DRIVE) + string(SUBSTRING "${CURRENT_PACKAGES_DIR}" 2 -1 PACKAGES_DIR_WITHOUT_DRIVE) + string(SUBSTRING "${NATIVE_INSTALLED_DIR}" 2 -1 NATIVE_INSTALLED_DIR_WITHOUT_DRIVE) + string(SUBSTRING "${NATIVE_PACKAGES_DIR}" 2 -1 NATIVE_PACKAGES_DIR_WITHOUT_DRIVE) + string(SUBSTRING "${NATIVE_INSTALLED_DIR}" 0 2 INSTALLED_DRIVE) + string(SUBSTRING "${NATIVE_PACKAGES_DIR}" 0 2 PACKAGES_DRIVE) + else() + set(INSTALLED_DRIVE "") + set(PACKAGES_DRIVE "") + set(INSTALLED_DIR_WITHOUT_DRIVE "${NATIVE_INSTALLED_DIR}") + set(PACKAGES_DIR_WITHOUT_DRIVE "${NATIVE_PACKAGES_DIR}") + set(NATIVE_INSTALLED_DIR_WITHOUT_DRIVE "${NATIVE_INSTALLED_DIR}") + set(NATIVE_PACKAGES_DIR_WITHOUT_DRIVE "${NATIVE_PACKAGES_DIR}") + endif() + + file(GLOB_RECURSE MAKEFILES "${BUILD_DIR}/**Makefile**") + + foreach(MAKEFILE ${MAKEFILES}) + #Set the correct install directory to packages + vcpkg_replace_string("${MAKEFILE}" + "${INSTALLED_DRIVE}$(INSTALL_ROOT)${INSTALLED_DIR_WITHOUT_DRIVE}" + "${PACKAGES_DRIVE}$(INSTALL_ROOT)${PACKAGES_DIR_WITHOUT_DRIVE}") + vcpkg_replace_string("${MAKEFILE}" + "${INSTALLED_DRIVE}$(INSTALL_ROOT)${NATIVE_INSTALLED_DIR_WITHOUT_DRIVE}" + "${PACKAGES_DRIVE}$(INSTALL_ROOT)${NATIVE_PACKAGES_DIR_WITHOUT_DRIVE}") + endforeach() + +endfunction() \ No newline at end of file