cmake: add qnx support Co-authored-by: elahav <elahav@users.noreply.github.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3059736..230624c 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.
@@ -1428,6 +1430,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()
@@ -1459,6 +1467,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)
@@ -1709,6 +1718,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 c4aec17..f1beef3 100644
--- a/cmake/sdlchecks.cmake
+++ b/cmake/sdlchecks.cmake
@@ -906,6 +906,22 @@ macro(CheckOpenGLES)
endmacro()
# Requires:
+# - EGL
+macro(CheckQNXScreen)
+ if(QNX AND HAVE_OPENGL_EGL)
+ check_c_source_compiles("
+ #include <screen/screen.h>
+ 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:
# - THREADS opt
@@ -955,6 +971,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 7daaa23..6d8ece6 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.*")