Using cmake, how to link an object file created by an external_project statement to another library?

In our project, we want to use a third-party library (A), which is built using autotools and which generates the object file (B) that we need, the binding time of one of our libraries (C).

external_project(
    A
    ...
)
set_source_files_properties(B PROPERTIES DEPEND A)
add_library(C ... A)
add_dependency(C B)

I had the impression that this should do the trick, but the cmake command did not work, stating that it could not find file A during the add_library check.

Any corrections or alternative solutions would be helpful! (changing a third-party library is not an option) thanks!

+5
source share
1 answer

There are several issues here:

4 : -)

, , B add_library, configure ( CMake), .

, - :

ExternalProject_Add(
    A
    ...
)

set_source_files_properties(
    ${B} PROPERTIES
    EXTERNAL_OBJECT TRUE  # Identifies this as an object file
    GENERATED TRUE  # Avoids need for file to exist at configure-time
)

add_library(C ... ${B})
+3