1 ## Copyright (C) 2011 BYVoid
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; either version 2, or (at your option)
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.
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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 ######## Project settings
18 cmake_minimum_required(VERSION 2.8)
19 set (PACKAGE_NAME libpinyin)
20 project (${PACKAGE_NAME} CXX C)
23 ######## Package information
24 set (PACKAGE_URL https://github.com/libpinyin/libpinyin)
25 set (PACKAGE_BUGREPORT https://github.com/libpinyin/libpinyin/issues)
26 set (LIBPINYIN_VERSION_MAJOR 0)
27 set (LIBPINYIN_VERSION_MINOR 7)
28 set (LIBPINYIN_VERSION_REVISION 0)
29 set (LIBPINYIN_BINARY_VERSION 2.0)
31 if (CMAKE_BUILD_TYPE MATCHES Debug)
32 set (version_suffix .Debug)
33 endif (CMAKE_BUILD_TYPE MATCHES Debug)
37 ${LIBPINYIN_VERSION_MAJOR}.${LIBPINYIN_VERSION_MINOR}.${LIBPINYIN_VERSION_REVISION}${version_suffix}
40 set (VERSION ${LIBPINYIN_VERSION})
44 include(CheckIncludeFileCXX)
45 check_include_file_cxx(locale.h HAVE_LOCALE_H)
46 check_include_file_cxx(libintl.h HAVE_LIBINTL_H)
47 check_include_file_cxx(stdlib.h HAVE_STDLIB_H)
48 check_include_file_cxx(string.h HAVE_STRING_H)
49 check_include_file_cxx(sys/time.h HAVE_SYS_TIME_H)
50 check_include_file_cxx(unistd.h HAVE_UNISTD_H)
52 include(CheckFunctionExists)
53 check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
54 check_function_exists(malloc HAVE_MALLOC)
55 check_function_exists(memcmp HAVE_MEMCMP)
56 check_function_exists(memmove HAVE_MEMMOVE)
57 check_function_exists(memset HAVE_MEMSET)
58 check_function_exists(realloc HAVE_REALLOC)
59 check_function_exists(setlocale HAVE_SETLOCALE)
60 check_function_exists(stat HAVE_STAT)
62 include(CheckTypeSize)
63 check_type_size(size_t SIZE_OF_SIZE_T)
65 set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
66 find_package(GLIB2 REQUIRED)
67 find_package(BerkeleyDB REQUIRED)
72 set(CMAKE_SHARED_LIBRARY_PREFIX ${CMAKE_INSTALL_PREFIX})
73 set(CMAKE_STATIC_LIBRARY_PREFIX ${CMAKE_INSTALL_PREFIX})
78 set (DIR_PREFIX ${CMAKE_INSTALL_PREFIX})
79 set (DIR_LIBRARY ${DIR_PREFIX}/${CMAKE_SHARED_LIBRARY_PREFIX})
80 set (DIR_LIBRARY_STATIC ${DIR_PREFIX}/${CMAKE_STATIC_LIBRARY_PREFIX})
81 set (DIR_INCLUDE ${DIR_PREFIX}/include)
82 set (DIR_SHARE ${DIR_PREFIX}/share)
83 set (DIR_BIN ${DIR_PREFIX}/bin)
84 set (DIR_ETC ${DIR_PREFIX}/etc)
86 if (DEFINED CMAKE_INSTALL_LIBDIR)
87 set (DIR_LIBRARY ${CMAKE_INSTALL_LIBDIR})
88 set (DIR_LIBRARY_STATIC ${CMAKE_INSTALL_LIBDIR})
89 endif (DEFINED CMAKE_INSTALL_LIBDIR)
91 if (DEFINED SHARE_INSTALL_PREFIX)
92 set (DIR_SHARE ${SHARE_INSTALL_PREFIX})
93 endif (DEFINED SHARE_INSTALL_PREFIX)
95 if (DEFINED INCLUDE_INSTALL_DIR)
96 set (DIR_INCLUDE ${INCLUDE_INSTALL_DIR})
97 endif (DEFINED INCLUDE_INSTALL_DIR)
99 if (DEFINED SYSCONF_INSTALL_DIR)
100 set (DIR_ETC ${SYSCONF_INSTALL_DIR})
101 endif (DEFINED SYSCONF_INSTALL_DIR)
103 set (DIR_SHARE_LIBPINYIN ${DIR_SHARE}/libpinyin)
104 set (DIR_INCLUDE_LIBPINYIN ${DIR_INCLUDE}/libpinyin-${LIBPINYIN_BINARY_VERSION})
106 ######## Configuration
108 set (prefix ${DIR_PREFIX})
109 set (exec_prefix ${DIR_PREFIX})
110 set (libdir ${DIR_LIBRARY})
111 set (includedir ${DIR_INCLUDE})
112 set (datadir ${DIR_SHARE})
122 ${CMAKE_BINARY_DIR}/libpinyin.pc
124 ${DIR_LIBRARY}/pkgconfig
129 if (CMAKE_BUILD_TYPE MATCHES Debug)
134 endif (CMAKE_BUILD_TYPE MATCHES Debug)
138 ${PROJECT_SOURCE_DIR}/src
139 ${PROJECT_SOURCE_DIR}/src/include
140 ${PROJECT_SOURCE_DIR}/src/storage
141 ${PROJECT_SOURCE_DIR}/src/lookup
142 ${PROJECT_SOURCE_DIR}/utils
143 ${PROJECT_SOURCE_DIR}/tests
146 ######## Subdirectories
148 add_subdirectory(src)
149 add_subdirectory(tests)
150 add_subdirectory(utils)
151 add_subdirectory(data)