mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-27 18:31:15 +08:00
[Qt5|qmake] pass toolchain setup (#26354)
* [qt5/qmake] Pass toolchain flags to build * v db * forgot a dependency * v db * add required ar flags * v db * Apply suggestions from code review Co-authored-by: Javier Matos Denizac <javier.matosd@gmail.com> * v db * inc port version * v db * qt5-base * v db Co-authored-by: Javier Matos Denizac <javier.matosd@gmail.com>
This commit is contained in:
parent
8e3595fad0
commit
f2453e0619
@ -29,6 +29,46 @@ function(configure_qt)
|
||||
#Cleanup previous build folders
|
||||
file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg")
|
||||
|
||||
vcpkg_cmake_get_vars(detected_file)
|
||||
include("${detected_file}")
|
||||
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)
|
||||
endfunction()
|
||||
# Setup Build tools
|
||||
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$")
|
||||
# This is the reason why users should probably use a
|
||||
# customized qt.conf with more domain knowledge.
|
||||
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()
|
||||
|
||||
#Find and ad Perl to PATH
|
||||
vcpkg_find_acquire_program(PERL)
|
||||
get_filename_component(PERL_EXE_PATH ${PERL} DIRECTORY)
|
||||
@ -39,7 +79,7 @@ function(configure_qt)
|
||||
else()
|
||||
#list(APPEND _csc_OPTIONS_DEBUG -separate-debug-info)
|
||||
endif()
|
||||
|
||||
|
||||
if(VCPKG_TARGET_IS_WINDOWS AND "${VCPKG_CRT_LINKAGE}" STREQUAL "static")
|
||||
list(APPEND _csc_OPTIONS -static-runtime)
|
||||
endif()
|
||||
@ -69,7 +109,7 @@ function(configure_qt)
|
||||
set(ENV{PKG_CONFIG} "${PKGCONFIG}")
|
||||
get_filename_component(PKGCONFIG_PATH "${PKGCONFIG}" DIRECTORY)
|
||||
vcpkg_add_to_path("${PKGCONFIG_PATH}")
|
||||
|
||||
|
||||
foreach(_buildname ${BUILDTYPES})
|
||||
set(PKGCONFIG_INSTALLED_DIR "${_VCPKG_INSTALLED_PKGCONF}${_path_suffix_${_buildname}}/lib/pkgconfig")
|
||||
set(PKGCONFIG_INSTALLED_SHARE_DIR "${_VCPKG_INSTALLED_PKGCONF}/share/pkgconfig")
|
||||
@ -86,6 +126,25 @@ function(configure_qt)
|
||||
message(STATUS "Configuring ${_build_triplet}")
|
||||
set(_build_dir "${CURRENT_BUILDTREES_DIR}/${_build_triplet}")
|
||||
file(MAKE_DIRECTORY ${_build_dir})
|
||||
|
||||
set(qmake_comp_flags "")
|
||||
# Note sure about these. VCPKG_QMAKE_OPTIONS offers a way to opt out of these. (earlier values being overwritten by later values; = set +=append *=append unique -=remove)
|
||||
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_${_buildname}}")
|
||||
qmake_add_flags("QMAKE_CFLAGS_${_buildname}" "+=" "${VCPKG_COMBINED_C_FLAGS_${_buildname}}")
|
||||
qmake_add_flags("QMAKE_CXXFLAGS_${_buildname}" "+=" "${VCPKG_COMBINED_CXX_FLAGS_${_buildname}}")
|
||||
qmake_add_flags("QMAKE_LFLAGS" "+=" "${VCPKG_COMBINED_SHARED_LINKER_FLAGS_${_buildname}}")
|
||||
qmake_add_flags("QMAKE_LFLAGS_SHLIB" "+=" "${VCPKG_COMBINED_SHARED_LINKER_FLAGS_${_buildname}}")
|
||||
qmake_add_flags("QMAKE_LFLAGS_PLUGIN" "+=" "${VCPKG_COMBINED_MODULE_LINKER_FLAGS_${_buildname}}")
|
||||
qmake_add_flags("QMAKE_LIBFLAGS_${_buildname}" "+=" "${VCPKG_COMBINED_STATIC_LINKER_FLAGS_${_buildname}}")
|
||||
|
||||
# These paths get hardcoded into qmake. So point them into the CURRENT_INSTALLED_DIR instead of CURRENT_PACKAGES_DIR
|
||||
# makefiles will be fixed to install into CURRENT_PACKAGES_DIR in install_qt
|
||||
set(BUILD_OPTIONS ${_csc_OPTIONS} ${_csc_OPTIONS_${_buildname}}
|
||||
@ -113,19 +172,19 @@ function(configure_qt)
|
||||
-L ${CURRENT_INSTALLED_DIR}${_path_suffix_${_buildname}}/lib/manual-link
|
||||
-platform ${_csc_TARGET_PLATFORM}
|
||||
)
|
||||
|
||||
|
||||
if(DEFINED _csc_HOST_TOOLS_ROOT) #use qmake
|
||||
if(WIN32)
|
||||
set(INVOKE_OPTIONS "QMAKE_CXX.QMAKE_MSC_VER=1911" "QMAKE_MSC_VER=1911")
|
||||
endif()
|
||||
vcpkg_execute_required_process(
|
||||
COMMAND ${INVOKE} "${_csc_SOURCE_PATH}" "${INVOKE_OPTIONS}" -- ${BUILD_OPTIONS}
|
||||
COMMAND ${INVOKE} "${_csc_SOURCE_PATH}" "${INVOKE_OPTIONS}" -- ${BUILD_OPTIONS} ${qmake_build_tools} ${qmake_comp_flags}
|
||||
WORKING_DIRECTORY ${_build_dir}
|
||||
LOGNAME config-${_build_triplet}
|
||||
)
|
||||
else()# call configure (builds qmake for triplet and calls it like above)
|
||||
vcpkg_execute_required_process(
|
||||
COMMAND "${INVOKE}" ${BUILD_OPTIONS}
|
||||
COMMAND "${INVOKE}" ${BUILD_OPTIONS} ${qmake_build_tools} ${qmake_comp_flags}
|
||||
WORKING_DIRECTORY ${_build_dir}
|
||||
LOGNAME config-${_build_triplet}
|
||||
)
|
||||
@ -145,7 +204,7 @@ function(configure_qt)
|
||||
string(REGEX REPLACE "\\[EffectiveSourcePaths\\]\r?\nPrefix=[^\r\n]+\r?\n" "" _contents ${_contents})
|
||||
string(REPLACE "Sysroot=\n" "" _contents ${_contents})
|
||||
string(REPLACE "SysrootifyPrefix=false\n" "" _contents ${_contents})
|
||||
file(WRITE "${CURRENT_PACKAGES_DIR}/tools/qt5/qt_${_build_type_${_buildname}}.conf" "${_contents}")
|
||||
endforeach()
|
||||
file(WRITE "${CURRENT_PACKAGES_DIR}/tools/qt5/qt_${_build_type_${_buildname}}.conf" "${_contents}")
|
||||
endforeach()
|
||||
|
||||
endfunction()
|
||||
|
@ -1,8 +1,5 @@
|
||||
|
||||
function(qt_build_submodule SOURCE_PATH)
|
||||
# This fixes issues on machines with default codepages that are not ASCII compatible, such as some CJK encodings
|
||||
set(ENV{_CL_} "/utf-8")
|
||||
|
||||
if(NOT PORT STREQUAL "qt5-webengine")
|
||||
vcpkg_find_acquire_program(PYTHON3)
|
||||
get_filename_component(PYTHON3_EXE_PATH ${PYTHON3} DIRECTORY)
|
||||
|
@ -80,9 +80,6 @@ endforeach()
|
||||
#########################
|
||||
## Setup Configure options
|
||||
|
||||
# This fixes issues on machines with default codepages that are not ASCII compatible, such as some CJK encodings
|
||||
set(ENV{_CL_} "/utf-8")
|
||||
|
||||
set(CORE_OPTIONS
|
||||
-confirm-license
|
||||
-opensource
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "qt5-base",
|
||||
"version": "5.15.6",
|
||||
"port-version": 1,
|
||||
"description": "Qt5 Application Framework Base Module. Includes Core, GUI, Widgets, Networking, SQL, Concurrent and other essential qt components.",
|
||||
"homepage": "https://www.qt.io/",
|
||||
"license": null,
|
||||
@ -31,6 +32,10 @@
|
||||
"default-features": false
|
||||
},
|
||||
"sqlite3",
|
||||
{
|
||||
"name": "vcpkg-cmake-get-vars",
|
||||
"host": true
|
||||
},
|
||||
{
|
||||
"name": "vcpkg-pkgconfig-get-modules",
|
||||
"host": true
|
||||
|
@ -13,6 +13,52 @@ function(vcpkg_configure_qmake)
|
||||
message(FATAL_ERROR "vcpkg_configure_qmake: unable to find qmake.")
|
||||
endif()
|
||||
|
||||
z_vcpkg_get_cmake_vars(cmake_vars_file)
|
||||
include("${cmake_vars_file}")
|
||||
|
||||
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)
|
||||
endfunction()
|
||||
# Setup Build tools
|
||||
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()
|
||||
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()
|
||||
|
||||
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
|
||||
vcpkg_list(APPEND arg_OPTIONS "CONFIG-=shared" "CONFIG*=static")
|
||||
else()
|
||||
@ -25,7 +71,7 @@ function(vcpkg_configure_qmake)
|
||||
endif()
|
||||
|
||||
if(DEFINED VCPKG_OSX_DEPLOYMENT_TARGET)
|
||||
set(ENV{QMAKE_MACOSX_DEPLOYMENT_TARGET} ${VCPKG_OSX_DEPLOYMENT_TARGET})
|
||||
set(ENV{QMAKE_MACOSX_DEPLOYMENT_TARGET} "${VCPKG_OSX_DEPLOYMENT_TARGET}")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
|
||||
@ -41,13 +87,22 @@ function(vcpkg_configure_qmake)
|
||||
message(STATUS "Configuring ${TARGET_TRIPLET}-rel")
|
||||
file(MAKE_DIRECTORY "${current_binary_dir}")
|
||||
|
||||
qmake_add_flags("QMAKE_LIBS" "+=" "${VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES}")
|
||||
qmake_add_flags("QMAKE_RC" "+=" "${VCPKG_DETECTED_CMAKE_RC_FLAGS_RELEASE}")
|
||||
qmake_add_flags("QMAKE_CFLAGS_RELEASE" "+=" "${VCPKG_DETECTED_CMAKE_C_FLAGS_RELEASE}")
|
||||
qmake_add_flags("QMAKE_CXXFLAGS_RELEASE" "+=" "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_RELEASE}")
|
||||
qmake_add_flags("QMAKE_LFLAGS" "+=" "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
|
||||
qmake_add_flags("QMAKE_LFLAGS_SHLIB" "+=" "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
|
||||
qmake_add_flags("QMAKE_LFLAGS_PLUGIN" "+=" "${VCPKG_DETECTED_CMAKE_MODULE_LINKER_FLAGS_RELEASE}")
|
||||
qmake_add_flags("QMAKE_LIBFLAGS_RELEASE" "+=" "${VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_RELEASE}")
|
||||
|
||||
vcpkg_list(SET build_opt_param)
|
||||
if(DEFINED arg_BUILD_OPTIONS OR DEFINED arg_BUILD_OPTIONS_RELEASE)
|
||||
vcpkg_list(SET build_opt_param -- ${arg_BUILD_OPTIONS} ${arg_BUILD_OPTIONS_RELEASE})
|
||||
endif()
|
||||
|
||||
vcpkg_execute_required_process(
|
||||
COMMAND "${qmake_executable}" CONFIG-=debug CONFIG+=release
|
||||
COMMAND "${qmake_executable}" CONFIG-=debug CONFIG+=release ${qmake_build_tools} ${qmake_comp_flags}
|
||||
${arg_OPTIONS} ${arg_OPTIONS_RELEASE} ${arg_SOURCE_PATH}
|
||||
-qtconf "${current_binary_dir}/qt.conf"
|
||||
${build_opt_param}
|
||||
@ -76,12 +131,22 @@ function(vcpkg_configure_qmake)
|
||||
message(STATUS "Configuring ${TARGET_TRIPLET}-dbg")
|
||||
file(MAKE_DIRECTORY "${current_binary_dir}")
|
||||
|
||||
set(qmake_comp_flags "")
|
||||
qmake_add_flags("QMAKE_LIBS" "+=" "${VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES}")
|
||||
qmake_add_flags("QMAKE_RC" "+=" "${VCPKG_DETECTED_CMAKE_RC_FLAGS_DEBUG}")
|
||||
qmake_add_flags("QMAKE_CFLAGS_DEBUG" "+=" "${VCPKG_DETECTED_CMAKE_C_FLAGS_DEBUG}")
|
||||
qmake_add_flags("QMAKE_CXXFLAGS_DEBUG" "+=" "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_DEBUG}")
|
||||
qmake_add_flags("QMAKE_LFLAGS" "+=" "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
|
||||
qmake_add_flags("QMAKE_LFLAGS_SHLIB" "+=" "${VCPKG_DETECTED_CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
|
||||
qmake_add_flags("QMAKE_LFLAGS_PLUGIN" "+=" "${VCPKG_DETECTED_CMAKE_MODULE_LINKER_FLAGS_DEBUG}")
|
||||
qmake_add_flags("QMAKE_LIBFLAGS_DEBUG" "+=" "${VCPKG_DETECTED_CMAKE_STATIC_LINKER_FLAGS_DEBUG}")
|
||||
|
||||
vcpkg_list(SET build_opt_param)
|
||||
if(DEFINED arg_BUILD_OPTIONS OR DEFINED arg_BUILD_OPTIONS_DEBUG)
|
||||
vcpkg_list(SET build_opt_param -- ${arg_BUILD_OPTIONS} ${arg_BUILD_OPTIONS_DEBUG})
|
||||
endif()
|
||||
vcpkg_execute_required_process(
|
||||
COMMAND "${qmake_executable}" CONFIG-=release CONFIG+=debug
|
||||
COMMAND "${qmake_executable}" CONFIG-=release CONFIG+=debug ${qmake_build_tools} ${qmake_comp_flags}
|
||||
${arg_OPTIONS} ${arg_OPTIONS_DEBUG} ${arg_SOURCE_PATH}
|
||||
-qtconf "${current_binary_dir}/qt.conf"
|
||||
${build_opt_param}
|
||||
|
@ -5898,7 +5898,7 @@
|
||||
},
|
||||
"qt5-base": {
|
||||
"baseline": "5.15.6",
|
||||
"port-version": 0
|
||||
"port-version": 1
|
||||
},
|
||||
"qt5-canvas3d": {
|
||||
"baseline": "0",
|
||||
|
@ -1,5 +1,10 @@
|
||||
{
|
||||
"versions": [
|
||||
{
|
||||
"git-tree": "7881b89de5ec007d8ea1cd868fd76dd74a2f08ad",
|
||||
"version": "5.15.6",
|
||||
"port-version": 1
|
||||
},
|
||||
{
|
||||
"git-tree": "432a70f67a01e3348d79cd158563b033a0304452",
|
||||
"version": "5.15.6",
|
||||
|
Loading…
x
Reference in New Issue
Block a user