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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:09:46+00:00 2026-05-13T13:09:46+00:00

In CMake, I’m trying to build a project that includes libraries for multiple different

  • 0

In CMake, I’m trying to build a project that includes libraries for multiple different processor architectures, compiled by different toolchains. For each architecture, static libraries are built in multiple subdirectories, and then collected into a shared library in the root directory. So far, I haven’t been able to figure this out.

The closest I’ve come so far is to use add_custom_command and add_custom_target in the subdirectories to produce the .a files and then try to collect them into a .so in the root directory using add_custom_command and add_custom_target again. But if I make the .so dependency point to the list of custom command outputs, the makefile says “No rule to make …” because the custom command outputs are not exported out of the subdirectory. So I tried making the .so dependency point to the list of custom targets in the subdirectory, and it complains that it can’t find a file with that name.

To put it in code form, here is what I have in a subdirectory:

add_custom_command(OUTPUT subout.a COMMAND ${MYAR} ...)
add_custom_target(subout_target DEPENDS subout.a)

In the root directory, I tried this:

add_custom_command(OUTPUT my.so COMMAND ${MYLD} ... DEPENDS sub/subout.a)
add_custom_target(dll ALL DEPENDS my.so)

And I get “No rule to make target ‘sub/subout.a’, needed by ‘my.so’. Stop.” Which makes sense because add_custom_command targets are not exported out of a directory.

And I tried this:

add_custom_command(OUTPUT my.so COMMAND ${MYLD} ... DEPENDS subout_target)
add_custom_target(dll ALL DEPENDS my.so)

This will actually cause the sub/subout.a file to be generated, but then it dies, saying “No rule to make target ‘subout_target’…”

I think what I really want is to be able to mimic the add_library behavior for multiple different architectures. But apparently, CMake doesn’t want me to do that… 🙂

Any ideas?

  • 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-13T13:09:46+00:00Added an answer on May 13, 2026 at 1:09 pm

    I presume you need to use add_dependencies to define dependencies between targets defined using add_custom_target. The DEPENDS option is used to specify file-level dependencies in custom rules but not target-level dependencies.

    For example, command generating .obj file as output uses DEPENDS to specify it depends on .cpp file. Also, a target can be dependant on a single file, not only on other targets. So, for file-level dependendies, use DEPENDS option, but add_dependencies for target-level.

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

Sidebar

Ask A Question

Stats

  • Questions 268k
  • Answers 268k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer No, the interface contains only method signatures. You cannot have… May 13, 2026 at 1:10 pm
  • Editorial Team
    Editorial Team added an answer I'm not sure if your example will work (did you… May 13, 2026 at 1:10 pm
  • Editorial Team
    Editorial Team added an answer MenuStrip uses a custom renderer, it doesn't leave it up… May 13, 2026 at 1:10 pm

Related Questions

I'm trying CTest in CMake in order to automatically run some of my tests
I'm wondering how I can use bash command in CMakeLists.txt. What I want is
I am trying to automate my build process with cmake. There is currently only
I would like to pass some options to a compiler. The option would have
I'm currently converting a small C project from autotools to CMake . In the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.