Perhaps try to set up your CMakeLists.txt to have a project in each directory, and a "root" CMakeLists.txt which simply does add_subdirectory for all the sub-projects... then CMake will generate a solution-file or makefile in each project-directory. You can then "step into" such a directory and build and and clean one project.
For example, in one of my projects I have the following structure:
projectroot/
applications/
appA
libraries/
libA
libB
In projectroot I set up a CMakeLists.txt like this:
project(MyProject)
add_subdirectory(libraries)
add_subdirectory(applications)
In libraries/
, I do the following:
project(Libraries)
add_subdirectory(libA)
add_subdirectory(libB)
add_subdirectory(libC)
And then in applications/
:
project(Applications)
add_subdirectory(appA)
In this case, I can step into projectroot/applications/appA
and call make
or msbuild appA.sln
and it will start building libA, B, C and then appA. Similarly you can call make clean
or msbuild /t:Clean appA.sln
.
The added benefit of an extra directory for all libraries is that I can build them at once by running make
or msbuild libraries.sln
in the libraries/
dir.