Closed pthom closed 2 years ago
You're basically suggesting to revert 686a0f34562587f2da41e2792b086af33a0a5d0c, committed for fixing https://github.com/libsdl-org/SDL/pull/5011. At the end of that pr, people were already reporting the cmake error you're highlighting here.
Before this goes in, can you please verify whether there is no change in behavior in detecting Metal/vulkan/joysticks when SDL is built as the main project or built as a subproject? https://github.com/libsdl-org/SDL/pull/5011#issuecomment-980500032 suggests the CMake generator is also at play here. So can you please do both tests with the Ninja and Xcode generator?
You don't need to rebuild SDL completely, just check whether the configure result is the same for all.
The WIP pr https://github.com/libsdl-org/SDL/pull/6198 is also fixing weird objective-c support, which makes me think OBJC support of CMake is not top notch.
Many thanks for your prompt answer.
Here is what I get when I build SDL with the workaround I mentioned:
This is on a Mac M1, with the latest version of MacOS (Monterey V12.6), XCode (Version 13.4.1 (13F100)) and Apple clang version 13.1.6 (clang-1316.0.21.2.5).
cmake ..
)-- SDL_METAL (Wanted: ON): ON
-- SDL_RENDER_METAL (Wanted: ON): ON
-- SDL_VULKAN (Wanted: ON): ON
-- Joystick: ON
-- SDL_HIDAPI_JOYSTICK (Wanted: ON): ON
-- SDL_VIRTUAL_JOYSTICK (Wanted: ON): ON
cmake .. -GNinja
)-- SDL_METAL (Wanted: ON): ON
-- SDL_RENDER_METAL (Wanted: ON): ON
-- SDL_VULKAN (Wanted: ON): ON
-- Joystick: ON
-- SDL_HIDAPI_JOYSTICK (Wanted: ON): ON
-- SDL_VIRTUAL_JOYSTICK (Wanted: ON): ON
cmake .. -GXcode
):-- SDL_METAL (Wanted: ON): ON
-- SDL_RENDER_METAL (Wanted: ON): ON
-- SDL_VULKAN (Wanted: ON): ON
-- Joystick: ON
-- SDL_HIDAPI_JOYSTICK (Wanted: ON): ON
-- SDL_VIRTUAL_JOYSTICK (Wanted: ON): ON
In case you need more details, below is the full sdl output for each generator:
Full output for cmake ..
--
-- SDL2 was configured with the following options:
--
-- Platform: Darwin-21.6.0
-- 64-bit: TRUE
-- Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Revision: SDL-release-2.24.0-624-gb9e1d1b4d
--
-- Subsystems:
-- Atomic: ON
-- Audio: ON
-- Video: ON
-- Render: ON
-- Events: ON
-- Joystick: ON
-- Haptic: ON
-- Hidapi: ON
-- Power: ON
-- Threads: ON
-- Timers: ON
-- File: ON
-- Loadso: ON
-- CPUinfo: ON
-- Filesystem: ON
-- Sensor: ON
-- Locale: ON
-- Misc: ON
--
-- Options:
-- SDL2_DISABLE_INSTALL (Wanted: ON): OFF
-- SDL2_DISABLE_SDL2MAIN (Wanted: OFF): OFF
-- SDL2_DISABLE_UNINSTALL (Wanted: OFF): OFF
-- SDL_3DNOW (Wanted: ON): OFF
-- SDL_ALSA (Wanted: OFF): OFF
-- SDL_ALSA_SHARED (Wanted: OFF): OFF
-- SDL_ALTIVEC (Wanted: ON): OFF
-- SDL_ARMNEON (Wanted: OFF): OFF
-- SDL_ARMSIMD (Wanted: OFF): OFF
-- SDL_ARTS (Wanted: OFF): OFF
-- SDL_ARTS_SHARED (Wanted: OFF): OFF
-- SDL_ASAN (Wanted: OFF): OFF
-- SDL_ASSEMBLY (Wanted: ON): ON
-- SDL_ASSERTIONS (Wanted: auto): auto
-- SDL_BACKGROUNDING_SIGNAL (Wanted: OFF): OFF
-- SDL_CLOCK_GETTIME (Wanted: OFF): OFF
-- SDL_COCOA (Wanted: ON): ON
-- SDL_DBUS (Wanted: OFF): OFF
-- SDL_DIRECTFB (Wanted: OFF): OFF
-- SDL_DIRECTFB_SHARED (Wanted: OFF): OFF
-- SDL_DIRECTX (Wanted: OFF): OFF
-- SDL_DISKAUDIO (Wanted: ON): ON
-- SDL_DUMMYAUDIO (Wanted: ON): ON
-- SDL_DUMMYVIDEO (Wanted: ON): ON
-- SDL_ESD (Wanted: OFF): OFF
-- SDL_ESD_SHARED (Wanted: OFF): OFF
-- SDL_FOREGROUNDING_SIGNAL (Wanted: OFF): OFF
-- SDL_FUSIONSOUND (Wanted: OFF): OFF
-- SDL_FUSIONSOUND_SHARED (Wanted: OFF): OFF
-- SDL_GCC_ATOMICS (Wanted: ON): ON
-- SDL_HIDAPI (Wanted: ON): ON
-- SDL_HIDAPI_JOYSTICK (Wanted: ON): ON
-- SDL_HIDAPI_LIBUSB (Wanted: OFF): OFF
-- SDL_IBUS (Wanted: OFF): OFF
-- SDL_INSTALL_TESTS (Wanted: OFF): OFF
-- SDL_JACK (Wanted: OFF): OFF
-- SDL_JACK_SHARED (Wanted: OFF): OFF
-- SDL_KMSDRM (Wanted: OFF): OFF
-- SDL_KMSDRM_SHARED (Wanted: OFF): OFF
-- SDL_LIBC (Wanted: ON): ON
-- SDL_LIBSAMPLERATE (Wanted: OFF): OFF
-- SDL_LIBSAMPLERATE_SHARED (Wanted: OFF): OFF
-- SDL_METAL (Wanted: ON): ON
-- SDL_MMX (Wanted: ON): OFF
-- SDL_NAS (Wanted: OFF): OFF
-- SDL_NAS_SHARED (Wanted: OFF): OFF
-- SDL_OFFSCREEN (Wanted: ON): ON
-- SDL_OPENGL (Wanted: ON): ON
-- SDL_OPENGLES (Wanted: ON): ON
-- SDL_OSS (Wanted: OFF): OFF
-- SDL_PIPEWIRE (Wanted: OFF): OFF
-- SDL_PIPEWIRE_SHARED (Wanted: OFF): OFF
-- SDL_PTHREADS (Wanted: ON): ON
-- SDL_PTHREADS_SEM (Wanted: ON): ON
-- SDL_PULSEAUDIO (Wanted: OFF): OFF
-- SDL_PULSEAUDIO_SHARED (Wanted: OFF): OFF
-- SDL_RENDER_D3D (Wanted: OFF): OFF
-- SDL_RENDER_METAL (Wanted: ON): ON
-- SDL_RPATH (Wanted: OFF): OFF
-- SDL_RPI (Wanted: OFF): OFF
-- SDL_SNDIO (Wanted: OFF): OFF
-- SDL_SNDIO_SHARED (Wanted: OFF): OFF
-- SDL_SSE (Wanted: ON): OFF
-- SDL_SSE2 (Wanted: ON): OFF
-- SDL_SSE3 (Wanted: ON): OFF
-- SDL_SSEMATH (Wanted: ON): ON
-- SDL_STATIC_PIC (Wanted: OFF): OFF
-- SDL_SYSTEM_ICONV (Wanted: ON): ON
-- SDL_TESTS (Wanted: OFF): OFF
-- SDL_VENDOR_INFO (Wanted: ): OFF
-- SDL_VIRTUAL_JOYSTICK (Wanted: ON): ON
-- SDL_VIVANTE (Wanted: OFF): OFF
-- SDL_VULKAN (Wanted: ON): ON
-- SDL_WASAPI (Wanted: OFF): OFF
-- SDL_WAYLAND (Wanted: OFF): OFF
-- SDL_WAYLAND_LIBDECOR (Wanted: OFF): OFF
-- SDL_WAYLAND_LIBDECOR_SHARED (Wanted: OFF): OFF
-- SDL_WAYLAND_QT_TOUCH (Wanted: OFF): OFF
-- SDL_WAYLAND_SHARED (Wanted: OFF): OFF
-- SDL_X11 (Wanted: OFF): OFF
-- SDL_X11_SHARED (Wanted: OFF): OFF
-- SDL_X11_XCURSOR (Wanted: OFF): OFF
-- SDL_X11_XDBE (Wanted: OFF): OFF
-- SDL_X11_XFIXES (Wanted: OFF): OFF
-- SDL_X11_XINPUT (Wanted: OFF): OFF
-- SDL_X11_XRANDR (Wanted: OFF): OFF
-- SDL_X11_XSCRNSAVER (Wanted: OFF): OFF
-- SDL_X11_XSHAPE (Wanted: OFF): OFF
-- SDL_XINPUT (Wanted: OFF): OFF
--
-- CFLAGS: -idirafter "/Users/pascal/dvp/OpenSource/ImGuiWork/sdl_glfw_cmake_issue/SDL/src/video/khronos"
-- EXTRA_CFLAGS: -Wall -fno-strict-aliasing -Wdeclaration-after-statement -fvisibility=hidden -Wshadow -D_THREAD_SAFE
-- EXTRA_LDFLAGS: -Wl,-framework,CoreVideo;-Wl,-framework,Cocoa;-Wl,-framework,IOKit;-Wl,-framework,ForceFeedback;-Wl,-framework,Carbon;-Wl,-framework,CoreAudio;-Wl,-framework,AudioToolbox;-Wl,-framework,AVFoundation;-Wl,-framework,Foundation;-Wl,-weak_framework,GameController;-Wl,-weak_framework,Metal;-Wl,-weak_framework,QuartzCore;-Wl,-weak_framework,CoreHaptics -Wl,-compatibility_version,2501.0.0;-Wl,-current_version,2501.0.0
-- EXTRA_LIBS: m;iconv
--
-- Build Shared Library: OFF
-- Build Static Library: ON
-- Build Static Library with Position Independent Code: OFF
--
-- If something was not detected, although the libraries
-- were installed, then make sure you have set the
-- CFLAGS and LDFLAGS environment variables correctly.
--
-- Configuring done
-- Generating done
Full output for cmake .. -GNinja
-- SDL2 was configured with the following options:
--
-- Platform: Darwin-21.6.0
-- 64-bit: TRUE
-- Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Revision: SDL-release-2.24.0-624-gb9e1d1b4d
--
-- Subsystems:
-- Atomic: ON
-- Audio: ON
-- Video: ON
-- Render: ON
-- Events: ON
-- Joystick: ON
-- Haptic: ON
-- Hidapi: ON
-- Power: ON
-- Threads: ON
-- Timers: ON
-- File: ON
-- Loadso: ON
-- CPUinfo: ON
-- Filesystem: ON
-- Sensor: ON
-- Locale: ON
-- Misc: ON
--
-- Options:
-- SDL2_DISABLE_INSTALL (Wanted: ON): OFF
-- SDL2_DISABLE_SDL2MAIN (Wanted: OFF): OFF
-- SDL2_DISABLE_UNINSTALL (Wanted: OFF): OFF
-- SDL_3DNOW (Wanted: ON): OFF
-- SDL_ALSA (Wanted: OFF): OFF
-- SDL_ALSA_SHARED (Wanted: OFF): OFF
-- SDL_ALTIVEC (Wanted: ON): OFF
-- SDL_ARMNEON (Wanted: OFF): OFF
-- SDL_ARMSIMD (Wanted: OFF): OFF
-- SDL_ARTS (Wanted: OFF): OFF
-- SDL_ARTS_SHARED (Wanted: OFF): OFF
-- SDL_ASAN (Wanted: OFF): OFF
-- SDL_ASSEMBLY (Wanted: ON): ON
-- SDL_ASSERTIONS (Wanted: auto): auto
-- SDL_BACKGROUNDING_SIGNAL (Wanted: OFF): OFF
-- SDL_CLOCK_GETTIME (Wanted: OFF): OFF
-- SDL_COCOA (Wanted: ON): ON
-- SDL_DBUS (Wanted: OFF): OFF
-- SDL_DIRECTFB (Wanted: OFF): OFF
-- SDL_DIRECTFB_SHARED (Wanted: OFF): OFF
-- SDL_DIRECTX (Wanted: OFF): OFF
-- SDL_DISKAUDIO (Wanted: ON): ON
-- SDL_DUMMYAUDIO (Wanted: ON): ON
-- SDL_DUMMYVIDEO (Wanted: ON): ON
-- SDL_ESD (Wanted: OFF): OFF
-- SDL_ESD_SHARED (Wanted: OFF): OFF
-- SDL_FOREGROUNDING_SIGNAL (Wanted: OFF): OFF
-- SDL_FUSIONSOUND (Wanted: OFF): OFF
-- SDL_FUSIONSOUND_SHARED (Wanted: OFF): OFF
-- SDL_GCC_ATOMICS (Wanted: ON): ON
-- SDL_HIDAPI (Wanted: ON): ON
-- SDL_HIDAPI_JOYSTICK (Wanted: ON): ON
-- SDL_HIDAPI_LIBUSB (Wanted: OFF): OFF
-- SDL_IBUS (Wanted: OFF): OFF
-- SDL_INSTALL_TESTS (Wanted: OFF): OFF
-- SDL_JACK (Wanted: OFF): OFF
-- SDL_JACK_SHARED (Wanted: OFF): OFF
-- SDL_KMSDRM (Wanted: OFF): OFF
-- SDL_KMSDRM_SHARED (Wanted: OFF): OFF
-- SDL_LIBC (Wanted: ON): ON
-- SDL_LIBSAMPLERATE (Wanted: OFF): OFF
-- SDL_LIBSAMPLERATE_SHARED (Wanted: OFF): OFF
-- SDL_METAL (Wanted: ON): ON
-- SDL_MMX (Wanted: ON): OFF
-- SDL_NAS (Wanted: OFF): OFF
-- SDL_NAS_SHARED (Wanted: OFF): OFF
-- SDL_OFFSCREEN (Wanted: ON): ON
-- SDL_OPENGL (Wanted: ON): ON
-- SDL_OPENGLES (Wanted: ON): ON
-- SDL_OSS (Wanted: OFF): OFF
-- SDL_PIPEWIRE (Wanted: OFF): OFF
-- SDL_PIPEWIRE_SHARED (Wanted: OFF): OFF
-- SDL_PTHREADS (Wanted: ON): ON
-- SDL_PTHREADS_SEM (Wanted: ON): ON
-- SDL_PULSEAUDIO (Wanted: OFF): OFF
-- SDL_PULSEAUDIO_SHARED (Wanted: OFF): OFF
-- SDL_RENDER_D3D (Wanted: OFF): OFF
-- SDL_RENDER_METAL (Wanted: ON): ON
-- SDL_RPATH (Wanted: OFF): OFF
-- SDL_RPI (Wanted: OFF): OFF
-- SDL_SNDIO (Wanted: OFF): OFF
-- SDL_SNDIO_SHARED (Wanted: OFF): OFF
-- SDL_SSE (Wanted: ON): OFF
-- SDL_SSE2 (Wanted: ON): OFF
-- SDL_SSE3 (Wanted: ON): OFF
-- SDL_SSEMATH (Wanted: ON): ON
-- SDL_STATIC_PIC (Wanted: OFF): OFF
-- SDL_SYSTEM_ICONV (Wanted: ON): ON
-- SDL_TESTS (Wanted: OFF): OFF
-- SDL_VENDOR_INFO (Wanted: ): OFF
-- SDL_VIRTUAL_JOYSTICK (Wanted: ON): ON
-- SDL_VIVANTE (Wanted: OFF): OFF
-- SDL_VULKAN (Wanted: ON): ON
-- SDL_WASAPI (Wanted: OFF): OFF
-- SDL_WAYLAND (Wanted: OFF): OFF
-- SDL_WAYLAND_LIBDECOR (Wanted: OFF): OFF
-- SDL_WAYLAND_LIBDECOR_SHARED (Wanted: OFF): OFF
-- SDL_WAYLAND_QT_TOUCH (Wanted: OFF): OFF
-- SDL_WAYLAND_SHARED (Wanted: OFF): OFF
-- SDL_X11 (Wanted: OFF): OFF
-- SDL_X11_SHARED (Wanted: OFF): OFF
-- SDL_X11_XCURSOR (Wanted: OFF): OFF
-- SDL_X11_XDBE (Wanted: OFF): OFF
-- SDL_X11_XFIXES (Wanted: OFF): OFF
-- SDL_X11_XINPUT (Wanted: OFF): OFF
-- SDL_X11_XRANDR (Wanted: OFF): OFF
-- SDL_X11_XSCRNSAVER (Wanted: OFF): OFF
-- SDL_X11_XSHAPE (Wanted: OFF): OFF
-- SDL_XINPUT (Wanted: OFF): OFF
--
-- CFLAGS: -idirafter "/Users/pascal/dvp/OpenSource/ImGuiWork/sdl_glfw_cmake_issue/SDL/src/video/khronos"
-- EXTRA_CFLAGS: -Wall -fno-strict-aliasing -Wdeclaration-after-statement -fvisibility=hidden -Wshadow -D_THREAD_SAFE
-- EXTRA_LDFLAGS: -Wl,-framework,CoreVideo;-Wl,-framework,Cocoa;-Wl,-framework,IOKit;-Wl,-framework,ForceFeedback;-Wl,-framework,Carbon;-Wl,-framework,CoreAudio;-Wl,-framework,AudioToolbox;-Wl,-framework,AVFoundation;-Wl,-framework,Foundation;-Wl,-weak_framework,GameController;-Wl,-weak_framework,Metal;-Wl,-weak_framework,QuartzCore;-Wl,-weak_framework,CoreHaptics -Wl,-compatibility_version,2501.0.0;-Wl,-current_version,2501.0.0
-- EXTRA_LIBS: m;iconv
--
-- Build Shared Library: OFF
-- Build Static Library: ON
-- Build Static Library with Position Independent Code: OFF
--
-- If something was not detected, although the libraries
-- were installed, then make sure you have set the
-- CFLAGS and LDFLAGS environment variables correctly.
--
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/pascal/dvp/OpenSource/ImGuiWork/sdl_glfw_cmake_issue/build
full output for cmake .. -GXcode
:
-- SDL2 was configured with the following options:
--
-- Platform: Darwin-21.6.0
-- 64-bit: TRUE
-- Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-- Revision: SDL-release-2.24.0-624-gb9e1d1b4d
--
-- Subsystems:-- SDL2 was configured with the following options:
--
-- Platform: Darwin-21.6.0
-- 64-bit: TRUE
-- Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-- Revision: SDL-release-2.24.0-624-gb9e1d1b4d
--
-- Subsystems:
-- Atomic: ON
-- Audio: ON
-- Video: ON
-- Render: ON
-- Events: ON
-- Joystick: ON
-- Haptic: ON
-- Hidapi: ON
-- Power: ON
-- Threads: ON
-- Timers: ON
-- File: ON
-- Loadso: ON
-- CPUinfo: ON
-- Filesystem: ON
-- Sensor: ON
-- Locale: ON
-- Misc: ON
--
-- Options:
-- SDL2_DISABLE_INSTALL (Wanted: ON): OFF
-- SDL2_DISABLE_SDL2MAIN (Wanted: OFF): OFF
-- SDL2_DISABLE_UNINSTALL (Wanted: OFF): OFF
-- SDL_3DNOW (Wanted: ON): OFF
-- SDL_ALSA (Wanted: OFF): OFF
-- SDL_ALSA_SHARED (Wanted: OFF): OFF
-- SDL_ALTIVEC (Wanted: ON): OFF
-- SDL_ARMNEON (Wanted: OFF): OFF
-- SDL_ARMSIMD (Wanted: OFF): OFF
-- SDL_ARTS (Wanted: OFF): OFF
-- SDL_ARTS_SHARED (Wanted: OFF): OFF
-- SDL_ASAN (Wanted: OFF): OFF
-- SDL_ASSEMBLY (Wanted: ON): ON
-- SDL_ASSERTIONS (Wanted: auto): auto
-- SDL_BACKGROUNDING_SIGNAL (Wanted: OFF): OFF
-- SDL_CLOCK_GETTIME (Wanted: OFF): OFF
-- SDL_COCOA (Wanted: ON): ON
-- SDL_DBUS (Wanted: OFF): OFF
-- SDL_DIRECTFB (Wanted: OFF): OFF
-- SDL_DIRECTFB_SHARED (Wanted: OFF): OFF
-- SDL_DIRECTX (Wanted: OFF): OFF
-- SDL_DISKAUDIO (Wanted: ON): ON
-- SDL_DUMMYAUDIO (Wanted: ON): ON
-- SDL_DUMMYVIDEO (Wanted: ON): ON
-- SDL_ESD (Wanted: OFF): OFF
-- SDL_ESD_SHARED (Wanted: OFF): OFF
-- SDL_FOREGROUNDING_SIGNAL (Wanted: OFF): OFF
-- SDL_FUSIONSOUND (Wanted: OFF): OFF
-- SDL_FUSIONSOUND_SHARED (Wanted: OFF): OFF
-- SDL_GCC_ATOMICS (Wanted: ON): ON
-- SDL_HIDAPI (Wanted: ON): ON
-- SDL_HIDAPI_JOYSTICK (Wanted: ON): ON
-- SDL_HIDAPI_LIBUSB (Wanted: OFF): OFF
-- SDL_IBUS (Wanted: OFF): OFF
-- SDL_INSTALL_TESTS (Wanted: OFF): OFF
-- SDL_JACK (Wanted: OFF): OFF
-- SDL_JACK_SHARED (Wanted: OFF): OFF
-- SDL_KMSDRM (Wanted: OFF): OFF
-- SDL_KMSDRM_SHARED (Wanted: OFF): OFF
-- SDL_LIBC (Wanted: ON): ON
-- SDL_LIBSAMPLERATE (Wanted: OFF): OFF
-- SDL_LIBSAMPLERATE_SHARED (Wanted: OFF): OFF
-- SDL_METAL (Wanted: ON): ON
-- SDL_MMX (Wanted: ON): OFF
-- SDL_NAS (Wanted: OFF): OFF
-- SDL_NAS_SHARED (Wanted: OFF): OFF
-- SDL_OFFSCREEN (Wanted: ON): ON
-- SDL_OPENGL (Wanted: ON): ON
-- SDL_OPENGLES (Wanted: ON): ON
-- SDL_OSS (Wanted: OFF): OFF
-- SDL_PIPEWIRE (Wanted: OFF): OFF
-- SDL_PIPEWIRE_SHARED (Wanted: OFF): OFF
-- SDL_PTHREADS (Wanted: ON): ON
-- SDL_PTHREADS_SEM (Wanted: ON): ON
-- SDL_PULSEAUDIO (Wanted: OFF): OFF
-- SDL_PULSEAUDIO_SHARED (Wanted: OFF): OFF
-- SDL_RENDER_D3D (Wanted: OFF): OFF
-- SDL_RENDER_METAL (Wanted: ON): ON
-- SDL_RPATH (Wanted: OFF): OFF
-- SDL_RPI (Wanted: OFF): OFF
-- SDL_SNDIO (Wanted: OFF): OFF
-- SDL_SNDIO_SHARED (Wanted: OFF): OFF
-- SDL_SSE (Wanted: ON): OFF
-- SDL_SSE2 (Wanted: ON): OFF
-- SDL_SSE3 (Wanted: ON): OFF
-- SDL_SSEMATH (Wanted: ON): ON
-- SDL_STATIC_PIC (Wanted: OFF): OFF
-- SDL_SYSTEM_ICONV (Wanted: ON): ON
-- SDL_TESTS (Wanted: OFF): OFF
-- SDL_VENDOR_INFO (Wanted: ): OFF
-- SDL_VIRTUAL_JOYSTICK (Wanted: ON): ON
-- SDL_VIVANTE (Wanted: OFF): OFF
-- SDL_VULKAN (Wanted: ON): ON
-- SDL_WASAPI (Wanted: OFF): OFF
-- SDL_WAYLAND (Wanted: OFF): OFF
-- SDL_WAYLAND_LIBDECOR (Wanted: OFF): OFF
-- SDL_WAYLAND_LIBDECOR_SHARED (Wanted: OFF): OFF
-- SDL_WAYLAND_QT_TOUCH (Wanted: OFF): OFF
-- SDL_WAYLAND_SHARED (Wanted: OFF): OFF
-- SDL_X11 (Wanted: OFF): OFF
-- SDL_X11_SHARED (Wanted: OFF): OFF
-- SDL_X11_XCURSOR (Wanted: OFF): OFF
-- SDL_X11_XDBE (Wanted: OFF): OFF
-- SDL_X11_XFIXES (Wanted: OFF): OFF
-- SDL_X11_XINPUT (Wanted: OFF): OFF
-- SDL_X11_XRANDR (Wanted: OFF): OFF
-- SDL_X11_XSCRNSAVER (Wanted: OFF): OFF
-- SDL_X11_XSHAPE (Wanted: OFF): OFF
-- SDL_XINPUT (Wanted: OFF): OFF
--
-- CFLAGS: -idirafter "/Users/pascal/dvp/OpenSource/ImGuiWork/sdl_glfw_cmake_issue/SDL/src/video/khronos"
-- EXTRA_CFLAGS: -Wall -fno-strict-aliasing -Wdeclaration-after-statement -fvisibility=hidden -Wshadow -D_THREAD_SAFE
-- EXTRA_LDFLAGS: -Wl,-framework,CoreVideo;-Wl,-framework,Cocoa;-Wl,-framework,IOKit;-Wl,-framework,ForceFeedback;-Wl,-framework,Carbon;-Wl,-framework,CoreAudio;-Wl,-framework,AudioToolbox;-Wl,-framework,AVFoundation;-Wl,-framework,Foundation;-Wl,-weak_framework,GameController;-Wl,-weak_framework,Metal;-Wl,-weak_framework,QuartzCore;-Wl,-weak_framework,CoreHaptics -Wl,-compatibility_version,2501.0.0;-Wl,-current_version,2501.0.0
-- EXTRA_LIBS: m;iconv
--
-- Build Shared Library: OFF
-- Build Static Library: ON
-- Build Static Library with Position Independent Code: OFF
--
-- If something was not detected, although the libraries
-- were installed, then make sure you have set the
-- CFLAGS and LDFLAGS environment variables correctly.
--
-- Configuring done
-- Atomic: ON
-- Audio: ON
-- Video: ON
-- Render: ON
-- Events: ON
-- Joystick: ON
-- Haptic: ON
-- Hidapi: ON
-- Power: ON
-- Threads: ON
-- Timers: ON
-- File: ON
-- Loadso: ON
-- CPUinfo: ON
-- Filesystem: ON
-- Sensor: ON
-- Locale: ON
-- Misc: ON
--
-- Options:
-- SDL2_DISABLE_INSTALL (Wanted: ON): OFF
-- SDL2_DISABLE_SDL2MAIN (Wanted: OFF): OFF
-- SDL2_DISABLE_UNINSTALL (Wanted: OFF): OFF
-- SDL_3DNOW (Wanted: ON): OFF
-- SDL_ALSA (Wanted: OFF): OFF
-- SDL_ALSA_SHARED (Wanted: OFF): OFF
-- SDL_ALTIVEC (Wanted: ON): OFF
-- SDL_ARMNEON (Wanted: OFF): OFF
-- SDL_ARMSIMD (Wanted: OFF): OFF
-- SDL_ARTS (Wanted: OFF): OFF
-- SDL_ARTS_SHARED (Wanted: OFF): OFF
-- SDL_ASAN (Wanted: OFF): OFF
-- SDL_ASSEMBLY (Wanted: ON): ON
-- SDL_ASSERTIONS (Wanted: auto): auto
-- SDL_BACKGROUNDING_SIGNAL (Wanted: OFF): OFF
-- SDL_CLOCK_GETTIME (Wanted: OFF): OFF
-- SDL_COCOA (Wanted: ON): ON
-- SDL_DBUS (Wanted: OFF): OFF
-- SDL_DIRECTFB (Wanted: OFF): OFF
-- SDL_DIRECTFB_SHARED (Wanted: OFF): OFF
-- SDL_DIRECTX (Wanted: OFF): OFF
-- SDL_DISKAUDIO (Wanted: ON): ON
-- SDL_DUMMYAUDIO (Wanted: ON): ON
-- SDL_DUMMYVIDEO (Wanted: ON): ON
-- SDL_ESD (Wanted: OFF): OFF
-- SDL_ESD_SHARED (Wanted: OFF): OFF
-- SDL_FOREGROUNDING_SIGNAL (Wanted: OFF): OFF
-- SDL_FUSIONSOUND (Wanted: OFF): OFF
-- SDL_FUSIONSOUND_SHARED (Wanted: OFF): OFF
-- SDL_GCC_ATOMICS (Wanted: ON): ON
-- SDL_HIDAPI (Wanted: ON): ON
-- SDL_HIDAPI_JOYSTICK (Wanted: ON): ON
-- SDL_HIDAPI_LIBUSB (Wanted: OFF): OFF
-- SDL_IBUS (Wanted: OFF): OFF
-- SDL_INSTALL_TESTS (Wanted: OFF): OFF
-- SDL_JACK (Wanted: OFF): OFF
-- SDL_JACK_SHARED (Wanted: OFF): OFF
-- SDL_KMSDRM (Wanted: OFF): OFF
-- SDL_KMSDRM_SHARED (Wanted: OFF): OFF
-- SDL_LIBC (Wanted: ON): ON
-- SDL_LIBSAMPLERATE (Wanted: OFF): OFF
-- SDL_LIBSAMPLERATE_SHARED (Wanted: OFF): OFF
-- SDL_METAL (Wanted: ON): ON
-- SDL_MMX (Wanted: ON): OFF
-- SDL_NAS (Wanted: OFF): OFF
-- SDL_NAS_SHARED (Wanted: OFF): OFF
-- SDL_OFFSCREEN (Wanted: ON): ON
-- SDL_OPENGL (Wanted: ON): ON
-- SDL_OPENGLES (Wanted: ON): ON
-- SDL_OSS (Wanted: OFF): OFF
-- SDL_PIPEWIRE (Wanted: OFF): OFF
-- SDL_PIPEWIRE_SHARED (Wanted: OFF): OFF
-- SDL_PTHREADS (Wanted: ON): ON
-- SDL_PTHREADS_SEM (Wanted: ON): ON
-- SDL_PULSEAUDIO (Wanted: OFF): OFF
-- SDL_PULSEAUDIO_SHARED (Wanted: OFF): OFF
-- SDL_RENDER_D3D (Wanted: OFF): OFF
-- SDL_RENDER_METAL (Wanted: ON): ON
-- SDL_RPATH (Wanted: OFF): OFF
-- SDL_RPI (Wanted: OFF): OFF
-- SDL_SNDIO (Wanted: OFF): OFF
-- SDL_SNDIO_SHARED (Wanted: OFF): OFF
-- SDL_SSE (Wanted: ON): OFF
-- SDL_SSE2 (Wanted: ON): OFF
-- SDL_SSE3 (Wanted: ON): OFF
-- SDL_SSEMATH (Wanted: ON): ON
-- SDL_STATIC_PIC (Wanted: OFF): OFF
-- SDL_SYSTEM_ICONV (Wanted: ON): ON
-- SDL_TESTS (Wanted: OFF): OFF
-- SDL_VENDOR_INFO (Wanted: ): OFF
-- SDL_VIRTUAL_JOYSTICK (Wanted: ON): ON
-- SDL_VIVANTE (Wanted: OFF): OFF
-- SDL_VULKAN (Wanted: ON): ON
-- SDL_WASAPI (Wanted: OFF): OFF
-- SDL_WAYLAND (Wanted: OFF): OFF
-- SDL_WAYLAND_LIBDECOR (Wanted: OFF): OFF
-- SDL_WAYLAND_LIBDECOR_SHARED (Wanted: OFF): OFF
-- SDL_WAYLAND_QT_TOUCH (Wanted: OFF): OFF
-- SDL_WAYLAND_SHARED (Wanted: OFF): OFF
-- SDL_X11 (Wanted: OFF): OFF
-- SDL_X11_SHARED (Wanted: OFF): OFF
-- SDL_X11_XCURSOR (Wanted: OFF): OFF
-- SDL_X11_XDBE (Wanted: OFF): OFF
-- SDL_X11_XFIXES (Wanted: OFF): OFF
-- SDL_X11_XINPUT (Wanted: OFF): OFF
-- SDL_X11_XRANDR (Wanted: OFF): OFF
-- SDL_X11_XSCRNSAVER (Wanted: OFF): OFF
-- SDL_X11_XSHAPE (Wanted: OFF): OFF
-- SDL_XINPUT (Wanted: OFF): OFF
--
-- CFLAGS: -idirafter "/Users/pascal/dvp/OpenSource/ImGuiWork/sdl_glfw_cmake_issue/SDL/src/video/khronos"
-- EXTRA_CFLAGS: -Wall -fno-strict-aliasing -Wdeclaration-after-statement -fvisibility=hidden -Wshadow -D_THREAD_SAFE
-- EXTRA_LDFLAGS: -Wl,-framework,CoreVideo;-Wl,-framework,Cocoa;-Wl,-framework,IOKit;-Wl,-framework,ForceFeedback;-Wl,-framework,Carbon;-Wl,-framework,CoreAudio;-Wl,-framework,AudioToolbox;-Wl,-framework,AVFoundation;-Wl,-framework,Foundation;-Wl,-weak_framework,GameController;-Wl,-weak_framework,Metal;-Wl,-weak_framework,QuartzCore;-Wl,-weak_framework,CoreHaptics -Wl,-compatibility_version,2501.0.0;-Wl,-current_version,2501.0.0
-- EXTRA_LIBS: m;iconv
--
-- Build Shared Library: OFF
-- Build Static Library: ON
-- Build Static Library with Position Independent Code: OFF
--
-- If something was not detected, although the libraries
-- were installed, then make sure you have set the
-- CFLAGS and LDFLAGS environment variables correctly.
--
-- Configuring done
Many thanks!
Can you also try the following? Use the current master SDL unmodified, and modify your root CMake project such that it loooks as follows:
cmake_minimum_required(VERSION 3.11)
project(sdl_glfw_cmake_issue)
if(APPLE)
enable_language(OBJC)
endif()
add_subdirectory(glfw)
add_subdirectory(SDL)
Your suggestion works perfectly with Ninja, XCode and make generators!
What CMake version do you use?
cmake version 3.24.2 the latest avaible via homebrew
Oh damn. I was asking because we might bump the minimum required version to 3.16 for SDL3. Oh well, as long as we don't use any fancy objective-c features that requires special runtime, I guess we're fine.
While I got your attention.
Can you build SDL2 as a shared/static library using the Xcode generator?
https://github.com/libsdl-org/SDL/pull/6198 tries to add an explicit -x objective-c
compile argument.
FYI:
I tried building SDL2 static and shared and I did not reproduce the issue described in https://github.com/libsdl-org/SDL/pull/6198. I could compile without any issue.
May be it is because I only build SDL, and I did not link any app to it?
Anyway, here is what I obtained.
Note: I was working with an unmodified SDL repo, and not using your suggestion to call enable_language(OBJC)
(it works, since I was building only SDL, and not glfw).
cmake_minimum_required(VERSION 3.11)
project(sdl_glfw_cmake_issue)
set(BUILD_SHARED_LIBS ON)
add_subdirectory(SDL)
> cmake .. -GXcode
> cmake --build . --config Release
> ls SDL/Release
libSDL2-2.0.0.dylib libSDL2-2.0.dylib libSDL2_test.a libSDL2main.a
cmake_minimum_required(VERSION 3.11)
project(sdl_glfw_cmake_issue)
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(SDL)
> cmake .. -GXcode
> cmake --build . --config Release
> ls SDL/Release
libSDL2.a libSDL2_test.a libSDL2main.a
When building also glfw (and using an early call to enable_language(OBJC)
), I get the same result, without any compilation error.
May be it is because I only build SDL, and I did not link any app to it?
Probably not. The problem was with compiling SDL's sources, not when compiling/linking an app.
I think we need to be careful with removing enable_language(OBJC)
.
I propose to do the following:
CheckLanguage
to check for the availability of OBJCenable_language(OBJC)
..m
files are compiled as objective c.I've done this in https://github.com/libsdl-org/SDL/pull/6455
Can you please re-run your tests? You can use my fork as submodule for re-running the github workflows: https://github.com/madebr/SDL/tree/apple-objc-troubles
Your PR works on my side
@pthom
For creating a reproducer for reporting upstream, does the little project below build/fail? Can you modify it so it fails? Can you reduce it even further? (I don't have any experience with Objective-C)
CMakeLists.txt
cmake_minimum_required(VERSION 3.15)
project(main_project)
add_subdirectory(subproject)
file(WRITE main.c [[
extern int sublibrary_function(void);
int main() {
sublibrary_function();
return 0;
}
]])
add_executable(main main.c)
target_link_libraries(main PRIVATE sublibrary)
subproject/CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(subproject)
enable_language(OBJC)
file(WRITE source.m [[
#import <Foundation/Foundation.h>
int sublibrary_function() {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSLog (@"hello world");
[pool drain];
return 0;
}
]])
add_library(sublibrary source.m)
target_link_libraries(sublibrary PRIVATE -Wl,-framework,Foundation)
This is a bug in CMake: minimal reproduction code here:
Do you want to report this to CMake, or do you prefer me to do it?
I'd prefer you do it. You are the one hit by this, and have Apple hardware readily available.
I guess you should do it, since it will probably be linked to the issue you posted here:
https://gitlab.kitware.com/cmake/cmake/-/issues/23944
(but this will add a minimum repro, so it should make the fix easier)
ok, I will do it
Issue posted at https://gitlab.kitware.com/cmake/cmake/-/issues/24104
Thanks for making the effort!
That issue I created is similar, but different.
"My issue" is about missing -x objective-c
compile arguments.
I don't have a reproducer, and the dude reporting this error is not responding to his pr.
Yours is about an error being emitted.
Hi,
I encountered a strange issue when trying to compile SDL and glfw via cmake in the same project under MacOS. I get this error message:
I do not known whether this is a bug in SDL, glfw or CMake in itself.
In order to make the repro as easy as possible, I created a small repo that reproduces the issue: https://github.com/pthom/sdl_glfw_cmake_issue (this repository provides a github action that will build on MacOS and show the issue)
It was created like this:
.gitmodules
CMakeLists.txt
And the error message can be seen on github CI at: https://github.com/pthom/sdl_glfw_cmake_issue/actions/runs/3348887402
Workaround: inside SDL/cmake/macros.cmake, replace
by this (i.e. ignore the code that deals with CMake >= 3.16)