Hi Victor,
(Without a name I don't have anything better to go on here...)
You could do the following in your subdirectory's CMakeLists.txt file:
set( SOURCE ${SOURCE} ${CMAKE_CURRENT_SOURCE_DIR}/file1.cpp ... )
set( SOURCE ${SOURCE} PARENT_SCOPE )
The second line will make sure that the variable is updated in the parent's
scope (the main CMakeLists.txt file) as well.
Cheers,
Attila
> On 17 Dec 2015, at 16:27, Victorious <[email protected]> wrote:
>
> Hi,
>
> I’d like to have all my source files in an src folder. The src folder may
> have .cpp/.h files, and can also have subfolders.
>
> This is how I’ve been doing it, but it only seems to work with files in the
> src folder (not sure how to extend this to subfolders inside src).
> Src/cmake list.txt:
>
> set(SOURCE
> ${SOURCE}
> ${CMAKE_CURRENT_SOURCE_DIR}/file1.cpp
> ${CMAKE_CURRENT_SOURCE_DIR}/file2.cpp
> PARENT_SCOPE
> )
>
> set(HEADERS
> ${HEADERS}
> ${CMAKE_CURRENT_SOURCE_DIR}/file1.h
> ${CMAKE_CURRENT_SOURCE_DIR}/file2.h
> PARENT_SCOPE
> add_subdirectory("subdir1")
>
> Src/subdir1’s cmake list looks similar minus the last line. Then in the top
> cmake list.txt,
> add_executable("app" ${SOURCE} ${HEADERS})
>
> A follow-up question: is it possible to do this without specifying each file
> manually?
>
> Thanks
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake