diff options
93 files changed, 1057 insertions, 174 deletions
diff --git a/Help/manual/cmake-buildsystem.7.rst b/Help/manual/cmake-buildsystem.7.rst index 03f9115..2b37c0c 100644 --- a/Help/manual/cmake-buildsystem.7.rst +++ b/Help/manual/cmake-buildsystem.7.rst @@ -428,7 +428,7 @@ the ``CONFIG`` generator expression. The ``CONFIG`` parameter is compared case-insensitively with the configuration being built. In the presence of :prop_tgt:`IMPORTED` targets, the content of -:prop_tgt:`MAP_IMPORTED_CONFIG_DEBUG <MAP_IMPORTED_CONFIG_CONFIG>` is also +:prop_tgt:`MAP_IMPORTED_CONFIG_DEBUG <MAP_IMPORTED_CONFIG_<CONFIG>>` is also accounted for by this expression. Some buildsystems generated by :manual:`cmake(1)` have a predetermined diff --git a/Help/manual/cmake-packages.7.rst b/Help/manual/cmake-packages.7.rst index b572bf7..e87eb83 100644 --- a/Help/manual/cmake-packages.7.rst +++ b/Help/manual/cmake-packages.7.rst @@ -392,11 +392,41 @@ should be provided by the ``ClimbingStats`` package, they should be in a separate file which is installed to the same location as the ``ClimbingStatsConfig.cmake`` file, and included from there. +Packages created by :command:`install(EXPORT)` are designed to be relocatable, +using paths relative to the location of the package itself. When defining +the interface of a target for ``EXPORT``, keep in mind that the include +directories should be specified as relative paths which are relative to the +:variable:`CMAKE_INSTALL_PREFIX`: + +.. code-block:: cmake + + target_include_directories(tgt INTERFACE + # Wrong, not relocatable: + $<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/TgtName> + ) + + target_include_directories(tgt INTERFACE + # Ok, relocatable: + $<INSTALL_INTERFACE:include/TgtName> + ) + +The ``$<INSTALL_PREFIX>`` +:manual:`generator expression <cmake-generator-expressions(7)>` may be used as +a placeholder for the install prefix without resulting in a non-relocatable +package. This is necessary if complex generator expressions are used: + +.. code-block:: cmake + + target_include_directories(tgt INTERFACE + # Ok, relocatable: + $<INSTALL_INTERFACE:$<$<CONFIG:Debug>:$<INSTALL_PREFIX>/include/TgtName>> + ) + The :command:`export(EXPORT)` command creates an :prop_tgt:`IMPORTED` targets -definition file which is specific to the build-tree. This can similiarly be -used with a suitable package configuration file and package version file to -define a package for the build tree which may be used without installation. -Consumers of the build tree can simply ensure that the +definition file which is specific to the build-tree, and is not relocatable. +This can similiarly be used with a suitable package configuration file and +package version file to define a package for the build tree which may be used +without installation. Consumers of the build tree can simply ensure that the :variable:`CMAKE_PREFIX_PATH` contains the build directory, or set the ``ClimbingStats_DIR`` to ``<build_dir>/ClimbingStats`` in the cache. diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 9138660..4bee05e 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -16,7 +16,9 @@ versions will begin to warn about the backward compatible behavior. It is possible to disable the warning by explicitly requesting the OLD, or backward compatible behavior using the :command:`cmake_policy` command. It is also possible to request NEW, or non-backward compatible behavior -for a policy, also avoiding the warning. +for a policy, also avoiding the warning. Each policy can also be set to +either NEW or OLD behavior explicitly on the command line with the +:variable:`CMAKE_POLICY_DEFAULT_CMP<NNNN>` variable. The :command:`cmake_minimum_required` command does more than report an error if a too-old version of CMake is used to build a project. It @@ -92,3 +94,6 @@ All Policies /policy/CMP0040 /policy/CMP0041 /policy/CMP0042 + /policy/CMP0043 + /policy/CMP0044 + /policy/CMP0045 diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index aebfe87..cdd996c 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -59,6 +59,7 @@ Variables that Provide Information /variable/CMAKE_SHARED_MODULE_PREFIX /variable/CMAKE_SHARED_MODULE_SUFFIX /variable/CMAKE_SIZEOF_VOID_P + /variable/CMAKE_SKIP_INSTALL_RULES /variable/CMAKE_SKIP_RPATH /variable/CMAKE_SOURCE_DIR /variable/CMAKE_STANDARD_LIBRARIES diff --git a/Help/policy/CMP0043.rst b/Help/policy/CMP0043.rst new file mode 100644 index 0000000..89a6cde --- /dev/null +++ b/Help/policy/CMP0043.rst @@ -0,0 +1,39 @@ +CMP0043 +------- + +Ignore COMPILE_DEFINITIONS_<Config> properties + +CMake 2.8.12 and lower allowed setting the +:prop_tgt:`COMPILE_DEFINITIONS_<CONFIG>` target property and +:prop_dir:`COMPILE_DEFINITIONS_<CONFIG>` directory property to apply +configuration-specific compile definitions. + +Since CMake 2.8.10, the :prop_tgt:`COMPILE_DEFINITIONS` property has supported +:manual:`generator expressions <cmake-generator-expressions(7)>` for setting +configuration-dependent content. The continued existence of the suffixed +variables is redundant, and causes a maintenance burden. Population of the +:prop_tgt:`COMPILE_DEFINITIONS_DEBUG <COMPILE_DEFINITIONS_<CONFIG>>` property +may be replaced with a population of :prop_tgt:`COMPILE_DEFINITIONS` directly +or via :command:`target_compile_definitions`: + +.. code-block:: cmake + + # Old Interface: + set_property(TARGET tgt APPEND PROPERTY + COMPILE_DEFINITIONS_DEBUG DEBUG_MODE + ) + + # New Interfaces: + set_property(TARGET tgt APPEND PROPERTY + COMPILE_DEFINITIONS $<$<CONFIG:Debug>:DEBUG_MODE> + ) + target_compile_definitions(tgt PRIVATE $<$<CONFIG:Debug>:DEBUG_MODE>) + +The OLD behavior for this policy is to consume the content of the suffixed +:prop_tgt:`COMPILE_DEFINITIONS_<CONFIG>` target property when generating the +compilation command. The NEW behavior for this policy is to ignore the content +of the :prop_tgt:`COMPILE_DEFINITIONS_<CONFIG>` target property . + +This policy was introduced in CMake version 3.0.0. CMake version +|release| warns when the policy is not set and uses OLD behavior. Use +the cmake_policy command to set it to OLD or NEW explicitly. diff --git a/Help/policy/CMP0044.rst b/Help/policy/CMP0044.rst new file mode 100644 index 0000000..edbadf5 --- /dev/null +++ b/Help/policy/CMP0044.rst @@ -0,0 +1,19 @@ +CMP0044 +------- + +Case sensitive ``<LANG>_COMPILER_ID`` generator expressions + +CMake 2.8.12 introduced the ``<LANG>_COMPILER_ID`` +:manual:`generator expressions <cmake-generator-expressions(7)>` to allow +comparison of the :variable:`CMAKE_<LANG>_COMPILER_ID` with a test value. The +possible valid values are lowercase, but the comparison with the test value +was performed case-insensitively. + +The OLD behavior for this policy is to perform a case-insensitive comparison +with the value in the ``<LANG>_COMPILER_ID`` expression. The NEW behavior +for this policy is to perform a case-sensitive comparison with the value in +the ``<LANG>_COMPILER_ID`` expression. + +This policy was introduced in CMake version 3.0.0. CMake version +|release| warns when the policy is not set and uses OLD behavior. Use +the cmake_policy command to set it to OLD or NEW explicitly. diff --git a/Help/policy/CMP0045.rst b/Help/policy/CMP0045.rst new file mode 100644 index 0000000..748eb6a --- /dev/null +++ b/Help/policy/CMP0045.rst @@ -0,0 +1,17 @@ +CMP0045 +------- + +Error on non-existent target in get_target_property. + +In CMake 2.8.12 and lower, the :command:`get_target_property` command accepted +a non-existent target argument without issuing any error or warning. The +result variable is set to a ``-NOTFOUND`` value. + +The OLD behavior for this policy is to issue no warning and set the result +variable to a ``-NOTFOUND`` value. The NEW behavior +for this policy is to issue a ``FATAL_ERROR`` if the command is called with a +non-existent target. + +This policy was introduced in CMake version 3.0.0. CMake version +|release| warns when the policy is not set and uses OLD behavior. Use +the cmake_policy command to set it to OLD or NEW explicitly. diff --git a/Help/variable/CMAKE_SKIP_INSTALL_RULES.rst b/Help/variable/CMAKE_SKIP_INSTALL_RULES.rst new file mode 100644 index 0000000..5eda254 --- /dev/null +++ b/Help/variable/CMAKE_SKIP_INSTALL_RULES.rst @@ -0,0 +1,7 @@ +CMAKE_SKIP_INSTALL_RULES +------------------------ + +Whether to disable generation of installation rules. + +If TRUE, cmake will neither generate installaton rules nor +will it generate cmake_install.cmake files. This variable is FALSE by default. diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake index a9efae4..ec28d8b 100644 --- a/Modules/CheckTypeSize.cmake +++ b/Modules/CheckTypeSize.cmake @@ -222,6 +222,8 @@ macro(CHECK_TYPE_SIZE TYPE VARIABLE) check_include_file(stdint.h HAVE_STDINT_H) check_include_file(stddef.h HAVE_STDDEF_H) endif() + unset(_CHECK_TYPE_SIZE_BUILTIN_TYPES_ONLY) + unset(_CHECK_TYPE_SIZE_LANGUAGE) # Compute or load the size or size map. set(${VARIABLE}_KEYS) diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 51a3d77..ae8baab 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -82,6 +82,9 @@ # Boost_USE_STATIC_RUNTIME - Set to ON or OFF to specify whether to use # libraries linked statically to the C++ runtime # ('s' tag). Default is platform dependent. +# Boost_USE_DEBUG_RUNTIME - Set to ON or OFF to specify whether to use +# libraries linked to the MS debug C++ runtime +# ('g' tag). Default is ON. # Boost_USE_DEBUG_PYTHON - Set to ON to use libraries compiled with a # debug Python build ('y' tag). Default is OFF. # Boost_USE_STLPORT - Set to ON to use libraries compiled with @@ -446,6 +449,9 @@ endfunction() if(NOT DEFINED Boost_USE_MULTITHREADED) set(Boost_USE_MULTITHREADED TRUE) endif() +if(NOT DEFINED Boost_USE_DEBUG_RUNTIME) + set(Boost_USE_DEBUG_RUNTIME TRUE) +endif() # Check the version of Boost against the requested version. if(Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR) @@ -787,7 +793,7 @@ if(Boost_USE_STATIC_RUNTIME) endif() # g using debug versions of the standard and runtime # support libraries -if(WIN32) +if(WIN32 AND Boost_USE_DEBUG_RUNTIME) if(MSVC OR "${CMAKE_CXX_COMPILER}" MATCHES "icl" OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc") set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}g") diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 28b8454..46a893d 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -761,7 +761,8 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) set(QT_MKSPECS_DIR NOTFOUND) find_path(QT_MKSPECS_DIR NAMES qconfig.pri HINTS ${qt_cross_paths} ${qt_mkspecs_dirs} - DOC "The location of the Qt mkspecs containing qconfig.pri") + DOC "The location of the Qt mkspecs containing qconfig.pri" + NO_CMAKE_FIND_ROOT_PATH) endif() if(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri") @@ -917,7 +918,8 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) endforeach() find_path(QT_PLUGINS_DIR NAMES accessible imageformats sqldrivers codecs designer HINTS ${qt_cross_paths} ${qt_plugins_dir} - DOC "The location of the Qt plugins") + DOC "The location of the Qt plugins" + NO_CMAKE_FIND_ROOT_PATH) endif () # ask qmake for the translations directory @@ -937,6 +939,7 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) find_path(QT_IMPORTS_DIR NAMES Qt HINTS ${qt_cross_paths} ${qt_imports_dir} DOC "The location of the Qt imports" + NO_CMAKE_FIND_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) mark_as_advanced(QT_IMPORTS_DIR) @@ -1178,20 +1181,24 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) endmacro() macro(_qt4_add_target_depends _QT_MODULE) - get_target_property(_configs Qt4::${_QT_MODULE} IMPORTED_CONFIGURATIONS) - _qt4_add_target_depends_internal(${_QT_MODULE} INTERFACE_LINK_LIBRARIES ${ARGN}) - foreach(_config ${_configs}) - _qt4_add_target_depends_internal(${_QT_MODULE} IMPORTED_LINK_INTERFACE_LIBRARIES_${_config} ${ARGN}) - endforeach() - set(_configs) + if (TARGET Qt4::${_QT_MODULE}) + get_target_property(_configs Qt4::${_QT_MODULE} IMPORTED_CONFIGURATIONS) + _qt4_add_target_depends_internal(${_QT_MODULE} INTERFACE_LINK_LIBRARIES ${ARGN}) + foreach(_config ${_configs}) + _qt4_add_target_depends_internal(${_QT_MODULE} IMPORTED_LINK_INTERFACE_LIBRARIES_${_config} ${ARGN}) + endforeach() + set(_configs) + endif() endmacro() macro(_qt4_add_target_private_depends _QT_MODULE) - get_target_property(_configs ${_QT_MODULE} IMPORTED_CONFIGURATIONS) - foreach(_config ${_configs}) - _qt4_add_target_depends_internal(${_QT_MODULE} IMPORTED_LINK_DEPENDENT_LIBRARIES_${_config} ${ARGN}) - endforeach() - set(_configs) + if (TARGET Qt4::${_QT_MODULE}) + get_target_property(_configs Qt4::${_QT_MODULE} IMPORTED_CONFIGURATIONS) + foreach(_config ${_configs}) + _qt4_add_target_depends_internal(${_QT_MODULE} IMPORTED_LINK_DEPENDENT_LIBRARIES_${_config} ${ARGN}) + endforeach() + set(_configs) + endif() endmacro() diff --git a/Modules/GNUInstallDirs.cmake b/Modules/GNUInstallDirs.cmake index c8d77c6..9f5b8a4 100644 --- a/Modules/GNUInstallDirs.cmake +++ b/Modules/GNUInstallDirs.cmake @@ -95,7 +95,7 @@ if(NOT DEFINED CMAKE_INSTALL_LIBDIR) # For Debian with multiarch, use 'lib/${CMAKE_LIBRARY_ARCHITECTURE}' if # CMAKE_LIBRARY_ARCHITECTURE is set (which contains e.g. "i386-linux-gnu" # See http://wiki.debian.org/Multiarch - if(CMAKE_SYSTEM_NAME MATCHES "Linux" + if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$" AND NOT CMAKE_CROSSCOMPILING) if (EXISTS "/etc/debian_version") # is this a debian system ? if(CMAKE_LIBRARY_ARCHITECTURE) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index e9309d3..3b0f3c0 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 12) -set(CMake_VERSION_TWEAK 20140108) +set(CMake_VERSION_TWEAK 20140110) #set(CMake_VERSION_RC 1) diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 01f7a20..9c27fc1 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -138,6 +138,8 @@ bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os) return this->PrintHelpListPolicies(os); case cmDocumentation::Version: return this->PrintVersion(os); + case cmDocumentation::OldCustomModules: + return this->PrintOldCustomModules(os); default: return false; } } @@ -336,7 +338,15 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv, GET_OPT_ARGUMENT(help.Filename); cmSystemTools::Message( "Warning: --help-custom-modules no longer supported"); - return true; + if(help.Filename.empty()) + { + return true; + } + // Avoid breaking old project builds completely by at least generating + // the output file. Abuse help.Argument to give the file name to + // PrintOldCustomModules without disrupting our internal API. + help.HelpType = cmDocumentation::OldCustomModules; + help.Argument = cmSystemTools::GetFilenameName(help.Filename); } else if(strcmp(argv[i], "--help-commands") == 0) { @@ -864,3 +874,48 @@ bool cmDocumentation::IsOption(const char* arg) const return ((arg[0] == '-') || (strcmp(arg, "/V") == 0) || (strcmp(arg, "/?") == 0)); } + +//---------------------------------------------------------------------------- +bool cmDocumentation::PrintOldCustomModules(std::ostream& os) +{ + // CheckOptions abuses the Argument field to give us the file name. + std::string filename = this->CurrentArgument; + std::string ext = cmSystemTools::UpperCase( + cmSystemTools::GetFilenameLastExtension(filename)); + std::string name = cmSystemTools::GetFilenameWithoutLastExtension(filename); + + const char* summary = "cmake --help-custom-modules no longer supported\n"; + const char* detail = + "CMake versions prior to 3.0 exposed their internal module help page\n" + "generation functionality through the --help-custom-modules option.\n" + "CMake versions 3.0 and above use other means to generate their module\n" + "help pages so this functionality is no longer available to be exposed.\n" + "\n" + "This file was generated as a placeholder to provide this information.\n" + ; + if((ext == ".HTM") || (ext == ".HTML")) + { + os << "<html><title>" << name << "</title><body>\n" + << summary << "<p/>\n" << detail << "</body></html>\n"; + } + else if((ext.length()==2) && (ext[1] >='1') && (ext[1]<='9')) + { + os << + ".TH " << name << " " << ext[1] << " \"" << + cmSystemTools::GetCurrentDateTime("%B %d, %Y") << + "\" \"cmake " << cmVersion::GetCMakeVersion() << "\"\n" + ".SH NAME\n" + ".PP\n" << + name << " \\- " << summary << + "\n" + ".SH DESCRIPTION\n" + ".PP\n" << + detail + ; + } + else + { + os << name << "\n\n" << summary << "\n" << detail; + } + return true; +} diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h index 05c0442..d5a7dd5 100644 --- a/Source/cmDocumentation.h +++ b/Source/cmDocumentation.h @@ -115,6 +115,7 @@ private: bool PrintHelpListVariables(std::ostream& os); bool PrintHelpListPolicies(std::ostream& os); bool PrintDocumentationUsage(std::ostream& os); + bool PrintOldCustomModules(std::ostream& os); const char* GetNameString() const; bool IsOption(const char* arg) const; diff --git a/Source/cmDocumentationFormatter.h b/Source/cmDocumentationFormatter.h index c7da52c..118f03d 100644 --- a/Source/cmDocumentationFormatter.h +++ b/Source/cmDocumentationFormatter.h @@ -28,7 +28,8 @@ public: { None, Version, Usage, ListManuals, ListCommands, ListModules, ListProperties, ListVariables, ListPolicies, - OneManual, OneCommand, OneModule, OneProperty, OneVariable, OnePolicy + OneManual, OneCommand, OneModule, OneProperty, OneVariable, OnePolicy, + OldCustomModules }; }; diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index fce1284..a066153 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -398,7 +398,8 @@ void cmExtraCodeBlocksGenerator case cmTarget::OBJECT_LIBRARY: case cmTarget::UTILITY: // can have sources since 2.6.3 { - const std::vector<cmSourceFile*>&sources=ti->second.GetSourceFiles(); + std::vector<cmSourceFile*> sources; + ti->second.GetSourceFiles(sources); for (std::vector<cmSourceFile*>::const_iterator si=sources.begin(); si!=sources.end(); si++) { diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index c93187e..3e9b786 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -559,7 +559,8 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets( std::vector<cmSourceGroup> sourceGroups=makefile->GetSourceGroups(); // get the files from the source lists then add them to the groups cmTarget* tgt = const_cast<cmTarget*>(&ti->second); - std::vector<cmSourceFile*>const & files = tgt->GetSourceFiles(); + std::vector<cmSourceFile*> files; + tgt->GetSourceFiles(files); for(std::vector<cmSourceFile*>::const_iterator sfIt = files.begin(); sfIt != files.end(); sfIt++) diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 9cbdd7c..52411e8 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -237,7 +237,8 @@ void cmExtraSublimeTextGenerator:: { cmGeneratorTarget *gtgt = this->GlobalGenerator ->GetGeneratorTarget(target); - std::vector<cmSourceFile*> const& sourceFiles = target->GetSourceFiles(); + std::vector<cmSourceFile*> sourceFiles; + target->GetSourceFiles(sourceFiles); std::vector<cmSourceFile*>::const_iterator sourceFilesEnd = sourceFiles.end(); for (std::vector<cmSourceFile*>::const_iterator iter = diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index b08c335..4ce1ea5 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -132,8 +132,8 @@ void cmFLTKWrapUICommand::FinalPass() cmSystemTools::Message(msg.c_str(),"Warning"); return; } - std::vector<cmSourceFile*> const& srcs = - target->GetSourceFiles(); + std::vector<cmSourceFile*> srcs; + target->GetSourceFiles(srcs); bool found = false; for (unsigned int i = 0; i < srcs.size(); ++i) { diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 5edea86..1feb03a 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -412,10 +412,32 @@ struct CompilerIdNode : public cmGeneratorExpressionNode return parameters.front().empty() ? "1" : "0"; } - if (cmsysString_strcasecmp(parameters.begin()->c_str(), compilerId) == 0) + if (strcmp(parameters.begin()->c_str(), compilerId) == 0) { return "1"; } + + if (cmsysString_strcasecmp(parameters.begin()->c_str(), compilerId) == 0) + { + switch(context->Makefile->GetPolicyStatus(cmPolicies::CMP0044)) + { + case cmPolicies::WARN: + { + cmOStringStream e; + e << context->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0044); + context->Makefile->GetCMakeInstance() + ->IssueMessage(cmake::AUTHOR_WARNING, + e.str().c_str(), context->Backtrace); + } + case cmPolicies::OLD: + return "1"; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + break; + } + } return "0"; } }; @@ -1024,7 +1046,12 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode /* else */ if (cmHasLiteralPrefix(propertyName.c_str(), "COMPILE_DEFINITIONS_")) { - interfacePropertyName = "INTERFACE_COMPILE_DEFINITIONS"; + cmPolicies::PolicyStatus polSt = + context->Makefile->GetPolicyStatus(cmPolicies::CMP0043); + if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD) + { + interfacePropertyName = "INTERFACE_COMPILE_DEFINITIONS"; + } } #undef POPULATE_INTERFACE_PROPERTY_NAME diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6894cfc..5cd1f42 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -65,7 +65,8 @@ cmGeneratorTarget::GetSourceDepends(cmSourceFile* sf) const static void handleSystemIncludesDep(cmMakefile *mf, const std::string &name, const char *config, cmTarget *headTarget, cmGeneratorExpressionDAGChecker *dagChecker, - std::vector<std::string>& result) + std::vector<std::string>& result, + bool excludeImported) { cmTarget* depTgt = mf->FindTargetToUse(name.c_str()); @@ -85,7 +86,7 @@ static void handleSystemIncludesDep(cmMakefile *mf, const std::string &name, config, false, headTarget, depTgt, dagChecker), result); } - if (!depTgt->IsImported()) + if (!depTgt->IsImported() || excludeImported) { return; } @@ -102,6 +103,84 @@ static void handleSystemIncludesDep(cmMakefile *mf, const std::string &name, } //---------------------------------------------------------------------------- +void +cmGeneratorTarget::GetObjectSources(std::vector<cmSourceFile*> &objs) const +{ + objs = this->ObjectSources; +} + +//---------------------------------------------------------------------------- +const std::string& cmGeneratorTarget::GetObjectName(cmSourceFile const* file) +{ + return this->Objects[file]; +} + +void cmGeneratorTarget::AddObject(cmSourceFile *sf, std::string const&name) +{ + this->Objects[sf] = name; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile* sf) +{ + this->ExplicitObjectName.insert(sf); +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::HasExplicitObjectName(cmSourceFile const* file) const +{ + std::set<cmSourceFile const*>::const_iterator it + = this->ExplicitObjectName.find(file); + return it != this->ExplicitObjectName.end(); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetResxSources(std::vector<cmSourceFile*>& srcs) const +{ + srcs = this->ResxSources; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetIDLSources(std::vector<cmSourceFile*>& srcs) const +{ + srcs = this->IDLSources; +} + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget::GetHeaderSources(std::vector<cmSourceFile*>& srcs) const +{ + srcs = this->HeaderSources; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetExtraSources(std::vector<cmSourceFile*>& srcs) const +{ + srcs = this->ExtraSources; +} + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget::GetCustomCommands(std::vector<cmSourceFile*>& srcs) const +{ + srcs = this->CustomCommands; +} + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget::GetExpectedResxHeaders(std::set<std::string>& srcs) const +{ + srcs = this->ExpectedResxHeaders; +} + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget::GetExternalObjects(std::vector<cmSourceFile*>& srcs) const +{ + srcs = this->ExternalObjects; +} + +//---------------------------------------------------------------------------- bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, const char *config) const { @@ -130,6 +209,9 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, this->GetName(), "SYSTEM_INCLUDE_DIRECTORIES", 0, 0); + bool excludeImported + = this->Target->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED"); + std::vector<std::string> result; for (std::set<cmStdString>::const_iterator it = this->Target->GetSystemIncludeDirectories().begin(); @@ -156,7 +238,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, } handleSystemIncludesDep(this->Makefile, *li, config, this->Target, - &dagChecker, result); + &dagChecker, result, excludeImported); std::vector<std::string> deps; tgt->GetTransitivePropertyLinkLibraries(config, this->Target, deps); @@ -167,7 +249,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, if (uniqueDeps.insert(*di).second) { handleSystemIncludesDep(this->Makefile, *di, config, this->Target, - &dagChecker, result); + &dagChecker, result, excludeImported); } } } @@ -202,9 +284,9 @@ bool cmGeneratorTarget::GetPropertyAsBool(const char *prop) const } //---------------------------------------------------------------------------- -std::vector<cmSourceFile*> const& cmGeneratorTarget::GetSourceFiles() const +void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*> &files) const { - return this->Target->GetSourceFiles(); + this->Target->GetSourceFiles(files); } //---------------------------------------------------------------------------- @@ -216,7 +298,8 @@ void cmGeneratorTarget::ClassifySources() bool isObjLib = targetType == cmTarget::OBJECT_LIBRARY; std::vector<cmSourceFile*> badObjLib; - std::vector<cmSourceFile*> const& sources = this->Target->GetSourceFiles(); + std::vector<cmSourceFile*> sources; + this->Target->GetSourceFiles(sources); for(std::vector<cmSourceFile*>::const_iterator si = sources.begin(); si != sources.end(); ++si) { @@ -414,7 +497,8 @@ cmTargetTraceDependencies this->CurrentEntry = 0; // Queue all the source files already specified for the target. - std::vector<cmSourceFile*> const& sources = this->Target->GetSourceFiles(); + std::vector<cmSourceFile*> sources; + this->Target->GetSourceFiles(sources); for(std::vector<cmSourceFile*>::const_iterator si = sources.begin(); si != sources.end(); ++si) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8b760f1..17a223a 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -30,36 +30,35 @@ public: const char *GetName() const; const char *GetProperty(const char *prop) const; bool GetPropertyAsBool(const char *prop) const; - std::vector<cmSourceFile*> const& GetSourceFiles() const; + void GetSourceFiles(std::vector<cmSourceFile*>& files) const; + + void GetObjectSources(std::vector<cmSourceFile*> &) const; + const std::string& GetObjectName(cmSourceFile const* file); + + void AddObject(cmSourceFile *sf, std::string const&name); + bool HasExplicitObjectName(cmSourceFile const* file) const; + void AddExplicitObjectName(cmSourceFile* sf); + + void GetResxSources(std::vector<cmSourceFile*>&) const; + void GetIDLSources(std::vector<cmSourceFile*>&) const; + void GetExternalObjects(std::vector<cmSourceFile*>&) const; + void GetHeaderSources(std::vector<cmSourceFile*>&) const; + void GetExtraSources(std::vector<cmSourceFile*>&) const; + void GetCustomCommands(std::vector<cmSourceFile*>&) const; + void GetExpectedResxHeaders(std::set<std::string>&) const; cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; cmGlobalGenerator* GlobalGenerator; - /** Sources classified by purpose. */ - std::vector<cmSourceFile*> CustomCommands; - std::vector<cmSourceFile*> ExtraSources; - std::vector<cmSourceFile*> HeaderSources; - std::vector<cmSourceFile*> ObjectSources; - std::vector<cmSourceFile*> ExternalObjects; - std::vector<cmSourceFile*> IDLSources; - std::vector<cmSourceFile*> ResxSources; - std::string ModuleDefinitionFile; - std::map<cmSourceFile const*, std::string> Objects; - std::set<cmSourceFile const*> ExplicitObjectName; - - std::set<std::string> ExpectedResxHeaders; - /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ std::string ObjectDirectory; - std::vector<cmTarget*> ObjectLibraries; - void UseObjectLibraries(std::vector<std::string>& objs) const; void GetAppleArchs(const char* config, @@ -89,11 +88,23 @@ public: /** Get sources that must be built before the given source. */ std::vector<cmSourceFile*> const* GetSourceDepends(cmSourceFile* sf) const; +private: + friend class cmTargetTraceDependencies; struct SourceEntry { std::vector<cmSourceFile*> Depends; }; typedef std::map<cmSourceFile*, SourceEntry> SourceEntriesType; SourceEntriesType SourceEntries; -private: + std::vector<cmSourceFile*> CustomCommands; + std::vector<cmSourceFile*> ExtraSources; + std::vector<cmSourceFile*> HeaderSources; + std::vector<cmSourceFile*> ExternalObjects; + std::vector<cmSourceFile*> IDLSources; + std::vector<cmSourceFile*> ResxSources; + std::map<cmSourceFile const*, std::string> Objects; + std::set<cmSourceFile const*> ExplicitObjectName; + std::set<std::string> ExpectedResxHeaders; + std::vector<cmSourceFile*> ObjectSources; + std::vector<cmTarget*> ObjectLibraries; mutable std::map<std::string, std::vector<std::string> > SystemIncludesCache; cmGeneratorTarget(cmGeneratorTarget const&); diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx index 02f00a5..488cc28 100644 --- a/Source/cmGetTargetPropertyCommand.cxx +++ b/Source/cmGetTargetPropertyCommand.cxx @@ -40,7 +40,36 @@ bool cmGetTargetPropertyCommand cmTarget& target = *tgt; prop = target.GetProperty(args[2].c_str()); } - + else + { + bool issueMessage = false; + cmOStringStream e; + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0045)) + { + case cmPolicies::WARN: + issueMessage = true; + e << this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0045) << "\n"; + case cmPolicies::OLD: + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + issueMessage = true; + messageType = cmake::FATAL_ERROR; + } + if (issueMessage) + { + e << "get_target_property() called with non-existent target \"" + << targetName << "\"."; + this->Makefile->IssueMessage(messageType, e.str().c_str()); + if (messageType == cmake::FATAL_ERROR) + { + return false; + } + } + } if (prop) { this->Makefile->AddDefinition(var.c_str(), prop); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 82c9155..f883fbe 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1183,7 +1183,11 @@ void cmGlobalGenerator::Generate() this->LocalGenerators[i]->GetMakefile()->SetGeneratingBuildSystem(); this->SetCurrentLocalGenerator(this->LocalGenerators[i]); this->LocalGenerators[i]->Generate(); - this->LocalGenerators[i]->GenerateInstallRules(); + if(!this->LocalGenerators[i]->GetMakefile()->IsOn( + "CMAKE_SKIP_INSTALL_RULES")) + { + this->LocalGenerators[i]->GenerateInstallRules(); + } this->LocalGenerators[i]->GenerateTestFiles(); this->CMakeInstance->UpdateProgress("Generating", (static_cast<float>(i)+1.0f)/ @@ -1330,9 +1334,6 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo() const std::vector<cmValueWithOrigin> noconfig_compile_definitions = mf->GetCompileDefinitionsEntries(); - std::vector<std::string> configs; - mf->GetConfigurations(configs); - cmTargets& targets = mf->GetTargets(); for(cmTargets::iterator ti = targets.begin(); ti != targets.end(); ++ti) @@ -1353,13 +1354,21 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo() t->InsertCompileDefinition(*it); } - for(std::vector<std::string>::const_iterator ci = configs.begin(); - ci != configs.end(); ++ci) + cmPolicies::PolicyStatus polSt + = mf->GetPolicyStatus(cmPolicies::CMP0043); + if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD) { - std::string defPropName = "COMPILE_DEFINITIONS_"; - defPropName += cmSystemTools::UpperCase(*ci); - t->AppendProperty(defPropName.c_str(), - mf->GetProperty(defPropName.c_str())); + std::vector<std::string> configs; + mf->GetConfigurations(configs); + + for(std::vector<std::string>::const_iterator ci = configs.begin(); + ci != configs.end(); ++ci) + { + std::string defPropName = "COMPILE_DEFINITIONS_"; + defPropName += cmSystemTools::UpperCase(*ci); + t->AppendProperty(defPropName.c_str(), + mf->GetProperty(defPropName.c_str())); + } } } } @@ -2271,7 +2280,14 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) } //Install - if(this->InstallTargetEnabled) + bool skipInstallRules = mf->IsOn("CMAKE_SKIP_INSTALL_RULES"); + if(this->InstallTargetEnabled && skipInstallRules) + { + mf->IssueMessage(cmake::WARNING, + "CMAKE_SKIP_INSTALL_RULES was enabled even though " + "installation rules have been specified"); + } + else if(this->InstallTargetEnabled && !skipInstallRules) { if(!cmakeCfgIntDir || !*cmakeCfgIntDir || cmakeCfgIntDir[0] == '.') { @@ -2884,7 +2900,8 @@ void cmGlobalGenerator::WriteSummary(cmTarget* target) // List the source files with any per-source labels. fout << "# Source files and their labels\n"; - std::vector<cmSourceFile*> const& sources = target->GetSourceFiles(); + std::vector<cmSourceFile*> sources; + target->GetSourceFiles(sources); for(std::vector<cmSourceFile*>::const_iterator si = sources.begin(); si != sources.end(); ++si) { diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index 61ff45b..ed0e15b 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -138,7 +138,8 @@ bool cmGlobalKdevelopGenerator for (cmTargets::iterator ti = targets.begin(); ti != targets.end(); ti++) { - const std::vector<cmSourceFile*>& sources=ti->second.GetSourceFiles(); + std::vector<cmSourceFile*> sources; + ti->second.GetSourceFiles(sources); for (std::vector<cmSourceFile*>::const_iterator si=sources.begin(); si!=sources.end(); si++) { diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 4b92058..ec91b0f 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -644,15 +644,17 @@ void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const dir_max += "/"; gt->ObjectDirectory = dir_max; + std::vector<cmSourceFile*> objectSources; + gt->GetObjectSources(objectSources); // Compute the name of each object file. for(std::vector<cmSourceFile*>::iterator - si = gt->ObjectSources.begin(); - si != gt->ObjectSources.end(); ++si) + si = objectSources.begin(); + si != objectSources.end(); ++si) { cmSourceFile* sf = *si; std::string objectName = gt->LocalGenerator ->GetObjectFileNameWithoutTarget(*sf, dir_max); - gt->Objects[sf] = objectName; + gt->AddObject(sf, objectName); } } diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 622a7c5..0b37a07 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -120,17 +120,19 @@ cmGlobalUnixMakefileGenerator3 dir_max += "/"; gt->ObjectDirectory = dir_max; + std::vector<cmSourceFile*> objectSources; + gt->GetObjectSources(objectSources); // Compute the name of each object file. for(std::vector<cmSourceFile*>::iterator - si = gt->ObjectSources.begin(); - si != gt->ObjectSources.end(); ++si) + si = objectSources.begin(); + si != objectSources.end(); ++si) { cmSourceFile* sf = *si; bool hasSourceExtension = true; std::string objectName = gt->LocalGenerator ->GetObjectFileNameWithoutTarget(*sf, dir_max, &hasSourceExtension); - gt->Objects[sf] = objectName; + gt->AddObject(sf, objectName); lg->AddLocalObjectFile(target, sf, objectName, hasSourceExtension); } } diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 93a597c..42492e6 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -129,9 +129,11 @@ cmGlobalVisualStudioGenerator // Count the number of object files with each name. Note that // windows file names are not case sensitive. std::map<cmStdString, int> counts; + std::vector<cmSourceFile*> objectSources; + gt->GetObjectSources(objectSources); for(std::vector<cmSourceFile*>::const_iterator - si = gt->ObjectSources.begin(); - si != gt->ObjectSources.end(); ++si) + si = objectSources.begin(); + si != objectSources.end(); ++si) { cmSourceFile* sf = *si; std::string objectNameLower = cmSystemTools::LowerCase( @@ -143,8 +145,8 @@ cmGlobalVisualStudioGenerator // For all source files producing duplicate names we need unique // object name computation. for(std::vector<cmSourceFile*>::const_iterator - si = gt->ObjectSources.begin(); - si != gt->ObjectSources.end(); ++si) + si = objectSources.begin(); + si != objectSources.end(); ++si) { cmSourceFile* sf = *si; std::string objectName = @@ -152,10 +154,10 @@ cmGlobalVisualStudioGenerator objectName += ".obj"; if(counts[cmSystemTools::LowerCase(objectName)] > 1) { - gt->ExplicitObjectName.insert(sf); + gt->AddExplicitObjectName(sf); objectName = lg->GetObjectFileNameWithoutTarget(*sf, dir_max); } - gt->Objects[sf] = objectName; + gt->AddObject(sf, objectName); } std::string dir = gt->Makefile->GetCurrentOutputDirectory(); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index eef49db..f7a42fc 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -991,7 +991,8 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, } // organize the sources - std::vector<cmSourceFile*> classes = cmtarget.GetSourceFiles(); + std::vector<cmSourceFile*> classes; + cmtarget.GetSourceFiles(classes); std::sort(classes.begin(), classes.end(), cmSourceFilePathCompare()); std::vector<cmXCodeObject*> externalObjFiles; @@ -1360,7 +1361,8 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, postbuild.push_back(command); } - std::vector<cmSourceFile*>const &classes = cmtarget.GetSourceFiles(); + std::vector<cmSourceFile*> classes; + cmtarget.GetSourceFiles(classes); // add all the sources std::vector<cmCustomCommand> commands; for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); @@ -2442,7 +2444,8 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) // Add source files without build rules for editing convenience. if(cmtarget.GetType() == cmTarget::UTILITY) { - std::vector<cmSourceFile*> const& sources = cmtarget.GetSourceFiles(); + std::vector<cmSourceFile*> sources; + cmtarget.GetSourceFiles(sources); for(std::vector<cmSourceFile*>::const_iterator i = sources.begin(); i != sources.end(); ++i) { @@ -2945,7 +2948,8 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, cmtarget.AddSourceFile(sf); } - std::vector<cmSourceFile*> classes = cmtarget.GetSourceFiles(); + std::vector<cmSourceFile*> classes; + cmtarget.GetSourceFiles(classes); // Put cmSourceFile instances in proper groups: for(std::vector<cmSourceFile*>::const_iterator s = classes.begin(); @@ -3925,9 +3929,11 @@ cmGlobalXCodeGenerator // to avoid exact duplicate file names. Note that Mac file names are not // typically case sensitive, hence the LowerCase. std::map<cmStdString, int> counts; + std::vector<cmSourceFile*> objectSources; + gt->GetObjectSources(objectSources); for(std::vector<cmSourceFile*>::const_iterator - si = gt->ObjectSources.begin(); - si != gt->ObjectSources.end(); ++si) + si = objectSources.begin(); + si != objectSources.end(); ++si) { cmSourceFile* sf = *si; std::string objectName = @@ -3941,7 +3947,7 @@ cmGlobalXCodeGenerator // TODO: emit warning about duplicate name? } - gt->Objects[sf] = objectName; + gt->AddObject(sf, objectName); } const char* configName = this->GetCMakeCFGIntDir(); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 455f542..3effe38 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -657,7 +657,8 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmStdString objs; std::vector<std::string> objVector; // Add all the sources outputs to the depends of the target - std::vector<cmSourceFile*> const& classes = target.GetSourceFiles(); + std::vector<cmSourceFile*> classes; + target.GetSourceFiles(classes); for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); i != classes.end(); ++i) { @@ -1631,7 +1632,8 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, if(this->Makefile->IsOn("WIN32") && !(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW"))) { - const std::vector<cmSourceFile*>& sources = target->GetSourceFiles(); + std::vector<cmSourceFile*> sources; + target->GetSourceFiles(sources); for(std::vector<cmSourceFile*>::const_iterator i = sources.begin(); i != sources.end(); ++i) { diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 8eeb89a..fb12521 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -314,7 +314,8 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout, std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups(); // get the classes from the source lists then add them to the groups - std::vector<cmSourceFile*> const & classes = target.GetSourceFiles(); + std::vector<cmSourceFile*> classes; + target.GetSourceFiles(classes); // now all of the source files have been properly assigned to the target // now stick them into source groups using the reg expressions @@ -401,9 +402,9 @@ void cmLocalVisualStudio6Generator std::string compileFlags; std::vector<std::string> depends; std::string objectNameDir; - if(gt->ExplicitObjectName.find(*sf) != gt->ExplicitObjectName.end()) + if(gt->HasExplicitObjectName(*sf)) { - objectNameDir = cmSystemTools::GetFilenamePath(gt->Objects[*sf]); + objectNameDir = cmSystemTools::GetFilenamePath(gt->GetObjectName(*sf)); } // Add per-source file flags. diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index b645f8f..57a4880 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1381,7 +1381,8 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, // get the classes from the source lists then add them to the groups this->ModuleDefinitionFile = ""; - std::vector<cmSourceFile*>const & classes = target.GetSourceFiles(); + std::vector<cmSourceFile*> classes; + target.GetSourceFiles(classes); for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); i != classes.end(); i++) { @@ -1468,9 +1469,9 @@ cmLocalVisualStudio7GeneratorFCInfo cmGeneratorTarget* gt = lg->GetGlobalGenerator()->GetGeneratorTarget(&target); std::string objectName; - if(gt->ExplicitObjectName.find(&sf) != gt->ExplicitObjectName.end()) + if(gt->HasExplicitObjectName(&sf)) { - objectName = gt->Objects[&sf]; + objectName = gt->GetObjectName(&sf); } // Compute per-source, per-config information. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 35b65b4..479e712 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1601,20 +1601,22 @@ void cmMakefile::InitializeFromParent() } // compile definitions property and per-config versions - { - this->SetProperty("COMPILE_DEFINITIONS", - parent->GetProperty("COMPILE_DEFINITIONS")); - std::vector<std::string> configs; - this->GetConfigurations(configs); - for(std::vector<std::string>::const_iterator ci = configs.begin(); - ci != configs.end(); ++ci) - { - std::string defPropName = "COMPILE_DEFINITIONS_"; - defPropName += cmSystemTools::UpperCase(*ci); - this->SetProperty(defPropName.c_str(), - parent->GetProperty(defPropName.c_str())); + cmPolicies::PolicyStatus polSt = this->GetPolicyStatus(cmPolicies::CMP0043); + if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD) + { + this->SetProperty("COMPILE_DEFINITIONS", + parent->GetProperty("COMPILE_DEFINITIONS")); + std::vector<std::string> configs; + this->GetConfigurations(configs); + for(std::vector<std::string>::const_iterator ci = configs.begin(); + ci != configs.end(); ++ci) + { + std::string defPropName = "COMPILE_DEFINITIONS_"; + defPropName += cmSystemTools::UpperCase(*ci); + const char* prop = parent->GetProperty(defPropName.c_str()); + this->SetProperty(defPropName.c_str(), prop); + } } - } // link libraries this->LinkLibraries = parent->LinkLibraries; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index f82b808..7f90078 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -151,9 +151,11 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() // First generate the object rule files. Save a list of all object // files for this target. + std::vector<cmSourceFile*> customCommands; + this->GeneratorTarget->GetCustomCommands(customCommands); for(std::vector<cmSourceFile*>::const_iterator - si = this->GeneratorTarget->CustomCommands.begin(); - si != this->GeneratorTarget->CustomCommands.end(); ++si) + si = customCommands.begin(); + si != customCommands.end(); ++si) { cmCustomCommand const* cc = (*si)->GetCustomCommand(); this->GenerateCustomRuleFile(*cc); @@ -170,21 +172,28 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() } } } + std::vector<cmSourceFile*> headerSources; + this->GeneratorTarget->GetHeaderSources(headerSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( - this->GeneratorTarget->HeaderSources, + headerSources, this->MacOSXContentGenerator); + std::vector<cmSourceFile*> extraSources; + this->GeneratorTarget->GetExtraSources(extraSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( - this->GeneratorTarget->ExtraSources, + extraSources, this->MacOSXContentGenerator); + std::vector<cmSourceFile*> externalObjects; + this->GeneratorTarget->GetExternalObjects(externalObjects); for(std::vector<cmSourceFile*>::const_iterator - si = this->GeneratorTarget->ExternalObjects.begin(); - si != this->GeneratorTarget->ExternalObjects.end(); ++si) + si = externalObjects.begin(); + si != externalObjects.end(); ++si) { this->ExternalObjects.push_back((*si)->GetFullPath()); } + std::vector<cmSourceFile*> objectSources; + this->GeneratorTarget->GetObjectSources(objectSources); for(std::vector<cmSourceFile*>::const_iterator - si = this->GeneratorTarget->ObjectSources.begin(); - si != this->GeneratorTarget->ObjectSources.end(); ++si) + si = objectSources.begin(); si != objectSources.end(); ++si) { // Generate this object file's rule file. this->WriteObjectRuleFiles(**si); @@ -421,7 +430,8 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source) } // Get the full path name of the object file. - std::string const& objectName = this->GeneratorTarget->Objects[&source]; + std::string const& objectName = this->GeneratorTarget + ->GetObjectName(&source); std::string obj = this->LocalGenerator->GetTargetDirectory(*this->Target); obj += "/"; obj += objectName; @@ -1142,8 +1152,8 @@ cmMakefileTargetGenerator ::DriveCustomCommands(std::vector<std::string>& depends) { // Depend on all custom command outputs. - const std::vector<cmSourceFile*>& sources = - this->Target->GetSourceFiles(); + std::vector<cmSourceFile*> sources; + this->Target->GetSourceFiles(sources); for(std::vector<cmSourceFile*>::const_iterator source = sources.begin(); source != sources.end(); ++source) { diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index c8b03e1..82f8d1b 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -276,7 +276,8 @@ cmNinjaTargetGenerator std::string path = this->LocalGenerator->GetHomeRelativeOutputPath(); if(!path.empty()) path += "/"; - std::string const& objectName = this->GeneratorTarget->Objects[source]; + std::string const& objectName = this->GeneratorTarget + ->GetObjectName(source); path += this->LocalGenerator->GetTargetDirectory(*this->Target); path += "/"; path += objectName; @@ -458,28 +459,37 @@ cmNinjaTargetGenerator << this->GetTargetName() << "\n\n"; + std::vector<cmSourceFile*> customCommands; + this->GeneratorTarget->GetCustomCommands(customCommands); for(std::vector<cmSourceFile*>::const_iterator - si = this->GeneratorTarget->CustomCommands.begin(); - si != this->GeneratorTarget->CustomCommands.end(); ++si) + si = customCommands.begin(); + si != customCommands.end(); ++si) { cmCustomCommand const* cc = (*si)->GetCustomCommand(); this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget()); } + std::vector<cmSourceFile*> headerSources; + this->GeneratorTarget->GetHeaderSources(headerSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( - this->GeneratorTarget->HeaderSources, + headerSources, this->MacOSXContentGenerator); + std::vector<cmSourceFile*> extraSources; + this->GeneratorTarget->GetExtraSources(extraSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( - this->GeneratorTarget->ExtraSources, + extraSources, this->MacOSXContentGenerator); + std::vector<cmSourceFile*> externalObjects; + this->GeneratorTarget->GetExternalObjects(externalObjects); for(std::vector<cmSourceFile*>::const_iterator - si = this->GeneratorTarget->ExternalObjects.begin(); - si != this->GeneratorTarget->ExternalObjects.end(); ++si) + si = externalObjects.begin(); + si != externalObjects.end(); ++si) { this->Objects.push_back(this->GetSourceFilePath(*si)); } + std::vector<cmSourceFile*> objectSources; + this->GeneratorTarget->GetObjectSources(objectSources); for(std::vector<cmSourceFile*>::const_iterator - si = this->GeneratorTarget->ObjectSources.begin(); - si != this->GeneratorTarget->ObjectSources.end(); ++si) + si = objectSources.begin(); si != objectSources.end(); ++si) { this->WriteObjectBuildStatement(*si); } @@ -539,9 +549,11 @@ cmNinjaTargetGenerator } // Add order-only dependencies on custom command outputs. + std::vector<cmSourceFile*> customCommands; + this->GeneratorTarget->GetCustomCommands(customCommands); for(std::vector<cmSourceFile*>::const_iterator - si = this->GeneratorTarget->CustomCommands.begin(); - si != this->GeneratorTarget->CustomCommands.end(); ++si) + si = customCommands.begin(); + si != customCommands.end(); ++si) { cmCustomCommand const* cc = (*si)->GetCustomCommand(); const std::vector<std::string>& ccoutputs = cc->GetOutputs(); diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index 8556565..1a7b445 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -42,8 +42,8 @@ void cmNinjaUtilityTargetGenerator::Generate() } } - const std::vector<cmSourceFile*>& sources = - this->GetTarget()->GetSourceFiles(); + std::vector<cmSourceFile*> sources; + this->GetTarget()->GetSourceFiles(sources); for(std::vector<cmSourceFile*>::const_iterator source = sources.begin(); source != sources.end(); ++source) { diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 987c663..5a189f8 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -316,6 +316,21 @@ cmPolicies::cmPolicies() CMP0042, "CMP0042", "MACOSX_RPATH is enabled by default.", 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0043, "CMP0043", + "Ignore COMPILE_DEFINITIONS_<Config> properties.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0044, "CMP0044", + "Case sensitive <LANG>_COMPILER_ID generator expressions.", + 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0045, "CMP0045", + "Error on non-existent target in get_target_property.", + 3,0,0,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 66eaf87..b1342bf 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -96,6 +96,9 @@ public: /// add_custom_command() must exist. CMP0041, ///< Error on relative include with generator expression CMP0042, ///< Enable MACOSX_RPATH by default + CMP0043, ///< Ignore COMPILE_DEFINITIONS_<Config> properties + CMP0044, ///< Case sensitive <LANG>_COMPILER_ID generator expressions + CMP0045, ///< Error on non-existent target in get_target_property /** \brief Always the last entry. * diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index bd7e75a..da22ab5 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -451,7 +451,8 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, const char* sepFiles = ""; const char* sepHeaders = ""; - const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles(); + std::vector<cmSourceFile*> srcFiles; + target->GetSourceFiles(srcFiles); std::string skip_moc; const char *sep = ""; @@ -643,7 +644,8 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, const char *qtUic = makefile->GetSafeDefinition("QT_UIC_EXECUTABLE"); makefile->AddDefinition("_qt_uic_executable", qtUic); - const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles(); + std::vector<cmSourceFile*> srcFiles; + target->GetSourceFiles(srcFiles); std::string skip_uic; const char *sep = ""; @@ -809,7 +811,8 @@ void cmQtAutoGenerators::InitializeAutoRccTarget(cmTarget* target) { cmMakefile *makefile = target->GetMakefile(); - const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles(); + std::vector<cmSourceFile*> srcFiles; + target->GetSourceFiles(srcFiles); std::vector<cmSourceFile*> newFiles; @@ -855,7 +858,8 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) const char* sepRccFiles = ""; cmMakefile *makefile = target->GetMakefile(); - const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles(); + std::vector<cmSourceFile*> srcFiles; + target->GetSourceFiles(srcFiles); std::string rccFileFiles; std::string rccFileOptions; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b06480b..4828d20 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -530,9 +530,9 @@ bool cmTarget::FindSourceFiles() } //---------------------------------------------------------------------------- -std::vector<cmSourceFile*> const& cmTarget::GetSourceFiles() const +void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files) const { - return this->SourceFiles; + files = this->SourceFiles; } //---------------------------------------------------------------------------- @@ -673,7 +673,8 @@ void cmTarget::ConstructSourceFileFlags() const // Handle the MACOSX_PACKAGE_LOCATION property on source files that // were not listed in one of the other lists. - std::vector<cmSourceFile*> const& sources = this->GetSourceFiles(); + std::vector<cmSourceFile*> sources; + this->GetSourceFiles(sources); for(std::vector<cmSourceFile*>::const_iterator si = sources.begin(); si != sources.end(); ++si) { @@ -2209,14 +2210,34 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, std::string configPropName = "COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config); const char *configProp = this->GetProperty(configPropName.c_str()); - std::string defsString = (configProp ? configProp : ""); - - cmGeneratorExpression ge(lfbt); - cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = - ge.Parse(defsString); - this->Internal - ->CachedLinkInterfaceCompileDefinitionsEntries[configString].push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + if (configProp) + { + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) + { + case cmPolicies::WARN: + { + cmOStringStream e; + e << this->Makefile->GetCMakeInstance()->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0043); + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, + e.str().c_str()); + } + case cmPolicies::OLD: + { + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = + ge.Parse(configProp); + this->Internal + ->CachedLinkInterfaceCompileDefinitionsEntries[configString] + .push_back(new cmTargetInternals::TargetPropertyEntry(cge)); + } + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::REQUIRED_IF_USED: + break; + } + } } } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 4916648..26d391f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -132,7 +132,7 @@ public: /** * Get the list of the source files used by this target */ - std::vector<cmSourceFile*> const& GetSourceFiles() const; + void GetSourceFiles(std::vector<cmSourceFile*> &files) const; void AddSourceFile(cmSourceFile* sf); std::vector<std::string> const& GetObjectLibraries() const { diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 784cadb..eee7c14 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -376,8 +376,8 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences() void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() { - std::vector<cmSourceFile*> const& resxObjs = - this->GeneratorTarget->ResxSources; + std::vector<cmSourceFile*> resxObjs; + this->GeneratorTarget->GetResxSources(resxObjs); if(!resxObjs.empty()) { this->WriteString("<ItemGroup>\n", 1); @@ -550,9 +550,11 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() void cmVisualStudio10TargetGenerator::WriteCustomCommands() { this->SourcesVisited.clear(); + std::vector<cmSourceFile*> customCommands; + this->GeneratorTarget->GetCustomCommands(customCommands); for(std::vector<cmSourceFile*>::const_iterator - si = this->GeneratorTarget->CustomCommands.begin(); - si != this->GeneratorTarget->CustomCommands.end(); ++si) + si = customCommands.begin(); + si != customCommands.end(); ++si) { this->WriteCustomCommand(*si); } @@ -697,7 +699,8 @@ void cmVisualStudio10TargetGenerator::WriteGroups() // collect up group information std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups(); - std::vector<cmSourceFile*> classes = this->Target->GetSourceFiles(); + std::vector<cmSourceFile*> classes; + this->Target->GetSourceFiles(classes); std::set<cmSourceGroup*> groupsUsed; for(std::vector<cmSourceFile*>::const_iterator s = classes.begin(); @@ -740,8 +743,8 @@ void cmVisualStudio10TargetGenerator::WriteGroups() this->WriteGroupSources(ti->first.c_str(), ti->second, sourceGroups); } - std::vector<cmSourceFile*> const& resxObjs = - this->GeneratorTarget->ResxSources; + std::vector<cmSourceFile*> resxObjs; + this->GeneratorTarget->GetResxSources(resxObjs); if(!resxObjs.empty()) { this->WriteString("<ItemGroup>\n", 1); @@ -813,7 +816,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() this->WriteString("</Filter>\n", 2); } - if(!this->GeneratorTarget->ResxSources.empty()) + if(!resxObjs.empty()) { this->WriteString("<Filter Include=\"Resource Files\">\n", 2); std::string guidName = "SG_Filter_Resource Files"; @@ -996,12 +999,18 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } this->WriteString("<ItemGroup>\n", 1); - this->WriteSources("ClInclude", this->GeneratorTarget->HeaderSources); - this->WriteSources("Midl", this->GeneratorTarget->IDLSources); + std::vector<cmSourceFile*> headerSources; + this->GeneratorTarget->GetHeaderSources(headerSources); + this->WriteSources("ClInclude", headerSources); + std::vector<cmSourceFile*> idlSources; + this->GeneratorTarget->GetIDLSources(idlSources); + this->WriteSources("Midl", idlSources); + std::vector<cmSourceFile*> objectSources; + this->GeneratorTarget->GetObjectSources(objectSources); for(std::vector<cmSourceFile*>::const_iterator - si = this->GeneratorTarget->ObjectSources.begin(); - si != this->GeneratorTarget->ObjectSources.end(); ++si) + si = objectSources.begin(); + si != objectSources.end(); ++si) { const char* lang = (*si)->GetLanguage(); const char* tool = NULL; @@ -1038,19 +1047,21 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } } + std::vector<cmSourceFile*> externalObjects; + this->GeneratorTarget->GetExternalObjects(externalObjects); if(this->LocalGenerator->GetVersion() > cmLocalVisualStudioGenerator::VS10) { // For VS >= 11 we use LinkObjects to avoid linking custom command // outputs. Use Object for all external objects, generated or not. - this->WriteSources("Object", this->GeneratorTarget->ExternalObjects); + this->WriteSources("Object", externalObjects); } else { // If an object file is generated in this target, then vs10 will use // it in the build, and we have to list it as None instead of Object. for(std::vector<cmSourceFile*>::const_iterator - si = this->GeneratorTarget->ExternalObjects.begin(); - si != this->GeneratorTarget->ExternalObjects.end(); ++si) + si = externalObjects.begin(); + si != externalObjects.end(); ++si) { std::vector<cmSourceFile*> const* d = this->GeneratorTarget->GetSourceDepends(*si); @@ -1058,7 +1069,9 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } } - this->WriteSources("None", this->GeneratorTarget->ExtraSources); + std::vector<cmSourceFile*> extraSources; + this->GeneratorTarget->GetExtraSources(extraSources); + this->WriteSources("None", extraSources); // Add object library contents as external objects. std::vector<std::string> objs; @@ -1081,10 +1094,9 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( cmSourceFile& sf = *source; std::string objectName; - if(this->GeneratorTarget->ExplicitObjectName.find(&sf) - != this->GeneratorTarget->ExplicitObjectName.end()) + if(this->GeneratorTarget->HasExplicitObjectName(&sf)) { - objectName = this->GeneratorTarget->Objects[&sf]; + objectName = this->GeneratorTarget->GetObjectName(&sf); } std::string flags; std::string defines; @@ -1425,7 +1437,9 @@ OutputIncludes(std::vector<std::string> const & includes) for(std::vector<std::string>::const_iterator i = includes.begin(); i != includes.end(); ++i) { - *this->BuildFileStream << cmVS10EscapeXML(*i) << ";"; + std::string incDir = *i; + this->ConvertToWindowsSlash(incDir); + *this->BuildFileStream << cmVS10EscapeXML(incDir) << ";"; } this->WriteString("%(AdditionalIncludeDirectories)" "</AdditionalIncludeDirectories>\n", 0); @@ -1882,8 +1896,10 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences() bool cmVisualStudio10TargetGenerator:: IsResxHeader(const std::string& headerFile) { - std::set<std::string>::iterator it = - this->GeneratorTarget->ExpectedResxHeaders.find(headerFile); + std::set<std::string> expectedResxHeaders; + this->GeneratorTarget->GetExpectedResxHeaders(expectedResxHeaders); - return it != this->GeneratorTarget->ExpectedResxHeaders.end(); + std::set<std::string>::const_iterator it = + expectedResxHeaders.find(headerFile); + return it != expectedResxHeaders.end(); } diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 78dddd3..7969078 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -742,6 +742,19 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --test-command ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstExeS2) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleInstallS2") + set(MissingInstallInstallDir + "${CMake_BINARY_DIR}/Tests/MissingInstall/InstallDirectory") + add_test(MissingInstall ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/MissingInstall" + "${CMake_BINARY_DIR}/Tests/MissingInstall" + ${build_generator_args} + --build-project TestMissingInstall + --build-two-config + --build-options ${build_options} + "-DCMAKE_INSTALL_PREFIX:PATH=${MissingInstallInstallDir}") + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MissingInstall") + # By default, run the CPackComponents test if the CTEST_TEST_CPACK # option is ON: # diff --git a/Tests/CompileDefinitions/compiletest.c b/Tests/CompileDefinitions/compiletest.c index d7883af..8871750 100644 --- a/Tests/CompileDefinitions/compiletest.c +++ b/Tests/CompileDefinitions/compiletest.c @@ -13,6 +13,10 @@ #error Unexpected LINK_LANGUAGE_IS_CXX #endif +#ifdef DEBUG_MODE +#error Unexpected DEBUG_MODE +#endif + int main(void) { return 0; diff --git a/Tests/CompileDefinitions/target_prop/CMakeLists.txt b/Tests/CompileDefinitions/target_prop/CMakeLists.txt index a0d3f4e..2ca2869 100644 --- a/Tests/CompileDefinitions/target_prop/CMakeLists.txt +++ b/Tests/CompileDefinitions/target_prop/CMakeLists.txt @@ -35,6 +35,9 @@ set_property(TARGET target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS add_executable(target_prop_c_executable ../compiletest.c) +cmake_policy(SET CMP0043 NEW) +set_property(TARGET target_prop_c_executable APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUG_MODE) + set_property(TARGET target_prop_c_executable APPEND PROPERTY COMPILE_DEFINITIONS "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:LINK_CXX_DEFINE>" "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>:LINK_C_DEFINE>" diff --git a/Tests/GeneratorExpression/CMP0044/CMakeLists.txt b/Tests/GeneratorExpression/CMP0044/CMakeLists.txt new file mode 100644 index 0000000..309a8cc --- /dev/null +++ b/Tests/GeneratorExpression/CMP0044/CMakeLists.txt @@ -0,0 +1,19 @@ + +string(TOLOWER ${CMAKE_C_COMPILER_ID} lc_test) +if (lc_test STREQUAL CMAKE_C_COMPILER_ID) + string(TOUPPER ${CMAKE_C_COMPILER_ID} lc_test) + if (lc_test STREQUAL CMAKE_C_COMPILER_ID) + message(SEND_ERROR "Try harder.") + endif() +endif() + +if (CMP0044_TYPE) + cmake_policy(SET CMP0044 ${CMP0044_TYPE}) +endif() + +add_library(cmp0044-check-${CMP0044_TYPE} cmp0044-check.cpp) +target_compile_definitions(cmp0044-check-${CMP0044_TYPE} + PRIVATE + Result=$<C_COMPILER_ID:${lc_test}> + Type_Is_${CMP0044_TYPE} +) diff --git a/Tests/GeneratorExpression/CMP0044/cmp0044-check.cpp b/Tests/GeneratorExpression/CMP0044/cmp0044-check.cpp new file mode 100644 index 0000000..2356bc4 --- /dev/null +++ b/Tests/GeneratorExpression/CMP0044/cmp0044-check.cpp @@ -0,0 +1,26 @@ + +#ifdef Type_Is_ +# if !Result +# error Result should be 1 in WARN mode +# endif +#endif + +#ifdef Type_Is_NEW +# if Result +# error Result should be 0 in NEW mode +# endif +#endif + +#ifdef Type_Is_OLD +# if !Result +# error Result should be 1 in OLD mode +# endif +#endif + +#if !defined(Type_Is_) && !defined(Type_Is_OLD) && !defined(Type_Is_NEW) +#error No expected definition present +#endif + +void foo(void) +{ +} diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index 3b85dc3..a0e34ef 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -252,3 +252,9 @@ endforeach() add_test(echo-old-style echo "\$<CONFIGURATION>") set_property(TEST echo-old-style PROPERTY PASS_REGULAR_EXPRESSION "^\\$<CONFIGURATION>\n$") + +add_subdirectory(CMP0044 ${CMAKE_BINARY_DIR}/CMP0044-WARN) +set(CMP0044_TYPE NEW) +add_subdirectory(CMP0044 ${CMAKE_BINARY_DIR}/CMP0044-NEW) +set(CMP0044_TYPE OLD) +add_subdirectory(CMP0044 ${CMAKE_BINARY_DIR}/CMP0044-OLD) diff --git a/Tests/MissingInstall/CMakeLists.txt b/Tests/MissingInstall/CMakeLists.txt new file mode 100644 index 0000000..91624f7 --- /dev/null +++ b/Tests/MissingInstall/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required (VERSION 2.8.12) +project(TestMissingInstall) + +set(CMAKE_SKIP_INSTALL_RULES ON) + +# Skip the dependency that causes a build when installing. This +# avoids infinite loops when the post-build rule below installs. +set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY 1) +set(CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY 1) + +if(CMAKE_CONFIGURATION_TYPES) + set(MULTI_CONFIG ON) +else() + set(MULTI_CONFIG OFF) +endif() + +add_executable(mybin mybin.cpp) +install(TARGETS mybin RUNTIME DESTINATION bin) + +add_custom_command(TARGET mybin + POST_BUILD + COMMAND ${CMAKE_COMMAND} "-DMULTI_CONFIG=${MULTI_CONFIG}" + -P ${CMAKE_CURRENT_SOURCE_DIR}/ExpectInstallFail.cmake + COMMENT "Install Project" +) diff --git a/Tests/MissingInstall/ExpectInstallFail.cmake b/Tests/MissingInstall/ExpectInstallFail.cmake new file mode 100644 index 0000000..3d677bf --- /dev/null +++ b/Tests/MissingInstall/ExpectInstallFail.cmake @@ -0,0 +1,18 @@ +if(MULTI_CONFIG) + set(SI_CONFIG --config $<CONFIGURATION>) +else() + set(SI_CONFIG) +endif() + +execute_process( + COMMAND ${CMAKE_COMMAND} + --build . + --target install ${SI_CONFIG} + RESULT_VARIABLE RESULT + OUTPUT_VARIABLE OUTPUT + ERROR_VARIABLE ERROR +) + +if(RESULT EQUAL 0) + message(FATAL_ERROR "install should have failed") +endif() diff --git a/Tests/MissingInstall/mybin.cpp b/Tests/MissingInstall/mybin.cpp new file mode 100644 index 0000000..237c8ce --- /dev/null +++ b/Tests/MissingInstall/mybin.cpp @@ -0,0 +1 @@ +int main() {} diff --git a/Tests/RunCMake/CMP0043/CMP0043-NEW-result.txt b/Tests/RunCMake/CMP0043/CMP0043-NEW-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0043/CMP0043-NEW-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0043/CMP0043-NEW-stderr.txt b/Tests/RunCMake/CMP0043/CMP0043-NEW-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0043/CMP0043-NEW-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0043/CMP0043-NEW.cmake b/Tests/RunCMake/CMP0043/CMP0043-NEW.cmake new file mode 100644 index 0000000..857153d --- /dev/null +++ b/Tests/RunCMake/CMP0043/CMP0043-NEW.cmake @@ -0,0 +1,7 @@ + +cmake_policy(SET CMP0043 NEW) + +add_library(foo empty.cpp) +set_property(TARGET foo + PROPERTY COMPILE_DEFINITIONS_DEBUG "DEBUG_MODE" +) diff --git a/Tests/RunCMake/CMP0043/CMP0043-OLD-result.txt b/Tests/RunCMake/CMP0043/CMP0043-OLD-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0043/CMP0043-OLD-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0043/CMP0043-OLD-stderr.txt b/Tests/RunCMake/CMP0043/CMP0043-OLD-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0043/CMP0043-OLD-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0043/CMP0043-OLD.cmake b/Tests/RunCMake/CMP0043/CMP0043-OLD.cmake new file mode 100644 index 0000000..f379430 --- /dev/null +++ b/Tests/RunCMake/CMP0043/CMP0043-OLD.cmake @@ -0,0 +1,7 @@ + +cmake_policy(SET CMP0043 OLD) + +add_library(foo empty.cpp) +set_property(TARGET foo + PROPERTY COMPILE_DEFINITIONS_DEBUG "DEBUG_MODE" +) diff --git a/Tests/RunCMake/CMP0043/CMP0043-WARN-result.txt b/Tests/RunCMake/CMP0043/CMP0043-WARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0043/CMP0043-WARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0043/CMP0043-WARN-stderr.txt b/Tests/RunCMake/CMP0043/CMP0043-WARN-stderr.txt new file mode 100644 index 0000000..4769a63 --- /dev/null +++ b/Tests/RunCMake/CMP0043/CMP0043-WARN-stderr.txt @@ -0,0 +1,5 @@ +CMake Warning \(dev\) in CMakeLists.txt: + Policy CMP0043 is not set: Ignore COMPILE_DEFINITIONS_<Config> properties. + Run "cmake --help-policy CMP0043" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0043/CMP0043-WARN.cmake b/Tests/RunCMake/CMP0043/CMP0043-WARN.cmake new file mode 100644 index 0000000..161a60d --- /dev/null +++ b/Tests/RunCMake/CMP0043/CMP0043-WARN.cmake @@ -0,0 +1,5 @@ + +add_library(foo empty.cpp) +set_property(TARGET foo + PROPERTY COMPILE_DEFINITIONS_DEBUG "DEBUG_MODE" +) diff --git a/Tests/RunCMake/CMP0043/CMakeLists.txt b/Tests/RunCMake/CMP0043/CMakeLists.txt new file mode 100644 index 0000000..b465c88 --- /dev/null +++ b/Tests/RunCMake/CMP0043/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) + +if(CMAKE_BUILD_TYPE) + # Dummy variable use +endif() diff --git a/Tests/RunCMake/CMP0043/RunCMakeTest.cmake b/Tests/RunCMake/CMP0043/RunCMakeTest.cmake new file mode 100644 index 0000000..7f9572e --- /dev/null +++ b/Tests/RunCMake/CMP0043/RunCMakeTest.cmake @@ -0,0 +1,7 @@ +include(RunCMake) + +list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) + +run_cmake(CMP0043-OLD) +run_cmake(CMP0043-NEW) +run_cmake(CMP0043-WARN) diff --git a/Tests/RunCMake/CMP0043/empty.cpp b/Tests/RunCMake/CMP0043/empty.cpp new file mode 100644 index 0000000..bfbbdde --- /dev/null +++ b/Tests/RunCMake/CMP0043/empty.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/CMP0045/CMP0045-NEW-result.txt b/Tests/RunCMake/CMP0045/CMP0045-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0045/CMP0045-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0045/CMP0045-NEW-stderr.txt b/Tests/RunCMake/CMP0045/CMP0045-NEW-stderr.txt new file mode 100644 index 0000000..805a85e --- /dev/null +++ b/Tests/RunCMake/CMP0045/CMP0045-NEW-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at CMP0045-NEW.cmake:4 \(get_target_property\): + get_target_property\(\) called with non-existent target "tgt". +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0045/CMP0045-NEW.cmake b/Tests/RunCMake/CMP0045/CMP0045-NEW.cmake new file mode 100644 index 0000000..7b2a3cd --- /dev/null +++ b/Tests/RunCMake/CMP0045/CMP0045-NEW.cmake @@ -0,0 +1,4 @@ + +cmake_policy(SET CMP0045 NEW) + +get_target_property(result tgt TYPE) diff --git a/Tests/RunCMake/CMP0045/CMP0045-OLD-result.txt b/Tests/RunCMake/CMP0045/CMP0045-OLD-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0045/CMP0045-OLD-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0045/CMP0045-OLD-stderr.txt b/Tests/RunCMake/CMP0045/CMP0045-OLD-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0045/CMP0045-OLD-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0045/CMP0045-OLD.cmake b/Tests/RunCMake/CMP0045/CMP0045-OLD.cmake new file mode 100644 index 0000000..90201a3 --- /dev/null +++ b/Tests/RunCMake/CMP0045/CMP0045-OLD.cmake @@ -0,0 +1,4 @@ + +cmake_policy(SET CMP0045 OLD) + +get_target_property(result tgt TYPE) diff --git a/Tests/RunCMake/CMP0045/CMP0045-WARN-result.txt b/Tests/RunCMake/CMP0045/CMP0045-WARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0045/CMP0045-WARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0045/CMP0045-WARN-stderr.txt b/Tests/RunCMake/CMP0045/CMP0045-WARN-stderr.txt new file mode 100644 index 0000000..4c53224 --- /dev/null +++ b/Tests/RunCMake/CMP0045/CMP0045-WARN-stderr.txt @@ -0,0 +1,9 @@ +CMake Warning \(dev\) at CMP0045-WARN.cmake:2 \(get_target_property\): + Policy CMP0045 is not set: Error on non-existent target in + get_target_property. Run "cmake --help-policy CMP0045" for policy details. + Use the cmake_policy command to set the policy and suppress this warning. + + get_target_property\(\) called with non-existent target "tgt". +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0045/CMP0045-WARN.cmake b/Tests/RunCMake/CMP0045/CMP0045-WARN.cmake new file mode 100644 index 0000000..86a99a0 --- /dev/null +++ b/Tests/RunCMake/CMP0045/CMP0045-WARN.cmake @@ -0,0 +1,2 @@ + +get_target_property(result tgt TYPE) diff --git a/Tests/RunCMake/CMP0045/CMakeLists.txt b/Tests/RunCMake/CMP0045/CMakeLists.txt new file mode 100644 index 0000000..11ea636 --- /dev/null +++ b/Tests/RunCMake/CMP0045/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/CMP0045/RunCMakeTest.cmake b/Tests/RunCMake/CMP0045/RunCMakeTest.cmake new file mode 100644 index 0000000..7c0e8a2 --- /dev/null +++ b/Tests/RunCMake/CMP0045/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0045-OLD) +run_cmake(CMP0045-NEW) +run_cmake(CMP0045-WARN) diff --git a/Tests/RunCMake/CMP0045/empty.cpp b/Tests/RunCMake/CMP0045/empty.cpp new file mode 100644 index 0000000..bfbbdde --- /dev/null +++ b/Tests/RunCMake/CMP0045/empty.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() +{ + return 0; +} diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 96724ce..77700d7 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -64,6 +64,8 @@ add_RunCMake_test(CMP0041) if(CMAKE_SYSTEM_NAME MATCHES Darwin AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG) add_RunCMake_test(CMP0042) endif() +add_RunCMake_test(CMP0043) +add_RunCMake_test(CMP0045) add_RunCMake_test(CTest) if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles") add_RunCMake_test(CompilerChange) @@ -143,3 +145,5 @@ add_RunCMake_test(File_Generate) add_RunCMake_test(ExportWithoutLanguage) add_RunCMake_test(target_link_libraries) add_RunCMake_test(CheckModules) + +add_RunCMake_test(install) diff --git a/Tests/RunCMake/CMakeLists.txt.orig b/Tests/RunCMake/CMakeLists.txt.orig new file mode 100644 index 0000000..96b0543 --- /dev/null +++ b/Tests/RunCMake/CMakeLists.txt.orig @@ -0,0 +1,142 @@ +# This directory contains tests that run CMake to configure a project +# but do not actually build anything. To add a test: +# +# 1.) Add a subdirectory named for the test. +# +# 2.) Call add_RunCMake_test and pass the test directory name. +# +# 3.) Create a RunCMakeTest.cmake script in the directory containing +# include(RunCMake) +# run_cmake(SubTest1) +# ... +# run_cmake(SubTestN) +# where SubTest1..SubTestN are sub-test names each corresponding to +# an independent CMake run and project configuration. +# +# 3.) Create a CMakeLists.txt file in the directory containing +# cmake_minimum_required(...) +# project(${RunCMake_TEST} NONE) # or languages needed +# include(${RunCMake_TEST}.cmake) +# where "${RunCMake_TEST}" is literal. A value for RunCMake_TEST +# will be passed to CMake by the run_cmake macro when running each +# sub-test. +# +# 4.) Create a <SubTest>.cmake file for each sub-test named above +# containing the actual test code. Optionally create files +# containing expected test results: +# <SubTest>-result.txt = Process result expected if not "0" +# <SubTest>-stdout.txt = Regex matching expected stdout content +# <SubTest>-stderr.txt = Regex matching expected stderr content +# <SubTest>-check.cmake = Custom result check +# Note that trailing newlines will be stripped from actual and expected test +# output before matching against the stdout and stderr expressions. +# The code in <SubTest>-check.cmake may use variables +# RunCMake_TEST_SOURCE_DIR = Top of test source tree +# RunCMake_TEST_BINARY_DIR = Top of test binary tree +# and an failure must store a message in RunCMake_TEST_FAILED. + +macro(add_RunCMake_test test) + add_test(RunCMake.${test} ${CMAKE_CMAKE_COMMAND} + -DCMAKE_MODULE_PATH=${CMAKE_CURRENT_SOURCE_DIR} + -DRunCMake_GENERATOR=${CMAKE_TEST_GENERATOR} + -DRunCMake_GENERATOR_TOOLSET=${CMAKE_TEST_GENERATOR_TOOLSET} + -DRunCMake_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/${test} + -DRunCMake_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/${test} + ${${test}_ARGS} + -P "${CMAKE_CURRENT_SOURCE_DIR}/${test}/RunCMakeTest.cmake" + ) +endmacro() + +if(XCODE_VERSION AND "${XCODE_VERSION}" VERSION_LESS 3) + set(GeneratorToolset_ARGS -DXCODE_BELOW_3=1) +endif() + +add_RunCMake_test(CMP0019) +add_RunCMake_test(CMP0022) +add_RunCMake_test(CMP0026) +add_RunCMake_test(CMP0027) +add_RunCMake_test(CMP0028) +add_RunCMake_test(CMP0037) +add_RunCMake_test(CMP0038) +add_RunCMake_test(CMP0039) +add_RunCMake_test(CMP0040) +add_RunCMake_test(CMP0041) +add_RunCMake_test(CTest) +if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles") + add_RunCMake_test(CompilerChange) +endif() +add_RunCMake_test(CompilerNotFound) +add_RunCMake_test(Configure) +add_RunCMake_test(DisallowedCommands) +add_RunCMake_test(ExternalData) +add_RunCMake_test(FPHSA) +add_RunCMake_test(GeneratorExpression) +add_RunCMake_test(GeneratorToolset) +add_RunCMake_test(TargetPropertyGeneratorExpressions) +add_RunCMake_test(Languages) +add_RunCMake_test(ObjectLibrary) +if(NOT WIN32) + add_RunCMake_test(PositionIndependentCode) + set(SKIP_VISIBILITY 0) + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" AND "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 4.2) + set(SKIP_VISIBILITY 1) + endif() + + if (CMAKE_CXX_COMPILER_ID MATCHES Watcom + OR CMAKE_SYSTEM_NAME MATCHES IRIX64 + OR CMAKE_CXX_COMPILER_ID MATCHES HP + OR CMAKE_CXX_COMPILER_ID MATCHES XL + OR CMAKE_CXX_COMPILER_ID MATCHES SunPro) + set(SKIP_VISIBILITY 1) + endif() + + if (NOT SKIP_VISIBILITY) + add_RunCMake_test(VisibilityPreset) + endif() +endif() +if (QT4_FOUND) + set(CompatibleInterface_ARGS -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}) +endif() +add_RunCMake_test(CompatibleInterface) +add_RunCMake_test(Syntax) + +add_RunCMake_test(add_dependencies) +add_RunCMake_test(build_command) +add_RunCMake_test(export) +add_RunCMake_test(cmake_minimum_required) +add_RunCMake_test(find_package) +add_RunCMake_test(get_filename_component) +add_RunCMake_test(if) +add_RunCMake_test(include) +add_RunCMake_test(include_directories) +add_RunCMake_test(list) +add_RunCMake_test(message) +add_RunCMake_test(string) +add_RunCMake_test(try_compile) +add_RunCMake_test(set) +add_RunCMake_test(variable_watch) +add_RunCMake_test(CMP0004) +add_RunCMake_test(TargetPolicies) +add_RunCMake_test(alias_targets) +add_RunCMake_test(interface_library) +add_RunCMake_test(no_install_prefix) + +find_package(Qt4 QUIET) +find_package(Qt5Core QUIET) +if (QT4_FOUND AND Qt5Core_FOUND AND NOT Qt5Core_VERSION VERSION_LESS 5.1.0) + add_RunCMake_test(IncompatibleQt) +endif() +if (QT4_FOUND) + set(ObsoleteQtMacros_ARGS -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}) + add_RunCMake_test(ObsoleteQtMacros) +endif() + +if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]") + add_RunCMake_test(include_external_msproject) + add_RunCMake_test(SolutionGlobalSections) +endif() + +add_RunCMake_test(File_Generate) +add_RunCMake_test(ExportWithoutLanguage) +add_RunCMake_test(target_link_libraries) +add_RunCMake_test(CheckModules) diff --git a/Tests/RunCMake/GeneratorExpression/CMP0044-WARN-result.txt b/Tests/RunCMake/GeneratorExpression/CMP0044-WARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/CMP0044-WARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/GeneratorExpression/CMP0044-WARN-stderr.txt b/Tests/RunCMake/GeneratorExpression/CMP0044-WARN-stderr.txt new file mode 100644 index 0000000..2079c12 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/CMP0044-WARN-stderr.txt @@ -0,0 +1,7 @@ +CMake Warning \(dev\) at CMP0044-WARN.cmake:13 \(target_compile_definitions\): + Policy CMP0044 is not set: Case sensitive <LANG>_COMPILER_ID generator + expressions. Run "cmake --help-policy CMP0044" for policy details. Use + the cmake_policy command to set the policy and suppress this warning. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/GeneratorExpression/CMP0044-WARN.cmake b/Tests/RunCMake/GeneratorExpression/CMP0044-WARN.cmake new file mode 100644 index 0000000..d5b85c9 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/CMP0044-WARN.cmake @@ -0,0 +1,17 @@ + +project(CMP0044-WARN) + +string(TOLOWER ${CMAKE_C_COMPILER_ID} lc_test) +if (lc_test STREQUAL CMAKE_C_COMPILER_ID) + string(TOUPPER ${CMAKE_C_COMPILER_ID} lc_test) + if (lc_test STREQUAL CMAKE_C_COMPILER_ID) + message(SEND_ERROR "Try harder.") + endif() +endif() + +add_library(cmp0044-check empty.c) +target_compile_definitions(cmp0044-check + PRIVATE + Result=$<C_COMPILER_ID:${lc_test}> + Type_Is_${CMP0044_TYPE} +) diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index 54d5064..f3f99ed 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -9,3 +9,4 @@ run_cmake(BadZero) run_cmake(BadTargetName) run_cmake(BadTargetTypeObject) run_cmake(BadInstallPrefix) +run_cmake(CMP0044-WARN) diff --git a/Tests/RunCMake/install/CMakeLists.txt b/Tests/RunCMake/install/CMakeLists.txt new file mode 100644 index 0000000..4b3de84 --- /dev/null +++ b/Tests/RunCMake/install/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.12) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake new file mode 100644 index 0000000..c8dc379 --- /dev/null +++ b/Tests/RunCMake/install/RunCMakeTest.cmake @@ -0,0 +1,4 @@ +include(RunCMake) +run_cmake(SkipInstallRulesWarning) +run_cmake(SkipInstallRulesNoWarning1) +run_cmake(SkipInstallRulesNoWarning2) diff --git a/Tests/RunCMake/install/SkipInstallRulesNoWarning1-check.cmake b/Tests/RunCMake/install/SkipInstallRulesNoWarning1-check.cmake new file mode 100644 index 0000000..2807698 --- /dev/null +++ b/Tests/RunCMake/install/SkipInstallRulesNoWarning1-check.cmake @@ -0,0 +1,9 @@ +if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/CMakeCache.txt") + message(FATAL_ERROR "missing test prerequisite CMakeCache.txt") +endif() + +set(CMAKE_INSTALL_CMAKE "${RunCMake_TEST_BINARY_DIR}/cmake_install.cmake") + +if(EXISTS ${CMAKE_INSTALL_CMAKE}) + message(FATAL_ERROR "${CMAKE_INSTALL_CMAKE} should not exist") +endif() diff --git a/Tests/RunCMake/install/SkipInstallRulesNoWarning1-stderr.txt b/Tests/RunCMake/install/SkipInstallRulesNoWarning1-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/install/SkipInstallRulesNoWarning1-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/install/SkipInstallRulesNoWarning1.cmake b/Tests/RunCMake/install/SkipInstallRulesNoWarning1.cmake new file mode 100644 index 0000000..22c7f8c --- /dev/null +++ b/Tests/RunCMake/install/SkipInstallRulesNoWarning1.cmake @@ -0,0 +1 @@ +set(CMAKE_SKIP_INSTALL_RULES ON) diff --git a/Tests/RunCMake/install/SkipInstallRulesNoWarning2-check.cmake b/Tests/RunCMake/install/SkipInstallRulesNoWarning2-check.cmake new file mode 100644 index 0000000..4372b77 --- /dev/null +++ b/Tests/RunCMake/install/SkipInstallRulesNoWarning2-check.cmake @@ -0,0 +1,9 @@ +if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/CMakeCache.txt") + message(FATAL_ERROR "missing test prerequisite CMakeCache.txt") +endif() + +set(CMAKE_INSTALL_CMAKE "${RunCMake_TEST_BINARY_DIR}/cmake_install.cmake") + +if(NOT EXISTS ${CMAKE_INSTALL_CMAKE}) + message(FATAL_ERROR "${CMAKE_INSTALL_CMAKE} should exist") +endif() diff --git a/Tests/RunCMake/install/SkipInstallRulesNoWarning2-stderr.txt b/Tests/RunCMake/install/SkipInstallRulesNoWarning2-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/install/SkipInstallRulesNoWarning2-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/install/SkipInstallRulesNoWarning2.cmake b/Tests/RunCMake/install/SkipInstallRulesNoWarning2.cmake new file mode 100644 index 0000000..2f5f03a --- /dev/null +++ b/Tests/RunCMake/install/SkipInstallRulesNoWarning2.cmake @@ -0,0 +1 @@ +install(FILES CMakeLists.txt DESTINATION src) diff --git a/Tests/RunCMake/install/SkipInstallRulesWarning-check.cmake b/Tests/RunCMake/install/SkipInstallRulesWarning-check.cmake new file mode 100644 index 0000000..2807698 --- /dev/null +++ b/Tests/RunCMake/install/SkipInstallRulesWarning-check.cmake @@ -0,0 +1,9 @@ +if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/CMakeCache.txt") + message(FATAL_ERROR "missing test prerequisite CMakeCache.txt") +endif() + +set(CMAKE_INSTALL_CMAKE "${RunCMake_TEST_BINARY_DIR}/cmake_install.cmake") + +if(EXISTS ${CMAKE_INSTALL_CMAKE}) + message(FATAL_ERROR "${CMAKE_INSTALL_CMAKE} should not exist") +endif() diff --git a/Tests/RunCMake/install/SkipInstallRulesWarning-stderr.txt b/Tests/RunCMake/install/SkipInstallRulesWarning-stderr.txt new file mode 100644 index 0000000..9130526 --- /dev/null +++ b/Tests/RunCMake/install/SkipInstallRulesWarning-stderr.txt @@ -0,0 +1,3 @@ +CMake Warning in CMakeLists.txt: + CMAKE_SKIP_INSTALL_RULES was enabled even though installation rules have + been specified diff --git a/Tests/RunCMake/install/SkipInstallRulesWarning.cmake b/Tests/RunCMake/install/SkipInstallRulesWarning.cmake new file mode 100644 index 0000000..b621d9b --- /dev/null +++ b/Tests/RunCMake/install/SkipInstallRulesWarning.cmake @@ -0,0 +1,2 @@ +set(CMAKE_SKIP_INSTALL_RULES ON) +install(FILES CMakeLists.txt DESTINATION src) |