Git Product home page Git Product logo

Comments (6)

lukka avatar lukka commented on May 21, 2024

@LegalizeAdulthood This template proposes an out-of-tree build (they are indeed side by side), as there is no mixture of CMakeCache.txt (and all the generated build-system files) with source files, e.g. you can delete the builds directory and no source file is going to be deleted.
Let me know your feedback about this, and please create a pull request with the desired approach as new ways of doing things are always welcome.

from cppcmakevcpkgtemplate.

LegalizeAdulthood avatar LegalizeAdulthood commented on May 21, 2024

I'm not sure why you say they are "side by side" when the preset is putting the binary directory as a subdirectory of sourcedir as shown in the snippet I quoted above. Isn't ${sourceDir} the top-level source directory from my git checkout?

from cppcmakevcpkgtemplate.

lukka avatar lukka commented on May 21, 2024

@LegalizeAdulthood CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR are not the same, hence this is not a in-source-build.
It is useful to list the benefits of this solution:

  • it allows to have multiple binary directories, that is multiple build configurations for a single source tree:
    • each binary directory gets a different CMakeCache.txt, that is can be configured with totally different values.
    • each binary directory is completely isolated from the others.
  • a binary directory could be deleted any time, no harm and no leftover would be there, and it helps to maintain a clean source tree.

And downsides:

  • the .gitignore file needs to be augmented to ignore the subtree of binary directories.
  • anything else?

@LegalizeAdulthood I think there are multiple similar ways to solve a problem, so I welcome you to submit a PR with your proposal.

from cppcmakevcpkgtemplate.

LegalizeAdulthood avatar LegalizeAdulthood commented on May 21, 2024

it allows to have multiple binary directories
a binary directory could be deleted any time

These benefits aren't because you've nested the binary directory in the source directory, it's simply because they aren't the same directory.

I've never seen anyone define "out of tree builds" as just saying that CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR don't have the same value. "Out of tree" means literally that -- the build directory isn't in the source tree, hence no need to modify the .gitignore, etc.

The Getting Started page in cmake docs initially implies that "out of source" is just considered having different values as you say, but if you look at the Makefile generator example at the bottom of the page, they are obviously showing the build directory as a peer to the source directory and not as a child:

# With source code in the directory MyProject
# to build MyProject-debug create that directory, cd into it and
ccmake ../MyProject -DCMAKE_BUILD_TYPE=Debug
# the same idea is used for the release tree MyProject-release
ccmake ../MyProject -DCMAKE_BUILD_TYPE=Release

...which is how I always envisioned "out of source" to literally mean that -- no build artifacts are within the source directory tree whatsoever. To visualize it more explicitly, it looks like this:

MyProject/
MyProject/CMakeLists.txt
MyProject/main.cpp
MyProject/...
debug/
debug/CMakeCache.txt
debug/main.o
debug/...
release/
release/CMakeCache.txt
release/main.o
release/...

You are then relieved from having to mark these in-source-tree build directories as being ignored by whatever version control system you're using.

from cppcmakevcpkgtemplate.

lukka avatar lukka commented on May 21, 2024

@LegalizeAdulthood I see you are not satisfied by my answers and I am still open to discuss this further if you deem so.
As always I am interested in receiving contributions for a better C++ project template, do not hesitate to open a PR on this repository, thank you.

from cppcmakevcpkgtemplate.

lukka avatar lukka commented on May 21, 2024

@LegalizeAdulthood closing this stale discussion.

from cppcmakevcpkgtemplate.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.