FindMYSQL.cmake 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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")
  27. ENDIF()
  28. IF (NOT "${EXTERNALS_DIRECTORY}" STREQUAL "")
  29. IF (UNIX)
  30. IF (${ARCH64BIT} EQUAL 1)
  31. SET (osdir "linux64_gcc4.1.1")
  32. ELSE()
  33. SET (osdir "linux32_gcc4.1.1")
  34. ENDIF()
  35. ELSEIF(WIN32)
  36. SET (osdir "lib")
  37. ELSE()
  38. SET (osdir "unknown")
  39. ENDIF()
  40. IF (NOT ("${osdir}" STREQUAL "unknown"))
  41. FIND_PATH (MYSQL_INCLUDE_DIR NAMES mysql.h PATHS "${EXTERNALS_DIRECTORY}/mysql/include" NO_DEFAULT_PATH)
  42. FIND_LIBRARY (MYSQL_LIBRARIES NAMES ${mysql_lib} PATHS "${EXTERNALS_DIRECTORY}/mysql/${osdir}" NO_DEFAULT_PATH)
  43. ENDIF()
  44. ENDIF()
  45. if (USE_NATIVE_LIBRARIES)
  46. # if we didn't find in externals, look in system include path
  47. FIND_PATH (MYSQL_INCLUDE_DIR NAMES mysql.h PATH_SUFFIXES mysql)
  48. FIND_LIBRARY (MYSQL_LIBRARIES NAMES ${mysql_lib} PATH_SUFFIXES mysql)
  49. endif()
  50. include(FindPackageHandleStandardArgs)
  51. find_package_handle_standard_args(MYSQL DEFAULT_MSG
  52. MYSQL_LIBRARIES
  53. MYSQL_INCLUDE_DIR
  54. )
  55. MARK_AS_ADVANCED(MYSQL_INCLUDE_DIR MYSQL_LIBRARIES)
  56. ENDIF()