@@ -166,6 +166,10 @@ impl CmakeBuilder {
166
166
// Allow environment to specify CMake toolchain.
167
167
if let Some ( toolchain) = optional_env_optional_crate_target ( "CMAKE_TOOLCHAIN_FILE" ) {
168
168
set_env_for_target ( "CMAKE_TOOLCHAIN_FILE" , toolchain) ;
169
+ // Only setup if allowed by environment variable
170
+ if use_prebuilt_nasm ( ) && Some ( true ) == allow_prebuilt_nasm ( ) {
171
+ self . configure_prebuilt_nasm ( & mut cmake_cfg) ;
172
+ }
169
173
return cmake_cfg;
170
174
}
171
175
// We only consider compiler CFLAGS when no cmake toolchain is set
@@ -244,7 +248,7 @@ impl CmakeBuilder {
244
248
} ;
245
249
emit_warning (
246
250
& format ! (
247
- "Neither script could be tested for execution, falling back to target-based selection: {}" ,
251
+ "Neither script could be tested for execution, falling back to target-based selection: {}" ,
248
252
fallback_script. file_name( ) . unwrap( ) . to_str( ) . unwrap( ) ) ) ;
249
253
fallback_script
250
254
}
@@ -304,42 +308,46 @@ impl CmakeBuilder {
304
308
}
305
309
}
306
310
if use_prebuilt_nasm ( ) {
307
- emit_warning ( "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" ) ;
308
- emit_warning ( "!!! Using pre-built NASM binaries !!!" ) ;
309
- emit_warning ( "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" ) ;
310
-
311
- let script_path = self . select_prebuilt_nasm_script ( ) ;
312
- let script_path = script_path. display ( ) . to_string ( ) ;
313
- let script_path = script_path. replace ( '\\' , "/" ) ;
314
-
315
- cmake_cfg. define ( "CMAKE_ASM_NASM_COMPILER" , script_path. as_str ( ) ) ;
316
- // Without the following definition, the build fails with a message similar to the one
317
- // reported here: https://gitlab.kitware.com/cmake/cmake/-/issues/19453
318
- // The variables below were found in the associated fix:
319
- // https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4257/diffs
320
- cmake_cfg. define (
321
- "CMAKE_ASM_NASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded" ,
322
- "" ,
323
- ) ;
324
- cmake_cfg. define (
325
- "CMAKE_ASM_NASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL" ,
326
- "" ,
327
- ) ;
328
- cmake_cfg. define (
329
- "CMAKE_ASM_NASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug" ,
330
- "" ,
331
- ) ;
332
- cmake_cfg. define (
333
- "CMAKE_ASM_NASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL" ,
334
- "" ,
335
- ) ;
336
- cmake_cfg. define (
337
- "CMAKE_ASM_NASM_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase" ,
338
- "" ,
339
- ) ;
311
+ self . configure_prebuilt_nasm ( cmake_cfg) ;
340
312
}
341
313
}
342
314
315
+ fn configure_prebuilt_nasm ( & self , cmake_cfg : & mut cmake:: Config ) {
316
+ emit_warning ( "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" ) ;
317
+ emit_warning ( "!!! Using pre-built NASM binaries !!!" ) ;
318
+ emit_warning ( "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" ) ;
319
+
320
+ let script_path = self . select_prebuilt_nasm_script ( ) ;
321
+ let script_path = script_path. display ( ) . to_string ( ) ;
322
+ let script_path = script_path. replace ( '\\' , "/" ) ;
323
+
324
+ cmake_cfg. define ( "CMAKE_ASM_NASM_COMPILER" , script_path. as_str ( ) ) ;
325
+ // Without the following definition, the build fails with a message similar to the one
326
+ // reported here: https://gitlab.kitware.com/cmake/cmake/-/issues/19453
327
+ // The variables below were found in the associated fix:
328
+ // https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4257/diffs
329
+ cmake_cfg. define (
330
+ "CMAKE_ASM_NASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded" ,
331
+ "" ,
332
+ ) ;
333
+ cmake_cfg. define (
334
+ "CMAKE_ASM_NASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL" ,
335
+ "" ,
336
+ ) ;
337
+ cmake_cfg. define (
338
+ "CMAKE_ASM_NASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug" ,
339
+ "" ,
340
+ ) ;
341
+ cmake_cfg. define (
342
+ "CMAKE_ASM_NASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL" ,
343
+ "" ,
344
+ ) ;
345
+ cmake_cfg. define (
346
+ "CMAKE_ASM_NASM_COMPILE_OPTIONS_MSVC_DEBUG_INFORMATION_FORMAT_ProgramDatabase" ,
347
+ "" ,
348
+ ) ;
349
+ }
350
+
343
351
fn configure_open_harmony ( cmake_cfg : & mut cmake:: Config ) {
344
352
let mut cflags = vec ! [ "-Wno-unused-command-line-argument" ] ;
345
353
let mut asmflags = vec ! [ ] ;
0 commit comments