diff options
101 files changed, 1416 insertions, 713 deletions
diff --git a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst index 6b17f6e..11aed0c 100644 --- a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst +++ b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst @@ -5,7 +5,9 @@ Enables tracing output for target properties. This variable can be populated with a list of properties to generate debug output for when evaluating target properties. Currently it can -only be used when evaluating the INCLUDE_DIRECTORIES, -COMPILE_DEFINITIONS, COMPILE_OPTIONS and AUTOUIC_OPTIONS target properties. -In that case, it outputs a backtrace for each entry in the target property. +only be used when evaluating the :prop_tgt:`INCLUDE_DIRECTORIES`, +:prop_tgt:`COMPILE_DEFINITIONS`, :prop_tgt:`COMPILE_OPTIONS`, :prop_tgt:`AUTOUIC_OPTIONS`, +:prop_tgt:`POSITION_INDEPENDENT_CODE` target properties and any other property +listed in :prop_tgt:`COMPATIBLE_INTERFACE_STRING` and other ``COMPATIBLE_INTERFACE_`` +properties. It outputs an origin for each entry in the target property. Default is unset. diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 518b8c6..2bcf3d1 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -232,7 +232,7 @@ Id flags: ${testflags} # ... # /path/to/cc ...CompilerId${lang}/... # to extract the compiler front-end for the language. - if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerId${lang}/\\./CompilerId${lang}[ \t\n\\\"]") + if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerId${lang}/(\\./)?CompilerId${lang}[ \t\n\\\"]") set(_comp "${CMAKE_MATCH_2}") if(EXISTS "${_comp}") set(CMAKE_${lang}_COMPILER_ID_TOOL "${_comp}" PARENT_SCOPE) diff --git a/Modules/CPackWIX.cmake b/Modules/CPackWIX.cmake index 237c5bc..d9e0ba7 100644 --- a/Modules/CPackWIX.cmake +++ b/Modules/CPackWIX.cmake @@ -116,6 +116,57 @@ # If this variable is not set, the default MSI template included with CMake # will be used. # +# .. variable:: CPACK_WIX_PATCH_FILE +# +# Optional XML file with fragments to be inserted into generated WiX sources +# +# This optional variable can be used to specify an XML file that the +# WiX generator will use to inject fragments into its generated +# source files. +# +# Patch files understood by the CPack WiX generator +# roughly follow this RELAX NG compact schema: +# +# .. code-block:: none +# +# start = CPackWiXPatch +# +# CPackWiXPatch = element CPackWiXPatch { CPackWiXFragment* } +# +# CPackWiXFragment = element CPackWiXFragment +# { +# attribute Id { string }, +# fragmentContent* +# } +# +# fragmentContent = element * - CPackWiXFragment +# { +# (attribute * { text } | text | fragmentContent)* +# } +# +# Currently fragments can be injected into most +# Component, File and Directory elements. +# +# The following example illustrates how this works. +# +# Given that the WiX generator creates the following XML element: +# +# .. code-block:: xml +# +# <Component Id="CM_CP_applications.bin.my_libapp.exe" Guid="*"/> +# +# The following XML patch file may be used to inject an Environment element +# into it: +# +# .. code-block:: xml +# +# <CPackWiXPatch> +# <CPackWiXFragment Id="CM_CP_applications.bin.my_libapp.exe"> +# <Environment Id="MyEnvironment" Action="set" +# Name="MyVariableName" Value="MyVariableValue"/> +# </CPackWiXFragment> +# </CPackWiXPatch> +# # .. variable:: CPACK_WIX_EXTRA_SOURCES # # Extra WiX source files diff --git a/Modules/FindFreetype.cmake b/Modules/FindFreetype.cmake index 179dc00..6f03c86 100644 --- a/Modules/FindFreetype.cmake +++ b/Modules/FindFreetype.cmake @@ -65,7 +65,10 @@ find_path(FREETYPE_INCLUDE_DIR_ft2build ft2build.h PATH_SUFFIXES include/freetype2 include ) -find_path(FREETYPE_INCLUDE_DIR_freetype2 freetype/config/ftheader.h +find_path(FREETYPE_INCLUDE_DIR_freetype2 + NAMES + freetype/config/ftheader.h + config/ftheader.h HINTS ENV FREETYPE_DIR PATHS @@ -97,11 +100,18 @@ find_library(FREETYPE_LIBRARY # set the user variables if(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2) set(FREETYPE_INCLUDE_DIRS "${FREETYPE_INCLUDE_DIR_ft2build};${FREETYPE_INCLUDE_DIR_freetype2}") + list(REMOVE_DUPLICATES FREETYPE_INCLUDE_DIRS) endif() set(FREETYPE_LIBRARIES "${FREETYPE_LIBRARY}") -if(FREETYPE_INCLUDE_DIR_freetype2 AND EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h") - file(STRINGS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h" freetype_version_str +if(EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h") + set(FREETYPE_H "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h") +elseif(EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype.h") + set(FREETYPE_H "${FREETYPE_INCLUDE_DIR_freetype2}/freetype.h") +endif() + +if(FREETYPE_INCLUDE_DIR_freetype2 AND FREETYPE_H) + file(STRINGS "${FREETYPE_H}" freetype_version_str REGEX "^#[\t ]*define[\t ]+FREETYPE_(MAJOR|MINOR|PATCH)[\t ]+[0-9]+$") unset(FREETYPE_VERSION_STRING) diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 24747f7..28b8454 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -1203,6 +1203,10 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) "${QT_MKSPECS_DIR}/default" ${QT_INCLUDE_DIR} ) + set_property(TARGET Qt4::QtCore APPEND PROPERTY + INTERFACE_COMPILE_DEFINITIONS + $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG> + ) set_property(TARGET Qt4::QtCore PROPERTY INTERFACE_QT_MAJOR_VERSION 4 ) diff --git a/Modules/FindSubversion.cmake b/Modules/FindSubversion.cmake index 2338721..0d13318 100644 --- a/Modules/FindSubversion.cmake +++ b/Modules/FindSubversion.cmake @@ -73,6 +73,8 @@ # License text for the above reference.) find_program(Subversion_SVN_EXECUTABLE svn + PATHS + [HKEY_LOCAL_MACHINE\\Software\\TortoiseSVN;Directory]/bin DOC "subversion command line client") mark_as_advanced(Subversion_SVN_EXECUTABLE) diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake index b5f005f..fd9819f 100644 --- a/Modules/Qt4Macros.cmake +++ b/Modules/Qt4Macros.cmake @@ -120,6 +120,7 @@ macro (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target) string (REPLACE ";" "\n" _moc_parameters "${_moc_parameters}") if(moc_target) + set (_moc_parameters_file ${_moc_parameters_file}$<$<BOOL:$<CONFIGURATION>>:_$<CONFIGURATION>>) set(targetincludes "$<TARGET_PROPERTY:${moc_target},INCLUDE_DIRECTORIES>") set(targetdefines "$<TARGET_PROPERTY:${moc_target},COMPILE_DEFINITIONS>") diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 17fb52d..3c944fb 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -517,6 +517,7 @@ if(WIN32) CPack/WiX/cmCPackWIXGenerator.cxx CPack/WiX/cmWIXSourceWriter.cxx CPack/WiX/cmWIXRichTextFormatWriter.cxx + CPack/WiX/cmWIXPatchParser.cxx ) endif() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index a2c6fcc..711b99a 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 20131218) +set(CMake_VERSION_TWEAK 20131219) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 1b9b20a..6f1daaa 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -218,6 +218,12 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration() CollectExtensions("CPACK_WIX_EXTENSIONS", lightExtensions); CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", lightExtensions); + const char* patchFilePath = GetOption("CPACK_WIX_PATCH_FILE"); + if(patchFilePath) + { + LoadPatchFragments(patchFilePath); + } + return true; } @@ -529,6 +535,28 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() wixSources.push_back(mainSourceFilePath); + std::string fragmentList; + for(cmWIXPatchParser::fragment_map_t::const_iterator + i = fragments.begin(); i != fragments.end(); ++i) + { + if(!fragmentList.empty()) + { + fragmentList += ", "; + } + + fragmentList += "'"; + fragmentList += i->first; + fragmentList += "'"; + } + + if(fragmentList.size()) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Some XML patch fragments did not have matching IDs: " << + fragmentList << std::endl); + return false; + } + return true; } @@ -872,6 +900,7 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( packageExecutables, shortcutMap); + ApplyPatchFragment(subDirectoryId, directoryDefinitions); directoryDefinitions.EndElement("Directory"); } else @@ -891,7 +920,10 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( fileDefinitions.AddAttribute("Source", fullPath); fileDefinitions.AddAttribute("KeyPath", "yes"); + ApplyPatchFragment(fileId, fileDefinitions); fileDefinitions.EndElement("File"); + + ApplyPatchFragment(componentId, fileDefinitions); fileDefinitions.EndElement("Component"); fileDefinitions.EndElement("DirectoryRef"); @@ -1146,3 +1178,45 @@ void cmCPackWIXGenerator::CreateStartMenuFolder( directoryDefinitions.EndElement("Directory"); } + +void cmCPackWIXGenerator::LoadPatchFragments(const std::string& patchFilePath) +{ + cmWIXPatchParser parser(fragments, Logger); + parser.ParseFile(patchFilePath.c_str()); +} + +void cmCPackWIXGenerator::ApplyPatchFragment( + const std::string& id, cmWIXSourceWriter& writer) +{ + cmWIXPatchParser::fragment_map_t::iterator i = fragments.find(id); + if(i == fragments.end()) return; + + const cmWIXPatchElement& fragment = i->second; + for(cmWIXPatchElement::child_list_t::const_iterator + j = fragment.children.begin(); j != fragment.children.end(); ++j) + { + ApplyPatchElement(**j, writer); + } + + fragments.erase(i); +} + +void cmCPackWIXGenerator::ApplyPatchElement( + const cmWIXPatchElement& element, cmWIXSourceWriter& writer) +{ + writer.BeginElement(element.name); + + for(cmWIXPatchElement::attributes_t::const_iterator + i = element.attributes.begin(); i != element.attributes.end(); ++i) + { + writer.AddAttribute(i->first, i->second); + } + + for(cmWIXPatchElement::child_list_t::const_iterator + i = element.children.begin(); i != element.children.end(); ++i) + { + ApplyPatchElement(**i, writer); + } + + writer.EndElement(element.name); +} diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h index 84f68b6..a0a057c 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.h +++ b/Source/CPack/WiX/cmCPackWIXGenerator.h @@ -13,6 +13,8 @@ #ifndef cmCPackWIXGenerator_h #define cmCPackWIXGenerator_h +#include "cmWIXPatchParser.h" + #include <CPack/cmCPackGenerator.h> #include <string> @@ -160,12 +162,21 @@ private: void CreateStartMenuFolder(cmWIXSourceWriter& directoryDefinitions); + void LoadPatchFragments(const std::string& patchFilePath); + + void ApplyPatchFragment(const std::string& id, cmWIXSourceWriter& writer); + + void ApplyPatchElement(const cmWIXPatchElement& element, + cmWIXSourceWriter& writer); + std::vector<std::string> wixSources; id_map_t pathToIdMap; ambiguity_map_t idAmbiguityCounter; extension_set_t candleExtensions; extension_set_t lightExtensions; + + cmWIXPatchParser::fragment_map_t fragments; }; #endif diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx new file mode 100644 index 0000000..0a3b3bc --- /dev/null +++ b/Source/CPack/WiX/cmWIXPatchParser.cxx @@ -0,0 +1,145 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2013 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#include "cmWIXPatchParser.h" + +#include <CPack/cmCPackGenerator.h> + +#include <cm_expat.h> + +cmWIXPatchElement::~cmWIXPatchElement() +{ + for(child_list_t::iterator i = children.begin(); i != children.end(); ++i) + { + delete *i; + } +} + +cmWIXPatchParser::cmWIXPatchParser( + fragment_map_t& fragments, cmCPackLog* logger): + Logger(logger), + state(BEGIN_DOCUMENT), + valid(true), + fragments(fragments) +{ + +} + +void cmWIXPatchParser::StartElement(const char *name, const char **atts) +{ + std::string name_str = name; + if(state == BEGIN_DOCUMENT) + { + if(name_str == "CPackWiXPatch") + { + state = BEGIN_FRAGMENTS; + } + else + { + ReportValidationError("Expected root element 'CPackWiXPatch'"); + } + } + else if(state == BEGIN_FRAGMENTS) + { + if(name_str == "CPackWiXFragment") + { + state = INSIDE_FRAGMENT; + StartFragment(atts); + } + else + { + ReportValidationError("Expected 'CPackWixFragment' element"); + } + } + else if(state == INSIDE_FRAGMENT) + { + cmWIXPatchElement &parent = *elementStack.back(); + + parent.children.resize(parent.children.size() + 1); + cmWIXPatchElement*& currentElement = parent.children.back(); + currentElement = new cmWIXPatchElement; + currentElement->name = name; + + for(size_t i = 0; atts[i]; i += 2) + { + std::string key = atts[i]; + std::string value = atts[i+1]; + + currentElement->attributes[key] = value; + } + + elementStack.push_back(currentElement); + } +} + +void cmWIXPatchParser::StartFragment(const char **attributes) +{ + for(size_t i = 0; attributes[i]; i += 2) + { + std::string key = attributes[i]; + std::string value = attributes[i+1]; + + if(key == "Id") + { + if(fragments.find(value) != fragments.end()) + { + std::stringstream tmp; + tmp << "Invalid reuse of 'CPackWixFragment' 'Id': " << value; + ReportValidationError(tmp.str()); + } + + elementStack.push_back(&fragments[value]); + } + else + { + ReportValidationError( + "The only allowed 'CPackWixFragment' attribute is 'Id'"); + } + } +} + +void cmWIXPatchParser::EndElement(const char *name) +{ + std::string name_str = name; + if(state == INSIDE_FRAGMENT) + { + if(name_str == "CPackWiXFragment") + { + state = BEGIN_FRAGMENTS; + elementStack.clear(); + } + else + { + elementStack.pop_back(); + } + } +} + +void cmWIXPatchParser::ReportError(int line, int column, const char* msg) +{ + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error while processing XML patch file at " << line << ":" << column << + ": "<< msg << std::endl); + valid = false; +} + +void cmWIXPatchParser::ReportValidationError(const std::string& message) +{ + ReportError(XML_GetCurrentLineNumber(Parser), + XML_GetCurrentColumnNumber(Parser), + message.c_str()); +} + +bool cmWIXPatchParser::IsValid() const +{ + return valid; +} diff --git a/Source/CPack/WiX/cmWIXPatchParser.h b/Source/CPack/WiX/cmWIXPatchParser.h new file mode 100644 index 0000000..4fa5e6f --- /dev/null +++ b/Source/CPack/WiX/cmWIXPatchParser.h @@ -0,0 +1,75 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2013 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmCPackWIXPatchParser_h +#define cmCPackWIXPatchParser_h + +#include <cmXMLParser.h> + +#include <CPack/cmCPackLog.h> + +#include <map> +#include <list> + +struct cmWIXPatchElement +{ + ~cmWIXPatchElement(); + + typedef std::list<cmWIXPatchElement*> child_list_t; + typedef std::map<std::string, std::string> attributes_t; + + std::string name; + child_list_t children; + attributes_t attributes; +}; + +/** \class cmWIXPatchParser + * \brief Helper class that parses XML patch files (CPACK_WIX_PATCH_FILE) + */ +class cmWIXPatchParser : public cmXMLParser +{ +public: + typedef std::map<std::string, cmWIXPatchElement> fragment_map_t; + + cmWIXPatchParser(fragment_map_t& fragments, cmCPackLog* logger); + +private: + virtual void StartElement(const char *name, const char **atts); + + void StartFragment(const char **attributes); + + virtual void EndElement(const char *name); + virtual void ReportError(int line, int column, const char* msg); + + void ReportValidationError(const std::string& message); + + bool IsValid() const; + + cmCPackLog* Logger; + + enum ParserState + { + BEGIN_DOCUMENT, + BEGIN_FRAGMENTS, + INSIDE_FRAGMENT + }; + + ParserState state; + + bool valid; + + fragment_map_t& fragments; + + std::list<cmWIXPatchElement*> elementStack; +}; + +#endif diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 31cc393..1be5980 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -619,19 +619,19 @@ cmComputeLinkDepends::AddLinkEntries(int depender_index, } //---------------------------------------------------------------------------- -cmTarget* cmComputeLinkDepends::FindTargetToLink(int depender_index, +cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index, const char* name) { // Look for a target in the scope of the depender. cmMakefile* mf = this->Makefile; if(depender_index >= 0) { - if(cmTarget* depender = this->EntryList[depender_index].Target) + if(cmTarget const* depender = this->EntryList[depender_index].Target) { mf = depender->GetMakefile(); } } - cmTarget* tgt = mf->FindTargetToUse(name); + cmTarget const* tgt = mf->FindTargetToUse(name); // Skip targets that will not really be linked. This is probably a // name conflict between an external library and an executable @@ -950,7 +950,7 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) int count = 2; for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { - if(cmTarget* target = this->EntryList[*ni].Target) + if(cmTarget const* target = this->EntryList[*ni].Target) { if(cmTarget::LinkInterface const* iface = target->GetLinkInterface(this->Config, this->HeadTarget)) @@ -997,7 +997,8 @@ void cmComputeLinkDepends::CheckWrongConfigItem(int depender_index, // For CMake 2.4 bug-compatibility we need to consider the output // directories of targets linked in another configuration as link // directories. - if(cmTarget* tgt = this->FindTargetToLink(depender_index, item.c_str())) + if(cmTarget const* tgt + = this->FindTargetToLink(depender_index, item.c_str())) { if(!tgt->IsImported()) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index b86c9b2..cf227fb 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -40,7 +40,7 @@ public: struct LinkEntry { std::string Item; - cmTarget* Target; + cmTarget const* Target; bool IsSharedDep; bool IsFlag; LinkEntry(): Item(), Target(0), IsSharedDep(false), IsFlag(false) {} @@ -53,7 +53,7 @@ public: EntryVector const& Compute(); void SetOldLinkDirMode(bool b); - std::set<cmTarget*> const& GetOldWrongConfigItems() const + std::set<cmTarget const*> const& GetOldWrongConfigItems() const { return this->OldWrongConfigItems; } private: @@ -83,7 +83,7 @@ private: void AddDirectLinkEntries(); void AddLinkEntries(int depender_index, std::vector<std::string> const& libs); - cmTarget* FindTargetToLink(int depender_index, const char* name); + cmTarget const* FindTargetToLink(int depender_index, const char* name); // One entry for each unique item. std::vector<LinkEntry> EntryList; @@ -164,7 +164,7 @@ private: // Compatibility help. bool OldLinkDirMode; void CheckWrongConfigItem(int depender_index, std::string const& item); - std::set<cmTarget*> OldWrongConfigItems; + std::set<cmTarget const*> OldWrongConfigItems; }; #endif diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 0ef3d2e..f3bdddd 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -477,7 +477,7 @@ std::vector<std::string> const& cmComputeLinkInformation::GetFrameworkPaths() } //---------------------------------------------------------------------------- -std::set<cmTarget*> const& +std::set<cmTarget const*> const& cmComputeLinkInformation::GetSharedLibrariesLinked() { return this->SharedLibrariesLinked; @@ -542,11 +542,11 @@ bool cmComputeLinkInformation::Compute() // For CMake 2.4 bug-compatibility we need to consider the output // directories of targets linked in another configuration as link // directories. - std::set<cmTarget*> const& wrongItems = cld.GetOldWrongConfigItems(); - for(std::set<cmTarget*>::const_iterator i = wrongItems.begin(); + std::set<cmTarget const*> const& wrongItems = cld.GetOldWrongConfigItems(); + for(std::set<cmTarget const*>::const_iterator i = wrongItems.begin(); i != wrongItems.end(); ++i) { - cmTarget* tgt = *i; + cmTarget const* tgt = *i; bool implib = (this->UseImportLibrary && (tgt->GetType() == cmTarget::SHARED_LIBRARY)); @@ -620,7 +620,8 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang) } //---------------------------------------------------------------------------- -void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt) +void cmComputeLinkInformation::AddItem(std::string const& item, + cmTarget const* tgt) { // Compute the proper name to use to link this library. const char* config = this->Config; @@ -700,7 +701,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt) //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, - cmTarget* tgt) + cmTarget const* tgt) { // If dropping shared library dependencies, ignore them. if(this->SharedDependencyMode == SharedDepModeNone) @@ -1062,7 +1063,7 @@ void cmComputeLinkInformation::SetCurrentLinkType(LinkType lt) //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddTargetItem(std::string const& item, - cmTarget* target) + cmTarget const* target) { // This is called to handle a link item that is a full path to a target. // If the target is not a static library make sure the link type is @@ -1744,7 +1745,7 @@ cmComputeLinkInformation::GetRuntimeSearchPath() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, - cmTarget* target) + cmTarget const* target) { // Ignore targets on Apple where install_name is not @rpath. // The dependenty library can be found with other means such as diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 1da5495..356e6ed 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -39,11 +39,11 @@ public: Item(): Value(), IsPath(true), Target(0) {} Item(Item const& item): Value(item.Value), IsPath(item.IsPath), Target(item.Target) {} - Item(std::string const& v, bool p, cmTarget* target = 0): + Item(std::string const& v, bool p, cmTarget const* target = 0): Value(v), IsPath(p), Target(target) {} std::string Value; bool IsPath; - cmTarget* Target; + cmTarget const* Target; }; typedef std::vector<Item> ItemVector; ItemVector const& GetItems(); @@ -57,13 +57,13 @@ public: void GetRPath(std::vector<std::string>& runtimeDirs, bool for_install); std::string GetRPathString(bool for_install); std::string GetChrpathString(); - std::set<cmTarget*> const& GetSharedLibrariesLinked(); + std::set<cmTarget const*> const& GetSharedLibrariesLinked(); std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; } std::string GetRPathLinkString(); private: - void AddItem(std::string const& item, cmTarget* tgt); - void AddSharedDepItem(std::string const& item, cmTarget* tgt); + void AddItem(std::string const& item, cmTarget const* tgt); + void AddSharedDepItem(std::string const& item, cmTarget const* tgt); // Output information. ItemVector Items; @@ -71,7 +71,7 @@ private: std::vector<std::string> Depends; std::vector<std::string> FrameworkPaths; std::vector<std::string> RuntimeSearchPath; - std::set<cmTarget*> SharedLibrariesLinked; + std::set<cmTarget const*> SharedLibrariesLinked; // Context information. cmTarget const* Target; @@ -139,7 +139,7 @@ private: std::string NoCaseExpression(const char* str); // Handling of link items. - void AddTargetItem(std::string const& item, cmTarget* target); + void AddTargetItem(std::string const& item, cmTarget const* target); void AddFullItem(std::string const& item); bool CheckImplicitDirItem(std::string const& item); void AddUserItem(std::string const& item, bool pathNotKnown); @@ -179,7 +179,8 @@ private: // Runtime path computation. cmOrderDirectories* OrderRuntimeSearchPath; - void AddLibraryRuntimeInfo(std::string const& fullPath, cmTarget* target); + void AddLibraryRuntimeInfo(std::string const& fullPath, + cmTarget const* target); void AddLibraryRuntimeInfo(std::string const& fullPath); // Dependent library path computation. diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index cb9e37e..73a8e27 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -143,12 +143,13 @@ bool cmComputeTargetDepends::Compute() //---------------------------------------------------------------------------- void -cmComputeTargetDepends::GetTargetDirectDepends(cmTarget* t, +cmComputeTargetDepends::GetTargetDirectDepends(cmTarget const* t, cmTargetDependSet& deps) { // Lookup the index for this target. All targets should be known by // this point. - std::map<cmTarget*, int>::const_iterator tii = this->TargetIndex.find(t); + std::map<cmTarget const*, int>::const_iterator tii + = this->TargetIndex.find(t); assert(tii != this->TargetIndex.end()); int i = tii->second; @@ -156,7 +157,7 @@ cmComputeTargetDepends::GetTargetDirectDepends(cmTarget* t, EdgeList const& nl = this->FinalGraph[i]; for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { - cmTarget* dep = this->Targets[*ni]; + cmTarget const* dep = this->Targets[*ni]; cmTargetDependSet::iterator di = deps.insert(dep).first; di->SetType(ni->IsStrong()); } @@ -170,10 +171,11 @@ void cmComputeTargetDepends::CollectTargets() this->GlobalGenerator->GetLocalGenerators(); for(unsigned int i = 0; i < lgens.size(); ++i) { - cmTargets& targets = lgens[i]->GetMakefile()->GetTargets(); - for(cmTargets::iterator ti = targets.begin(); ti != targets.end(); ++ti) + const cmTargets& targets = lgens[i]->GetMakefile()->GetTargets(); + for(cmTargets::const_iterator ti = targets.begin(); + ti != targets.end(); ++ti) { - cmTarget* target = &ti->second; + cmTarget const* target = &ti->second; int index = static_cast<int>(this->Targets.size()); this->TargetIndex[target] = index; this->Targets.push_back(target); @@ -198,7 +200,11 @@ void cmComputeTargetDepends::CollectDepends() void cmComputeTargetDepends::CollectTargetDepends(int depender_index) { // Get the depender. - cmTarget* depender = this->Targets[depender_index]; + cmTarget const* depender = this->Targets[depender_index]; + if (depender->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return; + } // Loop over all targets linked directly in all configs. // We need to make targets depend on the union of all config-specific @@ -208,15 +214,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) std::set<cmStdString> emitted; { std::vector<std::string> tlibs; - if (depender->GetType() == cmTarget::INTERFACE_LIBRARY) - { - // For INTERFACE_LIBRARY depend on the interface instead. - depender->GetInterfaceLinkLibraries(0, tlibs, depender); - } - else - { - depender->GetDirectLinkLibraries(0, tlibs, depender); - } + depender->GetDirectLinkLibraries(0, tlibs, depender); // A target should not depend on itself. emitted.insert(depender->GetName()); for(std::vector<std::string>::const_iterator lib = tlibs.begin(); @@ -237,15 +235,8 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) it != configs.end(); ++it) { std::vector<std::string> tlibs; - if (depender->GetType() == cmTarget::INTERFACE_LIBRARY) - { - // For INTERFACE_LIBRARY depend on the interface instead. - depender->GetInterfaceLinkLibraries(it->c_str(), tlibs, depender); - } - else - { - depender->GetDirectLinkLibraries(it->c_str(), tlibs, depender); - } + depender->GetDirectLinkLibraries(it->c_str(), tlibs, depender); + // A target should not depend on itself. emitted.insert(depender->GetName()); for(std::vector<std::string>::const_iterator lib = tlibs.begin(); @@ -282,11 +273,11 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) //---------------------------------------------------------------------------- void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, - cmTarget* dependee, + cmTarget const* dependee, const char *config, std::set<cmStdString> &emitted) { - cmTarget* depender = this->Targets[depender_index]; + cmTarget const* depender = this->Targets[depender_index]; if(cmTarget::LinkInterface const* iface = dependee->GetLinkInterface(config, depender)) { @@ -311,8 +302,8 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, bool linking, std::set<cmStdString> &emitted) { - cmTarget* depender = this->Targets[depender_index]; - cmTarget* dependee = + cmTarget const* depender = this->Targets[depender_index]; + cmTarget const* dependee = depender->GetMakefile()->FindTargetToUse(dependee_name); // Skip targets that will not really be linked. This is probably a // name conflict between an external library and an executable @@ -346,10 +337,10 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, bool linking) { // Get the depender. - cmTarget* depender = this->Targets[depender_index]; + cmTarget const* depender = this->Targets[depender_index]; // Check the target's makefile first. - cmTarget* dependee = + cmTarget const* dependee = depender->GetMakefile()->FindTargetToUse(dependee_name); // Skip targets that will not really be linked. This is probably a @@ -370,7 +361,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, //---------------------------------------------------------------------------- void cmComputeTargetDepends::AddTargetDepend(int depender_index, - cmTarget* dependee, + cmTarget const* dependee, bool linking) { if(dependee->IsImported()) @@ -380,7 +371,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, for(std::set<cmStdString>::const_iterator i = utils.begin(); i != utils.end(); ++i) { - if(cmTarget* transitive_dependee = + if(cmTarget const* transitive_dependee = dependee->GetMakefile()->FindTargetToUse(i->c_str())) { this->AddTargetDepend(depender_index, transitive_dependee, false); @@ -391,7 +382,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, { // Lookup the index for this target. All targets should be known by // this point. - std::map<cmTarget*, int>::const_iterator tii = + std::map<cmTarget const*, int>::const_iterator tii = this->TargetIndex.find(dependee); assert(tii != this->TargetIndex.end()); int dependee_index = tii->second; @@ -411,13 +402,13 @@ cmComputeTargetDepends::DisplayGraph(Graph const& graph, const char* name) for(int depender_index = 0; depender_index < n; ++depender_index) { EdgeList const& nl = graph[depender_index]; - cmTarget* depender = this->Targets[depender_index]; + cmTarget const* depender = this->Targets[depender_index]; fprintf(stderr, "target %d is [%s]\n", depender_index, depender->GetName()); for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { int dependee_index = *ni; - cmTarget* dependee = this->Targets[dependee_index]; + cmTarget const* dependee = this->Targets[dependee_index]; fprintf(stderr, " depends on target %d [%s] (%s)\n", dependee_index, dependee->GetName(), ni->IsStrong()? "strong" : "weak"); } @@ -504,7 +495,7 @@ cmComputeTargetDepends { // Get the depender. int i = *ci; - cmTarget* depender = this->Targets[i]; + cmTarget const* depender = this->Targets[i]; // Describe the depender. e << " \"" << depender->GetName() << "\" of type " @@ -517,7 +508,7 @@ cmComputeTargetDepends int j = *ni; if(cmap[j] == c) { - cmTarget* dependee = this->Targets[j]; + cmTarget const* dependee = this->Targets[j]; e << " depends on \"" << dependee->GetName() << "\"" << " (" << (ni->IsStrong()? "strong" : "weak") << ")\n"; } diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h index d6131cf..6cd6da0 100644 --- a/Source/cmComputeTargetDepends.h +++ b/Source/cmComputeTargetDepends.h @@ -38,19 +38,21 @@ public: bool Compute(); - std::vector<cmTarget*> const& GetTargets() const { return this->Targets; } - void GetTargetDirectDepends(cmTarget* t, cmTargetDependSet& deps); + std::vector<cmTarget const*> const& + GetTargets() const { return this->Targets; } + void GetTargetDirectDepends(cmTarget const* t, cmTargetDependSet& deps); private: void CollectTargets(); void CollectDepends(); void CollectTargetDepends(int depender_index); void AddTargetDepend(int depender_index, const char* dependee_name, bool linking); - void AddTargetDepend(int depender_index, cmTarget* dependee, bool linking); + void AddTargetDepend(int depender_index, cmTarget const* dependee, + bool linking); bool ComputeFinalDepends(cmComputeComponentGraph const& ccg); void AddInterfaceDepends(int depender_index, const char* dependee_name, bool linking, std::set<cmStdString> &emitted); - void AddInterfaceDepends(int depender_index, cmTarget* dependee, + void AddInterfaceDepends(int depender_index, cmTarget const* dependee, const char *config, std::set<cmStdString> &emitted); cmGlobalGenerator* GlobalGenerator; @@ -58,8 +60,8 @@ private: bool NoCycles; // Collect all targets. - std::vector<cmTarget*> Targets; - std::map<cmTarget*, int> TargetIndex; + std::vector<cmTarget const*> Targets; + std::map<cmTarget const*, int> TargetIndex; // Represent the target dependency graph. The entry at each // top-level index corresponds to a depender whose dependencies are diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index f8b4e28..2a87e4f 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -402,7 +402,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, //---------------------------------------------------------------------------- -void getPropertyContents(cmTarget *tgt, const char *prop, +void getPropertyContents(cmTarget const* tgt, const char *prop, std::set<std::string> &ifaceProperties) { const char *p = tgt->GetProperty(prop); diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index f020ddb..177ef8d 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -52,6 +52,8 @@ void cmExtraKateGenerator::Generate() this->ProjectName = this->GenerateProjectName(mf->GetProjectName(), mf->GetSafeDefinition("CMAKE_BUILD_TYPE"), this->GetPathBasename(mf->GetHomeOutputDirectory())); + this->UseNinja = (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0); + this->CreateKateProjectFile(mf); this->CreateDummyKateProjectFile(mf); } @@ -95,11 +97,12 @@ cmExtraKateGenerator::WriteTargets(const cmMakefile* mf, const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); const std::string makeArgs = mf->GetSafeDefinition( "CMAKE_KATE_MAKE_ARGUMENTS"); + const char* homeOutputDir = mf->GetHomeOutputDirectory(); this->AppendTarget(fout, "all", make, makeArgs, - mf->GetHomeOutputDirectory()); + homeOutputDir, homeOutputDir); this->AppendTarget(fout, "clean", make, makeArgs, - mf->GetHomeOutputDirectory()); + homeOutputDir, homeOutputDir); // add all executable and library targets and some of the GLOBAL // and UTILITY targets @@ -143,7 +146,8 @@ cmExtraKateGenerator::WriteTargets(const cmMakefile* mf, } if (insertTarget) { - this->AppendTarget(fout, ti->first, make, makeArgs, currentDir); + this->AppendTarget(fout, ti->first, make, makeArgs, + currentDir, homeOutputDir); } } break; @@ -158,7 +162,8 @@ cmExtraKateGenerator::WriteTargets(const cmMakefile* mf, break; } - this->AppendTarget(fout, ti->first, make, makeArgs, currentDir); + this->AppendTarget(fout, ti->first, make, makeArgs, + currentDir, homeOutputDir); break; case cmTarget::EXECUTABLE: case cmTarget::STATIC_LIBRARY: @@ -166,10 +171,12 @@ cmExtraKateGenerator::WriteTargets(const cmMakefile* mf, case cmTarget::MODULE_LIBRARY: case cmTarget::OBJECT_LIBRARY: { - this->AppendTarget(fout, ti->first, make, makeArgs, currentDir); + this->AppendTarget(fout, ti->first, make, makeArgs, + currentDir, homeOutputDir); std::string fastTarget = ti->first; fastTarget += "/fast"; - this->AppendTarget(fout, fastTarget, make, makeArgs, currentDir); + this->AppendTarget(fout, fastTarget, make, makeArgs, + currentDir, homeOutputDir); } break; @@ -185,7 +192,7 @@ cmExtraKateGenerator::WriteTargets(const cmMakefile* mf, fit != objectFileTargets.end(); ++fit) { - this->AppendTarget(fout, *fit, make, makeArgs, currentDir); + this->AppendTarget(fout, *fit, make, makeArgs, currentDir,homeOutputDir); } } @@ -199,14 +206,18 @@ cmExtraKateGenerator::AppendTarget(cmGeneratedFileStream& fout, const std::string& target, const std::string& make, const std::string& makeArgs, - const std::string& path) const + const std::string& path, + const char* homeOutputDir + ) const { static char JsonSep = ' '; fout << "\t\t\t" << JsonSep << "{\"name\":\"" << target << "\", " - "\"build_cmd\":\"" << make << " -C " << path << " " << makeArgs << " " - << target << "\"}\n"; + "\"build_cmd\":\"" << make + << " -C " << (this->UseNinja ? homeOutputDir : path.c_str()) + << " " << makeArgs << " " + << target << "\"}\n"; JsonSep = ','; } @@ -326,47 +337,3 @@ std::string cmExtraKateGenerator::GetPathBasename(const std::string& path)const return outputBasename; } - - -// Create the command line for building the given target using the selected -// make -std::string cmExtraKateGenerator::BuildMakeCommand(const std::string& make, - const char* makefile, const char* target) const -{ - std::string command = make; - if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0) - { - std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile); - command += " /NOLOGO /f ""; - command += makefileName; - command += "" "; - command += " VERBOSE=1 "; - command += target; - } - else if (strcmp(this->GlobalGenerator->GetName(), "MinGW Makefiles")==0) - { - // no escaping of spaces in this case, see - // http://public.kitware.com/Bug/view.php?id=10014 - std::string makefileName = makefile; - command += " -f ""; - command += makefileName; - command += "" "; - command += " VERBOSE=1 "; - command += target; - } - else if (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0) - { - command += " -v "; - command += target; - } - else - { - std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile); - command += " -f ""; - command += makefileName; - command += "" "; - command += " VERBOSE=1 "; - command += target; - } - return command; -} diff --git a/Source/cmExtraKateGenerator.h b/Source/cmExtraKateGenerator.h index 4979eff..6ced5fe 100644 --- a/Source/cmExtraKateGenerator.h +++ b/Source/cmExtraKateGenerator.h @@ -46,17 +46,17 @@ private: const std::string& target, const std::string& make, const std::string& makeArgs, - const std::string& path) const; + const std::string& path, + const char* homeOutputDir) const; std::string GenerateFilesString(const cmMakefile* mf) const; std::string GetPathBasename(const std::string& path) const; std::string GenerateProjectName(const std::string& name, const std::string& type, const std::string& path) const; - std::string BuildMakeCommand(const std::string& make, - const char* makefile, const char* target) const; std::string ProjectName; + bool UseNinja; }; #endif diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 6aff5f0..8b760f1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -104,7 +104,7 @@ struct cmStrictTargetComparison { bool operator()(cmTarget const* t1, cmTarget const* t2) const; }; -typedef std::map<cmTarget*, +typedef std::map<cmTarget const*, cmGeneratorTarget*, cmStrictTargetComparison> cmGeneratorTargetsType; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index e6f3d94..f160d28 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -950,7 +950,7 @@ void cmGlobalGenerator::ClearEnabledLanguages() } bool cmGlobalGenerator::IsDependedOn(const char* project, - cmTarget* targetIn) + cmTarget const* targetIn) { // Get all local gens for this project std::vector<cmLocalGenerator*>* gens = &this->ProjectMap[project]; @@ -1214,8 +1214,8 @@ bool cmGlobalGenerator::ComputeTargetDepends() { return false; } - std::vector<cmTarget*> const& targets = ctd.GetTargets(); - for(std::vector<cmTarget*>::const_iterator ti = targets.begin(); + std::vector<cmTarget const*> const& targets = ctd.GetTargets(); + for(std::vector<cmTarget const*>::const_iterator ti = targets.begin(); ti != targets.end(); ++ti) { ctd.GetTargetDirectDepends(*ti, this->TargetDependencies[*ti]); @@ -1379,6 +1379,10 @@ void cmGlobalGenerator::ComputeGeneratorTargetObjects() for(cmGeneratorTargetsType::iterator ti = targets.begin(); ti != targets.end(); ++ti) { + if (ti->second->Target->IsImported()) + { + continue; + } cmGeneratorTarget* gt = ti->second; gt->ClassifySources(); gt->LookupObjectLibraries(); @@ -1432,7 +1436,8 @@ void cmGlobalGenerator::ClearGeneratorMembers() } //---------------------------------------------------------------------------- -cmGeneratorTarget* cmGlobalGenerator::GetGeneratorTarget(cmTarget* t) const +cmGeneratorTarget* +cmGlobalGenerator::GetGeneratorTarget(cmTarget const* t) const { cmGeneratorTargetsType::const_iterator ti = this->GeneratorTargets.find(t); if(ti == this->GeneratorTargets.end()) @@ -1954,7 +1959,7 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() clg = clg->GetParent()) { // This local generator includes the target. - std::set<cmTarget*>& targetSet = + std::set<cmTarget const*>& targetSet = this->LocalGeneratorToTargetMap[clg]; targetSet.insert(&target); @@ -1965,7 +1970,8 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() for(TargetDependSet::const_iterator ti = tgtdeps.begin(); ti != tgtdeps.end(); ++ti) { - targetSet.insert(*ti); + cmTarget const* ttt = *ti; + targetSet.insert(ttt); } } } @@ -2478,7 +2484,7 @@ void cmGlobalGenerator::AppendDirectoryForConfig(const char*, const char*, //---------------------------------------------------------------------------- cmGlobalGenerator::TargetDependSet const& -cmGlobalGenerator::GetTargetDirectDepends(cmTarget & target) +cmGlobalGenerator::GetTargetDirectDepends(cmTarget const& target) { return this->TargetDependencies[&target]; } @@ -2600,7 +2606,7 @@ bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target) } //---------------------------------------------------------------------------- -void cmGlobalGenerator::AddTargetDepends(cmTarget* target, +void cmGlobalGenerator::AddTargetDepends(cmTarget const* target, TargetDependSet& projectTargets) { // add the target itself @@ -2611,7 +2617,7 @@ void cmGlobalGenerator::AddTargetDepends(cmTarget* target, TargetDependSet const& ts = this->GetTargetDirectDepends(*target); for(TargetDependSet::const_iterator i = ts.begin(); i != ts.end(); ++i) { - cmTarget* dtarget = *i; + cmTarget const* dtarget = *i; this->AddTargetDepends(dtarget, projectTargets); } } diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index eb720a8..f60d24d 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -218,7 +218,7 @@ public: /** If check to see if the target is linked to by any other target in the project */ - bool IsDependedOn(const char* project, cmTarget* target); + bool IsDependedOn(const char* project, cmTarget const* target); ///! Find a local generator by its startdirectory cmLocalGenerator* FindLocalGenerator(const char* start_dir); @@ -266,10 +266,10 @@ public: // what targets does the specified target depend on directly // via a target_link_libraries or add_dependencies - TargetDependSet const& GetTargetDirectDepends(cmTarget & target); + TargetDependSet const& GetTargetDirectDepends(cmTarget const& target); /** Get per-target generator information. */ - cmGeneratorTarget* GetGeneratorTarget(cmTarget*) const; + cmGeneratorTarget* GetGeneratorTarget(cmTarget const*) const; const std::map<cmStdString, std::vector<cmLocalGenerator*> >& GetProjectMap() const {return this->ProjectMap;} @@ -323,7 +323,8 @@ protected: TargetDependSet& originalTargets, cmLocalGenerator* root, GeneratorVector const&); virtual bool IsRootOnlyTarget(cmTarget* target); - void AddTargetDepends(cmTarget* target, TargetDependSet& projectTargets); + void AddTargetDepends(cmTarget const* target, + TargetDependSet& projectTargets); void SetLanguageEnabledFlag(const char* l, cmMakefile* mf); void SetLanguageEnabledMaps(const char* l, cmMakefile* mf); void FillExtensionToLanguageMap(const char* l, cmMakefile* mf); @@ -333,7 +334,8 @@ protected: virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS(); bool CheckTargets(); - typedef std::vector<std::pair<cmQtAutoGenerators, cmTarget*> > AutogensType; + typedef std::vector<std::pair<cmQtAutoGenerators, + cmTarget const*> > AutogensType; void CreateQtAutoGeneratorsTargets(AutogensType& autogens); std::string SelectMakeProgram(const char* makeProgram, @@ -362,7 +364,8 @@ protected: cmLocalGenerator* CurrentLocalGenerator; // map from project name to vector of local generators in that project std::map<cmStdString, std::vector<cmLocalGenerator*> > ProjectMap; - std::map<cmLocalGenerator*, std::set<cmTarget *> > LocalGeneratorToTargetMap; + std::map<cmLocalGenerator*, std::set<cmTarget const*> > + LocalGeneratorToTargetMap; // Set of named installation components requested by the project. std::set<cmStdString> InstallComponents; @@ -420,7 +423,7 @@ private: std::vector<std::string> FilesReplacedDuringGenerate; // Store computed inter-target dependencies. - typedef std::map<cmTarget *, TargetDependSet> TargetDependMap; + typedef std::map<cmTarget const*, TargetDependSet> TargetDependMap; TargetDependMap TargetDependencies; // Per-target generator information. diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 77571b2..4b92058 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -830,7 +830,7 @@ void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies() void cmGlobalNinjaGenerator -::AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs) +::AppendTargetOutputs(cmTarget const* target, cmNinjaDeps& outputs) { const char* configName = target->GetMakefile()->GetDefinition("CMAKE_BUILD_TYPE"); @@ -879,7 +879,7 @@ cmGlobalNinjaGenerator void cmGlobalNinjaGenerator -::AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs) +::AppendTargetDepends(cmTarget const* target, cmNinjaDeps& outputs) { if (target->GetType() == cmTarget::GLOBAL_TARGET) { // Global targets only depend on other utilities, which may not appear in diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 4fd0d5c..de38923 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -283,8 +283,8 @@ public: ASD.insert(deps.begin(), deps.end()); } - void AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs); - void AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs); + void AppendTargetOutputs(cmTarget const* target, cmNinjaDeps& outputs); + void AppendTargetDepends(cmTarget const* target, cmNinjaDeps& outputs); void AddDependencyToAll(cmTarget* target); void AddDependencyToAll(const std::string& input); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 6333873..622a7c5 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -480,7 +480,6 @@ cmGlobalUnixMakefileGenerator3 (l->second->GetType() == cmTarget::SHARED_LIBRARY) || (l->second->GetType() == cmTarget::MODULE_LIBRARY) || (l->second->GetType() == cmTarget::OBJECT_LIBRARY) || - (l->second->GetType() == cmTarget::INTERFACE_LIBRARY) || (l->second->GetType() == cmTarget::UTILITY)) { if(l->second->Target->IsImported()) @@ -658,7 +657,6 @@ cmGlobalUnixMakefileGenerator3 (t->second->GetType() == cmTarget::SHARED_LIBRARY) || (t->second->GetType() == cmTarget::MODULE_LIBRARY) || (t->second->GetType() == cmTarget::OBJECT_LIBRARY) || - (t->second->GetType() == cmTarget::INTERFACE_LIBRARY) || (t->second->GetType() == cmTarget::UTILITY))) { // Add a rule to build the target by name. @@ -680,10 +678,6 @@ cmGlobalUnixMakefileGenerator3 t->second->GetName(), depends, commands, true); - if (t->second->GetType() == cmTarget::INTERFACE_LIBRARY) - { - continue; - } // Add a fast rule to build the target std::string localName = lg->GetRelativeTargetDirectory(*t->second->Target); @@ -757,7 +751,6 @@ cmGlobalUnixMakefileGenerator3 || (t->second->GetType() == cmTarget::SHARED_LIBRARY) || (t->second->GetType() == cmTarget::MODULE_LIBRARY) || (t->second->GetType() == cmTarget::OBJECT_LIBRARY) - || (t->second->GetType() == cmTarget::INTERFACE_LIBRARY) || (t->second->GetType() == cmTarget::UTILITY))) { std::string makefileName; @@ -774,64 +767,53 @@ cmGlobalUnixMakefileGenerator3 << localName << "\n\n"; commands.clear(); + makeTargetName = localName; + makeTargetName += "/depend"; + commands.push_back(lg->GetRecursiveMakeCall + (makefileName.c_str(),makeTargetName.c_str())); - if(t->second->GetType() != cmTarget::INTERFACE_LIBRARY) + // add requires if we need it for this generator + if (needRequiresStep) { makeTargetName = localName; - makeTargetName += "/depend"; + makeTargetName += "/requires"; commands.push_back(lg->GetRecursiveMakeCall (makefileName.c_str(),makeTargetName.c_str())); + } + makeTargetName = localName; + makeTargetName += "/build"; + commands.push_back(lg->GetRecursiveMakeCall + (makefileName.c_str(),makeTargetName.c_str())); - // add requires if we need it for this generator - if (needRequiresStep) - { - makeTargetName = localName; - makeTargetName += "/requires"; - commands.push_back(lg->GetRecursiveMakeCall - (makefileName.c_str(),makeTargetName.c_str())); - } - makeTargetName = localName; - makeTargetName += "/build"; - commands.push_back(lg->GetRecursiveMakeCall - (makefileName.c_str(),makeTargetName.c_str())); - - // Write the rule. - localName += "/all"; - depends.clear(); + // Write the rule. + localName += "/all"; + depends.clear(); - std::string progressDir = - lg->GetMakefile()->GetHomeOutputDirectory(); - progressDir += cmake::GetCMakeFilesDirectory(); + std::string progressDir = + lg->GetMakefile()->GetHomeOutputDirectory(); + progressDir += cmake::GetCMakeFilesDirectory(); + { + cmOStringStream progCmd; + progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report "; + // all target counts + progCmd << lg->Convert(progressDir.c_str(), + cmLocalGenerator::FULL, + cmLocalGenerator::SHELL); + progCmd << " "; + std::vector<unsigned long>& progFiles = + this->ProgressMap[t->second->Target].Marks; + for (std::vector<unsigned long>::iterator i = progFiles.begin(); + i != progFiles.end(); ++i) { - cmOStringStream progCmd; - progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report "; - // all target counts - progCmd << lg->Convert(progressDir.c_str(), - cmLocalGenerator::FULL, - cmLocalGenerator::SHELL); - progCmd << " "; - std::vector<unsigned long>& progFiles = - this->ProgressMap[t->second->Target].Marks; - for (std::vector<unsigned long>::iterator i = progFiles.begin(); - i != progFiles.end(); ++i) - { - progCmd << " " << *i; - } - commands.push_back(progCmd.str()); + progCmd << " " << *i; } - progressDir = "Built target "; - progressDir += t->second->GetName(); - lg->AppendEcho(commands,progressDir.c_str()); - } - else - { - depends.clear(); + commands.push_back(progCmd.str()); } + progressDir = "Built target "; + progressDir += t->second->GetName(); + lg->AppendEcho(commands,progressDir.c_str()); + this->AppendGlobalTargetDepends(depends,*t->second->Target); - if(depends.empty() && this->EmptyRuleHackDepends != "") - { - depends.push_back(this->EmptyRuleHackDepends); - } lg->WriteMakeRule(ruleFileStream, "All Build rule for target.", localName.c_str(), depends, commands, true); @@ -847,7 +829,7 @@ cmGlobalUnixMakefileGenerator3 // Write the rule. commands.clear(); - std::string progressDir = lg->GetMakefile()->GetHomeOutputDirectory(); + progressDir = lg->GetMakefile()->GetHomeOutputDirectory(); progressDir += cmake::GetCMakeFilesDirectory(); { @@ -859,7 +841,7 @@ cmGlobalUnixMakefileGenerator3 cmLocalGenerator::FULL, cmLocalGenerator::SHELL); // - std::set<cmTarget *> emitted; + std::set<cmTarget const*> emitted; progCmd << " " << this->CountProgressMarksInTarget(t->second->Target, emitted); commands.push_back(progCmd.str()); @@ -937,8 +919,8 @@ cmGlobalUnixMakefileGenerator3 //---------------------------------------------------------------------------- size_t cmGlobalUnixMakefileGenerator3 -::CountProgressMarksInTarget(cmTarget* target, - std::set<cmTarget*>& emitted) +::CountProgressMarksInTarget(cmTarget const* target, + std::set<cmTarget const*>& emitted) { size_t count = 0; if(emitted.insert(target).second) @@ -964,9 +946,10 @@ cmGlobalUnixMakefileGenerator3 ::CountProgressMarksInAll(cmLocalUnixMakefileGenerator3* lg) { size_t count = 0; - std::set<cmTarget*> emitted; - std::set<cmTarget*> const& targets = this->LocalGeneratorToTargetMap[lg]; - for(std::set<cmTarget*>::const_iterator t = targets.begin(); + std::set<cmTarget const*> emitted; + std::set<cmTarget const*> const& targets + = this->LocalGeneratorToTargetMap[lg]; + for(std::set<cmTarget const*>::const_iterator t = targets.begin(); t != targets.end(); ++t) { count += this->CountProgressMarksInTarget(*t, emitted); @@ -987,7 +970,7 @@ cmGlobalUnixMakefileGenerator3::RecordTargetProgress( //---------------------------------------------------------------------------- bool cmGlobalUnixMakefileGenerator3::ProgressMapCompare -::operator()(cmTarget* l, cmTarget* r) const +::operator()(cmTarget const* l, cmTarget const* r) const { // Order by target name. if(int c = strcmp(l->GetName(), r->GetName())) diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 284f5d1..986d1d7 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -181,13 +181,14 @@ protected: std::vector<unsigned long> Marks; void WriteProgressVariables(unsigned long total, unsigned long& current); }; - struct ProgressMapCompare { bool operator()(cmTarget*,cmTarget*) const; }; - typedef std::map<cmTarget*, TargetProgress, + struct ProgressMapCompare { bool operator()(cmTarget const*, + cmTarget const*) const; }; + typedef std::map<cmTarget const*, TargetProgress, ProgressMapCompare> ProgressMapType; ProgressMapType ProgressMap; - size_t CountProgressMarksInTarget(cmTarget* target, - std::set<cmTarget*>& emitted); + size_t CountProgressMarksInTarget(cmTarget const* target, + std::set<cmTarget const*>& emitted); size_t CountProgressMarksInAll(cmLocalUnixMakefileGenerator3* lg); cmGeneratedFileStream *CommandDatabase; diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 614a79a..38c47ef 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -205,7 +205,7 @@ void cmGlobalVisualStudio6Generator tt = orderedProjectTargets.begin(); tt != orderedProjectTargets.end(); ++tt) { - cmTarget* target = *tt; + cmTarget const* target = *tt; if(target->GetType() == cmTarget::INTERFACE_LIBRARY) { continue; @@ -271,7 +271,7 @@ void cmGlobalVisualStudio6Generator::OutputDSWFile() void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout, const char* dspname, const char* dir, - cmTarget& target) + cmTarget const& target) { fout << "#########################################################" "######################\n\n"; @@ -364,7 +364,7 @@ void cmGlobalVisualStudio6Generator::WriteDSWHeader(std::ostream& fout) //---------------------------------------------------------------------------- std::string -cmGlobalVisualStudio6Generator::WriteUtilityDepend(cmTarget* target) +cmGlobalVisualStudio6Generator::WriteUtilityDepend(cmTarget const* target) { std::string pname = target->GetName(); pname += "_UTILITY"; diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index cb6cb8b..5521410 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -99,12 +99,12 @@ private: void WriteDSWFile(std::ostream& fout); void WriteDSWHeader(std::ostream& fout); void WriteProject(std::ostream& fout, - const char* name, const char* path, cmTarget &t); + const char* name, const char* path, cmTarget const& t); void WriteExternalProject(std::ostream& fout, const char* name, const char* path, const std::set<cmStdString>& dependencies); void WriteDSWFooter(std::ostream& fout); - virtual std::string WriteUtilityDepend(cmTarget* target); + virtual std::string WriteUtilityDepend(cmTarget const* target); std::string MSDevCommand; bool MSDevCommandInitialized; std::string const& GetMSDevCommand(); diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 61d3c4c..6cfad25 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -157,7 +157,7 @@ void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout, const char* dspname, const char* dir, - cmTarget& t) + cmTarget const& t) { // check to see if this is a fortran build const char* ext = ".vcproj"; @@ -209,7 +209,7 @@ void cmGlobalVisualStudio71Generator ::WriteProjectDepends(std::ostream& fout, const char*, - const char*, cmTarget& target) + const char*, cmTarget const& target) { VSDependSet const& depends = this->VSTargetDepends[&target]; for(VSDependSet::const_iterator di = depends.begin(); diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index e136db7..04e3a55 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -59,9 +59,11 @@ protected: std::vector<cmLocalGenerator*>& generators); virtual void WriteSolutionConfigurations(std::ostream& fout); virtual void WriteProject(std::ostream& fout, - const char* name, const char* path, cmTarget &t); + const char* name, const char* path, + cmTarget const& t); virtual void WriteProjectDepends(std::ostream& fout, - const char* name, const char* path, cmTarget &t); + const char* name, const char* path, + cmTarget const& t); virtual void WriteProjectConfigurations( std::ostream& fout, const char* name, cmTarget::TargetType type, const std::set<std::string>& configsPartOfDefaultBuild, diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index a217d8c..1899b40 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -335,7 +335,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations( for(OrderedTargetDependSet::const_iterator tt = projectTargets.begin(); tt != projectTargets.end(); ++tt) { - cmTarget* target = *tt; + cmTarget const* target = *tt; if(target->GetType() == cmTarget::INTERFACE_LIBRARY) { continue; @@ -376,7 +376,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( for(OrderedTargetDependSet::const_iterator tt = projectTargets.begin(); tt != projectTargets.end(); ++tt) { - cmTarget* target = *tt; + cmTarget const* target = *tt; if(target->GetType() == cmTarget::INTERFACE_LIBRARY) { continue; @@ -470,7 +470,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetDepends( for(OrderedTargetDependSet::const_iterator tt = projectTargets.begin(); tt != projectTargets.end(); ++tt) { - cmTarget* target = *tt; + cmTarget const* target = *tt; if(target->GetType() == cmTarget::INTERFACE_LIBRARY) { continue; @@ -619,7 +619,7 @@ cmGlobalVisualStudio7Generator::ConvertToSolutionPath(const char* path) // the libraries it uses are also done here void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout, const char* dspname, - const char* dir, cmTarget& target) + const char* dir, cmTarget const& target) { // check to see if this is a fortran build const char* ext = ".vcproj"; @@ -659,7 +659,7 @@ void cmGlobalVisualStudio7Generator ::WriteProjectDepends(std::ostream& fout, const char* dspname, - const char*, cmTarget& target) + const char*, cmTarget const& target) { int depcount = 0; std::string dspguid = this->GetGUID(dspname); @@ -819,7 +819,7 @@ void cmGlobalVisualStudio7Generator::WriteSLNHeader(std::ostream& fout) //---------------------------------------------------------------------------- std::string -cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget* target) +cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target) { std::string pname = target->GetName(); pname += "_UTILITY"; @@ -940,7 +940,7 @@ cmGlobalVisualStudio7Generator std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(const char* project, - cmTarget* target) + cmTarget const* target) { std::set<std::string> activeConfigs; // if it is a utilitiy target then only make it part of the diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 59e74ba..611422a 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -121,9 +121,11 @@ protected: virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators); virtual void WriteProject(std::ostream& fout, - const char* name, const char* path, cmTarget &t); + const char* name, const char* path, + cmTarget const& t); virtual void WriteProjectDepends(std::ostream& fout, - const char* name, const char* path, cmTarget &t); + const char* name, const char* path, + cmTarget const&t); virtual void WriteProjectConfigurations( std::ostream& fout, const char* name, cmTarget::TargetType type, const std::set<std::string>& configsPartOfDefaultBuild, @@ -132,7 +134,7 @@ protected: cmLocalGenerator* root); virtual void WriteSLNFooter(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout); - virtual std::string WriteUtilityDepend(cmTarget* target); + virtual std::string WriteUtilityDepend(cmTarget const* target); virtual void WriteTargetsToSolution( std::ostream& fout, @@ -158,7 +160,7 @@ protected: std::string ConvertToSolutionPath(const char* path); std::set<std::string> IsPartOfDefaultBuild(const char* project, - cmTarget* target); + cmTarget const* target); std::vector<std::string> Configurations; std::map<cmStdString, cmStdString> GUIDMap; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index e4ce13f..12c240b 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -415,7 +415,7 @@ bool cmGlobalVisualStudio8Generator::ComputeTargetDepends() //---------------------------------------------------------------------------- void cmGlobalVisualStudio8Generator::WriteProjectDepends( - std::ostream& fout, const char*, const char*, cmTarget& t) + std::ostream& fout, const char*, const char*, cmTarget const& t) { TargetDependSet const& unordered = this->GetTargetDirectDepends(t); OrderedTargetDependSet depends(unordered); diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index ad01a24..5b952c4 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -84,7 +84,7 @@ protected: const char* platformMapping = NULL); virtual bool ComputeTargetDepends(); virtual void WriteProjectDepends(std::ostream& fout, const char* name, - const char* path, cmTarget &t); + const char* path, cmTarget const& t); std::string Name; std::string WindowsCEVersion; diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 6c782e4..93a597c 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -315,7 +315,7 @@ std::string cmGlobalVisualStudioGenerator::GetUserMacrosRegKeyBase() } //---------------------------------------------------------------------------- -void cmGlobalVisualStudioGenerator::FillLinkClosure(cmTarget* target, +void cmGlobalVisualStudioGenerator::FillLinkClosure(cmTarget const* target, TargetSet& linked) { if(linked.insert(target).second) @@ -348,7 +348,7 @@ cmGlobalVisualStudioGenerator::GetTargetLinkClosure(cmTarget* target) //---------------------------------------------------------------------------- void cmGlobalVisualStudioGenerator::FollowLinkDepends( - cmTarget* target, std::set<cmTarget*>& linked) + cmTarget const* target, std::set<cmTarget const*>& linked) { if(target->GetType() == cmTarget::INTERFACE_LIBRARY) { @@ -397,7 +397,7 @@ bool cmGlobalVisualStudioGenerator::ComputeTargetDepends() } //---------------------------------------------------------------------------- -static bool VSLinkable(cmTarget* t) +static bool VSLinkable(cmTarget const* t) { return t->IsLinkable() || t->GetType() == cmTarget::OBJECT_LIBRARY; } @@ -439,7 +439,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) // Collect implicit link dependencies (target_link_libraries). // Static libraries cannot depend on their link implementation // due to behavior (2), but they do not really need to. - std::set<cmTarget*> linkDepends; + std::set<cmTarget const*> linkDepends; if(target.GetType() != cmTarget::STATIC_LIBRARY) { for(TargetDependSet::const_iterator di = depends.begin(); @@ -454,7 +454,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) } // Collect explicit util dependencies (add_dependencies). - std::set<cmTarget*> utilDepends; + std::set<cmTarget const*> utilDepends; for(TargetDependSet::const_iterator di = depends.begin(); di != depends.end(); ++di) { @@ -474,18 +474,18 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) } // Emit link dependencies. - for(std::set<cmTarget*>::iterator di = linkDepends.begin(); + for(std::set<cmTarget const*>::iterator di = linkDepends.begin(); di != linkDepends.end(); ++di) { - cmTarget* dep = *di; + cmTarget const* dep = *di; vsTargetDepend.insert(dep->GetName()); } // Emit util dependencies. Possibly use intermediate targets. - for(std::set<cmTarget*>::iterator di = utilDepends.begin(); + for(std::set<cmTarget const*>::iterator di = utilDepends.begin(); di != utilDepends.end(); ++di) { - cmTarget* dep = *di; + cmTarget const* dep = *di; if(allowLinkable || !VSLinkable(dep) || linked.count(dep)) { // Direct dependency allowed. @@ -523,7 +523,8 @@ void cmGlobalVisualStudioGenerator::AddPlatformDefinitions(cmMakefile* mf) } //---------------------------------------------------------------------------- -std::string cmGlobalVisualStudioGenerator::GetUtilityDepend(cmTarget* target) +std::string +cmGlobalVisualStudioGenerator::GetUtilityDepend(cmTarget const* target) { UtilityDependsMap::iterator i = this->UtilityDepends.find(target); if(i == this->UtilityDepends.end()) @@ -845,7 +846,8 @@ void RegisterVisualStudioMacros(const std::string& macrosFile, } } } -bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget& target) +bool +cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target) { // check to see if this is a fortran build std::set<cmStdString> languages; diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index da2d021..54e3c28 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -60,7 +60,7 @@ public: const char* vsSolutionFile = 0); // return true if target is fortran only - bool TargetIsFortranOnly(cmTarget& t); + bool TargetIsFortranOnly(cmTarget const& t); /** Get the top-level registry key for this VS version. */ std::string GetRegistryBase(); @@ -75,7 +75,7 @@ public: /** Return true if building for Windows CE */ virtual bool TargetsWindowsCE() const { return false; } - class TargetSet: public std::set<cmTarget*> {}; + class TargetSet: public std::set<cmTarget const*> {}; struct TargetCompare { bool operator()(cmTarget const* l, cmTarget const* r) const; @@ -96,15 +96,15 @@ protected: virtual bool ComputeTargetDepends(); class VSDependSet: public std::set<cmStdString> {}; - class VSDependMap: public std::map<cmTarget*, VSDependSet> {}; + class VSDependMap: public std::map<cmTarget const*, VSDependSet> {}; VSDependMap VSTargetDepends; void ComputeVSTargetDepends(cmTarget&); bool CheckTargetLinks(cmTarget& target, const char* name); std::string GetUtilityForTarget(cmTarget& target, const char*); - virtual std::string WriteUtilityDepend(cmTarget*) = 0; - std::string GetUtilityDepend(cmTarget* target); - typedef std::map<cmTarget*, cmStdString> UtilityDependsMap; + virtual std::string WriteUtilityDepend(cmTarget const*) = 0; + std::string GetUtilityDepend(cmTarget const* target); + typedef std::map<cmTarget const*, cmStdString> UtilityDependsMap; UtilityDependsMap UtilityDepends; const char* AdditionalPlatformDefinition; @@ -113,11 +113,12 @@ private: void PrintCompilerAdvice(std::ostream&, std::string, const char*) {} void ComputeTargetObjects(cmGeneratorTarget* gt) const; - void FollowLinkDepends(cmTarget* target, std::set<cmTarget*>& linked); + void FollowLinkDepends(cmTarget const* target, + std::set<cmTarget const*>& linked); class TargetSetMap: public std::map<cmTarget*, TargetSet> {}; TargetSetMap TargetLinkClosure; - void FillLinkClosure(cmTarget* target, TargetSet& linked); + void FillLinkClosure(cmTarget const* target, TargetSet& linked); TargetSet const& GetTargetLinkClosure(cmTarget* target); }; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 215d483..b5a46d0 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2622,7 +2622,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, } //---------------------------------------------------------------------------- -cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget* t) +cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget const* t) { if(!t) { diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index e8cbd14..6281c3b 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -125,7 +125,7 @@ private: multipleOutputPairs ); - cmXCodeObject* FindXCodeTarget(cmTarget*); + cmXCodeObject* FindXCodeTarget(cmTarget const*); std::string GetOrCreateId(const char* name, const char* id); // create cmXCodeObject from these functions so that memory can be managed diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 7b9109e..68f45a6 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -328,9 +328,10 @@ cmInstallTargetGenerator::GetInstallFilename(const char* config) const } //---------------------------------------------------------------------------- -std::string cmInstallTargetGenerator::GetInstallFilename(cmTarget* target, - const char* config, - NameType nameType) +std::string +cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, + const char* config, + NameType nameType) { std::string fname; // Compute the name of the library. @@ -515,11 +516,12 @@ cmInstallTargetGenerator std::map<cmStdString, cmStdString> install_name_remap; if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config)) { - std::set<cmTarget*> const& sharedLibs = cli->GetSharedLibrariesLinked(); - for(std::set<cmTarget*>::const_iterator j = sharedLibs.begin(); + std::set<cmTarget const*> const& sharedLibs + = cli->GetSharedLibrariesLinked(); + for(std::set<cmTarget const*>::const_iterator j = sharedLibs.begin(); j != sharedLibs.end(); ++j) { - cmTarget* tgt = *j; + cmTarget const* tgt = *j; // The install_name of an imported target does not change. if(tgt->IsImported()) diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 8cf72f9..18c3957 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -53,7 +53,8 @@ public: NameReal }; - static std::string GetInstallFilename(cmTarget*target, const char* config, + static std::string GetInstallFilename(cmTarget const* target, + const char* config, NameType nameType = NameNormal); cmTarget* GetTarget() const { return this->Target; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index c3c5299..402855c 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -261,6 +261,10 @@ void cmLocalGenerator::TraceDependencies() for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { + if (t->second->Target->IsImported()) + { + continue; + } t->second->TraceDependencies(); } } @@ -545,6 +549,10 @@ void cmLocalGenerator::GenerateTargetManifest() { continue; } + if (target.Target->IsImported()) + { + continue; + } if(configNames.empty()) { target.GenerateTargetManifest(0); @@ -1386,7 +1394,7 @@ std::string cmLocalGenerator::GetIncludeFlags( //---------------------------------------------------------------------------- void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines, - cmTarget* target, + cmTarget const* target, const char* config) { std::vector<std::string> targetDefines; diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 9a89f0f..ad662d5 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -224,8 +224,9 @@ public: bool stripImplicitInclDirs = true); void AddCompileOptions(std::string& flags, cmTarget* target, const char* lang, const char* config); - void AddCompileDefinitions(std::set<std::string>& defines, cmTarget* target, - const char* config); + void AddCompileDefinitions(std::set<std::string>& defines, + cmTarget const* target, + const char* config); /** Compute the language used to compile the given source file. */ const char* GetSourceFileLanguage(const cmSourceFile& source); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 6ca386c..7e97f78 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -388,7 +388,6 @@ void cmLocalUnixMakefileGenerator3 (t->second->GetType() == cmTarget::SHARED_LIBRARY) || (t->second->GetType() == cmTarget::MODULE_LIBRARY) || (t->second->GetType() == cmTarget::OBJECT_LIBRARY) || - (t->second->GetType() == cmTarget::INTERFACE_LIBRARY) || (t->second->GetType() == cmTarget::UTILITY)) { if (t->second->Target->IsImported()) diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 35818ee..399b582 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -85,9 +85,6 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() case cmTarget::OBJECT_LIBRARY: this->WriteObjectLibraryRules(); break; - case cmTarget::INTERFACE_LIBRARY: - // Nothing to do. - break; default: // If language is not known, this is an error. cmSystemTools::Error("Unknown Library Type"); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 2063a24..6e70285 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -76,7 +76,6 @@ cmMakefileTargetGenerator::New(cmGeneratorTarget *tgt) case cmTarget::SHARED_LIBRARY: case cmTarget::MODULE_LIBRARY: case cmTarget::OBJECT_LIBRARY: - case cmTarget::INTERFACE_LIBRARY: result = new cmMakefileLibraryTargetGenerator(tgt); break; case cmTarget::UTILITY: diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 835e3b4..2b4bb8a 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -138,14 +138,14 @@ cmQtAutoGenerators::cmQtAutoGenerators() } } -static std::string getAutogenTargetName(cmTarget *target) +static std::string getAutogenTargetName(cmTarget const* target) { std::string autogenTargetName = target->GetName(); autogenTargetName += "_automoc"; return autogenTargetName; } -static std::string getAutogenTargetDir(cmTarget *target) +static std::string getAutogenTargetDir(cmTarget const* target) { cmMakefile* makefile = target->GetMakefile(); std::string targetDir = makefile->GetCurrentOutputDirectory(); @@ -221,6 +221,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) if (target->GetPropertyAsBool("AUTORCC")) { toolNames.push_back("rcc"); + this->InitializeAutoRccTarget(target); } std::string tools = toolNames[0]; @@ -295,7 +296,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) return true; } -static void GetCompileDefinitionsAndDirectories(cmTarget *target, +static void GetCompileDefinitionsAndDirectories(cmTarget const* target, const char * config, std::string &incs, std::string &defs) @@ -303,10 +304,12 @@ static void GetCompileDefinitionsAndDirectories(cmTarget *target, cmMakefile* makefile = target->GetMakefile(); cmLocalGenerator* localGen = makefile->GetLocalGenerator(); std::vector<std::string> includeDirs; - cmGeneratorTarget gtgt(target); + cmGeneratorTarget *gtgt = target->GetMakefile()->GetLocalGenerator() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); // Get the include dirs for this target, without stripping the implicit // include dirs off, see http://public.kitware.com/Bug/view.php?id=13667 - localGen->GetIncludeDirectories(includeDirs, >gt, "CXX", config, false); + localGen->GetIncludeDirectories(includeDirs, gtgt, "CXX", config, false); const char* sep = ""; incs = ""; for(std::vector<std::string>::const_iterator incDirIt = includeDirs.begin(); @@ -332,7 +335,7 @@ static void GetCompileDefinitionsAndDirectories(cmTarget *target, } } -void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target) +void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) { cmMakefile* makefile = target->GetMakefile(); @@ -435,7 +438,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget* target) } } -void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget* target, +void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, const std::string &autogenTargetName, std::map<std::string, std::string> &configIncludes, std::map<std::string, std::string> &configDefines) @@ -614,7 +617,7 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector<std::string> &opts, opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); } -static void GetUicOpts(cmTarget *target, const char * config, +static void GetUicOpts(cmTarget const* target, const char * config, std::string &optString) { std::vector<std::string> opts; @@ -631,7 +634,7 @@ static void GetUicOpts(cmTarget *target, const char * config, } } -void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget* target, +void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target, std::map<std::string, std::string> &configUicOptions) { cmMakefile *makefile = target->GetMakefile(); @@ -801,14 +804,47 @@ void cmQtAutoGenerators::MergeRccOptions(std::vector<std::string> &opts, opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); } -void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget* target) +void cmQtAutoGenerators::InitializeAutoRccTarget(cmTarget* target) +{ + cmMakefile *makefile = target->GetMakefile(); + + const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles(); + + for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); + fileIt != srcFiles.end(); + ++fileIt) + { + cmSourceFile* sf = *fileIt; + std::string ext = sf->GetExtension(); + if (ext == "qrc") + { + std::string absFile = cmsys::SystemTools::GetRealPath( + sf->GetFullPath().c_str()); + bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")); + + if (!skip) + { + std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(absFile); + + std::string rcc_output_file = makefile->GetCurrentOutputDirectory(); + rcc_output_file += "/qrc_" + basename + ".cpp"; + makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", + rcc_output_file.c_str(), false); + cmSourceFile* rccCppSource + = makefile->GetOrCreateSource(rcc_output_file.c_str(), true); + target->AddSourceFile(rccCppSource); + } + } + } +} + +void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) { std::string _rcc_files; const char* sepRccFiles = ""; cmMakefile *makefile = target->GetMakefile(); - std::vector<cmSourceFile*> newFiles; - const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles(); std::string rccFileFiles; @@ -841,17 +877,6 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget* target) _rcc_files += absFile; sepRccFiles = ";"; - std::string basename = cmsys::SystemTools:: - GetFilenameWithoutLastExtension(absFile); - - std::string rcc_output_file = makefile->GetCurrentOutputDirectory(); - rcc_output_file += "/qrc_" + basename + ".cpp"; - makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", - rcc_output_file.c_str(), false); - cmSourceFile* rccCppSource - = makefile->GetOrCreateSource(rcc_output_file.c_str(), true); - newFiles.push_back(rccCppSource); - if (const char *prop = sf->GetProperty("AUTORCC_OPTIONS")) { std::vector<std::string> optsVec; @@ -880,13 +905,6 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget* target) } } - for(std::vector<cmSourceFile*>::const_iterator fileIt = newFiles.begin(); - fileIt != newFiles.end(); - ++fileIt) - { - target->AddSourceFile(*fileIt); - } - makefile->AddDefinition("_rcc_files", cmLocalGenerator::EscapeForCMake(_rcc_files.c_str()).c_str()); diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index e877f7d..80123d8 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -24,16 +24,17 @@ public: bool Run(const char* targetDirectory, const char *config); bool InitializeAutogenTarget(cmTarget* target); - void SetupAutoGenerateTarget(cmTarget* target); + void SetupAutoGenerateTarget(cmTarget const* target); private: - void SetupAutoMocTarget(cmTarget* target, + void SetupAutoMocTarget(cmTarget const* target, const std::string &autogenTargetName, std::map<std::string, std::string> &configIncludes, std::map<std::string, std::string> &configDefines); - void SetupAutoUicTarget(cmTarget* target, + void SetupAutoUicTarget(cmTarget const* target, std::map<std::string, std::string> &configUicOptions); - void SetupAutoRccTarget(cmTarget* target); + void InitializeAutoRccTarget(cmTarget* target); + void SetupAutoRccTarget(cmTarget const* target); cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, const char* targetDirectory); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 38fe945..a44cda1 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -828,7 +828,8 @@ void cmTarget::GetDirectLinkLibraries(const char *config, //---------------------------------------------------------------------------- void cmTarget::GetInterfaceLinkLibraries(const char *config, - std::vector<std::string> &libs, cmTarget *head) const + std::vector<std::string> &libs, + cmTarget const* head) const { const char *prop = this->GetProperty("INTERFACE_LINK_LIBRARIES"); if (prop) @@ -4860,6 +4861,15 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, const char** imp, std::string& suffix) const { + if (this->GetType() == INTERFACE_LIBRARY) + { + // This method attempts to find a config-specific LOCATION for the + // IMPORTED library. In the case of INTERFACE_LIBRARY, there is no + // LOCATION at all, so leaving *loc and *imp unchanged is the appropriate + // and valid response. + return true; + } + // Track the configuration-specific property suffix. suffix = "_"; suffix += desired_config; @@ -4992,8 +5002,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, const char* loc = 0; const char* imp = 0; std::string suffix; - if (this->GetType() != INTERFACE_LIBRARY && - !this->GetMappedConfig(desired_config, &loc, &imp, suffix)) + if (!this->GetMappedConfig(desired_config, &loc, &imp, suffix)) { return; } @@ -5762,7 +5771,8 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, //---------------------------------------------------------------------------- template<typename PropertyType> -void checkPropertyConsistency(cmTarget const* depender, cmTarget *dependee, +void checkPropertyConsistency(cmTarget const* depender, + cmTarget const* dependee, const char *propName, std::set<cmStdString> &emitted, const char *config, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 3f5a5d1..bf4a8ef 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -187,7 +187,7 @@ public: cmTarget const* head) const; void GetInterfaceLinkLibraries(const char *config, std::vector<std::string> &, - cmTarget *head) const; + cmTarget const* head) const; /** Compute the link type to use for the given configuration. */ LinkLibraryType ComputeLinkType(const char* config) const; diff --git a/Source/cmTargetDepend.h b/Source/cmTargetDepend.h index 258bacd..1feb072 100644 --- a/Source/cmTargetDepend.h +++ b/Source/cmTargetDepend.h @@ -20,17 +20,17 @@ class cmTarget; It may be marked as a 'link' or 'util' edge or both. */ class cmTargetDepend { - cmTarget* Target; + cmTarget const* Target; // The set order depends only on the Target, so we use // mutable members to acheive a map with set syntax. mutable bool Link; mutable bool Util; public: - cmTargetDepend(cmTarget* t): Target(t), Link(false), Util(false) {} - operator cmTarget*() const { return this->Target; } - cmTarget* operator->() const { return this->Target; } - cmTarget& operator*() const { return *this->Target; } + cmTargetDepend(cmTarget const* t): Target(t), Link(false), Util(false) {} + operator cmTarget const*() const { return this->Target; } + cmTarget const* operator->() const { return this->Target; } + cmTarget const& operator*() const { return *this->Target; } friend bool operator < (cmTargetDepend const& l, cmTargetDepend const& r) { return l.Target < r.Target; } void SetType(bool strong) const diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 10663b7..b9ae701 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1841,7 +1841,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences() for( OrderedTargetDependSet::const_iterator i = depends.begin(); i != depends.end(); ++i) { - cmTarget* dt = *i; + cmTarget const* dt = *i; if(dt->GetType() == cmTarget::INTERFACE_LIBRARY) { continue; diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 9e74b7d..5ea604f 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -285,24 +285,6 @@ if(BUILD_TESTING) PASS_REGULAR_EXPRESSION "(file is not of required architecture|does not match cputype|not the architecture being linked)") endif() - if(CMAKE_TEST_GENERATOR MATCHES Make) - set(InterfaceBuildTargets_libname testlib) - if (CMAKE_TEST_GENERATOR MATCHES "Borland|Watcom") - set(InterfaceBuildTargets_libname testlib.lib) - endif() - add_test(InterfaceBuildTargets ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/InterfaceBuildTargets" - "${CMake_BINARY_DIR}/Tests/InterfaceBuildTargets" - --build-two-config - ${build_generator_args} - --build-project InterfaceBuildTargets - --build-options ${build_options} - --test-command ${CMAKE_CMAKE_COMMAND} -E touch_nocreate ${InterfaceBuildTargets_libname} - ) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/InterfaceBuildTargets") - endif() - list(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX}) if(NOT QT4_FOUND) diff --git a/Tests/CPackWiXGenerator/CMakeLists.txt b/Tests/CPackWiXGenerator/CMakeLists.txt index ecfecdb..0b06045 100644 --- a/Tests/CPackWiXGenerator/CMakeLists.txt +++ b/Tests/CPackWiXGenerator/CMakeLists.txt @@ -49,6 +49,8 @@ set(CPACK_PACKAGE_EXECUTABLES "my-other-app" "Second CPack WiX Test" ) +set(CPACK_WIX_PATCH_FILE "${CMAKE_CURRENT_SOURCE_DIR}/patch.xml") + include(CPack) cpack_add_install_type(Full DISPLAY_NAME "Everything") diff --git a/Tests/CPackWiXGenerator/patch.xml b/Tests/CPackWiXGenerator/patch.xml new file mode 100644 index 0000000..13c392d --- /dev/null +++ b/Tests/CPackWiXGenerator/patch.xml @@ -0,0 +1,7 @@ +<CPackWiXPatch> + <CPackWiXFragment Id="CM_CP_applications.bin.my_libapp.exe"> + <Environment Id="MyEnvironment" Action="set" + Name="CPackWiXGeneratorTest" + Value="CPackWiXGeneratorTest"/> + </CPackWiXFragment> +</CPackWiXPatch> diff --git a/Tests/CTestTestMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/CMakeLists.txt index b5162c9..9bd7249 100644 --- a/Tests/CTestTestMemcheck/CMakeLists.txt +++ b/Tests/CTestTestMemcheck/CMakeLists.txt @@ -1,5 +1,13 @@ REGEX_ESCAPE_STRING(CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") +get_filename_component(CTEST_REALPATH_CMAKE_CURRENT_BINARY_DIR + "${CMAKE_CURRENT_BINARY_DIR}" REALPATH +) + +REGEX_ESCAPE_STRING(CTEST_ESCAPED_REALPATH_CMAKE_CURRENT_BINARY_DIR + "${CTEST_REALPATH_CMAKE_CURRENT_BINARY_DIR}" +) + foreach (_retval 0 1) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/memtester.cxx.in" "${CMAKE_CURRENT_BINARY_DIR}/ret${_retval}.cxx" @ONLY) endforeach () @@ -180,7 +188,7 @@ set_tests_properties(CTestTestMemcheckDummyBC PROPERTIES PASS_REGULAR_EXPRESSION "\n1/1 MemCheck #1: RunCMake \\.+ Passed +[0-9]+.[0-9]+ sec\n\n100% tests passed, 0 tests failed out of 1\n(.*\n)?Error parsing XML in stream at line 1: no element found\n") set_tests_properties(CTestTestMemcheckDummyValgrindInvalidSupFile PROPERTIES - PASS_REGULAR_EXPRESSION "\nCannot find memory checker suppression file: ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/does-not-exist\n") + PASS_REGULAR_EXPRESSION "\nCannot find memory checker suppression file: ${CTEST_ESCAPED_REALPATH_CMAKE_CURRENT_BINARY_DIR}/does-not-exist\n") set_tests_properties(CTestTestMemcheckDummyValgrindCustomOptions PROPERTIES PASS_REGULAR_EXPRESSION "\nCannot find memory tester output file: ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindCustomOptions/Testing/Temporary/MemoryChecker.1.log\n(.*\n)?Error in read script: ${CMAKE_CURRENT_BINARY_DIR}/DummyValgrindCustomOptions/test.cmake\n") diff --git a/Tests/Contracts/VTK/Dashboard.cmake.in b/Tests/Contracts/VTK/Dashboard.cmake.in index e33a2de..c3d10f4 100644 --- a/Tests/Contracts/VTK/Dashboard.cmake.in +++ b/Tests/Contracts/VTK/Dashboard.cmake.in @@ -1,3 +1,11 @@ +# This submission's role is to test leading edge of cmake development +# against VTK release +# +# Maintainer: Zack Galbreath <zack.galbreath@kitware.com> +# +# This file was generated as part of the CMake/VTK Contracts test. +# See <CMake-src>/Tests/Contracts/VTK/ for more information + set(CTEST_SITE "@SITE@") set(CTEST_BUILD_NAME "Contracts.VTK") set(CTEST_DASHBOARD_ROOT "@base_dir@") @@ -6,6 +14,7 @@ set(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/VTK-build") set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") set(CTEST_CONFIGURATION_TYPE Debug) +set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") # Assume a Linux build, with a make that supports -j9. Modify this script if # assumption is ever invalid. diff --git a/Tests/InterfaceBuildTargets/CMakeLists.txt b/Tests/InterfaceBuildTargets/CMakeLists.txt deleted file mode 100644 index a00e5d5..0000000 --- a/Tests/InterfaceBuildTargets/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -project(InterfaceBuildTargets) - -add_library(testlib EXCLUDE_FROM_ALL testlib.cxx) -set_property(TARGET testlib PROPERTY PREFIX "") -if(CMAKE_GENERATOR MATCHES "Borland|Watcom") - # These librarians add the .lib suffix anyway. - set_property(TARGET testlib PROPERTY SUFFIX ".lib") -else() - set_property(TARGET testlib PROPERTY SUFFIX "") -endif() - -add_library(iface INTERFACE) -target_link_libraries(iface INTERFACE testlib) diff --git a/Tests/InterfaceBuildTargets/main.cxx b/Tests/InterfaceBuildTargets/main.cxx deleted file mode 100644 index e9ad257..0000000 --- a/Tests/InterfaceBuildTargets/main.cxx +++ /dev/null @@ -1,5 +0,0 @@ - -int main(int, char**) -{ - return 0; -} diff --git a/Tests/InterfaceBuildTargets/testlib.cxx b/Tests/InterfaceBuildTargets/testlib.cxx deleted file mode 100644 index 02bd6b0..0000000 --- a/Tests/InterfaceBuildTargets/testlib.cxx +++ /dev/null @@ -1,5 +0,0 @@ - -void testlib(void) -{ - -} diff --git a/Tests/InterfaceLibrary/CMakeLists.txt b/Tests/InterfaceLibrary/CMakeLists.txt index 53aeb03..8154ced 100644 --- a/Tests/InterfaceLibrary/CMakeLists.txt +++ b/Tests/InterfaceLibrary/CMakeLists.txt @@ -13,3 +13,17 @@ add_subdirectory(libsdir) add_executable(sharedlibtestexe sharedlibtestexe.cpp) target_link_libraries(sharedlibtestexe shared_iface) + +add_library(broken EXCLUDE_FROM_ALL broken.cpp) + +add_library(iface_broken INTERFACE) +# This is not a dependency, so broken will not be built (and the error in +# it will not be hit) +target_link_libraries(iface_broken INTERFACE broken) + +add_library(iface_whitelist INTERFACE) +# The target property CUSTOM will never be evaluated on the INTERFACE library. +target_link_libraries(iface_whitelist INTERFACE $<$<BOOL:$<TARGET_PROPERTY:CUSTOM>>:irrelevant>) + +add_executable(exec_whitelist dummy.cpp) +target_link_libraries(exec_whitelist iface_whitelist) diff --git a/Tests/InterfaceLibrary/broken.cpp b/Tests/InterfaceLibrary/broken.cpp new file mode 100644 index 0000000..1fd1041 --- /dev/null +++ b/Tests/InterfaceLibrary/broken.cpp @@ -0,0 +1,2 @@ + +#error Broken diff --git a/Tests/InterfaceLibrary/dummy.cpp b/Tests/InterfaceLibrary/dummy.cpp new file mode 100644 index 0000000..341aaaf --- /dev/null +++ b/Tests/InterfaceLibrary/dummy.cpp @@ -0,0 +1,5 @@ + +int main(int, char **) +{ + return 0; +} diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index 09f1881..bf867a9 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -55,93 +55,9 @@ else() endif() endif() -set(DEPS - libshared - libstatic - lib_shared_and_static -) - -foreach(DEP ${DEPS}) - try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/${DEP}_build - ${CMAKE_CURRENT_SOURCE_DIR}/${DEP} - ${DEP} - OUTPUT_VARIABLE Out - ) - if (NOT Result) - message("OUTPUT: ${Out}") - endif() -endforeach() - -# The _do_build macro is called from a child scope, where -# the current source and binary dir are different. Save them here -# for use in the macro. -set(TEST_TOP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -set(TEST_TOP_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) - - -# We seem to get race conditions is writing this stuff to the same file at least on MinGW -# So to write to separate source and build directories, we use a count to differentiate. -set (COUNT 0) -macro(_do_build Include Library LibrarySource Source) - - math(EXPR COUNT "${COUNT} + 1" ) - - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/src.cpp" "#include \"${Include}\"\n" - "int main() { ${Source}; }\n" - ) - - if ("${Library}" STREQUAL "static_variant") - set(CONDITIONAL_STATIC_DEFINE "add_definitions(-DLIBSHARED_AND_STATIC_STATIC_DEFINE)\n") - endif() - - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/CMakeLists.txt" - "cmake_minimum_required(VERSION 2.8)\n" - - "project(compiletest)\n" - - "set(CMAKE_INCLUDE_CURRENT_DIR ON)\n" - - "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"\${CMAKE_CURRENT_BINARY_DIR}\")\n" - - "include(GenerateExportHeader)\n" - - "add_compiler_export_flags()\n" - - "if(NOT \"${ERROR_FLAG}\" STREQUAL \"\")\n" - " add_definitions(${ERROR_FLAG})\n" - "endif()\n" - - "include(\"${TEST_TOP_BINARY_DIR}/${LibrarySource}_build/Targets.cmake\")\n" - - "include_directories(\"${TEST_TOP_SOURCE_DIR}/${LibrarySource}\"\n" - " \"${TEST_TOP_BINARY_DIR}/${LibrarySource}_build\")\n" - - "${CONDITIONAL_STATIC_DEFINE}" - - "add_executable(compiletest src.cpp)\n" - "target_link_libraries(compiletest ${Library})\n" - ) - - try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/fail${COUNT} - ${CMAKE_CURRENT_BINARY_DIR}/test${COUNT} - compiletest - OUTPUT_VARIABLE Out - ) -endmacro() - -macro(build_fail Include Library LibrarySource Source Message) - _do_build(${Include} ${Library} ${LibrarySource} "${Source}") - test_fail(Result ${Message}) -endmacro() - -macro(build_pass Include Library LibrarySource Source Message) - _do_build(${Include} ${Library} ${LibrarySource} "${Source}") - test_pass(Result ${Message}) -endmacro() - include(GenerateExportHeader) -add_subdirectory(visibility_preset) +add_subdirectory(lib_shared_and_static) add_compiler_export_flags() @@ -159,23 +75,17 @@ macro(macro_add_test_library name) ${${name}_BINARY_DIR} # For the export header. ) list(APPEND link_libraries ${name}) - add_subdirectory(${name}test) endmacro() macro_add_test_library(libshared) macro_add_test_library(libstatic) -add_subdirectory(lib_shared_and_static) -add_subdirectory(lib_shared_and_statictest) -add_subdirectory(override_symbol) add_subdirectory(nodeprecated) -add_subdirectory(prefix) if(NOT BORLAND) add_subdirectory(c_identifier) endif() if (CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)) - # We deliberately call deprecated methods, and test for that elsewhere. # No need to clutter the test output with warnings. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations") endif() @@ -187,3 +97,24 @@ endif() add_executable(GenerateExportHeader exportheader_test.cpp) target_link_libraries(GenerateExportHeader ${link_libraries}) +if (WIN32) + if(MSVC AND COMPILER_HAS_DEPRECATED) + set(_platform Win32) + elseif(MINGW AND COMPILER_HAS_DEPRECATED) + set(_platform MinGW) + else() + set(_platform WinEmpty) + endif() +elseif(COMPILER_HAS_HIDDEN_VISIBILITY AND USE_COMPILER_HIDDEN_VISIBILITY) + set(_platform UNIX) +elseif(COMPILER_HAS_DEPRECATED) + set(_platform UNIX_DeprecatedOnly) +else() + set(_platform Empty) +endif() +message("#### Testing reference: ${_platform}") +target_compile_definitions(GenerateExportHeader + PRIVATE + "SRC_DIR=${CMAKE_CURRENT_SOURCE_DIR}/reference/${_platform}" + "BIN_DIR=${CMAKE_CURRENT_BINARY_DIR}" +) diff --git a/Tests/Module/GenerateExportHeader/exportheader_test.cpp b/Tests/Module/GenerateExportHeader/exportheader_test.cpp index 55c3c1a..146374a 100644 --- a/Tests/Module/GenerateExportHeader/exportheader_test.cpp +++ b/Tests/Module/GenerateExportHeader/exportheader_test.cpp @@ -11,6 +11,52 @@ #define DOES_NOT_BUILD(function) function #endif +#include <fstream> +#include <iostream> +#include <stdlib.h> +#include <string> + +void compare(const char* refName, const char* testName) +{ + std::ifstream ref; + ref.open(refName); + if (!ref.is_open()) + { + std::cout << "Could not open \"" << refName << "\"." << std::endl; + exit(1); + } + std::ifstream test; + test.open(testName); + if (!test.is_open()) + { + std::cout << "Could not open \"" << testName << "\"." << std::endl; + exit(1); + } + + while (!ref.eof() && !test.eof()) + { + std::string refLine; + std::string testLine; + std::getline(ref, refLine); + std::getline(test, testLine); + if (testLine.size() && testLine[testLine.size()-1] == ' ') + { + testLine = testLine.substr(0, testLine.size() - 1); + } + if (refLine != testLine) + { + std::cout << "Ref and test are not the same:\n Ref: \"" + << refLine << "\"\n Test: \"" << testLine << "\"\n"; + exit(1); + } + } + if (!ref.eof() || !test.eof()) + { + std::cout << "Ref and test have differing numbers of lines."; + exit(1); + } +} + int main() { { @@ -78,5 +124,13 @@ int main() libstatic_not_exported(); libstatic_excluded(); +#define STRINGIFY_IMPL(A) #A +#define STRINGIFY(A) STRINGIFY_IMPL(A) + + compare(STRINGIFY(SRC_DIR) "/libshared_export.h", + STRINGIFY(BIN_DIR) "/libshared/libshared_export.h"); + compare(STRINGIFY(SRC_DIR) "/libstatic_export.h", + STRINGIFY(BIN_DIR) "/libstatic/libstatic_export.h"); + return 0; } diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt b/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt index be0387f..c1be125 100644 --- a/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt @@ -5,7 +5,15 @@ project(lib_shared_and_static) include(GenerateExportHeader) -add_compiler_export_flags() +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) + +if (CMAKE_CXX_FLAGS MATCHES "-fvisibility=hidden") + message(SEND_ERROR "Do not use add_compiler_export_flags before adding this directory") +endif() +if (CMAKE_CXX_FLAGS MATCHES "-fvisibility-inlines-hidden") + message(SEND_ERROR "Do not use add_compiler_export_flags before adding this directory") +endif() set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -14,9 +22,13 @@ set(lib_SRCS ) add_library(shared_variant SHARED ${lib_SRCS}) +set_target_properties(shared_variant PROPERTIES DEFINE_SYMBOL SHARED_VARIANT_MAKEDLL) add_library(static_variant ${lib_SRCS}) -generate_export_header(shared_variant BASE_NAME libshared_and_static) +generate_export_header(shared_variant + BASE_NAME libshared_and_static + PREFIX_NAME MYPREFIX_ +) set_target_properties(static_variant PROPERTIES COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE) diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h index 049bfe9..5ad77f4 100644 --- a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h @@ -4,51 +4,51 @@ #include "libshared_and_static_export.h" -class LIBSHARED_AND_STATIC_EXPORT LibsharedAndStatic { +class MYPREFIX_LIBSHARED_AND_STATIC_EXPORT LibsharedAndStatic { public: int libshared_and_static() const; int libshared_and_static_exported() const; - int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; + int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; int libshared_and_static_not_exported() const; - int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; + int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; }; class LibsharedAndStaticNotExported { public: int libshared_and_static() const; - int LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const; + int MYPREFIX_LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const; - int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; + int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; int libshared_and_static_not_exported() const; - int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; + int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; }; -class LIBSHARED_AND_STATIC_NO_EXPORT LibsharedAndStaticExcluded { +class MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT LibsharedAndStaticExcluded { public: int libshared_and_static() const; - int LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const; + int MYPREFIX_LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const; - int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; + int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; int libshared_and_static_not_exported() const; - int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; + int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; }; -LIBSHARED_AND_STATIC_EXPORT int libshared_and_static_exported(); +MYPREFIX_LIBSHARED_AND_STATIC_EXPORT int libshared_and_static_exported(); -LIBSHARED_AND_STATIC_DEPRECATED_EXPORT int libshared_and_static_deprecated(); +MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED_EXPORT int libshared_and_static_deprecated(); int libshared_and_static_not_exported(); -int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded(); +int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded(); #endif diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt deleted file mode 100644 index 207534d..0000000 --- a/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ - -macro(shared_variant_build_pass Source Message) - build_pass("libshared_and_static.h" "shared_variant" "lib_shared_and_static" "${Source}" ${Message}) -endmacro() - -macro(shared_variant_build_fail Source Message) - build_fail("libshared_and_static.h" "shared_variant" "lib_shared_and_static" "${Source}" ${Message}) -endmacro() - -macro(static_variant_build_pass Source Message) - build_pass("libshared_and_static.h" "static_variant" "lib_shared_and_static" "${Source}" ${Message}) -endmacro() - -macro(static_variant_build_fail Source Message) - build_fail("libshared_and_static.h" "static_variant" "lib_shared_and_static" "${Source}" ${Message}) -endmacro() - -static_variant_build_pass("return libshared_and_static_exported();" "Failed to build static variant") -shared_variant_build_pass("return libshared_and_static_exported();" "Failed to build shared variant") -# if (COMPILER_HAS_DEPRECATED) -# shared_variant_build_fail("return libshared_and_static_deprecated();" "Built shared deprecated variant") -# static_variant_build_fail("return libshared_and_static_deprecated();" "Built static deprecated variant") -# else() -# shared_variant_build_pass("return libshared_and_static_deprecated();" "Built shared deprecated variant") -# static_variant_build_pass("return libshared_and_static_deprecated();" "Built static deprecated variant") -# endif() -static_variant_build_pass("return libshared_and_static_not_exported();" "Failed to build static not exported variant") - -if (WIN32 OR COMPILER_HAS_HIDDEN_VISIBILITY) - shared_variant_build_fail("return libshared_and_static_not_exported();" "Built shared not exported variant") -else() - shared_variant_build_pass("return libshared_and_static_not_exported();" "Built shared not exported variant") -endif() diff --git a/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt deleted file mode 100644 index 2a97d8f..0000000 --- a/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt +++ /dev/null @@ -1,45 +0,0 @@ - -macro(shared_build_pass Source Message) - build_pass("libshared.h" "libshared" "libshared" "${Source}" ${Message}) -endmacro() - -macro(shared_build_fail Source Message) - build_fail("libshared.h" "libshared" "libshared" "${Source}" ${Message}) -endmacro() - -shared_build_pass("Libshared l; return l.libshared_exported();" "Failed to build exported") -shared_build_pass("return libshared_exported();" "Failed to build exported function.") - -# if (COMPILER_HAS_DEPRECATED) -# shared_build_fail("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.") -# else() -# shared_build_pass("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.") -# endif() -if (COMPILER_HAS_HIDDEN_VISIBILITY) - shared_build_fail("Libshared l; return l.libshared_excluded();" "Built use of excluded class method. This should not be possible.") -else() - # There is no MSVC equivalent to hiding symbols. - shared_build_pass("Libshared l; return l.libshared_excluded();" "Built use of excluded class method. This is possible on MSVC.") -endif() - -if (WIN32 OR COMPILER_HAS_HIDDEN_VISIBILITY) - shared_build_fail("LibsharedNotExported l; return l.libshared();" "Built use of not-exported class method. This should not be possible.") - shared_build_fail("LibsharedNotExported l; return l.libshared_not_exported();" "Built use of not-exported class method. This should not be possible.") - shared_build_fail("LibsharedNotExported l; return l.libshared_excluded();" "Built use of not-exported class method. This should not be possible.") - shared_build_fail("LibsharedExcluded l; return l.libshared();" "Built use of excluded class method. This should not be possible.") - shared_build_fail("LibsharedExcluded l; return l.libshared_not_exported();" "Built use of excluded class method. This should not be possible.") - shared_build_fail("LibsharedExcluded l; return l.libshared_excluded();" "Built use of excluded class method. This should not be possible.") - - shared_build_fail("return libshared_excluded();" "Built use of excluded function. This should not be possible.") - shared_build_fail("return libshared_not_exported();" "Built use of not-exported function. This should not be possible.") -else() - shared_build_pass("LibsharedNotExported l; return l.libshared();" "Built use of not-exported class method.") - shared_build_pass("LibsharedNotExported l; return l.libshared_not_exported();" "Built use of not-exported class method.") - shared_build_pass("LibsharedNotExported l; return l.libshared_excluded();" "Built use of not-exported class method.") - shared_build_pass("LibsharedExcluded l; return l.libshared();" "Built use of excluded class method.") - shared_build_pass("LibsharedExcluded l; return l.libshared_not_exported();" "Built use of excluded class method.") - shared_build_pass("LibsharedExcluded l; return l.libshared_excluded();" "Built use of excluded class method.") - - shared_build_pass("return libshared_excluded();" "Built use of excluded function.") - shared_build_pass("return libshared_not_exported();" "Built use of not-exported function.") -endif() diff --git a/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt deleted file mode 100644 index eb6bb87..0000000 --- a/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ - -macro(static_build_pass Source Message) - build_pass("libstatic.h" "libstatic" "libstatic" "${Source}" ${Message}) -endmacro() - -macro(static_build_fail Source Message) - build_fail("libstatic.h" "libstatic" "libstatic" "${Source}" ${Message}) -endmacro() - -static_build_pass("Libstatic l; return l.libstatic_exported();" "Failed to build exported.") - -# if (COMPILER_HAS_DEPRECATED) -# static_build_fail("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.") -# static_build_fail("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.") -# else() -# static_build_pass("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.") -# static_build_pass("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.") -# endif() diff --git a/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt b/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt deleted file mode 100644 index aeeef20..0000000 --- a/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -project(override_symbol) - -add_library(somelib SHARED someclass.cpp) - -set_target_properties(somelib PROPERTIES DEFINE_SYMBOL SOMELIB_MAKEDLL) - -generate_export_header(somelib) - -add_executable(consumer main.cpp) - -target_link_libraries(consumer somelib) diff --git a/Tests/Module/GenerateExportHeader/override_symbol/main.cpp b/Tests/Module/GenerateExportHeader/override_symbol/main.cpp deleted file mode 100644 index eec46d3..0000000 --- a/Tests/Module/GenerateExportHeader/override_symbol/main.cpp +++ /dev/null @@ -1,9 +0,0 @@ - -#include "someclass.h" - -int main(int, char**) -{ - SomeClass sc; - sc.someMethod(); - return 0; -} diff --git a/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp b/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp deleted file mode 100644 index 427ec29..0000000 --- a/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp +++ /dev/null @@ -1,7 +0,0 @@ - -#include "someclass.h" - -void SomeClass::someMethod() const -{ - -} diff --git a/Tests/Module/GenerateExportHeader/override_symbol/someclass.h b/Tests/Module/GenerateExportHeader/override_symbol/someclass.h deleted file mode 100644 index ae5e844..0000000 --- a/Tests/Module/GenerateExportHeader/override_symbol/someclass.h +++ /dev/null @@ -1,8 +0,0 @@ - -#include "somelib_export.h" - -class SOMELIB_EXPORT SomeClass -{ -public: - void someMethod() const; -}; diff --git a/Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt b/Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt deleted file mode 100644 index bd64df2..0000000 --- a/Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -project(use_prefix) - -set(use_prefix_lib_SRCS - useprefixclass.cpp -) - -add_library(use_prefix_lib SHARED useprefixclass.cpp) - -generate_export_header(use_prefix_lib - PREFIX_NAME MYPREFIX_ -) - -add_executable(use_prefix main.cpp) - -target_link_libraries(use_prefix use_prefix_lib)
\ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/prefix/main.cpp b/Tests/Module/GenerateExportHeader/prefix/main.cpp deleted file mode 100644 index 507f6fd..0000000 --- a/Tests/Module/GenerateExportHeader/prefix/main.cpp +++ /dev/null @@ -1,8 +0,0 @@ - -#include "useprefixclass.h" - -int main(int argc, char **argv) -{ - UsePrefixClass upc; - return upc.someMethod(); -} diff --git a/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp deleted file mode 100644 index 1fd2cb2..0000000 --- a/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp +++ /dev/null @@ -1,7 +0,0 @@ - -#include "useprefixclass.h" - -int UsePrefixClass::someMethod() const -{ - return 0; -} diff --git a/Tests/Module/GenerateExportHeader/prefix/useprefixclass.h b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.h deleted file mode 100644 index f5e31b5..0000000 --- a/Tests/Module/GenerateExportHeader/prefix/useprefixclass.h +++ /dev/null @@ -1,13 +0,0 @@ - -#ifndef USEPREFIXCLASS_H -#define USEPREFIXCLASS_H - -#include "use_prefix_lib_export.h" - -class MYPREFIX_USE_PREFIX_LIB_EXPORT UsePrefixClass -{ -public: - int someMethod() const; -}; - -#endif diff --git a/Tests/Module/GenerateExportHeader/reference/Empty/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/Empty/libshared_export.h new file mode 100644 index 0000000..b6749b2 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/Empty/libshared_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSHARED_EXPORT_H +#define LIBSHARED_EXPORT_H + +#ifdef LIBSHARED_STATIC_DEFINE +# define LIBSHARED_EXPORT +# define LIBSHARED_NO_EXPORT +#else +# ifndef LIBSHARED_EXPORT +# ifdef libshared_EXPORTS + /* We are building this library */ +# define LIBSHARED_EXPORT +# else + /* We are using this library */ +# define LIBSHARED_EXPORT +# endif +# endif + +# ifndef LIBSHARED_NO_EXPORT +# define LIBSHARED_NO_EXPORT +# endif +#endif + +#ifndef LIBSHARED_DEPRECATED +# define LIBSHARED_DEPRECATED +#endif + +#ifndef LIBSHARED_DEPRECATED_EXPORT +# define LIBSHARED_DEPRECATED_EXPORT LIBSHARED_EXPORT LIBSHARED_DEPRECATED +#endif + +#ifndef LIBSHARED_DEPRECATED_NO_EXPORT +# define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSHARED_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/reference/Empty/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/Empty/libstatic_export.h new file mode 100644 index 0000000..e8000e2 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/Empty/libstatic_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSTATIC_EXPORT_H +#define LIBSTATIC_EXPORT_H + +#ifdef LIBSTATIC_STATIC_DEFINE +# define LIBSTATIC_EXPORT +# define LIBSTATIC_NO_EXPORT +#else +# ifndef LIBSTATIC_EXPORT +# ifdef libstatic_EXPORTS + /* We are building this library */ +# define LIBSTATIC_EXPORT +# else + /* We are using this library */ +# define LIBSTATIC_EXPORT +# endif +# endif + +# ifndef LIBSTATIC_NO_EXPORT +# define LIBSTATIC_NO_EXPORT +# endif +#endif + +#ifndef LIBSTATIC_DEPRECATED +# define LIBSTATIC_DEPRECATED +#endif + +#ifndef LIBSTATIC_DEPRECATED_EXPORT +# define LIBSTATIC_DEPRECATED_EXPORT LIBSTATIC_EXPORT LIBSTATIC_DEPRECATED +#endif + +#ifndef LIBSTATIC_DEPRECATED_NO_EXPORT +# define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSTATIC_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/reference/MinGW/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/MinGW/libshared_export.h new file mode 100644 index 0000000..d376631 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/MinGW/libshared_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSHARED_EXPORT_H +#define LIBSHARED_EXPORT_H + +#ifdef LIBSHARED_STATIC_DEFINE +# define LIBSHARED_EXPORT +# define LIBSHARED_NO_EXPORT +#else +# ifndef LIBSHARED_EXPORT +# ifdef libshared_EXPORTS + /* We are building this library */ +# define LIBSHARED_EXPORT __declspec(dllexport) +# else + /* We are using this library */ +# define LIBSHARED_EXPORT __declspec(dllimport) +# endif +# endif + +# ifndef LIBSHARED_NO_EXPORT +# define LIBSHARED_NO_EXPORT +# endif +#endif + +#ifndef LIBSHARED_DEPRECATED +# define LIBSHARED_DEPRECATED __attribute__ ((__deprecated__)) +#endif + +#ifndef LIBSHARED_DEPRECATED_EXPORT +# define LIBSHARED_DEPRECATED_EXPORT LIBSHARED_EXPORT LIBSHARED_DEPRECATED +#endif + +#ifndef LIBSHARED_DEPRECATED_NO_EXPORT +# define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSHARED_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/reference/MinGW/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/MinGW/libstatic_export.h new file mode 100644 index 0000000..fd021e9 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/MinGW/libstatic_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSTATIC_EXPORT_H +#define LIBSTATIC_EXPORT_H + +#ifdef LIBSTATIC_STATIC_DEFINE +# define LIBSTATIC_EXPORT +# define LIBSTATIC_NO_EXPORT +#else +# ifndef LIBSTATIC_EXPORT +# ifdef libstatic_EXPORTS + /* We are building this library */ +# define LIBSTATIC_EXPORT +# else + /* We are using this library */ +# define LIBSTATIC_EXPORT +# endif +# endif + +# ifndef LIBSTATIC_NO_EXPORT +# define LIBSTATIC_NO_EXPORT +# endif +#endif + +#ifndef LIBSTATIC_DEPRECATED +# define LIBSTATIC_DEPRECATED __attribute__ ((__deprecated__)) +#endif + +#ifndef LIBSTATIC_DEPRECATED_EXPORT +# define LIBSTATIC_DEPRECATED_EXPORT LIBSTATIC_EXPORT LIBSTATIC_DEPRECATED +#endif + +#ifndef LIBSTATIC_DEPRECATED_NO_EXPORT +# define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSTATIC_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/reference/UNIX/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/UNIX/libshared_export.h new file mode 100644 index 0000000..7d8087f --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/UNIX/libshared_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSHARED_EXPORT_H +#define LIBSHARED_EXPORT_H + +#ifdef LIBSHARED_STATIC_DEFINE +# define LIBSHARED_EXPORT +# define LIBSHARED_NO_EXPORT +#else +# ifndef LIBSHARED_EXPORT +# ifdef libshared_EXPORTS + /* We are building this library */ +# define LIBSHARED_EXPORT __attribute__((visibility("default"))) +# else + /* We are using this library */ +# define LIBSHARED_EXPORT __attribute__((visibility("default"))) +# endif +# endif + +# ifndef LIBSHARED_NO_EXPORT +# define LIBSHARED_NO_EXPORT __attribute__((visibility("hidden"))) +# endif +#endif + +#ifndef LIBSHARED_DEPRECATED +# define LIBSHARED_DEPRECATED __attribute__ ((__deprecated__)) +#endif + +#ifndef LIBSHARED_DEPRECATED_EXPORT +# define LIBSHARED_DEPRECATED_EXPORT LIBSHARED_EXPORT LIBSHARED_DEPRECATED +#endif + +#ifndef LIBSHARED_DEPRECATED_NO_EXPORT +# define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSHARED_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/reference/UNIX/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/UNIX/libstatic_export.h new file mode 100644 index 0000000..fd021e9 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/UNIX/libstatic_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSTATIC_EXPORT_H +#define LIBSTATIC_EXPORT_H + +#ifdef LIBSTATIC_STATIC_DEFINE +# define LIBSTATIC_EXPORT +# define LIBSTATIC_NO_EXPORT +#else +# ifndef LIBSTATIC_EXPORT +# ifdef libstatic_EXPORTS + /* We are building this library */ +# define LIBSTATIC_EXPORT +# else + /* We are using this library */ +# define LIBSTATIC_EXPORT +# endif +# endif + +# ifndef LIBSTATIC_NO_EXPORT +# define LIBSTATIC_NO_EXPORT +# endif +#endif + +#ifndef LIBSTATIC_DEPRECATED +# define LIBSTATIC_DEPRECATED __attribute__ ((__deprecated__)) +#endif + +#ifndef LIBSTATIC_DEPRECATED_EXPORT +# define LIBSTATIC_DEPRECATED_EXPORT LIBSTATIC_EXPORT LIBSTATIC_DEPRECATED +#endif + +#ifndef LIBSTATIC_DEPRECATED_NO_EXPORT +# define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSTATIC_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h new file mode 100644 index 0000000..5681f58 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSHARED_EXPORT_H +#define LIBSHARED_EXPORT_H + +#ifdef LIBSHARED_STATIC_DEFINE +# define LIBSHARED_EXPORT +# define LIBSHARED_NO_EXPORT +#else +# ifndef LIBSHARED_EXPORT +# ifdef libshared_EXPORTS + /* We are building this library */ +# define LIBSHARED_EXPORT +# else + /* We are using this library */ +# define LIBSHARED_EXPORT +# endif +# endif + +# ifndef LIBSHARED_NO_EXPORT +# define LIBSHARED_NO_EXPORT +# endif +#endif + +#ifndef LIBSHARED_DEPRECATED +# define LIBSHARED_DEPRECATED __attribute__ ((__deprecated__)) +#endif + +#ifndef LIBSHARED_DEPRECATED_EXPORT +# define LIBSHARED_DEPRECATED_EXPORT LIBSHARED_EXPORT LIBSHARED_DEPRECATED +#endif + +#ifndef LIBSHARED_DEPRECATED_NO_EXPORT +# define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSHARED_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h new file mode 100644 index 0000000..fd021e9 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSTATIC_EXPORT_H +#define LIBSTATIC_EXPORT_H + +#ifdef LIBSTATIC_STATIC_DEFINE +# define LIBSTATIC_EXPORT +# define LIBSTATIC_NO_EXPORT +#else +# ifndef LIBSTATIC_EXPORT +# ifdef libstatic_EXPORTS + /* We are building this library */ +# define LIBSTATIC_EXPORT +# else + /* We are using this library */ +# define LIBSTATIC_EXPORT +# endif +# endif + +# ifndef LIBSTATIC_NO_EXPORT +# define LIBSTATIC_NO_EXPORT +# endif +#endif + +#ifndef LIBSTATIC_DEPRECATED +# define LIBSTATIC_DEPRECATED __attribute__ ((__deprecated__)) +#endif + +#ifndef LIBSTATIC_DEPRECATED_EXPORT +# define LIBSTATIC_DEPRECATED_EXPORT LIBSTATIC_EXPORT LIBSTATIC_DEPRECATED +#endif + +#ifndef LIBSTATIC_DEPRECATED_NO_EXPORT +# define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSTATIC_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/reference/Win32/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/Win32/libshared_export.h new file mode 100644 index 0000000..976c92e --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/Win32/libshared_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSHARED_EXPORT_H +#define LIBSHARED_EXPORT_H + +#ifdef LIBSHARED_STATIC_DEFINE +# define LIBSHARED_EXPORT +# define LIBSHARED_NO_EXPORT +#else +# ifndef LIBSHARED_EXPORT +# ifdef libshared_EXPORTS + /* We are building this library */ +# define LIBSHARED_EXPORT __declspec(dllexport) +# else + /* We are using this library */ +# define LIBSHARED_EXPORT __declspec(dllimport) +# endif +# endif + +# ifndef LIBSHARED_NO_EXPORT +# define LIBSHARED_NO_EXPORT +# endif +#endif + +#ifndef LIBSHARED_DEPRECATED +# define LIBSHARED_DEPRECATED __declspec(deprecated) +#endif + +#ifndef LIBSHARED_DEPRECATED_EXPORT +# define LIBSHARED_DEPRECATED_EXPORT LIBSHARED_EXPORT LIBSHARED_DEPRECATED +#endif + +#ifndef LIBSHARED_DEPRECATED_NO_EXPORT +# define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSHARED_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/reference/Win32/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/Win32/libstatic_export.h new file mode 100644 index 0000000..db4df61 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/Win32/libstatic_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSTATIC_EXPORT_H +#define LIBSTATIC_EXPORT_H + +#ifdef LIBSTATIC_STATIC_DEFINE +# define LIBSTATIC_EXPORT +# define LIBSTATIC_NO_EXPORT +#else +# ifndef LIBSTATIC_EXPORT +# ifdef libstatic_EXPORTS + /* We are building this library */ +# define LIBSTATIC_EXPORT +# else + /* We are using this library */ +# define LIBSTATIC_EXPORT +# endif +# endif + +# ifndef LIBSTATIC_NO_EXPORT +# define LIBSTATIC_NO_EXPORT +# endif +#endif + +#ifndef LIBSTATIC_DEPRECATED +# define LIBSTATIC_DEPRECATED __declspec(deprecated) +#endif + +#ifndef LIBSTATIC_DEPRECATED_EXPORT +# define LIBSTATIC_DEPRECATED_EXPORT LIBSTATIC_EXPORT LIBSTATIC_DEPRECATED +#endif + +#ifndef LIBSTATIC_DEPRECATED_NO_EXPORT +# define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSTATIC_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/reference/WinEmpty/libshared_export.h b/Tests/Module/GenerateExportHeader/reference/WinEmpty/libshared_export.h new file mode 100644 index 0000000..2dc41d4 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/WinEmpty/libshared_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSHARED_EXPORT_H +#define LIBSHARED_EXPORT_H + +#ifdef LIBSHARED_STATIC_DEFINE +# define LIBSHARED_EXPORT +# define LIBSHARED_NO_EXPORT +#else +# ifndef LIBSHARED_EXPORT +# ifdef libshared_EXPORTS + /* We are building this library */ +# define LIBSHARED_EXPORT __declspec(dllexport) +# else + /* We are using this library */ +# define LIBSHARED_EXPORT __declspec(dllimport) +# endif +# endif + +# ifndef LIBSHARED_NO_EXPORT +# define LIBSHARED_NO_EXPORT +# endif +#endif + +#ifndef LIBSHARED_DEPRECATED +# define LIBSHARED_DEPRECATED +#endif + +#ifndef LIBSHARED_DEPRECATED_EXPORT +# define LIBSHARED_DEPRECATED_EXPORT LIBSHARED_EXPORT LIBSHARED_DEPRECATED +#endif + +#ifndef LIBSHARED_DEPRECATED_NO_EXPORT +# define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSHARED_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/reference/WinEmpty/libstatic_export.h b/Tests/Module/GenerateExportHeader/reference/WinEmpty/libstatic_export.h new file mode 100644 index 0000000..e8000e2 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/reference/WinEmpty/libstatic_export.h @@ -0,0 +1,41 @@ + +#ifndef LIBSTATIC_EXPORT_H +#define LIBSTATIC_EXPORT_H + +#ifdef LIBSTATIC_STATIC_DEFINE +# define LIBSTATIC_EXPORT +# define LIBSTATIC_NO_EXPORT +#else +# ifndef LIBSTATIC_EXPORT +# ifdef libstatic_EXPORTS + /* We are building this library */ +# define LIBSTATIC_EXPORT +# else + /* We are using this library */ +# define LIBSTATIC_EXPORT +# endif +# endif + +# ifndef LIBSTATIC_NO_EXPORT +# define LIBSTATIC_NO_EXPORT +# endif +#endif + +#ifndef LIBSTATIC_DEPRECATED +# define LIBSTATIC_DEPRECATED +#endif + +#ifndef LIBSTATIC_DEPRECATED_EXPORT +# define LIBSTATIC_DEPRECATED_EXPORT LIBSTATIC_EXPORT LIBSTATIC_DEPRECATED +#endif + +#ifndef LIBSTATIC_DEPRECATED_NO_EXPORT +# define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED +#endif + +#define DEFINE_NO_DEPRECATED 0 +#if DEFINE_NO_DEPRECATED +# define LIBSTATIC_NO_DEPRECATED +#endif + +#endif diff --git a/Tests/Module/GenerateExportHeader/visibility_preset/CMakeLists.txt b/Tests/Module/GenerateExportHeader/visibility_preset/CMakeLists.txt deleted file mode 100644 index 2571d22..0000000 --- a/Tests/Module/GenerateExportHeader/visibility_preset/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ - -set(CMAKE_CXX_VISIBILITY_PRESET hidden) -set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) - -if (CMAKE_CXX_FLAGS MATCHES "-fvisibility=hidden") - message(SEND_ERROR "Do not use add_compiler_export_flags before adding this directory") -endif() -if (CMAKE_CXX_FLAGS MATCHES "-fvisibility-inlines-hidden") - message(SEND_ERROR "Do not use add_compiler_export_flags before adding this directory") -endif() - -add_library(visibility_preset SHARED visibility_preset.cpp) -generate_export_header(visibility_preset) - -add_executable(visibility_preset_exe main.cpp) - -target_link_libraries(visibility_preset_exe visibility_preset) diff --git a/Tests/Module/GenerateExportHeader/visibility_preset/main.cpp b/Tests/Module/GenerateExportHeader/visibility_preset/main.cpp deleted file mode 100644 index 89c3977..0000000 --- a/Tests/Module/GenerateExportHeader/visibility_preset/main.cpp +++ /dev/null @@ -1,9 +0,0 @@ - -#include "visibility_preset.h" - -int main() -{ - VisibilityPreset vp; - vp.someMethod(); - return 0; -} diff --git a/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.cpp b/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.cpp deleted file mode 100644 index c97dec6..0000000 --- a/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.cpp +++ /dev/null @@ -1,7 +0,0 @@ - -#include "visibility_preset.h" - -void VisibilityPreset::someMethod() -{ - -} diff --git a/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.h b/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.h deleted file mode 100644 index 8becbe1..0000000 --- a/Tests/Module/GenerateExportHeader/visibility_preset/visibility_preset.h +++ /dev/null @@ -1,13 +0,0 @@ - -#ifndef VISIBILITY_PRESET_H -#define VISIBILITY_PRESET_H - -#include "visibility_preset_export.h" - -class VISIBILITY_PRESET_EXPORT VisibilityPreset -{ -public: - void someMethod(); -}; - -#endif diff --git a/Tests/RunCMake/interface_library/RunCMakeTest.cmake b/Tests/RunCMake/interface_library/RunCMakeTest.cmake index e257fb3..0d00b71 100644 --- a/Tests/RunCMake/interface_library/RunCMakeTest.cmake +++ b/Tests/RunCMake/interface_library/RunCMakeTest.cmake @@ -4,3 +4,4 @@ run_cmake(invalid_name) run_cmake(target_commands) run_cmake(no_shared_libs) run_cmake(whitelist) +run_cmake(genex_link) diff --git a/Tests/RunCMake/interface_library/genex_link-result.txt b/Tests/RunCMake/interface_library/genex_link-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/interface_library/genex_link-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/interface_library/genex_link-stderr.txt b/Tests/RunCMake/interface_library/genex_link-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/interface_library/genex_link-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/interface_library/genex_link.cmake b/Tests/RunCMake/interface_library/genex_link.cmake new file mode 100644 index 0000000..0dbf029 --- /dev/null +++ b/Tests/RunCMake/interface_library/genex_link.cmake @@ -0,0 +1,22 @@ + +cmake_minimum_required(VERSION 2.8.12.20131125 FATAL_ERROR) + +project(genex_link) + +set(_main_cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp) +file(WRITE ${_main_cpp} + "int main(int argc, char** argv) { return 0; }\n" +) + +add_library(foo::bar INTERFACE IMPORTED) +set_target_properties(foo::bar + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}" + # When not using a generator expression here, no error is generated + INTERFACE_LINK_LIBRARIES "$<$<NOT:$<CONFIG:DEBUG>>:foo_bar.lib>" +) + +add_executable(main ${_main_cpp}) +target_include_directories(main PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") + +target_link_libraries(main foo::bar) diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c index a4dc710..c7c808f 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c @@ -2412,9 +2412,10 @@ tar_atol(const char *p, size_t char_cnt) static int64_t tar_atol_base_n(const char *p, size_t char_cnt, int base) { - int64_t l, limit, last_digit_limit; + int64_t l, maxval, limit, last_digit_limit; int digit, sign; + maxval = INT64_MAX; limit = INT64_MAX / base; last_digit_limit = INT64_MAX % base; @@ -2431,6 +2432,10 @@ tar_atol_base_n(const char *p, size_t char_cnt, int base) sign = -1; p++; char_cnt--; + + maxval = INT64_MIN; + limit = -(INT64_MIN / base); + last_digit_limit = INT64_MIN % base; } l = 0; @@ -2438,8 +2443,7 @@ tar_atol_base_n(const char *p, size_t char_cnt, int base) digit = *p - '0'; while (digit >= 0 && digit < base && char_cnt != 0) { if (l>limit || (l == limit && digit > last_digit_limit)) { - l = INT64_MAX; /* Truncate on overflow. */ - break; + return maxval; /* Truncate on overflow. */ } l = (l * base) + digit; digit = *++p - '0'; @@ -2462,32 +2466,56 @@ tar_atol10(const char *p, size_t char_cnt) } /* - * Parse a base-256 integer. This is just a straight signed binary - * value in big-endian order, except that the high-order bit is - * ignored. + * Parse a base-256 integer. This is just a variable-length + * twos-complement signed binary value in big-endian order, except + * that the high-order bit is ignored. The values here can be up to + * 12 bytes, so we need to be careful about overflowing 64-bit + * (8-byte) integers. + * + * This code unashamedly assumes that the local machine uses 8-bit + * bytes and twos-complement arithmetic. */ static int64_t tar_atol256(const char *_p, size_t char_cnt) { - int64_t l, upper_limit, lower_limit; + uint64_t l; const unsigned char *p = (const unsigned char *)_p; + unsigned char c, neg; + + /* Extend 7-bit 2s-comp to 8-bit 2s-comp, decide sign. */ + c = *p; + if (c & 0x40) { + neg = 0xff; + c |= 0x80; + l = ~ARCHIVE_LITERAL_ULL(0); + } else { + neg = 0; + c &= 0x7f; + l = 0; + } - upper_limit = INT64_MAX / 256; - lower_limit = INT64_MIN / 256; + /* If more than 8 bytes, check that we can ignore + * high-order bits without overflow. */ + while (char_cnt > sizeof(int64_t)) { + --char_cnt; + if (c != neg) + return neg ? INT64_MIN : INT64_MAX; + c = *++p; + } - /* Sign-extend the 7-bit value to 64 bits. */ - if ((0x40 & *p) == 0x40) - l = ~((int64_t)0x3f) | *p++; - else - l = 0x3f & *p++; + /* c is first byte that fits; if sign mismatch, return overflow */ + if ((c ^ neg) & 0x80) { + return neg ? INT64_MIN : INT64_MAX; + } + + /* Accumulate remaining bytes. */ while (--char_cnt > 0) { - if (l > upper_limit) - return (INT64_MAX); /* Truncate on overflow */ - else if (l < lower_limit) - return (INT64_MIN); - l = (l << 8) | (0xff & (int64_t)*p++); + l = (l << 8) | c; + c = *++p; } - return (l); + l = (l << 8) | c; + /* Return signed twos-complement value. */ + return (int64_t)(l); } /* |