Merge branch 'main/rendor-staging' into main/atys-live
[ryzomcore.git] / CMakeModules / FindMySQL.cmake
blob631a96224c0cc90f4bf2a7f84dc9425355a8a069
1 # - Find MySQL
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_FOUND, If false, do not try to use MySQL.
8 # Copyright (c) 2006, Jaroslaw Staniek, <js@iidea.pl>
10 # Redistribution and use is allowed according to the terms of the BSD license.
11 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
13 IF(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
14    SET(MYSQL_FOUND TRUE)
16 ELSE()
18   FIND_PATH(MYSQL_INCLUDE_DIR mysql.h
19       PATH_SUFFIXES mysql mariadb
20       PATHS
21       /usr/include/mysql
22       /usr/include/mariadb
23       /usr/local/include/mysql
24       /usr/local/include/mariadb
25       /opt/local/include/mysql5/mysql
26       /opt/local/include/mysql55/mysql
27       /opt/local/include/mysql51/mysql
28       $ENV{ProgramFiles}/MySQL/*/include
29       $ENV{SystemDrive}/MySQL/*/include)
31   IF(WIN32 AND MSVC)
32     FIND_LIBRARY(MYSQL_LIBRARY_RELEASE NAMES libmysql mysqlclient libmariadb mariadbclient
33       PATHS
34       $ENV{ProgramFiles}/MySQL/*/lib/opt
35       $ENV{SystemDrive}/MySQL/*/lib/opt)
36     FIND_LIBRARY(MYSQL_LIBRARY_DEBUG NAMES libmysqld mysqlclientd libmariadb mariadbclient
37       PATHS
38       $ENV{ProgramFiles}/MySQL/*/lib/opt
39       $ENV{SystemDrive}/MySQL/*/lib/opt)
40   ELSE()
41     FIND_LIBRARY(MYSQL_LIBRARY_RELEASE NAMES mysqlclient mariadbclient
42       PATHS
43       /usr/lib
44       /usr/local/lib
45       /usr/lib/mariadb
46       /usr/lib/mysql
47       /usr/local/lib/mysql
48       /usr/local/lib/mariadb
49       /opt/local/lib/mysql5/mysql
50       /opt/local/lib/mysql55/mysql
51       /opt/local/lib/mysql51/mysql
52       )
54     FIND_LIBRARY(MYSQL_LIBRARY_DEBUG NAMES mysqlclientd mariadbclientd
55       PATHS
56       /usr/lib
57       /usr/local/lib
58       /usr/lib/mysql
59       /usr/local/lib/mysql
60       /opt/local/lib/mysql5/mysql
61       /opt/local/lib/mysql55/mysql
62       /opt/local/lib/mysql51/mysql
63       )
64   ENDIF()
66   IF(MYSQL_INCLUDE_DIR)
67     IF(MYSQL_LIBRARY_RELEASE)
68       IF(MYSQL_LIBRARY_DEBUG)
69         SET(MYSQL_LIBRARIES optimized ${MYSQL_LIBRARY_RELEASE} debug ${MYSQL_LIBRARY_DEBUG})
70       ELSE()
71             SET(MYSQL_LIBRARIES ${MYSQL_LIBRARY_RELEASE})
72       ENDIF()
73       FIND_PACKAGE(OpenSSL)
74       IF(OPENSSL_FOUND)
75         IF(WIN32)
76           SET(OPENSSL_LIBRARIES ${OPENSSL_LIBRARIES} Crypt32.lib)
77         ENDIF()
78         SET(MYSQL_LIBRARIES ${MYSQL_LIBRARIES} ${OPENSSL_LIBRARIES})
79       ENDIF()
80     ENDIF()
81   ENDIF()
83   IF(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
84     SET(MYSQL_FOUND TRUE)
85     MESSAGE(STATUS "Found MySQL: ${MYSQL_INCLUDE_DIR}, ${MYSQL_LIBRARIES}")
86     IF (MYSQL_LIBRARIES MATCHES "libmariadb" OR MYSQL_LIBRARIES MATCHES "mariadbclient")
87       SET(MARIADB_FOUND TRUE)
88       MESSAGE(STATUS "Found MariaDB.")
89     ENDIF()
90   ELSE()
91     SET(MYSQL_FOUND FALSE)
92     MESSAGE(STATUS "MySQL not found.")
93   ENDIF()
95   MARK_AS_ADVANCED(MYSQL_LIBRARY_RELEASE MYSQL_LIBRARY_DEBUG)
97 ENDIF()