소스 검색

Do not initialize NO_SYSTEM_FROM_IMPORTED on INTERFACE libraries

The change in commit v3.8.0-rc1~276^2 (Allow NO_SYSTEM_FROM_IMPORTED on
imported INTERFACE libraries, 2016-11-21) was incorrect.  The property
is not meant to be set on imported targets at all.  It is meant to be
set on their consumers that compile sources.  Since INTERFACE libraries
have no sources to compile, the property is not needed on them.

Revert most of that change.  Unfortunately we must still tolerate
project code setting NO_SYSTEM_FROM_IMPORTED on INTERFACE libraries
because they were allowed by CMake 3.8 and 3.9.

Issue: #17348
Brad King 8 년 전
부모
커밋
2de0e0fdfa
4개의 변경된 파일9개의 추가작업 그리고 7개의 파일을 삭제
  1. 0 1
      Help/manual/cmake-buildsystem.7.rst
  2. 1 4
      Source/cmTarget.cxx
  3. 8 1
      Source/cmTargetPropertyComputer.cxx
  4. 0 1
      Tests/InterfaceLibrary/CMakeLists.txt

+ 0 - 1
Help/manual/cmake-buildsystem.7.rst

@@ -970,7 +970,6 @@ are:
 * ``EXPORT_NAME``
 * ``EXPORT_NAME``
 * ``IMPORTED``
 * ``IMPORTED``
 * ``NAME``
 * ``NAME``
-* ``NO_SYSTEM_FROM_IMPORTED``
 * Properties matching ``IMPORTED_LIBNAME_*``
 * Properties matching ``IMPORTED_LIBNAME_*``
 * Properties matching ``MAP_IMPORTED_CONFIG_*``
 * Properties matching ``MAP_IMPORTED_CONFIG_*``
 
 

+ 1 - 4
Source/cmTarget.cxx

@@ -256,6 +256,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
     this->SetPropertyDefault("WIN32_EXECUTABLE", nullptr);
     this->SetPropertyDefault("WIN32_EXECUTABLE", nullptr);
     this->SetPropertyDefault("MACOSX_BUNDLE", nullptr);
     this->SetPropertyDefault("MACOSX_BUNDLE", nullptr);
     this->SetPropertyDefault("MACOSX_RPATH", nullptr);
     this->SetPropertyDefault("MACOSX_RPATH", nullptr);
+    this->SetPropertyDefault("NO_SYSTEM_FROM_IMPORTED", nullptr);
     this->SetPropertyDefault("BUILD_WITH_INSTALL_NAME_DIR", nullptr);
     this->SetPropertyDefault("BUILD_WITH_INSTALL_NAME_DIR", nullptr);
     this->SetPropertyDefault("C_CLANG_TIDY", nullptr);
     this->SetPropertyDefault("C_CLANG_TIDY", nullptr);
     this->SetPropertyDefault("C_COMPILER_LAUNCHER", nullptr);
     this->SetPropertyDefault("C_COMPILER_LAUNCHER", nullptr);
@@ -282,10 +283,6 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
     this->SetPropertyDefault("LINK_SEARCH_END_STATIC", nullptr);
     this->SetPropertyDefault("LINK_SEARCH_END_STATIC", nullptr);
   }
   }
 
 
-  if (this->GetType() != cmStateEnums::UTILITY) {
-    this->SetPropertyDefault("NO_SYSTEM_FROM_IMPORTED", nullptr);
-  }
-
   // Collect the set of configuration types.
   // Collect the set of configuration types.
   std::vector<std::string> configNames;
   std::vector<std::string> configNames;
   mf->GetConfigurations(configNames);
   mf->GetConfigurations(configNames);

+ 8 - 1
Source/cmTargetPropertyComputer.cxx

@@ -66,12 +66,19 @@ bool cmTargetPropertyComputer::WhiteListedInterfaceProperty(
   }
   }
 
 
   if (prop == "IMPORTED_CONFIGURATIONS" || prop == "IMPORTED_LIBNAME" ||
   if (prop == "IMPORTED_CONFIGURATIONS" || prop == "IMPORTED_LIBNAME" ||
-      prop == "NO_SYSTEM_FROM_IMPORTED" ||
       cmHasLiteralPrefix(prop, "IMPORTED_LIBNAME_") ||
       cmHasLiteralPrefix(prop, "IMPORTED_LIBNAME_") ||
       cmHasLiteralPrefix(prop, "MAP_IMPORTED_CONFIG_")) {
       cmHasLiteralPrefix(prop, "MAP_IMPORTED_CONFIG_")) {
     return true;
     return true;
   }
   }
 
 
+  // This property should not be allowed but was incorrectly added in
+  // CMake 3.8.  We can't remove it from the whitelist without breaking
+  // projects that try to set it.  One day we could warn about this, but
+  // for now silently accept it.
+  if (prop == "NO_SYSTEM_FROM_IMPORTED") {
+    return true;
+  }
+
   return false;
   return false;
 }
 }
 
 

+ 0 - 1
Tests/InterfaceLibrary/CMakeLists.txt

@@ -64,7 +64,6 @@ target_link_libraries(iface_whitelist INTERFACE $<$<BOOL:$<TARGET_PROPERTY:CUSTO
 add_executable(exec_whitelist dummy.cpp)
 add_executable(exec_whitelist dummy.cpp)
 target_link_libraries(exec_whitelist iface_whitelist)
 target_link_libraries(exec_whitelist iface_whitelist)
 
 
-set(CMAKE_NO_SYSTEM_FROM_IMPORTED 1)
 add_library(iface_imported INTERFACE IMPORTED)
 add_library(iface_imported INTERFACE IMPORTED)
 set_property(TARGET iface_imported PROPERTY
 set_property(TARGET iface_imported PROPERTY
   INTERFACE_COMPILE_DEFINITIONS
   INTERFACE_COMPILE_DEFINITIONS