From 63d64d5780aa189324800e70feb6345a73b8e8a3 Mon Sep 17 00:00:00 2001 From: Ian Scott Date: Mon, 2 Sep 2002 07:03:43 -0400 Subject: Define a single expected format for the values defined in every FindXXX.cmake file. Upgrade all the QT functionality to use the new FindXXX.cmake format Add a module for AVIFile. --- Modules/FindAVIFile.cmake | 40 ++++++++++++++++++ Modules/FindQt.cmake | 94 ++++++++++++++++++++++++++++--------------- Modules/LinkQT.cmake | 12 ++---- Modules/readme.txt | 18 +++++++++ Source/cmQTWrapCPPCommand.cxx | 2 +- Source/cmQTWrapUICommand.cxx | 4 +- 6 files changed, 125 insertions(+), 45 deletions(-) create mode 100644 Modules/FindAVIFile.cmake create mode 100644 Modules/readme.txt diff --git a/Modules/FindAVIFile.cmake b/Modules/FindAVIFile.cmake new file mode 100644 index 0000000..157d08a --- /dev/null +++ b/Modules/FindAVIFile.cmake @@ -0,0 +1,40 @@ +# Locate AVIFILE library and include paths + +# AVIFILE (http://avifile.sourceforge.net/ )is a set of library for i386 machines +# to use various AVI codecs. Support is limited beyond Linux. Windows +# provides native AVI support, and so doesn't need this library. + +# This module defines +# AVIFILE_INCLUDE_DIR, where to find avifile.h , etc. +# AVIFILE_LIBRARIES, the libraries to link against to use AVIFILE +# AVIFILE_DEFINITIONS, definitions to use when compiling code that uses AVIFILE. +# AVIFILE_FOUND, If false, do try to use AVIFILE. + +IF (UNIX) + + FIND_PATH(AVIFILE_INCLUDE_DIR avifile.h + /usr/local/avifile/include + /usr/local/include/avifile + /usr/include + ) + + FIND_LIBRARY(AVIFILE_AVIPLAY_LIBRARY aviplay + /usr/local/avifile/lib + /usr/local/lib + /usr/lib + ) + +ENDIF (UNIX) + +SET (AVIFILE_FOUND "NO") + +IF(AVIFILE_INCLUDE_DIR) + IF(AVIFILE_AVIPLAY_LIBRARY) + SET( AVIFILE_LIBRARIES ${AVIFILE_AVIPLAY_LIBRARY} ) + SET( AVIFILE_FOUND "YES" ) + SET( AVIFILE_DEFINITIONS "") + + ENDIF(AVIFILE_AVIPLAY_LIBRARY) +ENDIF(AVIFILE_INCLUDE_DIR) + + diff --git a/Modules/FindQt.cmake b/Modules/FindQt.cmake index c82e32a..d7a575e 100644 --- a/Modules/FindQt.cmake +++ b/Modules/FindQt.cmake @@ -1,18 +1,22 @@ # Locate Qt include paths and libraries # This module defines -# QT_INCLUDE_PATH, where to find qt.h, etc. -# QT_QT_LIBRARY, where to find the qt library -# QT_MOC_EXE, where to find the moc tool -# QT_UIC_EXE, where to find the uic tool -# USE_QT_FILE, a file for any CMakeLists.txt file to include to actually link against qt -# QT_WRAP_CPP, This allows the QT_WRAP_CPP command to work. -# QT_WRAP_UI, This allows the QT_WRAP_UI command to work. - +# QT_INCLUDE_DIR, where to find qt.h, etc. +# QT_LIBRARIES, the libraries to link against to use Qt. +# QT_DEFINITIONS, definitions to use when compiling code that uses Qt. +# QT_WRAP_CPP, If false, don't use QT_WRAP_CPP command. +# QT_WRAP_UI, If false, don't use QT_WRAP_UI command. +# QT_FOUND, If false, do try to use Qt. + +# also defined, but not for general use are +# QT_MOC_EXECUTABLE, where to find the moc tool. +# QT_UIC_EXECUTABLE, where to find the uic tool. +# QT_QT_LIBRARY, where to find the Qt library. +# QT_QTMAIN_LIBRARY, where to find the qtmain library. This is only required by Qt3 on Windows. IF (UNIX) - FIND_PATH(QT_INCLUDE_PATH qt.h + FIND_PATH(QT_INCLUDE_DIR qt.h ${QTDIR}/include /usr/local/qt/include /usr/local/include @@ -26,12 +30,12 @@ IF (UNIX) /usr/lib ) - FIND_FILE(QT_MOC_EXE moc + FIND_FILE(QT_MOC_EXECUTABLE moc ${QTDIR}/bin ${path} ) - FIND_FILE(QT_UIC_EXE uic + FIND_FILE(QT_UIC_EXECUTABLE uic ${QTDIR}/bin ${path} ) @@ -42,35 +46,59 @@ IF (WIN32) # Not sure where to look for Qt under windows # Assume that QTDIR has been set - FIND_PATH(QT_INCLUDE_PATH qt.h - ${QTDIR}/include - ) + FIND_PATH(QT_INCLUDE_DIR qt.h + ${QTDIR}/include C:/Progra~1/qt/include) ) FIND_LIBRARY(QT_QT_LIBRARY qt - ${QTDIR}/lib - ) + ${QTDIR}/lib C:/Progra~1/qt/lib ) - FIND_FILE(QT_MOC_EXE moc.exe - ${QTDIR}/bin - ${path} - ) + FIND_LIBRARY(QT_QTMAIN_LIBRARY qtmain + ${QTDIR}/lib C:/Progra~1/qt/lib ) - FIND_FILE(QT_UIC_EXE uic.exe - ${QTDIR}/bin - ${path} - ) + FIND_FILE(QT_MOC_EXECUTABLE moc.exe + ${QTDIR}/bin C:/Progra~1/qt/bin + ${path} ) -ENDIF (WIN32) + FIND_FILE(QT_UIC_EXECUTABLE uic.exe + ${QTDIR}/bin C:/Progra~1/qt/bin + ${path} ) - -IF (QT_MOC_EXE) - SET ( QT_WRAP_CPP 1 CACHE BOOL "Can we honour the QT_WRAP_CPP command" ) -ENDIF (QT_MOC_EXE) - -IF (QT_UIC_EXE) - SET ( QT_WRAP_UI 1 CACHE BOOL "Can we honour the QT_WRAP_UI command" ) -ENDIF (QT_UIC_EXE) +ENDIF (WIN32) +IF (QT_MOC_EXECUTABLE) + SET ( QT_WRAP_CPP "YES") +ENDIF (QT_MOC_EXECUTABLE) + +IF (QT_UIC_EXECUTABLE) + SET ( QT_WRAP_UI "YES") +ENDIF (QT_UIC_EXECUTABLE) + + +IF(QT_INCLUDE_DIR) + IF(QT_QT_LIBRARY) + SET( QT_LIBRARIES ${QT_LIBRARIES} ${QT_QT_LIBRARY} ) + SET( QT_FOUND "YES" ) + SET( QT_DEFINITIONS "") + + IF (WIN32) + IF (QT_QTMAIN_LIBRARY) + # for version 3 + SET (QT_DEFINITIONS -DQT_DLL) + SET (QT_LIBRARIES imm32.lib ${QT_QT_LIBRARY} ${QT_QTMAIN_LIBRARY} ) + ELSE (QT_QTMAIN_LIBRARY) + # for version 2 + SET (QT_LIBRARIES imm32.lib ws2_32.lib ${QT_QT_LIBRARY} ) + ENDIF (QT_QTMAIN_LIBRARY) + ELSE (WIN32) + SET (QT_LIBRARIES ${QT_QT_LIBRARY} ) + ENDIF (WIN32) + +# Backwards compatibility for CMake1.4 and 1.2 + SET (QT_MOC_EXE ${QT_MOC_EXECUTABLE} ) + SET (QT_UIC_EXE ${QT_UIC_EXECUTABLE} ) + + ENDIF(QT_QT_LIBRARY) +ENDIF(QT_INCLUDE_DIR) diff --git a/Modules/LinkQT.cmake b/Modules/LinkQT.cmake index 213c1af..f62c326 100644 --- a/Modules/LinkQT.cmake +++ b/Modules/LinkQT.cmake @@ -1,10 +1,4 @@ -# Link in QT +# Use of this file is deprecated. +# Replace any lines that include this file with the line below. - -IF (WIN32) - LINK_LIBRARIES( imm32.lib ws2_32.lib) -#Ensure that qt.lib is last -ENDIF (WIN32) - - -LINK_LIBRARIES( ${QT_QT_LIBRARY}) +LINK_LIBRARIES( ${QT_LIBRARIES}) diff --git a/Modules/readme.txt b/Modules/readme.txt new file mode 100644 index 0000000..57e7916 --- /dev/null +++ b/Modules/readme.txt @@ -0,0 +1,18 @@ +Note to authors of FindXXX.cmake files + +We would like all FindXXX.cmake files to produce consistent variable names. + +XXX_INCLUDE_DIR, Where to find xxx.h, etc. +XXX_LIBRARIES, The libraries to link against to use XXX. These should include full paths. +XXX_DEFINITIONS, Definitions to use when compiling code that uses XXX. +XXX_EXECUTABLE, Where to find the XXX tool. +XXX_YYY_EXECUTABLE, Where to find the YYY tool that comes with XXX. +XXX_ROOT_DIR, Where to find the home directory of XXX. +XXX_FOUND, Set to false if we haven't found, or don't want to use XXX. + + +You do not have to provide all of the above variables. You should provide XXX_FOUND under most circumstances. If XXX is a library, then XXX_INCLUDE_DIR, XXX_LIBRARIES, and XXX_DEFINITIONS should also be defined. + +Try to keep as many options as possible out of the cache, leaving at least one option which can be used to disable use of the module, or find a lost library (e.g. XXX_ROOT_DIR) + +If you need other commands to do special things (e.g. the QT_WRAP_UI setting in FindQt.cmake) then it should still begin with XXX_. This gives a sort of namespace effect. diff --git a/Source/cmQTWrapCPPCommand.cxx b/Source/cmQTWrapCPPCommand.cxx index 837e153..e74b001 100644 --- a/Source/cmQTWrapCPPCommand.cxx +++ b/Source/cmQTWrapCPPCommand.cxx @@ -99,7 +99,7 @@ void cmQTWrapCPPCommand::FinalPass() // first we add the rules for all the .h to Moc files size_t lastClass = m_WrapClasses.size(); std::vector depends; - std::string moc_exe = "${QT_MOC_EXE}"; + std::string moc_exe = "${QT_MOC_EXECUTABLE}"; // wrap all the .h files depends.push_back(moc_exe); diff --git a/Source/cmQTWrapUICommand.cxx b/Source/cmQTWrapUICommand.cxx index dd4e3a6..8e3827e 100644 --- a/Source/cmQTWrapUICommand.cxx +++ b/Source/cmQTWrapUICommand.cxx @@ -118,8 +118,8 @@ void cmQTWrapUICommand::FinalPass() // first we add the rules for all the .ui to .h and .cxx files size_t lastHeadersClass = m_WrapHeadersClasses.size(); std::vector depends; - std::string uic_exe = "${QT_UIC_EXE}"; - std::string moc_exe = "${QT_MOC_EXE}"; + std::string uic_exe = "${QT_UIC_EXECUTABLE}"; + std::string moc_exe = "${QT_MOC_EXECUTABLE}"; // wrap all the .h files -- cgit v0.12