Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

CMake can't find freetype2 installed with homebrew

The error:

-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
CMake Error at CMakeLists.txt:13 (find_package):
  Could not find a package configuration file provided by "freetype" with any
  of the following names:

    freetypeConfig.cmake
    freetype-config.cmake

  Add the installation prefix of "freetype" to CMAKE_PREFIX_PATH or set
  "freetype_DIR" to a directory containing one of the above files.  If
  "freetype" provides a separate development package or SDK, be sure it has
  been installed.


-- Configuring incomplete, errors occurred!

And this is my CMakeLists.txt:

cmake_minimum_required(VERSION 3.19)

project(ogle VERSION 1.0.0
            DESCRIPTION "Our first project" 
            LANGUAGES CXX)

set(CXX_STANDARD 20)
set(CXX_STANDARD true)
set(INCLUDE_DIRECTORIES ${PROJECT_SOURCE_DIR}/include)

find_package(glfw3 CONFIG REQUIRED)
find_package(glm CONFIG REQUIRED)
find_package(freetype CONFIG REQUIRED)
find_package(assimp CONFIG required)

add_executable(ogle /src/*.cpp ./*.cpp /src/*.c)

target_link_libraries(ogle PUBLIC glfw3::glfw3 glm::glm freetype::freetype PRIVATE assimp::assimp)

How to troubleshoot this? Freetype is in the same directory where all the other stuff is. Is this a known issue with the library?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Freetype2 does not ship with a CMake Config or module.
But it does come with a pkg-config configuration file, so use that:

find_package(PkgConfig REQUIRED)
pkg_check_modules(freetype2 REQUIRED IMPORTED_TARGET freetype2)
target_link_libraries(ogle PUBLIC PkgConfig::freetype2)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading