Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6978405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:45:06+00:00 2026-05-27T17:45:06+00:00

I have a large-ish codebase which builds several dozen libaries and several executables. The

  • 0

I have a large-ish codebase which builds several dozen libaries and several executables.

The codebase is broken down hierarchically and libraries are build at pretty much every level.

I’ve gone through and placed a CMakeLists.txt file at each directory to build each library.

In each CMakeLists.txt I have used the “project( xxx )” directive. This has defined for me PROJECT_NAME, PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR variables which I make judicious use of.

However, one of the team is unhappy with this approach as he can’t find any real world examples of anyone else having done this. He often cites the KitWare examples as not using this approach and therefore neither should we.

The alternative approach he is advocating is to set these variables up in each makefile which seems much like what “project” gives you.

I really can’t see his point and am making little headway in convincing him otherwise. Can anyone shed any light on the downsides of using the project directive in this way.

I throw myself on your collective wisdom?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:45:07+00:00Added an answer on May 27, 2026 at 5:45 pm

    Firstly, it enables you to use <projectName>_BINARY_DIR and <projectName>_SOURCE_DIR, but that’s not the main advantage. If you give CMake a project name then it will generate build targets for each of the sub-projects in their own directories. This means that whether you’re using GNU Make, Eclipse CDT, XCode, or any of the other supported generators you can build sub-projects individually. For instance with GNU Make each sub-project has its own full build system from it’s own directory.

    You can access the current project name through PROJECT_NAME, and the root project name by CMAKE_PROJECT_NAME.

    Edit: I’ve just realised the below will be standard CMake behaviour for any of its build targets whether they’re projects or not. I’ll keep it here for general information but it is not pertinent to the answer:

    Assume I have a C++ library, and I can generate three binary executables; Main and tests/test1, and examples/ex1. I can either run make in the directory I called CMake from with the ALL target, run make ex1, or I can change directory to examples/ and build the examples with make from that directory. This will build all of the dependent projects and libraries even if they’re somewhere else in the directory structure but won’t build Main or tests/test1 or any libraries that they depend on that examples/ex1 doesn’t. If I then run make from the main directory, it won’t rebuild any of the libraries that examples/ex1 depends on unless their source has changed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an existing large(ish) PHP web app (using Apache and MySQL) which now
I have a large-ish web project which is migrating from classic ASP to ASP.NET
We have a large-ish query here that has several params, and for each one,
I have a large-ish PHP project (hundreds of files) that I've been brought in
I have a large(ish) COM object that works as the back end of my
I've got a large-ish MySQL database which contains weather information. The DB is about
I have a large-ish file (4-5 GB compressed) of small messages that I wish
I am developing a large-ish application in WPF/WCF/NHibernate/etc. and have implemented the MVP pattern
I have several large projects that I work on. Depending on the project and
I'm developing a game with AS3 and AIR. I will have a large-ish quantity

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.