SDL-Mixer-X icon indicating copy to clipboard operation
SDL-Mixer-X copied to clipboard

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

Open knight-ryu12 opened this issue 2 months ago • 3 comments

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.

knight-ryu12 avatar Apr 22 '24 04:04 knight-ryu12

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 avatar Apr 22 '24 09:04 Wohlstand

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.

Wohlstand avatar Apr 22 '24 10:04 Wohlstand

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

knight-ryu12 avatar Apr 23 '24 05:04 knight-ryu12