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"><<a href="mailto:andrewfenn@gmail.com" target="_blank">andrewfenn@gmail.com</a>></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'm a little stuck on how to get this working exactly how I want it to<br>
and I'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("include")<br>
<br>
----<br>
<br>
So how my "Client" Project works is that I can just do the following<br>
and it works nicely:<br>
add_subdirectory("core/")<br>
<br>
I want to be able to do the same in my unit test too that way I don't<br>
have to edit two CMakeLists.txt every time I add a file to the core<br>
subfolder however I'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("${CMAKE_SOURCE_DIR}/code/client/core/"<br>
"${CMAKE_CURRENT_BINARY_DIR}/code/client/core/")<br>
<br>
I don't actually fully understand what'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't work either because it won't give<br>
me the whole file location, just the relative "src/GameRoot.cpp" for<br>
example which is kind of useless along with the fact that I don't know<br>
if "include_directories" will work either.<br>
<br>
So my question for the list after this long explanation is how can I<br>
set my unit test's CMakeLists.txt up so that I can just add the<br>
following and have it "just work":<br>
add_subdirectory("${CMAKE_SOURCE_DIR}/code/client/core/")<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>