@@ -110,31 +110,47 @@ if(NOT QT_MAJOR)
110110 set (QT_MAJOR 6)
111111endif ()
112112
113- find_package (Qt${QT_MAJOR} COMPONENTS Widgets SerialPort Multimedia MultimediaWidgets REQUIRED)
113+ # Make sure CI builds work without going overboard with per-platform directory shenanigans
114+ if (NOT DEPLOY_FILES)
115+ find_package (Qt${QT_MAJOR} COMPONENTS Widgets SerialPort Multimedia MultimediaWidgets REQUIRED)
116+ endif ()
114117
115118# Find Qt and windeployqt.exe relative to the Qt bin dir
116119if (WIN32 AND DEPLOY_FILES)
117120 # Define the base Qt installation directory
118- set (QT_BASE_DIR "C:/Qt" )
121+ if (PREFERRED_QT_DIR AND PREFERRED_QT_VER)
122+ set (QT_CANDIDATE_DIR "${PREFERRED_QT_DIR} /${PREFERRED_QT_VER} /msvc2022_64/lib/cmake" )
123+ endif ()
119124
120- # Find all subdirectories in the Qt base directory
121- file (GLOB QT_SUBDIRS LIST_DIRECTORIES true "${QT_BASE_DIR} /${QT_MAJOR} *" )
125+ # Set default base directory just in case, validate that Qt specified in CMakePresets.json exists
126+ # Otherwise search out the latest available in the default Qt directory.
127+ set (QT_BASE_DIR "C:/Qt" )
128+ if (QT_CANDIDATE_DIR AND EXISTS "${QT_CANDIDATE_DIR} " )
129+ message (STATUS "Using preferred Qt directory for Qt${QT_MAJOR} ${PREFERRED_QT_VER} : ${QT_CANDIDATE_DIR} " )
130+ set (CMAKE_PREFIX_PATH "${QT_CANDIDATE_DIR} " )
131+ find_package (Qt${QT_MAJOR} ${PREFERRED_QT_VER} COMPONENTS Widgets SerialPort Multimedia MultimediaWidgets REQUIRED)
132+ else ()
133+ # Find all subdirectories in the Qt base directory
134+ find_package (Qt${QT_MAJOR} COMPONENTS Widgets SerialPort Multimedia MultimediaWidgets REQUIRED)
135+ file (GLOB QT_SUBDIRS LIST_DIRECTORIES true "${QT_BASE_DIR} /${QT_MAJOR} *" )
122136
123- # Filter and sort the directories to find the latest version
124- list (SORT QT_SUBDIRS)
125- list (REVERSE QT_SUBDIRS)
137+ # Filter and sort the directories to find the latest version
138+ list (SORT QT_SUBDIRS)
139+ list (REVERSE QT_SUBDIRS)
126140
127- # Get the first directory in the sorted list (latest version)
128- list (GET QT_SUBDIRS 0 QT_LATEST_DIR)
141+ # Get the first directory in the sorted list (latest version)
142+ list (GET QT_SUBDIRS 0 QT_LATEST_DIR)
129143
130- # Debug message to verify the latest Qt directory
131- if (QT_LATEST_DIR)
132- message (STATUS "Latest Qt directory for Qt${QT_MAJOR} : ${QT_LATEST_DIR} " )
133- set (CMAKE_PREFIX_PATH "${QT_LATEST_DIR} /msvc2022_64/lib/cmake" )
134- else ()
135- message (FATAL_ERROR "No Qt${QT_MAJOR} installation found in ${QT_BASE_DIR} " )
144+ # Debug message to verify the latest Qt directory
145+ if (QT_LATEST_DIR)
146+ message (STATUS "Latest Qt directory for Qt${QT_MAJOR} : ${QT_LATEST_DIR} " )
147+ set (CMAKE_PREFIX_PATH "${QT_LATEST_DIR} /msvc2022_64/lib/cmake" )
148+ else ()
149+ message (FATAL_ERROR "No Qt${QT_MAJOR} installation found in ${QT_BASE_DIR} " )
150+ endif ()
136151 endif ()
137152
153+ # Find windeployqt.exe for Qt dependency deployment
138154 get_target_property (qt_core_location Qt${QT_MAJOR} ::Core LOCATION )
139155 get_filename_component (qt_bin_dir "${qt_core_location} " DIRECTORY )
140156 find_program (WINDEPLOYQT_EXECUTABLE windeployqt
0 commit comments