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., 675 Mass Ave, Cambridge, MA 02139, 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 2)
28 set (LIBPINYIN_VERSION_REVISION 99)
29 set (LIBPINYIN_BINARY_VERSION 0.3)
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}
42 include(CheckIncludeFileCXX)
43 check_include_file_cxx(locale.h HAVE_LOCALE_H)
44 check_include_file_cxx(libintl.h HAVE_LIBINTL_H)
45 check_include_file_cxx(stdlib.h HAVE_STDLIB_H)
46 check_include_file_cxx(string.h HAVE_STRING_H)
47 check_include_file_cxx(sys/time.h HAVE_SYS_TIME_H)
48 check_include_file_cxx(unistd.h HAVE_UNISTD_H)
50 include(CheckFunctionExists)
51 check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
52 check_function_exists(malloc HAVE_MALLOC)
53 check_function_exists(memcmp HAVE_MEMCMP)
54 check_function_exists(memmove HAVE_MEMMOVE)
55 check_function_exists(memset HAVE_MEMSET)
56 check_function_exists(realloc HAVE_REALLOC)
57 check_function_exists(setlocale HAVE_SETLOCALE)
58 check_function_exists(stat HAVE_STAT)
60 include(CheckTypeSize)
61 check_type_size(size_t SIZE_OF_SIZE_T)
63 set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
64 find_package(GLIB2 REQUIRED)
65 find_package(BerkeleyDB REQUIRED)
70 set(CMAKE_SHARED_LIBRARY_PREFIX ${CMAKE_INSTALL_PREFIX})
71 set(CMAKE_STATIC_LIBRARY_PREFIX ${CMAKE_INSTALL_PREFIX})
76 set (DIR_PREFIX ${CMAKE_INSTALL_PREFIX})
77 set (DIR_LIBRARY ${DIR_PREFIX}/${CMAKE_SHARED_LIBRARY_PREFIX})
78 set (DIR_LIBRARY_STATIC ${DIR_PREFIX}/${CMAKE_STATIC_LIBRARY_PREFIX})
79 set (DIR_INCLUDE ${DIR_PREFIX}/include)
80 set (DIR_SHARE ${DIR_PREFIX}/share)
81 set (DIR_BIN ${DIR_PREFIX}/bin)
82 set (DIR_ETC ${DIR_PREFIX}/etc)
84 if (DEFINED CMAKE_INSTALL_LIBDIR)
85 set (DIR_LIBRARY ${CMAKE_INSTALL_LIBDIR})
86 set (DIR_LIBRARY_STATIC ${CMAKE_INSTALL_LIBDIR})
87 endif (DEFINED CMAKE_INSTALL_LIBDIR)
89 if (DEFINED SHARE_INSTALL_PREFIX)
90 set (DIR_SHARE ${SHARE_INSTALL_PREFIX})
91 endif (DEFINED SHARE_INSTALL_PREFIX)
93 if (DEFINED INCLUDE_INSTALL_DIR)
94 set (DIR_INCLUDE ${INCLUDE_INSTALL_DIR})
95 endif (DEFINED INCLUDE_INSTALL_DIR)
97 if (DEFINED SYSCONF_INSTALL_DIR)
98 set (DIR_ETC ${SYSCONF_INSTALL_DIR})
99 endif (DEFINED SYSCONF_INSTALL_DIR)
101 set (DIR_SHARE_LIBPINYIN ${DIR_SHARE}/libpinyin)
102 set (DIR_INCLUDE_LIBPINYIN ${DIR_INCLUDE}/libpinyin-${LIBPINYIN_BINARY_VERSION})
104 ######## Configuration
114 ${CMAKE_BINARY_DIR}/libpinyin.pc
116 ${DIR_LIBRARY}/pkgconfig
121 if (CMAKE_BUILD_TYPE MATCHES Debug)
126 endif (CMAKE_BUILD_TYPE MATCHES Debug)
130 ${PROJECT_SOURCE_DIR}/src
131 ${PROJECT_SOURCE_DIR}/src/include
132 ${PROJECT_SOURCE_DIR}/src/storage
133 ${PROJECT_SOURCE_DIR}/src/lookup
136 ######## Subdirectories
138 add_subdirectory(data)
139 add_subdirectory(src)
140 add_subdirectory(tests)
141 add_subdirectory(utils)