I am not an expert at CMake, but since there are no other answers, I will take a look at the document and let it know. Organizing the source and including files in different directories is pretty much the norm.
It looks like CMake allows you to specify a list of include directories: http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:include_directories
So something like:
include_directories("src/top1/mid1/bot1" "src/top1/mid1/bot2/" ... )
They are passed to the compiler so that it can find the header files and passed for each of the source files. Therefore, any of your source files should be able to include any of the header files (which, I think, is what you are asking for).
Similarly, you should be able to list all the source files in the add_executable command :
add_executable(name "src/top1/mid1/bot1/src1.cpp" "src/top1/id1/bot2/src2.cpp" ...)
So, that would be a naive way to make everything build. Each source file will be compiled and will look for headers in all of these directories, and then the object files will be linked together. Consider whether there is a way to simplify this, so you donโt need so many included folders, maybe there are only a few common header files that need to be referenced by all the source files. If things get complicated, you can create sub-tiers in libraries, etc. Also consider separating source files and headers (e.g. in src and include).
Guy Sirton Aug 03 '11 at 7:22 2011-08-03 07:22
source share