Chlumsky / msdfgen

Multi-channel signed distance field generator
MIT License
3.91k stars 404 forks source link

Fix pragma(lib, ...) conflicting with cmake #120

Closed Luminiscental closed 3 years ago

Luminiscental commented 3 years ago

The visual studio build seems to use these pragma's to link to the freetype/skia binaries in the source tree, which can cause conflicts when running a cmake build on windows if cmake finds freetype/skia lib files with slightly different names, e.g. libfreetyped.lib, because in this case linking against msdfgen causes "freetype.lib not found" linker errors due to the pragma's even though cmake is correctly linking against the lib files it found.

To fix this issue I've added a simple macro-def to flag when cmake is being used so the pragma's can be disabled when building with cmake (which handles finding the libraries itself) but remain active when using the .sln file.

I've tested building with both cmake and the visual studio project in debug and release on linux and windows and these changes seem to fix any issues without breaking things.