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 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

Related Questions

I am building a cmake project that includes cuda code. I am unable to
I am using CMake to build my C++ project and it has multiple executables
Question: Can CMake generate build scripts that do not, in any way, use CMake?
I'm building some code using CMake that should be compiled against the ScriptingBridge .
I have been using CMake with C++ to build libraries and executables and would
I am using cmake-gui trying to build opencv but get this error: CMake Error
I have a Cmake project where I use static libraries from another project (which
I have a CMake project that generates a library. I have written a CMake
My CMake C++ project depends on several commercial libraries (only libs and headers are
I'm using CMake for my build system and in the project, we will have

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.