forked from vozbu/libslave
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
58 lines (50 loc) · 1.88 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
CMAKE_MINIMUM_REQUIRED (VERSION 2.8)
PROJECT (libslave)
# Build flags
IF (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# Common options
ADD_DEFINITIONS (-pipe)
ADD_DEFINITIONS (-Wall)
ADD_DEFINITIONS (-O2)
ADD_DEFINITIONS (-std=c++11)
ADD_DEFINITIONS (-DUSE_PSI_1)
ADD_DEFINITIONS (-DHAVE_PSI_1)
ENDIF ()
FIND_PACKAGE (Boost REQUIRED)
INCLUDE_DIRECTORIES (${Boost_INCLUDE_DIRS})
FIND_PACKAGE (Boost 1.41.0 COMPONENTS unit_test_framework system)
INCLUDE (FindPackageHandleStandardArgs)
FIND_PATH (IMYSQL mysql/mysql.h)
FIND_LIBRARY (LMYSQLCLIENT_R NAMES libmysqlclient_r.a
libmysqlclient.a
libmysqlclient_r.so
libmysqlclient.so PATH_SUFFIXES mysql)
SET (Mysql_FIND_REQUIRED YES)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Mysql DEFAULT_MSG IMYSQL LMYSQLCLIENT_R)
INCLUDE_DIRECTORIES ("${IMYSQL}/mysql")
# Check whether we've found static or dynamic library
STRING (REGEX MATCH ".*\\.a$" MYSQL_IS_STATIC ${LMYSQLCLIENT_R})
IF (MYSQL_IS_STATIC STREQUAL LMYSQLCLIENT_R)
SET (MYSQL_IS_STATIC ON)
ELSE ()
SET (MYSQL_IS_STATIC OFF)
ENDIF ()
FILE (GLOB HDR "*.h")
INSTALL (FILES ${HDR} DESTINATION include)
AUX_SOURCE_DIRECTORY (${CMAKE_SOURCE_DIR} SRC)
ADD_LIBRARY (slave_a ${SRC})
SET_TARGET_PROPERTIES (slave_a PROPERTIES OUTPUT_NAME slave)
TARGET_LINK_LIBRARIES (slave_a ${LMYSQLCLIENT_R})
INSTALL (TARGETS slave_a DESTINATION lib64)
# Most probably statc mysql is built without fPIC, so, we can't build dynamic library with it
IF (NOT MYSQL_IS_STATIC)
ADD_LIBRARY (slave_so SHARED ${SRC})
SET_TARGET_PROPERTIES (slave_so PROPERTIES OUTPUT_NAME slave)
TARGET_LINK_LIBRARIES (slave_so ${LMYSQLCLIENT_R})
INSTALL (TARGETS slave_so DESTINATION lib64)
ENDIF ()
IF (Boost_FOUND)
ENABLE_TESTING ()
ENDIF (Boost_FOUND)
ADD_SUBDIRECTORY (test)