From 933ec9e978aef2988270f1f996033c0d0bae5d85 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Fri, 29 Sep 2023 18:53:47 +0200 Subject: [PATCH] cmake: add qnx support Co-authored-by: elahav --- CMakeLists.txt | 20 ++++++++++++++++++-- cmake/sdlchecks.cmake | 18 ++++++++++++++++++ cmake/sdlplatform.cmake | 2 ++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fa10d64b..511f97130 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -227,11 +227,13 @@ elseif(MSVC_VERSION GREATER 1400) # VisualStudio 8.0+ elseif(CMAKE_C_COMPILER_ID MATCHES "^Intel$") set(OPT_DEF_ASM TRUE) set(USE_INTELCC TRUE) +elseif(CMAKE_C_COMPILER_ID MATCHES "QCC") + set(USE_QCC TRUE) else() set(OPT_DEF_ASM FALSE) endif() -if(USE_GCC OR USE_CLANG OR USE_INTELCC) +if(USE_GCC OR USE_CLANG OR USE_INTELCC OR USE_QCC) set(OPT_DEF_GCC_ATOMICS ON) endif() @@ -569,7 +571,7 @@ if(NOT SDL_FOREGROUNDING_SIGNAL STREQUAL "OFF") endif() # Compiler option evaluation -if(USE_GCC OR USE_CLANG OR USE_INTELCC) +if(USE_GCC OR USE_CLANG OR USE_INTELCC OR USE_QCC) # Check for -Wall first, so later things can override pieces of it. # Note: clang-cl treats -Wall as -Weverything (which is very loud), # /W3 as -Wall, and /W4 as -Wall -Wextra. So: /W3 is enough. @@ -1456,6 +1458,12 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU) file(GLOB AIX_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/paudio/*.c) list(APPEND SOURCE_FILES ${AIX_AUDIO_SOURCES}) set(HAVE_SDL_AUDIO TRUE) + elseif(QNX) + set(SDL_AUDIO_DRIVER_QSA 1) + file(GLOB QSA_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/qsa/*.c) + list(APPEND SOURCE_FILES ${QSA_AUDIO_SOURCES}) + list(APPEND EXTRA_LIBS asound) + set(HAVE_SDL_AUDIO TRUE) endif() CheckOSS() CheckALSA() @@ -1487,6 +1495,7 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU) set(SDL_VIDEO_VULKAN 1) set(HAVE_VULKAN TRUE) endif() + CheckQNXScreen() endif() if(UNIX) @@ -1730,6 +1739,13 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU) set(HAVE_RPATH TRUE) endif() + if(QNX) + # QNX's *printf() family generates a SIGSEGV if NULL is passed for a string + # specifier (on purpose), but SDL expects "(null)". Use the built-in + # implementation. + set(HAVE_VSNPRINTF 0) + set(USE_POSIX_SPAWN 1) + endif() elseif(WINDOWS) find_program(WINDRES windres) diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake index 35dd043ef..fc5b096b2 100644 --- a/cmake/sdlchecks.cmake +++ b/cmake/sdlchecks.cmake @@ -911,6 +911,22 @@ macro(CheckOpenGLES) endif() endmacro() +# Requires: +# - EGL +macro(CheckQNXScreen) + if(QNX AND HAVE_OPENGL_EGL) + check_c_source_compiles(" + #include + int main (int argc, char** argv) { return 0; }" HAVE_QNX_SCREEN) + if(HAVE_QNX_SCREEN) + set(SDL_VIDEO_DRIVER_QNX 1) + file(GLOB QNX_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/qnx/*.c) + list(APPEND SOURCE_FILES ${QNX_VIDEO_SOURCES}) + list(APPEND EXTRA_LIBS screen EGL) + endif() + endif() +endmacro() + # Requires: # - nada # Optional: @@ -961,6 +977,8 @@ macro(CheckPTHREAD) elseif(EMSCRIPTEN) set(PTHREAD_CFLAGS "-D_REENTRANT -pthread") set(PTHREAD_LDFLAGS "-pthread") + elseif(QNX) + # pthread support is baked in else() set(PTHREAD_CFLAGS "-D_REENTRANT") set(PTHREAD_LDFLAGS "-lpthread") diff --git a/cmake/sdlplatform.cmake b/cmake/sdlplatform.cmake index 7daaa2352..6d8ece6ac 100644 --- a/cmake/sdlplatform.cmake +++ b/cmake/sdlplatform.cmake @@ -28,6 +28,8 @@ macro(SDL_DetectCMakePlatform) set(SDL_CMAKE_PLATFORM AIX) elseif(CMAKE_SYSTEM_NAME MATCHES "Minix.*") set(SDL_CMAKE_PLATFORM MINIX) + elseif(CMAKE_SYSTEM_NAME MATCHES "QNX") + set(SDL_CMAKE_PLATFORM QNX) endif() elseif(APPLE) if(CMAKE_SYSTEM_NAME MATCHES ".*Darwin.*")