diff --git a/meson.build b/meson.build index 1d1f7f0d..b7f25bb0 100644 --- a/meson.build +++ b/meson.build @@ -14,7 +14,13 @@ vapidir = meson.current_source_dir() / 'vapi/' add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()), language: 'c') -add_project_arguments(['--vapidir', vapidir], language: 'vala') +vala_flags = ['--vapidir', vapidir] + +if get_option('nvidia').enabled() + vala_flags += ['--define', 'NVIDIA_SUPPORT'] +endif + +add_project_arguments(vala_flags, language: 'vala') # subprojects should be skipped: https://mesonbuild.com/Release-notes-for-0-58-0.html#skip-subprojects-installation # needs meson 0.58.0 @@ -48,8 +54,10 @@ app_dependencies = [ meson.get_compiler('c').find_library('pci'), meson.get_compiler('vala').find_library('pci', dirs: vapidir), - meson.get_compiler('c').find_library('XNVCtrl'), - meson.get_compiler('vala').find_library('libxnvctrl', dirs: vapidir), + # Allow building without nvidia libraries because they're not packaged or does not run + # on some distros due to incompatibility with muslc. Also they're not needed on ARM architecture + meson.get_compiler('c').find_library('XNVCtrl', required: get_option('nvidia').enabled()), + meson.get_compiler('vala').find_library('libxnvctrl', dirs: vapidir, required: get_option('nvidia').enabled()), ] config_data = configuration_data() diff --git a/meson_options.txt b/meson_options.txt index d0fedb3b..6dc700aa 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1 +1,2 @@ -option('indicator-wingpanel', type : 'feature', value : 'disabled', description : 'Enables the Indicator for Wingpanel.') \ No newline at end of file +option('indicator-wingpanel', type : 'feature', value : 'disabled', description : 'Enables the Indicator for Wingpanel.') +option('nvidia', type : 'feature', value : 'enabled', description : 'Build with NVIDIA support.') \ No newline at end of file diff --git a/src/Resources/GPU/GPUNvidia.vala b/src/Resources/GPU/GPUNvidia.vala index 6515afc7..980a69d2 100644 --- a/src/Resources/GPU/GPUNvidia.vala +++ b/src/Resources/GPU/GPUNvidia.vala @@ -64,6 +64,7 @@ public class Monitor.GPUNvidia : IGPU, Object { } private void update_nv_resources () { +#if NVIDIA_SUPPORT nvidia_resources_temperature = NVCtrl.XNVCTRLQueryAttribute ( nvidia_display, 0, @@ -119,6 +120,7 @@ public class Monitor.GPUNvidia : IGPU, Object { nvidia_fb_percentage = int.parse (((string) nvidia_used).split_set ("=,")[3]); debug ("USED_GRAPHICS: %d%\n", nvidia_percentage); debug ("USED_FB_MEMORY: %d%\n", nvidia_fb_percentage); +#endif if (!nvidia_resources_used) { warning ("Could not query NV_CTRL_STRING_GPU_UTILIZATION attribute!\n");