Skip to content

Commit

Permalink
CMake: fix --help doesn't work when building without python3
Browse files Browse the repository at this point in the history
  • Loading branch information
CarterLi committed Dec 7, 2023
1 parent 1504e26 commit 91e4e94
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 91e4e94

Please sign in to comment.