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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:08:56+00:00 2026-05-23T06:08:56+00:00

I’m currently using recursive make and autotools and am looking to migrate to CMake

  • 0

I’m currently using recursive make and autotools and am looking to migrate to CMake for a project that looks something like this:

lx/ (project root)
    src/
        lx.c (contains main method)
        conf.c
        util/
            str.c
            str.h
            etc.c
            etc.h
        server/
            server.c
            server.h
            request.c
            request.h
        js/
            js.c
            js.h
            interp.c
            interp.h
    bin/
        lx (executable)

How should I go about this?

  • 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-23T06:08:57+00:00Added an answer on May 23, 2026 at 6:08 am

    If there’s never any source higher than the lx/src directory, then there’s no need for the lx/CMakeLists.txt file. If there is, it should look something like this:

    cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
    project(lx)
    
    add_subdirectory(src)
    add_subdirectory(dir1)
    add_subdirectory(dir2)
    
    # And possibly other commands dealing with things
    # directly in the "lx" directory
    

    …where the subdirectories are added in library dependency order. Libraries that depend on nothing else should be added first, and then libraries that depend on those, and so on.

    lx/src/CMakeLists.txt

    cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
    project(lx_exe)
    
    add_subdirectory(util)
    add_subdirectory(js)
    add_subdirectory(server)
    
    set(lx_source_files conf.c lx.c)
    add_executable(lx ${lx_source_files})
    
    target_link_libraries(lx server)
      # also transitively gets the "js" and "util" dependencies
    

    lx/src/util/CMakeLists.txt

    set(util_source_files
      etc.c
      etc.h
      str.c
      str.h
    )
    add_library(util ${util_source_files})
    

    lx/src/js/CMakeLists.txt

    set(js_source_files
      interp.c
      interp.h
      js.c
      js.h
    )
    add_library(js ${js_source_files})
    
    target_link_libraries(js util)
    

    lx/src/server/CMakeLists.txt

    set(server_source_files
      request.c
      request.h
      server.c
      server.h
    )
    add_library(server ${server_source_files})
    
    target_link_libraries(server js)
      # also transitively gets the "util" dependency
    

    Then, in a command prompt:

    mkdir lx/bin
    cd lx/bin
    
    cmake ..
      # or "cmake ../src" if the top level
      # CMakeLists.txt is in lx/src
    
    make
    

    By default, the lx executable will end up in the “lx/bin/src” directory using this exact layout. You can control what directory it ends up in by using the RUNTIME_OUTPUT_DIRECTORY target property and the set_property command.

    http://www.cmake.org/cmake/help/cmake-2-8-docs.html#prop_tgt:RUNTIME_OUTPUT_DIRECTORY

    http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:set_property

    Refer to target_link_libraries libs either by CMake target name, if the lib is built as a CMake target via add_library, or by full path to the library file otherwise.

    See also, the output of “cmake –help-command target_link_libraries”, or any other cmake command, and the full online documentation for cmake commands found here:

    http://www.cmake.org/cmake/help/cmake-2-8-docs.html#section_Commands

    http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:target_link_libraries

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
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,

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.