@@ -343,8 +343,9 @@ if (LLAMA_MPI)
343343 set (GGML_SOURCES_MPI ggml-mpi.c ggml-mpi.h)
344344 add_compile_definitions (GGML_USE_MPI)
345345 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 ()
348349 set (LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} ${MPI_C_LIBRARIES} )
349350 set (LLAMA_EXTRA_INCLUDES ${LLAMA_EXTRA_INCLUDES} ${MPI_C_INCLUDE_DIRS} )
350351 # Even if you're only using the C header, C++ programs may bring in MPI
@@ -418,10 +419,11 @@ if (LLAMA_ALL_WARNINGS)
418419 set (c_flags -Wshadow -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes -Werror=implicit-int
419420 -Werror=implicit-function-declaration)
420421 set (cxx_flags -Wmissing-declarations -Wmissing-noreturn)
422+ set (host_cxx_flags "" )
421423
422424 if (CMAKE_C_COMPILER_ID MATCHES "Clang" )
423425 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)
425427
426428 if (
427429 (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)
431433 endif ()
432434 elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU" )
433435 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)
435437
436438 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)
438440 endif ()
439441 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)
441443 endif ()
442444 endif ()
443445 else ()
444446 # todo : msvc
445447 endif ()
446448
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 ()
452455
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} )
453464endif ()
454465
466+ add_compile_options ("$<$<COMPILE_LANGUAGE:CUDA>:${cuda_flags} >" )
467+
455468if (WIN32 )
456469 add_compile_definitions (_CRT_SECURE_NO_WARNINGS)
457470
0 commit comments