CMake's find_package() can't find Freetype?

688 Views Asked by At

I am looking for some guidance on adding Freetype to my game made in OpenGL. I am on Windows.

I have downloaded the most recent zip file from here and I have unzipped it into my game folder. I would prefer to keep Freetype in the same place as the game, if possible.

I am using the CMake application to do everything, and I have tried setting the value of Freetype_DIR to almost every folder. I have tried downloading the setup program through freetype-2.3.5-1-setup.exe, and setting Freetype_DIR to all of those too.

So in summary, now I have folders called freetype-2.13.0 and GNUWin32 in the game folder.

This is the error I cannot resolve:

CMake Error at C:/Program Files/CMake/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Freetype (missing: FREETYPE_LIBRARY) (found version
  "2.13.0")
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/CMake/share/cmake-3.25/Modules/FindFreetype.cmake:162 (find_package_handle_standard_args)
  CMakeLists.txt:99 (find_package)


Configuring incomplete, errors occurred!

And this is the Freetype specific code in my CMakeLists.txt:

# Freetype libraries
find_package(Freetype REQUIRED)
target_link_libraries(${PROJ_NAME} ${FREETYPE_LIBRARY})
target_include_directories(${PROJ_NAME} PRIVATE ${FREETYPE_INCLUDE_DIRS})

This is an image of my CMake application:

This is my CMake application with my attempt at linking the correct folder.

I have tried doing include(FindFreetype) as well, but according to this, find_package(Freetype REQUIRED) seems to be preferred. I also used this in order to try to solve my problem, but nothing has worked yet.

I apologize if this is a duplicate of this, but there is not really an answer for that one.

I also want to acknowledge that I may not be setting up Freetype properly, but I am not sure what "properly" would be.

I am using CMake 3.25.1

1

There are 1 best solutions below

0
user873413174137 On

Okay, so I may have figured it out. I haven't actually started using Freetype in the game, but I have found a potential solution to this particular issue.

The correct folder to use is generated from this setup file.

There are 2 names (FREETYPE_LIBRARY_DEBUG & FREETYPE_LIBRARY_RELEASE) under the "Advanced" hidden values. Setting those to the library file included in the GnuWin32/lib seems to have made everything work. I believe that the other two must be set to the /include folder, but I will update this answer if I learn anything else.

The values to set and what I have them set to are:

    FREETYPE_INCLUDE_DIR_freetype2 -> .../freetype-2.13.0/include
    FREETYPE_INCLUDE_DIR_ft2build -> .../freetype-2.13.0/include
    FREEYTPE_LIBRARY_RELEASE -> ...GnuWin32/lib/freetype.lib
    FREEYTPE_LIBRARY_DEBUG -> ...GnuWin32/lib/freetype.lib 

If anyone can provide a better answer, I would love that, as I am not sure if this solution is the right one.