From 7546be2e8a4a2662436461385333575fdcbd8b32 Mon Sep 17 00:00:00 2001
From: Dale Glass <dale@daleglass.net>
Date: Sun, 27 Jun 2021 16:35:54 +0200
Subject: [PATCH] Use qt5_add_binary_resources instead of custom command.

Also move find_package for Qt to the top, so that it finds the
rcc binary before it's needed
---
 interface/CMakeLists.txt | 30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)

diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt
index 31fab35df1..8d15ccc22e 100644
--- a/interface/CMakeLists.txt
+++ b/interface/CMakeLists.txt
@@ -21,6 +21,14 @@ set(CUSTOM_INTERFACE_QRC_PATHS "")
 
 find_npm()
 
+find_package(
+  Qt5 COMPONENTS
+  Gui Widgets Multimedia Network Qml Quick Script Svg
+  ${PLATFORM_QT_COMPONENTS}
+  WebChannel WebSockets
+)
+
+
 if (BUILD_TOOLS AND NPM_EXECUTABLE)
   add_custom_qrc_path(CUSTOM_INTERFACE_QRC_PATHS "${CMAKE_BINARY_DIR}/tools/jsdoc/out/hifiJSDoc.json" "auto-complete/hifiJSDoc.json")
 endif ()
@@ -31,23 +39,12 @@ generate_qrc(OUTPUT ${RESOURCES_QRC} PATH ${CMAKE_CURRENT_SOURCE_DIR}/resources
 
 if (ANDROID)
   # on Android, don't compress the rcc binary
-  add_custom_command(
-    OUTPUT ${RESOURCES_RCC}
-    DEPENDS ${RESOURCES_QRC} ${GENERATE_QRC_DEPENDS}
-    COMMAND "${RCC_BINARY}"
-    ARGS ${RESOURCES_QRC} -no-compress -binary -o ${RESOURCES_RCC}
-  )
+  qt5_add_binary_resources(resources "${RESOURCES_QRC}" DESTINATION "${RESOURCES_RCC}" OPTIONS -no-compress)
 else ()
-  add_custom_command(
-    OUTPUT ${RESOURCES_RCC}
-    DEPENDS ${RESOURCES_QRC} ${GENERATE_QRC_DEPENDS}
-    COMMAND "${RCC_BINARY}"
-    ARGS ${RESOURCES_QRC} -binary -o ${RESOURCES_RCC}
-  )
+  qt5_add_binary_resources(resources "${RESOURCES_QRC}" DESTINATION "${RESOURCES_RCC}")
 endif()
 
 list(APPEND GENERATE_QRC_DEPENDS ${RESOURCES_RCC})
-add_custom_target(resources ALL DEPENDS ${GENERATE_QRC_DEPENDS})
 
 # set a default root dir for each of our optional externals if it was not passed
 set(OPTIONAL_EXTERNALS "LeapMotion")
@@ -96,13 +93,6 @@ else ()
   list(REMOVE_ITEM INTERFACE_SRCS ${SPEECHRECOGNIZER_CPP})
 endif ()
 
-find_package(
-  Qt5 COMPONENTS
-  Gui Widgets Multimedia Network Qml Quick Script Svg
-  ${PLATFORM_QT_COMPONENTS}
-  WebChannel WebSockets
-)
-
 # grab the ui files in resources/ui
 file (GLOB_RECURSE QT_UI_FILES ui/*.ui)
 source_group("UI Files" FILES ${QT_UI_FILES})