From 95183b5760d7f168ae093ae8f9b29740628a278f Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Tue, 3 Mar 2015 01:14:07 -0500 Subject: migration to cmake --- klm/lm/CMakeLists.txt | 129 ++++++++++++++++++++++++++++++ klm/lm/Makefile.am | 63 --------------- klm/lm/builder/CMakeLists.txt | 31 +++++++ klm/lm/builder/Makefile.am | 34 -------- klm/search/CMakeLists.txt | 22 +++++ klm/search/Makefile.am | 22 ----- klm/util/CMakeLists.txt | 53 ++++++++++++ klm/util/Makefile.am | 66 --------------- klm/util/double-conversion/CMakeLists.txt | 24 ++++++ klm/util/double-conversion/Makefile.am | 23 ------ klm/util/stream/CMakeLists.txt | 20 +++++ klm/util/stream/Makefile.am | 21 ----- 12 files changed, 279 insertions(+), 229 deletions(-) create mode 100644 klm/lm/CMakeLists.txt delete mode 100644 klm/lm/Makefile.am create mode 100644 klm/lm/builder/CMakeLists.txt delete mode 100644 klm/lm/builder/Makefile.am create mode 100644 klm/search/CMakeLists.txt delete mode 100644 klm/search/Makefile.am create mode 100644 klm/util/CMakeLists.txt delete mode 100644 klm/util/Makefile.am create mode 100644 klm/util/double-conversion/CMakeLists.txt delete mode 100644 klm/util/double-conversion/Makefile.am create mode 100644 klm/util/stream/CMakeLists.txt delete mode 100644 klm/util/stream/Makefile.am (limited to 'klm') diff --git a/klm/lm/CMakeLists.txt b/klm/lm/CMakeLists.txt new file mode 100644 index 00000000..5814b623 --- /dev/null +++ b/klm/lm/CMakeLists.txt @@ -0,0 +1,129 @@ +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..) + +set(build_binary_SRCS build_binary_main.cc) +add_executable(build_binary ${build_binary_SRCS}) +target_link_libraries(build_binary klm klm_util klm_util_double z) + + +set(ngram_query_SRCS query_main.cc) +add_executable(ngram_query ${ngram_query_SRCS}) +target_link_libraries(ngram_query klm klm_util klm_util_double z) + +set(klm_STAT_SRCS + bhiksha.hh + binary_format.hh + blank.hh + config.hh + enumerate_vocab.hh + facade.hh + left.hh + lm_exception.hh + max_order.hh + model.hh + model_type.hh + ngram_query.hh + partial.hh + quantize.hh + read_arpa.hh + return.hh + search_hashed.hh + search_trie.hh + sizes.hh + state.hh + trie.hh + trie_sort.hh + value.hh + value_build.hh + virtual_interface.hh + vocab.hh + weights.hh + word_index.hh + bhiksha.cc + binary_format.cc + config.cc + lm_exception.cc + quantize.cc + model.cc + read_arpa.cc + search_hashed.cc + search_trie.cc + sizes.cc + trie.cc + trie_sort.cc + value_build.cc + virtual_interface.cc + vocab.cc) + +add_library(klm STATIC ${klm_STAT_SRCS}) + + +########### install files ############### + + + + +#original Makefile.am contents follow: + +#bin_PROGRAMS = build_binary ngram_query +# +#build_binary_SOURCES = build_binary_main.cc +#build_binary_LDADD = libklm.a ../util/libklm_util.a ../util/double-conversion/libklm_util_double.a -lz +# +#ngram_query_SOURCES = query_main.cc +#ngram_query_LDADD = libklm.a ../util/libklm_util.a ../util/double-conversion/libklm_util_double.a -lz +# +##noinst_PROGRAMS = \ +## ngram_test +##TESTS = ngram_test +##ngram_test_SOURCES = ngram_test.cc +##ngram_test_LDADD = ../util/libklm_util.a +# +#noinst_LIBRARIES = libklm.a +# +#libklm_a_SOURCES = \ +# bhiksha.hh \ +# binary_format.hh \ +# blank.hh \ +# config.hh \ +# enumerate_vocab.hh \ +# facade.hh \ +# left.hh \ +# lm_exception.hh \ +# max_order.hh \ +# model.hh \ +# model_type.hh \ +# ngram_query.hh \ +# partial.hh \ +# quantize.hh \ +# read_arpa.hh \ +# return.hh \ +# search_hashed.hh \ +# search_trie.hh \ +# sizes.hh \ +# state.hh \ +# trie.hh \ +# trie_sort.hh \ +# value.hh \ +# value_build.hh \ +# virtual_interface.hh \ +# vocab.hh \ +# weights.hh \ +# word_index.hh \ +# bhiksha.cc \ +# binary_format.cc \ +# config.cc \ +# lm_exception.cc \ +# quantize.cc \ +# model.cc \ +# read_arpa.cc \ +# search_hashed.cc \ +# search_trie.cc \ +# sizes.cc \ +# trie.cc \ +# trie_sort.cc \ +# value_build.cc \ +# virtual_interface.cc \ +# vocab.cc +# +#AM_CPPFLAGS = -W -Wall -Wno-sign-compare -I$(top_srcdir)/klm +# diff --git a/klm/lm/Makefile.am b/klm/lm/Makefile.am deleted file mode 100644 index 48b0ba34..00000000 --- a/klm/lm/Makefile.am +++ /dev/null @@ -1,63 +0,0 @@ -bin_PROGRAMS = build_binary ngram_query - -build_binary_SOURCES = build_binary_main.cc -build_binary_LDADD = libklm.a ../util/libklm_util.a ../util/double-conversion/libklm_util_double.a -lz - -ngram_query_SOURCES = query_main.cc -ngram_query_LDADD = libklm.a ../util/libklm_util.a ../util/double-conversion/libklm_util_double.a -lz - -#noinst_PROGRAMS = \ -# ngram_test -#TESTS = ngram_test -#ngram_test_SOURCES = ngram_test.cc -#ngram_test_LDADD = ../util/libklm_util.a - -noinst_LIBRARIES = libklm.a - -libklm_a_SOURCES = \ - bhiksha.hh \ - binary_format.hh \ - blank.hh \ - config.hh \ - enumerate_vocab.hh \ - facade.hh \ - left.hh \ - lm_exception.hh \ - max_order.hh \ - model.hh \ - model_type.hh \ - ngram_query.hh \ - partial.hh \ - quantize.hh \ - read_arpa.hh \ - return.hh \ - search_hashed.hh \ - search_trie.hh \ - sizes.hh \ - state.hh \ - trie.hh \ - trie_sort.hh \ - value.hh \ - value_build.hh \ - virtual_interface.hh \ - vocab.hh \ - weights.hh \ - word_index.hh \ - bhiksha.cc \ - binary_format.cc \ - config.cc \ - lm_exception.cc \ - quantize.cc \ - model.cc \ - read_arpa.cc \ - search_hashed.cc \ - search_trie.cc \ - sizes.cc \ - trie.cc \ - trie_sort.cc \ - value_build.cc \ - virtual_interface.cc \ - vocab.cc - -AM_CPPFLAGS = -W -Wall -Wno-sign-compare -I$(top_srcdir)/klm - diff --git a/klm/lm/builder/CMakeLists.txt b/klm/lm/builder/CMakeLists.txt new file mode 100644 index 00000000..5fb1b2d2 --- /dev/null +++ b/klm/lm/builder/CMakeLists.txt @@ -0,0 +1,31 @@ +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../..) + +set(lmplz_SRCS + lmplz_main.cc + adjust_counts.cc + adjust_counts.hh + corpus_count.cc + corpus_count.hh + discount.hh + hash_gamma.hh + header_info.hh + initial_probabilities.cc + initial_probabilities.hh + interpolate.cc + interpolate.hh + joint_order.hh + multi_stream.hh + ngram.hh + ngram_stream.hh + pipeline.cc + pipeline.hh + print.cc + print.hh + sort.hh) + +add_executable(lmplz ${lmplz_SRCS}) +target_link_libraries(lmplz klm klm_util_double klm_util_stream klm_util ${Boost_LIBRARIES}) + +set(dump_counts_SRCS print.cc dump_counts_main.cc) +add_executable(dump_counts ${dump_counts_SRCS}) +target_link_libraries(dump_counts klm klm_util_double klm_util_stream klm_util ${Boost_LIBRARIES}) diff --git a/klm/lm/builder/Makefile.am b/klm/lm/builder/Makefile.am deleted file mode 100644 index bb15ff04..00000000 --- a/klm/lm/builder/Makefile.am +++ /dev/null @@ -1,34 +0,0 @@ -bin_PROGRAMS = lmplz dump_counts - -dump_counts_SOURCES = \ - print.cc \ - dump_counts_main.cc - -lmplz_SOURCES = \ - lmplz_main.cc \ - adjust_counts.cc \ - adjust_counts.hh \ - corpus_count.cc \ - corpus_count.hh \ - discount.hh \ - hash_gamma.hh \ - header_info.hh \ - initial_probabilities.cc \ - initial_probabilities.hh \ - interpolate.cc \ - interpolate.hh \ - joint_order.hh \ - multi_stream.hh \ - ngram.hh \ - ngram_stream.hh \ - pipeline.cc \ - pipeline.hh \ - print.cc \ - print.hh \ - sort.hh - -dump_counts_LDADD = ../libklm.a ../../util/double-conversion/libklm_util_double.a ../../util/stream/libklm_util_stream.a ../../util/libklm_util.a $(BOOST_THREAD_LIBS) -lmplz_LDADD = ../libklm.a ../../util/double-conversion/libklm_util_double.a ../../util/stream/libklm_util_stream.a ../../util/libklm_util.a $(BOOST_THREAD_LIBS) - -AM_CPPFLAGS = -W -Wall -I$(top_srcdir)/klm - diff --git a/klm/search/CMakeLists.txt b/klm/search/CMakeLists.txt new file mode 100644 index 00000000..af352499 --- /dev/null +++ b/klm/search/CMakeLists.txt @@ -0,0 +1,22 @@ +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..) + +set(ksearch_STAT_SRCS + applied.hh + config.hh + context.hh + dedupe.hh + edge.hh + edge_generator.cc + edge_generator.hh + header.hh + nbest.cc + nbest.hh + rule.cc + rule.hh + types.hh + vertex.cc + vertex.hh + vertex_generator.hh) + +add_library(ksearch STATIC ${ksearch_STAT_SRCS}) + diff --git a/klm/search/Makefile.am b/klm/search/Makefile.am deleted file mode 100644 index b7f01c24..00000000 --- a/klm/search/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -noinst_LIBRARIES = libksearch.a - -libksearch_a_SOURCES = \ - applied.hh \ - config.hh \ - context.hh \ - dedupe.hh \ - edge.hh \ - edge_generator.cc \ - edge_generator.hh \ - header.hh \ - nbest.cc \ - nbest.hh \ - rule.cc \ - rule.hh \ - types.hh \ - vertex.cc \ - vertex.hh \ - vertex_generator.hh - -AM_CPPFLAGS = -W -Wall -Wno-sign-compare -I.. - diff --git a/klm/util/CMakeLists.txt b/klm/util/CMakeLists.txt new file mode 100644 index 00000000..bef1db78 --- /dev/null +++ b/klm/util/CMakeLists.txt @@ -0,0 +1,53 @@ +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..) + +set(cat_compressed_SRCS cat_compressed_main.cc) + +add_executable(cat_compressed ${cat_compressed_SRCS}) +target_link_libraries(cat_compressed klm_util) + +set(klm_util_STAT_SRCS + bit_packing.cc + bit_packing.hh + ersatz_progress.cc + ersatz_progress.hh + exception.cc + exception.hh + fake_ofstream.hh + file.cc + file.hh + file_piece.cc + file_piece.hh + fixed_array.hh + getopt.c + getopt.hh + have.hh + joint_sort.hh + mmap.cc + mmap.hh + multi_intersection.hh + murmur_hash.cc + murmur_hash.hh + parallel_read.cc + parallel_read.hh + pcqueue.hh + pool.cc + pool.hh + probing_hash_table.hh + proxy_iterator.hh + read_compressed.cc + read_compressed.hh + scoped.cc + scoped.hh + sized_iterator.hh + sorted_uniform.hh + string_piece.cc + string_piece.hh + string_piece_hash.hh + thread_pool.hh + tokenize_piece.hh + unistd.hh + usage.cc + usage.hh) + +add_library(klm_util STATIC ${klm_util_STAT_SRCS}) + diff --git a/klm/util/Makefile.am b/klm/util/Makefile.am deleted file mode 100644 index 5db6e340..00000000 --- a/klm/util/Makefile.am +++ /dev/null @@ -1,66 +0,0 @@ - -noinst_PROGRAMS = cat_compressed - -cat_compressed_SOURCES = cat_compressed_main.cc -cat_compressed_LDADD = libklm_util.a - -#TESTS = \ -# file_piece_test \ -# joint_sort_test \ -# key_value_packing_test \ -# probing_hash_table_test \ -# sorted_uniform_test -# file_piece_test \ -# joint_sort_test \ -# key_value_packing_test \ -# probing_hash_table_test \ -# sorted_uniform_test - -noinst_LIBRARIES = libklm_util.a - -libklm_util_a_SOURCES = \ - bit_packing.cc \ - bit_packing.hh \ - ersatz_progress.cc \ - ersatz_progress.hh \ - exception.cc \ - exception.hh \ - fake_ofstream.hh \ - file.cc \ - file.hh \ - file_piece.cc \ - file_piece.hh \ - fixed_array.hh \ - getopt.c \ - getopt.hh \ - have.hh \ - joint_sort.hh \ - mmap.cc \ - mmap.hh \ - multi_intersection.hh \ - murmur_hash.cc \ - murmur_hash.hh \ - parallel_read.cc \ - parallel_read.hh \ - pcqueue.hh \ - pool.cc \ - pool.hh \ - probing_hash_table.hh \ - proxy_iterator.hh \ - read_compressed.cc \ - read_compressed.hh \ - scoped.cc \ - scoped.hh \ - sized_iterator.hh \ - sorted_uniform.hh \ - string_piece.cc \ - string_piece.hh \ - string_piece_hash.hh \ - thread_pool.hh \ - tokenize_piece.hh \ - unistd.hh \ - usage.cc \ - usage.hh - -AM_CPPFLAGS = -W -Wall -I$(top_srcdir)/klm -I$(top_srcdir)/klm/util/double-conversion - diff --git a/klm/util/double-conversion/CMakeLists.txt b/klm/util/double-conversion/CMakeLists.txt new file mode 100644 index 00000000..df4162dc --- /dev/null +++ b/klm/util/double-conversion/CMakeLists.txt @@ -0,0 +1,24 @@ + + +set(klm_util_double_STAT_SRCS + bignum-dtoa.h + bignum.h + cached-powers.h + diy-fp.h + double-conversion.h + fast-dtoa.h + fixed-dtoa.h + ieee.h + strtod.h + utils.h + bignum.cc + bignum-dtoa.cc + cached-powers.cc + diy-fp.cc + double-conversion.cc + fast-dtoa.cc + fixed-dtoa.cc + strtod.cc) + +add_library(klm_util_double STATIC ${klm_util_double_STAT_SRCS}) + diff --git a/klm/util/double-conversion/Makefile.am b/klm/util/double-conversion/Makefile.am deleted file mode 100644 index dfcfb009..00000000 --- a/klm/util/double-conversion/Makefile.am +++ /dev/null @@ -1,23 +0,0 @@ -noinst_LIBRARIES = libklm_util_double.a - -libklm_util_double_a_SOURCES = \ - bignum-dtoa.h \ - bignum.h \ - cached-powers.h \ - diy-fp.h \ - double-conversion.h \ - fast-dtoa.h \ - fixed-dtoa.h \ - ieee.h \ - strtod.h \ - utils.h \ - bignum.cc \ - bignum-dtoa.cc \ - cached-powers.cc \ - diy-fp.cc \ - double-conversion.cc \ - fast-dtoa.cc \ - fixed-dtoa.cc \ - strtod.cc - -AM_CPPFLAGS = -W -Wall -I$(top_srcdir)/klm -I$(top_srcdir)/klm/util/double-conversion diff --git a/klm/util/stream/CMakeLists.txt b/klm/util/stream/CMakeLists.txt new file mode 100644 index 00000000..3ca25f17 --- /dev/null +++ b/klm/util/stream/CMakeLists.txt @@ -0,0 +1,20 @@ +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../..) + +set(klm_util_stream_STAT_SRCS + block.hh + chain.cc + chain.hh + config.hh + io.cc + io.hh + line_input.cc + line_input.hh + multi_progress.cc + multi_progress.hh + multi_stream.hh + sort.hh + stream.hh + timer.hh) + +add_library(klm_util_stream STATIC ${klm_util_stream_STAT_SRCS}) + diff --git a/klm/util/stream/Makefile.am b/klm/util/stream/Makefile.am deleted file mode 100644 index 25817b50..00000000 --- a/klm/util/stream/Makefile.am +++ /dev/null @@ -1,21 +0,0 @@ -noinst_LIBRARIES = libklm_util_stream.a - -libklm_util_stream_a_SOURCES = \ - block.hh \ - chain.cc \ - chain.hh \ - config.hh \ - io.cc \ - io.hh \ - line_input.cc \ - line_input.hh \ - multi_progress.cc \ - multi_progress.hh \ - multi_stream.hh \ - sort.hh \ - stream.hh \ - timer.hh - -AM_CPPFLAGS = -W -Wall -I$(top_srcdir)/klm - -#-I$(top_srcdir)/klm/util/double-conversion -- cgit v1.2.3 From 5eb2eb6693340c14766876bce705e3adb8733796 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Thu, 5 Mar 2015 00:14:16 -0500 Subject: deal with possible RT lib dependency --- cmake/FindRT.cmake | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ decoder/CMakeLists.txt | 4 ++-- klm/lm/CMakeLists.txt | 6 ++++-- 3 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 cmake/FindRT.cmake (limited to 'klm') diff --git a/cmake/FindRT.cmake b/cmake/FindRT.cmake new file mode 100644 index 00000000..55ae1a26 --- /dev/null +++ b/cmake/FindRT.cmake @@ -0,0 +1,55 @@ +# - Check for the presence of RT +# +# The following variables are set when RT is found: +# HAVE_RT = Set to true, if all components of RT +# have been found. +# RT_INCLUDES = Include path for the header files of RT +# RT_LIBRARIES = Link these to use RT + +## ----------------------------------------------------------------------------- +## Check for the header files + +find_path (RT_INCLUDES time.h + PATHS /usr/local/include /usr/include ${CMAKE_EXTRA_INCLUDES} + ) + +## ----------------------------------------------------------------------------- +## Check for the library + +find_library (RT_LIBRARIES rt + PATHS /usr/local/lib /usr/lib /lib ${CMAKE_EXTRA_LIBRARIES} + ) + +## ----------------------------------------------------------------------------- +## Actions taken when all components have been found + +if (RT_INCLUDES AND RT_LIBRARIES) + set (HAVE_RT TRUE) +else (RT_INCLUDES AND RT_LIBRARIES) + if (NOT RT_FIND_QUIETLY) + if (NOT RT_INCLUDES) + message (STATUS "Unable to find RT header files!") + endif (NOT RT_INCLUDES) + if (NOT RT_LIBRARIES) + message (STATUS "Unable to find RT library files!") + endif (NOT RT_LIBRARIES) + endif (NOT RT_FIND_QUIETLY) +endif (RT_INCLUDES AND RT_LIBRARIES) + +if (HAVE_RT) + if (NOT RT_FIND_QUIETLY) + message (STATUS "Found components for RT") + message (STATUS "RT_INCLUDES = ${RT_INCLUDES}") + message (STATUS "RT_LIBRARIES = ${RT_LIBRARIES}") + endif (NOT RT_FIND_QUIETLY) +else (HAVE_RT) + if (RT_FIND_REQUIRED) + message (FATAL_ERROR "Could not find RT!") + endif (RT_FIND_REQUIRED) +endif (HAVE_RT) + +mark_as_advanced ( + HAVE_RT + RT_LIBRARIES + RT_INCLUDES + ) diff --git a/decoder/CMakeLists.txt b/decoder/CMakeLists.txt index f7683887..ac07e9fe 100644 --- a/decoder/CMakeLists.txt +++ b/decoder/CMakeLists.txt @@ -3,10 +3,10 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../mteval) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../klm) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..) -set(CMAKE_POSITION_INDEPENDENT_CODE ON) - PROJECT(decoder C CXX) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + find_package(FLEX REQUIRED) FLEX_TARGET(RuleLexer rule_lexer.ll ${CMAKE_CURRENT_BINARY_DIR}/rule_lexer.cc) diff --git a/klm/lm/CMakeLists.txt b/klm/lm/CMakeLists.txt index 5814b623..b95cddee 100644 --- a/klm/lm/CMakeLists.txt +++ b/klm/lm/CMakeLists.txt @@ -1,13 +1,15 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..) +find_package(RT) + set(build_binary_SRCS build_binary_main.cc) add_executable(build_binary ${build_binary_SRCS}) -target_link_libraries(build_binary klm klm_util klm_util_double z) +target_link_libraries(build_binary klm klm_util klm_util_double z ${RT_LIBRARIES}) set(ngram_query_SRCS query_main.cc) add_executable(ngram_query ${ngram_query_SRCS}) -target_link_libraries(ngram_query klm klm_util klm_util_double z) +target_link_libraries(ngram_query klm klm_util klm_util_double z ${RT_LIBRARIES}) set(klm_STAT_SRCS bhiksha.hh -- cgit v1.2.3 From b5d04f4c8a734796c347e5cb5a5053dd75696533 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Thu, 2 Apr 2015 00:19:42 -0400 Subject: fix libRT use --- klm/lm/CMakeLists.txt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'klm') diff --git a/klm/lm/CMakeLists.txt b/klm/lm/CMakeLists.txt index b95cddee..fcd288c1 100644 --- a/klm/lm/CMakeLists.txt +++ b/klm/lm/CMakeLists.txt @@ -1,15 +1,21 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..) -find_package(RT) +find_package(RT QUIET) set(build_binary_SRCS build_binary_main.cc) add_executable(build_binary ${build_binary_SRCS}) -target_link_libraries(build_binary klm klm_util klm_util_double z ${RT_LIBRARIES}) - - set(ngram_query_SRCS query_main.cc) add_executable(ngram_query ${ngram_query_SRCS}) -target_link_libraries(ngram_query klm klm_util klm_util_double z ${RT_LIBRARIES}) +if (HAVE_RT) + target_link_libraries(build_binary klm klm_util klm_util_double z ${RT_LIBRARIES}) + target_link_libraries(ngram_query klm klm_util klm_util_double z ${RT_LIBRARIES}) +else (HAVE_RT) + target_link_libraries(build_binary klm klm_util klm_util_double z) + target_link_libraries(ngram_query klm klm_util klm_util_double z) +endif (HAVE_RT) + + + set(klm_STAT_SRCS bhiksha.hh -- cgit v1.2.3