Import targets from external CMakeLists.txt file, having already built the external source

220 views Asked by At

I am trying to integrate the Refinitiv Real-Time SDK into my own application.

I have downloaded the source code and built the libraries.

Typically you would then expect there to be an INSTALL target, which would install the libraries and headers into some location, and then, if we're lucky, a find_package module which we can later use to import the library targets into our own project.

Unfortunately, neither of these are provided.

How then, to import the libraries and their header files into my project?

ExternalProject_Add

I do not want to use the standard ExternalProject_Add to download and build the source code every time I reconfigure my project. (In particular because our CI server will have to do this for every single build.) Rather I want to build it once (and make it part of the CI server's docker image), and then link against the libraries / include the header files directly from where I've copied the source.

add_library INTERFACE

I know that I can create a new INTERFACE library target

find_library(LIB_EMA ema ${REFINITIV_BINARY_DIR})
find_library(LIB_ETA eta ${REFINITIV_BINARY_DIR})
# etc.. for all the refinitiv libraries

add_library(refinitiv INTERFACE)

target_link_libraries(refinitiv INTERFACE
    ${LIB_EMA}
    ${LIB_ETA}
    # etc...
    )

target_include_directories(refinitiv INTERFACE
    ${REFINITIV_SOURCE_DIR/Ema/Include
    ${REFINITIV_SOURCE_DIR/Eta/Include
    # etc...
    )

This is, however, tedious and prone to breaking whenever Refinitiv releases a new SDK version and decides to change a path or link dependency etc

Question:

What I would to do is use their CMakeLists.txt file, but only to access the already-built targets, not to build them as part of my build.

Is this possible?

0

There are 0 answers