View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0012550CMakeCMakepublic2011-11-01 17:222012-05-09 15:26
ReporterAaron Simmons 
Assigned ToBrad King 
PriorityhighSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
Platformi386OSMac OS XOS Version10.6
Product VersionCMake 2.8.6 
Target VersionCMake 2.8.7Fixed in VersionCMake 2.8.7 
Summary0012550: frameworks with spaces breaks cmake
DescriptionTrying to use target_link_libraries with a framework that contains spaces (such as the "Adobe AIR.framework" in the AIR SDK) doesn't work.
Steps To ReproduceFrom an unanswered email on the cmake forums http://www.mail-archive.com/cmake@cmake.org/msg38710.html: [^]


I'm having trouble linking my OS X application to a specific framework using
CMake without explicitly setting linker flags (somewhat defeating the
purpose of using CMake for cross-platform building). Say I have a framework
called "My Framework.framework". CMake successfully finds the framework
when I run:

find_library(MY_LIB \"My\ Framework\")

Then I link to my target with:

target_link_libraries(MyTarget ${MY_LIB})

The resulting linker flag is:

-Framework My Framework

This of course is incorrect and will cause gcc to try to link to "My" and
"Framework separately.

The solution is to write the linker flags myself, as follows:
set(CMAKE_EXE_LINKER_FLAGS -framework\ \"My\ Framework\")

Is there a better way?

BTW, I tried to fix up the name by replacing " " with "\ " i.e.

string(REPLACE " " "\\ " MY_LIB_FIX ${MY_LIB})

Such that MY_LIB_FIX is /Library/Frameworks/My\ Framework.framework. But to
my dismay, CMake interprets this format differently and produces a warning
that says "[the path] is a full-path but not a valid library file name."
 The the resulting linker flag is -l rather than the required -framework.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0027707)
Brad King (manager)
2011-11-02 08:53

You shouldn't need any backslashes for the find_library call. This should work:

  find_library(MY_LIB "My Framework")

You can work around this issue by passing the framework like this:

  target_link_libraries(MyTarget "-framework \"My Framework\"")
(0027708)
Brad King (manager)
2011-11-02 09:11

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e74f3744 [^]
(0029448)
David Cole (manager)
2012-05-09 15:26

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2011-11-01 17:22 Aaron Simmons New Issue
2011-11-02 08:46 Brad King Assigned To => Brad King
2011-11-02 08:46 Brad King Status new => assigned
2011-11-02 08:53 Brad King Note Added: 0027707
2011-11-02 09:11 Brad King Note Added: 0027708
2011-11-02 09:11 Brad King Status assigned => resolved
2011-11-02 09:11 Brad King Resolution open => fixed
2011-12-16 17:23 David Cole Fixed in Version => CMake 2.8.7
2011-12-16 17:23 David Cole Target Version => CMake 2.8.7
2012-05-09 15:26 David Cole Note Added: 0029448
2012-05-09 15:26 David Cole Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team