-
Notifications
You must be signed in to change notification settings - Fork 19
/
CMakeLists.txt
138 lines (114 loc) · 5.3 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
cmake_minimum_required(VERSION 3.21)
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()
include(FetchContent)
# --------------------------------------------------
# Declarations
# --------------------------------------------------
FetchContent_Declare(arcana.cpp
GIT_REPOSITORY https://github.com/microsoft/arcana.cpp.git
GIT_TAG 1a8a5d6e95413ed14b38a6ac9419048f9a9c8009)
FetchContent_Declare(AndroidExtensions
GIT_REPOSITORY https://github.com/bghgary/AndroidExtensions.git
GIT_TAG 7d88a601fda9892791e7b4e994e375e049615688)
FetchContent_Declare(asio
GIT_REPOSITORY https://github.com/chriskohlhoff/asio.git
GIT_TAG f693a3eb7fe72a5f19b975289afc4f437d373d9c)
FetchContent_Declare(CMakeExtensions
GIT_REPOSITORY https://github.com/BabylonJS/CMakeExtensions.git
GIT_TAG ea28b7689530bfdc4905806f27ecf7e8ed4b5419)
FetchContent_Declare(googletest
URL "https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz")
FetchContent_Declare(ios-cmake
GIT_REPOSITORY https://github.com/leetal/ios-cmake.git
GIT_TAG 4.4.1)
FetchContent_Declare(llhttp
URL "https://github.com/nodejs/llhttp/archive/refs/tags/release/v8.1.0.tar.gz")
FetchContent_Declare(UrlLib
GIT_REPOSITORY https://github.com/BabylonJS/UrlLib.git
GIT_TAG 2f12534f242ab15aa761c3b273538f44787cf5e3)
# --------------------------------------------------
FetchContent_MakeAvailable(CMakeExtensions)
if(IOS)
FetchContent_MakeAvailable_With_Message(ios-cmake)
set(CMAKE_TOOLCHAIN_FILE "${ios-cmake_SOURCE_DIR}/ios.toolchain.cmake" CACHE PATH "")
set(PLATFORM "OS64COMBINED" CACHE STRING "")
set(DEPLOYMENT_TARGET "12" CACHE STRING "")
endif()
project(JsRuntimeHost)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# --------------------------------------------------
# Options
# --------------------------------------------------
# General
option(JSRUNTIMEHOST_TESTS "Include JsRuntimeHost Tests." ${PROJECT_IS_TOP_LEVEL})
option(NAPI_BUILD_ABI "Build the ABI layer." ON)
option(BABYLON_DEBUG_TRACE "Debug Trace callback." OFF)
# Core
option(JSRUNTIMEHOST_CORE_APPRUNTIME "Include JsRuntimeHost Core AppRuntime" ON)
option(JSRUNTIMEHOST_CORE_APPRUNTIME_V8_INSPECTOR "Include the V8 inspector protocol required to debug JavaScript with a V8 debugger." ON)
option(JSRUNTIMEHOST_CORE_SCRIPTLOADER "Include JsRuntimeHost Core ScriptLoader" ON)
# Polyfills
option(JSRUNTIMEHOST_POLYFILL_CONSOLE "Include JsRuntimeHost Polyfill Console." ON)
option(JSRUNTIMEHOST_POLYFILL_SCHEDULING "Include JsRuntimeHost Polyfill Scheduling." ON)
option(JSRUNTIMEHOST_POLYFILL_XMLHTTPREQUEST "Include JsRuntimeHost Polyfill XMLHttpRequest." ON)
option(JSRUNTIMEHOST_POLYFILL_URL "Include JsRuntimeHost Polyfill URL and URLSearchParams." ON)
option(JSRUNTIMEHOST_POLYFILL_ABORT_CONTROLLER "Include JsRuntimeHost Polyfills AbortController and AbortSignal." ON)
option(JSRUNTIMEHOST_POLYFILL_WEBSOCKET "Include JsRuntimeHost Polyfill WebSocket." ON)
# --------------------------------------------------
FetchContent_MakeAvailable_With_Message(arcana.cpp)
set_property(TARGET arcana PROPERTY FOLDER Dependencies)
if(JSRUNTIMEHOST_POLYFILL_XMLHTTPREQUEST)
FetchContent_MakeAvailable_With_Message(UrlLib)
set_property(TARGET UrlLib PROPERTY FOLDER Dependencies)
endif()
if(BABYLON_DEBUG_TRACE)
add_definitions(-DBABYLON_DEBUG_TRACE)
endif()
if(NAPI_JAVASCRIPT_ENGINE STREQUAL "V8" AND JSRUNTIMEHOST_CORE_APPRUNTIME_V8_INSPECTOR)
FetchContent_MakeAvailable_With_Message(asio)
add_library(asio INTERFACE)
target_include_directories(asio INTERFACE "${asio_SOURCE_DIR}/asio/include")
set_property(TARGET asio PROPERTY FOLDER Dependencies)
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "")
set(BUILD_STATIC_LIBS ON CACHE INTERNAL "")
FetchContent_MakeAvailable_With_Message(llhttp)
set_property(TARGET llhttp_static PROPERTY FOLDER Dependencies)
endif()
if(JSRUNTIMEHOST_TESTS)
if(WIN32)
# For Windows: Prevent overriding the parent project's compiler/linker settings
# Default build type for my test projects are /MDd (MultiThreaded DLL) but GTests default to /MTd (MultiThreaded)
# see https://github.com/google/googletest/blob/main/googletest/README.md
# "Enabling this option will make gtest link the runtimes dynamically too, and match the project in which it is included."
set(gtest_force_shared_crt OFF CACHE BOOL "" FORCE)
endif()
FetchContent_MakeAvailable_With_Message(googletest)
set_property(TARGET gmock PROPERTY FOLDER Dependencies/GoogleTest)
set_property(TARGET gmock_main PROPERTY FOLDER Dependencies/GoogleTest)
set_property(TARGET gtest PROPERTY FOLDER Dependencies/GoogleTest)
set_property(TARGET gtest_main PROPERTY FOLDER Dependencies/GoogleTest)
endif()
if(ANDROID)
set(JSRUNTIMEHOST_PLATFORM "Android")
elseif(IOS)
set(JSRUNTIMEHOST_PLATFORM "iOS")
elseif(APPLE)
set(JSRUNTIMEHOST_PLATFORM "macOS")
elseif(WINDOWS_STORE)
set(JSRUNTIMEHOST_PLATFORM "UWP")
elseif(WIN32)
set(JSRUNTIMEHOST_PLATFORM "Win32")
elseif(UNIX)
set(JSRUNTIMEHOST_PLATFORM "Unix")
else()
message(FATAL_ERROR "Unrecognized platform: ${CMAKE_SYSTEM_NAME}")
endif()
add_subdirectory(Core)
add_subdirectory(Polyfills)
if(JSRUNTIMEHOST_TESTS AND NOT WINDOWS_STORE)
add_subdirectory(Tests)
endif()