#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.12)
set(QT_PATCH_VER 8)
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                8b6ed392dddaa7cd438fabbeb96c2e8d9dd6906a65eedcd193528ffd71ea42870071fa0ecd6f43cc65900b3938d19ae5316c43201b7d260ef9107dcc3a1e5441)
set(QT_HASH_qt5-3d                  7ccb8f0d072536422b1e23c56d95134524c2d83ec56818754bcfd710fe9be89e365afcca197900cb4ed4b9365ea6856bbbda89818e6f4b23b58c5a02386e5cc4)
set(QT_HASH_qt5-activeqt            74273e51d58ed91a2dd36eb76bfc1d9c4292ddd9b41c69999c4154445f6f86500f63ec365559287df1e0e2b4b783dcc5914a96a6397f5281e8ba6089f9b51b20)
set(QT_HASH_qt5-charts              72a672b53edc27785f64aefaa8f1ddb6a6fd2e35f6ade49d69499cbb94a702d744e1da656be47afee46f5926333a8d9c441b4564ec8216e994e6073f4e1a97fb)
set(QT_HASH_qt5-connectivity        d92d75f7efd246ca0b308811ade9f1d9f6678a4381e9ecb1f8e361dc27834a61aeae6aab1f067e3a1dba301397ef3d896a0e33019ed7bd1a39e143f80c3f70b4)
set(QT_HASH_qt5-datavis3d           d732dbc3c35372141a86524e04abc847c7a73b739ddf4c3699d81f71de549c88b8cdb155789d2effcbb5d1fc5751fe7059e0b37a39ee79cdfd88e91c1f65fa3f)
set(QT_HASH_qt5-declarative         10fe641bfd910b2395c26431c8e1dcc3063f1a036abeb96b2486812ebaea7c83a87416db019d8a0bd3ae00838789f8327aead98e04e9dc805ec8b73ba5fc5357)
set(QT_HASH_qt5-gamepad             b93903392e1b00db05a74a42feeb803c41cb86aee22e903905de70d3eb11e0aa95820d74ecca13b102661c3ddd216f26d81e2cb234e324f3ee3c869dc36b97a7)
set(QT_HASH_qt5-graphicaleffects    53e69d6f6ec532124daca5fb9469dd395c984eaf823d7e83f8a61a40b37c9e448711e758648028bcb4ed7c2abe6f8928248a4269afeb4beb3683c8e47de2f2c3)
set(QT_HASH_qt5-imageformats        db5f810a77adce6e0aed481e044e8c4a245b44e2340fddb4d1a46e85eaff0da14b8ad5104c3ff4114cb9b02074b5d5ce6931637534fb36d7c57ce4798278be4b)
set(QT_HASH_qt5-location            9521ae946039c1409ce4ba0a4ab5473f8773b7ccf59cd23ea5df7c3727929dcc6852d2b7b677d67832c096721a25428d7b2417608a13d8f1750662dd24d6c3be)
set(QT_HASH_qt5-macextras           9da4f5fc478d3e820636429fbc93904a9f70901a3a418f6441318fb3df2d321727ddcb2cd6550f48b98593bea6a255f5f3127623d75ed2391723013141b40f4f)
set(QT_HASH_qt5-mqtt                43d60bb1d98692850d2b196018784fe6975aedf1b7daea76c9b14f40fc9b907d59025d5f94d34a246daa24b6af7908d1d5a4d86b9cbf642577c03db7989241f2)
set(QT_HASH_qt5-multimedia          49e0f1205be497dac29af64532e6463e55a43ca8a3487950b9cc228297f9d11336e8b5a742607a3bca1818ed0ff9a3d0914569baa710c241f0837b5d97ee4048)
set(QT_HASH_qt5-networkauth         df154398732011c01cf4ed819834e0c2b4e0620d43c62b8032d0687675706eaa6bffa98411316011886434c1fa2950a161be82a3997ab60182eec9483b8b3c50)
set(QT_HASH_qt5-purchasing          192d43f05ffd90347341b32e1720a7112a9a565823ce4cdddb192bd402fb498c50ae1188ee937166819d8d578e57686f580f717dad820b306696d8db89ac85bc)
set(QT_HASH_qt5-quickcontrols       d3e71c56dd9b0c76643b464a59420ed66a7850ae3f5d1c1fd396807a92b54bbeda72380e6f53bf00db18c5fa83fb5de3c332d6c6a1bb9e57d24ec5aef377fc0d)
set(QT_HASH_qt5-quickcontrols2      e0b464500303a3e8ca5e821bd2d46f4bc19e0df5402aa566d797530b7310a095057b4726272a001bf38da59259cdd96d3b27630a6861e82d5a70910ddcb1c985)
set(QT_HASH_qt5-remoteobjects       92497b0eb2383e7d7552b1af4eba3b452d0d5130c00ce0cd44dc9a3f906335ddcaba0392f94d5f43de6b9a154c7d2b14f5d5899e2312df5e0bdd80f4d96b115b)
set(QT_HASH_qt5-script              11914d89ebe11bb0fbd211ec0f897b31f689d20874c3ab2de055abc87d5bb3b2052c47f83a6ae8bd00df2ce5f086683022124ac7e011a160853a00cd1bd534e3)
set(QT_HASH_qt5-scxml               376307ef8cae3bb88192f2137bc804609c76685ce574af48dc5d3f6acd65018d1bbfc7ad0e184aac5ac7cb0a2fa42b21c6e96e548f31cfdad90a478ca043866b)
set(QT_HASH_qt5-sensors             b3b74e8927ca277417777a979330b2de1e96814febf673c7e6f1b18eb17d2b0a92051049840431e7bb19329059ce89f17b5fcb152c804d30b287b351376cb9c8)
set(QT_HASH_qt5-serialport          35400ffec4bf1993e29c5d2465439e3c085db0f97ffdcf37226078df5aa64dd7ffa531c27ef59d5c53ada5f89453eea416f369099205a1fbbf8279bed6c69f36)
set(QT_HASH_qt5-speech              814b2bbadeac77e80b6c4b1a2586a733710d6e7bc80fa8f177ef36f0df4f6c39098ef6223fd16cd3287eb24b871a5f1589eb4301babe099cf91d3d89069c85c0)
set(QT_HASH_qt5-svg                 2788206a3bb0a0190bc984042ca8c471ed50325eb358ae8c7b50a147df0fb94ef96535606f5c96823b0d3380ddbc556187e3b1ec818fee7e597592b844352a7d)
set(QT_HASH_qt5-tools               1251244d4991f6d4b8fe2aba1ebf3aa74c4b0977b3106233a982b9cbf736697c133717e959915343dae6acfe7978f767ceed52771f28f1278e44bcfea6e883cd)
set(QT_HASH_qt5-virtualkeyboard     938bfcdbe63354ee956cff2d3e40884c4cd531eb522cf2258d1ceb7de14e2aa4fb9dc43e2007fe99fae008e0161461347acb362a616b230ed8f1d9b77f3169a3)
set(QT_HASH_qt5-webchannel          142eb16ed4dc061425d0c1b8be6e64a04b7cd58b77abb891bd6bcb304d94e642fd65ba8c4fd8c1d51ef2558bfc22d40adb90f4485dbea2a15da8dff8df9849d4)
set(QT_HASH_qt5-websockets          1a6baee5be5cbfadb23ce969784cf15724c10a188448bb0f3bec85f3fe9324389827e71ae719a85254b87a43523977b03d692da8f5ac273e0e7a598b1fdbdfb9)
set(QT_HASH_qt5-webview             68ad18555025ab4479b18b5c2f7cffbcb78608819901f91876291c60b53a248051c9306560ef4be15d9da3cd58b24ea42548620c3dd8db9d785efa1ec6779599)
set(QT_HASH_qt5-winextras           2692984f7106a104025648845bc08fbc7486d37e69128397294d47a4c6f5378d5f41a9762693bd6ec7498e8afa2b88e645f0c3ca82914d8de3becb7d4d46761d)
set(QT_HASH_qt5-xmlpatterns         1abf04685e169a149423b6f1d2ea9eb8d57a8e79aed6a9362333f50d747e71bfd385cc910901f4db05b672e7eea61de02079af47b1b297cbb24552e759bad93d)
##TODO
set(QT_HASH_qt5-doc                 63505d7bec54b6bdd663fc0f3962c22470e61f55031c62b26656eb68dafa5c7f835f706a53c240922607106772c47f4bc7f3ca91aa71464bd29381a238b8465e)
set(QT_HASH_qt5-x11extras           0b086747fc9be3bd83f83c0d95b5403e6cdf55f3d3727679f01caf3f211313c3da57e26706616275fc6c105d9ac12c8f2d87d0063b14c1de18ca1a70a928e68d)
set(QT_HASH_qt5-androidextras       caed501bca871c8773d60fc4aa8c093918ffe0021f0bdded2c2e47b6ec49e9a1a100ab18add7d6c9702ace35bd94cd99b28e73778271b3fb28339b607f68861b)
set(QT_HASH_qt5-canvas3d            5927ab205d6b15a6a8cef91610694d061ba5610afe5b83a44f9a118fbe30c56dea3e5048b37b4902b3675a094f48ad3d9c6294d3686ef4015dbcdcacdaf03555)
set(QT_HASH_qt5-translations        bb46837f5069f622ba0c9b01d934abdea5ad82b5e2d96d268b7540e29d36f79261273b7e77da7979e18ca9e0b44556012e7f9827085cf1605fc629d877197b8a)
set(QT_HASH_qt5-serialbus           5c9084852449813c47ca74448bb794c1f8fae1c012169e36175cc2a5c1f8dc956f43b8c112fcc147106b77db69d1c1b8be2f73d8072d49d5f7856a06323b0b24)
set(QT_HASH_qt5-webengine           b0b5c979d0ce66effe15c152e11f6460226c61a030122d581aa10cc968484ff404b492146cabef313c3018b59a064324c373b886ffdd22efa9d2990b873b7d69)
set(QT_HASH_qt5-webglplugin         c3741557c7298f30e88d26f22491520a825ec532778d2eb03f408fbed9bb19ad60702dce2bf5c9f347ea5f63a70dd3714a7cf54f204549c72b98817e275f97b3)
set(QT_HASH_qt5-wayland             f973b24778227ae0d1e62f4b88703c0aafb6409a6150c5b38a6054e7f7e79cf4542f9c989e0c8d012758ae09b1389208fa2654166b5cf4d06011b1e9ad27205a)


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()