-
Notifications
You must be signed in to change notification settings - Fork 20
/
CMakeLists.txt
94 lines (82 loc) · 2.57 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
include(FetchContent)
cmake_minimum_required(VERSION 3.11)
project (node-raylib
VERSION 0.10.0
DESCRIPTION "Node.js bindings for raylib"
HOMEPAGE_URL "https://github.com/RobLoach/node-raylib"
LANGUAGES C CXX)
if ( CMAKE_COMPILER_IS_GNUCC )
set(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS} -Wno-unused-result")
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
endif()
if ( MSVC )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /w")
endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
# version doesn't seem to pick correct version
#find_package(raylib 4.5 QUIET EXACT)
if (NOT raylib_FOUND)
include(FetchContent)
FetchContent_Declare(
raylib
GIT_REPOSITORY https://github.com/raysan5/raylib.git
GIT_TAG 4.5.0
GIT_SHALLOW TRUE
)
FetchContent_GetProperties(raylib)
if (NOT raylib_POPULATED)
set(FETCHCONTENT_QUIET NO)
FetchContent_Populate(raylib)
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory(${raylib_SOURCE_DIR} ${raylib_BINARY_DIR})
endif()
endif()
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(BUILD_GAMES OFF CACHE BOOL "" FORCE)
# Add all the include directories.
include_directories(${PROJECT_NAME}
"${CMAKE_JS_INC}"
"${CMAKE_SOURCE_DIR}/node_modules/node-addon-api"
"${CMAKE_CURRENT_SOURCE_DIR}/node_modules/node-addon-api"
"${CMAKE_SOURCE_DIR}/node_modules/node-addon-api/src"
"${CMAKE_CURRENT_SOURCE_DIR}/node_modules/node-addon-api/src"
"${CMAKE_CURRENT_SOURCE_DIR}/../node-addon-api"
"${CMAKE_CURRENT_SOURCE_DIR}/../node-addon-api/src"
)
# This is hardcoded so that updates force a re-compile.
add_library(${PROJECT_NAME} SHARED
# src/lib/AddDefine.h
# src/lib/AddFunction.h
# src/lib/CleanUp.h
# src/lib/GetArgFromParam.h
# src/lib/ValidArgs.h
# src/addon.cc
# src/node-raymath.h
# src/node-rlgl.h
# src/lib/WrappedFunctions.h
src/generated/node-raylib.cc
)
## Suffix the node module with .node.
set_target_properties(${PROJECT_NAME} PROPERTIES
PREFIX ""
SUFFIX ".node"
)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)
target_include_directories(${PROJECT_NAME} PUBLIC
"${CMAKE_JS_INC}"
"${CMAKE_SOURCE_DIR}/node_modules/node-addon-api"
"${CMAKE_CURRENT_SOURCE_DIR}/node_modules/node-addon-api"
"${CMAKE_SOURCE_DIR}/node_modules/node-addon-api/src"
"${CMAKE_CURRENT_SOURCE_DIR}/node_modules/node-addon-api/src"
"${CMAKE_CURRENT_SOURCE_DIR}/../node-addon-api"
"${CMAKE_CURRENT_SOURCE_DIR}/../node-addon-api/src"
)
# Link raylib.
target_link_libraries(${PROJECT_NAME}
${CMAKE_JS_LIB}
raylib
)