[CMake] Broken Cmake Behavior using --build VS2010

Rolf Eike Beer eike at sf-mail.de
Thu Dec 15 03:10:56 EST 2011


> This is because we should really only allow one project command per
> CMakeLists.txt file, but since we do not error out, it's difficult to
> change at this point in time...
>
> --build uses the CMAKE_PROJECT_NAME cache variable to decide what sln file
> to use, and that corresponds to the first project command.
>
> Do you need multiple project commands in your CMakeLists.txt file?
>
> What benefit do you get from it?
>
> I'd like to understand how people are using multiple project commands, so
> we can fix this the "right" way.

At my last employer we used multiple projects, too. But every
CMakeLists.txt had at most one project(). We had a large number of
libraries that had many dependencies regarding their include directories
and so on. Also they could be used to build different parts of the
software more or less standalone.

So what we did was to use the add_subdirectory_once() macro I posted here
a few time which does what add_subdirectory() does but will just do
nothing if the given directory is already part of the build.

And later we did things like
include_directories(${LIB1_SOURCE_DIR}/include) to easily get the includes
without too much relative paths.

Eike


More information about the CMake mailing list