diff options
Diffstat (limited to 'Source')
26 files changed, 522 insertions, 282 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 737087f..ea6e0e2 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 8) -set(CMake_VERSION_PATCH 20170420) +set(CMake_VERSION_PATCH 20170421) #set(CMake_VERSION_RC 1) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 80e7e7d..b273443 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -500,7 +500,10 @@ bool cmComputeLinkInformation::Compute() cmGeneratorTarget const* tgt = *i; bool implib = (this->UseImportLibrary && (tgt->GetType() == cmStateEnums::SHARED_LIBRARY)); - std::string lib = tgt->GetFullPath(this->Config, implib, true); + cmStateEnums::ArtifactType artifact = implib + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; + std::string lib = tgt->GetFullPath(this->Config, artifact, true); this->OldLinkDirItems.push_back(lib); } } @@ -596,8 +599,11 @@ void cmComputeLinkInformation::AddItem(std::string const& item, // platform. Add it now. std::string linkItem; linkItem = this->LoaderFlag; + cmStateEnums::ArtifactType artifact = this->UseImportLibrary + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; - std::string exe = tgt->GetFullPath(config, this->UseImportLibrary, true); + std::string exe = tgt->GetFullPath(config, artifact, true); linkItem += exe; this->Items.push_back(Item(linkItem, true, tgt)); this->Depends.push_back(exe); @@ -617,9 +623,12 @@ void cmComputeLinkInformation::AddItem(std::string const& item, bool implib = (this->UseImportLibrary && (impexe || tgt->GetType() == cmStateEnums::SHARED_LIBRARY)); + cmStateEnums::ArtifactType artifact = implib + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; // Pass the full path to the target file. - std::string lib = tgt->GetFullPath(config, implib, true); + std::string lib = tgt->GetFullPath(config, artifact, true); if (!this->LinkDependsNoShared || tgt->GetType() != cmStateEnums::SHARED_LIBRARY) { this->Depends.push_back(lib); @@ -689,7 +698,10 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, // linked will be able to find it. std::string lib; if (tgt) { - lib = tgt->GetFullPath(this->Config, this->UseImportLibrary); + cmStateEnums::ArtifactType artifact = this->UseImportLibrary + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; + lib = tgt->GetFullPath(this->Config, artifact); this->AddLibraryRuntimeInfo(lib, tgt); } else { lib = item; diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 978a7a1..a1c424a 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -200,9 +200,11 @@ void cmExportBuildFileGenerator::SetImportLocationProperty( prop += suffix; std::string value; if (target->IsAppBundleOnApple()) { - value = target->GetFullPath(config, false); + value = + target->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact); } else { - value = target->GetFullPath(config, false, true); + value = target->GetFullPath(config, + cmStateEnums::RuntimeBinaryArtifact, true); } properties[prop] = value; } @@ -212,7 +214,8 @@ void cmExportBuildFileGenerator::SetImportLocationProperty( mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) { std::string prop = "IMPORTED_IMPLIB"; prop += suffix; - std::string value = target->GetFullPath(config, true); + std::string value = + target->GetFullPath(config, cmStateEnums::ImportLibraryArtifact); target->GetImplibGNUtoMS(value, value, "${CMAKE_IMPORT_LIBRARY_SUFFIX}"); properties[prop] = value; } diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 77a4962..e065a74 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1607,7 +1607,10 @@ struct TargetFilesystemArtifactResultCreator<ArtifactLinkerTag> "executables with ENABLE_EXPORTS."); return std::string(); } - return target->GetFullPath(context->Config, target->HasImportLibrary()); + cmStateEnums::ArtifactType artifact = target->HasImportLibrary() + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; + return target->GetFullPath(context->Config, artifact); } }; @@ -1668,7 +1671,8 @@ struct TargetFilesystemArtifactResultCreator<ArtifactNameTag> cmGeneratorExpressionContext* context, const GeneratorExpressionContent* /*unused*/) { - return target->GetFullPath(context->Config, false, true); + return target->GetFullPath(context->Config, + cmStateEnums::RuntimeBinaryArtifact, true); } }; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2799505..1d6e7fe 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -216,52 +216,60 @@ const char* cmGeneratorTarget::GetProperty(const std::string& prop) const return this->Target->GetProperty(prop); } -const char* cmGeneratorTarget::GetOutputTargetType(bool implib) const +const char* cmGeneratorTarget::GetOutputTargetType( + cmStateEnums::ArtifactType artifact) const { switch (this->GetType()) { case cmStateEnums::SHARED_LIBRARY: if (this->IsDLLPlatform()) { - if (implib) { - // A DLL import library is treated as an archive target. - return "ARCHIVE"; + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + // A DLL shared library is treated as a runtime target. + return "RUNTIME"; + case cmStateEnums::ImportLibraryArtifact: + // A DLL import library is treated as an archive target. + return "ARCHIVE"; } - // A DLL shared library is treated as a runtime target. - return "RUNTIME"; } else { // For non-DLL platforms shared libraries are treated as // library targets. return "LIBRARY"; } + break; case cmStateEnums::STATIC_LIBRARY: // Static libraries are always treated as archive targets. return "ARCHIVE"; case cmStateEnums::MODULE_LIBRARY: - if (implib) { - // Module libraries are always treated as library targets. - return "ARCHIVE"; - } else { - // Module import libraries are treated as archive targets. - return "LIBRARY"; + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + // Module import libraries are treated as archive targets. + return "LIBRARY"; + case cmStateEnums::ImportLibraryArtifact: + // Module libraries are always treated as library targets. + return "ARCHIVE"; } + break; case cmStateEnums::EXECUTABLE: - if (implib) { - // Executable import libraries are treated as archive targets. - return "ARCHIVE"; - } else { - // Executables are always treated as runtime targets. - return "RUNTIME"; + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + // Executables are always treated as runtime targets. + return "RUNTIME"; + case cmStateEnums::ImportLibraryArtifact: + // Executable import libraries are treated as archive targets. + return "ARCHIVE"; } + break; default: break; } return ""; } -std::string cmGeneratorTarget::GetOutputName(const std::string& config, - bool implib) const +std::string cmGeneratorTarget::GetOutputName( + const std::string& config, cmStateEnums::ArtifactType artifact) const { // Lookup/compute/cache the output name for this configuration. - OutputNameKey key(config, implib); + OutputNameKey key(config, artifact); cmGeneratorTarget::OutputNameMapType::iterator i = this->OutputNameMap.find(key); if (i == this->OutputNameMap.end()) { @@ -271,7 +279,7 @@ std::string cmGeneratorTarget::GetOutputName(const std::string& config, // Compute output name. std::vector<std::string> props; - std::string type = this->GetOutputTargetType(implib); + std::string type = this->GetOutputTargetType(artifact); std::string configUpper = cmSystemTools::UpperCase(config); if (!type.empty() && !configUpper.empty()) { // <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME_<CONFIG> @@ -641,9 +649,10 @@ const char* cmGeneratorTarget::GetLocation(const std::string& config) const { static std::string location; if (this->IsImported()) { - location = this->Target->ImportedGetFullPath(config, false); + location = this->Target->ImportedGetFullPath( + config, cmStateEnums::RuntimeBinaryArtifact); } else { - location = this->GetFullPath(config, false); + location = this->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact); } return location.c_str(); } @@ -680,7 +689,8 @@ const char* cmGeneratorTarget::GetLocationForBuild() const { static std::string location; if (this->IsImported()) { - location = this->Target->ImportedGetFullPath("", false); + location = this->Target->ImportedGetFullPath( + "", cmStateEnums::RuntimeBinaryArtifact); return location.c_str(); } @@ -700,7 +710,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const } } location += "/"; - location += this->GetFullName("", false); + location += this->GetFullName("", cmStateEnums::RuntimeBinaryArtifact); return location.c_str(); } @@ -1145,7 +1155,8 @@ std::string cmGeneratorTarget::GetCompilePDBName( std::string prefix; std::string base; std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, + prefix, base, suffix); // Check for a per-configuration output directory target property. std::string configUpper = cmSystemTools::UpperCase(config); @@ -1506,7 +1517,8 @@ static bool shouldAddContentLevel( std::string cmGeneratorTarget::GetAppBundleDirectory( const std::string& config, BundleDirectoryLevel level) const { - std::string fpath = this->GetFullName(config, false); + std::string fpath = + this->GetFullName(config, cmStateEnums::RuntimeBinaryArtifact); fpath += "."; const char* ext = this->GetProperty("BUNDLE_EXTENSION"); if (!ext) { @@ -1532,7 +1544,7 @@ std::string cmGeneratorTarget::GetCFBundleDirectory( const std::string& config, BundleDirectoryLevel level) const { std::string fpath; - fpath += this->GetOutputName(config, false); + fpath += this->GetOutputName(config, cmStateEnums::RuntimeBinaryArtifact); fpath += "."; const char* ext = this->GetProperty("BUNDLE_EXTENSION"); if (!ext) { @@ -1556,7 +1568,7 @@ std::string cmGeneratorTarget::GetFrameworkDirectory( const std::string& config, BundleDirectoryLevel level) const { std::string fpath; - fpath += this->GetOutputName(config, false); + fpath += this->GetOutputName(config, cmStateEnums::RuntimeBinaryArtifact); fpath += "."; const char* ext = this->GetProperty("BUNDLE_EXTENSION"); if (!ext) { @@ -1570,13 +1582,13 @@ std::string cmGeneratorTarget::GetFrameworkDirectory( return fpath; } -std::string cmGeneratorTarget::GetFullName(const std::string& config, - bool implib) const +std::string cmGeneratorTarget::GetFullName( + const std::string& config, cmStateEnums::ArtifactType artifact) const { if (this->IsImported()) { - return this->GetFullNameImported(config, implib); + return this->GetFullNameImported(config, artifact); } - return this->GetFullNameInternal(config, implib); + return this->GetFullNameInternal(config, artifact); } std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( @@ -1869,13 +1881,11 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, } } -void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, - std::string& base, - std::string& suffix, - const std::string& config, - bool implib) const +void cmGeneratorTarget::GetFullNameComponents( + std::string& prefix, std::string& base, std::string& suffix, + const std::string& config, cmStateEnums::ArtifactType artifact) const { - this->GetFullNameInternal(config, implib, prefix, base, suffix); + this->GetFullNameInternal(config, artifact, prefix, base, suffix); } std::string cmGeneratorTarget::BuildBundleDirectory( @@ -1896,10 +1906,10 @@ std::string cmGeneratorTarget::BuildBundleDirectory( } std::string cmGeneratorTarget::GetMacContentDirectory( - const std::string& config, bool implib) const + const std::string& config, cmStateEnums::ArtifactType artifact) const { // Start with the output directory for the target. - std::string fpath = this->GetDirectory(config, implib); + std::string fpath = this->GetDirectory(config, artifact); fpath += "/"; BundleDirectoryLevel level = ContentLevel; if (this->IsFrameworkOnApple()) { @@ -2860,7 +2870,8 @@ void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const } // Get the directory. - std::string dir = this->GetDirectory(config, false); + std::string dir = + this->GetDirectory(config, cmStateEnums::RuntimeBinaryArtifact); // Add each name. std::string f; @@ -2889,7 +2900,7 @@ void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const gg->AddToManifest(f); } if (!impName.empty()) { - f = this->GetDirectory(config, true); + f = this->GetDirectory(config, cmStateEnums::ImportLibraryArtifact); f += "/"; f += impName; gg->AddToManifest(f); @@ -2907,19 +2918,20 @@ std::string cmGeneratorTarget::GetImportedLibName( } std::string cmGeneratorTarget::GetFullPath(const std::string& config, - bool implib, bool realname) const + cmStateEnums::ArtifactType artifact, + bool realname) const { if (this->IsImported()) { - return this->Target->ImportedGetFullPath(config, implib); + return this->Target->ImportedGetFullPath(config, artifact); } - return this->NormalGetFullPath(config, implib, realname); + return this->NormalGetFullPath(config, artifact, realname); } -std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, - bool implib, - bool realname) const +std::string cmGeneratorTarget::NormalGetFullPath( + const std::string& config, cmStateEnums::ArtifactType artifact, + bool realname) const { - std::string fpath = this->GetDirectory(config, implib); + std::string fpath = this->GetDirectory(config, artifact); fpath += "/"; if (this->IsAppBundleOnApple()) { fpath = this->BuildBundleDirectory(fpath, config, FullLevel); @@ -2927,12 +2939,18 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, } // Add the full name of the target. - if (implib) { - fpath += this->GetFullName(config, true); - } else if (realname) { - fpath += this->NormalGetRealName(config); - } else { - fpath += this->GetFullName(config, false); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + if (realname) { + fpath += this->NormalGetRealName(config); + } else { + fpath += + this->GetFullName(config, cmStateEnums::RuntimeBinaryArtifact); + } + break; + case cmStateEnums::ImportLibraryArtifact: + fpath += this->GetFullName(config, cmStateEnums::ImportLibraryArtifact); + break; } return fpath; } @@ -3009,7 +3027,8 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName, std::string prefix; std::string base; std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, + prefix, base, suffix); // The library name. name = prefix + base + suffix; @@ -3034,7 +3053,8 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName, // The import library name. if (this->GetType() == cmStateEnums::SHARED_LIBRARY || this->GetType() == cmStateEnums::MODULE_LIBRARY) { - impName = this->GetFullNameInternal(config, true); + impName = + this->GetFullNameInternal(config, cmStateEnums::ImportLibraryArtifact); } else { impName = ""; } @@ -3075,7 +3095,8 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, + prefix, base, suffix); // The executable name. name = prefix + base + suffix; @@ -3095,19 +3116,20 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, #endif // The import library name. - impName = this->GetFullNameInternal(config, true); + impName = + this->GetFullNameInternal(config, cmStateEnums::ImportLibraryArtifact); // The program database file name. pdbName = this->GetPDBName(config); } -std::string cmGeneratorTarget::GetFullNameInternal(const std::string& config, - bool implib) const +std::string cmGeneratorTarget::GetFullNameInternal( + const std::string& config, cmStateEnums::ArtifactType artifact) const { std::string prefix; std::string base; std::string suffix; - this->GetFullNameInternal(config, implib, prefix, base, suffix); + this->GetFullNameInternal(config, artifact, prefix, base, suffix); return prefix + base + suffix; } @@ -3116,22 +3138,21 @@ const char* cmGeneratorTarget::ImportedGetLocation( { static std::string location; assert(this->IsImported()); - location = this->Target->ImportedGetFullPath(config, false); + location = this->Target->ImportedGetFullPath( + config, cmStateEnums::RuntimeBinaryArtifact); return location.c_str(); } -std::string cmGeneratorTarget::GetFullNameImported(const std::string& config, - bool implib) const +std::string cmGeneratorTarget::GetFullNameImported( + const std::string& config, cmStateEnums::ArtifactType artifact) const { return cmSystemTools::GetFilenameName( - this->Target->ImportedGetFullPath(config, implib)); + this->Target->ImportedGetFullPath(config, artifact)); } -void cmGeneratorTarget::GetFullNameInternal(const std::string& config, - bool implib, - std::string& outPrefix, - std::string& outBase, - std::string& outSuffix) const +void cmGeneratorTarget::GetFullNameInternal( + const std::string& config, cmStateEnums::ArtifactType artifact, + std::string& outPrefix, std::string& outBase, std::string& outSuffix) const { // Use just the target name for non-main target types. if (this->GetType() != cmStateEnums::STATIC_LIBRARY && @@ -3144,9 +3165,12 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, return; } + const bool isImportedLibraryArtifact = + (artifact == cmStateEnums::ImportLibraryArtifact); + // Return an empty name for the import library if this platform // does not support import libraries. - if (implib && + if (isImportedLibraryArtifact && !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) { outPrefix = ""; outBase = ""; @@ -3159,14 +3183,16 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, if (this->GetType() != cmStateEnums::SHARED_LIBRARY && this->GetType() != cmStateEnums::MODULE_LIBRARY && this->GetType() != cmStateEnums::EXECUTABLE) { - implib = false; + artifact = cmStateEnums::RuntimeBinaryArtifact; } // Compute the full name for main target types. - const char* targetPrefix = (implib ? this->GetProperty("IMPORT_PREFIX") - : this->GetProperty("PREFIX")); - const char* targetSuffix = (implib ? this->GetProperty("IMPORT_SUFFIX") - : this->GetProperty("SUFFIX")); + const char* targetPrefix = + (isImportedLibraryArtifact ? this->GetProperty("IMPORT_PREFIX") + : this->GetProperty("PREFIX")); + const char* targetSuffix = + (isImportedLibraryArtifact ? this->GetProperty("IMPORT_SUFFIX") + : this->GetProperty("SUFFIX")); const char* configPostfix = CM_NULLPTR; if (!config.empty()) { std::string configProp = cmSystemTools::UpperCase(config); @@ -3178,8 +3204,8 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, configPostfix = CM_NULLPTR; } } - const char* prefixVar = this->Target->GetPrefixVariableInternal(implib); - const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); + const char* prefixVar = this->Target->GetPrefixVariableInternal(artifact); + const char* suffixVar = this->Target->GetSuffixVariableInternal(artifact); // Check for language-specific default prefix and suffix. std::string ll = this->GetLinkerLanguage(config); @@ -3223,14 +3249,15 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, outPrefix = targetPrefix ? targetPrefix : ""; // Append the target name or property-specified name. - outBase += this->GetOutputName(config, implib); + outBase += this->GetOutputName(config, artifact); // Append the per-configuration postfix. outBase += configPostfix ? configPostfix : ""; // Name shared libraries with their version number on some platforms. if (const char* soversion = this->GetProperty("SOVERSION")) { - if (this->GetType() == cmStateEnums::SHARED_LIBRARY && !implib && + if (this->GetType() == cmStateEnums::SHARED_LIBRARY && + !isImportedLibraryArtifact && this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) { outBase += "-"; outBase += soversion; @@ -3252,7 +3279,8 @@ std::string cmGeneratorTarget::GetPDBName(const std::string& config) const std::string prefix; std::string base; std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, + prefix, base, suffix); std::vector<std::string> props; std::string configUpper = cmSystemTools::UpperCase(config); @@ -4404,26 +4432,31 @@ const cmLinkInterfaceLibraries* cmGeneratorTarget::GetLinkInterfaceLibraries( return iface.Exists ? &iface : CM_NULLPTR; } -std::string cmGeneratorTarget::GetDirectory(const std::string& config, - bool implib) const +std::string cmGeneratorTarget::GetDirectory( + const std::string& config, cmStateEnums::ArtifactType artifact) const { if (this->IsImported()) { // Return the directory from which the target is imported. return cmSystemTools::GetFilenamePath( - this->Target->ImportedGetFullPath(config, implib)); + this->Target->ImportedGetFullPath(config, artifact)); } if (OutputInfo const* info = this->GetOutputInfo(config)) { // Return the directory in which the target will be built. - return implib ? info->ImpDir : info->OutDir; + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + return info->OutDir; + case cmStateEnums::ImportLibraryArtifact: + return info->ImpDir; + } } return ""; } -bool cmGeneratorTarget::UsesDefaultOutputDir(const std::string& config, - bool implib) const +bool cmGeneratorTarget::UsesDefaultOutputDir( + const std::string& config, cmStateEnums::ArtifactType artifact) const { std::string dir; - return this->ComputeOutputDir(config, implib, dir); + return this->ComputeOutputDir(config, artifact, dir); } cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo( @@ -4457,8 +4490,10 @@ cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo( i = this->OutputInfoMap.insert(entry).first; // Compute output directories. - this->ComputeOutputDir(config, false, info.OutDir); - this->ComputeOutputDir(config, true, info.ImpDir); + this->ComputeOutputDir(config, cmStateEnums::RuntimeBinaryArtifact, + info.OutDir); + this->ComputeOutputDir(config, cmStateEnums::ImportLibraryArtifact, + info.ImpDir); if (!this->ComputePDBOutputDir("PDB", config, info.PdbDir)) { info.PdbDir = info.OutDir; } @@ -4478,14 +4513,15 @@ cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo( } bool cmGeneratorTarget::ComputeOutputDir(const std::string& config, - bool implib, std::string& out) const + cmStateEnums::ArtifactType artifact, + std::string& out) const { bool usesDefaultOutputDir = false; std::string conf = config; // Look for a target property defining the target output directory // based on the target type. - std::string targetTypeName = this->GetOutputTargetType(implib); + std::string targetTypeName = this->GetOutputTargetType(artifact); const char* propertyName = CM_NULLPTR; std::string propertyNameStr = targetTypeName; if (!propertyNameStr.empty()) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 5b903de..3a0d23f 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -203,9 +203,12 @@ public: /** Get the full path to the target according to the settings in its makefile and the configuration type. */ - std::string GetFullPath(const std::string& config = "", bool implib = false, - bool realname = false) const; - std::string NormalGetFullPath(const std::string& config, bool implib, + std::string GetFullPath( + const std::string& config = "", + cmStateEnums::ArtifactType artifact = cmStateEnums::RuntimeBinaryArtifact, + bool realname = false) const; + std::string NormalGetFullPath(const std::string& config, + cmStateEnums::ArtifactType artifact, bool realname) const; std::string NormalGetRealName(const std::string& config) const; @@ -233,7 +236,8 @@ public: /** Get the full name of the target according to the settings in its makefile. */ std::string GetFullName(const std::string& config = "", - bool implib = false) const; + cmStateEnums::ArtifactType artifact = + cmStateEnums::RuntimeBinaryArtifact) const; /** @return the Mac framework directory without the base. */ std::string GetFrameworkDirectory(const std::string& config, @@ -278,7 +282,8 @@ public: void GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, const std::string& config = "", - bool implib = false) const; + cmStateEnums::ArtifactType artifact = + cmStateEnums::RuntimeBinaryArtifact) const; /** Append to @a base the bundle directory hierarchy up to a certain @a level * and return it. */ @@ -287,8 +292,8 @@ public: BundleDirectoryLevel level) const; /** @return the mac content directory for this target. */ - std::string GetMacContentDirectory(const std::string& config = CM_NULLPTR, - bool implib = false) const; + std::string GetMacContentDirectory( + const std::string& config, cmStateEnums::ArtifactType artifact) const; /** @return folder prefix for IDEs. */ std::string GetEffectiveFolderName() const; @@ -355,7 +360,7 @@ public: std::vector<cmGeneratorTarget*>& objlibs) const; std::string GetFullNameImported(const std::string& config, - bool implib) const; + cmStateEnums::ArtifactType artifact) const; /** Get source files common to all configurations and diagnose cases with per-config sources. Excludes sources added by a TARGET_OBJECTS @@ -415,7 +420,8 @@ public: subdirectory for that configuration. Otherwise just the canonical output directory is given. */ std::string GetDirectory(const std::string& config = "", - bool implib = false) const; + cmStateEnums::ArtifactType artifact = + cmStateEnums::RuntimeBinaryArtifact) const; /** Get the directory in which to place the target compiler .pdb file. If the configuration name is given then the generator will add its @@ -429,7 +435,8 @@ public: /** Return whether this target uses the default value for its output directory. */ - bool UsesDefaultOutputDir(const std::string& config, bool implib) const; + bool UsesDefaultOutputDir(const std::string& config, + cmStateEnums::ArtifactType artifact) const; // Cache target output paths for each configuration. struct OutputInfo @@ -470,7 +477,8 @@ public: std::string GetCompilePDBPath(const std::string& config = "") const; // Get the target base name. - std::string GetOutputName(const std::string& config, bool implib) const; + std::string GetOutputName(const std::string& config, + cmStateEnums::ArtifactType artifact) const; void AddSource(const std::string& src); void AddTracedSources(std::vector<std::string> const& srcs); @@ -653,8 +661,9 @@ private: mutable std::map<std::string, bool> DebugCompatiblePropertiesDone; std::string GetFullNameInternal(const std::string& config, - bool implib) const; - void GetFullNameInternal(const std::string& config, bool implib, + cmStateEnums::ArtifactType artifact) const; + void GetFullNameInternal(const std::string& config, + cmStateEnums::ArtifactType artifact, std::string& outPrefix, std::string& outBase, std::string& outSuffix) const; @@ -662,7 +671,7 @@ private: mutable LinkClosureMapType LinkClosureMap; // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. - const char* GetOutputTargetType(bool implib) const; + const char* GetOutputTargetType(cmStateEnums::ArtifactType artifact) const; void ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, std::string const& suffix, @@ -788,7 +797,8 @@ private: cmLinkImplementationLibraries const* GetLinkImplementationLibrariesInternal( const std::string& config, const cmGeneratorTarget* head) const; - bool ComputeOutputDir(const std::string& config, bool implib, + bool ComputeOutputDir(const std::string& config, + cmStateEnums::ArtifactType artifact, std::string& out) const; typedef std::map<std::string, OutputInfo> OutputInfoMapType; @@ -800,7 +810,7 @@ private: void ComputeModuleDefinitionInfo(std::string const& config, ModuleDefinitionInfo& info) const; - typedef std::pair<std::string, bool> OutputNameKey; + typedef std::pair<std::string, cmStateEnums::ArtifactType> OutputNameKey; typedef std::map<OutputNameKey, std::string> OutputNameMapType; mutable OutputNameMapType OutputNameMap; mutable std::set<cmLinkItem> UtilityItems; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index aae01ca..e61cbd9 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -246,7 +246,7 @@ void cmGlobalNinjaGenerator::WriteBuild( bool useResponseFile = false; if (cmdLineLimit < 0 || (cmdLineLimit > 0 && - (args.size() + buildstr.size() + assignments.size()) > + (args.size() + buildstr.size() + assignments.size() + 1000) > static_cast<size_t>(cmdLineLimit))) { variable_assignments.str(std::string()); cmGlobalNinjaGenerator::WriteVariable(variable_assignments, "RSP_FILE", @@ -983,8 +983,8 @@ void cmGlobalNinjaGenerator::AppendTargetOutputs( case cmStateEnums::SHARED_LIBRARY: case cmStateEnums::STATIC_LIBRARY: case cmStateEnums::MODULE_LIBRARY: { - outputs.push_back(this->ConvertToNinjaPath( - target->GetFullPath(configName, false, realname))); + outputs.push_back(this->ConvertToNinjaPath(target->GetFullPath( + configName, cmStateEnums::RuntimeBinaryArtifact, realname))); break; } case cmStateEnums::OBJECT_LIBRARY: diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 8c1c0e7..4213751 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1817,7 +1817,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, gtgt->GetType() == cmStateEnums::MODULE_LIBRARY || gtgt->GetType() == cmStateEnums::EXECUTABLE) { if (this->XcodeVersion >= 21) { - if (!gtgt->UsesDefaultOutputDir(configName, false)) { + if (!gtgt->UsesDefaultOutputDir(configName, + cmStateEnums::RuntimeBinaryArtifact)) { std::string pncdir = gtgt->GetDirectory(configName); buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR", this->CreateString(pncdir)); @@ -2009,6 +2010,10 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, BuildObjectListOrString dirs(this, this->XcodeVersion >= 30); BuildObjectListOrString fdirs(this, this->XcodeVersion >= 30); + BuildObjectListOrString sysdirs(this, this->XcodeVersion >= 30); + BuildObjectListOrString sysfdirs(this, this->XcodeVersion >= 30); + const bool emitSystemIncludes = this->XcodeVersion >= 83; + std::vector<std::string> includes; this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt, "C", configName); @@ -2022,11 +2027,22 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, frameworkDir += "/../"; frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir); if (emitted.insert(frameworkDir).second) { - fdirs.Add(this->XCodeEscapePath(frameworkDir)); + std::string incpath = this->XCodeEscapePath(frameworkDir); + if (emitSystemIncludes && + gtgt->IsSystemIncludeDirectory(frameworkDir, configName)) { + sysfdirs.Add(incpath); + } else { + fdirs.Add(incpath); + } } } else { std::string incpath = this->XCodeEscapePath(*i); - dirs.Add(incpath); + if (emitSystemIncludes && + gtgt->IsSystemIncludeDirectory(*i, configName)) { + sysdirs.Add(incpath); + } else { + dirs.Add(incpath); + } } } // Add framework search paths needed for linking. @@ -2035,7 +2051,13 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, for (std::vector<std::string>::const_iterator fdi = fwDirs.begin(); fdi != fwDirs.end(); ++fdi) { if (emitted.insert(*fdi).second) { - fdirs.Add(this->XCodeEscapePath(*fdi)); + std::string incpath = this->XCodeEscapePath(*fdi); + if (emitSystemIncludes && + gtgt->IsSystemIncludeDirectory(*fdi, configName)) { + sysfdirs.Add(incpath); + } else { + fdirs.Add(incpath); + } } } } @@ -2045,8 +2067,16 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, if (!dirs.IsEmpty()) { buildSettings->AddAttribute("HEADER_SEARCH_PATHS", dirs.CreateList()); } + if (!sysfdirs.IsEmpty()) { + buildSettings->AddAttribute("SYSTEM_FRAMEWORK_SEARCH_PATHS", + sysfdirs.CreateList()); + } + if (!sysdirs.IsEmpty()) { + buildSettings->AddAttribute("SYSTEM_HEADER_SEARCH_PATHS", + sysdirs.CreateList()); + } - if (this->XcodeVersion >= 60) { + if (this->XcodeVersion >= 60 && !emitSystemIncludes) { // Add those per-language flags in addition to HEADER_SEARCH_PATHS to gain // system include directory awareness. We need to also keep on setting // HEADER_SEARCH_PATHS to work around a missing compile options flag for diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 6ecf42d..1827ed3 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -103,7 +103,10 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( fromDirConfig += cmake::GetCMakeFilesDirectory(); fromDirConfig += "/CMakeRelink.dir/"; } else { - fromDirConfig = this->Target->GetDirectory(config, this->ImportLibrary); + cmStateEnums::ArtifactType artifact = this->ImportLibrary + ? cmStateEnums::ImportLibraryArtifact + : cmStateEnums::RuntimeBinaryArtifact; + fromDirConfig = this->Target->GetDirectory(config, artifact); fromDirConfig += "/"; } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 7535ef4..f86c034 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1130,7 +1130,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( if (stackVal) { fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"\n"; } - temp = target->GetDirectory(configName, true); + temp = + target->GetDirectory(configName, cmStateEnums::ImportLibraryArtifact); temp += "/"; temp += targetNameImport; fout << "\t\t\t\tImportLibrary=\"" @@ -1227,7 +1228,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( if (stackVal) { fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\""; } - temp = target->GetDirectory(configName, true); + temp = + target->GetDirectory(configName, cmStateEnums::ImportLibraryArtifact); temp += "/"; temp += targetNameImport; fout << "\t\t\t\tImportLibrary=\"" diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index e20fe50..3d7b60b 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -80,8 +80,10 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target, !(isFortran && target->GetType() == cmStateEnums::SHARED_LIBRARY)) { return pcc; } - std::string outDir = target->GetDirectory(config, false); - std::string impDir = target->GetDirectory(config, true); + std::string outDir = + target->GetDirectory(config, cmStateEnums::RuntimeBinaryArtifact); + std::string impDir = + target->GetDirectory(config, cmStateEnums::ImportLibraryArtifact); if (impDir == outDir) { return pcc; } diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 493f474..a93b42d 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -21,6 +21,7 @@ #include "cmState.h" #include "cmStateDirectory.h" #include "cmStateSnapshot.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cm_auto_ptr.hxx" #include "cmake.h" @@ -332,7 +333,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } else { cmSystemTools::MakeDirectory(outpath.c_str()); if (!targetNameImport.empty()) { - outpathImp = this->GeneratorTarget->GetDirectory(this->ConfigName, true); + outpathImp = this->GeneratorTarget->GetDirectory( + this->ConfigName, cmStateEnums::ImportLibraryArtifact); cmSystemTools::MakeDirectory(outpathImp.c_str()); outpathImp += "/"; } diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index cc8a6b3..e017b29 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -514,7 +514,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( cmSystemTools::MakeDirectory(outpath.c_str()); outpath += "/"; if (!targetNameImport.empty()) { - outpathImp = this->GeneratorTarget->GetDirectory(this->ConfigName, true); + outpathImp = this->GeneratorTarget->GetDirectory( + this->ConfigName, cmStateEnums::ImportLibraryArtifact); cmSystemTools::MakeDirectory(outpathImp.c_str()); outpathImp += "/"; } diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index ed38024..7acfb85 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -30,10 +30,6 @@ #include "cm_auto_ptr.hxx" #include "cmake.h" -#ifndef _WIN32 -#include <unistd.h> -#endif - cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target) : cmCommonTargetGenerator(target) , OSXBundleGenerator(CM_NULLPTR) @@ -509,8 +505,8 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY || this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY || this->GeneratorTarget->GetType() == cmStateEnums::MODULE_LIBRARY) { - targetFullPathReal = - this->GeneratorTarget->GetFullPath(this->ConfigName, false, true); + targetFullPathReal = this->GeneratorTarget->GetFullPath( + this->ConfigName, cmStateEnums::RuntimeBinaryArtifact, true); targetFullPathPDB = this->GeneratorTarget->GetPDBDirectory(this->ConfigName); targetFullPathPDB += "/"; @@ -1492,15 +1488,6 @@ void cmMakefileTargetGenerator::CreateLinkScript( makefile_depends.push_back(linkScriptName); } -static size_t calculateCommandLineLengthLimit() -{ -#if defined(_SC_ARG_MAX) - return ((size_t)sysconf(_SC_ARG_MAX)) - 1000; -#else - return 0; -#endif -} - bool cmMakefileTargetGenerator::CheckUseResponseFileForObjects( std::string const& l) const { @@ -1514,7 +1501,7 @@ bool cmMakefileTargetGenerator::CheckUseResponseFileForObjects( } // Check for a system limit. - if (size_t const limit = calculateCommandLineLengthLimit()) { + if (size_t const limit = cmSystemTools::CalculateCommandLineLengthLimit()) { // Compute the total length of our list of object files with room // for argument separation and quoting. This does not convert paths // relative to CMAKE_CURRENT_BINARY_DIR like the final list will be, so the diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index aaeb659..cfc91bd 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -5,11 +5,9 @@ #include <algorithm> #include <assert.h> #include <iterator> -#include <limits> #include <map> #include <set> #include <sstream> -#include <stddef.h> #include "cmAlgorithms.h" #include "cmCustomCommand.h" @@ -35,10 +33,6 @@ #include "cm_auto_ptr.hxx" #include "cmake.h" -#ifndef _WIN32 -#include <unistd.h> -#endif - cmNinjaNormalTargetGenerator::cmNinjaNormalTargetGenerator( cmGeneratorTarget* target) : cmNinjaTargetGenerator(target) @@ -491,10 +485,9 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd() cmGeneratorTarget& gt = *this->GetGeneratorTarget(); const std::string cfgName = this->GetConfigName(); std::string targetOutput = ConvertToNinjaPath(gt.GetFullPath(cfgName)); - std::string targetOutputReal = - this->ConvertToNinjaPath(gt.GetFullPath(cfgName, - /*implib=*/false, - /*realname=*/true)); + std::string targetOutputReal = this->ConvertToNinjaPath( + gt.GetFullPath(cfgName, cmStateEnums::RuntimeBinaryArtifact, + /*realname=*/true)); cmakeCommand += targetOutputReal; cmakeCommand += " || true"; linkCmds.push_back(cmakeCommand); @@ -546,36 +539,6 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd() return std::vector<std::string>(); } -static int calculateCommandLineLengthLimit(int linkRuleLength) -{ - static int const limits[] = { -#ifdef _WIN32 - 8000, -#endif -#if defined(__linux) - // #define MAX_ARG_STRLEN (PAGE_SIZE * 32) in Linux's binfmts.h - ((int)sysconf(_SC_PAGESIZE) * 32) - 1000, -#endif - std::numeric_limits<int>::max() - }; - - size_t const arrSz = cmArraySize(limits); - int sz = *std::min_element(limits, limits + arrSz); -#if defined(_SC_ARG_MAX) - // for instance ARG_MAX is 2096152 on Ubuntu or 262144 on Mac - int const szArgMax = static_cast<int>(sysconf(_SC_ARG_MAX)); - // a return value of -1 signifies an unrestricted value - if (szArgMax != -1) { - sz = std::min(sz, szArgMax - 1000); - } -#endif - if (sz == std::numeric_limits<int>::max()) { - return 0; - } - - return sz - linkRuleLength; -} - void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement() { cmGeneratorTarget& genTarget = *this->GetGeneratorTarget(); @@ -616,9 +579,8 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement() std::string const targetOutputReal = ConvertToNinjaPath( genTarget.ObjectDirectory + "cmake_device_link" + objExt); - std::string const targetOutputImplib = - ConvertToNinjaPath(genTarget.GetFullPath(cfgName, - /*implib=*/true)); + std::string const targetOutputImplib = ConvertToNinjaPath( + genTarget.GetFullPath(cfgName, cmStateEnums::ImportLibraryArtifact)); this->DeviceLinkObject = targetOutputReal; @@ -761,8 +723,9 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement() // Device linking currently doesn't support response files so // do not check if the user has explicitly forced a response file. - int const commandLineLengthLimit = calculateCommandLineLengthLimit( - globalGen.GetRuleCmdLength(this->LanguageLinkerDeviceRule())); + int const commandLineLengthLimit = + static_cast<int>(cmSystemTools::CalculateCommandLineLengthLimit()) - + globalGen.GetRuleCmdLength(this->LanguageLinkerDeviceRule()); const std::string rspfile = std::string(cmake::GetCMakeFilesDirectoryPostSlash()) + @@ -788,13 +751,11 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() cmGeneratorTarget& gt = *this->GetGeneratorTarget(); const std::string cfgName = this->GetConfigName(); std::string targetOutput = ConvertToNinjaPath(gt.GetFullPath(cfgName)); - std::string targetOutputReal = - ConvertToNinjaPath(gt.GetFullPath(cfgName, - /*implib=*/false, - /*realname=*/true)); - std::string targetOutputImplib = - ConvertToNinjaPath(gt.GetFullPath(cfgName, - /*implib=*/true)); + std::string targetOutputReal = ConvertToNinjaPath( + gt.GetFullPath(cfgName, cmStateEnums::RuntimeBinaryArtifact, + /*realname=*/true)); + std::string targetOutputImplib = ConvertToNinjaPath( + gt.GetFullPath(cfgName, cmStateEnums::ImportLibraryArtifact)); if (gt.IsAppBundleOnApple()) { // Create the app bundle @@ -1048,8 +1009,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() !(this->TargetLinkLanguage == "RC" || this->TargetLinkLanguage == "CUDA"); int commandLineLengthLimit = -1; if (!lang_supports_response || !this->ForceResponseFile()) { - commandLineLengthLimit = calculateCommandLineLengthLimit( - globalGen.GetRuleCmdLength(this->LanguageLinkerRule())); + commandLineLengthLimit = + static_cast<int>(cmSystemTools::CalculateCommandLineLengthLimit()) - + globalGen.GetRuleCmdLength(this->LanguageLinkerRule()); } const std::string rspfile = diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index c09feef..332fa83 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -7,6 +7,7 @@ #include "cmGeneratorTarget.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" @@ -213,8 +214,8 @@ std::string cmOSXBundleGenerator::InitMacOSXContentDirectory( { // Construct the full path to the content subdirectory. - std::string macdir = this->GT->GetMacContentDirectory(this->ConfigName, - /*implib*/ false); + std::string macdir = this->GT->GetMacContentDirectory( + this->ConfigName, cmStateEnums::RuntimeBinaryArtifact); macdir += "/"; macdir += pkgloc; cmSystemTools::MakeDirectory(macdir.c_str()); diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index 82de9a2..239b18d 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -96,6 +96,41 @@ static std::string GetQtMajorVersion(cmGeneratorTarget const* target) return qtMajorVersion; } +static std::string GetQtMinorVersion(cmGeneratorTarget const* target, + const std::string& qtMajorVersion) +{ + cmMakefile* makefile = target->Target->GetMakefile(); + std::string qtMinorVersion; + if (qtMajorVersion == "5") { + qtMinorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MINOR"); + } + if (qtMinorVersion.empty()) { + qtMinorVersion = makefile->GetSafeDefinition("QT_VERSION_MINOR"); + } + + const char* targetQtVersion = + target->GetLinkInterfaceDependentStringProperty("QT_MINOR_VERSION", ""); + if (targetQtVersion != CM_NULLPTR) { + qtMinorVersion = targetQtVersion; + } + return qtMinorVersion; +} + +static bool QtVersionGreaterOrEqual(const std::string& major, + const std::string& minor, + unsigned long requestMajor, + unsigned long requestMinor) +{ + unsigned long majorUL(0); + unsigned long minorUL(0); + if (cmSystemTools::StringToULong(major.c_str(), &majorUL) && + cmSystemTools::StringToULong(minor.c_str(), &minorUL)) { + return (majorUL > requestMajor) || + (majorUL == requestMajor && minorUL >= requestMinor); + } + return false; +} + static void GetCompileDefinitionsAndDirectories( cmGeneratorTarget const* target, const std::string& config, std::string& incs, std::string& defs) @@ -258,6 +293,12 @@ static void MocSetupAutoTarget( AddDefinitionEscaped(makefile, "_moc_depend_filters", GetSafeProperty(target, "AUTOMOC_DEPEND_FILTERS")); + if (QtVersionGreaterOrEqual( + qtMajorVersion, GetQtMinorVersion(target, qtMajorVersion), 5, 8)) { + AddDefinitionEscaped( + makefile, "_moc_predefs_cmd", + makefile->GetSafeDefinition("CMAKE_CXX_COMPILER_PREDEFINES_COMMAND")); + } // Moc includes and compile definitions { std::string _moc_incs; diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 88ec9e8..d142693 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -360,6 +360,8 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile( InfoGet(makefile, "AM_QT_MOC_EXECUTABLE", this->MocExecutable); InfoGet(makefile, "AM_QT_UIC_EXECUTABLE", this->UicExecutable); InfoGet(makefile, "AM_QT_RCC_EXECUTABLE", this->RccExecutable); + + InfoGet(makefile, "AM_MOC_PREDEFS_CMD", this->MocPredefsCmd); // Check Qt version if ((this->QtMajorVersion != "4") && (this->QtMajorVersion != "5")) { this->LogError("AutoGen: Error: Unsupported Qt version: " + @@ -579,6 +581,12 @@ void cmQtAutoGenerators::Init(cmMakefile* makefile) this->MocCppFilenameAbs = this->CurrentBinaryDir + this->MocCppFilenameRel; + // Moc predefs file + if (!this->MocPredefsCmd.empty()) { + this->MocPredefsFileRel = this->AutogenBuildSubDir + "moc_predefs.h"; + this->MocPredefsFileAbs = this->CurrentBinaryDir + this->MocPredefsFileRel; + } + // Init file path checksum generator fpathCheckSum.setupParentDirs(this->CurrentSourceDir, this->CurrentBinaryDir, this->ProjectSourceDir, @@ -1142,6 +1150,50 @@ bool cmQtAutoGenerators::MocGenerateAll( return true; } + // Generate moc_predefs + if (!this->MocPredefsCmd.empty()) { + if (!this->MakeParentDirectory(this->MocPredefsFileAbs)) { + this->LogError("AutoMoc: Error creating directory for " + + this->MocPredefsFileRel); + return false; + } + this->LogBold("Generating MOC predefs " + this->MocPredefsFileRel); + + std::vector<std::string> cmd = this->MocPredefsCmd; + cmd.insert(cmd.end(), this->MocIncludes.begin(), this->MocIncludes.end()); + for (std::vector<std::string>::const_iterator it = + this->MocDefinitions.begin(); + it != this->MocDefinitions.end(); ++it) { + cmd.push_back("-D" + (*it)); + } + cmd.insert(cmd.end(), this->MocOptions.begin(), this->MocOptions.end()); + + std::string output; + bool moc_predefsGenerated = this->RunCommand(cmd, output, false); + if (!moc_predefsGenerated) { + return false; + } + + // actually write the file + cmsys::ofstream outfile; + outfile.open(this->MocPredefsFileAbs.c_str(), std::ios::trunc); + if (!outfile) { + moc_predefsGenerated = false; + this->LogError("AutoMoc: Error opening " + this->MocPredefsFileRel); + } else { + outfile << output; + // Check for write errors + if (!outfile.good()) { + moc_predefsGenerated = false; + this->LogError("AutoMoc: Error writing " + this->MocPredefsFileRel); + } + } + + if (!moc_predefsGenerated) { + return false; + } + } + bool mocCompFileGenerated = false; bool mocCompChanged = false; @@ -1305,6 +1357,10 @@ bool cmQtAutoGenerators::MocGenerateFile( cmd.push_back("-D" + (*it)); } cmd.insert(cmd.end(), this->MocOptions.begin(), this->MocOptions.end()); + if (!this->MocPredefsFileAbs.empty()) { + cmd.push_back("--include"); + cmd.push_back(this->MocPredefsFileAbs); + } #ifdef _WIN32 cmd.push_back("-DWIN32"); #endif @@ -1805,7 +1861,7 @@ bool cmQtAutoGenerators::MakeParentDirectory(const std::string& filename) const * @return True on success */ bool cmQtAutoGenerators::RunCommand(const std::vector<std::string>& command, - std::string& output) const + std::string& output, bool verbose) const { // Log command if (this->Verbose) { @@ -1813,8 +1869,9 @@ bool cmQtAutoGenerators::RunCommand(const std::vector<std::string>& command, } // Execute command int retVal = 0; - bool res = - cmSystemTools::RunSingleCommand(command, &output, &output, &retVal); + bool res = cmSystemTools::RunSingleCommand( + command, &output, &output, &retVal, CM_NULLPTR, + verbose ? cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE); return (res && (retVal == 0)); } diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index d359059..24c0a33 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -143,8 +143,8 @@ private: const char* basePrefix, const char* baseSuffix) const; bool MakeParentDirectory(const std::string& filename) const; - bool RunCommand(const std::vector<std::string>& command, - std::string& output) const; + bool RunCommand(const std::vector<std::string>& command, std::string& output, + bool verbose = true) const; bool FindHeader(std::string& header, const std::string& testBasePath) const; @@ -177,6 +177,8 @@ private: // - Moc std::string MocCppFilenameRel; std::string MocCppFilenameAbs; + std::string MocPredefsFileRel; + std::string MocPredefsFileAbs; std::vector<std::string> MocSkipList; std::vector<std::string> MocIncludePaths; std::vector<std::string> MocIncludes; @@ -198,6 +200,8 @@ private: MacroFilter MacroFilters[2]; cmsys::RegularExpression RegExpMocInclude; cmsys::RegularExpression RegExpUicInclude; + // - moc_predefs + std::vector<std::string> MocPredefsCmd; // - Flags bool IncludeProjectDirsBefore; bool Verbose; diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index a5c1a23..8227ab7 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -763,9 +763,11 @@ static Json::Value DumpTarget(cmGeneratorTarget* target, if (target->HaveWellDefinedOutputFiles()) { Json::Value artifacts = Json::arrayValue; - artifacts.append(target->GetFullPath(config, false)); + artifacts.append( + target->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact)); if (target->IsDLLPlatform()) { - artifacts.append(target->GetFullPath(config, true)); + artifacts.append( + target->GetFullPath(config, cmStateEnums::ImportLibraryArtifact)); const cmGeneratorTarget::OutputInfo* output = target->GetOutputInfo(config); if (output && !output->PdbDir.empty()) { diff --git a/Source/cmStateTypes.h b/Source/cmStateTypes.h index b2b12b4..7d6158e 100644 --- a/Source/cmStateTypes.h +++ b/Source/cmStateTypes.h @@ -53,6 +53,12 @@ enum CacheEntryType STATIC, UNINITIALIZED }; + +enum ArtifactType +{ + RuntimeBinaryArtifact, + ImportLibraryArtifact +}; } #endif diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 7ace0a3..39625ae 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -570,6 +570,46 @@ std::vector<std::string> cmSystemTools::ParseArguments(const char* command) return args; } +size_t cmSystemTools::CalculateCommandLineLengthLimit() +{ + size_t sz = +#ifdef _WIN32 + // There's a maximum of 65536 bytes and thus 32768 WCHARs on Windows + // However, cmd.exe itself can only handle 8191 WCHARs and Ninja for + // example uses it to spawn processes. + size_t(8191); +#elif defined(__linux) + // MAX_ARG_STRLEN is the maximum length of a string permissible for + // the execve() syscall on Linux. It's defined as (PAGE_SIZE * 32) + // in Linux's binfmts.h + static_cast<size_t>(sysconf(_SC_PAGESIZE) * 32); +#else + size_t(0); +#endif + +#if defined(_SC_ARG_MAX) + // ARG_MAX is the maximum size of the command and environment + // that can be passed to the exec functions on UNIX. + // The value in limits.h does not need to be present and may + // depend upon runtime memory constraints, hence sysconf() + // should be used to query it. + long szArgMax = sysconf(_SC_ARG_MAX); + // A return value of -1 signifies an undetermined limit, but + // it does not imply an infinite limit, and thus is ignored. + if (szArgMax != -1) { + // We estimate the size of the environment block to be 1000. + // This isn't accurate at all, but leaves some headroom. + szArgMax = szArgMax < 1000 ? 0 : szArgMax - 1000; +#if defined(_WIN32) || defined(__linux) + sz = std::min(sz, static_cast<size_t>(szArgMax)); +#else + sz = static_cast<size_t>(szArgMax); +#endif + } +#endif + return sz; +} + bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command, std::string* captureStdOut, std::string* captureStdErr, int* retVal, diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 86d92be..a8a9995 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -253,6 +253,8 @@ public: static void ParseUnixCommandLine(const char* command, std::vector<std::string>& args); + static size_t CalculateCommandLineLengthLimit(); + static void EnableMessages() { s_DisableMessages = false; } static void DisableMessages() { s_DisableMessages = true; } static void DisableRunCommandOutput() { s_DisableRunCommandOutput = true; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0b1bb06..bda1d95 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -35,7 +35,7 @@ const char* cmTargetPropertyComputer::ComputeLocationForBuild<cmTarget>( { static std::string loc; if (tgt->IsImported()) { - loc = tgt->ImportedGetFullPath("", false); + loc = tgt->ImportedGetFullPath("", cmStateEnums::RuntimeBinaryArtifact); return loc.c_str(); } @@ -54,7 +54,8 @@ const char* cmTargetPropertyComputer::ComputeLocation<cmTarget>( { static std::string loc; if (tgt->IsImported()) { - loc = tgt->ImportedGetFullPath(config, false); + loc = + tgt->ImportedGetFullPath(config, cmStateEnums::RuntimeBinaryArtifact); return loc.c_str(); } @@ -63,7 +64,7 @@ const char* cmTargetPropertyComputer::ComputeLocation<cmTarget>( gg->CreateGenerationObjects(); } cmGeneratorTarget* gt = gg->FindGeneratorTarget(tgt->GetName()); - loc = gt->GetFullPath(config, false); + loc = gt->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact); return loc.c_str(); } @@ -1294,58 +1295,88 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const return cmSystemTools::IsOn(this->GetProperty(prop)); } -const char* cmTarget::GetSuffixVariableInternal(bool implib) const +const char* cmTarget::GetSuffixVariableInternal( + cmStateEnums::ArtifactType artifact) const { switch (this->GetType()) { case cmStateEnums::STATIC_LIBRARY: return "CMAKE_STATIC_LIBRARY_SUFFIX"; case cmStateEnums::SHARED_LIBRARY: - return (implib ? "CMAKE_IMPORT_LIBRARY_SUFFIX" - : "CMAKE_SHARED_LIBRARY_SUFFIX"); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + return "CMAKE_SHARED_LIBRARY_SUFFIX"; + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_SUFFIX"; + } + break; case cmStateEnums::MODULE_LIBRARY: - return (implib ? "CMAKE_IMPORT_LIBRARY_SUFFIX" - : "CMAKE_SHARED_MODULE_SUFFIX"); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + return "CMAKE_SHARED_MODULE_SUFFIX"; + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_SUFFIX"; + } + break; case cmStateEnums::EXECUTABLE: - return (implib - ? "CMAKE_IMPORT_LIBRARY_SUFFIX" - // Android GUI application packages store the native - // binary as a shared library. - : (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI") - ? "CMAKE_SHARED_LIBRARY_SUFFIX" - : "CMAKE_EXECUTABLE_SUFFIX")); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + // Android GUI application packages store the native + // binary as a shared library. + return (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI") + ? "CMAKE_SHARED_LIBRARY_SUFFIX" + : "CMAKE_EXECUTABLE_SUFFIX"); + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_SUFFIX"; + } + break; default: break; } return ""; } -const char* cmTarget::GetPrefixVariableInternal(bool implib) const +const char* cmTarget::GetPrefixVariableInternal( + cmStateEnums::ArtifactType artifact) const { switch (this->GetType()) { case cmStateEnums::STATIC_LIBRARY: return "CMAKE_STATIC_LIBRARY_PREFIX"; case cmStateEnums::SHARED_LIBRARY: - return (implib ? "CMAKE_IMPORT_LIBRARY_PREFIX" - : "CMAKE_SHARED_LIBRARY_PREFIX"); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + return "CMAKE_SHARED_LIBRARY_PREFIX"; + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_PREFIX"; + } + break; case cmStateEnums::MODULE_LIBRARY: - return (implib ? "CMAKE_IMPORT_LIBRARY_PREFIX" - : "CMAKE_SHARED_MODULE_PREFIX"); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + return "CMAKE_SHARED_MODULE_PREFIX"; + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_PREFIX"; + } + break; case cmStateEnums::EXECUTABLE: - return (implib - ? "CMAKE_IMPORT_LIBRARY_PREFIX" - // Android GUI application packages store the native - // binary as a shared library. - : (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI") - ? "CMAKE_SHARED_LIBRARY_PREFIX" - : "")); + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + // Android GUI application packages store the native + // binary as a shared library. + return (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI") + ? "CMAKE_SHARED_LIBRARY_PREFIX" + : ""); + case cmStateEnums::ImportLibraryArtifact: + return "CMAKE_IMPORT_LIBRARY_PREFIX"; + } + break; default: break; } return ""; } -std::string cmTarget::ImportedGetFullPath(const std::string& config, - bool pimplib) const +std::string cmTarget::ImportedGetFullPath( + const std::string& config, cmStateEnums::ArtifactType artifact) const { assert(this->IsImported()); @@ -1364,32 +1395,37 @@ std::string cmTarget::ImportedGetFullPath(const std::string& config, if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && this->GetMappedConfig(desired_config, &loc, &imp, suffix)) { - if (!pimplib) { - if (loc) { - result = loc; - } else { - std::string impProp = "IMPORTED_LOCATION"; - impProp += suffix; - if (const char* config_location = this->GetProperty(impProp)) { - result = config_location; - } else if (const char* location = - this->GetProperty("IMPORTED_LOCATION")) { - result = location; + switch (artifact) { + case cmStateEnums::RuntimeBinaryArtifact: + if (loc) { + result = loc; + } else { + std::string impProp = "IMPORTED_LOCATION"; + impProp += suffix; + if (const char* config_location = this->GetProperty(impProp)) { + result = config_location; + } else if (const char* location = + this->GetProperty("IMPORTED_LOCATION")) { + result = location; + } } - } - } else { - if (imp) { - result = imp; - } else if (this->GetType() == cmStateEnums::SHARED_LIBRARY || - this->IsExecutableWithExports()) { - std::string impProp = "IMPORTED_IMPLIB"; - impProp += suffix; - if (const char* config_implib = this->GetProperty(impProp)) { - result = config_implib; - } else if (const char* implib = this->GetProperty("IMPORTED_IMPLIB")) { - result = implib; + break; + + case cmStateEnums::ImportLibraryArtifact: + if (imp) { + result = imp; + } else if (this->GetType() == cmStateEnums::SHARED_LIBRARY || + this->IsExecutableWithExports()) { + std::string impProp = "IMPORTED_IMPLIB"; + impProp += suffix; + if (const char* config_implib = this->GetProperty(impProp)) { + result = config_implib; + } else if (const char* implib = + this->GetProperty("IMPORTED_IMPLIB")) { + result = implib; + } } - } + break; } } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c67143a..1f00c01 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -267,11 +267,13 @@ public: }; std::string ImportedGetFullPath(const std::string& config, - bool implib) const; + cmStateEnums::ArtifactType artifact) const; private: - const char* GetSuffixVariableInternal(bool implib) const; - const char* GetPrefixVariableInternal(bool implib) const; + const char* GetSuffixVariableInternal( + cmStateEnums::ArtifactType artifact) const; + const char* GetPrefixVariableInternal( + cmStateEnums::ArtifactType artifact) const; // Use a makefile variable to set a default for the given property. // If the variable is not defined use the given default instead. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index f0f04a8..adf5f74 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1051,8 +1051,8 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged( std::string postfixName = cmSystemTools::UpperCase(config); postfixName += "_POSTFIX"; - std::string assemblyName = - this->GeneratorTarget->GetOutputName(config, false); + std::string assemblyName = this->GeneratorTarget->GetOutputName( + config, cmStateEnums::RuntimeBinaryArtifact); if (const char* postfix = this->GeneratorTarget->GetProperty(postfixName)) { assemblyName += postfix; } @@ -3014,8 +3014,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( std::string pdb = this->GeneratorTarget->GetPDBDirectory(config.c_str()); pdb += "/"; pdb += targetNamePDB; - std::string imLib = - this->GeneratorTarget->GetDirectory(config.c_str(), true); + std::string imLib = this->GeneratorTarget->GetDirectory( + config.c_str(), cmStateEnums::ImportLibraryArtifact); imLib += "/"; imLib += targetNameImport; @@ -3395,13 +3395,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences() this->ConvertToWindowsSlash(path); (*this->BuildFileStream) << cmVS10EscapeXML(path) << "\">\n"; this->WriteString("<Project>", 3); - if (csproj == this->ProjectType) { - (*this->BuildFileStream) << "{"; - } - (*this->BuildFileStream) << this->GlobalGenerator->GetGUID(name.c_str()); - if (csproj == this->ProjectType) { - (*this->BuildFileStream) << "}"; - } + (*this->BuildFileStream) + << "{" << this->GlobalGenerator->GetGUID(name.c_str()) << "}"; (*this->BuildFileStream) << "</Project>\n"; this->WriteString("<Name>", 3); (*this->BuildFileStream) << name << "</Name>\n"; |