Module library is installed to LIBRARY instead of RUNTIME

In my CMakeLists I have the following code segment

add_library(myModule MODULE)
install(
  TARGETS myModule 
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION bin
  )

add _library(mySharedLib SHARED)
install(
  TARGETS mySharedLib 
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION bin
  )

If I now install these libraries, then mySharedLib is put to LIBRARY on linux and RUNTIME on windows (as expected by the documentation in https://cmake.org/cmake/help/latest/command/install.html#installing-targets

However the myModule dll is installed to LIBRARY on linux and windows.
Shouldn’t this also be installed to RUNTIME in windows since it is still a dll file?

A key thing that differentiates a MODULE from a SHARED library is that you cannot link to a MODULE library. A MODULE is intended to be loaded dynamically at run time. The only reason DLLs get put in bin is so that any other DLL or executable that links to it can find it at run time (assuming that DLL or executable is in the same directory). Since a MODULE cannot be linked to, it doesn’t have that need, and lib is the more appropriate location for it.

2 Likes

Thanks for the explanation.