Skip to content

Commit

Permalink
Refactor cmake
Browse files Browse the repository at this point in the history
Removing optionality for interpolation; it's now triggered by eigen
Absorb common into main kenlm library
Library files, also reduces required version
  • Loading branch information
kpu committed Feb 22, 2016
1 parent 1837229 commit a003941
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 152 deletions.
15 changes: 1 addition & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
cmake_minimum_required(VERSION 2.8.8)
#
# The KenLM cmake files make use of add_library(... OBJECTS ...)
#
# This syntax allows grouping of source files when compiling
# (effectively creating "fake" libraries based on source subdirs).
#
# This syntax was only added in cmake version 2.8.8
#
# see http://www.cmake.org/Wiki/CMake/Tutorials/Object_Library


cmake_minimum_required(VERSION 2.6)
# This CMake file was created by Lane Schwartz <[email protected]>


Expand Down Expand Up @@ -49,8 +38,6 @@ include_directories(
${Boost_INCLUDE_DIRS}
)

option(BUILD_INTERPOLATE "Build language model interpolation code" OFF)

# Process subdirectories
add_subdirectory(util)
add_subdirectory(lm)
Expand Down
35 changes: 9 additions & 26 deletions lm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
cmake_minimum_required(VERSION 2.8.8)
#
# The KenLM cmake files make use of add_library(... OBJECTS ...)
#
# This syntax allows grouping of source files when compiling
# (effectively creating "fake" libraries based on source subdirs).
#
# This syntax was only added in cmake version 2.8.8
#
# see http://www.cmake.org/Wiki/CMake/Tutorials/Object_Library


# This CMake file was created by Lane Schwartz <[email protected]>


Expand All @@ -24,7 +12,7 @@ add_definitions(-DKENLM_MAX_ORDER=${KENLM_MAX_ORDER})
# that should be included in the kenlm library,
# (this excludes any unit test files)
# you should add them to the following list:
set(KENLM_SOURCE
set(KENLM_LM_SOURCE
bhiksha.cc
binary_format.cc
config.cc
Expand All @@ -48,11 +36,12 @@ set(KENLM_SOURCE
# Given add_library(foo OBJECT ${my_foo_sources}),
# refer to these objects as $<TARGET_OBJECTS:foo>
#
add_library(kenlm OBJECT ${KENLM_SOURCE})
add_subdirectory(common)

add_library(kenlm ${KENLM_LM_SOURCE} ${KENLM_LM_COMMON_SOURCE})

# This directory has children that need to be processed
add_subdirectory(builder)
add_subdirectory(common)
add_subdirectory(filter)
add_subdirectory(interpolate)

Expand All @@ -63,27 +52,21 @@ set(EXE_LIST
build_binary
)

AddExes(EXES ${EXE_LIST}
DEPENDS $<TARGET_OBJECTS:kenlm> $<TARGET_OBJECTS:kenlm_util>
LIBRARIES ${Boost_LIBRARIES} pthread)
set(LM_LIBS kenlm kenlm_util ${Boost_LIBRARIES} pthread)

# Conditionally build the interpolation code
if(BUILD_INTERPOLATE)
add_subdirectory(interpolate)
endif()
AddExes(EXES ${EXE_LIST}
LIBRARIES ${LM_LIBS})

if(BUILD_TESTING)

set(KENLM_BOOST_TESTS_LIST left_test partial_test)
AddTests(TESTS ${KENLM_BOOST_TESTS_LIST}
DEPENDS $<TARGET_OBJECTS:kenlm> $<TARGET_OBJECTS:kenlm_util>
LIBRARIES ${Boost_LIBRARIES} pthread
LIBRARIES ${LM_LIBS}
TEST_ARGS ${CMAKE_CURRENT_SOURCE_DIR}/test.arpa)

# model_test requires an extra command line parameter
KenLMAddTest(TEST model_test
DEPENDS $<TARGET_OBJECTS:kenlm> $<TARGET_OBJECTS:kenlm_util>
LIBRARIES ${Boost_LIBRARIES} pthread
LIBRARIES ${LM_LIBS}
TEST_ARGS ${CMAKE_CURRENT_SOURCE_DIR}/test.arpa
${CMAKE_CURRENT_SOURCE_DIR}/test_nounk.arpa)
endif()
24 changes: 4 additions & 20 deletions lm/builder/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
cmake_minimum_required(VERSION 2.8.8)
#
# The KenLM cmake files make use of add_library(... OBJECTS ...)
#
# This syntax allows grouping of source files when compiling
# (effectively creating "fake" libraries based on source subdirs).
#
# This syntax was only added in cmake version 2.8.8
#
# see http://www.cmake.org/Wiki/CMake/Tutorials/Object_Library


# This CMake file was created by Lane Schwartz <[email protected]>

# Explicitly list the source files for this subdirectory
Expand Down Expand Up @@ -38,14 +26,14 @@ set(KENLM_BUILDER_SOURCE
# Given add_library(foo OBJECT ${my_foo_sources}),
# refer to these objects as $<TARGET_OBJECTS:foo>
#
add_library(kenlm_builder OBJECT ${KENLM_BUILDER_SOURCE})
add_library(kenlm_builder ${KENLM_BUILDER_SOURCE})


# Compile the executable, linking against the requisite dependent object files
add_executable(lmplz lmplz_main.cc $<TARGET_OBJECTS:kenlm> $<TARGET_OBJECTS:kenlm_common> $<TARGET_OBJECTS:kenlm_builder> $<TARGET_OBJECTS:kenlm_util>)
add_executable(lmplz lmplz_main.cc)

# Link the executable against boost
target_link_libraries(lmplz ${Boost_LIBRARIES} pthread)
target_link_libraries(lmplz kenlm_builder kenlm kenlm_util ${Boost_LIBRARIES} pthread)

# Group executables together
set_target_properties(lmplz PROPERTIES FOLDER executables)
Expand All @@ -59,9 +47,5 @@ if(BUILD_TESTING)
)

AddTests(TESTS ${KENLM_BOOST_TESTS_LIST}
DEPENDS $<TARGET_OBJECTS:kenlm>
$<TARGET_OBJECTS:kenlm_common>
$<TARGET_OBJECTS:kenlm_util>
$<TARGET_OBJECTS:kenlm_builder>
LIBRARIES ${Boost_LIBRARIES} pthread)
LIBRARIES kenlm_builder kenlm kenlm_util ${Boost_LIBRARIES} pthread)
endif()
25 changes: 2 additions & 23 deletions lm/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
cmake_minimum_required(VERSION 2.8.8)
#
# The KenLM cmake files make use of add_library(... OBJECTS ...)
#
# This syntax allows grouping of source files when compiling
# (effectively creating "fake" libraries based on source subdirs).
#
# This syntax was only added in cmake version 2.8.8
#
# see http://www.cmake.org/Wiki/CMake/Tutorials/Object_Library


# This CMake file was created by Lane Schwartz <[email protected]>

# Explicitly list the source files for this subdirectory
Expand All @@ -23,18 +11,9 @@ cmake_minimum_required(VERSION 2.8.8)
# in case this variable is referenced by CMake files in the parent directory,
# we prefix all files with ${CMAKE_CURRENT_SOURCE_DIR}.
#
set(KENLM_COMMON_SOURCE
set(KENLM_LM_COMMON_SOURCE
${CMAKE_CURRENT_SOURCE_DIR}/model_buffer.cc
${CMAKE_CURRENT_SOURCE_DIR}/print.cc
${CMAKE_CURRENT_SOURCE_DIR}/renumber.cc
${CMAKE_CURRENT_SOURCE_DIR}/size_option.cc
)


# Group these objects together for later use.
#
# Given add_library(foo OBJECT ${my_foo_sources}),
# refer to these objects as $<TARGET_OBJECTS:foo>
#
add_library(kenlm_common OBJECT ${KENLM_COMMON_SOURCE})

PARENT_SCOPE)
18 changes: 3 additions & 15 deletions lm/filter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
cmake_minimum_required(VERSION 2.8.8)
#
# The KenLM cmake files make use of add_library(... OBJECTS ...)
#
# This syntax allows grouping of source files when compiling
# (effectively creating "fake" libraries based on source subdirs).
#
# This syntax was only added in cmake version 2.8.8
#
# see http://www.cmake.org/Wiki/CMake/Tutorials/Object_Library


# This CMake file was created by Lane Schwartz <[email protected]>

# Explicitly list the source files for this subdirectory
Expand All @@ -35,7 +23,7 @@ set(KENLM_FILTER_SOURCE
# Given add_library(foo OBJECT ${my_foo_sources}),
# refer to these objects as $<TARGET_OBJECTS:foo>
#
add_library(kenlm_filter OBJECT ${KENLM_FILTER_SOURCE})
add_library(kenlm_filter ${KENLM_FILTER_SOURCE})


# Explicitly list the executable files to be compiled
Expand All @@ -49,10 +37,10 @@ set(EXE_LIST
foreach(exe ${EXE_LIST})

# Compile the executable, linking against the requisite dependent object files
add_executable(${exe} ${exe}_main.cc $<TARGET_OBJECTS:kenlm> $<TARGET_OBJECTS:kenlm_filter> $<TARGET_OBJECTS:kenlm_util>)
add_executable(${exe} ${exe}_main.cc)

# Link the executable against boost
target_link_libraries(${exe} ${Boost_LIBRARIES} pthread)
target_link_libraries(${exe} kenlm_filter kenlm kenlm_util ${Boost_LIBRARIES} pthread)

# Group executables together
set_target_properties(${exe} PROPERTIES FOLDER executables)
Expand Down
17 changes: 6 additions & 11 deletions lm/interpolate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,17 @@ if(EIGEN3_FOUND)
tune_weights.cc
universal_vocab.cc)

add_library(kenlm_interpolate OBJECT ${KENLM_INTERPOLATE_SOURCE})
add_library(kenlm_interpolate ${KENLM_INTERPOLATE_SOURCE})

set(KENLM_INTERPOLATE_EXES
interpolate
streaming_example)

set(KENLM_INTERPOLATE_DEPENDS
$<TARGET_OBJECTS:kenlm>
$<TARGET_OBJECTS:kenlm_util>
$<TARGET_OBJECTS:kenlm_common>
$<TARGET_OBJECTS:kenlm_interpolate>)
set(KENLM_INTERPOLATE_LIBS
kenlm_interpolate kenlm kenlm_util ${Boost_LIBRARIES} pthread)

AddExes(EXES ${KENLM_INTERPOLATE_EXES}
DEPENDS ${KENLM_INTERPOLATE_DEPENDS}
LIBRARIES ${Boost_LIBRARIES} pthread)
LIBRARIES ${KENLM_INTERPOLATE_LIBS})

if(BUILD_TESTING)
set(KENLM_INTERPOLATE_TESTS
Expand All @@ -42,13 +38,12 @@ if(EIGEN3_FOUND)
tune_derivatives_test)

AddTests(TESTS ${KENLM_INTERPOLATE_TESTS}
DEPENDS ${KENLM_INTERPOLATE_DEPENDS}
LIBRARIES ${Boost_LIBRARIES} pthread)
LIBRARIES ${KENLM_INTERPOLATE_LIBS} pthread)

# tune_instances_test needs an extra command line parameter
KenLMAddTest(TEST tune_instances_test
DEPENDS ${KENLM_INTERPOLATE_DEPENDS}
LIBRARIES ${Boost_LIBRARIES} pthread
LIBRARIES ${KENLM_INTERPOLATE_LIBS}
TEST_ARGS
${CMAKE_CURRENT_SOURCE_DIR}/tune_instances_data/toy0.1)
endif()
Expand Down
20 changes: 3 additions & 17 deletions util/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
cmake_minimum_required(VERSION 2.8.8)
#
# The KenLM cmake files make use of add_library(... OBJECTS ...)
#
# This syntax allows grouping of source files when compiling
# (effectively creating "fake" libraries based on source subdirs).
#
# This syntax was only added in cmake version 2.8.8
#
# see http://www.cmake.org/Wiki/CMake/Tutorials/Object_Library


# This CMake file was created by Lane Schwartz <[email protected]>


Expand Down Expand Up @@ -52,7 +40,7 @@ add_subdirectory(stream)
# Given add_library(foo OBJECT ${my_foo_sources}),
# refer to these objects as $<TARGET_OBJECTS:foo>
#
add_library(kenlm_util OBJECT ${KENLM_UTIL_DOUBLECONVERSION_SOURCE} ${KENLM_UTIL_STREAM_SOURCE} ${KENLM_UTIL_SOURCE})
add_library(kenlm_util ${KENLM_UTIL_DOUBLECONVERSION_SOURCE} ${KENLM_UTIL_STREAM_SOURCE} ${KENLM_UTIL_SOURCE})



Expand All @@ -71,12 +59,10 @@ if(BUILD_TESTING)
)

AddTests(TESTS ${KENLM_BOOST_TESTS_LIST}
DEPENDS $<TARGET_OBJECTS:kenlm_util>
LIBRARIES ${Boost_LIBRARIES} pthread)
LIBRARIES kenlm_util ${Boost_LIBRARIES} pthread)

# file_piece_test requires an extra command line parameter
KenLMAddTest(TEST file_piece_test
DEPENDS $<TARGET_OBJECTS:kenlm_util>
LIBRARIES ${Boost_LIBRARIES} pthread
LIBRARIES kenlm_util ${Boost_LIBRARIES} pthread
TEST_ARGS ${CMAKE_CURRENT_SOURCE_DIR}/file_piece.cc)
endif()
12 changes: 0 additions & 12 deletions util/double-conversion/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
cmake_minimum_required(VERSION 2.8.8)
#
# The KenLM cmake files make use of add_library(... OBJECTS ...)
#
# This syntax allows grouping of source files when compiling
# (effectively creating "fake" libraries based on source subdirs).
#
# This syntax was only added in cmake version 2.8.8
#
# see http://www.cmake.org/Wiki/CMake/Tutorials/Object_Library


# This CMake file was created by Lane Schwartz <[email protected]>

# Explicitly list the source files for this subdirectory
Expand Down
15 changes: 1 addition & 14 deletions util/stream/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
cmake_minimum_required(VERSION 2.8.8)
#
# The KenLM cmake files make use of add_library(... OBJECTS ...)
#
# This syntax allows grouping of source files when compiling
# (effectively creating "fake" libraries based on source subdirs).
#
# This syntax was only added in cmake version 2.8.8
#
# see http://www.cmake.org/Wiki/CMake/Tutorials/Object_Library


# This CMake file was created by Lane Schwartz <[email protected]>

# Explicitly list the source files for this subdirectory
Expand Down Expand Up @@ -46,6 +34,5 @@ if(BUILD_TESTING)
)

AddTests(TESTS ${KENLM_BOOST_TESTS_LIST}
DEPENDS $<TARGET_OBJECTS:kenlm_util>
LIBRARIES ${Boost_LIBRARIES} pthread)
LIBRARIES kenlm_util ${Boost_LIBRARIES} pthread)
endif()

0 comments on commit a003941

Please sign in to comment.