Merge topic 'disallow-IMPORTED-interface-porcelain'
b98d14d
Disallow porcelain to populate includes and defines of IMPORTED targets.48a4cf2
Revert "Allow target_link_libraries with IMPORTED targets."
This commit is contained in:
commit
76ace2b95a
|
@ -20,13 +20,11 @@ bool cmTargetCompileDefinitionsCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmTargetCompileDefinitionsCommand
|
void cmTargetCompileDefinitionsCommand
|
||||||
::HandleImportedTargetInvalidScope(const std::string &scope,
|
::HandleImportedTarget(const std::string &tgt)
|
||||||
const std::string &tgt)
|
|
||||||
{
|
{
|
||||||
cmOStringStream e;
|
cmOStringStream e;
|
||||||
e << "Cannot specify " << scope << " compile definitions for imported "
|
e << "Cannot specify compile definitions for imported target \""
|
||||||
"target \"" << tgt << "\". Compile definitions can only be "
|
<< tgt << "\".";
|
||||||
"specified for an imported target in the INTERFACE mode.";
|
|
||||||
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ public:
|
||||||
"Specify compile definitions or targets to use when compiling a given "
|
"Specify compile definitions or targets to use when compiling a given "
|
||||||
"target. "
|
"target. "
|
||||||
"The named <target> must have been created by a command such as "
|
"The named <target> 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 INTERFACE, PUBLIC and PRIVATE keywords are required to specify "
|
||||||
"the scope of the following arguments. PRIVATE and PUBLIC items will "
|
"the scope of the following arguments. PRIVATE and PUBLIC items will "
|
||||||
"populate the COMPILE_DEFINITIONS property of <target>. PUBLIC and "
|
"populate the COMPILE_DEFINITIONS property of <target>. PUBLIC and "
|
||||||
|
@ -78,8 +78,7 @@ public:
|
||||||
cmTypeMacro(cmTargetCompileDefinitionsCommand, cmCommand);
|
cmTypeMacro(cmTargetCompileDefinitionsCommand, cmCommand);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void HandleImportedTargetInvalidScope(const std::string &scope,
|
virtual void HandleImportedTarget(const std::string &tgt);
|
||||||
const std::string &tgt);
|
|
||||||
virtual void HandleMissingTarget(const std::string &name);
|
virtual void HandleMissingTarget(const std::string &name);
|
||||||
|
|
||||||
virtual bool HandleNonTargetArg(std::string &content,
|
virtual bool HandleNonTargetArg(std::string &content,
|
||||||
|
|
|
@ -22,13 +22,11 @@ bool cmTargetIncludeDirectoriesCommand
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmTargetIncludeDirectoriesCommand
|
void cmTargetIncludeDirectoriesCommand
|
||||||
::HandleImportedTargetInvalidScope(const std::string &tgt,
|
::HandleImportedTarget(const std::string &tgt)
|
||||||
const std::string &scope)
|
|
||||||
{
|
{
|
||||||
cmOStringStream e;
|
cmOStringStream e;
|
||||||
e << "Cannot specify " << scope << " include directories for imported "
|
e << "Cannot specify include directories for imported target \""
|
||||||
"target \"" << tgt << "\". Include directories can only be "
|
<< tgt << "\".";
|
||||||
"specified for an imported target in the INTERFACE mode.";
|
|
||||||
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ public:
|
||||||
"Specify include directories or targets to use when compiling a given "
|
"Specify include directories or targets to use when compiling a given "
|
||||||
"target. "
|
"target. "
|
||||||
"The named <target> must have been created by a command such as "
|
"The named <target> 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 "
|
"If BEFORE is specified, the content will be prepended to the property "
|
||||||
"instead of being appended.\n"
|
"instead of being appended.\n"
|
||||||
"The INTERFACE, PUBLIC and PRIVATE keywords are required to specify "
|
"The INTERFACE, PUBLIC and PRIVATE keywords are required to specify "
|
||||||
|
@ -82,8 +82,7 @@ public:
|
||||||
cmTypeMacro(cmTargetIncludeDirectoriesCommand, cmCommand);
|
cmTypeMacro(cmTargetIncludeDirectoriesCommand, cmCommand);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void HandleImportedTargetInvalidScope(const std::string &tgt,
|
virtual void HandleImportedTarget(const std::string &tgt);
|
||||||
const std::string &scope);
|
|
||||||
virtual void HandleMissingTarget(const std::string &name);
|
virtual void HandleMissingTarget(const std::string &name);
|
||||||
|
|
||||||
virtual bool HandleNonTargetArg(std::string &content,
|
virtual bool HandleNonTargetArg(std::string &content,
|
||||||
|
|
|
@ -33,10 +33,6 @@ bool cmTargetLinkLibrariesCommand
|
||||||
this->Target =
|
this->Target =
|
||||||
this->Makefile->GetCMakeInstance()
|
this->Makefile->GetCMakeInstance()
|
||||||
->GetGlobalGenerator()->FindTarget(0, args[0].c_str());
|
->GetGlobalGenerator()->FindTarget(0, args[0].c_str());
|
||||||
if(!this->Target)
|
|
||||||
{
|
|
||||||
this->Target = this->Makefile->FindTargetToUse(args[0].c_str());
|
|
||||||
}
|
|
||||||
if(!this->Target)
|
if(!this->Target)
|
||||||
{
|
{
|
||||||
cmake::MessageType t = cmake::FATAL_ERROR; // fail by default
|
cmake::MessageType t = cmake::FATAL_ERROR; // fail by default
|
||||||
|
@ -261,16 +257,6 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib,
|
||||||
// Handle normal case first.
|
// Handle normal case first.
|
||||||
if(this->CurrentProcessingState != ProcessingLinkInterface)
|
if(this->CurrentProcessingState != ProcessingLinkInterface)
|
||||||
{
|
{
|
||||||
if (this->Target->IsImported())
|
|
||||||
{
|
|
||||||
cmOStringStream e;
|
|
||||||
e << "Imported targets may only be used with the "
|
|
||||||
"LINK_INTERFACE_LIBRARIES specifier to target_link_libraries.";
|
|
||||||
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
this->Makefile
|
this->Makefile
|
||||||
->AddLinkLibraryForTarget(this->Target->GetName(), lib, llt);
|
->AddLinkLibraryForTarget(this->Target->GetName(), lib, llt);
|
||||||
if (this->CurrentProcessingState != ProcessingPublicInterface)
|
if (this->CurrentProcessingState != ProcessingPublicInterface)
|
||||||
|
|
|
@ -88,9 +88,9 @@ bool cmTargetPropCommandBase
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this->Target->IsImported() && scope != "INTERFACE")
|
if(this->Target->IsImported())
|
||||||
{
|
{
|
||||||
this->HandleImportedTargetInvalidScope(args[0], scope);
|
this->HandleImportedTarget(args[0]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,7 @@ public:
|
||||||
const char *prop, ArgumentFlags flags = NO_FLAGS);
|
const char *prop, ArgumentFlags flags = NO_FLAGS);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void HandleImportedTargetInvalidScope(const std::string &tgt,
|
virtual void HandleImportedTarget(const std::string &tgt) = 0;
|
||||||
const std::string &scope) = 0;
|
|
||||||
virtual void HandleMissingTarget(const std::string &name) = 0;
|
virtual void HandleMissingTarget(const std::string &name) = 0;
|
||||||
|
|
||||||
virtual bool HandleNonTargetArg(std::string &content,
|
virtual bool HandleNonTargetArg(std::string &content,
|
||||||
|
|
|
@ -12,11 +12,6 @@ target_compile_definitions(target_compile_definitions
|
||||||
INTERFACE MY_INTERFACE_DEFINE
|
INTERFACE MY_INTERFACE_DEFINE
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(importedlib UNKNOWN IMPORTED)
|
|
||||||
target_compile_definitions(importedlib
|
|
||||||
INTERFACE MY_IMPORTEDINTERFACE_DEFINE
|
|
||||||
)
|
|
||||||
|
|
||||||
add_executable(consumer
|
add_executable(consumer
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp"
|
"${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp"
|
||||||
)
|
)
|
||||||
|
@ -24,5 +19,5 @@ add_executable(consumer
|
||||||
target_compile_definitions(consumer
|
target_compile_definitions(consumer
|
||||||
PRIVATE target_compile_definitions importedlib
|
PRIVATE target_compile_definitions importedlib
|
||||||
$<$<TARGET_DEFINED:notdefined>:SHOULD_NOT_BE_DEFINED>
|
$<$<TARGET_DEFINED:notdefined>:SHOULD_NOT_BE_DEFINED>
|
||||||
$<$<TARGET_DEFINED:importedlib>:SHOULD_BE_DEFINED>
|
$<$<TARGET_DEFINED:target_compile_definitions>:SHOULD_BE_DEFINED>
|
||||||
)
|
)
|
||||||
|
|
|
@ -11,10 +11,6 @@
|
||||||
#error Expected MY_INTERFACE_DEFINE
|
#error Expected MY_INTERFACE_DEFINE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MY_IMPORTEDINTERFACE_DEFINE
|
|
||||||
#error Expected MY_IMPORTEDINTERFACE_DEFINE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SHOULD_NOT_BE_DEFINED
|
#ifdef SHOULD_NOT_BE_DEFINED
|
||||||
#error Unexpected SHOULD_NOT_BE_DEFINED
|
#error Unexpected SHOULD_NOT_BE_DEFINED
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -11,9 +11,6 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/publicinclude/publicinclude.h" "#define
|
||||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/interfaceinclude")
|
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/interfaceinclude")
|
||||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/interfaceinclude/interfaceinclude.h" "#define INTERFACEINCLUDE_DEFINE\n")
|
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(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/poison")
|
||||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/poison/common.h" "#error Should not be included\n")
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/poison/common.h" "#error Should not be included\n")
|
||||||
|
|
||||||
|
@ -41,15 +38,10 @@ target_include_directories(target_include_directories
|
||||||
BEFORE PUBLIC "$<$<TARGET_DEFINED:notdefined>:${CMAKE_CURRENT_BINARY_DIR}/poison>"
|
BEFORE PUBLIC "$<$<TARGET_DEFINED:notdefined>:${CMAKE_CURRENT_BINARY_DIR}/poison>"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(importedlib UNKNOWN IMPORTED)
|
|
||||||
target_include_directories(importedlib
|
|
||||||
INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/importedinterfaceinclude"
|
|
||||||
)
|
|
||||||
|
|
||||||
add_executable(consumer
|
add_executable(consumer
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp"
|
"${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(consumer
|
target_include_directories(consumer
|
||||||
PRIVATE target_include_directories importedlib
|
PRIVATE target_include_directories
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "publicinclude.h"
|
#include "publicinclude.h"
|
||||||
#include "interfaceinclude.h"
|
#include "interfaceinclude.h"
|
||||||
#include "importedinterfaceinclude.h"
|
|
||||||
|
|
||||||
#ifdef PRIVATEINCLUDE_DEFINE
|
#ifdef PRIVATEINCLUDE_DEFINE
|
||||||
#error Unexpected PRIVATEINCLUDE_DEFINE
|
#error Unexpected PRIVATEINCLUDE_DEFINE
|
||||||
|
@ -16,10 +15,6 @@
|
||||||
#error Expected INTERFACEINCLUDE_DEFINE
|
#error Expected INTERFACEINCLUDE_DEFINE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef IMPORTEDINTERFACEINCLUDE_DEFINE
|
|
||||||
#error Expected IMPORTEDINTERFACEINCLUDE_DEFINE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CURE_DEFINE
|
#ifndef CURE_DEFINE
|
||||||
#error Expected CURE_DEFINE
|
#error Expected CURE_DEFINE
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -29,9 +29,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
add_library(depA SHARED depA.cpp)
|
add_library(depA SHARED depA.cpp)
|
||||||
generate_export_header(depA)
|
generate_export_header(depA)
|
||||||
|
|
||||||
add_library(importedlib UNKNOWN IMPORTED)
|
|
||||||
target_link_libraries(importedlib LINK_INTERFACE_LIBRARIES depA)
|
|
||||||
|
|
||||||
add_library(depB SHARED depB.cpp)
|
add_library(depB SHARED depB.cpp)
|
||||||
generate_export_header(depB)
|
generate_export_header(depB)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue