I'd like to import a library retrieved with find_package, and then export an alias. Anyway this code
set(mylib_DIR ${lib_install_dir})
find_package(my_lib 3.5.2 CONFIG REQUIRED)
# find package returns library_dir and include_dir, no target
set(my_lib mylibname)
add_library(${my_lib}_imp SHARED IMPORTED)
set_property(TARGET ${my_lib}_imp PROPERTY
IMPORTED_LOCATION ${library_dir})
target_include_directories(${my_lib}_imp INTERFACE ${include_dir})
add_library(myns::${my_lib} ALIAS ${my_lib}_imp)
set_property(TARGET ${my_lib}_imp PROPERTY EXPORT_NAME myns::${my_lib}) -> error
gives an error
CMake Error at cmake/libigl.cmake:446 (set_property):
EXPORT_NAME property can't be set on imported targets ("mylib_imp")
Is there a way to export an imported library this manner? Is there a workaround, maybe creating a dummy target, I don't know... Note tha find_package in my case retrieves only the shared lib and the includes, as from an installed library, and declares no target. For CMake there are no sources here, just a bunch of files. Thanks in advance