ENH: add changes for qt4 from Clinton Stimpson

This commit is contained in:
Bill Hoffman 2005-08-02 16:34:23 -04:00
parent 67d336ece8
commit feb5019890
1 changed files with 97 additions and 22 deletions

View File

@ -10,6 +10,10 @@
# This module defines
# QT_INCLUDES ,list of paths to all include directories of Qt4
#
# macro QT4_WRAP_CPP(outfiles inputfile ... )
# macro QT4_WRAP_UI(outfiles inputfile ... )
# macro QT4_ADD_RESOURCE(outfiles inputfile ... )
#
# QT_INCLUDE_DIR ,path to "include" of Qt4
# QT_QT_INCLUDE_DIR ,path to "include/Qt" of Qt4
# QT_QT3SUPPORT_INCLUDE_DIR ,path to "include/Qt3Support" of Qt
@ -279,7 +283,7 @@ IF(NOT QT_QTCORE_LIBRARY)
ENDIF(QT_QMAKE)
# Set QT_QTCORE_LIBRARY by searching for a lib with "QtCore." as part of the filename
FIND_LIBRARY( QT_QTCORE_LIBRARY
NAMES QtCore
NAMES QtCore QtCore4
PATHS
${qt_libs}
$ENV{QTDIR}/lib
@ -300,7 +304,7 @@ IF(NOT QT_QTCORE_LIBRARY_DEBUG)
OUTPUT_VARIABLE qt_libs )
ENDIF(QT_QMAKE)
FIND_LIBRARY( QT_QTCORE_LIBRARY_DEBUG
NAMES QtCore_debug
NAMES QtCore_debug QtCored4
PATHS
${qt_libs}
$ENV{QTDIR}/lib
@ -329,82 +333,82 @@ ENDIF(NOT QT_LIBRARY_DIR)
# Set QT_QT3SUPPORT_LIBRARY
IF(NOT QT_QT3SUPPORT_LIBRARY)
FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY Qt3Support ${QT_LIBRARY_DIR})
FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY NAMES Qt3Support Qt3Support4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QT3SUPPORT_LIBRARY)
IF(NOT QT_QT3SUPPORT_LIBRARY_DEBUG)
FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_DEBUG Qt3Support_debug ${QT_LIBRARY_DIR})
FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_DEBUG NAMES Qt3Support_debug Qt3Supportd4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QT3SUPPORT_LIBRARY_DEBUG)
# Set QT_QTASSISTANT_LIBRARY
IF(NOT QT_QTASSISTANT_LIBRARY)
FIND_LIBRARY(QT_QTASSISTANT_LIBRARY QtAssistant ${QT_LIBRARY_DIR})
FIND_LIBRARY(QT_QTASSISTANT_LIBRARY NAMES QtAssistant QtAssistant4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTASSISTANT_LIBRARY)
IF(NOT QT_QTASSISTANT_LIBRARY_DEBUG)
FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_DEBUG QtAssistant_debug ${QT_LIBRARY_DIR})
FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_DEBUG NAMES QtAssistant_debug QtAssistantd4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTASSISTANT_LIBRARY_DEBUG)
# Set QT_QTDESIGNER_LIBRARY
IF(NOT QT_QTDESIGNER_LIBRARY)
FIND_LIBRARY(QT_QTDESIGNER_LIBRARY QtDesigner ${QT_LIBRARY_DIR})
FIND_LIBRARY(QT_QTDESIGNER_LIBRARY NAMES QtDesigner QtDesigner4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTDESIGNER_LIBRARY)
IF(NOT QT_QTDESIGNER_LIBRARY_DEBUG)
FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_DEBUG QtDesigner_debug ${QT_LIBRARY_DIR})
FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_DEBUG NAMES QtDesigner_debug QtDesignerd4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTDESIGNER_LIBRARY_DEBUG)
# Set QT_QTGUI_LIBRARY
IF(NOT QT_QTGUI_LIBRARY)
FIND_LIBRARY(QT_QTGUI_LIBRARY QtGui ${QT_LIBRARY_DIR})
FIND_LIBRARY(QT_QTGUI_LIBRARY NAMES QtGui QtGui4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTGUI_LIBRARY)
IF(NOT QT_QTGUI_LIBRARY_DEBUG)
FIND_LIBRARY(QT_QTGUI_LIBRARY_DEBUG QtGui_debug ${QT_LIBRARY_DIR})
FIND_LIBRARY(QT_QTGUI_LIBRARY_DEBUG NAMES QtGui_debug QtGuid4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTGUI_LIBRARY_DEBUG)
# Set QT_QTMOTIF_LIBRARY
IF(NOT QT_QTMOTIF_LIBRARY)
FIND_LIBRARY(QT_QTMOTIF_LIBRARY QtMotif ${QT_LIBRARY_DIR})
FIND_LIBRARY(QT_QTMOTIF_LIBRARY NAMES QtMotif PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTMOTIF_LIBRARY)
IF(NOT QT_QTMOTIF_LIBRARY_DEBUG)
FIND_LIBRARY(QT_QTMOTIF_LIBRARY_DEBUG QtMotif_debug ${QT_LIBRARY_DIR})
FIND_LIBRARY(QT_QTMOTIF_LIBRARY_DEBUG NAMES QtMotif_debug PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTMOTIF_LIBRARY_DEBUG)
# Set QT_QTNETWORK_LIBRARY
IF(NOT QT_QTNETWORK_LIBRARY)
FIND_LIBRARY(QT_QTNETWORK_LIBRARY QtNetwork ${QT_LIBRARY_DIR})
FIND_LIBRARY(QT_QTNETWORK_LIBRARY NAMES QtNetwork QtNetwork4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTNETWORK_LIBRARY)
IF(NOT QT_QTNETWORK_LIBRARY_DEBUG)
FIND_LIBRARY(QT_QTNETWORK_LIBRARY_DEBUG QtNetwork_debug ${QT_LIBRARY_DIR})
FIND_LIBRARY(QT_QTNETWORK_LIBRARY_DEBUG NAMES QtNetwork_debug QtNetworkd4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTNETWORK_LIBRARY_DEBUG)
# Set QT_QTNSPLUGIN_LIBRARY
IF(NOT QT_QTNSPLUGIN_LIBRARY)
FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY QtNsPlugin ${QT_LIBRARY_DIR})
FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY NAMES QtNsPlugin PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTNSPLUGIN_LIBRARY)
IF(NOT QT_QTNSPLUGIN_LIBRARY_DEBUG)
FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY_DEBUG QtNsPlugin_debug ${QT_LIBRARY_DIR})
FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY_DEBUG NAMES QtNsPlugin_debug PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTNSPLUGIN_LIBRARY_DEBUG)
# Set QT_QTOPENGL_LIBRARY
IF(NOT QT_QTOPENGL_LIBRARY)
FIND_LIBRARY(QT_QTOPENGL_LIBRARY QtOpenGL ${QT_LIBRARY_DIR})
FIND_LIBRARY(QT_QTOPENGL_LIBRARY NAMES QtOpenGL QtOpenGL4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTOPENGL_LIBRARY)
IF(NOT QT_QTOPENGL_LIBRARY_DEBUG)
FIND_LIBRARY(QT_QTOPENGL_LIBRARY_DEBUG QtOpenGL_debug ${QT_LIBRARY_DIR})
FIND_LIBRARY(QT_QTOPENGL_LIBRARY_DEBUG NAMES QtOpenGL_debug QtOpenGLd4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTOPENGL_LIBRARY_DEBUG)
# Set QT_QTSQL_LIBRARY
IF(NOT QT_QTSQL_LIBRARY)
FIND_LIBRARY(QT_QTSQL_LIBRARY QtSql ${QT_LIBRARY_DIR})
FIND_LIBRARY(QT_QTSQL_LIBRARY NAMES QtSql QtSql4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTSQL_LIBRARY)
IF(NOT QT_QTSQL_LIBRARY_DEBUG)
FIND_LIBRARY(QT_QTSQL_LIBRARY_DEBUG QtSql_debug ${QT_LIBRARY_DIR})
FIND_LIBRARY(QT_QTSQL_LIBRARY_DEBUG NAMES QtSql_debug QtSqld4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTSQL_LIBRARY_DEBUG)
# Set QT_QTXML_LIBRARY
IF(NOT QT_QTXML_LIBRARY)
FIND_LIBRARY(QT_QTXML_LIBRARY QtXml ${QT_LIBRARY_DIR})
FIND_LIBRARY(QT_QTXML_LIBRARY NAMES QtXml QtXml4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTXML_LIBRARY)
IF(NOT QT_QTXML_LIBRARY_DEBUG)
FIND_LIBRARY(QT_QTXML_LIBRARY_DEBUG QtXml_debug ${QT_LIBRARY_DIR})
FIND_LIBRARY(QT_QTXML_LIBRARY_DEBUG NAMES QtXml_debug QtXmld4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTXML_LIBRARY_DEBUG)
# Make variables changeble to the advanced user
@ -730,6 +734,77 @@ MARK_AS_ADVANCED(
QT_MOC_EXECUTABLE
QT_RCC_EXECUTABLE )
######################################
#
# Macros for building Qt files
#
######################################
# QT4_WRAP_CPP(outfiles inputfile ... )
# TODO perhaps add support for -D, -U and other minor options
MACRO(QT4_WRAP_CPP outfiles )
# get include dirs
GET_DIRECTORY_PROPERTY(moc_includes_tmp INCLUDE_DIRECTORIES)
SET(moc_includes)
FOREACH(it ${moc_includes_tmp})
SET(moc_includes ${moc_includes} "-I${it}")
ENDFOREACH(it)
FOREACH(it ${ARGN})
GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
SET(infile ${CMAKE_CURRENT_SOURCE_DIR}/${it})
SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/moc_${outfile}.cxx)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_MOC_EXECUTABLE}
ARGS ${moc_includes} -o ${outfile} ${infile}
MAIN_DEPENDENCY ${infile})
SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH(it)
ENDMACRO(QT4_WRAP_CPP)
# QT4_WRAP_UI(outfiles inputfile ... )
MACRO(QT4_WRAP_UI outfiles )
FOREACH(it ${ARGN})
GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
SET(infile ${CMAKE_CURRENT_SOURCE_DIR}/${it})
SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_UIC_EXECUTABLE}
ARGS -o ${outfile} ${infile}
MAIN_DEPENDENCY ${infile})
SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH(it)
ENDMACRO(QT4_WRAP_UI)
# QT4_ADD_RESOURCE(outfiles inputfile ... )
# TODO perhaps consider adding support for compression and root options to rcc
MACRO(QT4_ADD_RESOURCES outfiles )
FOREACH(it ${ARGN})
GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE)
SET(infile ${CMAKE_CURRENT_SOURCE_DIR}/${it})
SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx)
ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
COMMAND ${QT_RCC_EXECUTABLE}
ARGS -name ${outfilename} -o ${outfile} ${infile}
MAIN_DEPENDENCY ${infile} )
SET(${outfiles} ${${outfiles}} ${outfile})
ENDFOREACH(it)
ENDMACRO(QT4_ADD_RESOURCES)
######################################
#
# deside if Qt got found