null+****@clear*****
null+****@clear*****
2012年 4月 13日 (金) 19:50:12 JST
Kouhei Sutou 2012-04-13 19:50:12 +0900 (Fri, 13 Apr 2012) New Revision: 957db72450516c8b4397e6062e5813c56c3d0ad2 Log: cmake: start tokenizers support but it's not completed yet Added files: plugins/tokenizers/CMakeLists.txt plugins/tokenizers/kytea_sources.am plugins/tokenizers/mecab_sources.am Modified files: CMakeLists.txt plugins/CMakeLists.txt plugins/tokenizers/Makefile.am Modified: CMakeLists.txt (+38 -2) =================================================================== --- CMakeLists.txt 2012-04-13 19:24:36 +0900 (ca3ee4d) +++ CMakeLists.txt 2012-04-13 19:50:12 +0900 (7bcc36d) @@ -21,6 +21,7 @@ file(READ base_version GRN_VERSION) include(CheckIncludeFile) include(CheckFunctionExists) include(CheckLibraryExists) +include(FindPkgConfig) set(GRN_LOG_PATH "${CMAKE_INSTALL_PREFIX}/var/log/${CMAKE_PROJECT_NAME}/${CMAKE_PROJECT_NAME}.log" @@ -91,7 +92,7 @@ endif() option(WITH_ZLIB "use zlib for data compression." OFF) if(WITH_ZLIB) - AC_CHECK_LIB(z compress) + ac_check_lib(z compress) if (NOT HAVE_LIBZ) message(FATAL_ERROR "No libz found") endif() @@ -99,12 +100,47 @@ endif() option(WITH_LZO "use LZO for data compression." OFF) if(WITH_LZO) - AC_CHECK_LIB(lzo2 lzo1_compress) + ac_check_lib(lzo2 lzo1_compress) if (NOT HAVE_LIBLZO2) message(FATAL_ERROR "No liblzo2 found") endif() endif() +set(WITH_MECAB "auto" + CACHE STRING "use MeCab for morphological analysis") +if(NOT ${WITH_MECAB} STREQUAL "no") + set(MECAB_CONFIG "mecab-config" CACHE FILEPATH "mecab-config path") + if(NOT CMAKE_CROSSCOMPILING) + find_program(MECAB_CONFIG "${MECAB_CONFIG}") + endif() + if(EXISTS "${MECAB_CONFIG}") + execute_process(COMMAND "${MECAB_CONFIG}" --inc-dir + OUTPUT_VARIABLE MECAB_CPPFLAGS) + execute_process(COMMAND "${MECAB_CONFIG}" --libs-only-L + OUTPUT_VARIABLE MECAB_LDFLAGS) + ac_check_lib(mecab mecab_new) + else() + set(WITH_MECAB FALSE) + if(${WITH_MECAB} STREQUAL "yes") + message(FATAL_ERROR "No MeCab found") + endif() + endif() +else() + set(WITH_MECAB FALSE) +endif() + +set(WITH_KYTEA "auto" + CACHE STRING "use KyTea for morphological analysis") +if(NOT ${WITH_KYTEA} STREQUAL "no") + pkg_check_modules(KYTEA kytea) + set(WITH_KEYTEA KYTEA_FUOND) + if(NOT WITH_KEYTEA AND ${WITH_KYTEA} STREQUAL "yes") + message(FATAL_ERROR "No KyTea found") + endif() +else() + set(WITH_KEYTEA FALSE) +endif() + set(LIBGROONGA ${CMAKE_BINARY_DIR}/lib/libgroonga.so) add_subdirectory(lib) Modified: plugins/CMakeLists.txt (+1 -0) =================================================================== --- plugins/CMakeLists.txt 2012-04-13 19:24:36 +0900 (109f069) +++ plugins/CMakeLists.txt 2012-04-13 19:50:12 +0900 (c0646a4) @@ -14,3 +14,4 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA add_subdirectory(suggest) +add_subdirectory(tokenizers) Added: plugins/tokenizers/CMakeLists.txt (+34 -0) 100644 =================================================================== --- /dev/null +++ plugins/tokenizers/CMakeLists.txt 2012-04-13 19:50:12 +0900 (7ae9522) @@ -0,0 +1,34 @@ +# Copyright(C) 2012 Brazil +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1 as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +include(${CMAKE_SOURCE_DIR}/build/cmake_modules/ReadFileList.cmake) + +include_directories( + ${CMAKE_SOURCE_DIR}/lib + ) + +if(WITH_MECAB) + read_file_list(${CMAKE_CURRENT_SOURCE_DIR}/mecab_sources.am MECAB_SOURCES) + add_library(mecab MODULE ${MECAB_SOURCES}) + set_target_properties(mecab PROPERTIES PREFIX "") + target_link_libraries(mecab ${LIBGROONGA}) +endif() + +if(WITH_KYTEA) + read_file_list(${CMAKE_CURRENT_SOURCE_DIR}/kytea_sources.am KYTEA_SOURCES) + add_library(kytea MODULE ${KYTEA_SOURCES}) + set_target_properties(kytea PROPERTIES PREFIX "") + target_link_libraries(kytea ${LIBGROONGA}) +endif() Modified: plugins/tokenizers/Makefile.am (+2 -2) =================================================================== --- plugins/tokenizers/Makefile.am 2012-04-13 19:24:36 +0900 (b94c035) +++ plugins/tokenizers/Makefile.am 2012-04-13 19:50:12 +0900 (03f0783) @@ -19,12 +19,12 @@ if WITH_KYTEA tokenizer_plugins_LTLIBRARIES += kytea.la endif +include mecab_sources mecab_la_CPPFLAGS = $(MECAB_CPPFLAGS) -mecab_la_SOURCES = mecab.c mecab_la_LIBADD = $(LIBS) $(MECAB_LIBS) mecab_la_LDFLAGS = $(AM_LDFLAGS) $(MECAB_LDFLAGS) +include kytea_sources kytea_la_CPPFLAGS = $(KYTEA_CPPFLAGS) -kytea_la_SOURCES = kytea.cpp kytea_la_LIBADD = $(LIBS) $(KYTEA_LIBS) kytea_la_LDFLAGS = $(AM_LDFLAGS) $(KYTEA_LDFLAGS) Added: plugins/tokenizers/kytea_sources.am (+2 -0) 100644 =================================================================== --- /dev/null +++ plugins/tokenizers/kytea_sources.am 2012-04-13 19:50:12 +0900 (182f385) @@ -0,0 +1,2 @@ +kytea_la_SOURCES = \ + kytea.cpp Added: plugins/tokenizers/mecab_sources.am (+2 -0) 100644 =================================================================== --- /dev/null +++ plugins/tokenizers/mecab_sources.am 2012-04-13 19:50:12 +0900 (5691272) @@ -0,0 +1,2 @@ +mecab_la_SOURCES = \ + mecab.c