1

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?

Steve Lorimer
  • 27,059
  • 17
  • 118
  • 213
  • Have you considered patching the upstream `CMakeLists.txt` to install/export targets? – Stephen Newell May 10 '21 at 12:50
  • Upstream's cmake is a total mess - each target pulls headers from multiple different locations within the source tree - including several files with the same name in each of these different locations - hence installing all the headers to somewhere like `/usr/local/include` is not really viable. I would rather just *"install"* the source tree to somewhere like `/opt` and import the targets from there - and ideally, via their `CMakeLists.txt` – Steve Lorimer May 10 '21 at 12:59
  • 3
    CMake has no ability to parse `CMakeLists.txt` and extract some its artifacts without "executing" it. So you should either to find these artifacts on disk, using `find_` commands, or patch (wrap) that `CMakeLists.txt` with install/export, so it will produce new CMake script which describes these artifacts. – Tsyvarev May 10 '21 at 13:15
  • @Tsyvarev ok, thanks - I guess that was the answer I was looking for! (not the one I was hoping for though!) – Steve Lorimer May 10 '21 at 13:16
  • 1
    Actually the type of target you're creating is not the one I'd use (,at least if you want to create the same type of targets that a configuration script would create). Targets that are already available via file system are usually created as `IMPORTED` targets, but in that case you need to specify the exact locations of the library files/include dirs ect, as target properties/via `target_include_directories(INTERFACE)`; `file(GLOB[_RECURSE])` or `find_library` may help find the libs. I'd put the generated imported targets in a `Find.cmake` script... – fabian May 10 '21 at 19:57
  • 1
    Perhaps adding the external project to as subdir when building it and retrieving some of the target properties and writing the info to a file in an appropriate format via `configure_file` or `file(WRITE)` could be helpful... – fabian May 10 '21 at 20:02

0 Answers0