Fix check_c_source_compiles with pthread.

Also fix the variables: we need to check for PTHREAD_PRIO_INHERIT
and PTHREAD_CREATE_JOINABLE (not PTHREAD_CREATE_UNDETACHED) and
internally use HAVE_PTHREAD_PRIO_INHERIT and PTHREAD_CREATE_JOINABLE
(and not HAVE_PTHREAD_CREATE_JOINABLE).
cmake/config.h.in actually had the right variables.

BUG=webp:498

Change-Id: Ibf6cf854337cea5781a74316024f8ff4960366d7
(cherry picked from commit ceddb5fc8d077fb1d5d4536012c33172645c69cf)
diff --git a/cmake/config.h.in b/cmake/config.h.in
index 547aa4c..3770935 100644
--- a/cmake/config.h.in
+++ b/cmake/config.h.in
@@ -93,10 +93,6 @@
 /* Define to the version of this package. */
 #cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@"
 
-/* Define to necessary symbol if this constant uses a non-standard name on
-   your system. */
-#cmakedefine PTHREAD_CREATE_JOINABLE 1
-
 /* Define to 1 if you have the ANSI C header files. */
 #cmakedefine STDC_HEADERS 1
 
diff --git a/cmake/deps.cmake b/cmake/deps.cmake
index 0ea836d..fb55f04 100644
--- a/cmake/deps.cmake
+++ b/cmake/deps.cmake
@@ -27,18 +27,18 @@
   find_package(Threads)
 endif()
 if(Threads_FOUND)
-  if(CMAKE_USE_PTHREADS_INIT)
+  # work around cmake bug on QNX (https://cmake.org/Bug/view.php?id=11333)
+  if(CMAKE_USE_PTHREADS_INIT AND NOT CMAKE_SYSTEM_NAME STREQUAL "QNX")
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
   endif()
-  foreach(PTHREAD_TEST HAVE_PTHREAD_PRIO_INHERIT PTHREAD_CREATE_UNDETACHED)
-    check_c_source_compiles("
-        #include <pthread.h>
-        int main (void) {
-          int attr = ${PTHREAD_TEST};
-          return attr;
-        }
-      " ${PTHREAD_TEST})
-  endforeach()
+  check_c_source_compiles("
+      #include <pthread.h>
+      int main (void) {
+        int attr = PTHREAD_PRIO_INHERIT;
+        return attr;
+      }
+    " FLAG_HAVE_PTHREAD_PRIO_INHERIT)
+  set(HAVE_PTHREAD_PRIO_INHERIT ${FLAG_HAVE_PTHREAD_PRIO_INHERIT})
   list(APPEND WEBP_DEP_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
 endif()
 set(WEBP_USE_THREAD ${Threads_FOUND})