From 207292cf459d70840e42a3a864d299aa77dab2d2 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Wed, 6 Sep 2006 08:31:50 -0400 Subject: ENH: fixes from Clinton to allow qt to work with static libs --- Modules/FindQt4.cmake | 266 ++++++++++++++++++++++++++++++++++++-------------- Modules/UseQt4.cmake | 156 +++++++++++------------------ 2 files changed, 248 insertions(+), 174 deletions(-) diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index aaa4fec..21ffcf6 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -19,6 +19,9 @@ # QT_USE_QTOPENGL # QT_USE_QTSQL # QT_USE_QTXML +# QT_USE_QTSVG +# QT_USE_QTTEST +# QT_USE_QTUITOOLS # # All the libraries required are stored in a variable called QT_LIBRARIES. # Add this variable to your TARGET_LINK_LIBRARIES. @@ -45,6 +48,7 @@ # QT_QTXML_FOUND True if QtXml was found. # QT_QTSVG_FOUND True if QtSvg was found. # QT_QTTEST_FOUND True if QtTest was found. +# QT_QTUITOOLS_FOUND True if QtUiTools was found. # # QT_DEFINITIONS Definitions to use when compiling code that uses Qt. # @@ -167,10 +171,6 @@ SET(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake) SET( QT_DEFINITIONS "") -IF (WIN32) - SET(QT_DEFINITIONS -DQT_DLL) -ENDIF(WIN32) - # check for qmake FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake qmake-qt4 PATHS "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin" @@ -180,6 +180,20 @@ FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake qmake-qt4 PATHS SET(QT4_INSTALLED_VERSION_TOO_OLD FALSE) +## macro for asking qmake to process pro files +MACRO(QT_QUERY_QMAKE outvar invar) + FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake/tmp.pro + "message(CMAKE_MESSAGE<$$${invar}>)") + EXECUTE_PROCESS(COMMAND ${QT_QMAKE_EXECUTABLE} + WORKING_DIRECTORY + ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake + OUTPUT_VARIABLE _qmake_query_output + ERROR_VARIABLE _qmake_query_output ) + FILE(REMOVE_RECURSE + "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake") + STRING(REGEX REPLACE ".*CMAKE_MESSAGE<([^>]*).*" "\\1" ${outvar} "${_qmake_query_output}") +ENDMACRO(QT_QUERY_QMAKE) + IF (QT_QMAKE_EXECUTABLE) @@ -467,59 +481,57 @@ IF (QT4_QMAKE_FOUND) # Set QT_INCLUDES SET( QT_INCLUDES ${QT_INCLUDE_DIR} ${QT_QT_INCLUDE_DIR} ${QT_MKSPECS_DIR}/default ) + # Set QT_QTCORE_LIBRARY by searching for a lib with "QtCore." as part of the filename + FIND_LIBRARY(QT_QTCORE_LIBRARY_RELEASE NAMES QtCore QtCore4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH ) + FIND_LIBRARY(QT_QTCORE_LIBRARY_DEBUG NAMES QtCore_debug QtCored QtCored4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - - # Set QT_QTCORE_LIBRARY by searching for a lib with "QtCore." as part of the filename - FIND_LIBRARY(QT_QTCORE_LIBRARY_RELEASE NAMES QtCore QtCore4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH ) - FIND_LIBRARY(QT_QTCORE_LIBRARY_DEBUG NAMES QtCore_debug QtCored QtCored4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + # Set QT_QT3SUPPORT_LIBRARY + FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_RELEASE NAMES Qt3Support Qt3Support4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_DEBUG NAMES Qt3Support_debug Qt3Supportd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - # Set QT_QT3SUPPORT_LIBRARY - FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_RELEASE NAMES Qt3Support Qt3Support4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_DEBUG NAMES Qt3Support_debug Qt3Supportd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + # Set QT_QTGUI_LIBRARY + FIND_LIBRARY(QT_QTGUI_LIBRARY_RELEASE NAMES QtGui QtGui4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTGUI_LIBRARY_DEBUG NAMES QtGui_debug QtGuid4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - # Set QT_QTGUI_LIBRARY - FIND_LIBRARY(QT_QTGUI_LIBRARY_RELEASE NAMES QtGui QtGui4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTGUI_LIBRARY_DEBUG NAMES QtGui_debug QtGuid4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - - # Set QT_QTMOTIF_LIBRARY - IF(Q_WS_X11) - FIND_LIBRARY(QT_QTMOTIF_LIBRARY_RELEASE NAMES QtMotif PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTMOTIF_LIBRARY_DEBUG NAMES QtMotif_debug PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - ENDIF(Q_WS_X11) + # Set QT_QTMOTIF_LIBRARY + IF(Q_WS_X11) + FIND_LIBRARY(QT_QTMOTIF_LIBRARY_RELEASE NAMES QtMotif PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTMOTIF_LIBRARY_DEBUG NAMES QtMotif_debug PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + ENDIF(Q_WS_X11) - # Set QT_QTNETWORK_LIBRARY - FIND_LIBRARY(QT_QTNETWORK_LIBRARY_RELEASE NAMES QtNetwork QtNetwork4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTNETWORK_LIBRARY_DEBUG NAMES QtNetwork_debug QtNetworkd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + # Set QT_QTNETWORK_LIBRARY + FIND_LIBRARY(QT_QTNETWORK_LIBRARY_RELEASE NAMES QtNetwork QtNetwork4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTNETWORK_LIBRARY_DEBUG NAMES QtNetwork_debug QtNetworkd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - # Set QT_QTNSPLUGIN_LIBRARY - FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY_RELEASE NAMES QtNsPlugin PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY_DEBUG NAMES QtNsPlugin_debug PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + # Set QT_QTNSPLUGIN_LIBRARY + FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY_RELEASE NAMES QtNsPlugin PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY_DEBUG NAMES QtNsPlugin_debug PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - # Set QT_QTOPENGL_LIBRARY - FIND_LIBRARY(QT_QTOPENGL_LIBRARY_RELEASE NAMES QtOpenGL QtOpenGL4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTOPENGL_LIBRARY_DEBUG NAMES QtOpenGL_debug QtOpenGLd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + # Set QT_QTOPENGL_LIBRARY + FIND_LIBRARY(QT_QTOPENGL_LIBRARY_RELEASE NAMES QtOpenGL QtOpenGL4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTOPENGL_LIBRARY_DEBUG NAMES QtOpenGL_debug QtOpenGLd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - # Set QT_QTSQL_LIBRARY - FIND_LIBRARY(QT_QTSQL_LIBRARY_RELEASE NAMES QtSql QtSql4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTSQL_LIBRARY_DEBUG NAMES QtSql_debug QtSqld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + # Set QT_QTSQL_LIBRARY + FIND_LIBRARY(QT_QTSQL_LIBRARY_RELEASE NAMES QtSql QtSql4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTSQL_LIBRARY_DEBUG NAMES QtSql_debug QtSqld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - # Set QT_QTXML_LIBRARY - FIND_LIBRARY(QT_QTXML_LIBRARY_RELEASE NAMES QtXml QtXml4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTXML_LIBRARY_DEBUG NAMES QtXml_debug QtXmld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + # Set QT_QTXML_LIBRARY + FIND_LIBRARY(QT_QTXML_LIBRARY_RELEASE NAMES QtXml QtXml4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTXML_LIBRARY_DEBUG NAMES QtXml_debug QtXmld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - # Set QT_QTSVG_LIBRARY - FIND_LIBRARY(QT_QTSVG_LIBRARY_RELEASE NAMES QtSvg QtSvg4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTSVG_LIBRARY_DEBUG NAMES QtSvg_debug QtSvgd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + # Set QT_QTSVG_LIBRARY + FIND_LIBRARY(QT_QTSVG_LIBRARY_RELEASE NAMES QtSvg QtSvg4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTSVG_LIBRARY_DEBUG NAMES QtSvg_debug QtSvgd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - # Set QT_QTUITOOLS_LIBRARY - FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools QtUiTools4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_DEBUG NAMES QtUiTools_debug QtUiToolsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + # Set QT_QTUITOOLS_LIBRARY + FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools QtUiTools4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_DEBUG NAMES QtUiTools_debug QtUiToolsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - # Set QT_QTTEST_LIBRARY - FIND_LIBRARY(QT_QTTEST_LIBRARY_RELEASE NAMES QtTest QtTest4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTTEST_LIBRARY_DEBUG NAMES QtTest_debug QtTest_debug4 QtTestd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + # Set QT_QTTEST_LIBRARY + FIND_LIBRARY(QT_QTTEST_LIBRARY_RELEASE NAMES QtTest QtTest4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTTEST_LIBRARY_DEBUG NAMES QtTest_debug QtTest_debug4 QtTestd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - MARK_AS_ADVANCED(QT_QT3SUPPORT_LIBRARY QT_QTGUI_LIBRARY ) + MARK_AS_ADVANCED(QT_QT3SUPPORT_LIBRARY QT_QTGUI_LIBRARY ) IF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE ) IF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED) @@ -617,6 +629,8 @@ IF (QT4_QMAKE_FOUND) _QT4_ADJUST_LIB_VARS(QTUITOOLS) _QT4_ADJUST_LIB_VARS(QTTEST) + + ####################################### # # Check the executables of Qt @@ -626,23 +640,8 @@ IF (QT4_QMAKE_FOUND) # find moc and uic using qmake - FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake/tmp.pro - "message(MOC<$$QMAKE_MOC>) - message(UIC<$$QMAKE_UIC>) - ") - - EXECUTE_PROCESS(COMMAND ${QT_QMAKE_EXECUTABLE} - WORKING_DIRECTORY - ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake - OUTPUT_VARIABLE _moc_OUTPUT - ERROR_VARIABLE _moc_OUTPUT ) - FILE(REMOVE_RECURSE - "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake") - - STRING(REGEX REPLACE - ".*MOC<([^>]+).*" "\\1" QT_MOC_EXECUTABLE_INTERNAL "${_moc_OUTPUT}" ) - STRING(REGEX REPLACE - ".*UIC<([^>]+).*" "\\1" QT_UIC_EXECUTABLE_INTERNAL "${_moc_OUTPUT}" ) + QT_QUERY_QMAKE(QT_MOC_EXECUTABLE_INTERNAL "QMAKE_MOC") + QT_QUERY_QMAKE(QT_UIC_EXECUTABLE_INTERNAL "QMAKE_UIC") FILE(TO_CMAKE_PATH "${QT_MOC_EXECUTABLE_INTERNAL}" QT_MOC_EXECUTABLE_INTERNAL) @@ -833,23 +832,142 @@ IF (QT4_QMAKE_FOUND) ENDIF( Qt4_FIND_REQUIRED) ENDIF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE) SET(QT_FOUND ${QT4_FOUND}) - - + ####################################### # - # System dependent settings + # Qt configuration # ####################################### - # for unix add X11 stuff - IF(UNIX) - # on OS X X11 may not be required - IF (Q_WS_X11) - FIND_PACKAGE(X11) - ENDIF (Q_WS_X11) - FIND_PACKAGE(Threads) - SET(QT_QTCORE_LIBRARY ${QT_QTCORE_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) - ENDIF(UNIX) + IF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri") + FILE(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents) + STRING(REGEX MATCH "QT_CONFIG[^\n]+" QT_QCONFIG ${_qconfig_FILE_contents}) + STRING(REGEX MATCH "CONFIG[^\n]+" QT_CONFIG ${_qconfig_FILE_contents}) + ENDIF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri") + + ############################################### + # + # configuration/system dependent settings + # + ############################################### + + SET(QT_GUI_LIB_DEPENDENCIES "") + SET(QT_CORE_LIB_DEPENDENCIES "") + + # shared build needs -DQT_SHARED + IF(NOT QT_CONFIG MATCHES "static") + # warning currently only qconfig.pri on Windows potentially contains "static" + # so QT_SHARED might not get defined properly on Mac/X11 (which seems harmless right now) + # Trolltech said they'd consider exporting it for all platforms in future releases. + SET(QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_SHARED) + ENDIF(NOT QT_CONFIG MATCHES "static") + + ## system png + IF(QT_QCONFIG MATCHES "system-png") + FIND_LIBRARY(QT_PNG_LIBRARY NAMES png) + SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_PNG_LIBRARY}) + MARK_AS_ADVANCED(QT_PNG_LIBRARY) + ENDIF(QT_QCONFIG MATCHES "system-png") + + # for X11, get X11 library directory + IF(Q_WS_X11) + QT_QUERY_QMAKE(QMAKE_LIBDIR_X11 "QMAKE_LIBDIR_X11") + ENDIF(Q_WS_X11) + + ## X11 SM + IF(QT_QCONFIG MATCHES "x11sm") + # ask qmake where the x11 libs are + FIND_LIBRARY(QT_X11_SM_LIBRARY NAMES SM PATHS ${QMAKE_LIBDIR_X11}) + FIND_LIBRARY(QT_X11_ICE_LIBRARY NAMES ICE PATHS ${QMAKE_LIBDIR_X11}) + SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_X11_SM_LIBRARY} ${QT_X11_ICE_LIBRARY}) + MARK_AS_ADVANCED(QT_X11_SM_LIBRARY) + MARK_AS_ADVANCED(QT_X11_ICE_LIBRARY) + ENDIF(QT_QCONFIG MATCHES "x11sm") + + ## Xi + IF(QT_QCONFIG MATCHES "tablet") + FIND_LIBRARY(QT_XI_LIBRARY NAMES Xi PATHS ${QMAKE_LIBDIR_X11}) + SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XI_LIBRARY}) + MARK_AS_ADVANCED(QT_XI_LIBRARY) + ENDIF(QT_QCONFIG MATCHES "tablet") + + ## Xrender + IF(QT_QCONFIG MATCHES "xrender") + FIND_LIBRARY(QT_XRENDER_LIBRARY NAMES Xrender PATHS ${QMAKE_LIBDIR_X11}) + SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XRENDER_LIBRARY}) + MARK_AS_ADVANCED(QT_XRENDER_LIBRARY) + ENDIF(QT_QCONFIG MATCHES "xrender") + + ## Xrandr + IF(QT_QCONFIG MATCHES "xrandr") + FIND_LIBRARY(QT_XRANDR_LIBRARY NAMES Xrandr PATHS ${QMAKE_LIBDIR_X11}) + SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XRANDR_LIBRARY}) + MARK_AS_ADVANCED(QT_XRANDR_LIBRARY) + ENDIF(QT_QCONFIG MATCHES "xrandr") + + ## Xcursor + IF(QT_QCONFIG MATCHES "xcursor") + FIND_LIBRARY(QT_XCURSOR_LIBRARY NAMES Xcursor PATHS ${QMAKE_LIBDIR_X11}) + SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XCURSOR_LIBRARY}) + MARK_AS_ADVANCED(QT_XCURSOR_LIBRARY) + ENDIF(QT_QCONFIG MATCHES "xcursor") + + ## Xinerama + IF(QT_QCONFIG MATCHES "xinerama") + FIND_LIBRARY(QT_XINERAMA_LIBRARY NAMES Xinerama PATHS ${QMAKE_LIBDIR_X11}) + SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_XINERAMA_LIBRARY}) + MARK_AS_ADVANCED(QT_XINERAMA_LIBRARY) + ENDIF(QT_QCONFIG MATCHES "xinerama") + + ## system-freetype + IF(QT_QCONFIG MATCHES "system-freetype") + FIND_LIBRARY(QT_FREETYPE_LIBRARY NAMES freetype) + SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_FREETYPE_LIBRARY}) + MARK_AS_ADVANCED(QT_FREETYPE_LIBRARY) + ENDIF(QT_QCONFIG MATCHES "system-freetype") + + ## fontconfig + IF(QT_QCONFIG MATCHES "fontconfig") + FIND_LIBRARY(QT_FONTCONFIG_LIBRARY NAMES fontconfig) + SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${QT_FONTCONFIG_LIBRARY}) + MARK_AS_ADVANCED(QT_FONTCONFIG_LIBRARY) + ENDIF(QT_QCONFIG MATCHES "fontconfig") + + ## system-zlib + IF(QT_QCONFIG MATCHES "system-zlib") + FIND_LIBRARY(QT_ZLIB_LIBRARY NAMES z) + SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ${QT_ZLIB_LIBRARY}) + MARK_AS_ADVANCED(QT_ZLIB_LIBRARY) + ENDIF(QT_QCONFIG MATCHES "system-zlib") + + IF(Q_WS_X11) + # X11 libraries Qt absolutely depends on + QT_QUERY_QMAKE(QT_LIBS_X11 "QMAKE_LIBS_X11") + SEPARATE_ARGUMENTS(QT_LIBS_X11) + FOREACH(QT_X11_LIB ${QT_LIBS_X11}) + STRING(REGEX REPLACE "-l" "" QT_X11_LIB "${QT_X11_LIB}") + SET(QT_TMP_STR "QT_X11_${QT_X11_LIB}_LIBRARY") + FIND_LIBRARY(${QT_TMP_STR} NAMES "${QT_X11_LIB}" PATHS ${QMAKE_LIBDIR_X11}) + SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} ${${QT_TMP_STR}}) + ENDFOREACH(QT_X11_LIB) + + QT_QUERY_QMAKE(QT_LIBS_THREAD "QMAKE_LIBS_THREAD") + SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ${QT_LIBS_THREAD}) + + QT_QUERY_QMAKE(QMAKE_LIBS_DYNLOAD "QMAKE_LIBS_DYNLOAD") + SET (QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} ${QMAKE_LIBS_DYNLOAD}) + + ENDIF(Q_WS_X11) + + IF(Q_WS_WIN) + SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} Imm32 Winmm) + SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} Ws2_32) + ENDIF(Q_WS_WIN) + + IF(Q_WS_MAC) + SET(QT_GUI_LIB_DEPENDENCIES ${QT_GUI_LIB_DEPENDENCIES} "-framework Carbon" "-framework QuickTime") + SET(QT_CORE_LIB_DEPENDENCIES ${QT_CORE_LIB_DEPENDENCIES} "-framework ApplicationServices") + ENDIF(Q_WS_MAC) ####################################### # diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake index 04fa934..17fb1e1 100644 --- a/Modules/UseQt4.cmake +++ b/Modules/UseQt4.cmake @@ -10,125 +10,81 @@ INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR}) SET(QT_LIBRARIES "") -IF (NOT QT_DONT_USE_QTCORE) - IF (QT_QTCORE_FOUND) - INCLUDE_DIRECTORIES(${QT_QTCORE_INCLUDE_DIR}) - ADD_DEFINITIONS(-DQT_CORE_LIB) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QTCORE_LIBRARY}) - IF (UNIX) - IF (CMAKE_DL_LIBS) - SET (QT_LIBRARIES ${QT_LIBRARIES} ${CMAKE_DL_LIBS}) - ENDIF (CMAKE_DL_LIBS) - ENDIF (UNIX) - ELSE (QT_QTCORE_FOUND) - MESSAGE("QtCore library not found.") - ENDIF (QT_QTCORE_FOUND) -ENDIF (NOT QT_DONT_USE_QTCORE) +IF (QT_USE_QTMAIN) + IF (WIN32) + SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY}) + ENDIF (WIN32) +ENDIF (QT_USE_QTMAIN) -IF (NOT QT_DONT_USE_QTGUI) - IF (QT_QTGUI_FOUND) - INCLUDE_DIRECTORIES(${QT_QTGUI_INCLUDE_DIR}) - ADD_DEFINITIONS(-DQT_GUI_LIB) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QTGUI_LIBRARY}) - IF (UNIX) - IF (X11_FOUND) - SET (QT_LIBRARIES ${QT_LIBRARIES} ${X11_LIBRARIES}) - ENDIF (X11_FOUND) - ENDIF (UNIX) - ELSE (QT_QTGUI_FOUND) - MESSAGE("QtGui library not found.") - ENDIF (QT_QTGUI_FOUND) -ENDIF (NOT QT_DONT_USE_QTGUI) +# Macro for setting up compile flags for Qt modules +MACRO(QT_MODULE_SETUP module) + IF (QT_QT${module}_FOUND) + ADD_DEFINITIONS(-DQT_${module}_LIB) + INCLUDE_DIRECTORIES(${QT_QT${module}_INCLUDE_DIR}) + SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QT${module}_LIBRARY}) + SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIB_DEPENDENCIES}) + ELSE (QT_QT${module}_FOUND) + MESSAGE("Qt ${module} library not found.") + ENDIF (QT_QT${module}_FOUND) +ENDMACRO(QT_MODULE_SETUP) + + +# Qt modules (in order of dependence) IF (QT_USE_QT3SUPPORT) - IF (QT_QT3SUPPORT_FOUND) - INCLUDE_DIRECTORIES(${QT_QT3SUPPORT_INCLUDE_DIR}) - ADD_DEFINITIONS(-DQT3_SUPPORT) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QT3SUPPORT_LIBRARY}) - ELSE (QT_QT3SUPPORT_FOUND) - MESSAGE("Qt3Support library not found.") - ENDIF (QT_QT3SUPPORT_FOUND) + QT_MODULE_SETUP(3SUPPORT) ENDIF (QT_USE_QT3SUPPORT) +IF (QT_USE_QTOPENGL) + QT_MODULE_SETUP(OPENGL) +ENDIF (QT_USE_QTOPENGL) + IF (QT_USE_QTASSISTANT) - IF (QT_QTASSISTANT_FOUND) - INCLUDE_DIRECTORIES(${QT_QTASSISTANT_INCLUDE_DIR}) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QTASSISTANT_LIBRARY}) - ELSE (QT_QTASSISTANT_FOUND) - MESSAGE("QtAssistant library not found.") - ENDIF (QT_QTASSISTANT_FOUND) + QT_MODULE_SETUP(ASSISTANT) ENDIF (QT_USE_QTASSISTANT) IF (QT_USE_QTDESIGNER) - IF (QT_QTDESIGNER_FOUND) - INCLUDE_DIRECTORIES(${QT_QTDESIGNER_INCLUDE_DIR}) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QTDESIGNER_LIBRARY}) - ELSE (QT_QTDESIGNER_FOUND) - MESSAGE("QtDesigner library not found.") - ENDIF (QT_QTDESIGNER_FOUND) + QT_MODULE_SETUP(DESIGNER) ENDIF (QT_USE_QTDESIGNER) -IF (QT_USE_QTMAIN) - IF (WIN32) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY}) - ENDIF (WIN32) -ENDIF (QT_USE_QTMAIN) - IF (QT_USE_QTMOTIF) - IF (QT_QTMOTIF_FOUND) - INCLUDE_DIRECTORIES(${QT_QTMOTIF_INCLUDE_DIR}) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QTMOTIF_LIBRARY}) - ELSE (QT_QTMOTIF_FOUND) - MESSAGE("QtMotif library not found.") - ENDIF (QT_QTMOTIF_FOUND) + QT_MODULE_SETUP(MOTIF) ENDIF (QT_USE_QTMOTIF) -IF (QT_USE_QTNETWORK) - IF (QT_QTNETWORK_FOUND) - INCLUDE_DIRECTORIES(${QT_QTNETWORK_INCLUDE_DIR}) - ADD_DEFINITIONS(-DQT_NETWORK_LIB) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QTNETWORK_LIBRARY}) - ELSE (QT_QTNETWORK_FOUND) - MESSAGE("QtNetwork library not found.") - ENDIF (QT_QTNETWORK_FOUND) -ENDIF (QT_USE_QTNETWORK) - IF (QT_USE_QTNSPLUGIN) - IF (QT_QTNSPLUGIN_FOUND) - INCLUDE_DIRECTORIES(${QT_QTNSPLUGIN_INCLUDE_DIR}) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QTNSPLUGIN_LIBRARY}) - ELSE (QT_QTNSPLUGIN_FOUND) - MESSAGE("QtNsPlugin library not found.") - ENDIF (QT_QTNSPLUGIN_FOUND) + QT_MODULE_SETUP(NSPLUGIN) ENDIF (QT_USE_QTNSPLUGIN) -IF (QT_USE_QTOPENGL) - IF (QT_QTOPENGL_FOUND) - INCLUDE_DIRECTORIES(${QT_QTOPENGL_INCLUDE_DIR}) - ADD_DEFINITIONS(-DQT_OPENGL_LIB) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY}) - ELSE (QT_QTOPENGL_FOUND) - MESSAGE("QtOpenGL library not found.") - ENDIF (QT_QTOPENGL_FOUND) -ENDIF (QT_USE_QTOPENGL) +IF (QT_USE_QTSVG) + QT_MODULE_SETUP(SVG) +ENDIF (QT_USE_QTSVG) -IF (QT_USE_QTSQL) - IF (QT_QTSQL_FOUND) - INCLUDE_DIRECTORIES(${QT_QTSQL_INCLUDE_DIR}) - ADD_DEFINITIONS(-DQT_SQL_LIB) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QTSQL_LIBRARY}) - ELSE (QT_QTSQL_FOUND) - MESSAGE("QtSql library not found.") - ENDIF (QT_QTSQL_FOUND) -ENDIF (QT_USE_QTSQL) +IF (QT_USE_QTUITOOLS) + QT_MODULE_SETUP(UITOOLS) +ENDIF (QT_USE_QTUITOOLS) + +IF (NOT QT_DONT_USE_QTGUI) + QT_MODULE_SETUP(GUI) +ENDIF (NOT QT_DONT_USE_QTGUI) + +IF (QT_USE_QTTEST) + QT_MODULE_SETUP(TEST) +ENDIF (QT_USE_QTTEST) IF (QT_USE_QTXML) - IF (QT_QTXML_FOUND) - INCLUDE_DIRECTORIES(${QT_QTXML_INCLUDE_DIR}) - ADD_DEFINITIONS(-DQT_XML_LIB) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QTXML_LIBRARY}) - ELSE (QT_QTXML_FOUND) - MESSAGE("QtXml library not found.") - ENDIF (QT_QTXML_FOUND) + QT_MODULE_SETUP(XML) ENDIF (QT_USE_QTXML) +IF (QT_USE_QTSQL) + QT_MODULE_SETUP(SQL) +ENDIF (QT_USE_QTSQL) + +IF (QT_USE_QTNETWORK) + QT_MODULE_SETUP(NETWORK) +ENDIF (QT_USE_QTNETWORK) + +IF (NOT QT_DONT_USE_QTCORE) + QT_MODULE_SETUP(CORE) +ENDIF (NOT QT_DONT_USE_QTCORE) + + -- cgit v0.12