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

  • SEARCH
  • Home
  • 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 6780399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:30:05+00:00 2026-05-26T16:30:05+00:00

How do I tell cmake where it should output its build data? Let’s say

  • 0

How do I tell cmake where it should output its build data?

Let’s say I have a dir with the source code called src/,
and then since cmake outputs a lot of files I would like him to put all of that in
a dir called build/.
BUT I would like him to put the generated Makefile in the project root,
so I don’t have to go into the build dir to build the application.

Is this possible with cmake?

I have managed to get the cmake out put if I fun cmake in the build dir like this:

cd build/
cmake ../src/
make
./hello 

But it would be nice to stay in the project root and type something like this

cmake
make 
./hello

I guess that I need to put a CMakeList.txt in the project root with some magic commands telling him where he could put the object files and where he can find the source code.

Thanks


Update:
Since my question is a little bit vague.

After I have run the cmake commands this is how I would like my tree to look like:

src/CMakeLists.txt
src/hello.c 
src/hello.h

build/CMakeCache.txt  
build/CMakeFiles/
build/cmake_install.cmake  

CMakeLists.txt
Makefile

So the question is how should the CMakeLists.txt look like in this setup.

  • CMakeLists.txt
  • src/CMakeLists.txt

But maybe that is not possible?

  • 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-26T16:30:05+00:00Added an answer on May 26, 2026 at 4:30 pm

    BUT I would like him to put the generated Makefile in the project root, so I don’t have to go into the build
    dir to build the application.

    cmake not designed for that, as I know,
    BUT you can stay in the project root and type:
    make -C build
    ./hello
    with custom build rules or set_target_properties,
    you can force cmake to put result executable to
    sources directory or you can use
    ./build/hello

    Type “cd build && cmake ..” you need only once,
    after that make will automaticaly start cmake, if something
    changed.

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

Sidebar

Related Questions

please tell me how to get and bind data to UltraGrid dynamically on each
I have a plugin with a model called profile. Also I have a profile
I have dual head (VGA output, DVI or HDMI output) from 1 PC using
As the title says, I want to have a build tool that quite much
I'm building a file using the CMake Build System and Microsoft's Visual C++ compiler.
Please tell me whats wrong with this c# code.. public bool CloseCOMPort() { try
We are using CMake to manage our builds and have a rather large project
Tell me please, how to use getBulkUserInformationFor: method correctly? I have Could not authenticate
How do I achieve the following in CMake (using version 2.8.5)? I have documentation
When I try to update a user, let's say his account balance $this->User->id =

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.