Skip to content

Commit d8a19a7

Browse files
author
Jimmy Yang
committed
Move the "libevent" to the top build directory. And add cmake option
WITH_LIBEVENT, so user can build the daemon memcached either with "bundled" libevent or with user installed libevent.
1 parent 6cb8924 commit d8a19a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+100
-9
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ ENDIF()
139139
# Add macros
140140
INCLUDE(character_sets)
141141
INCLUDE(zlib)
142+
INCLUDE(libevent)
142143
INCLUDE(ssl)
143144
INCLUDE(readline)
144145
INCLUDE(mysql_version)
@@ -248,6 +249,8 @@ MYSQL_CHECK_ZLIB_WITH_COMPRESS()
248249
MYSQL_CHECK_SSL()
249250
# Add readline or libedit.
250251
MYSQL_CHECK_READLINE()
252+
# Add libevent
253+
MYSQL_CHECK_LIBEVENT()
251254

252255
#
253256
# Setup maintainer mode options by the end. Platform checks are

cmake/libevent.cmake

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Copyright (C) 2011 Oracle and/or its affiliates. All Rights Reserved.
2+
#
3+
# This program is free software; you can redistribute it and/or modify
4+
# it under the terms of the GNU General Public License as published by
5+
# the Free Software Foundation; version 2 of the License.
6+
#
7+
# This program is distributed in the hope that it will be useful,
8+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
# GNU General Public License for more details.
11+
#
12+
# You should have received a copy of the GNU General Public License
13+
# along with this program; if not, write to the Free Software
14+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15+
16+
MACRO (MYSQL_USE_BUNDLED_LIBEVENT)
17+
SET(LIBEVENT_LIBRARY event)
18+
SET(LIBEVENT_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/libevent)
19+
SET(LIBEVENT_FOUND TRUE)
20+
SET(WITH_LIBEVENT "bundled" CACHE STRING "Use bundled libevent")
21+
ADD_SUBDIRECTORY(libevent)
22+
GET_TARGET_PROPERTY(src libevent SOURCES)
23+
FOREACH(file ${src})
24+
SET(LIBEVENT_SOURCES ${LIBEVENT_SOURCES} ${CMAKE_SOURCE_DIR}/libevent/${file})
25+
ENDFOREACH()
26+
ENDMACRO()
27+
28+
# MYSQL_CHECK_LIBEVENT
29+
#
30+
# Provides the following configure options:
31+
# WITH_LIBEVENT_BUNDLED
32+
# If this is set,we use bindled zlib
33+
# If this is not set,search for system zlib.
34+
# if system zlib is not found, use bundled copy
35+
# LIBEVENT_LIBRARIES, LIBEVENT_INCLUDE_DIR and LIBEVENT_SOURCES
36+
# are set after this macro has run
37+
38+
MACRO (MYSQL_CHECK_LIBEVENT)
39+
40+
IF (NOT WITH_LIBEVENT)
41+
SET(WITH_LIBEVENT "bundled" CACHE STRING "By default use bundled libevent on this platform")
42+
ENDIF()
43+
44+
IF(WITH_LIBEVENT STREQUAL "bundled")
45+
MYSQL_USE_BUNDLED_LIBEVENT()
46+
ELSEIF(WITH_LIBEVENT STREQUAL "system" OR WITH_LIBEVENT STREQUAL "yes")
47+
SET(LIBEVENT_FIND_QUIETLY TRUE)
48+
49+
IF (NOT LIBEVENT_INCLUDE_PATH)
50+
set(LIBEVENT_INCLUDE_PATH /usr/local/include /opt/local/include)
51+
ENDIF()
52+
53+
find_path(LIBEVENT_INCLUDE_DIR event.h PATHS ${LIBEVENT_INCLUDE_PATH})
54+
55+
if (NOT LIBEVENT_INCLUDE_DIR)
56+
MESSAGE(SEND_ERROR "Cannot find appropriate event.h in /usr/local/include or /opt/local/include. Use bundled libevent")
57+
endif()
58+
59+
IF (NOT LIBEVENT_LIB_PATHS)
60+
set(LIBEVENT_LIB_PATHS /usr/local/lib /opt/local/lib)
61+
ENDIF()
62+
63+
find_library(LIBEVENT_LIB event PATHS ${LIBEVENT_LIB_PATHS})
64+
65+
if (NOT LIBEVENT_LIB)
66+
MESSAGE(SEND_ERROR "Cannot find appropriate event lib in /usr/local/lib or /opt/local/lib. Use bundled libevent")
67+
endif()
68+
69+
IF (LIBEVENT_LIB AND LIBEVENT_INCLUDE_DIR)
70+
set(LIBEVENT_FOUND TRUE)
71+
set(LIBEVENT_LIBS ${LIBEVENT_LIB})
72+
ELSE()
73+
set(LIBEVENT_FOUND FALSE)
74+
ENDIF()
75+
76+
IF(LIBEVENT_FOUND)
77+
SET(LIBEVENT_SOURCES "")
78+
SET(LIBEVENT_LIBRARIES ${LIBEVENT_LIBS})
79+
SET(LIBEVENT_INCLUDE_DIRS ${LIBEVENT_INCLUDE_DIR})
80+
SET(LIBEVENT_DEFINES "-DHAVE_LIBEVENT")
81+
ELSE()
82+
IF(WITH_LIBEVENT STREQUAL "system")
83+
MESSAGE(SEND_ERROR "Cannot find appropriate system libraries for libevent. Use bundled libevent")
84+
ENDIF()
85+
MYSQL_USE_BUNDLED_LIBEVENT()
86+
ENDIF()
87+
88+
ENDIF()
89+
ENDMACRO()

plugin/innodb_memcached/libevent/CMakeLists.txt renamed to libevent/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515

1616
# Common defines and includes
1717
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
18-
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/plugin/innodb_memcached/libevent/compat/sys
19-
${CMAKE_SOURCE_DIR}/plugin/innodb_memcached/libevent)
18+
INCLUDE_DIRECTORIES(${LIBEVENT_INCLUDE_DIR}/compat/sys
19+
${LIBEVENT_INCLUDE_DIR})
2020

21-
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_SHARED_LIBRARY_C_FLAGS} -I${CMAKE_SOURCE_DIR}/plugin/innodb_memcached/libevent")
21+
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_SHARED_LIBRARY_C_FLAGS} -I${LIBEVENT_INCLUDE_DIR}")
2222

2323
SET(LIBEVENT_CORE_SOURCES
2424
event.h

plugin/innodb_memcached/libevent/ChangeLog renamed to libevent/ChangeLog

File renamed without changes.

plugin/innodb_memcached/libevent/Makefile.am renamed to libevent/Makefile.am

File renamed without changes.

plugin/innodb_memcached/libevent/WIN32-Code/event-config.h renamed to libevent/WIN32-Code/event-config.h

File renamed without changes.

plugin/innodb_memcached/libevent/WIN32-Code/misc.c renamed to libevent/WIN32-Code/misc.c

File renamed without changes.

plugin/innodb_memcached/libevent/WIN32-Code/misc.h renamed to libevent/WIN32-Code/misc.h

File renamed without changes.

0 commit comments

Comments
 (0)