WohlSoft / SDL-Mixer-X

SDL Mixer X (Or "MixerX" shortly) - An audio mixer library based on the SDL library, a fork of SDL_mixer
https://wohlsoft.github.io/SDL-Mixer-X/
Other
102 stars 26 forks source link

MixerX returns cryptic error when SDL2 is already included in the library #76

Open knight-ryu12 opened 3 months ago

knight-ryu12 commented 3 months ago

Seems that when FetchContent_Declare is defined for SDL2 FIRST, then MixerX was Declared, MixerX tries to install SDL2 no matter what.

Error is

CMake Error: The INTERFACE_SDL2_SHARED property of "SDL2" does
not agree with the value of SDL2_SHARED already determined
for "sdl2_vulkan".

CMake Error: install(EXPORT "SDL2MixerExtStaticTargets" ...) includes target "SDL2_mixer_ext_Static" which requires target "SDL2" that is not in any export set.

I'd suggest check for SDL2_DISABLE_INSTALL is enabled or not to prevent double install.

Wohlstand commented 3 months ago

Actually, I never used the FetchContent way, and I more prefer the ExternalProject as it gives me a full control on what to configure and how to install, and what content is to take. You may want to check out this example on how to use the MixerX and dependent libraries from the AudioCodec set: https://github.com/TheXTech/TheXTech/blob/main/cmake/library_SDLMixerX.cmake (Note: In this example, AudioCodecs and MixerX are submodules of the project, and they gets used by local way, i.e. reuse the same source directory without the clonning/updating the whole repo - this results a time waste while debugging because it also tries to sync the repo and rebuild the library when it's not needed).

Wohlstand commented 3 months ago

MixerX tries to install SDL2 no matter what.

As I remember, by default build it attempts to find the nearest available in-system SDL2, and it does downloading and installing of extra things if enable the separate AudioCodecs downloading :thinking: Here is also a flag that tells to use system SDL2 in any way, and therefore SDL2 from AudioCodecs will not being used and system-wide will be preferred.

knight-ryu12 commented 3 months ago

Seems that if SDL is being add_subdirectory'd into project, you can't install any target that depends into SDL, because SDL isn't itself scheduled to be installed by the project

If you then add_subdirectory MixerX, it tries to install itself (which depends on SDL), which breaks