forked from saghul/txiki.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
131 lines (112 loc) · 3.51 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
cmake_minimum_required(VERSION 3.4)
project(tjs LANGUAGES C)
include(GNUInstallDirs)
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Release")
set(CMAKE_BUILD_TYPE "Release")
endif()
message(STATUS "Building in ${CMAKE_BUILD_TYPE} mode")
message(STATUS "Building with ${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION} on ${CMAKE_SYSTEM}")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(TJS__VERSION_MAJOR 19)
set(TJS__VERSION_MINOR 0)
set(TJS__VERSION_PATCH 0)
set(TJS__VERSION_SUFFIX "-alpha")
configure_file(
"${CMAKE_SOURCE_DIR}/src/version.h.in"
"${CMAKE_SOURCE_DIR}/src/version.h"
)
macro(cpr_option OPTION_NAME OPTION_TEXT OPTION_DEFAULT)
option(${OPTION_NAME} ${OPTION_TEXT} ${OPTION_DEFAULT})
if(DEFINED ENV{${OPTION_NAME}})
# Allow setting the option through an environment variable
set(${OPTION_NAME} $ENV{${OPTION_NAME}})
endif()
if(${OPTION_NAME})
add_definitions(-D${OPTION_NAME})
endif()
message(STATUS " ${OPTION_NAME}: ${${OPTION_NAME}}")
endmacro()
include(${CMAKE_SOURCE_DIR}/src/js/CMakeLists.txt)
add_subdirectory(deps/quickjs EXCLUDE_FROM_ALL)
option(libuv_buildtests "" OFF)
add_subdirectory(deps/libuv EXCLUDE_FROM_ALL)
cpr_option(DISABLE_WASM "If ON, WASM support will be disabled" OFF)
if (NOT DISABLE_WASM)
option(BUILD_WASI_SUPPORT "" ON)
add_subdirectory(deps/wasm3/source EXCLUDE_FROM_ALL)
target_compile_definitions(m3 PRIVATE
d_m3LogOutput=0
)
endif()
cpr_option(DISABLE_CURL "If ON, curl support will be disabled" OFF)
cpr_option(USE_SYSTEM_CURL "If ON, this project will look in the system paths for an installed curl library" ON)
if(NOT DISABLE_CURL)
if(USE_SYSTEM_CURL)
find_package(CURL)
endif()
if(NOT USE_SYSTEM_CURL OR NOT CURL_FOUND)
message(STATUS "Not using system Curl, using built-in curl project instead.")
option(HTTP_ONLY "disables all protocols except HTTP" ON)
option(BUILD_TESTING "Set to ON to build cURL tests." OFF)
option(BUILD_CURL_EXE "Set to ON to build cURL executable." OFF)
if(APPLE)
option(CMAKE_USE_SECTRANSP "Enable Apple OS native SSL/TLS" ON)
endif()
add_subdirectory(deps/curl)
set(CURL_FOUND TRUE)
set(CURL_LIBRARIES libcurl)
set(CURL_INCLUDE_DIRS
${CURL_SOURCE_DIR}/include
${CURL_BINARY_DIR}/include/curl)
endif()
endif()
add_executable(tjs
src/bootstrap.c
src/cli.c
src/curl-utils.c
src/dns.c
src/error.c
src/fs.c
src/misc.c
src/modules.c
src/process.c
src/std.c
src/streams.c
src/signals.c
src/timers.c
src/udp.c
src/utils.c
src/version.c
src/vm.c
src/wasm.c
src/worker.c
src/xhr.c
${CMAKE_CURRENT_BINARY_DIR}/js.c
../deps/quickjs/src/cutils.c
)
set_target_properties(tjs PROPERTIES
C_STANDARD 11
C_STANDARD_REQUIRED ON
)
if (CURL_FOUND)
if (USE_SYSTEM_CURL)
target_compile_definitions(tjs PRIVATE
TJS_HAVE_SYSTEM_CURL
)
endif()
target_compile_definitions(tjs PRIVATE
TJS_HAVE_CURL
)
target_include_directories(tjs PRIVATE ${CURL_INCLUDE_DIRS})
target_link_libraries(tjs ${CURL_LIBRARIES})
endif()
string(TOLOWER ${CMAKE_SYSTEM_NAME} TJS_PLATFORM)
target_compile_definitions(tjs PRIVATE TJS__PLATFORM="${TJS_PLATFORM}")
if (NOT DISABLE_WASM)
target_compile_definitions(tjs PRIVATE
TJS_HAVE_WASM
)
target_link_libraries(tjs m3)
endif()
target_link_libraries(tjs qjs uv_a m)