Spurious error when export set contains only a namelink
When specifying version and soversion details for a shared library, it is common to want to put the real library and soname link in a runtime component and the namelink in a development component, as shown in the example further below. If the only thing in the development component is a namelink, CMake issues a spurious error for such cases:
CMake Error: INSTALL(EXPORT) given unknown export "Development"
If some other real file is added to the same export set as the namelink, CMake does not complain and the namelink is installed and exported as it should be. A minimal example reproducing the problem is shown below (contents of a.cpp can be anything simple).
cmake_minimum_required(VERSION 3.11)
project(Example)
add_library(myShared SHARED a.cpp)
set_target_properties(myShared PROPERTIES
VERSION 1.2.3
SOVERSION 1
)
install(TARGETS myShared
EXPORT Development
LIBRARY
DESTINATION lib
NAMELINK_ONLY
COMPONENT Development
)
install(TARGETS myShared
EXPORT Runtime
LIBRARY
DESTINATION lib
NAMELINK_SKIP
COMPONENT Runtime
)
install(EXPORT Development
DESTINATION cmake
COMPONENT Development
)
install(EXPORT Runtime
DESTINATION cmake
COMPONENT Runtime
)
This issue was originally reported in !1982 (comment 402031)