Stewart
Stewart

Reputation: 5022

CMake target doesn't install to component

I have this install code:

add_library(foo SHARED ...)
install(TARGETS foo
  RUNTIME DESTINATION bin  # foo.dll
  LIBRARY DESTINATION lib  # libfoo.so
  COMPONENT libs)
install(FILES conf DESTINATION etc COMPONENT libs)

On linux things work great. After cpack, the -libs package contains everything.

On windows, things don't work great. After cpack I get a -libs package containing etc/conf, but no bin/foo.dll.

If I make install (no component installation), then install_manifest.txt contains everything.

Why isn't foo.dll deployed in the windows component install?

Upvotes: 0

Views: 495

Answers (1)

Stewart
Stewart

Reputation: 5022

This line doesn't do what you think it does:

install(TARGETS foo
  RUNTIME DESTINATION bin  # foo.dll
  LIBRARY DESTINATION lib  # libfoo.so
  COMPONENT libs)

There is no RUNTIME DESTINATION argument. Instead there is a RUNTIME argument, and several commands which affect RUNTIME including DESTINATION and COMPONENT. With correct indenting, what you wrote is:

install(TARGETS foo
  RUNTIME
    DESTINATION bin
  LIBRARY
    DESTINATION lib
    COMPONENT libs
)

Now you can see that COMPONENT only applies to LIBRARY and not RUNTIME. The solution is:

install(TARGETS foo
  RUNTIME
    DESTINATION bin # foo.dll
    COMPONENT libs
  LIBRARY
    DESTINATION lib # libfoo.so
    COMPONENT libs
)

Upvotes: 1

Related Questions