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 7643617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:29:35+00:00 2026-05-31T09:29:35+00:00

I am just starting playing with CMake. I have something like: /DEV |– lib1

  • 0

I am just starting playing with CMake. I have something like:

/DEV
 |-- lib1
        | CMakeLists.txt

 |-- lib2
        | CMakeLists.txt

 |-- exe1
        | CMakeLists.txt

/BUILD
 |-- lib1
 |-- lib2
 |-- exe1

/INSTALL
 |-- include
 |-- lib
 |-- bin

I would like to:

  • Build each lib and exe independently when needed. (So I suppose I must add a CMakeLists.txt file for each lib and exe);
  • When building, include and lib directories should reference INSTALL directory; (is it a good idea?)
  • When building, add dependencies to other lib and rebuild them if not up to date.

I dont have any clue where to start. Please help…

  • 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-31T09:29:36+00:00Added an answer on May 31, 2026 at 9:29 am

    You don’t need individual CMakeLists.txt to build targets independently. Say you have one top level CMakeLists.txt with:

    ADD_LIBRARY(lib1 ${all_lib1_files})
    ADD_LIBRARY(lib2 ${all_lib2_files})
    ADD_EXECUTABLE(exe1 ${all_exe1_files})
    TARGET_LINK_LIBRARIES(lib2 lib1)  # lib2 now depends on lib1
    TARGET_LINK_LIBRARIES(exe1 lib2)  # exe1 now depends on lib2 and lib1
    

    Then you can build just lib1 by running make lib1 or msbuild lib1.vcxproj, etc. You can achieve the same by having individual CMakeLists.txt files per target – it’s up to you if you think it’s worth it.

    If your project imports these targets using FIND_LIBRARY or FIND_PACKAGE, then they won’t be rebuilt if they’re not up to date. Ultimately, if you want out-of-date dependencies to be automatically rebuilt, you need to let CMake know about the sources and rules for the dependent target, i.e. the CMakeLists.txt file needs to have added the target using ADD_LIBRARY or ADD_EXECUTABLE.

    You shouldn’t then need to reference the INSTALL directory (except in INSTALL commands I imagine), since CMake will implicitly use libs/exes build locations rather than installed locations when linking targets.

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

Sidebar

Related Questions

I'm just starting out with IoC frameworks and have been playing with Autofac. In
I'm just starting out playing around with Linq Expressions and I've hit a wall.
Just starting out in asp.net. Have just created a login.aspx page in my site
Just starting out with subversion, have set up repos for 3 current projects and
Im just starting with localization today and need some information. I have a project
I'm just starting with SubSonic 3 and playing with the SimpleRepository approach. What's the
I'm just starting out with unit testing in C#. I have been reading about
I have a simple hello, world servlet application that I am just playing around
I've just starting playing with Apache, and I wanted know. If I base myself
I just started playing with scala and have been using the Scala By Example

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.