flightlessmango / MangoHud

A Vulkan and OpenGL overlay for monitoring FPS, temperatures, CPU/GPU load and more. Discord: https://discordapp.com/invite/Gj5YmBb
MIT License
6.13k stars 262 forks source link

meson: verify if system lib are present before fallback to submodules #1321

Closed MrDuartePT closed 2 months ago

MrDuartePT commented 2 months ago

This PR removed the need of use_system_spdlog and check if the submodules library are present in the system before downloading and build them.

This allow mangohud to be build only using local installed system dependencies.

Also code to use system Vulkan Headers is comment out (can be used in the future if Mangohud start using latest Vulkan SDK, for exemple gentoo only packages the latest SDK on there repo) https://packages.gentoo.org/packages/dev-util/vulkan-headers

flightlessmango commented 2 months ago

The purpose of use_system_spdlog is to force the use of system or subproject. By default we want the user to use the subproject over the system libs because that's what we've tested against

MrDuartePT commented 2 months ago

The purpose of use_system_spdlog is to force the use of system or subproject. By default we want the user to use the subproject over the system libs because that's what we've tested against

Ok noted. About the other submodules you like the change or not? Also you want me to make use_system_lib-name for the other submodules?

MrDuartePT commented 2 months ago

With the lastet commit you done the use_system_spdlog dosent work, meson will always use the system libary

With spdlog install:

mrduarte@GentooLegion /tmp/MangoHud (master) $ meson setup -Duse_system_spdlog=disabled sourcedir
The Meson build system
Version: 1.3.2
Source dir: /tmp/MangoHud
Build dir: /tmp/MangoHud/sourcedir
Build type: native build
Project name: MangoHud
Project version: v0.7.1
C compiler for the host machine: clang (clang 18.1.5 "clang version 18.1.5+libcxx")
C linker for the host machine: clang ld.lld 18.1.5
C++ compiler for the host machine: clang++ (clang 18.1.5 "clang version 18.1.5+libcxx")
C++ linker for the host machine: clang++ ld.lld 18.1.5
Host machine cpu family: x86_64
Host machine cpu: x86_64
(...)

Executing subproject vulkan-headers
(...)

Executing subproject imgui
(...)

Executing subproject implot
(...)

Library spdlog found: YES
Run-time dependency spdlog found: YES 1.13.0
Run-time dependency nlohmann_json found: YES 3.11.3
Program glslang found: YES (/usr/bin/glslang)
Program git found: YES (/usr/bin/git)
Has header "NVCtrl/NVCtrl.h" : YES
Compiler for C supports link arguments -Wl,-Bsymbolic-functions: YES
Compiler for C supports link arguments -Wl,-z,relro: YES
Compiler for C supports link arguments -Wl,--exclude-libs,ALL: YES
Compiler for C supports link arguments -lGL: YES
Compiler for C supports link arguments -static-libstdc++: YES
WARNING: extract_all_objects called without setting recursive
keyword argument. Meson currently defaults to
non-recursive to maintain backward compatibility but
the default will be changed in the future.

Configuring MangoHud.x86_64.json using configuration
Configuring mangohud using configuration
Program appstreamcli found: YES (/usr/bin/appstreamcli)
Build targets in project: 10

MangoHud v0.7.1

  Subprojects
    imgui            : YES
    implot           : YES
    vulkan-headers   : YES

  User defined options
    use_system_spdlog: disabled

Found ninja-1.12.0 at /usr/bin/ninja

Without it:

mrduarte@GentooLegion /tmp/MangoHud (master) $ meson setup -Duse_system_spdlog=disabled sourcedir
(...)
Library spdlog found: NO
Downloading spdlog source from https://github.com/gabime/spdlog/archive/refs/tags/v1.14.1.tar.gz
Download size: 270896
Downloading: ..........
Downloading spdlog patch from https://wrapdb.mesonbuild.com/v2/spdlog_1.14.1-1/get_patch
Download size: 2965
Downloading: ..........

Executing subproject spdlog

spdlog| Project name: spdlog
spdlog| Project version: 1.14.1
spdlog| C++ compiler for the host machine: clang++ (clang 18.1.5 "clang version 18.1.5+libcxx")
spdlog| C++ linker for the host machine: clang++ ld.lld 18.1.5
spdlog| Dependency threads found: YES unknown (cached)
spdlog| Header "format" has symbol "__cpp_lib_format" skipped: feature std_format disabled
spdlog| Dependency fmt skipped: feature external_fmt disabled
spdlog| Build targets in project: 5
spdlog| Subproject spdlog finished.

Dependency nlohmann_json found: YES 3.11.3 (cached)
Program glslang found: YES (/usr/bin/glslang)
Program git found: YES (/usr/bin/git)
Has header "NVCtrl/NVCtrl.h" : YES (cached)
Compiler for C supports link arguments -Wl,-Bsymbolic-functions: YES (cached)
Compiler for C supports link arguments -Wl,-z,relro: YES (cached)
Compiler for C supports link arguments -Wl,--exclude-libs,ALL: YES (cached)
Compiler for C supports link arguments -lGL: YES (cached)
Compiler for C supports link arguments -static-libstdc++: YES (cached)
WARNING: extract_all_objects called without setting recursive
keyword argument. Meson currently defaults to
non-recursive to maintain backward compatibility but
the default will be changed in the future.

Configuring MangoHud.x86_64.json using configuration
Configuring mangohud using configuration
Program appstreamcli found: YES (/usr/bin/appstreamcli)
Build targets in project: 11

MangoHud v0.7.1

  Subprojects
    imgui            : YES
    implot           : YES
    spdlog           : YES
    vulkan-headers   : YES

  User defined options
    use_system_spdlog: disabled

Found ninja-1.12.0 at /usr/bin/ninja
flightlessmango commented 2 months ago

With the latest commit you done the use_system_spdlog dosent work

Yes this needs to be fixed so it works again

Also you want me to make use_system_lib-name for the other submodules

I don't think any other are required

MrDuartePT commented 2 months ago

After the recent changes made.

With spdlog installed and Duse_system_spdlog=enabled:

meson setup --reconfigure -Duse_system_spdlog=enabled sourcedir
(...)
Checking for size of "void*" : 8 (cached)
Dependency imgui found: YES 1.89.9 (cached)
Dependency implot found: YES 0.16 (cached)
Dependency spdlog found: YES 1.13.0 (cached)
Dependency nlohmann_json found: YES 3.11.3 (cached)
Program glslang found: YES (/usr/bin/glslang)
Program git found: YES (/usr/bin/git)
Has header "NVCtrl/NVCtrl.h" : YES (cached)
(...)

Configuring MangoHud.x86_64.json using configuration
Configuring mangohud using configuration
Program appstreamcli found: YES (/usr/bin/appstreamcli)
Build targets in project: 8

MangoHud v0.7.1

  Subprojects
    vulkan-headers   : YES

With spdlog installed and Duse_system_spdlog=disabled:

meson setup --reconfigure -Duse_system_spdlog=disabled sourcedir
(...)
Dependency nlohmann_json found: YES 3.11.3 (cached)
Program glslang found: YES (/usr/bin/glslang)
Program git found: YES (/usr/bin/git)
Has header "NVCtrl/NVCtrl.h" : YES (cached)
(...)

Configuring MangoHud.x86_64.json using configuration
Configuring mangohud using configuration
Program appstreamcli found: YES (/usr/bin/appstreamcli)
Build targets in project: 9

MangoHud v0.7.1

  Subprojects
    spdlog           : YES
    vulkan-headers   : YES

With spdlog not installed and Duse_system_spdlog=enabled (by mistake for exemple):

meson setup --reconfigure -Duse_system_spdlog=enabled sourcedir
(...)
spdlog| Project name: spdlog
spdlog| Project version: 1.14.1
spdlog| C++ compiler for the host machine: clang++ (clang 18.1.5 "clang version 18.1.5+libcxx")
spdlog| C++ linker for the host machine: clang++ ld.lld 18.1.5
spdlog| Dependency threads found: YES unknown (cached)
spdlog| Header "format" has symbol "__cpp_lib_format" skipped: feature std_format disabled
spdlog| Dependency fmt skipped: feature external_fmt disabled
spdlog| Build targets in project: 3
spdlog| Subproject spdlog finished.

Dependency spdlog from subproject subprojects/spdlog-1.14.1 found: YES 1.14.1
Run-time dependency nlohmann_json found: YES 3.11.3
Program glslang found: YES (/usr/bin/glslang)
Program git found: YES (/usr/bin/git)
Has header "NVCtrl/NVCtrl.h" : YES
(...)

Configuring MangoHud.x86_64.json using configuration
Configuring mangohud using configuration
Program appstreamcli found: YES (/usr/bin/appstreamcli)
Build targets in project: 9

MangoHud v0.7.1

  Subprojects
    spdlog           : YES
    vulkan-headers   : YES

  User defined options
    use_system_spdlog: enabled

I can remove the fallback and made meson failed when use_system_spdlog: enabled and spdlog is not found

flightlessmango commented 2 months ago

I can remove the fallback and made meson failed when use_system_spdlog: enabled and spdlog is not found

It should be fine to just fallback, doesn't need to fail

MrDuartePT commented 2 months ago

Done, add a warning when meson fallback to the submodule with use_system_spdlog enabled

Edit commit: fix typo

MrDuartePT commented 2 months ago

The workflow failure is fix

MrDuartePT commented 2 months ago

The migw failed because I applied the same logic to minhook as the other dependencies, I gonna give a look at minhook meson.build and fix the error. Edit: should be solve now

MrDuartePT commented 2 months ago

It was a typo with minhook, now everything should build fine