From 6cbdccb1d9a62b2723b962ba4b6e66f1631e48d3 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Tue, 3 Mar 2015 01:14:07 -0500 Subject: migration to cmake --- utils/CMakeLists.txt | 115 ++++++++++++++++++++++++++++++++++++++++ utils/Makefile.am | 127 --------------------------------------------- utils/fast_sparse_vector.h | 6 --- utils/gzstream.cc | 2 +- 4 files changed, 116 insertions(+), 134 deletions(-) create mode 100644 utils/CMakeLists.txt delete mode 100644 utils/Makefile.am (limited to 'utils') diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt new file mode 100644 index 00000000..17436263 --- /dev/null +++ b/utils/CMakeLists.txt @@ -0,0 +1,115 @@ +include_directories() + +set(TEST_SRCS dict_test.cc + logval_test.cc + m_test.cc + small_vector_test.cc + stringlib_test.cc + sv_test.cc + ts.cc + weights_test.cc) + +foreach(testSrc ${TEST_SRCS}) + #Extract the filename without an extension (NAME_WE) + get_filename_component(testName ${testSrc} NAME_WE) + + #Add compile target + set_source_files_properties(${testSrc} PROPERTIES COMPILE_FLAGS "-DBOOST_TEST_DYN_LINK -DTEST_DATA=\\\"test_data/\\\"") + add_executable(${testName} ${testSrc}) + + #link to Boost libraries AND your targets and dependencies + target_link_libraries(${testName} utils ${Boost_LIBRARIES} ${ZLIB_LIBRARIES}) + + #I like to move testing binaries into a testBin directory + set_target_properties(${testName} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + + #Finally add it to test execution - + #Notice the WORKING_DIRECTORY and COMMAND + add_test(NAME ${testName} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${testName} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) +endforeach(testSrc) + + +set(atools_SRCS atools.cc) +add_executable(atools ${atools_SRCS}) +target_link_libraries(atools utils ${Boost_LIBRARIES} ${ZLIB_LIBRARIES}) + +set(dedup_corpus_SRCS dedup_corpus.cc) +add_executable(dedup_corpus ${dedup_corpus_SRCS}) +target_link_libraries(dedup_corpus utils ${Boost_LIBRARIES} ${ZLIB_LIBRARIES}) + +set(utils_STAT_SRCS + test_data + alias_sampler.h + alignment_io.h + array2d.h + b64featvector.h + b64tools.h + batched_append.h + city.h + citycrc.h + corpus_tools.h + dict.h + exp_semiring.h + fast_sparse_vector.h + fdict.h + feature_vector.h + filelib.h + gzstream.h + hash.h + have_64_bits.h + indices_after.h + kernel_string_subseq.h + logval.h + m.h + maxent.h + maxent.cpp + murmur_hash3.h + murmur_hash3.cc + named_enum.h + null_deleter.h + null_traits.h + perfect_hash.h + prob.h + sampler.h + semiring.h + show.h + small_vector.h + sparse_vector.h + star.h + static_utoa.h + stringlib.h + string_piece.hh + tdict.h + timing_stats.h + utoa.h + value_array.h + verbose.h + warning_compiler.h + warning_pop.h + warning_push.h + weights.h + wordid.h + writer.h + fast_lexical_cast.hpp + intrusive_refcount.hpp + alignment_io.cc + b64featvector.cc + b64tools.cc + corpus_tools.cc + dict.cc + tdict.cc + fdict.cc + gzstream.cc + filelib.cc + stringlib.cc + string_piece.cc + sparse_vector.cc + timing_stats.cc + verbose.cc + weights.cc) + +add_library(utils STATIC ${utils_STAT_SRCS}) + + diff --git a/utils/Makefile.am b/utils/Makefile.am deleted file mode 100644 index c858ac7e..00000000 --- a/utils/Makefile.am +++ /dev/null @@ -1,127 +0,0 @@ -bin_PROGRAMS = reconstruct_weights atools dedup_corpus - -noinst_PROGRAMS = \ - ts \ - phmt \ - dict_test \ - m_test \ - weights_test \ - logval_test \ - small_vector_test \ - stringlib_test \ - sv_test - -TESTS = ts small_vector_test logval_test weights_test dict_test m_test sv_test stringlib_test - -noinst_LIBRARIES = libutils.a - -# EXTRA_DIST = test_data - -libutils_a_SOURCES = \ - test_data \ - alias_sampler.h \ - alignment_io.h \ - array2d.h \ - b64featvector.h \ - b64tools.h \ - batched_append.h \ - city.h \ - citycrc.h \ - corpus_tools.h \ - dict.h \ - exp_semiring.h \ - fast_sparse_vector.h \ - fdict.h \ - feature_vector.h \ - filelib.h \ - gzstream.h \ - hash.h \ - have_64_bits.h \ - indices_after.h \ - kernel_string_subseq.h \ - logval.h \ - m.h \ - maxent.h \ - maxent.cpp \ - murmur_hash3.h \ - murmur_hash3.cc \ - named_enum.h \ - null_deleter.h \ - null_traits.h \ - perfect_hash.h \ - prob.h \ - sampler.h \ - semiring.h \ - show.h \ - small_vector.h \ - sparse_vector.h \ - star.h \ - static_utoa.h \ - stringlib.h \ - string_piece.hh \ - tdict.h \ - timing_stats.h \ - utoa.h \ - value_array.h \ - verbose.h \ - warning_compiler.h \ - warning_pop.h \ - warning_push.h \ - weights.h \ - wordid.h \ - writer.h \ - fast_lexical_cast.hpp \ - intrusive_refcount.hpp \ - alignment_io.cc \ - b64featvector.cc \ - b64tools.cc \ - corpus_tools.cc \ - dict.cc \ - tdict.cc \ - fdict.cc \ - gzstream.cc \ - filelib.cc \ - stringlib.cc \ - string_piece.cc \ - sparse_vector.cc \ - timing_stats.cc \ - verbose.cc \ - weights.cc - -if HAVE_CMPH - libutils_a_SOURCES += perfect_hash.cc -endif - -reconstruct_weights_SOURCES = reconstruct_weights.cc -reconstruct_weights_LDADD = libutils.a -atools_SOURCES = atools.cc -atools_LDADD = libutils.a -atools_LDFLAGS = $(STATIC_FLAGS) - -dedup_corpus_SOURCES = dedup_corpus.cc -dedup_corpus_LDADD = libutils.a -dedup_corpus_LDFLAGS = $(STATIC_FLAGS) - -phmt_SOURCES = phmt.cc -phmt_LDADD = libutils.a $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) -ts_SOURCES = ts.cc -ts_LDADD = libutils.a $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) -m_test_SOURCES = m_test.cc -m_test_LDADD = libutils.a $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) -dict_test_SOURCES = dict_test.cc -dict_test_LDADD = libutils.a $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) -weights_test_SOURCES = weights_test.cc -weights_test_LDADD = libutils.a $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) -logval_test_SOURCES = logval_test.cc -logval_test_LDADD = libutils.a $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) -small_vector_test_SOURCES = small_vector_test.cc -small_vector_test_LDADD = libutils.a $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) -sv_test_SOURCES = sv_test.cc -sv_test_LDADD = libutils.a $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) -stringlib_test_SOURCES = stringlib_test.cc -stringlib_test_LDADD = libutils.a $(BOOST_UNIT_TEST_FRAMEWORK_LDFLAGS) $(BOOST_UNIT_TEST_FRAMEWORK_LIBS) - -################################################################ -# do NOT NOT NOT add any other -I includes NO NO NO NO NO ###### -AM_CPPFLAGS = -DBOOST_TEST_DYN_LINK -W -Wall -I. -I$(top_srcdir) -DTEST_DATA=\"$(top_srcdir)/utils/test_data\" -################################################################ diff --git a/utils/fast_sparse_vector.h b/utils/fast_sparse_vector.h index 1e0ab428..0697fc44 100644 --- a/utils/fast_sparse_vector.h +++ b/utils/fast_sparse_vector.h @@ -20,9 +20,7 @@ #endif #include -#if HAVE_BOOST_ARCHIVE_TEXT_OARCHIVE_HPP #include -#endif #include "fdict.h" @@ -471,7 +469,6 @@ class FastSparseVector { unsigned char local_size_; bool is_remote_; -#if HAVE_BOOST_ARCHIVE_TEXT_OARCHIVE_HPP private: friend class boost::serialization::access; template @@ -502,12 +499,9 @@ class FastSparseVector { } } BOOST_SERIALIZATION_SPLIT_MEMBER() -#endif }; -#if HAVE_BOOST_ARCHIVE_TEXT_OARCHIVE_HPP BOOST_CLASS_TRACKING(FastSparseVector,track_never) -#endif template const FastSparseVector operator+(const FastSparseVector& x, const FastSparseVector& y) { diff --git a/utils/gzstream.cc b/utils/gzstream.cc index 88cd1bd2..dbfa2f53 100644 --- a/utils/gzstream.cc +++ b/utils/gzstream.cc @@ -26,7 +26,7 @@ // Standard C++ Library". // ============================================================================ -#include +#include "gzstream.h" #include #include // for memcpy #include -- cgit v1.2.3