Better constant folding for concat
[hiphop-php.git] / CMake / FindMySQL.cmake
blob69430e0fd0d270f1862a5b77a8c9c22b31b40a0c
1 #--------------------------------------------------------
2 # Copyright (C) 1995-2007 MySQL AB
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of version 2 of the GNU General Public License as
6 # published by the Free Software Foundation.
8 # There are special exceptions to the terms and conditions of the GPL
9 # as it is applied to this software. View the full text of the exception
10 # in file LICENSE.exceptions in the top-level directory of this software
11 # distribution.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc.,
21 # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
23 # The MySQL Connector/ODBC is licensed under the terms of the
24 # GPL, like most MySQL Connectors. There are special exceptions
25 # to the terms and conditions of the GPL as it is applied to
26 # this software, see the FLOSS License Exception available on
27 # mysql.com.
29 ##########################################################################
32 #-------------- FIND MYSQL_INCLUDE_DIR ------------------
33 FIND_PATH(MYSQL_INCLUDE_DIR mysql.h
34   /usr/include/mysql
35   /usr/local/include/mysql
36   /opt/mysql/mysql/include
37   /opt/mysql/mysql/include/mysql
38   /opt/mysql/include
39   /opt/local/include/mysql5
40   /usr/local/mysql/include
41   /usr/local/mysql/include/mysql
42   $ENV{ProgramFiles}/MySQL/*/include
43   $ENV{SystemDrive}/MySQL/*/include)
45 #----------------- FIND MYSQL_LIB_DIR -------------------
46 IF (WIN32)
47   # Set lib path suffixes
48   # dist = for mysql binary distributions
49   # build = for custom built tree
50   IF (CMAKE_BUILD_TYPE STREQUAL Debug)
51     SET(libsuffixDist debug)
52     SET(libsuffixBuild Debug)
53   ELSE (CMAKE_BUILD_TYPE STREQUAL Debug)
54     SET(libsuffixDist opt)
55     SET(libsuffixBuild Release)
56     ADD_DEFINITIONS(-DDBUG_OFF)
57   ENDIF (CMAKE_BUILD_TYPE STREQUAL Debug)
59   FIND_LIBRARY(MYSQL_LIB NAMES mysqlclient
60     PATHS
61     $ENV{MYSQL_DIR}/lib/${libsuffixDist}
62     $ENV{MYSQL_DIR}/libmysql
63     $ENV{MYSQL_DIR}/libmysql/${libsuffixBuild}
64     $ENV{MYSQL_DIR}/client/${libsuffixBuild}
65     $ENV{MYSQL_DIR}/libmysql/${libsuffixBuild}
66     $ENV{ProgramFiles}/MySQL/*/lib/${libsuffixDist}
67     $ENV{SystemDrive}/MySQL/*/lib/${libsuffixDist})
68 ELSE (WIN32)
69   FIND_LIBRARY(MYSQL_LIB NAMES mysqlclient_r mysqlclient
70     PATHS
71     /usr/lib/mysql
72     /usr/local/lib/mysql
73     /usr/local/mysql/lib
74     /usr/local/mysql/lib/mysql
75     /opt/local/mysql5/lib
76     /opt/local/lib/mysql5/mysql
77     /opt/mysql/mysql/lib/mysql
78     /opt/mysql/lib/mysql)
79 ENDIF (WIN32)
81 IF(MYSQL_LIB)
82   GET_FILENAME_COMPONENT(MYSQL_LIB_DIR ${MYSQL_LIB} PATH)
83 ENDIF(MYSQL_LIB)
85 IF (MYSQL_INCLUDE_DIR AND MYSQL_LIB_DIR)
86   SET(MYSQL_FOUND TRUE)
88   INCLUDE_DIRECTORIES(${MYSQL_INCLUDE_DIR})
89   LINK_DIRECTORIES(${MYSQL_LIB_DIR})
91   FIND_LIBRARY(MYSQL_ZLIB zlib PATHS ${MYSQL_LIB_DIR})
92   FIND_LIBRARY(MYSQL_TAOCRYPT taocrypt PATHS ${MYSQL_LIB_DIR})
93   IF (MYSQL_LIB)
94     SET(MYSQL_CLIENT_LIBS ${MYSQL_LIB})
95   ELSE()
96     SET(MYSQL_CLIENT_LIBS mysqlclient_r)
97   ENDIF()
98   IF (MYSQL_ZLIB)
99     SET(MYSQL_CLIENT_LIBS ${MYSQL_CLIENT_LIBS} zlib)
100   ENDIF (MYSQL_ZLIB)
101   IF (MYSQL_TAOCRYPT)
102     SET(MYSQL_CLIENT_LIBS ${MYSQL_CLIENT_LIBS} taocrypt)
103   ENDIF (MYSQL_TAOCRYPT)
104   # Added needed mysqlclient dependencies on Windows
105   IF (WIN32)
106     SET(MYSQL_CLIENT_LIBS ${MYSQL_CLIENT_LIBS} ws2_32)
107   ENDIF (WIN32)
109   MESSAGE(STATUS "MySQL Include dir: ${MYSQL_INCLUDE_DIR}  library dir: ${MYSQL_LIB_DIR}")
110   MESSAGE(STATUS "MySQL client libraries: ${MYSQL_CLIENT_LIBS}")
111 ELSEIF (MySQL_FIND_REQUIRED)
112   MESSAGE(FATAL_ERROR "Cannot find MySQL. Include dir: ${MYSQL_INCLUDE_DIR}  library dir: ${MYSQL_LIB_DIR}")
113 ENDIF (MYSQL_INCLUDE_DIR AND MYSQL_LIB_DIR)