@@ -30,8 +30,10 @@ macro(xcheck_add_c_compiler_flag FLAG)
30
30
endmacro ()
31
31
32
32
xcheck_add_c_compiler_flag (-Wall )
33
- xcheck_add_c_compiler_flag (-Werror )
34
- xcheck_add_c_compiler_flag (-Wextra )
33
+ if (NOT MSVC )
34
+ xcheck_add_c_compiler_flag (-Werror )
35
+ xcheck_add_c_compiler_flag (-Wextra )
36
+ endif ()
35
37
xcheck_add_c_compiler_flag (-Wno-implicit-fallthrough )
36
38
xcheck_add_c_compiler_flag (-Wno-sign-compare )
37
39
xcheck_add_c_compiler_flag (-Wno-missing-field-initializers )
@@ -42,6 +44,19 @@ xcheck_add_c_compiler_flag(-Wno-array-bounds)
42
44
xcheck_add_c_compiler_flag (-Wno-format-truncation )
43
45
xcheck_add_c_compiler_flag (-funsigned-char )
44
46
47
+ # ClangCL is command line compatible with MSVC, so 'MSVC' is set.
48
+ if (MSVC )
49
+ xcheck_add_c_compiler_flag (-Wno-unsafe-buffer-usage )
50
+ xcheck_add_c_compiler_flag (-Wno-sign-conversion )
51
+ xcheck_add_c_compiler_flag (-Wno-nonportable-system-include-path )
52
+ xcheck_add_c_compiler_flag (-Wno-implicit-int-conversion )
53
+ xcheck_add_c_compiler_flag (-Wno-shorten-64-to-32 )
54
+ xcheck_add_c_compiler_flag (-Wno-reserved-macro-identifier )
55
+ xcheck_add_c_compiler_flag (-Wno-reserved-identifier )
56
+ xcheck_add_c_compiler_flag (-Wdeprecated-declarations )
57
+ add_compile_definitions (WIN32_LEAN_AND_MEAN )
58
+ endif ()
59
+
45
60
if (CMAKE_BUILD_TYPE MATCHES "Debug" )
46
61
add_compile_options (-O0 )
47
62
xcheck_add_c_compiler_flag (-ggdb )
@@ -130,12 +145,12 @@ if(BUILD_QJS_LIBC)
130
145
list (APPEND qjs_sources quickjs-libc.c )
131
146
endif ()
132
147
list (APPEND qjs_defines _GNU_SOURCE )
133
- list (APPEND qjs_libs qjs m )
148
+ list (APPEND qjs_libs qjs )
134
149
if (NOT WIN32 )
135
150
list (APPEND qjs_libs dl )
136
151
endif ()
137
152
if (NOT MSVC )
138
- list (APPEND qjs_libs pthread )
153
+ list (APPEND qjs_libs m pthread )
139
154
endif ()
140
155
141
156
add_library (qjs ${qjs_sources} )
@@ -167,7 +182,7 @@ target_link_libraries(qjsc ${qjs_libs})
167
182
168
183
add_custom_command (
169
184
OUTPUT repl.c
170
- COMMAND " ${CMAKE_CURRENT_BINARY_DIR} / qjsc" -o ./repl.c -m ${CMAKE_CURRENT_SOURCE_DIR} /repl.js
185
+ COMMAND qjsc -o ./repl.c -m ${CMAKE_CURRENT_SOURCE_DIR} /repl.js
171
186
DEPENDS qjsc
172
187
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
173
188
COMMENT "Compile repl.js to bytecode"
@@ -190,21 +205,23 @@ if(BUILD_STATIC_QJS_EXE OR MINGW)
190
205
target_link_options (qjs_exe PRIVATE -static-libgcc )
191
206
endif ()
192
207
endif ()
193
- if (NOT MINGW )
208
+ if (NOT WIN32 )
194
209
set_target_properties (qjs_exe PROPERTIES ENABLE_EXPORTS TRUE )
195
210
endif ()
196
211
197
212
198
213
# Test262 runner
199
214
#
200
215
201
- add_executable (run-test262
202
- quickjs-libc.c
203
- run-test262.c
204
- )
205
- target_compile_definitions (run-test262 PRIVATE ${qjs_defines} )
206
- target_link_libraries (run-test262 ${qjs_libs} )
207
-
216
+ # run-test262 uses pthreads.
217
+ if (NOT WIN32 )
218
+ add_executable (run-test262
219
+ quickjs-libc.c
220
+ run-test262.c
221
+ )
222
+ target_compile_definitions (run-test262 PRIVATE ${qjs_defines} )
223
+ target_link_libraries (run-test262 ${qjs_libs} )
224
+ endif ()
208
225
209
226
# Unicode generator
210
227
#
@@ -220,10 +237,10 @@ target_compile_definitions(unicode_gen PRIVATE ${qjs_defines})
220
237
# Examples
221
238
#
222
239
223
- if (BUILD_EXAMPLES AND NOT MINGW )
240
+ if (BUILD_EXAMPLES AND NOT WIN32 )
224
241
add_custom_command (
225
242
OUTPUT hello.c
226
- COMMAND " ${CMAKE_CURRENT_BINARY_DIR} / qjsc" -e -o hello.c ${CMAKE_CURRENT_SOURCE_DIR} /examples/hello.js
243
+ COMMAND qjsc -e -o hello.c ${CMAKE_CURRENT_SOURCE_DIR} /examples/hello.js
227
244
DEPENDS qjsc
228
245
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
229
246
COMMENT "Compile hello.js to a C file with bytecode embeddee"
@@ -239,7 +256,7 @@ if(BUILD_EXAMPLES AND NOT MINGW)
239
256
240
257
add_custom_command (
241
258
OUTPUT hello_module.c
242
- COMMAND " ${CMAKE_CURRENT_BINARY_DIR} / qjsc" -e -o hello_module.c -m ${CMAKE_CURRENT_SOURCE_DIR} /examples/hello_module.js
259
+ COMMAND qjsc -e -o hello_module.c -m ${CMAKE_CURRENT_SOURCE_DIR} /examples/hello_module.js
243
260
DEPENDS qjsc
244
261
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
245
262
COMMENT "Compile hello_module.js to a C file with bytecode embeddee"
@@ -253,7 +270,7 @@ if(BUILD_EXAMPLES AND NOT MINGW)
253
270
target_compile_definitions (hello_module PRIVATE ${qjs_defines} )
254
271
target_link_libraries (hello_module ${qjs_libs} )
255
272
256
- if (NOT MINGW )
273
+ if (NOT WIN32 )
257
274
add_library (fib MODULE examples/fib.c )
258
275
set_target_properties (fib PROPERTIES
259
276
PREFIX ""
@@ -287,7 +304,7 @@ if(BUILD_EXAMPLES AND NOT MINGW)
287
304
288
305
add_custom_command (
289
306
OUTPUT test_fib.c
290
- COMMAND " ${CMAKE_CURRENT_BINARY_DIR} / qjsc" -e -o test_fib.c -M ${CMAKE_CURRENT_SOURCE_DIR} /examples/fib.so,fib -m ${CMAKE_CURRENT_SOURCE_DIR} /examples/test_fib.js
307
+ COMMAND qjsc -e -o test_fib.c -M ${CMAKE_CURRENT_SOURCE_DIR} /examples/fib.so,fib -m ${CMAKE_CURRENT_SOURCE_DIR} /examples/test_fib.js
291
308
DEPENDS qjsc
292
309
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
293
310
COMMENT "Compile test_fib.js to a C file with bytecode embedded"
0 commit comments