diff mbox series

[2/4] kernel-shark: Allow specifying TT_FONT_FILE on cmake command line

Message ID 20210317164101.30848-3-michal.sojka@cvut.cz (mailing list archive)
State Accepted
Commit eec8dfe4d374009482e7447bc610966ad688bfcb
Headers show
Series kernel-shark: CMake changes | expand

Commit Message

Michal Sojka March 17, 2021, 4:40 p.m. UTC
On distributions like NixOS, which build packages in a sandbox,
fontconfig configuration files may not be available at build time,
which leads to the following cmake warnings even if the font itself is
available:

    Fontconfig error: Cannot load default config file
    CMake Warning at CMakeLists.txt:62 (message):

      Could not find font FreeSans!

This commit allows to specify exact font location on cmake commandline
via -DTT_FONT_FILE=... When specified, automatic font look up via
fc-list is skipped.

Signed-off-by: Michal Sojka <michal.sojka@cvut.cz>
---
 CMakeLists.txt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/CMakeLists.txt b/CMakeLists.txt
index efcccb1..c4731c1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -50,8 +50,10 @@  find_package(OpenGL)
 find_package(GLUT)
 
 set(KS_FONT FreeSans)
-execute_process(COMMAND  bash "-c" "fc-list '${KS_FONT}' |grep ${KS_FONT}.ttf | cut -d':' -f 1 -z"
-                OUTPUT_VARIABLE TT_FONT_FILE)
+if (NOT TT_FONT_FILE)
+    execute_process(COMMAND  bash "-c" "fc-list '${KS_FONT}' |grep ${KS_FONT}.ttf | cut -d':' -f 1 -z"
+                    OUTPUT_VARIABLE TT_FONT_FILE)
+endif (NOT TT_FONT_FILE)
 
 if (TT_FONT_FILE)