[CMake] Exclude CMakeFiles path from GLOB_RECURSE
Michael Wild
themiwi at gmail.com
Thu Jul 1 04:04:50 EDT 2010
On 1. Jul, 2010, at 9:45 , Diablo 666 wrote:
>
> Hi,
>
> I'm currently trying to use the following line to include all source files into my build:
>
> file (GLOB_RECURSE Files_CPP *.cpp)
> add_executable(test
> ${Files_CPP}
> )
>
> Everything runs fine while using an out-of-source build, but for in-source builds these lines include .cpp files from the CMakeFiles directory. Is there any way to exclude this directory within the file command?
>
> Best regards,
> Andreas
1. Never use GLOB_RECURSE. It's evil. E.g. if you add or remove source files, CMake has no way of knowing that it should be re-run. Just list all the files in your CMakeLists.txt (or, if you think the list is excessively long, create a file called e.g. files.cmake, put the list in there and INCLUDE it in the CMakeLists.txt file.
2. Never do in-source builds. CMake creates many, many files, and you don't want to delete them all individually for a clean build. And there's no way to implement a safe "make clean" (e.g. your build system might be running a custom utility which generates files CMake knows nothing about).
HTH
Michael
More information about the CMake
mailing list