FindMYSQL.cmake 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. ################################################################################
  2. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ################################################################################
  16. # - Try to find the MYSQL library
  17. # Once done this will define
  18. #
  19. # MYSQL_FOUND - system has the MYSQL library
  20. # MYSQL_INCLUDE_DIR - the MYSQL include directory
  21. # MYSQL_LIBRARIES - The libraries needed to use MYSQL
  22. IF (NOT MYSQL_FOUND)
  23. IF (WIN32)
  24. SET (mysql_lib "libmysql")
  25. ELSE()
  26. SET (mysql_lib "mysqlclient_r") # Use the re-entrant version if it exists
  27. SET (mysql_lib_alt "mysqlclient") # (but newer versions do not make the distinction and supply just the one)
  28. ENDIF()
  29. IF (NOT "${EXTERNALS_DIRECTORY}" STREQUAL "")
  30. IF (UNIX)
  31. IF (${ARCH64BIT} EQUAL 1)
  32. SET (osdir "linux64_gcc4.1.1")
  33. ELSE()
  34. SET (osdir "linux32_gcc4.1.1")
  35. ENDIF()
  36. ELSEIF(WIN32)
  37. IF (${ARCH64BIT} EQUAL 1)
  38. SET (osdir "win64")
  39. ELSE()
  40. SET (osdir "win32")
  41. ENDIF()
  42. ELSE()
  43. SET (osdir "unknown")
  44. ENDIF()
  45. IF (NOT ("${osdir}" STREQUAL "unknown"))
  46. FIND_PATH (MYSQL_INCLUDE_DIR NAMES mysql.h PATHS "${EXTERNALS_DIRECTORY}/mysql/${osdir}/include"
  47. "${EXTERNALS_DIRECTORY}/mysql/include" NO_DEFAULT_PATH)
  48. FIND_LIBRARY (MYSQL_LIBRARIES NAMES ${mysql_lib} PATHS "${EXTERNALS_DIRECTORY}/mysql/${osdir}/lib"
  49. "${EXTERNALS_DIRECTORY}/mysql/${osdir}" "${EXTERNALS_DIRECTORY}/mysql/lib" NO_DEFAULT_PATH)
  50. FIND_LIBRARY (MYSQL_LIBRARIES NAMES ${mysql_lib_alt} PATHS "${EXTERNALS_DIRECTORY}/mysql/${osdir}/lib"
  51. "${EXTERNALS_DIRECTORY}/mysql/${osdir}" "${EXTERNALS_DIRECTORY}/mysql/lib" NO_DEFAULT_PATH)
  52. ENDIF()
  53. ENDIF()
  54. if (USE_NATIVE_LIBRARIES)
  55. # if we didn't find in externals, look in system include path
  56. FIND_PATH (MYSQL_INCLUDE_DIR NAMES mysql.h PATH_SUFFIXES mysql)
  57. FIND_LIBRARY (MYSQL_LIBRARIES NAMES ${mysql_lib} PATH_SUFFIXES mysql)
  58. FIND_LIBRARY (MYSQL_LIBRARIES NAMES ${mysql_lib_alt} PATH_SUFFIXES mysql)
  59. endif()
  60. include(FindPackageHandleStandardArgs)
  61. find_package_handle_standard_args(MYSQL DEFAULT_MSG
  62. MYSQL_LIBRARIES
  63. MYSQL_INCLUDE_DIR
  64. )
  65. MARK_AS_ADVANCED(MYSQL_INCLUDE_DIR MYSQL_LIBRARIES)
  66. ENDIF()