The easiest way (quick and dirty) to set the cache variables is to edit the CMakeCache.txt
file directly, and then re-run cmake. But this has to be repeated each time you do a clean build, so it’s not ideal.
Another way is by passing multiple -D
values when you run cmake, one for each variable. This can be tedious, but you can put the whole cmake command-line into a bash script to make it reusable.
For putting cache variables into a CMakeLists.txt
, it’s necessary to use the CACHE
keyword in the set()
command:
set(CMAKE_BUILD_TYPE Release CACHE STRING "")
syntax: (note that <docstring>
can be an empty string)
set(<variable> <value> CACHE <type> <docstring> [FORCE])
Instead of putting these in the CMakeLists.txt
, they can be put in their own cmake file, e.g. a file called cache.cmake
that is used like this:
cmake -C cache.cmake ...
where cache.cmake
contains
set(CMAKE_BUILD_TYPE Release CACHE STRING "")
set(CMAKE_PREFIX_PATH
/home/ilmu011/Desktop/vcpkg/installed/x64-linux/share/vtk
CACHE PATH ""
)
It’s verbose, which is why using -D
is more common.
Make sure that you have libfreetype-dev
installed, it’s possible that cmake didn’t automatically find the system libs and headers for freetype because they’re not installed on your system.
Hopefully someone else can answer the vcpkg questions, because I don’t really know anything about it, except that it exists.