[CMake] OS X Frameworks with spaces in filename

Adam Somers adsomers at gmail.com
Fri Oct 21 19:32:49 EDT 2011


Sorry if this is not the correct list to post questions.  Please direct me
to the proper place if so.

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.

Any help greatly appreciated!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111021/ac142d76/attachment.htm>


More information about the CMake mailing list