Skip to content

Commit c9df323

Browse files
committed
Add checks for NodeJS headers integrity.
1 parent 10f04c7 commit c9df323

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

cmake/FindNodeJS.cmake

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,22 +162,25 @@ find_path(NODEJS_INCLUDE_DIR ${NODEJS_HEADERS}
162162
DOC "NodeJS JavaScript Runtime Headers"
163163
)
164164

165-
message(STATUS "1) --- ${NODEJS_INCLUDE_DIR}")
165+
# Check if the include directory contains all headers in the same folder
166+
if(NODEJS_INCLUDE_DIR)
167+
foreach(HEADER IN ${NODEJS_HEADERS})
168+
if(NOT EXISTS ${NODEJS_INCLUDE_DIR}/${HEADER})
169+
set(NODEJS_INCLUDE_DIR FALSE)
170+
endif()
171+
endforeach()
172+
endif()
166173

167-
# # Check if the include directory contains all headers in the same folder
168-
# if(NODEJS_INCLUDE_DIR)
169-
170-
# endif()
174+
message(STATUS "NodeJS include dir: ${NODEJS_INCLUDE_DIR}")
171175

176+
# TODO: Remove this workaround when NodeJS begins to distribute node as a shared library (maybe never?) with proper includes
172177
if(NOT NODEJS_INCLUDE_DIR)
173178
if(NOT NODEJS_VERSION)
174179
# We do not have any way to know what version to install
175180
message(WARNING "NodeJS headers could not be found, neither a valid NodeJS version.")
176181
return()
177182
endif()
178183

179-
# TODO: Remove this workaround when NodeJS begins to distribute node as a shared library (maybe never?) with proper includes
180-
181184
# NodeJS download and output path (workaround for NodeJS headers)
182185
set(NODEJS_DOWNLOAD_URL "https://nodejs.org/dist/v${NODEJS_VERSION}/node-v${NODEJS_VERSION}-headers.tar.gz")
183186
set(NODEJS_DOWNLOAD_FILE "${CMAKE_CURRENT_BINARY_DIR}/node-v${NODEJS_VERSION}-headers.tar.gz")
@@ -203,8 +206,6 @@ if(NOT NODEJS_INCLUDE_DIR)
203206
PATH_SUFFIXES ${NODEJS_INCLUDE_SUFFIXES}
204207
DOC "NodeJS JavaScript Runtime Headers"
205208
)
206-
207-
message(STATUS "2) --- ${NODEJS_INCLUDE_DIR}")
208209
endif()
209210

210211
if(NODEJS_INCLUDE_DIR)

0 commit comments

Comments
 (0)