[CMake] make superclean target? (i.e. clear *everything*)
Hi all, Is it possible to ask CMake to make another make clean target that clears *all* the CMake generated files including the cache? I am a bit annoyed that the only way to clear everything is to basically run rm -rf *. Cheers, Daniel. -- Lord of the rings calendar in your Linux/Unix/Mac terminal: cat /usr/share/calendar/calendar.lotr -- 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] make superclean target? (i.e. clear *everything*)
What would be the benefit of such a command besides syntax? -- 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] make superclean target? (i.e. clear *everything*)
2013/4/4 Daniel Carrera dcarr...@gmail.com Hi all, Is it possible to ask CMake to make another make clean target that clears *all* the CMake generated files including the cache? I am a bit annoyed that the only way to clear everything is to basically run rm -rf *. You can perfectly add a custom target/command to do that, if you do out-of-source build then removing the build dir is ok. Now, this would be a one-shot suicidal target since this will basically erase the build tool file (VS project, Makefile, ...) which is needed to launch itself :-] -- Erk Le gouvernement représentatif n'est pas la démocratie -- http://www.le-message.org -- 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] make superclean target? (i.e. clear *everything*)
On 4 April 2013 11:40, Ansis Māliņš ansis.mal...@gmail.com wrote: What would be the benefit of such a command besides syntax? Only a small convenience, nothing big. I am used to typing make cleann when I want to make sure that I am starting from a clean slate. I also have my shell configured so that it warns me when I type rm -rf *. I generally appreciate the warning but I want to make an exception for the build directory. -- Lord of the rings calendar in your Linux/Unix/Mac terminal: cat /usr/share/calendar/calendar.lotr -- 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] make superclean target? (i.e. clear *everything*)
On 4 April 2013 11:41, Eric Noulard eric.noul...@gmail.com wrote: You can perfectly add a custom target/command to do that, if you do out-of-source build then removing the build dir is ok. Thanks. Yes, I am doing out of source builds. Now, this would be a one-shot suicidal target since this will basically erase the build tool file (VS project, Makefile, ...) which is needed to launch itself :-] Why is it suicidal? The Makefile doesn't mean anything. All the intelligence is in CMakeLists.txt. Cheers, Daniel. -- Lord of the rings calendar in your Linux/Unix/Mac terminal: cat /usr/share/calendar/calendar.lotr -- 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] make superclean target? (i.e. clear *everything*)
2013/4/4 Daniel Carrera dcarr...@gmail.com On 4 April 2013 11:41, Eric Noulard eric.noul...@gmail.com wrote: You can perfectly add a custom target/command to do that, if you do out-of-source build then removing the build dir is ok. Thanks. Yes, I am doing out of source builds. Now, this would be a one-shot suicidal target since this will basically erase the build tool file (VS project, Makefile, ...) which is needed to launch itself :-] Why is it suicidal? The Makefile doesn't mean anything. All the intelligence is in CMakeLists.txt. Yes I know. By suicidal I mean that the built tool will remove its own file (but not the CMakeLists.txt off course). i.e: make superclean will succeed , but ... make superclean; make won't since make superclean will have thrown the Makefile away. -- Erk Le gouvernement représentatif n'est pas la démocratie -- http://www.le-message.org -- 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] make superclean target? (i.e. clear *everything*)
Hello, On 04/04/13 11:40, Ansis Māliņš wrote: Is it possible to ask CMake to make another make clean target that clears *all* the CMake generated files including the cache? I am a bit annoyed that the only way to clear everything is to basically run rm -rf *. What would be the benefit of such a command besides syntax? I also find that such a command would be useful. It could be something like the make maintainer-clean target generated by autotools. One benefit is that it would allow to easily remove all cmake files when you wrongly run cmake in the source directory instead of in the build one. Cheers, Daniele -- 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] make superclean target? (i.e. clear *everything*)
2013/4/4 Daniele E. Domenichelli daniele.domeniche...@gmail.com Hello, On 04/04/13 11:40, Ansis Māliņš wrote: Is it possible to ask CMake to make another make clean target that clears *all* the CMake generated files including the cache? I am a bit annoyed that the only way to clear everything is to basically run rm -rf *. What would be the benefit of such a command besides syntax? I also find that such a command would be useful. It could be something like the make maintainer-clean target generated by autotools. One benefit is that it would allow to easily remove all cmake files when you wrongly run cmake in the source directory instead of in the build one. CMake cannot currently do that and it does not seem wise to ask for that feature. You may search the mailing list for this discussion topic and you'll find many answers. The only [reasonable] option is to do out-of-source build, then you know for sure that you can throw away the build tree. Safely avoiding accidental in-source build is a feature request: http://public.kitware.com/Bug/view.php?id=6672 Another option which is unrelated to CMake in order to clean-up a source tree is to use a VCS which may be able to remove any non versioned file easily. (see e.g. git clean) -- Erk Le gouvernement représentatif n'est pas la démocratie -- http://www.le-message.org -- 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] make superclean target? (i.e. clear *everything*)
On 04/04/13 15:34, Eric Noulard wrote: CMake cannot currently do that and it does not seem wise to ask for that feature. You may search the mailing list for this discussion topic and you'll find many answers. The only [reasonable] option is to do out-of-source build, then you know for sure that you can throw away the build tree. Safely avoiding accidental in-source build is a feature request: http://public.kitware.com/Bug/view.php?id=6672 That would work even better for me... Another option which is unrelated to CMake in order to clean-up a source tree is to use a VCS which may be able to remove any non versioned file easily. (see e.g. git clean) That works as well, but you need to pay really good attention if you have some unversioned files in your source tree (for example because you didn't commit them yet) Cheers, Daniele -- 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] make superclean target? (i.e. clear *everything*)
On 4 April 2013 12:41, Eric Noulard eric.noul...@gmail.com wrote: Yes I know. By suicidal I mean that the built tool will remove its own file (but not the CMakeLists.txt off course). I see what you mean. The Makefile is killing itself. It is committing suicide. Would it be a reasonable idea to delete CMakeCache.txt and maybe even CMakeFiles but leaving Makefile intact? Cheers, Daniel. -- Lord of the rings calendar in your Linux/Unix/Mac terminal: cat /usr/share/calendar/calendar.lotr -- 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] make superclean target? (i.e. clear *everything*)
On Thu, Apr 4, 2013 at 6:01 AM, Daniele E. Domenichelli daniele.domeniche...@gmail.com wrote: One benefit is that it would allow to easily remove all cmake files when you wrongly run cmake in the source directory instead of in the build one. A while ago I found the attached macro online[1]. It stops the build process early on preventing an in source build. Since it has to start the process to work you still get a CMakeCache.txt file and CMakeFiles directory but those are easy enough to remove compared to picking through your whole source tree. To use it place the Macro as close to the top of your master CMakeLists.txt file as you can and call it with something like: # Appends the path where you are keeping this Macro set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) #Forces out of source builds just in case. include(MacroOutOfSourceBuild) macro_ensure_out_of_source_build(${PROJECT_NAME} requires an out of source build.) -Brian [1] https://github.com/DisCODe/DisCODe/blob/master/cmake/modules/MacroOutOfSourceBuild.cmake MacroOutOfSourceBuild.cmake Description: Binary data -- 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] make superclean target? (i.e. clear *everything*)
On 2013-04-04 11:01, Daniel Carrera wrote: On 4 April 2013 12:41, Eric Noulard wrote: Yes I know. By suicidal I mean that the built tool will remove its own file (but not the CMakeLists.txt off course). I see what you mean. The Makefile is killing itself. It is committing suicide. Would it be a reasonable idea to delete CMakeCache.txt and maybe even CMakeFiles but leaving Makefile intact? IMHO, probably not; with the cache gone, re-running CMake is not guaranteed to succeed, and even less to produce the same results as before. I'd think it would be better to erase the Makefile that probably is no longer useful/correct. -- Matthew -- 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] make superclean target? (i.e. clear *everything*)
On 2013-04-04 06:30, Daniel Carrera wrote: On 4 April 2013 11:40, Ansis Māliņš wrote: What would be the benefit of such a command besides syntax? Only a small convenience, nothing big. I am used to typing make cleann when I want to make sure that I am starting from a clean slate. I also have my shell configured so that it warns me when I type rm -rf *. I generally appreciate the warning but I want to make an exception for the build directory. cd .. rm -rf build mkdir build cd build ...? ;-) (If your build directories tend to be in the same place, you could easily write a shell function to do this, to save typing.) -- Matthew -- 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] make superclean target? (i.e. clear *everything*)
On 4 April 2013 17:32, Matthew Woehlke matthew.woeh...@kitware.com wrote: cd .. rm -rf build mkdir build cd build ...? ;-) (If your build directories tend to be in the same place, you could easily write a shell function to do this, to save typing.) Done. I should have thought of that. Cheers, Daniel. -- Lord of the rings calendar in your Linux/Unix/Mac terminal: cat /usr/share/calendar/calendar.lotr -- 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] make superclean target? (i.e. clear *everything*)
Am 04.04.2013 um 17:31 schrieb Brian Milco: On Thu, Apr 4, 2013 at 6:01 AM, Daniele E. Domenichelli daniele.domeniche...@gmail.com wrote: One benefit is that it would allow to easily remove all cmake files when you wrongly run cmake in the source directory instead of in the build one. A while ago I found the attached macro online[1]. It stops the build process early on preventing an in source build. Since it has to start the process to work you still get a CMakeCache.txt file and CMakeFiles directory but those are easy enough to remove compared to picking through your whole source tree. To use it place the Macro as close to the top of your master CMakeLists.txt file as you can and call it with something like: # Appends the path where you are keeping this Macro set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) #Forces out of source builds just in case. include(MacroOutOfSourceBuild) macro_ensure_out_of_source_build(${PROJECT_NAME} requires an out of source build.) -Brian [1] https://github.com/DisCODe/DisCODe/blob/master/cmake/modules/MacroOutOfSourceBuild.cmake MacroOutOfSourceBuild.cmake-- 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 Hi all, What about just doing a string comparison on the ProjectName_SOURCE_DIR and ProjectName_BINARY_DIR? No need to include a file for what is effectively three lines: if(${MyProj_SOURCE_DIR} STREQUAL ${MyProj_BINARY_DIR}) message(FATAL_ERROR Only out-of source builds allowed at the moment.) endif() Or are there some traps I'm not seeing with this method? Andreas smime.p7s Description: S/MIME cryptographic signature -- 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] make superclean target? (i.e. clear *everything*)
Consider looking at the implementation of PreventInSourceBuilds.cmake in ITK See https://github.com/Kitware/ITK/blob/master/CMake/PreventInSourceBuilds.cmake May it could be generalized and integrated in CMake itself ? Jc On Thu, Apr 4, 2013 at 12:49 PM, Andreas Stahl andreas.st...@tu-dresden.dewrote: Am 04.04.2013 um 17:31 schrieb Brian Milco: On Thu, Apr 4, 2013 at 6:01 AM, Daniele E. Domenichelli daniele.domeniche...@gmail.com wrote: One benefit is that it would allow to easily remove all cmake files when you wrongly run cmake in the source directory instead of in the build one. A while ago I found the attached macro online[1]. It stops the build process early on preventing an in source build. Since it has to start the process to work you still get a CMakeCache.txt file and CMakeFiles directory but those are easy enough to remove compared to picking through your whole source tree. To use it place the Macro as close to the top of your master CMakeLists.txt file as you can and call it with something like: # Appends the path where you are keeping this Macro set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) #Forces out of source builds just in case. include(MacroOutOfSourceBuild) macro_ensure_out_of_source_build(${PROJECT_NAME} requires an out of source build.) -Brian [1] https://github.com/DisCODe/DisCODe/blob/master/cmake/modules/MacroOutOfSourceBuild.cmake MacroOutOfSourceBuild.cmake-- 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 Hi all, What about just doing a string comparison on the ProjectName_SOURCE_DIR and ProjectName_BINARY_DIR? No need to include a file for what is effectively three lines: if(${MyProj_SOURCE_DIR} STREQUAL ${MyProj_BINARY_DIR}) message(FATAL_ERROR Only out-of source builds allowed at the moment.) endif() Or are there some traps I'm not seeing with this method? Andreas -- 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 -- +1 919 869 8849 -- 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] make superclean target? (i.e. clear *everything*)
2013/4/4 Jean-Christophe Fillion-Robin jchris.filli...@kitware.com Consider looking at the implementation of PreventInSourceBuilds.cmake in ITK See https://github.com/Kitware/ITK/blob/master/CMake/PreventInSourceBuilds.cmake May it could be generalized and integrated in CMake itself ? Yes it could but it is not a user-friendly solution, since the macro 1) Does not prevent the creation of CMakeCache.txt nor CMakeFiles dir. 2) Tell the user that he should remove those himself (and rely on git to do so). Thus the feature request: http://public.kitware.com/Bug/view.php?id=6672 Even Brad found it could be cool: http://public.kitware.com/Bug/view.php?id=6672#c17606 May be somebody will find time to craft some patch for that... -- Erk Le gouvernement représentatif n'est pas la démocratie -- http://www.le-message.org -- 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