MantisBT - CMake
View Issue Details
0015485CMakeCMakepublic2015-03-31 12:072016-06-10 14:31
Daniel Dunbar 
Kitware Robot 
normalmajoralways
closedmoved 
OS X
 
 
0015485: CFBundleExecutable path in a bundle should not be a relative path into bundle
The CFBundleExecutable path inside of a CMake generated bundle is a relative path including the bundle name itself. This is not correct, it should simply be the name of the bundle binary that is inside the MacOS directory:

In this example:
--
$ cat CMakeLists.txt
cmake_minimum_required(VERSION 3.2)
add_library(Bar MODULE Bar.c)
set_target_properties(Bar PROPERTIES BUNDLE true)
$ touch Bar.c
$ cmake -G Ninja .
...
$ ninja
[1/2] Building C object CMakeFiles/Bar.dir/Bar.c.o
[2/2] Linking C CFBundle shared module Bar.bundle/Contents/MacOS/Bar
$ defaults read $(pwd)/Bar.bundle/Contents/Info.plist CFBundleExecutable
Bar.bundle/Contents/MacOS/Bar
$
--
the last line should just print "Bar".


You can verify this is not what the platform expects by trying to load the bundle from somewhere else:
--
$ cat load.m
#import <Foundation/Foundation.h>

int main(int argc, char **argv) {
    @autoreleasepool {
        NSBundle *bundle = [NSBundle bundleWithPath:[[NSString alloc] initWithUTF8String:argv[1]]];
        [bundle load];
    }
    return 0;
}
$ clang load.m -o load -framework Foundation && ./load Bar.bundle
2015-03-31 09:07:24.778 load[95727:5952049] Cannot find executable for CFBundle 0x7fc292d13ac0 </private/tmp/bar/Bar.bundle> (not loaded)
--
whereas this will load fine if the CFBundleExecutable key is just "Bar".

No tags attached.
patch 0001-Show-only-bundle-name-in-Xcode.patch (969) 2015-04-01 16:28
https://public.kitware.com/Bug/file/5418/0001-Show-only-bundle-name-in-Xcode.patch
Issue History
2015-03-31 12:07Daniel DunbarNew Issue
2015-03-31 13:30Brad KingNote Added: 0038372
2015-03-31 13:31Brad KingNote Added: 0038373
2015-04-01 16:28Gregor JasnyNote Added: 0038385
2015-04-01 16:28Gregor JasnyFile Added: 0001-Show-only-bundle-name-in-Xcode.patch
2015-04-01 16:29Gregor JasnyNote Edited: 0038385bug_revision_view_page.php?bugnote_id=38385#r1739
2015-04-01 16:36Brad KingNote Added: 0038388
2016-06-10 14:29Kitware RobotNote Added: 0042746
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0038372)
Brad King   
2015-03-31 13:30   
The GenerateAppleInfoPList method:

 http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmLocalGenerator.cxx;hb=v3.2.1#l3698 [^]

uses its targetName parameter as the value for CFBundleExecutable in the Info.plist file. The value of that parameter is correct for application bundles. It may need a special case for CFBundles because the value of targetName comes from cmTarget::GetFullNameInternal:

 http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmTarget.cxx;hb=v3.2.1#l3928 [^]

which has a special case for CFBundles here:

 http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmTarget.cxx;hb=v3.2.1#l4027 [^]
(0038373)
Brad King   
2015-03-31 13:31   
Nicolas?
(0038385)
Gregor Jasny   
2015-04-01 16:28   
(edited on: 2015-04-01 16:29)
Same for the product name visible in Xcode. Patch attached. Maybe one can find a general solution.

(0038388)
Brad King   
2015-04-01 16:36   
Re 0015485:0038385: I think there can be more than one slash.

Ideally some refactoring would be done to allow the proper name to be extracted anywhere it is needed.
(0042746)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.