On Thu, Sep 16, 2010 at 6:45 AM, David Aldrich <span dir="ltr"><<a href="mailto:David.Aldrich@eu.nec.com">David.Aldrich@eu.nec.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi<br>
<br>
I have now successfully configured CMakeLists files to create some of our static and dynamic libraries using CMake. I would now like some advice on how to configure these separate build files as a single project.<br>
<br>
Here's what our current folder structure is like:<br>
<br>
Trunk ------- Kernel <==== a static library containing main()<br>
|<br>
|--- DynLibs <==== containg multiple folders containing<br>
| proprietary source code, each folder<br>
| builds one shared library<br>
|<br>
|--- MyExe <==== contains top-level makefile that<br>
a) links Kernel static library into an .exe<br>
b) calls makefiles for the dynamic libraries<br>
<br>
This structure may not be ideal from a CMake standpoint, but I would like to maintain it to ease the transition from pure gnu make to CMake.<br></blockquote><div><br></div><div>CMake is flexible about where source files are located. This structure looks perfectly reasonable.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
What would I need to put in the top-level CMakeLists file (MyExe/CMakeLists.txt) to reference the other CMakeLists files?<br></blockquote><div><br></div><div>Something like this should work:</div><div><br></div><div>cmake_minimum_required(VERSION 2.8)</div>
<div>project(MyExe)</div><div><br></div><div>add_subdirectory(../Kernel Kernel)</div><div>add_subdirectory(../DynLibs DynLibs)</div><div><br></div><div>add_executable(MyExe exe.cxx)</div><div>target_link_libraries(MyExe Kernel)</div>
<div><br></div><div><br></div><div>If your DynLibs build dll files on Windows, the easiest way to get them to load into the exe is to use the RUNTIME_OUTPUT_DIRECTORY target property. (Just put the exe and the dlls all in the same folder with each other...)</div>
<div><a href="http://www.cmake.org/cmake/help/cmake-2-8-docs.html#prop_tgt:RUNTIME_OUTPUT_DIRECTORY">http://www.cmake.org/cmake/help/cmake-2-8-docs.html#prop_tgt:RUNTIME_OUTPUT_DIRECTORY</a></div><div><br></div><div>Or just once in your top level CMakeLists, the CMAKE_RUNTIME_OUTPUT_DIRECTORY variable:</div>
<div><a href="http://www.cmake.org/cmake/help/cmake-2-8-docs.html#variable:CMAKE_RUNTIME_OUTPUT_DIRECTORY">http://www.cmake.org/cmake/help/cmake-2-8-docs.html#variable:CMAKE_RUNTIME_OUTPUT_DIRECTORY</a></div><div><br></div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Should each CMakeLists file have its own Project name, or should they all be the same?<br></blockquote><div><br></div><div>Only the top one *needs* a project command, but if you do have project commands in your other CMakeLists.txt files, they should definitely each be unique.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Any advice would be much appreciated.<br>
<br>
Best regards<br>
<br>
David<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/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>
</blockquote></div><br><div><br></div><div>HTH,</div><div>David C.</div><div><br></div>