]> OCCT Git - occt.git/commitdiff
Configuration - Enhance Qt5 directory detection for Windows #419
authorPasukhin Dmitry <dpasukhi@opencascade.com>
Sun, 9 Mar 2025 18:04:44 +0000 (18:04 +0000)
committerGitHub <noreply@github.com>
Sun, 9 Mar 2025 18:04:44 +0000 (18:04 +0000)
Update the detection Qt5 folder to search for bin folder.
That will affected for the starting DRAW or samples as a part of env.

adm/cmake/qt.cmake

index a87b1db29d634f34baf2a3270233855c7bcefe3d..c89916be96f40e994e5e914441fe1b1d3521e317 100644 (file)
@@ -31,13 +31,26 @@ if (NOT ${Qt5_FOUND})
   # Now we can apply standard CMake finder for Qt. We do this mostly
   # to have qt4_wrap_cpp() function available
   find_package(Qt4)
-else()
-  set (3RDPARTY_QT_DIR ${Qt5_DIR} CACHE PATH "The directory containing Qt" FORCE)
+elseif(NOT ${USE_QT_FROM_3RDPARTY_DIR} AND WIN32)
+  # Qt5_DIR typically points to lib/cmake/Qt5, need to go up to Qt root
+  get_filename_component(QT_CMAKE_DIR "${Qt5_DIR}" DIRECTORY)
+  get_filename_component(QT_LIB_DIR "${QT_CMAKE_DIR}" DIRECTORY)
+  get_filename_component(QT_ROOT_DIR "${QT_LIB_DIR}" DIRECTORY)
+  
+  # Verify this is indeed the Qt root by checking for bin and packages directories
+  if(EXISTS "${QT_ROOT_DIR}/bin")
+    set(3RDPARTY_QT_DIR ${QT_ROOT_DIR} CACHE PATH "The directory containing Qt" FORCE)
+  else()
+    message(WARNING "Found Qt5 at ${Qt5_DIR} but could not determine Qt root directory with bin/ and plugins/ folders")
+    set(3RDPARTY_QT_DIR ${Qt5_DIR} CACHE PATH "The directory containing Qt" FORCE)
+  endif()
+elseif(NOT ${USE_QT_FROM_3RDPARTY_DIR})
+  set(3RDPARTY_QT_DIR ${Qt5_DIR} CACHE PATH "The directory containing Qt" FORCE)
 endif()
 
 set (USED_3RDPARTY_QT_DIR "${3RDPARTY_QT_DIR}")
 
-if (3RDPARTY_QT_DIR OR EXISTS "${3RDPARTY_QT_DIR}")
+if (3RDPARTY_QT_DIR OR EXISTS "${3RDPARTY_QT_DIR}/bin")
   list (APPEND 3RDPARTY_DLL_DIRS "${3RDPARTY_QT_DIR}/bin")
 else()
   list (APPEND 3RDPARTY_NO_DLLS 3RDPARTY_QT_DLL_DIR)