[CMake] Exclude CMakeFiles path from GLOB_RECURSE
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 _ http://redirect.gimas.net/?n=M1007xHM2 Räumen Sie Ihr Postfach auf - ganz einfach mit Hotmail!___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Exclude CMakeFiles path from GLOB_RECURSE
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 ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Exclude CMakeFiles path from GLOB_RECURSE
Hi, thanks for your reply. 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. I have tested rerunning cmake manually and it worked out well. (Testcase: I added a new .cpp file to the build) I either have to change the CMakeLists.txt or to rerun cmake manually. Seems to be the same effort for me. 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). I know these problems. I will never do an in-source-build again :-) But unfortunately, I have to support in-source builds, too. Best regards, Andreas _ http://redirect.gimas.net/?n=M1007xHMTL4 Künftig E-Mails über Hotmail ohne Werbung versenden!___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Exclude CMakeFiles path from GLOB_RECURSE
On 1. Jul, 2010, at 10:15 , Diablo 666 wrote: Hi, thanks for your reply. 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. I have tested rerunning cmake manually and it worked out well. (Testcase: I added a new .cpp file to the build) I either have to change the CMakeLists.txt or to rerun cmake manually. Seems to be the same effort for me. Thing is: will you never forget? And it prevents stray files from being picked up (as you experienced). Also, you get an immediate response if a file is missing, and not just when the compiler complains about a missing header or you get undefined references during the linking stage. If you insist on using GLOB_RECURSE, don't apply it to CMAKE_CURRENT_SOURCE_DIR, but use GLOB on the CMAKE_CURRENT_SOURCE_DIR and use GLOB_RECURSE on all the subdirectories individually, so you don't get CMake-generated stuff. Also, you could filter out all the items contained in the CMakeFiles directory: file(GLOB_RECURSE SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp *.h) string(REGEX REPLACE CMakeFiles/[^;]+;? SRCS ${SRCS}) Michael ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Exclude CMakeFiles path from GLOB_RECURSE
Thing is: will you never forget? And it prevents stray files from being picked up (as you experienced). Also, you get an immediate response if a file is missing, and not just when the compiler complains about a missing header or you get undefined references during the linking stage. Ok, that sounds reasoble. (This should especially convince some lazy people :-D ) Thanks a lot! _ http://redirect.gimas.net/?n=M1007xHM2 Räumen Sie Ihr Postfach auf - ganz einfach mit Hotmail!___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake