[CMake] organizing source files with CMake
Victorious
dtvictorious at gmail.com
Thu Dec 17 10:27:18 EST 2015
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20151217/5a1a069d/attachment.html>
More information about the CMake
mailing list