Re: [cmake-developers] option to prevent in-source builds

2018-11-09 Thread Eric Noulard
Just a small remark to say this request of "builtin" way to forbid
in-source is quite old:
https://gitlab.kitware.com/cmake/cmake/issues/6672
which find its origin in:
https://cmake.org/Bug/view.php?id=6672

I don't know if the note from that initial discussion are valid nowadays
but the fact that:
"Code in CMakeLists.txt is not even executed until after the cache is
initialized so there would have to be some other way to indicate in the
source tree that it should not be built in-source."
and the fact that
"The cache is initialized before the procedural steps start to run. With
cmake-gui or the cmake command-line "-D" option it is even possible to
store entries in the cache before CMake even parses CMakeLists.txt"
almost implies that this should be done outside CMakeLists.txt

That said, I think that
I would rather have some obviously visible and fixed place like
CMakeInit.json that should be located in the very same directory as the
concerned CMakeLists.txt rather than some list of possible places (cmake/,
cmake/init, .cmake, etc...). The exact path to CMakeInit.json could be
overwritten by some new command line option, like --init-file if for some
reason we want
a configurable place (may be used in various CI scripts occasion).
This file could hold more options than "just forbid in-source" it could
indicate a default generator (which may be different from the usual default
generator on the concerned platform),
some a toolchain. It's usage would be different than the initial cache
precisely because it could work before cache is created.


Le ven. 9 nov. 2018 à 17:03, Ben Boeckel  a écrit :

> On Fri, Nov 09, 2018 at 07:28:54 -0500, Taylor Holberton wrote:
> > A lot of projects that use CMake already have a `./cmake` directory, I
> > would think `./cmake/init.json` would fit nicer as opposed to the hidden
> > directory. I'm not a fan of hidden directories in software projects
> anyway.
>
> There are also `./CMake` directories. HDF5 uses `./config/cmake`. I
> think just claiming a "hidden" directory with exact casing is better.
>
> --Ben
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> https://cmake.org/mailman/listinfo/cmake-developers
>


-- 
Eric
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake-developers


Re: [cmake-developers] option to prevent in-source builds

2018-11-09 Thread Ben Boeckel
On Fri, Nov 09, 2018 at 07:28:54 -0500, Taylor Holberton wrote:
> A lot of projects that use CMake already have a `./cmake` directory, I
> would think `./cmake/init.json` would fit nicer as opposed to the hidden
> directory. I'm not a fan of hidden directories in software projects anyway.

There are also `./CMake` directories. HDF5 uses `./config/cmake`. I
think just claiming a "hidden" directory with exact casing is better.

--Ben
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake-developers


Re: [cmake-developers] option to prevent in-source builds

2018-11-09 Thread Brad King
On 11/09/2018 07:28 AM, Taylor Holberton wrote:
> A lot of projects that use CMake already have a `./cmake` directory,
> I would think `./cmake/init.json` would fit nicer as opposed to the
> hidden directory.

We could have a list of supported places so projects can choose.

> I would prefer an init file be written as a CMake file instead of JSON.

We need to be able to load the file without initializing much.
If it is a CMake language file then people will try to write `if`
conditions to check things that we wouldn't provide access to at
that point.  The idea of this file is to have a purely declarative
specification.  A format like JSON will work well for that.

-Brad
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake-developers


Re: [cmake-developers] option to prevent in-source builds

2018-11-09 Thread Taylor Holberton
A lot of projects that use CMake already have a `./cmake` directory, I
would think `./cmake/init.json` would fit nicer as opposed to the hidden
directory. I'm not a fan of hidden directories in software projects anyway.

I would prefer an init file be written as a CMake file instead of JSON.
JSON is nice because it plays well with GUIs, but I think using CMake
syntax will function better if the file ever needs to be a bit more
complicated.

On Fri, Nov 9, 2018, 07:14 Brad King  On 11/09/2018 05:34 AM, Joachim Wuttke wrote:
> > include(PreventInSourceBuilds)
> >
> > to protect users (and myself) from unintentionally running CMake
> > in the source directory.
> >
> > Would you consider adding this little module to the CMake code base?
>
> If we are going to offer an upstream solution for this I think
> it should be done in a way that avoids ever creating any files
> (like CMakeCache.txt or CMakeFiles) in the first place.  This
> could be achieved by looking for a `.cmake/init.json` file
> at the top of the source tree with declarative information
> about the project's preferences.  One of those settings could
> reject in-source builds.
>
> -Brad
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> https://cmake.org/mailman/listinfo/cmake-developers
>
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake-developers


Re: [cmake-developers] option to prevent in-source builds

2018-11-09 Thread Brad King
On 11/09/2018 05:34 AM, Joachim Wuttke wrote:
> include(PreventInSourceBuilds)
> 
> to protect users (and myself) from unintentionally running CMake
> in the source directory.
> 
> Would you consider adding this little module to the CMake code base?

If we are going to offer an upstream solution for this I think
it should be done in a way that avoids ever creating any files
(like CMakeCache.txt or CMakeFiles) in the first place.  This
could be achieved by looking for a `.cmake/init.json` file
at the top of the source tree with declarative information
about the project's preferences.  One of those settings could
reject in-source builds.

-Brad
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake-developers