-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
50 lines (39 loc) · 1.26 KB
/
CMakeLists.txt
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
cmake_minimum_required (VERSION 3.11)
include (FetchContent)
project (cpu-perf-counters)
set (CMAKE_POSITION_INDEPENDENT_CODE ON)
# Essential include files to build a node addon with cmake.js
include_directories (${CMAKE_JS_INC})
add_library (${PROJECT_NAME} SHARED
"src/addon.cc"
# Linux only
"$<IF:$<PLATFORM_ID:Linux>,"
"src/counter_group.linux.cc,"
"src/counter_group.unknown.cc"
">"
)
set_target_properties (${PROJECT_NAME} PROPERTIES
CXX_STANDARD 17
PREFIX ""
SUFFIX ".node"
)
# Find the N-API wrappers
execute_process (
COMMAND node -e "process.stdout.write(require('node-addon-api').include.replace(/^\"|\"+$/g, ''))"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE NODE_ADDON_API_DIR
)
# Include N-API wrappers
target_include_directories (${PROJECT_NAME}
PRIVATE "${NODE_ADDON_API_DIR}"
)
# N-API v6 required for BigInt support
target_compile_definitions (${PROJECT_NAME}
PUBLIC NAPI_VERSION=6
)
target_compile_options (${PROJECT_NAME} PUBLIC
"$<$<CXX_COMPILER_ID:Clang>:-Wall;-Wextra;-pedantic;-msse2;-O2;-fno-omit-frame-pointer>"
)
# Essential library files to link to a node addon,
# you should add this line in every CMake.js based project.
target_link_libraries (${PROJECT_NAME} ${CMAKE_JS_LIB})