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&#39;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 &quot;My Framework.framework&quot;.  CMake successfully finds the framework when I run:</div>

<div><br></div><div>find_library(MY_LIB \&quot;My\ Framework\&quot;)</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 &quot;My&quot; and &quot;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\ \&quot;My\ Framework\&quot;)</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 &quot; &quot; with &quot;\ &quot; i.e.</div>

<div><br></div><div>string(REPLACE &quot; &quot; &quot;\\ &quot; 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 &quot;[the path] is a full-path but not a valid library file name.&quot;  The the resulting linker flag is -l rather than the required -framework.</div>

<div><br></div><div>Any help greatly appreciated!</div>