[cmake-developers] [CMake 0014105]: IMPORTED target for a framework not handled correctly.
Mantis Bug Tracker
mantis at public.kitware.com
Mon Apr 22 11:04:13 EDT 2013
The following issue has been SUBMITTED.
======================================================================
http://public.kitware.com/Bug/view.php?id=14105
======================================================================
Reported By: Stephen Kelly
Assigned To:
======================================================================
Project: CMake
Issue ID: 14105
Category: CMake
Reproducibility: always
Severity: minor
Priority: normal
Status: new
======================================================================
Date Submitted: 2013-04-22 11:04 EDT
Last Modified: 2013-04-22 11:04 EDT
======================================================================
Summary: IMPORTED target for a framework not handled
correctly.
Description:
Given this:
cmake_minimum_required(VERSION 2.8)
project(cmake_framework_target)
find_library(COCOA_LIBRARY Cocoa)
add_library(Custom::Cocoa IMPORTED SHARED)
set_property(TARGET Custom::Cocoa APPEND PROPERTY IMPORTED_CONFIGURATIONS
RELEASE)
set_property(TARGET Custom::Cocoa PROPERTY IMPORTED_LOCATION_RELEASE
"${COCOA_LIBRARY}")
set_property(TARGET Custom::Cocoa PROPERTY FRAMEWORK 1)
add_executable(Framework_test main.cpp)
#target_link_libraries(Framework_test ${COCOA_LIBRARY})
target_link_libraries(Framework_test Custom::Cocoa)
Using the COCOA_LIBRARY in the tll() line works fine, linking is done with
-framework Cocoa.
However, using the IMPORTED target, cmake links with this result:
Linking CXX executable Framework_test
/Users/kdab/dev/cmake/build/bin/cmake -E cmake_link_script
CMakeFiles/Framework_test.dir/link.txt --verbose=1
/usr/bin/c++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names
CMakeFiles/Framework_test.dir/main.cpp.o -o Framework_test
/System/Library/Frameworks/Cocoa.framework
ld: in /System/Library/Frameworks/Cocoa.framework, can't map file, errno=22 for
architecture x86_64
collect2: ld returned 1 exit status
This patch fixes the issue, but I have no idea if it is appropriate (because I
don't have any familiarity with Mac, or how frameworks are supposed to work, or
if it is appropriate to create an imported target for a framework at all in
cmake):
diff --git a/Source/cmComputeLinkInformation.cxx
b/Source/cmComputeLinkInformation.cxx
index 896b50a..4fd32ea 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -657,14 +657,21 @@ void cmComputeLinkInformation::AddItem(std::string const&
item, cmTarget* tgt)
// Pass the full path to the target file.
std::string lib = tgt->GetFullPath(config, implib, true);
- if(!this->LinkDependsNoShared ||
- tgt->GetType() != cmTarget::SHARED_LIBRARY)
+ if(cmSystemTools::FileIsDirectory(lib.c_str()))
{
- this->Depends.push_back(lib);
+ this->AddDirectoryItem(lib);
}
+ else
+ {
+ if(!this->LinkDependsNoShared ||
+ tgt->GetType() != cmTarget::SHARED_LIBRARY)
+ {
+ this->Depends.push_back(lib);
+ }
- this->AddTargetItem(lib, tgt);
- this->AddLibraryRuntimeInfo(lib, tgt);
+ this->AddTargetItem(lib, tgt);
+ this->AddLibraryRuntimeInfo(lib, tgt);
+ }
}
}
else
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2013-04-22 11:04 Stephen Kelly New Issue
======================================================================
More information about the cmake-developers
mailing list