From 341fdaad77d65f0c4ca18db5c489520032f4effd Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Fri, 23 Feb 2024 20:54:10 -0500 Subject: [PATCH] build(cmake): add option to skip cuda inheriting compile options (#2164) --- cmake/prep/options.cmake | 4 ++++ cmake/targets/common.cmake | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cmake/prep/options.cmake b/cmake/prep/options.cmake index 7a8d728ba..90f748eb8 100644 --- a/cmake/prep/options.cmake +++ b/cmake/prep/options.cmake @@ -6,6 +6,10 @@ option(SUNSHINE_REQUIRE_TRAY "Require system tray icon. Fail the build if tray r option(SUNSHINE_SYSTEM_WAYLAND_PROTOCOLS "Use system installation of wayland-protocols rather than the submodule." OFF) +option(CUDA_INHERIT_COMPILE_OPTIONS + "When building CUDA code, inherit compile options from the the main project. You may want to disable this if + your IDE throws errors about unknown flags after running cmake." ON) + if(APPLE) option(SUNSHINE_CONFIGURE_PORTFILE "Configure macOS Portfile. Recommended to use with SUNSHINE_CONFIGURE_ONLY" OFF) diff --git a/cmake/targets/common.cmake b/cmake/targets/common.cmake index cb5fe4e67..3dd629e0c 100644 --- a/cmake/targets/common.cmake +++ b/cmake/targets/common.cmake @@ -28,9 +28,12 @@ set_target_properties(sunshine PROPERTIES CXX_STANDARD 17 VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) -foreach(flag IN LISTS SUNSHINE_COMPILE_OPTIONS) - list(APPEND SUNSHINE_COMPILE_OPTIONS_CUDA "$<$:--compiler-options=${flag}>") -endforeach() +# CLion complains about unknown flags after running cmake, and cannot add symbols to the index for cuda files +if(CUDA_INHERIT_COMPILE_OPTIONS) + foreach(flag IN LISTS SUNSHINE_COMPILE_OPTIONS) + list(APPEND SUNSHINE_COMPILE_OPTIONS_CUDA "$<$:--compiler-options=${flag}>") + endforeach() +endif() target_compile_options(sunshine PRIVATE $<$:${SUNSHINE_COMPILE_OPTIONS}>;$<$:${SUNSHINE_COMPILE_OPTIONS_CUDA};-std=c++17>) # cmake-lint: disable=C0301