Skip to content

Instantly share code, notes, and snippets.

@hkrn
Created March 27, 2011 14:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hkrn/889259 to your computer and use it in GitHub Desktop.
Save hkrn/889259 to your computer and use it in GitHub Desktop.
Julius/OpenJTalk/HTSEngine のビルド設定の CMake 移植 (当然非公式です)
#
# CMake configuration for HTSEngine
#
cmake_minimum_required(VERSION 2.6)
# set library version
set(HTS_ENGINE_API_VERSION 1.02)
project(HTSEngine)
aux_source_directory(lib libHTSEngine_source)
include_directories(include)
add_library(HTSEngine ${libHTSEngine_source})
set_target_properties(HTSEngine PROPERTIES VERSION ${HTS_ENGINE_API_VERSION})
set_target_properties(HTSEngine PROPERTIES SO_VERSION ${HTS_ENGINE_API_VERSION})
option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
if(BUILD_SHARED_LIBS)
set(LIB_TYPE SHARED)
else()
set(LIB_TYPE STATIC)
endif()
option(EMBEDDED "Turn on compiling for embedded devices" OFF)
if(EMBEDDED)
add_definitions(-DHTS_EMBEDDED)
endif()
option(FESTIVAL "Use memory allocation/free functions of speech tools" OFF)
if(FESTIVAL)
add_definitions(-DFESTIVAL)
endif()
if(NOT MSVC)
install(TARGETS HTSEngine DESTINATION lib)
install(DIRECTORY include DESTINATION include PATTERN "*.h" PATTERN ".svn" EXCLUDE)
endif()
#
# CMake configuration for julius
#
# FIXME: configuration of NetAudio support for libsent
#
cmake_minimum_required(VERSION 2.6)
include(CheckFunctionExists)
include(CheckIncludeFiles)
include(CheckLibraryExists)
# set library version
set(VERSION 4.1.5)
# build configuration
project(julius)
aux_source_directory(libjulius/src libjulius_source)
aux_source_directory(libsent/src/anlz libsent_anlz_source)
aux_source_directory(libsent/src/dfa libsent_dfa_source)
aux_source_directory(libsent/src/hmminfo libsent_hmminfo_source)
aux_source_directory(libsent/src/net libsent_net_source)
aux_source_directory(libsent/src/ngram libsent_ngram_source)
aux_source_directory(libsent/src/phmm libsent_phmm_source)
aux_source_directory(libsent/src/util libsent_util_source)
aux_source_directory(libsent/src/voca libsent_voca_source)
aux_source_directory(libsent/src/wav2mfcc libsent_wav2mfcc_source)
include_directories(libjulius/include libsent/include)
# create a empty file
file(WRITE libjulius/include/julius/config.h "")
file(WRITE libsent/include/sent/config.h "")
#set(JULIUS_PRODUCTNAME "\"juliusLib\"")
#set(JULIUS_VERSION "\"${JULIUS_VERSION}\"")
#set(JULIUS_HOSTINFO "\"\"")
add_definitions(-DJULIUS_PRODUCTNAME="juliusLib"
-DJULIUS_VERSION="${JULIUS_VERSION}"
-DJULIUS_HOSTINFO="")
option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
if(BUILD_SHARED_LIBS)
set(LIB_TYPE SHARED)
else()
set(LIB_TYPE STATIC)
endif()
# libjulius configuration
option(UNIGRAM_FACOTRING "use 1-gram factoring on 1st pass" OFF)
option(BIGRAM_FACOTRING "use 2-gram factoring on 1st pass" OFF)
option(PASS1_IWCD "handle inter-word triphone on 1st pass" OFF)
option(PASS2_STRICT_ICWD "strict IWCD scoring on 2nd pass" OFF)
if(BIGRAM_FACOTRING)
set(UNIGRAM_FACOTRING OFF BOOL)
endif()
option(ALGORITHM_SET_STANDARD "high accuracy, slow speed" OFF)
option(ALGORITHM_SET_FAST "balanced for both speed and accuracy" ON)
if(ALGORITHM_SET_FAST)
set(UNIGRAM_FACOTRING ON BOOL)
set(PASS1_IWCD ON BOOL)
set(PASS2_STRICT_ICWD ON BOOL)
set(GPRUNE_DEFAULT "safe" INTERNAL)
#set(JULIUS_SETUP "\"fast\"")
add_definitions(-DJULIUS_SETUP="fast")
elseif(ALGORITHM_SET_STANDARD)
set(UNIGRAM_FACOTRING ON BOOL)
set(PASS1_IWCD ON BOOL)
set(PASS2_STRICT_ICWD ON BOOL)
set(GPRUNE_DEFAULT "\"beam\"" INTERNAL)
#set(JULIUS_SETUP "\"standard\"")
add_definitions(-DJULIUS_SETUP="standard")
endif()
if(UNIGRAM_FACOTRING)
add_definitions(-DUNIGRAM_FACTORING)
endif()
if(PASS1_IWCD)
add_definitions(-DPASS1_IWCD)
endif()
if(PASS2_STRICT_ICWD)
add_definitions(-DPASS2_STRICT_IWCD)
endif()
if(GPRUNE_DEFAULT STREQUAL "safe")
add_definitions(-DGPRUNE_DEFAULT_SAFE)
#set(GPRUNE_DEFAULT_SAFE ON BOOL)
elseif(GPRUNE_DEFAULT STREQUAL "beam")
add_definitions(-DGPRUNE_DEFAULT_BEAM)
#set(GPRUNE_DEFAULT_BEAM ON BOOL)
endif()
option(LOWMEM "all words share a single root on lexicon tree" OFF)
if(LOWMEM)
add_definitions(-DLOWMEM)
endif()
option(LOWMEM2 "separate hi-freq words from lexicon tree" OFF)
if(LOWMEM2)
add_definitions(-DLOWMEM2)
endif()
option(MONOTREE "monophone lexicon on 1st pass (EXPERIMENTAL)" OFF)
if(MONOTREE)
add_definitions(-DMONOTREE)
endif()
option(SCORE_BEAM "enable score envelope beaming on 2nd pass scan" ON)
if(SCORE_BEAM)
add_definitions(-DSCAN_BEAM)
endif()
option(WPAIR "use word-pair approximation on 1st pass" OFF)
if(WPAIR)
add_definitions(-DWPAIR)
endif()
option(WPAIR_NLIMIT "keep only N-best path with wpair (-nlimit)" OFF)
if(WPAIR_NLIMIT)
add_definitions(-DWPAIR)
add_definitions(-DWPAIR_KEEP_NLIMIT)
endif()
option(WORD_GRAPH "use word graph instead of trellis between passes" OFF)
if(WORD_GRAPH)
add_definitions(-DWORD_GRAPH)
endif()
option(GMM_VAD "GMM-based VAD (EXPERIMENTAL)" OFF)
if(GMM_VAD)
add_definitions(-DGMM_VAD -DBACKEND_VAD)
#set(GMM_VAD ON)
#set(BACKEND_VAD ON)
endif()
option(DECODER_VAD "a new decoder-based VAD by NAIST team" OFF)
if(DECODER_VAD)
add_definitions(-DSPSEGMENT_NAIST -DBACKEND_VAD)
#set(SPSEGMENT_NAIST ON BOOL)
#set(BACKEND_VAD ON BOOL)
endif()
option(POWER_REJECT "post rejection by power" OFF)
if(POWER_REJECT)
add_definitions(-DPOWER_REJECT)
endif()
option(GRAPHOUT_NBEST "word graph output from N-best sentence" OFF)
if(NOT GRAPHOUT_NBEST)
add_definitions(-DGRAPHOUT_DYNAMIC -DGRAPHOUT_SEARCH)
#set(GRAPHOUT_DYNAMIC ON BOOL)
#set(GRAPHOUT_SEARCH ON BOOL)
endif()
option(LMFIX "" ON)
if(LMFIX)
add_definitions(-DLM_FIX_DOUBLE_SCORING)
endif()
option(ENABLE_PLUGIN "plugin support" ON)
if(ENABLE_PLUGIN)
check_library_exists(dl dlopen "" HAVE_DLOPEN)
if(HAVE_DLOPEN)
add_definitions(-DENABLE_PLUGIN)
endif()
endif()
option(ENABLE_THREAD "use thread" ON)
if(ENABLE_THREAD)
include(FindThreads)
set(HAVE_PTHREAD CMAKE_USE_PTHREADS_INIT)
endif()
option(CONFIDENCE_MEASURE "confidence measure computation" ON)
option(CM_NBEST "N-best CM instead of search CM" OFF)
option(CM_MULTIPLE_ALPHA "EXPERIMENTAL: test multi alphas (need much mem)" OFF)
option(CMTHRES "confidence score based pruning on 2nd pass" OFF)
if(CONFIDENCE_MEASURE)
add_definitions(-DCONFIDENCE_MEASURE)
endif()
if(CM_NBEST)
if(CONFIDENCE_MEASURE)
add_definitions(-DCM_BEST)
else()
message(FATAL_ERROR "CM AND JULIUS_CM_NBEST conflicts")
endif()
endif()
if(CM_MULTIPLE_ALPHA)
if(CONFIDENCE_MEASURE)
add_definitions(-DCM_MULTIPLE_ALPHA)
else()
message(FATAL_ERROR "CM AND JULIUS_CM_MULTIPLE_ALPHA conflicts")
endif()
endif()
if(CMTHRES)
if(CONFIDENCE_MEASURE)
if(CM_NBEST)
message(FATAL_ERROR "CMTHRES cannot be used with JULIUS_CM_NBEST")
elseif(CM_MULTIPLE_ALPHA)
message(FATAL_ERROR "CMTHRES cannot be used with JULIUS_CM_MULTIPLE_ALPHA")
else()
add_definitions(-DCM_SEARCH_LIMIT)
set(CM_SEARCH_LIMIT ON)
endif()
else()
message(FATAL_ERROR "CM and JULIUS_CMTHRES conflicts")
endif()
endif()
#configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libjulius/include/julius/config.h.in
# ${CMAKE_CURRENT_SOURCE_DIR}/libjulius/include/julius/config.h)
# libsent configuration
set(libsent_adin_source "libsent/src/adin/adin_file.c"
"libsent/src/adin/adin_tcpip.c"
"libsent/src/adin/ds48to16.c"
"libsent/src/adin/zc-e.c"
"libsent/src/adin/zmean.c")
option(USE_ADD_ARRAY "addlog_array() function" ON)
if(USE_ADD_ARRAY)
add_definitions(-DUSE_ADD_ARRAY)
endif()
option(WORDS_INT "integer instead of unsigned short for word ID to extend vocabulary limit to 2^31=2G words" OFF)
if(WORDS_INT)
add_definitions(-DWORDS_INT)
endif()
option(CLASS_NGRAM "class N-gram support" ON)
if(CLASS_NGRAM)
add_definitions(-DCLASS_NGRAM)
endif()
option(FORK_ADINNET "process forking on adinnet" OFF)
if(FORK_ADINNET)
add_definitions(-DFORK_ADINNET)
endif()
option(MFCC_SINCOS_TABLE "sin/cos table for MFCC calculation" ON)
if(MFCC_SINCOS_TABLE)
add_definitions(-DMFCC_SINCOS_TABLE)
endif()
option(ENABLE_MSD "MSD model support" OFF)
if(ENABLE_MSD)
add_definitions(-DENABLE_MSD)
endif()
option(LINK_ZLIB "link against with zlib" ON)
if(LINK_ZLIB)
find_package(ZLIB)
if(ZLIB_FOUND)
list(APPEND LIBSENT_DEPENDS_INCLUDE ${ZLIB_INCLUDE_DIR})
list(APPEND LIBSENT_DEPENDS_LIBRARY ${ZLIB_LIBRARIES})
set(GZDESC "zlib library")
endif()
endif()
find_program(GZIP_BIN "gzip")
if(GZIP_BIN)
add_definitions(-DZCAT="gzip -d -c")
else()
add_definitions(-DZCAT="")
endif()
if(NOT ZLIB_FOUND)
set(GZDESC "gzip command")
elseif(NOT ZLIB_FOUND AND NOT GZIP_BIN)
set(GZDESC "none")
endif()
set(WAVEFILE_SUPPORT "RAW and WAV only")
option(LINK_SNDFILE "link against with libsndfile" ON)
if(LINK_SNDFILE)
find_path(LIBSNDFILE_INCLUDE sndfile.h)
find_library(LIBSNDFILE_LIBRARY sndfile)
if(LIBSNDFILE_INCLUDE AND LIBSNDFILE_LIBRARY)
list(APPEND LIBSENT_DEPENDS_INCLUDE ${LIBSNDFILE_INCLUDE})
list(APPEND LIBSENT_DEPENDS_LIBRARY ${LIBSNDFILE_LIBRARY})
list(APPEND libsent_adin_source "libsent/src/adin/adin_sndfile.c")
set(WAVEFILE_SUPPORT "various formats by libsndfile ver.1")
add_definitions(-DHAVE_LIBSNDFILE -DHAVE_LIBSNDFILE_VER1)
endif()
endif()
set(ALTYPE "portaudio")
if(ALTYPE STREQUAL "portaudio" OR ALTYPE MATCHES "pa-*")
include(CheckLibraryExists)
find_path(PA_INCLUDE portaudio.h)
find_library(PA_LIBRARY portaudio)
if(PA_INCLUDE AND PA_LIBRARY)
list(APPEND libsent_adin_source "libsent/src/adin/adin_portaudio.c")
list(APPEND LIBSENT_DEPENDS_INCLUDE ${PA_INCLUDE})
list(APPEND LIBSENT_DEPENDS_LIBRARY ${PA_LIBRARY})
set(ALDESC "PortAudio library (external)")
else()
list(APPEND libsent_adin_source "libsent/src/adin/adin_portaudio.c"
"libsent/src/adin/pa/pa_lib.c"
"libsent/src/adin/pa/pa_convert.c"
"libsent/src/adin/pa/pa_trace.c"
"libsent/src/adin/pa/pablio.c"
"libsent/src/adin/pa/ringbuffer.c")
include_directories("libsent/src/adin/pa")
if(ALTYPE STREQUAL "pa-winmm")
find_library(WINMM_LIBRARY "winmm")
list(APPEND libsent_adin_source "libsent/src/adin/pa/pa_win_wmme.c")
list(APPEND LIBSENT_DEPENDS_LIBRARY ${WINMM_LIBRARY})
elseif(ALTYPE STREQUAL "pa-dsound")
find_library(WINMM_LIBRARY "winmm")
find_library(DSOUND_LIBRARY "dsound")
list(APPEND libsent_adin_source "libsent/src/adin/pa/dsound_wrapper.c")
list(APPEND LIBSENT_DEPENDS_LIBRARY ${WINMM_LIBRARY} ${DSOUND_LIBRARY})
elseif(ALTYPE STREQUAL "pa-oss")
list(APPEND libsent_adin_source "libsent/src/adin/pa/pa_unix.c"
"libsent/src/adin/pa/pa_unix_oss.c")
elseif(ALTYPE STREQUAL "pa-solaris")
list(APPEND libsent_adin_source "libsent/src/adin/pa/pa_unix_solaris.c")
endif()
endif()
add_definitions(-DUSE_MIC)
endif()
if(APPLE)
find_library(AUDIO_UNIT_FRAMEWORK "AudioUnit")
find_library(AUDIO_TOOLBOX_FRAMEWORK "AudioToolbox")
find_library(CORE_AUDIO_FRAMEWORK "CoreAudio")
find_library(CORE_SERVICES_FRAMEWORK "CoreServices")
list(APPEND LIBSENT_DEPENDS_LIBRARY ${AUDIO_UNIT_FRAMEWORK}
${AUDIO_TOOLBOX_FRAMEWORK}
${CORE_AUDIO_FRAMEWORK}
${CORE_SERVICES_FRAMEWORK})
endif()
check_include_files(unistd.h HAVE_UNISTD_H)
if(HAVE_UNISTD_H)
add_definitions(-DHAVE_UNISTD_H)
endif()
check_function_exists(strcasecmp HAVE_STRCASECMP)
if(HAVE_STRCASECMP)
add_definitions(-DHAVE_STRCASECMP)
endif()
check_function_exists(strcasecmp HAVE_SLEEP)
if(HAVE_SLEEP)
add_definitions(-DHAVE_SLEEP)
endif()
find_library(SOCKET_LIBRARY socket)
if(SOCKET_LIBRARY)
add_definitions(-DHAVE_LIBSOCKET)
list(APPEND LIBSENT_DEPENDS_LIBRARY ${SOCKET_LIBRARY})
endif()
find_library(ICONV_LIBRARY iconv)
if(ICONV_LIBRARY)
add_definitions(-DHAVE_ICONV)
list(APPEND LIBSENT_DEPENDS_LIBRARY ${ICONV_LIBRARY})
endif()
add_definitions(-DLIBSENT_VERSION="${JULIUS_VERSION}"
-DAUDIO_API_NAME="${ALTYPE}"
-DAUDIO_API_DESC="${ALDESC}"
-DAUDIO_FORMAT_DESC="${WAVEFILE_SUPPORT}"
-DGZIP_READING_DESC="${GZDESC}")
add_library(julius ${libjulius_source} ${libsent_anlz_source}
${libsent_dfa_source} ${libsent_hmminfo_source}
${libsent_net_source} ${libsent_ngram_source}
${libsent_phmm_source} ${libsent_util_source}
${libsent_voca_source} ${libsent_wav2mfcc_source}
${libsent_adin_source})
target_link_libraries(julius ${LIBSENT_DEPENDS_LIBRARY})
include_directories(julius ${LIBSENT_DEPENDS_INCLUDE})
set_target_properties(julius PROPERTIES VERSION ${VERSION})
set_target_properties(julius PROPERTIES SO_VERSION ${VERSION})
if(NOT MSVC)
install(TARGETS julius DESTINATION lib)
install(DIRECTORY libjulius/include/ libsent/include
DESTINATION include
PATTERN "*.h"
PATTERN ".svn" EXCLUDE
PATTERN "config.h" EXCLUDE)
endif()
#
# CMake configuration for OpenJTalk
#
cmake_minimum_required(VERSION 2.6)
include(CheckIncludeFiles)
include(CheckFunctionExists)
include(CheckLibraryExists)
include(CheckTypeSize)
# set library version
set(OPEN_JTALK_VERSION 1.02)
file(WRITE "mecab/src/config.h")
# build configuration
project(OpenJTalk)
aux_source_directory(jpcommon libjpcommon_source)
aux_source_directory(mecab/src libmecab_source)
aux_source_directory(mecab2njd libmecab2njd_source)
aux_source_directory(njd libnjd_source)
aux_source_directory(njd2jpcommon libnjd2jpcommon_source)
aux_source_directory(njd_set_accent_phrase libnjd_set_accent_phrase_source)
aux_source_directory(njd_set_accent_type libnjd_set_accent_type_source)
aux_source_directory(njd_set_digit libnjd_set_digit_source)
aux_source_directory(njd_set_long_vowel libnjd_set_long_vowel_source)
aux_source_directory(njd_set_pronunciation libnjd_set_pronunciation_source)
aux_source_directory(njd_set_unvoiced_vowel libnjd_set_unvoiced_vowel_source)
aux_source_directory(text2mecab libtext2mecab_source)
include_directories(jpcommon mecab/src mecab2njd njd njd2jpcommon njd_set_accent_phrase
njd_set_accent_type njd_set_digit njd_set_long_vowel
njd_set_pronunciation njd_set_unvoiced_vowel text2mecab)
add_library(OpenJTalk ${libjpcommon_source} ${libmecab_source} ${libmecab2njd_source}
${libnjd_source} ${libnjd2jpcommon_source}
${libnjd_set_accent_phrase_source} ${libnjd_set_accent_type_source}
${libnjd_set_digit_source} ${libnjd_set_long_vowel_source}
${libnjd_set_pronunciation_source} ${libnjd_set_unvoiced_vowel_source}
${libtext2mecab_source})
set_target_properties(OpenJTalk PROPERTIES VERSION ${OPEN_JTALK_VERSION})
set_target_properties(OpenJTalk PROPERTIES SO_VERSION ${OPEN_JTALK_VERSION})
# generate mecab/config.h
check_include_files(ctype.h HAVE_CTYPE_H)
if(HAVE_CTYPE_H)
add_definitions(-DHAVE_CTYPE_H)
endif()
check_include_files(dirent.h HAVE_DIRENT_H)
if(HAVE_DIRENT_H)
add_definitions(-DHAVE_DIRENT_H)
endif()
check_include_files(fcntl.h HAVE_FCNTL_H)
if(HAVE_FCNTL_H)
add_definitions(-DHAVE_FCNTL_H)
endif()
check_include_files(inttypes.h HAVE_INTTYPES_H)
if(HAVE_INTTYPES_H)
add_definitions(-DHAVE_INTTYPES_H)
endif()
check_include_files(io.h HAVE_IO_H)
if(HAVE_IO_H)
add_definitions(-DHAVE_IO_H)
endif()
check_include_files(memory.h HAVE_MEMORY_H)
if(HAVE_MEMORY_H)
add_definitions(-DHAVE_MEMORY_H)
endif()
check_include_files(setjmp.h HAVE_SETJMP_H)
if(HAVE_SETJMP_H)
add_definitions(-DHAVE_SETJMP_H)
endif()
check_include_files(stdint.h HAVE_STDINT_H)
if(HAVE_STDINT_H)
add_definitions(-DHAVE_STDINT_H)
endif()
check_include_files(stdlib.h HAVE_STDLIB_H)
if(HAVE_STDLIB_H)
add_definitions(-DHAVE_STDLIB_H)
endif()
check_include_files(strings.h HAVE_STRINGS_H)
if(HAVE_STRINGS_H)
add_definitions(-DHAVE_STRINGS_H)
endif()
check_include_files(string.h HAVE_STRING_H)
if(HAVE_STRING_H)
add_definitions(-DHAVE_STRING_H)
endif()
check_include_files(sys/mman.h HAVE_SYS_MMAN_H)
if(HAVE_SYS_MMAN_H)
add_definitions(-DHAVE_SYS_MMAN_H)
endif()
check_include_files(sys/stat.h HAVE_SYS_STAT_H)
if(HAVE_SYS_STAT_H)
add_definitions(-DHAVE_SYS_STAT_H)
endif()
check_include_files(sys/times.h HAVE_SYS_TIMES_H)
if(HAVE_SYS_TIMES_H)
add_definitions(-DHAVE_SYS_TIMES_H)
endif()
check_include_files(sys/types.h HAVE_SYS_TYPES_H)
if(HAVE_SYS_TYPES_H)
add_definitions(-DHAVE_SYS_TYPES_H)
endif()
check_include_files(unistd.h HAVE_UNISTD_H)
if(HAVE_UNISTD_H)
add_definitions(-DHAVE_UNISTD_H)
endif()
check_function_exists(getenv HAVE_GETENV)
if(HAVE_GETENV)
add_definitions(-DHAVE_GETENV)
endif()
check_function_exists(getpagesize HAVE_GETPAGESIZE)
if(HAVE_GETPAGESIZE)
add_definitions(-DHAVE_GETPAGESIZE)
endif()
check_function_exists(mmap HAVE_MMAP)
if(HAVE_MMAP)
add_definitions(-DHAVE_MMAP)
endif()
check_function_exists(opendir HAVE_OPENDIR)
if(HAVE_OPENDIR)
add_definitions(-DHAVE_OPENDIR)
endif()
check_function_exists(setjmp HAVE_SETJMP)
if(HAVE_SETJMP)
add_definitions(-DHAVE_SETJMP)
endif()
check_function_exists(sqrt HAVE_SQRT)
if(HAVE_SQRT)
add_definitions(-DHAVE_SQRT)
endif()
check_function_exists(strstr HAVE_STRSTR)
if(HAVE_STRSTR)
add_definitions(-DHAVE_STRSTR)
endif()
find_library(HAVE_ICONV "iconv")
if(HAVE_ICONV)
add_definitions(-DICONV_CONST)
endif()
find_library(HAVE_LIBM "m")
if(HAVE_LIBM)
add_definitions(-DHAVE_LIBM)
endif()
add_definitions(-DHAVE_CONFIG_H
-DDIC_VERSION=102
-DMECAB_DEFAULT_RC="dummy"
-DMECAB_WITHOUT_SHARE_DIC
-DPACKAGE="open_jtalk"
-DVERSION="${OPEN_JTALK_VERSION}")
# whether build as a shared library or not
option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
if(BUILD_SHARED_LIBS)
set(LIB_TYPE SHARED)
else()
set(LIB_TYPE STATIC)
endif()
# find HTSEngine
find_path(HTS_ENGINE_INCLUDE_DIR HTS_engine.h)
find_library(HTS_ENGINE_LIB HTSEngine)
if(HTS_ENGINE_INCLUDE_DIR AND HTS_ENGINE_LIB)
target_link_libraries(OpenJTalk ${HTS_ENGINE_LIB})
include_directories(OpenJTalk ${HTS_ENGINE_INCLUDE_DIR})
else()
message(FATAL_ERROR "Required HTSEngine not found")
endif()
# configuration for charset
#option(CHARSET "Encoding set for mecab" "eucjp")
set(CHARSET "sjis")
if(${CHARSET} STREQUAL "sjis")
add_definitions(-DCHARSET_SHIFT_JIS -DMECAB_CHARSET=sjis)
foreach(flag CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
set(${flag} "${${flag}} -finput-charset=cp932 -fexec-charset=cp932")
endforeach()
elseif(${CHARSET} STREQUAL "eucjp")
add_definitions(-DCHARSET_EUC_JP -DMECAB_CHARSET=euc-jp)
elseif(${CHARSET} STREQUAL "utf8")
add_definitions(-DCHARSET_UTF_8 -DMECAB_CHARSET=utf-8 -DMECAB_UTF8_USE_ONLY)
foreach(flag CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
set(${flag} "${${flag}} -finput-charset=UTF-8 -fexec-charset=UTF-8")
endforeach()
else()
message(FATAL_ERROR "Encoding ${CHARSET} not recognized. You can set sjis/eucjp/utf8")
endif()
# installation
if(NOT MSVC)
install(TARGETS OpenJTalk DESTINATION lib)
install(FILES jpcommon/jpcommon.h mecab/src/mecab.h mecab2njd/mecab2njd.h njd/njd.h njd2jpcommon/njd2jpcommon.h
njd_set_accent_phrase/njd_set_accent_phrase.h njd_set_accent_type/njd_set_accent_type.h
njd_set_digit/njd_set_digit.h njd_set_long_vowel/njd_set_long_vowel.h njd_set_pronunciation/njd_set_pronunciation.h
njd_set_unvoiced_vowel/njd_set_unvoiced_vowel.h text2mecab/text2mecab.h
DESTINATION include/OpenJTalk)
endif()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment