build: accept false constant other than `OFF` for `REBUILD_WEB` (#7219)

This commit is contained in:
Yat Ho 2024-11-04 06:50:04 +08:00 committed by GitHub
parent c97527b555
commit 2315903015
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 12 deletions

View File

@ -554,13 +554,14 @@ tr_add_external_auto_library(B64 libb64 b64
-DLIBB64_SHARED:BOOL=OFF) -DLIBB64_SHARED:BOOL=OFF)
set(TR_WEB_ASSETS ${PROJECT_SOURCE_DIR}/web/public_html) set(TR_WEB_ASSETS ${PROJECT_SOURCE_DIR}/web/public_html)
if(NOT ${REBUILD_WEB} STREQUAL "OFF") if(REBUILD_WEB)
tr_get_required_flag(REBUILD_WEB NPM_IS_REQUIRED)
find_program(NPM npm) find_program(NPM npm)
if ("${NPM}" STREQUAL "NPM-NOTFOUND") if ("${NPM}" STREQUAL "NPM-NOTFOUND")
if ("${REBUILD_WEB}" STREQUAL "ON") set(NPM_FOUND OFF)
if(NPM_IS_REQUIRED)
message(FATAL_ERROR "Could NOT find NPM, minimum required is \"${NPM_MINIMUM}\"") message(FATAL_ERROR "Could NOT find NPM, minimum required is \"${NPM_MINIMUM}\"")
else() # AUTO
set(REBUILD_WEB OFF)
endif() endif()
else() else()
execute_process(COMMAND "${NPM}" --version execute_process(COMMAND "${NPM}" --version
@ -568,18 +569,21 @@ if(NOT ${REBUILD_WEB} STREQUAL "OFF")
OUTPUT_VARIABLE NPM_VERSION_STRING) OUTPUT_VARIABLE NPM_VERSION_STRING)
if("${NPM_VERSION_STRING}" VERSION_GREATER_EQUAL "${NPM_MINIMUM}") if("${NPM_VERSION_STRING}" VERSION_GREATER_EQUAL "${NPM_MINIMUM}")
message(STATUS "Found NPM: ${NPM} (found suitable version \"${NPM_VERSION_STRING}\", minimum required is \"${NPM_MINIMUM}\")") message(STATUS "Found NPM: ${NPM} (found suitable version \"${NPM_VERSION_STRING}\", minimum required is \"${NPM_MINIMUM}\")")
set(REBUILD_WEB ON) set(NPM_FOUND ON)
elseif ("${REBUILD_WEB}" STREQUAL "ON") elseif(NPM_IS_REQUIRED)
message(FATAL_ERROR "Found NPM: ${NPM} Found unsuitable version \"${NPM_VERSION_STRING}\", but required is at least \"${NPM_MINIMUM}\"") message(FATAL_ERROR "Found NPM: ${NPM} Found unsuitable version \"${NPM_VERSION_STRING}\", but required is at least \"${NPM_MINIMUM}\"")
else() # AUTO else()
message(STATUS "Found NPM: ${NPM} Found unsuitable version \"${NPM_VERSION_STRING}\", but required is at least \"${NPM_MINIMUM}\"") message(STATUS "Found NPM: ${NPM} Found unsuitable version \"${NPM_VERSION_STRING}\", but required is at least \"${NPM_MINIMUM}\"")
set(REBUILD_WEB OFF) set(NPM_FOUND OFF)
endif() endif()
endif() endif()
tr_fixup_auto_option(REBUILD_WEB NPM_FOUND NPM_IS_REQUIRED)
endif()
if(REBUILD_WEB) if(REBUILD_WEB)
add_subdirectory(web) add_subdirectory(web)
endif() endif()
endif()
if(WITH_INOTIFY) if(WITH_INOTIFY)
tr_get_required_flag(WITH_INOTIFY INOTIFY_IS_REQUIRED) tr_get_required_flag(WITH_INOTIFY INOTIFY_IS_REQUIRED)