Improve NodeJS Addon API find script.
# NODEJS_ADDON_API_INCLUDE_DIR - NodeJS Addon API headers path
# Prevent vervosity if already included
-if(NODEJS_ADDON_API_FOUND)
- set(NODEJS_ADDON_FIND_QUIETLY TRUE)
+if(NODEJS_ADDON_API_INCLUDE_DIR)
+ set(NODEJS_ADDON_API_FIND_QUIETLY TRUE)
endif()
# Include package manager
@@ -33,18 +33,18 @@ execute_process(
ERROR_VARIABLE NODEJS_ADDON_API_ERROR
)
-string(REPLACE "\n" "" NODEJS_ADDON_API_INCLUDE_DIR ${NODEJS_ADDON_API_INCLUDE_DIR})
-string(REPLACE "\"" "" NODEJS_ADDON_API_INCLUDE_DIR ${NODEJS_ADDON_API_INCLUDE_DIR})
-
-if(NODEJS_ADDON_API_ERROR)
+if(NODEJS_ADDON_API_ERROR OR NODEJS_ADDON_API_INCLUDE_DIR STREQUAL "")
message(FATAL_ERROR "Node Addon API includes could not be found. Include: ${NODEJS_ADDON_API_INCLUDE_DIR}. Error: ${NODEJS_ADDON_API_ERROR}")
return()
-else()
- message(STATUS "NODEJS_ADDON_API_INCLUDE_DIR: ${NODEJS_ADDON_API_INCLUDE_DIR}")
endif()
+string(REPLACE "\n" "" NODEJS_ADDON_API_INCLUDE_DIR ${NODEJS_ADDON_API_INCLUDE_DIR})
+string(REPLACE "\"" "" NODEJS_ADDON_API_INCLUDE_DIR ${NODEJS_ADDON_API_INCLUDE_DIR})
+
find_package_handle_standard_args(NODEJS_ADDON_API
REQUIRED_VARS NODEJS_ADDON_API_INCLUDE_DIR
)
mark_as_advanced(NODEJS_ADDON_API_INCLUDE_DIR)
+
+message(STATUS "NODEJS_ADDON_API_INCLUDE_DIR: ${NODEJS_ADDON_API_INCLUDE_DIR}")
