diff --git a/Source/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx index 492a1b7d0..683eff62a 100644 --- a/Source/cmTargetCompileDefinitionsCommand.cxx +++ b/Source/cmTargetCompileDefinitionsCommand.cxx @@ -20,13 +20,11 @@ bool cmTargetCompileDefinitionsCommand } void cmTargetCompileDefinitionsCommand -::HandleImportedTargetInvalidScope(const std::string &scope, - const std::string &tgt) +::HandleImportedTarget(const std::string &tgt) { cmOStringStream e; - e << "Cannot specify " << scope << " compile definitions for imported " - "target \"" << tgt << "\". Compile definitions can only be " - "specified for an imported target in the INTERFACE mode."; + e << "Cannot specify compile definitions for imported target \"" + << tgt << "\"."; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); } diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h index 4b066b7a0..d49b9e8ee 100644 --- a/Source/cmTargetCompileDefinitionsCommand.h +++ b/Source/cmTargetCompileDefinitionsCommand.h @@ -59,7 +59,7 @@ public: "Specify compile definitions or targets to use when compiling a given " "target. " "The named must have been created by a command such as " - "add_executable or add_library. " + "add_executable or add_library and must not be an IMPORTED target. " "The INTERFACE, PUBLIC and PRIVATE keywords are required to specify " "the scope of the following arguments. PRIVATE and PUBLIC items will " "populate the COMPILE_DEFINITIONS property of . PUBLIC and " @@ -78,8 +78,7 @@ public: cmTypeMacro(cmTargetCompileDefinitionsCommand, cmCommand); private: - virtual void HandleImportedTargetInvalidScope(const std::string &scope, - const std::string &tgt); + virtual void HandleImportedTarget(const std::string &tgt); virtual void HandleMissingTarget(const std::string &name); virtual bool HandleNonTargetArg(std::string &content, diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index 18e2cba4e..aeba4686a 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -22,13 +22,11 @@ bool cmTargetIncludeDirectoriesCommand //---------------------------------------------------------------------------- void cmTargetIncludeDirectoriesCommand -::HandleImportedTargetInvalidScope(const std::string &tgt, - const std::string &scope) +::HandleImportedTarget(const std::string &tgt) { cmOStringStream e; - e << "Cannot specify " << scope << " include directories for imported " - "target \"" << tgt << "\". Include directories can only be " - "specified for an imported target in the INTERFACE mode."; + e << "Cannot specify include directories for imported target \"" + << tgt << "\"."; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); } diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h index 90e039c4d..5a5f859fd 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.h +++ b/Source/cmTargetIncludeDirectoriesCommand.h @@ -60,7 +60,7 @@ public: "Specify include directories or targets to use when compiling a given " "target. " "The named must have been created by a command such as " - "add_executable or add_library.\n" + "add_executable or add_library and must not be an IMPORTED target.\n" "If BEFORE is specified, the content will be prepended to the property " "instead of being appended.\n" "The INTERFACE, PUBLIC and PRIVATE keywords are required to specify " @@ -82,8 +82,7 @@ public: cmTypeMacro(cmTargetIncludeDirectoriesCommand, cmCommand); private: - virtual void HandleImportedTargetInvalidScope(const std::string &tgt, - const std::string &scope); + virtual void HandleImportedTarget(const std::string &tgt); virtual void HandleMissingTarget(const std::string &name); virtual bool HandleNonTargetArg(std::string &content, diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index 69aaf1777..c79c16ff7 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -80,9 +80,9 @@ bool cmTargetPropCommandBase return false; } - if(this->Target->IsImported() && scope != "INTERFACE") + if(this->Target->IsImported()) { - this->HandleImportedTargetInvalidScope(args[0], scope); + this->HandleImportedTarget(args[0]); return false; } diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h index e757f9da1..15a78c9a6 100644 --- a/Source/cmTargetPropCommandBase.h +++ b/Source/cmTargetPropCommandBase.h @@ -32,8 +32,7 @@ public: const char *prop, ArgumentFlags flags = NO_FLAGS); private: - virtual void HandleImportedTargetInvalidScope(const std::string &tgt, - const std::string &scope) = 0; + virtual void HandleImportedTarget(const std::string &tgt) = 0; virtual void HandleMissingTarget(const std::string &name) = 0; virtual bool HandleNonTargetArg(std::string &content, diff --git a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt index a37c59708..3eca7fc78 100644 --- a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt +++ b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt @@ -12,11 +12,6 @@ target_compile_definitions(target_compile_definitions INTERFACE MY_INTERFACE_DEFINE ) -add_library(importedlib UNKNOWN IMPORTED) -target_compile_definitions(importedlib - INTERFACE MY_IMPORTEDINTERFACE_DEFINE -) - add_executable(consumer "${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp" ) @@ -24,5 +19,5 @@ add_executable(consumer target_compile_definitions(consumer PRIVATE target_compile_definitions importedlib $<$:SHOULD_NOT_BE_DEFINED> - $<$:SHOULD_BE_DEFINED> + $<$:SHOULD_BE_DEFINED> ) diff --git a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp index 1ef657d5a..f835b6cf5 100644 --- a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp +++ b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp @@ -11,10 +11,6 @@ #error Expected MY_INTERFACE_DEFINE #endif -#ifndef MY_IMPORTEDINTERFACE_DEFINE -#error Expected MY_IMPORTEDINTERFACE_DEFINE -#endif - #ifdef SHOULD_NOT_BE_DEFINED #error Unexpected SHOULD_NOT_BE_DEFINED #endif diff --git a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt index a0f2ee08c..486bca0af 100644 --- a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt +++ b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt @@ -11,9 +11,6 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/publicinclude/publicinclude.h" "#define file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/interfaceinclude") file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/interfaceinclude/interfaceinclude.h" "#define INTERFACEINCLUDE_DEFINE\n") -file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/importedinterfaceinclude") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/importedinterfaceinclude/importedinterfaceinclude.h" "#define IMPORTEDINTERFACEINCLUDE_DEFINE\n") - file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/poison") file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/poison/common.h" "#error Should not be included\n") @@ -36,15 +33,10 @@ target_include_directories(target_include_directories BEFORE PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/cure" ) -add_library(importedlib UNKNOWN IMPORTED) -target_include_directories(importedlib - INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/importedinterfaceinclude" -) - add_executable(consumer "${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp" ) target_include_directories(consumer - PRIVATE target_include_directories importedlib + PRIVATE target_include_directories ) diff --git a/Tests/CMakeCommands/target_include_directories/consumer.cpp b/Tests/CMakeCommands/target_include_directories/consumer.cpp index 6fd61d5b7..5d88488b5 100644 --- a/Tests/CMakeCommands/target_include_directories/consumer.cpp +++ b/Tests/CMakeCommands/target_include_directories/consumer.cpp @@ -2,7 +2,6 @@ #include "common.h" #include "publicinclude.h" #include "interfaceinclude.h" -#include "importedinterfaceinclude.h" #ifdef PRIVATEINCLUDE_DEFINE #error Unexpected PRIVATEINCLUDE_DEFINE @@ -16,10 +15,6 @@ #error Expected INTERFACEINCLUDE_DEFINE #endif -#ifndef IMPORTEDINTERFACEINCLUDE_DEFINE -#error Expected IMPORTEDINTERFACEINCLUDE_DEFINE -#endif - #ifndef CURE_DEFINE #error Expected CURE_DEFINE #endif