How do I merge subdirectories into a single executable?
I understand that every subdirect开发者_如何学Pythonory has to have a CMakeLists.txt, but I don't want to create a library or an executable for each directory.
My folder structure:
/src
/exportedHeaders
/server
main.cpp
Each subfolder has a mix of .h and .cpp files. I don't understand how I can mix all of it up into a single executable, there doesn't seem to be a command for that.
I haven't really used CMake, so there is probably a better way, but as far as I know you can just specify the path to all the source files.
eg:
add_executable (myProgram main.cpp subdir1/foo.cpp subdir2/bla.cpp)
I imagine you could use file globbing to get *.cpp
in each subdir, to reduce typing.
See this mailing list message for info about file globbing in CMake.
精彩评论