Sfoglia il codice sorgente

BUG: Fix #10021 don't specify libraries Qt depends on unless Qt is static.

Clinton Stimpson 16 anni fa
parent
commit
56ee3b43a9
2 ha cambiato i file con 29 aggiunte e 8 eliminazioni
  1. 25 7
      Modules/Qt4ConfigDependentSettings.cmake
  2. 4 1
      Modules/UseQt4.cmake

+ 25 - 7
Modules/Qt4ConfigDependentSettings.cmake

@@ -22,8 +22,7 @@
 
 # find dependencies for some Qt modules
 # when doing builds against a static Qt, they are required
-# when doing builds against a shared Qt, they are sometimes not required
-# even some Linux distros do not require these dependencies
+# when doing builds against a shared Qt, they are not required
 # if a user needs the dependencies, and they couldn't be found, they can set
 # the variables themselves.
 
@@ -35,12 +34,31 @@ SET(QT_QTDBUS_LIB_DEPENDENCIES "")
 SET(QT_QTHELP_LIB_DEPENDENCIES ${QT_QTCLUCENE_LIBRARY})
 
 
-# build using shared Qt needs -DQT_DLL
-IF(WIN32  AND  NOT QT_CONFIG MATCHES "static")
-  # warning currently only qconfig.pri on Windows potentially contains "static"
-  # so QT_DLL might not get defined properly on other platforms.
+IF(WIN32)
+  # On Windows, qconfig.pri has "static" for static library builds
+  IF(QT_CONFIG MATCHES "static")
+    SET(QT_IS_STATIC 1)
+  ENDIF(QT_CONFIG MATCHES "static")
+ELSE(WIN32)
+  # On other platforms, check file extension to know if its static
+  IF(QT_QTCORE_LIBRARY_RELEASE)
+    GET_FILENAME_COMPONENT(qtcore_lib_ext "${QT_QTCORE_LIBRARY_RELEASE}" EXT)
+    IF(${qtcore_lib_ext} STREQUAL ${CMAKE_STATIC_LIBRARY_SUFFIX})
+      SET(QT_IS_STATIC 1)
+    ENDIF(${qtcore_lib_ext} STREQUAL ${CMAKE_STATIC_LIBRARY_SUFFIX})
+  ENDIF(QT_QTCORE_LIBRARY_RELEASE)
+  IF(QT_QTCORE_LIBRARY_DEBUG)
+    GET_FILENAME_COMPONENT(qtcore_lib_ext "${QT_QTCORE_LIBRARY_DEBUG}" EXT)
+    IF(${qtcore_lib_ext} STREQUAL ${CMAKE_STATIC_LIBRARY_SUFFIX})
+      SET(QT_IS_STATIC 1)
+    ENDIF(${qtcore_lib_ext} STREQUAL ${CMAKE_STATIC_LIBRARY_SUFFIX})
+  ENDIF(QT_QTCORE_LIBRARY_DEBUG)
+ENDIF(WIN32)
+
+# build using shared Qt needs -DQT_DLL on Windows
+IF(WIN32  AND  NOT QT_IS_STATIC)
   SET(QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_DLL)
-ENDIF(WIN32  AND  NOT QT_CONFIG MATCHES "static")
+ENDIF(WIN32  AND  NOT QT_IS_STATIC)
 
 
 # QtOpenGL dependencies

+ 4 - 1
Modules/UseQt4.cmake

@@ -80,7 +80,10 @@ FOREACH(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN
         ADD_DEFINITIONS(-DQT_${qt_module_def}_LIB)
         INCLUDE_DIRECTORIES(${QT_${module}_INCLUDE_DIR})
       ENDIF(QT_USE_${module})
-      SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIBRARY} ${QT_${module}_LIB_DEPENDENCIES})
+      SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIBRARY})
+      IF(QT_IS_STATIC)
+        SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIB_DEPENDENCIES})
+      ENDIF(QT_IS_STATIC)
       FOREACH(depend_module ${QT_${module}_MODULE_DEPENDS})
         SET(QT_USE_${depend_module}_DEPENDS 1)
       ENDFOREACH(depend_module ${QT_${module}_MODULE_DEPENDS})