Proper way to install library with external dependencies ?

Hello

My library (odbc++) has a public dependency on ODBC32.dll,

I can successfully use:

find_library(ODBC_LIBRARY_PATH "ODBC32")
target_link_libraries(odbc++ PUBLIC "${ODBC_LIBRARY_PATH}")

and cmake would find the associated .lib file from the Windows SDK, and link with it.

But when I install and export odbc++, the config file emitted is very bad:

set_target_properties(odbc++ PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.22000.0/um/x64/odbc32.lib")

This is a hard-coded dependency on my local version of Windows SDK !

Why does CMake hard-code any library path at all in the export file ?

Is there a way to mark the library as a “SYSTEM” library, and instruct cmake to maybe use find_library() in the export file ?

I guess the more general question is how to export a library with “floating” dependencies, so the consuming project would try to locate them (with find_package() for example) ?

Sorry I feel I don’t know how to express this any better, I am sure such a scenario appeared many times before


Thank you
Timothy Madden