When I was investigating similar problem, I found alternative approach at <a href="http://code.google.com/p/dynamorio/source/browse/trunk/CMakeLists.txt">http://code.google.com/p/dynamorio/source/browse/trunk/CMakeLists.txt</a>.<br>
<br>The thing is to change linker rules, to something like this:<br>    set(CMAKE_C_CREATE_SHARED_LIBRARY<br>        # standard rule<br>        &quot;&lt;CMAKE_C_COMPILER&gt; &lt;CMAKE_SHARED_LIBRARY_C_FLAGS&gt; &lt;LANGUAGE_COMPILE_FLAGS&gt; &lt;LINK_FLAGS&gt; &lt;CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS&gt; &lt;CMAKE_SHARED_LIBRARY_SONAME_C_FLAG&gt;&lt;TARGET_SONAME&gt; -o &lt;TARGET&gt; &lt;OBJECTS&gt; &lt;LINK_LIBRARIES&gt;&quot;<br>
        # now create a .debug copy<br>        &quot;${CMAKE_OBJCOPY} --only-keep-debug &lt;TARGET&gt; &lt;TARGET&gt;.debug&quot;<br>        # link original to point at .debug copy<br>        # directory components are removed, so &quot;../lib/&quot; is fine<br>
        &quot;${CMAKE_OBJCOPY} --add-gnu-debuglink=&lt;TARGET&gt;.debug &lt;TARGET&gt;&quot;<br>        # Strip all information from target binary.<br>        &quot;${CMAKE_STRIP} --strip-debug --discard-all --preserve-dates &lt;TARGET&gt;&quot;<br>
    )<br><br>I don&#39;t exactly remember benefits from this approach but it kind of works.<br><br>And I agree that functionality like installing debug symbols in install() rules out of box would be quite handy.<br><br>Regards,<br>
Yuri<br><br><div class="gmail_quote">On Sat, Sep 24, 2011 at 4:02 AM, Michael Hertling <span dir="ltr">&lt;<a href="mailto:mhertling@online.de">mhertling@online.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 09/22/2011 01:24 PM, Rolf Eike Beer wrote:<br>
&gt;&gt; Il 22/09/2011 10.13, Rolf Eike Beer ha scritto:<br>
&gt;&gt;&gt;&gt; Yeah, that&#39;s exactly what I had in mind. Any chance that we will see<br>
&gt;&gt;&gt;&gt; this in a future release?<br>
&gt;&gt;&gt; This is usually &quot;find someone who does it and writes tests for it&quot;.<br>
&gt;&gt;&gt; Which<br>
&gt;&gt;&gt; then boils down to find someone who has enough knowledge and spare time<br>
&gt;&gt;&gt; to<br>
&gt;&gt;&gt; do or someone that needs it and is willing to pay Kitware for doing it.<br>
&gt;<br>
&gt;&gt; Why don&#39;t you invoke ${CMAKE_OBJCOPY} as a post build command?<br>
&gt;<br>
&gt; That would be a way to _get_ these debug symbol files, but not a clean way<br>
&gt; to _install_ them. And the other reason is that this variable doesn&#39;t show<br>
&gt; up in any CMake documentation.<br>
&gt;<br>
&gt; Eike<br>
<br>
</div>In order to take up Andrea&#39;s suggestion for Lukas&#39; concern:<br>
<br>
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)<br>
PROJECT(DEBUGINFO C)<br>
SET(CMAKE_VERBOSE_MAKEFILE ON)<br>
FILE(WRITE ${CMAKE_BINARY_DIR}/main.c &quot;int main(void){return 0;}\n&quot;)<br>
ADD_EXECUTABLE(main main.c)<br>
FIND_PROGRAM(OBJCOPY objcopy)<br>
ADD_CUSTOM_COMMAND(TARGET main POST_BUILD<br>
    COMMAND ${OBJCOPY} --only-keep-debug<br>
        $&lt;TARGET_FILE:main&gt; ${CMAKE_BINARY_DIR}/main.dbg<br>
    COMMAND ${OBJCOPY} --strip-debug<br>
        $&lt;TARGET_FILE:main&gt;<br>
    COMMAND ${OBJCOPY} --add-gnu-debuglink=main.dbg<br>
        $&lt;TARGET_FILE:main&gt;<br>
)<br>
INSTALL(TARGETS main RUNTIME DESTINATION bin)<br>
INSTALL(FILES ${CMAKE_BINARY_DIR}/main.dbg DESTINATION bin)<br>
<br>
This exemplary project simply follows objcopy&#39;s manpage<br>
w.r.t. the --only-keep-debug switch and works on *nix.<br>
Does it not work for you, or is it not clean enough?<br>
<br>
Regards,<br>
<br>
Michael<br>
<font color="#888888">--<br>
</font><div><div></div><div class="h5"><br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</div></div></blockquote></div><br>