Skip to content

install(EXPORT): 3.19 introduces spurious "includes target ... more than once in the export set"

As reported on discourse, the following code:

add_library(myproj SHARED myproj.c)
set_property(TARGET myproj PROPERTY VERSION 1)
install(TARGETS myproj EXPORT myproj
  ARCHIVE DESTINATION lib COMPONENT development
  LIBRARY DESTINATION lib COMPONENT runtime NAMELINK_SKIP
  RUNTIME DESTINATION bin COMPONENT runtime
  )

install(TARGETS myproj EXPORT myproj LIBRARY DESTINATION lib COMPONENT development NAMELINK_ONLY)
install(EXPORT myproj DESTINATION lib/cmake/myproj)

produces an incorrect error with CMake 3.19.0 and 3.19.1:

CMake Error: install(EXPORT "myproj" ...) includes target "myproj" more than once in the export set.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information