I recently had an issue where my IDE (Visual Studio) had no support for CMake.js and this was my solution.
This solution sets up all the CMake.js variables. By defining CMAKE_JS_INC
and CMAKE_JS_LIB
for use in your project.
Just call setup_cmakejs()
to define the variables. It is also compatible with Windows development environments. Linux and macOS are untested, but assumedly work just fine.
Happy coding!
Here's an example just in case you need it:
cmake_minimum_required(VERSION 3.2.2)
include("cmakejs.cmake")
setup_cmakejs()
project (my_project_name)
include_directories(${CMAKE_JS_INC})
file(GLOB SOURCE_FILES "main.cpp")
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC})
set_target_properties(${PROJECT_NAME} PROPERTIES
PREFIX ""
SUFFIX ".node"
RUNTIME_OUTPUT_DIRECTORY ${ARTIFACTS_DIRECTORY}
LINKER_LANGUAGE CXX
)
target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB})
Huh, odd. On windows, when installing LTS Node.js on Windows, NPM is actually
npm.cmd
on thePATH
variable. If you take a look at lines 22 thru 28, you can see me appending that extension. Would something similar suffice for your problem?