2021-11-24 03:41:33 +08:00
#[===[.md:
# vcpkg_qmake_configure
C o n f i g u r e a q m a k e - b a s e d p r o j e c t .
###User setable triplet variables:
V C P K G _ O S X _ D E P L O Y M E N T _ T A R G E T : D e t e r m i n e s Q M A K E _ M A C O S X _ D E P L O Y M E N T _ T A R G E T
V C P K G _ Q M A K E _ C O M M A N D : P a t h t o q m a k e . ( d e f a u l t : " $ { C U R R E N T _ H O S T _ I N S T A L L E D _ D I R } / t o o l s / Q t 6 / b i n / q m a k e $ { V C P K G _ H O S T _ E X E C U T A B L E _ S U F F I X } " )
VCPKG_QT_CONF_ ( RELEASE|DEBUG ) : P a t h t o q t . c o n f i g b e i n g u s e d f o r R E L E A S E / D E B U G . ( d e f a u l t : " $ { C U R R E N T _ I N S T A L L E D _ D I R } / t o o l s / Q t 6 / qt_ ( release|debug ) . c o n f " )
VCPKG_QMAKE_OPTIONS ( _RELEASE|_DEBUG ) ? : E x t r a o p t i o n s t o p a s s t o Q M a k e
` ` ` c m a k e
vcpkg_qmake_configure (
S O U R C E _ P A T H < p r o _ f i l e _ p a t h >
[ Q M A K E _ O P T I O N S a r g 1 [ a r g 2 . . . ] ]
[ Q M A K E _ O P T I O N S _ R E L E A S E a r g 1 [ a r g 2 . . . ] ]
[ Q M A K E _ O P T I O N S _ D E B U G a r g 1 [ a r g 2 . . . ] ]
[ O P T I O N S a r g 1 [ a r g 2 . . . ] ]
[ O P T I O N S _ R E L E A S E a r g 1 [ a r g 2 . . . ] ]
[ O P T I O N S _ D E B U G a r g 1 [ a r g 2 . . . ] ]
)
` ` `
### SOURCE_PATH
T h e p a t h t o t h e * . p r o q m a k e p r o j e c t f i l e .
### QMAKE_OPTIONS, QMAKE_OPTIONS\_RELEASE, QMAKE_OPTIONS\_DEBUG
o p t i o n s d i r e c t l y p a s s e d t o q m a k e w i t h t h e f o r m Q M A K E _ X = s o m e t h i n g o r C O N F I G = s o m e t h i n g
### OPTIONS, OPTIONS\_RELEASE, OPTIONS\_DEBUG
T h e o p t i o n s p a s s e d a f t e r - - t o q m a k e .
#]===]
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 _csc_QMAKE_OPTIONS "CONFIG*=static-runtime" )
endif ( )
if ( DEFINED VCPKG_OSX_DEPLOYMENT_TARGET )
set ( ENV{QMAKE_MACOSX_DEPLOYMENT_TARGET} "${VCPKG_OSX_DEPLOYMENT_TARGET}" )
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 ) # For users using outside Qt6
set ( VCPKG_QMAKE_COMMAND "${CURRENT_HOST_INSTALLED_DIR}/tools/Qt6/bin/qmake${VCPKG_HOST_EXECUTABLE_SUFFIX}" )
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}" )
# QMAKE_OBJCOPY ?
if ( VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW )
qmake_append_program ( qmake_build_tools "LINKER" "${VCPKG_DETECTED_CMAKE_LINKER}" )
qmake_append_program ( qmake_build_tools "QMAKE_LINK" "${VCPKG_DETECTED_CMAKE_LINKER}" )
qmake_append_program ( qmake_build_tools "QMAKE_LINK_C" "${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_C" "${VCPKG_DETECTED_CMAKE_C_COMPILER}" )
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}" )
# Setup qt.conf
if ( NOT VCPKG_QT_CONF_ ${ buildtype } )
set ( VCPKG_QT_CONF_ ${ buildtype } "${CURRENT_INSTALLED_DIR}/tools/Qt6/qt_${lowerbuildtype}.conf" )
endif ( )
configure_file ( "${VCPKG_QT_CONF_${buildtype}}" "${CURRENT_BUILDTREES_DIR}/${config_triplet}/qt.conf" ) # Needs probably more TODO for cross builds
vcpkg_backup_env_variables ( VARS PKG_CONFIG_PATH )
vcpkg_host_path_list ( PREPEND PKG_CONFIG_PATH "${prefix}/lib/pkgconfig" "${prefix}/share/pkgconfig" )
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)
vcpkg_list ( APPEND qmake_comp_flags "QMAKE_LIBS+=${VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES}"
2022-03-31 05:52:25 +08:00
" Q M A K E _ R C + = $ { V C P K G _ C O M B I N E D _ R C _ F L A G S _ $ { b u i l d t y p e } } "
" Q M A K E _ C F L A G S _ $ { b u i l d t y p e } * = $ { V C P K G _ C O M B I N E D _ C _ F L A G S _ $ { b u i l d t y p e } } "
" Q M A K E _ C X X F L A G S _ $ { b u i l d t y p e } * = $ { V C P K G _ C O M B I N E D _ C X X _ F L A G S _ $ { b u i l d t y p e } } "
" Q M A K E _ L F L A G S * = $ { V C P K G _ C O M B I N E D _ S H A R E D _ L I N K E R _ F L A G S _ $ { b u i l d t y p e } } "
" Q M A K E _ L I B F L A G S * = $ { V C P K G _ C O M B I N E D _ S T A T I C _ L I N K E R _ F L A G S _ $ { b u i l d t y p e } } "
" Q M A K E _ L F L A G S _ E X E * = $ { V C P K G _ C O M B I N E D _ E X E _ L I N K E R _ F L A G S _ $ { b u i l d t y p e } } "
2021-11-24 03:41:33 +08:00
)
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 (
C O M M A N D $ { V C P K G _ Q M A K E _ C O M M A N D } $ { q m a k e _ c o n f i g _ $ { b u i l d t y p e } }
$ { a r g _ Q M A K E _ O P T I O N S } $ { a r g _ Q M A K E _ O P T I O N S _ D E B U G }
$ { V C P K G _ Q M A K E _ O P T I O N S } $ { V C P K G _ Q M A K E _ O P T I O N S _ $ { b u i l d t y p e } } # Advanced users need a way to inject QMAKE variables via the triplet.
$ { q m a k e _ b u i l d _ t o o l s } $ { q m a k e _ c o m p _ f l a g s }
" $ { a r g _ S O U R C E _ P A T H } "
- q t c o n f " $ { C U R R E N T _ B U I L D T R E E S _ D I R } / $ { c o n f i g _ t r i p l e t } / q t . c o n f "
$ { o p t i o n s }
W O R K I N G _ D I R E C T O R Y $ { C U R R E N T _ B U I L D T R E E S _ D I R } / $ { c o n f i g _ t r i p l e t }
L O G N A M E c o n f i g - $ { c o n f i g _ t r i p l e t }
)
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 ( )