CMake is looking for file.cpp in the top level directory.<div><br></div><div>In your sub, do this instead:</div><div><span class="Apple-style-span" style="border-collapse: collapse; ">  set(subfiles &quot;${CMAKE_CURRENT_SOURCE_DIR}/file.cpp&quot; PARENT_SCOPE)</span><br>
<br></div><div><br><div class="gmail_quote">On Thu, Mar 5, 2009 at 10:22 AM,  <span dir="ltr">&lt;<a href="mailto:mbritton@astro.caltech.edu">mbritton@astro.caltech.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Hello:<br>
<br>
I am trying to assemble sources that are distributed across a number of<br>
subdirectories into a variable for inclusion in an add_library command.<br>
I&#39;ve tried using PARENT_SCOPE to do so, but I haven&#39;t been successful.<br>
<br>
Here is a specific example:<br>
<br>
toplevel CMakeLists.txt:<br>
<br>
  cmake_minimum_required(VERSION 2.6)<br>
<br>
  add_subdirectory(sub)<br>
<br>
  message(status &quot; subfiles ${subfiles}&quot;)<br>
<br>
  add_library(tst ${subfiles})<br>
<br>
<br>
CMakeLists.txt in subdirectory sub:<br>
<br>
  set(subfiles file.cpp PARENT_SCOPE)<br>
<br>
<br>
Output from cmake version 2.6-patch 3<br>
<br>
  -- The C compiler identification is GNU<br>
  -- The CXX compiler identification is GNU<br>
  -- Check for working C compiler: /usr/bin/gcc<br>
  -- Check for working C compiler: /usr/bin/gcc -- works<br>
  -- Detecting C compiler ABI info<br>
  -- Detecting C compiler ABI info - done<br>
  -- Check for working CXX compiler: /usr/bin/c++<br>
  -- Check for working CXX compiler: /usr/bin/c++ -- works<br>
  -- Detecting CXX compiler ABI info<br>
  -- Detecting CXX compiler ABI info - done<br>
  status subfiles file.cpp<br>
  -- Configuring done<br>
CMake Error in CMakeLists.txt:<br>
  Cannot find source file &quot;file.cpp&quot;.  Tried extensions .c .C .c++ .cc<br>
.cpp .cxx<br>
  .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx<br>
<br>
<br>
-- Build files have been written to: /home/matthew/tmp/build<br>
<br>
<br>
As you can see, the variable ${subfiles} is set correctly, but does not<br>
seem to be expanded when placed into the add_library command.<br>
<br>
<br>
Sincerely yours<br>
Matthew<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></div>