fix: detect NPM version for ENABLE_WEB in cmake (#4669)

This commit is contained in:
Charles Kerr 2023-01-25 22:17:24 -06:00 committed by GitHub
parent f2363fecdc
commit 23bb8fa32e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 17 deletions

View File

@ -22,7 +22,7 @@ jobs:
make-source-tarball: ${{ steps.check-main-push.outputs.is-main-push == '1' || steps.check-diffs.outputs.any-code-changed == '1' }}
make-tests: ${{ steps.check-main-push.outputs.is-main-push == '1' || steps.check-diffs.outputs.tests-changed == '1' }}
make-utils: ${{ steps.check-main-push.outputs.is-main-push == '1' || steps.check-diffs.outputs.utils-changed == '1' || steps.check-diffs.outputs.tests-changed == '1' }}
make-web: ${{ steps.check-main-push.outputs.is-main-push == '1' || steps.check-diffs.outputs.web-changed == '1' }}
make-web: 'false' # this is handled in the webapp workflow
test-style: ${{ steps.check-main-push.outputs.is-main-push == '1' || steps.check-diffs.outputs.our-code-changed == '1' }}
steps:
- name: Check Push to Main Branch

View File

@ -38,6 +38,7 @@ set(GLIBMM_MINIMUM 2.60.0)
set(GTKMM_MINIMUM 3.24.0)
set(OPENSSL_MINIMUM 0.9.7)
set(MBEDTLS_MINIMUM 1.3)
set(NPM_MINIMUM 8.1.307) # Node.js 14
set(PSL_MINIMUM 0.21.1)
set(QT_MINIMUM 5.6)
@ -502,6 +503,30 @@ endif()
tr_add_external_auto_library(B64 libb64 b64
TARGET libb64::libb64)
if(NOT ${ENABLE_WEB} STREQUAL "OFF")
find_program(NPM npm)
if ("${NPM}" STREQUAL "NPM-NOTFOUND")
if ("${ENABLE_WEB}" STREQUAL "ON")
message(FATAL_ERROR "Could NOT find NPM, minimum required is \"${NPM_MINIMUM}\"")
else() # AUTO
set(ENABLE_WEB OFF)
endif()
else()
execute_process(COMMAND "${NPM}" --version
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE NPM_VERSION_STRING)
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}\")")
set(ENABLE_WEB ON)
elseif ("${ENABLE_WEB}" STREQUAL "ON")
message(FATAL_ERROR "Found NPM: ${NPM} Found unsuitable version \"${NPM_VERSION_STRING}\", but required is at least \"${NPM_MINIMUM}\"")
else() # AUTO
message(STATUS "Found NPM: ${NPM} Found unsuitable version \"${NPM_VERSION_STRING}\", but required is at least \"${NPM_MINIMUM}\"")
set(ENABLE_WEB OFF)
endif()
endif()
endif()
if(WITH_INOTIFY)
tr_get_required_flag(WITH_INOTIFY INOTIFY_IS_REQUIRED)
@ -724,22 +749,6 @@ if(ENABLE_GTK AND ENABLE_NLS)
add_subdirectory(po)
endif()
if("${ENABLE_WEB}" STREQUAL "AUTO")
message(STATUS "searching for npm")
find_program(NPM npm)
message(STATUS "searching for npm - ${NPM}")
if ("${NPM}" STREQUAL "NPM-NOTFOUND")
set(ENABLE_WEB OFF)
else()
set(ENABLE_WEB ON)
endif()
endif()
if ("${ENABLE_WEB}" STREQUAL "ON")
message(STATUS "searching for npm")
find_program(NPM npm REQUIRED)
message(STATUS "searching for npm - ${NPM}")
endif()
foreach(P cli daemon gtk mac qt utils web)
string(TOUPPER "${P}" P_ID)
if(ENABLE_${P_ID})