mirror of
https://github.com/eclipse/upm.git
synced 2025-03-14 20:47:30 +03:00
FindNodejs: Updated to find node<version>
Updates to the FindNodejs.cmake module to find newer installs of nodejs across other distros. For example openSUSE: /usr/include/node6/node.h * Added PATH_SUFFIX to find_path for node.h. * Standardized usage of message() (added STATUS) * Call find_package_handle_standard_args with version * Reformatted to look uniform. Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
parent
96bcfc9128
commit
7d83e8c569
@ -1,69 +1,66 @@
|
||||
# Macro to add directory to NODEJS_INCLUDE_DIRS if it exists and is not /usr/include
|
||||
macro(add_include_dir dir)
|
||||
# Macro to add directory to NODEJS_INCLUDE_DIRS if it exists and is not /usr/include
|
||||
macro(add_include_dir dir)
|
||||
if (IS_DIRECTORY ${dir} AND NOT ${dir} STREQUAL "/usr/include")
|
||||
set(NODEJS_INCLUDE_DIRS ${NODEJS_INCLUDE_DIRS} ${dir})
|
||||
set(NODEJS_INCLUDE_DIRS ${NODEJS_INCLUDE_DIRS} ${dir})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
find_program (NODEJS_EXECUTABLE NAMES node nodejs
|
||||
HINTS
|
||||
$ENV{NODE_DIR}
|
||||
PATH_SUFFIXES bin
|
||||
DOC "Node.js interpreter"
|
||||
)
|
||||
DOC "Node.js interpreter")
|
||||
|
||||
include (FindPackageHandleStandardArgs)
|
||||
|
||||
# If compat-libuv package exists, it must be at start of include path
|
||||
find_path (UV_ROOT_DIR "uv.h" PATHS /usr/include/compat-libuv010 NO_DEFAULT_PATH)
|
||||
if (UV_ROOT_DIR)
|
||||
# set (NODEJS_INCLUDE_DIRS ${UV_ROOT_DIR})
|
||||
add_include_dir(${UV_ROOT_DIR})
|
||||
# set (NODEJS_INCLUDE_DIRS ${UV_ROOT_DIR})
|
||||
add_include_dir(${UV_ROOT_DIR})
|
||||
endif()
|
||||
|
||||
# Now look for node. Flag an error if not found
|
||||
find_path (NODE_ROOT_DIR "include/node/node.h" "include/src/node.h" "src/node.h"
|
||||
PATHS /usr/include/nodejs /usr/local/include/nodejs /usr/local/include)
|
||||
find_path (NODE_ROOT_DIR
|
||||
NAMES node.h
|
||||
PATH_SUFFIXES node node4 node5 node6 node7 node8 nodejs
|
||||
PATHS /usr/include /usr/local/include)
|
||||
|
||||
if (NODE_ROOT_DIR)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/src)
|
||||
add_include_dir(${NODE_ROOT_DIR}/src)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/node)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/deps/v8/include)
|
||||
add_include_dir(${NODE_ROOT_DIR}/deps/v8/include)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/deps/uv/include)
|
||||
add_include_dir(${NODE_ROOT_DIR}/deps/uv/include)
|
||||
add_include_dir(${NODE_ROOT_DIR})
|
||||
add_include_dir(${NODE_ROOT_DIR}/deps/uv/include)
|
||||
add_include_dir(${NODE_ROOT_DIR}/deps/v8/include)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/deps/uv/include)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/deps/v8/include)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/node)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/src)
|
||||
add_include_dir(${NODE_ROOT_DIR}/src)
|
||||
else()
|
||||
unset(NODEJS_INCLUDE_DIRS)
|
||||
message(ERROR " - node.h not found")
|
||||
unset(NODEJS_INCLUDE_DIRS)
|
||||
message(ERROR " - node.h not found")
|
||||
endif()
|
||||
|
||||
# Check that v8.h is in NODEJS_INCLUDE_DIRS
|
||||
find_path (V8_ROOT_DIR "v8.h" PATHS ${NODEJS_INCLUDE_DIRS})
|
||||
if (NOT V8_ROOT_DIR)
|
||||
unset(NODEJS_INCLUDE_DIRS)
|
||||
message(ERROR " - v8.h not found")
|
||||
unset(NODEJS_INCLUDE_DIRS)
|
||||
message(ERROR " - v8.h not found")
|
||||
endif()
|
||||
|
||||
# Check that uv.h is in NODEJS_INCLUDE_DIRS
|
||||
find_path (UV_ROOT_DIR "uv.h" PATHS ${NODEJS_INCLUDE_DIRS})
|
||||
if (NOT UV_ROOT_DIR)
|
||||
unset(NODEJS_INCLUDE_DIRS)
|
||||
message(ERROR " - uv.h not found")
|
||||
unset(NODEJS_INCLUDE_DIRS)
|
||||
message(ERROR " - uv.h not found")
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args (Nodejs DEFAULT_MSG
|
||||
NODEJS_EXECUTABLE
|
||||
NODEJS_INCLUDE_DIRS
|
||||
)
|
||||
|
||||
if (NODEJS_EXECUTABLE)
|
||||
execute_process(COMMAND ${NODEJS_EXECUTABLE} --version
|
||||
OUTPUT_VARIABLE _VERSION
|
||||
RESULT_VARIABLE _NODE_VERSION_RESULT)
|
||||
OUTPUT_VARIABLE _VERSION
|
||||
RESULT_VARIABLE _NODE_VERSION_RESULT)
|
||||
execute_process(COMMAND ${NODEJS_EXECUTABLE} -e "console.log(process.versions.v8)"
|
||||
OUTPUT_VARIABLE _V8_VERSION
|
||||
RESULT_VARIABLE _V8_RESULT)
|
||||
OUTPUT_VARIABLE _V8_VERSION
|
||||
RESULT_VARIABLE _V8_RESULT)
|
||||
if (NOT _NODE_VERSION_RESULT AND NOT _V8_RESULT)
|
||||
string (REPLACE "v" "" NODE_VERSION_STRING "${_VERSION}")
|
||||
string (REPLACE "." ";" _VERSION_LIST "${NODE_VERSION_STRING}")
|
||||
@ -88,13 +85,15 @@ if (NODEJS_EXECUTABLE)
|
||||
set (V8_VERSION_MINOR "28")
|
||||
set (V8_VERSION_PATCH "72")
|
||||
set (V8_VERSION_STRING "3.28.72")
|
||||
message ("defaulted to node 0.10.30")
|
||||
message (STATUS "defaulted to node 0.10.30")
|
||||
endif ()
|
||||
string (REGEX REPLACE "\n" "" NODE_VERSION_STRING ${NODE_VERSION_STRING})
|
||||
string (REGEX REPLACE "\n" "" V8_VERSION_STRING ${V8_VERSION_STRING})
|
||||
message (STATUS "Node version is ${NODE_VERSION_STRING}")
|
||||
message (STATUS "Node using v8 ${V8_VERSION_STRING}")
|
||||
mark_as_advanced (NODEJS_EXECUTABLE)
|
||||
endif ()
|
||||
|
||||
mark_as_advanced (NODEJS_EXECUTABLE)
|
||||
mark_as_advanced (NODEJS_EXECUTABLE)
|
||||
|
||||
find_package_handle_standard_args (Nodejs
|
||||
REQUIRED_VARS NODEJS_EXECUTABLE NODEJS_INCLUDE_DIRS
|
||||
VERSION_VAR NODE_VERSION_STRING)
|
||||
message(STATUS "Found v8: ${V8_ROOT_DIR}/v8.h (found version \"${V8_VERSION_STRING}\")")
|
||||
endif ()
|
||||
|
Loading…
x
Reference in New Issue
Block a user