mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / mysql_storage_engine.cmake
blobf27191a2bf87c637aadf7e2123d555e4aa33f0ac
1 # Copyright (c) 2009 Sun Microsystems, Inc.
2 # Use is subject to license terms.
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; version 2 of the License.
7
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
17 # MYSQL_STORAGE_ENGINE Macro creates a project to build storage engine
18 # library. 
20 # Parameters:
21 # engine - storage engine name.
22 # variable ENGINE_BUILD_TYPE should be set to "STATIC" or "DYNAMIC"
23 # Remarks:
24 # ${engine}_SOURCES  variable containing source files to produce the library must set before
25 # calling this macro
26 # ${engine}_LIBS variable containing extra libraries to link with may be set
29 MACRO(MYSQL_STORAGE_ENGINE engine)
30 IF(NOT SOURCE_SUBLIBS)
31   # Add common include directories
32   INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib
33                     ${CMAKE_SOURCE_DIR}/sql
34                     ${CMAKE_SOURCE_DIR}/regex
35                     ${CMAKE_SOURCE_DIR}/extra/yassl/include)
36   STRING(TOUPPER ${engine} engine)
37   STRING(TOLOWER ${engine} libname)
38   IF(${ENGINE_BUILD_TYPE} STREQUAL "STATIC")
39     ADD_DEFINITIONS(-DWITH_${engine}_STORAGE_ENGINE -DMYSQL_SERVER)
40     #Create static library. The name of the library is <storage_engine>.lib
41     ADD_LIBRARY(${libname} ${${engine}_SOURCES})
42     ADD_DEPENDENCIES(${libname} GenError)
43     IF(${engine}_LIBS)
44       TARGET_LINK_LIBRARIES(${libname} ${${engine}_LIBS})
45     ENDIF(${engine}_LIBS)
46     MESSAGE("build ${engine} as static library")
47   ELSEIF(${ENGINE_BUILD_TYPE} STREQUAL "DYNAMIC")
48     ADD_DEFINITIONS(-DMYSQL_DYNAMIC_PLUGIN)
49     #Create a DLL.The name of the dll is ha_<storage_engine>.dll
50     #The dll is linked to the mysqld executable
51     SET(dyn_libname ha_${libname})
52     ADD_LIBRARY(${dyn_libname} SHARED ${${engine}_SOURCES})
53     TARGET_LINK_LIBRARIES (${dyn_libname}  mysqld)
54     IF(${engine}_LIBS)
55       TARGET_LINK_LIBRARIES(${dyn_libname} ${${engine}_LIBS})
56     ENDIF(${engine}_LIBS)
57     MESSAGE("build ${engine} as DLL")
58   ENDIF(${ENGINE_BUILD_TYPE} STREQUAL "STATIC")
59 ENDIF(NOT SOURCE_SUBLIBS)
60 ENDMACRO(MYSQL_STORAGE_ENGINE)