How to link with Windows system libraries with CMake?

I am creating a simple Windows application that needs to be associated with gdiplus and winmm.
I used to

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

but CMake does not find the library when using the Visual Studio 2015 target using Visual C ++ Build Tools. According to the answer here, I should probably give up find_libraryand just use

target_link_libraries(target gdiplus.lib)

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

+4
source share

Source: https://habr.com/ru/post/1661373/


All Articles