In our project, we want to use a third-party library (A) which is built using autotools and which generates an object file (B) which we need @ link 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 fails by stating that it cannot find file A during the check for add_library.
Any fixes or alternative solutions would be greatly appreciated! (changing the third-party library is not an option) thanks!
There are a few issues here:
external_project should be ExternalProject_Add
DEPEND available - the set_source_files_properties command has no effect here. (Here are the properties available on source files)add_library expects a list of source files to be passed, not another CMake target (which A is)add_dependency should be add_dependencies
Apart from those 4 lines it's all OK :-)
So the issue is going to be that you want to include the object file B in the add_library call, but it's not going to be available at configure-time (when CMake is invoked), only at build time.
I think you're going to have to do something like:
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})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With