[CMake] FindFreetype works with MinGW but not Visual Studio?

Stuart Mentzer Stuart_Mentzer at objexx.com
Thu Jul 21 11:41:36 EDT 2016


On 7/21/2016 6:15 AM, Nicholas Braden wrote:
> I'm having a weird issue that is driving me crazy. I've attached a
> minimal test case - it downloads and builds Freetype 2.6.4 as static
> and then configures a project that just calls find_package(Freetype
> REQUIRED). If the attachment is not there, you can find the two text
> files here:
> https://gist.github.com/LB--/34d9dd2d9888fa4479bc9ef61183502c
> Save "my-project-CMakeLists.txt" as "CMakeLists.txt" in a "my-project"
> directory next to the other CMakeLists.txt
>
> When I build with MinGW (cmake -G "MinGW Makefiles") everything works
> smoothly and the find_package command works flawlessly.
>
> However, when I build with Visual Studio (cmake -G "Visual Studio 14
> 2015 Win64") I get this error message:
> Could NOT find Freetype (missing: FREETYPE_LIBRARY) (found version "2.6.4")
>
> Looking in the install prefix, in the lib folder MinGW has a
> "libfreetype.a" and MSVC has a "freetyped.lib". Both should be
> acceptable according to the source code of the FindFreetype module:
> https://github.com/Kitware/CMake/blob/v3.6.0/Modules/FindFreetype.cmake
>
> Here are my build logs:
> MinGW: https://gist.github.com/LB--/b4f1413ba72181de7710b6f916c399f8
> MSVC: https://gist.github.com/LB--/14a2f65dd069aa59c2a5dacd840f3535
>
> I'm using CMake 3.6.0, MinGW-w64 GCC 6.1.0, and Visual Studio 2015
> Update 3 - all on a Windows 10 Pro 64-bit system (build 10586.494).
>
> Does anyone know what is causing this? Why can't the find module
> discover the library archive when building with Visual Studio?
>
> For now I have been working around the issue by manually specifying
> FREETYPE_LIBRARY, which works, but is not desireable.
>
> Thanks for your time,
> Nicholas "LB" Braden
>
>
Hi Nicholas,

I ran in to the same issue: it is due to the 'd' suffix on the debug lib name not being handled. We've got a fixed up FindFreetype.cmake on deck for the next release in https://github.com/Kitware/CMake/blob/next/Modules/FindFreetype.cmake that you can drop into your 3.6.0 installation for now.

Stuart


More information about the CMake mailing list