FindMYSQL.cmake 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. ################################################################################
  2. # Copyright (C) 2011 HPCC Systems.
  3. #
  4. # All rights reserved. This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU Affero General Public License as
  6. # published by the Free Software Foundation, either version 3 of the
  7. # License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU Affero General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. ################################################################################
  17. # - Try to find the MYSQL library
  18. # Once done this will define
  19. #
  20. # MYSQL_FOUND - system has the MYSQL library
  21. # MYSQL_INCLUDE_DIR - the MYSQL include directory
  22. # MYSQL_LIBRARIES - The libraries needed to use MYSQL
  23. IF (NOT MYSQL_FOUND)
  24. IF (WIN32)
  25. SET (mysql_lib "libmysql")
  26. ELSE()
  27. SET (mysql_lib "mysqlclient")
  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. SET (osdir "lib")
  38. ELSE()
  39. SET (osdir "unknown")
  40. ENDIF()
  41. IF (NOT ("${osdir}" STREQUAL "unknown"))
  42. FIND_PATH (MYSQL_INCLUDE_DIR NAMES mysql.h PATHS "${EXTERNALS_DIRECTORY}/mysql/include" NO_DEFAULT_PATH)
  43. FIND_LIBRARY (MYSQL_LIBRARIES NAMES ${mysql_lib} PATHS "${EXTERNALS_DIRECTORY}/mysql/${osdir}" NO_DEFAULT_PATH)
  44. ENDIF()
  45. ENDIF()
  46. if (USE_NATIVE_LIBRARIES)
  47. # if we didn't find in externals, look in system include path
  48. FIND_PATH (MYSQL_INCLUDE_DIR NAMES mysql.h PATH_SUFFIXES mysql)
  49. FIND_LIBRARY (MYSQL_LIBRARIES NAMES ${mysql_lib} PATH_SUFFIXES mysql)
  50. endif()
  51. include(FindPackageHandleStandardArgs)
  52. find_package_handle_standard_args(MYSQL DEFAULT_MSG
  53. MYSQL_LIBRARIES
  54. MYSQL_INCLUDE_DIR
  55. )
  56. MARK_AS_ADVANCED(MYSQL_INCLUDE_DIR MYSQL_LIBRARIES)
  57. ENDIF()