[CMake] how to set current source directory relative to external project

hex hex7c3 at gmail.com
Tue Jul 9 16:24:07 EDT 2019


On 09/07/2019 18:25, J Decker wrote:
>
> On Tue, Jul 9, 2019 at 9:38 AM hex <hex7c3 at gmail.com 
> <mailto:hex7c3 at gmail.com>> wrote:
>
>
>     I think the better solution now is to make it relative to build
>     directory and force out of source builds.
>
>
> +1 I think; You said it was generated?  It should be in the build 
> directory anyway :)
> And out of source always.  (makes it easier to source version control)
>
Now that I look at it it seems very obvious. I still have doubts, though:

I guess I am seeing the contents of a build directory as somewhat 
volatile. For most files I want that, to either clean the project or 
override the files.

But what about files I want to archive, such as a tarball or zipped 
documentation: does it make sense to place them into the build 
directory? The files belong to the project, though are not source 
controlled but aren't install targets either.

Another thing I noticed is that my CMAKE_GENERATOR are now buried in 
subfolders. To change that I set PREFIX 
"${CMAKE_BINARY_DIR}/workspaces". Now all external projects are using 
the same prefix and are therefore generated into the same directory 
'workspaces'.

I could even set PREFIX "${CMAKE_SOURCE_DIR}/workspaces" which I'd 
actually prefer.

The default binary directory is per project so I'd also change this to 
BINARY_DIR=${CMAKE_BINARY_DIR}

I'm not concerned about /how/ to do it but rather /if/ it should be 
done. The documentation recommends to stick with the defaults.


Any thoughts on this?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190709/1b49eb4e/attachment.html>


More information about the CMake mailing list