MantisBT - CMake
View Issue Details
0013797CMakeCMakepublic2012-12-14 13:482013-11-04 09:33
Richard Bateman 
Clinton Stimpson 
highmajoralways
closedfixed 
XCodeMac OSall (presumably)
 
CMake 2.8.12 
0013797: OS X CFBundle PREFIX and SUFFIX are set too late
Starting with cmake 2.8.10 when I use:

    get_property(LIBDIR TARGET ${PROJNAME} PROPERTY LOCATION)

I now get /path/to/libGCPlugin.so.plugin/Contents/MacOS/libGCPlugin.so

I should get /path/to/GCPlugin.plugin/Contents/MacOS/GCPLugin

I don't know what changed;
There is a test in the cmake source that should be able to reproduce it; if it's not a simple thing to see what happened I can help track it down.

Basically create a library:

add_library(somePlugin MODULE ${SOURCES})

    set_target_properties(somePlugin PROPERTIES
        OUTPUT_NAME somePlugin
        BUNDLE 1
        BUNDLE_EXTENSION plugin
        XCODE_ATTRIBUTE_WRAPPER_EXTENSION plugin #sets the extension to .plugin
        XCODE_ATTRIBUTE_MACH_O_TYPE mh_bundle
        XCODE_ATTRIBUTE_INFOPLIST_FILE ${CMAKE_CURRENT_BINARY_DIR}/bundle/Info.plist
        MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/bundle/Info.plist)

Then do:

    get_property(LIBDIR TARGET somePlugin PROPERTY LOCATION)

message("Lib dir: ${LIBDIR}")
This is really easy to reproduce with a firebreath plugin; I can upload a test project that you could play with with firebreath if you wanted to try it that way. I am also willing to help if you can give me an idea where to look. I am willing to help if it is needed.
No tags attached.
related to 0011295closed David Cole Support for "CFBundle" (.plugin) types on Mac OS 
Issue History
2012-12-14 13:48Richard BatemanNew Issue
2012-12-14 14:16Brad KingNote Added: 0031898
2012-12-14 14:40Brad KingRelationship addedrelated to 0011295
2012-12-14 14:44Brad KingNote Added: 0031899
2012-12-14 14:49Brad KingTarget Version => CMake 2.8.11
2012-12-14 14:49Brad KingSummaryget_property(... TARGET project PROPERTY LOCATION returns incorrect value => OS X CFBundle PREFIX and SUFFIX are set too late
2013-05-17 09:33Robert MaynardTarget VersionCMake 2.8.11 => CMake 2.8.12
2013-06-03 08:32Clinton StimpsonAssigned To => Clinton Stimpson
2013-06-03 08:32Clinton StimpsonStatusnew => assigned
2013-06-03 08:40Clinton StimpsonNote Added: 0033174
2013-06-03 08:40Clinton StimpsonStatusassigned => resolved
2013-06-03 08:40Clinton StimpsonResolutionopen => fixed
2013-11-04 09:33Robert MaynardNote Added: 0034350
2013-11-04 09:33Robert MaynardStatusresolved => closed

Notes
(0031898)
Brad King   
2012-12-14 14:16   
What version of CMake were you using that reported the correct path in this case? I'd like to find when/why this changed.

However, you may not need to use the property. Note from the LOCATION property documentation:

 http://www.cmake.org/cmake/help/v2.8.10/cmake.html#prop_tgt:LOCATION [^]
 "this property is provided for compatibility with CMake 2.4 and below"

If you are getting the location to pass to add_custom_command or add_test then use the $<TARGET_FILE:...> generator expression instead.
(0031899)
Brad King   
2012-12-14 14:44   
From a small test case I can see that LOCATION gets the prefix/suffix but $<TARGET_FILE:...> does not. The reason is that the former is computed during configuration and the latter during generation. In between those steps this code runs:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmGlobalXCodeGenerator.cxx;hb=v2.8.10.2#l706 [^]
  if(cmtarget.IsCFBundleOnApple())
    {
    cmtarget.SetProperty("PREFIX", "");
    cmtarget.SetProperty("SUFFIX", "");
    }

This was part of your original patch:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5457b825 [^]

I think setting the properties during generation like that is incorrect. Instead cmTarget::GetFullNameInternal should be taught that for CFBundle targets the prefix and suffix should default to empty if the property is not explicitly set.
(0033174)
Clinton Stimpson   
2013-06-03 08:40   
483e208 OS X: Fix getting of CFBundle LOCATION property.
(0034350)
Robert Maynard   
2013-11-04 09:33   
Closing resolved issues that have not been updated in more than 4 months.