File: FindNodeJS.cmake

package info (click to toggle)
halide 21.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 55,752 kB
  • sloc: cpp: 289,334; ansic: 22,751; python: 7,486; makefile: 4,299; sh: 2,508; java: 1,549; javascript: 282; pascal: 207; xml: 127; asm: 9
file content (29 lines) | stat: -rw-r--r-- 715 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
find_program(
    NodeJS_EXECUTABLE
    NAMES node nodejs
)

set(NodeJS_VERSION "")
if (NodeJS_EXECUTABLE)
    execute_process(
        COMMAND "${NodeJS_EXECUTABLE}" --version
        OUTPUT_VARIABLE NodeJS_VERSION
        OUTPUT_STRIP_TRAILING_WHITESPACE
    )
    string(REPLACE "v" "" NodeJS_VERSION "${NodeJS_VERSION}")
endif ()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
    NodeJS
    REQUIRED_VARS NodeJS_EXECUTABLE
    VERSION_VAR NodeJS_VERSION
    HANDLE_COMPONENTS
)

if (NodeJS_FOUND AND NOT TARGET NodeJS::node)
    add_executable(NodeJS::node IMPORTED)
    set_target_properties(
        NodeJS::node PROPERTIES IMPORTED_LOCATION "${NodeJS_EXECUTABLE}"
    )
endif ()