diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2006-04-28 13:00:10 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2006-04-28 13:00:10 (GMT) |
commit | e841dde6c3a9229d53c8d2fdf00ce5073cadf016 (patch) | |
tree | fea3828f9eecd82116c1cda09429f99d7dd81d16 | |
parent | e6d820ed49dfa56f7ed7df2fa09db7828a57fcae (diff) | |
download | CMake-e841dde6c3a9229d53c8d2fdf00ce5073cadf016.zip CMake-e841dde6c3a9229d53c8d2fdf00ce5073cadf016.tar.gz CMake-e841dde6c3a9229d53c8d2fdf00ce5073cadf016.tar.bz2 |
ENH: merge changes from main tree
24 files changed, 886 insertions, 496 deletions
diff --git a/ChangeLog.manual b/ChangeLog.manual index cd6a16b..9ed3b24 100644 --- a/ChangeLog.manual +++ b/ChangeLog.manual @@ -1,5 +1,13 @@ Changes in CMake 2.4.1 +* Many updates and fixes for FindQt4.cmake + +* Fix CMAKE_REQUIRED_FLAGS in CheckCXXSourceCompiles.cmake + +* Handle running make from a symlinked build tree + +* Automatic color ouput detection for shells building with make + * Kdevelop generator handles CMakeFiles directory better * add correct depend information for fluid diff --git a/Docs/cmake-mode.el b/Docs/cmake-mode.el index abfe1e8..160f0ec 100644 --- a/Docs/cmake-mode.el +++ b/Docs/cmake-mode.el @@ -11,47 +11,59 @@ ; PURPOSE. See the above copyright notices for more information. ; ;============================================================================= -; cmake-mode.el = Emacs major mode for editing CMake listfiles. - -; Add cmake listfile names to the mode list. -(setq auto-mode-alist - (append - '(("CMakeLists\\.txt\\'" . cmake-mode)) - '(("\\.cmake\\'" . cmake-mode)) - auto-mode-alist)) -; Note, add the above setq auto-mode-alist to your .emacs -; along with the following to have the mode loaded when -; a CMakeLists.txt or *.cmake file is loaded in emacs. -; (autoload 'cmake-mode "~/CMake/Docs/cmake-mode.el" t) - -; Default indentation increment. -(defvar cmake-tab-width 2) +;;; cmake-mode.el --- major-mode for editing CMake sources -; Regular expressions used by line indentation function. +;------------------------------------------------------------------------------ -(defconst cmake-regex-blank "^[ \t]*$") +;;; Commentary: + +;; Provides syntax highlighting and indentation for CMakeLists.txt and +;; *.cmake source files. +;; +;; Add this code to your .emacs file to use the mode: +;; +;; (setq load-path (cons (expand-file-name "/dir/with/cmake-mode") load-path)) +;; (require 'cmake-mode) +;; (setq auto-mode-alist +;; (append '(("CMakeLists\\.txt\\'" . cmake-mode) +;; ("\\.cmake\\'" . cmake-mode)) +;; auto-mode-alist)) + +;------------------------------------------------------------------------------ +;;; Code: + +;; +;; Regular expressions used by line indentation function. +;; +(defconst cmake-regex-blank "^[ \t]*$") (defconst cmake-regex-comment "#.*") (defconst cmake-regex-paren-left "(") (defconst cmake-regex-paren-right ")") -(defconst cmake-regex-argument-quoted "\"\\([^\"\\\\]\\|\\\\\\(.\\|\n\\)\\)*\"") -(defconst cmake-regex-argument-unquoted "\\([^ \t\r\n()#\"\\\\]\\|\\\\.\\)\\([^ \t\r\n()#\\\\]\\|\\\\.\\)*") - +(defconst cmake-regex-argument-quoted + "\"\\([^\"\\\\]\\|\\\\\\(.\\|\n\\)\\)*\"") +(defconst cmake-regex-argument-unquoted + "\\([^ \t\r\n()#\"\\\\]\\|\\\\.\\)\\([^ \t\r\n()#\\\\]\\|\\\\.\\)*") (defconst cmake-regex-token (concat "\\(" cmake-regex-comment "\\|" cmake-regex-paren-left "\\|" cmake-regex-paren-right "\\|" cmake-regex-argument-unquoted "\\|" cmake-regex-argument-quoted "\\)")) - (defconst cmake-regex-indented (concat "^\\(" cmake-regex-token "\\|" "[ \t\r\n]" "\\)*")) +(defconst cmake-regex-block-open + "^\\(IF\\|MACRO\\|FOREACH\\|ELSE\\|WHILE\\)$") +(defconst cmake-regex-block-close + "^[ \t]*\\(ENDIF\\|ENDFOREACH\\|ENDMACRO\\|ELSE\\|ENDWHILE\\)[ \t]*(") -(defconst cmake-regex-block-open "^\\(IF\\|MACRO\\|FOREACH\\|ELSE\\|WHILE\\)$") -(defconst cmake-regex-block-close "^[ \t]*\\(ENDIF\\|ENDFOREACH\\|ENDMACRO\\|ELSE\\|ENDWHILE\\)[ \t]*(") +;------------------------------------------------------------------------------ +;; +;; Helper functions for line indentation function. +;; (defun cmake-line-starts-inside-string () "Determine whether the beginning of the current line is in a string." (if (save-excursion @@ -82,7 +94,11 @@ ) ) -; Line indentation function. +;------------------------------------------------------------------------------ + +;; +;; Line indentation function. +;; (defun cmake-indent () "Indent current line as CMAKE code." (interactive) @@ -134,30 +150,40 @@ ) ) -; (regexp-opt '("ADD_CUSTOM_COMMAND" "ADD_CUSTOM_TARGET" "ADD_DEFINITIONS" "ADD_DEPENDENCIES" "ADD_SUBDIRECTORY" "ADD_EXECUTABLE" "ADD_LIBRARY" "ADD_TEST" "AUX_SOURCE_DIRECTORY" "BUILD_COMMAND" "BUILD_NAME" "CMAKE_MINIMUM_REQUIRED" "CONFIGURE_FILE" "CREATE_TEST_SOURCELIST" "CREATE_TEST_SOURCELIST " "ELSE" "ENABLE_TESTING" "ENABLE_TESTING " "ENDFOREACH" "ENDIF" "ENDMACRO" "ENDWHILE" "EXEC_PROGRAM" "EXECUTE_PROCESS" "EXPORT_LIBRARY_DEPENDENCIES" "FIND_FILE" "FIND_LIBRARY" "FIND_PACKAGE" "FIND_PATH" "FIND_PROGRAM" "FLTK_WRAP_UI" "FOREACH" "GET_CMAKE_PROPERTY" "GET_DIRECTORY_PROPERTY" "GET_FILENAME_COMPONENT" "GET_SOURCE_FILE_PROPERTY" "GET_TARGET_PROPERTY" "IF" "INCLUDE" "INCLUDE_DIRECTORIES" "INCLUDE_EXTERNAL_MSPROJECT" "INCLUDE_REGULAR_EXPRESSION" "INSTALL" "INSTALL_FILES" "INSTALL_PROGRAMS" "INSTALL_TARGETS" "ITK_WRAP_TCL" "LINK_DIRECTORIES" "LINK_LIBRARIES" "LIST" "LOAD_CACHE" "LOAD_COMMAND" "MACRO" "MAKE_DIRECTORY" "MARK_AS_ADVANCED" "MESSAGE" "OPTION" "OUTPUT_REQUIRED_FILES" "PROJECT" "QT_WRAP_CPP" "QT_WRAP_UI" "REMOVE" "SEPARATE_ARGUMENTS" "SET" "SET_DIRECTORY_PROPERTIES" "SET_SOURCE_FILES_PROPERTIES" "SET_TARGET_PROPERTIES" "SITE_NAME" "SOURCE_GROUP" "STRING" "SUBDIRS" "SUBDIR_DEPENDS" "TARGET_LINK_LIBRARIES" "TRY_COMPILE" "TRY_RUN" "USE_MANGLED_MESA" "UTILITY_SOURCE" "VARIABLE_REQUIRES" "VTK_MAKE_INSTANTIATOR" "VTK_MAKE_INSTANTIATOR " "VTK_WRAP_JAVA" "VTK_WRAP_PYTHON" "VTK_WRAP_TCL" "WHILE" "WRITE_FILE" "add_custom_command" "add_custom_target" "add_definitions" "add_dependencies" "add_subdirectory" "add_executable" "add_library" "add_test" "aux_source_directory" "build_command" "build_name" "cmake_minimum_required" "configure_file" "create_test_sourcelist" "create_test_sourcelist " "else" "enable_testing" "enable_testing " "endforeach" "endif" "endmacro" "endwhile" "exec_program" "export_library_dependencies" "find_file" "find_library" "find_package" "find_path" "find_program" "fltk_wrap_ui" "foreach" "get_cmake_property" "get_directory_property" "get_filename_component" "get_source_file_property" "get_target_property" "if" "include" "include_directories" "include_external_msproject" "include_regular_expression" "install_files" "install_programs" "install_targets" "itk_wrap_tcl" "link_directories" "link_libraries" "load_cache" "load_command" "macro" "make_directory" "mark_as_advanced" "message" "option" "output_required_files" "project" "qt_wrap_cpp" "qt_wrap_ui" "remove" "separate_arguments" "set" "set_directory_properties" "set_source_files_properties" "set_target_properties" "site_name" "source_group" "string" "subdirs" "subdir_depends" "target_link_libraries" "try_compile" "try_run" "use_mangled_mesa" "utility_source" "variable_requires" "vtk_make_instantiator" "vtk_make_instantiator " "vtk_wrap_java" "vtk_wrap_python" "vtk_wrap_tcl" "while" "write_file") t) -; run the above in the scatch buffer to generate the string that -; goes in (list '("the regexp string" . font-lock-function-name-face) -; the string will be available in the *Messages* buffer - -; Define keyword highlighting. -(defconst cmake-font-lock-defaults - (list -;; '("(" . font-lock-keyword-face) - '("\\(A\\(?:DD_\\(?:CUSTOM_\\(?:COMMAND\\|TARGET\\)\\|DE\\(?:\\(?:FINITION\\|PENDENCIE\\)S\\)\\|EXECUTABLE\\|LIBRARY\\|SUBDIRECTORY\\|TEST\\)\\|UX_SOURCE_DIRECTORY\\)\\|BUILD_\\(?:COMMAND\\|NAME\\)\\|C\\(?:MAKE_MINIMUM_REQUIRED\\|ONFIGURE_FILE\\|REATE_TEST_SOURCELIST ?\\)\\|E\\(?:LSE\\|N\\(?:ABLE_TESTING ?\\|D\\(?:FOREACH\\|IF\\|MACRO\\|WHILE\\)\\)\\|X\\(?:EC\\(?:UTE_PROCESS\\|_PROGRAM\\)\\|PORT_LIBRARY_DEPENDENCIES\\)\\)\\|F\\(?:IND_\\(?:FILE\\|LIBRARY\\|P\\(?:A\\(?:CKAGE\\|TH\\)\\|ROGRAM\\)\\)\\|LTK_WRAP_UI\\|OREACH\\)\\|GET_\\(?:CMAKE_PROPERTY\\|DIRECTORY_PROPERTY\\|FILENAME_COMPONENT\\|\\(?:SOURCE_FILE\\|TARGET\\)_PROPERTY\\)\\|I\\(?:F\\|N\\(?:CLUDE\\(?:_\\(?:DIRECTORIES\\|EXTERNAL_MSPROJECT\\|REGULAR_EXPRESSION\\)\\)?\\|STALL\\(?:_\\(?:\\(?:FILE\\|PROGRAM\\|TARGET\\)S\\)\\)?\\)\\|TK_WRAP_TCL\\)\\|L\\(?:I\\(?:NK_\\(?:\\(?:DIRECTO\\|LIBRA\\)RIES\\)\\|ST\\)\\|OAD_C\\(?:ACHE\\|OMMAND\\)\\)\\|M\\(?:A\\(?:CRO\\|KE_DIRECTORY\\|RK_AS_ADVANCED\\)\\|ESSAGE\\)\\|O\\(?:PTION\\|UTPUT_REQUIRED_FILES\\)\\|PROJECT\\|QT_WRAP_\\(?:CPP\\|UI\\)\\|REMOVE\\|S\\(?:E\\(?:PARATE_ARGUMENTS\\|T\\(?:_\\(?:\\(?:DIRECTORY\\|SOURCE_FILES\\|TARGET\\)_PROPERTIES\\)\\)?\\)\\|ITE_NAME\\|OURCE_GROUP\\|TRING\\|UBDIR\\(?:\\(?:_DEPEND\\)?S\\)\\)\\|T\\(?:ARGET_LINK_LIBRARIES\\|RY_\\(?:COMPILE\\|RUN\\)\\)\\|U\\(?:SE_MANGLED_MESA\\|TILITY_SOURCE\\)\\|V\\(?:ARIABLE_REQUIRES\\|TK_\\(?:MAKE_INSTANTIATOR ?\\|WRAP_\\(?:JAVA\\|PYTHON\\|TCL\\)\\)\\)\\|W\\(?:\\(?:H\\|RITE_F\\)ILE\\)\\|a\\(?:dd_\\(?:custom_\\(?:command\\|target\\)\\|de\\(?:\\(?:finition\\|pendencie\\)s\\)\\|executable\\|library\\|subdirectory\\|test\\)\\|ux_source_directory\\)\\|build_\\(?:command\\|name\\)\\|c\\(?:make_minimum_required\\|onfigure_file\\|reate_test_sourcelist ?\\)\\|e\\(?:lse\\|n\\(?:able_testing ?\\|d\\(?:foreach\\|if\\|macro\\|while\\)\\)\\|x\\(?:ec_program\\|port_library_dependencies\\)\\)\\|f\\(?:ind_\\(?:file\\|library\\|p\\(?:a\\(?:ckage\\|th\\)\\|rogram\\)\\)\\|ltk_wrap_ui\\|oreach\\)\\|get_\\(?:cmake_property\\|directory_property\\|filename_component\\|\\(?:source_file\\|target\\)_property\\)\\|i\\(?:f\\|n\\(?:clude\\(?:_\\(?:directories\\|external_msproject\\|regular_expression\\)\\)?\\|stall_\\(?:\\(?:file\\|program\\|target\\)s\\)\\)\\|tk_wrap_tcl\\)\\|l\\(?:ink_\\(?:\\(?:directo\\|libra\\)ries\\)\\|oad_c\\(?:ache\\|ommand\\)\\)\\|m\\(?:a\\(?:cro\\|ke_directory\\|rk_as_advanced\\)\\|essage\\)\\|o\\(?:ption\\|utput_required_files\\)\\|project\\|qt_wrap_\\(?:cpp\\|ui\\)\\|remove\\|s\\(?:e\\(?:parate_arguments\\|t\\(?:_\\(?:\\(?:directory\\|source_files\\|target\\)_properties\\)\\)?\\)\\|ite_name\\|ource_group\\|tring\\|ubdir\\(?:\\(?:_depend\\)?s\\)\\)\\|t\\(?:arget_link_libraries\\|ry_\\(?:compile\\|run\\)\\)\\|u\\(?:se_mangled_mesa\\|tility_source\\)\\|v\\(?:ariable_requires\\|tk_\\(?:make_instantiator ?\\|wrap_\\(?:java\\|python\\|tcl\\)\\)\\)\\|w\\(?:\\(?:h\\|rite_f\\)ile\\)\\)" . font-lock-function-name-face) - "Highlighting expressions for CMAKE mode.") +;------------------------------------------------------------------------------ + +;; +;; Keyword highlighting regex-to-face map. +;; +(defconst cmake-font-lock-keywords + (list '("^[ \t]*\\(\\w+\\)[ \t]*(" 1 font-lock-function-name-face)) + "Highlighting expressions for CMAKE mode." ) -; Define a variable to hold the syntax table. -(defvar cmake-mode-syntax-table nil "Syntax table for cmake-mode.") +;------------------------------------------------------------------------------ -; If this mode file is reloaded, we want the syntax table to be -; regenerated when cmake-mode is called. +;; +;; Syntax table for this mode. Initialize to nil so that it is +;; regenerated when the cmake-mode function is called. +;; +(defvar cmake-mode-syntax-table nil "Syntax table for cmake-mode.") (setq cmake-mode-syntax-table nil) -; Let users hook to this mode. +;; +;; User hook entry point. +;; (defvar cmake-mode-hook nil) -; Mode startup function. +;; +;; Indentation increment. +;; +(defvar cmake-tab-width 2) + +;------------------------------------------------------------------------------ + +;; +;; CMake mode startup function. +;; (defun cmake-mode () "Major mode for editing CMake listfiles." (interactive) @@ -176,7 +202,7 @@ ; Setup font-lock mode. (make-local-variable 'font-lock-defaults) - (setq font-lock-defaults '(cmake-font-lock-defaults)) + (setq font-lock-defaults '(cmake-font-lock-keywords)) ; Setup indentation function. (make-local-variable 'indent-line-function) @@ -186,7 +212,10 @@ (make-local-variable 'comment-start) (setq comment-start "#") + ; Run user hooks. (run-hooks 'cmake-mode-hook)) ; This file provides cmake-mode. (provide 'cmake-mode) + +;;; cmake-mode.el ends here diff --git a/Modules/CheckCSourceCompiles.cmake b/Modules/CheckCSourceCompiles.cmake index 35a4bdc..ec74325 100644 --- a/Modules/CheckCSourceCompiles.cmake +++ b/Modules/CheckCSourceCompiles.cmake @@ -36,7 +36,7 @@ MACRO(CHECK_C_SOURCE_COMPILES SOURCE VAR) ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/src.c COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} - CMAKE_FLAGS + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} "${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}" "${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}" OUTPUT_VARIABLE OUTPUT) diff --git a/Modules/CheckCXXSourceCompiles.cmake b/Modules/CheckCXXSourceCompiles.cmake index 30a97af..52a2217 100644 --- a/Modules/CheckCXXSourceCompiles.cmake +++ b/Modules/CheckCXXSourceCompiles.cmake @@ -36,7 +36,7 @@ MACRO(CHECK_CXX_SOURCE_COMPILES SOURCE VAR) ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/src.cxx COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} - CMAKE_FLAGS + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} "${CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES}" "${CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES}" OUTPUT_VARIABLE OUTPUT) diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index cec75ab..1bab008 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -1,5 +1,7 @@ # - Find QT 4 # This module can be used to find Qt4. +# The most important issue is that the Qt4 qmake is available via the system path. +# This qmake is then used to detect basically everything else. # This module defines a number of key variables and macros. First is # QT_USE_FILE which is the path to a CMake file that can be included to compile # Qt 4 applications and libraries. By default, the QtCore and QtGui @@ -11,17 +13,21 @@ # QT_USE_QTASSISTANT # QT_USE_QTDESIGNER # QT_USE_QTMOTIF +# QT_USE_QTMAIN # QT_USE_QTNETWORK # QT_USE_QTNSPLUGIN # QT_USE_QTOPENGL # QT_USE_QTSQL # QT_USE_QTXML +# # All the libraries required are stored in a variable called QT_LIBRARIES. # Add this variable to your TARGET_LINK_LIBRARIES. # # macro QT4_WRAP_CPP(outfiles inputfile ... ) # macro QT4_WRAP_UI(outfiles inputfile ... ) # macro QT4_ADD_RESOURCE(outfiles inputfile ... ) +# macro QT4_AUTOMOC(inputfile ... ) +# macro QT4_GENERATE_MOC(inputfile outputfile ) # # QT_FOUND If false, don't try to use Qt. # QT4_FOUND If false, don't try to use Qt 4. @@ -37,13 +43,13 @@ # QT_QTOPENGL_FOUND True if QtOpenGL was found. # QT_QTSQL_FOUND True if QtSql was found. # 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_DEFINITIONS Definitions to use when compiling code that -# uses Qt. +# QT_DEFINITIONS Definitions to use when compiling code that uses Qt. # # QT_INCLUDES List of paths to all include directories of -# Qt4 QT_INCLUDE_DIR, QT_QT_INCLUDE_DIR, -# and QT_QTGUI_INCLUDE_DIR are +# Qt4 QT_INCLUDE_DIR and QT_QTCORE_INCLUDE_DIR are # always in this variable even if NOTFOUND, # all other INCLUDE_DIRS are # only added if they are found. @@ -61,39 +67,87 @@ # QT_QTOPENGL_INCLUDE_DIR Path to "include/QtOpenGL" # QT_QTSQL_INCLUDE_DIR Path to "include/QtSql" # QT_QTXML_INCLUDE_DIR Path to "include/QtXml" +# QT_QTSVG_INCLUDE_DIR Path to "include/QtSvg" +# QT_QTTEST_INCLUDE_DIR Path to "include/QtTest" # # QT_LIBRARY_DIR Path to "lib" of Qt4 # -# QT_QT3SUPPORT_LIBRARY Fullpath to Qt3Support library -# QT_QTASSISTANT_LIBRARY Fullpath to QtAssistant library -# QT_QTCORE_LIBRARY Fullpath to QtCore library -# QT_QTDESIGNER_LIBRARY Fullpath to QtDesigner library -# QT_QTGUI_LIBRARY Fullpath to QtGui library -# QT_QTMOTIF_LIBRARY Fullpath to QtMotif library -# QT_QTNETWORK_LIBRARY Fullpath to QtNetwork library -# QT_QTNSPLUGIN_LIBRARY Fullpath to QtNsPlugin library -# QT_QTOPENGL_LIBRARY Fullpath to QtOpenGL library -# QT_QTSQL_LIBRARY Fullpath to QtSql library -# QT_QTXML_LIBRARY Fullpath to QtXml library +# For every library of Qt there are three variables: +# QT_QTFOO_LIBRARY_RELEASE, which contains the full path to the release version +# QT_QTFOO_LIBRARY_DEBUG, which contains the full path to the debug version +# QT_QTFOO_LIBRARY, the full path to the release version if available, otherwise to the debug version +# +# So there are the following variables: +# The Qt3Support library: QT_QT3SUPPORT_LIBRARY +# QT_QT3SUPPORT_LIBRARY_RELEASE +# QT_QT3SUPPORT_DEBUG +# +# The QtAssistant library: QT_QTASSISTANT_LIBRARY +# QT_QTASSISTANT_LIBRARY_RELEASE +# QT_QTASSISTANT_LIBRARY_DEBUG +# +# The QtCore library: QT_QTCORE_LIBRARY +# QT_QTCORE_LIBRARY_RELEASE +# QT_QTCORE_LIBRARY_DEBUG +# +# The QtDesigner library: QT_QTDESIGNER_LIBRARY +# QT_QTDESIGNER_LIBRARY_RELEASE +# QT_QTDESIGNER_LIBRARY_DEBUG +# +# The QtGui library: QT_QTGUI_LIBRARY +# QT_QTGUI_LIBRARY_RELEASE +# QT_QTGUI_LIBRARY_DEBUG +# +# The QtMotif library: QT_QTMOTIF_LIBRARY +# QT_QTMOTIF_LIBRARY_RELEASE +# QT_QTMOTIF_LIBRARY_DEBUG +# +# The QtNetwork library: QT_QTNETWORK_LIBRARY +# QT_QTNETWORK_LIBRARY_RELEASE +# QT_QTNETWORK_LIBRARY_DEBUG +# +# The QtNsPLugin library: QT_QTNSPLUGIN_LIBRARY +# QT_QTNSPLUGIN_LIBRARY_RELEASE +# QT_QTNSPLUGIN_LIBRARY_DEBUG +# +# The QtOpenGL library: QT_QTOPENGL_LIBRARY +# QT_QTOPENGL_LIBRARY_RELEASE +# QT_QTOPENGL_LIBRARY_DEBUG +# +# The QtSql library: QT_QTSQL_LIBRARY +# QT_QTSQL_LIBRARY_RELEASE +# QT_QTSQL_LIBRARY_DEBUG +# +# The QtXml library: QT_QTXML_LIBRARY +# QT_QTXML_LIBRARY_RELEASE +# QT_QTXML_LIBRARY_DEBUG +# +# The QtSvg library: QT_QTSVG_LIBRARY +# QT_QTSVG_LIBRARY_RELEASE +# QT_QTSVG_LIBRARY_DEBUG +# +# The QtTest library: QT_QTTEST_LIBRARY +# QT_QTTEST_LIBRARY_RELEASE +# QT_QTTEST_LIBRARY_DEBUG +# +# The qtmain library for Windows QT_QTMAIN_LIBRARY +# QT_QTMAIN_LIBRARY_RELEASE +# QT_QTMAIN_LIBRARY_DEBUG +# +#The QtUiTools library: QT_QTUITOOLS_LIBRARY +# QT_QTUITOOLS_LIBRARY_RELEASE +# QT_QTUITOOLS_LIBRARY_DEBUG # -# QT_QT3SUPPORT_LIBRARY_DEBUG Fullpath to Qt3Support_debug library -# QT_QTASSISTANT_LIBRARY_DEBUG Fullpath to QtAssistant_debug library -# -# QT_QTCORE_LIBRARY_DEBUG Fullpath to QtCore_debug -# QT_QTDESIGNER_LIBRARY_DEBUG Fullpath to QtDesigner_debug -# QT_QTGUI_LIBRARY_DEBUG Fullpath to QtGui_debug -# QT_QTMOTIF_LIBRARY_DEBUG Fullpath to QtMotif_debug -# QT_QTNETWORK_LIBRARY_DEBUG Fullpath to QtNetwork_debug -# QT_QTNSPLUGIN_LIBRARY_DEBUG Fullpath to QtNsPlugin_debug -# QT_QTOPENGL_LIBRARY_DEBUG Fullpath to QtOpenGL_debug -# QT_QTSQL_LIBRARY_DEBUG Fullpath to QtSql_debug -# QT_QTXML_LIBRARY_DEBUG Fullpath to QtXml_debug -# -# also defined, but not for general use are +# 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_UIC3_EXECUTABLE Where to find the uic3 tool. # QT_RCC_EXECUTABLE Where to find the rcc tool # +# QT_DOC_DIR Path to "doc" of Qt4 +# QT_MKSPECS_DIR Path to "mkspecs" of Qt4 +# +# # These are around for backwards compatibility # they will be set # QT_WRAP_CPP Set true if QT_MOC_EXECUTABLE is found @@ -104,8 +158,9 @@ # # These variables are set to "" Because Qt structure changed # (They make no sense in Qt4) -# QT_QT_LIBRARY Qt-Library is now splitt -# QT_QTMAIN_LIBRARY Qt-Library is now splitt +# QT_QT_LIBRARY Qt-Library is now split + +INCLUDE(CheckSymbolExists) SET(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake) @@ -115,35 +170,71 @@ IF (WIN32) SET(QT_DEFINITIONS -DQT_DLL) ENDIF(WIN32) -FILE(GLOB GLOB_TEMP_VAR /usr/local/Trolltech/Qt-4*/) -SET(GLOB_TEMP_VAR) -IF(GLOB_TEMP_VAR) - SET(QT4_PATHS ${QT4_PATHS} ${GLOB_TEMP_VAR}) -ENDIF(GLOB_TEMP_VAR) -SET(GLOB_TEMP_VAR) -FILE(GLOB GLOB_TEMP_VAR /usr/local/qt-x11-commercial-4*/bin/) -IF(GLOB_TEMP_VAR) - SET(QT4_PATHS ${QT4_PATHS} ${GLOB_TEMP_VAR}) -ENDIF(GLOB_TEMP_VAR) # check for qmake -FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake-qt4 qmake PATHS +FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake qmake-qt4 PATHS "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin" "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin" $ENV{QTDIR}/bin - ${QT4_PATHS} ) -IF(QT_QMAKE_EXECUTABLE) - EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} ARGS "-query QT_VERSION" - OUTPUT_VARIABLE QTVERSION) - IF(QTVERSION MATCHES "4.*") +SET(QT4_INSTALLED_VERSION_TOO_OLD FALSE) + + +IF (QT_QMAKE_EXECUTABLE) + + SET(QT4_QMAKE_FOUND FALSE) + + EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION) + + # check that we found the Qt4 qmake, Qt3 qmake output won't match here + STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" qt_version_tmp "${QTVERSION}") + IF (qt_version_tmp) + + # we need at least version 4.0.0 + IF (NOT QT_MIN_VERSION) + SET(QT_MIN_VERSION "4.0.0") + ENDIF (NOT QT_MIN_VERSION) + + #now parse the parts of the user given version string into variables + STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" req_qt_major_vers "${QT_MIN_VERSION}") + IF (NOT req_qt_major_vers) + MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", expected e.g. \"4.0.1\"") + ENDIF (NOT req_qt_major_vers) + + # now parse the parts of the user given version string into variables + STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_qt_major_vers "${QT_MIN_VERSION}") + STRING(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_qt_minor_vers "${QT_MIN_VERSION}") + STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_qt_patch_vers "${QT_MIN_VERSION}") + + IF (NOT req_qt_major_vers EQUAL 4) + MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", major version 4 is required, e.g. \"4.0.1\"") + ENDIF (NOT req_qt_major_vers EQUAL 4) + + # and now the version string given by qmake + STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" found_qt_major_vers "${QTVERSION}") + STRING(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" found_qt_minor_vers "${QTVERSION}") + STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" found_qt_patch_vers "${QTVERSION}") + + # compute an overall version number which can be compared at once + MATH(EXPR req_vers "${req_qt_major_vers}*10000 + ${req_qt_minor_vers}*100 + ${req_qt_patch_vers}") + MATH(EXPR found_vers "${found_qt_major_vers}*10000 + ${found_qt_minor_vers}*100 + ${found_qt_patch_vers}") + + IF (found_vers LESS req_vers) + SET(QT4_QMAKE_FOUND FALSE) + SET(QT4_INSTALLED_VERSION_TOO_OLD TRUE) + ELSE (found_vers LESS req_vers) SET(QT4_QMAKE_FOUND TRUE) - ENDIF(QTVERSION MATCHES "4.*") -ENDIF(QT_QMAKE_EXECUTABLE) + ENDIF (found_vers LESS req_vers) + + ENDIF (qt_version_tmp) + +ENDIF (QT_QMAKE_EXECUTABLE) -IF(QT4_QMAKE_FOUND) +IF (QT4_QMAKE_FOUND) + + # ask qmake for the library dir # Set QT_LIBRARY_DIR - IF(NOT QT_LIBRARY_DIR) + IF (NOT QT_LIBRARY_DIR) EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_LIBS" OUTPUT_VARIABLE QT_LIBRARY_DIR_TMP ) @@ -151,7 +242,7 @@ IF(QT4_QMAKE_FOUND) SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE PATH "Qt library dir") ELSE(EXISTS "${QT_LIBRARY_DIR_TMP}") MESSAGE("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_LIBS as ${QT_LIBRARY_DIR_TMP}") - MESSAGE("Warning: ${QT_LIBRARY_DIR_TMP} does not exist, Qt must not be installed correctly.") + MESSAGE("Warning: ${QT_LIBRARY_DIR_TMP} does NOT exist, Qt must NOT be installed correctly.") ENDIF(EXISTS "${QT_LIBRARY_DIR_TMP}") ENDIF(NOT QT_LIBRARY_DIR) @@ -167,164 +258,215 @@ IF(QT4_QMAKE_FOUND) MARK_AS_ADVANCED(QT_USE_FRAMEWORKS) ENDIF (APPLE) - ######################################## - # - # Setting the INCLUDE-Variables - # - ######################################## + # ask qmake for the binary dir + IF (NOT QT_BINARY_DIR) + EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} + ARGS "-query QT_INSTALL_BINS" + OUTPUT_VARIABLE qt_bins ) + SET(QT_BINARY_DIR ${qt_bins} CACHE INTERNAL "") + ENDIF (NOT QT_BINARY_DIR) + + # ask qmake for the include dir IF (NOT QT_HEADERS_DIR) - # Set QT_QT_INCLUDE_DIR by searching for qglobal.h - IF(QT_QMAKE_EXECUTABLE) EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_HEADERS" OUTPUT_VARIABLE qt_headers ) SET(QT_HEADERS_DIR ${qt_headers} CACHE INTERNAL "") - ENDIF(QT_QMAKE_EXECUTABLE) - ENDIF (NOT QT_HEADERS_DIR) - FILE(GLOB GLOB_TEMP_VAR /usr/local/qt-x11-commercial-3*/include/Qt/) - SET(QT_PATH_INCLUDE ${GLOB_TEMP_VAR}) - FILE(GLOB GLOB_TEMP_VAR /usr/local/Trolltech/Qt-4*/include/Qt/) - SET(QT_PATH_INCLUDE ${GLOB_TEMP_VAR}) - FIND_PATH( QT_QT_INCLUDE_DIR qglobal.h - "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/include/Qt" - ${QT_PATH_INCLUDE} - ${QT_HEADERS_DIR}/Qt + ENDIF(NOT QT_HEADERS_DIR) + + + # ask qmake for the documentation directory + IF (NOT QT_DOC_DIR) + EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} + ARGS "-query QT_INSTALL_DOCS" + OUTPUT_VARIABLE qt_doc_dir ) + SET(QT_DOC_DIR ${qt_doc_dir} CACHE PATH "The location of the Qt docs") + ENDIF (NOT QT_DOC_DIR) + + # ask qmake for the mkspecs directory + IF (NOT QT_MKSPECS_DIR) + EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} + ARGS "-query QMAKE_MKSPECS" + OUTPUT_VARIABLE qt_mkspecs_dir ) + SET(QT_MKSPECS_DIR ${qt_mkspecs_dir} CACHE PATH "The location of the Qt mkspecs") + ENDIF (NOT QT_MKSPECS_DIR) + + ######################################## + # + # Setting the INCLUDE-Variables + # + ######################################## + + FIND_PATH(QT_QTCORE_INCLUDE_DIR QtGlobal + "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/include/QtCore" + ${QT_HEADERS_DIR}/QtCore ${QT_LIBRARY_DIR}/QtCore.framework/Headers - $ENV{QTDIR}/include/Qt - /usr/local/qt/include/Qt - /usr/local/include/Qt - /usr/lib/qt/include/Qt - /usr/include/Qt - /usr/share/qt4/include/Qt + $ENV{QTDIR}/include/QtCore "$ENV{ProgramFiles}/qt/include/Qt" - "C:/Program Files/qt/include/Qt" - /usr/include/qt4/Qt) + ) - # Set QT_INCLUDE_DIR by removine "/Qt" in the string ${QT_QT_INCLUDE_DIR} - IF( QT_QT_INCLUDE_DIR AND NOT QT_INCLUDE_DIR) + # Set QT_INCLUDE_DIR by removine "/QtCore" in the string ${QT_QTCORE_INCLUDE_DIR} + IF( QT_QTCORE_INCLUDE_DIR AND NOT QT_INCLUDE_DIR) IF (QT_USE_FRAMEWORKS) SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR}) ELSE (QT_USE_FRAMEWORKS) - STRING( REGEX REPLACE "/Qt$" "" qt4_include_dir ${QT_QT_INCLUDE_DIR}) + STRING( REGEX REPLACE "/QtCore$" "" qt4_include_dir ${QT_QTCORE_INCLUDE_DIR}) SET( QT_INCLUDE_DIR ${qt4_include_dir} CACHE PATH "") ENDIF (QT_USE_FRAMEWORKS) - ENDIF( QT_QT_INCLUDE_DIR AND NOT QT_INCLUDE_DIR) + ENDIF( QT_QTCORE_INCLUDE_DIR AND NOT QT_INCLUDE_DIR) + IF( NOT QT_INCLUDE_DIR) IF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED) - MESSAGE( FATAL_ERROR "Could not find qglobal.h") + MESSAGE( FATAL_ERROR "Could NOT find QtGlobal header") ENDIF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED) ENDIF( NOT QT_INCLUDE_DIR) + ############################################# + # + # Find out what window system we're using + # + ############################################# + # Save required includes variable + SET(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) + # Add QT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES + SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_INCLUDE_DIR}") + # Check for Window system symbols (note: only one should end up being set) + CHECK_SYMBOL_EXISTS(Q_WS_X11 "QtCore/qglobal.h" Q_WS_X11) + CHECK_SYMBOL_EXISTS(Q_WS_MAC "QtCore/qglobal.h" Q_WS_MAC) + CHECK_SYMBOL_EXISTS(Q_WS_WIN "QtCore/qglobal.h" Q_WS_WIN) + + IF (QT_QTCOPY_REQUIRED) + CHECK_SYMBOL_EXISTS(QT_IS_QTCOPY "QtCore/qglobal.h" QT_KDE_QT_COPY) + IF (NOT QT_IS_QTCOPY) + MESSAGE(FATAL_ERROR "qt-copy is required, but hasn't been found") + ENDIF (NOT QT_IS_QTCOPY) + ENDIF (QT_QTCOPY_REQUIRED) + + # Restore CMAKE_REQUIRED_INCLUDES variable + SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + # + ############################################# + IF (QT_USE_FRAMEWORKS) - SET(QT_DEFINITIONS ${QT_DEFINITIONS} - -F${QT_LIBRARY_DIR} - ) + SET(QT_DEFINITIONS ${QT_DEFINITIONS} -F${QT_LIBRARY_DIR} -L${QT_LIBRARY_DIR} ) ENDIF (QT_USE_FRAMEWORKS) # Set QT_QT3SUPPORT_INCLUDE_DIR - FIND_PATH( QT_QT3SUPPORT_INCLUDE_DIR Qt3Support + FIND_PATH(QT_QT3SUPPORT_INCLUDE_DIR Qt3Support + PATHS ${QT_INCLUDE_DIR}/Qt3Support ${QT_LIBRARY_DIR}/Qt3Support.framework/Headers + NO_DEFAULT_PATH ) - # Set QT_QTCORE_INCLUDE_DIR - FIND_PATH( QT_QTCORE_INCLUDE_DIR QtCore - ${QT_INCLUDE_DIR}/QtCore + # Set QT_QT_INCLUDE_DIR + FIND_PATH(QT_QT_INCLUDE_DIR qglobal.h + PATHS + ${QT_INCLUDE_DIR}/Qt ${QT_LIBRARY_DIR}/QtCore.framework/Headers + NO_DEFAULT_PATH ) # Set QT_QTGUI_INCLUDE_DIR - FIND_PATH( QT_QTGUI_INCLUDE_DIR QtGui + FIND_PATH(QT_QTGUI_INCLUDE_DIR QtGui + PATHS ${QT_INCLUDE_DIR}/QtGui ${QT_LIBRARY_DIR}/QtGui.framework/Headers + NO_DEFAULT_PATH + ) + + # Set QT_QTSVG_INCLUDE_DIR + FIND_PATH(QT_QTSVG_INCLUDE_DIR QtSvg + PATHS + ${QT_INCLUDE_DIR}/QtSvg + ${QT_LIBRARY_DIR}/QtSvg.framework/Headers + NO_DEFAULT_PATH + ) + + # Set QT_QTTEST_INCLUDE_DIR + FIND_PATH(QT_QTTEST_INCLUDE_DIR QtTest + PATHS + ${QT_INCLUDE_DIR}/QtTest + ${QT_LIBRARY_DIR}/QtTest.framework/Headers + NO_DEFAULT_PATH + ) + + # Set QT_QTUITOOLS_INCLUDE_DIR + FIND_PATH(QT_QTUITOOLS_INCLUDE_DIR QtTest + PATHS + ${QT_INCLUDE_DIR}/QtUiTools + ${QT_LIBRARY_DIR}/QtUiTools.framework/Headers + NO_DEFAULT_PATH ) + + # Set QT_QTMOTIF_INCLUDE_DIR - FIND_PATH( QT_QTMOTIF_INCLUDE_DIR QtMotif ${QT_INCLUDE_DIR}/QtMotif) + IF(Q_WS_X11) + FIND_PATH(QT_QTMOTIF_INCLUDE_DIR QtMotif PATHS ${QT_INCLUDE_DIR}/QtMotif NO_DEFAULT_PATH ) + ENDIF(Q_WS_X11) # Set QT_QTNETWORK_INCLUDE_DIR - FIND_PATH( QT_QTNETWORK_INCLUDE_DIR QtNetwork + FIND_PATH(QT_QTNETWORK_INCLUDE_DIR QtNetwork + PATHS ${QT_INCLUDE_DIR}/QtNetwork ${QT_LIBRARY_DIR}/QtNetwork.framework/Headers + NO_DEFAULT_PATH ) # Set QT_QTNSPLUGIN_INCLUDE_DIR - FIND_PATH( QT_QTNSPLUGIN_INCLUDE_DIR QtNsPlugin + FIND_PATH(QT_QTNSPLUGIN_INCLUDE_DIR QtNsPlugin + PATHS ${QT_INCLUDE_DIR}/QtNsPlugin ${QT_LIBRARY_DIR}/QtNsPlugin.framework/Headers + NO_DEFAULT_PATH ) # Set QT_QTOPENGL_INCLUDE_DIR - FIND_PATH( QT_QTOPENGL_INCLUDE_DIR QtOpenGL + FIND_PATH(QT_QTOPENGL_INCLUDE_DIR QtOpenGL + PATHS ${QT_INCLUDE_DIR}/QtOpenGL ${QT_LIBRARY_DIR}/QtOpenGL.framework/Headers + NO_DEFAULT_PATH ) # Set QT_QTSQL_INCLUDE_DIR - FIND_PATH( QT_QTSQL_INCLUDE_DIR QtSql + FIND_PATH(QT_QTSQL_INCLUDE_DIR QtSql + PATHS ${QT_INCLUDE_DIR}/QtSql ${QT_LIBRARY_DIR}/QtSql.framework/Headers + NO_DEFAULT_PATH ) # Set QT_QTXML_INCLUDE_DIR - FIND_PATH( QT_QTXML_INCLUDE_DIR QtXml + FIND_PATH(QT_QTXML_INCLUDE_DIR QtXml + PATHS ${QT_INCLUDE_DIR}/QtXml ${QT_LIBRARY_DIR}/QtXml.framework/Headers + NO_DEFAULT_PATH ) # Set QT_QTASSISTANT_INCLUDE_DIR - FIND_PATH( QT_QTASSISTANT_INCLUDE_DIR QtAssistant + FIND_PATH(QT_QTASSISTANT_INCLUDE_DIR QtAssistant + PATHS ${QT_INCLUDE_DIR}/QtAssistant ${QT_HEADERS_DIR}/QtAssistant + NO_DEFAULT_PATH ) # Set QT_QTDESIGNER_INCLUDE_DIR - FIND_PATH( QT_QTDESIGNER_INCLUDE_DIR QDesignerComponents + FIND_PATH(QT_QTDESIGNER_INCLUDE_DIR QDesignerComponents + PATHS ${QT_INCLUDE_DIR}/QtDesigner ${QT_HEADERS_DIR}/QtDesigner + NO_DEFAULT_PATH ) # Make variables changeble to the advanced user - MARK_AS_ADVANCED( - QT_LIBRARY_DIR - QT_INCLUDE_DIR - QT_QT_INCLUDE_DIR - QT_QT3SUPPORT_INCLUDE_DIR - QT_QTASSISTANT_INCLUDE_DIR - QT_QTCORE_INCLUDE_DIR - QT_QTDESIGNER_INCLUDE_DIR - QT_QTGUI_INCLUDE_DIR - QT_QTMOTIF_INCLUDE_DIR - QT_QTNETWORK_INCLUDE_DIR - QT_QTNSPLUGIN_INCLUDE_DIR - QT_QTOPENGL_INCLUDE_DIR - QT_QTSQL_INCLUDE_DIR - QT_QTXML_INCLUDE_DIR - ) + MARK_AS_ADVANCED( QT_LIBRARY_DIR QT_INCLUDE_DIR QT_QT_INCLUDE_DIR QT_DOC_DIR) # Set QT_INCLUDES - SET( QT_INCLUDES - ${QT_INCLUDE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QT_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ) - # append optional flags - MACRO(QT4_APPEND_INCLUDES_FLAG FLAG) - IF(${FLAG}) - SET(QT_INCLUDES ${QT_INCLUDES} "${${FLAG}}") - ENDIF(${FLAG}) - ENDMACRO(QT4_APPEND_INCLUDES_FLAG) - QT4_APPEND_INCLUDES_FLAG(QT_QT3SUPPORT_INCLUDE_DIR) - QT4_APPEND_INCLUDES_FLAG(QT_QTASSISTANT_INCLUDE_DIR) - QT4_APPEND_INCLUDES_FLAG(QT_QTDESIGNER_INCLUDE_DIR) - QT4_APPEND_INCLUDES_FLAG(QT_QTDESIGNER_INCLUDE_DIR) - QT4_APPEND_INCLUDES_FLAG(QT_QTMOTIF_INCLUDE_DIR) - QT4_APPEND_INCLUDES_FLAG(QT_QTNETWORK_INCLUDE_DIR) - QT4_APPEND_INCLUDES_FLAG(QT_QTNSPLUGIN_INCLUDE_DIR) - QT4_APPEND_INCLUDES_FLAG(QT_QTOPENGL_INCLUDE_DIR) - QT4_APPEND_INCLUDES_FLAG(QT_QTSQL_INCLUDE_DIR) - QT4_APPEND_INCLUDES_FLAG(QT_QTXML_INCLUDE_DIR) + SET( QT_INCLUDES ${QT_INCLUDE_DIR} ${QT_QT_INCLUDE_DIR} ${QT_MKSPECS_DIR}/default ) ######################################## @@ -334,137 +476,96 @@ IF(QT4_QMAKE_FOUND) ######################################## IF (QT_USE_FRAMEWORKS) - # If FIND_LIBRARY found libraries in Apple frameworks, we would not have + # If FIND_LIBRARY found libraries in Apple frameworks, we would NOT have # to jump through these hoops. - SET(QT_QTCORE_LIBRARY "-F${QT_LIBRARY_DIR} -framework QtCore" - CACHE STRING "The QtCore library.") - SET(QT_QTCORE_LIBRARY_DEBUG "-F${QT_LIBRARY_DIR} -framework QtCore" - CACHE STRING "The QtCore library.") - SET(QT_QT3SUPPORT_LIBRARY "-framework Qt3Support" - CACHE STRING "The Qt3Support library.") - SET(QT_QT3SUPPORT_LIBRARY_DEBUG "-framework Qt3Support" - CACHE STRING "The Qt3Support library.") - SET(QT_QTGUI_LIBRARY "-framework QtGui" - CACHE STRING "The QtGui library.") - SET(QT_QTGUI_LIBRARY_DEBUG "-framework QtGui" - CACHE STRING "The QtGui library.") - SET(QT_QTNETWORK_LIBRARY "-framework QtNetwork" - CACHE STRING "The QtNetwork library.") - SET(QT_QTNETWORK_LIBRARY_DEBUG "-framework QtNetwork" - CACHE STRING "The QtNetwork library.") - SET(QT_QTOPENGL_LIBRARY "-framework QtOpenGL" - CACHE STRING "The QtOpenGL library.") - SET(QT_QTOPENGL_LIBRARY_DEBUG "-framework QtOpenGL" - CACHE STRING "The QtOpenGL library.") - SET(QT_QTSQL_LIBRARY "-framework QtSql" - CACHE STRING "The QtSql library.") - SET(QT_QTSQL_LIBRARY_DEBUG "-framework QtSql" - CACHE STRING "The QtSql library.") - SET(QT_QTXML_LIBRARY "-framework QtXml" - CACHE STRING "The QtXml library.") - SET(QT_QTXML_LIBRARY_DEBUG "-framework QtXml" - CACHE STRING "The QtXml library.") + SET(QT_QTCORE_LIBRARY_RELEASE "-F${QT_LIBRARY_DIR} -framework QtCore" CACHE STRING "The QtCore library.") + SET(QT_QTCORE_LIBRARY_DEBUG "-F${QT_LIBRARY_DIR} -framework QtCore" CACHE STRING "The QtCore library.") + SET(QT_QT3SUPPORT_LIBRARY_RELEASE "-framework Qt3Support" CACHE STRING "The Qt3Support library.") + SET(QT_QT3SUPPORT_LIBRARY_DEBUG "-framework Qt3Support" CACHE STRING "The Qt3Support library.") + SET(QT_QTGUI_LIBRARY_RELEASE "-framework QtGui" CACHE STRING "The QtGui library.") + SET(QT_QTGUI_LIBRARY_DEBUG "-framework QtGui" CACHE STRING "The QtGui library.") + SET(QT_QTNETWORK_LIBRARY_RELEASE "-framework QtNetwork" CACHE STRING "The QtNetwork library.") + SET(QT_QTNETWORK_LIBRARY_DEBUG "-framework QtNetwork" CACHE STRING "The QtNetwork library.") + SET(QT_QTOPENGL_LIBRARY_RELEASE "-framework QtOpenGL" CACHE STRING "The QtOpenGL library.") + SET(QT_QTOPENGL_LIBRARY_DEBUG "-framework QtOpenGL" CACHE STRING "The QtOpenGL library.") + SET(QT_QTSQL_LIBRARY_RELEASE "-framework QtSql" CACHE STRING "The QtSql library.") + SET(QT_QTSQL_LIBRARY_DEBUG "-framework QtSql" CACHE STRING "The QtSql library.") + SET(QT_QTXML_LIBRARY_RELEASE "-framework QtXml" CACHE STRING "The QtXml library.") + SET(QT_QTXML_LIBRARY_DEBUG "-framework QtXml" CACHE STRING "The QtXml library.") + SET(QT_QTSVG_LIBRARY_RELEASE "-framework QtSvg" CACHE STRING "The QtSvg library.") + SET(QT_QTSVG_LIBRARY_DEBUG "-framework QtSvg" CACHE STRING "The QtSvg library.") + SET(QT_QTUITOOLS_LIBRARY_RELEASE "-framework QtUiTools" CACHE STRING "The QtUiTools library.") + SET(QT_QTUITOOLS_LIBRARY_DEBUG "-framework QtUiTools" CACHE STRING "The QtUiTools library.") + + + # WTF? why don't we have frameworks? :P + SET(QT_QTTEST_LIBRARY_RELEASE "-L${QT_LIBRARY_DIR} -lQtTest" CACHE STRING "The QtTest library.") + SET(QT_QTTEST_LIBRARY_DEBUG "-L${QT_LIBRARY_DIR} -lQtTest_debug" CACHE STRING "The QtTest library.") + MARK_AS_ADVANCED(QT_QT3SUPPORT_LIBRARY QT_QTGUI_LIBRARY ) + ELSE (QT_USE_FRAMEWORKS) - # Set QT_QTCORE_LIBRARY by searching for a lib with "QtCore." as part of - # the filename - FIND_LIBRARY( QT_QTCORE_LIBRARY - NAMES QtCore QtCore4 - PATHS - ${QT_LIBRARY_DIR} - $ENV{QTDIR}/lib - /usr/local/qt/lib - /usr/local/lib - /usr/lib/qt/lib - /usr/lib - /usr/share/qt4/lib - C:/Progra~1/qt/lib - /usr/lib/qt4 ) - - # Set QT_QTCORE_LIBRARY_DEBUG by searching for a lib with "QtCore_debug" - # as part of the filename - FIND_LIBRARY( QT_QTCORE_LIBRARY_DEBUG - NAMES QtCore_debug QtCored4 - PATHS - ${QT_LIBRARY_DIR} - $ENV{QTDIR}/lib - /usr/local/qt/lib - /usr/local/lib - /usr/lib/qt/lib - /usr/lib - /usr/share/qt4/lib - C:/Progra~1/qt/lib - /usr/lib/qt4 ) + # 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 QtCored4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QT3SUPPORT_LIBRARY - FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY NAMES Qt3Support Qt3Support4 PATHS ${QT_LIBRARY_DIR}) - FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_DEBUG NAMES Qt3Support_debug Qt3Supportd4 PATHS ${QT_LIBRARY_DIR}) + 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 NAMES QtGui QtGui4 PATHS ${QT_LIBRARY_DIR}) - FIND_LIBRARY(QT_QTGUI_LIBRARY_DEBUG NAMES QtGui_debug QtGuid4 PATHS ${QT_LIBRARY_DIR}) + 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 - FIND_LIBRARY(QT_QTMOTIF_LIBRARY NAMES QtMotif PATHS ${QT_LIBRARY_DIR}) - FIND_LIBRARY(QT_QTMOTIF_LIBRARY_DEBUG NAMES QtMotif_debug PATHS ${QT_LIBRARY_DIR}) + 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 NAMES QtNetwork QtNetwork4 PATHS ${QT_LIBRARY_DIR}) - FIND_LIBRARY(QT_QTNETWORK_LIBRARY_DEBUG NAMES QtNetwork_debug QtNetworkd4 PATHS ${QT_LIBRARY_DIR}) + 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 NAMES QtNsPlugin PATHS ${QT_LIBRARY_DIR}) - FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY_DEBUG NAMES QtNsPlugin_debug PATHS ${QT_LIBRARY_DIR}) + 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 NAMES QtOpenGL QtOpenGL4 PATHS ${QT_LIBRARY_DIR}) - FIND_LIBRARY(QT_QTOPENGL_LIBRARY_DEBUG NAMES QtOpenGL_debug QtOpenGLd4 PATHS ${QT_LIBRARY_DIR}) + 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 NAMES QtSql QtSql4 PATHS ${QT_LIBRARY_DIR}) - FIND_LIBRARY(QT_QTSQL_LIBRARY_DEBUG NAMES QtSql_debug QtSqld4 PATHS ${QT_LIBRARY_DIR}) + 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 NAMES QtXml QtXml4 PATHS ${QT_LIBRARY_DIR}) - FIND_LIBRARY(QT_QTXML_LIBRARY_DEBUG NAMES QtXml_debug QtXmld4 PATHS ${QT_LIBRARY_DIR}) + 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_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) + + MARK_AS_ADVANCED(QT_QT3SUPPORT_LIBRARY QT_QTGUI_LIBRARY ) ENDIF (QT_USE_FRAMEWORKS) # Set QT_QTASSISTANT_LIBRARY - FIND_LIBRARY(QT_QTASSISTANT_LIBRARY NAMES QtAssistant QtAssistant4 PATHS ${QT_LIBRARY_DIR}) - FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_DEBUG NAMES QtAssistant_debug QtAssistantd4 PATHS ${QT_LIBRARY_DIR}) + FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_RELEASE NAMES QtAssistantClient QtAssistant QtAssistant4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_DEBUG NAMES QtAssistantClientd QtAssistantClient_debug QtAssistant_debug QtAssistantd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QTDESIGNER_LIBRARY - FIND_LIBRARY(QT_QTDESIGNER_LIBRARY NAMES QtDesigner QtDesigner4 PATHS ${QT_LIBRARY_DIR}) - FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_DEBUG NAMES QtDesigner_debug QtDesignerd4 PATHS ${QT_LIBRARY_DIR}) - - # Make variables changeble to the advanced user - MARK_AS_ADVANCED( - QT_QT3SUPPORT_LIBRARY - QT_QTASSISTANT_LIBRARY - QT_QTCORE_LIBRARY - QT_QTDESIGNER_LIBRARY - QT_QTGUI_LIBRARY - QT_QTMOTIF_LIBRARY - QT_QTNETWORK_LIBRARY - QT_QTNSPLUGIN_LIBRARY - QT_QTOPENGL_LIBRARY - QT_QTSQL_LIBRARY - QT_QTXML_LIBRARY ) - - # Make variables changeble to the advanced user - MARK_AS_ADVANCED( - QT_QT3SUPPORT_LIBRARY_DEBUG - QT_QTASSISTANT_LIBRARY_DEBUG - QT_QTCORE_LIBRARY_DEBUG - QT_QTDESIGNER_LIBRARY_DEBUG - QT_QTGUI_LIBRARY_DEBUG - QT_QTMOTIF_LIBRARY_DEBUG - QT_QTNETWORK_LIBRARY_DEBUG - QT_QTNSPLUGIN_LIBRARY_DEBUG - QT_QTOPENGL_LIBRARY_DEBUG - QT_QTSQL_LIBRARY_DEBUG - QT_QTXML_LIBRARY_DEBUG ) + FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_RELEASE NAMES QtDesigner QtDesigner4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_DEBUG NAMES QtDesigner_debug QtDesignerd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) ############################################ # @@ -472,82 +573,63 @@ IF(QT4_QMAKE_FOUND) # ############################################ - IF (QT_QTCORE_INCLUDE_DIR AND QT_QTCORE_LIBRARY) - SET(QT_QTCORE_FOUND 1) - IF (NOT QT_QTCORE_LIBRARY_DEBUG) - SET(QT_QTCORE_LIBRARY_DEBUG ${QT_QTCORE_LIBRARY}) - ENDIF (NOT QT_QTCORE_LIBRARY_DEBUG) - ENDIF (QT_QTCORE_INCLUDE_DIR AND QT_QTCORE_LIBRARY) - - IF (QT_QTGUI_INCLUDE_DIR AND QT_QTGUI_LIBRARY) - SET(QT_QTGUI_FOUND 1) - IF (NOT QT_QTGUI_LIBRARY_DEBUG) - SET(QT_QTGUI_LIBRARY_DEBUG ${QT_QTGUI_LIBRARY}) - ENDIF (NOT QT_QTGUI_LIBRARY_DEBUG) - ENDIF (QT_QTGUI_INCLUDE_DIR AND QT_QTGUI_LIBRARY) - - IF (QT_QT3SUPPORT_INCLUDE_DIR AND QT_QT3SUPPORT_LIBRARY) - SET(QT_QT3SUPPORT_FOUND 1) - IF (NOT QT_QT3SUPPORT_LIBRARY_DEBUG) - SET(QT_QT3SUPPORT_LIBRARY_DEBUG ${QT_QT3SUPPORT_LIBRARY}) - ENDIF (NOT QT_QT3SUPPORT_LIBRARY_DEBUG) - ENDIF (QT_QT3SUPPORT_INCLUDE_DIR AND QT_QT3SUPPORT_LIBRARY) - - IF (QT_QTASSISTANT_INCLUDE_DIR AND QT_QTASSISTANT_LIBRARY) - SET(QT_QTASSISTANT_FOUND 1) - IF (NOT QT_QTASSISTANT_LIBRARY_DEBUG) - SET(QT_QTASSISTANT_LIBRARY_DEBUG ${QT_QTASSISTANT_LIBRARY}) - ENDIF (NOT QT_QTASSISTANT_LIBRARY_DEBUG) - ENDIF (QT_QTASSISTANT_INCLUDE_DIR AND QT_QTASSISTANT_LIBRARY) - - IF (QT_QTDESIGNER_INCLUDE_DIR AND QT_QTDESIGNER_LIBRARY) - SET(QT_QTDESIGNER_FOUND 1) - IF (NOT QT_QTDESIGNER_LIBRARY_DEBUG) - SET(QT_QTDESIGNER_LIBRARY_DEBUG ${QT_QTDESIGNER_LIBRARY}) - ENDIF (NOT QT_QTDESIGNER_LIBRARY_DEBUG) - ENDIF (QT_QTDESIGNER_INCLUDE_DIR AND QT_QTDESIGNER_LIBRARY) - - IF (QT_QTMOTIF_INCLUDE_DIR AND QT_QTMOTIF_LIBRARY) - SET(QT_QTMOTIF_FOUND 1) - IF (NOT QT_QTMOTIF_LIBRARY_DEBUG) - SET(QT_QTMOTIF_LIBRARY_DEBUG ${QT_QTMOTIF_LIBRARY}) - ENDIF (NOT QT_QTMOTIF_LIBRARY_DEBUG) - ENDIF (QT_QTMOTIF_INCLUDE_DIR AND QT_QTMOTIF_LIBRARY) - - IF (QT_QTNETWORK_INCLUDE_DIR AND QT_QTNETWORK_LIBRARY) - SET(QT_QTNETWORK_FOUND 1) - IF (NOT QT_QTNETWORK_LIBRARY_DEBUG) - SET(QT_QTNETWORK_LIBRARY_DEBUG ${QT_QTNETWORK_LIBRARY}) - ENDIF (NOT QT_QTNETWORK_LIBRARY_DEBUG) - ENDIF (QT_QTNETWORK_INCLUDE_DIR AND QT_QTNETWORK_LIBRARY) - - IF (QT_QTNSPLUGIN_INCLUDE_DIR AND QT_QTNSPLUGIN_LIBRARY) - SET(QT_QTNSPLUGIN_FOUND 1) - IF (NOT QT_QTNSPLUGIN_LIBRARY_DEBUG) - SET(QT_QTNSPLUGIN_LIBRARY_DEBUG ${QT_QTNSPLUGIN_LIBRARY}) - ENDIF (NOT QT_QTNSPLUGIN_LIBRARY_DEBUG) - ENDIF (QT_QTNSPLUGIN_INCLUDE_DIR AND QT_QTNSPLUGIN_LIBRARY) - - IF (QT_QTOPENGL_INCLUDE_DIR AND QT_QTOPENGL_LIBRARY) - SET(QT_QTOPENGL_FOUND 1) - IF (NOT QT_QTOPENGL_LIBRARY_DEBUG) - SET(QT_QTOPENGL_LIBRARY_DEBUG ${QT_QTOPENGL_LIBRARY}) - ENDIF (NOT QT_QTOPENGL_LIBRARY_DEBUG) - ENDIF (QT_QTOPENGL_INCLUDE_DIR AND QT_QTOPENGL_LIBRARY) - - IF (QT_QTSQL_INCLUDE_DIR AND QT_QTSQL_LIBRARY) - SET(QT_QTSQL_FOUND 1) - IF (NOT QT_QTSQL_LIBRARY_DEBUG) - SET(QT_QTSQL_LIBRARY_DEBUG ${QT_QTSQL_LIBRARY}) - ENDIF (NOT QT_QTSQL_LIBRARY_DEBUG) - ENDIF (QT_QTSQL_INCLUDE_DIR AND QT_QTSQL_LIBRARY) - - IF (QT_QTXML_INCLUDE_DIR AND QT_QTXML_LIBRARY) - SET(QT_QTXML_FOUND 1) - IF (NOT QT_QTXML_LIBRARY_DEBUG) - SET(QT_QTXML_LIBRARY_DEBUG ${QT_QTXML_LIBRARY}) - ENDIF (NOT QT_QTXML_LIBRARY_DEBUG) - ENDIF (QT_QTXML_INCLUDE_DIR AND QT_QTXML_LIBRARY) + MACRO (_QT4_ADJUST_LIB_VARS basename) + IF (QT_${basename}_INCLUDE_DIR) + + # if only the release version was found, set the debug variable also to the release version + IF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG) + SET(QT_${basename}_LIBRARY_DEBUG ${QT_${basename}_LIBRARY_RELEASE}) + SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE}) + SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_RELEASE}) + ENDIF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG) + + # if only the debug version was found, set the release variable also to the debug version + IF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE) + SET(QT_${basename}_LIBRARY_RELEASE ${QT_${basename}_LIBRARY_DEBUG}) + SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_DEBUG}) + SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_DEBUG}) + ENDIF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE) + + IF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE) + SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE}) + SET(QT_${basename}_LIBRARIES optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG}) + ENDIF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE) + + SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY} CACHE FILEPATH "The Qt ${basename} library") + + IF (QT_${basename}_LIBRARY) + SET(QT_${basename}_FOUND 1) + ENDIF (QT_${basename}_LIBRARY) + + #add the include directory to QT_INCLUDES + SET(QT_INCLUDES ${QT_INCLUDES} "${QT_${basename}_INCLUDE_DIR}") + ENDIF (QT_${basename}_INCLUDE_DIR ) + + # Make variables changeble to the advanced user + MARK_AS_ADVANCED(QT_${basename}_LIBRARY QT_${basename}_LIBRARY_RELEASE QT_${basename}_LIBRARY_DEBUG QT_${basename}_INCLUDE_DIR) + ENDMACRO (_QT4_ADJUST_LIB_VARS) + + IF(WIN32) + _QT4_ADJUST_LIB_VARS(QTMAIN) + ENDIF(WIN32) + + + _QT4_ADJUST_LIB_VARS(QTCORE) + _QT4_ADJUST_LIB_VARS(QTGUI) + _QT4_ADJUST_LIB_VARS(QT3SUPPORT) + _QT4_ADJUST_LIB_VARS(QTASSISTANT) + _QT4_ADJUST_LIB_VARS(QTDESIGNER) + IF(Q_WS_X11) + _QT4_ADJUST_LIB_VARS(QTMOTIF) + ENDIF(Q_WS_X11) + _QT4_ADJUST_LIB_VARS(QTNETWORK) + _QT4_ADJUST_LIB_VARS(QTNSPLUGIN) + _QT4_ADJUST_LIB_VARS(QTOPENGL) + _QT4_ADJUST_LIB_VARS(QTSQL) + _QT4_ADJUST_LIB_VARS(QTXML) + _QT4_ADJUST_LIB_VARS(QTSVG) + _QT4_ADJUST_LIB_VARS(QTUITOOLS) + _QT4_ADJUST_LIB_VARS(QTTEST) ####################################### # @@ -555,66 +637,51 @@ IF(QT4_QMAKE_FOUND) # ( moc, uic, rcc ) # ####################################### - IF (NOT QT_BINARY_DIR) - EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} - ARGS "-query QT_INSTALL_BINS" - OUTPUT_VARIABLE qt_bins ) - SET(QT_BINARY_DIR ${qt_bins} CACHE INTERNAL "") - ENDIF (NOT QT_BINARY_DIR) - FIND_PROGRAM(QT_MOC_EXECUTABLE - NAMES moc - PATHS - ${QT_BINARY_DIR} - $ENV{QTDIR}/bin - /usr/local/qt/bin - /usr/local/bin - /usr/lib/qt/bin - /usr/bin - /usr/share/qt4/bin - C:/Progra~1/qt/bin - /usr/bin/qt4 - ) - IF(QT_MOC_EXECUTABLE) - SET ( QT_WRAP_CPP "YES") - ENDIF(QT_MOC_EXECUTABLE) - FIND_PROGRAM(QT_UIC_EXECUTABLE - NAMES uic - PATHS - ${QT_BINARY_DIR} - $ENV{QTDIR}/bin - /usr/local/qt/bin - /usr/local/bin - /usr/lib/qt/bin - /usr/bin - /usr/share/qt4/bin - C:/Progra~1/qt/bin - /usr/bin/qt4 - ) + # find moc and uic using qmake + FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CMakeTmpQmake/tmp.pro + "message("MOC <$$QMAKE_MOC>") + message("UIC <$$QMAKE_UIC>") + ") + + EXECUTE_PROCESS(COMMAND ${QT_QMAKE_EXECUTABLE} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CMakeTmpQmake + OUTPUT_VARIABLE _moc_OUTPUT + ERROR_VARIABLE _moc_OUTPUT ) - IF(QT_UIC_EXECUTABLE) - SET ( QT_WRAP_UI "YES") - ENDIF(QT_UIC_EXECUTABLE) + FILE(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CMakeTmpQmake") + + STRING(REGEX REPLACE ".*MOC<([^>]+).*" "\\1" QT_MOC_EXECUTABLE "${_moc_OUTPUT}" ) + STRING(REGEX REPLACE ".*UIC<([^>]+).*" "\\1" QT_UIC_EXECUTABLE "${_moc_OUTPUT}" ) + + SET(QT_MOC_EXECUTABLE ${QT_MOC_EXECUTABLE} CACHE FILEPATH "The moc executable") + SET(QT_UIC_EXECUTABLE ${QT_UIC_EXECUTABLE} CACHE FILEPATH "The uic executable") + + + FIND_PROGRAM(QT_UIC3_EXECUTABLE + NAMES uic3 + PATHS ${QT_BINARY_DIR} + NO_DEFAULT_PATH + ) FIND_PROGRAM(QT_RCC_EXECUTABLE NAMES rcc - PATHS - ${QT_BINARY_DIR} - $ENV{QTDIR}/bin - /usr/local/qt/bin - /usr/local/bin - /usr/lib/qt/bin - /usr/bin - /usr/share/qt4/bin - C:/Progra~1/qt/bin - /usr/bin/qt4 + PATHS ${QT_BINARY_DIR} + NO_DEFAULT_PATH ) - MARK_AS_ADVANCED( - QT_UIC_EXECUTABLE - QT_MOC_EXECUTABLE - QT_RCC_EXECUTABLE ) + 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) + + + + MARK_AS_ADVANCED( QT_UIC_EXECUTABLE QT_UIC3_EXECUTABLE QT_MOC_EXECUTABLE QT_RCC_EXECUTABLE ) ###################################### # @@ -622,39 +689,56 @@ IF(QT4_QMAKE_FOUND) # ###################################### + MACRO (QT4_GET_MOC_INC_DIRS _moc_INC_DIRS) + SET(${_moc_INC_DIRS}) + GET_DIRECTORY_PROPERTY(_inc_DIRS INCLUDE_DIRECTORIES) + + FOREACH(_current ${_inc_DIRS}) + SET(${_moc_INC_DIRS} ${${_moc_INC_DIRS}} "-I" ${_current}) + ENDFOREACH(_current ${_inc_DIRS}) + ENDMACRO(QT4_GET_MOC_INC_DIRS) + + + MACRO (QT4_GENERATE_MOC infile outfile ) + # get include dirs + QT4_GET_MOC_INC_DIRS(moc_includes) + + GET_FILENAME_COMPONENT(infile ${infile} ABSOLUTE) + + ADD_CUSTOM_COMMAND(OUTPUT ${outfile} + COMMAND ${QT_MOC_EXECUTABLE} + ARGS ${moc_includes} -o ${outfile} ${infile} + DEPENDS ${infile}) + ENDMACRO (QT4_GENERATE_MOC) + # QT4_WRAP_CPP(outfiles inputfile ... ) # TODO perhaps add support for -D, -U and other minor options - MACRO(QT4_WRAP_CPP outfiles ) - + 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) + QT4_GET_MOC_INC_DIRS(moc_includes) - FOREACH(it ${ARGN}) + FOREACH (it ${ARGN}) + GET_FILENAME_COMPONENT(it ${it} ABSOLUTE) 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}) + ARGS ${moc_includes} -o ${outfile} ${it} + DEPENDS ${it}) SET(${outfiles} ${${outfiles}} ${outfile}) ENDFOREACH(it) - ENDMACRO(QT4_WRAP_CPP) + ENDMACRO (QT4_WRAP_CPP) # QT4_WRAP_UI(outfiles inputfile ... ) - MACRO(QT4_WRAP_UI outfiles ) + MACRO (QT4_WRAP_UI outfiles ) - FOREACH(it ${ARGN}) + 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) @@ -663,16 +747,17 @@ IF(QT4_QMAKE_FOUND) ARGS -o ${outfile} ${infile} MAIN_DEPENDENCY ${infile}) SET(${outfiles} ${${outfiles}} ${outfile}) - ENDFOREACH(it) + ENDFOREACH (it) + + ENDMACRO (QT4_WRAP_UI) - 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 ) + MACRO (QT4_ADD_RESOURCES outfiles ) - FOREACH(it ${ARGN}) + 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) @@ -681,9 +766,65 @@ IF(QT4_QMAKE_FOUND) ARGS -name ${outfilename} -o ${outfile} ${infile} MAIN_DEPENDENCY ${infile} ) SET(${outfiles} ${${outfiles}} ${outfile}) - ENDFOREACH(it) + ENDFOREACH (it) + + ENDMACRO (QT4_ADD_RESOURCES) + - ENDMACRO(QT4_ADD_RESOURCES) + MACRO(_QT4_ADD_FILE_DEPENDENCIES _file) + GET_SOURCE_FILE_PROPERTY(_deps ${_file} OBJECT_DEPENDS) + IF (_deps) + SET(_deps ${_deps} ${ARGN}) + ELSE (_deps) + SET(_deps ${ARGN}) + ENDIF (_deps) + SET_SOURCE_FILES_PROPERTIES(${_file} PROPERTIES OBJECT_DEPENDS "${_deps}") + ENDMACRO(_QT4_ADD_FILE_DEPENDENCIES) + + + MACRO(QT4_AUTOMOC) + QT4_GET_MOC_INC_DIRS(_moc_INCS) + + SET(_matching_FILES ) + FOREACH (_current_FILE ${ARGN}) + + GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE) + # if "SKIP_AUTOMOC" is set to true, we will not handle this file here. + # here. this is required to make bouic work correctly: + # we need to add generated .cpp files to the sources (to compile them), + # but we cannot let automoc handle them, as the .cpp files don't exist yet when + # cmake is run for the very first time on them -> however the .cpp files might + # exist at a later run. at that time we need to skip them, so that we don't add two + # different rules for the same moc file + GET_SOURCE_FILE_PROPERTY(_skip ${_abs_FILE} SKIP_AUTOMOC) + + IF ( NOT _skip AND EXISTS ${_abs_FILE} ) + + FILE(READ ${_abs_FILE} _contents) + + GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH) + + STRING(REGEX MATCHALL "#include +[^ ]+\\.moc[\">]" _match "${_contents}") + IF(_match) + FOREACH (_current_MOC_INC ${_match}) + STRING(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}") + + GET_filename_component(_basename ${_current_MOC} NAME_WE) + # SET(_header ${CMAKE_CURRENT_SOURCE_DIR}/${_basename}.h) + SET(_header ${_abs_PATH}/${_basename}.h) + SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC}) + ADD_CUSTOM_COMMAND(OUTPUT ${_moc} + COMMAND ${QT_MOC_EXECUTABLE} + ARGS ${_moc_INCS} ${_header} -o ${_moc} + DEPENDS ${_header} + ) + + _QT4_ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc}) + ENDFOREACH (_current_MOC_INC) + ENDIF(_match) + ENDIF ( NOT _skip AND EXISTS ${_abs_FILE} ) + ENDFOREACH (_current_FILE) + ENDMACRO(QT4_AUTOMOC) @@ -692,6 +833,7 @@ IF(QT4_QMAKE_FOUND) # decide if Qt got found # ###################################### + # if the includes,libraries,moc,uic and rcc are found then we have it IF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE) SET( QT4_FOUND "YES" ) @@ -714,7 +856,12 @@ IF(QT4_QMAKE_FOUND) ####################################### # 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) @@ -728,13 +875,20 @@ IF(QT4_QMAKE_FOUND) SET (QT_UIC_EXE ${QT_UIC_EXECUTABLE} ) SET( QT_QT_LIBRARY "") - SET( QT_QTMAIN_LIBRARY "") + ELSE(QT4_QMAKE_FOUND) - IF(QT_QMAKE_EXECUTABLE) - MESSAGE("QT_QMAKE_EXECUTABLE set to qmake version: QTVERSION = ${QTVERSION}\nQT_QMAKE_EXECUTABLE = ${QT_QMAKE_EXECUTABLE}, please set to path to qmake from qt4.") - ENDIF(QT_QMAKE_EXECUTABLE) - IF( Qt4_FIND_REQUIRED) + + IF(Qt4_FIND_REQUIRED) + IF(QT4_INSTALLED_VERSION_TOO_OLD) + MESSAGE(FATAL_ERROR "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required") + ELSE(QT4_INSTALLED_VERSION_TOO_OLD) MESSAGE( FATAL_ERROR "Qt qmake not found!") - ENDIF( Qt4_FIND_REQUIRED) + ENDIF(QT4_INSTALLED_VERSION_TOO_OLD) + ELSE(Qt4_FIND_REQUIRED) + IF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY) + MESSAGE(STATUS "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required") + ENDIF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY) + ENDIF(Qt4_FIND_REQUIRED) + +ENDIF (QT4_QMAKE_FOUND) -ENDIF(QT4_QMAKE_FOUND) diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake index d0d8638..62a1edf 100644 --- a/Modules/UseQt4.cmake +++ b/Modules/UseQt4.cmake @@ -103,6 +103,19 @@ IF (QT_USE_QTDESIGNER) ENDIF (QT_QTDESIGNER_FOUND) ENDIF (QT_USE_QTDESIGNER) +IF (QT_USE_QTMAIN) + IF (WIN32) + IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + SET(QT_LIBRARIES ${QT_LIBRARIES} + optimized "${QT_QTMAIN_LIBRARY}" + debug "${QT_QTMAIN_LIBRARY_DEBUG}" + ) + ELSE (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + SET(QT_LIBRARIES ${QT_LIBRARIES} "${QT_QTMAIN_LIBRARY}") + ENDIF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + ENDIF (WIN32) +ENDIF (QT_USE_QTMAIN) + IF (QT_USE_QTMOTIF) IF (QT_QTMOTIF_FOUND) INCLUDE_DIRECTORIES(${QT_QTMOTIF_INCLUDE_DIR}) diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx index e33c518..b1efb70 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.cxx +++ b/Source/cmGlobalBorlandMakefileGenerator.cxx @@ -24,7 +24,7 @@ cmGlobalBorlandMakefileGenerator::cmGlobalBorlandMakefileGenerator() this->EmptyRuleHackDepends = "NUL"; this->FindMakeProgramFile = "CMakeBorlandFindMake.cmake"; this->ForceUnixPaths = false; - this->ToolSupportsColorVT100 = false; + this->ToolSupportsColor = true; } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 812ed51..a18073f 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -35,7 +35,7 @@ cmGlobalGenerator::cmGlobalGenerator() this->ForceUnixPaths = false; // By default do not try to support color. - this->ToolSupportsColorVT100 = false; + this->ToolSupportsColor = false; } cmGlobalGenerator::~cmGlobalGenerator() diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 9325107..e8f2634 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -127,7 +127,7 @@ public: static int s_TryCompileTimeout; bool GetForceUnixPaths() {return this->ForceUnixPaths;} - bool GetToolSupportsColorVT100() { return this->ToolSupportsColorVT100; } + bool GetToolSupportsColor() { return this->ToolSupportsColor; } ///! return the language for the given extension const char* GetLanguageFromExtension(const char* ext); ///! is an extension to be ignored @@ -204,7 +204,7 @@ protected: std::vector<std::string> depends, bool depends_on_all = false); bool ForceUnixPaths; - bool ToolSupportsColorVT100; + bool ToolSupportsColor; cmStdString FindMakeProgramFile; cmStdString ConfiguredFilesPath; cmake *CMakeInstance; diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index 37e4542..f40722c 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -28,7 +28,7 @@ cmGlobalKdevelopGenerator::cmGlobalKdevelopGenerator() // This type of makefile always requires unix style paths this->ForceUnixPaths = true; this->FindMakeProgramFile = "CMakeUnixFindMake.cmake"; - this->ToolSupportsColorVT100 = false; + this->ToolSupportsColor = false; } ///! Create a local generator appropriate to this Global Generator diff --git a/Source/cmGlobalMSYSMakefileGenerator.cxx b/Source/cmGlobalMSYSMakefileGenerator.cxx index a94a1b5..98862df 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.cxx +++ b/Source/cmGlobalMSYSMakefileGenerator.cxx @@ -23,7 +23,7 @@ cmGlobalMSYSMakefileGenerator::cmGlobalMSYSMakefileGenerator() { this->FindMakeProgramFile = "CMakeMSYSFindMake.cmake"; this->ForceUnixPaths = true; - this->ToolSupportsColorVT100 = true; + this->ToolSupportsColor = true; } std::string diff --git a/Source/cmGlobalMinGWMakefileGenerator.cxx b/Source/cmGlobalMinGWMakefileGenerator.cxx index e924ca0..5ede978 100644 --- a/Source/cmGlobalMinGWMakefileGenerator.cxx +++ b/Source/cmGlobalMinGWMakefileGenerator.cxx @@ -22,7 +22,7 @@ cmGlobalMinGWMakefileGenerator::cmGlobalMinGWMakefileGenerator() { this->FindMakeProgramFile = "CMakeMinGWFindMake.cmake"; this->ForceUnixPaths = true; - this->ToolSupportsColorVT100 = false; + this->ToolSupportsColor = true; } void cmGlobalMinGWMakefileGenerator::EnableLanguage(std::vector<std::string>const& l, diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx index bd9952b..3784a80 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.cxx +++ b/Source/cmGlobalNMakeMakefileGenerator.cxx @@ -22,7 +22,7 @@ cmGlobalNMakeMakefileGenerator::cmGlobalNMakeMakefileGenerator() { this->FindMakeProgramFile = "CMakeNMakeFindMake.cmake"; this->ForceUnixPaths = false; - this->ToolSupportsColorVT100 = false; + this->ToolSupportsColor = true; } void cmGlobalNMakeMakefileGenerator::EnableLanguage(std::vector<std::string>const& l, diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index ee5279e..1a92293 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -26,7 +26,7 @@ cmGlobalUnixMakefileGenerator3::cmGlobalUnixMakefileGenerator3() // This type of makefile always requires unix style paths this->ForceUnixPaths = true; this->FindMakeProgramFile = "CMakeUnixFindMake.cmake"; - this->ToolSupportsColorVT100 = true; + this->ToolSupportsColor = true; } void cmGlobalUnixMakefileGenerator3 @@ -823,7 +823,7 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule if (lg2 == lg || !lg->GetParent()) { // for each target Generate the rule files for each target. - cmTargets& targets = lg->GetMakefile()->GetTargets(); + cmTargets& targets = lg2->GetMakefile()->GetTargets(); for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) { if((t->second.GetType() == cmTarget::EXECUTABLE) || diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index ff67fd0..f1bf776 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -40,6 +40,22 @@ void cmGlobalVisualStudio7Generator::EnableLanguage(std::vector<std::string>cons // Create list of configurations requested by user's cache, if any. this->cmGlobalGenerator::EnableLanguage(lang, mf); this->GenerateConfigurations(mf); + + // if this environment variable is set, then copy it to + // a static cache entry. It will be used by + // cmLocalGenerator::ConstructScript, to add an extra PATH + // to all custom commands. This is because the VS IDE + // does not use the environment it is run in, and this allows + // for running commands and using dll's that the IDE environment + // does not know about. + const char* extraPath = cmSystemTools::GetEnv("CMAKE_MSVCIDE_RUN_PATH"); + if(extraPath) + { + mf->AddCacheDefinition("CMAKE_MSVCIDE_RUN_PATH", + extraPath, "Saved environment variable CMAKE_MSVCIDE_RUN_PATH", + cmCacheManager::STATIC); + } + } std::string cmGlobalVisualStudio7Generator::GenerateBuildCommand(const char* makeProgram, diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx index a040484..3e19c9e 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.cxx +++ b/Source/cmGlobalWatcomWMakeGenerator.cxx @@ -22,7 +22,7 @@ cmGlobalWatcomWMakeGenerator::cmGlobalWatcomWMakeGenerator() { this->FindMakeProgramFile = "CMakeFindWMake.cmake"; this->ForceUnixPaths = false; - this->ToolSupportsColorVT100 = false; + this->ToolSupportsColor = true; this->EmptyCommandsHack = "@cd ."; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 6ada0d9..c0f029b 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1103,15 +1103,40 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs) } } - // Construct the ordered list. + // Get the project-specified include directories. std::vector<std::string>& includes = this->Makefile->GetIncludeDirectories(); + + // Support putting all the in-project include directories first if + // it is requested by the project. + if(this->Makefile->IsOn("CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE")) + { + const char* topSourceDir = this->Makefile->GetHomeDirectory(); + const char* topBinaryDir = this->Makefile->GetHomeOutputDirectory(); for(std::vector<std::string>::iterator i = includes.begin(); i != includes.end(); ++i) { - if(emitted.find(*i) == emitted.end()) + // Emit this directory only if it is a subdirectory of the + // top-level source or binary tree. + if(cmSystemTools::ComparePath(i->c_str(), topSourceDir) || + cmSystemTools::ComparePath(i->c_str(), topBinaryDir) || + cmSystemTools::IsSubDirectory(i->c_str(), topSourceDir) || + cmSystemTools::IsSubDirectory(i->c_str(), topBinaryDir)) + { + if(emitted.insert(*i).second) + { + dirs.push_back(*i); + } + } + } + } + + // Construct the final ordered include directory list. + for(std::vector<std::string>::iterator i = includes.begin(); + i != includes.end(); ++i) + { + if(emitted.insert(*i).second) { dirs.push_back(*i); - emitted.insert(*i); } } } @@ -1726,7 +1751,19 @@ cmLocalGenerator::ConstructScript(const cmCustomCommandLines& commandLines, script += this->Convert(workingDirectory, START_OUTPUT, SHELL); script += newline; } - + // for visual studio IDE add extra stuff to the PATH + // if CMAKE_MSVCIDE_RUN_PATH is set. + if(this->Makefile->GetDefinition("MSVC_IDE")) + { + const char* extraPath = this->Makefile->GetDefinition("CMAKE_MSVCIDE_RUN_PATH"); + if(extraPath) + { + script += "set PATH="; + script += extraPath; + script += ";%PATH%"; + script += newline; + } + } // Write each command on a single line. for(cmCustomCommandLines::const_iterator cl = commandLines.begin(); cl != commandLines.end(); ++cl) diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 865f5a9..051b478 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -35,28 +35,6 @@ #include <memory> // auto_ptr #include <queue> -#define CMAKE_VT100_NORMAL "\33[0m" -#define CMAKE_VT100_BOLD "\33[1m" -#define CMAKE_VT100_UNDERLINE "\33[4m" -#define CMAKE_VT100_BLINK "\33[5m" -#define CMAKE_VT100_INVERSE "\33[7m" -#define CMAKE_VT100_FRONT_BLACK "\33[30m" -#define CMAKE_VT100_FRONT_RED "\33[31m" -#define CMAKE_VT100_FRONT_GREEN "\33[32m" -#define CMAKE_VT100_FRONT_YELLOW "\33[33m" -#define CMAKE_VT100_FRONT_BLUE "\33[34m" -#define CMAKE_VT100_FRONT_MAGENTA "\33[35m" -#define CMAKE_VT100_FRONT_CYAN "\33[36m" -#define CMAKE_VT100_FRONT_WHITE "\33[37m" -#define CMAKE_VT100_BACK_BLACK "\33[40m" -#define CMAKE_VT100_BACK_RED "\33[41m" -#define CMAKE_VT100_BACK_GREEN "\33[42m" -#define CMAKE_VT100_BACK_YELLOW "\33[43m" -#define CMAKE_VT100_BACK_BLUE "\33[44m" -#define CMAKE_VT100_BACK_MAGENTA "\33[45m" -#define CMAKE_VT100_BACK_CYAN "\33[46m" -#define CMAKE_VT100_BACK_WHITE "\33[47m" - //---------------------------------------------------------------------------- cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3() { @@ -532,7 +510,8 @@ cmLocalUnixMakefileGenerator3 if(this->WindowsShell) { makefileStream - << "SHELL = C:\\WINDOWS\\system32\\cmd.exe\n"; + << "SHELL = cmd.exe\n" + << "\n"; } else { @@ -876,32 +855,35 @@ cmLocalUnixMakefileGenerator3::AppendEcho(std::vector<std::string>& commands, EchoColor color) { // Choose the color for the text. - std::string prefix; - if(this->GlobalGenerator->GetToolSupportsColorVT100() && + std::string color_name; +#ifdef CMAKE_BUILD_WITH_CMAKE + if(this->GlobalGenerator->GetToolSupportsColor() && this->Makefile->IsOn("CMAKE_COLOR_MAKEFILE")) { + // See cmake::ExecuteEchoColor in cmake.cxx for these options. + // This color set is readable on both black and white backgrounds. switch(color) { case EchoNormal: break; case EchoDepend: - prefix = CMAKE_VT100_FRONT_MAGENTA; + color_name = "--magenta --bold "; break; case EchoBuild: - prefix = CMAKE_VT100_FRONT_GREEN; + color_name = "--green "; break; case EchoLink: - prefix = CMAKE_VT100_FRONT_RED; + color_name = "--red --bold "; break; case EchoGenerate: - prefix = CMAKE_VT100_FRONT_BLUE; + color_name = "--blue --bold "; break; case EchoGlobal: - prefix = CMAKE_VT100_FRONT_CYAN; + color_name = "--cyan "; break; } } - std::string suffix = prefix.empty()? "" : CMAKE_VT100_NORMAL; +#endif // Echo one line at a time. std::string line; @@ -914,16 +896,28 @@ cmLocalUnixMakefileGenerator3::AppendEcho(std::vector<std::string>& commands, if(*c != '\0' || !line.empty()) { // Add a command to echo this line. - std::string cmd = "@echo "; + std::string cmd; + if(color_name.empty()) + { + // Use the native echo command. + cmd = "@echo "; if(this->EchoNeedsQuote) { cmd += "\""; } - cmd += prefix; cmd += line; - cmd += suffix; if(this->EchoNeedsQuote) { + cmd += "\""; + } + } + else + { + // Use cmake to echo the text in color. + cmd = "@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) "; + cmd += color_name; + cmd += "\""; + cmd += line; cmd += "\""; } commands.push_back(cmd); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index a73213a..bf8422a 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -562,6 +562,17 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() cmOStringStream depCmd; // TODO: Account for source file properties and directory-level // definitions when scanning for dependencies. +#if !defined(_WIN32) || defined(__CYGWIN__) + // This platform supports symlinks, so cmSystemTools will translate + // paths. Make sure PWD is set to the original name of the home + // output directory to help cmSystemTools to create the same + // translation table for the dependency scanning process. + depCmd << "cd " + << (this->LocalGenerator->Convert( + this->Makefile->GetHomeOutputDirectory(), + cmLocalGenerator::FULL, cmLocalGenerator::SHELL)) + << " && "; +#endif depCmd << "$(CMAKE_COMMAND) -E cmake_depends " << " \"" << this->GlobalGenerator->GetName() << "\" " diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx index affff8a..ee7d952 100644 --- a/Source/cmTest.cxx +++ b/Source/cmTest.cxx @@ -42,6 +42,7 @@ void cmTest::SetCommand(const char* command) command = ""; } this->Command = command; + cmSystemTools::ConvertToUnixSlashes(this->Command); } void cmTest::SetArguments(const std::vector<cmStdString>& args) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 2c08ae3..cc55aa4 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -28,6 +28,7 @@ # include "cmDependsFortran.h" // For -E cmake_copy_f90_mod callback. # include "cmVariableWatch.h" # include "cmVersion.h" +# include <cmsys/Terminal.h> #endif // only build kdevelop generator on non-windows platforms @@ -1005,6 +1006,14 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args) return 1; } +#ifdef CMAKE_BUILD_WITH_CMAKE + // Internal CMake color makefile support. + else if (args[1] == "cmake_echo_color") + { + return cmake::ExecuteEchoColor(args); + } +#endif + // Tar files else if (args[1] == "tar" && args.size() > 3) { @@ -2344,3 +2353,115 @@ void cmake::GenerateGraphViz(const char* fileName) str << "}" << std::endl; } +//---------------------------------------------------------------------------- +#ifdef CMAKE_BUILD_WITH_CMAKE +int cmake::ExecuteEchoColor(std::vector<std::string>& args) +{ + // The arguments are + // argv[0] == <cmake-executable> + // argv[1] == cmake_echo_color + + // On some platforms (an MSYS prompt) cmsysTerminal may not be able + // to determine whether the stream is displayed on a tty. In this + // case it assumes no unless we tell it otherwise. Since we want + // color messages to be displayed for users we will assume yes. + // However, we can test for some situations when the answer is most + // likely no. + int assumeTTY = cmsysTerminal_Color_AssumeTTY; + if(cmSystemTools::GetEnv("DART_TEST_FROM_DART") || + cmSystemTools::GetEnv("DASHBOARD_TEST_FROM_CTEST")) + { + // Avoid printing color escapes during dashboard builds. + assumeTTY = 0; + } + + bool enabled = true; + int color = cmsysTerminal_Color_Normal; + bool newline = true; + for(unsigned int i=2; i < args.size(); ++i) + { + if(args[i].find("--switch=") == 0) + { + // Enable or disable color based on the switch value. + std::string value = args[i].substr(9); + if(!value.empty()) + { + if(cmSystemTools::IsOn(value.c_str())) + { + enabled = true; + } + else + { + enabled = false; + } + } + } + else if(args[i] == "--normal") + { + color = cmsysTerminal_Color_Normal; + } + else if(args[i] == "--black") + { + color = cmsysTerminal_Color_ForegroundBlack; + } + else if(args[i] == "--red") + { + color = cmsysTerminal_Color_ForegroundRed; + } + else if(args[i] == "--green") + { + color = cmsysTerminal_Color_ForegroundGreen; + } + else if(args[i] == "--yellow") + { + color = cmsysTerminal_Color_ForegroundYellow; + } + else if(args[i] == "--blue") + { + color = cmsysTerminal_Color_ForegroundBlue; + } + else if(args[i] == "--magenta") + { + color = cmsysTerminal_Color_ForegroundMagenta; + } + else if(args[i] == "--cyan") + { + color = cmsysTerminal_Color_ForegroundCyan; + } + else if(args[i] == "--white") + { + color = cmsysTerminal_Color_ForegroundWhite; + } + else if(args[i] == "--bold") + { + color |= cmsysTerminal_Color_ForegroundBold; + } + else if(args[i] == "--no-newline") + { + newline = false; + } + else if(args[i] == "--newline") + { + newline = true; + } + else if(enabled) + { + // Color is enabled. Print with the current color. + cmsysTerminal_cfprintf(color | assumeTTY, stdout, "%s%s", + args[i].c_str(), newline? "\n" : ""); + } + else + { + // Color is disabled. Print without color. + fprintf(stdout, "%s%s", args[i].c_str(), newline? "\n" : ""); + } + } + + return 0; +} +#else +int cmake::ExecuteEchoColor(std::vector<std::string>&) +{ + return 1; +} +#endif diff --git a/Source/cmake.h b/Source/cmake.h index ca3e0bc..18d2587 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -315,6 +315,8 @@ protected: void CleanupCommandsAndMacros(); void GenerateGraphViz(const char* fileName); + + static int ExecuteEchoColor(std::vector<std::string>& args); cmVariableWatch* VariableWatch; diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index 1cd4b4a..2269db0 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -94,6 +94,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) SET(KWSYS_USE_SystemTools 1) SET(KWSYS_USE_CommandLineArguments 1) SET(KWSYS_USE_FundamentalType 1) + SET(KWSYS_USE_Terminal 1) ENDIF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) #----------------------------------------------------------------------------- @@ -436,7 +437,7 @@ FOREACH(cpp ${cppclasses}) ENDFOREACH(cpp) # Add selected C components. -FOREACH(c Process Base64 FundamentalType) +FOREACH(c Process Base64 FundamentalType Terminal) IF(KWSYS_USE_${c}) SET(KWSYS_H_FILES ${KWSYS_H_FILES} ${c}) ENDIF(KWSYS_USE_${c}) @@ -463,10 +464,12 @@ IF(KWSYS_USE_Process) ENDIF(NOT UNIX) ENDIF(KWSYS_USE_Process) -# Add sources for Base64 encoding. -IF(KWSYS_USE_Base64) - SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} Base64.c) -ENDIF(KWSYS_USE_Base64) +# Add selected C sources. +FOREACH(c Base64 Terminal) + IF(KWSYS_USE_${c}) + SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ${c}.c) + ENDIF(KWSYS_USE_${c}) +ENDFOREACH(c) # Configure headers of C++ classes and construct the list of sources. FOREACH(c ${KWSYS_CLASSES}) @@ -632,6 +635,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) FOREACH(test testProcess testFail + testTerminal ) ADD_EXECUTABLE(${test} ${test}.c) TARGET_LINK_LIBRARIES(${test} ${KWSYS_NAMESPACE}_c) diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 6ab76b4..e70d3fc 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -3466,7 +3466,7 @@ bool SystemTools::IsSubDirectory(const char* cSubdir, const char* cDir) do { path = SystemTools::GetParentDirectory(path.c_str()); - if ( dir == path ) + if(SystemTools::ComparePath(dir.c_str(), path.c_str())) { return true; } |