[cmake-developers] Apple tests for target_link_libraries failing

Bill Hoffman bill.hoffman at kitware.com
Tue Oct 11 14:52:17 EDT 2011


So, basically we this:


set(CMAKE_LINK_INTERFACE_LIBRARIES "")

add_library(libA SHARED classA.cpp)
add_library(libB SHARED classB.cpp)
add_library(libC SHARED classC.cpp)

generate_export_header(libA)
generate_export_header(libB)
generate_export_header(libC)

target_link_libraries(libB libA)
target_link_libraries(libC libA libB)

add_executable(exec
   "main.cpp"
)
target_link_libraries(exec libC )


So, setting CMAKE_LINK_INTERFACE_LIBRARIES to "" is supposed to make the 
transitive linking of A and B not happen when linking C.  I tried adding 
some print stuff in the code.  But, I am not sure where to look.

I added the following:

  void cmTarget::SetPropertyDefault(const char* property,
                                    const char* default_value)
  {
+  bool debug = false;
+  if(strcmp("LINK_INTERFACE_LIBRARIES", property) == 0)
+    debug = true;
+  if(debug) std::cerr << this->GetName() << "\n";
    // Compute the name of the variable holding the default value.
    std::string var = "CMAKE_";
    var += property;
-
+  if(debug) std::cerr << var << "\n";
    if(const char* value = this->Makefile->GetDefinition(var.c_str()))
      {
+    if(debug) std::cerr << "found it " << value << "\n";
      this->SetProperty(property, value);
      }
    else if(default_value)
      {
+    if(debug) std::cerr << "not found " << default_value << "\n";
      this->SetProperty(property, default_value);
      }
  }
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLin
kLibrariesCommand.cxx
index 805959d..d2be3fa 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -219,6 +219,7 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const cha
r* lib,
    // Handle normal case first.
    if(!this->DoingInterface)
      {
+    std::cerr << this->Target->GetName() << " Not doing interface" << "\
n";
      this->Makefile


I ended up with this:

libA
CMAKE_LINK_INTERFACE_LIBRARIES
found it
libB
CMAKE_LINK_INTERFACE_LIBRARIES
found it
libC
CMAKE_LINK_INTERFACE_LIBRARIES
found it


libB Not doing interface
libC Not doing interface
libC Not doing interface


Do you have other prints that I should add?  How is this supposed to work?

-Bill




More information about the cmake-developers mailing list