<div dir="ltr">to use the same sources in multiple outputs, with different compile options, I make a copy of the file (copy_if_different) into the binary, and then specify that for the related projects.<div><br></div><div>
<div>EXECUTE_PROCESS(COMMAND cmake -E copy_if_different ${CMAKE_SOURCE_DIR}/${VECTLIB_SOURCES} ${CMAKE_BINARY_DIR}/src/vectlib/vectlib_double.cpp )</div></div><div><br></div><div style>it's quite happy to make any missing path parts... can do something to extract original path parts so you can make it be a similar relative path in the binary.</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Apr 22, 2013 at 11:45 AM, Nick Gnedin <span dir="ltr"><<a href="mailto:ngnedin@gmail.com" target="_blank">ngnedin@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Folks,<br>
<br>
I am using CMake to create 2 targets - a stand-alone executable and a library that can be imported by Python. Both share most of the sources. If I just specify them as two separate targets, each will compile all the sources, so most of the source files end up compiled twice.<br>
<br>
Is there a way to share the compiled sources between the two targets? I can create an intermediate library, but that is less convenient since the executable will then depend on it. What I would really like is to have a self-contained executable and a separate library that use the same object files.<br>
<br>
Many thanks for any hint,<br>
<br>
Nick Gnedin<br>
--<br>
<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/<u></u>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/<u></u>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/<u></u>listinfo/cmake</a><br>
</blockquote></div><br></div>