Library's CMake generates DLL. Application's CMake wants LIB

My library has minimal, straightforward CMake code with the pertinent lines

add_library(MyLib <sources>)

install(
    TARGETS MyLib
    LIBRARY DESTINATION ${destination}/lib
    RUNTIME DESTINATION ${destination}/lib
    COMPONENT Libraries)
install(
    FILES mylib.h
    DESTINATION ${destination}/include
    COMPONENT Headers)

When executed under Windows, the system installs a .DLL file.

My application has minimal, straightforward CMake code to search for my library:

find_path(MyLib_INCLUDE_DIR mylib.h)
find_library(MyLib_LIBRARIES NAMES MyLib)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MyLib DEFAULT_MSG MyLib_LIBRARIES MyLib_INCLUDE_DIR)

Which works under Linux, but under Windows results in

-- Could NOT find MyLib (missing: MyLib_LIBRARIES)

From experimentation I know that this error occurs whenever there is only a .DLL file, and no associated .LIB import library.

Shall I correct MyLib to create a .LIB, or is it possible to modify my application so that it is satisfied with a .DLL only? And how?

((cross-posting: https://stackoverflow.com/questions/59390335))

Probably an even better solution would be for MyLib to produce the appropriate config files.
In any case: in typical scenario on windows you need *.lib for linking and *.dll for running.

In the meantime I found out that a .LIB file is generated, but not installed. I edited the question to show the install statements. So my question boils down to: How to install the .LIB file?

.lib files are installed as ARCHIVE targets, not as LIBRARY targets. So adding an ARCHIVE DESTINATION ${destination}/lib argument to your install() command should help.

Great. Just works. Thank you, Petr. Would you like to post your answer at https://stackoverflow.com/questions/59390335? Otherwise I will do so.

Feel free to post it to SO yourself. See my SO profile for why I don’t (currently) want to post it myself.

You’ve already worked out the underlying issue you were facing, but in case it is of interest, you can see this and other related material covered in my CppCon 2019 talk: