I have a C++ library provided by a third party as pre-built binaries. The package contains .dll
files, corresponding .lib
files and API headers. Now I need to provide a CMakeList.txt
file to install the library on a given path, and a find-foo.cmake
helper, for other CMake projects to find and link against this library. However, it seems not possible to export imported libraries in CMake:
cmake_minimum_required(VERSION 3.11)
project(libfoo)
add_library(libfoo SHARED IMPORTED)
set_property(TARGET libfoo PROPERTY IMPORTED_LOCATION libfoo.dll)
set_property(TARGET libfoo PROPERTY IMPORTED_IMPLIB libfoo.lib)
# This doesn't work:
install(
EXPORT libfoo
NAMESPACE foo::
FILE find-foo.cmake
DESTINATION share/find-foo.cmake
)
So basically what I am trying to do is to install a target as if it was built by CMake. Any workaround?