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?
Specify libraries or flags to use when linking a given target and/or its dependents. Usage requirements from linked library targets will be propagated. Usage requirements of a target's dependencies affect compilation of its own sources.
I have been looking to link with Rpcrt4.lib and this worked on windows
target_link_libraries(${"LIB_NAME"} rpcrt4.lib)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With