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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:24:15+00:00 2026-05-27T02:24:15+00:00

I’m trying to set up a test project looking like my own project just

  • 0

I’m trying to set up a test project looking like my own project just to get things working first and it looks like this:

/MainProject/inc/main.h
/MainProject/src/main.cpp
/LibProject/inc/test.h
/LibProject/src/test.cpp

I’ve found some tutorials, but I cant find out how to set up this when I have the inc and src folder? How would the CMakeLists.txt files look? Would I have one in /, one in each of the project folders? It seems like I dont need to have one in the inc and src folders?

  • 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-27T02:24:16+00:00Added an answer on May 27, 2026 at 2:24 am

    You need a CMakeLists.txt for each source subdirectory. Your structure should look something like this:

    root
    |-MainProject
    | |-inc
    | | '-main.h
    | |-src
    | | |-main.cpp
    | | '-CMakeLists.txt
    | '-CMakeLists.txt 
    |-LibProject
    | |-inc
    | | '-test.h
    | |-src
    | | |-test.cpp
    | | '-CMakeLists.txt
    | '-CMakeLists.txt
    '-CMakeLists.txt
    

    Content of root/CMakeLists.txt:

    project(MyProject)
    add_subdirectory(MainProject)
    add_subdirectory(LibProject)
    

    Content of LibProject/CMakeLists.txt and MainProject/CMakeLists.txt:

    add_subdirectory(src)
    

    Content of LibProject/src/CMakeLists.txt:

    # Notice name prefix of this variable, set by CMake according
    # to value given with "project()" in the root CMakeLists.txt.
    include_directories(${MyProject_SOURCE_DIR}/LibProject/inc)
    add_library(LibProject test.cpp)
    

    Content of MainProject/src/CMakeLists.txt:

    include_directories(${MyProject_SOURCE_DIR}/MainProject/inc)
    # I assume you want to use LibProject as a library in MainProject.
    include_directories(${MyProject_SOURCE_DIR}/LibProject/inc)
    link_directories(${MyProject_SOURCE_DIR}/LibProject/src)
    add_executable(MainProject main.cpp)
    target_link_libraries(MainProject LibProject)
    

    Then configure and build with:

    $ cd root
    $ mkdir build
    $ cd build
    $ cmake ..
    $ make
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

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.