Sorry if this is not the correct list to post questions. Please direct me to the proper place if so.<div><br></div><div>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:</div>
<div><br></div><div>find_library(MY_LIB \"My\ Framework\")</div><div><br></div><div>Then I link to my target with:</div><div><br></div><div>target_link_libraries(MyTarget ${MY_LIB})</div><div><br></div><div>The resulting linker flag is:</div>
<div><br></div><div>-Framework My Framework</div><div><br></div><div>This of course is incorrect and will cause gcc to try to link to "My" and "Framework separately.</div><div><br></div><div>The solution is to write the linker flags myself, as follows:</div>
<div>set(CMAKE_EXE_LINKER_FLAGS -framework\ \"My\ Framework\")</div><div><br></div><div>Is there a better way?</div><div><br></div><div>BTW, I tried to fix up the name by replacing " " with "\ " i.e.</div>
<div><br></div><div>string(REPLACE " " "\\ " MY_LIB_FIX ${MY_LIB})</div><div><br></div><div>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.</div>
<div><br></div><div>Any help greatly appreciated!</div>