Multiple source directories for one executable with CMake
问题 I want my source organised in a number of subdirectories but be able to create a single executable without having to build a library for each subdirectory. Can CMake do this? Something like: ADD_EXECUTABLE(foo a/main.cpp a/other.cpp b/another.cpp) Is it that simple? With the / working as a directory separator regardless of platform? 回答1: Here the my simple example cmake_minimum_required(VERSION 2.8 FATAL_ERROR) project(foo CXX) # get all *.cpp files recursively file(GLOB_RECURSE SRC_FILES $