Check return value of nodejs --version
FindNodeJS.cmake once failed due to an error executing the program. To see why it failed, the error output of the command should be printed.
This commit is contained in:
parent
2539183be2
commit
785507b002
@ -13,10 +13,17 @@ if (${NODEJS_EXECUTABLE} MATCHES "NOTFOUND")
|
||||
unset(NODEJS_EXECUTABLE)
|
||||
else()
|
||||
execute_process(COMMAND ${NODEJS_EXECUTABLE} --version
|
||||
OUTPUT_VARIABLE VERSION_VAR)
|
||||
string(REGEX REPLACE "[v]" "" VERSION_VAR ${VERSION_VAR})
|
||||
string(STRIP ${VERSION_VAR} VERSION_VAR)
|
||||
set(NODEJS_VERSION ${VERSION_VAR} CACHE INTERNAL "")
|
||||
set(NODEJS_FOUND TRUE CACHE INTERNAL "")
|
||||
message(STATUS "Found Node.js version ${NODEJS_VERSION}: ${NODEJS_EXECUTABLE}")
|
||||
OUTPUT_VARIABLE VERSION_VAR
|
||||
ERROR_VARIABLE ERROR_VAR
|
||||
RESULT_VARIABLE RESULT_VAR)
|
||||
|
||||
if (RESULT_VAR EQUAL 0)
|
||||
string(REGEX REPLACE "[v]" "" VERSION_VAR ${VERSION_VAR})
|
||||
string(STRIP ${VERSION_VAR} VERSION_VAR)
|
||||
set(NODEJS_VERSION ${VERSION_VAR} CACHE INTERNAL "")
|
||||
set(NODEJS_FOUND TRUE CACHE INTERNAL "")
|
||||
message(STATUS "Found Node.js version ${NODEJS_VERSION}: ${NODEJS_EXECUTABLE}")
|
||||
else()
|
||||
message(WARNING "Failed to execute NodeJS --version command: ${ERROR_VAR}")
|
||||
endif()
|
||||
endif()
|
||||
|
Loading…
x
Reference in New Issue
Block a user