kenlm icon indicating copy to clipboard operation
kenlm copied to clipboard

Best way to add kenlm to your own C++ project using Cmake?

Open digital10111 opened this issue 6 years ago • 2 comments

digital10111 avatar Mar 30 '19 06:03 digital10111

https://cmake.org/cmake/help/latest/module/ExternalProject.html

kpu avatar Apr 01 '19 09:04 kpu

add_subdirectory can be used for build with MSVC 17 x64 compiler, C++11.

# CMakeLists.txt file
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(test)

# set(Boost_DEBUG 1)         # for build debug
set(Boost_LIB_PREFIX lib)     # check in ur boost root dir
set(Boost_COMPILER  "-vc") #depends on ur compiler for boost install

add_subdirectory("path/to/kenlm")
add_library(lib_name STATIC ${sources})
target_include_directories(lib_name ${includes} ${Boost_INCLUDE_DIRS} path/to/kenlm)
target_link_libraries(lib_name kenlm ${other_libs})

add_executable(test ${src})
target_link_libraries(test lib_name)
set_property(TARGET test PROPERTY CXX_STANDARD 11)

Before building you need to install boost. kenlm require Eigen3, ZLIB, BZip2, LibLZMA, but for my task i can build app without these dependencies (although i have a lot of errors on kenlm building, but my app is builded)

And in ur project path:

mkdir build
cd build
cmake -G "Visual Studio 15 2017" -A x64 ..
cmake --build . --config Release

iamilyasedunov avatar Oct 27 '20 16:10 iamilyasedunov