1 # - Find MySQL / MySQL Embedded
2 # Find the MySQL includes and client library
4 # MYSQL_INCLUDE_DIR, where to find mysql.h
5 # MYSQL_LIBRARIES, the libraries needed to use MySQL.
6 # MYSQL_EMBEDDED_LIBRARIES, the libraries needed to use MySQL Embedded.
7 # MYSQL_FOUND, If false, do not try to use MySQL.
8 # MYSQL_EMBEDDED_FOUND, If false, do not try to use MySQL Embedded.
10 # Copyright (c) 2006, Jaroslaw Staniek, <js@iidea.pl>
12 # Redistribution and use is allowed according to the terms of the BSD license.
13 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
16 find_path(MYSQL_INCLUDE_DIR mysql.h
18 /usr/local/include/mysql
21 find_library(MYSQL_LIBRARIES NAMES mysqlclient
27 find_library(MYSQL_EMBEDDED_LIBRARIES NAMES mysqld
34 macro_push_required_vars()
35 set( CMAKE_REQUIRED_INCLUDES ${MYSQL_INCLUDE_DIR} )
36 set( CMAKE_REQUIRED_LIBRARIES ${MYSQL_EMBEDDED_LIBRARIES} )
37 check_cxx_source_compiles( "#include <mysql.h>\nint main() { int i = MYSQL_OPT_USE_EMBEDDED_CONNECTION; }" HAVE_MYSQL_OPT_EMBEDDED_CONNECTION )
38 macro_pop_required_vars()
40 if(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
42 message(STATUS "Found MySQL: ${MYSQL_INCLUDE_DIR}, ${MYSQL_LIBRARIES}")
43 else(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
44 set(MYSQL_FOUND FALSE)
45 message(STATUS "MySQL not found.")
46 endif(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
48 if(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_OPT_EMBEDDED_CONNECTION)
49 set(MYSQL_EMBEDDED_FOUND TRUE)
50 message(STATUS "Found MySQL Embedded: ${MYSQL_INCLUDE_DIR}, ${MYSQL_EMBEDDED_LIBRARIES}")
51 else(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_OPT_EMBEDDED_CONNECTION)
52 set(MYSQL_EMBEDDED_FOUND FALSE)
53 message(STATUS "MySQL Embedded not found.")
54 endif(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_OPT_EMBEDDED_CONNECTION)
56 mark_as_advanced(MYSQL_INCLUDE_DIR MYSQL_LIBRARIES MYSQL_EMBEDDED_LIBRARIES)