From 91e4e94aaaca5ff15781aed28267a24cb1cb458f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 7 Dec 2023 23:51:56 +0800 Subject: [PATCH] CMake: fix `--help` doesn't work when building without python3 --- CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 20a65e01f..e4dc90511 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -221,12 +221,15 @@ endfunction(fastfetch_load_text) find_package(Python) if(Python_FOUND) - # Minify JSON string. `io.open(0,encoding='utf-8')` is needed to avoid encoding issues on Windows execute_process(COMMAND ${Python_EXECUTABLE} -c "import json,sys;json.dump(json.load(sys.stdin),sys.stdout,separators=(',',':'))" INPUT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/src/data/help.json" OUTPUT_VARIABLE DATATEXT_JSON_HELP) + if(DATATEXT_JSON_HELP STREQUAL "") + message(ERROR "DATATEXT_JSON_HELP is empty, which should not happen!") + endif() else() - file(READ "src/data/help.json" TEMP) + message(STATUS "Python3 is not found, 'help.json' will not be minified") + file(READ "src/data/help.json" DATATEXT_JSON_HELP) endif() fastfetch_encode_c_string("${DATATEXT_JSON_HELP}" DATATEXT_JSON_HELP)