@@ -343,8 +343,9 @@ if (LLAMA_MPI)
343
343
set (GGML_SOURCES_MPI ggml-mpi.c ggml-mpi.h)
344
344
add_compile_definitions (GGML_USE_MPI)
345
345
add_compile_definitions (${MPI_C_COMPILE_DEFINITIONS} )
346
- set (cxx_flags ${cxx_flags} -Wno-cast-qual)
347
- set (c_flags ${c_flags} -Wno-cast-qual)
346
+ if (NOT MSVC )
347
+ add_compile_options (-Wno-cast-qual)
348
+ endif ()
348
349
set (LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} ${MPI_C_LIBRARIES} )
349
350
set (LLAMA_EXTRA_INCLUDES ${LLAMA_EXTRA_INCLUDES} ${MPI_C_INCLUDE_DIRS} )
350
351
# Even if you're only using the C header, C++ programs may bring in MPI
@@ -418,10 +419,11 @@ if (LLAMA_ALL_WARNINGS)
418
419
set (c_flags -Wshadow -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes -Werror=implicit-int
419
420
-Werror=implicit-function-declaration)
420
421
set (cxx_flags -Wmissing-declarations -Wmissing-noreturn)
422
+ set (host_cxx_flags "" )
421
423
422
424
if (CMAKE_C_COMPILER_ID MATCHES "Clang" )
423
425
set (warning_flags ${warning_flags} -Wunreachable-code-break -Wunreachable-code-return)
424
- set (cxx_flags ${cxx_flags } -Wmissing-prototypes -Wextra-semi)
426
+ set (host_cxx_flags ${host_cxx_flags } -Wmissing-prototypes -Wextra-semi)
425
427
426
428
if (
427
429
(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 3.8.0) OR
@@ -431,27 +433,38 @@ if (LLAMA_ALL_WARNINGS)
431
433
endif ()
432
434
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU" )
433
435
set (c_flags ${c_flags} -Wdouble-promotion)
434
- set (cxx_flags ${cxx_flags } -Wno-array-bounds)
436
+ set (host_cxx_flags ${host_cxx_flags } -Wno-array-bounds)
435
437
436
438
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7.1.0)
437
- set (cxx_flags ${cxx_flags } -Wno-format-truncation)
439
+ set (host_cxx_flags ${host_cxx_flags } -Wno-format-truncation)
438
440
endif ()
439
441
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1.0)
440
- set (cxx_flags ${cxx_flags } -Wextra-semi)
442
+ set (host_cxx_flags ${host_cxx_flags } -Wextra-semi)
441
443
endif ()
442
444
endif ()
443
445
else ()
444
446
# todo : msvc
445
447
endif ()
446
448
447
- add_compile_options (
448
- ${warning_flags}
449
- "$<$<COMPILE_LANGUAGE:C>:${c_flags} >"
450
- "$<$<COMPILE_LANGUAGE:CXX>:${cxx_flags} >"
451
- )
449
+ set (c_flags ${c_flags} ${warning_flags} )
450
+ set (cxx_flags ${cxx_flags} ${warning_flags} )
451
+ add_compile_options ("$<$<COMPILE_LANGUAGE:C>:${c_flags} >"
452
+ "$<$<COMPILE_LANGUAGE:CXX>:${cxx_flags} ${host_cxx_flags} >" )
453
+
454
+ endif ()
452
455
456
+ if (NOT MSVC )
457
+ set (cuda_flags -Wno-pedantic)
458
+ endif ()
459
+ set (cuda_flags ${cxx_flags} -use_fast_math ${cuda_flags} )
460
+
461
+ list (JOIN host_cxx_flags " " cuda_host_flags) # pass host compiler flags as a single argument
462
+ if (NOT cuda_host_flags STREQUAL "" )
463
+ set (cuda_flags ${cuda_flags} -Xcompiler ${cuda_host_flags} )
453
464
endif ()
454
465
466
+ add_compile_options ("$<$<COMPILE_LANGUAGE:CUDA>:${cuda_flags} >" )
467
+
455
468
if (WIN32 )
456
469
add_compile_definitions (_CRT_SECURE_NO_WARNINGS)
457
470
0 commit comments