diff options
-rw-r--r-- | Modules/CTest.cmake | 3 | ||||
-rw-r--r-- | Modules/DartConfiguration.tcl.in | 5 | ||||
-rw-r--r-- | Modules/DeployQt4.cmake | 274 | ||||
-rw-r--r-- | Modules/FindQt4.cmake | 8 | ||||
-rw-r--r-- | Modules/UseQt4.cmake | 2 | ||||
-rw-r--r-- | Source/CTest/cmCTestCoverageHandler.cxx | 9 | ||||
-rw-r--r-- | Source/cmDocumentVariables.cxx | 9 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio11Generator.cxx | 2 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 5 | ||||
-rw-r--r-- | Source/cmQtAutomoc.cxx | 178 | ||||
-rw-r--r-- | Source/cmQtAutomoc.h | 16 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 4 | ||||
-rw-r--r-- | Source/kwsys/SystemTools.hxx.in | 4 | ||||
-rw-r--r-- | Source/kwsys/kwsysDateStamp.cmake | 2 | ||||
-rw-r--r-- | Tests/QtAutomoc/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/QtAutomoc/foo.cpp | 39 | ||||
-rw-r--r-- | Tests/QtAutomoc/foo.h | 28 | ||||
-rw-r--r-- | Tests/QtAutomoc/main.cpp | 4 |
18 files changed, 500 insertions, 94 deletions
diff --git a/Modules/CTest.cmake b/Modules/CTest.cmake index c261eb3..ec9dbeb 100644 --- a/Modules/CTest.cmake +++ b/Modules/CTest.cmake @@ -189,6 +189,8 @@ IF(BUILD_TESTING) FIND_PROGRAM(COVERAGE_COMMAND gcov DOC "Path to the coverage program that CTest uses for performing coverage inspection" ) + SET(COVERAGE_EXTRA_FLAGS "-l" CACHE STRING + "Extra command line flags to pass to the coverage tool") # set the site name SITE_NAME(SITE) @@ -257,6 +259,7 @@ IF(BUILD_TESTING) BZRCOMMAND BZR_UPDATE_OPTIONS COVERAGE_COMMAND + COVERAGE_EXTRA_FLAGS CTEST_SUBMIT_RETRY_DELAY CTEST_SUBMIT_RETRY_COUNT CVSCOMMAND diff --git a/Modules/DartConfiguration.tcl.in b/Modules/DartConfiguration.tcl.in index caf0afe..ad7f805 100644 --- a/Modules/DartConfiguration.tcl.in +++ b/Modules/DartConfiguration.tcl.in @@ -59,14 +59,17 @@ UpdateType: @UPDATE_TYPE@ # Compiler info Compiler: @CMAKE_CXX_COMPILER@ -# Dynamic analysis and coverage +# Dynamic analysis (MemCheck) PurifyCommand: @PURIFYCOMMAND@ ValgrindCommand: @VALGRIND_COMMAND@ ValgrindCommandOptions: @VALGRIND_COMMAND_OPTIONS@ MemoryCheckCommand: @MEMORYCHECK_COMMAND@ MemoryCheckCommandOptions: @MEMORYCHECK_COMMAND_OPTIONS@ MemoryCheckSuppressionFile: @MEMORYCHECK_SUPPRESSIONS_FILE@ + +# Coverage CoverageCommand: @COVERAGE_COMMAND@ +CoverageExtraFlags: @COVERAGE_EXTRA_FLAGS@ # Cluster commands SlurmBatchCommand: @SLURM_SBATCH_COMMAND@ diff --git a/Modules/DeployQt4.cmake b/Modules/DeployQt4.cmake new file mode 100644 index 0000000..bdf8360 --- /dev/null +++ b/Modules/DeployQt4.cmake @@ -0,0 +1,274 @@ +# - Functions to help assemble a standalone Qt4 executable. +# A collection of CMake utility functions useful for deploying +# Qt4 executables. +# +# The following functions are provided by this module: +# write_qt4_conf +# resolve_qt4_paths +# fixup_qt4_executable +# install_qt4_plugin_path +# install_qt4_plugin +# install_qt4_executable +# Requires CMake 2.6 or greater because it uses function and +# PARENT_SCOPE. Also depends on BundleUtilities.cmake. +# +# WRITE_QT4_CONF(<qt_conf_dir> <qt_conf_contents>) +# Writes a qt.conf file with the <qt_conf_contents> into <qt_conf_dir>. +# +# RESOLVE_QT4_PATHS(<paths_var> [<executable_path>]) +# Loop through <paths_var> list and if any don't exist resolve them +# relative to the <executable_path> (if supplied) or the CMAKE_INSTALL_PREFIX. +# +# FIXUP_QT4_EXECUTABLE(<executable> [<qtplugins> <libs> <dirs> <plugins_dir> <request_qt_conf>]) +# Copies Qt plugins, writes a Qt configuration file (if needed) and fixes up a +# Qt4 executable using BundleUtilities so it is standalone and can be +# drag-and-drop copied to another machine as long as all of the system +# libraries are compatible. +# +# <executable> should point to the executable to be fixed-up. +# +# <qtplugins> should contain a list of the names or paths of any Qt plugins +# to be installed. +# +# <libs> will be passed to BundleUtilities and should be a list of any already +# installed plugins, libraries or executables to also be fixed-up. +# +# <dirs> will be passed to BundleUtilities and should contain and directories +# to be searched to find library dependencies. +# +# <plugins_dir> allows an custom plugins directory to be used. +# +# <request_qt_conf> will force a qt.conf file to be written even if not needed. +# +# INSTALL_QT4_PLUGIN_PATH(plugin executable copy installed_plugin_path_var <plugins_dir> <component> <configurations>) +# Install (or copy) a resolved <plugin> to the default plugins directory +# (or <plugins_dir>) relative to <executable> and store the result in +# <installed_plugin_path_var>. +# +# If <copy> is set to TRUE then the plugins will be copied rather than +# installed. This is to allow this module to be used at CMake time rather than +# install time. +# +# If <component> is set then anything installed will use this COMPONENT. +# +# INSTALL_QT4_PLUGIN(plugin executable copy installed_plugin_path_var <plugins_dir> <component>) +# Install (or copy) an unresolved <plugin> to the default plugins directory +# (or <plugins_dir>) relative to <executable> and store the result in +# <installed_plugin_path_var>. See documentation of INSTALL_QT4_PLUGIN_PATH. +# +# INSTALL_QT4_EXECUTABLE(<executable> <qtplugins> [<libs> <dirs> <plugins_dir> <request_qt_conf>]) +# Installs Qt plugins, writes a Qt configuration file (if needed) and fixes up +# a Qt4 executable using BundleUtilities so it is standalone and can be +# drag-and-drop copied to another machine as long as all of the system +# libraries are compatible. The executable will be fixed-up at install time. +# See documentation of FIXUP_QT4_BUNDLE. + +#============================================================================= +# Copyright 2011 Mike McQuaid <mike@mikemcquaid.com> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# The functions defined in this file depend on the fixup_bundle function +# (and others) found in BundleUtilities.cmake + +include(BundleUtilities) +set(DeployQt4_cmake_dir "${CMAKE_CURRENT_LIST_DIR}") + +function(write_qt4_conf qt_conf_dir qt_conf_contents) + set(qt_conf_path "${qt_conf_dir}/qt.conf") + message(STATUS "Writing ${qt_conf_path}") + file(WRITE "${qt_conf_path}" "${qt_conf_contents}") +endfunction() + +function(resolve_qt4_paths paths_var) + set(executable_path ${ARGV1}) + + set(paths_resolved) + foreach(path ${${paths_var}}) + if(EXISTS "${path}") + list(APPEND paths_resolved "${path}") + else() + if(${executable_path}) + list(APPEND paths_resolved "${executable_path}/${path}") + else() + list(APPEND paths_resolved "\${CMAKE_INSTALL_PREFIX}/${path}") + endif() + endif() + endforeach() + set(${paths_var} ${paths_resolved} PARENT_SCOPE) +endfunction() + +function(fixup_qt4_executable executable qtplugins) + set(libs ${ARGV2}) + set(dirs ${ARGV3}) + set(plugins_dir ${ARGV4}) + set(request_qt_conf ${ARGV5}) + + message(STATUS "fixup_qt4_executable") + message(STATUS " executable='${executable}'") + message(STATUS " qtplugins='${qtplugins}'") + message(STATUS " libs='${libs}'") + message(STATUS " dirs='${dirs}'") + message(STATUS " plugins_dir='${plugins_dir}'") + message(STATUS " request_qt_conf='${request_qt_conf}'") + + if(QT_LIBRARY_DIR) + list(APPEND dirs "${QT_LIBRARY_DIR}") + endif() + + if(APPLE) + set(qt_conf_dir "${executable}/Contents/Resources") + set(executable_path "${executable}") + set(write_qt_conf TRUE) + else() + get_filename_component(executable_path "${executable}" PATH) + if(NOT executable_path) + set(executable_path ".") + endif() + set(qt_conf_dir "${executable_path}") + set(write_qt_conf ${request_qt_conf}) + endif() + + foreach(plugin ${qtplugins}) + set(installed_plugin_path "") + install_qt4_plugin("${plugin}" "${plugins_dir}" "${executable}" 1 installed_plugin_path) + list(APPEND libs ${installed_plugin_path}) + endforeach() + + foreach(lib ${libs}) + if(NOT EXISTS "${lib}") + message(FATAL_ERROR "Library does not exist: ${lib}") + endif() + endforeach() + + resolve_qt4_paths(libs "${executable_path}") + resolve_qt4_paths(dirs "${executable_path}") + + if(write_qt_conf) + set(qt_conf_contents "[Paths]\nPlugins = ${plugins_dir}") + write_qt4_conf("${qt_conf_dir}" "${qt_conf_contents}") + endif() + + fixup_bundle("${executable}" "${libs}" "${dirs}") +endfunction() + +function(install_qt4_plugin_path plugin executable copy installed_plugin_path_var) + set(plugins_dir ${ARGV4}) + set(component ${ARGV5}) + set(configurations ${ARGV6}) + if(EXISTS "${plugin}") + if(plugins_dir) + set(plugins_dir "${plugins_dir}") + else() + if(APPLE) + set(plugins_dir "PlugIns") + else() + set(plugins_dir "plugins") + endif() + endif() + if(APPLE) + set(plugins_path "${executable}/Contents/${plugins_dir}") + else() + get_filename_component(executable_path "${executable}" PATH) + if(NOT executable_path) + set(executable_path ".") + endif() + set(plugins_path "${executable_path}/${plugins_dir}") + endif() + + set(plugin_group "") + + get_filename_component(plugin_path "${plugin}" PATH) + get_filename_component(plugin_parent_path "${plugin_path}" PATH) + get_filename_component(plugin_parent_dir_name "${plugin_parent_path}" NAME) + get_filename_component(plugin_name "${plugin}" NAME) + string(TOLOWER "${plugin_parent_dir_name}" plugin_parent_dir_name) + + if("${plugin_parent_dir_name}" STREQUAL "plugins") + get_filename_component(plugin_group "${plugin_path}" NAME) + set(${plugin_group_var} "${plugin_group}") + endif() + set(plugins_path "${plugins_path}/${plugin_group}") + + if(${copy}) + file(MAKE_DIRECTORY "${plugins_path}") + file(COPY "${plugin}" DESTINATION "${plugins_path}") + else() + if(configurations AND (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)) + set(configurations CONFIGURATIONS ${configurations}) + endif() + if(component) + set(component COMPONENT ${component}) + endif() + install(FILES "${plugin}" DESTINATION "${plugins_path}" ${configurations} ${component}) + endif() + set(${installed_plugin_path_var} ${${installed_path_var}} "${plugins_path}/${plugin_name}" PARENT_SCOPE) + endif() +endfunction() + +function(install_qt4_plugin plugin executable copy installed_plugin_path_var) + set(plugins_dir ${ARGV4}) + set(component ${ARGV5}) + if(EXISTS "${plugin}") + install_qt4_plugin_path("${plugin}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}") + else() + if(QT_IS_STATIC) + string(TOUPPER "QT_${plugin}_LIBRARY" plugin_var) + else() + string(TOUPPER "QT_${plugin}_PLUGIN" plugin_var) + endif() + set(plugin_release "${${plugin_var}_RELEASE}") + set(plugin_debug "${${plugin_var}_DEBUG}") + if(NOT EXISTS "${plugin_release}" AND NOT EXISTS "${plugin_debug}") + message(WARNING "Qt plugin \"${plugin}\" not recognized or found.") + endif() + install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}" "Release|RelWithDebInfo|MinSizeRel") + install_qt4_plugin_path("${plugin_debug}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}" "Debug") + endif() + set(installed_plugin_path_var "${installed_plugin_path_var}" PARENT_SCOPE) +endfunction() + +function(install_qt4_executable executable) + set(qtplugins ${ARGV1}) + set(libs ${ARGV2}) + set(dirs ${ARGV3}) + set(plugins_dir ${ARGV4}) + set(request_qt_conf ${ARGV5}) + set(plugin_component ${ARGV6}) + if(QT_LIBRARY_DIR) + list(APPEND dirs "${QT_LIBRARY_DIR}") + endif() + + get_filename_component(executable_absolute "${executable}" ABSOLUTE) + gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY}" qtcore_type) + if(qtcore_type STREQUAL "system") + set(qt_plugins_dir "") + endif() + + if(NOT qtplugins AND QT_LIBRARIES_PLUGINS) + set(qtplugins "${QT_LIBRARIES_PLUGINS}") + endif() + + foreach(plugin ${qtplugins}) + set(installed_plugin_paths "") + install_qt4_plugin("${plugin}" "${executable}" 0 installed_plugin_paths "${plugins_dir}" "${plugin_component}") + list(APPEND libs ${installed_plugin_paths}) + endforeach() + + resolve_qt4_paths(libs) + resolve_qt4_paths(dirs) + + install(CODE + " INCLUDE( \"${DeployQt4_cmake_dir}/DeployQt4.cmake\" ) + SET( BU_CHMOD_BUNDLE_ITEMS TRUE ) + FIXUP_QT4_EXECUTABLE( \"\${CMAKE_INSTALL_PREFIX}/${executable}\" \"\" \"${libs}\" \"${dirs}\" \"${plugins_dir}\" \"${request_qt_conf}\" ) " + ) +endfunction() diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 3b05c2b..c56827e 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -1062,6 +1062,14 @@ IF (QT_QMAKE_EXECUTABLE AND QTVERSION) SET( QT_SCRIPT_PLUGINS qtscriptdbus ) SET( QT_SQLDRIVERS_PLUGINS qsqldb2 qsqlibase qsqlite qsqlite2 qsqlmysql qsqloci qsqlodbc qsqlpsql qsqltds ) + SET( QT_PHONON_PLUGINS ${QT_PHONON_BACKEND_PLUGINS} ) + SET( QT_QT3SUPPORT_PLUGINS qtaccessiblecompatwidgets ) + SET( QT_QTCORE_PLUGINS ${QT_BEARER_PLUGINS} ${QT_CODECS_PLUGINS} ) + SET( QT_QTGUI_PLUGINS qtaccessiblewidgets qgif qjpeg qmng qico qtiff ${QT_DECORATIONS_PLUGINS} ${QT_GRAPHICSDRIVERS_PLUGINS} ${QT_GRAPHICSSYSTEMS_PLUGINS} ${QT_INPUTMETHODS_PLUGINS} ${QT_MOUSEDRIVERS_PLUGINS} ) + SET( QT_QTSCRIPT_PLUGINS ${QT_SCRIPT_PLUGINS} ) + SET( QT_QTSQL_PLUGINS ${QT_SQLDRIVERS_PLUGINS} ) + SET( QT_QTSVG_PLUGINS qsvg qsvgicon ) + IF(QT_QMAKE_CHANGED) FOREACH(QT_PLUGIN_TYPE ${QT_PLUGIN_TYPES}) STRING(TOUPPER ${QT_PLUGIN_TYPE} _upper_qt_plugin_type) diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake index dbe28ac..b824392 100644 --- a/Modules/UseQt4.cmake +++ b/Modules/UseQt4.cmake @@ -28,6 +28,7 @@ ENDIF() INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR}) SET(QT_LIBRARIES "") +SET(QT_LIBRARIES_PLUGINS "") IF (QT_USE_QTMAIN) IF (Q_WS_WIN) @@ -91,6 +92,7 @@ FOREACH(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN INCLUDE_DIRECTORIES(${QT_${module}_INCLUDE_DIR}) ENDIF(QT_USE_${module}) SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIBRARY}) + SET(QT_LIBRARIES_PLUGINS ${QT_LIBRARIES_PLUGINS} ${QT_${module}_PLUGINS}) IF(QT_IS_STATIC) SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIB_DEPENDENCIES}) ENDIF(QT_IS_STATIC) diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 005651f..0b1c9fe 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -751,12 +751,15 @@ int cmCTestCoverageHandler::HandlePHPCoverage( } return static_cast<int>(cont->TotalCoverage.size()); } + //---------------------------------------------------------------------- int cmCTestCoverageHandler::HandleGCovCoverage( cmCTestCoverageHandlerContainer* cont) { std::string gcovCommand = this->CTest->GetCTestConfiguration("CoverageCommand"); + std::string gcovExtraFlags + = this->CTest->GetCTestConfiguration("CoverageExtraFlags"); // Style 1 std::string st1gcovOutputRex1 @@ -825,8 +828,10 @@ int cmCTestCoverageHandler::HandleGCovCoverage( // Call gcov to get coverage data for this *.gcda file: // std::string fileDir = cmSystemTools::GetFilenamePath(it->c_str()); - std::string command = "\"" + gcovCommand + "\" -l -p -o \"" + fileDir - + "\" \"" + *it + "\""; + std::string command = "\"" + gcovCommand + "\" " + + gcovExtraFlags + " " + + "-o \"" + fileDir + "\" " + + "\"" + *it + "\""; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, command.c_str() << std::endl); diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index f2b01f1..f4d4e7c 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -1219,7 +1219,14 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Therefore a specific build configuration must be chosen even " "if the generated build system supports multiple configurations.",false, "Variables that Control the Build"); - + cm->DefineProperty + ("CMAKE_LINK_INTERFACE_LIBRARIES", cmProperty::VARIABLE, + "Default value for LINK_INTERFACE_LIBRARIES of targets.", + "This variable is used to initialize the " + "LINK_INTERFACE_LIBRARIES property on all the targets. " + "See that target property for additional information.", + false, + "Variables that Control the Build"); // Variables defined when the a language is enabled These variables will // also be defined whenever CMake has loaded its support for compiling (LANG) diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index a70427a..97308bb 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -32,7 +32,7 @@ void cmGlobalVisualStudio11Generator::AddPlatformDefinitions(cmMakefile* mf) void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout) { fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n"; - fout << "# Visual Studio 2011\n"; + fout << "# Visual Studio 11\n"; } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 09265ae..32eaef8 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1328,6 +1328,8 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, cmSystemTools::ReplaceString(makecmd, "\\ ", "\\\\ "); buildphase->AddAttribute("shellScript", this->CreateString(makecmd.c_str())); + buildphase->AddAttribute("showEnvVarsInLog", + this->CreateString("0")); } //---------------------------------------------------------------------------- @@ -2065,6 +2067,9 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) shellBuildPhase->AddAttribute("shellScript", this->CreateString( "# shell script goes here\nexit 0")); + shellBuildPhase->AddAttribute("showEnvVarsInLog", + this->CreateString("0")); + cmXCodeObject* target = this->CreateObject(cmXCodeObject::PBXAggregateTarget); target->SetComment(cmtarget.GetName()); diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index abda47e..a839489 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -1,3 +1,16 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + #include "cmGlobalGenerator.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" @@ -377,9 +390,8 @@ bool cmQtAutomoc::RunAutomocQt4() // key = moc source filepath, value = moc output filepath std::map<std::string, std::string> includedMocs; - // key = moc source filepath, value = moc output filename - std::map<std::string, std::string> notIncludedMocs; - + // collect all headers which may need to be mocced + std::set<std::string> headerFiles; std::vector<std::string> sourceFiles; cmSystemTools::ExpandListArgument(this->Sources, sourceFiles); @@ -393,34 +405,22 @@ bool cmQtAutomoc::RunAutomocQt4() { std::cout << "AUTOMOC: Checking " << absFilename << std::endl; } - this->ParseCppFile(absFilename, includedMocs, notIncludedMocs); + this->ParseCppFile(absFilename, includedMocs, headerFiles); } - std::vector<std::string> headerFiles; - cmSystemTools::ExpandListArgument(this->Headers, headerFiles); - for (std::vector<std::string>::const_iterator it = headerFiles.begin(); - it != headerFiles.end(); + std::vector<std::string> headerFilesVec; + cmSystemTools::ExpandListArgument(this->Headers, headerFilesVec); + for (std::vector<std::string>::const_iterator it = headerFilesVec.begin(); + it != headerFilesVec.end(); ++it) { - const std::string &absFilename = *it; - if (this->Verbose) - { - std::cout << "AUTOMOC: Checking " << absFilename << std::endl; - } - if (includedMocs.find(absFilename) == includedMocs.end() - && notIncludedMocs.find(absFilename) == notIncludedMocs.end()) - { - // if this header is not getting processed yet and is explicitly - // mentioned for the automoc the moc is run unconditionally on the - // header and the resulting file is included in the _automoc.cpp file - // (unless there's a .cpp file later on that includes the moc from - // this header) - const std::string currentMoc = "moc_" + cmsys::SystemTools:: - GetFilenameWithoutLastExtension(absFilename) + ".cpp"; - notIncludedMocs[absFilename] = currentMoc; - } + headerFiles.insert(*it); } + // key = moc source filepath, value = moc output filename + std::map<std::string, std::string> notIncludedMocs; + this->ParseHeaders(headerFiles, includedMocs, notIncludedMocs); + // run moc on all the moc's that are #included in source files for(std::map<std::string, std::string>::const_iterator it = includedMocs.begin(); @@ -487,12 +487,11 @@ bool cmQtAutomoc::RunAutomocQt4() void cmQtAutomoc::ParseCppFile(const std::string& absFilename, std::map<std::string, std::string>& includedMocs, - std::map<std::string, std::string>& notIncludedMocs) + std::set<std::string>& absHeaders) { cmsys::RegularExpression mocIncludeRegExp( "[\n][ \t]*#[ \t]*include[ \t]+" "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]"); - cmsys::RegularExpression qObjectRegExp("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]"); std::list<std::string> headerExtensions; headerExtensions.push_back(".h"); headerExtensions.push_back(".hpp"); @@ -520,52 +519,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/'; std::string::size_type matchOffset = 0; - if (!mocIncludeRegExp.find(contentsString.c_str())) - { - // no moc #include, look whether we need to create a moc from - // the .h nevertheless - const std::string basename = - cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename); - for(std::list<std::string>::const_iterator ext = headerExtensions.begin(); - ext != headerExtensions.end(); - ++ext) - { - const std::string headername = absPath + basename + (*ext); - if (cmsys::SystemTools::FileExists(headername.c_str()) - && includedMocs.find(headername) == includedMocs.end() - && notIncludedMocs.find(headername) == notIncludedMocs.end()) - { - const std::string currentMoc = "moc_" + basename + ".cpp"; - const std::string contents = this->ReadAll(headername); - if (qObjectRegExp.find(contents)) - { - //std::cout << "header contains Q_OBJECT macro"; - notIncludedMocs[headername] = currentMoc; - } - break; - } - } - for(std::list<std::string>::const_iterator ext = headerExtensions.begin(); - ext != headerExtensions.end(); - ++ext) - { - const std::string privateHeaderName = absPath+basename+"_p"+(*ext); - if (cmsys::SystemTools::FileExists(privateHeaderName.c_str()) - && includedMocs.find(privateHeaderName) == includedMocs.end() - && notIncludedMocs.find(privateHeaderName) == notIncludedMocs.end()) - { - const std::string currentMoc = "moc_" + basename + "_p.cpp"; - const std::string contents = this->ReadAll(privateHeaderName); - if (qObjectRegExp.find(contents)) - { - //std::cout << "header contains Q_OBJECT macro"; - notIncludedMocs[privateHeaderName] = currentMoc; - } - break; - } - } - } - else + if (mocIncludeRegExp.find(contentsString.c_str())) { // for every moc include in the file do @@ -581,17 +535,13 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, // the Q_OBJECT class declaration in a header file. // If the moc include is of the foo.moc style we need to look for // a Q_OBJECT macro in the current source file, if it contains the - // macro we generate the moc file from the source file, else from the - // header. + // macro we generate the moc file from the source file. // Q_OBJECT - if (moc_style || !qObjectRegExp.find(contentsString)) + if (moc_style) { - if (moc_style) - { - // basename should be the part of the moc filename used for - // finding the correct header, so we need to remove the moc_ part - basename = basename.substr(4); - } + // basename should be the part of the moc filename used for + // finding the correct header, so we need to remove the moc_ part + basename = basename.substr(4); bool headerFound = false; for(std::list<std::string>::const_iterator ext = @@ -604,7 +554,6 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, { headerFound = true; includedMocs[sourceFilePath] = currentMoc; - notIncludedMocs.erase(sourceFilePath); break; } } @@ -628,7 +577,6 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, { headerFound = true; includedMocs[sourceFilePath] = currentMoc; - notIncludedMocs.erase(sourceFilePath); break; } } @@ -658,11 +606,71 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename, else { includedMocs[absFilename] = currentMoc; - notIncludedMocs.erase(absFilename); } matchOffset += mocIncludeRegExp.end(); } while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset)); } + + // search for header files and private header files we may need to moc: + const std::string basename = + cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename); + for(std::list<std::string>::const_iterator ext = headerExtensions.begin(); + ext != headerExtensions.end(); + ++ext) + { + const std::string headerName = absPath + basename + (*ext); + if (cmsys::SystemTools::FileExists(headerName.c_str())) + { + absHeaders.insert(headerName); + break; + } + } + for(std::list<std::string>::const_iterator ext = headerExtensions.begin(); + ext != headerExtensions.end(); + ++ext) + { + const std::string privateHeaderName = absPath+basename+"_p"+(*ext); + if (cmsys::SystemTools::FileExists(privateHeaderName.c_str())) + { + absHeaders.insert(privateHeaderName); + break; + } + } + +} + + +void cmQtAutomoc::ParseHeaders(const std::set<std::string>& absHeaders, + const std::map<std::string, std::string>& includedMocs, + std::map<std::string, std::string>& notIncludedMocs) +{ + cmsys::RegularExpression qObjectRegExp("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]"); + for(std::set<std::string>::const_iterator hIt=absHeaders.begin(); + hIt!=absHeaders.end(); + ++hIt) + { + const std::string& headerName = *hIt; + + if (includedMocs.find(headerName) == includedMocs.end()) + { + if (this->Verbose) + { + std::cout << "AUTOMOC: Checking " << headerName << std::endl; + } + + const std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(headerName); + + const std::string currentMoc = "moc_" + basename + ".cpp"; + const std::string contents = this->ReadAll(headerName); + if (qObjectRegExp.find(contents)) + { + //std::cout << "header contains Q_OBJECT macro"; + notIncludedMocs[headerName] = currentMoc; + } + } + } + } diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutomoc.h index 4fd9041..c3550a4 100644 --- a/Source/cmQtAutomoc.h +++ b/Source/cmQtAutomoc.h @@ -1,3 +1,16 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + #ifndef cmQtAutomoc_h #define cmQtAutomoc_h @@ -27,6 +40,9 @@ private: const std::string& mocFileName); void ParseCppFile(const std::string& absFilename, std::map<std::string, std::string>& includedMocs, + std::set<std::string>& absHeaders); + void ParseHeaders(const std::set<std::string>& absHeaders, + const std::map<std::string, std::string>& includedMocs, std::map<std::string, std::string>& notIncludedMocs); void Init(); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e74e70c..f7d3ba9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -642,6 +642,9 @@ void cmTarget::DefineProperties(cmake *cm) "If the list is empty then no transitive link dependencies will be " "incorporated when this target is linked into another target even if " "the default set is non-empty. " + "This property is initialized by the value of the variable " + "CMAKE_LINK_INTERFACE_LIBRARIES if it is set when a target is " + "created. " "This property is ignored for STATIC libraries."); cm->DefineProperty @@ -1176,6 +1179,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0); this->SetPropertyDefault("OSX_ARCHITECTURES", 0); this->SetPropertyDefault("AUTOMOC", 0); + this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", 0); // Collect the set of configuration types. std::vector<std::string> configNames; diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index fd2ed19..04f1978 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -612,7 +612,7 @@ public: * Up to 'length' bytes are read from the file, if more than 'percent_bin' % * of the bytes are non-textual elements, the file is considered binary, * otherwise textual. Textual elements are bytes in the ASCII [0x20, 0x7E] - * range, but also \n, \r, \t. + * range, but also \\n, \\r, \\t. * The algorithm is simplistic, and should probably check for usual file * extensions, 'magic' signature, unicode, etc. */ @@ -812,7 +812,7 @@ public: * Convert windows-style arguments given as a command-line string * into more traditional argc/argv arguments. * Note that argv[0] will be assigned the executable name using - * the ::GetModuleFileName function. + * the GetModuleFileName() function. */ static void ConvertWindowsCommandLineToUnixArguments( const char *cmd_line, int *argc, char ***argv); diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 80902d5..b452f6d 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 10) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 19) +SET(KWSYS_DATE_STAMP_DAY 25) diff --git a/Tests/QtAutomoc/CMakeLists.txt b/Tests/QtAutomoc/CMakeLists.txt index 4a5ff10..01f6bea 100644 --- a/Tests/QtAutomoc/CMakeLists.txt +++ b/Tests/QtAutomoc/CMakeLists.txt @@ -13,7 +13,7 @@ add_definitions(-DFOO) # create an executable and a library target, both requiring automoc: add_library(codeeditorLib STATIC codeeditor.cpp) -add_executable(foo main.cpp calwidget.cpp ) +add_executable(foo main.cpp calwidget.cpp foo.cpp) set_target_properties(foo codeeditorLib PROPERTIES AUTOMOC TRUE) diff --git a/Tests/QtAutomoc/foo.cpp b/Tests/QtAutomoc/foo.cpp new file mode 100644 index 0000000..699ba09 --- /dev/null +++ b/Tests/QtAutomoc/foo.cpp @@ -0,0 +1,39 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#include "foo.h" + +#include <stdio.h> + +class FooFoo : public QObject +{ + Q_OBJECT + public: + FooFoo():QObject() {} + public slots: + int getValue() const { return 12; } +}; + +Foo::Foo() +:QObject() +{ +} + + +void Foo::doFoo() +{ + FooFoo ff; + printf("Hello automoc: %d\n", ff.getValue()); +} + +#include "foo.moc" diff --git a/Tests/QtAutomoc/foo.h b/Tests/QtAutomoc/foo.h new file mode 100644 index 0000000..32d4c8d --- /dev/null +++ b/Tests/QtAutomoc/foo.h @@ -0,0 +1,28 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef FOO_H +#define FOO_H + +#include <QObject> + +class Foo : public QObject +{ + Q_OBJECT + public: + Foo(); + public slots: + void doFoo(); +}; + +#endif diff --git a/Tests/QtAutomoc/main.cpp b/Tests/QtAutomoc/main.cpp index 7bf4a5d..b7cfb41 100644 --- a/Tests/QtAutomoc/main.cpp +++ b/Tests/QtAutomoc/main.cpp @@ -42,6 +42,7 @@ #include "codeeditor.h" #include "calwidget.h" +#include "foo.h" int main(int argv, char **args) { @@ -54,5 +55,8 @@ int main(int argv, char **args) Window w; w.show(); + Foo foo; + foo.doFoo(); + return app.exec(); } |