25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

129 satır
4.2KB

  1. # - Try to find MySQL / MySQL Embedded library
  2. # Find the MySQL includes and client library
  3. # This module defines
  4. # MYSQL_INCLUDE_DIR, where to find mysql.h
  5. # MYSQL_LIBRARIES, the libraries needed to use MySQL.
  6. # MYSQL_LIB_DIR, path to the MYSQL_LIBRARIES
  7. # MYSQL_EMBEDDED_LIBRARIES, the libraries needed to use MySQL Embedded.
  8. # MYSQL_EMBEDDED_LIB_DIR, path to the MYSQL_EMBEDDED_LIBRARIES
  9. # MYSQL_FOUND, If false, do not try to use MySQL.
  10. # MYSQL_EMBEDDED_FOUND, If false, do not try to use MySQL Embedded.
  11. # Copyright (c) 2006-2008, Jarosław Staniek <staniek@kde.org>
  12. #
  13. # Redistribution and use is allowed according to the terms of the BSD license.
  14. # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
  15. include(CheckCXXSourceCompiles)
  16. if(WIN32)
  17. find_path(MYSQL_INCLUDE_DIR mysql.h
  18. PATHS
  19. $ENV{MYSQL_INCLUDE_DIR}
  20. $ENV{MYSQL_DIR}/include
  21. $ENV{ProgramFiles}/MySQL/*/include
  22. $ENV{SystemDrive}/MySQL/*/include
  23. $ENV{ProgramW6432}/MySQL/*/include
  24. )
  25. else(WIN32)
  26. find_path(MYSQL_INCLUDE_DIR mysql/mysql.h
  27. PATHS
  28. $ENV{MYSQL_INCLUDE_DIR}
  29. $ENV{MYSQL_DIR}/include
  30. /usr/local/mysql/include
  31. /opt/mysql/mysql/include
  32. PATH_SUFFIXES
  33. mysql
  34. )
  35. endif(WIN32)
  36. if(WIN32)
  37. if (${CMAKE_BUILD_TYPE})
  38. string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER)
  39. endif()
  40. # path suffix for debug/release mode
  41. # binary_dist: mysql binary distribution
  42. # build_dist: custom build
  43. if(CMAKE_BUILD_TYPE_TOLOWER MATCHES "debug")
  44. set(binary_dist debug)
  45. set(build_dist Debug)
  46. else(CMAKE_BUILD_TYPE_TOLOWER MATCHES "debug")
  47. ADD_DEFINITIONS(-DDBUG_OFF)
  48. set(binary_dist opt)
  49. set(build_dist Release)
  50. endif(CMAKE_BUILD_TYPE_TOLOWER MATCHES "debug")
  51. # find_library(MYSQL_LIBRARIES NAMES mysqlclient
  52. set(MYSQL_LIB_PATHS
  53. $ENV{MYSQL_DIR}/lib/${binary_dist}
  54. $ENV{MYSQL_DIR}/libmysql/${build_dist}
  55. $ENV{MYSQL_DIR}/client/${build_dist}
  56. $ENV{ProgramFiles}/MySQL/*/lib/${binary_dist}
  57. $ENV{SystemDrive}/MySQL/*/lib/${binary_dist}
  58. $ENV{MYSQL_DIR}/lib/opt
  59. $ENV{MYSQL_DIR}/client/release
  60. $ENV{ProgramFiles}/MySQL/*/lib/opt
  61. $ENV{ProgramFiles}/MySQL/*/lib/
  62. $ENV{SystemDrive}/MySQL/*/lib/opt
  63. $ENV{ProgramW6432}/MySQL/*/lib
  64. )
  65. find_library(MYSQL_LIBRARIES NAMES libmysql
  66. PATHS
  67. ${MYSQL_LIB_PATHS}
  68. )
  69. else(WIN32)
  70. # find_library(MYSQL_LIBRARIES NAMES mysqlclient
  71. set(MYSQL_LIB_PATHS
  72. $ENV{MYSQL_DIR}/libmysql_r/.libs
  73. $ENV{MYSQL_DIR}/lib
  74. $ENV{MYSQL_DIR}/lib/mysql
  75. /usr/local/mysql/lib
  76. /opt/mysql/mysql/lib
  77. $ENV{MYSQL_DIR}/libmysql_r/.libs
  78. $ENV{MYSQL_DIR}/lib
  79. $ENV{MYSQL_DIR}/lib/mysql
  80. /usr/local/mysql/lib
  81. /opt/mysql/mysql/lib
  82. PATH_SUFFIXES
  83. mysql
  84. )
  85. find_library(MYSQL_LIBRARIES NAMES mysqlclient
  86. PATHS
  87. ${MYSQL_LIB_PATHS}
  88. )
  89. endif(WIN32)
  90. find_library(MYSQL_EMBEDDED_LIBRARIES NAMES mysqld
  91. PATHS
  92. ${MYSQL_LIB_PATHS}
  93. )
  94. if(MYSQL_LIBRARIES)
  95. get_filename_component(MYSQL_LIB_DIR ${MYSQL_LIBRARIES} PATH)
  96. endif(MYSQL_LIBRARIES)
  97. if(MYSQL_EMBEDDED_LIBRARIES)
  98. get_filename_component(MYSQL_EMBEDDED_LIB_DIR ${MYSQL_EMBEDDED_LIBRARIES} PATH)
  99. endif(MYSQL_EMBEDDED_LIBRARIES)
  100. set( CMAKE_REQUIRED_INCLUDES ${MYSQL_INCLUDE_DIR} )
  101. set( CMAKE_REQUIRED_LIBRARIES ${MYSQL_EMBEDDED_LIBRARIES} )
  102. check_cxx_source_compiles( "#include <mysql.h>\nint main() { int i = MYSQL_OPT_USE_EMBEDDED_CONNECTION; }" HAVE_MYSQL_OPT_EMBEDDED_CONNECTION )
  103. if(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
  104. set(MYSQL_FOUND TRUE)
  105. else(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
  106. set(MYSQL_FOUND FALSE)
  107. message(STATUS "MySQL not found.")
  108. endif(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
  109. if(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_OPT_EMBEDDED_CONNECTION)
  110. set(MYSQL_EMBEDDED_FOUND TRUE)
  111. message(STATUS "Found MySQL Embedded: ${MYSQL_INCLUDE_DIR}, ${MYSQL_EMBEDDED_LIBRARIES}")
  112. else(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_OPT_EMBEDDED_CONNECTION)
  113. set(MYSQL_EMBEDDED_FOUND FALSE)
  114. endif(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_OPT_EMBEDDED_CONNECTION)
  115. mark_as_advanced(MYSQL_INCLUDE_DIR MYSQL_LIBRARIES MYSQL_EMBEDDED_LIBRARIES)