nodejs: cmake updates to more thoroughly check Node.js configuration
Signed-off-by: Henry Bruce <henry.bruce@intel.com> Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
committed by
Brendan Le Foll
parent
ba5318fee9
commit
ff31d6763c
@@ -1,3 +1,13 @@
|
||||
# Macro to add directory to NODE_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(NODE_INCLUDE_DIRS ${NODE_INCLUDE_DIRS} ${dir})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
set (Nodejs_FOUND TRUE)
|
||||
|
||||
find_program (NODE_EXECUTABLE NAMES node nodejs
|
||||
HINTS
|
||||
$ENV{NODE_DIR}
|
||||
@@ -7,15 +17,39 @@ find_program (NODE_EXECUTABLE NAMES node nodejs
|
||||
|
||||
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 (NODE_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 "node/node.h" "src/node.h"
|
||||
PATHS /usr/include/nodejs /usr/local/include/nodejs /usr/local/include)
|
||||
if (NODE_ROOT_DIR)
|
||||
add_include_dir(${NODE_ROOT_DIR}/src)
|
||||
add_include_dir(${NODE_ROOT_DIR}/node)
|
||||
add_include_dir(${NODE_ROOT_DIR}/deps/v8/include)
|
||||
add_include_dir(${NODE_ROOT_DIR}/deps/uv/include)
|
||||
else()
|
||||
message(ERROR " - node.h not found")
|
||||
set (Nodejs_FOUND FALSE)
|
||||
endif()
|
||||
|
||||
set (NODE_INCLUDE_DIRS
|
||||
${NODE_ROOT_DIR}/src
|
||||
${NODE_ROOT_DIR}/node
|
||||
${NODE_ROOT_DIR}/deps/v8/include
|
||||
${NODE_ROOT_DIR}/deps/uv/include
|
||||
)
|
||||
# Check that v8.h is in NODE_INCLUDE_DIRS
|
||||
find_path (V8_ROOT_DIR "v8.h" PATHS NODE_INCLUDE_DIRS)
|
||||
if (NOT V8_ROOT_DIR)
|
||||
message(ERROR " - v8.h not found")
|
||||
set (Nodejs_FOUND FALSE)
|
||||
endif()
|
||||
|
||||
# Check that uv.h is in NODE_INCLUDE_DIRS
|
||||
find_path (UV_ROOT_DIR "u8.h" PATHS NODE_INCLUDE_DIRS)
|
||||
if (NOT UV_ROOT_DIR)
|
||||
message(ERROR " - uv.h not found")
|
||||
set (Nodejs_FOUND FALSE)
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args (Node DEFAULT_MSG
|
||||
NODE_EXECUTABLE
|
||||
@@ -53,7 +87,14 @@ if (NODE_EXECUTABLE)
|
||||
set (V8_VERSION_STRING "3.28.72")
|
||||
message ("defaulted to node 0.10.30")
|
||||
endif ()
|
||||
message ("INFO - Node version is " ${NODE_VERSION_STRING} "INFO - Node using v8 " ${V8_VERSION_STRING})
|
||||
string (REGEX REPLACE "\n" "" NODE_VERSION_STRING ${NODE_VERSION_STRING})
|
||||
string (REGEX REPLACE "\n" "" V8_VERSION_STRING ${V8_VERSION_STRING})
|
||||
message ("INFO - Node version is " ${NODE_VERSION_STRING})
|
||||
message ("INFO - Node using v8 " ${V8_VERSION_STRING})
|
||||
mark_as_advanced (NODE_EXECUTABLE)
|
||||
else()
|
||||
message ("ERROR - node executable not found")
|
||||
set (Nodejs_FOUND FALSE)
|
||||
endif ()
|
||||
|
||||
mark_as_advanced (NODE_EXECUTABLE)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user