#Every update requires an update of these hashes and the version within the control file of each of the 32 ports. 
#So it is probably better to have a central location for these hashes and let the ports update via a script
set(QT_MAJOR_MINOR_VER 5.14)
set(QT_PATCH_VER 2)
set(QT_UPDATE_VERSION 0) # Switch to update qt and not build qt. Creates a file cmake/qt_new_hashes.cmake in qt5-base with the new hashes.

set(QT_PORT_LIST base 3d activeqt charts connectivity datavis3d declarative gamepad graphicaleffects imageformats location macextras mqtt multimedia networkauth
                 purchasing quickcontrols quickcontrols2 remoteobjects script scxml sensors serialport speech svg tools virtualkeyboard webchannel websockets
                 webview winextras xmlpatterns)

set(QT_HASH_qt5-base                8c83e06d58b56e9f288e83d6c3dd4ad6cc9f1eb1a32c7b44fb912fda34ed7255766fd9fa60cd740ee001df7d6172f25df05f1f95e986c3e793fbcd9bf4f18de9)
set(QT_HASH_qt5-3d                  43053d001d59094bfac19c5bf3ad17df277c64d0c214b72d4cf02231396d9109a231da8d9d72ebe79822bc09ee24fa2387b4b120dbad43d69a49e3d66ee21da8)
set(QT_HASH_qt5-activeqt            730a9086d09659e869045f2bc2a5eb43f99447e1bc176159bbc59175562ef6a562bd7a24f9923f4ceac12fdd902104fd7dbc418d8acda9b127c3e3f2d871a8f3)
set(QT_HASH_qt5-charts              2776db3dfe6f6f1047bd19d8d936d3f72de46c0807bbf02ba874053113d76df4cf80497d5ed2cee192ad94abb8e12b4fbce8359a63d8beb1190d491fc2da35bc)
set(QT_HASH_qt5-connectivity        948050b915f6f2e1fffcb2c8b55d9061f25a82314d02e7a39faa9b88e065bb924ce5f8a7c26ed1f07b29b986d47acd5678f57bb96668d1c1ecd93ad3a7e40c7a)
set(QT_HASH_qt5-datavis3d           25d207e045e58f9edc3a661b641225f6a11eb45f723847281007fa53b753430dc5792e31bdd142c95e886bfda5f6d29826cd151cb23a1e1a81cc0b91d5f7a2f6)
set(QT_HASH_qt5-declarative         48d3a547237514a8bdc2a4c0b3f97732abceacece0e0899d2f33787293eb99f54c28efce35a34b8c46dcd4d78ebbc88bfc820bc68496076eacace40aaceee004)
set(QT_HASH_qt5-gamepad             23971fae9b1626afc005dccae3bb715f719695bf5e24a1711b3e7049ce49ef5c72097e1eb702464ab7663d41750bf4103e4ed78ee7954269921e3064b79f4c05)
set(QT_HASH_qt5-graphicaleffects    fa6ed3eff243675f9d0bfa71b2886804e4902cf9d7d91d5dec0f8e4f060ee7c347ba7775a89e3f8effd0ffed8314f916b55f09056902abc892ee27e79ce2925c)
set(QT_HASH_qt5-imageformats        e835489bdd1cf19aaa1c04e6ae1c480d4077cf24eee1d46b2f4deb03c093f64df6beaf83adb69b7edcba67c952a60deb89a26923addf2b4254aff18bc2ebf6a6)
set(QT_HASH_qt5-location            ca11e118a9061f69ac0181db14b1bf92309c03615802092f7cf404c882108efa3acae9bb73ee3870ea68cd7d7d11863445fc72dcf52099d6be77e0986b7f012c)
set(QT_HASH_qt5-macextras           99c8dc6a5cb6f62691d645a889d81438203f50eea19c25bfb0e3d784816712cd8ec01ed42fbc0db4307cf81d00b4c00a20b026683bbeef758a4f1888bc1e2094)
set(QT_HASH_qt5-mqtt                8040b23c1078c53cc69f1a0e57e363bbc277c970f007058d168152cd0246062ef877d65928a4d6754f94c6aec696995fc88d166a84ba1678d999541b9a091c0d)
set(QT_HASH_qt5-multimedia          5ebee0f96334d58b74ae344875aa93d32bfdd7c906856f84152e9ae0a3ebb12f627a0d3ab4552031b70c20ad59db1674b1a261ed0828e1efcc6ab48ba3718559)
set(QT_HASH_qt5-networkauth         9001755ae289213f7d2c994bedbbcc1ca641b3c80fc5279f6829ed48c31eed8cdbd87a0ed0ce451bc9611318ef09ef7c40b795d2c45fface2bd357ee579b15ad)
set(QT_HASH_qt5-purchasing          5576a5fbef50a25b2c3ebfbb674b630fad2f9b2c3e8737fe0db0b9374c8f07d47dc6212024af1fc6ce585787087a0da1a193cc964290370dcc0ec200c3ed5ccb)
set(QT_HASH_qt5-quickcontrols       e5076d838e54e8fcc62ffd76d66ab322f1927f6489c51dd0fa6e39de1e003c1994d24730da79c8d9d2747839faaa7b1b78f14b58f05447db440a477094be40e4)
set(QT_HASH_qt5-quickcontrols2      de8b669417c2d039c0f49e805be72e757877991bc3c7feb13417202a4964cb6391924837751c520ed6234930e90dfe00417ca1c369418b2cdf4f09da679ba722)
set(QT_HASH_qt5-remoteobjects       0e9fe5d6bfa8ef5ecc8700c7b757d98ad6f6711c8b10667aedaa9dcb32ae201a12bb37fb2d7a827e1bec399c2a75e8cf40226ddd6810feb9c44e287974b5345e)
set(QT_HASH_qt5-script              2eef6c4d23fccd67abc3647852ca92edd951b4ece8047f28571689a143421c5a1403ef0fcc96615e4ed708df64f7eede643d872fac850554031a17e2d907f398)
set(QT_HASH_qt5-scxml               2e1cbea7c32d93675b4a67287dd17c9ed120a6655f8f9a30edfe12a16f67b3c5ad6d0fd04c0102297693bf87e225d81e963534958c8e73622c605388c9fc8425)
set(QT_HASH_qt5-sensors             43872a51163317c2fb642f59a9e41ede77cb86d7148436d9e673ac94543fb8acffe4e040824dd88a9029943418a3371c77815b82a0a566426857d18fbc23e341)
set(QT_HASH_qt5-serialport          4a4fb81bcccaddc5902223940031a9002395cbc5e99c78c1ac5df04031b6a0551bb340757f84bad82ca7ef551358c1eba3a035b0b8f4221f7db0ab738ac65b06)
set(QT_HASH_qt5-speech              d3870cc66cba4f5dd2c0a2a4845defe4299de2d7affe12ccdadc4948116317590b580592d575cc5e8eb190043a92f38416e030f47cfb87f5cf3419a31152e00f)
set(QT_HASH_qt5-svg                 b4cf8a7081e01caea3c71826d32ebb9da6a71bd4eab3cf353e87080009065aff2c533300c0c08a005ff8f441d2da641a097319114a5c11b618398fac41f574a7)
set(QT_HASH_qt5-tools               e5b56d38acaa59511f24c817999f901510397d6e8baccc06a8fb8375f09b71dcffda4c57def4eb88d6c2782926d612b382957175a087a0c2224245051c54fe7e)
set(QT_HASH_qt5-virtualkeyboard     752634de8796a1809818176db47021aa24de842cf6334d689a91d3b011105a5e2b8113615a8f50f6974bf8fa989026b434121b42278de1ef905075ba3ee72c47)
set(QT_HASH_qt5-webchannel          57080c8cf7fb5c91fa6b325566d3fb2dc3c1d3bcd8128d2a40ea92f8bae7ca0f0fb4bac1d68452998a5dc06781155058d149df069fed5ff16b6d8ad43a72e002)
set(QT_HASH_qt5-websockets          091e17459a8a255fccece092399ac32994307aa53e6e72e736e6ff9f1bb745c49bfcb9a747e1e21acaa0ed95754f7f450ba2f73a3bbafad54e21bf600f7da92f)
set(QT_HASH_qt5-webview             1a70be0c64f72b7e3b10c8e3ca58d4a04bef14496c8e4852c5cafbd13d653e2f682a58f7dcd576fce79ed082c01a5f8ffc6533836f495f6e5d4b6ddf2be8e3ca)
set(QT_HASH_qt5-winextras           2cd46242845ceb9d41d4d13cdda7697d9caa4cc3ee860ae9f4813192381fbaf3aa3124bf8998db28470479b8ebc755fe86607681696480300c65a7d9ed9073ef)
set(QT_HASH_qt5-xmlpatterns         27f674c4811b010ec461c54ee258b1d6b58dcb5c11795621b7bbad9fa2c19c1b6b62286cbe8895151261129c7d6d91007c3a8be6cf64af1f4cb32e2e9976ac23)
##TODO
set(QT_HASH_qt5-doc                 38277f3ec84754e564aac4fb3b495953d1a4ab823d7a4733633e14947e41af9d7b79af0d2812b9457fb3824c17a83c14df8d2b80420c6743d1806aa521e04cf4)
set(QT_HASH_qt5-x11extras           cf30e66fda18b9bfd266b41f15713f7ca7390bc533fb8093096853f1554c2a91eb065dc17acb5b355b8fad08df3c695289d8c8081d568061c99659ec35d79b14)
set(QT_HASH_qt5-androidextras       7355e8e049c739597b820c3dd96cdd48be7bed0becb171e1255c7caffd3a67aac349064da644ff3f3b11ebed31c26588d5db11fa5ffc743d7d010d1355eed26f)
set(QT_HASH_qt5-canvas3d            0) # removed in latest
set(QT_HASH_qt5-translations        38cedf19a1d7b920b7dcfcc014d3986c4067dafd7192efe43c3b8f282e0637391f9ec0b8cc7f5506cc76629d005298becba1421506b48c6baf3366ec2f378544)
set(QT_HASH_qt5-serialbus           c98c7d30dc7f44837a601088b2797bc85d8b659dcdba5f22c229edad0fcee57e38c5b5d55ed223f22c9ce4e14b72ea6e59b920d4f4b366d0381b208e3e9cff40)
set(QT_HASH_qt5-webengine           bcfd9ece04bdbfded5272ce1b3ab482e88349b1f5c5a071f58f6e66fcb9604d1fc38fe909ae3d9631bdf0bf7c081d7590620c3388f1a577b5236f68b084699bf)
set(QT_HASH_qt5-webglplugin         02b059301527a3d943f842f3d076daba36470bee65c5888d1f896986f75556abb577bcfbf8337e4cf4fa1c6eb43e352430b1ea6ee1e02be826cd02b108915dc9)
set(QT_HASH_qt5-wayland             0f396cabace17f099c2f2c0be54317006dc00c5f4be08cd79a4fa4fdc94362f63cc6ce9decc7feb63f566dd2ea52d562257e4bb23332557054418fc16dc7e899)

if(QT_UPDATE_VERSION)
    message(STATUS "Running Qt in automatic version port update mode!")
    set(_VCPKG_INTERNAL_NO_HASH_CHECK 1)
    if("${PORT}" MATCHES "qt5-base")
        foreach(_current_qt_port ${QT_PORT_LIST})
            set(_current_control "${VCPKG_ROOT_DIR}/ports/qt5-${_current_qt_port}/CONTROL")
            file(READ ${_current_control} _control_contents)
            #message(STATUS "Before: \n${_control_contents}")
            string(REGEX REPLACE "Version:[^0-9]+[0-9]\.[0-9]+\.[0-9]+[^\n]*\n" "Version: ${QT_MAJOR_MINOR_VER}.${QT_PATCH_VER}\n" _control_contents "${_control_contents}")
            #message(STATUS "After: \n${_control_contents}")
            file(WRITE ${_current_control} "${_control_contents}")
        endforeach()
    endif()
endif()