'How to link against Windows system libraries with CMake?

I am building a simple Windows application that needs to link against gdiplus and winmm.
Previously I was using

find_library(GDIPLUS gdiplus)
target_link_libraries(target ${GDIPLUS})

but CMake does not find the library when using the Visual Studio 2015 target with the Visual C++ Build Tools. According to the answer here I should probably drop the find_library and just use

target_link_libraries(target gdiplus.lib)

but I'm not sure if this will only work for Visual Studio or for example also with Cygwin.
So what is the correct (or best) way to link against Windows system libraries from CMake?



Solution 1:[1]

I have been looking to link with Rpcrt4.lib and this worked on windows

target_link_libraries(${"LIB_NAME"} rpcrt4.lib)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1