$OpenBSD: patch-cmake_FindSpeechd_cmake,v 1.5 2014/07/09 20:03:24 zhuk Exp $
Allow to find speechd both when it require "speech-dispatcher/" prefix in
include lines, and when it doesn't. Also, switch to CMake convention for
naming configuration variables.

NB: keep synced with the same patch in kaccessible.
--- cmake/FindSpeechd.cmake.orig	Thu Jan  2 23:33:57 2014
+++ cmake/FindSpeechd.cmake	Tue Mar  4 12:31:05 2014
@@ -1,17 +1,40 @@
 # find speech-dispatcher library and header if available
 # Copyright (c) 2009, Jeremy Whiting <jeremy@scitools.com>
 # Copyright (c) 2011, Raphael Kubo da Costa <kubito@gmail.com>
-# This module defines
-#  SPEECHD_INCLUDE_DIR, where to find libspeechd.h
-#  SPEECHD_LIBRARIES, the libraries needed to link against speechd
-#  SPEECHD_FOUND, If false, speechd was not found
 #
+# This module defines:
+#  SPEECHD_INCLUDE_DIRS	     Directories with speechd header files.
+#  SPEECHD_LIBRARIES         The libraries needed to link against speechd.
+#  SPEECHD_FOUND             If false, speechd was not found.
+#  SPEECHD_USES_INC_PREFIX   True if speechd wants <speechd-dispatcher/foo.h>
+#                            scheme, and false if plain <foo.h> should be used.
+#
 # Redistribution and use is allowed according to the terms of the BSD license.
 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
 
-find_path(SPEECHD_INCLUDE_DIR libspeechd.h PATH_SUFFIXES speech-dispatcher)
+# Some versions of speech-dispatcher force <speech-dispatcher/foo.h> scheme,
+# and some force <foo.h> scheme. This hack allows us to support both.
 
-find_library(SPEECHD_LIBRARIES NAMES speechd)
+include(CheckIncludeFiles)
+include(CMakePushCheckState)
 
+find_path(SPEECHD_INCLUDE_DIR speech-dispatcher/libspeechd.h)
+if(SPEECHD_INCLUDE_DIR)
+  cmake_push_check_state()
+  set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${SPEECHD_INCLUDE_DIR})
+  check_include_files("speech-dispatcher/libspeechd.h" SPEECHD_USES_INC_PREFIX)
+  if(SPEECHD_USES_INC_PREFIX)
+    add_definitions(-DSPEECHD_USES_INC_PREFIX)
+  else(SPEECHD_USES_INC_PREFIX)
+    set(SPEECHD_INCLUDE_DIR "${SPEECHD_INCLUDE_DIR}/speech-dispatcher")
+  endif(SPEECHD_USES_INC_PREFIX)
+  cmake_pop_check_state()
+endif(SPEECHD_INCLUDE_DIR)
+
+find_library(SPEECHD_LIBRARY NAMES speechd)
+
+set(SPEECHD_INCLUDE_DIRS ${SPEECHD_INCLUDE_DIR})
+set(SPEECHD_LIBRARIES ${SPEECHD_LIBRARY})
+
 include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(Speechd REQUIRED_VARS SPEECHD_INCLUDE_DIR SPEECHD_LIBRARIES)
+find_package_handle_standard_args(Speechd REQUIRED_VARS SPEECHD_INCLUDE_DIRS SPEECHD_LIBRARIES)
