[CMake] Freetype on linux systems in non-standard directories

Andreas Naumann Andreas-Naumann at gmx.net
Tue Jun 7 16:58:04 EDT 2016


Hey Kristian,

as the documentation 
https://github.com/Kitware/CMake/blob/master/Modules/FindFreetype.cmake 
at line 21 states, FREETYPE_DIR is an environment variable.
So, if you change your line
set(FREETYPE_DIR "/home/kristian/Documents/freetype/freetype")
to
set(ENV{FREETYPE_DIR} "/home/kristian/Documents/freetype/freetype")
I would assume, your script will work.

Hth,
Andreas

Am 07.06.2016 um 22:47 schrieb Kristian:
> Hey guys,
>
> I wanted to try something out with CMake and latest version of 
> freetype (2.6.3). So I downloaded freetype, compiled it with the commands
>
> > ./configure --prefix=/home/kristian/Documents/freetype/freetype
> > make
> > make install
>
> After that, I created a small C++-file and a CMakeLists.txt. The 
> C++-file depends on freetype, so my CMakeLists.txt looks like this:
>
> =====
>
> > cmake_minimum_required(VERSION 3.5)
> > project(freetype_ex)
> >
> > set(FREETYPE_DIR "/home/kristian/Documents/freetype/freetype")
> > find_package(Freetype)
> >
> > set(SOURCES main.cpp)
> >
> > include_directories(${FREETYPE_INCLUDE_DIRS})
> >
> > add_executable(${PROJECT_NAME} ${SOURCES})
> > target_link_libraries(${PROJECT_NAME} ${FREETYPE_LIBRARIES})
>
> =====
>
> But when calling cmake, I am getting this error:
> =====
>
> > -- Could NOT find Freetype (missing: FREETYPE_LIBRARY 
> FREETYPE_INCLUDE_DIRS)
> > CMake Error: The following variables are used in this project, but 
> they are set to NOTFOUND.
> > Please set them or make sure they are set and tested correctly in 
> the CMake files:
> > FREETYPE_LIBRARY (ADVANCED)
> >     linked by target "freetype_ex" in directory 
> /home/kristian/Documents/freetype/cmake
> >
> > -- Configuring incomplete, errors occurred!
> > See also 
> "/home/kristian/Documents/freetype/cmake/CMakeFiles/CMakeOutput.log".
>
> =====
>
> This sort of error seems for me to be a bug, because I would assume, 
> that when I set the variable FREETYPE_DIR, then CMake would also look 
> at this dir.
>
> I looked at the FindFreetype.cmake file 
> (https://github.com/Kitware/CMake/blob/master/Modules/FindFreetype.cmake) 
> and my first assumption is, that it would help, to add something like 
> ${FREETYPE_DIR} the the find_path calls.
>
> What do you think of this? Another idea is, to add another variable 
> instead of FREETYPE_DIR, e.g. FREETYPE_ROOT_DIR...
>
>



More information about the CMake mailing list