Hi Andrew.<br><br>Just a clarification: do you actually need the source-gathering file (currently /project_src/code/client/core/CMakeLists.txt) to be a CMakeList? If all it does is set up some variables, you might be best off renaming it e.g. FileSetup.cmake and then including it using include(...) in both CMakeLists.<br>
<br>Petr<br><br><div class="gmail_quote">On Sun, Sep 30, 2012 at 9:26 AM, Andrew Fenn <span dir="ltr">&lt;<a href="mailto:andrewfenn@gmail.com" target="_blank">andrewfenn@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello all,<br>
<br>
I&#39;m a little stuck on how to get this working exactly how I want it to<br>
and I&#39;m hoping someone here will be able to help me figure it out.<br>
<br>
My project is structured as so:<br>
<br>
/project_src/tests/client/CMakeLists.txt  -  Client Unit Test Project<br>
/project_src/code/client/CMakeLists.txt  -  Client Project<br>
/project_src/code/client/core/src  - *.cpp files<br>
/project_src/code/client/core/include  - *.h files<br>
/project_src/code/client/core/CMakeLists.txt - Gets the source for the<br>
above dirs like so..<br>
<br>
-----<br>
set(client_source<br>
    src/GameRoot.cpp<br>
    src/GameManager.cpp<br>
    src/RootGameState.cpp<br>
    src/GameState.cpp<br>
)<br>
<br>
include_directories(&quot;include&quot;)<br>
<br>
----<br>
<br>
So how my &quot;Client&quot; Project works is that I can just do the following<br>
and it works nicely:<br>
add_subdirectory(&quot;core/&quot;)<br>
<br>
I want to be able to do the same in my unit test too that way I don&#39;t<br>
have to edit two CMakeLists.txt every time I add a file to the core<br>
subfolder however I&#39;m having a lot of difficultly doing so.<br>
<br>
My first issue is that I have to change the command to the following<br>
in my CMakeLists.txt in my unit test:<br>
add_subdirectory(&quot;${CMAKE_SOURCE_DIR}/code/client/core/&quot;<br>
&quot;${CMAKE_CURRENT_BINARY_DIR}/code/client/core/&quot;)<br>
<br>
I don&#39;t actually fully understand what&#39;s going on in the second<br>
argument here but it seems to add the folder; however now I have a new<br>
problem which is that the ${client_source} variable that you can see<br>
above in my /project_src/code/client/core/CMakeLists.txt goes out of<br>
scope. This is weird because it works fine in my client project.<br>
<br>
In order to resolve that problem I found that you can add PARENT_SCOPE<br>
to the set function but that doesn&#39;t work either because it won&#39;t give<br>
me the whole file location, just the relative &quot;src/GameRoot.cpp&quot; for<br>
example which is kind of useless along with the fact that I don&#39;t know<br>
if &quot;include_directories&quot; will work either.<br>
<br>
So my question for the list after this long explanation is how can I<br>
set my unit test&#39;s CMakeLists.txt up so that I can just add the<br>
following and have it &quot;just work&quot;:<br>
add_subdirectory(&quot;${CMAKE_SOURCE_DIR}/code/client/core/&quot;)<br>
<br>
Thanks,<br>
Andrew<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/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>