diff options
57 files changed, 837 insertions, 490 deletions
diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake index 6cd8fe6..ee8040e 100644 --- a/Modules/CMakeGenericSystem.cmake +++ b/Modules/CMakeGenericSystem.cmake @@ -39,6 +39,8 @@ SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) SET (CMAKE_SKIP_RPATH "NO" CACHE BOOL "If set, runtime paths are not added when using shared libraries.") +SET (CMAKE_SKIP_INSTALL_RPATH "NO" CACHE BOOL + "If set, runtime paths are not added when installing shared libraries, but are added when building.") SET(CMAKE_VERBOSE_MAKEFILE FALSE CACHE BOOL "If this value is on, makefiles will be generated without the .SILENT directive, and all commands will be echoed to the console during the make. This is useful for debugging only. With Visual Studio IDE projects all commands are done without /nologo.") @@ -168,5 +170,6 @@ ENDIF(CMAKE_HOST_UNIX) MARK_AS_ADVANCED( CMAKE_SKIP_RPATH + CMAKE_SKIP_INSTALL_RPATH CMAKE_VERBOSE_MAKEFILE ) diff --git a/Modules/DeployQt4.cmake b/Modules/DeployQt4.cmake index 83f322c..8a5e9c5 100644 --- a/Modules/DeployQt4.cmake +++ b/Modules/DeployQt4.cmake @@ -82,6 +82,7 @@ include(BundleUtilities) set(DeployQt4_cmake_dir "${CMAKE_CURRENT_LIST_DIR}") +set(DeployQt4_apple_plugins_dir "PlugIns") function(write_qt4_conf qt_conf_dir qt_conf_contents) set(qt_conf_path "${qt_conf_dir}/qt.conf") @@ -130,6 +131,9 @@ function(fixup_qt4_executable executable) set(qt_conf_dir "${executable}/Contents/Resources") set(executable_path "${executable}") set(write_qt_conf TRUE) + if(NOT plugins_dir) + set(plugins_dir "${DeployQt4_apple_plugins_dir}") + endif() else() get_filename_component(executable_path "${executable}" PATH) if(NOT executable_path) @@ -141,7 +145,7 @@ function(fixup_qt4_executable executable) foreach(plugin ${qtplugins}) set(installed_plugin_path "") - install_qt4_plugin("${plugin}" "${plugins_dir}" "${executable}" 1 installed_plugin_path) + install_qt4_plugin("${plugin}" "${executable}" 1 installed_plugin_path) list(APPEND libs ${installed_plugin_path}) endforeach() @@ -166,23 +170,19 @@ function(install_qt4_plugin_path plugin executable copy installed_plugin_path_va 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) + if(NOT plugins_dir) + set(plugins_dir "${DeployQt4_apple_plugins_dir}") + endif() set(plugins_path "${executable}/Contents/${plugins_dir}") else() - get_filename_component(executable_path "${executable}" PATH) - if(NOT executable_path) - set(executable_path ".") + get_filename_component(plugins_path "${executable}" PATH) + if(NOT plugins_path) + set(plugins_path ".") + endif() + if(plugins_dir) + set(plugins_path "${plugins_path}/${plugins_dir}") endif() - set(plugins_path "${executable_path}/${plugins_dir}") endif() set(plugin_group "") @@ -210,7 +210,7 @@ function(install_qt4_plugin_path plugin executable copy installed_plugin_path_va endif() install(FILES "${plugin}" DESTINATION "${plugins_path}" ${configurations} ${component}) endif() - set(${installed_plugin_path_var} ${${installed_path_var}} "${plugins_path}/${plugin_name}" PARENT_SCOPE) + set(${installed_plugin_path_var} "${plugins_path}/${plugin_name}" PARENT_SCOPE) endif() endfunction() @@ -220,11 +220,7 @@ function(install_qt4_plugin plugin executable copy installed_plugin_path_var) 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() + string(TOUPPER "QT_${plugin}_PLUGIN" plugin_var) set(plugin_release_var "${plugin_var}_RELEASE") set(plugin_debug_var "${plugin_var}_DEBUG") set(plugin_release "${${plugin_release_var}}") @@ -232,10 +228,24 @@ function(install_qt4_plugin plugin executable copy installed_plugin_path_var) if(DEFINED "${plugin_release_var}" AND DEFINED "${plugin_debug_var}" AND 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") + if(NOT EXISTS "${${plugin_debug_var}}") + set(plugin_debug "${plugin_release}") + endif() + + if(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}_release" "${plugins_dir}" "${component}" "Release|RelWithDebInfo|MinSizeRel") + install_qt4_plugin_path("${plugin_debug}" "${executable}" "${copy}" "${installed_plugin_path_var}_debug" "${plugins_dir}" "${component}" "Debug") + + if(CMAKE_BUILD_TYPE MATCHES "^Debug$") + set(${installed_plugin_path_var} ${${installed_plugin_path_var}_debug}) + else() + set(${installed_plugin_path_var} ${${installed_plugin_path_var}_release}) + endif() + else() + install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}") + endif() endif() - set(installed_plugin_path_var "${installed_plugin_path_var}" PARENT_SCOPE) + set(${installed_plugin_path_var} ${${installed_plugin_path_var}} PARENT_SCOPE) endfunction() function(install_qt4_executable executable) @@ -264,16 +274,16 @@ function(install_qt4_executable executable) set(qt_plugins_dir "") endif() - if(NOT qtplugins AND QT_LIBRARIES_PLUGINS) - set(qtplugins "${QT_LIBRARIES_PLUGINS}") + if(QT_IS_STATIC) + message(WARNING "Qt built statically: not installing plugins.") + else() + foreach(plugin ${qtplugins}) + set(installed_plugin_paths "") + install_qt4_plugin("${plugin}" "${executable}" 0 installed_plugin_paths "${plugins_dir}" "${component}") + list(APPEND libs ${installed_plugin_paths}) + endforeach() endif() - foreach(plugin ${qtplugins}) - set(installed_plugin_paths "") - install_qt4_plugin("${plugin}" "${executable}" 0 installed_plugin_paths "${plugins_dir}" "${component}") - list(APPEND libs ${installed_plugin_paths}) - endforeach() - resolve_qt4_paths(libs) install(CODE diff --git a/Modules/FindQt3.cmake b/Modules/FindQt3.cmake index 86236cc..2d8dbde 100644 --- a/Modules/FindQt3.cmake +++ b/Modules/FindQt3.cmake @@ -1,10 +1,11 @@ # - Locate Qt include paths and libraries # This module defines: -# QT_INCLUDE_DIR - where to find qt.h, etc. -# QT_LIBRARIES - the libraries to link against to use Qt. -# QT_DEFINITIONS - definitions to use when -# compiling code that uses Qt. -# QT_FOUND - If false, don't try to use Qt. +# QT_INCLUDE_DIR - where to find qt.h, etc. +# QT_LIBRARIES - the libraries to link against to use Qt. +# QT_DEFINITIONS - definitions to use when +# compiling code that uses Qt. +# QT_FOUND - If false, don't try to use Qt. +# QT_VERSION_STRING - the version of Qt found # # If you need the multithreaded version of Qt, set QT_MT_REQUIRED to TRUE # @@ -46,13 +47,16 @@ IF(QT4_FOUND) ENDIF(QT4_FOUND) -FILE(GLOB GLOB_PATHS_BIN /usr/lib/qt-3*/bin/) +FILE(GLOB GLOB_PATHS /usr/lib/qt-3*) +FOREACH(GLOB_PATH ${GLOB_PATHS}) + LIST(APPEND GLOB_PATHS_BIN "${GLOB_PATH}/bin") +ENDFOREACH(GLOB_PATH) FIND_PATH(QT_INCLUDE_DIR qt.h "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/include/Qt" "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/include/Qt" "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/include/Qt" $ENV{QTDIR}/include - ${GLOB_PATHS_BIN} + ${GLOB_PATHS} /usr/local/qt/include /usr/lib/qt/include /usr/lib/qt3/include @@ -71,12 +75,13 @@ ENDIF(NOT EXISTS ${QT_INCLUDE_DIR}/qglobal.h) IF(QT_INCLUDE_DIR) #extract the version string from qglobal.h FILE(READ ${QT_INCLUDE_DIR}/qglobal.h QGLOBAL_H) - STRING(REGEX MATCH "#define[\t ]+QT_VERSION_STR[\t ]+\"([0-9]+.[0-9]+.[0-9]+)\"" QGLOBAL_H "${QGLOBAL_H}") - STRING(REGEX REPLACE ".*\"([0-9]+.[0-9]+.[0-9]+)\".*" "\\1" qt_version_str "${QGLOBAL_H}") + STRING(REGEX MATCH "#define[\t ]+QT_VERSION_STR[\t ]+\"[0-9]+.[0-9]+.[0-9]+[a-z]*\"" QGLOBAL_H "${QGLOBAL_H}") + STRING(REGEX REPLACE ".*\"([0-9]+.[0-9]+.[0-9]+[a-z]*)\".*" "\\1" qt_version_str "${QGLOBAL_H}") # Under windows the qt library (MSVC) has the format qt-mtXYZ where XYZ is the # version X.Y.Z, so we need to remove the dots from version STRING(REGEX REPLACE "\\." "" qt_version_str_lib "${qt_version_str}") + SET(QT_VERSION_STRING "${qt_version_str}") ENDIF(QT_INCLUDE_DIR) FILE(GLOB GLOB_PATHS_LIB /usr/lib/qt-3*/lib/) @@ -195,58 +200,16 @@ IF (WIN32) ) ENDIF (WIN32) - -IF (QT_MIN_VERSION) - - STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" qt_major_vers "${qt_version_str}") - STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" qt_minor_vers "${qt_version_str}") - STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" qt_patch_vers "${qt_version_str}") - - #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) - error_message( "Invalid Qt version string given: \"${QT_MIN_VERSION}\", expected e.g. \"3.1.5\"") - ENDIF (NOT req_qt_major_vers) - - 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}") - - # req = "6.5.4", qt = "3.2.1" - MACRO(error_message msg) - IF(QT3_REQUIRED) - MESSAGE( FATAL_ERROR ${msg}) - ELSE(QT3_REQUIRED) - MESSAGE( STATUS ${msg}) - ENDIF(QT3_REQUIRED) - ENDMACRO(error_message) - - IF (req_qt_major_vers GREATER qt_major_vers) # (6 > 3) ? - ERROR_MESSAGE( "Qt major version not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})") # yes - ELSE (req_qt_major_vers GREATER qt_major_vers) # no - IF (req_qt_major_vers LESS qt_major_vers) # (6 < 3) ? - SET( QT_VERSION_BIG_ENOUGH "YES" ) # yes - ELSE (req_qt_major_vers LESS qt_major_vers) # ( 6==3) ? - IF (req_qt_minor_vers GREATER qt_minor_vers) # (5>2) ? - ERROR_MESSAGE( "Qt minor version not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})") # yes - ELSE (req_qt_minor_vers GREATER qt_minor_vers) # no - IF (req_qt_minor_vers LESS qt_minor_vers) # (5<2) ? - SET( QT_VERSION_BIG_ENOUGH "YES" ) # yes - ELSE (req_qt_minor_vers LESS qt_minor_vers) # (5==2) - IF (req_qt_patch_vers GREATER qt_patch_vers) # (4>1) ? - ERROR_MESSAGE( "Qt patch level not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})") # yes - ELSE (req_qt_patch_vers GREATER qt_patch_vers) # (4>1) ? - SET( QT_VERSION_BIG_ENOUGH "YES" ) # yes - ENDIF (req_qt_patch_vers GREATER qt_patch_vers) # (4>1) ? - ENDIF (req_qt_minor_vers LESS qt_minor_vers) - ENDIF (req_qt_minor_vers GREATER qt_minor_vers) - ENDIF (req_qt_major_vers LESS qt_major_vers) - ENDIF (req_qt_major_vers GREATER qt_major_vers) -ENDIF (QT_MIN_VERSION) +#support old QT_MIN_VERSION if set, but not if version is supplied by find_package() +IF(NOT Qt3_FIND_VERSION AND QT_MIN_VERSION) + SET(Qt3_FIND_VERSION ${QT_MIN_VERSION}) +ENDIF(NOT Qt3_FIND_VERSION AND QT_MIN_VERSION) # if the include a library are found then we have it INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Qt3 DEFAULT_MSG QT_QT_LIBRARY QT_INCLUDE_DIR QT_MOC_EXECUTABLE) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Qt3 + REQUIRED_VARS QT_QT_LIBRARY QT_INCLUDE_DIR QT_MOC_EXECUTABLE + VERSION_VAR QT_VERSION_STRING) SET(QT_FOUND ${QT3_FOUND} ) IF(QT_FOUND) @@ -296,8 +259,16 @@ IF(QT_FOUND) ENDIF(QT_QT_LIBRARY MATCHES "qt-mt") ENDIF(QT_FOUND) -EXEC_PROGRAM(${QT_MOC_EXECUTABLE} ARGS "-v" OUTPUT_VARIABLE QTVERSION_MOC) -EXEC_PROGRAM(${QT_UIC_EXECUTABLE} ARGS "-version" OUTPUT_VARIABLE QTVERSION_UIC) +IF(QT_MOC_EXECUTABLE) + EXECUTE_PROCESS(COMMAND ${QT_MOC_EXECUTABLE} "-v" + OUTPUT_VARIABLE QTVERSION_MOC + ERROR_QUIET) +ENDIF(QT_MOC_EXECUTABLE) +IF(QT_UIC_EXECUTABLE) + EXECUTE_PROCESS(COMMAND ${QT_UIC_EXECUTABLE} "-version" + OUTPUT_VARIABLE QTVERSION_UIC + ERROR_QUIET) +ENDIF(QT_UIC_EXECUTABLE) SET(_QT_UIC_VERSION_3 FALSE) IF("${QTVERSION_UIC}" MATCHES ".* 3..*") diff --git a/Source/cmCommandArgumentParserHelper.h b/Source/cmCommandArgumentParserHelper.h index a211e95..cdb832b 100644 --- a/Source/cmCommandArgumentParserHelper.h +++ b/Source/cmCommandArgumentParserHelper.h @@ -81,7 +81,6 @@ private: cmStdString InputBuffer; std::vector<char> OutputBuffer; int CurrentLine; - int UnionsAvailable; int Verbose; void Print(const char* place, const char* str); diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 57fd5b4..df78bf8 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1772,6 +1772,7 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, !linking_for_install); bool use_link_rpath = outputRuntime && linking_for_install && + !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH") && this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); // Construct the RPATH. diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx index 19558fa..9296d4c 100644 --- a/Source/cmDepends.cxx +++ b/Source/cmDepends.cxx @@ -260,12 +260,27 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends, //---------------------------------------------------------------------------- void cmDepends::SetIncludePathFromLanguage(const char* lang) { + // Look for the new per "TARGET_" variant first: + const char * includePath = 0; std::string includePathVar = "CMAKE_"; includePathVar += lang; - includePathVar += "_INCLUDE_PATH"; + includePathVar += "_TARGET_INCLUDE_PATH"; cmMakefile* mf = this->LocalGenerator->GetMakefile(); - if(const char* includePath = mf->GetDefinition(includePathVar.c_str())) + includePath = mf->GetDefinition(includePathVar.c_str()); + if(includePath) { cmSystemTools::ExpandListArgument(includePath, this->IncludePath); } + else + { + // Fallback to the old directory level variable if no per-target var: + includePathVar = "CMAKE_"; + includePathVar += lang; + includePathVar += "_INCLUDE_PATH"; + includePath = mf->GetDefinition(includePathVar.c_str()); + if(includePath) + { + cmSystemTools::ExpandListArgument(includePath, this->IncludePath); + } + } } diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index a31dd01..897e516 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -355,7 +355,9 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "If this is set to TRUE, then the rpath information " "is not added to compiled executables. The default " "is to add rpath information if the platform supports it. " - "This allows for easy running from the build tree.",false, + "This allows for easy running from the build tree. To omit RPATH" + "in the install step, but not the build step, use " + "CMAKE_SKIP_INSTALL_RPATH instead.",false, "Variables that Provide Information"); cm->DefineProperty ("CMAKE_SOURCE_DIR", cmProperty::VARIABLE, @@ -1201,6 +1203,20 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Variables that Control the Build"); cm->DefineProperty + ("CMAKE_SKIP_INSTALL_RPATH", cmProperty::VARIABLE, + "Do not include RPATHs in the install tree.", + "Normally CMake uses the build tree for the RPATH when building " + "executables etc on systems that use RPATH. When the software " + "is installed the executables etc are relinked by CMake to have " + "the install RPATH. If this variable is set to true then the software " + "is always installed without RPATH, even if RPATH is enabled when " + "building. This can be useful for example to allow running tests from " + "the build directory with RPATH enabled before the installation step. " + "To omit RPATH in both the build and install steps, use " + "CMAKE_SKIP_RPATH instead.",false, + "Variables that Control the Build"); + + cm->DefineProperty ("CMAKE_EXE_LINKER_FLAGS", cmProperty::VARIABLE, "Linker flags used to create executables.", "Flags used by the linker when creating an executable.",false, @@ -1278,6 +1294,22 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "See that target property for additional information.", false, "Variables that Control the Build"); + cm->DefineProperty + ("CMAKE_WIN32_EXECUTABLE", cmProperty::VARIABLE, + "Default value for WIN32_EXECUTABLE of targets.", + "This variable is used to initialize the " + "WIN32_EXECUTABLE property on all the targets. " + "See that target property for additional information.", + false, + "Variables that Control the Build"); + cm->DefineProperty + ("CMAKE_MACOSX_BUNDLE", cmProperty::VARIABLE, + "Default value for MACOSX_BUNDLE of targets.", + "This variable is used to initialize the " + "MACOSX_BUNDLE 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/cmExprParserHelper.cxx b/Source/cmExprParserHelper.cxx index ee37352..7728d74 100644 --- a/Source/cmExprParserHelper.cxx +++ b/Source/cmExprParserHelper.cxx @@ -30,12 +30,6 @@ cmExprParserHelper::~cmExprParserHelper() this->CleanupParser(); } -void cmExprParserHelper::SetLineFile(long line, const char* file) -{ - this->FileLine = line; - this->FileName = file; -} - int cmExprParserHelper::ParseString(const char* str, int verb) { if ( !str) diff --git a/Source/cmExprParserHelper.h b/Source/cmExprParserHelper.h index 0c36b44..690426d 100644 --- a/Source/cmExprParserHelper.h +++ b/Source/cmExprParserHelper.h @@ -46,8 +46,6 @@ public: int GetResult() { return this->Result; } - void SetLineFile(long line, const char* file); - const char* GetError() { return this->ErrorString.c_str(); } private: @@ -55,7 +53,6 @@ private: cmStdString InputBuffer; std::vector<char> OutputBuffer; int CurrentLine; - int UnionsAvailable; int Verbose; void Print(const char* place, const char* str); diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 6e246e6..ccb17f0 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -596,16 +596,17 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, // the include directories for this target std::set<std::string> uniqIncludeDirs; - const std::vector<std::string>& incDirs = - target->GetMakefile()->GetIncludeDirectories(); - for(std::vector<std::string>::const_iterator dirIt=incDirs.begin(); - dirIt != incDirs.end(); + + std::vector<std::string> includes; + target->GetMakefile()->GetLocalGenerator()-> + GetIncludeDirectories(includes, target); + for(std::vector<std::string>::const_iterator dirIt=includes.begin(); + dirIt != includes.end(); ++dirIt) { uniqIncludeDirs.insert(*dirIt); } - std::string systemIncludeDirs = makefile->GetSafeDefinition( "CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS"); if (!systemIncludeDirs.empty()) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index c8c86c7..ebd7c7f 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -893,9 +893,13 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) { - const std::vector<std::string>& includeDirs - = (*it)->GetMakefile()->GetIncludeDirectories(); - this->AppendIncludeDirectories(fout, includeDirs, emmited); + cmTargets & targets = (*it)->GetMakefile()->GetTargets(); + for (cmTargets::iterator l = targets.begin(); l != targets.end(); ++l) + { + std::vector<std::string> includeDirs; + (*it)->GetIncludeDirectories(includeDirs, &l->second); + this->AppendIncludeDirectories(fout, includeDirs, emmited); + } } // now also the system include directories, in case we found them in // CMakeSystemSpecificInformation.cmake. This makes Eclipse find the diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 8dce053..a988844 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1067,9 +1067,9 @@ void cmGlobalGenerator::CheckLocalGenerators() { manager = this->LocalGenerators[i]->GetMakefile()->GetCacheManager(); this->LocalGenerators[i]->ConfigureFinalPass(); - const cmTargets & targets = + cmTargets & targets = this->LocalGenerators[i]->GetMakefile()->GetTargets(); - for (cmTargets::const_iterator l = targets.begin(); + for (cmTargets::iterator l = targets.begin(); l != targets.end(); l++) { const cmTarget::LinkLibraryVectorType& libs = @@ -1095,27 +1095,28 @@ void cmGlobalGenerator::CheckLocalGenerators() notFoundMap[varName] = text; } } - } - const std::vector<std::string>& incs = - this->LocalGenerators[i]->GetMakefile()->GetIncludeDirectories(); + std::vector<std::string> incs; + this->LocalGenerators[i]->GetIncludeDirectories(incs, &l->second); - for( std::vector<std::string>::const_iterator incDir = incs.begin(); - incDir != incs.end(); ++incDir) - { - if(incDir->size() > 9 && - cmSystemTools::IsNOTFOUND(incDir->c_str())) + for( std::vector<std::string>::const_iterator incDir = incs.begin(); + incDir != incs.end(); ++incDir) { - std::string varName = incDir->substr(0, incDir->size()-9); - cmCacheManager::CacheIterator it = - manager->GetCacheIterator(varName.c_str()); - if(it.GetPropertyAsBool("ADVANCED")) + if(incDir->size() > 9 && + cmSystemTools::IsNOTFOUND(incDir->c_str())) { - varName += " (ADVANCED)"; + std::string varName = incDir->substr(0, incDir->size()-9); + cmCacheManager::CacheIterator it = + manager->GetCacheIterator(varName.c_str()); + if(it.GetPropertyAsBool("ADVANCED")) + { + varName += " (ADVANCED)"; + } + std::string text = notFoundMap[varName]; + text += "\n used as include directory in directory "; + text += this->LocalGenerators[i] + ->GetMakefile()->GetCurrentDirectory(); + notFoundMap[varName] = text; } - std::string text = notFoundMap[varName]; - text += "\n used as include directory in directory "; - text += this->LocalGenerators[i]->GetMakefile()->GetCurrentDirectory(); - notFoundMap[varName] = text; } } this->CMakeInstance->UpdateProgress diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 859503f..cb74746 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1811,7 +1811,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, BuildObjectListOrString dirs(this, this->XcodeVersion >= 30); BuildObjectListOrString fdirs(this, this->XcodeVersion >= 30); std::vector<std::string> includes; - this->CurrentLocalGenerator->GetIncludeDirectories(includes); + this->CurrentLocalGenerator->GetIncludeDirectories(includes, &target); std::set<cmStdString> emitted; emitted.insert("/System/Library/Frameworks"); for(std::vector<std::string>::iterator i = includes.begin(); diff --git a/Source/cmIncludeDirectoryCommand.h b/Source/cmIncludeDirectoryCommand.h index b90fe42..dcc116a 100644 --- a/Source/cmIncludeDirectoryCommand.h +++ b/Source/cmIncludeDirectoryCommand.h @@ -58,13 +58,21 @@ public: { return " include_directories([AFTER|BEFORE] [SYSTEM] dir1 dir2 ...)\n" - "Add the given directories to those searched by the compiler for " - "include files. By default the directories are appended onto " - "the current list of directories. This default behavior can be " - "changed by setting CMAKE_INCLUDE_DIRECTORIES_BEFORE to ON. " - "By using BEFORE or AFTER you can select between appending and " - "prepending, independent from the default. " - "If the SYSTEM option is given the compiler will be told that the " + "Add the given directories to those the compiler uses to search " + "for include files. " + "These directories are added to the directory property " + "INCLUDE_DIRECTORIES for the current CMakeLists file. " + "They are also added to the target property INCLUDE_DIRECTORIES " + "for each target in the current CMakeLists file. " + "The target property values are the ones used by the generators." + "\n" + "By default the directories are appended onto the current list of " + "directories. " + "This default behavior can be changed by setting " + "CMAKE_INCLUDE_DIRECTORIES_BEFORE to ON. " + "By using AFTER or BEFORE explicitly, you can select between " + "appending and prepending, independent of the default. " + "If the SYSTEM option is given, the compiler will be told the " "directories are meant as system include directories on some " "platforms."; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index dc8d1c4..8a63387 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -556,7 +556,7 @@ void cmLocalGenerator::GenerateTargetManifest() void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, const char* lang, cmSourceFile& source, - cmTarget& ) + cmTarget& target) { std::string objectDir = cmSystemTools::GetFilenamePath(std::string(ofname)); objectDir = this->Convert(objectDir.c_str(),START_OUTPUT,SHELL); @@ -574,7 +574,11 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, std::string flags; flags += this->Makefile->GetSafeDefinition(varString.c_str()); flags += " "; - flags += this->GetIncludeFlags(lang); + { + std::vector<std::string> includes; + this->GetIncludeDirectories(includes, &target, lang); + flags += this->GetIncludeFlags(includes, lang); + } flags += this->Makefile->GetDefineFlags(); // Construct the command lines. @@ -1192,24 +1196,16 @@ cmLocalGenerator::ConvertToIncludeReference(std::string const& path) } //---------------------------------------------------------------------------- -const char* cmLocalGenerator::GetIncludeFlags(const char* lang, - bool forResponseFile) +std::string cmLocalGenerator::GetIncludeFlags( + const std::vector<std::string> &includes, + const char* lang, bool forResponseFile) { if(!lang) { return ""; } - std::string key = lang; - key += forResponseFile? "@" : ""; - if(this->LanguageToIncludeFlags.count(key)) - { - return this->LanguageToIncludeFlags[key].c_str(); - } cmOStringStream includeFlags; - std::vector<std::string> includes; - this->GetIncludeDirectories(includes, lang); - std::vector<std::string>::iterator i; std::string flagVar = "CMAKE_INCLUDE_FLAG_"; flagVar += lang; @@ -1251,6 +1247,7 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang, #ifdef __APPLE__ emitted.insert("/System/Library/Frameworks"); #endif + std::vector<std::string>::const_iterator i; for(i = includes.begin(); i != includes.end(); ++i) { if(this->Makefile->IsOn("APPLE") @@ -1311,16 +1308,12 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang, { flags[flags.size()-1] = ' '; } - this->LanguageToIncludeFlags[key] = flags; - - // Use this temorary variable for the return value to work-around a - // bogus GCC 2.95 warning. - const char* ret = this->LanguageToIncludeFlags[key].c_str(); - return ret; + return flags; } //---------------------------------------------------------------------------- void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, + cmTarget* target, const char* lang) { // Need to decide whether to automatically include the source and @@ -1375,8 +1368,12 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, // Store the automatic include paths. if(includeBinaryDir) { - dirs.push_back(this->Makefile->GetStartOutputDirectory()); - emitted.insert(this->Makefile->GetStartOutputDirectory()); + if(emitted.find( + this->Makefile->GetStartOutputDirectory()) == emitted.end()) + { + dirs.push_back(this->Makefile->GetStartOutputDirectory()); + emitted.insert(this->Makefile->GetStartOutputDirectory()); + } } if(includeSourceDir) { @@ -1402,9 +1399,12 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, } } - // Get the project-specified include directories. - std::vector<std::string>& includes = - this->Makefile->GetIncludeDirectories(); + // Get the target-specific include directories. + std::vector<std::string> includes; + if(target) + { + includes = target->GetIncludeDirectories(); + } // Support putting all the in-project include directories first if // it is requested by the project. @@ -1412,7 +1412,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, { const char* topSourceDir = this->Makefile->GetHomeDirectory(); const char* topBinaryDir = this->Makefile->GetHomeOutputDirectory(); - for(std::vector<std::string>::iterator i = includes.begin(); + for(std::vector<std::string>::const_iterator i = includes.begin(); i != includes.end(); ++i) { // Emit this directory only if it is a subdirectory of the @@ -1431,7 +1431,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, } // Construct the final ordered include directory list. - for(std::vector<std::string>::iterator i = includes.begin(); + for(std::vector<std::string>::const_iterator i = includes.begin(); i != includes.end(); ++i) { if(emitted.insert(*i).second) diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index c3d057f..4270b2f 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -146,8 +146,8 @@ public: ///! Append flags to a string. virtual void AppendFlags(std::string& flags, const char* newFlags); ///! Get the include flags for the current makefile and language - const char* GetIncludeFlags(const char* lang, - bool forResponseFile = false); + std::string GetIncludeFlags(const std::vector<std::string> &includes, + const char* lang, bool forResponseFile = false); /** * Encode a list of preprocessor definitions for the compiler @@ -198,6 +198,7 @@ public: /** Get the include flags for the current makefile and language. */ void GetIncludeDirectories(std::vector<std::string>& dirs, + cmTarget* target, const char* lang = "C"); /** Compute the language used to compile the given source file. */ @@ -395,7 +396,6 @@ protected: std::vector<std::string> StartOutputDirectoryComponents; cmLocalGenerator* Parent; std::vector<cmLocalGenerator*> Children; - std::map<cmStdString, cmStdString> LanguageToIncludeFlags; std::map<cmStdString, cmStdString> UniqueObjectNamesMap; std::string::size_type ObjectPathMax; std::set<cmStdString> ObjectMaxPathViolations; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index dd313ca..75226b5 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -452,28 +452,6 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile() << "\n"; } - // Store the include search path for this directory. - infoFileStream - << "# The C and CXX include file search paths:\n"; - infoFileStream - << "SET(CMAKE_C_INCLUDE_PATH\n"; - std::vector<std::string> includeDirs; - this->GetIncludeDirectories(includeDirs); - for(std::vector<std::string>::iterator i = includeDirs.begin(); - i != includeDirs.end(); ++i) - { - infoFileStream - << " \"" << this->Convert(i->c_str(),HOME_OUTPUT).c_str() << "\"\n"; - } - infoFileStream - << " )\n"; - infoFileStream - << "SET(CMAKE_CXX_INCLUDE_PATH ${CMAKE_C_INCLUDE_PATH})\n"; - infoFileStream - << "SET(CMAKE_Fortran_INCLUDE_PATH ${CMAKE_C_INCLUDE_PATH})\n"; - infoFileStream - << "SET(CMAKE_ASM_INCLUDE_PATH ${CMAKE_C_INCLUDE_PATH})\n"; - // Store the include regular expressions for this directory. infoFileStream << "\n" diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 1dfcbea..c846d6b 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -103,52 +103,9 @@ void cmLocalVisualStudio6Generator::OutputDSPFile() } } - // Setup /I and /LIBPATH options for the resulting DSP file. VS 6 - // truncates long include paths so make it as short as possible if - // the length threatens this problem. - unsigned int maxIncludeLength = 3000; - bool useShortPath = false; - for(int j=0; j < 2; ++j) - { - std::vector<std::string> includes; - this->GetIncludeDirectories(includes); - std::vector<std::string>::iterator i; - for(i = includes.begin(); i != includes.end(); ++i) - { - std::string tmp = - this->ConvertToOptionallyRelativeOutputPath(i->c_str()); - if(useShortPath) - { - cmSystemTools::GetShortPath(tmp.c_str(), tmp); - } - this->IncludeOptions += " /I "; - - // quote if not already quoted - if (tmp[0] != '"') - { - this->IncludeOptions += "\""; - this->IncludeOptions += tmp; - this->IncludeOptions += "\""; - } - else - { - this->IncludeOptions += tmp; - } - } - if(j == 0 && this->IncludeOptions.size() > maxIncludeLength) - { - this->IncludeOptions = ""; - useShortPath = true; - } - else - { - break; - } - } - // Create the DSP or set of DSP's for libraries and executables - cmTargets &tgts = this->Makefile->GetTargets(); + cmTargets &tgts = this->Makefile->GetTargets(); for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { @@ -895,6 +852,61 @@ inline std::string removeQuotes(const std::string& s) return s; } + +std::string +cmLocalVisualStudio6Generator::GetTargetIncludeOptions(cmTarget &target) +{ + std::string includeOptions; + + // Setup /I and /LIBPATH options for the resulting DSP file. VS 6 + // truncates long include paths so make it as short as possible if + // the length threatens this problem. + unsigned int maxIncludeLength = 3000; + bool useShortPath = false; + for(int j=0; j < 2; ++j) + { + std::vector<std::string> includes; + this->GetIncludeDirectories(includes, &target); + + std::vector<std::string>::iterator i; + for(i = includes.begin(); i != includes.end(); ++i) + { + std::string tmp = + this->ConvertToOptionallyRelativeOutputPath(i->c_str()); + if(useShortPath) + { + cmSystemTools::GetShortPath(tmp.c_str(), tmp); + } + includeOptions += " /I "; + + // quote if not already quoted + if (tmp[0] != '"') + { + includeOptions += "\""; + includeOptions += tmp; + includeOptions += "\""; + } + else + { + includeOptions += tmp; + } + } + + if(j == 0 && includeOptions.size() > maxIncludeLength) + { + includeOptions = ""; + useShortPath = true; + } + else + { + break; + } + } + + return includeOptions; +} + + // Code in blocks surrounded by a test for this definition is needed // only for compatibility with user project's replacement DSP // templates. The CMake templates no longer use them. @@ -1132,6 +1144,9 @@ void cmLocalVisualStudio6Generator } #endif + // Get include options for this target. + std::string includeOptions = this->GetTargetIncludeOptions(target); + // Get extra linker options for this target type. std::string extraLinkOptions; std::string extraLinkOptionsDebug; @@ -1510,7 +1525,7 @@ void cmLocalVisualStudio6Generator optionsRelWithDebInfo.c_str()); cmSystemTools::ReplaceString(line, "BUILD_INCLUDES", - this->IncludeOptions.c_str()); + includeOptions.c_str()); cmSystemTools::ReplaceString(line, "TARGET_VERSION_FLAG", targetVersionFlag.c_str()); cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_DEBUG", diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h index 195d654..c9c5dd1 100644 --- a/Source/cmLocalVisualStudio6Generator.h +++ b/Source/cmLocalVisualStudio6Generator.h @@ -89,7 +89,7 @@ private: void ComputeLinkOptions(cmTarget& target, const char* configName, const std::string extraOptions, std::string& options); - std::string IncludeOptions; + std::string GetTargetIncludeOptions(cmTarget &target); std::vector<std::string> Configurations; std::string GetConfigName(std::string const& configuration) const; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 11a0387..1743517 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -807,7 +807,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.OutputAdditionalOptions(fout, "\t\t\t\t", "\n"); fout << "\t\t\t\tAdditionalIncludeDirectories=\""; std::vector<std::string> includes; - this->GetIncludeDirectories(includes); + this->GetIncludeDirectories(includes, &target); std::vector<std::string>::iterator i = includes.begin(); for(;i != includes.end(); ++i) { diff --git a/Source/cmMakeDepend.cxx b/Source/cmMakeDepend.cxx index 0b4eea5..6055c55 100644 --- a/Source/cmMakeDepend.cxx +++ b/Source/cmMakeDepend.cxx @@ -54,16 +54,33 @@ void cmMakeDepend::SetMakefile(cmMakefile* makefile) this->Makefile->IncludeFileRegularExpression.c_str()); this->ComplainFileRegularExpression.compile( this->Makefile->ComplainFileRegularExpression.c_str()); - - // Now extract any include paths from the makefile flags - const std::vector<std::string>& includes = - this->Makefile->GetIncludeDirectories(); - for(std::vector<std::string>::const_iterator j = includes.begin(); - j != includes.end(); ++j) + + // Now extract any include paths from the targets + std::set<std::string> uniqueIncludes; + std::vector<std::string> orderedAndUniqueIncludes; + cmTargets & targets = this->Makefile->GetTargets(); + for (cmTargets::iterator l = targets.begin(); l != targets.end(); ++l) + { + const std::vector<std::string>& includes = + l->second.GetIncludeDirectories(); + for(std::vector<std::string>::const_iterator j = includes.begin(); + j != includes.end(); ++j) + { + std::string path = *j; + this->Makefile->ExpandVariablesInString(path); + if(uniqueIncludes.insert(path).second) + { + orderedAndUniqueIncludes.push_back(path); + } + } + } + + for(std::vector<std::string>::const_iterator + it = orderedAndUniqueIncludes.begin(); + it != orderedAndUniqueIncludes.end(); + ++it) { - std::string path = *j; - this->Makefile->ExpandVariablesInString(path); - this->AddSearchPath(path.c_str()); + this->AddSearchPath(it->c_str()); } } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index fdf5b31..f90c35c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -116,7 +116,6 @@ cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals) this->Targets = mf.Targets; this->SourceFiles = mf.SourceFiles; this->Tests = mf.Tests; - this->IncludeDirectories = mf.IncludeDirectories; this->LinkDirectories = mf.LinkDirectories; this->SystemIncludeDirectories = mf.SystemIncludeDirectories; this->ListFiles = mf.ListFiles; @@ -210,9 +209,9 @@ cmMakefile::~cmMakefile() { delete *i; } - for(unsigned int i=0; i < this->UsedCommands.size(); i++) + for(unsigned int i=0; i < this->FinalPassCommands.size(); i++) { - delete this->UsedCommands[i]; + delete this->FinalPassCommands[i]; } std::vector<cmFunctionBlocker*>::iterator pos; for (pos = this->FunctionBlockers.begin(); @@ -278,8 +277,6 @@ void cmMakefile::Print() this->cmHomeDirectory.c_str() << std::endl; std::cout << " this->ProjectName; " << this->ProjectName.c_str() << std::endl; - this->PrintStringVector("this->IncludeDirectories;", - this->IncludeDirectories); this->PrintStringVector("this->LinkDirectories", this->LinkDirectories); #if defined(CMAKE_BUILD_WITH_CMAKE) for( std::vector<cmSourceGroup>::const_iterator i = @@ -421,7 +418,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, else if(pcmd->HasFinalPass()) { // use the command - this->UsedCommands.push_back(pcmd.release()); + this->FinalPassCommands.push_back(pcmd.release()); } } else if ( this->GetCMakeInstance()->GetWorkingMode() == cmake::SCRIPT_MODE @@ -813,8 +810,8 @@ void cmMakefile::FinalPass() // give all the commands a chance to do something // after the file has been parsed before generation - for(std::vector<cmCommand*>::iterator i = this->UsedCommands.begin(); - i != this->UsedCommands.end(); ++i) + for(std::vector<cmCommand*>::iterator i = this->FinalPassCommands.begin(); + i != this->FinalPassCommands.end(); ++i) { (*i)->FinalPass(); } @@ -1478,7 +1475,8 @@ void cmMakefile::InitializeFromParent() this->Internal->VarStack.top() = parent->Internal->VarStack.top().Closure(); // copy include paths - this->IncludeDirectories = parent->IncludeDirectories; + this->SetProperty("INCLUDE_DIRECTORIES", + parent->GetProperty("INCLUDE_DIRECTORIES")); this->SystemIncludeDirectories = parent->SystemIncludeDirectories; // define flags @@ -1603,42 +1601,61 @@ void cmMakefile::AddSubDirectory(const char* srcPath, const char *binPath, } } -void cmMakefile::AddIncludeDirectory(const char* inc, bool before) +//---------------------------------------------------------------------------- +void AddStringToProperty(cmProperty *prop, const char* name, const char* s, + bool before) { - // if there is a newline then break it into multiple arguments - if (!inc) + if (!prop) { return; } - // Don't add an include directory that is already present. Yes, - // this linear search results in n^2 behavior, but n won't be - // getting much bigger than 20. We cannot use a set because of - // order dependency of the include path. - std::vector<std::string>::iterator i = - std::find(this->IncludeDirectories.begin(), - this->IncludeDirectories.end(), inc); - if(i == this->IncludeDirectories.end()) + // Don't worry about duplicates at this point. We eliminate them when + // we convert the property to a vector in GetIncludeDirectories. + + if (before) { - if (before) + const char *val = prop->GetValue(); + cmOStringStream oss; + + if(val && *val) { - // WARNING: this *is* expensive (linear time) since it's a vector - this->IncludeDirectories.insert(this->IncludeDirectories.begin(), inc); + oss << s << ";" << val; } else { - this->IncludeDirectories.push_back(inc); + oss << s; } + + std::string newVal = oss.str(); + prop->Set(name, newVal.c_str()); } else { - if(before) - { - // if this before and already in the path then remove it - this->IncludeDirectories.erase(i); - // WARNING: this *is* expensive (linear time) since it's a vector - this->IncludeDirectories.insert(this->IncludeDirectories.begin(), inc); - } + prop->Append(name, s); + } +} + +//---------------------------------------------------------------------------- +void cmMakefile::AddIncludeDirectory(const char* inc, bool before) +{ + if (!inc) + { + return; + } + + // Directory property: + cmProperty *prop = + this->GetProperties().GetOrCreateProperty("INCLUDE_DIRECTORIES"); + AddStringToProperty(prop, "INCLUDE_DIRECTORIES", inc, before); + + // Property on each target: + for (cmTargets::iterator l = this->Targets.begin(); + l != this->Targets.end(); ++l) + { + cmTarget &t = l->second; + prop = t.GetProperties().GetOrCreateProperty("INCLUDE_DIRECTORIES"); + AddStringToProperty(prop, "INCLUDE_DIRECTORIES", inc, before); } } @@ -2093,17 +2110,37 @@ void cmMakefile::AddExtraDirectory(const char* dir) } -// expance CMAKE_BINARY_DIR and CMAKE_SOURCE_DIR in the +// expand CMAKE_BINARY_DIR and CMAKE_SOURCE_DIR in the // include and library directories. void cmMakefile::ExpandVariables() { // Now expand variables in the include and link strings - for(std::vector<std::string>::iterator d = this->IncludeDirectories.begin(); - d != this->IncludeDirectories.end(); ++d) + + // May not be necessary anymore... But may need a policy for strict + // backwards compatibility + const char *includeDirs = this->GetProperty("INCLUDE_DIRECTORIES"); + if (includeDirs) { - this->ExpandVariablesInString(*d, true, true); + std::string dirs = includeDirs; + this->ExpandVariablesInString(dirs, true, true); + this->SetProperty("INCLUDE_DIRECTORIES", dirs.c_str()); + } + + // Also for each target's INCLUDE_DIRECTORIES property: + for (cmTargets::iterator l = this->Targets.begin(); + l != this->Targets.end(); ++l) + { + cmTarget &t = l->second; + includeDirs = t.GetProperty("INCLUDE_DIRECTORIES"); + if (includeDirs) + { + std::string dirs = includeDirs; + this->ExpandVariablesInString(dirs, true, true); + t.SetProperty("INCLUDE_DIRECTORIES", dirs.c_str()); + } } + for(std::vector<std::string>::iterator d = this->LinkDirectories.begin(); d != this->LinkDirectories.end(); ++d) { @@ -3317,16 +3354,6 @@ void cmMakefile::SetProperty(const char* prop, const char* value) // handle special props std::string propname = prop; - if ( propname == "INCLUDE_DIRECTORIES" ) - { - std::vector<std::string> varArgsExpanded; - if(value) - { - cmSystemTools::ExpandListArgument(value, varArgsExpanded); - } - this->SetIncludeDirectories(varArgsExpanded); - return; - } if ( propname == "LINK_DIRECTORIES" ) { @@ -3368,17 +3395,6 @@ void cmMakefile::AppendProperty(const char* prop, const char* value, // handle special props std::string propname = prop; - if ( propname == "INCLUDE_DIRECTORIES" ) - { - std::vector<std::string> varArgsExpanded; - cmSystemTools::ExpandListArgument(value, varArgsExpanded); - for(std::vector<std::string>::const_iterator vi = varArgsExpanded.begin(); - vi != varArgsExpanded.end(); ++vi) - { - this->AddIncludeDirectory(vi->c_str()); - } - return; - } if ( propname == "LINK_DIRECTORIES" ) { @@ -3474,23 +3490,6 @@ const char *cmMakefile::GetProperty(const char* prop, output += this->DefineFlagsOrig; return output.c_str(); } - else if (!strcmp("INCLUDE_DIRECTORIES",prop) ) - { - cmOStringStream str; - for (std::vector<std::string>::const_iterator - it = this->GetIncludeDirectories().begin(); - it != this->GetIncludeDirectories().end(); - ++ it ) - { - if ( it != this->GetIncludeDirectories().begin()) - { - str << ";"; - } - str << it->c_str(); - } - output = str.str(); - return output.c_str(); - } else if (!strcmp("LINK_DIRECTORIES",prop)) { cmOStringStream str; @@ -3861,9 +3860,22 @@ void cmMakefile::DefineProperties(cmake *cm) cm->DefineProperty ("INCLUDE_DIRECTORIES", cmProperty::DIRECTORY, "List of preprocessor include file search directories.", - "This read-only property specifies the list of directories given " - "so far to the include_directories command. " - "It is intended for debugging purposes.", false); + "This property specifies the list of directories given " + "so far to the include_directories command. " + "This property exists on directories and targets. " + "In addition to accepting values from the include_directories " + "command, values may be set directly on any directory or any " + "target using the set_property command. " + "A target gets its initial value for this property from the value " + "of the directory property. " + "A directory gets its initial value from its parent directory if " + "it has one. " + "Both directory and target property values are adjusted by calls " + "to the include_directories command." + "\n" + "The target property values are used by the generators to set " + "the include paths for the compiler. " + "See also the include_directories command."); cm->DefineProperty ("LINK_DIRECTORIES", cmProperty::DIRECTORY, diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1c46a73..960ba39 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -522,22 +522,6 @@ public: cmTarget* FindTargetToUse(const char* name); /** - * Get a list of include directories in the build. - */ - std::vector<std::string>& GetIncludeDirectories() - { - return this->IncludeDirectories; - } - const std::vector<std::string>& GetIncludeDirectories() const - { - return this->IncludeDirectories; - } - void SetIncludeDirectories(const std::vector<std::string>& vec) - { - this->IncludeDirectories = vec; - } - - /** * Mark include directories as system directories. */ void AddSystemIncludeDirectory(const char* dir); @@ -620,12 +604,6 @@ public: */ bool CanIWriteThisFile(const char* fileName); - /** - * Get the vector of used command instances. - */ - const std::vector<cmCommand*>& GetUsedCommands() const - {return this->UsedCommands;} - #if defined(CMAKE_BUILD_WITH_CMAKE) /** * Get the vector source groups. @@ -880,9 +858,7 @@ protected: // Tests std::map<cmStdString, cmTest*> Tests; - // The include and link-library paths. These may have order - // dependency, so they must be vectors (not set). - std::vector<std::string> IncludeDirectories; + // The link-library paths. Order matters, use std::vector (not std::set). std::vector<std::string> LinkDirectories; // The set of include directories that are marked as system include @@ -913,7 +889,7 @@ protected: std::vector<cmSourceGroup> SourceGroups; #endif - std::vector<cmCommand*> UsedCommands; + std::vector<cmCommand*> FinalPassCommands; cmLocalGenerator* LocalGenerator; bool IsFunctionBlocked(const cmListFileFunction& lff, cmExecutionStatus &status); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index a3a832b..e5be4aa 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1069,6 +1069,35 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() << "SET(CMAKE_Fortran_TARGET_MODULE_DIR \"" << mdir << "\")\n"; } + // Target-specific include directories: + *this->InfoFileStream + << "\n" + << "# The include file search paths:\n"; + *this->InfoFileStream + << "SET(CMAKE_C_TARGET_INCLUDE_PATH\n"; + std::vector<std::string> includes; + this->LocalGenerator->GetIncludeDirectories(includes, this->Target); + for(std::vector<std::string>::iterator i = includes.begin(); + i != includes.end(); ++i) + { + *this->InfoFileStream + << " \"" + << this->LocalGenerator->Convert(i->c_str(), + cmLocalGenerator::HOME_OUTPUT) + << "\"\n"; + } + *this->InfoFileStream + << " )\n"; + *this->InfoFileStream + << "SET(CMAKE_CXX_TARGET_INCLUDE_PATH " + << "${CMAKE_C_TARGET_INCLUDE_PATH})\n"; + *this->InfoFileStream + << "SET(CMAKE_Fortran_TARGET_INCLUDE_PATH " + << "${CMAKE_C_TARGET_INCLUDE_PATH})\n"; + *this->InfoFileStream + << "SET(CMAKE_ASM_TARGET_INCLUDE_PATH " + << "${CMAKE_C_TARGET_INCLUDE_PATH})\n"; + // and now write the rule to use it std::vector<std::string> depends; std::vector<std::string> commands; @@ -1534,7 +1563,7 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags() emitted.insert("/System/Library/Frameworks"); #endif std::vector<std::string> includes; - this->LocalGenerator->GetIncludeDirectories(includes); + this->LocalGenerator->GetIncludeDirectories(includes, this->Target); std::vector<std::string>::iterator i; // check all include directories for frameworks as this // will already have added a -F for the framework @@ -1829,8 +1858,12 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags, responseVar += "_USE_RESPONSE_FILE_FOR_INCLUDES"; bool useResponseFile = this->Makefile->IsOn(responseVar.c_str()); + + std::vector<std::string> includes; + this->LocalGenerator->GetIncludeDirectories(includes, this->Target, lang); + std::string includeFlags = - this->LocalGenerator->GetIncludeFlags(lang, useResponseFile); + this->LocalGenerator->GetIncludeFlags(includes, lang, useResponseFile); if(includeFlags.empty()) { return; @@ -1930,7 +1963,7 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags) this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG")) { std::vector<std::string> includes; - this->LocalGenerator->GetIncludeDirectories(includes); + this->LocalGenerator->GetIncludeDirectories(includes, this->Target); for(std::vector<std::string>::const_iterator idi = includes.begin(); idi != includes.end(); ++idi) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index da99eb9..43f2068 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -480,6 +480,26 @@ void cmTarget::DefineProperties(cmake *cm) "undefined behavior."); cm->DefineProperty + ("INCLUDE_DIRECTORIES", cmProperty::TARGET, + "List of preprocessor include file search directories.", + "This property specifies the list of directories given " + "so far to the include_directories command. " + "This property exists on directories and targets. " + "In addition to accepting values from the include_directories " + "command, values may be set directly on any directory or any " + "target using the set_property command. " + "A target gets its initial value for this property from the value " + "of the directory property. " + "A directory gets its initial value from its parent directory if " + "it has one. " + "Both directory and target property values are adjusted by calls " + "to the include_directories command." + "\n" + "The target property values are used by the generators to set " + "the include paths for the compiler. " + "See also the include_directories command."); + + cm->DefineProperty ("INSTALL_NAME_DIR", cmProperty::TARGET, "Mac OSX directory name for installed targets.", "INSTALL_NAME_DIR is a string specifying the " @@ -861,7 +881,9 @@ void cmTarget::DefineProperties(cmake *cm) "of of just main()." "This makes it a GUI executable instead of a console application. " "See the CMAKE_MFC_FLAG variable documentation to configure use " - "of MFC for WinMain executables."); + "of MFC for WinMain executables. " + "This property is initialized by the value of the variable " + "CMAKE_WIN32_EXECUTABLE if it is set when a target is created."); cm->DefineProperty ("MACOSX_BUNDLE", cmProperty::TARGET, @@ -871,7 +893,9 @@ void cmTarget::DefineProperties(cmake *cm) "This makes it a GUI executable that can be launched from " "the Finder. " "See the MACOSX_BUNDLE_INFO_PLIST target property for information " - "about creation of the Info.plist file for the application bundle."); + "about creation of the Info.plist file for the application bundle. " + "This property is initialized by the value of the variable " + "CMAKE_MACOSX_BUNDLE if it is set when a target is created."); cm->DefineProperty ("MACOSX_BUNDLE_INFO_PLIST", cmProperty::TARGET, @@ -1224,6 +1248,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("AUTOMOC", 0); this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", 0); this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", 0); + this->SetPropertyDefault("WIN32_EXECUTABLE", 0); + this->SetPropertyDefault("MACOSX_BUNDLE", 0); // Collect the set of configuration types. std::vector<std::string> configNames; @@ -1263,6 +1289,11 @@ void cmTarget::SetMakefile(cmMakefile* mf) // Save the backtrace of target construction. this->Makefile->GetBacktrace(this->Internal->Backtrace); + // Initialize the INCLUDE_DIRECTORIES property based on the current value + // of the same directory property: + this->SetProperty("INCLUDE_DIRECTORIES", + this->Makefile->GetProperty("INCLUDE_DIRECTORIES")); + // Record current policies for later use. this->PolicyStatusCMP0003 = this->Makefile->GetPolicyStatus(cmPolicies::CMP0003); @@ -3586,7 +3617,8 @@ bool cmTarget::HaveBuildTreeRPATH() bool cmTarget::HaveInstallTreeRPATH() { const char* install_rpath = this->GetProperty("INSTALL_RPATH"); - return install_rpath && *install_rpath; + return (install_rpath && *install_rpath) && + !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH"); } //---------------------------------------------------------------------------- @@ -3693,7 +3725,8 @@ std::string cmTarget::GetInstallNameDirForInstallTree(const char* config, { std::string dir; - if(!this->Makefile->IsOn("CMAKE_SKIP_RPATH")) + if(!this->Makefile->IsOn("CMAKE_SKIP_RPATH") && + !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) { const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR"); if(install_name_dir && *install_name_dir) @@ -4660,6 +4693,30 @@ cmTarget::GetLinkInformation(const char* config) } //---------------------------------------------------------------------------- +std::vector<std::string> cmTarget::GetIncludeDirectories() +{ + std::vector<std::string> includes; + const char *prop = this->GetProperty("INCLUDE_DIRECTORIES"); + if(prop) + { + cmSystemTools::ExpandListArgument(prop, includes); + } + + std::set<std::string> uniqueIncludes; + std::vector<std::string> orderedAndUniqueIncludes; + for(std::vector<std::string>::const_iterator + li = includes.begin(); li != includes.end(); ++li) + { + if(uniqueIncludes.insert(*li).second) + { + orderedAndUniqueIncludes.push_back(*li); + } + } + + return orderedAndUniqueIncludes; +} + +//---------------------------------------------------------------------------- cmTargetLinkInformationMap ::cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r): derived() { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index f4b6955..0977332 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -457,6 +457,9 @@ public: directory. */ bool UsesDefaultOutputDir(const char* config, bool implib); + /** Get the include directories for this target. */ + std::vector<std::string> GetIncludeDirectories(); + private: /** * A list of direct dependencies. Use in conjunction with DependencyMap. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 9418761..f9148a1 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1586,7 +1586,7 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups() static_cast<cmGlobalVisualStudio7Generator *> (this->GlobalGenerator)->GetConfigurations(); std::vector<std::string> includes; - this->LocalGenerator->GetIncludeDirectories(includes); + this->LocalGenerator->GetIncludeDirectories(includes, this->Target); for(std::vector<std::string>::iterator i = configs->begin(); i != configs->end(); ++i) { diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 0b7a996..1221597 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -598,14 +598,10 @@ bool cmake::FindPackage(const std::vector<std::string>& args) std::string includes = mf->GetSafeDefinition("PACKAGE_INCLUDE_DIRS"); std::vector<std::string> includeDirs; cmSystemTools::ExpandListArgument(includes, includeDirs); - for(std::vector<std::string>::const_iterator dirIt=includeDirs.begin(); - dirIt != includeDirs.end(); - ++dirIt) - { - mf->AddIncludeDirectory(dirIt->c_str(), false); - } - std::string includeFlags = lg->GetIncludeFlags(language.c_str(), false); + std::string includeFlags = lg->GetIncludeFlags(includeDirs, + language.c_str(), false); + std::string definitions = mf->GetSafeDefinition("PACKAGE_DEFINITIONS"); printf("%s %s\n", includeFlags.c_str(), definitions.c_str()); } diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 617f126..1946a39 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2012) SET(KWSYS_DATE_STAMP_MONTH 03) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 06) +SET(KWSYS_DATE_STAMP_DAY 08) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 00cac94..53c59cc 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -233,12 +233,35 @@ IF(BUILD_TESTING) LIST(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX}) + IF(NOT QT4_FOUND) + FIND_PACKAGE(Qt4) + ENDIF(NOT QT4_FOUND) + + IF(QT4_FOUND) + # test whether the Qt4 which has been found works, on some machines + # which run nightly builds there were errors like "wrong file format" + # for libQtCore.so. So first check it works, and only if it does add + # the automoc test. + INCLUDE(CheckCXXSourceCompiles) + SET(_save_CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}") + SET(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + + SET(CMAKE_REQUIRED_INCLUDES ${QT_INCLUDES}) + SET(CMAKE_REQUIRED_LIBRARIES ${QT_QTCORE_LIBRARIES}) + + CHECK_CXX_SOURCE_COMPILES("#include <QCoreApplication>\n int main() {return (qApp == 0 ? 0 : 1); }\n" + QT4_WORKS) + + SET(CMAKE_REQUIRED_INCLUDES "${_save_CMAKE_REQUIRED_INCLUDES}") + SET(CMAKE_REQUIRED_LIBRARIES "${_save_CMAKE_REQUIRED_LIBRARIES}") + ENDIF() # run test for BundleUtilities on supported platforms/compilers if(MSVC OR CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Darwin") if(NOT "${CMAKE_TEST_GENERATOR}" STREQUAL "Watcom WMake") + ADD_TEST(BundleUtilities ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/BundleUtilities" @@ -248,6 +271,24 @@ IF(BUILD_TESTING) --build-project BundleUtilities ) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleUtilities") + + # run test for DeployQt4 on supported platforms/compilers (which depends on BundleUtilities) + # this test also depends on the existence of the standard qtiff plugin + if(QT4_WORKS AND QT_QTSQL_FOUND) + ADD_TEST(Qt4Deploy ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Qt4Deploy" + "${CMake_BINARY_DIR}/Tests/Qt4Deploy" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project Qt4Deploy + --build-options + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Deploy") + endif() + endif() endif() @@ -861,43 +902,20 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Environment") - IF(NOT QT4_FOUND) - FIND_PACKAGE(Qt4) - ENDIF(NOT QT4_FOUND) - - IF(QT4_FOUND) - # test whether the Qt4 which has been found works, on some machines - # which run nightly builds there were errors like "wrong file format" - # for libQtCore.so. So first check it works, and only if it does add - # the automoc test. - INCLUDE(CheckCXXSourceCompiles) - SET(_save_CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}") - SET(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - - SET(CMAKE_REQUIRED_INCLUDES ${QT_INCLUDES}) - SET(CMAKE_REQUIRED_LIBRARIES ${QT_QTCORE_LIBRARIES}) - - CHECK_CXX_SOURCE_COMPILES("#include <QCoreApplication>\n int main() {return (qApp == 0 ? 0 : 1); }\n" - QT4_WORKS_FOR_AUTOMOC_TEST) - - SET(CMAKE_REQUIRED_INCLUDES "${_save_CMAKE_REQUIRED_INCLUDES}") - SET(CMAKE_REQUIRED_LIBRARIES "${_save_CMAKE_REQUIRED_LIBRARIES}") - - IF(QT4_WORKS_FOR_AUTOMOC_TEST) - ADD_TEST(QtAutomoc ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/QtAutomoc" - "${CMake_BINARY_DIR}/Tests/QtAutomoc" - --build-generator ${CMAKE_TEST_GENERATOR} - --build-project QtAutomoc - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --build-exe-dir "${CMake_BINARY_DIR}/Tests/QtAutomoc" - --force-new-ctest-process - --build-options -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} - --test-command ${CMAKE_CTEST_COMMAND} -V - ) - LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomoc") - ENDIF() + IF(QT4_WORKS AND QT_QTGUI_FOUND) + ADD_TEST(QtAutomoc ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/QtAutomoc" + "${CMake_BINARY_DIR}/Tests/QtAutomoc" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project QtAutomoc + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/QtAutomoc" + --force-new-ctest-process + --build-options -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + --test-command ${CMAKE_CTEST_COMMAND} -V + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomoc") ENDIF() ADD_TEST(ExternalProject ${CMAKE_CTEST_COMMAND} diff --git a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt index e6e4c74..22b1b7b 100644 --- a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt +++ b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt @@ -61,7 +61,7 @@ endmacro(check_version_string) # reported. foreach(VTEST ALSA ARMADILLO BZIP2 CUPS CURL EXPAT FREETYPE GETTEXT GIT HSPELL - JASPER LIBXML2 LIBXSLT PERL PostgreSQL TCLSH TIFF ZLIB) + JASPER LIBXML2 LIBXSLT PERL PostgreSQL TIFF ZLIB) check_version_string(${VTEST} ${VTEST}_VERSION_STRING) endforeach(VTEST) diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index aa4d52e..c42c490 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -22,6 +22,7 @@ AddCMakeTest(ConfigureFile "") AddCMakeTest(SeparateArguments "") AddCMakeTest(ImplicitLinkInfo "") AddCMakeTest(ModuleNotices "") +AddCMakeTest(GetProperty "") AddCMakeTest(If "") AddCMakeTest(String "") AddCMakeTest(Math "") @@ -56,14 +57,13 @@ AddCMakeTest(GetPrerequisites "${GetPrerequisites_PreArgs}") # suite. It detects if any changes have been made to the CMake source tree # by any previous configure, build or test steps. # -if(do_cvs_tests OR GIT_EXECUTABLE) +if(GIT_EXECUTABLE) string(REPLACE "\\" "/" ENV_HOME "$ENV{HOME}") set(CheckSourceTree_PreArgs "-DCMake_BINARY_DIR:PATH=${CMake_BINARY_DIR}" "-DCMake_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}" - "-DCVS_EXECUTABLE:STRING=${CVS_EXECUTABLE}" "-DGIT_EXECUTABLE:STRING=${GIT_EXECUTABLE}" "-DHOME:STRING=${ENV_HOME}" ) AddCMakeTest(CheckSourceTree "${CheckSourceTree_PreArgs}") -endif(do_cvs_tests OR GIT_EXECUTABLE) +endif() diff --git a/Tests/CMakeTests/CheckSourceTreeTest.cmake.in b/Tests/CMakeTests/CheckSourceTreeTest.cmake.in index 73f8b01..59b2890 100644 --- a/Tests/CMakeTests/CheckSourceTreeTest.cmake.in +++ b/Tests/CMakeTests/CheckSourceTreeTest.cmake.in @@ -5,7 +5,6 @@ message("CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") message("") message("CMake_BINARY_DIR='${CMake_BINARY_DIR}'") message("CMake_SOURCE_DIR='${CMake_SOURCE_DIR}'") -message("CVS_EXECUTABLE='${CVS_EXECUTABLE}'") message("GIT_EXECUTABLE='${GIT_EXECUTABLE}'") message("HOME='${HOME}'") message("ENV{DASHBOARD_TEST_FROM_CTEST}='$ENV{DASHBOARD_TEST_FROM_CTEST}'") @@ -43,7 +42,7 @@ message("in_source_build='${in_source_build}'") message("") -# If this does not appear to be a git or CVS checkout, just pass the test here +# If this does not appear to be a git checkout, just pass the test here # and now. (Do not let the test fail if it is run in a tree *exported* from a # repository or unpacked from a .zip file source installer...) # @@ -52,29 +51,13 @@ if(EXISTS "${CMake_SOURCE_DIR}/.git") set(is_git_checkout 1) endif() -set(is_cvs_checkout 0) -if(EXISTS "${CMake_SOURCE_DIR}/CVS/Root") - set(is_cvs_checkout 1) -endif() - message("is_git_checkout='${is_git_checkout}'") -message("is_cvs_checkout='${is_cvs_checkout}'") message("") -if(NOT is_cvs_checkout) if(NOT is_git_checkout) - message("source tree is neither git nor CVS checkout... test passes by early return...") + message("source tree is not a git checkout... test passes by early return...") return() endif() -endif() - -if(is_cvs_checkout) -if(is_git_checkout) - message("warning: source tree has both git *and* CVS file system bits???") - # should this condition be a FATAL_ERROR test failure...? -endif() -endif() - # This test looks for the following types of changes in the source tree: # @@ -83,51 +66,13 @@ set(conflicts 0) set(modifications 0) set(nonadditions 0) -# ov == output variable... conditionally filled in by either cvs or git below: +# ov == output variable... conditionally filled in by either git below: # set(cmd "") set(ov "") set(ev "") set(rv "") - -if(is_cvs_checkout AND CVS_EXECUTABLE) - # Check with "cvs -q -n up -dP" if there are any local modifications to the - # CMake source tree: - # - message("=============================================================================") - message("This is a cvs checkout, using cvs to verify source tree....") - message("") - - execute_process(COMMAND ${CVS_EXECUTABLE} --version - WORKING_DIRECTORY ${CMake_SOURCE_DIR} - OUTPUT_VARIABLE version_output - OUTPUT_STRIP_TRAILING_WHITESPACE) - message("=== output of 'cvs --version' ===") - message("${version_output}") - message("=== end output ===") - message("") - - file(READ "${CMake_SOURCE_DIR}/CVS/Root" contents) - message("=== content of CVS/Root ===") - message("${contents}") - message("=== end content ===") - message("") - - file(READ "${CMake_SOURCE_DIR}/CVS/Repository" contents) - message("=== content of CVS/Repository ===") - message("${contents}") - message("=== end content ===") - message("") - - message("Copy/paste this command to reproduce:") - message("cd \"${CMake_SOURCE_DIR}\" && \"${CVS_EXECUTABLE}\" -q -n up -dP") - message("") - - set(cmd ${CVS_EXECUTABLE} -q -n up -dP) -endif() - - # If no GIT_EXECUTABLE, see if we can figure out which git was used # for the ctest_update step on this dashboard... # @@ -268,8 +213,8 @@ endif() if(cmd) - # Use the HOME value passed in to the script for calling cvs/git so it can - # find its .cvspass or user/global config settings... + # Use the HOME value passed in to the script for calling git so it can + # find its user/global config settings... # set(original_ENV_HOME "$ENV{HOME}") set(ENV{HOME} "${HOME}") @@ -322,28 +267,6 @@ if(NOT ov STREQUAL "") endif() if(consider) - if(is_cvs_checkout) - if(line MATCHES "^A ") - message(" locally added file/directory detected...") - set(additions 1) - endif() - - if(line MATCHES "^C ") - message(" conflict detected...") - set(conflicts 1) - endif() - - if(line MATCHES "^M ") - message(" locally modified file detected...") - set(modifications 1) - endif() - - if(line MATCHES "^\\? ") - message(" locally non-added file/directory detected...") - set(nonadditions 1) - endif() - endif() - if(is_git_checkout) if(line MATCHES "^#[ \t]*modified:") message(" locally modified file detected...") diff --git a/Tests/CMakeTests/GetProperty-Bad-Argument.cmake b/Tests/CMakeTests/GetProperty-Bad-Argument.cmake new file mode 100644 index 0000000..382dabb --- /dev/null +++ b/Tests/CMakeTests/GetProperty-Bad-Argument.cmake @@ -0,0 +1 @@ +get_property(FOO GLOBAL PROPERTY FOO FOO) diff --git a/Tests/CMakeTests/GetProperty-Bad-Directory.cmake b/Tests/CMakeTests/GetProperty-Bad-Directory.cmake new file mode 100644 index 0000000..cdbfa80 --- /dev/null +++ b/Tests/CMakeTests/GetProperty-Bad-Directory.cmake @@ -0,0 +1 @@ +get_property(FOO DIRECTORY NonExistentSubDir PROPERTY FOO) diff --git a/Tests/CMakeTests/GetProperty-Bad-Scope.cmake b/Tests/CMakeTests/GetProperty-Bad-Scope.cmake new file mode 100644 index 0000000..ea8566b --- /dev/null +++ b/Tests/CMakeTests/GetProperty-Bad-Scope.cmake @@ -0,0 +1 @@ +get_property(FOO FOO FOO) diff --git a/Tests/CMakeTests/GetProperty-Bad-Target.cmake b/Tests/CMakeTests/GetProperty-Bad-Target.cmake new file mode 100644 index 0000000..9992dab --- /dev/null +++ b/Tests/CMakeTests/GetProperty-Bad-Target.cmake @@ -0,0 +1 @@ +get_property(FOO TARGET FOO PROPERTY FOO) diff --git a/Tests/CMakeTests/GetProperty-Bad-Test.cmake b/Tests/CMakeTests/GetProperty-Bad-Test.cmake new file mode 100644 index 0000000..44bf3eb --- /dev/null +++ b/Tests/CMakeTests/GetProperty-Bad-Test.cmake @@ -0,0 +1 @@ +get_property(FOO TEST FOO PROPERTY FOO) diff --git a/Tests/CMakeTests/GetProperty-Doc-Properties.cmake b/Tests/CMakeTests/GetProperty-Doc-Properties.cmake new file mode 100644 index 0000000..6c2c362 --- /dev/null +++ b/Tests/CMakeTests/GetProperty-Doc-Properties.cmake @@ -0,0 +1,10 @@ +get_property(FOO_BRIEF GLOBAL PROPERTY FOO BRIEF_DOCS) +get_property(FOO_FULL GLOBAL PROPERTY FOO FULL_DOCS) + +if (NOT FOO_BRIEF STREQUAL "NOTFOUND") + message(SEND_ERROR "property FOO has BRIEF_DOCS set to '${FOO_BRIEF}'") +endif () + +if (NOT FOO_FULL STREQUAL "NOTFOUND") + message(SEND_ERROR "property FOO has FULL_DOCS set to '${FOO_FULL}'") +endif () diff --git a/Tests/CMakeTests/GetProperty-Global-Name.cmake b/Tests/CMakeTests/GetProperty-Global-Name.cmake new file mode 100644 index 0000000..497700c --- /dev/null +++ b/Tests/CMakeTests/GetProperty-Global-Name.cmake @@ -0,0 +1 @@ +get_property(FOO GLOBAL FOO PROPERTY FOO) diff --git a/Tests/CMakeTests/GetProperty-Missing-Argument.cmake b/Tests/CMakeTests/GetProperty-Missing-Argument.cmake new file mode 100644 index 0000000..f0d004d --- /dev/null +++ b/Tests/CMakeTests/GetProperty-Missing-Argument.cmake @@ -0,0 +1 @@ +get_property() diff --git a/Tests/CMakeTests/GetProperty-No-Cache.cmake b/Tests/CMakeTests/GetProperty-No-Cache.cmake new file mode 100644 index 0000000..9719fe7 --- /dev/null +++ b/Tests/CMakeTests/GetProperty-No-Cache.cmake @@ -0,0 +1 @@ +get_property(FOO CACHE PROPERTY FOO) diff --git a/Tests/CMakeTests/GetProperty-No-Property.cmake b/Tests/CMakeTests/GetProperty-No-Property.cmake new file mode 100644 index 0000000..bee230d --- /dev/null +++ b/Tests/CMakeTests/GetProperty-No-Property.cmake @@ -0,0 +1 @@ +get_property(FOO GLOBAL PROPERTY) diff --git a/Tests/CMakeTests/GetProperty-No-Source.cmake b/Tests/CMakeTests/GetProperty-No-Source.cmake new file mode 100644 index 0000000..89773c8 --- /dev/null +++ b/Tests/CMakeTests/GetProperty-No-Source.cmake @@ -0,0 +1 @@ +get_property(FOO SOURCE PROPERTY FOO) diff --git a/Tests/CMakeTests/GetProperty-No-Target.cmake b/Tests/CMakeTests/GetProperty-No-Target.cmake new file mode 100644 index 0000000..8f1fa23 --- /dev/null +++ b/Tests/CMakeTests/GetProperty-No-Target.cmake @@ -0,0 +1 @@ +get_property(FOO TARGET PROPERTY FOO) diff --git a/Tests/CMakeTests/GetProperty-No-Test.cmake b/Tests/CMakeTests/GetProperty-No-Test.cmake new file mode 100644 index 0000000..045bd56 --- /dev/null +++ b/Tests/CMakeTests/GetProperty-No-Test.cmake @@ -0,0 +1 @@ +get_property(FOO TEST PROPERTY FOO) diff --git a/Tests/CMakeTests/GetProperty-Variable-Name.cmake b/Tests/CMakeTests/GetProperty-Variable-Name.cmake new file mode 100644 index 0000000..9190f80 --- /dev/null +++ b/Tests/CMakeTests/GetProperty-Variable-Name.cmake @@ -0,0 +1 @@ +get_property(FOO VARIABLE FOO PROPERTY FOO) diff --git a/Tests/CMakeTests/GetPropertyTest.cmake.in b/Tests/CMakeTests/GetPropertyTest.cmake.in new file mode 100644 index 0000000..ab96e5b --- /dev/null +++ b/Tests/CMakeTests/GetPropertyTest.cmake.in @@ -0,0 +1,98 @@ +include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") + +set(Missing-Argument-RESULT 1) +set(Missing-Argument-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-Missing-Argument.cmake:1 \\(get_property\\):.*get_property called with incorrect number of arguments.*") + +check_cmake_test(GetProperty + Missing-Argument +) + +set(Bad-Scope-RESULT 1) +set(Bad-Scope-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-Bad-Scope.cmake:1 \\(get_property\\):.*get_property given invalid scope FOO\\..*") + +check_cmake_test(GetProperty + Bad-Scope +) + +set(Bad-Argument-RESULT 1) +set(Bad-Argument-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-Bad-Argument.cmake:1 \\(get_property\\):.*get_property given invalid argument \"FOO\"\\..*") + +check_cmake_test(GetProperty + Bad-Argument +) + +set(No-Property-RESULT 1) +set(No-Property-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-No-Property.cmake:1 \\(get_property\\):.*get_property not given a PROPERTY <name> argument\\..*") + +check_cmake_test(GetProperty + No-Property +) + +set(Doc-Properties-RESULT 0) + +check_cmake_test(GetProperty + Doc-Properties +) + +set(Global-Name-RESULT 1) +set(Global-Name-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-Global-Name.cmake:1 \\(get_property\\):.*get_property given name for GLOBAL scope\\..*") + +check_cmake_test(GetProperty + Global-Name +) + +set(Bad-Directory-RESULT 1) +set(Bad-Directory-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-Bad-Directory.cmake:1 \\(get_property\\):.*get_property DIRECTORY scope provided but requested directory was not.*found\\..*") + +check_cmake_test(GetProperty + Bad-Directory +) + +set(No-Target-RESULT 1) +set(No-Target-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-No-Target.cmake:1 \\(get_property\\):.*get_property not given name for TARGET scope\\..*") + +check_cmake_test(GetProperty + No-Target +) + +set(Bad-Target-RESULT 1) +set(Bad-Target-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-Bad-Target.cmake:1 \\(get_property\\):.*get_property could not find TARGET FOO\\..*") + +check_cmake_test(GetProperty + Bad-Target +) + +set(No-Source-RESULT 1) +set(No-Source-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-No-Source.cmake:1 \\(get_property\\):.*get_property not given name for SOURCE scope\\..*") + +check_cmake_test(GetProperty + No-Source +) + +set(No-Test-RESULT 1) +set(No-Test-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-No-Test.cmake:1 \\(get_property\\):.*get_property not given name for TEST scope\\..*") + +check_cmake_test(GetProperty + No-Test +) + +set(Bad-Test-RESULT 1) +set(Bad-Test-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-Bad-Test.cmake:1 \\(get_property\\):.*get_property given TEST name that does not exist: FOO.*") + +check_cmake_test(GetProperty + Bad-Test +) + +set(Variable-Name-RESULT 1) +set(Variable-Name-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-Variable-Name.cmake:1 \\(get_property\\):.*get_property given name for VARIABLE scope\\..*") + +check_cmake_test(GetProperty + Variable-Name +) + +set(No-Cache-RESULT 1) +set(No-Cache-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?GetProperty-No-Cache.cmake:1 \\(get_property\\):.*get_property not given name for CACHE scope\\..*") + +check_cmake_test(GetProperty + No-Cache +) diff --git a/Tests/CTestUpdateCVS.cmake.in b/Tests/CTestUpdateCVS.cmake.in index a04673e..f7f5db6 100644 --- a/Tests/CTestUpdateCVS.cmake.in +++ b/Tests/CTestUpdateCVS.cmake.in @@ -18,6 +18,19 @@ set(CVS "@CVS_EXECUTABLE@") message(" cvs = ${CVS}") set(REPO ${TOP}/repo) + +# The MSYS cvs tool interprets "c:/" as a "machine:" name for SSH. +# Detect the MSYS cvs and convert the repo path to an MSYS path. +if(WIN32) + if(EXISTS "${CVS}") + file(STRINGS "${CVS}" cvs_is_msys LIMIT_COUNT 1 REGEX "[Mm][Ss][Yy][Ss]") + if(cvs_is_msys) + message(" '${CVS}' is from MSYS (contains '${cvs_is_msys}')") + string(REGEX REPLACE "^([A-Za-z]):" "/\\1" REPO "${REPO}") + endif() + endif() +endif() + set(CVSCMD ${CVS} -d${REPO}) # CVSNT requires an extra option to 'cvs init'. diff --git a/Tests/CTestUpdateHG.cmake.in b/Tests/CTestUpdateHG.cmake.in index 543ddd9..5a9daae 100644 --- a/Tests/CTestUpdateHG.cmake.in +++ b/Tests/CTestUpdateHG.cmake.in @@ -28,7 +28,7 @@ run_child( WORKING_DIRECTORY ${TOP}/repo.hg COMMAND ${HG} init ) -set(REPO file://${TOP}/repo.hg) +set(REPO file:///${TOP}/repo.hg) #----------------------------------------------------------------------------- # Import initial content into the repository. diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index ac70129..7a76261 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -280,6 +280,18 @@ if(do_cvs_tests) set_property(TARGET ${proj} PROPERTY FOLDER "SetupRepos/Local/Deeply/Nested/For/Testing") + # The MSYS cvs tool interprets "c:/" as a "machine:" name for SSH. + # Detect the MSYS cvs and convert the repo path to an MSYS path. + if(WIN32) + if(EXISTS "${CVS_EXECUTABLE}") + file(STRINGS "${CVS_EXECUTABLE}" cvs_is_msys LIMIT_COUNT 1 REGEX "[Mm][Ss][Yy][Ss]") + if(cvs_is_msys) + message(STATUS "'${CVS_EXECUTABLE}' is from MSYS (contains '${cvs_is_msys}')") + string(REGEX REPLACE "^([A-Za-z]):" "/\\1" local_cvs_repo "${local_cvs_repo}") + endif() + endif() + endif() + # CVS by date stamp: # set(proj TutorialStep1-CVS-20090626) diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt index 60b8c22..60f5e5e 100644 --- a/Tests/IncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/CMakeLists.txt @@ -45,3 +45,5 @@ else() set_target_properties(IncludeDirectories PROPERTIES COMPILE_FLAGS "-ITarProp") endif() + +add_subdirectory(TargetIncludeDirectories) diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt new file mode 100644 index 0000000..2cf36f5 --- /dev/null +++ b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt @@ -0,0 +1,26 @@ + +cmake_minimum_required(VERSION 2.8) + +project(TargetIncludeDirectories) + +macro(create_header _name) + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${_name}") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_name}/${_name}.h" + "//${_name}.h + ") +endmacro() + +create_header(bar) +create_header(bat) +create_header(foo) +create_header(baz) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +include_directories("${CMAKE_CURRENT_BINARY_DIR}/bar") + +add_executable(TargetIncludeDirectories main.cpp) +set_property(TARGET TargetIncludeDirectories APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/bat") +set_property(TARGET TargetIncludeDirectories APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/foo") + +include_directories("${CMAKE_CURRENT_BINARY_DIR}/baz") diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp b/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp new file mode 100644 index 0000000..8aa3532 --- /dev/null +++ b/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp @@ -0,0 +1,10 @@ + +#include "bar.h" +#include "bat.h" +#include "foo.h" +#include "baz.h" + +int main(int, char**) +{ + return 0; +} diff --git a/Tests/Qt4Deploy/CMakeLists.txt b/Tests/Qt4Deploy/CMakeLists.txt new file mode 100644 index 0000000..646ea9f --- /dev/null +++ b/Tests/Qt4Deploy/CMakeLists.txt @@ -0,0 +1,70 @@ +cmake_minimum_required(VERSION 2.8) + +project(Qt4Deploy) +set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/install) + +find_package(Qt4 REQUIRED QtMain QtCore QtSql) +include(${QT_USE_FILE}) + +add_executable(testdeploy MACOSX_BUNDLE testdeploy.cpp) +target_link_libraries(testdeploy ${QT_LIBRARIES}) +set_target_properties(testdeploy PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}") + +if(CMAKE_CONFIGURATION_TYPES AND QT_QTCORE_LIBRARY_RELEASE AND QT_QTCORE_LIBRARY_DEBUG) + # note: installing debug Qt libraries from a Qt installation configured with + # -debug-and-release not yet supported (very low priority). + install(CODE " + if(\"\${CMAKE_INSTALL_CONFIG_NAME}\" MATCHES \"^([Dd][Ee][Bb][Uu][Gg])$\") + return() + endif() + ") +endif() + +# install the Qt4 app with qsqlite plugin +install(CODE "file(REMOVE_RECURSE \"${CMAKE_INSTALL_PREFIX}\")") +install(TARGETS testdeploy DESTINATION .) +include(../../Modules/DeployQt4.cmake) +if(APPLE) + install_qt4_executable(testdeploy.app "qsqlite") +elseif(WIN32) + install_qt4_executable(testdeploy.exe "qsqlite") +else() + install_qt4_executable(testdeploy "qsqlite") +endif() + + +# test depends on standard qsqlite plugin +if(QT_QSQLITE_PLUGIN_DEBUG OR QT_QSQLITE_PLUGIN_RELEASE) + + # test the deployed Qt application + if(APPLE) + install(CODE " + message(STATUS \"executing: ${CMAKE_INSTALL_PREFIX}/testdeploy.app/Contents/MacOS/testdeploy\") + execute_process(COMMAND \"${CMAKE_INSTALL_PREFIX}/testdeploy.app/Contents/MacOS/testdeploy\" + RESULT_VARIABLE result) + if(NOT result STREQUAL \"0\") + message(FATAL_ERROR \"error running testdeploy app\") + endif() + ") + else() + install(CODE " + message(STATUS \"executing: ${CMAKE_INSTALL_PREFIX}/testdeploy\") + execute_process(COMMAND \"${CMAKE_INSTALL_PREFIX}/testdeploy\" + RESULT_VARIABLE result) + if(NOT result STREQUAL \"0\") + message(FATAL_ERROR \"error running testdeploy app\") + endif() + ") + endif() + + # custom target to install and test the installation at build time + if(CMAKE_CONFIGURATION_TYPES) + set(install_config "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_CFG_INTDIR}") + endif() + + add_custom_target(testdeploy_test ALL + COMMAND ${CMAKE_COMMAND} ${install_config} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake + COMMENT "${CMAKE_COMMAND} ${install_config} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake" + DEPENDS testdeploy) + +endif() diff --git a/Tests/Qt4Deploy/testdeploy.cpp b/Tests/Qt4Deploy/testdeploy.cpp new file mode 100644 index 0000000..8b9c8d6 --- /dev/null +++ b/Tests/Qt4Deploy/testdeploy.cpp @@ -0,0 +1,29 @@ +#include <QCoreApplication> +#include <QSqlDatabase> +#include <QLibraryInfo> +#include <QDebug> +#include <QStringList> + +int main(int argc, char** argv) +{ + QCoreApplication app(argc, argv); + + qDebug() << "App path:" << app.applicationDirPath(); + qDebug() << "Plugin path:" << QLibraryInfo::location(QLibraryInfo::PluginsPath); + + bool foundSqlite = false; + + qDebug() << "Supported Database Drivers:"; + foreach(const QString &sqlDriver, QSqlDatabase::drivers()) + { + qDebug() << " " << sqlDriver; + if(sqlDriver == "QSQLITE") + foundSqlite = true; + } + + if(foundSqlite) + qDebug() << "Found sqlite support from plugin."; + else + qDebug() << "Could not find sqlite support from plugin."; + return foundSqlite ? 0 : 1; +} diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt index 29ce25d6..caa44f1 100644 --- a/Utilities/cmcurl/CMakeLists.txt +++ b/Utilities/cmcurl/CMakeLists.txt @@ -126,9 +126,9 @@ IF(CURL_MALLOC_DEBUG) ENDIF(CURL_MALLOC_DEBUG) # On windows preload settings -IF(WIN32) +IF(WIN32 AND NOT MINGW) INCLUDE(${LIBCURL_SOURCE_DIR}/Platforms/WindowsCache.cmake) -ENDIF(WIN32) +ENDIF() # This macro checks if the symbol exists in the library and if it # does, it appends library to the list. |