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

Reply via email to