浏览代码

prop_sf/OBJECT_NAME: no-op for the FASTBuild and Xcode generators

There's no control over the object base name implemented in the
FASTBuild generator. Rather than expecting some half-supported behavior,
just ignore it completely there.

Similarly, Xcode ends up making its own object paths internally
regardless of what CMake would like.
Ben Boeckel 2 月之前
父节点
当前提交
84372ce0b5

+ 4 - 0
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.

+ 2 - 0
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,

+ 2 - 0
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,

+ 2 - 0
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.
    */

+ 2 - 1
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);

+ 12 - 0
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)