Skip to content

fix(build): make windows build compatible with CUDA

Description

Rework the way the compile flags are set when dealing with CUDA language. Basically, NVCC forwards some flags that he knows only the real compiler is concerned, but not the one it doesn't understand, making the build fail. This MR ensure that unknown flags are enclosed within a "-Xcompiler=", effectively forwarding such flags to the right person. The trick was to use "cmake-generator-expressions" and specify the language like in:

add_compile_options(
  "$<$<AND:$<CXX_COMPILER_ID:MSVC>,$<COMPILE_LANGUAGE:C,CXX>>:/experimental\:external;/external\:W0;/external\:I >"
)

add_compile_options(
  "$<$<AND:$<CXX_COMPILER_ID:MSVC>,$<COMPILE_LANGUAGE:CUDA>>:-Xcompiler=-experimental\:external -external\:W0 -external\:I >"
)

This forces us to define two time the flags, but there is no easy way to factorize, as we use "cmake-generator-expressions". If someone has a better fix, feel free...

Closes #1117 (closed)

How to test it?

  • Build Sight + with a CUDA enabled project:

    • on Windows
    • on Linux
  • Build Sight without CUDA:

    • on Windows
    • on Linux
Edited by Didier WECKMANN

Merge request reports