diff --git a/Help/prop_sf/OBJECT_NAME.rst b/Help/prop_sf/OBJECT_NAME.rst index 2424a5aacb..d3c09599c4 100644 --- a/Help/prop_sf/OBJECT_NAME.rst +++ b/Help/prop_sf/OBJECT_NAME.rst @@ -24,3 +24,7 @@ allow for context-sensitive (i.e., configuration-dependent) expressions. * Generated PCH source files (``cmake_pch``) * Generated Unity compilation files (``unity_``) * Qt autogen sources (``moc_compilations.cpp``) + +.. note:: + The :generator:`FASTBuild` and :generator:`Xcode` generators do not support + this property and it is ignored. diff --git a/Source/cmGlobalFastbuildGenerator.h b/Source/cmGlobalFastbuildGenerator.h index 1cb08b4ea8..139e3897fe 100644 --- a/Source/cmGlobalFastbuildGenerator.h +++ b/Source/cmGlobalFastbuildGenerator.h @@ -356,6 +356,8 @@ public: bool IsMultiConfig() const override { return false; } + bool SupportsCustomObjectNames() const override { return false; } + void ComputeTargetObjectDirectory(cmGeneratorTarget*) const override; void AppendDirectoryForConfig(std::string const& prefix, std::string const& config, diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 23241dcccc..38091de0c2 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -174,6 +174,8 @@ public: return false; } + virtual bool SupportsCustomObjectNames() const { return true; } + virtual bool SupportsBuildDatabase() const { return false; } bool AddBuildDatabaseTargets(); void AddBuildDatabaseFile(std::string const& lang, std::string const& config, diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 55c1dd3e5e..4a3efd79a4 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -116,6 +116,8 @@ public: bool ShouldStripResourcePath(cmMakefile*) const override; + bool SupportsCustomObjectNames() const override { return false; } + /** * Used to determine if this generator supports DEPFILE option. */ diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index b5b6f43006..2e338c3ad7 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -4336,7 +4336,8 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget( useShortObjectNames = *forceShortObjectName; } - if (!useShortObjectNames) { + if (!useShortObjectNames && + this->GetGlobalGenerator()->SupportsCustomObjectNames()) { auto customName = this->GetCustomObjectFileName(source); if (!customName.empty()) { auto ext = this->GlobalGenerator->GetLanguageOutputExtension(source); diff --git a/Tests/RunCMake/OBJECT_NAME/RunCMakeTest.cmake b/Tests/RunCMake/OBJECT_NAME/RunCMakeTest.cmake index 5735eecc25..91ee6e683c 100644 --- a/Tests/RunCMake/OBJECT_NAME/RunCMakeTest.cmake +++ b/Tests/RunCMake/OBJECT_NAME/RunCMakeTest.cmake @@ -8,6 +8,18 @@ if (RunCMake_GENERATOR STREQUAL "Xcode" AND "$ENV{CMAKE_OSX_ARCHITECTURES}" MATC return () endif () +if (RunCMake_GENERATOR STREQUAL "FASTBuild") + # FASTBuild does not offer full control over object paths. Just skip all + # tests rather than expecting some half-supported behavior. + return () +endif () + +if (RunCMake_GENERATOR STREQUAL "Xcode") + # Xcode does not offer full control over object paths. Just skip all tests + # rather than expecting some half-supported behavior. + return () +endif () + function(run_build_test case) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build) set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE:STRING=Debug)