Re: [CMake] Disallowing in-source builds

2010-10-09 Thread Joshua L. Blocher
This is how is it done in KDE SC.
http://websvn.kde.org/trunk/KDE/kdelibs/cmake/modules/MacroEnsureOutOfSourceBuild.cmake?view=markup
Joshua L. Blocher
___
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] Disallowing in-source builds

2010-10-08 Thread aaron.meadows
Here's what I ended up with:

 

function(AssureOutOfSourceBuilds)

  # make sure the user doesn't play dirty with symlinks

  get_filename_component(srcdir ${CMAKE_SOURCE_DIR} REALPATH)

  get_filename_component(bindir ${CMAKE_BINARY_DIR} REALPATH)

 

  # disallow in-source builds

  if(${srcdir} STREQUAL ${bindir})

message(##)

message(You are attempting to build in your Source Directory.)

message(You must run cmake from a build directory.)

message(##)

 

# attempt to remove cache and cache files... this actually fails to
work,

# but no hurt trying incase it starts working..

file(REMOVE_RECURSE ${CMAKE_SOURCE_DIR}/CMakeCache.txt
${CMAKE_SOURCE_DIR}/CMakeFiles)

 

message(FATAL_ERROR In-source builds are forbidden!)

  endif()

 

  # check for polluted source tree

  if(EXISTS ${CMAKE_SOURCE_DIR}/CMakeCache.txt OR EXISTS
${CMAKE_SOURCE_DIR}/CMakeFiles)

 
message(###
#)

message( Found results from an in-source build in your source
directory.)

 
message(###
#)

 

# attempt to remove cache and cache files...

file(REMOVE_RECURSE ${CMAKE_SOURCE_DIR}/CMakeCache.txt
${CMAKE_SOURCE_DIR}/CMakeFiles)

 

message(FATAL_ERROR Source Directory Cleaned, please rerun CMake.)

  endif()

endfunction()

 

It's basically exactly what you mentioned.  I changed the order of the
checks to allow it to check for an in-source build before dealing with
the consequences of such.  I added more logging and actual cleanup.

 

Thanks for all the help. If you have any suggestions on improving this,
please let me know.  Incidentally, removing the CMakeCache.txt and
CMakeFiles directory does not work during the in-source build, but does
during the check to insure there isn't anything left over from an in
source build.  I went ahead and removed the files there and then
fatal_error'd out to allow the right CMakeCache.txt to be loaded in the
build tree when cmake is next run.

 

Aaron C. Meadows 

 

-Original Message-
From: Michael Wild [mailto:them...@gmail.com] 
Sent: Thursday, October 07, 2010 2:20 AM
To: Meadows, Aaron C.; Meadows, Aaron C.
Cc: cmake@cmake.org
Subject: Re: [CMake] Disallowing in-source builds

 

 

On 6. Oct, 2010, at 20:10 , aaron.mead...@thomsonreuters.com
aaron.mead...@thomsonreuters.com wrote:

 

 Hi all.

 

 

 

 Is there a good way to disallow in-source builds?  Ideally, I'd like
to

 prevent it before any cruft is written into the source tree.  I

 experimented with writing a function into my CMakelists file and
calling

 it.  The function checked if CMAKE_BINARY_DIR was equal to

 CMAKE_SOURCE_DIR and messaged a FATAL_ERROR if that was the case.
This

 works ok, but still generates a CMakeFiles directory and a

 CMakeCache.txt file.

 

I don't think there's a way to prevent that from happening. The bad
thing about this is that if the user doesn't clean away the in-source
CMakeCache.txt file, subsequent out-of-source builds will fail. Perhaps
you can do something like this:

 

# check for polluted source tree

if(EXISTS ${CMAKE_SOURCE_DIR}/CMakeCache.txt OR

EXISTS ${CMAKE_SOURCE_DIR}/CMakeFiles)

  message(FATAL_ERROR

CMakeCache.txt or CMakeFiles exists in source directory!)

endif()

# make sure the user doesn't play dirty with symlinks

get_filename_component(srcdir ${CMAKE_SOURCE_DIR} REALPATH)

get_filename_component(bindir ${CMAKE_BINARY_DIR} REALPATH)

# disallow in-source builds

if(${srcdir} STREQUAL ${bindir})

  message(FATAL_ERROR In-source builds are forbidden!)

endif()

 

 

 The second half of the question is of course, is there an easy way to

 clean out a source tree if an in-source build was accidentally kicked

 off?  (short of dividing the files by their timestamp and removing the

 newer ones, etc..)

 

No, simply because CMake cannot. Your build system might have something
like the following:

 

execute_process(COMMAND echo BOOM  ${CMAKE_BINARY_DIR}/boom.txt
VERBATIM)

 

CMake never knows that the file boom.txt is written, and therefor can't
clean it away. The only reasonable way I know of is using git
(http://git-scm.com):

 

git clean -df

 

will remove all the files and directories that are not part of the
repository. With tar-ball builds it's easier. Just wipe the source tree
and unpack again.

 

 

Michael



This email was sent to you by Thomson Reuters, the global news and information 
company.
Any views expressed in this message are those of the individual sender, except 
where the sender specifically states them to be the views of Thomson Reuters.

___
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

Re: [CMake] Disallowing in-source builds

2010-10-07 Thread Michael Wild

On 6. Oct, 2010, at 20:10 , aaron.mead...@thomsonreuters.com 
aaron.mead...@thomsonreuters.com wrote:

 Hi all.
 
 
 
 Is there a good way to disallow in-source builds?  Ideally, I'd like to
 prevent it before any cruft is written into the source tree.  I
 experimented with writing a function into my CMakelists file and calling
 it.  The function checked if CMAKE_BINARY_DIR was equal to
 CMAKE_SOURCE_DIR and messaged a FATAL_ERROR if that was the case.  This
 works ok, but still generates a CMakeFiles directory and a
 CMakeCache.txt file.

I don't think there's a way to prevent that from happening. The bad thing about 
this is that if the user doesn't clean away the in-source CMakeCache.txt file, 
subsequent out-of-source builds will fail. Perhaps you can do something like 
this:

# check for polluted source tree
if(EXISTS ${CMAKE_SOURCE_DIR}/CMakeCache.txt OR
EXISTS ${CMAKE_SOURCE_DIR}/CMakeFiles)
  message(FATAL_ERROR
CMakeCache.txt or CMakeFiles exists in source directory!)
endif()
# make sure the user doesn't play dirty with symlinks
get_filename_component(srcdir ${CMAKE_SOURCE_DIR} REALPATH)
get_filename_component(bindir ${CMAKE_BINARY_DIR} REALPATH)
# disallow in-source builds
if(${srcdir} STREQUAL ${bindir})
  message(FATAL_ERROR In-source builds are forbidden!)
endif()

 
 The second half of the question is of course, is there an easy way to
 clean out a source tree if an in-source build was accidentally kicked
 off?  (short of dividing the files by their timestamp and removing the
 newer ones, etc..)

No, simply because CMake cannot. Your build system might have something like 
the following:

execute_process(COMMAND echo BOOM  ${CMAKE_BINARY_DIR}/boom.txt VERBATIM)

CMake never knows that the file boom.txt is written, and therefor can't clean 
it away. The only reasonable way I know of is using git (http://git-scm.com):

git clean -df

will remove all the files and directories that are not part of the repository. 
With tar-ball builds it's easier. Just wipe the source tree and unpack again.


Michael

PGP.sig
Description: This is a digitally signed message part
___
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

[CMake] Disallowing in-source builds

2010-10-07 Thread fatman

  is there an easy way to clean out a source tree if an in-source
  build was accidentally kicked off? (short of dividing the files by
  their timestamp and removing the newer ones, etc..)

My immediate thought was, does make clean not work for you? But I
guess you're talking about CMake debris rather than make debris.

  Ideally, I?d
  like to prevent it before any cruft is written into the source
  tree.

I suggest an alternative. I think I read about it on this list but I'm
not sure.

What I do is provide an empty cmake folder in my source tree root, and
run all CMake commands in it. This ensures all the CMake cruft is
contained in one in-source folder. (I guess you could modify this so
it's out-source.)

To re-run the rootwards-most CMakeLists.txt file:
cd projectx/cmake  cmake ..

Then, to clear all CMake debris:
rm -r projectx/cmake/*

(insert usual disclaimer on rm usage)

This doesn't prevent anything, but it does at least make it
easy to build in-source without cluttering the source tree.

  Is there a good way to disallow in-source builds?

Probably the best way is to circulate an email stating the lead
developer has threatened to eat^H^H^H^H fire anyone who builds
in-source.

You could maybe do something with user permissions and build
scripts. Make sure the build scripts only work in one place.

Regards,
Adam J Richardson
___
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] Disallowing in-source builds

2010-10-07 Thread Mateusz Loskot

On 07/10/10 10:21, fat...@crackmonkey.us wrote:

Then, to clear all CMake debris:
rm -r projectx/cmake/*


On Unix, if a project is managed by SVN it's easy to clean tree from 
generated files:


$ svn-clean

Distributed with Debian, Ubuntu, etc. as well as downloadable [1]

I'm sure there are similar commands/tools possible for Git, Mercurial 
and others.


[1] 
http://websvn.kde.org/*checkout*/trunk/KDE/kdesdk/scripts/svn-clean?pathrev=499176


Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org
Member of ACCU, http://accu.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] Disallowing in-source builds

2010-10-07 Thread Philip Lowman
On Thu, Oct 7, 2010 at 3:19 AM, Michael Wild them...@gmail.com wrote:


 On 6. Oct, 2010, at 20:10 , aaron.mead...@thomsonreuters.com 
 aaron.mead...@thomsonreuters.com wrote:

  Hi all.
 
 
 
  Is there a good way to disallow in-source builds?  Ideally, I'd like to
  prevent it before any cruft is written into the source tree.  I
  experimented with writing a function into my CMakelists file and calling
  it.  The function checked if CMAKE_BINARY_DIR was equal to
  CMAKE_SOURCE_DIR and messaged a FATAL_ERROR if that was the case.  This
  works ok, but still generates a CMakeFiles directory and a
  CMakeCache.txt file.

 I don't think there's a way to prevent that from happening. The bad thing
 about this is that if the user doesn't clean away the in-source
 CMakeCache.txt file, subsequent out-of-source builds will fail. Perhaps you
 can do something like this:

 # check for polluted source tree
 if(EXISTS ${CMAKE_SOURCE_DIR}/CMakeCache.txt OR
EXISTS ${CMAKE_SOURCE_DIR}/CMakeFiles)
  message(FATAL_ERROR
CMakeCache.txt or CMakeFiles exists in source directory!)
 endif()
 # make sure the user doesn't play dirty with symlinks
 get_filename_component(srcdir ${CMAKE_SOURCE_DIR} REALPATH)
 get_filename_component(bindir ${CMAKE_BINARY_DIR} REALPATH)
 # disallow in-source builds
 if(${srcdir} STREQUAL ${bindir})
  message(FATAL_ERROR In-source builds are forbidden!)
 endif()

 
  The second half of the question is of course, is there an easy way to
  clean out a source tree if an in-source build was accidentally kicked
  off?  (short of dividing the files by their timestamp and removing the
  newer ones, etc..)

 No, simply because CMake cannot. Your build system might have something
 like the following:

 execute_process(COMMAND echo BOOM  ${CMAKE_BINARY_DIR}/boom.txt
 VERBATIM)

 CMake never knows that the file boom.txt is written, and therefor can't
 clean it away.


I think this is a bit of a red herring.  CMake could be perfectly capable of
cleaning up after itself (i.e. its own files).
If the user is doing things like making a bunch of files that CMake isn't
aware of (that aren't generated), these could be added to
ADDITIONAL_MAKE_CLEAN_FILES, or a new property could be added for custom
files that are to be deleted on a distclean.

-- 
Philip Lowman
___
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] Disallowing in-source builds

2010-10-07 Thread kent williams
Two things:  You should have your source code under version control,
for many reasons, but in this context:

1. The VC system can tell you which files are unknown to it, i.e.
those CMake pooped all over your source tree.
2. You can make sure your work is checked in, then delete the source
directory and start fresh.

Second: The post-CMake cleanup is by no means straightforward, because
of what CMake's capabilities. You can have it generate blizzards of
thousands of new files if that's what you want.  CMake would, in
effect, to run its configure process in reverse to truly clean up from
any arbitrary set of CMakeLists.txt instructions.

This would be a huge effort, and all to solve a problem that is
actually between the chair and the keyboard.

Software -- especially software for developers -- can't prevent every
dumb thing a user can do. If it tries, it will end up tied in knots,
and become inflexible and annoying to use.
___
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] Disallowing in-source builds

2010-10-07 Thread aaron.meadows
Yeah, I think I'll go with something like what you are saying.  I wonder
if I can remove the CMakeFiles directory and the CMakeCache.txt file
from within the CMakeLists script... 

Aaron C. Meadows 

 Hi all.
 
 
 
 Is there a good way to disallow in-source builds?  Ideally, I'd like
to
 prevent it before any cruft is written into the source tree.  I
 experimented with writing a function into my CMakelists file and
calling
 it.  The function checked if CMAKE_BINARY_DIR was equal to
 CMAKE_SOURCE_DIR and messaged a FATAL_ERROR if that was the case.
This
 works ok, but still generates a CMakeFiles directory and a
 CMakeCache.txt file.

I don't think there's a way to prevent that from happening. The bad
thing about this is that if the user doesn't clean away the in-source
CMakeCache.txt file, subsequent out-of-source builds will fail. Perhaps
you can do something like this:

# check for polluted source tree
if(EXISTS ${CMAKE_SOURCE_DIR}/CMakeCache.txt OR
EXISTS ${CMAKE_SOURCE_DIR}/CMakeFiles)
  message(FATAL_ERROR
CMakeCache.txt or CMakeFiles exists in source directory!)
endif()
# make sure the user doesn't play dirty with symlinks
get_filename_component(srcdir ${CMAKE_SOURCE_DIR} REALPATH)
get_filename_component(bindir ${CMAKE_BINARY_DIR} REALPATH)
# disallow in-source builds
if(${srcdir} STREQUAL ${bindir})
  message(FATAL_ERROR In-source builds are forbidden!)
endif()

 
 The second half of the question is of course, is there an easy way to
 clean out a source tree if an in-source build was accidentally kicked
 off?  (short of dividing the files by their timestamp and removing the
 newer ones, etc..)

No, simply because CMake cannot. Your build system might have something
like the following:

execute_process(COMMAND echo BOOM  ${CMAKE_BINARY_DIR}/boom.txt
VERBATIM)

CMake never knows that the file boom.txt is written, and therefor can't
clean it away. The only reasonable way I know of is using git
(http://git-scm.com):

git clean -df

will remove all the files and directories that are not part of the
repository. With tar-ball builds it's easier. Just wipe the source tree
and unpack again.


Michael

This email was sent to you by Thomson Reuters, the global news and information 
company.
Any views expressed in this message are those of the individual sender, except 
where the sender specifically states them to be the views of Thomson Reuters.


___
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] Disallowing in-source builds

2010-10-07 Thread kent williams
You could try, though it makes my brain hurt to think about it.  Why
go to such lengths to protect users from themselves?

On Thu, Oct 7, 2010 at 11:57 AM,  aaron.mead...@thomsonreuters.com wrote:
 Yeah, I think I'll go with something like what you are saying.  I wonder
 if I can remove the CMakeFiles directory and the CMakeCache.txt file
 from within the CMakeLists script...

 Aaron C. Meadows

 Hi all.



 Is there a good way to disallow in-source builds?  Ideally, I'd like
 to
 prevent it before any cruft is written into the source tree.  I
 experimented with writing a function into my CMakelists file and
 calling
 it.  The function checked if CMAKE_BINARY_DIR was equal to
 CMAKE_SOURCE_DIR and messaged a FATAL_ERROR if that was the case.
 This
 works ok, but still generates a CMakeFiles directory and a
 CMakeCache.txt file.

 I don't think there's a way to prevent that from happening. The bad
 thing about this is that if the user doesn't clean away the in-source
 CMakeCache.txt file, subsequent out-of-source builds will fail. Perhaps
 you can do something like this:

 # check for polluted source tree
 if(EXISTS ${CMAKE_SOURCE_DIR}/CMakeCache.txt OR
    EXISTS ${CMAKE_SOURCE_DIR}/CMakeFiles)
  message(FATAL_ERROR
    CMakeCache.txt or CMakeFiles exists in source directory!)
 endif()
 # make sure the user doesn't play dirty with symlinks
 get_filename_component(srcdir ${CMAKE_SOURCE_DIR} REALPATH)
 get_filename_component(bindir ${CMAKE_BINARY_DIR} REALPATH)
 # disallow in-source builds
 if(${srcdir} STREQUAL ${bindir})
  message(FATAL_ERROR In-source builds are forbidden!)
 endif()


 The second half of the question is of course, is there an easy way to
 clean out a source tree if an in-source build was accidentally kicked
 off?  (short of dividing the files by their timestamp and removing the
 newer ones, etc..)

 No, simply because CMake cannot. Your build system might have something
 like the following:

 execute_process(COMMAND echo BOOM  ${CMAKE_BINARY_DIR}/boom.txt
 VERBATIM)

 CMake never knows that the file boom.txt is written, and therefor can't
 clean it away. The only reasonable way I know of is using git
 (http://git-scm.com):

 git clean -df

 will remove all the files and directories that are not part of the
 repository. With tar-ball builds it's easier. Just wipe the source tree
 and unpack again.


 Michael

 This email was sent to you by Thomson Reuters, the global news and 
 information company.
 Any views expressed in this message are those of the individual sender, 
 except where the sender specifically states them to be the views of Thomson 
 Reuters.


 ___
 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

___
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] Disallowing in-source builds

2010-10-07 Thread aaron.meadows
I'd rather make it as hard as possible to form bad habits.  It would also be 
helpful to me.  I've moved to the console and typed cmake . several times 
thinking I was in the build directory, and then cussed quite a bit while 
digging through removing cruft. (Points on Version Control taken, I'll take 
care of that shortly...)

Aaron C. Meadows 

-Original Message-
From: cmake-boun...@cmake.org [mailto:cmake-boun...@cmake.org] On Behalf Of 
kent williams
Sent: Thursday, October 07, 2010 12:55 PM
To: CMake ML
Subject: Re: [CMake] Disallowing in-source builds

You could try, though it makes my brain hurt to think about it.  Why
go to such lengths to protect users from themselves?

On Thu, Oct 7, 2010 at 11:57 AM,  aaron.mead...@thomsonreuters.com wrote:
 Yeah, I think I'll go with something like what you are saying.  I wonder
 if I can remove the CMakeFiles directory and the CMakeCache.txt file
 from within the CMakeLists script...

 Aaron C. Meadows

 Hi all.



 Is there a good way to disallow in-source builds?  Ideally, I'd like
 to
 prevent it before any cruft is written into the source tree.  I
 experimented with writing a function into my CMakelists file and
 calling
 it.  The function checked if CMAKE_BINARY_DIR was equal to
 CMAKE_SOURCE_DIR and messaged a FATAL_ERROR if that was the case.
 This
 works ok, but still generates a CMakeFiles directory and a
 CMakeCache.txt file.

 I don't think there's a way to prevent that from happening. The bad
 thing about this is that if the user doesn't clean away the in-source
 CMakeCache.txt file, subsequent out-of-source builds will fail. Perhaps
 you can do something like this:

 # check for polluted source tree
 if(EXISTS ${CMAKE_SOURCE_DIR}/CMakeCache.txt OR
    EXISTS ${CMAKE_SOURCE_DIR}/CMakeFiles)
  message(FATAL_ERROR
    CMakeCache.txt or CMakeFiles exists in source directory!)
 endif()
 # make sure the user doesn't play dirty with symlinks
 get_filename_component(srcdir ${CMAKE_SOURCE_DIR} REALPATH)
 get_filename_component(bindir ${CMAKE_BINARY_DIR} REALPATH)
 # disallow in-source builds
 if(${srcdir} STREQUAL ${bindir})
  message(FATAL_ERROR In-source builds are forbidden!)
 endif()


 The second half of the question is of course, is there an easy way to
 clean out a source tree if an in-source build was accidentally kicked
 off?  (short of dividing the files by their timestamp and removing the
 newer ones, etc..)

 No, simply because CMake cannot. Your build system might have something
 like the following:

 execute_process(COMMAND echo BOOM  ${CMAKE_BINARY_DIR}/boom.txt
 VERBATIM)

 CMake never knows that the file boom.txt is written, and therefor can't
 clean it away. The only reasonable way I know of is using git
 (http://git-scm.com):

 git clean -df

 will remove all the files and directories that are not part of the
 repository. With tar-ball builds it's easier. Just wipe the source tree
 and unpack again.


 Michael

 This email was sent to you by Thomson Reuters, the global news and 
 information company.
 Any views expressed in this message are those of the individual sender, 
 except where the sender specifically states them to be the views of Thomson 
 Reuters.


 ___
 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

___
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


This email was sent to you by Thomson Reuters, the global news and information 
company.
Any views expressed in this message are those of the individual sender, except 
where the sender specifically states them to be the views of Thomson Reuters.


___
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] Disallowing in-source builds

2010-10-06 Thread Philip Lowman
On Wed, Oct 6, 2010 at 2:10 PM, aaron.mead...@thomsonreuters.com wrote:

  *Hi all.*

 * *

 *Is there a good way to disallow in-source builds?  Ideally, I’d like to
 prevent it before any cruft is written into the source tree.  I experimented
 with writing a function into my CMakelists file and calling it.  The
 function checked if CMAKE_BINARY_DIR was equal to CMAKE_SOURCE_DIR and
 messaged a FATAL_ERROR if that was the case.  This works ok, but still
 generates a CMakeFiles directory and a CMakeCache.txt file.*



 * **The second half of the question is of course, is there an easy way to
 clean out a source tree if an in-source build was accidentally kicked off?
 (short of dividing the files by their timestamp and removing the newer ones,
 etc..)*


CMake doesn't have a command to clean up after itself which seems to be what
you're asking for (it would help for both use-cases you specify).  This is
kind of related to my ticket asking for a distclean target, so I'll just
throw it out there in case anyone has some free time on their hands.

http://www.cmake.org/Bug/view.php?id=6647

-- 
Philip Lowman
___
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