[CMake] How to create SOURCE_GROUP for include files
Brad King
brad.king at kitware.com
Fri Jul 7 12:50:59 EDT 2006
Steve Johns wrote:
> ProjDir
> src
> incl
> lib
>
>
> into which directory's CMakelists.txt file should I put the
>
> SOURCE_FILES( "Include Files" FILES x.hpp y.hpp )
>
> command, and could this:
>
> ADD_LIBRARY( MyLibProj x.cpp y.cpp x.hpp y.hpp )
The source and header files will not magically be found in other
directories. You have to tell CMake where to find them. Try this in
the top-level CMakeLists.txt file:
ADD_LIBRARY(mylib src/x.cpp incl/x.hpp)
SOURCE_GROUP("Include Files" FILES incl/x.hpp)
Basically source files have to be named with a relative path to the
location of the CMakeLists.txt file. This may also work from
lib/CMakeLists.txt:
ADD_LIBRARY(mylib ../src/x.cpp ../incl/x.hpp)
SOURCE_GROUP("Include Files" FILES ../incl/x.hpp)
-Brad
More information about the CMake
mailing list