SDL
SDL copied to clipboard
How to disable subsystems in CMake?
How do you disable subsystems in the new CMake build system?
I tried to disable MFI joystick support using the following, and it didn't work:
cmake .. -DSDL_JOYSTICK_MFI=OFF -DCMAKE_BUILD_TYPE=Debug
Current cmake only allows you to enable/disable the main SDL subsystems and some extra options.
I even didn't know mfi being an Apple thing until now.
I think you can disable it by configuring with -DSDL_JOYSTICK=OFF -DSDL_HAPTIC=OFF
.
If you want more fine-grained control/options somewhere, please ask.
We basically want to be able to disable any of the driver related SDL_* defines in SDL_build_config.h.cmake. In this case I was trying to build without MFI support because there's an Apple bug I wanted to workaround for testing. I was able to manually clear it, but I was under the impression that any of the SDL defines could be overridden on the cmake command line.
-DSDL_JOYSTICK_ENABLED_BY_DEFAULT=OFF -DSDL_HAPTIC_ENABLED_BY_DEFAULT=OFF
It does work perfectly fine on MacOS. I had some issues with ARM64 build so I had to disable those.
Edit:
Ohh, I see that you did change it from 2.28.5 which is the way it is as I described above. The part of the CMakeLists.txt
changed from:
set(SDL_SUBSYSTEMS
Atomic Audio Video Render Events Joystick Haptic Hidapi Power Threads Timers
File Loadso CPUinfo Filesystem Sensor Locale Misc)
foreach(_SUB ${SDL_SUBSYSTEMS})
string(TOUPPER ${_SUB} _OPT)
if (NOT DEFINED SDL_${_OPT}_ENABLED_BY_DEFAULT)
set(SDL_${_OPT}_ENABLED_BY_DEFAULT ON)
endif()
option(SDL_${_OPT} "Enable the ${_SUB} subsystem" ${SDL_${_OPT}_ENABLED_BY_DEFAULT})
endforeach()
to:
set(SDL_SUBSYSTEMS
Atomic
Audio
Video
Render
Events
Joystick
Haptic
Hidapi
Power
Threads
Timers
File
Loadso
CPUinfo
Filesystem
Sensor
Locale
Misc
)
foreach(_SUB IN LISTS SDL_SUBSYSTEMS)
string(TOUPPER ${_SUB} _OPT)
if(NOT DEFINED SDL_${_OPT}_DEFAULT)
set(SDL_${_OPT}_DEFAULT ON)
endif()
option(SDL_${_OPT} "Enable the ${_SUB} subsystem" ${SDL_${_OPT}_DEFAULT})
endforeach()
So now that would be:
-DSDL_JOYSTICK_DEFAULT=OFF -DSDL_HAPTIC_DEFAULT=OFF