Add custom directories for NodeJS libraries.
# Find NodeJS executable and include paths
#
# NODEJS_FOUND - True if NodeJS was found
-# NODEJS_INCLUDE_DIR - NodeJS headers path
# NODEJS_VERSION - NodeJS version
# NODEJS_VERSION_MAJOR - NodeJS major version
# NODEJS_VERSION_MINOR - NodeJS minor version
# NODEJS_V8_VERSION_PATCH - V8 patch version of NodeJS
# NODEJS_V8_VERSION_TWEAK - V8 patch version of NodeJS
# NODEJS_V8_VERSION_HEX - V8 version of NodeJS in hexadecimal format
-# NODEJS_LIBRARY - NodeJS shared library
-# NODEJS_EXECUTABLE - NodeJS shell
#
# Configuration variables:
#
+# NODEJS_LIBRARY_CUSTOM - Define custom NodeJS shared library
+# NODEJS_EXECUTABLE_CUSTOM - Define custom NodeJS shell
+# NODEJS_INCLUDE_DIR_CUSTOM - Define custom NodeJS headers path
# NODEJS_CMAKE_DEBUG - Print paths for debugging
# NODEJS_EXECUTABLE_ONLY - Find only NodeJS executable (avoid library and include files)
# Prevent vervosity if already included
-if(NODEJS_INCLUDE_DIR)
+if(NODEJS_EXECUTABLE)
set(NODEJS_FIND_QUIETLY TRUE)
endif()
+option(NODEJS_EXECUTABLE_CUSTOM "Define a custom path for NodeJS executable." OFF)
+option(NODEJS_INCLUDE_DIR_CUSTOM "Define a custom path for NodeJS includes." OFF)
+option(NODEJS_LIBRARY_CUSTOM "Define a custom path for NodeJS library." OFF)
option(NODEJS_CMAKE_DEBUG "Print paths for debugging NodeJS dependencies." OFF)
option(NODEJS_SHARED_UV "If it is enabled, libuv won't be required by this script." OFF)
@@ -98,12 +101,16 @@ set(NODEJS_INCLUDE_PATHS
)
# Find NodeJS executable
+if(NOT NODEJS_EXECUTABLE_CUSTOM)
find_program(NODEJS_EXECUTABLE
NAMES node nodejs node.exe
HINTS ${NODEJS_PATHS}
PATH_SUFFIXES bin
DOC "NodeJS JavaScript Runtime Interpreter"
)
+else()
+ set(NODEJS_EXECUTABLE ${NODEJS_EXECUTABLE_CUSTOM})
+endif()
if(NODEJS_EXECUTABLE)
# Detect NodeJS version
@@ -161,12 +168,16 @@ if(NODEJS_EXECUTABLE)
endif()
# Find NodeJS includes
+if(NOT NODEJS_INCLUDE_DIR_CUSTOM)
find_path(NODEJS_INCLUDE_DIR
NAMES ${NODEJS_HEADERS}
PATHS ${NODEJS_INCLUDE_PATHS}
PATH_SUFFIXES ${NODEJS_INCLUDE_SUFFIXES}
DOC "NodeJS JavaScript Runtime Headers"
)
+else()
+ set(NODEJS_INCLUDE_DIR ${NODEJS_INCLUDE_DIR_CUSTOM})
+endif()
# Check if the include directory contains all headers in the same folder
if(NODEJS_INCLUDE_DIR)
@@ -265,6 +276,7 @@ if(NODEJS_INCLUDE_DIR)
endif()
# Find NodeJS library from module version
+if(NOT NODEJS_LIBRARY_CUSTOM)
if(NODEJS_MODULE_VERSION)
# NodeJS library names
set(NODEJS_LIBRARY_NAMES
@@ -293,6 +305,9 @@ if(NODEJS_MODULE_VERSION)
DOC "NodeJS JavaScript Runtime Library"
)
endif()
+else()
+ set(NODEJS_LIBRARY ${NODEJS_LIBRARY_CUSTOM})
+endif()
# TODO: Remove this workaround when NodeJS begins to distribute node as a shared library (maybe never?)
if(NOT NODEJS_LIBRARY)
